fd3500a8602dd1a970fe3544ac4df108a91b6bee
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("gosaMemberApplication");
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 $this->gosaMemberApplication = array();
38 for ($i= 0; $i<$this->attrs["gosaMemberApplication"]["count"]; $i++){
39 $this->gosaMemberApplication[]=
40 $this->attrs["gosaMemberApplication"][$i];
41 }
42 }
44 /* Load application options */
45 if (isset($this->attrs['gosaApplicationParameter'])){
46 for ($i= 0; $i<$this->attrs['gosaApplicationParameter']['count']; $i++){
47 $option= preg_replace('/^[^:]+:/', '',
48 $this->attrs['gosaApplicationParameter'][$i]);
49 $name= preg_replace('/:.*$/', '',
50 $this->attrs['gosaApplicationParameter'][$i]);
51 $this->appoption[$name]= $option;
52 }
53 }
55 /* Parse MemberApplication*/
56 $tmp = array();
57 $tmp2 = array();
58 $prios = array();
59 $cats = array();
61 foreach($this->gosaMemberApplication as $memberApp){
62 if(preg_match("/\|/i",$memberApp)){
64 $tmp = split("\|",$memberApp);
66 if(!empty($tmp[0])){
67 $tmp2[$tmp[1]][$tmp[2]] = array("App"=>$tmp[0]);
68 }
69 if(!empty($tmp[1])){
70 $n = split("/",$tmp[1]);
71 $c = count($n);
72 $cats [$tmp[1]] = $n[$c-1];
73 }
74 $prios[$tmp[1]][$tmp[2]] = $tmp[2];
75 }else{
76 $tmp2[]['App'] = $memberApp;
77 }
78 }
80 $this->Categories = $cats;
82 $this->gosaMemberApplication = $tmp2;
83 $cats[""]="";
84 foreach($cats as $cat ){
85 if((isset($prios[$cat]))&&(count($prios[$cat]))){
86 $max = max($prios[$cat]);
87 $min = 1;//min($prios[$cat]);
88 $last = false;
89 for($i = $min ; $i < $max ; $i++){
90 if(!isset($prios[$cat][$i])){
91 if($last == false){
92 $this->gosaMemberApplication[$cat][$i]['App'] = "__SEPARATOR__".$i;
94 $last = true;
95 }
96 }else{
97 $last = false;
98 }
99 }
100 }
101 }
103 $tmp = array();
104 foreach($this->gosaMemberApplication as $key => $entries){
105 ksort ($entries);
106 foreach($entries as $entry){
107 $tmp[$key][]= $entry;
108 }
109 }
110 $this->gosaMemberApplication = $tmp;
111 $this->curbase = $this->config->current['BASE'];
112 }
115 /* Combine new array */
116 function combineArrays($ar0,$ar1,$ar2)
117 {
118 $ret = array();
119 if(is_array($ar0))
120 foreach($ar0 as $ar => $a){
121 $ret[$ar]=$a;
122 }
123 if(is_array($ar1))
124 foreach($ar1 as $ar => $a){
125 $ret[$ar]=$a;
126 }
127 if(is_array($ar2))
128 foreach($ar2 as $ar => $a){
129 $ret[$ar]=$a;
130 }
131 return($ret);
132 }
134 function getpos($atr,$attrs)
135 {
136 $i = 0;
137 foreach($attrs as $attr => $name) {
138 $i++;
139 if($attr == $atr){
140 return($i);
141 }
142 }
143 return(-1);
144 }
147 /* TRansports the geiven Arraykey one position up*/
148 function ArrayUp($atr,$attrs)
149 {
150 $ret = $attrs;
151 $pos = $this->getpos($atr,$attrs) ;
152 $cn = count($attrs);
153 if(!(($pos == -1)||($pos == 1))){
154 $before = array_slice($attrs,0,($pos-2));
155 $mitte = array_reverse(array_slice($attrs,($pos-2),2));
156 $unten = array_slice($attrs,$pos);
157 $ret = array();
158 $ret = $this->combineArrays($before,$mitte,$unten);
159 }
160 return($ret);
161 }
164 /* TRansports the geiven Arraykey one position up*/
165 function ArrayDown($atr,$attrs)
166 {
167 $ret = $attrs;
168 $pos = $this->getpos($atr,$attrs) ;
169 $cn = count($attrs);
170 if(!(($pos == -1)||($pos == $cn))){
171 $before = array_slice($attrs,0,($pos-1));
172 $mitte = array_reverse(array_slice($attrs,($pos-1),2));
173 $unten = array_slice($attrs,($pos+1));
174 $ret = array();
175 $ret = $this->combineArrays($before,$mitte,$unten);
176 }
177 return($ret);
178 }
181 function catUp($id)
182 {
183 /* Get all cats depinding on current dir */
184 $cats = $this->GetSubdirs($this->curCatDir);
185 $newcats =$this->ArrayUp($id,$cats);
187 foreach($newcats as $cat => $name){
188 unset($this->Categories[$cat]);
189 }
190 foreach($newcats as $cat => $name){
191 $this->Categories[$cat]=$name;
192 }
193 }
196 function catDown($id)
197 {
198 /* Get all cats depinding on current dir */
199 $cats = $this->GetSubdirs($this->curCatDir);
201 $newcats =$this->ArrayDown($id,$cats);
203 foreach($newcats as $cat => $name){
204 unset($this->Categories[$cat]);
205 }
206 foreach($newcats as $cat => $name){
207 $this->Categories[$cat]=$name;
208 }
209 }
212 function getOneUp($appl)
213 {
214 $cat = $this->curCatDir;
215 $apps = $this->gosaMemberApplication[$cat];
217 $appsA = array();
218 foreach ($apps as $appkey => $name){
219 $appsA[$name['App']] =$name['App'];
220 }
222 $result = $this->ArrayUp($appl,$appsA);
224 $ret = array();
225 foreach($result as $app){
226 $ret[]=array("App"=>$app);
227 }
228 $this->gosaMemberApplication[$cat] = $ret;
229 }
232 function getOneDown($appl)
233 {
234 $cat = $this->curCatDir;
235 $apps = $this->gosaMemberApplication[$cat];
237 $appsA = array();
238 foreach ($apps as $appkey => $name){
239 $appsA[$name['App']] =$name['App'];
240 }
242 $result = $this->ArrayDown($appl,$appsA);
244 $ret = array();
245 foreach($result as $app){
246 $ret[]=array("App"=>$app);
247 }
248 $this->gosaMemberApplication[$cat] = $ret;
249 }
253 function AddSeperator($id)
254 {
255 $found = false;
256 $cat = "";
257 $tmp = array();
258 foreach($this->gosaMemberApplication[$this->curCatDir] as $appID => $app){
259 $tmp[] = $app;
260 if(($app['App'] == $id)&&(!$found)){
261 $cnt = count($this->gosaMemberApplication[$this->curCatDir]);
262 $tmp[] = array("App" => "__SEPARATOR__".($cnt+1));
263 $found = true;
264 }
265 }
266 if($found){
267 $this->gosaMemberApplication[$this->curCatDir]=$tmp;
268 }
269 }
271 function execute()
272 {
273 /* Call parent execute */
274 plugin::execute();
276 if((isset($_GET['act']))&&($_GET['act']=="depopen")){
277 $dep = base64_decode($_GET['depid']);
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))&&(!$only_once)){
384 $only_once = true;
385 $appname = $value;
386 $appname = preg_replace("/EdiApp_/","",$name);
387 $appname = preg_replace("/_.*$/","",$appname);
388 /* We've got the appname, get parameters from ldap */
389 $ldap= $this->config->get_ldap_link();
390 $ldap->cd($this->config->current['BASE']);
391 $ldap->search("(&(objectClass=gosaApplication)(cn=$appname))",array("gosaApplicationParameter"));
392 if ($ldap->count() != 1){
393 print_red (_("The selected application name is not uniq. Please check your LDAP."));
394 } else {
395 $attrs= $ldap->fetch();
396 if(isset($attrs['gosaApplicationParameter'])){
397 $this->dialog= TRUE;
399 /* Fill name and value arrays */
400 for ($i= 0; $i<$attrs['gosaApplicationParameter']['count']; $i++){
401 $option= preg_replace('/^[^:]+:/', '',
402 $attrs['gosaApplicationParameter'][$i]);
403 $name= preg_replace('/:.*$/', '',
404 $attrs['gosaApplicationParameter'][$i]);
405 $this->option_name[$i]= $name;
407 /* Fill with values from application, default should be
408 loaded by the external scripts */
409 if (isset($this->appoption[$name])){
410 $this->option_value[$i]= $this->appoption[$name];
411 }
412 }
414 /* Create edit field */
415 $table= "<table summary=\"\">";
416 for ($i= 0; $i < count($this->option_name); $i++){
417 if (isset($this->option_value[$i])){
418 $value= $this->option_value[$i];
419 } else {
420 $value= "";
421 }
422 $table.="<tr><td>".$this->option_name[$i]."</td><td>".
423 "<input name=\"value$i\" size=60 maxlength=250 ".
424 "value=\"".$value."\"><br></td></tr>";
425 }
426 $table.= "</table>";
427 $this->table= $table;
428 } else {
429 print_red (_("The selected application has no options."));
430 }
431 }
432 }
433 }
434 $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(400);
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']."&act=depopen&depid=%s'>%s</a>";
510 $linkadd = "<a href='?plug=".$_GET['plug']."&act=add&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")."'> ".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")."'> ".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(base64_decode($_GET['id']));
537 }
538 if($_GET['act']=="cat_down"){
539 $this->catDown(base64_decode($_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'];
548 if($act == "one_up"){
549 $this->getOneUp($id);
550 }elseif($act == "one_down") {
551 $this->getOneDown($id);
552 }
553 }
554 }
556 $div2 = new DivSelectBox("appgroup");
557 $div2->SetHeight(400);
559 $linkopen = "<img src='images/folder.png' alt=\"\"> <a href='?plug=".$_GET['plug']."&act=open&id=%s'>%s</a>";
560 $catremove = " <input type='image' src='images/edittrash.png' title='"._("Delete entry")."' name='DelCat_%s' value='%s'>";
561 $app = "<img src='images/select_application.png' alt=\"\"> %s";
563 $catupdown = "<a href='?plug=".$_GET['plug']."&act=cat_up&id=%s'>
564 <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'>
565 <img alt=\"\" src='images/sort_down.png' title='"._("Move down")."' border=0></a>";
567 if(empty($this->curCatDir)){
568 $cnt =0;
569 }else{
570 $cnt = count(split("/",$this->curCatDir));
571 $tmp = split("/",$this->curCatDir);
572 $bbk = "";
573 for($i = 0 ; $i < ($cnt -1 ) ; $i++){
574 $bbk .= $tmp[$i];
575 }
576 $div2 ->AddEntry(array(array("string"=>sprintf($linkopen,base64_encode($bbk),"..")),array("string"=>" ","attach"=>"style='border-right:0px;'")));
577 }
579 $this->GetSubdirs($this->curCatDir);
581 foreach($this->GetSubdirs($this->curCatDir) as $path => $name){
582 $div2 ->AddEntry(array(
583 array("string"=>sprintf($linkopen,base64_encode($path),$name)),
584 array("string"=>preg_replace("/%s/",base64_encode($path),$catupdown.$catremove),
585 "attach"=>"align='right' style='width:80px;border-right:0px;'")));
586 }
588 /* Append entries */
590 $separator ="<hr size=1>";
592 $sep = "<input type='image' src='images/back.png' title='"._("Insert seperator")."' value='%s' name='AddSep_%s'>";
594 $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>".
595 " <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>".
596 " <input type='image' src='images/edittrash.png' title='"._("Delete entry")."' name='DelApp_%s' value='%s' alt='{t}delete{/t}' >";
597 $edit= " <input type='image' src='images/edit.png' title='"._("Edit entry")."' name='EdiApp_%s' value='%s' alt='{t}edit{/t}' >";
599 if(isset($this->gosaMemberApplication[$this->curCatDir])){
600 foreach($this->gosaMemberApplication[$this->curCatDir] as $cat => $entry){
601 if(preg_match("/__SEPARATOR__/",$entry['App'])){
602 $div2 ->AddEntry(array(array("string"=>$separator),
603 array("string"=>preg_replace("/\%s/",htmlentities($entry['App']),$upudown),"attach"=>"align='right' style='border-right:0px;'")));
604 }else{
605 $div2 ->AddEntry(array(array("string"=>sprintf($app,$entry['App'])),
606 array("string"=>preg_replace("/\%s/",htmlentities($entry['App']),$sep.$edit.$upudown),"attach"=>"align='right' style='border-right:0px;'")));
607 }
608 }
609 }
611 $smarty->assign("UsedApps", $div2->DrawList());
612 $smarty->assign("List", $div->DrawList());
613 $smarty->assign("apps", $apps);
615 /* Show main page */
616 if ($this->dialog){
617 $smarty->assign("table", $this->table);
618 $display.= $smarty->fetch (get_template_path('application_options.tpl', TRUE));
619 } else {
620 $display.= $smarty->fetch (get_template_path('application.tpl', TRUE));
621 }
622 return ($display);
623 }
626 function remove_from_parent()
627 {
628 plugin::remove_from_parent();
630 $this->attrs["gosaMemberApplication"]= array();
632 $ldap= $this->config->get_ldap_link();
633 $ldap->cd($this->dn);
634 $this->cleanup();
635 $ldap->modify ($this->attrs);
637 show_ldap_error($ldap->get_error());
639 /* Optionally execute a command after we're done */
640 $this->handle_post_events("remove");
641 }
644 /* Save to LDAP */
645 function save()
646 {
647 plugin::save();
649 /* Copy members */
650 $this->Categories[""]="";
651 $this->attrs["gosaMemberApplication"]= array();
652 foreach($this->Categories as $name => $cats){
653 $i =0;
654 if(isset($this->gosaMemberApplication[$name])){
655 foreach($this->gosaMemberApplication[$name] as $entry){
656 if(!preg_match("/__SEPARATOR__/",$entry['App'])){
657 $this->attrs["gosaMemberApplication"][]= $entry['App']."|".$name."|".$i;
658 }
659 $i ++;
660 }
661 }
662 if(($i==0)&&(!empty($name))){
663 $this->attrs["gosaMemberApplication"][]= "|".$name."|".$i;
664 }
665 }
667 /* Are there application parameters to be saved */
668 $this->attrs['gosaApplicationParameter']= array();
669 foreach($this->appoption as $name => $value){
670 if ($value != ""){
671 $this->attrs['gosaApplicationParameter'][]= "$name:$value";
672 }
673 }
675 /* Write back to LDAP */
676 $ldap= $this->config->get_ldap_link();
677 $ldap->cd($this->dn);
678 $this->cleanup();
679 $ldap->modify ($this->attrs);
681 show_ldap_error($ldap->get_error());
683 /* Optionally execute a command after we're done */
684 if ($this->initially_was_account == $this->is_account){
685 if ($this->is_modified){
686 $this->handle_post_events("mofify");
687 }
688 } else {
689 $this->handle_post_events("add");
690 }
692 }
694 function check()
695 {
696 $message= array();
697 return ($message);
698 }
701 function reload()
702 {
703 /* Generate applist */
704 $this->apps= array();
705 $ldap= $this->config->get_ldap_link();
706 $ldap->cd ("ou=apps,".$this->curbase);
708 $ldap->ls ("(objectClass=gosaApplication)","ou=apps,".$this->curbase);
709 while ($attrs= $ldap->fetch()){
710 if (isset($attrs["description"][0])){
711 $this->apps[$attrs["cn"][0]]=
712 $attrs["cn"][0]." (".
713 $attrs["description"][0].")";
714 } else {
715 $this->apps[$attrs["cn"][0]]=
716 $attrs["cn"][0];
717 }
718 }
719 natcasesort ($this->apps);
720 reset ($this->apps);
722 if(is_array($this->gosaMemberApplication))
723 foreach ($this->gosaMemberApplication as $cat){
724 if(is_array($cat))
725 foreach($cat as $entry){
726 $this->used_apps[$entry['App']]= $entry['App'];
727 }
728 }
729 }
732 function addApp($cn)
733 {
734 if((isset($this->gosaMemberApplication[$this->curCatDir]))&&(is_array($this->gosaMemberApplication[$this->curCatDir]))){
735 foreach($this->gosaMemberApplication[$this->curCatDir] as $entry){
736 if($entry['App'] == $cn) return;
737 }
738 }
739 $this->gosaMemberApplication[$this->curCatDir][]= array("App"=>$cn);
740 $this->used_apps[$cn]=$cn;
741 $this->is_modified= TRUE;
742 }
745 function removeApp($cn)
746 {
747 $temp= array();
748 foreach ($this->gosaMemberApplication as $value){
749 if ($value != $cn){
750 $temp[]= $value;
751 }
752 }
753 $this->gosaMemberApplication= $temp;
754 $this->is_modified= TRUE;
755 }
757 function GetSubdirs($dir)
758 {
759 $ret = array();
760 $tmp1 = split("/",$this->curCatDir);
762 foreach($this->Categories as $path=>$cat){
763 $tmp2 = split("/",$path);
765 if((empty($this->curCatDir))&&(!preg_match("/\//",$path))){
766 $abort = false;
767 }elseif(((count($tmp1))+1) == (count($tmp2))){
768 $abort = false;
769 for($i = 0 ; $i < count($tmp1) ; $i++){
770 if($tmp1[$i] != $tmp2[$i]){
771 $abort = true;
772 }
773 }
774 }else{
775 $abort= true;
776 }
777 if(!$abort){
778 $ret[$path]=$cat;
779 }
780 }
781 return($ret);
782 }
784 }
786 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
787 ?>