Permalink
Browse files

improved canEdit check by moving it to the class

  • Loading branch information...
1 parent bf83b0d commit 4557291c4d34b0fe276d8d60668041105fcfab65 @jdalsem jdalsem committed May 8, 2012
Showing with 12 additions and 7 deletions.
  1. +9 −0 classes/WidgetManagerWidget.php
  2. +3 −7 views/default/object/widget.php
@@ -55,4 +55,13 @@ public function getURL(){
return parent::getURL();
}
}
+
+ public function canEdit($user_guid = 0){
+ $result = parent::canEdit($user_guid);
+
+ if($result && ($this->fixed && !elgg_is_admin_logged_in())){
+ $result = false;
+ }
+ return $result;
+ }
}
@@ -11,7 +11,7 @@
return true;
}
-$widget = new WidgetManagerWidget($widget->getGUID());
+$widget = new WidgetManagerWidget($widget->getGUID()); // @todo improve by registering a specific class for widgets
$show_access = elgg_extract('show_access', $vars, true);
@@ -31,11 +31,7 @@
$edit_area = '';
$can_edit = $widget->canEdit();
-if($can_edit && $widget->fixed){
- // fixed widgets are not editable
- $can_edit = false;
-}
-if ($can_edit || elgg_is_admin_logged_in()) {
+if ($can_edit) {
$edit_area = elgg_view('object/widget/elements/settings', array(
'widget' => $widget,
'show_access' => $show_access,
@@ -62,7 +58,7 @@
$widget_instance = "elgg-widget-instance-$handler";
$widget_class = "elgg-module elgg-module-widget";
-if ($can_edit || elgg_is_admin_logged_in()) {
+if ($can_edit) {
$widget_class .= " elgg-state-draggable $widget_instance";
} else {
$widget_class .= " elgg-state-fixed $widget_instance";

0 comments on commit 4557291

Please sign in to comment.