Code

Some (not completed) netatalk plugin
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 9 Nov 2006 12:31:28 +0000 (12:31 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 9 Nov 2006 12:31:28 +0000 (12:31 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@5062 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/personal/netatalk/class_netatalk.inc
plugins/personal/netatalk/netatalk.tpl

index 9df9eeb19f47bdea8f6a3f29ac11b2cc3390211a..ad52179cb1283208aae7411988ae9c5fde302d7f 100644 (file)
@@ -55,7 +55,8 @@ class netatalk extends plugin {
   
   /* Attributes to save to LDAP */
   var $attributes = array ("apple-user-homeurl", "apple-user-homeDirectory");
-  var $CopyPasteVars= array("apple_user_homeurl", "apple_user_homeDirectory");
+  var $CopyPasteVars= array("apple_user_homeurl", "apple_user_homeDirectory","apple_user_share","shares_settings","apple_user_homepath_raw",
+                            "apple_user_homeurl_raw","apple_user_homeurl_xml","apple_user_homeurl","selectedshare","mountDirectory");
 
   /* Attributes to use in smarty template */
   var $smarty_attributes = array ("apple_user_homepath_raw", "shares", "selectedshare");
@@ -94,33 +95,20 @@ class netatalk extends plugin {
     if (strlen($this->apple_user_homeDirectory) >0) {
       $this->apple_user_homepath_raw = substr($this->apple_user_homeDirectory, strrpos($this->apple_user_homeDirectory, '/') + 1 );
     }
-    
+    /* get share list an set default values */
+    $this->get_netatalk_shares(); 
+    $this->apple_user_share = $this->selectedshare;
+
     /* Save initial account state */
     $this->initially_was_account = $this->is_account;
   }
 
-  /* Execute the plugin, produce the output. */
-  function execute() {
-    plugin :: execute();
 
-    /* Use the smarty templating engine here... */
-    $smarty = get_smarty();
-    $display = "";
-
-    /* Do we need to flip is_account state? */
-    if (isset ($_POST['modify_state'])) {
-      $this->is_account = !$this->is_account;
-    }
-
-    /* Do we represent a valid account? */
-    if (!$this->is_account && $this->parent == NULL) {
-      $display = "<img alt=\"\"src=\"images/stop.png\" align=\"middle\">&nbsp;<b>"._("This account has no netatalk extensions.")."</b>";
-
-      $display .= back_to_main();
-      return ($display);
-    }
-    
     
+  /* Get netatalk shares */
+  function get_netatalk_shares()
+  {
     /* Get netatalk shares */
     $this->shares = array();
     $ldap = $this->config->get_ldap_link();
@@ -133,11 +121,11 @@ class netatalk extends plugin {
     }
     $ldap->search ("(&(objectClass=mount)(|(mountType=url)(mountType=nfs))(cn=*))");
 
-
     /* Show tab dialog headers */
     if ($this->parent != NULL) {
       if ($this->is_account) {
-        $display = $this->show_header(_("Remove netatalk account"), _("This account has netatalk features enabled. You can disable them by clicking below."));
+        $display = $this->show_header(_("Remove netatalk account"), 
+          _("This account has netatalk features enabled. You can disable them by clicking below."));
       } else {
         $errmsg="";
         $obj = $this->parent->by_object['posixAccount'];
@@ -148,19 +136,19 @@ class netatalk extends plugin {
           $errmsg.="At least one share with netatalk or NFS mount entry needed.";
         }
         if($errmsg==""){
-          $display = $this->show_header(_("Create netatalk account"), _("This account has netatalk features disabled. You can enable them by clicking below."));
+          $display = $this->show_header(_("Create netatalk account"), 
+            _("This account has netatalk features disabled. You can enable them by clicking below."));
         } else {
           $display = $this->show_header(_("Create netatalk account"), _($errmsg), TRUE);  
         }
         return ($display);
       }
     }
-    
-    
+
     while ($attrs = $ldap->fetch()){
-      $tmp = split(":", $attrs["cn"][0]);
+      $tmp  = split(":", $attrs["cn"][0]);
       $host = trim($tmp[0]);
-      $dir = trim($tmp[1]);
+      $dir  = trim($tmp[1]);
       $mountType = trim($attrs["mountType"][0]);
       if ($mountType == "url") {
         $mountTypeReal = "netatalk";
@@ -176,11 +164,35 @@ class netatalk extends plugin {
       $oldShare=substr($this->apple_user_homeDirectory, 0, strrpos($this->apple_user_homeDirectory, '/'));
       $newShare=($this->mountDirectory . "/". $host . $dir );
       if (strcmp($oldShare, $newShare)==0) {
-            $this->selectedshare = $share;
+        $this->selectedshare = $share;
       }
     }
     asort($this->shares);
-    /* Assign attributes and ACL to smarty */
+  }
+
+
+  /* Execute the plugin, produce the output. */
+  function execute() 
+  {
+    plugin :: execute();
+
+    /* Use the smarty templating engine here... */
+    $smarty = get_smarty();
+    $display = "";
+
+    /* Do we need to flip is_account state? */
+    if (isset ($_POST['modify_state'])) {
+      $this->is_account = !$this->is_account;
+    }
+
+    /* Do we represent a valid account? */
+    if (!$this->is_account && $this->parent == NULL) {
+      $display = "<img alt=\"\"src=\"images/stop.png\" align=\"middle\">&nbsp;<b>"._("This account has no netatalk extensions.")."</b>";
+
+      $display .= back_to_main();
+      return ($display);
+    }
+    
     
     $smarty->assign("netatalkShareACL", chkacl($this->acl, "netatalkShare"));
     $smarty->assign("netatalkUserHomepathACL", chkacl($this->acl, "netatalkUserHomepath"));
@@ -204,6 +216,8 @@ class netatalk extends plugin {
   /* Check if we have correct data */
   function check() {
     $message = array ();
+  
+    echo $this->apple_user_share;
 
     if (strlen($this->apple_user_share) == 0) {
       $message[] = _("You must select a share to use.");
index 0f5b4a0394aa947f7081517832fee4be5afa3100..8d34ac4b2b1290cef966085851dc1256395d42ae 100644 (file)
@@ -4,7 +4,10 @@
                <label for="apple_user_share">{t}Share{/t}</label>
        </td>
        <td>
-               <select name="apple_user_share" id="apple_user_share" {$netatalkShareACL} >{html_options options=$shares selected=$selectedshare}</select>
+               <select name="apple_user_share" id="apple_user_share" {$netatalkShareACL} >
+                       {html_options options=$shares selected=$selectedshare}
+       
+                       </select>
        </td>
 <tr>
        <td>