Code

Fixed baseSelectDialog parameters
[gosa.git] / plugins / personal / generic / class_user.inc
index 1d3e4d4d150153fcc19853a56dd3de96c492ee55..ec56ed885bf14dc326de4d57bcc74ce677f5445f 100644 (file)
@@ -201,7 +201,7 @@ class user extends plugin
     /* Put gender attribute to upper case */
     if (isset ($this->attrs['gender'])){
       $this->gender= strtoupper($this->attrs['gender'][0]);
-    }  
+    }
   }
 
 
@@ -257,7 +257,9 @@ class user extends plugin
     $smarty->assign("gender_list", $sex);
 
     /* Assign prefered langage */
-    $language= array(0 => " ", "fr_FR" => ("fr_FR"), "en_EN" => ("en_EN"), "de_DE" => ("de_DE"), "it_IT" => ("it_IT"), "nl_NL" => ("nl_NL"));
+    $language= array(0 => " ", "fr_FR" => ("fr_FR"), "en_EN" => ("en_EN"), 
+                                    "de_DE" => ("de_DE"), "it_IT" => ("it_IT"), 
+                                    "nl_NL" => ("nl_NL"), "ru_RU" => ("ru_RU"));
     $smarty->assign("preferredLanguage_list", $language);
 
     /* Get random number for pictures */
@@ -276,7 +278,7 @@ class user extends plugin
     foreach($_POST as $name => $value){
       if(preg_match("/^chooseBase/",$name) && $once){
         $once = false;
-        $this->dialog = new baseSelectDialog($this->config,$this->allowedBasesToMoveTo());
+        $this->dialog = new baseSelectDialog($this->config,$this,$this->allowedBasesToMoveTo());
         $this->dialog->setCurrentBase($this->base);
       }
     }
@@ -479,7 +481,7 @@ class user extends plugin
       $this->pw_storage= $this->config->current['HASH'];
     }
 
-    $temp   = passwordMethod::get_available_methods();
+    $temp   = @passwordMethod::get_available_methods();
     $hashes = $temp['name'];
     
     $smarty->assign("pwmode", $hashes);
@@ -541,6 +543,7 @@ class user extends plugin
   {
     $ldap= $this->config->get_ldap_link();
     $ldap->rmdir ($this->dn);
+    show_ldap_error($ldap->get_error(), _("Removing generic user account failed"));
 
     /* Delete references to groups */
     $ldap->cd ($this->config->current['BASE']);
@@ -808,7 +811,7 @@ class user extends plugin
 
     /* Save data. Using 'modify' implies that the entry is already present, use 'add' for
        new entries. So do a check first... */
-    $ldap->cat ($this->dn);
+    $ldap->cat ($this->dn, array('dn'));
     if ($ldap->fetch()){
       $mode= "modify";
     } else {
@@ -829,7 +832,7 @@ class user extends plugin
     $this->cleanup();
     $ldap->cd ($this->dn);
     $ldap->$mode ($this->attrs);
-    if (show_ldap_error($ldap->get_error())){
+    if (show_ldap_error($ldap->get_error(), _("Saving generic user account failed"))){
       return (1);
     }
 
@@ -921,6 +924,9 @@ class user extends plugin
       $this->handle_post_events("modify");
     }
 
+    /* Fix tagging if needed */
+    $this->handle_object_tagging();
+
     return (0);
   }
 
@@ -928,7 +934,8 @@ class user extends plugin
   /* Check formular input */
   function check()
   {
-    $message= array();
+    /* Call common method to give check the hook */
+    $message= plugin::check();
 
     /* Assemble cn */
     $this->cn= $this->givenName." ".$this->sn;
@@ -1224,10 +1231,59 @@ class user extends plugin
   } 
 
 
+  function getCopyDialog()
+  {
+    $str = "";
+
+    $_SESSION['binary'] = $this->photoData; 
+    $_SESSION['binarytype']= "image/jpeg";
+
+    /* Get random number for pictures */
+    srand((double)microtime()*1000000); 
+    $rand = rand(0, 10000);
+
+    $smarty = get_smarty();
+
+    $smarty->assign("passwordTodo","clear");
+
+    if(isset($_POST['passwordTodo'])){
+      $smarty->assign("passwordTodo",$_POST['passwordTodo']);
+    }
+
+    $smarty->assign("sn",       $this->sn);
+    $smarty->assign("givenName",$this->givenName);
+    $smarty->assign("uid",      $this->uid);
+    $smarty->assign("rand",     $rand);
+    $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE,dirname(__FILE__)));
+
 
+    $ret = array();
+    $ret['string'] = $str;
+    $ret['status'] = "";  
+    return($ret);
+  }
 
+  function saveCopyDialog()
+  {
 
+    if((isset($_FILES['picture_file']['tmp_name'])) && ($_FILES['picture_file']['size'] > 0)){
+      $this->set_picture($_FILES['picture_file']['tmp_name']);
+    }
 
+    /* Remove picture? */
+    if (isset($_POST['picture_remove'])){
+      $this->jpegPhoto= "*removed*";
+      $this->set_picture ("./images/default.jpg");
+      $this->is_modified= TRUE;
+    }
+
+    $attrs = array("uid","givenName","sn");
+    foreach($attrs as $attr){
+      if(isset($_POST[$attr])){
+        $this->$attr = $_POST[$attr];
+      }
+    } 
+  }
 }
 
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: