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 users";
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 protected $releaseSelector = NULL;
47 function __construct($config,$ui)
48 {
49 $this->config = $config;
50 $this->ui = $ui;
52 $this->storagePoints = array(get_ou("userRDN"));
54 // Build filter
55 if (session::global_is_set(get_class($this)."_filter")){
56 $filter= session::global_get(get_class($this)."_filter");
57 } else {
58 $filter = new filter(get_template_path("user-filter.xml", true));
59 $filter->setObjectStorage($this->storagePoints);
60 }
61 $this->setFilter($filter);
63 // Build headpage
64 $headpage = new listing(get_template_path("user-list.xml", true));
65 $headpage->registerElementFilter("lockLabel", "userManagement::filterLockLabel");
66 $headpage->registerElementFilter("lockImage", "userManagement::filterLockImage");
67 $headpage->registerElementFilter("filterProperties", "userManagement::filterProperties");
68 $headpage->setFilter($filter);
70 // Add copy&paste and snapshot handler.
71 if ($this->config->boolValueIsTrue("main", "copyPaste")){
72 $this->cpHandler = new CopyPasteHandler($this->config);
73 }
74 if($this->config->get_cfg_value("enableSnapshots") == "true"){
75 $this->snapHandler = new SnapshotHandler($this->config);
76 }
78 parent::__construct($config, $ui, "users", $headpage);
80 // Register special user actions
81 $this->registerAction("lock", "lockEntry");
82 $this->registerAction("lockUsers", "lockUsers");
83 $this->registerAction("unlockUsers", "lockUsers");
84 $this->registerAction("new_template", "newTemplate");
85 $this->registerAction("newfromtpl", "newUserFromTemplate");
86 $this->registerAction("templateContinue", "templateContinue");
87 $this->registerAction("templatize", "templatizeUsers");
88 $this->registerAction("templatizeContinue", "templatizeContinue");
90 $this->registerAction("password", "changePassword");
91 $this->registerAction("passwordQueue", "handlePasswordQueue");
92 $this->registerAction("passwordCancel", "closeDialogs");
94 $this->registerAction("sendMessage", "sendMessage");
95 $this->registerAction("saveEventDialog", "saveEventDialog");
96 $this->registerAction("abortEventDialog", "closeDialogs");
98 // Register shortcut icon actions
99 $this->registerAction("edit_user","editEntry");
100 $this->registerAction("edit_posixAccount","editEntry");
101 $this->registerAction("edit_mailAccount","editEntry");
102 $this->registerAction("edit_sambaAccount","editEntry");
103 $this->registerAction("edit_netatalk","editEntry");
104 $this->registerAction("edit_environment","editEntry");
105 $this->registerAction("edit_gofaxAccount","editEntry");
106 $this->registerAction("edit_phoneAccount","editEntry");
109 $rel = array("a" => "/");
110 $rel['b,a'] = "test";
111 $rel['c,a'] = "test/f";
113 $this->releaseSelector = new releaseSelector($rel, "a");
114 }
117 function renderList()
118 {
119 $smarty = get_smarty();
120 $smarty->assign("RELEASE", $this->releaseSelector->render());
121 return(management::renderList());
122 }
126 // Inject user actions
127 function detectPostActions()
128 {
129 $action = management::detectPostActions();
130 if(isset($_POST['template_continue'])) $action['action'] = "templateContinue";
131 if(isset($_POST['templatize_continue'])) $action['action'] = "templatizeContinue";
132 if(isset($_POST['save_event_dialog'])) $action['action'] = "saveEventDialog";
133 if(isset($_POST['abort_event_dialog'])) $action['action'] = "abortEventDialog";
134 if(isset($_POST['password_cancel'])){
135 $action['action'] = "passwordCancel";
136 }elseif((count($this->pwd_change_queue) || isset($_POST['password_finish']))){
137 $action['action'] = "passwordQueue";
138 }
139 return($action);
140 }
143 function editEntry($action="",$target=array(),$all=array(), $altTabClass ="", $altTabType = "", $altAclCategory="")
144 {
145 $str = management::editEntry($action,$target);
146 if($str) return($str);
148 if(preg_match("/^edit_/",$action)){
149 $tab = preg_replace("/^edit_/","",$action);
150 if(isset($this->tabObject->by_object[$tab])){
151 $this->tabObject->current = $tab;
152 }else{
153 trigger_error("Unknown tab: ".$tab);
154 }
155 }
156 }
159 function closeDialogs()
160 {
161 management::closeDialogs();
162 $this->pwd_change_queue = array();
163 }
166 /*! \brief Sends a message to a set of users using gosa-si events.
167 */
168 function sendMessage($action="",$target=array(),$all=array())
169 {
170 if(class_available("DaemonEvent")){
171 $uids = array();
172 $ldap = $this->config->get_ldap_link();
173 $ldap->cd($this->config->current['BASE']);
174 foreach($target as $dn){
175 $ldap->cat($dn,array('uid'));
176 $attrs = $ldap->fetch();
177 if(isset($attrs['uid'][0])){
178 $uids[] = $attrs['uid'][0];
179 }
180 }
181 if(count($uids)){
182 $events = DaemonEvent::get_event_types(USER_EVENT);
183 $event = "DaemonEvent_notify";
184 if(isset($events['BY_CLASS'][$event])){
185 $type = $events['BY_CLASS'][$event];
186 $this->dialogObject = new $type['CLASS_NAME']($this->config);
187 $this->dialogObject->add_users($uids);
188 $this->dialogObject->set_type(SCHEDULED_EVENT);
189 }
190 }
191 }
192 }
195 /*! \brief Sends a message to a set of users using gosa-si events.
196 */
197 function saveEventDialog()
198 {
199 $this->dialogObject->save_object();
200 $msgs = $this->dialogObject->check();
201 if(count($msgs)){
202 msg_dialog::displayChecks($msgs);
203 }else{
204 $o_queue = new gosaSupportDaemon();
205 $o_queue->append($this->dialogObject);
206 if($o_queue->is_error()){
207 msg_dialog::display(_("Infrastructure error"), msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
208 }
209 $this->closeDialogs();
210 }
211 }
214 /*! \brief Intiates template creation.
215 */
216 function newTemplate($action,$entry)
217 {
218 $this->newEntry();
219 $this->tabObject->set_template_mode ();
220 }
223 /*! \brief Queues a set of users for password changes
224 */
225 function changePassword($action="",$target=array(),$all=array())
226 {
227 $this->dn ="";
228 $this->pwd_change_queue = $target;
230 // Check permisions
231 $disallowed = array();
232 foreach($this->pwd_change_queue as $key => $dn){
233 if(!preg_match("/w/",$this->ui->get_permissions($dn,$this->aclCategory."/password"))){
234 unset($this->pwd_change_queue[$key]);
235 $disallowed[] = $dn;
236 }
237 }
238 if(count($disallowed)){
239 msg_dialog::display(_("Permission"),msgPool::permModify($disallowed),INFO_DIALOG);
240 }
242 // Now display change dialog.
243 return($this->handlePasswordQueue());
244 }
247 function handlePasswordQueue()
248 {
249 $smarty = get_smarty();
251 // Get next entry from queue.
252 if(empty($this->dn) && count($this->pwd_change_queue)){
253 $this->dn = array_pop($this->pwd_change_queue);
254 set_object_info($this->dn);
255 return ($smarty->fetch(get_template_path('password.tpl', TRUE)));
256 }
258 // Check permissions
259 $dn = $this->dn;
260 $acl = $this->ui->get_permissions($dn, "users/password");
261 $cacl= $this->ui->get_permissions($dn, "users/user");
262 if (preg_match('/w/', $acl) || preg_match('/c/', $cacl)){
263 $message= array();
264 if ($_POST['new_password'] != $_POST['repeated_password']){
265 $message[]= _("The passwords you've entered as 'New password' and 'Repeated new password' do not match.");
266 } else {
267 if ($_POST['new_password'] == ""){
268 $message[] = msgPool::required(_("New password"));
269 }
270 }
272 // Display errors
273 if (count($message) != 0){
274 msg_dialog::displayChecks($message);
275 return($smarty->fetch(get_template_path('password.tpl', TRUE)));
276 }
278 // Change cassword
279 if(isset($this->force_hash_type[$this->dn])){
280 if(!change_password ($this->dn, $_POST['new_password'],0,$this->force_hash_type[$this->dn])){
281 return($smarty->fetch(get_template_path('password.tpl', TRUE)));
282 }
283 }else{
284 if(!change_password ($this->dn, $_POST['new_password'])){
285 return($smarty->fetch(get_template_path('password.tpl', TRUE)));
286 }
287 }
288 if ($this->config->get_cfg_value("passwordHook") != ""){
289 exec($this->config->get_cfg_value("passwordHook")." ".$username." ".$_POST['new_password'], $resarr);
290 }
291 new log("modify","users/".get_class($this),$this->dn,array(),"Password has been changed");
292 $this->dn ="";
294 } else {
295 msg_dialog::display(_("Password change"),
296 _("You have no permission to change this users password!"),
297 WARNING_DIALOG);
298 }
300 // Cleanup
301 if(!count($this->pwd_change_queue)){
302 $this->remove_lock();
303 $this->closeDialogs();
304 }else{
305 return($this->handlePasswordQueue());
306 }
307 }
310 /*! \brief Save user modifications.
311 * Whenever we save a 'new' user, request a password change for him.
312 */
313 function saveChanges()
314 {
315 $str = management::saveChanges();
317 if(!empty($str)) return($str);
319 if($this->last_tabObject instanceOf multi_plug){
320 foreach($this->last_tabObject->a_handles as $user){
321 if($user->password_change_needed()){
322 $this->force_hash_type[$user->dn] = $user->by_object['user']->pw_storage;
323 $this->pwd_change_queue[] = $user->dn;
324 }
325 }
326 return($this->handlePasswordQueue());
327 }
329 if(isset($this->last_tabObject->by_object['user']) && $this->last_tabObject->by_object['user']->password_change_needed()){
330 $this->force_hash_type[$this->last_tabObject->dn] = $this->last_tabObject->by_object['user']->pw_storage;
331 $this->pwd_change_queue[] = $this->last_tabObject->dn;
332 return($this->handlePasswordQueue());
333 }
334 }
336 function cancelEdit()
337 {
338 $str = management::cancelEdit();
339 if(!empty($str)) return($str);
341 if(isset($this->last_tabObject->by_object['user']) &&
342 $this->last_tabObject->by_object['user']->dn != "new" &&
343 $this->last_tabObject->by_object['user']->password_change_needed()){
344 $this->force_hash_type[$this->last_tabObject->dn] = $this->last_tabObject->by_object['user']->pw_storage;
345 $this->pwd_change_queue[] = $this->last_tabObject->dn;
346 return($this->handlePasswordQueue());
347 }
348 }
351 /*! \brief Intiates user creation.
352 * If we've user templates, then the user will be asked to use to use one.
353 * -> See 'templateContinue' for further handling.
354 */
355 function newUserFromTemplate($action="",$target=array(),$all=array())
356 {
357 // Call parent method, it knows whats to do, locking and so on ...
358 $str = management::newEntry($action,$target,$all);
359 if(!empty($str)) return($str);
361 // Reset uid selection.
362 $this->got_uid= "";
364 // Use template if there are any of them
365 $templates = array();
366 $templates['none']= _("none");
367 $templates = array_merge($templates,$this->get_templates());
369 // We've templates, so preset the current template and display the input dialog.
370 if (count($templates)){
371 $smarty = get_smarty();
372 foreach(array("sn", "givenName", "uid", "got_uid") as $attr){
373 $smarty->assign("$attr", "");
374 }
375 $smarty->assign("template", array_pop($target));
376 $smarty->assign("templates", $templates);
377 $smarty->assign("edit_uid", "");
378 return($smarty->fetch(get_template_path('template.tpl', TRUE)));
380 // -> See 'templateContinue' for further handling!
381 }
382 }
386 /*! \brief Intiates user creation.
387 * If we've user templates, then the user will be asked
388 * if he wants to use one.
389 * -> See 'templateContinue' for further handling.
390 */
391 function newEntry($action="",$target=array(),$all=array(), $altTabClass ="", $altTabType = "", $altAclCategory="")
392 {
394 // Call parent method, it manages everything, locking, object creation...
395 $str = management::newEntry($action,$target,$all);
396 if(!empty($str)) return($str);
398 // If we've at least one template, then ask the user if he wants to use one?
399 $templates = array();
400 $templates['none']= _("none");
401 $templates = array_merge($templates,$this->get_templates());
403 // Display template selection
404 if (count($templates) > 1){
405 $smarty = get_smarty();
407 // Set default variables, normally empty.
408 foreach(array("sn", "givenName", "uid", "got_uid") as $attr){
409 $smarty->assign($attr, "");
410 }
411 $smarty->assign("template", "none");
412 $smarty->assign("templates", $templates);
413 $smarty->assign("edit_uid", "");
414 return($smarty->fetch(get_template_path('template.tpl', TRUE)));
416 // -> See 'templateContinue' for further handling!
417 }
418 }
421 /* !\brief This method is called whenever a template selection was displayed.
422 * Here we act on the use selection.
423 * - Does the user want to create a user from template?
424 * - Create user without template?
425 * - Input correct, every value given and valid?
426 */
427 function templateContinue()
428 {
429 // Get the list of available templates.
430 $templates = array();
431 $templates['none']= _("none");
432 $templates = array_merge($templates,$this->get_templates());
434 // Input validation, if someone wants to create a user from a template
435 // then validate the given values.
436 $message = array();
437 if(!isset($_POST['template']) || (empty($_POST['template']))){
438 $message[]= msgPool::invalid(_("Template"));
439 }
440 if(!isset($_POST['sn']) || (empty($_POST['sn']))){
441 $message[]= msgPool::required(_("Name"));
442 }
443 if(!isset($_POST['givenName']) || (empty($_POST['givenName']))){
444 $message[]= msgPool::required(_("Given name"));
445 }
447 /********************
448 * 1 We've had input errors - Display errors and show input dialog again.
449 ********************/
451 if (count($message) > 0){
452 msg_dialog::displayChecks($message);
454 // Preset input fields with user input.
455 $smarty = get_smarty();
456 foreach(array("sn", "givenName", "uid", "template") as $attr){
457 if(isset($_POST[$attr])){
458 $smarty->assign("$attr", get_post($attr));
459 }else{
460 $smarty->assign("$attr", "");
461 }
462 }
464 $smarty->assign("templates",$templates);
465 $smarty->assign("got_uid", $this->got_uid);
466 $smarty->assign("edit_uid",false);
467 return($smarty->fetch(get_template_path('template.tpl', TRUE)));
468 }
471 /********************
472 * 2 There was a template selected, now ask for the uid.
473 ********************/
475 if ($_POST['template'] != 'none' && !isset($_POST['uid'])){
477 // Remember user input.
478 $smarty = get_smarty();
479 $this->sn = $_POST['sn'];
480 $this->givenName = $_POST['givenName'];
482 // Avoid duplicate entries, check if such a user already exists.
483 $dn= preg_replace("/^[^,]+,/i", "", $_POST['template']);
484 $ldap= $this->config->get_ldap_link();
485 $ldap->cd ($dn);
486 $ldap->search ("(&(sn=".normalizeLdap($this->sn).")(givenName=".normalizeLdap($this->givenName)."))", array("givenName"));
487 if ($ldap->count () != 0){
488 msg_dialog::displayChecks(array(msgPool::duplicated(_("Name"))));
489 }else{
491 // Preset uid field by using the idGenerator
492 $attributes= array('sn' => $this->sn, 'givenName' => $this->givenName);
493 if ($this->config->get_cfg_value("idGenerator") != ""){
494 $uids= gen_uids ($this->config->get_cfg_value("idGenerator"), $attributes);
495 if (count($uids)){
496 $smarty->assign("edit_uid", "false");
497 $smarty->assign("uids", $uids);
498 $this->uid= current($uids);
499 }
500 } else {
501 $smarty->assign("edit_uid", "");
502 $this->uid= "";
503 }
504 $this->got_uid= true;
505 }
507 // Assign user input
508 foreach(array("sn", "givenName", "uid", "got_uid") as $attr){
509 $smarty->assign("$attr", $this->$attr);
510 }
511 if (isset($_POST['template'])){
512 $smarty->assign("template", $_POST['template']);
513 }
514 $smarty->assign("templates",$templates);
515 return($smarty->fetch(get_template_path('template.tpl', TRUE)));
516 }
519 /********************
520 * 3 No template - Ok. Lets fill the data into the user object and skip templating here.
521 ********************/
522 if ($_POST['template'] == 'none'){
523 foreach(array("sn", "givenName", "uid") as $attr){
524 if (isset($_POST[$attr])){
525 $this->tabObject->by_object['user']->$attr= $_POST[$attr];
526 }
527 }
529 // The user Tab object is already instantiated, so just go back and let the
530 // management class do the rest.
531 return("");
532 }
535 /********************
536 * 4 Template selected and uid given - Ok, then lets adapt tempalte values.
537 ********************/
538 if(isset($_POST['uid'])){
540 // Move user supplied data to sub plugins
541 foreach(array("uid","sn","givenName") as $attr){
542 $this->$attr = $_POST[$attr];
543 $this->tabObject->$attr = $this->$attr;
544 $this->tabObject->by_object['user']->$attr = $this->$attr;
545 }
547 // Adapt template values.
548 $template_dn = $_POST['template'];
549 $this->tabObject->adapt_from_template($template_dn, array("uid","cn","givenName","sn"));
550 $template_base = preg_replace("/^[^,]+,".preg_quote(get_people_ou(), '/i')."/", '', $template_dn);
551 $this->tabObject->by_object['user']->base= $template_base;
553 // The user Tab object is already instantiated, so just go back and let the
554 // management class do the rest.
555 return("");
556 }
557 }
560 /* !\brief This method applies a template to a set of users.
561 */
562 function templatizeUsers($action="",$target=array(),$all=array())
563 {
564 $this->dns = array();
565 if(count($target)){
567 // Get the list of available templates.
568 $templates = $this->get_templates();
570 // Check entry locking
571 foreach($target as $dn){
572 if (($user= get_lock($dn)) != ""){
573 $this->dn = $dn;
574 return(gen_locked_message ($user, $dn));
575 }
576 $this->dns[] = $dn;
577 }
579 // Display template
580 $smarty = get_smarty();
581 $smarty->assign("templates", $templates);
582 return($smarty->fetch(get_template_path('templatize.tpl', TRUE)));
583 }
584 }
587 /* !\brief This method is called whenever the templatize dialog was used.
588 */
589 function templatizeContinue()
590 {
591 // Template readable?
592 $template= get_post('template');
593 $acl = $this->ui->get_permissions($template, $this->aclCategory."/".$this->aclPlugin);
594 if (preg_match('/r/', $acl)){
595 $tab = $this->tabClass;
596 foreach ($this->dns as $dn){
598 // User writeable
599 $acl = $this->ui->get_permissions($dn, $this->aclCategory."/".$this->aclPlugin);
600 if (preg_match('/w/', $acl)){
601 $this->tabObject= new $tab($this->config, $this->config->data['TABS'][$this->tabType], $dn, $this->aclCategory);
602 $this->tabObject->adapt_from_template($template, array("sn", "givenName", "uid"));
603 $this->tabObject->save();
604 } else {
605 msg_dialog::display(_("Permission error"), msgPool::permModify($dn), ERROR_DIALOG);
606 }
607 }
608 } else {
609 msg_dialog::display(_("Permission error"), msgPool::permView($template), ERROR_DIALOG);
610 }
612 // Cleanup!
613 $this->remove_lock();
614 $this->closeDialogs();
615 }
618 /* !\brief Lock/unlock multiple users.
619 */
620 function lockUsers($action,$target,$all)
621 {
622 if(!count($target)) return;
623 if($action == "lockUsers"){
624 $this->lockEntry($action,$target, $all, "lock");
625 }else{
626 $this->lockEntry($action,$target, $all, "unlock");
627 }
628 }
631 /* !\brief Locks/unlocks the given user(s).
632 */
633 function lockEntry($action,$entry, $all, $type = "toggle")
634 {
636 // Filter out entries we are not allowed to modify
637 $disallowed = array();
638 $dns = array();
639 foreach($entry as $dn){
640 if (!preg_match("/w/",$this->ui->get_permissions($dn,"users/password"))){
641 $disallowed[] = $dn;
642 }else{
643 $allowed[] = $dn;
644 }
645 }
646 if(count($disallowed)){
647 msg_dialog::display(_("Permission"),msgPool::permDelete($disallowed),INFO_DIALOG);
648 }
650 // Try to lock/unlock the rest of the entries.
651 $ldap = $this->config->get_ldap_link();
652 foreach($allowed as $dn){
653 $ldap->cat($dn, array('userPassword'));
654 if($ldap->count() == 1){
656 // We can't lock empty passwords.
657 $val = $ldap->fetch();
658 if(!isset($val['userPassword'])){
659 continue;
660 }
662 // Detect the password method and try to lock/unlock.
663 $pwd = $val['userPassword'][0];
664 $method = passwordMethod::get_method($pwd,$val['dn']);
665 $success= true;
666 if($method instanceOf passwordMethod){
667 if($type == "toggle"){
668 if($method->is_locked($this->config,$val['dn'])){
669 $success= $method->unlock_account($this->config,$val['dn']);
670 }else{
671 $success= $method->lock_account($this->config,$val['dn']);
672 }
673 }elseif($type == "lock" && !$method->is_locked($this->config,$val['dn'])){
674 $success= $method->lock_account($this->config,$val['dn']);
675 }elseif($type == "unlock" && $method->is_locked($this->config,$val['dn'])){
676 $success= $method->unlock_account($this->config,$val['dn']);
677 }
679 // Check if everything went fine.
680 if (!$success){
681 $hn= $method->get_hash_name();
682 if (is_array($hn)){
683 $hn= $hn[0];
684 }
685 msg_dialog::display(_("Account locking"),
686 sprintf(_("Password method '%s' does not support locking. Account (%s) has not been locked!"),
687 $hn,$dn),WARNING_DIALOG);
688 }
689 }else{
690 // Can't lock unknown methods.
691 }
692 }
693 }
694 }
697 /* !\brief This method returns a list of all available templates.
698 */
699 function get_templates()
700 {
701 $templates= array();
702 $ldap= $this->config->get_ldap_link();
703 foreach ($this->config->departments as $key => $value){
704 $acl = $this->ui->get_permissions($value,$this->aclCategory."/".$this->aclPlugin);
705 if (preg_match("/c/",$acl)){
707 // Search all templates from the current dn.
708 $ldap->cd (get_people_ou().$value);
709 $ldap->search ("(objectClass=gosaUserTemplate)", array("uid"));
710 if ($ldap->count() != 0){
711 while ($attrs= $ldap->fetch()){
712 $templates[$ldap->getDN()]= $attrs['uid'][0]." - ".LDAP::fix($key);
713 }
714 }
715 }
716 }
717 natcasesort ($templates);
718 reset ($templates);
719 return($templates);
720 }
723 function copyPasteHandler($action="",$target=array(),$all=array(),
724 $altTabClass ="", $altTabType = "", $altAclCategory="",$altAclPlugin="")
725 {
726 if ($this->config->boolValueIsTrue("main", "copyPaste")){
727 $this->cpHandler->lastdn = "";
728 $str = management::copyPasteHandler($action,$target,$all);
729 if($this->cpHandler->lastdn != "" && isset($_POST['passwordTodo']) && $_POST['passwordTodo'] == "new"){
730 $this->pwd_change_queue[] = $this->cpHandler->lastdn;
731 return($this->handlePasswordQueue());
732 }
733 return($str);
734 }
736 return "";
737 }
740 static function filterLockImage($userPassword)
741 {
742 $image= "images/empty.png";
743 if(isset($userPassword[0]) && preg_match("/^\{[^\}]/",$userPassword[0])){
744 if(preg_match("/^[^\}]*+\}!/",$userPassword[0])){
745 $image= "images/lists/locked.png";
746 }else{
747 $image= "images/lists/unlocked.png";
748 }
749 }
750 return $image;
751 }
754 static function filterLockLabel($userPassword)
755 {
756 $label= "";
757 if(isset($userPassword[0]) && preg_match("/^\{[^\}]/",$userPassword[0])){
758 if(preg_match("/^[^\}]*+\}!/",$userPassword[0])){
759 $label= _("Unlock account");
760 }else{
761 $label= _("Lock account");
762 }
763 }
764 return $label;
765 }
768 static function filterProperties($row, $classes)
769 {
770 $result= "";
771 $map= array( "gosaAccount" => array( "image" => "plugins/users/images/select_user.png",
772 "plugin" => "user",
773 "alt" => _("Generic"),
774 "title" => _("Edit generic properties")),
775 "posixAccount" => array("image" => "images/penguin.png",
776 "plugin" => "posixAccount",
777 "alt" => _("POSIX"),
778 "title" => _("Edit POSIX properties")),
779 "gosaMailAccount" => array("image" => "images/mailto.png",
780 "alt" => _("Mail"),
781 "plugin" => "mailAccount",
782 "title" => _("Edit mail properties")),
783 "sambaSamAccount" => array("image" => "plugins/systems/images/select_winstation.png",
784 "plugin" => "sambaAccount",
785 "alt" => _("Samba"),
786 "title" => _("Edit samba properties")),
787 "apple-user" => array("image" => "plugins/netatalk/images/select_netatalk.png",
788 "plugin" => "netatalk",
789 "alt" => _("Netatalk"),
790 "title" => _("Edit netatalk properties")),
791 "gotoEnvironment" => array("image" => "plugins/users/images/small_environment.png",
792 "plugin" => "environment",
793 "alt" => _("Environment"),
794 "title" => _("Edit environment properties")),
795 "goFaxAccount" => array("image" => "plugins/users/images/fax_small.png",
796 "plugin" => "gofaxAccount",
797 "alt" => _("FAX"),
798 "title" => _("Edit FAX properties")),
799 "goFonAccount" => array("image" => "plugins/gofon/images/select_phone.png",
800 "plugin" => "phoneAccount",
801 "alt" => _("Phone"),
802 "title" => _("Edit phone properties")));
804 // Walk thru map
805 foreach ($map as $oc => $properties) {
806 if (in_array_ics($oc, $classes)) {
807 $result.= image($properties['image'], "listing_edit_".$properties['plugin']."_$row", $properties['title']);
808 } else {
809 $result.= image('images/empty.png');
810 }
811 }
812 return $result;
813 }
815 }
816 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
817 ?>