Code

59fb4d7ca1c03cb6b995207063ffc9162ca682e3
[gosa.git] / plugins / admin / groups / class_groupApplication.inc
1 <?php
2 class appgroup extends plugin
3 {
4   /* CLI vars */
5   var $cli_summary= "Manage application groups";
6   var $cli_description= "Some longer text\nfor help";
7   var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
9   /* Appgroup attributes */
10   var $gosaMemberApplication= array();
12   /* Helpers */
13   var $departments        = "";       // All departments within $this->curbase;
14   var $apps               = array();  // All available applications
15   var $used_apps          = array();  // Specifies which applications are currently assigned 
17   var $option_name  = array();
18   var $option_value = array();
19   var $appoption    = array();
21   var $table          = "";
22   var $curbase        = "";
23   var $curCatDir      ;
24   var $curCatDepth    =0;         //
26   /* attribute list for save action */
27   var $attributes= array();
28   var $objectclasses= array("gosaApplicationGroup");
30   function appgroup ($config, $dn= NULL)
31   {
32     plugin::plugin ($config, $dn);
34     /* Load member applications */
35     if (isset ($this->attrs["gosaMemberApplication"][0])){
36       for ($i= 0; $i<$this->attrs["gosaMemberApplication"]["count"]; $i++){
37         $this->gosaMemberApplication[]=
38           $this->attrs["gosaMemberApplication"][$i];
39       }
40     }
42     /* Load application options */
43     if (isset($this->attrs['gosaApplicationParameter'])){
44       for ($i= 0; $i<$this->attrs['gosaApplicationParameter']['count']; $i++){
45         $option= preg_replace('/^[^:]+:/', '',
46             $this->attrs['gosaApplicationParameter'][$i]);
47         $name= preg_replace('/:.*$/', '',
48             $this->attrs['gosaApplicationParameter'][$i]);
49         $this->appoption[$name]= $option;
50       }
51     }
53     /* Parse MemberApplication*/
54     $tmp = array();
55     $tmp2 = array();
56     $prios = array();
57     $cats = array();
59     foreach($this->gosaMemberApplication as $memberApp){
60       if(preg_match("/\|/i",$memberApp)){
61     
62         $tmp = split("\|",$memberApp);
63  
64         if(!empty($tmp[0])){
65           $tmp2[$tmp[1]][$tmp[2]] = array("App"=>$tmp[0]);
66         }
67         if(!empty($tmp[1])){
68           $n = split("/",$tmp[1]);
69           $c = count($n);
70           $cats [$tmp[1]] = $n[$c-1];
71         }
72         $prios[$tmp[1]][$tmp[2]] = $tmp[2];
73       }else{
74         $tmp2[]['App'] = $memberApp;
75       }
76     }
78     $this->Categories = $cats;
80     $this->gosaMemberApplication = $tmp2;
81     $cats[""]="";
82     foreach($cats as $cat ){
83       if((isset($prios[$cat]))&&(count($prios[$cat]))){
84         $max = max($prios[$cat]);
85         $min = 1;//min($prios[$cat]);  
86         $last = false;
87         for($i = $min ; $i < $max ; $i++){
88           if(!isset($prios[$cat][$i])){
89             if($last == false){
90               $this->gosaMemberApplication[$cat][$i]['App'] = "__SEPARATOR__".$i;
91             
92               $last = true;
93             }
94           }else{
95             $last = false;
96           }
97         }
98       }
99     }
101     $tmp = array();
102     foreach($this->gosaMemberApplication as $key =>  $entries){
103       ksort ($entries);
104       foreach($entries as $entry){
105         $tmp[$key][]= $entry;
106       }
107     }
108     $this->gosaMemberApplication = $tmp;
109     $this->curbase = $this->config->current['BASE'];
110   }
112   function catDown($id){
113   
114    /* Get all cats depinding on current dir */
115     $cats = $this->GetSubdirs($this->curCatDir);
117     $ret = array();
119     if((in_array($id,array_flip($cats)))&&(count($cats)>1)){
120       if(count($cats) == 2){
121         $ret = array_reverse($cats);
122       }else{
123         $cnt = 0;
124         $hit = 0;
125         foreach($cats as $cat=>$name){
126           if($cat  == $id){
127             $hit = $cnt;
128           }
129           $cnt ++;
130         }
131           
132         
133         if($hit == 0){ 
134           $first  = array_slice($cats,0,0);
135           $middle = array_slice($cats,0,2);
136           $last   = array_slice($cats,$hit+2,$cnt);
137         }else{
138           $first  = array_slice($cats,0,$hit);
139           $middle = array_slice($cats,$hit,2);
140           $last   = array_slice($cats,$hit+2,$cnt);
141         }
142 /*        print "first";
143         print_a($first);
144         print "middle";
145         print_a($middle);
146         print "last";
147         print_a($last);
148 */
149         foreach($first as $cat => $name){
150           $ret[$cat]=$name;
151         }
152         foreach(array_reverse($middle) as $cat => $name){
153           $ret[$cat]=$name;
154         }
155         foreach($last as $cat => $name){
156           $ret[$cat]=$name;
157         }
158       }
161       foreach($cats as $cat => $name){
162         unset($this->Categories[$cat]);
163       }
164       foreach($ret as $cat => $name){
165         $this->Categories[$cat]=$name;
166       }
167       
168     }
169   }
171   function catUp($id)
172   {
173     /* Get all cats depinding on current dir */
174     $cats = $this->GetSubdirs($this->curCatDir);
176     $ret = array();
178     if((in_array($id,array_flip($cats)))&&(count($cats)>1)){
179       if(count($cats) == 2){
180         $ret = array_reverse($cats);
181       }else{
182         $cnt = 0;
183         $hit = 0;
184         foreach($cats as $cat => $name){
185           $cnt ++;
186           if($cat  == $id){
187             $hit = $cnt;
188           }
189         }
191         if($hit>1){
192           if($hit == 2){ 
193             $first  = array_slice($cats,0,$hit-2);
194             $middle = array_slice($cats,$hit-2,$hit);
195             $last   = array_slice($cats,$hit,$cnt); 
196           }else{
197             $first  = array_slice($cats,0,$hit-2);
198             $middle = array_slice($cats,$hit-2,2);
199             $last   = array_slice($cats,$hit,$cnt); 
200           }
201           foreach($first as $cat => $name){
202             $ret[$cat]=$name;
203           }
204           foreach(array_reverse($middle) as $cat => $name){
205             $ret[$cat]=$name;
206           }
207           foreach($last as $cat => $name){
208             $ret[$cat]=$name;
209           }
210         }
211       }
213       foreach($cats as $cat => $name){
214         unset($this->Categories[$cat]);
215       } 
216       foreach($ret as $cat => $name){
217         $this->Categories[$cat]=$name;
218       }
219     }
220     
222   }
224   function getOneUp($appl)
225   {
226     $cat = $this->curCatDir;
227     if(!isset($this->gosaMemberApplication[$cat][($appl-1)])) return;
228     $f = 1;
229     if($appl == 1 ){
230       $f = 0;
231     }
232     $first  = array_slice($this->gosaMemberApplication[$cat],0,($appl-1));
233     $middle = array_slice($this->gosaMemberApplication[$cat],$appl-1,(($appl+1)-$f));
234     $last   = array_slice($this->gosaMemberApplication[$cat],($appl+1));
235     $tmp = array();
236     foreach($first as $entry){
237       $tmp[] = $entry;
238     }
239     foreach(array_reverse($middle) as $entry){
240       $tmp[] = $entry;
241     }
242     foreach($last as $entry){
243       $tmp[] = $entry;
244     }
245     $this->gosaMemberApplication[$cat] =$tmp;
246   }
247   
248   function getOneDown($appl){
249     $cat = $this->curCatDir;
250     if(!isset($this->gosaMemberApplication[$cat][($appl+1)])) return;
251     $f = 0;
252     if($appl == 0 ){
253       $f = 1;
254     }
255     $first  = array_slice($this->gosaMemberApplication[$cat],0,($appl));
256     $middle = array_slice($this->gosaMemberApplication[$cat],$appl,(($appl+1+$f)));
257     $last   = array_slice($this->gosaMemberApplication[$cat],($appl+2));
258   
259     $tmp = array();
260     foreach($first as $entry){
261       $tmp[] = $entry;
262     }
263     foreach(array_reverse($middle) as $entry){
264       $tmp[] = $entry;
265     }
266     foreach($last as $entry){
267       $tmp[] = $entry;
268     }
269     $this->gosaMemberApplication[$cat] =$tmp;
270   }
271   
272   function AddSeperator($id)
273   {
274     $found  = false;
275     $cat    = "";
276     $tmp = array();
277     foreach($this->gosaMemberApplication[$this->curCatDir] as $appID => $app){  
278       $tmp[] = $app;    
279       if(($app['App'] == $id)&&(!$found)){
280         $cnt = count($this->gosaMemberApplication[$this->curCatDir]);
281         $tmp[] = array("App" => "__SEPARATOR__".($cnt+1));
282         $found = true;
283       }
284     }
285     if($found){
286       $this->gosaMemberApplication[$this->curCatDir]=$tmp;
287     }
288     return;
289     $cat = $this->curCatDir;
290     $cnt = count($this->gosaMemberApplication[$cat]);
291     $tmp = array("App" => "__SEPARATOR__".($cnt+1));
292     $this->gosaMemberApplication[$cat][] = $tmp;
293   }
295   function execute()
296   {
297           /* Call parent execute */
298         plugin::execute();
300     if((isset($_GET['act']))&&($_GET['act']=="depopen")){
301       $dep = base64_decode($_GET['depid']);  
302       if(isset($this->config->idepartments[$dep])){
303         $this->curbase = $dep;
304       }
305     }
307     if((isset($_GET['act']))&&($_GET['act']=="open")){
308       $this->curCatDir = $_GET['id'];
309     }
311     /* Do we need to flip is_account state? */
312     if (isset($_POST['modify_state'])){
313       $this->is_account= !$this->is_account;
314     }
316     /* Do we represent a valid group? */
317     if (!$this->is_account && $this->parent == NULL){
318       $display= "<img alt=\"\" src=\"images/stop.png\" align=\"middle\">&nbsp;<b>".
319         _("This 'dn' is no appgroup.")."</b>";
320       return ($display);
321     }
323     /* Show tab dialog headers */
324     $display= "";
325     if ($this->parent != NULL){
326       if ($this->is_account){
327         $display= $this->show_header(_("Remove applications"),
328             _("This group has application features enabled. You can disable them by clicking below."));
329       } else {
330         $display.= $this->show_header(_("Create applications"),
331             _("This group has application features disabled. You can enable them by clicking below."));
332         return ($display);
333       }
334     }
337     /* Add Categorie */ 
338   
339     
340     if((isset($_POST['AddCat']))&&(isset($_POST['CatName']))&&(!empty($_POST['CatName']))){
341       
342       if(preg_match("/[^0-9a-z,\.-;:_#\+\- ]/i",$_POST['CatName'])){
343         print_red(_("Invalid character in category name."));
344       }elseif(!in_array($_POST['CatName'],$this->Categories)){ 
345         if(empty($this->curCatDir)){
346           $this->Categories[$_POST['CatName']]=$_POST['CatName'];
347         }else{
348           $this->Categories[$this->curCatDir."/".$_POST['CatName']]=$_POST['CatName'];
349         }
350       }else{
351         print_red(_("The specified category already exists."));
352       }
353     }
356     $this->reload();
357     foreach($_POST as $name => $value){
358       if(preg_match("/AddSep_/",$name)){
359         $this->AddSeperator($value);
360       }
361     
363       if(preg_match("/DelApp_/",$name)){
364         $app = $value; 
366         foreach($this->gosaMemberApplication as $key =>  $cat){
367           foreach($cat as $key2 => $app){
368             if($app['App'] == $value){
369               unset($this->gosaMemberApplication[$key][$key2]);
370               if(isset($this->used_apps[$value])){
371                 unset($this->used_apps[$value]);
372               }
373             }
374           }
375         }
376       }
377       if(preg_match("/DelCat_/",$name)){
378         $app = $value; 
379         foreach($this->Categories as $key =>  $cat){
380           if($cat == $value){
381             unset($this->Categories[$key]);
382           }
383         }
384       }
385       if(preg_match("/EdiApp_/",$name)){
386         $appname = $value;
387         /* We've got the appname, get parameters from ldap */
388         $ldap= $this->config->get_ldap_link();
389         $ldap->cd($this->config->current['BASE']);
390         $ldap->search("(&(objectClass=gosaApplication)(cn=$appname))");
391         if ($ldap->count() != 1){
392           print_red (_("The selected application name is not uniq. Please check your LDAP."));
393         } else {
394           $attrs= $ldap->fetch();
395           if(isset($attrs['gosaApplicationParameter'])){
396             $this->dialog= TRUE;
398             /* Fill name and value arrays */
399             for ($i= 0; $i<$attrs['gosaApplicationParameter']['count']; $i++){
400               $option= preg_replace('/^[^:]+:/', '',
401                   $attrs['gosaApplicationParameter'][$i]);
402               $name= preg_replace('/:.*$/', '', 
403                   $attrs['gosaApplicationParameter'][$i]);
404               $this->option_name[$i]= $name;
406               /* Fill with values from application, default should be
407                  loaded by the external scripts */
408               if (isset($this->appoption[$name])){
409                 $this->option_value[$i]= $this->appoption[$name];
410               }
411             }
413             /* Create edit field */
414             $table= "<table summary=\"\">";
415             for ($i= 0; $i < count($this->option_name); $i++){
416               if (isset($this->option_value[$i])){
417                 $value= $this->option_value[$i];
418               } else {
419                 $value= "";
420               }
421               $table.="<tr><td>".$this->option_name[$i]."</td><td>".
422                 "<input name=\"value$i\" size=60 maxlength=250 ".
423                 "value=\"".$value."\"><br></td></tr>";
424             }
425             $table.= "</table>";
426             $this->table= $table;
427           } else {
428             print_red (_("The selected application has no options."));
429           }
430         }
431       }
432     }
433     $this->reload();
435     /* Add group with post */
436     if((isset($_GET['act']))&&($_GET['act']=="add")){
437       $this->used_apps[$_GET['id']]= $_GET['id'];
438       asort($this->used_apps);
439       $this->addApp($_GET['id']);
440     }
442     /* Add multiple */
443     if(isset($_POST['AddApps'])){
444       foreach($_POST as $name => $value){
445         if(preg_match("/AddApp_/",$name)){
446           $app = preg_replace("/AddApp_/","",$name);
447           $this->addApp($app);
448         }
449       }
450     }
453     /* Cancel edit options? */
454     if (isset($_POST['edit_options_cancel'])){
455       $this->dialog= FALSE;
456     }
458     /* Finish edit options? */
459     if (isset($_POST['edit_options_finish'])){
460       $this->dialog= FALSE;
462       /* Save informations passed by the user */
463       $this->option_value= array();
464       for ($i= 0; $i<count($this->option_name); $i++){
465         $this->appoption[$this->option_name[$i]]= $_POST["value$i"];
466         $this->is_modified= TRUE;
467       }
468     }
470     /* Prepare templating stuff */
471     $smarty= get_smarty();
472     $smarty->assign("used_apps", $this->used_apps);
473     $apps= array();
474     foreach ($this->apps as $key => $value){
475       if (!array_key_exists($key, $this->used_apps)){
476         $apps["$key"]= "$value";
477       }
478     }
480     $div = new DivSelectBox("appgroup");    
482     $div->SetHeight(300);
484     /* NEW LIST MANAGMENT
485      * We also need to search for the departments
486      * So we are able to navigate like in konquerer
487      */
489     $ldap = $this->config->get_ldap_link();
490     $ldap->cd($this->curbase) ;
491     $ldap->ls("(objectClass=gosaDepartment)"); 
492     $departments= array();
493     $tmp = array();
494     while ($value = $ldap->fetch()){
495       $tmp[strtolower($value['dn']).$value['dn']]=$value;
496     }
497     ksort($tmp);
498     foreach($tmp as $value){
499       if($value["description"][0]!=".."){
500         $departments[$value['dn']]=convert_department_dn($value['dn'])." - [".$value["description"][0]."]";
501       }else{
502         $departments[$value['dn']]=convert_department_dn($value['dn']);
503       }
504     }
506     /* END NEW LIST MANAGMENT
507      */
509     $linkopen = "<a href='?plug=".$_GET['plug']."&amp;act=depopen&amp;depid=%s'>%s</a>";
510     $linkadd  = "<a href='?plug=".$_GET['plug']."&amp;act=add&amp;id=%s'>%s</a>";
512     $base_back = preg_replace("/^[^,]+,/","",$this->curbase);
513     if((strlen($base_back)>= strlen($this->config->current['BASE']))&&($this->curbase!=$this->config->current['BASE'])){
514       $div->AddEntry(array(
515             array("string"=>sprintf($linkopen,base64_encode($base_back),".. ["._("back")."]"),
516               "attach"=>"style='border:0px;'")
517             ));
518     }
519     foreach($departments as $key => $app){
520       $div->AddEntry(array(
521             array("string"=>"<img src='images/folder.png' alt='"._("department")."'>&nbsp;".sprintf($linkopen,base64_encode($key),$app),
522               "attach"=>"style='border:0px;'")
523             ));
524     }
526     foreach($apps as $key => $app){
527       $div->AddEntry(array(
528             array("string"=>sprintf("<input type='checkbox' value='1' name='AddApp_%s'>",$key).
529               "<img src='images/select_application.png' alt='"._("application")."'>&nbsp;".sprintf($linkadd,$key,$app),
530               "attach"=>"style='border:0px;'")
531             ));
532     }
534     if((isset($_GET['act']))&&(($_GET['act'] == "cat_up")||($_GET['act']=="cat_down"))){
535       if($_GET['act']=="cat_up"){
536         $this->catUp($_GET['id']);
537       }
538       if($_GET['act']=="cat_down"){
539         $this->catDown($_GET['id']);
540       }
541     }
543     if((isset($_GET['act']))&&(($_GET['act'] == "one_up")||($_GET['act']=="one_down"))){
544       if(isset($_GET['id'])){
545         $id   = $_GET['id'];
546         $act  = $_GET['act']; 
547         $found = -1;
548         if(isset($this->gosaMemberApplication[$this->curCatDir])){
549           foreach($this->gosaMemberApplication[$this->curCatDir] as $key =>  $member){
550             if($id == $member['App']){
551               $found = $key;
552             }
553           }
554         }
556         if($found != -1){
557           if($act == "one_up"){
558             $this->getOneUp($found);
559           }elseif($act == "one_down")   { 
560             $this->getOneDown($found);
561           }
562         }
563       }
564     }
566     $div2 = new DivSelectBox("appgroup");
567     $div2->SetHeight(300);
569     $linkopen       = "<img src='images/folder.png'>&nbsp;<a href='?plug=".$_GET['plug']."&amp;act=open&amp;id=%s'>%s</a>";
570     $catremove      = "&nbsp;<input type='image' src='images/edittrash.png' name='DelCat_%s' value='%s'>";
571     $app            = "<img src='images/select_application.png'>&nbsp;%s";
572     
573     $catupdown        = "<a href='?plug=".$_GET['plug']."&amp;act=cat_up&id=%s'>
574                        <img src='images/sort_up.png' border=0></a>&nbsp;<a href='?plug=".$_GET['plug']."&amp;act=cat_down&id=%s'> 
575                        <img src='images/sort_down.png' border=0></a>";
577     if(empty($this->curCatDir)){
578       $cnt =0;
579     }else{
580       $cnt = count(split("/",$this->curCatDir));
581       $tmp = split("/",$this->curCatDir);
582       $bbk = "";
583       for($i = 0 ; $i < ($cnt -1 ) ; $i++){
584         $bbk .= $tmp[$i];
585       }
586       $div2 ->AddEntry(array(array("string"=>sprintf($linkopen,$bbk,"..")),array("string"=>"&nbsp;","attach"=>"style='border-right:0px;'")));
587     }
589     $this->GetSubdirs($this->curCatDir);
591     foreach($this->GetSubdirs($this->curCatDir) as $path => $name){
592       $div2 ->AddEntry(array( 
593             array("string"=>sprintf($linkopen,$path,$name)),
594             array("string"=>preg_replace("/%s/",$path,$catupdown.$catremove).
595               "<img src='images/empty.png' width='19px'>",
596               "attach"=>"align='right' style='width:80px;border-right:0px;'"))); 
597     }
599     /* Append entries */
601     $separator ="<hr height=1  size=1></hr>"; 
603     $sep = "<input type='image' src='images/back.png' value='%s' name='AddSep_%s'>";
604   
605     $upudown ="<a href='?plug=".$_GET['plug']."&amp;act=one_up&id=%s'>   <img src='images/sort_up.png' border=0></a>".
606       "&nbsp;<a href='?plug=".$_GET['plug']."&amp;act=one_down&id=%s'> <img src='images/sort_down.png' border=0></a>".
607       "&nbsp;<input type='image' src='images/edittrash.png' name='DelApp_%s' value='%s'>";
608     $edit=      "&nbsp;<input type='image' src='images/edit.png' name='EdiApp_%s' value='%s'>";
610     if(isset($this->gosaMemberApplication[$this->curCatDir])){
611       foreach($this->gosaMemberApplication[$this->curCatDir] as $cat => $entry){
612         if(preg_match("/__SEPARATOR__/",$entry['App'])){
613           $div2 ->AddEntry(array(array("string"=>$separator),
614                 array("string"=>preg_replace("/\%s/",$entry['App'],$upudown."<img src='images/empty.png' width='19px'>"),"attach"=>"align='right' style='border-right:0px;'")));
615         }else{
616           $div2 ->AddEntry(array(array("string"=>sprintf($app,$entry['App'])),
617                 array("string"=>preg_replace("/\%s/",$entry['App'],$sep.$upudown.$edit),"attach"=>"align='right' style='border-right:0px;'")));
618         }
619       }
620     }
622     $smarty->assign("UsedApps", $div2->DrawList());
623     $smarty->assign("List", $div->DrawList());
624     $smarty->assign("apps", $apps);
626     /* Show main page */
627     if ($this->dialog){
628       $smarty->assign("table", $this->table);
629       $display.= $smarty->fetch (get_template_path('application_options.tpl', TRUE));
630     } else {
631       $display.= $smarty->fetch (get_template_path('application.tpl', TRUE));
632     }
633     return ($display);
634   }
637   function remove_from_parent()
638   {
639     plugin::remove_from_parent();
641     $this->attrs["gosaMemberApplication"]= array();
643     $ldap= $this->config->get_ldap_link();
644     $ldap->cd($this->dn);
645     $ldap->modify($this->attrs);
646     show_ldap_error($ldap->get_error());
648     /* Optionally execute a command after we're done */
649     $this->handle_post_events("remove");
650   }
653   /* Save to LDAP */
654   function save()
655   {
656     plugin::save();
658     /* Copy members */
659     $this->Categories[""]=""; 
660     $this->attrs["gosaMemberApplication"]= array();
661     $cats = array();
662     foreach($this->Categories as $name => $cats){
663       $cats[$name] =0;
664       if(isset($this->gosaMemberApplication[$name])){
665         foreach($this->gosaMemberApplication[$name] as $entry){
666           if(!preg_match("/__SEPARATOR__/",$entry['App'])){
667             $this->attrs["gosaMemberApplication"][]= $entry['App']."|".$name."|".$cats[$name];
668           }
669           $cats[$name] = $cats[$name] + 1;
670         }
671       }
672       if(($cats[$name]==0)&&(!empty($name))){
673         $this->attrs["gosaMemberApplication"][]= "|".$name."|".$cats[$name];
674       }
675     }
677     /* Are there application parameters to be saved */
678     $this->attrs['gosaApplicationParameter']= array();
679     foreach($this->appoption as $name => $value){
680       if ($value != ""){
681         $this->attrs['gosaApplicationParameter'][]= "$name:$value";
682       }
683     }
685     /* Write back to LDAP */
686     $ldap= $this->config->get_ldap_link();
687     $ldap->cd($this->dn);
688     $ldap->modify($this->attrs);
689     show_ldap_error($ldap->get_error());
691     /* Optionally execute a command after we're done */
692     if ($this->initially_was_account == $this->is_account){
693       if ($this->is_modified){
694         $this->handle_post_events("mofify");
695       }
696     } else {
697       $this->handle_post_events("add");
698     }
700   }
702   function check()
703   {
704     $message= array();
705     return ($message);
706   }
709   function reload()
710   {
711     /* Generate applist */
712     $this->apps= array();
713     $ldap= $this->config->get_ldap_link();
714     $ldap->cd ("ou=apps,".$this->curbase);
716     $ldap->ls ("(objectClass=gosaApplication)","ou=apps,".$this->curbase);
717     while ($attrs= $ldap->fetch()){
718       if (isset($attrs["description"][0])){    
719         $this->apps[$attrs["cn"][0]]=
720           $attrs["cn"][0]." (".
721           $attrs["description"][0].")";
722       } else {
723         $this->apps[$attrs["cn"][0]]=
724           $attrs["cn"][0];
725       }
726     }
727     natcasesort ($this->apps);
728     reset ($this->apps);
730     if(is_array($this->gosaMemberApplication))
731       foreach ($this->gosaMemberApplication as $cat){   
732         if(is_array($cat))
733           foreach($cat as $entry){
734             $this->used_apps[$entry['App']]= $entry['App'];
735           }
736       }
737   }
740   function addApp($cn)
741   {
742     if((isset($this->gosaMemberApplication[$this->curCatDir]))&&(is_array($this->gosaMemberApplication[$this->curCatDir]))){
743       foreach($this->gosaMemberApplication[$this->curCatDir] as $entry){
744         if($entry['App'] == $cn) return;
745       }
746     }
747     $this->gosaMemberApplication[$this->curCatDir][]= array("App"=>$cn);
748     $this->used_apps[$cn]=$cn;
749     $this->is_modified= TRUE;
750   }
753   function removeApp($cn)
754   {
755     $temp= array();
756     foreach ($this->gosaMemberApplication as $value){
757       if ($value != $cn){
758         $temp[]= $value;
759       }
760     }
761     $this->gosaMemberApplication= $temp;
762     $this->is_modified= TRUE;
763   }
765   function GetSubdirs($dir)
766   {
767     $ret = array();
768     $tmp1 = split("/",$this->curCatDir);
769  
770     foreach($this->Categories as $path=>$cat){
771       $tmp2 = split("/",$path);
772       
773       if((empty($this->curCatDir))&&(!preg_match("/\//",$path))){
774         $abort = false;
775       }elseif(((count($tmp1))+1) == (count($tmp2))){
776         $abort = false;
777         for($i = 0 ; $i < count($tmp1) ; $i++){
778           if($tmp1[$i] != $tmp2[$i]){
779             $abort = true;
780           }
781         }
782       }else{
783         $abort= true;
784       }
785       if(!$abort){
786         $ret[$path]=$cat;
787       } 
788     }
789   return($ret);
790   }
794 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
795 ?>