Code

Added some acls to gofon macro management
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 25 Oct 2006 06:22:56 +0000 (06:22 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 25 Oct 2006 06:22:56 +0000 (06:22 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@4933 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/gofon/macro/class_divListMacros.inc
plugins/gofon/macro/class_gofonMacroManagement.inc

index 5ffdd144783d511f245e1c375b483e0343d0edcc..68dce0468493810ac032ebac74f0ba2a529290c3 100755 (executable)
@@ -66,14 +66,32 @@ class divListMacro extends MultiSelectWindow
        which are shown in the listbox on top of the listbox
      */
     $options= "";
-    foreach ($this->config->idepartments as $key => $value){
-      if ($this->selectedBase == $key){
-        $options.= "<option selected='selected' value='$key'>$value</option>";
-      } else {
-        $options.= "<option value='$key'>$value</option>";
+
+    /* Get all departments within this subtree */
+    $base = $this->config->current['BASE'];
+    $deps= get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base,
+                    array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH);
+
+    /* Load possible departments */
+    $ui= get_userinfo();
+    $tdeps= $ui->get_module_departments("groups");
+
+    $ids = $this->config->idepartments;
+
+    foreach($deps as $dep){
+      if(isset($ids[$dep['dn']]) && in_array_ics($dep['dn'], $tdeps)){
+
+        $value = $ids[$dep['dn']];
+        if ($this->selectedBase == $dep['dn']){
+          $options.= "<option selected='selected' value='".$dep['dn']."'>$value</option>";
+        } else {
+          $options.= "<option value='".$dep['dn']."'>$value</option>";
+        }
       }
     }
 
+    $acls  = $ui->get_permissions($this->selectedBase,"gofon/macro");
+
     /* NEW LIST MANAGMENT */
     $listhead = "<div style='background:#F0F0F9;padding:5px;'>".
       " <input class='center' type='image' src='images/list_root.png' align='middle' 
@@ -85,11 +103,15 @@ class divListMacro extends MultiSelectWindow
       " <input class='center' type='image' src='images/list_reload.png' align='middle' 
         title='"._("Reload list")."' name='submit_department' alt='"._("Submit")."'>&nbsp;".
         " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;";
-    $listhead .= $this->get_snapshot_header($this->selectedBase);
-    $listhead .=  " <input class='center' type='image' align='middle' src='images/list_new_macro.png' 
-      title='"._("Create new phone macro")."' alt='"._("New")."' name='user_new'>&nbsp;".
-      " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;".
-      _("Base")."&nbsp;<select name='CurrentMainBase' onChange='mainform.submit()' class='center'>$options</select>".
+    if(preg_match("/w/",$acls) && preg_match("/c/",$acls)){
+      $listhead .= $this->get_snapshot_header($this->selectedBase);
+    }
+    if(preg_match("/c/",$acls)){
+      $listhead .=  " <input class='center' type='image' align='middle' src='images/list_new_macro.png' 
+        title='"._("Create new phone macro")."' alt='"._("New")."' name='user_new'>&nbsp;";
+      $listhead .= " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;";
+    }
+    $listhead .= _("Base")."&nbsp;<select name='CurrentMainBase' onChange='mainform.submit()' class='center'>$options</select>".
       " <input class='center' type='image' src='images/list_submit.png' align='middle' 
       title='"._("Submit department")."' name='submit_department' alt='"._("Submit")."'>&nbsp;".
       "</div>";
@@ -123,16 +145,30 @@ class divListMacro extends MultiSelectWindow
       $action_col_size += 20;
     }
 
+    $ui = get_userinfo();
+
     foreach($list as $key => $val){
-   
-      $action= "<input class='center' type='image' src='images/edit.png' alt='"._("edit")."'     
+       
+      $sacl  = $ui->get_permissions($val['dn'],"gofon/macro");
+
+      $action = "";
+      if(!preg_match("/r/",$sacl)){
+        continue;
+      }
+
+      $action.= "<input class='center' type='image' src='images/edit.png' alt='"._("edit")."'     
         name='user_edit_%KEY%' title='"._("Edit macro")."'>";
-      $action.= $this->GetSnapShotActions($val['dn']); 
-      $action.= "<input class='center' type='image' src='images/edittrash.png' alt='"._("delete")."'   
-        name='user_del_%KEY%' title='"._("Delete macro")."'>";
 
-      $display= $val["displayName"][0];
+      if(preg_match("/c/",$sacl) && preg_match("/w/",$sacl)){
+        $action.= $this->GetSnapShotActions($val['dn']); 
+      }
+
+      if(preg_match("/d/",$sacl)){
+        $action.= "<input class='center' type='image' src='images/edittrash.png' alt='"._("delete")."'   
+          name='user_del_%KEY%' title='"._("Delete macro")."'>";
+      }
 
+      $display= $val["displayName"][0];
       if(isset($val['goFonMacroVisible']['0'])&&($val['goFonMacroVisible']['0'] == "1")){
         $pic1 = $visible;
       }else{
index 1f3bd1e3e267ffc0c4a2968a91eef3995cc0e40d..847d404caa11cc14bc56ee10c3e1bb6110cc69cb 100755 (executable)
@@ -29,7 +29,6 @@ class gofonMacro extends plugin
   var $macrotabs                   = NULL;
   var $macros                  = array();
   var $ui                                      = NULL;
-  var $acl                                   = "";
   var $DivListMacro     = NULL;
 
   function gofonMacro($config, $ui)
@@ -38,9 +37,6 @@ class gofonMacro extends plugin
     $this->config= $config;
     $this->ui= $ui;
 
-    $acl= get_permissions ($ui->dn, $ui->subtreeACL);
-    $this->acl= get_module_permission($acl, "goFonMacro", $ui->dn);
-
     $this->DivListMacro = new divListMacro($this->config,$this);
   }
 
@@ -164,41 +160,43 @@ class gofonMacro extends plugin
     /* User wants to edit data */
     if (($s_action=="edit") && (!isset($this->macrotabs->config))){
 
-      /* Get 'dn' from posted 'macrolists', must be unique */
-      $this->dn= $this->macros[$s_entry]['dn']; 
+      $dn  = $this->macros[$s_entry]['dn'];
+      $acl = $this->ui->get_permissions($dn,"gofon/marco");
 
-      /* Check locking, save current plugin in 'back_plugin', so
-         the dialog knows where to return. */
-      if (($user= get_lock($this->dn)) != ""){
-        return(gen_locked_message ($user, $this->dn));
-      }
+      if(preg_match("/r/",$acl)){
+        $this->dn = $dn;
 
-      /* Lock the current entry, so everyone will get the
-         above dialog */
-      add_lock ($this->dn, $this->ui->dn);
-      /* Register macrotabs to trigger edit dialog */
-      $this->macrotabs= new macrotabs($this->config,
-          $this->config->data['TABS']['MACROTABS'], $this->dn);
-      $_SESSION['objectinfo']= $this->dn;
-    }
+        /* Check locking, save current plugin in 'back_plugin', so
+           the dialog knows where to return. */
+        if (($user= get_lock($this->dn)) != ""){
+          return(gen_locked_message ($user, $this->dn));
+        }
 
+        /* Lock the current entry, so everyone will get the
+           above dialog */
+        add_lock ($this->dn, $this->ui->dn);
+        /* Register macrotabs to trigger edit dialog */
+        $this->macrotabs= new macrotabs($this->config,
+            $this->config->data['TABS']['MACROTABS'], $this->dn);
+        $_SESSION['objectinfo']= $this->dn;
+      }
+    }
 
     /*****************
       Remove marco
      *****************/
-
+    
     /* Remove user was requested */
     if ($s_action=="del"){
 
       /* Get 'dn' from posted 'uid' */
-      $this->dn= $this->macros[$s_entry]['dn'];
+      $dn  = $this->macros[$s_entry]['dn'];
+      $acl = $this->ui->get_permissions($dn,"gofon/marco");
 
-      /* Load permissions for selected 'dn' and check if
-         we're allowed to remove this 'dn' */
-      $acl= get_permissions ($this->dn, $this->ui->subtreeACL);
-      $this->acl= get_module_permission($acl, "goFonMacro", $this->dn);
-      if (chkacl($this->acl, "delete") == ""){
+      if(preg_match("/d/",$acl)){
 
+        $this->dn = $dn;
+  
         /* Check locking, save current plugin in 'back_plugin', so
            the dialog knows where to return. */
         if (($user= get_lock($this->dn)) != ""){
@@ -226,9 +224,9 @@ class gofonMacro extends plugin
     /* Confirmation for deletion has been passed. Macro should be deleted. */
     if (isset($_POST['delete_macro_confirm'])){
 
-      /* Some nice guy may send this as POST, so we've to check
-         for the permissions again. */
-      if (chkacl($this->acl, "delete") == ""){
+      $acl = $this->ui->get_permissions($this->dn,"gofon/marco");
+
+      if(preg_match("/r/",$acl)){
 
         /* Delete request is permitted, perform LDAP action */
         $this->macrotabs= new macrotabs($this->config,$this->config->data['TABS']['MACROTABS'], $this->dn);