Code

Added ability to select ogroup membership in terminal Generic
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 21 Sep 2006 06:34:45 +0000 (06:34 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 21 Sep 2006 06:34:45 +0000 (06:34 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@4751 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/systems/class_goShareServer.inc
plugins/admin/systems/class_servNfs.inc
plugins/admin/systems/goShareServer.tpl
plugins/admin/systems/servnfs.tpl

index 99c75c32624facd006789bb49f2e70fedc431f1d..5bfe63424829bfb9c29cbc9ed582b80543dbf893 100644 (file)
@@ -1,6 +1,8 @@
 <?php
 
-class goShareServer extends plugin{
+require_once("class_goService.inc");
+
+class goShareServer extends goService{
 
   var $cli_summary      = "This plugin is used within the ServerService Pluign \nand indicates that this server supports shares.";
   var $cli_description  = "Some longer text\nfor help";
@@ -16,7 +18,6 @@ class goShareServer extends plugin{
 
   var $DisplayName      = "";
   var $dn               = NULL;
-  var $acl;
   var $cn                   = "";
   var $goShareServerStatus  = "";
   var $goExportEntry        = array();
@@ -67,7 +68,9 @@ class goShareServer extends plugin{
 
     if(isset($_POST['NewNfsAdd'])){
       $this->oldone = NULL;
-      $this->o_subWindow = new servnfs($this->config,$this->acl, $this->allow_mounts, $this->dn);
+      $this->o_subWindow = new servnfs($this->config, $this);
+      $this->o_subWindow->set_acl_category("server");
+      $this->o_subWindow->set_acl_base($this->dn);
       $this->dialog = true;
     }
 
@@ -75,7 +78,9 @@ class goShareServer extends plugin{
       $entry = $this->goExportEntryList[$_POST['goExportEntryList'][0]];
       $add_mount=isset($this->mounts_to_add[$entry]);
       $this->oldone=$entry;
-      $this->o_subWindow = new servnfs($this->config,$this->acl,$this->allow_mounts,$this->dn,$entry,$add_mount);
+      $this->o_subWindow = new servnfs($this->config,$this,$entry,$add_mount);
+      $this->o_subWindow->set_acl_base($this->dn);
+      $this->o_subWindow->set_acl_category("server");
       $this->dialog = true;
     }
     if(isset($this->o_subWindow)){
@@ -117,14 +122,20 @@ class goShareServer extends plugin{
       return $this->o_subWindow->execute();
     }
 
-
-
-
-
     foreach($this->attributes as $attr){
       $smarty->assign($attr,$this->$attr);
-      $smarty->assign($attr."ACL",chkacl($this->acl,$attr));
     }
+
+    /* Set acls */
+    $tmp = $this->plInfo();
+    $acl = ""; 
+    foreach($tmp['plProvidedAcls'] as $name => $translated){
+      $acl .= $this->getacl($name);
+    }
+    $smarty->assign("goExportEntryACL",$acl);
+    $smarty->assign("createable",$this->acl_is_createable());
+    $smarty->assign("removeable",$this->acl_is_removeable());
+
     $tellSmarty= array();
     ksort($this->goExportEntryList);
     foreach($this->goExportEntryList as $name=>$values){
@@ -133,53 +144,19 @@ class goShareServer extends plugin{
     }
     $smarty->assign("goExportEntry",array_keys($tellSmarty));
     $smarty->assign("goExportEntryKeys",($tellSmarty));
-    $smarty->assign("goExportEntryACL", chkacl($this->acl, "goExportEntry"));
-
-
     return($smarty->fetch(get_template_path("goShareServer.tpl",TRUE,dirname(__FILE__))));
   }
 
 
   function getListEntry()
   {
-    $this->updateStatusState();
-    $flag = $this->StatusFlag;
-    $fields['Status']     = $this->$flag;
-    $fields['Message']    = _("Shares");
-    $fields['AllowStart'] = true;
-    $fields['AllowStop']  = true;
-    $fields['AllowRestart'] = true;
-    $fields['AllowRemove']= true;
+    $fields = goService::getListEntry();
+    $fields['Message']    = _("File service (Shares)");
     $fields['AllowEdit']  = true;
     return($fields);
   }
 
 
-  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();
-    }
-
-    /* Check if this is a new entry ... add/modify */
-    $ldap = $this->config->get_ldap_link();
-    $ldap->cat($this->dn,array("objectClass"));
-    if($ldap->count()){
-      $ldap->cd($this->dn);
-      $ldap->modify($this->attrs);
-    }else{
-      $ldap->cd($this->dn);
-      $ldap->add($this->attrs);
-    }
-    show_ldap_error($ldap->get_error(), sprintf(_("Removing of system server/shares with dn '%s' failed."),$this->dn));
-    $this->handle_post_events("remove");
-  }
-
-
   function save()
   {
     plugin::save();
@@ -198,7 +175,6 @@ class goShareServer extends plugin{
       $this->process_mounts();
     }
 
-
     /* Check if this is a new entry ... add/modify */
     $ldap = $this->config->get_ldap_link();
     $ldap->cat($this->dn,array("objectClass"));
@@ -218,30 +194,6 @@ class goShareServer extends plugin{
   }
 
 
-  /* Directly save new status flag */
-  function setStatus($value)
-  {
-    if($value == "none") return;
-    if(!$this->initially_was_account) 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 system server/shares with dn '%s' failed."),$this->dn));
-      $this->action_hook();
-    }
-  }
-
-
   function check()
   { 
     $message = plugin::check();
@@ -314,66 +266,6 @@ class goShareServer extends plugin{
     }
   }
 
-   function action_hook($add_attrs= array())
-  {
-    /* Find postcreate entries for this class */
-    $command= search_config($this->config->data['MENU'], get_class($this), "ACTION_HOOK");
-    if ($command == "" && isset($this->config->data['TABS'])){
-      $command= search_config($this->config->data['TABS'], get_class($this), "ACTION_HOOK");
-    }
-    if ($command != ""){
-      /* Walk through attribute list */
-      foreach ($this->attributes as $attr){
-        if (!is_array($this->$attr)){
-          $command= preg_replace("/%$attr/", $this->$attr, $command);
-        }
-      }
-      $command= preg_replace("/%dn/", $this->dn, $command);
-      /* Additional attributes */
-      foreach ($add_attrs as $name => $value){
-        $command= preg_replace("/%$name/", $value, $command);
-      }
-
-      /* If there are still some %.. in our command, try to fill these with some other class vars */
-      if(preg_match("/%/",$command)){
-        $attrs = get_object_vars($this);
-        foreach($attrs as $name => $value){
-          if(!is_string($value)) continue;
-          $command= preg_replace("/%$name/", $value, $command);
-        }
-      }
-
-      if (check_command($command)){
-        @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__,
-            $command, "Execute");
-
-        exec($command);
-      } else {
-        $message= sprintf(_("Command '%s', specified as ACTION_HOOK for plugin '%s' doesn't seem to exist."), $command, get_class($this));
-        print_red ($message);
-      }
-    }
-  }
-
-  /* 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 addToMountList($entry) 
   {
     $key =  key($entry);
@@ -454,7 +346,15 @@ class goShareServer extends plugin{
           "plCategory"    => array("server"),
 
           "plProvidedAcls"=> array(
-            "goExportEntry"     =>_("Share entry"))
+              "name"        => _("Name"),
+              "netatalkmount" => _("Apple mounts"),
+              "description" => _("Description"),
+              "type"        => _("Type"),
+              "charset"     => _("Charset"),
+              "path"        => _("Path"),
+              "option"      => _("Option"),
+              "volume"      => _("Volume"))
+
           ));
   }
 
index fbda973248ad639c51ae553444f6d94f1c2d8876..928f0052f898ad5acd108f84d29d7c3aa6bf84f5 100644 (file)
@@ -24,22 +24,22 @@ class servnfs extends plugin
   var $volume        ="";  // Volume
   var $option        ="";  // Options
   var $is_edit           =false;
-  var $allow_mounts = false; //do we allow mount entries?
   var $create_mount_init = false; //mount entry set for this entry (while editing)?
   var $create_mount = false; //save mount entry
 
-  function servnfs ($config, $acl, $allow_mounts, $dn= NULL,$entry = false,$mount = false)
+  var $parent       = NULL;
+
+  function servnfs ($config, $parent,$entry= false,$mount =false)
   {
+    $this->parent = $parent;
+    $dn = $parent->dn;
     plugin::plugin ($config, $dn);
-    
+  
     $this->types   = array("CIFS" => "CIFS", "NFS"=>"NFS","samba"=>"samba","netatalk"=>"netatalk","NCP"=>"NCP");
     if($dn){
       $this->host = substr($dn, 3, strpos($dn, ',')-3);
     }
     
-    $this->acl = $acl;
-       $this->allow_mounts=$allow_mounts;
-       
     $this->charsets = array();
 
     if(!file_exists("/etc/gosa/encodings")){
@@ -96,21 +96,20 @@ class servnfs extends plugin
       $smarty->assign($attr,$this->$attr);
     }
 
-    $smarty->assign("nameACL","");    
-    $smarty->assign("name",$this->name);
+    $tmp = $this->parent->plInfo();
+    foreach($tmp['plProvidedAcls'] as $name => $translation){
+      $smarty->assign($name."ACL",$this->parent->getacl($name));
+    }
 
+    $smarty->assign("name",$this->name);
     if($this->is_edit){
-      $smarty->assign("nameACL"," disabled ");
+      $smarty->assign("nameACL", preg_replace("/w/",$this->getacl("name")));
     }
     
-    $smarty->assign("allow_mounts", $this->allow_mounts);
+    $smarty->assign("allow_mounts", $this->parent->allow_mounts);
     $smarty->assign("mount_checked", "");
     
-    
-    $appleMountsACL=chkacl($this->acl,"gotoShareAppleMounts");
-    $appleMountsACLset=strpos($appleMountsACL, "disabled");
-    $smarty->assign("appleMountsACL", $appleMountsACL);
-    $smarty->assign("appleMountsACLset", $appleMountsACLset);
+    $smarty->assign("appleMountsACL",    $this->getacl("appleMounts"));
   
     if (($this->type == "netatalk") || ($this->type == "NFS")) {
         if ($this->create_mount_init) {
@@ -154,17 +153,19 @@ class servnfs extends plugin
   /* Save data to object */
   function save_object()
   {
-    plugin::save_object(TRUE);
     if(isset($_POST['path'])){
-      foreach($this->attributes as $attr){
-        $this->$attr = $_POST[$attr];
+
+      foreach($this->attributes as $name){
+        if($this->parent->acl_is_writeable($name) && isset($_POST[$name])){
+          $this->$name = $_POST[$name];
+        }
       }
-    }
-    
-    if ((isset($_POST['netatalk_mount'])) && (($this->type == "netatalk") || ($this->type == "NFS"))) {
+
+      if ((isset($_POST['netatalk_mount'])) && (($this->type == "netatalk") || ($this->type == "NFS"))) {
         $this->create_mount = true;
-    } else {
+      } else {
         $this->create_mount = false;
+      }
     }
   }
 
@@ -256,27 +257,7 @@ class servnfs extends plugin
     return $this->create_mount;
   }
 
-  /* Return plugin informations for acl handling */
-  function plInfo()
-  {
-    return (array(
-          "plShortName"   => _("NFS"),
-          "plDescription" => _("NFS service"),
-          "plSelfModify"  => FALSE,
-          "plDepends"     => array(),
-          "plPriority"    => 0,
-          "plSection"     => array("administration"),
-          "plCategory"    => array("server"),
-
-          "plProvidedAcls"=> array(
-              "description" => _("Description"),
-              "type"        => _("Type"),
-              "charset"     => _("Charset"),
-              "path"        => _("Path"),
-              "option"      => _("Option"), 
-              "volume"      => _("Volume"))
-            ));
-  }
+
 }
 
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
index 1699407db8cde59b1a4e9982cc3fee2c8f792a5f..6cb4c45a651d33bb309887831944674f0bae4399 100644 (file)
@@ -2,14 +2,19 @@
    <table summary="" style="width:100%">
     <tr>
      <td>
-        <select style="width:100%" id="goExportEntry" name="goExportEntryList[]" {$goExportEntryACL} size=12 multiple >
+{render acl=$goExportEntryACL}
+        <select style="width:100%" id="goExportEntry" name="goExportEntryList[]" size=12 multiple >
             {html_options values=$goExportEntry output=$goExportEntryKeys}
             <option disabled>&nbsp;</option>
         </select>
+{/render}
     <br>
-        <input type="submit"    value="{t}Add{/t}"  name="NewNfsAdd"   {$goExportEntryACL}  id="NewNfsAddId">
-        <input type="submit"    value="{t}Edit{/t}"     name="NewNfsEdit"  {$goExportEntryACL}  id="NewNfsEditId">
-        <input type="submit"    value="{t}Delete{/t}"   name="DelNfsEnt"   {$goExportEntryACL}  id="DelNfsEntId">
+       
+        <input type="submit"    value="{t}Add{/t}"     name="NewNfsAdd"   id="NewNfsAddId" {if !$createable} disabled {/if}>
+{render acl=$goExportEntryACL}
+        <input type="submit"    value="{t}Edit{/t}"     name="NewNfsEdit"  id="NewNfsEditId">
+{/render}
+        <input type="submit"    value="{t}Delete{/t}"   name="DelNfsEnt"   id="DelNfsEntId" {if !$removeable} disabled {/if}>
     </td>
     </tr>
    </table>
index 4a7fb40ce02c08570c5ff4b94b07919f00c35963..006f5d9c4a164ebdc45871487d836af831bb7772 100644 (file)
@@ -9,7 +9,9 @@
                                                {t}Name{/t} {$must}
                                        </td>
                                        <td>
+{render acl=$nameACL}
                                                <input type="text" name="name" value="{$name}" {$nameACL}>
+{/render}
                                        </td>
                                </tr>
                                <tr>
@@ -17,7 +19,9 @@
                                                {t}Description{/t}
                                        </td>
                                        <td>
+{render acl=$descriptionACL}
                                                <input type="text" size="40" name="description" value="{$description}">
+{/render}
                                        </td>
                                </tr>
                                <tr>
@@ -25,7 +29,9 @@
                                                {t}Path{/t} / {t}Volume{/t}
                                        </td>
                                        <td>
+{render acl=$pathACL}
                                                <input type="text" size="40" name="path" value="{$path}">
+{/render}
                                        </td>
                                </tr>
                                <tr>
@@ -33,7 +39,9 @@
                                                <div id="vlabel">{t}Server{/t}</div>
                                        </td>
                                        <td>
+{render acl=$volumeACL}
                                                <input type="text" id="volume" size="40" name="volume" value="{$volume}">
+{/render}
                                        </td>
                                </tr>
                        </table>
                        <table summary="">
                                <tr>
                                        <td style="vertical-align:top">
+
                                                {t}Type{/t}
                                        </td>
                                        <td>
+{render acl=$typeACL}
                                                <select size="1" name="type" id="sharetype">
                                                        {html_options options=$types selected=$type}
                                                </select>
+{/render}
                                                {if $allow_mounts == TRUE}
-                                                       <br><br><input type="checkbox" name="netatalk_mount" id="netatalk_mount" {$mount_checked} {$appleMountsACL}/><label for="netatalk_mount">{t}Auto-mount share on Apple systems{/t}</label>
+                                               <br><br>
+{render acl=$netatalkmountACL}
+                                               <input type="checkbox" name="netatalk_mount" id="netatalk_mount" {$mount_checked} {$appleMountsACL}/>
+{/render}
+                                               <label for="netatalk_mount">{t}Auto-mount share on Apple systems{/t}</label>
                                                        <br>
                                                        <br>
                                                {/if}
                                                {t}Codepage{/t}
                                        </td>
                                        <td>
+{render acl=$charsetACL}
                                                <select size="1" name="charset">
                                                        {html_options options=$charsets selected=$charset}
                                                </select>       
+{/render}
                                        </td>
                                </tr>
                                <tr>
                                        {t}Option{/t}
                                    </td>
                                    <td>
+{render acl=$optionACL}
                                                                <input type="text" name="option" value="{$option}">
+{/render}
                                    </td>
                                </tr>
                        </table>