Project

General

Profile

How to impersonate admin permissions for non-admins to ONLY View all issues globally through a created plugin?

Added by Gregorio Hagopian almost 8 years ago

Good Day Redminers!
I have been battling this task for weeks to find a solution, documentation or any kind of instruction on how to create a plugin that allows non-admin users to view "all issues globally" whether they belong to a project or not. No edit operation or anything is needed other than to "*View All Issues*" for this Task I'm working on. The view all issues feature automatically is built into redmine through filter, however because permissions of the non-admin user, only issues belonging to the user can only be seen or public issues. For non-admin users, I need a "*view only*" feature for all issues globally without the permission affecting whats being fetch from the mysql database. I know permissions from redmine's core .rb files automatically merge with the plugins permissions by default. Is there a way to overide this??? If it isn't a possibility to do this, which with coding there is no such thing as impossibility, then the second option would be to find some way directly connect to the mysql database through the plugin and retrieve a table from the mysql database entirely thats not dependent on user permissions and show the whole list global on a

def global_authorize
  User.current.memberships.detect {|m| m.role.position == 1}
end

require 'redmine'

Redmine::Plugin.register :department_search do
  name 'Department Search plugin'
  author 'Gregorio Hagopian'
  description 'This is a plugin for Redmine to retrieve data from the mysql database'
  version '0.0.1'
  url 'http://example.com/path/to/plugin'
  author_url 'http://example.com/about'
    project_module :issue_tracking do
       User.current.memberships.detect {|m| m.role.position == 1}||
       User.current.allowed_to?(:see_project_issues, nil, :global => true)||
       User.current.allowed_to?(:view_project_issues, nil, :global => true)
       permission :all_issues, { :all_issues => [:index, :change] }, :public => true
       menu :top_menu, :all_issues, { :controller => 'issues', :action => 'index', :project_id => @project}, :caption => "Department Search" 
    end
end page.

Can anyone please assist me?


Computer and Server Info

Im working on a local bitnami redmine dev enviroment.
OS is Ubuntu 16.04
Database mysql version is Server version: 5.6.33 - MySQL Community Server (GPL)
Protocol version: 10
Uses Apache
Database client version: libmysql - mysqlnd 5.0.11-dev - 20120503 - $Id: 76b08b24596e12d4553bd41fc93cccd5bac2fe7a $
PHP extension: mysqliDocumentation curlDocumentation mbstringDocumentation
PHP version: 5.6.26


Here is my Redmine information.

RAILS_ENV=production  bin/about
/home/ghagopian/redmine-3.3.1-0/apps/redmine/htdocs/vendor/bundle/ruby/2.3.0/gems/htmlentities-4.3.1/lib/htmlentities/mappings/expanded.rb:465: warning: key "inodot" is duplicated and overwritten on line 466

sh: 1: svn: not found
sh: 1: darcs: not found
sh: 1: hg: not found
sh: 1: cvs: not found
sh: 1: bzr: not found
Environment:
  Redmine version                3.3.1.stable
  Ruby version                   2.3.1-p112 (2016-04-26) [x86_64-linux-gnu]
  Rails version                  4.2.7.1
  Environment                    production
  Database adapter               Mysql2
SCM:
  Git                            2.7.4
  Filesystem                     
Redmine plugins:
  department_search              0.0.1

Update:

So after doing some research is seems that there a possibility I can use function like:

def authorize_global(ctrl = params[:controller], action = params[:action], global = true)
    authorize(ctrl, action, global)
  end

To at least authorize_global permission to what I want, but I'm a little lost how to apply it the view all_issues how to write it with the init.rb

So far I have wrote in the init.rb this:


def global_authorize
  User.current.memberships.detect {|m| m.role.position == 1}
end

require 'redmine'

Redmine::Plugin.register :department_search do
  name 'Department Search plugin'
  author 'Gregorio Hagopian'
  description 'This is a plugin for Redmine to retrieve data from the mysql database'
  version '0.0.1'
  url 'http://example.com/path/to/plugin'
  author_url 'http://example.com/about'
    project_module :issue_tracking do
       User.current.memberships.detect {|m| m.role.position == 1}||
       User.current.allowed_to?(:see_project_issues, nil, :global => true)||
       User.current.allowed_to?(:view_project_issues, nil, :global => true)
       permission :all_issues, { :all_issues => [:index, :change] }, :global => true
       menu :top_menu, :all_issues, { :controller => 'issues', :action => 'index', :project_id => @project}, :caption => "Department Search" 
    end
end

Any Suggestions?

Thank You.

Any Suggestions?

Thank You.