Commit 6a441d3fb602a0ba5f6bdb7bc4c5116591ae2156
1 parent
aa5bcb3a
Exists in
master
and in
29 other branches
ActionItem111: change some links
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@718 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
3 changed files
with
45 additions
and
9 deletions
Show diff stats
app/controllers/profile_admin/cms_controller.rb
app/controllers/profile_admin/profile_editor_controller.rb
app/helpers/application_helper.rb
| ... | ... | @@ -146,23 +146,58 @@ module ApplicationHelper |
| 146 | 146 | content_tag('span', (link_to _('Logout'), { :controller => 'account', :action => 'logout'}, :method => 'post'), :id => 'logout_box') |
| 147 | 147 | end |
| 148 | 148 | |
| 149 | - def account_links | |
| 150 | - | |
| 151 | - | |
| 149 | + def link_if_permitted(link, permission = nil, target = nil) | |
| 150 | + if permission.nil? || current_user.person.has_permission?(permission, target) | |
| 151 | + link | |
| 152 | + else | |
| 153 | + nil | |
| 154 | + end | |
| 152 | 155 | end |
| 153 | 156 | |
| 154 | 157 | def admin_links |
| 158 | + environment = current_user.person.environment | |
| 159 | + links = [ | |
| 160 | + [(link_to _('Features'), :controller => 'features'), 'edit_environment_features', environment], | |
| 161 | + [(link_to _('Edit visual'), :controller => 'edit_template'), 'edit_environment_design', environment], | |
| 162 | + [(link_to _('Manage categories'), :controller => 'categories'), 'manage_environment_categories', environment], | |
| 163 | + [(link_to _('Manage permissions'), :controller => 'role'), 'manage_environment_roles', environment], | |
| 164 | + [(link_to _('Manage validators'), :controller => 'region_validators'), 'manage_environment_validators', environment], | |
| 165 | + ] | |
| 166 | + end | |
| 167 | + | |
| 168 | + def membership_links | |
| 169 | + links = [ | |
| 170 | + [(link_to _('New enterprise'), :controller => 'membership_editor', :action => 'new_enterprise'),'create_enterprise_for_profile', profile], | |
| 171 | + ] | |
| 155 | 172 | end |
| 156 | 173 | |
| 174 | + def profile_links | |
| 175 | + links = [ | |
| 176 | + [(link_to_myprofile _('Edit visual design'), :controller => 'profile_editor', :action => 'design_editor'), 'edit_profile_design', profile], | |
| 177 | + [(link_to_myprofile _('Edit informations'), :controller => 'profile_editor'), 'edit_profile', profile], | |
| 178 | + [(link_to_myprofile _('Manage content'), :controller => 'cms'), 'post_content', profile], | |
| 179 | + ] | |
| 180 | + | |
| 181 | + if profile.kind_of?(Enterprise) | |
| 182 | + links << [(link_to_myprofile _('Exclude'), :controller => 'enterprise_editor', :action => 'destroy'), 'edit_profile', profile] | |
| 183 | + else | |
| 184 | + links | |
| 185 | + end | |
| 186 | + end | |
| 187 | + | |
| 188 | + | |
| 189 | + #FIXME: find a way of accessing environment from here | |
| 157 | 190 | def user_options |
| 158 | 191 | case params[:controller] |
| 159 | - when 'account' | |
| 160 | - account_links | |
| 161 | - when 'admin' | |
| 192 | + when 'admin_panel' | |
| 162 | 193 | admin_links |
| 194 | + when 'membership_editor' | |
| 195 | + membership_links | |
| 196 | + when 'profile_editor' | |
| 197 | + profile_links | |
| 163 | 198 | else |
| 164 | - nil | |
| 165 | - end | |
| 199 | + [] | |
| 200 | + end.map{|l| link_if_permitted(l[0], l[1], l[3]) } | |
| 166 | 201 | end |
| 167 | 202 | |
| 168 | 203 | def footer | ... | ... |