Project

General

Profile

Defect #10949

Updated by Mischa The Evil over 12 years ago

Hi, 

 I try to create an advanced plugin like the "field_permission" plugin. 

 I've set a permission, let's say @"view_description"@ "view_description" in my _init.rb_ init.rb 

 Then in the _"_form.html.erb"_ "_form.html.erb" I've put this code in order to filter the description block: 

 <pre><code class="rhtml"> block : 
 <% @<% if not User.current.allowed_to?(:view_description, @project, :global => true).nil? %> 
 <% if @issue.safe_attribute? 'description' %> 
 <p> 
   <label><%= l(:field_description) %></label> 
   <%= link_to_function image_tag('edit.png'),  
     'Element.hide(this); Effect.toggle("issue_description_and_toolbar", "appear", {duration:0.3})' unless @issue.new_record? %> 
   <%= content_tag 'span', :id => "issue_description_and_toolbar", :style => (@issue.new_record? ? nil : 'display:none') do %> 
     <%= f.text_area :description, 
                    :cols => 60, 
                    :rows => (@issue.description.blank? ? 10 : [[10, @issue.description.length / 50].max, 100].min), 
                    :accesskey => accesskey(:edit), 
                    :class => 'wiki-edit', 
                    :no_label => true %> 
   <% end %> 
 </p> 
 <% end %> 
 </pre></code> %>@ 

 The symptoms are 
  
 * that normal accounts respond to the if statement correctly depending if they have the permission or not. This is ok 
 * admin accounts, with role that applies, do not take in consideration this filter and the @allowed_to@ allowed_to method always respond true and do not correspond to the @view_description@ view_description permission. 

 Environment: 
 * 
   Redmine version: version                            2.0.0.stable 
 * 
   Ruby version: version                               1.8.7 (x86_64-linux) 
 * 
   Rails version: version                              3.2.3 
 * Environment: 
   Environment                                production 
 * 
   Database adapter: adapter                           MySQL 

Back