Code

Added diffrent pictures if department is empty .. or contains another dep..
[gosa.git] / plugins / admin / groups / class_groupManagement.inc
1 <?php
2 /*
3    This code is part of GOsa (https://gosa.gonicus.de)
4    Copyright (C) 2003  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_group.inc";
22 class groupManagement extends plugin
23 {
24   /* Definitions */
25   var $plHeadline= "Groups";
26   var $plDescription= "This does something";
27   var $departments = array();
29   /* Dialog attributes */
30   var $grouptab= NULL;
31   var $grouplist= array();
32   var $ui= NULL;
33   var $acl= "";
35   function groupManagement ($config, $ui)
36   {
37     /* Save configuration for internal use */
38     $this->config= $config;
39     $this->ui= $ui;
41     /* Get global filter config */
42     if (!is_global("groupfilter")){
43       $base= get_base_from_people($ui->dn);
44       $groupfilter= array("primarygroups" => "checked",
45           "mailgroups" => "checked",
46           "sambagroups" => "checked",
47           "appgroups" => "checked",
48           "functionalgroups" => "checked",
49           "guser" => "*",
50           "subsearch" => "",
51           "depselect" => $base,
52           "regex" => "*");
53       register_global("groupfilter", $groupfilter);
54     }
55   }
57   function execute()
58   {
59     /* Save data */
60     $groupfilter= get_global("groupfilter");
61     $s_action   = "";
62     $s_entry    = "";
65     if (!isset($this->grouptab)){
66       foreach( array("depselect", "guser", "regex") as $type){
67         if (isset($_POST[$type])){
68           $groupfilter[$type]= $_POST[$type];
69         } 
70       }
71       if (isset($_POST['regex'])){
72         foreach( array("primarygroups", "sambagroups", "mailgroups", "appgroups",
73               "functionalgroups", "subsearch") as $type){
75           if (isset($_POST[$type])) {
76             $groupfilter[$type]= "checked";
77           } else {
78             $groupfilter[$type]= "";
79           }
80         }
81       }
82       if (isset($_GET['search'])){
83         $s= mb_substr($_GET['search'], 0, 1, "UTF8")."*";
84         if ($s == "**"){
85           $s= "*";
86         }
87         $groupfilter['regex']= $s;
88       }
89       register_global("groupfilter", $groupfilter);
90     }
93     /* Test Posts */
94     foreach($_POST as $key => $val){
95       // Post for delete
96       if(preg_match("/group_del.*/",$key)){
97         $s_action = "del";
98         $s_entry  = preg_replace("/group_".$s_action."_/i","",$key);
99         // Post for edit
100       }elseif(preg_match("/group_edit_.*/",$key)){
101         $s_action="edit";
102         $s_entry  = preg_replace("/group_".$s_action."_/i","",$key);
103         // Post for new
104       }elseif(preg_match("/dep_back.*/i",$key)){
105         $s_action="back";
106       }elseif(preg_match("/group_new.*/",$key)){
107         $s_action="new";
108       }elseif(preg_match("/dep_home.*/i",$key)){
109         $s_action="home";
110       }elseif(preg_match("/group_tplnew.*/i",$key)){
111         $s_action="new_tpl";
112       }elseif(preg_match("/group_chgpw.*/i",$key)){
113         $s_action="change_pw";
114         $s_entry  = preg_replace("/group_chgpw_/i","",$key);
115       }elseif(preg_match("/dep_root.*/i",$key)){
116         $s_action="root";
117       }
118     }
119     $s_entry  = preg_replace("/_.$/","",$s_entry); 
121     /* Start for New List Managment */
122     if(isset($_GET['act'])&&($_GET['act']=="dep_open")){
123       $s_action="open";
124       $s_entry = base64_decode($_GET['dep_id']);
125       $groupfilter['depselect']= "".$this->config->departments[trim($s_entry)];
126       $this->reload();
127     }
129     // Edit if
130     if((isset($_GET['act']))&&($_GET['act']=="edit_entry")){
131       $s_action ="edit";
132       $s_entry  = $_GET['id'];
133     }
135     /* Department changed? */
136     if(isset($_POST['depselect']) && $_POST['depselect']){
137       $groupfilter['depselect']= $_POST['depselect'];
138       $this->reload();
139     }
141     /* Homebutton is posted */
142     if($s_action=="home"){
143       $groupfilter['depselect']= (preg_replace("/^[^,]+,/","",$this->ui->dn));
144       $groupfilter['depselect']= (preg_replace("/^[^,]+,/","",$groupfilter['depselect']));
145       $this->reload();
146     }
148     if($s_action=="root"){
149       $groupfilter['depselect']=($this->config->current['BASE']);
150       $this->reload();
151     }
153     /* If Backbutton is Posted */
154     if($s_action == "back"){
155       $base_back= preg_replace("/^[^,]+,/","",$groupfilter['depselect']);
156       $base_back= convert_department_dn($base_back);
158       if(isset($this->config->departments[trim($base_back)])){
159         $groupfilter['depselect']= $this->config->departments[trim($base_back)];
160       }else{
161         $groupfilter['depselect']= $this->config->departments["/"];
162       }
163       $this->reload();
164     }
165     register_global("groupfilter", $groupfilter);
167     $smarty= get_smarty();
169     /* Prepare formular */
170     if (!isset($this->grouptab) &&
171         !isset($_POST['new_group']) &&
172         !isset($_POST['delete_group']) &&
173         !isset($_POST['select_group'])){
174       $this->reload();
175     }
177     /* Check for exeeded sizelimit */
178     if (($message= check_sizelimit()) != ""){
179       return($message);
180     }
182     /* New group? */
183     if ($s_action=="new"){
185       /* By default we set 'dn' to 'new', all relevant plugins will
186          react on this. */
187       $this->dn= "new";
189       /* Create new usertab object */
190       $this->grouptab= new grouptabs($this->config,
191           $this->config->data['TABS']['GROUPTABS'], $this->dn);
192       $this->grouptab->set_acl(array(':all'));
193     }
195     /* Cancel dialogs */
196     if (isset($_POST['edit_cancel']) || isset($_POST['password_cancel'])){
197       del_lock ($this->grouptab->dn);
198       unset ($this->grouptab);
199       $this->grouptab= NULL;
200       unset($_SESSION['objectinfo']);
201     }
203     /* Finish group edit is triggered by the tabulator dialog, so
204        the user wants to save edited data. Check and save at this
205        point. */
206     if (isset($_POST['edit_finish'])){
208       /* Check tabs, will feed message array */
209       $message= $this->grouptab->check();
211       /* Save, or display error message? */
212       if (count($message) == 0){
214         /* Save user data to ldap */
215         $this->grouptab->save();
216         gosa_log ("Group object'".$this->dn."' has been saved");
218         /* Group has been saved successfully, remove lock from
219            LDAP. */
220         if ($this->dn != "new"){
221           del_lock ($this->dn);
222         }
224         /* There's no page reload so we have to read new users at
225            this point. */
226         $this->reload ();
227         unset ($this->grouptab);
228         $this->grouptab= NULL;
229         unset ($_SESSION['objectinfo']);
231       } else {
232         /* Ok. There seem to be errors regarding to the tab data,
233            show message and continue as usual. */
234         show_errors($message);
235       }
236     }
238     /* User wants to edit data? */
239     if ($s_action=="edit"){
241       /* Get 'dn' from posted 'uid', must be unique */
242       $this->dn= $this->grouplist[trim($s_entry)]['dn'];
244       /* Check locking, save current plugin in 'back_plugin', so
245          the dialog knows where to return. */
246       if (($user= get_lock($this->dn)) != ""){
247         return(gen_locked_message ($user, $this->dn));
248       }
250       /* Lock the current entry, so everyone will get the
251          above dialog */
252       add_lock ($this->dn, $this->ui->dn);
254       /* Set up the users ACL's for this 'dn' */
255       $acl= get_permissions ($this->dn, $this->ui->subtreeACL);
257       /* Register grouptab to trigger edit dialog */
258       $this->grouptab= new grouptabs($this->config,
259           $this->config->data['TABS']['GROUPTABS'], $this->dn);
260       $this->grouptab->set_acl($acl);
261       $_SESSION['objectinfo']= $this->dn;
262     }
264     /* Remove user was requested */
265     if ($s_action=="del"){
266       /* Get 'dn' from posted 'uid' */
267       $this->dn= $this->grouplist[trim($s_entry)]['dn'];
269       /* Load permissions for selected 'dn' and check if
270          we're allowed to remove this 'dn' */
271       $acl= get_permissions ($this->dn, $this->ui->subtreeACL);
272       $this->acl= get_module_permission($acl, "group", $this->dn);
273       if (chkacl($this->acl, "delete") == ""){
275         /* Check locking, save current plugin in 'back_plugin', so
276            the dialog knows where to return. */
277         if (($user= get_lock($this->dn)) != ""){
278           return(gen_locked_message ($user, $this->dn));
279         }
281         /* Lock the current entry, so nobody will edit it during deletion */
282         add_lock ($this->dn, $this->ui->dn);
283         $smarty->assign("info", sprintf(_("You're about to delete the group '%s'."), $this->dn));
284         return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
285       } else {
287         /* Obviously the user isn't allowed to delete. Show message and
288            clean session. */
289         print_red (_("You are not allowed to delete this group!"));
290       }
291     }
293     /* Confirmation for deletion has been passed. Group should be deleted. */
294     if (isset($_POST['delete_group_confirm'])){
296       /* Some nice guy may send this as POST, so we've to check
297          for the permissions again. */
298       if (chkacl($this->acl, "delete") == ""){
300         /* Delete request is permitted, perform LDAP action */
301         $this->grouptab= new grouptabs($this->config,
302             $this->config->data['TABS']['GROUPTABS'], $this->dn);
303         $this->grouptab->set_acl(array($this->acl));
304         $this->grouptab->delete ();
305         gosa_log ("Group object'".$this->dn."' has been removed");
306         unset ($this->grouptab);
307         $this->grouptab= NULL;
309         /* Group list has changed, reload it. */
310         $this->reload ();
311       } else {
313         /* Normally this shouldn't be reached, send some extra
314            logs to notify the administrator */
315         print_red (_("You are not allowed to delete this group!"));
316         gosa_log ("Warning: '".$this->ui->uid."' tried to trick group deletion.");
317       }
319       /* Remove lock file after successfull deletion */
320       del_lock ($this->dn);
321       unset($_SESSION['objectinfo']);
322     }
325     /* Delete group canceled? */
326     if (isset($_POST['delete_cancel'])){
327       del_lock ($this->dn);
328       unset($_SESSION['objectinfo']);
329     }
331     /* Show tab dialog if object is present */
332     if ($this->grouptab){
333       $display= $this->grouptab->execute();
335       /* Don't show buttons if tab dialog requests this */
336       if (!$this->grouptab->by_object[$this->grouptab->current]->dialog){
337         $display.= "<p style=\"text-align:right\">\n";
338         $display.= "<input type=submit name=\"edit_finish\" value=\""._("Finish")."\">\n";
339         $display.= "&nbsp;\n";
340         $display.= "<input type=submit name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
341         $display.= "</p>";
342       }
343       return ($display);
344     }
346     /* Prepare departments */
347     $options= "";
348     foreach ($this->config->idepartments as $key => $value){
349             if ($groupfilter['depselect'] == $key){
350                     $options.= "<option selected value='$key'>$value</option>";
351             } else {
352                     $options.= "<option value='$key'>$value</option>";
353             }
354     }
356     // Managment
357     $listhead = "<div style='background:#F0F0F9;padding:5px;'>".
358       " <input type='image' align='middle' src='images/list_back.png' title='"._("Go up one department")."' alt='"._("Up")."' name='dep_back'>&nbsp;".
359       " <input type='image' src='images/list_root.png' align='middle' title='"._("Go to root department")."' name='dep_root' alt='"._("Root")."'>&nbsp;".
360       " <input type='image' align='middle' src='images/list_home.png' title='"._("Go to users department")."'
361  alt='"._("Home")."' name='dep_home'>&nbsp;".
362       " <img src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;".
363       " <input type='image' align='middle' src='images/list_new_group.png' title='"._("Create new group")."'
364  alt='"._("New")."' name='group_new'>&nbsp;".
365       " <img src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;".
366       _("Current base")."&nbsp;<select name='depselect' onChange='mainform.submit()'>$options</select>".
367        " <input type='image' src='images/list_submit.png' align='middle' title='"._("Submit department")."'   name='submit_department' alt='"._("Submit")."'>&nbsp;".
368       "</div>";
370     
371     $actions = "<input type='image' src='images/edit.png' alt='"._("edit")."' name='group_edit_%KEY%' title='"._("Edit this entry")."'>";
372     $actions.= "<input type='image' src='images/edittrash.png' alt='"._("delete")."' name='group_del_%KEY%' title='"._("Delete this entry")."'>";
374     // Defining Links
375     $linkopen = "<a href='?plug=".$_GET['plug']."&amp;act=dep_open&amp;dep_id=%s'>%s</a>";
377     // image Buttons 
378     $editlink = "<a href='?plug=".$_GET['plug']."&amp;id=%s&amp;act=edit_entry'>%s</a>";
379     $userimg  = "<img src='images/select_groups.png' alt='User'    title='%s'>";
381     // Extension images 
382     $posiximg = "<img src='images/select_groups.png'        alt='P'  title='"._("Posix")  ."'>";
383     $mailimg  = "<img src='images/mailto.png'             alt='M'  title='"._("Mail")   ."'>";
384     $sambaimg = "<img src='images/select_winstation.png'  alt='S'  title='"._("Samba")  ."'>";
385     $applimg  = "<img src='images/select_application.png' alt='A'  title='"._("Application")."'>"; 
386     $phoneimg  = "<img src='images/select_phone.png'      alt='Ph' title='"._("Phone")  ."'>"; 
387     // Space
388     $empty    = "<img src='images/empty.png' style='width:16px;height:16px;' alt=''>";
391     $divlist = new divlist("groupstab");
392     $divlist->SetHeader(array(
393           array("string" => "&nbsp;"),
394           array("string" => _("Groupname")." / "._("Department")),
395           array("string" => _("Properties"), "attach" => "style='width:100px;'"),
396           array("string" => _("Actions")    ,"attach" => "style='border:none'")
397           ));
400     $divlist->SetSummary(_("This table displays all groups, in the selected tree."));
401     $divlist->SetEntriesPerPage(20);
403     foreach($this->departments as $key=> $val){
405       if(!isset($this->config->departments[trim($key)])){
406         $this->config->departments[trim($key)]="";
407       }
409       $non_empty="";
410       $keys= str_replace("/","\/",$key);
411       foreach($this->config->departments as $keyd=>$vald ){
412         if(preg_match("/".$keys."\/.*/",$keyd)){
413           $non_empty="full";
414         }
415       }
418       $field1 = array("string" => "<img src='images/".$non_empty."folder.png' alt='department'>");
419       $field2 = array("string" => sprintf($linkopen,base64_encode($key),$val));
420       $field3 = array("string" => "&nbsp;");
421       $field4 = array("string" => "&nbsp;","attach"=>"style='text-align:right;border:none'");
423       $divlist->AddEntry(array($field1,$field2,$field3,$field4));
424     }
426     foreach($this->grouplist as $key => $val){
428       if(isset($val['objectClass'])){
429         if(in_array("posixGroup",           $val['objectClass']))   $posix = $posiximg;   else $posix   = $empty;
430         if(in_array("gosaMailAccount",      $val['objectClass']))   $mail  = $mailimg;    else $mail    = $empty;
431         if(in_array("sambaGroupMapping",    $val['objectClass']))   $samba = $sambaimg;   else $samba   = $empty;
432         if(in_array("gosaApplicationGroup", $val['objectClass']))   $appl  = $applimg;    else $appl    = $empty;
433         if(in_array("goFonPickupGroup",     $val['objectClass']))   $phone = $phoneimg;   else $phone   = $empty;
434       }else{
435         $posix=$mail=$samba=$appl=$phone=$empty;
436       }
438       $title = "title='gid : ".$key." - dn : ".$val['dn']."'";
440       if(!isset($val['description'][0])){
441         $desc = "";
442       }else{
443         $desc = " - [ ".$val['description'][0]." ]";
444       }      
445       $field1 = array("string" => sprintf($userimg,$val['dn']),"attach"=>"style='width:20px;align:middle;'");
446       $field2 = array("string" => sprintf($editlink,$key,($val['cn']['0'].$desc)),"attach"=>$title);
447       $field3 = array("string" => $posix."&nbsp;".$mail."&nbsp;".$samba."&nbsp;".$appl."&nbsp;".$phone);  
448       $field4 = array("string" => preg_replace("/%KEY%/", $key, $actions),"attach"=>"style='text-align:right;border:none;width:32px;'");
449       
450       $divlist->AddEntry(array($field1,$field2,$field3,$field4));    
451     }
453     /* Show main page */
454     $smarty->assign("grouplisthead", $listhead);
455     $smarty->assign("grouplist", $divlist->DrawList());
456     $smarty->assign("search_image", get_template_path('images/search.png'));
457     $smarty->assign("tree_image", get_template_path('images/tree.png'));
458     $smarty->assign("infoimage", get_template_path('images/info.png'));
459     $smarty->assign("launchimage", get_template_path('images/launch.png'));
460     $smarty->assign("deplist", $this->config->idepartments);
461     foreach( array("depselect", "guser", "regex", "primarygroups", "mailgroups","appgroups", "sambagroups", "functionalgroups", "subsearch") as $type){
462       $smarty->assign("$type", $groupfilter[$type]);
463     }
465     /* Extend if we are not using javascript */
466     $smarty->assign("apply", apply_filter());
467     $smarty->assign("alphabet", generate_alphabet());
468     $smarty->assign("hint", print_sizelimit_warning());
470     return($smarty->fetch(get_template_path('headpage.tpl', TRUE)));
471   }
475   function reload2()
476   {
477     /* Get config */
478     $groupfilter= get_global('groupfilter');
480     /* Set base for all searches */
481     $base= $groupfilter['depselect'];
483     /* Regex filter? */
484     if ($groupfilter['regex'] != ""){
485       $regex= $groupfilter['regex'];
486     } else {
487       $regex= "*";
488     }
490     /* User filter? */
491     $filter= "";
492     $error= "";
493     $error2= "";
494     $this->grouplist= array();
496     /* What are primary groups? */
497     $primaries= array();
498     $ldap= $this->config->get_ldap_link(TRUE);
499     $ldap->cd($base);
500     $ldap->search("(&(uid=$regex)(!(uid=*$))(objectClass=posixAccount)(gidNumber=*))", array("gidNumber", "cn"));
501     $error= $ldap->error;
502     while ($attrs= $ldap->fetch()){
503       $primaries[$attrs['gidNumber'][0]]= $attrs['cn'][0];
504     }
506     if ($groupfilter['primarygroups'] == "checked"){
507       $filter.= "(&(objectClass=posixGroup)(|";
508       foreach ($primaries as $gidNumber => $cn){
509         $filter.= "(gidNumber=$gidNumber)";
510       }
511       $filter.= "))";
512     } else {
513       $filter.= "(&(objectClass=posixGroup)(!(|";
514       foreach ($primaries as $gidNumber => $cn){
515         $filter.= "(gidNumber=$gidNumber)";
516       }
517       $filter.= ")))";
518     }
519  /* Set filter depending on selection */
520     $sfilter= "";
521     if ($groupfilter['appgroups'] == "checked"){
522       $filter.= "(objectClass=gosaApplicationGroup)";
523     }
524     if ($this->config->current['SAMBAVERSION'] == 3){
525       if ($groupfilter['primarygroups'] != "checked"){
526         $sfilter= "(objectClass=sambaGroupMapping)";
527       } elseif ($groupfilter['sambagroups'] == "checked"){
528         $filter.= "(objectClass=sambaGroupMapping)";
529       }
530     }
532     if ($groupfilter['mailgroups'] == "checked"){
533       $filter.= "(objectClass=gosaMailAccount)";
534     }
535     if ($groupfilter['functionalgroups'] == "checked"){
536       $ldap->cd($base);
537       $ldap->set_size_limit($_SESSION['size_limit']);
538       $ldap->search("(&(cn=$regex)(objectClass=posixGroup)(!(|(objectClass=gosaMailAccount)(objectClass=gosaApplicationGroup)$sfilter)))", array("cn",      "gidNumber", "description"));
539       $error2= $ldap->error;
540       while ($attrs= $ldap->fetch()){
541         if (!isset($primaries[$attrs['gidNumber'][0]])){
542           if (isset($attrs["description"][0])){
543             $this->grouplist[$attrs["dn"]]= $attrs["cn"][0]." [".
544               $attrs["description"][0]."]";
545           } else {
546             $this->grouplist[$attrs["dn"]]= $attrs["cn"][0];
547           }
548         }
549       }
550     }
552     /* Generate grouplist */
553     if ($filter != ""){
554       $filter= "(&(cn=$regex)(objectClass=posixGroup)(|$filter))";
555       if ($groupfilter['guser'] != ""){
556         $filter= "(&(|(memberUID=" . $groupfilter['guser'] . ")(cn=" . $groupfilter['guser'] . "))$filter)";
557       }
558     }
559     if ($groupfilter['subsearch'] == "checked"){
560       $res= get_list($this->ui->subtreeACL, "$filter", TRUE, $base, array("cn", "description", "gidNumber"), TRUE);
561     } else {
562       $base= get_groups_ou().$base;
563       $res= get_list($this->ui->subtreeACL, "$filter", FALSE, $base, array("cn", "description", "gidNumber"), TRUE);
564     }
565     if (preg_match("/size limit/i", $error) || preg_match("/size limit/i", $error2)){
566       $_SESSION['limit_exceeded']= TRUE;
567     }
569    foreach ($res as $value){
570       if (isset($value["description"][0])){
571         $this->grouplist[$value["dn"]]= $value["cn"][0]." [".
572           $value["description"][0]."]";
573       } else {
574         $this->grouplist[$value["dn"]]= $value["cn"][0];
575       }
576     }
578     natcasesort ($this->grouplist);
579     reset ($this->grouplist);
580   }
593   function reload()
594   {
595     /* Get config */
596     $groupfilter= get_global('groupfilter');
598     /* Set base for all searches */
599     $base= $groupfilter['depselect'];
601     /* Regex filter? */
602     if ($groupfilter['regex'] != ""){
603       $regex= $groupfilter['regex'];
604     } else {
605       $regex= "*";
606     }
608     /* User filter? */
609     $filter= "";
610     $error= "";
611     $error2= "";
612     $this->grouplist= array();
614     /* What are primary groups? */
615     $primaries= array();
616     $ldap= $this->config->get_ldap_link(TRUE);
617     $ldap->cd($base);
618     $ldap->search("(&(uid=$regex)(!(uid=*$))(objectClass=posixAccount)(gidNumber=*))", array("gidNumber", "cn"));
619     $error= $ldap->error;
620     while ($attrs= $ldap->fetch()){
621       $primaries[$attrs['gidNumber'][0]]= $attrs['cn'][0];
622     }
624     if ($groupfilter['primarygroups'] == "checked"){
625       $filter.= "(&(objectClass=posixGroup)(|";
626       foreach ($primaries as $gidNumber => $cn){
627         $filter.= "(gidNumber=$gidNumber)";
628       }
629       $filter.= "))";
630     } else {
631       $filter.= "(&(objectClass=posixGroup)(!(|";
632       foreach ($primaries as $gidNumber => $cn){
633         $filter.= "(gidNumber=$gidNumber)";
634       }
635       $filter.= ")))";
636     }
638   
639     /* Set filter depending on selection */
640     $sfilter= "";
641     if ($groupfilter['appgroups'] == "checked"){
642       $filter.= "(objectClass=gosaApplicationGroup)";
643     }
644     if ($this->config->current['SAMBAVERSION'] == 3){
645       if ($groupfilter['primarygroups'] != "checked"){
646         $sfilter= "(objectClass=sambaGroupMapping)";
647       } elseif ($groupfilter['sambagroups'] == "checked"){
648         $filter.= "(objectClass=sambaGroupMapping)";
649       }
650     }
652     if ($groupfilter['mailgroups'] == "checked"){
653       $filter.= "(objectClass=gosaMailAccount)";
654     }
655     if ($groupfilter['functionalgroups'] == "checked"){
656       $ldap->cd($base);
657       $ldap->set_size_limit($_SESSION['size_limit']);
658       $ldap->search("(&(cn=$regex)(objectClass=posixGroup)(!(|(objectClass=gosaMailAccount)(objectClass=gosaApplicationGroup)$sfilter)))", array("cn", "gidNumber", "description"));
659       $error2= $ldap->error;
660       while ($attrs= $ldap->fetch()){
661         if (!isset($primaries[$attrs['gidNumber'][0]])){
662           $this->grouplist[$attrs['gidNumber'][0]]= $attrs;
663         }
664       }
665     }
667     /*
668      * We also need to search for the departments
669      * So we are able to navigate like in konquerer
670      */
671     $base2 = preg_replace("/ou=people,/i","",$base);
673     $res3 =  get_list2($this->ui->subtreeACL, "(&(|(ou=$regex)(description=$regex))(objectClass=gosaDepartment))",
674                               TRUE, $base2, array("ou", "description"), TRUE);
676     $this->departments= array();
677     $tmp = array();
678     foreach ($res3 as $value){
679       $tmp[strtolower($value['dn']).$value['dn']]=$value;
680     }
681     ksort($tmp);
682     foreach($tmp as $value){
683       if($value["description"][0]!=".."){
684         $this->departments[$value['dn']]=convert_department_dn2($value['dn'])." - [".$value["description"][0]."]";
685       }else{
686         $this->departments[$value['dn']]=$value["description"][0];
687       }
688     }
690     /* Generate grouplist */
691     if ($filter != ""){
692       $filter= "(&(cn=$regex)(objectClass=posixGroup)(|$filter))";
693       if ($groupfilter['guser'] != ""){
694         $filter= "(&(|(memberUID=" . $groupfilter['guser'] . ")(cn=" . $groupfilter['guser'] . "))$filter)";
695       }
696     }
697     if ($groupfilter['subsearch'] == "checked"){
698       $res= get_list($this->ui->subtreeACL, "$filter", TRUE, $base, array("cn", "description", "gidNumber"), TRUE);
699     } else {
700       $base= get_groups_ou().$base;
701       $res= get_list($this->ui->subtreeACL, "$filter", FALSE, $base, array("cn", "description", "gidNumber"), TRUE);
702     }
703     if (preg_match("/size limit/i", $error) || preg_match("/size limit/i", $error2)){
704       $_SESSION['limit_exceeded']= TRUE;
705     }
707     foreach ($res as $value){
708       $this->grouplist[$value['gidNumber'][0]]= $value;
709     }
713       $tmp=array();
714     foreach($this->grouplist as $tkey => $val ){
715       $tmp[strtolower($val['cn'][0]).$val['cn'][0]]=$val;
716     }
717     ksort($tmp);
718     $this->grouplist=array();
719     foreach($tmp as $val){
720       $this->grouplist[]=$val;
721     }
722     reset ($this->grouplist);
723   }
725   function remove_from_parent()
726   {
727     /* Optionally execute a command after we're done */
728     $this->postremove();
729   }
732   /* Save data to object */
733   function save_object()
734   {
735   }
738   /* Check values */
739   function check()
740   {
741   }
744   /* Save to LDAP */
745   function save()
746   {
747     /* Optionally execute a command after we're done */
748     $this->postcreate();
749   }
751   function adapt_from_template($dn)
752   {
753   }
755   function password_change_needed()
756   {
757   }
759   function show_header($button_text, $text, $disabled= FALSE)
760   {
761   }
763   function remove_lock()
764   {
765     if (isset($this->grouptab->dn)){
766       del_lock ($this->grouptab->dn);
767     }
768   }
772 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
773 ?>