From: hickert Date: Mon, 26 May 2008 13:56:55 +0000 (+0000) Subject: Prepared class_acl.inc to use ACL checks. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=ff406832b85eb48614fb37aa4b492aae6bb41d25;p=gosa.git Prepared class_acl.inc to use ACL checks. - Only the member functions acl_is_readable,acl_is_removeable ... must be modified now. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@11007 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-core/include/class_acl.inc b/gosa-core/include/class_acl.inc index 72610a383..44a612db1 100644 --- a/gosa-core/include/class_acl.inc +++ b/gosa-core/include/class_acl.inc @@ -322,30 +322,33 @@ class acl extends plugin $this->aclContents = base64_decode($_POST['selected_role']); } } - - /* Only be interested in new acl's, if we're in the right _POST place */ - if ($aclDialog && $this->aclObject != "" && is_array($this->ocMapping[$this->aclObject])){ - foreach ($this->ocMapping[$this->aclObject] as $oc){ + if($this->acl_is_writeable("")){ + + /* Only be interested in new acl's, if we're in the right _POST place */ + if ($aclDialog && $this->aclObject != "" && is_array($this->ocMapping[$this->aclObject])){ - if(isset($this->aclContents[$oc]) && is_array($this->aclContents)){ - unset($this->aclContents[$oc]); - unset($this->aclContents[$this->aclObject.'/'.$oc]); - }else{ + foreach ($this->ocMapping[$this->aclObject] as $oc){ + + if(isset($this->aclContents[$oc]) && is_array($this->aclContents)){ + unset($this->aclContents[$oc]); + unset($this->aclContents[$this->aclObject.'/'.$oc]); + }else{ # trigger_error("Huhm?"); - } - if (isset($new_acl[$oc]) && is_array($new_acl)){ - $this->aclContents[$oc]= $new_acl[$oc]; - } - if (isset($new_acl[$this->aclObject.'/'.$oc]) && is_array($new_acl)){ - $this->aclContents[$this->aclObject.'/'.$oc]= $new_acl[$this->aclObject.'/'.$oc]; + } + if (isset($new_acl[$oc]) && is_array($new_acl)){ + $this->aclContents[$oc]= $new_acl[$oc]; + } + if (isset($new_acl[$this->aclObject.'/'.$oc]) && is_array($new_acl)){ + $this->aclContents[$this->aclObject.'/'.$oc]= $new_acl[$this->aclObject.'/'.$oc]; + } } } - } - /* Save new acl in case of base edit mode */ - if ($this->aclType == 'base' && !$firstedit){ - $this->aclContents= $new_acl; + /* Save new acl in case of base edit mode */ + if ($this->aclType == 'base' && !$firstedit){ + $this->aclContents= $new_acl; + } } /* Cancel new acl? */ @@ -414,9 +417,11 @@ class acl extends plugin } /* Save common values */ - foreach (array("aclType","aclFilter", "aclObject", "target") as $key){ - if (isset($_POST[$key])){ - $this->$key= validate($_POST[$key]); + if($this->acl_is_writeable("")){ + foreach (array("aclType","aclFilter", "aclObject", "target") as $key){ + if (isset($_POST[$key])){ + $this->$key= validate($_POST[$key]); + } } } @@ -430,12 +435,23 @@ class acl extends plugin /* Fill in entries */ foreach ($this->gosaAclEntry as $key => $entry){ + if(!$this->acl_is_readable("")) continue; + + $action =""; + $field1= array("string" => $this->aclTypes[$entry['type']], "attach" => "style='width:150px'"); $field2= array("string" => $this->assembleAclSummary($entry)); - $action= ""; - $action.= ""; + + if($this->acl_is_writeable("")){ + $action.= ""; + $action.= ""; + } + $action.= ""; - $action.= ""; + + if($this->acl_is_removeable()){ + $action.= ""; + } $field3= array("string" => $action, "attach" => "style='border-right:0px;width:50px;text-align:right;'"); $aclList->AddEntry(array($field1, $field2, $field3)); @@ -547,6 +563,12 @@ class acl extends plugin /* Show main page */ $smarty->assign("dialogState", $this->dialogState); + + /* Assign acls */ + $smarty->assign("acl_createable",$this->acl_is_createable()); + $smarty->assign("acl_writeable" ,$this->acl_is_writeable("")); + $smarty->assign("acl_readable" ,$this->acl_is_readable("")); + $smarty->assign("acl_removeable",$this->acl_is_removeable()); return ($smarty->fetch (get_template_path('acl.tpl'))); } @@ -618,33 +640,35 @@ class acl extends plugin /* Add select all/none buttons */ $style = "style='width:100px;'"; - $display .= ""; - $display .= ""; - $display .= " - "; - $display .= ""; - $display .= " - "; - - $display .= ""; - $display .= ""; - - $display .= "
"; - - $style = "style='width:50px;'"; - $display .= ""; - $display .= ""; - $display .= ""; - $display .= ""; - $display .= ""; - $display .= " - "; - $display .= ""; - $display .= ""; - $display .= ""; - $display .= " - "; - - $display .= ""; - $display .= ""; - $display .= ""; - $display .= ""; + if($this->acl_is_writeable("")){ + $display .= ""; + $display .= ""; + $display .= " - "; + $display .= ""; + $display .= " - "; + + $display .= ""; + $display .= ""; + + $display .= "
"; + + $style = "style='width:50px;'"; + $display .= ""; + $display .= ""; + $display .= ""; + $display .= ""; + $display .= ""; + $display .= " - "; + $display .= ""; + $display .= ""; + $display .= ""; + $display .= " - "; + + $display .= ""; + $display .= ""; + $display .= ""; + $display .= ""; + } /* Build general objects */ $list =$this->sort_by_priority($list); @@ -792,8 +816,12 @@ class acl extends plugin function mkchkbx($name, $text, $state= FALSE) { $state= $state?"checked":""; - return "\n ". - "\n "; + if($this->acl_is_writeable("")){ + return "\n ". + "\n "; + }else{ + return "\n $text"; + } } @@ -801,10 +829,16 @@ class acl extends plugin { $rstate= preg_match('/r/', $state)?'checked':''; $wstate= preg_match('/w/', $state)?'checked':''; - return ("\n ". - "\n ". - "\n ". - "\n "); + + if($this->acl_is_writeable("")){ + return ("\n ". + "\n ". + "\n ". + "\n "); + }else{ + return ("\n "._("read"). + "\n "._("write")); + } } @@ -1215,6 +1249,38 @@ class acl extends plugin $acl -> save(); } } + + + function acl_is_writeable($attribute,$skip_write = FALSE) + { + return(TRUE); + $ui= get_userinfo(); + return preg_match('/w/', $ui->get_permissions($this->acl_base, $this->acl_category.get_class($this), $attribute, $skip_write)); + } + + + function acl_is_readable($attribute) + { + return(TRUE); + $ui= get_userinfo(); + return preg_match('/r/', $ui->get_permissions($this->acl_base, $this->acl_category.get_class($this), $attribute)); + } + + + function acl_is_createable() + { + return(TRUE); + $ui= get_userinfo(); + return preg_match('/c/', $ui->get_permissions($this->acl_base, $this->acl_category.get_class($this), '0')); + } + + + function acl_is_removeable() + { + return(TRUE); + $ui= get_userinfo(); + return preg_match('/d/', $ui->get_permissions($this->acl_base, $this->acl_category.get_class($this), '0')); + } } // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: