Code

Updated serverService : Set acl base/category for services
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 20 Sep 2006 05:13:02 +0000 (05:13 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 20 Sep 2006 05:13:02 +0000 (05:13 +0000)
Added acls for repository service

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@4735 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/systems/class_servRepository.inc
plugins/admin/systems/class_servRepositorySetup.inc
plugins/admin/systems/class_serverService.inc
plugins/admin/systems/servRepository.tpl
plugins/admin/systems/servRepositorySetup.tpl

index b49778d17393c24028ecd8c98d45729196157267..e3dc800cdd6368d0620b0e9b59827733fa139e89 100644 (file)
@@ -1,6 +1,8 @@
 <?php
 
-class servrepository extends plugin
+require_once("class_goService.inc");
+
+class servrepository extends goService
 {
   /* CLI vars */
   var $cli_summary          = "Manage server basic objects";
@@ -21,8 +23,6 @@ class servrepository extends plugin
   /* Repositories */
   var $repositories          = array();
   var $FAIrepository         = array();
-
-
   var $conflicts             = array("FAIrepositoryServer");
   var $DisplayName           = "";
   var $StatusFlag            = "";
@@ -83,6 +83,7 @@ class servrepository extends plugin
 
     /* Fill templating stuff */
     $smarty= get_smarty();
+    $smarty->assign("is_createable",$this->acl_is_createable());
     $display= "";
 
     /* Smarty vars*/
@@ -103,13 +104,13 @@ class servrepository extends plugin
     if(isset($_POST['servRepository'])){
       foreach($_POST as $name => $value){
 
-        if(preg_match("/AddRepository/",$name)){
+        if(preg_match("/AddRepository/",$name) && $this->acl_is_createable()){
           $once = true;
           $this->dialog = new servRepositorySetup($this->config,$this->dn);
-          $this->dialog->acl = $this->acl;
+          $this->dialog->parent = $this;
         }
 
-        if((preg_match("/^delete_/",$name))&&(!$once)){
+        if((preg_match("/^delete_/",$name)) && (!$once) && $this->acl_is_removeable()){
           $once = true;
           $value = preg_replace("/delete_/","",$name);
           $value = base64_decode(preg_replace("/_.*$/","",$value));
@@ -178,7 +179,7 @@ class servrepository extends plugin
               /* to be able to detect if this was renamed */
               $obj['initialy_was'] = $obj['Release'];
               $this->dialog = new servRepositorySetup($this->config,$this->dn,$obj);
-              $this->dialog->acl = $this->acl;
+              $this->dialog->parent = $this;
             }
           }
         }
@@ -188,16 +189,9 @@ class servrepository extends plugin
       $obj = $this->repositories[base64_decode($_GET['id'])];
       $obj['initialy_was'] = $obj['Release'];
       $this->dialog = new servRepositorySetup($this->config,$this->dn,$obj);
-      $this->dialog->acl = $this->acl;
+      $this->dialog->parent = $this;
     }
 
-    /*
-    if(isset($_POST['AddRepository'])){
-      $this->dialog = new servRepositorySetup($this->config,$this->dn);
-      $this->dialog->acl = $this->acl;
-    }
-    */
-
     if(isset($_POST['repository_setup_save'])){
       $this->dialog->save_object();
       if(($this->dialog->is_new_name())&&(isset($this->repositories[$this->dialog->GetName()]))){
@@ -248,23 +242,25 @@ class servrepository extends plugin
 
     $link   = "<a href='?plug=".$_GET['plug']."&amp;act=open&amp;id=%s'>%s</a>";
     $edit   = "<input type='image' value='%s' name='edit_%s'   src='images/edit.png'>&nbsp;";
-    $delete = "<input type='image' value='%s' name='delete_%s' src='images/edittrash.png'>";
+   
+    /* Hide delete icon, if delete is not allowed */ 
+    if($this->acl_is_removeable()){
+      $delete = "<input type='image' value='%s' name='delete_%s' src='images/edittrash.png'>";
+    }else{
+      $delete = "<img src='images/empty.png' alt='&nbsp;'>";
+    }
   
     foreach($this->repositories as $name => $reps){
 
       $str = " ";
-
       if(preg_match("/".str_replace("*",".*",$this->regex)."/",$reps['Release'])){
-    
-
       foreach($reps['Sections'] as $sec){
         $str.=$sec." ";  
       }    
-  
       $divlist->AddEntry(array(
-                              array("string"=>sprintf($link,base64_encode($name),$name),"attach"=>"style='width:80px;'"),
-                              array("string"=>sprintf($link,base64_encode($name),_("Sections")." :".$str)),
-                              array("string"=>preg_replace("/%s/",base64_encode($name),$edit.$delete),"attach"=>"style='border-right:0px;width:55px;text-align:right;'")
+          array("string"=>sprintf($link,base64_encode($name),$name),"attach"=>"style='width:80px;'"),
+          array("string"=>sprintf($link,base64_encode($name),_("Sections")." :".$str)),
+          array("string"=>preg_replace("/%s/",base64_encode($name),$edit.$delete),"attach"=>"style='border-right:0px;width:55px;text-align:right;'")
                               ));
       }
     }
@@ -275,30 +271,6 @@ class servrepository extends plugin
     return($display);
   }
 
-  function remove_from_parent()
-  {
-    plugin::remove_from_parent();    
-
-     /* Remove status flag, it is not a memeber of
-        this->attributes, so ensure that it is deleted too */
-    if(!empty($this->StatusFlag)){
-      $this->attrs[$this->StatusFlag] = array();
-    }
-
-    $ldap= $this->config->get_ldap_link();
-    $ldap->cd ($this->config->current['BASE']);
-    
-    $ldap->cat($this->dn, array('dn'));
-    
-    if($ldap->count()){
-      $ldap->cd($this->dn);
-      $this->cleanup();
-      $ldap->modify ($this->attrs); 
-
-      $this->handle_post_events("modify");
-    }
-  }
-
 
   /* Save data to object */
   function save_object()
@@ -315,7 +287,6 @@ class servrepository extends plugin
   {
     /* Call common method to give check the hook */
     $message= plugin::check();
-        
     return ($message);
   }
 
@@ -361,69 +332,15 @@ class servrepository extends plugin
     }
   }
 
-  /* Get updates for status flag */
-  function updateStatusState()
-  {
-    if(empty($this->StatusFlag)) return;
-
-    $attrs = array();
-    $flag = $this->StatusFlag;
-    $ldap = $this->config->get_ldap_link();
-    $ldap->cd($this->cn);
-    $ldap->cat($this->dn,array($flag));
-    if($ldap->count()){
-      $attrs = $ldap->fetch();
-    }
-    if(isset($attrs[$flag][0])){
-      $this->$flag = $attrs[$flag][0];
-    }
-  }
-
 
   function getListEntry()
   {
-    $this->updateStatusState();
-    $flag = $this->StatusFlag;
-    if(empty($flag)){
-      $fields['Status']      = "";
-    }else{
-      $fields['Status']      = $this->$flag;
-    }
+    $fields = goService::getListEntry();
     $fields['Message']    = _("Repository service");
-    $fields['AllowStart'] = true;
-    $fields['AllowStop']  = true;
-    $fields['AllowRestart'] = true;
-    $fields['AllowRemove']= true;
     $fields['AllowEdit']  = true;
     return($fields);
   }
 
-
-  /* Directly save new status flag */
-  function setStatus($value)
-  {
-    if($value == "none") return;
-    if(!$this->initially_was_account) return;
-    if(empty($this->StatusFlag)) return;
-    $ldap = $this->config->get_ldap_link();
-    $ldap->cd($this->dn);
-    $ldap->cat($this->dn,array("objectClass"));
-    if($ldap->count()){
-
-      $tmp = $ldap->fetch();
-      for($i = 0; $i < $tmp['objectClass']['count']; $i ++){
-        $attrs['objectClass'][] = $tmp['objectClass'][$i];
-      }
-      $flag = $this->StatusFlag;
-      $attrs[$flag] = $value;
-      $this->$flag = $value;
-      $ldap->modify($attrs);
-      show_ldap_error($ldap->get_error(), sprintf(_("Set status flag for server services/repository with dn '%s' failed."),$this->dn));
-      $this->action_hook();
-    }
-  }
-
-
   /* Return plugin informations for acl handling */
   function plInfo()
   {
@@ -439,6 +356,7 @@ class servrepository extends plugin
           "plProvidedAcls"=> array(
               "cn"            => _("Name"),
               "Release"       => _("Releases"),
+              "Section"       => _("Sections"),
               "ParentServer"  => _("Parent server"),
               "Url"           => _("Url"))
             ));
index a1c62e7baad9a62b52d3681d66f81a5dc41eb0ad..3ed15dfab94241b51f7085c9bad3784380a61024 100644 (file)
@@ -20,6 +20,7 @@ class servRepositorySetup  extends plugin
   var $ParentServers    = "";
   var $initialy_was     = false;
   var $cn               = "";
+  var $parent           = "";
 
   function servRepositorySetup ($config, $dn= NULL,$data = false)
   {
@@ -107,9 +108,15 @@ class servRepositorySetup  extends plugin
   
     $smarty->assign("Sections",$divlist->DrawList());
 
+    /* Get && assign acls */
+    $tmp = $this->parent->plInfo();
+    foreach($tmp['plProvidedAcls'] as $name => $translated){
+      $smarty->assign($name."ACL",$this->parent->getacl($name));
+    }
+
+    /* Assign values */
     foreach($this->attributes as $attr){
       $smarty->assign($attr       ,$this->$attr);
-      $smarty->assign($attr."ACL" ,chkacl($this->acl,$attr));
     }
   
     $tmp = $this->getParentServers();
@@ -121,7 +128,7 @@ class servRepositorySetup  extends plugin
 
   /* Save data to object */
   function save_object()
-  {
+  { 
     plugin::save_object();
   }
 
index 514563c8a9a356d96616688cc3ce3cfc442884ca..62a31f1e107bcb2a19a9e0cc28e9a548c5ad8831 100644 (file)
@@ -45,6 +45,21 @@ class ServerService extends plugin
     $this->divList = new divListSystemService($config,$this);
        }
 
+  function set_acl_base($base)
+  {
+    plugin::set_acl_base($base);
+    foreach($this->plugins as $name => $obj){
+      $this->plugins[$name]->set_acl_base($base);
+    }
+  }
+
+  function set_acl_category($category)
+  {
+    plugin::set_acl_category($category);
+    foreach($this->plugins as $name => $obj){
+      $this->plugins[$name]->set_acl_category($category);
+    }
+  }
 
   function execute()
   {
@@ -106,10 +121,12 @@ class ServerService extends plugin
 
       /* Create resetted obj */
       $new_obj = new $s_entry($this->config,$this->dn);
+      $new_obj -> set_acl_base($this->acl_base);
+      $new_obj -> set_acl_category(preg_replace("/\/$/","",$this->acl_category));
       $tmp     = $new_obj->getListEntry();
 
       if($tmp['AllowRemove']){
-        $this->plugins[$s_entry] = new $s_entry($this->config,$this->dn);
+        $this->plugins[$s_entry] = $new_obj;
         $this->plugins[$s_entry]->is_account = false;
       }
     }
@@ -137,6 +154,9 @@ class ServerService extends plugin
     if(isset($_POST['CancelService'])){
       if($this->backup == NULL){
         $this->plugins[$this->current] = new $this->current($this->config,$this->dn);
+        $this->plugins[$this->current]-> set_acl_base($this->acl_base);
+        $this->plugins[$this->current]-> set_acl_category(preg_replace("/\/$/","",$this->acl_category));
+
       }else{
         foreach($this->backup as $name => $value){
           $this->plugins[$this->current]->$name = $value;
index 84a4bcdb97e5bacfde0e2483843eb2e17e6f85bd..7feaf1d3c2b2838edfbac12439507428d062cfb9 100644 (file)
@@ -8,7 +8,9 @@
   </div>
   <div class="contentboxb">
        <div style='background:#F0F0F9;padding:5px;'>
-<input type="image" src="images/fai_new_packages.png" title="{t}Add repository{/t}" name="AddRepository">
+{if $is_createable}
+               <input type="image" src="images/fai_new_packages.png" title="{t}Add repository{/t}" name="AddRepository">
+{/if}
        </div>
 </div>
 <div style='height:4px;'></div>          
index a87c7b151f335ecb113c2b9ad1452bafc96ebe9b..210d853c1e14e5fdaacb166c02e2fd8e997f3174 100644 (file)
@@ -8,32 +8,44 @@
                                        <td>{t}Parent server{/t}
                                        </td>
                                        <td>
-                                               <select name="ParentServer" {$ParentServerACL}>
+{render acl=$ParentServerACL}
+                                               <select name="ParentServer">
                                                        {html_options options=$ParentServers values=$ParentServerKeys selected=$ParentServer} 
                                                </select>
+{/render}
                                        </td>
                                </tr>
                                <tr>
                                        <td>{t}Release{/t}
                                        </td>
                                        <td>
-                                               <input type="text" value="{$Release}" name="Release" {$ReleaseACL}>
+{render acl=$ReleaseACL}
+                                               <input type="text" value="{$Release}" name="Release">
+{/render}
                                        </td>
                                </tr>
                                <tr>
                                        <td>{t}URL{/t}
                                        </td>
                                        <td>
-                                               <input type="text" size="40" value="{$Url}" name="Url" {$UrlACL}>
+{render acl=$UrlACL}
+                                               <input type="text" size="40" value="{$Url}" name="Url">
+{/render}
                                        </td>
                                </tr>
                        </table>
                </td>
                <td>
                        {t}Sections{/t}<br>
+{render acl=$SectionACL}
                        {$Sections}
+{/render}
+{render acl=$SectionACL}
                        <input type="text"      name="SectionName" value="" style='width:100%;'>
+{/render}
+{render acl=$SectionACL}
                        <input type="submit"    name="AddSection"  value="{t}Add{/t}">
+{/render}
                </td>
        </tr>
 </table>