729a273d8195bc1cdcdc6989c3ef3fc3e9e533fe
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 function __construct($config,$ui)
46 {
47 $this->config = $config;
48 $this->ui = $ui;
50 $this->storagePoints = array(get_ou("userRDN"));
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 }
141 function closeDialogs()
142 {
143 management::closeDialogs();
144 $this->pwd_change_queue = array();
145 }
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 // Get next entry from queue.
232 if(empty($this->dn) && count($this->pwd_change_queue)){
233 $this->dn = array_pop($this->pwd_change_queue);
234 set_object_info($this->dn);
235 $smarty = get_smarty();
236 return ($smarty->fetch(get_template_path('password.tpl', TRUE)));
237 }
239 // Check permissions
240 $dn = $this->dn;
241 $acl = $this->ui->get_permissions($dn, "users/password");
242 $cacl= $this->ui->get_permissions($dn, "users/user");
243 if (preg_match('/w/', $acl) || preg_match('/c/', $cacl)){
244 $message= array();
245 if ($_POST['new_password'] != $_POST['repeated_password']){
246 $message[]= _("The passwords you've entered as 'New password' and 'Repeated new password' do not match.");
247 } else {
248 if ($_POST['new_password'] == ""){
249 $message[] = msgPool::required(_("New password"));
250 }
251 }
253 // Display errors
254 if (count($message) != 0){
255 msg_dialog::displayChecks($message);
256 $smarty = get_smarty();
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 ="";
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 if(!empty($str)) return($str);
300 if(isset($this->last_tabObject->by_object['user']) && $this->last_tabObject->by_object['user']->password_change_needed()){
301 $this->force_hash_type[$this->last_tabObject->dn] = $this->last_tabObject->by_object['user']->pw_storage;
302 $this->pwd_change_queue[] = $this->last_tabObject->dn;
303 return($this->handlePasswordQueue());
304 }
305 }
307 function cancelEdit()
308 {
309 $str = management::cancelEdit();
310 if(!empty($str)) return($str);
312 if(isset($this->last_tabObject->by_object['user']) &&
313 $this->last_tabObject->by_object['user']->dn != "new" &&
314 $this->last_tabObject->by_object['user']->password_change_needed()){
315 $this->force_hash_type[$this->last_tabObject->dn] = $this->last_tabObject->by_object['user']->pw_storage;
316 $this->pwd_change_queue[] = $this->last_tabObject->dn;
317 return($this->handlePasswordQueue());
318 }
319 }
322 /*! \brief Intiates user creation.
323 * If we've user templates, then the user will be asked to use to use one.
324 * -> See 'templateContinue' for further handling.
325 */
326 function newUserFromTemplate($action="",$target=array(),$all=array())
327 {
328 // Call parent method, it knows whats to do, locking and so on ...
329 $str = management::newEntry($action,$target,$all);
330 if(!empty($str)) return($str);
332 // Reset uid selection.
333 $this->got_uid= "";
335 // Use template if there are any of them
336 $templates = array();
337 $templates['none']= _("none");
338 $templates = array_merge($templates,$this->get_templates());
340 // We've templates, so preset the current template and display the input dialog.
341 if (count($templates)){
342 $smarty = get_smarty();
343 foreach(array("sn", "givenName", "uid", "got_uid") as $attr){
344 $smarty->assign("$attr", "");
345 }
346 $smarty->assign("template", array_pop($target));
347 $smarty->assign("templates", $templates);
348 $smarty->assign("edit_uid", "");
349 return($smarty->fetch(get_template_path('template.tpl', TRUE)));
351 // -> See 'templateContinue' for further handling!
352 }
353 }
357 /*! \brief Intiates user creation.
358 * If we've user templates, then the user will be asked
359 * if he wants to use one.
360 * -> See 'templateContinue' for further handling.
361 */
362 function newEntry($action="",$target=array(),$all=array(), $altTabClass ="", $altTabType = "", $altAclCategory="")
363 {
365 // Call parent method, it manages everything, locking, object creation...
366 $str = management::newEntry($action,$target,$all);
367 if(!empty($str)) return($str);
369 // If we've at least one template, then ask the user if he wants to use one?
370 $templates = array();
371 $templates['none']= _("none");
372 $templates = array_merge($templates,$this->get_templates());
374 // Display template selection
375 if (count($templates) > 1){
376 $smarty = get_smarty();
378 // Set default variables, normally empty.
379 foreach(array("sn", "givenName", "uid", "got_uid") as $attr){
380 $smarty->assign($attr, "");
381 }
382 $smarty->assign("template", "none");
383 $smarty->assign("templates", $templates);
384 $smarty->assign("edit_uid", "");
385 return($smarty->fetch(get_template_path('template.tpl', TRUE)));
387 // -> See 'templateContinue' for further handling!
388 }
389 }
392 /* !\brief This method is called whenever a template selection was displayed.
393 * Here we act on the use selection.
394 * - Does the user want to create a user from template?
395 * - Create user without template?
396 * - Input correct, every value given and valid?
397 */
398 function templateContinue()
399 {
400 // Get the list of available templates.
401 $templates = array();
402 $templates['none']= _("none");
403 $templates = array_merge($templates,$this->get_templates());
405 // Input validation, if someone wants to create a user from a template
406 // then validate the given values.
407 $message = array();
408 if(!isset($_POST['template']) || (empty($_POST['template']))){
409 $message[]= msgPool::invalid(_("Template"));
410 }
411 if(!isset($_POST['sn']) || (empty($_POST['sn']))){
412 $message[]= msgPool::required(_("Name"));
413 }
414 if(!isset($_POST['givenName']) || (empty($_POST['givenName']))){
415 $message[]= msgPool::required(_("Given name"));
416 }
418 /********************
419 * 1 We've had input errors - Display errors and show input dialog again.
420 ********************/
422 if (count($message) > 0){
423 msg_dialog::displayChecks($message);
425 // Preset input fields with user input.
426 $smarty = get_smarty();
427 foreach(array("sn", "givenName", "uid", "template") as $attr){
428 if(isset($_POST[$attr])){
429 $smarty->assign("$attr", get_post($attr));
430 }else{
431 $smarty->assign("$attr", "");
432 }
433 }
435 $smarty->assign("templates",$templates);
436 $smarty->assign("got_uid", $this->got_uid);
437 $smarty->assign("edit_uid",false);
438 return($smarty->fetch(get_template_path('template.tpl', TRUE)));
439 }
442 /********************
443 * 2 There was a template selected, now ask for the uid.
444 ********************/
446 if ($_POST['template'] != 'none' && !isset($_POST['uid'])){
448 // Remember user input.
449 $smarty = get_smarty();
450 $this->sn = $_POST['sn'];
451 $this->givenName = $_POST['givenName'];
453 // Avoid duplicate entries, check if such a user already exists.
454 $dn= preg_replace("/^[^,]+,/i", "", $_POST['template']);
455 $ldap= $this->config->get_ldap_link();
456 $ldap->cd ($dn);
457 $ldap->search ("(&(sn=".normalizeLdap($this->sn).")(givenName=".normalizeLdap($this->givenName)."))", array("givenName"));
458 if ($ldap->count () != 0){
459 msg_dialog::displayChecks(array(msgPool::duplicated(_("Name"))));
460 }else{
462 // Preset uid field by using the idGenerator
463 $attributes= array('sn' => $this->sn, 'givenName' => $this->givenName);
464 if ($this->config->get_cfg_value("idGenerator") != ""){
465 $uids= gen_uids ($this->config->get_cfg_value("idGenerator"), $attributes);
466 if (count($uids)){
467 $smarty->assign("edit_uid", "false");
468 $smarty->assign("uids", $uids);
469 $this->uid= current($uids);
470 }
471 } else {
472 $smarty->assign("edit_uid", "");
473 $this->uid= "";
474 }
475 $this->got_uid= true;
476 }
478 // Assign user input
479 foreach(array("sn", "givenName", "uid", "got_uid") as $attr){
480 $smarty->assign("$attr", $this->$attr);
481 }
482 if (isset($_POST['template'])){
483 $smarty->assign("template", $_POST['template']);
484 }
485 $smarty->assign("templates",$templates);
486 return($smarty->fetch(get_template_path('template.tpl', TRUE)));
487 }
490 /********************
491 * 3 No template - Ok. Lets fill the data into the user object and skip templating here.
492 ********************/
493 if ($_POST['template'] == 'none'){
494 foreach(array("sn", "givenName", "uid") as $attr){
495 if (isset($_POST[$attr])){
496 $this->tabObject->by_object['user']->$attr= $_POST[$attr];
497 }
498 }
500 // The user Tab object is already instantiated, so just go back and let the
501 // management class do the rest.
502 return("");
503 }
506 /********************
507 * 4 Template selected and uid given - Ok, then lets adapt tempalte values.
508 ********************/
509 if(isset($_POST['uid'])){
511 // Move user supplied data to sub plugins
512 foreach(array("uid","sn","givenName") as $attr){
513 $this->$attr = $_POST[$attr];
514 $this->tabObject->$attr = $this->$attr;
515 $this->tabObject->by_object['user']->$attr = $this->$attr;
516 }
518 // Adapt template values.
519 $template_dn = $_POST['template'];
520 $this->tabObject->adapt_from_template($template_dn, array("uid","cn","givenName","sn"));
521 $template_base = preg_replace("/^[^,]+,".preg_quote(get_people_ou(), '/i')."/", '', $template_dn);
522 $this->tabObject->by_object['user']->base= $template_base;
524 // The user Tab object is already instantiated, so just go back and let the
525 // management class do the rest.
526 return("");
527 }
528 }
531 /* !\brief This method applies a template to a set of users.
532 */
533 function templatizeUsers($action="",$target=array(),$all=array())
534 {
535 $this->dns = array();
536 if(count($target)){
538 // Get the list of available templates.
539 $templates = $this->get_templates();
541 // Check entry locking
542 foreach($target as $dn){
543 if (($user= get_lock($dn)) != ""){
544 return(gen_locked_message ($user, $dn));
545 }
546 $this->dns[] = $dn;
547 }
549 // Display template
550 $smarty = get_smarty();
551 $smarty->assign("templates", $templates);
552 return($smarty->fetch(get_template_path('templatize.tpl', TRUE)));
553 }
554 }
557 /* !\brief This method is called whenever the templatize dialog was used.
558 */
559 function templatizeContinue()
560 {
561 // Template readable?
562 $template= get_post('template');
563 $acl = $this->ui->get_permissions($template, $this->aclCategory."/".$this->aclPlugin);
564 if (preg_match('/r/', $acl)){
565 $tab = $this->tabClass;
566 foreach ($this->dns as $dn){
568 // User writeable
569 $acl = $this->ui->get_permissions($dn, $this->aclCategory."/".$this->aclPlugin);
570 if (preg_match('/w/', $acl)){
571 $this->tabObject= new $tab($this->config, $this->config->data['TABS'][$this->tabType], $dn, $this->aclCategory);
572 $this->tabObject->adapt_from_template($template, array("sn", "givenName", "uid"));
573 $this->tabObject->save();
574 } else {
575 msg_dialog::display(_("Permission error"), msgPool::permModify($dn), ERROR_DIALOG);
576 }
577 }
578 } else {
579 msg_dialog::display(_("Permission error"), msgPool::permView($template), ERROR_DIALOG);
580 }
582 // Cleanup!
583 $this->remove_lock();
584 $this->closeDialogs();
585 }
588 /* !\brief Lock/unlock multiple users.
589 */
590 function lockUsers($action,$target,$all)
591 {
592 if($action == "lockUsers"){
593 $this->lockEntry($action,$target, $all, "lock");
594 }else{
595 $this->lockEntry($action,$target, $all, "unlock");
596 }
597 }
600 /* !\brief Locks/unlocks the given user(s).
601 */
602 function lockEntry($action,$entry, $all, $type = "toggle")
603 {
605 // Filter out entries we are not allowed to modify
606 $disallowed = array();
607 $dns = array();
608 foreach($entry as $dn){
609 if (!preg_match("/w/",$this->ui->get_permissions($dn,"users/password"))){
610 $disallowed[] = $dn;
611 }else{
612 $allowed[] = $dn;
613 }
614 }
615 if(count($disallowed)){
616 msg_dialog::display(_("Permission"),msgPool::permDelete($disallowed),INFO_DIALOG);
617 }
619 // Try to lock/unlock the rest of the entries.
620 $ldap = $this->config->get_ldap_link();
621 foreach($allowed as $dn){
622 $ldap->cat($dn, array('userPassword'));
623 if($ldap->count() == 1){
625 // We can't lock empty passwords.
626 $val = $ldap->fetch();
627 if(!isset($val['userPassword'])){
628 continue;
629 }
631 // Detect the password method and try to lock/unlock.
632 $pwd = $val['userPassword'][0];
633 $method = passwordMethod::get_method($pwd,$val['dn']);
634 $success= true;
635 if($method instanceOf passwordMethod){
636 if($type == "toggle"){
637 if($method->is_locked($this->config,$val['dn'])){
638 $success= $method->unlock_account($this->config,$val['dn']);
639 }else{
640 $success= $method->lock_account($this->config,$val['dn']);
641 }
642 }elseif($type == "lock" && !$method->is_locked($this->config,$val['dn'])){
643 $success= $method->lock_account($this->config,$val['dn']);
644 }elseif($type == "unlock" && $method->is_locked($this->config,$val['dn'])){
645 $success= $method->unlock_account($this->config,$val['dn']);
646 }
648 // Check if everything went fine.
649 if (!$success){
650 $hn= $method->get_hash_name();
651 if (is_array($hn)){
652 $hn= $hn[0];
653 }
654 msg_dialog::display(_("Account locking"),
655 sprintf(_("Password method '%s' does not support locking. Account (%s) has not been locked!"),
656 $hn,$dn),WARNING_DIALOG);
657 }
658 }else{
659 // Can't lock unknown methods.
660 }
661 }
662 }
663 }
666 /* !\brief This method returns a list of all available templates.
667 */
668 function get_templates()
669 {
670 $templates= array();
671 $ldap= $this->config->get_ldap_link();
672 foreach ($this->config->departments as $key => $value){
673 $acl = $this->ui->get_permissions($value,$this->aclCategory."/".$this->aclPlugin);
674 if (preg_match("/c/",$acl)){
676 // Search all templates from the current dn.
677 $ldap->cd (get_people_ou().$value);
678 $ldap->search ("(objectClass=gosaUserTemplate)", array("uid"));
679 if ($ldap->count() != 0){
680 while ($attrs= $ldap->fetch()){
681 $templates[$ldap->getDN()]= $attrs['uid'][0]." - ".LDAP::fix($key);
682 }
683 }
684 }
685 }
686 natcasesort ($templates);
687 reset ($templates);
688 return($templates);
689 }
692 function copyPasteHandler($action="",$target=array(),$all=array(),
693 $altTabClass ="", $altTabType = "", $altAclCategory="",$altAclPlugin="")
694 {
695 if ($this->config->boolValueIsTrue("main", "copyPaste")){
696 $this->cpHandler->lastdn = "";
697 $str = management::copyPasteHandler($action,$target,$all);
698 if($this->cpHandler->lastdn != "" && isset($_POST['passwordTodo']) && $_POST['passwordTodo'] == "new"){
699 $this->pwd_change_queue[] = $this->cpHandler->lastdn;
700 return($this->handlePasswordQueue());
701 }
702 return($str);
703 }
705 return "";
706 }
709 static function filterLockImage($userPassword)
710 {
711 $image= "images/empty.png";
712 if(isset($userPassword[0]) && preg_match("/^\{[^\}]/",$userPassword[0])){
713 if(preg_match("/^[^\}]*+\}!/",$userPassword[0])){
714 $image= "images/lists/locked.png";
715 }else{
716 $image= "images/lists/unlocked.png";
717 }
718 }
719 return $image;
720 }
723 static function filterLockLabel($userPassword)
724 {
725 $label= "";
726 if(isset($userPassword[0]) && preg_match("/^\{[^\}]/",$userPassword[0])){
727 if(preg_match("/^[^\}]*+\}!/",$userPassword[0])){
728 $label= _("Unlock account");
729 }else{
730 $label= _("Lock account");
731 }
732 }
733 return $label;
734 }
737 static function filterProperties($row, $classes)
738 {
739 $result= "";
740 $map= array( "gosaAccount" => array( "image" => "plugins/users/images/select_user.png",
741 "plugin" => "user",
742 "alt" => _("Generic"),
743 "title" => _("Edit generic properties")),
744 "posixAccount" => array("image" => "images/penguin.png",
745 "plugin" => "posixAccount",
746 "alt" => _("POSIX"),
747 "title" => _("Edit POSIX properties")),
748 "gosaMailAccount" => array("image" => "images/mailto.png",
749 "alt" => _("Mail"),
750 "plugin" => "mailAccount",
751 "title" => _("Edit mail properties")),
752 "sambaSamAccount" => array("image" => "plugins/systems/images/select_winstation.png",
753 "plugin" => "sambaAccount",
754 "alt" => _("Samba"),
755 "title" => _("Edit samba properties")),
756 "apple-user" => array("image" => "plugins/netatalk/images/select_netatalk.png",
757 "plugin" => "netatalk",
758 "alt" => _("Netatalk"),
759 "title" => _("Edit netatalk properties")),
760 "gotoEnvironment" => array("image" => "plugins/users/images/small_environment.png",
761 "plugin" => "environment",
762 "alt" => _("Environment"),
763 "title" => _("Edit environment properties")),
764 "goFaxAccount" => array("image" => "plugins/users/images/fax_small.png",
765 "plugin" => "gofaxAccount",
766 "alt" => _("FAX"),
767 "title" => _("Edit FAX properties")),
768 "goFonAccount" => array("image" => "plugins/gofon/images/select_phone.png",
769 "plugin" => "phoneAccount",
770 "alt" => _("Phone"),
771 "title" => _("Edit phone properties")));
773 // Walk thru map
774 foreach ($map as $oc => $properties) {
775 if (in_array_ics($oc, $classes)) {
776 $result.="<input class='center' type='image' src='".$properties['image']."' ".
777 "alt='".$properties['alt']."' title='".$properties['title'].
778 "' name='listing_edit_".$properties['plugin']."_$row' style='padding:1px'>";
779 } else {
780 $result.="<img src='images/empty.png' alt=' ' class='center' style='padding:1px'>";
781 }
782 }
783 return $result;
784 }
786 }
787 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
788 ?>