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)){
63 $tmp = split("\|",$memberApp);
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;
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 }
195 function catDown($id)
196 {
197 /* Get all cats depinding on current dir */
198 $cats = $this->GetSubdirs($this->curCatDir);
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 }
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 }
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\"> <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 */
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 $only_once = false;
334 foreach($_POST as $name => $value){
336 if((preg_match("/AddSep_/",$name))&&(!$only_once)){
337 $only_once = true;
338 $n = preg_replace("/AddSep_/","",$name);
339 $val= preg_replace("/_.*$/","",$n);
340 $this->AddSeperator($val);
341 }
343 if((preg_match("/DelApp_/",$name))&&(!$only_once)){
344 $only_once = true;
347 if(preg_match("/DelApp___SEPARATOR__/",$name)) {
348 $n= preg_replace("/DelApp___SEPARATOR__/","",$name);
349 $val= "__SEPARATOR__".preg_replace("/_.*$/","",$n);
350 }else{
351 $n = preg_replace("/DelApp_/","",$name);
352 $val= preg_replace("/_.*$/","",$n);
353 }
355 foreach($this->gosaMemberApplication as $key => $cat){
356 foreach($cat as $key2 => $app){
357 if($app['App'] == $val){
358 unset($this->gosaMemberApplication[$key][$key2]);
359 if(isset($this->used_apps[$val])){
360 unset($this->used_apps[$val]);
361 }
362 }
363 }
364 }
365 }
367 if(preg_match("/DelCat_/",$name)){
368 $n = preg_replace("/DelCat_/","",$name);
369 $app = base64_decode( preg_replace("/_.*$/","",$n));
370 foreach($this->Categories as $key => $cat){
371 if($cat == $app){
372 foreach($this->Categories as $p => $n){
373 if(preg_match("/^".$key."\/.*/",$p)){
374 unset($this->Categories[$p]);
375 }
376 }
377 unset($this->Categories[$key]);
378 }
379 }
380 }
382 if(preg_match("/EdiApp_/",$name)){
383 $appname = $value;
384 /* We've got the appname, get parameters from ldap */
385 $ldap= $this->config->get_ldap_link();
386 $ldap->cd($this->config->current['BASE']);
387 $ldap->search("(&(objectClass=gosaApplication)(cn=$appname))");
388 if ($ldap->count() != 1){
389 print_red (_("The selected application name is not uniq. Please check your LDAP."));
390 } else {
391 $attrs= $ldap->fetch();
392 if(isset($attrs['gosaApplicationParameter'])){
393 $this->dialog= TRUE;
395 /* Fill name and value arrays */
396 for ($i= 0; $i<$attrs['gosaApplicationParameter']['count']; $i++){
397 $option= preg_replace('/^[^:]+:/', '',
398 $attrs['gosaApplicationParameter'][$i]);
399 $name= preg_replace('/:.*$/', '',
400 $attrs['gosaApplicationParameter'][$i]);
401 $this->option_name[$i]= $name;
403 /* Fill with values from application, default should be
404 loaded by the external scripts */
405 if (isset($this->appoption[$name])){
406 $this->option_value[$i]= $this->appoption[$name];
407 }
408 }
410 /* Create edit field */
411 $table= "<table summary=\"\">";
412 for ($i= 0; $i < count($this->option_name); $i++){
413 if (isset($this->option_value[$i])){
414 $value= $this->option_value[$i];
415 } else {
416 $value= "";
417 }
418 $table.="<tr><td>".$this->option_name[$i]."</td><td>".
419 "<input name=\"value$i\" size=60 maxlength=250 ".
420 "value=\"".$value."\"><br></td></tr>";
421 }
422 $table.= "</table>";
423 $this->table= $table;
424 } else {
425 print_red (_("The selected application has no options."));
426 }
427 }
428 }
429 }
430 $this->reload();
431 /* Add group with post */
432 if((isset($_GET['act']))&&($_GET['act']=="add")){
433 $this->used_apps[$_GET['id']]= $_GET['id'];
434 asort($this->used_apps);
435 $this->addApp($_GET['id']);
436 }
438 /* Add multiple */
439 if(isset($_POST['AddApps'])){
440 foreach($_POST as $name => $value){
441 if(preg_match("/AddApp_/",$name)){
442 $app = preg_replace("/AddApp_/","",$name);
443 $this->addApp($app);
444 }
445 }
446 }
449 /* Cancel edit options? */
450 if (isset($_POST['edit_options_cancel'])){
451 $this->dialog= FALSE;
452 }
454 /* Finish edit options? */
455 if (isset($_POST['edit_options_finish'])){
456 $this->dialog= FALSE;
458 /* Save informations passed by the user */
459 $this->option_value= array();
460 for ($i= 0; $i<count($this->option_name); $i++){
461 $this->appoption[$this->option_name[$i]]= $_POST["value$i"];
462 $this->is_modified= TRUE;
463 }
464 }
466 /* Prepare templating stuff */
467 $smarty= get_smarty();
468 $smarty->assign("used_apps", $this->used_apps);
469 $apps= array();
470 foreach ($this->apps as $key => $value){
471 if (!array_key_exists($key, $this->used_apps)){
472 $apps["$key"]= "$value";
473 }
474 }
476 $div = new DivSelectBox("appgroup");
478 $div->SetHeight(400);
480 /* NEW LIST MANAGMENT
481 * We also need to search for the departments
482 * So we are able to navigate like in konquerer
483 */
485 $ldap = $this->config->get_ldap_link();
486 $ldap->cd($this->curbase) ;
487 $ldap->ls("(objectClass=gosaDepartment)");
488 $departments= array();
489 $tmp = array();
490 while ($value = $ldap->fetch()){
491 $tmp[strtolower($value['dn']).$value['dn']]=$value;
492 }
493 ksort($tmp);
494 foreach($tmp as $value){
495 if($value["description"][0]!=".."){
496 $departments[$value['dn']]=convert_department_dn($value['dn'])." - [".$value["description"][0]."]";
497 }else{
498 $departments[$value['dn']]=convert_department_dn($value['dn']);
499 }
500 }
502 /* END NEW LIST MANAGMENT
503 */
505 $linkopen = "<a href='?plug=".$_GET['plug']."&act=depopen&depid=%s'>%s</a>";
506 $linkadd = "<a href='?plug=".$_GET['plug']."&act=add&id=%s'>%s</a>";
508 $base_back = preg_replace("/^[^,]+,/","",$this->curbase);
509 if((strlen($base_back)>= strlen($this->config->current['BASE']))&&($this->curbase!=$this->config->current['BASE'])){
510 $div->AddEntry(array(
511 array("string"=>sprintf($linkopen,base64_encode($base_back),".. ["._("back")."]"),
512 "attach"=>"style='border:0px;'")
513 ));
514 }
515 foreach($departments as $key => $app){
516 $div->AddEntry(array(
517 array("string"=>"<img src='images/folder.png' alt='"._("department")."'> ".sprintf($linkopen,base64_encode($key),$app),
518 "attach"=>"style='border:0px;'")
519 ));
520 }
522 foreach($apps as $key => $app){
523 $div->AddEntry(array(
524 array("string"=>sprintf("<input type='checkbox' value='1' name='AddApp_%s'>",$key).
525 "<img src='images/select_application.png' alt='"._("application")."'> ".sprintf($linkadd,$key,$app),
526 "attach"=>"style='border:0px;'")
527 ));
528 }
530 if((isset($_GET['act']))&&(($_GET['act'] == "cat_up")||($_GET['act']=="cat_down"))){
531 if($_GET['act']=="cat_up"){
532 $this->catUp(base64_decode($_GET['id']));
533 }
534 if($_GET['act']=="cat_down"){
535 $this->catDown(base64_decode($_GET['id']));
536 }
537 }
539 if((isset($_GET['act']))&&(($_GET['act'] == "one_up")||($_GET['act']=="one_down"))){
540 if(isset($_GET['id'])){
541 $id = $_GET['id'];
542 $act = $_GET['act'];
544 if($act == "one_up"){
545 $this->getOneUp($id);
546 }elseif($act == "one_down") {
547 $this->getOneDown($id);
548 }
549 }
550 }
552 $div2 = new DivSelectBox("appgroup");
553 $div2->SetHeight(400);
555 $linkopen = "<img src='images/folder.png' alt=\"\"> <a href='?plug=".$_GET['plug']."&act=open&id=%s'>%s</a>";
556 $catremove = " <input type='image' src='images/edittrash.png' title='"._("Delete entry")."' name='DelCat_%s' value='%s'>";
557 $app = "<img src='images/select_application.png' alt=\"\"> %s";
559 $catupdown = "<a href='?plug=".$_GET['plug']."&act=cat_up&id=%s'>
560 <img align='top' alt=\"\" src='images/sort_up.png' border=0 title='"._("Move up")."'></a> <a href='?plug=".$_GET['plug']."&act=cat_down&id=%s'>
561 <img alt=\"\" src='images/sort_down.png' title='"._("Move down")."' border=0></a>";
563 if(empty($this->curCatDir)){
564 $cnt =0;
565 }else{
566 $cnt = count(split("/",$this->curCatDir));
567 $tmp = split("/",$this->curCatDir);
568 $bbk = "";
569 for($i = 0 ; $i < ($cnt -1 ) ; $i++){
570 $bbk .= $tmp[$i];
571 }
572 $div2 ->AddEntry(array(array("string"=>sprintf($linkopen,$bbk,"..")),array("string"=>" ","attach"=>"style='border-right:0px;'")));
573 }
575 $this->GetSubdirs($this->curCatDir);
577 foreach($this->GetSubdirs($this->curCatDir) as $path => $name){
578 $div2 ->AddEntry(array(
579 array("string"=>sprintf($linkopen,base64_encode($path),$name)),
580 array("string"=>preg_replace("/%s/",base64_encode($path),$catupdown.$catremove),
581 "attach"=>"align='right' style='width:80px;border-right:0px;'")));
582 }
584 /* Append entries */
586 $separator ="<hr size=1>";
588 $sep = "<input type='image' src='images/back.png' title='"._("Insert seperator")."' value='%s' name='AddSep_%s'>";
590 $upudown ="<a href='?plug=".$_GET['plug']."&act=one_up&id=%s'> <img alt='{t}sort{/t}' align='top' src='images/sort_up.png' title='"._("Move up")."' border=0></a>".
591 " <a href='?plug=".$_GET['plug']."&act=one_down&id=%s'> <img alt='{t}sort{/t}' src='images/sort_down.png' title='"._("Move down")."' border=0></a>".
592 " <input type='image' src='images/edittrash.png' title='"._("Delete entry")."' name='DelApp_%s' value='%s' alt='{t}delete{/t}' >";
593 $edit= " <input type='image' src='images/edit.png' title='"._("Edit entry")."' name='EdiApp_%s' value='%s' alt='{t}edit{/t}' >";
595 if(isset($this->gosaMemberApplication[$this->curCatDir])){
596 foreach($this->gosaMemberApplication[$this->curCatDir] as $cat => $entry){
597 if(preg_match("/__SEPARATOR__/",$entry['App'])){
598 $div2 ->AddEntry(array(array("string"=>$separator),
599 array("string"=>preg_replace("/\%s/",htmlentities($entry['App']),$upudown),"attach"=>"align='right' style='border-right:0px;'")));
600 }else{
601 $div2 ->AddEntry(array(array("string"=>sprintf($app,$entry['App'])),
602 array("string"=>preg_replace("/\%s/",htmlentities($entry['App']),$sep.$edit.$upudown),"attach"=>"align='right' style='border-right:0px;'")));
603 }
604 }
605 }
607 $smarty->assign("UsedApps", $div2->DrawList());
608 $smarty->assign("List", $div->DrawList());
609 $smarty->assign("apps", $apps);
611 /* Show main page */
612 if ($this->dialog){
613 $smarty->assign("table", $this->table);
614 $display.= $smarty->fetch (get_template_path('application_options.tpl', TRUE));
615 } else {
616 $display.= $smarty->fetch (get_template_path('application.tpl', TRUE));
617 }
618 return ($display);
619 }
622 function remove_from_parent()
623 {
624 plugin::remove_from_parent();
626 $this->attrs["gosaMemberApplication"]= array();
628 $ldap= $this->config->get_ldap_link();
629 $ldap->cd($this->dn);
630 $ldap->modify($this->attrs);
631 show_ldap_error($ldap->get_error());
633 /* Optionally execute a command after we're done */
634 $this->handle_post_events("remove");
635 }
638 /* Save to LDAP */
639 function save()
640 {
641 plugin::save();
643 /* Copy members */
644 $this->Categories[""]="";
645 $this->attrs["gosaMemberApplication"]= array();
646 $cats = array();
647 foreach($this->Categories as $name => $cats){
648 $cats[$name] =0;
649 if(isset($this->gosaMemberApplication[$name])){
650 foreach($this->gosaMemberApplication[$name] as $entry){
651 if(!preg_match("/__SEPARATOR__/",$entry['App'])){
652 $this->attrs["gosaMemberApplication"][]= $entry['App']."|".$name."|".$cats[$name];
653 }
654 $cats[$name] = $cats[$name] + 1;
655 }
656 }
657 if(($cats[$name]==0)&&(!empty($name))){
658 $this->attrs["gosaMemberApplication"][]= "|".$name."|".$cats[$name];
659 }
660 }
662 /* Are there application parameters to be saved */
663 $this->attrs['gosaApplicationParameter']= array();
664 foreach($this->appoption as $name => $value){
665 if ($value != ""){
666 $this->attrs['gosaApplicationParameter'][]= "$name:$value";
667 }
668 }
670 /* Write back to LDAP */
671 $ldap= $this->config->get_ldap_link();
672 $ldap->cd($this->dn);
673 $ldap->modify($this->attrs);
674 show_ldap_error($ldap->get_error());
676 /* Optionally execute a command after we're done */
677 if ($this->initially_was_account == $this->is_account){
678 if ($this->is_modified){
679 $this->handle_post_events("mofify");
680 }
681 } else {
682 $this->handle_post_events("add");
683 }
685 }
687 function check()
688 {
689 $message= array();
690 return ($message);
691 }
694 function reload()
695 {
696 /* Generate applist */
697 $this->apps= array();
698 $ldap= $this->config->get_ldap_link();
699 $ldap->cd ("ou=apps,".$this->curbase);
701 $ldap->ls ("(objectClass=gosaApplication)","ou=apps,".$this->curbase);
702 while ($attrs= $ldap->fetch()){
703 if (isset($attrs["description"][0])){
704 $this->apps[$attrs["cn"][0]]=
705 $attrs["cn"][0]." (".
706 $attrs["description"][0].")";
707 } else {
708 $this->apps[$attrs["cn"][0]]=
709 $attrs["cn"][0];
710 }
711 }
712 natcasesort ($this->apps);
713 reset ($this->apps);
715 if(is_array($this->gosaMemberApplication))
716 foreach ($this->gosaMemberApplication as $cat){
717 if(is_array($cat))
718 foreach($cat as $entry){
719 $this->used_apps[$entry['App']]= $entry['App'];
720 }
721 }
722 }
725 function addApp($cn)
726 {
727 if((isset($this->gosaMemberApplication[$this->curCatDir]))&&(is_array($this->gosaMemberApplication[$this->curCatDir]))){
728 foreach($this->gosaMemberApplication[$this->curCatDir] as $entry){
729 if($entry['App'] == $cn) return;
730 }
731 }
732 $this->gosaMemberApplication[$this->curCatDir][]= array("App"=>$cn);
733 $this->used_apps[$cn]=$cn;
734 $this->is_modified= TRUE;
735 }
738 function removeApp($cn)
739 {
740 $temp= array();
741 foreach ($this->gosaMemberApplication as $value){
742 if ($value != $cn){
743 $temp[]= $value;
744 }
745 }
746 $this->gosaMemberApplication= $temp;
747 $this->is_modified= TRUE;
748 }
750 function GetSubdirs($dir)
751 {
752 $ret = array();
753 $tmp1 = split("/",$this->curCatDir);
755 foreach($this->Categories as $path=>$cat){
756 $tmp2 = split("/",$path);
758 if((empty($this->curCatDir))&&(!preg_match("/\//",$path))){
759 $abort = false;
760 }elseif(((count($tmp1))+1) == (count($tmp2))){
761 $abort = false;
762 for($i = 0 ; $i < count($tmp1) ; $i++){
763 if($tmp1[$i] != $tmp2[$i]){
764 $abort = true;
765 }
766 }
767 }else{
768 $abort= true;
769 }
770 if(!$abort){
771 $ret[$path]=$cat;
772 }
773 }
774 return($ret);
775 }
777 }
779 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
780 ?>