67b0f6c9cabc3330f7de3c84ca7092425be77ffe
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 management::editEntry($action,$target);
129 if(preg_match("/^edit_/",$action)){
130 $tab = preg_replace("/^edit_/","",$action);
131 if(isset($this->tabObject->by_object[$tab])){
132 $this->tabObject->current = $tab;
133 }else{
134 trigger_error("Unknown tab: ".$tab);
135 }
136 }
137 }
140 function closeDialogs()
141 {
142 management::closeDialogs();
143 $this->pwd_change_queue = array();
144 }
147 /*! \brief Sends a message to a set of users using gosa-si events.
148 */
149 function sendMessage($action="",$target=array(),$all=array())
150 {
151 if(class_available("DaemonEvent")){
152 $uids = array();
153 $ldap = $this->config->get_ldap_link();
154 $ldap->cd($this->config->current['BASE']);
155 foreach($target as $dn){
156 $ldap->cat($dn,array('uid'));
157 $attrs = $ldap->fetch();
158 if(isset($attrs['uid'][0])){
159 $uids[] = $attrs['uid'][0];
160 }
161 }
162 if(count($uids)){
163 $events = DaemonEvent::get_event_types(USER_EVENT);
164 $event = "DaemonEvent_notify";
165 if(isset($events['BY_CLASS'][$event])){
166 $type = $events['BY_CLASS'][$event];
167 $this->dialogObject = new $type['CLASS_NAME']($this->config);
168 $this->dialogObject->add_users($uids);
169 $this->dialogObject->set_type(SCHEDULED_EVENT);
170 }
171 }
172 }
173 }
176 /*! \brief Sends a message to a set of users using gosa-si events.
177 */
178 function saveEventDialog()
179 {
180 $this->dialogObject->save_object();
181 $msgs = $this->dialogObject->check();
182 if(count($msgs)){
183 msg_dialog::displayChecks($msgs);
184 }else{
185 $o_queue = new gosaSupportDaemon();
186 $o_queue->append($this->dialogObject);
187 if($o_queue->is_error()){
188 msg_dialog::display(_("Infrastructure error"), msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
189 }
190 $this->closeDialogs();
191 }
192 }
195 /*! \brief Intiates template creation.
196 */
197 function newTemplate($action,$entry)
198 {
199 $this->newEntry();
200 $this->tabObject->set_template_mode ();
201 }
204 /*! \brief Queues a set of users for password changes
205 */
206 function changePassword($action="",$target=array(),$all=array())
207 {
208 $this->dn ="";
209 $this->pwd_change_queue = $target;
211 // Check permisions
212 $disallowed = array();
213 foreach($this->pwd_change_queue as $key => $dn){
214 if(!preg_match("/w/",$this->ui->get_permissions($dn,$this->aclCategory."/password"))){
215 unset($this->pwd_change_queue[$key]);
216 $disallowed[] = $dn;
217 }
218 }
219 if(count($disallowed)){
220 msg_dialog::display(_("Permission"),msgPool::permModify($disallowed),INFO_DIALOG);
221 }
223 // Now display change dialog.
224 return($this->handlePasswordQueue());
225 }
228 function handlePasswordQueue()
229 {
230 // Get next entry from queue.
231 if(empty($this->dn) && count($this->pwd_change_queue)){
232 $this->dn = array_pop($this->pwd_change_queue);
233 set_object_info($this->dn);
234 $smarty = get_smarty();
235 return ($smarty->fetch(get_template_path('password.tpl', TRUE)));
236 }
238 // Check permissions
239 $dn = $this->dn;
240 $acl = $this->ui->get_permissions($dn, "users/password");
241 $cacl= $this->ui->get_permissions($dn, "users/user");
242 if (preg_match('/w/', $acl) || preg_match('/c/', $cacl)){
243 $message= array();
244 if ($_POST['new_password'] != $_POST['repeated_password']){
245 $message[]= _("The passwords you've entered as 'New password' and 'Repeated new password' do not match.");
246 } else {
247 if ($_POST['new_password'] == ""){
248 $message[] = msgPool::required(_("New password"));
249 }
250 }
252 // Display errors
253 if (count($message) != 0){
254 msg_dialog::displayChecks($message);
255 $smarty = get_smarty();
256 return($smarty->fetch(get_template_path('password.tpl', TRUE)));
257 }
259 // Change cassword
260 if(isset($this->force_hash_type[$this->dn])){
261 if(!change_password ($this->dn, $_POST['new_password'],0,$this->force_hash_type[$this->dn])){
262 return($smarty->fetch(get_template_path('password.tpl', TRUE)));
263 }
264 }else{
265 if(!change_password ($this->dn, $_POST['new_password'])){
266 return($smarty->fetch(get_template_path('password.tpl', TRUE)));
267 }
268 }
269 if ($this->config->get_cfg_value("passwordHook") != ""){
270 exec($this->config->get_cfg_value("passwordHook")." ".$username." ".$_POST['new_password'], $resarr);
271 }
272 new log("modify","users/".get_class($this),$this->dn,array(),"Password has been changed");
273 $this->dn ="";
275 } else {
276 msg_dialog::display(_("Password change"),
277 _("You have no permission to change this users password!"),
278 WARNING_DIALOG);
279 }
281 // Cleanup
282 if(!count($this->pwd_change_queue)){
283 $this->remove_lock();
284 $this->closeDialogs();
285 }else{
286 return($this->handlePasswordQueue());
287 }
288 }
291 /*! \brief Save user modifications.
292 * Whenever we save a 'new' user, request a password change for him.
293 */
294 function saveChanges()
295 {
296 management::saveChanges();
298 if(isset($this->last_tabObject->by_object['user']) && $this->last_tabObject->by_object['user']->password_change_needed()){
299 $this->force_hash_type[$this->last_tabObject->dn] = $this->last_tabObject->by_object['user']->pw_storage;
300 $this->pwd_change_queue[] = $this->last_tabObject->dn;
301 return($this->handlePasswordQueue());
302 }
303 }
305 function cancelEdit()
306 {
307 management::cancelEdit();
309 if(isset($this->last_tabObject->by_object['user']) &&
310 $this->last_tabObject->by_object['user']->dn != "new" &&
311 $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 }
319 /*! \brief Intiates user creation.
320 * If we've user templates, then the user will be asked to use to use one.
321 * -> See 'templateContinue' for further handling.
322 */
323 function newUserFromTemplate($action="",$target=array(),$all=array())
324 {
325 // Call parent method, it knows whats to do, locking and so on ...
326 management::newEntry($action,$target,$all);
328 // Reset uid selection.
329 $this->got_uid= "";
331 // Use template if there are any of them
332 $templates = array();
333 $templates['none']= _("none");
334 $templates = array_merge($templates,$this->get_templates());
336 // We've templates, so preset the current template and display the input dialog.
337 if (count($templates)){
338 $smarty = get_smarty();
339 foreach(array("sn", "givenName", "uid", "got_uid") as $attr){
340 $smarty->assign("$attr", "");
341 }
342 $smarty->assign("template", array_pop($target));
343 $smarty->assign("templates", $templates);
344 $smarty->assign("edit_uid", "");
345 return($smarty->fetch(get_template_path('template.tpl', TRUE)));
347 // -> See 'templateContinue' for further handling!
348 }
349 }
353 /*! \brief Intiates user creation.
354 * If we've user templates, then the user will be asked
355 * if he wants to use one.
356 * -> See 'templateContinue' for further handling.
357 */
358 function newEntry($action="",$target=array(),$all=array(), $altTabClass ="", $altTabType = "", $altAclCategory="")
359 {
361 // Call parent method, it manages everything, locking, object creation...
362 management::newEntry($action,$target,$all);
364 // If we've at least one template, then ask the user if he wants to use one?
365 $templates = array();
366 $templates['none']= _("none");
367 $templates = array_merge($templates,$this->get_templates());
369 // Display template selection
370 if (count($templates) > 1){
371 $smarty = get_smarty();
373 // Set default variables, normally empty.
374 foreach(array("sn", "givenName", "uid", "got_uid") as $attr){
375 $smarty->assign($attr, "");
376 }
377 $smarty->assign("template", "none");
378 $smarty->assign("templates", $templates);
379 $smarty->assign("edit_uid", "");
380 return($smarty->fetch(get_template_path('template.tpl', TRUE)));
382 // -> See 'templateContinue' for further handling!
383 }
384 }
387 /* !\brief This method is called whenever a template selection was displayed.
388 * Here we act on the use selection.
389 * - Does the user want to create a user from template?
390 * - Create user without template?
391 * - Input correct, every value given and valid?
392 */
393 function templateContinue()
394 {
395 // Get the list of available templates.
396 $templates = array();
397 $templates['none']= _("none");
398 $templates = array_merge($templates,$this->get_templates());
400 // Input validation, if someone wants to create a user from a template
401 // then validate the given values.
402 $message = array();
403 if(!isset($_POST['template']) || (empty($_POST['template']))){
404 $message[]= msgPool::invalid(_("Template"));
405 }
406 if(!isset($_POST['sn']) || (empty($_POST['sn']))){
407 $message[]= msgPool::required(_("Name"));
408 }
409 if(!isset($_POST['givenName']) || (empty($_POST['givenName']))){
410 $message[]= msgPool::required(_("Given name"));
411 }
413 /********************
414 * 1 We've had input errors - Display errors and show input dialog again.
415 ********************/
417 if (count($message) > 0){
418 msg_dialog::displayChecks($message);
420 // Preset input fields with user input.
421 $smarty = get_smarty();
422 foreach(array("sn", "givenName", "uid", "template") as $attr){
423 if(isset($_POST[$attr])){
424 $smarty->assign("$attr", get_post($attr));
425 }else{
426 $smarty->assign("$attr", "");
427 }
428 }
430 $smarty->assign("templates",$templates);
431 $smarty->assign("got_uid", $this->got_uid);
432 $smarty->assign("edit_uid",false);
433 return($smarty->fetch(get_template_path('template.tpl', TRUE)));
434 }
437 /********************
438 * 2 There was a template selected, now ask for the uid.
439 ********************/
441 if ($_POST['template'] != 'none' && !isset($_POST['uid'])){
443 // Remember user input.
444 $smarty = get_smarty();
445 $this->sn = $_POST['sn'];
446 $this->givenName = $_POST['givenName'];
448 // Avoid duplicate entries, check if such a user already exists.
449 $dn= preg_replace("/^[^,]+,/i", "", $_POST['template']);
450 $ldap= $this->config->get_ldap_link();
451 $ldap->cd ($dn);
452 $ldap->search ("(&(sn=".normalizeLdap($this->sn).")(givenName=".normalizeLdap($this->givenName)."))", array("givenName"));
453 if ($ldap->count () != 0){
454 msg_dialog::displayChecks(array(msgPool::duplicated(_("Name"))));
455 }else{
457 // Preset uid field by using the idGenerator
458 $attributes= array('sn' => $this->sn, 'givenName' => $this->givenName);
459 if ($this->config->get_cfg_value("idGenerator") != ""){
460 $uids= gen_uids ($this->config->get_cfg_value("idGenerator"), $attributes);
461 if (count($uids)){
462 $smarty->assign("edit_uid", "false");
463 $smarty->assign("uids", $uids);
464 $this->uid= current($uids);
465 }
466 } else {
467 $smarty->assign("edit_uid", "");
468 $this->uid= "";
469 }
470 $this->got_uid= true;
471 }
473 // Assign user input
474 foreach(array("sn", "givenName", "uid", "got_uid") as $attr){
475 $smarty->assign("$attr", $this->$attr);
476 }
477 if (isset($_POST['template'])){
478 $smarty->assign("template", $_POST['template']);
479 }
480 $smarty->assign("templates",$templates);
481 return($smarty->fetch(get_template_path('template.tpl', TRUE)));
482 }
485 /********************
486 * 3 No template - Ok. Lets fill the data into the user object and skip templating here.
487 ********************/
488 if ($_POST['template'] == 'none'){
489 foreach(array("sn", "givenName", "uid") as $attr){
490 if (isset($_POST[$attr])){
491 $this->tabObject->by_object['user']->$attr= $_POST[$attr];
492 }
493 }
495 // The user Tab object is already instantiated, so just go back and let the
496 // management class do the rest.
497 return("");
498 }
501 /********************
502 * 4 Template selected and uid given - Ok, then lets adapt tempalte values.
503 ********************/
504 if(isset($_POST['uid'])){
506 // Move user supplied data to sub plugins
507 foreach(array("uid","sn","givenName") as $attr){
508 $this->$attr = $_POST[$attr];
509 $this->tabObject->$attr = $this->$attr;
510 $this->tabObject->by_object['user']->$attr = $this->$attr;
511 }
513 // Adapt template values.
514 $template_dn = $_POST['template'];
515 $this->tabObject->adapt_from_template($template_dn, array("uid","cn","givenName","sn"));
516 $template_base = preg_replace("/^[^,]+,".preg_quote(get_people_ou(), '/i')."/", '', $template_dn);
517 $this->tabObject->by_object['user']->base= $template_base;
519 // The user Tab object is already instantiated, so just go back and let the
520 // management class do the rest.
521 return("");
522 }
523 }
526 /* !\brief This method applies a template to a set of users.
527 */
528 function templatizeUsers($action="",$target=array(),$all=array())
529 {
530 $this->dns = array();
531 if(count($target)){
533 // Get the list of available templates.
534 $templates = $this->get_templates();
536 // Check entry locking
537 foreach($target as $dn){
538 if (($user= get_lock($dn)) != ""){
539 return(gen_locked_message ($user, $dn));
540 }
541 $this->dns[] = $dn;
542 }
544 // Display template
545 $smarty = get_smarty();
546 $smarty->assign("templates", $templates);
547 return($smarty->fetch(get_template_path('templatize.tpl', TRUE)));
548 }
549 }
552 /* !\brief This method is called whenever the templatize dialog was used.
553 */
554 function templatizeContinue()
555 {
556 // Template readable?
557 $template= get_post('template');
558 $acl = $this->ui->get_permissions($template, $this->aclCategory."/".$this->aclPlugin);
559 if (preg_match('/r/', $acl)){
560 $tab = $this->tabClass;
561 foreach ($this->dns as $dn){
563 // User writeable
564 $acl = $this->ui->get_permissions($dn, $this->aclCategory."/".$this->aclPlugin);
565 if (preg_match('/w/', $acl)){
566 $this->tabObject= new $tab($this->config, $this->config->data['TABS'][$this->tabType], $dn, $this->aclCategory);
567 $this->tabObject->adapt_from_template($template, array("sn", "givenName", "uid"));
568 $this->tabObject->save();
569 } else {
570 msg_dialog::display(_("Permission error"), msgPool::permModify($dn), ERROR_DIALOG);
571 }
572 }
573 } else {
574 msg_dialog::display(_("Permission error"), msgPool::permView($template), ERROR_DIALOG);
575 }
577 // Cleanup!
578 $this->remove_lock();
579 $this->closeDialogs();
580 }
583 /* !\brief Lock/unlock multiple users.
584 */
585 function lockUsers($action,$target,$all)
586 {
587 if($action == "lockUsers"){
588 $this->lockEntry($action,$target, $all, "lock");
589 }else{
590 $this->lockEntry($action,$target, $all, "unlock");
591 }
592 }
595 /* !\brief Locks/unlocks the given user(s).
596 */
597 function lockEntry($action,$entry, $all, $type = "toggle")
598 {
600 // Filter out entries we are not allowed to modify
601 $disallowed = array();
602 $dns = array();
603 foreach($entry as $dn){
604 if (!preg_match("/w/",$this->ui->get_permissions($dn,"users/password"))){
605 $disallowed[] = $dn;
606 }else{
607 $allowed[] = $dn;
608 }
609 }
610 if(count($disallowed)){
611 msg_dialog::display(_("Permission"),msgPool::permDelete($disallowed),INFO_DIALOG);
612 }
614 // Try to lock/unlock the rest of the entries.
615 $ldap = $this->config->get_ldap_link();
616 foreach($allowed as $dn){
617 $ldap->cat($dn, array('userPassword'));
618 if($ldap->count() == 1){
620 // We can't lock empty passwords.
621 $val = $ldap->fetch();
622 if(!isset($val['userPassword'])){
623 continue;
624 }
626 // Detect the password method and try to lock/unlock.
627 $pwd = $val['userPassword'][0];
628 $method = passwordMethod::get_method($pwd,$val['dn']);
629 $success= true;
630 if($method instanceOf passwordMethod){
631 if($type == "toggle"){
632 if($method->is_locked($this->config,$val['dn'])){
633 $success= $method->unlock_account($this->config,$val['dn']);
634 }else{
635 $success= $method->lock_account($this->config,$val['dn']);
636 }
637 }elseif($type == "lock" && !$method->is_locked($this->config,$val['dn'])){
638 $success= $method->lock_account($this->config,$val['dn']);
639 }elseif($type == "unlock" && $method->is_locked($this->config,$val['dn'])){
640 $success= $method->unlock_account($this->config,$val['dn']);
641 }
643 // Check if everything went fine.
644 if (!$success){
645 $hn= $method->get_hash_name();
646 if (is_array($hn)){
647 $hn= $hn[0];
648 }
649 msg_dialog::display(_("Account locking"),
650 sprintf(_("Password method '%s' does not support locking. Account (%s) has not been locked!"),
651 $hn,$dn),WARNING_DIALOG);
652 }
653 }else{
654 // Can't lock unknown methods.
655 }
656 }
657 }
658 }
661 /* !\brief This method returns a list of all available templates.
662 */
663 function get_templates()
664 {
665 $templates= array();
666 $ldap= $this->config->get_ldap_link();
667 foreach ($this->config->departments as $key => $value){
668 $acl = $this->ui->get_permissions($value,$this->aclCategory."/".$this->aclPlugin);
669 if (preg_match("/c/",$acl)){
671 // Search all templates from the current dn.
672 $ldap->cd (get_people_ou().$value);
673 $ldap->search ("(objectClass=gosaUserTemplate)", array("uid"));
674 if ($ldap->count() != 0){
675 while ($attrs= $ldap->fetch()){
676 $templates[$ldap->getDN()]= $attrs['uid'][0]." - ".LDAP::fix($key);
677 }
678 }
679 }
680 }
681 natcasesort ($templates);
682 reset ($templates);
683 return($templates);
684 }
687 function copyPasteHandler($action="",$target=array(),$all=array(),
688 $altTabClass ="", $altTabType = "", $altAclCategory="",$altAclPlugin="")
689 {
690 if ($this->config->boolValueIsTrue("main", "copyPaste")){
691 $this->cpHandler->lastdn = "";
692 $str = management::copyPasteHandler($action,$target,$all);
693 if($this->cpHandler->lastdn != "" && isset($_POST['passwordTodo']) && $_POST['passwordTodo'] == "new"){
694 $this->pwd_change_queue[] = $this->cpHandler->lastdn;
695 return($this->handlePasswordQueue());
696 }
697 return($str);
698 }
700 return "";
701 }
704 static function filterLockImage($userPassword)
705 {
706 $image= "images/empty.png";
707 if(isset($userPassword[0]) && preg_match("/^\{[^\}]/",$userPassword[0])){
708 if(preg_match("/^[^\}]*+\}!/",$userPassword[0])){
709 $image= "images/lists/locked.png";
710 }else{
711 $image= "images/lists/unlocked.png";
712 }
713 }
714 return $image;
715 }
718 static function filterLockLabel($userPassword)
719 {
720 $label= "";
721 if(isset($userPassword[0]) && preg_match("/^\{[^\}]/",$userPassword[0])){
722 if(preg_match("/^[^\}]*+\}!/",$userPassword[0])){
723 $label= _("Unlock account");
724 }else{
725 $label= _("Lock account");
726 }
727 }
728 return $label;
729 }
732 static function filterProperties($row, $classes)
733 {
734 $result= "";
735 $map= array( "gosaAccount" => array( "image" => "plugins/users/images/select_user.png",
736 "plugin" => "user",
737 "alt" => _("Generic"),
738 "title" => _("Edit generic properties")),
739 "posixAccount" => array("image" => "images/penguin.png",
740 "plugin" => "posixAccount",
741 "alt" => _("POSIX"),
742 "title" => _("Edit POSIX properties")),
743 "gosaMailAccount" => array("image" => "images/mailto.png",
744 "alt" => _("Mail"),
745 "plugin" => "mailAccount",
746 "title" => _("Edit mail properties")),
747 "sambaSamAccount" => array("image" => "plugins/systems/images/select_winstation.png",
748 "plugin" => "sambaAccount",
749 "alt" => _("Samba"),
750 "title" => _("Edit samba properties")),
751 "apple-user" => array("image" => "plugins/netatalk/images/select_netatalk.png",
752 "plugin" => "netatalk",
753 "alt" => _("Netatalk"),
754 "title" => _("Edit netatalk properties")),
755 "gotoEnvironment" => array("image" => "plugins/users/images/small_environment.png",
756 "plugin" => "environment",
757 "alt" => _("Environment"),
758 "title" => _("Edit environment properties")),
759 "goFaxAccount" => array("image" => "plugins/users/images/fax_small.png",
760 "plugin" => "gofaxAccount",
761 "alt" => _("FAX"),
762 "title" => _("Edit FAX properties")),
763 "goFonAccount" => array("image" => "plugins/gofon/images/select_phone.png",
764 "plugin" => "phoneAccount",
765 "alt" => _("Phone"),
766 "title" => _("Edit phone properties")));
768 // Walk thru map
769 foreach ($map as $oc => $properties) {
770 if (in_array_ics($oc, $classes)) {
771 $result.="<input class='center' type='image' src='".$properties['image']."' ".
772 "alt='".$properties['alt']."' title='".$properties['title'].
773 "' name='listing_edit_".$properties['plugin']."_$row' style='padding:1px'>";
774 } else {
775 $result.="<img src='images/empty.png' alt=' ' class='center' style='padding:1px'>";
776 }
777 }
778 return $result;
779 }
781 }
782 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
783 ?>