Code

ecd339518092184daf300a95273ecaa78b891b6e
[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           "depselect" => $base,
79           "regex" => "*");
80       register_global("ogroupfilter", $ogroupfilter);
81     }
82   }
84   function execute()
85   {
86           /* Call parent execute */
87           plugin::execute();
89     $_SESSION['LOCK_VARS_TO_USE'] = array("/^act$/","/^id$/","/^group_edit_/","/^group_del_/");
91     /* Prepare template */
92     $smarty= get_smarty();
94     $ogroupfilter= get_global("ogroupfilter");
95     $s_action   = "";
96     $s_entry    = "";
98     foreach( array("depselect", "regex") as $type){
99       if (isset($_POST[$type])){
100         $ogroupfilter[$type]= $_POST[$type];
101       }
102     }
103     if (isset($_POST['Ogroup_dialog_posted'])){
104       foreach( array("usergroups", "groupgroups", "appgroups", "depgroups",
105             "servergroups", "wsgroups", "prtgroups", "tcgroups", "fongroups") as $type){
107         if (isset($_POST[$type])) {
108           $ogroupfilter[$type]= "checked";
109         } else {
110           $ogroupfilter[$type]= "";
111         }
112       }
113     }
114     if (isset($_GET['search'])){
115       $s= mb_substr($_GET['search'], 0, 1, "UTF8")."*";
116       if ($s == "**"){
117         $s= "*";
118       }
119       $ogroupfilter['regex']= $s;
120     }
122     /* Test Posts */
123     foreach($_POST as $key => $val){
124       // Post for delete
125       if(preg_match("/^group_del.*/",$key)){
126         $s_action = "del";
127         $s_entry  = preg_replace("/^group_".$s_action."_/i","",$key);
128         // Post for edit
129       }elseif(preg_match("/^group_edit_.*/",$key)){
130         $s_action="edit";
131         $s_entry  = preg_replace("/^group_".$s_action."_/i","",$key);
132         // Post for new
133       }elseif(preg_match("/^dep_back.*/i",$key)){
134         $s_action="back";
135       }elseif(preg_match("/^group_new.*/",$key)){
136         $s_action="new";
137       }elseif(preg_match("/^dep_home.*/i",$key)){
138         $s_action="home";
139       }elseif(preg_match("/^group_tplnew.*/i",$key)){
140         $s_action="new_tpl";
141       }elseif(preg_match("/^group_chgpw.*/i",$key)){
142         $s_action="change_pw";
143         $s_entry  = preg_replace("/group_chgpw_/i","",$key);
144       }elseif(preg_match("/^dep_root.*/i",$key)){
145         $s_action="root";
146       }elseif(preg_match("/^editPaste.*/i",$key)){
147         $s_action="editPaste";
148       }elseif(preg_match("/^copy_.*/",$key)){
149         $s_action="copy";
150         $s_entry  = preg_replace("/^copy_/i","",$key);
151       }elseif(preg_match("/^cut_.*/",$key)){
152         $s_action="cut";
153         $s_entry  = preg_replace("/^cut_/i","",$key);
154       }elseif(preg_match("/_group_edit_/",$key)){
155         $type = preg_replace("/_group_edit_.*$/","",$key);
156         $s_action="edit";
157         $s_entry  = preg_replace("/".$type."_group_edit_/i","",$key);
158         $_POST['arg'] = $type;
159       }
160     }
161     $s_entry  = preg_replace("/_.$/","",$s_entry);
162     
163     /* Department changed? */
164     if(isset($_POST['depselect']) && $_POST['depselect']){
165       $ogroupfilter['depselect']= $_POST['depselect'];
166     }
168     /* Start for New List Managment */
169     if(isset($_GET['act'])&&($_GET['act']=="dep_open")){
170       $s_action="open";
171       $s_entry = base64_decode($_GET['dep_id']);
172       $ogroupfilter['depselect']= "".$this->config->departments[trim($s_entry)];
173     }
175     /* If Backbutton is Posted */
176     if($s_action=="back"){
177       $base_back          = preg_replace("/^[^,]+,/","",$ogroupfilter['depselect']);
178       $base_back          = convert_department_dn($base_back);
180       if(isset($this->config->departments[trim($base_back)])){
181         $ogroupfilter['depselect']= $this->config->departments[trim($base_back)];
182       }else{
183         $ogroupfilter['depselect']= $this->config->departments["/"];
184       }
185       register_global("ogroupfilter", $ogroupfilter);
186     }
188     /* Homebutton is posted */
189     if($s_action=="home"){
190       $ogroupfilter['depselect']=(preg_replace("/^[^,]+,/","",$this->ui->dn));
191       $ogroupfilter['depselect']=(preg_replace("/^[^,]+,/","",$ogroupfilter['depselect']));
192     }
194     /* root posted */ 
195     if($s_action=="root"){
196       $ogroupfilter['depselect']=($this->config->current['BASE']);
197     }
199     // Edit if
200     if((isset($_GET['act']))&&($_GET['act']=="edit_entry")){
201       $s_action ="edit";
202       $s_entry  = $_GET['id'];
203     }
205     register_global("ogroupfilter", $ogroupfilter);
207     $this->reload();
209     /* Check for exeeded sizelimit */
210     if (($message= check_sizelimit()) != ""){
211       return($message);
212     }
214     /* Only perform copy / paste if it is enabled
215      */
216     if($this->enableCopyPaste){
217  
218        /* Paste copied/cutted object in here
219        */
220       if(($s_action == "editPaste") || ($this->CopyPasteHandler->stillOpen())){
221         $this->CopyPasteHandler->save_object();
222         $this->CopyPasteHandler->SetVar("base",$ogroupfilter['depselect']);
223         return($this->CopyPasteHandler->execute());
224       }
227       /* Copy current object to CopyHandler
228        */
229       if($s_action == "copy"){
230         $this->CopyPasteHandler->Clear();
231         $dn       =   $this->ogrouplist[$s_entry]['dn'];
232         $obj      =   new ogrouptabs($this->config, $this->config->data['TABS']['OGROUPTABS'], $dn);
233         $objNew   =   new ogrouptabs($this->config, $this->config->data['TABS']['OGROUPTABS'], "new");
234         $this->CopyPasteHandler->Copy($obj,$objNew);
235       }
238       /* Copy current object to CopyHandler
239        */
240       if($s_action == "cut"){
241         $this->CopyPasteHandler->Clear();
242         $dn       =   $this->ogrouplist[$s_entry]['dn'];
243         $obj      =   new ogrouptabs($this->config, $this->config->data['TABS']['OGROUPTABS'], $dn);
244         $this->CopyPasteHandler->Cut($obj);
245       }
246     }
248     /* New group? */
249     if ($s_action=="new"){
251       /* By default we set 'dn' to 'new', all relevant plugins will
252          react on this. */
253       $this->dn= "new";
255       /* Create new usertab object */
256       $this->ogroup= new ogrouptabs($this->config,
257       $this->config->data['TABS']['OGROUPTABS'], $this->dn);
258     }
260     if ($s_action=="del"){
262       /* Get 'dn' from posted 'uid' */
263       $this->dn= $this->ogrouplist[$s_entry]['dn'];
265       /* Load permissions for selected 'dn' and check if
266          we're allowed to remove this 'dn' */
267       $acl= get_permissions ($this->dn, $this->ui->subtreeACL);
268       $this->acl= get_module_permission($acl, "ogroup", $this->dn);
269       if (chkacl($this->acl, "delete") == ""){
271         /* Check locking, save current plugin in 'back_plugin', so
272            the dialog knows where to return. */
273         if (($user= get_lock($this->dn)) != ""){
274           return(gen_locked_message ($user, $this->dn));
275         }
277         /* Lock the current entry, so nobody will edit it during deletion */
278         add_lock ($this->dn, $this->ui->dn);
279         $smarty->assign("info", sprintf(_("You're about to delete the object group '%s'."), LDAP::fix($this->dn)));
280         return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
281       } else {
283         /* Obviously the user isn't allowed to delete. Show message and
284            clean session. */
285         print_red (_("You are not allowed to delete this object group!"));
286       }
287     }
289     /* Confirmation for deletion has been passed. Group should be deleted. */
290     if (isset($_POST['delete_group_confirm'])){
292       /* Some nice guy may send this as POST, so we've to check
293          for the permissions again. */
294       if (chkacl($this->acl, "delete") == ""){
296         /* Delete request is permitted, perform LDAP action */
297         $this->ogroup= new ogrouptabs($this->config,
298         $this->config->data['TABS']['OGROUPTABS'], $this->dn);
299         $this->ogroup->set_acl(array($this->acl));
300         $this->ogroup->delete ();
301         gosa_log ("Object group'".$this->dn."' has been removed");
302         unset ($this->ogroup);
303         $this->ogroup= NULL;
305         /* Group list has changed, reload it. */
306         $this->reload ();
307       } else {
309         /* Normally this shouldn't be reached, send some extra
310            logs to notify the administrator */
311         print_red (_("You are not allowed to delete this object group!"));
312         gosa_log ("Warning: '".$this->ui->uid."' tried to trick group deletion.");
313       }
315       /* Remove lock file after successfull deletion */
316       del_lock ($this->dn);
317       unset($_SESSION['objectinfo']);
318     }
321     /* Delete group canceled? */
322     if (isset($_POST['delete_cancel'])){
323       del_lock ($this->dn);
324       unset($_SESSION['objectinfo']);
325     }
327     if (($s_action=="edit") && (! isset($this->ogroup->config)) ){
329       /* Get 'dn' from posted 'uid', must be unique */
330       $this->dn= $this->ogrouplist[$s_entry]['dn'];
332       /* Check locking, save current plugin in 'back_plugin', so
333          the dialog knows where to return. */
334       if (($user= get_lock($this->dn)) != ""){
335         return(gen_locked_message ($user, $this->dn));
336       }
338       /* Lock the current entry, so everyone will get the
339          above dialog */
340       add_lock ($this->dn, $this->ui->dn);
342       /* Set up the users ACL's for this 'dn' */
343       $acl= get_permissions ($this->dn, $this->ui->subtreeACL);
345       /* Register grouptab to trigger edit dialog */
346       $this->ogroup= new ogrouptabs($this->config, $this->config->data['TABS']['OGROUPTABS'],
347           $this->dn);
348       $this->ogroup->set_acl($acl);
349       $_SESSION['objectinfo']= $this->dn;
350     }
352     /* Finish button has been pressed */
353     if ((isset($_POST['edit_finish'])) && (isset($this->ogroup->config)) ){
355       /* Check tabs, will feed message array */
356       $message= $this->ogroup->check();
358       /* Save, or display error message? */
359       if (count($message) == 0){
361         /* Save user data to ldap */
362         $this->ogroup->save();
363         gosa_log ("Object group'".$this->dn."' has been saved");
365         /* Group has been saved successfully, remove lock from
366            LDAP. */
367         if ($this->dn != "new"){
368           del_lock ($this->dn);
369         }
371         /* There's no page reload so we have to read new users at
372            this point. */
373         $this->reload ();
374         unset ($this->ogroup);
375         $this->ogroup= NULL;
376         unset ($_SESSION['objectinfo']);
378       } else {
379         /* Ok. There seem to be errors regarding to the tab data,
380            show message and continue as usual. */
381         show_errors($message);
382       }
383     }
385     /* Cancel dialogs */
386     if (isset($_POST['edit_cancel'])){
387       del_lock ($this->ogroup->dn);
388       unset ($this->ogroup);
389       $this->ogroup= NULL;
390       unset($_SESSION['objectinfo']);
391     }
393     /* Show dialog if object is present */
394     if (isset($this->ogroup->config)){
395       $display= $this->ogroup->execute();
397       /* Don't show buttons if tab dialog requests this */
398       if (!$this->ogroup->by_object[$this->ogroup->current]->dialog){
399         $display.= "<p style=\"text-align:right\">\n";
400         $display.= "<input type=submit name=\"edit_finish\" value=\""._("Finish")."\">\n";
401         $display.= "&nbsp;\n";
402         $display.= "<input type=submit name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
403         $display.= "</p>";
404       }
405       return ($display);
406     }
408     /* Prepare departments */
409     $options= "";
410     foreach ($this->config->idepartments as $key => $value){
411             if ($ogroupfilter['depselect'] == $key){
412                     $options.= "<option selected value='$key'>$value</option>";
413             } else {
414                     $options.= "<option value='$key'>$value</option>";
415             }
416     }
419     /* Create paste icon 
420      * This icon is only displayed if copy & paste is enabled 
421      */
422     if($this->enableCopyPaste){
423       $Copy_Paste = " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;";
424       if($this->CopyPasteHandler->isCurrentObjectPastAble()){
425         if($this->CopyPasteHandler->isCurrentCutted()){
426           $img = "images/cutpaste.png";
427         }else{
428           $img = "images/copypaste.png";
429         }
430         $Copy_Paste .= "<input type='image' name='editPaste' class='center'
431           src='".$img."' alt='"._("Paste")."' title='".$this->CopyPasteHandler->GetCurrentDn()."'>&nbsp;";
432       }else{
433         $Copy_Paste .= "<img class='center' src='images/cant_editpaste.png' alt='"._("Can't paste")."'>&nbsp;";
434       }
435     }else{
436       $Copy_Paste ="";
437     }
440     // Managment
441     $listhead = "<div style='background:#F0F0F9;padding:5px;'>".
442       " <input class='center' type='image' align='middle' src='images/list_back.png' title='"._("Go up one department")."' alt='"._("Up")."' name='dep_back'>&nbsp;".
443       " <input class='center' type='image' src='images/list_root.png' align='middle' title='"._("Go to root department")."'
444 name='dep_root' alt='"._("Root")."'>&nbsp;".
445       " <input class='center' type='image' align='middle' src='images/list_home.png' title='"._("Go to users department")."'
446  alt='"._("Home")."' name='dep_home'>&nbsp;".
447       " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;".
448       " <input class='center' type='image' align='middle' src='images/list_new_ogroup.png' title='"._("Create new object group")."' alt='"._("new")."' name='group_new'>".
449       $Copy_Paste.
450       " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;".
451       _("Base")."&nbsp;<select name='depselect' onChange='mainform.submit()' class='center'>$options</select>".
452       " <input class='center' type='image' src='images/list_submit.png' align='middle' title='"._("Submit department")."' name='submit_department' alt='"._("Submit")."'>&nbsp;".
453       "</div>";
456     /* Add Copy & Paste buttons if copy&paste is enabled 
457      */
458     if($this->enableCopyPaste){
459       $actions = "<input class='center' type='image'
460         src='images/editcut.png' alt='"._("cut")."' name='cut_%KEY%' title='"._("Cut this entry")."'>&nbsp;";
461       $actions.= "<input class='center' type='image'
462         src='images/editcopy.png' alt='"._("copy")."' name='copy_%KEY%' title='"._("Copy this entry")."'>&nbsp;";
463       $actions.= "<input class='center' type='image' 
464                     src='images/edit.png' alt='"._("edit")."' name='group_edit_%KEY%' title='"._("Edit this entry")."'>";
465       $actions.= "<input class='center' type='image' 
466                     src='images/edittrash.png' alt='"._("delete")."' name='group_del_%KEY%' title='"._("Delete this entry")."'>";
467     }else{
468       $actions = "<input class='center' type='image' 
469                     src='images/edit.png' alt='"._("edit")."' name='group_edit_%KEY%' title='"._("Edit this entry")."'>";
470       $actions.= "<input class='center' type='image' 
471                     src='images/edittrash.png' alt='"._("delete")."' name='group_del_%KEY%' title='"._("Delete this entry")."'>";
472     }
475     // Defining Links
476     $linkopen = "<a href='?plug=".$_GET['plug']."&amp;act=dep_open&amp;dep_id=%s'>%s</a>";
478     // image Buttons
479     $editlink = "<a href='?plug=".$_GET['plug']."&amp;id=%s&amp;act=edit_entry'>%s</a>";
480     $userimg  = "<img class='center' src='images/select_groups.png' alt='User'    title='%s'>";
482     // Extension images
483     $mailimg  = "<img class='center' src='images/mailto.png'             alt='M'  title='"._("Mail")   ."'>";
485     // Space
486     $empty    = "<img class='center' src='images/empty.png' style='width:16px;height:16px;' alt=''>";
488     // List Setup
489     $divlist = new divlist("ogroubstab");
490     $divlist->SetHeader(array(
491           array("string" => "&nbsp;", "attach" => "style='text-align:center;width:20px;'"),
492           array("string" => _("Name of object groups")." / "._("Departments"), "attach" => "style=''"),
493           array("string" => _("Properties"), "attach" => "style='width:136px;'"),
494           array("string" => _("Actions"), "attach" => "style='width:80;border-right:0px;text-align:right;'")
495           ));
498     $divlist->SetSummary(_("This table displays all groups, in the selected tree."));
499     $divlist->SetEntriesPerPage(0);
501     foreach($this->departments as $key=> $val){
503       if(!isset($this->config->departments[trim($key)])){
504         $this->config->departments[trim($key)]="";
505       }
507       $non_empty="";
508       $keys= str_replace("/","\/",$key);
509       foreach($this->config->departments as $keyd=>$vald ){
510         if(preg_match("/".$keys."\/.*/",$keyd)){
511           $non_empty="full";
512         }
513       }
517       $field1 = array("string" => "<img src='images/".$non_empty."folder.png' alt='"._("Department")."'>", "attach" => "style='text-align:center;width:20px;'");
518       $field2 = array("string" => sprintf($linkopen,base64_encode($key),$val), "attach" => "style=''");
519       $field3 = array("string" => "&nbsp;", "attach" => "style='width:136px;'");
520       $field4 = array("string" => "&nbsp;", "attach" => "style='width:80;border-right:0px;text-align:right;'");
522       $divlist->AddEntry(array($field1,$field2,$field3,$field4));
523     }
525     // Assigning ogroups 
526     foreach($this->ogrouplist as $key => $val){
528       if(isset($val['mail'])){
529         $mail = $mailimg;
530       }else{
531         $mail = $empty;
532       }
534       $title = "title='dn : ".$val['dn']."'";
536       if(!isset($val['description'][0])){
537         $desc = "";
538       }else{
539         $desc = " - [ ".$val['description'][0]." ]";
540       }
541       $field1 = array("string" => "<img src='images/list_ogroup.png' alt='"._("Object group")."' ".$title.">", "attach" => "style='text-align:center;width:20px;'");
542       $field2 = array("string" => sprintf($editlink,$key,($val['cn']['0'].$desc)), "attach" => "style='' ".$title);
543       $field3 = array("string" => preg_replace("/%KEY/", $key, $this->convert_list($val))."&nbsp;".$mail, "attach" => "style='width:136px;'");
544       $field4 = array("string" => preg_replace("/%KEY%/", $key, $actions), "attach" => "style='width:80;border-right:0px;text-align:right;'");
546       $divlist->AddEntry(array($field1,$field2,$field3,$field4));
547     }
554     /* Show main page */
555     $smarty->assign("search_image", get_template_path('images/search.png'));
556     $smarty->assign("tree_image", get_template_path('images/tree.png'));
557     $smarty->assign("infoimage", get_template_path('images/info.png'));
558     $smarty->assign("launchimage", get_template_path('images/launch.png'));
559     $smarty->assign("deplist", $this->config->idepartments);
561     $smarty->assign("groupshead", $listhead);
562     $smarty->assign("groups", $divlist->DrawList());
564     foreach( array("usergroups", "groupgroups", "appgroups", "depgroups",
565           "servergroups", "wsgroups", "prtgroups", "tcgroups", "fongroups", "regex", "depselect") as $type){
566       $smarty->assign("$type", $ogroupfilter[$type]);
567     }
569     $smarty->assign("hint", print_sizelimit_warning());
570     $smarty->assign("apply", apply_filter());
571     $smarty->assign("alphabet", generate_alphabet());
572     return ($smarty->fetch (get_template_path('headpage.tpl', TRUE)));
573   }
576   function convert_list($input)
577   {
578     $temp= "";
581     $conv= array(   
582         "U" => array("select_user.png"        ,_("User")        , "ogroup"),
583         "G" => array("select_groups.png"      ,_("Group")       , "ogroup"),
584         "A" => array("select_application.png" ,_("Application") , "ogroup"),
585         "D" => array("select_department.png"  ,_("Department")  , "ogroup"),
586         "S" => array("select_server.png"      ,_("Server")      , "ogroup"),
587         "F" => array("select_phone.png"       ,_("Phone")       , "phonequeue"),
588         "W" => array("select_workstation.png" ,_("Workstation") , "workstartup"),
589         "T" => array("select_terminal.png"    ,_("Terminal")    , "termgroup"),
590         "P" => array("select_printer.png"     ,_("Printer")     , "ogroup"));
592     /* Assemble picture */
593     $type= $input['gosaGroupObjects'][0];
594     $type= preg_replace("/[^A-Z]/i","",$type);
595     if (isset($type[0])){
596       $p1['pic']= $conv[$type[0]][0];
597       $p1['tit']= $conv[$type[0]][1];
598       $p1['alt']= $type[0];
599       $p1['lnk']= $conv[$type[0]][2];
600     } else {
601       $p1['pic']= "empty.png";
602       $p1['tit']= "";
603       $p1['alt']= "";
604       $p1['lnk']= "";//$conv[$type[0]][2];
605     }
607     if (isset($type[1])){
608       $p2['pic']= $conv[$type[1]][0];
609       $p2['alt']= $type[1];
610       $p2['tit']= $conv[$type[1]][1];
611       $p2['lnk']= $conv[$type[1]][2];
612     } else {
613       $p2['pic']= "empty.png";
614       $p2['alt']= "";
615       $p2['tit']= "";
616       $p2['lnk']= ""; //$conv[$type[0]][2];
617     }
618     $temp = "<input type='image' name='".$p1['lnk']."_group_edit_%KEY' class='center' 
619               src='images/".$p1['pic']."' alt='".$p1['alt']."' title='".$p1['tit']."'>";
620     $temp.= "<input type='image' name='".$p2['lnk']."_group_edit_%KEY'class='center' 
621               src='images/".$p2['pic']."' alt='".$p2['alt']."' title='".$p2['tit']."'>";
622     return ($temp);
623   }
626   function reload()
627   {
628     /* Get config */
629     $ogroupfilter= get_global('ogroupfilter');
631     /* Set base for all searches */
632     $base= $ogroupfilter['depselect'];
634     /* Regex filter? */
635     if ($ogroupfilter['regex'] != ""){
636       $regex= $ogroupfilter['regex'];
637     } else {
638       $regex= "*";
639     }
641     /* User filter? */
642     $this->oogrouplist= array();
644     /* Generate oogrouplist filter */
645     $filter= "";
647     if ($ogroupfilter['usergroups'] == "checked"){
648       $filter.= "(gosaGroupObjects=*U*)";
649     }
650     if ($ogroupfilter['groupgroups'] == "checked"){
651       $filter.= "(gosaGroupObjects=*G*)";
652     }
653     if ($ogroupfilter['appgroups'] == "checked"){
654       $filter.= "(gosaGroupObjects=*A*)";
655     }
656     if ($ogroupfilter['depgroups'] == "checked"){
657       $filter.= "(gosaGroupObjects=*D*)";
658     }
659     if ($ogroupfilter['servergroups'] == "checked"){
660       $filter.= "(gosaGroupObjects=*S*)";
661     }
662     if ($ogroupfilter['wsgroups'] == "checked"){
663       $filter.= "(gosaGroupObjects=*W*)";
664     }
665     if ($ogroupfilter['prtgroups'] == "checked"){
666       $filter.= "(gosaGroupObjects=*P*)";
667     }
668     if ($ogroupfilter['tcgroups'] == "checked"){
669       $filter.= "(gosaGroupObjects=*T*)";
670     }
671     if ($ogroupfilter['fongroups'] == "checked"){
672       $filter.= "(gosaGroupObjects=*F*)";
673     }
674     $filter.= "(gosaGroupObjects=[])";
676     if ($filter != ""){
677       $filter= "(&(cn=$regex)(objectClass=gosaGroupOfNames)(|$filter))";
678     } else {
679       $filter= "(&(cn=$regex)(objectClass=gosaGroupOfNames))";
680     }
681     
682    $groups = ($this->config->current['GROUPS']);
684     $res= get_list($this->ui->subtreeACL, "$filter",FALSE, $groups.",".$base, array("*"), TRUE);
685     $this->ogrouplist= $res;
686     ksort ($this->ogrouplist);
687     reset ($this->ogrouplist);
690     /* NEW LIST MANAGMENT
691      * We also need to search for the departments
692      * So we are able to navigate like in konquerer
693      */
694     $peopleOU = get_people_ou();
696     if(empty($peopleOU)){
697       $base2 = $base;
698     }else{
699       $base2 = preg_replace("/".$peopleOU."/i","",$base);
700     }
702     $res3 =  get_list2($this->ui->subtreeACL, "(&(|(ou=$regex)(description=$regex))(objectClass=gosaDepartment))",
703                               TRUE, $base2, array("ou", "description"), TRUE);
705    
707     $this->departments= array();
708     $tmp = array();
709     foreach ($res3 as $value){
710       $tmp[strtolower($value['dn']).$value['dn']]=$value;
711     }
712     ksort($tmp);
713     foreach($tmp as $value){
714       if(isset($value["description"][0])){
715         $this->departments[$value['dn']]=convert_department_dn2($value['dn'])." - [".$value["description"][0]."]";
716       }else{
717         $this->departments[$value['dn']]=convert_department_dn2($value['dn']);//$value["description"][0];
718       }
719     }
720     /* END NEW LIST MANAGMENT
721      */
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);
736   }
740 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
741 ?>