Code

Updated images and themes
[gosa.git] / gosa-core / plugins / admin / users / class_userManagement.inc
1 <?php
2 /*
3  * This code is part of GOsa (http://www.gosa-project.org)
4  * Copyright (C) 2003-2008 GONICUS GmbH
5  *
6  * ID: $$Id$$
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  */
23 class userManagement extends management
24 {
25   var $plHeadline     = "Users";
26   var $plDescription  = "Manage aspects of user accounts like generic, posix, samba and mail settings";
27   var $plIcon  = "plugins/users/images/user.png";
29   var $sn = "";
30   var $givenName = "";
31   var $uid = "";
32   var $got_uid = "";
33   var $edit_uid = "";
35   var $pwd_change_queue = array();
36   var $force_hash_type = array();
38   // Tab definition 
39   protected $tabClass = "usertabs";
40   protected $tabType = "USERTABS";
41   protected $aclCategory = "users";
42   protected $aclPlugin   = "user";
43   protected $objectName   = "user";
45   function __construct($config,$ui)
46   {
47     $this->config = $config;
48     $this->ui = $ui;
49    
50     $this->storagePoints = array(get_ou("userRDN"));
51  
52     // Build filter
53     if (session::global_is_set(get_class($this)."_filter")){
54       $filter= session::global_get(get_class($this)."_filter");
55     } else {
56       $filter = new filter(get_template_path("user-filter.xml", true));
57       $filter->setObjectStorage($this->storagePoints);
58     }
59     $this->setFilter($filter);
61     // Build headpage
62     $headpage = new listing(get_template_path("user-list.xml", true));
63     $headpage->registerElementFilter("lockLabel", "userManagement::filterLockLabel");
64     $headpage->registerElementFilter("lockImage", "userManagement::filterLockImage");
65     $headpage->registerElementFilter("filterProperties", "userManagement::filterProperties");
66     $headpage->setFilter($filter);
68     // Add copy&paste and snapshot handler.
69     if ($this->config->boolValueIsTrue("main", "copyPaste")){
70       $this->cpHandler = new CopyPasteHandler($this->config);
71     }
72     if($this->config->get_cfg_value("enableSnapshots") == "true"){
73       $this->snapHandler = new SnapshotHandler($this->config);
74     }
76     parent::__construct($config, $ui, "users", $headpage);
78     // Register special user actions 
79     $this->registerAction("lock",   "lockEntry");
80     $this->registerAction("lockUsers",   "lockUsers");
81     $this->registerAction("unlockUsers", "lockUsers");
82     $this->registerAction("new_template", "newTemplate");
83     $this->registerAction("newfromtpl", "newUserFromTemplate");
84     $this->registerAction("templateContinue", "templateContinue");
85     $this->registerAction("templatize", "templatizeUsers");
86     $this->registerAction("templatizeContinue", "templatizeContinue");
88     $this->registerAction("password", "changePassword");
89     $this->registerAction("passwordQueue", "handlePasswordQueue");
90     $this->registerAction("passwordCancel", "closeDialogs");
92     $this->registerAction("sendMessage", "sendMessage");
93     $this->registerAction("saveEventDialog", "saveEventDialog");
94     $this->registerAction("abortEventDialog", "closeDialogs");
96     // Register shortcut icon actions 
97     $this->registerAction("edit_user","editEntry");
98     $this->registerAction("edit_posixAccount","editEntry");
99     $this->registerAction("edit_mailAccount","editEntry");
100     $this->registerAction("edit_sambaAccount","editEntry");
101     $this->registerAction("edit_netatalk","editEntry");
102     $this->registerAction("edit_environment","editEntry");
103     $this->registerAction("edit_gofaxAccount","editEntry");
104     $this->registerAction("edit_phoneAccount","editEntry");
105   }
108   // Inject user actions 
109   function detectPostActions()
110   {
111     $action = management::detectPostActions();
112     if(isset($_POST['template_continue'])) $action['action'] = "templateContinue";
113     if(isset($_POST['templatize_continue'])) $action['action'] = "templatizeContinue";
114     if(isset($_POST['save_event_dialog'])) $action['action'] = "saveEventDialog";
115     if(isset($_POST['abort_event_dialog'])) $action['action'] = "abortEventDialog";
116     if(isset($_POST['password_cancel'])){
117       $action['action'] = "passwordCancel";
118     }elseif((count($this->pwd_change_queue) || isset($_POST['password_finish']))){
119       $action['action'] = "passwordQueue";
120     }
121     return($action);
122   }
125   function editEntry($action="",$target=array(),$all=array(), $altTabClass ="", $altTabType = "", $altAclCategory="")
126   {
127     $str = management::editEntry($action,$target);
128     if($str) return($str);
130     if(preg_match("/^edit_/",$action)){
131       $tab = preg_replace("/^edit_/","",$action); 
132       if(isset($this->tabObject->by_object[$tab])){
133         $this->tabObject->current = $tab;
134       }else{
135         trigger_error("Unknown tab: ".$tab);
136       }
137     }
138   }
140   
141   function closeDialogs()
142   {
143     management::closeDialogs();
144     $this->pwd_change_queue = array();
145   }
146     
148   /*! \brief  Sends a message to a set of users using gosa-si events.
149    */ 
150   function sendMessage($action="",$target=array(),$all=array())
151   {
152     if(class_available("DaemonEvent")){
153       $uids = array();
154       $ldap = $this->config->get_ldap_link();
155       $ldap->cd($this->config->current['BASE']);
156       foreach($target as $dn){
157         $ldap->cat($dn,array('uid'));
158         $attrs = $ldap->fetch();
159         if(isset($attrs['uid'][0])){
160           $uids[] = $attrs['uid'][0];
161         }
162       }
163       if(count($uids)){
164         $events = DaemonEvent::get_event_types(USER_EVENT);
165         $event = "DaemonEvent_notify";
166         if(isset($events['BY_CLASS'][$event])){
167           $type = $events['BY_CLASS'][$event];
168           $this->dialogObject = new $type['CLASS_NAME']($this->config);
169           $this->dialogObject->add_users($uids);
170           $this->dialogObject->set_type(SCHEDULED_EVENT);
171         }
172       }
173     }
174   }
177   /*! \brief  Sends a message to a set of users using gosa-si events.
178    */ 
179   function saveEventDialog()
180   {
181     $this->dialogObject->save_object();
182     $msgs = $this->dialogObject->check();
183     if(count($msgs)){
184       msg_dialog::displayChecks($msgs);
185     }else{
186       $o_queue = new gosaSupportDaemon();
187       $o_queue->append($this->dialogObject);
188       if($o_queue->is_error()){
189         msg_dialog::display(_("Infrastructure error"), msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
190       }
191       $this->closeDialogs();
192     }
193   }
196   /*! \brief  Intiates template creation. 
197    */ 
198   function newTemplate($action,$entry)
199   {
200     $this->newEntry();
201     $this->tabObject->set_template_mode ();
202   }
205   /*! \brief  Queues a set of users for password changes
206    */ 
207   function changePassword($action="",$target=array(),$all=array())
208   {
209     $this->dn ="";
210     $this->pwd_change_queue = $target;
212     // Check permisions
213     $disallowed = array();
214     foreach($this->pwd_change_queue as $key => $dn){
215       if(!preg_match("/w/",$this->ui->get_permissions($dn,$this->aclCategory."/password"))){
216         unset($this->pwd_change_queue[$key]);
217         $disallowed[] = $dn; 
218       }
219     }
220     if(count($disallowed)){
221       msg_dialog::display(_("Permission"),msgPool::permModify($disallowed),INFO_DIALOG);
222     }
224     // Now display change dialog.
225     return($this->handlePasswordQueue()); 
226   }
229   function handlePasswordQueue()
230   {
231     $smarty = get_smarty();
233     // Get next entry from queue.
234     if(empty($this->dn) && count($this->pwd_change_queue)){
235       $this->dn = array_pop($this->pwd_change_queue);
236       set_object_info($this->dn);
237       return ($smarty->fetch(get_template_path('password.tpl', TRUE)));
238     }
240     // Check permissions
241     $dn  = $this->dn;
242     $acl = $this->ui->get_permissions($dn, "users/password");
243     $cacl= $this->ui->get_permissions($dn, "users/user");
244     if (preg_match('/w/', $acl) || preg_match('/c/', $cacl)){
245       $message= array();
246       if ($_POST['new_password'] != $_POST['repeated_password']){
247         $message[]= _("The passwords you've entered as 'New password' and 'Repeated new password' do not match.");
248       } else {
249         if ($_POST['new_password'] == ""){
250           $message[] = msgPool::required(_("New password"));
251         }
252       }
254       // Display errors
255       if (count($message) != 0){
256         msg_dialog::displayChecks($message);
257         return($smarty->fetch(get_template_path('password.tpl', TRUE)));
258       }
260       // Change cassword 
261       if(isset($this->force_hash_type[$this->dn])){
262         if(!change_password ($this->dn, $_POST['new_password'],0,$this->force_hash_type[$this->dn])){
263           return($smarty->fetch(get_template_path('password.tpl', TRUE)));
264         }
265       }else{
266         if(!change_password ($this->dn, $_POST['new_password'])){
267           return($smarty->fetch(get_template_path('password.tpl', TRUE)));
268         }
269       }
270       if ($this->config->get_cfg_value("passwordHook") != ""){
271         exec($this->config->get_cfg_value("passwordHook")." ".$username." ".$_POST['new_password'], $resarr);
272       }
273       new log("modify","users/".get_class($this),$this->dn,array(),"Password has been changed");
274       $this->dn ="";
275       
276     } else {
277       msg_dialog::display(_("Password change"),
278           _("You have no permission to change this users password!"),
279           WARNING_DIALOG);
280     }
282     // Cleanup
283     if(!count($this->pwd_change_queue)){
284       $this->remove_lock();
285       $this->closeDialogs();
286     }else{
287       return($this->handlePasswordQueue());
288     }
289   }
292   /*! \brief  Save user modifications. 
293    *          Whenever we save a 'new' user, request a password change for him.
294    */ 
295   function saveChanges()
296   {
297     $str = management::saveChanges();
298   
299     if(!empty($str)) return($str);
301     if($this->last_tabObject instanceOf multi_plug){
302       foreach($this->last_tabObject->a_handles as $user){
303         if($user->password_change_needed()){
304           $this->force_hash_type[$user->dn] = $user->by_object['user']->pw_storage;
305           $this->pwd_change_queue[] = $user->dn;
306         }
307       }
308       return($this->handlePasswordQueue());
309     }
311     if(isset($this->last_tabObject->by_object['user']) && $this->last_tabObject->by_object['user']->password_change_needed()){
312       $this->force_hash_type[$this->last_tabObject->dn] = $this->last_tabObject->by_object['user']->pw_storage;
313       $this->pwd_change_queue[] = $this->last_tabObject->dn;
314       return($this->handlePasswordQueue());
315     }
316   }
318   function cancelEdit()
319   {
320     $str = management::cancelEdit();
321     if(!empty($str)) return($str);
323     if(isset($this->last_tabObject->by_object['user']) && 
324         $this->last_tabObject->by_object['user']->dn != "new" &&  
325         $this->last_tabObject->by_object['user']->password_change_needed()){
326       $this->force_hash_type[$this->last_tabObject->dn] = $this->last_tabObject->by_object['user']->pw_storage;
327       $this->pwd_change_queue[] = $this->last_tabObject->dn;
328       return($this->handlePasswordQueue());
329     }
330   }
333   /*! \brief  Intiates user creation. 
334    *          If we've user templates, then the user will be asked to use to use one. 
335    *          -> See 'templateContinue' for further handling.
336    */ 
337   function newUserFromTemplate($action="",$target=array(),$all=array())
338   {
339     // Call parent method, it knows whats to do, locking and so on ...
340     $str = management::newEntry($action,$target,$all);
341     if(!empty($str)) return($str);
343     // Reset uid selection.
344     $this->got_uid= "";
346     // Use template if there are any of them 
347     $templates = array();
348     $templates['none']= _("none");
349     $templates = array_merge($templates,$this->get_templates());
351     // We've templates, so preset the current template and display the input dialog.
352     if (count($templates)){
353       $smarty = get_smarty();
354       foreach(array("sn", "givenName", "uid", "got_uid") as $attr){
355         $smarty->assign("$attr", "");
356       }
357       $smarty->assign("template",  array_pop($target));
358       $smarty->assign("templates", $templates);
359       $smarty->assign("edit_uid", "");
360       return($smarty->fetch(get_template_path('template.tpl', TRUE)));
362       // -> See 'templateContinue' for further handling!
363     }
364   }
368   /*! \brief  Intiates user creation. 
369    *          If we've user templates, then the user will be asked 
370    *           if he wants to use one. 
371    *          -> See 'templateContinue' for further handling.
372    */ 
373   function newEntry($action="",$target=array(),$all=array(), $altTabClass ="", $altTabType = "", $altAclCategory="")
374   {
375   
376     // Call parent method, it manages everything, locking, object creation...
377     $str = management::newEntry($action,$target,$all);
378     if(!empty($str)) return($str);
379     
380     // If we've at least one template, then ask the user if he wants to use one?
381     $templates = array();
382     $templates['none']= _("none");
383     $templates = array_merge($templates,$this->get_templates());
385     // Display template selection
386     if (count($templates) > 1){
387       $smarty = get_smarty();
388   
389       // Set default variables, normally empty.
390       foreach(array("sn", "givenName", "uid", "got_uid") as $attr){
391         $smarty->assign($attr, "");
392       }
393       $smarty->assign("template", "none");
394       $smarty->assign("templates", $templates);
395       $smarty->assign("edit_uid", "");
396       return($smarty->fetch(get_template_path('template.tpl', TRUE)));
398       // -> See 'templateContinue' for further handling!
399     }
400   }
403   /* !\brief  This method is called whenever a template selection was displayed.
404    *          Here we act on the use selection. 
405    *          - Does the user want to create a user from template?
406    *          - Create user without template?
407    *          - Input correct, every value given and valid? 
408    */ 
409   function templateContinue()
410   {
411     // Get the list of available templates.
412     $templates = array();
413     $templates['none']= _("none");
414     $templates = array_merge($templates,$this->get_templates());
416     // Input validation, if someone wants to create a user from a template
417     //  then validate the given values.
418     $message = array();
419     if(!isset($_POST['template']) || (empty($_POST['template']))){
420       $message[]= msgPool::invalid(_("Template"));
421     }
422     if(!isset($_POST['sn']) || (empty($_POST['sn']))){
423       $message[]= msgPool::required(_("Name"));
424     }
425     if(!isset($_POST['givenName']) || (empty($_POST['givenName']))){
426       $message[]= msgPool::required(_("Given name"));
427     }
429     /********************
430      * 1   We've had input errors - Display errors and show input dialog again. 
431      ********************/
433     if (count($message) > 0){
434       msg_dialog::displayChecks($message);
436       // Preset input fields with user input. 
437       $smarty = get_smarty();
438       foreach(array("sn", "givenName", "uid", "template") as $attr){
439         if(isset($_POST[$attr])){
440           $smarty->assign("$attr", get_post($attr));
441         }else{
442           $smarty->assign("$attr", "");
443         }
444       }
446       $smarty->assign("templates",$templates);
447       $smarty->assign("got_uid", $this->got_uid);
448       $smarty->assign("edit_uid",false);
449       return($smarty->fetch(get_template_path('template.tpl', TRUE)));
450     }
453     /********************
454      * 2   There was a template selected, now ask for the uid.
455      ********************/
457     if ($_POST['template'] != 'none' && !isset($_POST['uid'])){
459       // Remember user input.
460       $smarty = get_smarty();
461       $this->sn             = $_POST['sn'];
462       $this->givenName      = $_POST['givenName'];
464       // Avoid duplicate entries, check if such a user already exists.
465       $dn= preg_replace("/^[^,]+,/i", "", $_POST['template']);
466       $ldap= $this->config->get_ldap_link();
467       $ldap->cd ($dn);
468       $ldap->search ("(&(sn=".normalizeLdap($this->sn).")(givenName=".normalizeLdap($this->givenName)."))", array("givenName"));
469       if ($ldap->count () != 0){
470         msg_dialog::displayChecks(array(msgPool::duplicated(_("Name"))));
471       }else{
473         // Preset uid field by using the idGenerator 
474         $attributes= array('sn' => $this->sn, 'givenName' => $this->givenName);
475         if ($this->config->get_cfg_value("idGenerator") != ""){
476           $uids= gen_uids ($this->config->get_cfg_value("idGenerator"), $attributes);
477           if (count($uids)){
478             $smarty->assign("edit_uid", "false");
479             $smarty->assign("uids", $uids);
480             $this->uid= current($uids);
481           }
482         } else {
483           $smarty->assign("edit_uid", "");
484           $this->uid= "";
485         }
486         $this->got_uid= true;
487       }
489       // Assign user input 
490       foreach(array("sn", "givenName", "uid", "got_uid") as $attr){
491         $smarty->assign("$attr", $this->$attr);
492       }
493       if (isset($_POST['template'])){
494         $smarty->assign("template", $_POST['template']);
495       }
496       $smarty->assign("templates",$templates); 
497       return($smarty->fetch(get_template_path('template.tpl', TRUE)));
498     }
501     /********************
502      * 3   No template - Ok. Lets fill the data into the user object and skip templating here. 
503      ********************/
504     if ($_POST['template'] == 'none'){
505       foreach(array("sn", "givenName", "uid") as $attr){
506         if (isset($_POST[$attr])){
507           $this->tabObject->by_object['user']->$attr= $_POST[$attr];
508         }
509       }
510       
511       // The user Tab object is already instantiated, so just go back and let the 
512       //  management class do the rest.
513       return("");
514     }
517     /********************
518      * 4   Template selected and uid given - Ok, then lets adapt tempalte values. 
519      ********************/
520     if(isset($_POST['uid'])){
522       // Move user supplied data to sub plugins 
523       foreach(array("uid","sn","givenName") as $attr){
524         $this->$attr = $_POST[$attr];
525         $this->tabObject->$attr       = $this->$attr;
526         $this->tabObject->by_object['user']->$attr = $this->$attr;
527       }
529       // Adapt template values.
530       $template_dn              = $_POST['template'];
531       $this->tabObject->adapt_from_template($template_dn, array("uid","cn","givenName","sn"));
532       $template_base            = preg_replace("/^[^,]+,".preg_quote(get_people_ou(), '/i')."/", '', $template_dn);
533       $this->tabObject->by_object['user']->base= $template_base;
535       // The user Tab object is already instantiated, so just go back and let the 
536       //  management class do the rest.
537       return("");
538     }
539   }
542   /* !\brief  This method applies a template to a set of users.
543    */ 
544   function templatizeUsers($action="",$target=array(),$all=array())
545   {
546     $this->dns = array();
547     if(count($target)){
549       // Get the list of available templates.
550       $templates = $this->get_templates();
552       // Check entry locking
553       foreach($target as $dn){
554         if (($user= get_lock($dn)) != ""){
555           $this->dn = $dn;
556           return(gen_locked_message ($user, $dn));
557         }
558         $this->dns[] = $dn;
559       }
560           
561       // Display template
562       $smarty = get_smarty();
563       $smarty->assign("templates", $templates);
564       return($smarty->fetch(get_template_path('templatize.tpl', TRUE)));
565     }
566   }
569   /* !\brief  This method is called whenever the templatize dialog was used.
570    */ 
571   function templatizeContinue()
572   {
573     // Template readable? 
574     $template= get_post('template');
575     $acl = $this->ui->get_permissions($template, $this->aclCategory."/".$this->aclPlugin);
576     if (preg_match('/r/', $acl)){
577       $tab = $this->tabClass;
578       foreach ($this->dns as $dn){
580         // User writeable
581         $acl = $this->ui->get_permissions($dn,  $this->aclCategory."/".$this->aclPlugin);
582         if (preg_match('/w/', $acl)){
583           $this->tabObject= new $tab($this->config, $this->config->data['TABS'][$this->tabType], $dn, $this->aclCategory);
584           $this->tabObject->adapt_from_template($template, array("sn", "givenName", "uid"));
585           $this->tabObject->save();
586         } else {
587           msg_dialog::display(_("Permission error"), msgPool::permModify($dn), ERROR_DIALOG);
588         }
589       }
590     } else {
591       msg_dialog::display(_("Permission error"), msgPool::permView($template), ERROR_DIALOG);
592     }
594     // Cleanup!
595     $this->remove_lock(); 
596     $this->closeDialogs();
597   }
600   /* !\brief  Lock/unlock multiple users.
601    */ 
602   function lockUsers($action,$target,$all)
603   {
604     if(!count($target)) return;
605     if($action == "lockUsers"){
606       $this->lockEntry($action,$target, $all, "lock");
607     }else{
608       $this->lockEntry($action,$target, $all, "unlock");
609     }
610   }
612   
613   /* !\brief  Locks/unlocks the given user(s).
614    */ 
615   function lockEntry($action,$entry, $all, $type = "toggle")
616   {
617     
618     // Filter out entries we are not allowed to modify
619     $disallowed = array();
620     $dns = array();
621     foreach($entry as $dn){
622       if (!preg_match("/w/",$this->ui->get_permissions($dn,"users/password"))){
623         $disallowed[] = $dn;
624       }else{
625         $allowed[] = $dn;
626       }
627     }
628     if(count($disallowed)){
629       msg_dialog::display(_("Permission"),msgPool::permDelete($disallowed),INFO_DIALOG);
630     }
632     // Try to lock/unlock the rest of the entries.
633     $ldap = $this->config->get_ldap_link();
634     foreach($allowed as $dn){
635       $ldap->cat($dn, array('userPassword'));
636       if($ldap->count() == 1){
638         // We can't lock empty passwords.
639         $val = $ldap->fetch();
640         if(!isset($val['userPassword'])){
641           continue;
642         }
644         // Detect the password method and try to lock/unlock.
645         $pwd = $val['userPassword'][0];
646         $method = passwordMethod::get_method($pwd,$val['dn']);
647         $success= true;
648         if($method instanceOf passwordMethod){
649           if($type == "toggle"){
650             if($method->is_locked($this->config,$val['dn'])){
651               $success= $method->unlock_account($this->config,$val['dn']);
652             }else{
653               $success= $method->lock_account($this->config,$val['dn']);
654             }
655           }elseif($type == "lock" && !$method->is_locked($this->config,$val['dn'])){
656             $success= $method->lock_account($this->config,$val['dn']);
657           }elseif($type == "unlock" && $method->is_locked($this->config,$val['dn'])){
658             $success= $method->unlock_account($this->config,$val['dn']);
659           }
661           // Check if everything went fine.
662           if (!$success){
663             $hn= $method->get_hash_name();
664             if (is_array($hn)){
665               $hn= $hn[0];
666             }
667             msg_dialog::display(_("Account locking"),
668                 sprintf(_("Password method '%s' does not support locking. Account (%s) has not been locked!"), 
669                   $hn,$dn),WARNING_DIALOG);
670           }
671         }else{
672           // Can't lock unknown methods.
673         }
674       }
675     }
676   }
679   /* !\brief  This method returns a list of all available templates.
680    */ 
681   function get_templates()
682   {
683     $templates= array();
684     $ldap= $this->config->get_ldap_link();
685     foreach ($this->config->departments as $key => $value){
686       $acl = $this->ui->get_permissions($value,$this->aclCategory."/".$this->aclPlugin);
687       if (preg_match("/c/",$acl)){
689         // Search all templates from the current dn.
690         $ldap->cd (get_people_ou().$value);
691         $ldap->search ("(objectClass=gosaUserTemplate)", array("uid"));
692         if ($ldap->count() != 0){
693           while ($attrs= $ldap->fetch()){
694             $templates[$ldap->getDN()]= $attrs['uid'][0]." - ".LDAP::fix($key);
695           }
696         }
697       }
698     }
699     natcasesort ($templates);
700     reset ($templates);
701     return($templates);
702   }
705   function copyPasteHandler($action="",$target=array(),$all=array(),
706       $altTabClass ="", $altTabType = "", $altAclCategory="",$altAclPlugin="")
707   {
708     if ($this->config->boolValueIsTrue("main", "copyPaste")){
709       $this->cpHandler->lastdn = "";
710       $str = management::copyPasteHandler($action,$target,$all);
711       if($this->cpHandler->lastdn != "" && isset($_POST['passwordTodo']) && $_POST['passwordTodo'] == "new"){
712         $this->pwd_change_queue[] = $this->cpHandler->lastdn;
713         return($this->handlePasswordQueue());
714       }
715       return($str);
716     }
718     return "";
719   }
722   static function filterLockImage($userPassword)
723   {
724     $image= "images/empty.png";
725     if(isset($userPassword[0]) && preg_match("/^\{[^\}]/",$userPassword[0])){
726       if(preg_match("/^[^\}]*+\}!/",$userPassword[0])){
727         $image= "images/lists/locked.png";
728       }else{
729         $image= "images/lists/unlocked.png";
730       }
731     }
732     return $image;
733   }
736   static function filterLockLabel($userPassword)
737   {
738     $label= "";
739     if(isset($userPassword[0]) && preg_match("/^\{[^\}]/",$userPassword[0])){
740       if(preg_match("/^[^\}]*+\}!/",$userPassword[0])){
741         $label= _("Unlock account")."<rowClass:entry-locked/>";
742       }else{
743         $label= _("Lock account");
744       }
745     }
746     return $label;
747   }
750   static function filterProperties($row, $classes)
751   {
752     $result= "";
753     $map= array( "gosaAccount" => array( "image" => "plugins/users/images/select_user.png",
754                                          "plugin" => "user",
755                                          "alt" => _("Generic"),
756                                          "title" => _("Edit generic properties")),
757                  "posixAccount" => array("image" => "images/penguin.png",
758                                          "plugin" => "posixAccount",
759                                          "alt" => _("POSIX"),
760                                          "title" => _("Edit POSIX properties")),
761                  "gosaMailAccount" => array("image" => "images/mailto.png",
762                                          "alt" => _("Mail"),
763                                          "plugin" => "mailAccount",
764                                          "title" => _("Edit mail properties")),
765                  "sambaSamAccount" => array("image" => "plugins/systems/images/select_winstation.png",
766                                          "plugin" => "sambaAccount",
767                                          "alt" => _("Samba"),
768                                          "title" => _("Edit samba properties")),
769                  "apple-user" => array("image" => "plugins/netatalk/images/select_netatalk.png",
770                                          "plugin" => "netatalk",
771                                          "alt" => _("Netatalk"),
772                                          "title" => _("Edit netatalk properties")),
773                  "gotoEnvironment" => array("image" => "plugins/users/images/small_environment.png",
774                                          "plugin" => "environment",
775                                          "alt" => _("Environment"),
776                                          "title" => _("Edit environment properties")),
777                  "goFaxAccount" => array("image" => "plugins/users/images/fax_small.png",
778                                          "plugin" => "gofaxAccount",
779                                          "alt" => _("FAX"),
780                                          "title" => _("Edit FAX properties")),
781                  "goFonAccount" => array("image" => "plugins/gofon/images/select_phone.png",
782                                          "plugin" => "phoneAccount",
783                                          "alt" => _("Phone"),
784                                          "title" => _("Edit phone properties")));
786     // Walk thru map
787     foreach ($map as $oc => $properties) {
788       if (in_array_ics($oc, $classes)) {
789         $result.= image($properties['image'], "listing_edit_".$properties['plugin']."_$row", $properties['title']);
790       } else {
791         $result.= image('images/empty.png');
792       }
793     }
794     return $result;
795   }
797
798 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
799 ?>