Code

9f3d02d436af3a4cca562031dfa76ff67fa8bbe7
[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");
31   function appgroup ($config, $dn= NULL)
32   {
33     plugin::plugin ($config, $dn);
35     /* Load member applications */
36     if (isset ($this->attrs["gosaMemberApplication"][0])){
37       for ($i= 0; $i<$this->attrs["gosaMemberApplication"]["count"]; $i++){
38         $this->gosaMemberApplication[]=
39           $this->attrs["gosaMemberApplication"][$i];
40       }
41     }
43     /* Load application options */
44     if (isset($this->attrs['gosaApplicationParameter'])){
45       for ($i= 0; $i<$this->attrs['gosaApplicationParameter']['count']; $i++){
46         $option= preg_replace('/^[^:]+:/', '',
47             $this->attrs['gosaApplicationParameter'][$i]);
48         $name= preg_replace('/:.*$/', '',
49             $this->attrs['gosaApplicationParameter'][$i]);
50         $this->appoption[$name]= $option;
51       }
52     }
54     /* Parse MemberApplication*/
55     $tmp = array();
56     $tmp2 = array();
57     $prios = array();
58     $cats = array();
60     foreach($this->gosaMemberApplication as $memberApp){
61       if(preg_match("/\|/i",$memberApp)){
62     
63         $tmp = split("\|",$memberApp);
64  
65         if(!empty($tmp[0])){
66           $tmp2[$tmp[1]][$tmp[2]] = array("App"=>$tmp[0]);
67         }
68         if(!empty($tmp[1])){
69           $n = split("/",$tmp[1]);
70           $c = count($n);
71           $cats [$tmp[1]] = $n[$c-1];
72         }
73         $prios[$tmp[1]][$tmp[2]] = $tmp[2];
74       }else{
75         $tmp2[]['App'] = $memberApp;
76       }
77     }
79     $this->Categories = $cats;
81     $this->gosaMemberApplication = $tmp2;
82     $cats[""]="";
83     foreach($cats as $cat ){
84       if((isset($prios[$cat]))&&(count($prios[$cat]))){
85         $max = max($prios[$cat]);
86         $min = 1;//min($prios[$cat]);  
87         $last = false;
88         for($i = $min ; $i < $max ; $i++){
89           if(!isset($prios[$cat][$i])){
90             if($last == false){
91               $this->gosaMemberApplication[$cat][$i]['App'] = "__SEPARATOR__".$i;
92             
93               $last = true;
94             }
95           }else{
96             $last = false;
97           }
98         }
99       }
100     }
102     $tmp = array();
103     foreach($this->gosaMemberApplication as $key =>  $entries){
104       ksort ($entries);
105       foreach($entries as $entry){
106         $tmp[$key][]= $entry;
107       }
108     }
109     $this->gosaMemberApplication = $tmp;
110     $this->curbase = $this->config->current['BASE'];
111   }
114   /* Combine new array */
115   function combineArrays($ar0,$ar1,$ar2)
116   {
117     $ret = array();
118     if(is_array($ar0))
119     foreach($ar0 as $ar => $a){
120         $ret[$ar]=$a;
121     }
122     if(is_array($ar1))
123     foreach($ar1 as $ar => $a){
124         $ret[$ar]=$a;
125     }
126     if(is_array($ar2))
127     foreach($ar2 as $ar => $a){
128         $ret[$ar]=$a;
129     }
130     return($ret);
131   }
133   function getpos($atr,$attrs)
134   {
135     $i = 0;
136     foreach($attrs as $attr => $name)    {
137       $i++;
138       if($attr == $atr){
139         return($i);
140       }
141     }
142     return(-1);
143   }
146   /* TRansports the geiven Arraykey one position up*/
147   function ArrayUp($atr,$attrs)
148   {
149     $ret = $attrs;
150     $pos = $this->getpos($atr,$attrs) ;
151     $cn = count($attrs);
152     if(!(($pos == -1)||($pos == 1))){
153       $before = array_slice($attrs,0,($pos-2));
154       $mitte  = array_reverse(array_slice($attrs,($pos-2),2));
155       $unten  = array_slice($attrs,$pos);
156       $ret = array();
157       $ret = $this->combineArrays($before,$mitte,$unten);
158     }
159     return($ret);
160   }
163   /* TRansports the geiven Arraykey one position up*/
164   function ArrayDown($atr,$attrs)
165   {
166     $ret = $attrs;
167     $pos = $this->getpos($atr,$attrs) ;
168     $cn = count($attrs);
169     if(!(($pos == -1)||($pos == $cn))){
170       $before = array_slice($attrs,0,($pos-1));
171       $mitte  = array_reverse(array_slice($attrs,($pos-1),2));
172       $unten  = array_slice($attrs,($pos+1));
173       $ret = array();
174       $ret = $this->combineArrays($before,$mitte,$unten);
175     }
176     return($ret);
177   }
180   function catUp($id)
181   {
182     /* Get all cats depinding on current dir */
183     $cats = $this->GetSubdirs($this->curCatDir);
184     $newcats =$this->ArrayUp($id,$cats);
186     foreach($newcats as $cat => $name){
187       unset($this->Categories[$cat]);
188     }
189     foreach($newcats as $cat => $name){
190       $this->Categories[$cat]=$name;
191     }
192   }
194   
195   function catDown($id)
196   {
197    /* Get all cats depinding on current dir */
198     $cats = $this->GetSubdirs($this->curCatDir);
199      
200     $newcats =$this->ArrayDown($id,$cats);
202     foreach($newcats as $cat => $name){
203       unset($this->Categories[$cat]);
204     }
205     foreach($newcats as $cat => $name){
206       $this->Categories[$cat]=$name;
207     }
208   }
211   function getOneUp($appl)
212   { 
213     $cat  = $this->curCatDir;
214     $apps = $this->gosaMemberApplication[$cat];
216     $appsA = array();
217     foreach ($apps as $appkey => $name){
218       $appsA[$name['App']] =$name['App'];
219     }
220  
221     $result = $this->ArrayUp($appl,$appsA);
223     $ret = array();
224     foreach($result as $app){
225       $ret[]=array("App"=>$app);
226     }
227     $this->gosaMemberApplication[$cat] = $ret;
228   }
231   function getOneDown($appl)
232   {
233     $cat  = $this->curCatDir;
234     $apps = $this->gosaMemberApplication[$cat];
236     $appsA = array();
237     foreach ($apps as $appkey => $name){
238       $appsA[$name['App']] =$name['App'];
239     }
241     $result = $this->ArrayDown($appl,$appsA);
243     $ret = array();
244     foreach($result as $app){
245       $ret[]=array("App"=>$app);
246     }
247     $this->gosaMemberApplication[$cat] = $ret;
248   } 
250    
251   
252   function AddSeperator($id)
253   {
254     $found  = false;
255     $cat    = "";
256     $tmp = array();
257     foreach($this->gosaMemberApplication[$this->curCatDir] as $appID => $app){  
258       $tmp[] = $app;    
259       if(($app['App'] == $id)&&(!$found)){
260         $cnt = count($this->gosaMemberApplication[$this->curCatDir]);
261         $tmp[] = array("App" => "__SEPARATOR__".($cnt+1));
262         $found = true;
263       }
264     }
265     if($found){
266       $this->gosaMemberApplication[$this->curCatDir]=$tmp;
267     }
268   }
270   function execute()
271   {
272           /* Call parent execute */
273         plugin::execute();
275     if((isset($_GET['act']))&&($_GET['act']=="depopen")){
276       print $_GET['id'];
277       $dep = base64_decode($_GET['id']);  
278       if(isset($this->config->idepartments[$dep])){
279         $this->curbase =$dep;
280       }
281     }
283     if((isset($_GET['act']))&&($_GET['act']=="open")){
284       $this->curCatDir = base64_decode($_GET['id']);
285     }
287     /* Do we need to flip is_account state? */
288     if (isset($_POST['modify_state'])){
289       $this->is_account= !$this->is_account;
290     }
292     /* Do we represent a valid group? */
293     if (!$this->is_account && $this->parent == NULL){
294       $display= "<img alt=\"\" src=\"images/stop.png\" align=\"middle\">&nbsp;<b>".
295         _("This 'dn' is no appgroup.")."</b>";
296       return ($display);
297     }
299     /* Show tab dialog headers */
300     $display= "";
301     if ($this->parent != NULL){
302       if ($this->is_account){
303         $display= $this->show_header(_("Remove applications"),
304             _("This group has application features enabled. You can disable them by clicking below."));
305       } else {
306         $display.= $this->show_header(_("Create applications"),
307             _("This group has application features disabled. You can enable them by clicking below."));
308         return ($display);
309       }
310     }
313     /* Add Categorie */ 
314   
315     
316     if((isset($_POST['AddCat']))&&(isset($_POST['CatName']))&&(!empty($_POST['CatName']))){
318       if(preg_match("/[\\\\\/]/i",$_POST['CatName'])){
319         print_red(_("Invalid character in category name."));
320       }elseif(!in_array($_POST['CatName'],$this->Categories)){ 
321         if(empty($this->curCatDir)){
322           $this->Categories[$_POST['CatName']]=$_POST['CatName'];
323         }else{
324           $this->Categories[$this->curCatDir."/".$_POST['CatName']]=$_POST['CatName'];
325         }
326       }else{
327         print_red(_("The specified category already exists."));
328       }
329     }
332     $this->reload();
333     foreach($_POST as $name => $value){
334       
335       if(preg_match("/AddSep_/",$name)){
336         $this->AddSeperator($value);
337       }
338     
340       if(preg_match("/DelApp_/",$name)){
341         $app = $value; 
342         foreach($this->gosaMemberApplication as $key =>  $cat){
343           foreach($cat as $key2 => $app){
344             if($app['App'] == $value){
345               unset($this->gosaMemberApplication[$key][$key2]);
346               if(isset($this->used_apps[$value])){
347                 unset($this->used_apps[$value]);
348               }
349             }
350           }
351         }
352       }
354       if(preg_match("/DelCat_/",$name)){
355         $n = preg_replace("/DelCat_/","",$name);
356         $app = base64_decode( preg_replace("/_.*$/","",$n));
357         foreach($this->Categories as $key =>  $cat){
358           if($cat == $app){
359             foreach($this->Categories as $p => $n){
360               if(preg_match("/^".$key."\/.*/",$p)){
361                 unset($this->Categories[$p]);    
362               }
363             }
364             unset($this->Categories[$key]);
365           }
366         }
367       }
368       
369       if(preg_match("/EdiApp_/",$name)){
370         $appname = $value;
371         /* We've got the appname, get parameters from ldap */
372         $ldap= $this->config->get_ldap_link();
373         $ldap->cd($this->config->current['BASE']);
374         $ldap->search("(&(objectClass=gosaApplication)(cn=$appname))");
375         if ($ldap->count() != 1){
376           print_red (_("The selected application name is not uniq. Please check your LDAP."));
377         } else {
378           $attrs= $ldap->fetch();
379           if(isset($attrs['gosaApplicationParameter'])){
380             $this->dialog= TRUE;
382             /* Fill name and value arrays */
383             for ($i= 0; $i<$attrs['gosaApplicationParameter']['count']; $i++){
384               $option= preg_replace('/^[^:]+:/', '',
385                   $attrs['gosaApplicationParameter'][$i]);
386               $name= preg_replace('/:.*$/', '', 
387                   $attrs['gosaApplicationParameter'][$i]);
388               $this->option_name[$i]= $name;
390               /* Fill with values from application, default should be
391                  loaded by the external scripts */
392               if (isset($this->appoption[$name])){
393                 $this->option_value[$i]= $this->appoption[$name];
394               }
395             }
397             /* Create edit field */
398             $table= "<table summary=\"\">";
399             for ($i= 0; $i < count($this->option_name); $i++){
400               if (isset($this->option_value[$i])){
401                 $value= $this->option_value[$i];
402               } else {
403                 $value= "";
404               }
405               $table.="<tr><td>".$this->option_name[$i]."</td><td>".
406                 "<input name=\"value$i\" size=60 maxlength=250 ".
407                 "value=\"".$value."\"><br></td></tr>";
408             }
409             $table.= "</table>";
410             $this->table= $table;
411           } else {
412             print_red (_("The selected application has no options."));
413           }
414         }
415       }
416     }
417     $this->reload();
418     /* Add group with post */
419     if((isset($_GET['act']))&&($_GET['act']=="add")){
420       $this->used_apps[$_GET['id']]= $_GET['id'];
421       asort($this->used_apps);
422       $this->addApp($_GET['id']);
423     }
425     /* Add multiple */
426     if(isset($_POST['AddApps'])){
427       foreach($_POST as $name => $value){
428         if(preg_match("/AddApp_/",$name)){
429           $app = preg_replace("/AddApp_/","",$name);
430           $this->addApp($app);
431         }
432       }
433     }
436     /* Cancel edit options? */
437     if (isset($_POST['edit_options_cancel'])){
438       $this->dialog= FALSE;
439     }
441     /* Finish edit options? */
442     if (isset($_POST['edit_options_finish'])){
443       $this->dialog= FALSE;
445       /* Save informations passed by the user */
446       $this->option_value= array();
447       for ($i= 0; $i<count($this->option_name); $i++){
448         $this->appoption[$this->option_name[$i]]= $_POST["value$i"];
449         $this->is_modified= TRUE;
450       }
451     }
453     /* Prepare templating stuff */
454     $smarty= get_smarty();
455     $smarty->assign("used_apps", $this->used_apps);
456     $apps= array();
457     foreach ($this->apps as $key => $value){
458       if (!array_key_exists($key, $this->used_apps)){
459         $apps["$key"]= "$value";
460       }
461     }
463     $div = new DivSelectBox("appgroup");    
465     $div->SetHeight(400);
467     /* NEW LIST MANAGMENT
468      * We also need to search for the departments
469      * So we are able to navigate like in konquerer
470      */
472     $ldap = $this->config->get_ldap_link();
473     $ldap->cd($this->curbase) ;
474     $ldap->ls("(objectClass=gosaDepartment)"); 
475     $departments= array();
476     $tmp = array();
477     while ($value = $ldap->fetch()){
478       $tmp[strtolower($value['dn']).$value['dn']]=$value;
479     }
480     ksort($tmp);
481     foreach($tmp as $value){
482       if($value["description"][0]!=".."){
483         $departments[$value['dn']]=convert_department_dn($value['dn'])." - [".$value["description"][0]."]";
484       }else{
485         $departments[$value['dn']]=convert_department_dn($value['dn']);
486       }
487     }
489     /* END NEW LIST MANAGMENT
490      */
492     $linkopen = "<a href='?plug=".$_GET['plug']."&amp;act=depopen&amp;depid=%s'>%s</a>";
493     $linkadd  = "<a href='?plug=".$_GET['plug']."&amp;act=add&amp;id=%s'>%s</a>";
495     $base_back = preg_replace("/^[^,]+,/","",$this->curbase);
496     if((strlen($base_back)>= strlen($this->config->current['BASE']))&&($this->curbase!=$this->config->current['BASE'])){
497       $div->AddEntry(array(
498             array("string"=>sprintf($linkopen,base64_encode($base_back),".. ["._("back")."]"),
499               "attach"=>"style='border:0px;'")
500             ));
501     }
502     foreach($departments as $key => $app){
503       $div->AddEntry(array(
504             array("string"=>"<img src='images/folder.png' alt='"._("department")."'>&nbsp;".sprintf($linkopen,base64_encode($key),$app),
505               "attach"=>"style='border:0px;'")
506             ));
507     }
509     foreach($apps as $key => $app){
510       $div->AddEntry(array(
511             array("string"=>sprintf("<input type='checkbox' value='1' name='AddApp_%s'>",$key).
512               "<img src='images/select_application.png' alt='"._("application")."'>&nbsp;".sprintf($linkadd,$key,$app),
513               "attach"=>"style='border:0px;'")
514             ));
515     }
517     if((isset($_GET['act']))&&(($_GET['act'] == "cat_up")||($_GET['act']=="cat_down"))){
518       if($_GET['act']=="cat_up"){
519         $this->catUp(base64_decode($_GET['id']));
520       }
521       if($_GET['act']=="cat_down"){
522         $this->catDown(base64_decode($_GET['id']));
523       }
524     }
526     if((isset($_GET['act']))&&(($_GET['act'] == "one_up")||($_GET['act']=="one_down"))){
527       if(isset($_GET['id'])){
528         $id   = $_GET['id'];
529         $act  = $_GET['act']; 
531         if($act == "one_up"){
532           $this->getOneUp($id);
533         }elseif($act == "one_down")   { 
534           $this->getOneDown($id);
535         }
536       }
537     }
539     $div2 = new DivSelectBox("appgroup");
540     $div2->SetHeight(400);
542     $linkopen       = "<img src='images/folder.png' alt=\"\">&nbsp;<a href='?plug=".$_GET['plug']."&amp;act=open&amp;id=%s'>%s</a>";
543     $catremove      = "&nbsp;<input type='image' src='images/edittrash.png' title='"._("Delete entry")."' name='DelCat_%s' value='%s'>";
544     $app            = "<img src='images/select_application.png' alt=\"\">&nbsp;%s";
545     
546     $catupdown        = "<a href='?plug=".$_GET['plug']."&amp;act=cat_up&amp;id=%s'>
547                        <img align='top' alt=\"\" src='images/sort_up.png' border=0 title='"._("Move up")."'></a>&nbsp;<a href='?plug=".$_GET['plug']."&amp;act=cat_down&amp;id=%s'> 
548                        <img alt=\"\" src='images/sort_down.png' title='"._("Move down")."' border=0></a>";
550     if(empty($this->curCatDir)){
551       $cnt =0;
552     }else{
553       $cnt = count(split("/",$this->curCatDir));
554       $tmp = split("/",$this->curCatDir);
555       $bbk = "";
556       for($i = 0 ; $i < ($cnt -1 ) ; $i++){
557         $bbk .= $tmp[$i];
558       }
559       $div2 ->AddEntry(array(array("string"=>sprintf($linkopen,$bbk,"..")),array("string"=>"&nbsp;","attach"=>"style='border-right:0px;'")));
560     }
562     $this->GetSubdirs($this->curCatDir);
564     foreach($this->GetSubdirs($this->curCatDir) as $path => $name){
565       $div2 ->AddEntry(array( 
566             array("string"=>sprintf($linkopen,base64_encode($path),$name)),
567             array("string"=>preg_replace("/%s/",base64_encode($path),$catupdown.$catremove),
568               "attach"=>"align='right' style='width:80px;border-right:0px;'"))); 
569     }
571     /* Append entries */
573     $separator ="<hr size=1>"; 
575     $sep = "<input type='image' src='images/back.png' title='"._("Insert seperator")."' value='%s' name='AddSep_%s'>";
576   
577     $upudown ="<a href='?plug=".$_GET['plug']."&amp;act=one_up&amp;id=%s'>   <img alt='{t}sort{/t}' align='top' src='images/sort_up.png' title='"._("Move up")."' border=0></a>".
578       "&nbsp;<a href='?plug=".$_GET['plug']."&amp;act=one_down&amp;id=%s'> <img alt='{t}sort{/t}' src='images/sort_down.png' title='"._("Move down")."' border=0></a>".
579       "&nbsp;<input type='image' src='images/edittrash.png' title='"._("Delete entry")."' name='DelApp_%s' value='%s' alt='{t}delete{/t}' >";
580     $edit=      "&nbsp;<input type='image' src='images/edit.png' title='"._("Edit entry")."' name='EdiApp_%s' value='%s' alt='{t}edit{/t}' >";
582     if(isset($this->gosaMemberApplication[$this->curCatDir])){
583       foreach($this->gosaMemberApplication[$this->curCatDir] as $cat => $entry){
584         if(preg_match("/__SEPARATOR__/",$entry['App'])){
585           $div2 ->AddEntry(array(array("string"=>$separator),
586                 array("string"=>preg_replace("/\%s/",htmlentities($entry['App']),$upudown),"attach"=>"align='right' style='border-right:0px;'")));
587         }else{
588           $div2 ->AddEntry(array(array("string"=>sprintf($app,$entry['App'])),
589                 array("string"=>preg_replace("/\%s/",htmlentities($entry['App']),$sep.$edit.$upudown),"attach"=>"align='right' style='border-right:0px;'")));
590         }
591       }
592     }
594     $smarty->assign("UsedApps", $div2->DrawList());
595     $smarty->assign("List", $div->DrawList());
596     $smarty->assign("apps", $apps);
598     /* Show main page */
599     if ($this->dialog){
600       $smarty->assign("table", $this->table);
601       $display.= $smarty->fetch (get_template_path('application_options.tpl', TRUE));
602     } else {
603       $display.= $smarty->fetch (get_template_path('application.tpl', TRUE));
604     }
605     return ($display);
606   }
609   function remove_from_parent()
610   {
611     plugin::remove_from_parent();
613     $this->attrs["gosaMemberApplication"]= array();
615     $ldap= $this->config->get_ldap_link();
616     $ldap->cd($this->dn);
617     $ldap->modify($this->attrs);
618     show_ldap_error($ldap->get_error());
620     /* Optionally execute a command after we're done */
621     $this->handle_post_events("remove");
622   }
625   /* Save to LDAP */
626   function save()
627   {
628     plugin::save();
630     /* Copy members */
631     $this->Categories[""]=""; 
632     $this->attrs["gosaMemberApplication"]= array();
633     $cats = array();
634     foreach($this->Categories as $name => $cats){
635       $cats[$name] =0;
636       if(isset($this->gosaMemberApplication[$name])){
637         foreach($this->gosaMemberApplication[$name] as $entry){
638           if(!preg_match("/__SEPARATOR__/",$entry['App'])){
639             $this->attrs["gosaMemberApplication"][]= $entry['App']."|".$name."|".$cats[$name];
640           }
641           $cats[$name] = $cats[$name] + 1;
642         }
643       }
644       if(($cats[$name]==0)&&(!empty($name))){
645         $this->attrs["gosaMemberApplication"][]= "|".$name."|".$cats[$name];
646       }
647     }
649     /* Are there application parameters to be saved */
650     $this->attrs['gosaApplicationParameter']= array();
651     foreach($this->appoption as $name => $value){
652       if ($value != ""){
653         $this->attrs['gosaApplicationParameter'][]= "$name:$value";
654       }
655     }
657     /* Write back to LDAP */
658     $ldap= $this->config->get_ldap_link();
659     $ldap->cd($this->dn);
660     $ldap->modify($this->attrs);
661     show_ldap_error($ldap->get_error());
663     /* Optionally execute a command after we're done */
664     if ($this->initially_was_account == $this->is_account){
665       if ($this->is_modified){
666         $this->handle_post_events("mofify");
667       }
668     } else {
669       $this->handle_post_events("add");
670     }
672   }
674   function check()
675   {
676     $message= array();
677     return ($message);
678   }
681   function reload()
682   {
683     /* Generate applist */
684     $this->apps= array();
685     $ldap= $this->config->get_ldap_link();
686     $ldap->cd ("ou=apps,".$this->curbase);
688     $ldap->ls ("(objectClass=gosaApplication)","ou=apps,".$this->curbase);
689     while ($attrs= $ldap->fetch()){
690       if (isset($attrs["description"][0])){    
691         $this->apps[$attrs["cn"][0]]=
692           $attrs["cn"][0]." (".
693           $attrs["description"][0].")";
694       } else {
695         $this->apps[$attrs["cn"][0]]=
696           $attrs["cn"][0];
697       }
698     }
699     natcasesort ($this->apps);
700     reset ($this->apps);
702     if(is_array($this->gosaMemberApplication))
703       foreach ($this->gosaMemberApplication as $cat){   
704         if(is_array($cat))
705           foreach($cat as $entry){
706             $this->used_apps[$entry['App']]= $entry['App'];
707           }
708       }
709   }
712   function addApp($cn)
713   {
714     if((isset($this->gosaMemberApplication[$this->curCatDir]))&&(is_array($this->gosaMemberApplication[$this->curCatDir]))){
715       foreach($this->gosaMemberApplication[$this->curCatDir] as $entry){
716         if($entry['App'] == $cn) return;
717       }
718     }
719     $this->gosaMemberApplication[$this->curCatDir][]= array("App"=>$cn);
720     $this->used_apps[$cn]=$cn;
721     $this->is_modified= TRUE;
722   }
725   function removeApp($cn)
726   {
727     $temp= array();
728     foreach ($this->gosaMemberApplication as $value){
729       if ($value != $cn){
730         $temp[]= $value;
731       }
732     }
733     $this->gosaMemberApplication= $temp;
734     $this->is_modified= TRUE;
735   }
737   function GetSubdirs($dir)
738   {
739     $ret = array();
740     $tmp1 = split("/",$this->curCatDir);
741  
742     foreach($this->Categories as $path=>$cat){
743       $tmp2 = split("/",$path);
744       
745       if((empty($this->curCatDir))&&(!preg_match("/\//",$path))){
746         $abort = false;
747       }elseif(((count($tmp1))+1) == (count($tmp2))){
748         $abort = false;
749         for($i = 0 ; $i < count($tmp1) ; $i++){
750           if($tmp1[$i] != $tmp2[$i]){
751             $abort = true;
752           }
753         }
754       }else{
755         $abort= true;
756       }
757       if(!$abort){
758         $ret[$path]=$cat;
759       } 
760     }
761   return($ret);
762   }
766 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
767 ?>