Code

Added acls to gofonMacro, macro parameter is still missing
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 25 Oct 2006 07:23:27 +0000 (07:23 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 25 Oct 2006 07:23:27 +0000 (07:23 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@4936 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/gofon/macro/class_gofonMacro.inc
plugins/gofon/macro/class_gofonMacroManagement.inc
plugins/gofon/macro/class_gofonMacroParameters.inc
plugins/gofon/macro/generic.tpl
plugins/gofon/macro/tabs_macros.inc

index 60d0f52847769772f54c617b9f21ce5d131e7dea..cbed42605bfe58080330c70fc902ae8796e05a4b 100755 (executable)
@@ -48,6 +48,8 @@ class macro extends plugin
   /*! Objectclasses that this calls handles */
   var $objectclasses  = array("top", "goFonMacro");
 
+  var $ui ;
+
   //! The Konstructor   
   /*!  Konstructor, load class with  attributes of the given dn*/
   function macro ($config, $dn= NULL, $parent= NULL)
@@ -55,13 +57,11 @@ class macro extends plugin
     plugin::plugin ($config, $dn, $parent);
 
     $ldap= $config->get_ldap_link();
-
     $this->dn = $dn;
 
     /* This is always an account */
     $this->is_account= TRUE;
 
-
     /* Edit or new one ?*/
     if ($this->dn == "new"){
       if(isset($_SESSION['CurrentMainBase'])){
@@ -77,16 +77,14 @@ class macro extends plugin
       $this->orig_cn=$this->cn;
       $this->base= preg_replace("/ou=macros,ou=asterisk,ou=configs,ou=systems,/","",dn2base($this->dn));
     }
-    $ui= get_userinfo();
-    $acl= get_permissions ($ui->dn, $ui->subtreeACL);
-    $this->acl= get_module_permission($acl, "goFonMacro", $ui->dn);
+    $this->ui = get_userinfo();
   }
 
   /*!  Execute this plugin */
   function execute()
   {
-       /* Call parent execute */
-       plugin::execute();
+    /* Call parent execute */
+    plugin::execute();
 
     /* Variables */
     $vars      = "";
@@ -129,16 +127,31 @@ class macro extends plugin
       }
     }
 
-
-
     /* Fill templating stuff */
     $smarty= get_smarty();
-    $smarty->assign("bases", $this->config->idepartments);
+    $smarty->assign("bases", $this->get_allowed_bases());
+  
+    /* Assign base ACL */
+    $baseACL = $this->getacl("base");
+    if(!$this->acl_is_moveable()) {
+      $baseACL = preg_replace("/w/","",$baseACL);
+    }
+    $smarty->assign("baseACL",          $baseACL);
+
+    $tmp = $this->plInfo();
+    foreach($tmp['plProvidedAcls'] as $name => $translation){
+      $smarty->assign($name."ACL",$this->getacl($name));
+    }
+
+    if($this->acl_is_writeable("base")){
+      $smarty->assign("baseSelect",true);
+    }else{
+      $smarty->assign("baseSelect",false);
+    }
 
     /* Assign all vars to Smarty */
     foreach($this->attributes as $ar){
       $smarty->assign($ar, $this->$ar);
-      $smarty->assign($ar."ACL", chkacl($this->acl,$ar));
     }
     /* Checkboxes */
     $smarty->assign("base_select", $this->base);
@@ -150,23 +163,8 @@ class macro extends plugin
       $smarty->assign("goFonMacroVisibleChecked","");
     }
 
-    if(isset($_POST['goFonMacroVisible'])) {
-      $this->goFonMacroVisible= 1 ;
-      $smarty->assign("goFonMacroVisibleChecked"," checked ");
-    }else  {
-      if(isset($_POST['displayName'])){
-        $this->goFonMacroVisible= 0 ;
-        $smarty->assign("goFonMacroVisibleChecked","");
-      }
-    }
-    
-    if(!$this->is_new){
-      $smarty->assign("disable_cn"," disabled ");
-      $smarty->assign("cn",$this->orig_cn);
-    }else{
-      $smarty->assign("disable_cn","  ");
-      $smarty->assign("cn",$this->cn);
-    }
+    $smarty->assign("cnACL",$this->getacl("cn",!$this->is_new));
+    $smarty->assign("cn",$this->cn);
     $this->generate_mysql_entension_entries();
     /* Show main page */
     return($smarty->fetch (get_template_path('generic.tpl', TRUE)));
@@ -360,11 +358,29 @@ class macro extends plugin
   function save_object()
   {
     if (isset($_POST['displayName'])){
+      $old_cn= $this->cn;
+      $old_visible = $this->goFonMacroVisible;
+
       plugin::save_object();
-    }
-    foreach($this->attributes as $attr){
-      if(isset($_POST[$attr])){
-        $this->$attr= $_POST [$attr];
+
+      /* Restore old cn if we have insuficient acls to change cn ... */
+      if(!$this->acl_is_writeable("cn",!$this->is_new)){
+        $this->cn = $old_cn;
+      }
+
+      /* check if we are allowed to toggle visibility */
+      if($this->acl_is_writeable("goFonMacroVisible")) {
+    
+        /* Checkbox selected ? */
+        if(isset($_POST['goFonMacroVisible'])) {
+          $this->goFonMacroVisible= 1 ;
+        }else  {
+          if(isset($_POST['displayName'])){
+            $this->goFonMacroVisible= 0 ;
+          }
+        }
+      }else{
+        $this->goFonMacroVisible = $old_visible;
       }
     }
   }
@@ -398,13 +414,6 @@ class macro extends plugin
       $message[]=_("The given cn is too long, to create a Makro entry, maximum 20 chars.");
     }
  
-    foreach($this->attributes as $attr){
-      if(chkacl($this->acl,"edit")){
-        $str =  sprintf( _("Insufficient permissions, can't change attribute '%s' in goFonMacro"),$attr) ;
-        return(array($str));
-        }
-      }
-    
     if(count(split("\n",$this->goFonMacroContent))>100){
       $message[] = _("Makro length must be lower than 100 lines");
     }
@@ -471,6 +480,7 @@ class macro extends plugin
         "plCategory"    => array("gofon"),
 
         "plProvidedAcls" => array(
+          "cn"                            => _("Macro name"),
           "base"                          => _("Base"), 
           "description"                   => _("Description"), 
           "displayName"                   => _("Display name"),
index 847d404caa11cc14bc56ee10c3e1bb6110cc69cb..5fea98f343f6e63c2494c17ed81088f13e724727 100755 (executable)
@@ -96,7 +96,7 @@ class gofonMacro extends plugin
       $this->dn= "new";
 
       /* Create new usertab object */
-      $this->macrotabs= new macrotabs($this->config,$this->config->data['TABS']['MACROTABS'], $this->dn);
+      $this->macrotabs= new macrotabs($this->config,$this->config->data['TABS']['MACROTABS'], $this->dn,"gofon");
     }
 
 
@@ -161,8 +161,7 @@ class gofonMacro extends plugin
     if (($s_action=="edit") && (!isset($this->macrotabs->config))){
 
       $dn  = $this->macros[$s_entry]['dn'];
-      $acl = $this->ui->get_permissions($dn,"gofon/marco");
-
+      $acl = $this->ui->get_permissions($dn,"gofon/macro");
       if(preg_match("/r/",$acl)){
         $this->dn = $dn;
 
@@ -177,13 +176,13 @@ class gofonMacro extends plugin
         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);
+            $this->config->data['TABS']['MACROTABS'], $this->dn,"gofon");
         $_SESSION['objectinfo']= $this->dn;
       }
     }
 
     /*****************
-      Remove marco
+      Remove macro
      *****************/
     
     /* Remove user was requested */
@@ -191,7 +190,7 @@ class gofonMacro extends plugin
 
       /* Get 'dn' from posted 'uid' */
       $dn  = $this->macros[$s_entry]['dn'];
-      $acl = $this->ui->get_permissions($dn,"gofon/marco");
+      $acl = $this->ui->get_permissions($dn,"gofon/macro");
 
       if(preg_match("/d/",$acl)){
 
@@ -224,14 +223,12 @@ class gofonMacro extends plugin
     /* Confirmation for deletion has been passed. Macro should be deleted. */
     if (isset($_POST['delete_macro_confirm'])){
 
-      $acl = $this->ui->get_permissions($this->dn,"gofon/marco");
+      $acl = $this->ui->get_permissions($this->dn,"gofon/macro");
 
       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);
-        $this->macrotabs->set_acl(array($this->acl));
-
+        $this->macrotabs= new macrotabs($this->config,$this->config->data['TABS']['MACROTABS'], $this->dn,"gofon");
         $this->macrotabs->delete ();
         gosa_log ("macro object'".$this->dn."' has been removed");
         unset ($this->macrotabs);
index cafc1da0133b10c0d9d6ee0b904cd589c49f1f96..4815c6e224a31a7843a4749ff84b58b28859e9cd 100755 (executable)
@@ -35,6 +35,7 @@ class macroParameter extends plugin
   
   /*! Objectclasses needed by the class*/  
   var $objectclasses= array("top", "goFonMacro");
+  var $ui;
 
   //! The konstructor of macroParameter    
   /*! The konstructor of macroParameter...
@@ -102,9 +103,7 @@ class macroParameter extends plugin
 
     $this->para_count = count ($tmp2);
    
-    $ui= get_userinfo();
-    $acl= get_permissions ($ui->dn, $ui->subtreeACL);
-    $this->acl= get_module_permission($acl, "goFonMacro", $ui->dn);
+    $this->ui= get_userinfo();
   }
 
   //! Perform Parameter check 
@@ -323,14 +322,6 @@ class macroParameter extends plugin
     /* Call common method to give check the hook */
     $message= plugin::check();
 
-    foreach($this->attributes as $attr){
-      if(chkacl($this->acl,"edit")){
-        $str =  sprintf( _("Insufficient permissions, can't change attribute '%s' in goFonMacro."),$attr) ;
-        return(array($str));
-      }
-    }
-
-
     foreach($this->goFonMacroParameter as $key=>$val){
       if((strstr($val['default'],"!"))||(strstr($val['default'],"#"))) {
         $message[] = sprintf(_("The parameter %s contains invalid char. '!,#' is used as delimiter"),$val['name']);
index 07ab79fe0d2083560a90d27d680fa6485b5793d8..9c5d37c30f014211d3136a783a5930533104029f 100755 (executable)
@@ -4,12 +4,19 @@
                        <table summary="">
                        <tr>
                                <td><LABEL for="cn">{t}Macro name{/t}</LABEL>{$must}</td>
-                               <td><input {$disable_cn} name="cn" id="id" size=13 maxlength=13 value="{$cn}" {$cnACL} title="{t}Macro name{/t}"></td>
+                               <td>
+{render acl=$cnACL}
+                                       <input name="cn" id="id" size=13 maxlength=13 value="{$cn}" title="{t}Macro name{/t}">
+{/render}
+                               </td>
                        </tr>
                        <tr>
                                <td><LABEL for="displayName">{t}Display name{/t}</LABEL>{$must}</td>
                                <td>
-                                       <input {$displayNameACL} name="displayName" id="displayName" size=35 maxlength=60 value="{$displayName}" title="{t}Macro name to be displayed{/t}">
+{render acl=$displayNameACL}
+                                       <input name="displayName" id="displayName" size=35 maxlength=60 value="{$displayName}" 
+                                               title="{t}Macro name to be displayed{/t}">
+{/render}
                                </td>
                        </tr>
                        <tr>
                        <tr>
                                <td><LABEL for="base">{t}Base{/t}</LABEL>{$must}</td>
                                <td>
-                                          <select size="1" id="base" name="base" title="{t}Choose subtree to place macro in{/t}" {$baseACL}>
-                                                       {html_options options=$bases selected=$base_select}
-                                                       <option disabled>&nbsp;</option>
-                                          </select>
-                                               {if $baseACL == ""}
-                                                       <input type="image" name="chooseBase" src="images/folder.png" class="center" title="{t}Select a base{/t}">
-                                               {else}
-                                                       <img src="images/folder_gray.png" class="center" title="{t}Select a base{/t}">
-                                               {/if}
+                                       {render acl=$baseACL}
+                                             <select id="base" size="1" name="base" title="{t}Choose subtree to place group in{/t}">
+                                              {html_options options=$bases selected=$base_select}
+                                             </select>
+                                       {/render}
+
+                                       {render acl=$baseACL disable_picture='images/folder_gray.png'}
+                                               <input type="image" name="chooseBase" src="images/folder.png" class="center" title="{t}Select a base{/t}">
+                                       {/render}
+
                                </td>
                        </tr>
                        </table>
                        <tr>
                                <td><LABEL for="description">{t}Description{/t}</LABEL></td>
                                <td>
-                                       <input name="description" id="description" size=35 maxlength=80 value="{$description}"  {$descriptionACL}>
+{render acl=$descriptionACL}
+                                       <input name="description" id="description" size=35 maxlength=80 value="{$description}">
+{/render}
                                </td>
                        </tr>
                        <tr>
                                <td colspan=2>
-                                       <input type="checkbox" name="goFonMacroVisible" size=35 maxlength=60 value="1" {$goFonMacroVisibleACL} {$goFonMacroVisibleChecked}> {t}Visible for user{/t}
+{render acl=$goFonMacroVisibleACL}
+                                       <input type="checkbox" name="goFonMacroVisible" size=35 maxlength=60 value="1" 
+                                               {$goFonMacroVisibleChecked}> {t}Visible for user{/t}
+{/render}
                                </td>
                        </tr>
                        </table>
@@ -56,7 +69,9 @@
 <br>
 {t}Macro text{/t}
 <br>
-<textarea name="goFonMacroContent" style="width:99%;height:300px;font-size:14px;font-family:Arial;" {$goFonMacroContentACL}>{$goFonMacroContent}</textarea>
+{render acl=$goFonMacroContentACL}
+<textarea name="goFonMacroContent" style="width:99%;height:300px;font-size:14px;font-family:Arial;">{$goFonMacroContent}</textarea>
+{/render}
 
 <!-- Place cursor -->
 <script language="JavaScript" type="text/javascript">
index 58f9dc0e2ed0d9a525c908da37a59f315532649b..7df52ef7ea8668c0beec7fdcddb097e1384a23e4 100755 (executable)
@@ -3,9 +3,9 @@
 class macrotabs extends tabs
 {
 
-  function macrotabs($config, $data, $dn)
+  function macrotabs($config, $data, $dn,$category)
   {
-         tabs::tabs($config, $data, $dn);
+         tabs::tabs($config, $data, $dn,$category);
 
          /* Add references/acls/snapshots */
          $this->addSpecialTabs();