Code

Added new (but currently not 100% working) Management dialog
[gosa.git] / plugins / admin / ogroups / class_ogroupManagement.inc
1 <?php
2 /*
3    This code is part of GOsa (https://gosa.gonicus.de)
4    Copyright (C) 2004 Cajus Pollmeier
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2 of the License, or
9    (at your option) any later version.
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
16    You should have received a copy of the GNU General Public License
17    along with this program; if not, write to the Free Software
18    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20 require "tabs_ogroups.inc";
22 class ogroupManagement extends plugin
23 {
24   /* Definitions */
25   var $plHeadline= "Object groups";
26   var $plDescription= "This does something";
28   /* attribute list for save action */
29   var $attributes= array();
30   var $objectclasses= array();
31   var $obtypes= array();
32   var $ogroup;
34   var $CopyPasteHandler ;
36   var $enableCopyPaste = false;
39   function ogroupManagement ($config, $dn= NULL)
40   {
41     /* Include config object */
42     $this->config= $config;
43     $this->ui= get_userinfo();
45     /* Copy & Paste enabled ?
46      */
47     if((isset($this->config->data['MAIN']['ENABLECOPYPASTE']))&&(preg_match("/true/i",$this->config->data['MAIN']['ENABLECOPYPASTE'] ))){
48       $this->enableCopyPaste = true;
49     }
51     $this->CopyPasteHandler = new CopyPasteHandler($this->config);
53     /* Fill translation array */
54     $this->obtypes= array(      "posixAccount" => _("UNIX accounts"),
55         "posixGroup" => _("Groups"),
56         "gosaDepartment" => _("Departments"),
57         "gosaApplication" => _("Applications"),
58         "goServer" => _("Servers"),
59         "gotoTerminal" => _("Thin Clients"),
60         "gotoWorkstation" => _("Workstations"),
61         "goFonHardware" => _("Phone"),
62         "gotoPrinter" => _("Printer"));
63     asort($this->obtypes);
65     /* Get global filter config */
66     if (!is_global("ogroupfilter")){
67       $ui= get_userinfo();
68       $base= get_base_from_people($ui->dn);
69       $ogroupfilter= array(     "usergroups" => "checked",
70           "groupgroups" => "checked",
71           "appgroups" => "checked",
72           "depgroups" => "checked",
73           "servergroups" => "checked",
74           "wsgroups" => "checked",
75           "prtgroups" => "checked",
76           "tcgroups" => "checked",
77           "fongroups" => "checked",
78           "regex" => "*");
79       register_global("ogroupfilter", $ogroupfilter);
80     }
81     if(!isset($_SESSION['CurrentMainBase'])){
82       $ui= get_userinfo();
83       $base= get_base_from_people($ui->dn);
84       $_SESSION['CurrentMainBase'] = $base;
85     }
86   }
88   function execute()
89   {
90           /* Call parent execute */
91           plugin::execute();
93     $_SESSION['LOCK_VARS_TO_USE'] = array("/^act$/","/^id$/","/^group_edit_/","/^group_del_/");
95     /* Prepare template */
96     $smarty= get_smarty();
98     $ogroupfilter= get_global("ogroupfilter");
99     $s_action   = "";
100     $s_entry    = "";
102     foreach( array("regex") as $type){
103       if (isset($_POST[$type])){
104         $ogroupfilter[$type]= $_POST[$type];
105       }
106     }
107     if(isset($_POST['CurrentMainBase'])){
108       $_SESSION['CurrentMainBase'] = $_POST['CurrentMainBase'];
109     }
111     if (isset($_POST['Ogroup_dialog_posted'])){
112       foreach( array("usergroups", "groupgroups", "appgroups", "depgroups",
113             "servergroups", "wsgroups", "prtgroups", "tcgroups", "fongroups") as $type){
115         if (isset($_POST[$type])) {
116           $ogroupfilter[$type]= "checked";
117         } else {
118           $ogroupfilter[$type]= "";
119         }
120       }
121     }
122     if (isset($_GET['search'])){
123       $s= mb_substr($_GET['search'], 0, 1, "UTF8")."*";
124       if ($s == "**"){
125         $s= "*";
126       }
127       $ogroupfilter['regex']= $s;
128     }
130     /* Test Posts */
131     foreach($_POST as $key => $val){
132       // Post for delete
133       if(preg_match("/^group_del.*/",$key)){
134         $s_action = "del";
135         $s_entry  = preg_replace("/^group_".$s_action."_/i","",$key);
136         // Post for edit
137       }elseif(preg_match("/^group_edit_.*/",$key)){
138         $s_action="edit";
139         $s_entry  = preg_replace("/^group_".$s_action."_/i","",$key);
140         // Post for new
141       }elseif(preg_match("/^dep_back.*/i",$key)){
142         $s_action="back";
143       }elseif(preg_match("/^group_new.*/",$key)){
144         $s_action="new";
145       }elseif(preg_match("/^dep_home.*/i",$key)){
146         $s_action="home";
147       }elseif(preg_match("/^group_tplnew.*/i",$key)){
148         $s_action="new_tpl";
149       }elseif(preg_match("/^group_chgpw.*/i",$key)){
150         $s_action="change_pw";
151         $s_entry  = preg_replace("/group_chgpw_/i","",$key);
152       }elseif(preg_match("/^dep_root.*/i",$key)){
153         $s_action="root";
154       }elseif(preg_match("/^editPaste.*/i",$key)){
155         $s_action="editPaste";
156       }elseif(preg_match("/^copy_.*/",$key)){
157         $s_action="copy";
158         $s_entry  = preg_replace("/^copy_/i","",$key);
159       }elseif(preg_match("/^cut_.*/",$key)){
160         $s_action="cut";
161         $s_entry  = preg_replace("/^cut_/i","",$key);
162       }elseif(preg_match("/_group_edit_/",$key)){
163         $type = preg_replace("/_group_edit_.*$/","",$key);
164         $s_action="edit";
165         $s_entry  = preg_replace("/".$type."_group_edit_/i","",$key);
166         $_POST['arg'] = $type;
167       }
168     }
169     $s_entry  = preg_replace("/_.$/","",$s_entry);
170     
171     /* Department changed? */
172     if(isset($_POST['CurrentMainBase']) && $_POST['CurrentMainBase']){
173       $_SESSION['CurrentMainBase'] = $_POST['CurrentMainBase'];
174     }
176     /* Start for New List Managment */
177     if(isset($_GET['act'])&&($_GET['act']=="dep_open")){
178       $s_action="open";
179       $s_entry = base64_decode($_GET['dep_id']);
180       $_SESSION['CurrentMainBase'] = "".$this->config->departments[trim($s_entry)];
181     }
183     /* If Backbutton is Posted */
184     if($s_action=="back"){
185       $base_back          = preg_replace("/^[^,]+,/","", $_SESSION['CurrentMainBase']);
186       $base_back          = convert_department_dn($base_back);
188       if(isset($this->config->departments[trim($base_back)])){
189         $_SESSION['CurrentMainBase']= $this->config->departments[trim($base_back)];
190       }else{
191         $_SESSION['CurrentMainBase']= $this->config->departments["/"];
192       }
193       register_global("ogroupfilter", $ogroupfilter);
194     }
196     /* Homebutton is posted */
197     if($s_action=="home"){
198       $_SESSION['CurrentMainBase']=(preg_replace("/^[^,]+,/","",$this->ui->dn));
199       $_SESSION['CurrentMainBase']=(preg_replace("/^[^,]+,/","", $_SESSION['CurrentMainBase']));
200     }
202     /* root posted */ 
203     if($s_action=="root"){
204       $_SESSION['CurrentMainBase']=($this->config->current['BASE']);
205     }
207     // Edit if
208     if((isset($_GET['act']))&&($_GET['act']=="edit_entry")){
209       $s_action ="edit";
210       $s_entry  = $_GET['id'];
211     }
213     register_global("ogroupfilter", $ogroupfilter);
215     $this->reload();
217     /* Check for exeeded sizelimit */
218     if (($message= check_sizelimit()) != ""){
219       return($message);
220     }
222     /* Only perform copy / paste if it is enabled
223      */
224     if($this->enableCopyPaste){
225  
226        /* Paste copied/cutted object in here
227        */
228       if(($s_action == "editPaste") || ($this->CopyPasteHandler->stillOpen())){
229         $this->CopyPasteHandler->save_object();
230         $this->CopyPasteHandler->SetVar("base", $_SESSION['CurrentMainBase']);
231         return($this->CopyPasteHandler->execute());
232       }
235       /* Copy current object to CopyHandler
236        */
237       if($s_action == "copy"){
238         $this->CopyPasteHandler->Clear();
239         $dn       =   $this->ogrouplist[$s_entry]['dn'];
240         $obj      =   new ogrouptabs($this->config, $this->config->data['TABS']['OGROUPTABS'], $dn);
241         $objNew   =   new ogrouptabs($this->config, $this->config->data['TABS']['OGROUPTABS'], "new");
242         $this->CopyPasteHandler->Copy($obj,$objNew);
243       }
246       /* Copy current object to CopyHandler
247        */
248       if($s_action == "cut"){
249         $this->CopyPasteHandler->Clear();
250         $dn       =   $this->ogrouplist[$s_entry]['dn'];
251         $obj      =   new ogrouptabs($this->config, $this->config->data['TABS']['OGROUPTABS'], $dn);
252         $this->CopyPasteHandler->Cut($obj);
253       }
254     }
256     /* New group? */
257     if ($s_action=="new"){
259       /* By default we set 'dn' to 'new', all relevant plugins will
260          react on this. */
261       $this->dn= "new";
263       /* Create new usertab object */
264       $this->ogroup= new ogrouptabs($this->config,
265       $this->config->data['TABS']['OGROUPTABS'], $this->dn);
266     }
268     if ($s_action=="del"){
270       /* Get 'dn' from posted 'uid' */
271       $this->dn= $this->ogrouplist[$s_entry]['dn'];
273       /* Load permissions for selected 'dn' and check if
274          we're allowed to remove this 'dn' */
275       $acl= get_permissions ($this->dn, $this->ui->subtreeACL);
276       $this->acl= get_module_permission($acl, "ogroup", $this->dn);
277       if (chkacl($this->acl, "delete") == ""){
279         /* Check locking, save current plugin in 'back_plugin', so
280            the dialog knows where to return. */
281         if (($user= get_lock($this->dn)) != ""){
282           return(gen_locked_message ($user, $this->dn));
283         }
285         /* Lock the current entry, so nobody will edit it during deletion */
286         add_lock ($this->dn, $this->ui->dn);
287         $smarty->assign("info", sprintf(_("You're about to delete the object group '%s'."), @LDAP::fix($this->dn)));
288         return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
289       } else {
291         /* Obviously the user isn't allowed to delete. Show message and
292            clean session. */
293         print_red (_("You are not allowed to delete this object group!"));
294       }
295     }
297     /* Confirmation for deletion has been passed. Group should be deleted. */
298     if (isset($_POST['delete_group_confirm'])){
300       /* Some nice guy may send this as POST, so we've to check
301          for the permissions again. */
302       if (chkacl($this->acl, "delete") == ""){
304         /* Delete request is permitted, perform LDAP action */
305         $this->ogroup= new ogrouptabs($this->config,
306         $this->config->data['TABS']['OGROUPTABS'], $this->dn);
307         $this->ogroup->set_acl(array($this->acl));
308         $this->ogroup->delete ();
309         gosa_log ("Object group'".$this->dn."' has been removed");
310         unset ($this->ogroup);
311         $this->ogroup= NULL;
313         /* Group list has changed, reload it. */
314         $this->reload ();
315       } else {
317         /* Normally this shouldn't be reached, send some extra
318            logs to notify the administrator */
319         print_red (_("You are not allowed to delete this object group!"));
320         gosa_log ("Warning: '".$this->ui->uid."' tried to trick group deletion.");
321       }
323       /* Remove lock file after successfull deletion */
324       del_lock ($this->dn);
325       unset($_SESSION['objectinfo']);
326     }
329     /* Delete group canceled? */
330     if (isset($_POST['delete_cancel'])){
331       del_lock ($this->dn);
332       unset($_SESSION['objectinfo']);
333     }
335     if (($s_action=="edit") && (! isset($this->ogroup->config)) ){
337       /* Get 'dn' from posted 'uid', must be unique */
338       $this->dn= $this->ogrouplist[$s_entry]['dn'];
340       /* Check locking, save current plugin in 'back_plugin', so
341          the dialog knows where to return. */
342       if (($user= get_lock($this->dn)) != ""){
343         return(gen_locked_message ($user, $this->dn));
344       }
346       /* Lock the current entry, so everyone will get the
347          above dialog */
348       add_lock ($this->dn, $this->ui->dn);
350       /* Set up the users ACL's for this 'dn' */
351       $acl= get_permissions ($this->dn, $this->ui->subtreeACL);
353       /* Register grouptab to trigger edit dialog */
354       $this->ogroup= new ogrouptabs($this->config, $this->config->data['TABS']['OGROUPTABS'],
355           $this->dn);
356       $this->ogroup->set_acl($acl);
357       $_SESSION['objectinfo']= $this->dn;
358     }
360     /* Finish button has been pressed */
361     if ((isset($_POST['edit_finish'])) && (isset($this->ogroup->config)) ){
363       /* Check tabs, will feed message array */
364       $message= $this->ogroup->check();
366       /* Save, or display error message? */
367       if (count($message) == 0){
369         /* Save user data to ldap */
370         $this->ogroup->save();
371         gosa_log ("Object group'".$this->dn."' has been saved");
373         /* Group has been saved successfully, remove lock from
374            LDAP. */
375         if ($this->dn != "new"){
376           del_lock ($this->dn);
377         }
379         /* There's no page reload so we have to read new users at
380            this point. */
381         $this->reload ();
382         unset ($this->ogroup);
383         $this->ogroup= NULL;
384         unset ($_SESSION['objectinfo']);
386       } else {
387         /* Ok. There seem to be errors regarding to the tab data,
388            show message and continue as usual. */
389         show_errors($message);
390       }
391     }
393     /* Cancel dialogs */
394     if (isset($_POST['edit_cancel'])){
395       del_lock ($this->ogroup->dn);
396       unset ($this->ogroup);
397       $this->ogroup= NULL;
398       unset($_SESSION['objectinfo']);
399     }
401     /* Show dialog if object is present */
402     if (isset($this->ogroup->config)){
403       $display= $this->ogroup->execute();
405       /* Don't show buttons if tab dialog requests this */
406       if (!$this->ogroup->by_object[$this->ogroup->current]->dialog){
407         $display.= "<p style=\"text-align:right\">\n";
408         $display.= "<input type=submit name=\"edit_finish\" value=\""._("Save")."\">\n";
409         $display.= "&nbsp;\n";
410         $display.= "<input type=submit name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
411         $display.= "</p>";
412       }
413       return ($display);
414     }
416     /* Prepare departments */
417     $options= "";
418     foreach ($this->config->idepartments as $key => $value){
419             if ($_SESSION['CurrentMainBase'] == $key){
420                     $options.= "<option selected value='$key'>$value</option>";
421             } else {
422                     $options.= "<option value='$key'>$value</option>";
423             }
424     }
427     /* Create paste icon 
428      * This icon is only displayed if copy & paste is enabled 
429      */
430     if($this->enableCopyPaste){
431       $Copy_Paste = " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;";
432       if($this->CopyPasteHandler->isCurrentObjectPastAble()){
433         if($this->CopyPasteHandler->isCurrentCutted()){
434           $img = "images/cutpaste.png";
435         }else{
436           $img = "images/copypaste.png";
437         }
438         $Copy_Paste .= "<input type='image' name='editPaste' class='center'
439           src='".$img."' alt='"._("Paste")."' title='".$this->CopyPasteHandler->GetCurrentDn()."'>&nbsp;";
440       }else{
441         $Copy_Paste .= "<img class='center' src='images/cant_editpaste.png' alt='"._("Can't paste")."'>&nbsp;";
442       }
443     }else{
444       $Copy_Paste ="";
445     }
448     // Managment
449     $listhead = "<div style='background:#F0F0F9;padding:5px;'>".
450       " <input class='center' type='image' src='images/list_root.png' align='middle' title='"._("Go to root department")."'
451 name='dep_root' alt='"._("Root")."'>&nbsp;".
452       " <input class='center' type='image' align='middle' src='images/list_back.png' title='"._("Go up one department")."' alt='"._("Up")."' name='dep_back'>&nbsp;".
453       " <input class='center' type='image' align='middle' src='images/list_home.png' title='"._("Go to users department")."'
454  alt='"._("Home")."' name='dep_home'>&nbsp;".
455        " <input class='center' type='image' src='images/list_reload.png' align='middle' title='"._("Reload list")."' name='submit_department' alt='"._("Submit")."'>&nbsp;".
456       " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;".
457       " <input class='center' type='image' align='middle' src='images/list_new_ogroup.png' title='"._("Create new object group")."' alt='"._("new")."' name='group_new'>".
458       $Copy_Paste.
459       " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;".
460       _("Base")."&nbsp;<select name='CurrentMainBase' onChange='mainform.submit()' class='center'>$options</select>".
461       " <input class='center' type='image' src='images/list_submit.png' align='middle' title='"._("Submit department")."' name='submit_department' alt='"._("Submit")."'>&nbsp;".
462       "</div>";
465     /* Add Copy & Paste buttons if copy&paste is enabled 
466      */
467     if($this->enableCopyPaste){
468       $actions = "<input class='center' type='image'
469         src='images/editcut.png' alt='"._("cut")."' name='cut_%KEY%' title='"._("Cut this entry")."'>&nbsp;";
470       $actions.= "<input class='center' type='image'
471         src='images/editcopy.png' alt='"._("copy")."' name='copy_%KEY%' title='"._("Copy this entry")."'>&nbsp;";
472       $actions.= "<input class='center' type='image' 
473                     src='images/edit.png' alt='"._("edit")."' name='group_edit_%KEY%' title='"._("Edit this entry")."'>";
474       $actions.= "<input class='center' type='image' 
475                     src='images/edittrash.png' alt='"._("delete")."' name='group_del_%KEY%' title='"._("Delete this entry")."'>";
476     }else{
477       $actions = "<input class='center' type='image' 
478                     src='images/edit.png' alt='"._("edit")."' name='group_edit_%KEY%' title='"._("Edit this entry")."'>";
479       $actions.= "<input class='center' type='image' 
480                     src='images/edittrash.png' alt='"._("delete")."' name='group_del_%KEY%' title='"._("Delete this entry")."'>";
481     }
484     // Defining Links
485     $linkopen = "<a href='?plug=".$_GET['plug']."&amp;act=dep_open&amp;dep_id=%s'>%s</a>";
487     // image Buttons
488     $editlink = "<a href='?plug=".$_GET['plug']."&amp;id=%s&amp;act=edit_entry'>%s</a>";
489     $userimg  = "<img class='center' src='images/select_groups.png' alt='User'    title='%s'>";
491     // Extension images
492     $mailimg  = "<img class='center' src='images/mailto.png'             alt='M'  title='"._("Mail")   ."'>";
494     // Space
495     $empty    = "<img class='center' src='images/empty.png' style='width:16px;height:16px;' alt=''>";
497     // List Setup
498     $divlist = new divlist("ogroubstab");
499     $divlist->SetHeader(array(
500           array("string" => "&nbsp;", "attach" => "style='text-align:center;width:20px;'"),
501           array("string" => _("Name of object groups")." / "._("Departments"), "attach" => "style=''"),
502           array("string" => _("Properties"), "attach" => "style='width:136px;'"),
503           array("string" => _("Actions"), "attach" => "style='width:80;border-right:0px;text-align:right;'")
504           ));
507     $divlist->SetSummary(_("This table displays all groups, in the selected tree."));
508     $divlist->SetEntriesPerPage(0);
510     foreach($this->departments as $key=> $val){
512       if(!isset($this->config->departments[trim($key)])){
513         $this->config->departments[trim($key)]="";
514       }
516       $non_empty="";
517       $keys= str_replace("/","\/",$key);
518       foreach($this->config->departments as $keyd=>$vald ){
519         if(preg_match("/".$keys."\/.*/",$keyd)){
520           $non_empty="full";
521         }
522       }
526       $field1 = array("string" => "<img src='images/".$non_empty."folder.png' alt='"._("Department")."'>", "attach" => "style='text-align:center;width:20px;'");
527       $field2 = array("string" => sprintf($linkopen,base64_encode($key),$val), "attach" => "style=''");
528       $field3 = array("string" => "&nbsp;", "attach" => "style='width:136px;'");
529       $field4 = array("string" => "&nbsp;", "attach" => "style='width:80;border-right:0px;text-align:right;'");
531       $divlist->AddEntry(array($field1,$field2,$field3,$field4));
532     }
534     // Assigning ogroups 
535     foreach($this->ogrouplist as $key => $val){
537       if(isset($val['mail'])){
538         $mail = $mailimg;
539       }else{
540         $mail = $empty;
541       }
543       $title = "title='dn:&nbsp;".@LDAP::fix($val['dn'])."'";
545       if(!isset($val['description'][0])){
546         $desc = "";
547       }else{
548         $desc = " - [ ".$val['description'][0]." ]";
549       }
550       $field1 = array("string" => "<img src='images/list_ogroup.png' alt='"._("Object group")."' ".$title.">", "attach" => "style='text-align:center;width:20px;'");
551       $field2 = array("string" => sprintf($editlink,$key,($val['cn']['0'].$desc)), "attach" => "style='' ".$title);
552       $field3 = array("string" => preg_replace("/%KEY/", $key, $this->convert_list($val))."&nbsp;".$mail, "attach" => "style='width:136px;'");
553       $field4 = array("string" => preg_replace("/%KEY%/", $key, $actions), "attach" => "style='width:80;border-right:0px;text-align:right;'");
555       $divlist->AddEntry(array($field1,$field2,$field3,$field4));
556     }
563     /* Show main page */
564     $smarty->assign("search_image", get_template_path('images/search.png'));
565     $smarty->assign("tree_image", get_template_path('images/tree.png'));
566     $smarty->assign("infoimage", get_template_path('images/info.png'));
567     $smarty->assign("launchimage", get_template_path('images/launch.png'));
568     $smarty->assign("deplist", $this->config->idepartments);
570     $smarty->assign("groupshead", $listhead);
571     $smarty->assign("groups", $divlist->DrawList());
573     foreach( array("usergroups", "groupgroups", "appgroups", "depgroups",
574           "servergroups", "wsgroups", "prtgroups", "tcgroups", "fongroups", "regex" ) as $type){
575       $smarty->assign("$type", $ogroupfilter[$type]);
576     }
577     $smarty->assign("CurrentMainBase" , $_SESSION['CurrentMainBase']);
578     $smarty->assign("hint", print_sizelimit_warning());
579     $smarty->assign("apply", apply_filter());
580     $smarty->assign("alphabet", generate_alphabet());
581     return ($smarty->fetch (get_template_path('headpage.tpl', TRUE)));
582   }
585   function convert_list($input)
586   {
587     $temp= "";
590     $conv= array(   
591         "U" => array("select_user.png"        ,_("User")        , "ogroup"),
592         "G" => array("select_groups.png"      ,_("Group")       , "ogroup"),
593         "A" => array("select_application.png" ,_("Application") , "ogroup"),
594         "D" => array("select_department.png"  ,_("Department")  , "ogroup"),
595         "S" => array("select_server.png"      ,_("Server")      , "ogroup"),
596         "F" => array("select_phone.png"       ,_("Phone")       , "phonequeue"),
597         "W" => array("select_workstation.png" ,_("Workstation") , "workstartup"),
598         "T" => array("select_terminal.png"    ,_("Terminal")    , "termgroup"),
599         "P" => array("select_printer.png"     ,_("Printer")     , "ogroup"));
601     /* Assemble picture */
602     $type= $input['gosaGroupObjects'][0];
603     $type= preg_replace("/[^A-Z]/i","",$type);
604     if (isset($type[0])){
605       $p1['pic']= $conv[$type[0]][0];
606       $p1['tit']= $conv[$type[0]][1];
607       $p1['alt']= $type[0];
608       $p1['lnk']= $conv[$type[0]][2];
609     } else {
610       $p1['pic']= "empty.png";
611       $p1['tit']= "";
612       $p1['alt']= "";
613       $p1['lnk']= "";//$conv[$type[0]][2];
614     }
616     if (isset($type[1])){
617       $p2['pic']= $conv[$type[1]][0];
618       $p2['alt']= $type[1];
619       $p2['tit']= $conv[$type[1]][1];
620       $p2['lnk']= $conv[$type[1]][2];
621     } else {
622       $p2['pic']= "empty.png";
623       $p2['alt']= "";
624       $p2['tit']= "";
625       $p2['lnk']= ""; //$conv[$type[0]][2];
626     }
627     $temp = "<input type='image' name='".$p1['lnk']."_group_edit_%KEY' class='center' 
628               src='images/".$p1['pic']."' alt='".$p1['alt']."' title='".$p1['tit']."'>";
629     $temp.= "<input type='image' name='".$p2['lnk']."_group_edit_%KEY'class='center' 
630               src='images/".$p2['pic']."' alt='".$p2['alt']."' title='".$p2['tit']."'>";
631     return ($temp);
632   }
635   function reload()
636   {
637     /* Get config */
638     $ogroupfilter= get_global('ogroupfilter');
640     /* Set base for all searches */
641     $base= $_SESSION['CurrentMainBase'];
643     /* Regex filter? */
644     if ($ogroupfilter['regex'] != ""){
645       $regex= $ogroupfilter['regex'];
646     } else {
647       $regex= "*";
648     }
650     /* User filter? */
651     $this->oogrouplist= array();
653     /* Generate oogrouplist filter */
654     $filter= "";
656     if ($ogroupfilter['usergroups'] == "checked"){
657       $filter.= "(gosaGroupObjects=*U*)";
658     }
659     if ($ogroupfilter['groupgroups'] == "checked"){
660       $filter.= "(gosaGroupObjects=*G*)";
661     }
662     if ($ogroupfilter['appgroups'] == "checked"){
663       $filter.= "(gosaGroupObjects=*A*)";
664     }
665     if ($ogroupfilter['depgroups'] == "checked"){
666       $filter.= "(gosaGroupObjects=*D*)";
667     }
668     if ($ogroupfilter['servergroups'] == "checked"){
669       $filter.= "(gosaGroupObjects=*S*)";
670     }
671     if ($ogroupfilter['wsgroups'] == "checked"){
672       $filter.= "(gosaGroupObjects=*W*)";
673     }
674     if ($ogroupfilter['prtgroups'] == "checked"){
675       $filter.= "(gosaGroupObjects=*P*)";
676     }
677     if ($ogroupfilter['tcgroups'] == "checked"){
678       $filter.= "(gosaGroupObjects=*T*)";
679     }
680     if ($ogroupfilter['fongroups'] == "checked"){
681       $filter.= "(gosaGroupObjects=*F*)";
682     }
683     $filter.= "(gosaGroupObjects=[])";
685     if ($filter != ""){
686       $filter= "(&(cn=$regex)(objectClass=gosaGroupOfNames)(|$filter))";
687     } else {
688       $filter= "(&(cn=$regex)(objectClass=gosaGroupOfNames))";
689     }
690     
691     $res= get_list($filter, $this->ui->subtreeACL, get_groups_ou().$base, array("*"), GL_SIZELIMIT );
692     $this->ogrouplist= $res;
693     ksort ($this->ogrouplist);
694     reset ($this->ogrouplist);
697     /* NEW LIST MANAGMENT
698      * We also need to search for the departments
699      * So we are able to navigate like in konquerer
700      */
701     $peopleOU = get_people_ou();
703     if(empty($peopleOU)){
704       $base2 = $base;
705     }else{
706       $base2 = preg_replace("/".$peopleOU."/i","",$base);
707     }
709     /* Get all departments within this subtree */
710     $deps= get_list("(&(|(ou=$regex)(description=$regex))(objectClass=gosaDepartment))", $this->ui->subtreeACL,
711         $base2, array("ou", "description"), GL_SIZELIMIT | GL_CONVERT);
713     $this->departments = array();
714     foreach($deps as $value){
715       if(isset($value['description'][0])){
716         $this->departments[$value['dn']]= get_sub_department($value['dn'])." - [".$value["description"][0]."]";
717       }else{
718         $this->departments[$value['dn']]= get_sub_department($value['dn']);
719       }
720     }
721     natcasesort($this->departments);
723     $tmp=array();
724     foreach($this->ogrouplist as $tkey => $val ){
725       $tmp[strtolower($val['cn'][0]).$val['cn'][0]]=$val;
726     }
727     ksort($tmp);
728     $this->ogrouplist=array();
729     foreach($tmp as $val){
730       $this->ogrouplist[]=$val;
731     }
732     reset ($this->ogrouplist);
733   }
736 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
737 ?>