maxrossello / redmine_extended_watchers

Grant additional issue and project view permissions to watcher users
GNU General Public License v3.0
44 stars 20 forks source link

"issues created by or assigned to or watched by the user". #41

Closed ashrafalzyoud closed 2 years ago

ashrafalzyoud commented 2 years ago

thx for your plugin i want ask u question in my case in my case if my issue its assignee in group 1 then group 2 then group 3 and i want let the group 1 and group 2 as watchers and visibility to see the issue when assignee group 3

any mode selected?? default - extended-protected ??

i need this role "issues created by or assigned to or watched by the user" im using plugin custom workflow and this code

 if self.assigned_to.is_a?(Group)
   arr = Array.new
   arr = Group.find(self.assigned_to_id).user_ids
   for item in arr
     self.add_watcher(User.find(item)) unless self.watched_by?(User.find(item))
   end

to added the users in group as watcher @maxrossello

maxrossello commented 2 years ago

im using plugin custom workflow

note that I can't provide support about missing interoperability. Supported plugins are those defined in project redmine_testsuites. You do not need such custom code, because Redmine can assign roles and assign as watchers groups as well as users.

If I understand your need, and provided that there's no conflict with custom workflow (you should make a test by removing it), I think that your use case is covered if you do the following:

  1. use protected mode
  2. assign a membership role to the group(s). Any role that can show issues when "issues created by or assigned to", will be transformed in "issues created by or assigned to or watched by the user/group"

As a bonus, when you remove the role to a group, the users within do not retain the access unless they have individual membership or gain a membership through other group(s).

Let me know if this works for you.

ashrafalzyoud commented 2 years ago

im install it in redmine 5.0.2 ruby 3.1.2 but give this error 500

[a8929db9-3355-4cd8-a315-8c8a8af2a2b2] plugins/redmine_people/lib/redmine_people/patches/user_patch.rb:68:in `block in <module:InstanceMethods>'
[a8929db9-3355-4cd8-a315-8c8a8af2a2b2] plugins/redmine_extended_watchers/lib/extended_watchers_user_patch.rb:23:in `allowed_to?

this line 68 /redmine_people/patches/user_patch.rb:68

        define_method 'allowed_to?_with_people' do |action, context, options={}, &block|
          return allowed_people_to?(action) if !action.is_a?(Hash) && RedminePeople.available_permissions.include?(action)

68          public_send('allowed_to?_without_people', action, context, options, &block)
        end

in your plugin

   def allowed_to?(action, context, options={}, &block)
      is_allowed = super(action, context, options, &block)
      return is_allowed if is_allowed || Setting.plugin_redmine_extended_watchers["policy"] != "extended"

i think becuase the tow plugins define in same name allowed_to

when im change the name allowed_to to allowedd_to like that

   def allowedd_to?(action, context, options={}, &block)
      is_allowedd = super(action, context, options, &block)
      return is_allowedd if is_allowedd || Setting.plugin_redmine_extended_watchers["policy"] != "extended"

every things work without any error if what im do correct tell me? @maxrossello

maxrossello commented 2 years ago

I can't provide support for redmine_people or any other plugin conflict with this. However, it seems to me that redmine_people is not supporting Redmine 5 because it is still using alias method change instead of prepend (it is clear from the allowed_to?_with_people notation)

ashrafalzyoud commented 2 years ago

ok thx for replay but if u can help if im edited the name like this your plugin work or no?? when im change the name allowed_to to allowedd_to like that

   def allowedd_to?(action, context, options={}, &block)
      is_allowedd = super(action, context, options, &block)
      return is_allowedd if is_allowedd || Setting.plugin_redmine_extended_watchers["policy"] != "extended"
maxrossello commented 2 years ago

Renaming a method's name is like deleting the method, which extends the behavior of Redmine's one with the same name. You cannot expect the plugin to work as intended if you remove its implementation.

However you felt the need to do so only because of the clash with redmine_people, yet redmine_people can't work on Redmine 5. So just remove redmine_people from the filesystem and you'll see that this plugin is going to work properly.

ashrafalzyoud commented 2 years ago

@maxrossello the plugin redmine_peoble its working in my redmine 5.0.2 and when im editing the name allowed_to its working your plugin with all function

maxrossello commented 2 years ago

no, this plugin won't extend issue visibility properly if you remove or rename the method. Later on you would complain for not respecting the expected behavior.

Your version of redmine_people uses alias_method_chain which is deprecated and can't work together with another plugin extending the same method using the method prepend mechanism.

In any case I see the most recent redmine_people on github is Planio's and was updated 2 years ago. Yet it seems to use a different approach from what you reported. That defines a new method without override, so it might avoid a clash. Cfr https://github.com/planio-gmbh/redmine_people/blob/master/lib/redmine_people/patches/user_patch.rb

When you mix and match plugins you are on your own, I'm afraid. Good luck.