Code

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