Code

f3476f02bfcda98442aab7e6c2ecc9c93c9b0e72
[gosa.git] / gosa-plugins / goto / admin / groups / apps / class_groupApplication2.inc
1 <?php
2 class appgroup2 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");
10   var $config;
11   var $curbase;
13   /* Contains the menu structure in an array.
14    */
15   var $a_Structure= array();
16   var $a_Structure_on_load = array();
17   var $Releases;
18   var $FAIrelease = 0;
19   var $apps = array();
20   var $_cache = array();
22   public function __construct(&$config, $dn= NULL, $parent= NULL)
23   {
24     plugin::plugin($config,$dn,$parent);
25     $this->dn = $dn; 
26     $this->_load_menu_structure();
27     $this->a_Structure_on_load = $this->a_Structure;
29     /* Check if we have relase mangement enabled and prepare group application for release management */
30     $tmp = $config->search("faiManagement", "CLASS",array('menu','tabs'));
31     if(!empty($tmp)){
32       $this->enableReleaseManagement = true;
33     }
35     /* Get required release informations */
36     if($this->enableReleaseManagement){
37       $this->Releases   = $this->getReleases();
38 #      $this->FAIrelease = 0;
39     }
40 #    $this->curbase = $this->config->current['BASE'];
41     $this->reload();
42   }
45   function reload()
46   {
47     $ret = array();
48     $release_info = $this->Releases[$this->FAIrelease];
50     if(1 | !isset($this->_cache['ReleaseApps'][$release_info['suffix']])){
52       $ldap = $this->config->get_ldap_link();
53       $ldap->cd($this->curbase);
54       $ldap->search("ou=apps",array("dn"));
55       $app_deps = array();
56       while($attrs = $ldap->fetch()){
57         $app_deps[] = $attrs['dn'];
58       }
60       foreach($app_deps as $dep){
61         $ldap->cd($dep);
62         $ldap->search("objectClass=FAIbranch",array("dn"));
63         while($attrs = $ldap->fetch()){
64           $app_deps[] = $attrs['dn'];
65         }
66       }
68       foreach($app_deps as $dep){
69         if(preg_match("/^".normalizePreg($release_info['suffix'])."/",$dep)){
70           $ret = array_merge($ret,get_list("(objectClass=gosaApplication)","application",$dep,array("*"),GL_NONE));
71         }
72       }
73       $this->_cache['ReleaseApps'][$release_info['suffix']] = $ret;
74     } 
75     $this->apps = $this->_cache['ReleaseApps'][$release_info['suffix']];
76   }
79   function getReleases()
80   {
81     /* Only display those releases that we are able to read */
82     $dn     = $this->config->current['BASE'];
83     $filter = "(&(objectClass=organizationalUnit)(objectClass=FAIbranch))";
84     $res    = get_list($filter,"application", $dn, array("ou"), GL_SUBSEARCH);
86     $ret =array(array("name" => "/" , "parts" => array(),"suffix" => get_ou('applicationou')));
87     foreach($res as $attrs){
88       if(preg_match("/".get_ou('applicationou')."/",$attrs['dn'])){
89         $bb     = preg_replace("/".get_ou('applicationou').".*/","",$attrs['dn']);
90         $parts  = array_reverse(split("ou=",$bb));
92         $str ="";
93         foreach($parts as $key => $part){
94           if(empty($part)) {
95             unset($parts[$key]);
96             continue;
97           }
98           $part = str_replace(",","",$part);
99           $str .= $part."/";
100           $parts[$key] = $part;
101         }
102         $name = preg_replace("/\/$/","",$str);
103         if(empty($name)) {
104           $name ="/";
105         }
106         $ret[] = array("name" => $name , "dn" => $attrs['dn'], "parts" => $parts,"suffix" => $bb.get_ou('applicationou'));
107       }
108     }
109     return($ret);
110   }
113   function _load_menu_structure()
114   {
115     $this->a_Structure  = array();
116     $ldap = $this->config->get_ldap_link();
117     $ldap->cd($this->dn);
118     $ldap->search("(|(objectClass=gotoSubmenuEntry)(objectClass=FAIbranch)(objectClass=gotoMenuEntry))",array("*"));
119     $parent_id = 0;
120     while($attrs = $ldap->fetch()){
121       $cur = &$this->a_Structure;
122       $sub_dn       = preg_replace("/,".normalizePreg($this->dn)."$/","",$attrs['dn']);
123       $sub_dn_array = split("\,",$sub_dn);
124       for($i = (count($sub_dn_array)-1) ; $i >= 0 ; $i--){
125         $name = preg_replace("/^[^=]*+=/","",$sub_dn_array[$i]);
126         if($i != 0){
127           foreach($cur as $key => $entry){
128             if($entry['NAME'] == $name){
129               $cur = &$cur[$key]['ENTRIES'];
130               $parent_id = $entry['UNIQID'];
131             }
132           }
133         }else{
135           $priority = 1;
136           if(isset($attrs['gosaApplicationPriority'])){
137             $priority= $attrs['gosaApplicationPriority'][0];
138           }
139           while(isset($cur[$priority])){
140             $priority ++;
141           }
143           $data = array();
144           if(in_array("gotoSubmenuEntry",$attrs['objectClass'])){
145             $type = "FOLDER";
146           }elseif(in_array("gotoMenuEntry",$attrs['objectClass'])){
147             $type = "ENTRY";
148           }elseif(in_array("FAIbranch",$attrs['objectClass'])){
149             $type = "RELEASE";
150             $data['FAIstate'] = $attrs['FAIstate'][0];
151           }
153           $data['DN']       = $attrs['dn'];
154           $data['NAME']     = $name;
155           $data['TYPE']     = $type;
156           $data['PRIORITY'] = $priority;
157           $data['ENTRIES']  = array();
158           $data['UNIQID']   = uniqid();
159           $data['PARENT']   = $parent_id;
160           $data['STATUS']   = "LOADED";
161           $cur[$priority]   = $data;
162           ksort($cur);
163         }
164       }
165     }
166   } 
169   function execute()
170   {
171     /* Call parent execute */
172     plugin::execute();
174     if(isset($_GET['r']))
175     $this->__construct($this->config,$this->dn);
177     $smarty = get_smarty();
179     /* Create application list */
180     $div = new divSelectBox("appgroup");
181     $div->SetHeight(300);
182     $departments = array();
183     $res = get_list("(objectClass=gosaDepartment)", "application", $this->curbase,array("description","cn","ou"),GL_SIZELIMIT);
184     foreach($res as $value){
185       $fdn = $value['dn'];
186       $fdn = preg_replace("/".normalizePreg($this->curbase)."/","",$fdn);
187       $fdn= @LDAP::fix($fdn);
188       if($value["description"][0]!=".."){
189         $departments[$value['dn']]= convert_department_dn($fdn)." - [".$value["description"][0]."]";
190       }else{
191         $departments[$value['dn']]=convert_department_dn($fdn)." ["._("Back")."]";
192       }
193     }
195     /* Create 'open' and 'add' links */
196 #    if($this->acl_is_writeable("gosaMemberApplication",$this->no_release_acls)){
197       $linkadd  = "<a href='?plug=".$_GET['plug']."&amp;act=add&amp;id=%s'>%s</a>";
198  #   }else{
199   #    $linkadd = "%s";
200    # }
201     $linkopen = "<a href='?plug=".$_GET['plug']."&amp;act=depopen&amp;depid=%s'>%s</a>";
203     /* Create base back entry */
204     $base_back = preg_replace("/^[^,]+,/","",$this->curbase);
205     if((strlen($base_back)>= strlen($this->config->current['BASE']))&&($this->curbase!=$this->config->current['BASE'])){
206       $div->AddEntry(array(
207             array("string"=>sprintf($linkopen,base64_encode($base_back),".. ["._("back")."]"),
208               "attach"=>"style='border:0px;'")
209             ));
210     }
212     /* Append departments for current base */
213     foreach($departments as $key => $app){
214       $div->AddEntry(array(
215             array("string"=>"<img class='center' src='images/folder.png' alt='"._("department")."'>&nbsp;".sprintf($linkopen,
216                 base64_encode($key),$app),
217               "attach"=>"style='border:0px;'")
218             ));
219     }
221   
222     /* Add applications found on this base */
223     $used_apps = $this->_get_used_entry_name();
224     foreach($this->apps as $key => $app){
225       if(in_array($app['cn'][0],$used_apps)){
226         continue;
227       }
228       if(!preg_match("/".get_ou('applicationou').normalizePreg($this->curbase)."$/",$app['dn'])){
229         continue;
230       }
232       $name = $app['cn'][0];
233       if(isset($app['description'])){
234         $name .= "&nbsp;[".$app['description'][0]."]";
235       }
236       $div->AddEntry(array(
237             array("string"=>sprintf("<input class='center' type='checkbox' value='1' name='AddApp_%s'>",$key).
238               "<img class='center' src='images/select_application.png' alt='"._("application")."'>&nbsp;".sprintf($linkadd,$key,$name),
239               "attach"=>"style='border:0px;'")
240             ));
241     }
243     
244     $smarty->assign("FAIrelease",$this->FAIrelease);
245     $smarty->assign("app_list",$div->DrawList());
246     $smarty->assign("releases",$this->Releases);
247     $smarty->assign("folders" , $this->_get_folder_names());
248     $entries = $this->_get_entries_for_release($this->FAIrelease);
249     $smarty->assign("entries",$entries);
250     $display= $smarty->fetch (get_template_path('app_list.tpl', TRUE, dirname(__FILE__)));
251     return($display);
252   }
254     
255   function _get_folder_names()
256   {
257     $data = $this->_get_entries_for_release($this->FAIrelease);
258     $ret = array("BASE" => ".");
259     foreach($data as $entry){
260       if($entry['TYPE'] == "FOLDER"){
261         $ret[$entry['UNIQID']] = $entry['NAME'];
262       }
263     }
264     return($ret);
265   }
267  
268   function _get_used_entry_name()
269   {
270     $data = $this->_get_entries_for_release($this->FAIrelease);
271     $ret = array();
272     foreach($data as $entry){
273       if($entry['TYPE'] == "ENTRY"){
274         $ret[] = $entry['NAME'];
275       }
276     }
277     return($ret);
278   }
280  
281   function _get_entries_for_release($release,$cur = NULL)
282   {
283     $all = $this->_get_all_entries();
284     $key = $this->_get_release_key($release);
285     if(isset($all[$key])){
286       return($this->_get_all_entries(TRUE,TRUE,&$all[$key]['ENTRIES']));
287     } 
288     return(array());
289   }
292   function _edit_entry_edit($id)
293   {
294   }
297   function remove_from_parent()
298   {
299   }
302   function save()
303   {
304     $ldap = $this->config->get_ldap_link();
305     $all = $this->_get_all_entries();
306     $prio = 0;
307     foreach($all as $entry){
308       $prio ++;
309       $cur = $entry;
310       $dn = "";
312       do{  
313         if($cur['TYPE'] == "ENTRY"){
314           $dn.= "cn=".$cur['NAME'].",";
315         }elseif($cur['TYPE'] == "FOLDER"){
316           $dn.= "cn=".$cur['NAME'].",";
317         }elseif($cur['TYPE'] == "RELEASE"){
318           $dn.= "ou=".$cur['NAME'].",";
319         }
320         $cur = $all[$cur['PARENT']];
321         if(!isset($cur['PARENT'])){
322           $cur = NULL;
323         }
324       }while(is_array($cur));
325       $cur_dn = $dn.$this->dn;
327       $attrs = array();
328       switch($entry['TYPE']){
329         case "ENTRY"    :
330         { 
331           $attrs['objectClass'] = "gotoMenuEntry";
332           $attrs['cn']          = $entry['NAME'];
333           $attrs['gosaApplicationPriority'] = $prio;
334         }
335         break;
336         case "FOLDER"   : 
337         { 
338           $attrs['objectClass'] = "gotoSubmenuEntry";
339           $attrs['cn']          = $entry['NAME'];
340           $attrs['gosaApplicationPriority'] = $prio;
341         }
342         break;
343         case "RELEASE"  : 
344         { 
345           $attrs['ou']            = $entry['NAME'];
346           $attrs['objectClass']   = array();
347           $attrs['objectClass'][] = "top";
348           $attrs['objectClass'][] = "organizationalUnit";
349           $attrs['objectClass'][] = "FAIbranch";
350           $attrs['FAIstate']      = $entry['FAIstate'];
351         }
352         break;
353       }
354   
355       echo $entry['STATUS']." ---> ".$cur_dn."<br>";
356       if($entry['STATUS'] == "LOADED"){
357         continue;
358       }
359       if($entry['STATUS'] == "REMOVED"){
360         echo "REMOVE<br>";
361         $ldap->rmdir_recursive($cur_dn);
362         echo $ldap->get_error();
363       }
364       if($entry['STATUS'] == "EDITED"){
365         echo "EDITED<br>";
366         $ldap->cd($cur_dn);
367         $ldap->modify($attrs);
368         echo $ldap->get_error();
369         print_a($attrs);
370       }
371       if($entry['STATUS'] == "ADDED"){
372         echo "ADDED<br>";
373         $ldap->cd($cur_dn);
374         $ldap->add($attrs);
375         echo $ldap->get_error();
376         print_a($attrs);
377       }
378     }
379     print_a($this->a_Structure);
380     exit();
382   }
385   function check()
386   {
387   }
391   /* !\brief Handle ui POSTS, like sort up/down/delete
392    */ 
393   function save_object()
394   {
395     foreach($_POST as $name => $value){
396       if(preg_match("/del_/",$name)){
397         $id = preg_replace("/^del_/","",$name);
398         $id = preg_replace("/_(x|y)$/","",$id);
399         $this->_remove_entry_id($id);
400         break;
401       }
402       if(preg_match("/edit_/",$name)){
403         $id = preg_replace("/^edit_/","",$name);
404         $id = preg_replace("/_(x|y)$/","",$id);
405         $this->_edit_entry_edit($id);
406         break;
407       }
408       if(preg_match("/up_/",$name)){
409         $id = preg_replace("/^up_/","",$name);
410         $id = preg_replace("/_(x|y)$/","",$id);
411         $this->_move_entry_up($id);
412         break;
413       }
414       if(preg_match("/down_/",$name)){
415         $id = preg_replace("/^down_/","",$name);
416         $id = preg_replace("/_(x|y)$/","",$id);
417         $this->_move_entry_down($id);
418         break;
419       }
420     }
421     if(isset($_POST['FAIrelease'])){
422       $this->FAIrelease = $_POST['FAIrelease'];
423     }
424     if(isset($_GET['act']) && $_GET['act'] == 'depopen'){
425       $this->curbase = base64_decode($_GET['depid']);
426     }
427     if(isset($_POST['add_to_folder']) && isset($_POST['folder'])){
428       $folder = $_POST['folder'];
429       foreach($_POST as $name => $value){
430         if(preg_match("/^AddApp_[0-9]*$/",$name)){
431           $this->_add_app_id($folder,preg_replace("/^AddApp_/","",$name));   
432         }
433       }
434     }
435     if(isset($_POST['add_menu_to_folder']) && isset($_POST['menu_folder'])){
436       $folder = $_POST['menu_folder'];
437       $name = $_POST['menu_folder_name'];
438       if(strlen($name) > 0 && preg_match("/[a-z ]/i",$name)){
439         $this->_add_sub_folder($folder,$name);
440       }
441     }
442     $this->reload();
443   }
445   
446   function _get_release_key($release)
447   {
448     $release_info = $this->Releases[$release];
449     $cur = &$this->a_Structure;
450     $s_key = "";
451     $found = FALSE;
452     foreach($release_info['parts'] as $name){
453       foreach($cur as $key => $obj){
454         if($obj['TYPE'] == "RELEASE" && $obj['NAME'] == $name){
455           $s_key = $cur[$key]['UNIQID'];
456           $cur = &$cur[$key]['ENTRIES'];
457           $found = TRUE;
458           break;
459         }
460         $found = FALSE;
461       }
462     }
463     if($found){
464       return($s_key);  
465     }  
466     return(FALSE);
467   }
469   
470   function _add_sub_folder($folder,$name)
471   {
472     $all = $this->_get_all_entries();
473     if($folder == "BASE"){
474       $folder = $this->_get_release_key($this->FAIrelease);
475     }
476     
477     if(isset($all[$folder])){
478       $a_folder = array();
479       $a_folder['STATUS'] = "ADDED";
480       $a_folder['NAME']   = $name;
481       $a_folder['UNIQID'] = uniqid();
482       $a_folder['PARENT'] = $folder;      
483       $a_folder['TYPE']   = "FOLDER";
484       $all[$folder]['ENTRIES'][] = $a_folder;
485     }
486   }
489   /* !\brief Remove the given id from the menu structure.
490       @param  String  ID to of the entry we want to remove.
491       @return Boolean TRUE on success
492    */
493   function _remove_entry_id($id)
494   {
495     $all = $this->_get_all_entries();
496     if(isset($all[$id])){
497       $all[$id]['STATUS'] = "REMOVED";
498       return(TRUE);
499     }
500     return(FALSE);
501   }
503   
504   /* !\brief Remove the given id from the menu structure.
505       @param  String  ID to of the entry we want to remove.
506       @return Boolean TRUE on success
507    */
508   function _add_entry($folder_id,$entry,$pos = 0)
509   {
510     $all = $this->_get_all_entries();
512     if(isset($all[$folder_id])){
514       $folder  = &$all[$folder_id];
515       $entries = $entry['ENTRIES'];
517       $entry['UNIQID'] = uniqid();     
518       $entry['PARENT'] = $folder_id;
519       $entry['ENTRIES']= array();
520       $entry['STATUS'] = "ADDED";
521       
522       $cnt = 0; 
523       $new = array();
524       $added =FALSE;
525       foreach($folder['ENTRIES'] as $key => $obj){
526         if($pos == $cnt){
527           $new[] = $entry;
528           $added = TRUE;
529           $cnt ++;
530         }
531         $new[] = $obj;
532       }
533       if(!$added){
534         $new[] = $entry;
535       }
536       $all[$folder_id]['ENTRIES'] = $new;
537       foreach($entries as $sub){
538         $this->_add_entry($entry['UNIQID'],$sub);
539       }
540       return(TRUE);
541     }
542     return(FALSE);
543   }
545   
546   function _add_app_id($folder_id,$app_id)
547   {
548     $all = $this->_get_all_entries();
549     if($folder_id == "BASE"){
550       $folder_id = $this->_get_release_key($this->FAIrelease);
551     }
552     if(isset($all[$folder_id]) && isset($this->apps[$app_id])){
554       $new = array();
555       $new['TYPE']  = "ENTRY";
556       $new['NAME']  = $this->apps[$app_id]['cn'][0];
557       $new['UNIQID']= uniqid(); 
558       $new['PARENT']= $folder_id;
559       $new['STATUS']= "ADDED";
560       $all[$folder_id]['ENTRIES'][] = $new;
561     }
562   }
565   /*! \brief move the object identified by the given ID one position up.
566       @param  String  The ID of the entry to be moved.
567       @return Boolean TRUE on success, else FALSE;
568    */
569   function _move_entry_up($id)
570   {
571     $all = $this->_get_all_entries(TRUE);
572     $parent = FALSE;
573     foreach($all as $entry){
574       if(isset($entry['UNIQID']) && $entry['UNIQID'] == $id){
575         if($parent != FALSE){
576           return($this->__switch_entries($id,"up",$parent));
577         }
578       }else{
579         if(in_array($entry['TYPE'],array("CLOSE","OPEN"))){
580           $parent = $entry['PARENT'];
581         }else{
582           $parent = $entry['UNIQID'];
583         }
584       }
585     }
586     return(FALSE);
587   }
590   /*! \brief move the object identified by the given ID one position down.
591       @param  String  The ID of the entry to be moved.
592       @return Boolean TRUE on success, else FALSE;
593    */
594   function _move_entry_down($id)
595   {
596     $all = $this->_get_all_entries(TRUE);
597     $found = FALSE;
598     foreach($all as $entry){
599       if(isset($entry['UNIQID']) && $entry['UNIQID'] == $id){
600         $found = TRUE;
601         continue;
602       }else{
603         if(in_array($entry['TYPE'],array("CLOSE","OPEN"))){
604           $parent = $entry['PARENT'];
605         }else{
606           $parent = $entry['UNIQID'];
607         }
608         if($found){
609           return($this->__switch_entries($id,"down",$parent));
610         }
611       }
612     }
613     return(FALSE);
614   }
617   /*! \brief  Return all entries linear. 
618       @param  Boolean   $add_tags  If TRUE, OPEN/CLOSE Tags will be appended.
619       @param  &Array    Start here, Pointer to an array.
620    */ 
621   function _get_all_entries($add_tags = FALSE, $skip_release = FALSE, $cur = NULL)
622   {
623     $ret = array();
624     if($cur == NULL){
625       $cur = &$this->a_Structure;
626     }
627     foreach($cur as $key => $entry){
629       if($skip_release && $entry['TYPE'] == "RELEASE"){
630         continue;
631       }    
632       if($entry['TYPE'] == "ENTRY"){
633         $found = FALSE;
634         foreach($this->apps as $app){
635           if($app['cn'][0] == $entry['NAME']){
636             $found = TRUE;
637             if(isset($app['description'][0])){
638               $entry['INFO'] = "[".$app['description'][0]."]";
639             }
640             break;
641           }
642         } 
643         if(!$found){
644           $entry['INFO'] = "<font color='red'>"._("Not available in release.")."</font>";
645         }
646       }
647       
649       $tmp = $entry;
650       if(!$add_tags){
651         $ret[$tmp['UNIQID']] = &$cur[$key];
652         if(isset($entry['ENTRIES']) && count($entry['ENTRIES'])){
653           $ret = array_merge($ret,$this->_get_all_entries($add_tags,$skip_release,&$cur[$key]['ENTRIES']));
654         }
655       }else{
656       
657         if(isset($tmp['ENTRIES'])){
658           unset($tmp['ENTRIES']);
659         }
661         if($tmp['STATUS'] != "REMOVED"){
662           $ret[] = $tmp;
663           if(isset($entry['ENTRIES']) && count($entry['ENTRIES'])){
664             $ret[] = array("TYPE" => "OPEN", "PARENT" => $entry['UNIQID']);
665             $ret = array_merge($ret,$this->_get_all_entries($add_tags,$skip_release,&$cur[$key]['ENTRIES']));
666             $ret[] = array("TYPE" => "CLOSE" , "PARENT" => $entry['UNIQID']);
667           }
668         }
669       }
670     }
671     return($ret);
672   }
675   /* !\brief Switch one entry with another 
676      @param  String  from  The source ID.
677      @param  String  type  "up"/"down" type switched.
678      @param  String  to    The destination ID.
679      return  Boolean TRUE on success 
680    */
681   function __switch_entries($from,$type,$to)
682   {
683     $all = $this->_get_all_entries();
685     $o_to   = &$all[$to];
686     $o_from = &$all[$from];
688     /***********************
689      * Source == Destination 
690      * Move into next parent. 
691      ************************/
692     if($to == $from){
693       $to = $o_to['PARENT'];
694       $o_to   = &$all[$to];
695     }
697     /***********************
698      * Target is container 
699      ************************/
700     if(in_array($o_to['TYPE'],array("FOLDER","RELEASE"))){
702       /***********************
703        * Move into parent folder  
704        *   + Target 
705        *   |-> Source
706        ************************/
707       if($to == $o_from['PARENT']){
709  
710         /* Check if source is a folder object 
711          */
712         $o_to_sub = &$all[$o_to['PARENT']]; 
713         if(in_array($o_to_sub['TYPE'],array("FOLDER","RELEASE"))){
715           $o_from['STATUS'] = "ADDED";
717           /* Adding new */
718           $tmp2 = array();  
719           $cnt = 0; 
720           foreach($o_to_sub['ENTRIES'] as $key => $entry){
721             $cnt ++;
722             if($entry['UNIQID'] == $to){
723               break;
724             }
725           }
726           if($type == "up"){
727             $cnt --;
728  
729          }
730          $this->_add_entry($o_to_sub['UNIQID'],$o_from,$cnt);
732           /* Removing old */
733           $tmp = array();
734           if(!$this->_remove_entry_id($from)){
735             return(FALSE);
736           }
737         } 
738       }else{
740         /***********************
741          * Target is NOT parent container
742          *  + Parent Folder
743          *  |-> Source 
744          *  + Destination
745          ************************/
747         /* Removing old */
748         $o_to   = $all[$to];
749         $o_from = $all[$from];
750         $this->_add_entry($to,$o_from);
751         $this->_remove_entry_id($from);
752       }
753     }else{
755       /***********************
756        * Source and Destination in some Folder.
757        *  + Parent folder
758        *  |-> Source
759        *  |-> Destination
760        ************************/
761       $o_to   = &$all[$to];
762       $o_from = &$all[$from];
763       $parent = &$all[$o_to['PARENT']];
765       if($o_to['PARENT'] == $o_from['PARENT']){
766         $tmp = $all[$to];
767         $all[$to]   = $o_from;
768         $all[$from] = $tmp;
769   
770         /* Ensure that the app priority is updated */
771         foreach($parent['ENTRIES'] as $key => $entry){
772           $parent['ENTRIES'][$key]['STATUS'] = "EDITED";
773         }
774       }
775     }
776   }
779   /* Return plugin informations for acl handling  */ 
780   static function plInfo()
781   {
782     return (array(
783           "plShortName"   => _("Applications"),
784           "plDescription" => _("Group applications"),
785           "plSelfModify"  => FALSE,
786           "plDepends"     => array(),
787           "plPriority"    => 0,
788           "plSection"     => array("admin"),
789           "plCategory"    => array("groups"),
790           "plProvidedAcls"=> array(
791             "gosaMemberApplication"     => _("Application"),
792             "FAIrelease"                => _("Release"),
793             "gosaApplicationParameter"  => _("Application parameter"))
794           ));
795   }
798   function PrepareForCopyPaste($source)
799   {
800   }
803   function multiple_save_object()
804   {
805     if(isset($_POST['group_apps_multi'])){
806       $this->save_object(); 
807       plugin::multiple_save_object();    
808   
809       /* Get posts */
810       foreach(array("apps") as $attr){
811         if(isset($_POST['use_'.$attr])) {
812           $this->multi_boxes[] = $attr;
813         }
814       }
815     }
816   }
817   
819   function get_multi_edit_values()
820   {
821     $ret = plugin::get_multi_edit_values();
823     if(in_array("apps",$this->multi_boxes)){
824       $ret['gosaApplicationParameter'] = $this->gosaApplicationParameter;
825       $ret['Categories']               = $this->Categories;
826       $ret['gosaMemberApplication']    = $this->gosaMemberApplication;
827       $ret['FAIrelease']               = $this->FAIrelease;
828       $ret['appoption']                = $this->appoption;
829     }
830     return($ret);
831   }
833 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
834 ?>