Code

Removed samba2 references
[gosa.git] / gosa-core / plugins / admin / users / class_userManagement.inc
index 9b4d57f82e1203b6253974af70f064b0dddd7079..f3bb656588e81fc3f83daa842aa21eab0336e824 100644 (file)
@@ -33,6 +33,7 @@ class userManagement extends plugin
   var $templates            = array();
   var $got_uid              = false;
   var $CopyPasteHandler     = NULL;
+  var $SnapshotHandler     = NULL;
   var $CPPasswordChange     = ""; // Contains the entry id which should get a new password
   var $DivListUsers;
 
@@ -43,6 +44,11 @@ class userManagement extends plugin
   var $acl_module = array("users");  
   var $dns    = array();
 
+  // Filter/headpage tests
+  var $filter= null;
+  var $headpage= null;
+
+
   function userManagement(&$config, $ui)
   {
     /* Save configuration for internal use */
@@ -53,6 +59,9 @@ class userManagement extends plugin
     if ($this->config->boolValueIsTrue("main", "copyPaste")){
       $this->CopyPasteHandler= new CopyPasteHandler($this->config);
     }
+    if($this->config->get_cfg_value("enableSnapshots") == "true"){
+      $this->SnapshotHandler= new SnapshotHandler($this->config);
+    }
 
     /* Creat dialog object */
     $this->DivListUsers = new divListUsers($this->config,$this);
@@ -979,25 +988,128 @@ class userManagement extends plugin
     $this->DivListUsers->setEntries($this->list);
 
     # FILTER Test #################################################
-    #$filter = new filter(get_template_path("user-filter.xml", true));
-    #$filter->setObjectStorage(get_people_ou());
-    #$filter->setCategory("users");
-    #$filter->setCurrentBase($this->DivListUsers->selectedBase);
-    #$filter->update();
-    #session::set('autocomplete', $filter);
-    #if (!$filter->isValid()){
+    ## Build filter
+    #if (!$this->filter) {
+    #  $this->filter = new filter(get_template_path("user-filter.xml", true));
+    #  $this->filter->setObjectStorage(get_people_ou());
+    #}
+    #$this->filter->update();
+    #session::set('autocomplete', $this->filter);
+    #if (!$this->filter->isValid()){
     #  msg_dialog::display(_("Filter error"), _("The filter is uncomplete!"), ERROR_DIALOG);
-    #} else {
-    #  print "Filter results:";
-    #  print_a($filter->query());
     #}
-    #return($filter->renderFilter().$this->DivListUsers->Draw());
+
+    ## Build headpage
+    #if (!$this->headpage){
+    #  $this->headpage = new listing(get_template_path("user-list.xml", true));
+    #  $this->headpage->registerElementFilter("accountProperties", "userManagement::filterProperties");
+    #  $this->headpage->registerElementFilter("lockLabel", "userManagement::filterLockLabel");
+    #  $this->headpage->registerElementFilter("lockImage", "userManagement::filterLockImage");
+    #  $this->headpage->setFilter($this->filter);
+    #}
+
+    ## Needs to be called before update!
+    #$action= $this->headpage->getAction();
+    #if ($action['action'] != '') {
+    #  echo "List detected action:";
+    #  print_a($action);
+    #}
+
+    ## Refresh for filter
+    #$this->headpage->update();
+    #
+    #return($this->headpage->render());
     ################################################### FILTER Test
 
     return($this->DivListUsers->Draw());
   }
 
 
+  static function filterLockImage($userPassword)
+  {
+    $image= "images/empty.png";
+
+    if(isset($userPassword[0]) && preg_match("/^\{[^\}]/",$userPassword[0])){
+      if(preg_match("/^[^\}]*+\}!/",$userPassword[0])){
+        $image= "images/lists/locked.png";
+      }else{
+        $image= "images/lists/unlocked.png";
+      }
+    }
+
+    return $image;
+  }
+
+
+  static function filterLockLabel($userPassword)
+  {
+    $label= "";
+
+    if(isset($userPassword[0]) && preg_match("/^\{[^\}]/",$userPassword[0])){
+      if(preg_match("/^[^\}]*+\}!/",$userPassword[0])){
+        $label= _("Unlock account");
+      }else{
+        $label= _("Lock account");
+      }
+    }
+
+    return $label;
+  }
+
+
+  static function filterProperties($dn, $row, $class)
+  {
+    $result= "";
+
+    $map= array( "gosaAccount" => array( "image" => "plugins/users/images/select_user.png",
+                                         "plugin" => "user",
+                                         "alt" => _("Generic"),
+                                         "title" => _("Edit generic properties")),
+                 "posixAccount" => array("image" => "images/penguin.png",
+                                         "plugin" => "posixAccount",
+                                         "alt" => _("POSIX"),
+                                         "title" => _("Edit POSIX properties")),
+                 "gosaMailAccount" => array("image" => "images/mailto.png",
+                                         "alt" => _("Mail"),
+                                         "plugin" => "mailAccount",
+                                         "title" => _("Edit mail properties")),
+                 "sambaSamAccount" => array("image" => "plugins/systems/images/select_winstation.png",
+                                         "plugin" => "sambaAccount",
+                                         "alt" => _("Samba"),
+                                         "title" => _("Edit samba properties")),
+                 "apple-user" => array("image" => "plugins/netatalk/images/select_netatalk.png",
+                                         "plugin" => "sambaAccount",
+                                         "alt" => _("Netatalk"),
+                                         "title" => _("Edit netatalk properties")),
+                 "gotoEnvironment" => array("image" => "plugins/users/images/small_environment.png",
+                                         "plugin" => "gotoEnvironment",
+                                         "alt" => _("Environment"),
+                                         "title" => _("Edit environment properties")),
+                 "goFaxAccount" => array("image" => "plugins/users/images/fax_small.png",
+                                         "plugin" => "goFaxAccount",
+                                         "alt" => _("FAX"),
+                                         "title" => _("Edit FAX properties")),
+                 "goFonAccount" => array("image" => "plugins/gofon/images/select_phone.png",
+                                         "plugin" => "goFonAccount",
+                                         "alt" => _("Phone"),
+                                         "title" => _("Edit phone properties")));
+
+    // Walk thru map
+    foreach ($map as $oc => $properties) {
+      if (in_array($oc, $class)) {
+        $result.="<input class='center' type='image' src='".$properties['image']."' ".
+                 "alt='".$properties['alt']."' title='".$properties['title'].
+                 "' name='listing_edit_".$properties['plugin']."_$row' style='padding:1px'>";
+      } else {
+        $result.="<img src='images/empty.png' alt=' ' class='center' style='padding:1px'>";
+      }
+    }
+
+    return $result;
+  }
+
+
+
   /* Return departments, that will be included within snapshot detection */
   function get_used_snapshot_bases()
   {
@@ -1023,11 +1135,7 @@ class userManagement extends plugin
 
     /* Setup filter depending on selection */
     $filter="";
-    if ($this->config->get_cfg_value("sambaversion") == 3){
-      $samba= "sambaSamAccount";
-    } else {
-      $samba= "sambaAccount";
-    }
+    $samba= "sambaSamAccount";
 
     if ($ShowFunctionalUsers){
       $filter.= "(&(objectClass=gosaAccount)(!(|(objectClass=posixAccount)".