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)){
62 $tmp = split("\|",$memberApp);
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;
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 /* Get all cats depinding on current dir */
114 $cats = $this->GetSubdirs($this->curCatDir);
115 $ret = array();
116 if((in_array($id,array_flip($cats)))&&(count($cats)>1)){
117 if(count($cats) == 2){
118 $ret = array_reverse($cats);
119 }else{
120 $cnt = 0;
121 $hit = 0;
122 foreach($cats as $cat=>$name){
123 if($cat == $id){
124 $hit = $cnt;
125 }
126 $cnt ++;
127 }
128 if($hit == 0){
129 $first = array_slice($cats,0,0);
130 $middle = array_slice($cats,0,2);
131 $last = array_slice($cats,$hit+2,$cnt);
132 }else{
133 $first = array_slice($cats,0,$hit);
134 $middle = array_slice($cats,$hit,2);
135 $last = array_slice($cats,$hit+2,$cnt);
136 }
137 foreach($first as $cat => $name){
138 $ret[$cat]=$name;
139 }
140 foreach(array_reverse($middle) as $cat => $name){
141 $ret[$cat]=$name;
142 }
143 foreach($last as $cat => $name){
144 $ret[$cat]=$name;
145 }
146 }
147 foreach($cats as $cat => $name){
148 unset($this->Categories[$cat]);
149 }
150 foreach($ret as $cat => $name){
151 $this->Categories[$cat]=$name;
152 }
153 }
154 }
156 function catUp($id)
157 {
158 /* Get all cats depinding on current dir */
159 $cats = $this->GetSubdirs($this->curCatDir);
161 $ret = array();
163 if((in_array($id,array_flip($cats)))&&(count($cats)>1)){
164 if(count($cats) == 2){
165 $ret = array_reverse($cats);
166 }else{
167 $cnt = 0;
168 $hit = 0;
169 foreach($cats as $cat => $name){
170 $cnt ++;
171 if($cat == $id){
172 $hit = $cnt;
173 }
174 }
176 if($hit>1){
177 if($hit == 2){
178 $first = array_slice($cats,0,$hit-2);
179 $middle = array_slice($cats,$hit-2,$hit);
180 $last = array_slice($cats,$hit,$cnt);
181 }else{
182 $first = array_slice($cats,0,$hit-2);
183 $middle = array_slice($cats,$hit-2,2);
184 $last = array_slice($cats,$hit,$cnt);
185 }
186 foreach($first as $cat => $name){
187 $ret[$cat]=$name;
188 }
189 foreach(array_reverse($middle) as $cat => $name){
190 $ret[$cat]=$name;
191 }
192 foreach($last as $cat => $name){
193 $ret[$cat]=$name;
194 }
195 }
196 }
198 foreach($cats as $cat => $name){
199 unset($this->Categories[$cat]);
200 }
201 foreach($ret as $cat => $name){
202 $this->Categories[$cat]=$name;
203 }
204 }
207 }
209 function getOneUp($appl)
210 {
211 $cat = $this->curCatDir;
212 if(!isset($this->gosaMemberApplication[$cat][($appl-1)])) return;
213 $f = 1;
214 if($appl == 1 ){
215 $f = 0;
216 }
217 $first = array_slice($this->gosaMemberApplication[$cat],0,($appl-1));
218 $middle = array_slice($this->gosaMemberApplication[$cat],$appl-1,(($appl+1)-$f));
219 $last = array_slice($this->gosaMemberApplication[$cat],($appl+1));
220 $tmp = array();
221 foreach($first as $entry){
222 $tmp[] = $entry;
223 }
224 foreach(array_reverse($middle) as $entry){
225 $tmp[] = $entry;
226 }
227 foreach($last as $entry){
228 $tmp[] = $entry;
229 }
230 $this->gosaMemberApplication[$cat] =$tmp;
231 }
233 function getOneDown($appl){
234 $cat = $this->curCatDir;
235 if(!isset($this->gosaMemberApplication[$cat][($appl+1)])) return;
236 $f = 0;
237 if($appl == 0 ){
238 $f = 1;
239 }
240 $first = array_slice($this->gosaMemberApplication[$cat],0,($appl));
241 $middle = array_slice($this->gosaMemberApplication[$cat],$appl,(($appl+1+$f)));
242 $last = array_slice($this->gosaMemberApplication[$cat],($appl+2));
244 $tmp = array();
245 foreach($first as $entry){
246 $tmp[] = $entry;
247 }
248 foreach(array_reverse($middle) as $entry){
249 $tmp[] = $entry;
250 }
251 foreach($last as $entry){
252 $tmp[] = $entry;
253 }
254 $this->gosaMemberApplication[$cat] =$tmp;
255 }
257 function AddSeperator($id)
258 {
259 $found = false;
260 $cat = "";
261 $tmp = array();
262 foreach($this->gosaMemberApplication[$this->curCatDir] as $appID => $app){
263 $tmp[] = $app;
264 if(($app['App'] == $id)&&(!$found)){
265 $cnt = count($this->gosaMemberApplication[$this->curCatDir]);
266 $tmp[] = array("App" => "__SEPARATOR__".($cnt+1));
267 $found = true;
268 }
269 }
270 if($found){
271 $this->gosaMemberApplication[$this->curCatDir]=$tmp;
272 }
273 }
275 function execute()
276 {
277 /* Call parent execute */
278 plugin::execute();
280 if((isset($_GET['act']))&&($_GET['act']=="depopen")){
281 $dep = base64_decode($_GET['depid']);
282 if(isset($this->config->idepartments[$dep])){
283 $this->curbase = $dep;
284 }
285 }
287 if((isset($_GET['act']))&&($_GET['act']=="open")){
288 $this->curCatDir = $_GET['id'];
289 }
291 /* Do we need to flip is_account state? */
292 if (isset($_POST['modify_state'])){
293 $this->is_account= !$this->is_account;
294 }
296 /* Do we represent a valid group? */
297 if (!$this->is_account && $this->parent == NULL){
298 $display= "<img alt=\"\" src=\"images/stop.png\" align=\"middle\"> <b>".
299 _("This 'dn' is no appgroup.")."</b>";
300 return ($display);
301 }
303 /* Show tab dialog headers */
304 $display= "";
305 if ($this->parent != NULL){
306 if ($this->is_account){
307 $display= $this->show_header(_("Remove applications"),
308 _("This group has application features enabled. You can disable them by clicking below."));
309 } else {
310 $display.= $this->show_header(_("Create applications"),
311 _("This group has application features disabled. You can enable them by clicking below."));
312 return ($display);
313 }
314 }
317 /* Add Categorie */
320 if((isset($_POST['AddCat']))&&(isset($_POST['CatName']))&&(!empty($_POST['CatName']))){
322 if(preg_match("/[^0-9a-z,\.-;:_#\+\- ]/i",$_POST['CatName'])){
323 print_red(_("Invalid character in category name."));
324 }elseif(!in_array($_POST['CatName'],$this->Categories)){
325 if(empty($this->curCatDir)){
326 $this->Categories[$_POST['CatName']]=$_POST['CatName'];
327 }else{
328 $this->Categories[$this->curCatDir."/".$_POST['CatName']]=$_POST['CatName'];
329 }
330 }else{
331 print_red(_("The specified category already exists."));
332 }
333 }
336 $this->reload();
337 foreach($_POST as $name => $value){
338 if(preg_match("/AddSep_/",$name)){
339 $this->AddSeperator($value);
340 }
343 if(preg_match("/DelApp_/",$name)){
344 $app = $value;
346 foreach($this->gosaMemberApplication as $key => $cat){
347 foreach($cat as $key2 => $app){
348 if($app['App'] == $value){
349 unset($this->gosaMemberApplication[$key][$key2]);
350 if(isset($this->used_apps[$value])){
351 unset($this->used_apps[$value]);
352 }
353 }
354 }
355 }
356 }
357 if(preg_match("/DelCat_/",$name)){
358 $app = $value;
359 foreach($this->Categories as $key => $cat){
360 if($cat == $value){
361 unset($this->Categories[$key]);
362 }
363 }
364 }
365 if(preg_match("/EdiApp_/",$name)){
366 $appname = $value;
367 /* We've got the appname, get parameters from ldap */
368 $ldap= $this->config->get_ldap_link();
369 $ldap->cd($this->config->current['BASE']);
370 $ldap->search("(&(objectClass=gosaApplication)(cn=$appname))");
371 if ($ldap->count() != 1){
372 print_red (_("The selected application name is not uniq. Please check your LDAP."));
373 } else {
374 $attrs= $ldap->fetch();
375 if(isset($attrs['gosaApplicationParameter'])){
376 $this->dialog= TRUE;
378 /* Fill name and value arrays */
379 for ($i= 0; $i<$attrs['gosaApplicationParameter']['count']; $i++){
380 $option= preg_replace('/^[^:]+:/', '',
381 $attrs['gosaApplicationParameter'][$i]);
382 $name= preg_replace('/:.*$/', '',
383 $attrs['gosaApplicationParameter'][$i]);
384 $this->option_name[$i]= $name;
386 /* Fill with values from application, default should be
387 loaded by the external scripts */
388 if (isset($this->appoption[$name])){
389 $this->option_value[$i]= $this->appoption[$name];
390 }
391 }
393 /* Create edit field */
394 $table= "<table summary=\"\">";
395 for ($i= 0; $i < count($this->option_name); $i++){
396 if (isset($this->option_value[$i])){
397 $value= $this->option_value[$i];
398 } else {
399 $value= "";
400 }
401 $table.="<tr><td>".$this->option_name[$i]."</td><td>".
402 "<input name=\"value$i\" size=60 maxlength=250 ".
403 "value=\"".$value."\"><br></td></tr>";
404 }
405 $table.= "</table>";
406 $this->table= $table;
407 } else {
408 print_red (_("The selected application has no options."));
409 }
410 }
411 }
412 }
413 $this->reload();
415 /* Add group with post */
416 if((isset($_GET['act']))&&($_GET['act']=="add")){
417 $this->used_apps[$_GET['id']]= $_GET['id'];
418 asort($this->used_apps);
419 $this->addApp($_GET['id']);
420 }
422 /* Add multiple */
423 if(isset($_POST['AddApps'])){
424 foreach($_POST as $name => $value){
425 if(preg_match("/AddApp_/",$name)){
426 $app = preg_replace("/AddApp_/","",$name);
427 $this->addApp($app);
428 }
429 }
430 }
433 /* Cancel edit options? */
434 if (isset($_POST['edit_options_cancel'])){
435 $this->dialog= FALSE;
436 }
438 /* Finish edit options? */
439 if (isset($_POST['edit_options_finish'])){
440 $this->dialog= FALSE;
442 /* Save informations passed by the user */
443 $this->option_value= array();
444 for ($i= 0; $i<count($this->option_name); $i++){
445 $this->appoption[$this->option_name[$i]]= $_POST["value$i"];
446 $this->is_modified= TRUE;
447 }
448 }
450 /* Prepare templating stuff */
451 $smarty= get_smarty();
452 $smarty->assign("used_apps", $this->used_apps);
453 $apps= array();
454 foreach ($this->apps as $key => $value){
455 if (!array_key_exists($key, $this->used_apps)){
456 $apps["$key"]= "$value";
457 }
458 }
460 $div = new DivSelectBox("appgroup");
462 $div->SetHeight(400);
464 /* NEW LIST MANAGMENT
465 * We also need to search for the departments
466 * So we are able to navigate like in konquerer
467 */
469 $ldap = $this->config->get_ldap_link();
470 $ldap->cd($this->curbase) ;
471 $ldap->ls("(objectClass=gosaDepartment)");
472 $departments= array();
473 $tmp = array();
474 while ($value = $ldap->fetch()){
475 $tmp[strtolower($value['dn']).$value['dn']]=$value;
476 }
477 ksort($tmp);
478 foreach($tmp as $value){
479 if($value["description"][0]!=".."){
480 $departments[$value['dn']]=convert_department_dn($value['dn'])." - [".$value["description"][0]."]";
481 }else{
482 $departments[$value['dn']]=convert_department_dn($value['dn']);
483 }
484 }
486 /* END NEW LIST MANAGMENT
487 */
489 $linkopen = "<a href='?plug=".$_GET['plug']."&act=depopen&depid=%s'>%s</a>";
490 $linkadd = "<a href='?plug=".$_GET['plug']."&act=add&id=%s'>%s</a>";
492 $base_back = preg_replace("/^[^,]+,/","",$this->curbase);
493 if((strlen($base_back)>= strlen($this->config->current['BASE']))&&($this->curbase!=$this->config->current['BASE'])){
494 $div->AddEntry(array(
495 array("string"=>sprintf($linkopen,base64_encode($base_back),".. ["._("back")."]"),
496 "attach"=>"style='border:0px;'")
497 ));
498 }
499 foreach($departments as $key => $app){
500 $div->AddEntry(array(
501 array("string"=>"<img src='images/folder.png' alt='"._("department")."'> ".sprintf($linkopen,base64_encode($key),$app),
502 "attach"=>"style='border:0px;'")
503 ));
504 }
506 foreach($apps as $key => $app){
507 $div->AddEntry(array(
508 array("string"=>sprintf("<input type='checkbox' value='1' name='AddApp_%s'>",$key).
509 "<img src='images/select_application.png' alt='"._("application")."'> ".sprintf($linkadd,$key,$app),
510 "attach"=>"style='border:0px;'")
511 ));
512 }
514 if((isset($_GET['act']))&&(($_GET['act'] == "cat_up")||($_GET['act']=="cat_down"))){
515 if($_GET['act']=="cat_up"){
516 $this->catUp($_GET['id']);
517 }
518 if($_GET['act']=="cat_down"){
519 $this->catDown($_GET['id']);
520 }
521 }
523 if((isset($_GET['act']))&&(($_GET['act'] == "one_up")||($_GET['act']=="one_down"))){
524 if(isset($_GET['id'])){
525 $id = $_GET['id'];
526 $act = $_GET['act'];
527 $found = -1;
528 if(isset($this->gosaMemberApplication[$this->curCatDir])){
529 foreach($this->gosaMemberApplication[$this->curCatDir] as $key => $member){
530 if($id == $member['App']){
531 $found = $key;
532 }
533 }
534 }
536 if($found != -1){
537 if($act == "one_up"){
538 $this->getOneUp($found);
539 }elseif($act == "one_down") {
540 $this->getOneDown($found);
541 }
542 }
543 }
544 }
546 $div2 = new DivSelectBox("appgroup");
547 $div2->SetHeight(400);
549 $linkopen = "<img src='images/folder.png'> <a href='?plug=".$_GET['plug']."&act=open&id=%s'>%s</a>";
550 $catremove = " <input type='image' src='images/edittrash.png' title='"._("Delete entry")."' name='DelCat_%s' value='%s'>";
551 $app = "<img src='images/select_application.png'> %s";
553 $catupdown = "<a href='?plug=".$_GET['plug']."&act=cat_up&id=%s'>
554 <img align='top' src='images/sort_up.png' border=0 title='"._("Move up")."'></a> <a href='?plug=".$_GET['plug']."&act=cat_down&id=%s'>
555 <img src='images/sort_down.png' title='"._("Move down")."' border=0></a>";
557 if(empty($this->curCatDir)){
558 $cnt =0;
559 }else{
560 $cnt = count(split("/",$this->curCatDir));
561 $tmp = split("/",$this->curCatDir);
562 $bbk = "";
563 for($i = 0 ; $i < ($cnt -1 ) ; $i++){
564 $bbk .= $tmp[$i];
565 }
566 $div2 ->AddEntry(array(array("string"=>sprintf($linkopen,$bbk,"..")),array("string"=>" ","attach"=>"style='border-right:0px;'")));
567 }
569 $this->GetSubdirs($this->curCatDir);
571 foreach($this->GetSubdirs($this->curCatDir) as $path => $name){
572 $div2 ->AddEntry(array(
573 array("string"=>sprintf($linkopen,$path,$name)),
574 array("string"=>preg_replace("/%s/",$path,$catupdown.$catremove),
575 "attach"=>"align='right' style='width:80px;border-right:0px;'")));
576 }
578 /* Append entries */
580 $separator ="<hr height=1 size=1></hr>";
582 $sep = "<input type='image' src='images/back.png' title='"._("Insert seperator")."' value='%s' name='AddSep_%s'>";
584 $upudown ="<a href='?plug=".$_GET['plug']."&act=one_up&id=%s'> <img align='top' src='images/sort_up.png' title='"._("Move up")."' border=0></a>".
585 " <a href='?plug=".$_GET['plug']."&act=one_down&id=%s'> <img src='images/sort_down.png' title='"._("Move down")."' border=0></a>".
586 " <input type='image' src='images/edittrash.png' title='"._("Delete entry")."' name='DelApp_%s' value='%s'>";
587 $edit= " <input type='image' src='images/edit.png' title='"._("Edit entry")."' name='EdiApp_%s' value='%s'>";
589 if(isset($this->gosaMemberApplication[$this->curCatDir])){
590 foreach($this->gosaMemberApplication[$this->curCatDir] as $cat => $entry){
591 if(preg_match("/__SEPARATOR__/",$entry['App'])){
592 $div2 ->AddEntry(array(array("string"=>$separator),
593 array("string"=>preg_replace("/\%s/",$entry['App'],$upudown),"attach"=>"align='right' style='border-right:0px;'")));
594 }else{
595 $div2 ->AddEntry(array(array("string"=>sprintf($app,$entry['App'])),
596 array("string"=>preg_replace("/\%s/",$entry['App'],$sep.$edit.$upudown),"attach"=>"align='right' style='border-right:0px;'")));
597 }
598 }
599 }
601 $smarty->assign("UsedApps", $div2->DrawList());
602 $smarty->assign("List", $div->DrawList());
603 $smarty->assign("apps", $apps);
605 /* Show main page */
606 if ($this->dialog){
607 $smarty->assign("table", $this->table);
608 $display.= $smarty->fetch (get_template_path('application_options.tpl', TRUE));
609 } else {
610 $display.= $smarty->fetch (get_template_path('application.tpl', TRUE));
611 }
612 return ($display);
613 }
616 function remove_from_parent()
617 {
618 plugin::remove_from_parent();
620 $this->attrs["gosaMemberApplication"]= array();
622 $ldap= $this->config->get_ldap_link();
623 $ldap->cd($this->dn);
624 $ldap->modify($this->attrs);
625 show_ldap_error($ldap->get_error());
627 /* Optionally execute a command after we're done */
628 $this->handle_post_events("remove");
629 }
632 /* Save to LDAP */
633 function save()
634 {
635 plugin::save();
637 /* Copy members */
638 $this->Categories[""]="";
639 $this->attrs["gosaMemberApplication"]= array();
640 $cats = array();
641 foreach($this->Categories as $name => $cats){
642 $cats[$name] =0;
643 if(isset($this->gosaMemberApplication[$name])){
644 foreach($this->gosaMemberApplication[$name] as $entry){
645 if(!preg_match("/__SEPARATOR__/",$entry['App'])){
646 $this->attrs["gosaMemberApplication"][]= $entry['App']."|".$name."|".$cats[$name];
647 }
648 $cats[$name] = $cats[$name] + 1;
649 }
650 }
651 if(($cats[$name]==0)&&(!empty($name))){
652 $this->attrs["gosaMemberApplication"][]= "|".$name."|".$cats[$name];
653 }
654 }
656 /* Are there application parameters to be saved */
657 $this->attrs['gosaApplicationParameter']= array();
658 foreach($this->appoption as $name => $value){
659 if ($value != ""){
660 $this->attrs['gosaApplicationParameter'][]= "$name:$value";
661 }
662 }
664 /* Write back to LDAP */
665 $ldap= $this->config->get_ldap_link();
666 $ldap->cd($this->dn);
667 $ldap->modify($this->attrs);
668 show_ldap_error($ldap->get_error());
670 /* Optionally execute a command after we're done */
671 if ($this->initially_was_account == $this->is_account){
672 if ($this->is_modified){
673 $this->handle_post_events("mofify");
674 }
675 } else {
676 $this->handle_post_events("add");
677 }
679 }
681 function check()
682 {
683 $message= array();
684 return ($message);
685 }
688 function reload()
689 {
690 /* Generate applist */
691 $this->apps= array();
692 $ldap= $this->config->get_ldap_link();
693 $ldap->cd ("ou=apps,".$this->curbase);
695 $ldap->ls ("(objectClass=gosaApplication)","ou=apps,".$this->curbase);
696 while ($attrs= $ldap->fetch()){
697 if (isset($attrs["description"][0])){
698 $this->apps[$attrs["cn"][0]]=
699 $attrs["cn"][0]." (".
700 $attrs["description"][0].")";
701 } else {
702 $this->apps[$attrs["cn"][0]]=
703 $attrs["cn"][0];
704 }
705 }
706 natcasesort ($this->apps);
707 reset ($this->apps);
709 if(is_array($this->gosaMemberApplication))
710 foreach ($this->gosaMemberApplication as $cat){
711 if(is_array($cat))
712 foreach($cat as $entry){
713 $this->used_apps[$entry['App']]= $entry['App'];
714 }
715 }
716 }
719 function addApp($cn)
720 {
721 if((isset($this->gosaMemberApplication[$this->curCatDir]))&&(is_array($this->gosaMemberApplication[$this->curCatDir]))){
722 foreach($this->gosaMemberApplication[$this->curCatDir] as $entry){
723 if($entry['App'] == $cn) return;
724 }
725 }
726 $this->gosaMemberApplication[$this->curCatDir][]= array("App"=>$cn);
727 $this->used_apps[$cn]=$cn;
728 $this->is_modified= TRUE;
729 }
732 function removeApp($cn)
733 {
734 $temp= array();
735 foreach ($this->gosaMemberApplication as $value){
736 if ($value != $cn){
737 $temp[]= $value;
738 }
739 }
740 $this->gosaMemberApplication= $temp;
741 $this->is_modified= TRUE;
742 }
744 function GetSubdirs($dir)
745 {
746 $ret = array();
747 $tmp1 = split("/",$this->curCatDir);
749 foreach($this->Categories as $path=>$cat){
750 $tmp2 = split("/",$path);
752 if((empty($this->curCatDir))&&(!preg_match("/\//",$path))){
753 $abort = false;
754 }elseif(((count($tmp1))+1) == (count($tmp2))){
755 $abort = false;
756 for($i = 0 ; $i < count($tmp1) ; $i++){
757 if($tmp1[$i] != $tmp2[$i]){
758 $abort = true;
759 }
760 }
761 }else{
762 $abort= true;
763 }
764 if(!$abort){
765 $ret[$path]=$cat;
766 }
767 }
768 return($ret);
769 }
771 }
773 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
774 ?>