Code

Fixed a couple of static/non-static error messages
[gosa.git] / plugins / personal / generic / class_user.inc
index bfd6bd462344fa05948a0664ff7081f006122ea9..6437f1dd9452694874bc0cd197cce1aed39b6d9e 100644 (file)
@@ -83,7 +83,7 @@ class user extends plugin
 
   /* variables to trigger password changes */
   var $pw_storage= "crypt";
-  var $last_pw_storage= "crypt";
+  var $last_pw_storage= "unset";
   var $had_userCertificate= FALSE;
 
   var $view_logged = FALSE;
@@ -105,8 +105,10 @@ class user extends plugin
       "functionalTitle", "certificateSerialNumber", "publicVisible", "street", "role",
       "postalCode");
 
-  var $multiple_support =TRUE;
-
+  var $multiple_support = TRUE;
+  var $multiple_support_active  = FALSE;
+  var $selected_edit_values  = array();
+  var $multiple_user_handles  = array();
 
   /* constructor, if 'dn' is set, the node loads the given
      'dn' from LDAP */
@@ -119,11 +121,6 @@ class user extends plugin
       $this->attributes=array_merge($this->attributes,$this->govattrs);
     }
 
-    $this->dn = $dn;
-    if(is_array($dn)){
-      return;
-    }
-
     /* Load base attributes */
     plugin::plugin ($config, $dn);
 
@@ -220,19 +217,21 @@ class user extends plugin
     if (isset ($this->attrs['gender'])){
       $this->gender= strtoupper($this->attrs['gender'][0]);
     }
-  
     $this->orig_base = $this->base;
   }
 
 
+
+
   /* execute generates the html output for this node */
   function execute()
   {
     /* Call parent execute */
     plugin::execute();
 
-    if(is_array($this->dn)){
-      return("Still not supported.");
+    if($this->multiple_support_active){
+      return($this->execute_multiple());
     }
     /* Log view */
     if($this->is_account && !$this->view_logged){
@@ -657,7 +656,10 @@ class user extends plugin
   /* Save data to object */
   function save_object()
   {
-    if (isset($_POST['generic'])){
+    if (isset($_POST['multiple_user_posted'])){
+      $this->save_object_multiple();
+    }
+    if(isset($_POST['generic']) || isset($_POST['multiple_user_posted'])){
 
       /* Make a backup of the current selected base */
       $base_tmp = $this->base;
@@ -732,6 +734,7 @@ class user extends plugin
     }
   }
 
+  
   /* Save data to LDAP, depending on is_account we save or delete */
   function save()
   {
@@ -741,7 +744,6 @@ class user extends plugin
     if($this->gender=="0") $this->gender ="";
     if($this->preferredLanguage=="0") $this->preferredLanguage ="";
     
     /* First use parents methods to do some basic fillup in $this->attrs */
     plugin::save ();
 
@@ -1053,48 +1055,52 @@ class user extends plugin
       $this->set_acl_base($this->base);
     }
 
-    /* must: sn, givenName, uid */
-    if ($this->sn == "" && ($this->acl_is_writeable("sn",(!is_object($this->parent) && !isset($_SESSION['edit'])) || ($this->is_new)))){
-      $message[]= _("The required field 'Name' is not set.");
-    }
 
-    /* UID already used? */
-    $ldap= $this->config->get_ldap_link();
-    $ldap->cd($this->config->current['BASE']);
-    $ldap->search("(uid=$this->uid)", array("uid"));
-    $ldap->fetch();
-    if ($ldap->count() != 0 && $this->dn == 'new'){
-      $message[]= _("There's already a person with this 'Login' in the database.");
-    }
+    if(!$this->multiple_support_active){
 
-    /* In template mode, the uid and givenName are autogenerated... */
-    if (!$this->is_template){
-      if ($this->givenName == "" && $this->acl_is_writeable("givenName",(!is_object($this->parent) && !isset($_SESSION['edit'])))){
-        $message[]= _("The required field 'Given name' is not set.");
+      /* must: sn, givenName, uid */
+      if ($this->sn == "" && ($this->acl_is_writeable("sn",(!is_object($this->parent) && !isset($_SESSION['edit'])) || ($this->is_new)))){
+        $message[]= _("The required field 'Name' is not set.");
       }
-      if ($this->uid == "" && $this->acl_is_writeable("uid",(!is_object($this->parent) && !isset($_SESSION['edit'])))){
-        $message[]= _("The required field 'Login' is not set.");
+
+      /* UID already used? */
+      $ldap= $this->config->get_ldap_link();
+      $ldap->cd($this->config->current['BASE']);
+      $ldap->search("(uid=$this->uid)", array("uid"));
+      $ldap->fetch();
+      if ($ldap->count() != 0 && $this->dn == 'new'){
+        $message[]= _("There's already a person with this 'Login' in the database.");
       }
-      if (!(isset($this->config->current['DNMODE']) && $this->config->current['DNMODE'] == "uid")){
-        $ldap->cat($this->new_dn);
-        if ($ldap->count() != 0 && $this->dn != $this->new_dn && $this->dn == 'new'){
-          $message[]= _("There's already a person with this 'Name'/'Given name' combination in the database.");
+
+      /* In template mode, the uid and givenName are autogenerated... */
+      if (!$this->is_template){
+        if ($this->givenName == "" && $this->acl_is_writeable("givenName",(!is_object($this->parent) && !isset($_SESSION['edit'])))){
+          $message[]= _("The required field 'Given name' is not set.");
+        }
+        if ($this->uid == "" && $this->acl_is_writeable("uid",(!is_object($this->parent) && !isset($_SESSION['edit'])))){
+          $message[]= _("The required field 'Login' is not set.");
+        }
+        if (!(isset($this->config->current['DNMODE']) && $this->config->current['DNMODE'] == "uid")){
+          $ldap->cat($this->new_dn);
+          if ($ldap->count() != 0 && $this->dn != $this->new_dn && $this->dn == 'new'){
+            $message[]= _("There's already a person with this 'Name'/'Given name' combination in the database.");
+          }
         }
       }
-    }
 
-    /* Check for valid input */
-    if ($this->is_modified && !is_uid($this->uid)){
-      $message[]= _("The field 'Login' contains invalid characters. Lowercase, numbers and dashes are allowed.");
-    }
-    if (!is_url($this->labeledURI)){
-      $message[]= _("The field 'Homepage' contains an invalid URL definition.");
-    }
-    if (preg_match ("/[\\\\]/", $this->sn)){
-      $message[]= _("The field 'Name' contains invalid characters.");
-    }
-    if (preg_match ("/[\\\\]/", $this->givenName)){
-      $message[]= _("The field 'Given name' contains invalid characters.");
+      /* Check for valid input */
+      if ($this->is_modified && !is_uid($this->uid)){
+        $message[]= _("The field 'Login' contains invalid characters. Lowercase, numbers and dashes are allowed.");
+      }
+      if (!is_url($this->labeledURI)){
+        $message[]= _("The field 'Homepage' contains an invalid URL definition.");
+      }
+      if (preg_match ("/[\\\\]/", $this->sn)){
+        $message[]= _("The field 'Name' contains invalid characters.");
+      }
+      if (preg_match ("/[\\\\]/", $this->givenName)){
+        $message[]= _("The field 'Given name' contains invalid characters.");
+      }
     }
 
     /* Check phone numbers */
@@ -1126,7 +1132,7 @@ class user extends plugin
   /* Indicate whether a password change is needed or not */
   function password_change_needed()
   {
-    return ($this->pw_storage != $this->last_pw_storage);
+    return($this->pw_storage != $this->last_pw_storage);
   }
 
 
@@ -1344,7 +1350,7 @@ class user extends plugin
   }
 
 
-  function plInfo()
+  static function plInfo()
   {
   
     $govattrs= array(
@@ -1411,9 +1417,85 @@ class user extends plugin
         $ret["plProvidedAcls"][$attr] = $desc;
       }
     }
-
     return($ret);
   }
+
+
+
+
+
+
+
+
+  function get_values_to_update()
+  {
+    $ret = plugin::get_multi_edit_values();
+    return($ret); 
+  }
+
+
+  function save_object_multiple()
+  {
+    foreach(array("pw_storage","base","edit_cert") as $attr){
+      if(isset($_POST["use_".$attr])){
+        $this->selected_edit_values[$attr] = TRUE;
+      }else{
+        $this->selected_edit_values[$attr] = FALSE;
+      }
+    }
+  }
+
+
+  function execute_multiple()
+  {
+    $smarty =get_smarty(); 
+    $language= array_merge(array(0 => " ") ,get_languages(TRUE));
+    $smarty->assign("preferredLanguage_list", $language);
+    @$smarty->assign("bases", $this->allowedBasesToMoveTo());
+    $smarty->assign("base_select",      $this->base);
+
+    /* Save government mode attributes */
+    if (isset($this->config->current['GOVERNMENTMODE']) &&
+        preg_match('/true/i', $this->config->current['GOVERNMENTMODE'])){
+      $smarty->assign("governmentmode", "true");
+      $ivbbmodes= array("nein", "ivbv", "testa", "ivbv,testa", "internet",
+          "internet,ivbv", "internet,testa", "internet,ivbv,testa");
+      $smarty->assign("ivbbmodes", $ivbbmodes);
+      foreach ($this->govattrs as $val){
+        $smarty->assign("$val", $this->$val);
+        $smarty->assign("$val"."ACL", $this->getacl($val,(!is_object($this->parent) && !isset($_SESSION['edit']))));
+      }
+    } else {
+      $smarty->assign("governmentmode", "false");
+    }
+
+    $temp= passwordMethod::get_available_methods();
+    $hashes = $temp['name'];
+    $test= new $temp[$this->pw_storage]($this->config);
+    $is_configurable= $test->is_configurable();
+    $smarty->assign("pwmode", $hashes);
+    $smarty->assign("pwmode_select", $this->pw_storage);
+    $smarty->assign("pw_configurable", $is_configurable);
+
+    foreach($this->attributes as $attr){
+      if(isset($this->selected_edit_values[$attr]) && $this->selected_edit_values[$attr] == TRUE){
+        $smarty->assign("use_".$attr,TRUE);
+      }else{
+        $smarty->assign("use_".$attr,FALSE);
+      }
+      $smarty->assign($attr,$this->$attr);
+    }
+    foreach(array("pw_storage","base","edit_cert") as $attr){
+      if(isset($this->selected_edit_values[$attr]) && $this->selected_edit_values[$attr] == TRUE){
+        $smarty->assign("use_".$attr,TRUE);
+      }else{
+        $smarty->assign("use_".$attr,FALSE);
+      }
+    }
+    return($smarty->fetch (get_template_path('multiple_generic.tpl', TRUE, dirname(__FILE__))));
+  }
+
+
 }
 
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: