Code

6122cf25a39682013f1857305971b82a66a6f200
[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       $dep = base64_decode($_GET['depid']);  
277       if(isset($this->config->idepartments[$dep])){
278         $this->curbase = $dep;
279       }
280     }
282     if((isset($_GET['act']))&&($_GET['act']=="open")){
283       $this->curCatDir = $_GET['id'];
284     }
286     /* Do we need to flip is_account state? */
287     if (isset($_POST['modify_state'])){
288       $this->is_account= !$this->is_account;
289     }
291     /* Do we represent a valid group? */
292     if (!$this->is_account && $this->parent == NULL){
293       $display= "<img alt=\"\" src=\"images/stop.png\" align=\"middle\">&nbsp;<b>".
294         _("This 'dn' is no appgroup.")."</b>";
295       return ($display);
296     }
298     /* Show tab dialog headers */
299     $display= "";
300     if ($this->parent != NULL){
301       if ($this->is_account){
302         $display= $this->show_header(_("Remove applications"),
303             _("This group has application features enabled. You can disable them by clicking below."));
304       } else {
305         $display.= $this->show_header(_("Create applications"),
306             _("This group has application features disabled. You can enable them by clicking below."));
307         return ($display);
308       }
309     }
312     /* Add Categorie */ 
313   
314     
315     if((isset($_POST['AddCat']))&&(isset($_POST['CatName']))&&(!empty($_POST['CatName']))){
316       
317       if(preg_match("/[^0-9a-z,\.-;:_#\+\- ]/i",$_POST['CatName'])){
318         print_red(_("Invalid character in category name."));
319       }elseif(!in_array($_POST['CatName'],$this->Categories)){ 
320         if(empty($this->curCatDir)){
321           $this->Categories[$_POST['CatName']]=$_POST['CatName'];
322         }else{
323           $this->Categories[$this->curCatDir."/".$_POST['CatName']]=$_POST['CatName'];
324         }
325       }else{
326         print_red(_("The specified category already exists."));
327       }
328     }
331     $this->reload();
332     foreach($_POST as $name => $value){
333       if(preg_match("/AddSep_/",$name)){
334         $this->AddSeperator($value);
335       }
336     
338       if(preg_match("/DelApp_/",$name)){
339         $app = $value; 
341         foreach($this->gosaMemberApplication as $key =>  $cat){
342           foreach($cat as $key2 => $app){
343             if($app['App'] == $value){
344               unset($this->gosaMemberApplication[$key][$key2]);
345               if(isset($this->used_apps[$value])){
346                 unset($this->used_apps[$value]);
347               }
348             }
349           }
350         }
351       }
352       if(preg_match("/DelCat_/",$name)){
353         $app = $value; 
354         foreach($this->Categories as $key =>  $cat){
355           if($cat == $value){
356             unset($this->Categories[$key]);
357           }
358         }
359       }
360       if(preg_match("/EdiApp_/",$name)){
361         $appname = $value;
362         /* We've got the appname, get parameters from ldap */
363         $ldap= $this->config->get_ldap_link();
364         $ldap->cd($this->config->current['BASE']);
365         $ldap->search("(&(objectClass=gosaApplication)(cn=$appname))");
366         if ($ldap->count() != 1){
367           print_red (_("The selected application name is not uniq. Please check your LDAP."));
368         } else {
369           $attrs= $ldap->fetch();
370           if(isset($attrs['gosaApplicationParameter'])){
371             $this->dialog= TRUE;
373             /* Fill name and value arrays */
374             for ($i= 0; $i<$attrs['gosaApplicationParameter']['count']; $i++){
375               $option= preg_replace('/^[^:]+:/', '',
376                   $attrs['gosaApplicationParameter'][$i]);
377               $name= preg_replace('/:.*$/', '', 
378                   $attrs['gosaApplicationParameter'][$i]);
379               $this->option_name[$i]= $name;
381               /* Fill with values from application, default should be
382                  loaded by the external scripts */
383               if (isset($this->appoption[$name])){
384                 $this->option_value[$i]= $this->appoption[$name];
385               }
386             }
388             /* Create edit field */
389             $table= "<table summary=\"\">";
390             for ($i= 0; $i < count($this->option_name); $i++){
391               if (isset($this->option_value[$i])){
392                 $value= $this->option_value[$i];
393               } else {
394                 $value= "";
395               }
396               $table.="<tr><td>".$this->option_name[$i]."</td><td>".
397                 "<input name=\"value$i\" size=60 maxlength=250 ".
398                 "value=\"".$value."\"><br></td></tr>";
399             }
400             $table.= "</table>";
401             $this->table= $table;
402           } else {
403             print_red (_("The selected application has no options."));
404           }
405         }
406       }
407     }
408     $this->reload();
410     /* Add group with post */
411     if((isset($_GET['act']))&&($_GET['act']=="add")){
412       $this->used_apps[$_GET['id']]= $_GET['id'];
413       asort($this->used_apps);
414       $this->addApp($_GET['id']);
415     }
417     /* Add multiple */
418     if(isset($_POST['AddApps'])){
419       foreach($_POST as $name => $value){
420         if(preg_match("/AddApp_/",$name)){
421           $app = preg_replace("/AddApp_/","",$name);
422           $this->addApp($app);
423         }
424       }
425     }
428     /* Cancel edit options? */
429     if (isset($_POST['edit_options_cancel'])){
430       $this->dialog= FALSE;
431     }
433     /* Finish edit options? */
434     if (isset($_POST['edit_options_finish'])){
435       $this->dialog= FALSE;
437       /* Save informations passed by the user */
438       $this->option_value= array();
439       for ($i= 0; $i<count($this->option_name); $i++){
440         $this->appoption[$this->option_name[$i]]= $_POST["value$i"];
441         $this->is_modified= TRUE;
442       }
443     }
445     /* Prepare templating stuff */
446     $smarty= get_smarty();
447     $smarty->assign("used_apps", $this->used_apps);
448     $apps= array();
449     foreach ($this->apps as $key => $value){
450       if (!array_key_exists($key, $this->used_apps)){
451         $apps["$key"]= "$value";
452       }
453     }
455     $div = new DivSelectBox("appgroup");    
457     $div->SetHeight(400);
459     /* NEW LIST MANAGMENT
460      * We also need to search for the departments
461      * So we are able to navigate like in konquerer
462      */
464     $ldap = $this->config->get_ldap_link();
465     $ldap->cd($this->curbase) ;
466     $ldap->ls("(objectClass=gosaDepartment)"); 
467     $departments= array();
468     $tmp = array();
469     while ($value = $ldap->fetch()){
470       $tmp[strtolower($value['dn']).$value['dn']]=$value;
471     }
472     ksort($tmp);
473     foreach($tmp as $value){
474       if($value["description"][0]!=".."){
475         $departments[$value['dn']]=convert_department_dn($value['dn'])." - [".$value["description"][0]."]";
476       }else{
477         $departments[$value['dn']]=convert_department_dn($value['dn']);
478       }
479     }
481     /* END NEW LIST MANAGMENT
482      */
484     $linkopen = "<a href='?plug=".$_GET['plug']."&amp;act=depopen&amp;depid=%s'>%s</a>";
485     $linkadd  = "<a href='?plug=".$_GET['plug']."&amp;act=add&amp;id=%s'>%s</a>";
487     $base_back = preg_replace("/^[^,]+,/","",$this->curbase);
488     if((strlen($base_back)>= strlen($this->config->current['BASE']))&&($this->curbase!=$this->config->current['BASE'])){
489       $div->AddEntry(array(
490             array("string"=>sprintf($linkopen,base64_encode($base_back),".. ["._("back")."]"),
491               "attach"=>"style='border:0px;'")
492             ));
493     }
494     foreach($departments as $key => $app){
495       $div->AddEntry(array(
496             array("string"=>"<img src='images/folder.png' alt='"._("department")."'>&nbsp;".sprintf($linkopen,base64_encode($key),$app),
497               "attach"=>"style='border:0px;'")
498             ));
499     }
501     foreach($apps as $key => $app){
502       $div->AddEntry(array(
503             array("string"=>sprintf("<input type='checkbox' value='1' name='AddApp_%s'>",$key).
504               "<img src='images/select_application.png' alt='"._("application")."'>&nbsp;".sprintf($linkadd,$key,$app),
505               "attach"=>"style='border:0px;'")
506             ));
507     }
509     if((isset($_GET['act']))&&(($_GET['act'] == "cat_up")||($_GET['act']=="cat_down"))){
510       if($_GET['act']=="cat_up"){
511         $this->catUp($_GET['id']);
512       }
513       if($_GET['act']=="cat_down"){
514         $this->catDown($_GET['id']);
515       }
516     }
518     if((isset($_GET['act']))&&(($_GET['act'] == "one_up")||($_GET['act']=="one_down"))){
519       if(isset($_GET['id'])){
520         $id   = $_GET['id'];
521         $act  = $_GET['act']; 
523         if($act == "one_up"){
524           $this->getOneUp($id);
525         }elseif($act == "one_down")   { 
526           $this->getOneDown($id);
527         }
528       }
529     }
531     $div2 = new DivSelectBox("appgroup");
532     $div2->SetHeight(400);
534     $linkopen       = "<img src='images/folder.png'>&nbsp;<a href='?plug=".$_GET['plug']."&amp;act=open&amp;id=%s'>%s</a>";
535     $catremove      = "&nbsp;<input type='image' src='images/edittrash.png' title='"._("Delete entry")."' name='DelCat_%s' value='%s'>";
536     $app            = "<img src='images/select_application.png'>&nbsp;%s";
537     
538     $catupdown        = "<a href='?plug=".$_GET['plug']."&amp;act=cat_up&id=%s'>
539                        <img align='top' src='images/sort_up.png' border=0 title='"._("Move up")."'></a>&nbsp;<a href='?plug=".$_GET['plug']."&amp;act=cat_down&id=%s'> 
540                        <img src='images/sort_down.png' title='"._("Move down")."' border=0></a>";
542     if(empty($this->curCatDir)){
543       $cnt =0;
544     }else{
545       $cnt = count(split("/",$this->curCatDir));
546       $tmp = split("/",$this->curCatDir);
547       $bbk = "";
548       for($i = 0 ; $i < ($cnt -1 ) ; $i++){
549         $bbk .= $tmp[$i];
550       }
551       $div2 ->AddEntry(array(array("string"=>sprintf($linkopen,$bbk,"..")),array("string"=>"&nbsp;","attach"=>"style='border-right:0px;'")));
552     }
554     $this->GetSubdirs($this->curCatDir);
556     foreach($this->GetSubdirs($this->curCatDir) as $path => $name){
557       $div2 ->AddEntry(array( 
558             array("string"=>sprintf($linkopen,$path,$name)),
559             array("string"=>preg_replace("/%s/",$path,$catupdown.$catremove),
560               "attach"=>"align='right' style='width:80px;border-right:0px;'"))); 
561     }
563     /* Append entries */
565     $separator ="<hr height=1  size=1></hr>"; 
567     $sep = "<input type='image' src='images/back.png' title='"._("Insert seperator")."' value='%s' name='AddSep_%s'>";
568   
569     $upudown ="<a href='?plug=".$_GET['plug']."&amp;act=one_up&id=%s'>   <img align='top' src='images/sort_up.png' title='"._("Move up")."' border=0></a>".
570       "&nbsp;<a href='?plug=".$_GET['plug']."&amp;act=one_down&id=%s'> <img src='images/sort_down.png' title='"._("Move down")."' border=0></a>".
571       "&nbsp;<input type='image' src='images/edittrash.png' title='"._("Delete entry")."' name='DelApp_%s' value='%s'>";
572     $edit=      "&nbsp;<input type='image' src='images/edit.png' title='"._("Edit entry")."' name='EdiApp_%s' value='%s'>";
574     if(isset($this->gosaMemberApplication[$this->curCatDir])){
575       foreach($this->gosaMemberApplication[$this->curCatDir] as $cat => $entry){
576         if(preg_match("/__SEPARATOR__/",$entry['App'])){
577           $div2 ->AddEntry(array(array("string"=>$separator),
578                 array("string"=>preg_replace("/\%s/",$entry['App'],$upudown),"attach"=>"align='right' style='border-right:0px;'")));
579         }else{
580           $div2 ->AddEntry(array(array("string"=>sprintf($app,$entry['App'])),
581                 array("string"=>preg_replace("/\%s/",$entry['App'],$sep.$edit.$upudown),"attach"=>"align='right' style='border-right:0px;'")));
582         }
583       }
584     }
586     $smarty->assign("UsedApps", $div2->DrawList());
587     $smarty->assign("List", $div->DrawList());
588     $smarty->assign("apps", $apps);
590     /* Show main page */
591     if ($this->dialog){
592       $smarty->assign("table", $this->table);
593       $display.= $smarty->fetch (get_template_path('application_options.tpl', TRUE));
594     } else {
595       $display.= $smarty->fetch (get_template_path('application.tpl', TRUE));
596     }
597     return ($display);
598   }
601   function remove_from_parent()
602   {
603     plugin::remove_from_parent();
605     $this->attrs["gosaMemberApplication"]= array();
607     $ldap= $this->config->get_ldap_link();
608     $ldap->cd($this->dn);
609     $ldap->modify($this->attrs);
610     show_ldap_error($ldap->get_error());
612     /* Optionally execute a command after we're done */
613     $this->handle_post_events("remove");
614   }
617   /* Save to LDAP */
618   function save()
619   {
620     plugin::save();
622     /* Copy members */
623     $this->Categories[""]=""; 
624     $this->attrs["gosaMemberApplication"]= array();
625     $cats = array();
626     foreach($this->Categories as $name => $cats){
627       $cats[$name] =0;
628       if(isset($this->gosaMemberApplication[$name])){
629         foreach($this->gosaMemberApplication[$name] as $entry){
630           if(!preg_match("/__SEPARATOR__/",$entry['App'])){
631             $this->attrs["gosaMemberApplication"][]= $entry['App']."|".$name."|".$cats[$name];
632           }
633           $cats[$name] = $cats[$name] + 1;
634         }
635       }
636       if(($cats[$name]==0)&&(!empty($name))){
637         $this->attrs["gosaMemberApplication"][]= "|".$name."|".$cats[$name];
638       }
639     }
641     /* Are there application parameters to be saved */
642     $this->attrs['gosaApplicationParameter']= array();
643     foreach($this->appoption as $name => $value){
644       if ($value != ""){
645         $this->attrs['gosaApplicationParameter'][]= "$name:$value";
646       }
647     }
649     /* Write back to LDAP */
650     $ldap= $this->config->get_ldap_link();
651     $ldap->cd($this->dn);
652     $ldap->modify($this->attrs);
653     show_ldap_error($ldap->get_error());
655     /* Optionally execute a command after we're done */
656     if ($this->initially_was_account == $this->is_account){
657       if ($this->is_modified){
658         $this->handle_post_events("mofify");
659       }
660     } else {
661       $this->handle_post_events("add");
662     }
664   }
666   function check()
667   {
668     $message= array();
669     return ($message);
670   }
673   function reload()
674   {
675     /* Generate applist */
676     $this->apps= array();
677     $ldap= $this->config->get_ldap_link();
678     $ldap->cd ("ou=apps,".$this->curbase);
680     $ldap->ls ("(objectClass=gosaApplication)","ou=apps,".$this->curbase);
681     while ($attrs= $ldap->fetch()){
682       if (isset($attrs["description"][0])){    
683         $this->apps[$attrs["cn"][0]]=
684           $attrs["cn"][0]." (".
685           $attrs["description"][0].")";
686       } else {
687         $this->apps[$attrs["cn"][0]]=
688           $attrs["cn"][0];
689       }
690     }
691     natcasesort ($this->apps);
692     reset ($this->apps);
694     if(is_array($this->gosaMemberApplication))
695       foreach ($this->gosaMemberApplication as $cat){   
696         if(is_array($cat))
697           foreach($cat as $entry){
698             $this->used_apps[$entry['App']]= $entry['App'];
699           }
700       }
701   }
704   function addApp($cn)
705   {
706     if((isset($this->gosaMemberApplication[$this->curCatDir]))&&(is_array($this->gosaMemberApplication[$this->curCatDir]))){
707       foreach($this->gosaMemberApplication[$this->curCatDir] as $entry){
708         if($entry['App'] == $cn) return;
709       }
710     }
711     $this->gosaMemberApplication[$this->curCatDir][]= array("App"=>$cn);
712     $this->used_apps[$cn]=$cn;
713     $this->is_modified= TRUE;
714   }
717   function removeApp($cn)
718   {
719     $temp= array();
720     foreach ($this->gosaMemberApplication as $value){
721       if ($value != $cn){
722         $temp[]= $value;
723       }
724     }
725     $this->gosaMemberApplication= $temp;
726     $this->is_modified= TRUE;
727   }
729   function GetSubdirs($dir)
730   {
731     $ret = array();
732     $tmp1 = split("/",$this->curCatDir);
733  
734     foreach($this->Categories as $path=>$cat){
735       $tmp2 = split("/",$path);
736       
737       if((empty($this->curCatDir))&&(!preg_match("/\//",$path))){
738         $abort = false;
739       }elseif(((count($tmp1))+1) == (count($tmp2))){
740         $abort = false;
741         for($i = 0 ; $i < count($tmp1) ; $i++){
742           if($tmp1[$i] != $tmp2[$i]){
743             $abort = true;
744           }
745         }
746       }else{
747         $abort= true;
748       }
749       if(!$abort){
750         $ret[$path]=$cat;
751       } 
752     }
753   return($ret);
754   }
758 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
759 ?>