Code

d1822939b4093ec8a7f368230168669815335401
[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->config->current['BASE']);
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     $Actions = array("Remove" => array(),"Edit" => array() , "Add" => array());
308     foreach($all as $entry){
309       $prio ++;
310       $cur = $entry;
311       $dn = "";
313       do{  
314         if($cur['TYPE'] == "ENTRY"){
315           $dn.= "cn=".$cur['NAME'].",";
316         }elseif($cur['TYPE'] == "FOLDER"){
317           $dn.= "cn=".$cur['NAME'].",";
318         }elseif($cur['TYPE'] == "RELEASE"){
319           $dn.= "ou=".$cur['NAME'].",";
320         }
321         $cur = $all[$cur['PARENT']];
322         if(!isset($cur['PARENT'])){
323           $cur = NULL;
324         }
325       }while(is_array($cur));
326       $cur_dn = $dn.$this->dn;
328       $attrs = array();
329       switch($entry['TYPE']){
330         case "ENTRY"    :
331         { 
332           $attrs['objectClass'] = "gotoMenuEntry";
333           $attrs['cn']          = $entry['NAME'];
334           $attrs['gosaApplicationPriority'] = $prio;
335         }
336         break;
337         case "FOLDER"   : 
338         { 
339           $attrs['objectClass'] = "gotoSubmenuEntry";
340           $attrs['cn']          = $entry['NAME'];
341           $attrs['gosaApplicationPriority'] = $prio;
342         }
343         break;
344         case "RELEASE"  : 
345         { 
346           $attrs['ou']            = $entry['NAME'];
347           $attrs['objectClass']   = array();
348           $attrs['objectClass'][] = "top";
349           $attrs['objectClass'][] = "organizationalUnit";
350           $attrs['objectClass'][] = "FAIbranch";
351           $attrs['FAIstate']      = $entry['FAIstate'];
352         }
353         break;
354       }
355   
356       if($entry['STATUS'] == "LOADED"){
357         continue;
358       }
359       if($entry['STATUS'] == "REMOVED"){
360         $Actions['Remove'][$cur_dn] = $cur_dn;
361       }
362       if($entry['STATUS'] == "EDITED"){
363         $Actions['Edit'][$cur_dn] = $attrs;
364       }
365       if($entry['STATUS'] == "ADDED"){
366         $Actions['Add'][$cur_dn] = $attrs;
367       }
368     }
370     $ldap = $this->config->get_ldap_link();
371     $ldap->cd($this->config->current['BASE']);
372     foreach($Actions['Remove'] as $dn){
373       $ldap->cd($dn);
374       $ldap->cat($dn);
375       if($ldap->count()){
376         $ldap->rmdir_recursive($dn);
377       }
378     }
379     foreach($Actions['Add'] as $dn => $data){
380       $ldap->cd($dn);
381       $ldap->cat($dn);
382       if(!$ldap->count()){
383         $ldap->add($data);
384       }
385     }
386     foreach($Actions['Edit'] as $dn => $data){
387       $ldap->cd($dn);
388       $ldap->cat($dn);
389       if($ldap->count()){
390         $ldap->modify($data);
391       }
392     }
393   }
396   function check()
397   {
398   }
402   /* !\brief Handle ui POSTS, like sort up/down/delete
403    */ 
404   function save_object()
405   {
406     foreach($_POST as $name => $value){
407       if(preg_match("/del_/",$name)){
408         $id = preg_replace("/^del_/","",$name);
409         $id = preg_replace("/_(x|y)$/","",$id);
410         $this->_remove_entry_id($id);
411         break;
412       }
413       if(preg_match("/edit_/",$name)){
414         $id = preg_replace("/^edit_/","",$name);
415         $id = preg_replace("/_(x|y)$/","",$id);
416         $this->_edit_entry_edit($id);
417         break;
418       }
419       if(preg_match("/up_/",$name)){
420         $id = preg_replace("/^up_/","",$name);
421         $id = preg_replace("/_(x|y)$/","",$id);
422         $this->_move_entry_up($id);
423         break;
424       }
425       if(preg_match("/down_/",$name)){
426         $id = preg_replace("/^down_/","",$name);
427         $id = preg_replace("/_(x|y)$/","",$id);
428         $this->_move_entry_down($id);
429         break;
430       }
431     }
432     if(isset($_POST['FAIrelease'])){
433       $this->FAIrelease = $_POST['FAIrelease'];
434     }
435     if(isset($_GET['act']) && $_GET['act'] == 'depopen'){
436       $this->curbase = base64_decode($_GET['depid']);
437     }
438     if(isset($_POST['add_to_folder']) && isset($_POST['folder'])){
439       $folder = $_POST['folder'];
440       foreach($_POST as $name => $value){
441         if(preg_match("/^AddApp_[0-9]*$/",$name)){
442           $this->_add_app_id($folder,preg_replace("/^AddApp_/","",$name));   
443         }
444       }
445     }
446     if(isset($_POST['add_menu_to_folder']) && isset($_POST['menu_folder'])){
447       $folder = $_POST['menu_folder'];
448       $name = $_POST['menu_folder_name'];
449       if(strlen($name) > 0 && preg_match("/[a-z ]/i",$name)){
450         $this->_add_sub_folder($folder,$name);
451       }
452     }
453     $this->reload();
454   }
456   
457   function _get_release_key($release)
458   {
459     $release_info = $this->Releases[$release];
460     $cur = &$this->a_Structure;
461     $s_key = "";
462     $found = FALSE;
463     foreach($release_info['parts'] as $name){
464       foreach($cur as $key => $obj){
465         if($obj['TYPE'] == "RELEASE" && $obj['NAME'] == $name){
466           $s_key = $cur[$key]['UNIQID'];
467           $cur = &$cur[$key]['ENTRIES'];
468           $found = TRUE;
469           break;
470         }
471         $found = FALSE;
472       }
473     }
474     if($found){
475       return($s_key);  
476     }  
477     return(FALSE);
478   }
480   
481   function _add_sub_folder($folder,$name)
482   {
483     $all = $this->_get_all_entries();
484     if($folder == "BASE"){
485       $folder = $this->_get_release_key($this->FAIrelease);
486     }
487     
488     if(isset($all[$folder])){
489       $a_folder = array();
490       $a_folder['STATUS'] = "ADDED";
491       $a_folder['NAME']   = $name;
492       $a_folder['UNIQID'] = uniqid();
493       $a_folder['PARENT'] = $folder;      
494       $a_folder['TYPE']   = "FOLDER";
495       $all[$folder]['ENTRIES'][] = $a_folder;
496     }
497   }
500   /* !\brief Remove the given id from the menu structure.
501       @param  String  ID to of the entry we want to remove.
502       @return Boolean TRUE on success
503    */
504   function _remove_entry_id($id)
505   {
506     $all = $this->_get_all_entries();
507     if(isset($all[$id])){
508       $all[$id]['STATUS'] = "REMOVED";
509       return(TRUE);
510     }
511     return(FALSE);
512   }
514   
515   /* !\brief Remove the given id from the menu structure.
516       @param  String  ID to of the entry we want to remove.
517       @return Boolean TRUE on success
518    */
519   function _add_entry($folder_id,$entry,$pos = 0)
520   {
521     $all = $this->_get_all_entries();
523     if(isset($all[$folder_id])){
525       $folder  = &$all[$folder_id];
526       $entries = $entry['ENTRIES'];
528       $entry['UNIQID'] = uniqid();     
529       $entry['PARENT'] = $folder_id;
530       $entry['ENTRIES']= array();
531       $entry['STATUS'] = "ADDED";
532       
533       $cnt = 0; 
534       $new = array();
535       $added =FALSE;
536       foreach($folder['ENTRIES'] as $key => $obj){
537         if($pos == $cnt){
538           $new[] = $entry;
539           $added = TRUE;
540           $cnt ++;
541         }
542         $new[] = $obj;
543       }
544       if(!$added){
545         $new[] = $entry;
546       }
547       $all[$folder_id]['ENTRIES'] = $new;
548       foreach($entries as $sub){
549         $this->_add_entry($entry['UNIQID'],$sub);
550       }
551       return(TRUE);
552     }
553     return(FALSE);
554   }
556   
557   function _add_app_id($folder_id,$app_id)
558   {
559     $all = $this->_get_all_entries();
560     if($folder_id == "BASE"){
561       $folder_id = $this->_get_release_key($this->FAIrelease);
562     }
563     if(isset($all[$folder_id]) && isset($this->apps[$app_id])){
565       $new = array();
566       $new['TYPE']  = "ENTRY";
567       $new['NAME']  = $this->apps[$app_id]['cn'][0];
568       $new['UNIQID']= uniqid(); 
569       $new['PARENT']= $folder_id;
570       $new['STATUS']= "ADDED";
571       $all[$folder_id]['ENTRIES'][] = $new;
572     }
573   }
576   /*! \brief move the object identified by the given ID one position up.
577       @param  String  The ID of the entry to be moved.
578       @return Boolean TRUE on success, else FALSE;
579    */
580   function _move_entry_up($id)
581   {
582     $all = $this->_get_all_entries(TRUE);
583     $parent = FALSE;
584     foreach($all as $entry){
585       if(isset($entry['UNIQID']) && $entry['UNIQID'] == $id){
586         if($parent != FALSE){
587           return($this->__switch_entries($id,"up",$parent));
588         }
589       }else{
590         if(in_array($entry['TYPE'],array("CLOSE","OPEN"))){
591           $parent = $entry['PARENT'];
592         }else{
593           $parent = $entry['UNIQID'];
594         }
595       }
596     }
597     return(FALSE);
598   }
601   /*! \brief move the object identified by the given ID one position down.
602       @param  String  The ID of the entry to be moved.
603       @return Boolean TRUE on success, else FALSE;
604    */
605   function _move_entry_down($id)
606   {
607     $all = $this->_get_all_entries(TRUE);
608     $found = FALSE;
609     foreach($all as $entry){
610       if(isset($entry['UNIQID']) && $entry['UNIQID'] == $id){
611         $found = TRUE;
612         continue;
613       }else{
614         if(in_array($entry['TYPE'],array("CLOSE","OPEN"))){
615           $parent = $entry['PARENT'];
616         }else{
617           $parent = $entry['UNIQID'];
618         }
619         if($found){
620           return($this->__switch_entries($id,"down",$parent));
621         }
622       }
623     }
624     return(FALSE);
625   }
628   /*! \brief  Return all entries linear. 
629       @param  Boolean   $add_tags  If TRUE, OPEN/CLOSE Tags will be appended.
630       @param  &Array    Start here, Pointer to an array.
631    */ 
632   function _get_all_entries($add_tags = FALSE, $skip_release = FALSE, $cur = NULL)
633   {
634     $ret = array();
635     if($cur == NULL){
636       $cur = &$this->a_Structure;
637     }
638     foreach($cur as $key => $entry){
640       if($skip_release && $entry['TYPE'] == "RELEASE"){
641         continue;
642       }    
643       if($entry['TYPE'] == "ENTRY"){
644         $found = FALSE;
645         foreach($this->apps as $app){
646           if($app['cn'][0] == $entry['NAME']){
647             $found = TRUE;
648             if(isset($app['description'][0])){
649               $entry['INFO'] = "[".$app['description'][0]."]";
650             }
651             break;
652           }
653         } 
654         if(!$found){
655           $entry['INFO'] = "<font color='red'>"._("Not available in release.")."</font>";
656         }
657       }
658       
660       $tmp = $entry;
661       if(!$add_tags){
662         $ret[$tmp['UNIQID']] = &$cur[$key];
663         if(isset($entry['ENTRIES']) && count($entry['ENTRIES'])){
664           $ret = array_merge($ret,$this->_get_all_entries($add_tags,$skip_release,&$cur[$key]['ENTRIES']));
665         }
666       }else{
667       
668         if(isset($tmp['ENTRIES'])){
669           unset($tmp['ENTRIES']);
670         }
672         if($tmp['STATUS'] != "REMOVED"){
673           $ret[] = $tmp;
674           if(isset($entry['ENTRIES']) && count($entry['ENTRIES'])){
675             $ret[] = array("TYPE" => "OPEN", "PARENT" => $entry['UNIQID']);
676             $ret = array_merge($ret,$this->_get_all_entries($add_tags,$skip_release,&$cur[$key]['ENTRIES']));
677             $ret[] = array("TYPE" => "CLOSE" , "PARENT" => $entry['UNIQID']);
678           }
679         }
680       }
681     }
682     return($ret);
683   }
686   /* !\brief Switch one entry with another 
687      @param  String  from  The source ID.
688      @param  String  type  "up"/"down" type switched.
689      @param  String  to    The destination ID.
690      return  Boolean TRUE on success 
691    */
692   function __switch_entries($from,$type,$to)
693   {
694     $all = $this->_get_all_entries();
696     $o_to   = &$all[$to];
697     $o_from = &$all[$from];
699     /***********************
700      * Source == Destination 
701      * Move into next parent. 
702      ************************/
703     if($to == $from){
704       $to = $o_to['PARENT'];
705       $o_to   = &$all[$to];
706     }
708     /***********************
709      * Target is container 
710      ************************/
711     if(in_array($o_to['TYPE'],array("FOLDER","RELEASE"))){
713       /***********************
714        * Move into parent folder  
715        *   + Target 
716        *   |-> Source
717        ************************/
718       if($to == $o_from['PARENT']){
720  
721         /* Check if source is a folder object 
722          */
723         $o_to_sub = &$all[$o_to['PARENT']]; 
724         if(in_array($o_to_sub['TYPE'],array("FOLDER","RELEASE"))){
726           $o_from['STATUS'] = "ADDED";
728           /* Adding new */
729           $tmp2 = array();  
730           $cnt = 0; 
731           foreach($o_to_sub['ENTRIES'] as $key => $entry){
732             $cnt ++;
733             if($entry['UNIQID'] == $to){
734               break;
735             }
736           }
737           if($type == "up"){
738             $cnt --;
739  
740          }
741          $this->_add_entry($o_to_sub['UNIQID'],$o_from,$cnt);
743           /* Removing old */
744           $tmp = array();
745           if(!$this->_remove_entry_id($from)){
746             return(FALSE);
747           }
748         } 
749       }else{
751         /***********************
752          * Target is NOT parent container
753          *  + Parent Folder
754          *  |-> Source 
755          *  + Destination
756          ************************/
758         /* Removing old */
759         $o_to   = $all[$to];
760         $o_from = $all[$from];
761         $this->_add_entry($to,$o_from);
762         $this->_remove_entry_id($from);
763       }
764     }else{
766       /***********************
767        * Source and Destination in some Folder.
768        *  + Parent folder
769        *  |-> Source
770        *  |-> Destination
771        ************************/
772       $o_to   = &$all[$to];
773       $o_from = &$all[$from];
774       $parent = &$all[$o_to['PARENT']];
776       if($o_to['PARENT'] == $o_from['PARENT']){
777         $tmp = $all[$to];
778         $all[$to]   = $o_from;
779         $all[$from] = $tmp;
780   
781         /* Ensure that the app priority is updated */
782         foreach($parent['ENTRIES'] as $key => $entry){
783           $parent['ENTRIES'][$key]['STATUS'] = "EDITED";
784         }
785       }
786     }
787   }
790   /* Return plugin informations for acl handling  */ 
791   static function plInfo()
792   {
793     return (array(
794           "plShortName"   => _("Applications"),
795           "plDescription" => _("Group applications"),
796           "plSelfModify"  => FALSE,
797           "plDepends"     => array(),
798           "plPriority"    => 0,
799           "plSection"     => array("admin"),
800           "plCategory"    => array("groups"),
801           "plProvidedAcls"=> array(
802             "gosaMemberApplication"     => _("Application"),
803             "FAIrelease"                => _("Release"),
804             "gosaApplicationParameter"  => _("Application parameter"))
805           ));
806   }
809   function PrepareForCopyPaste($source)
810   {
811   }
814   function multiple_save_object()
815   {
816     if(isset($_POST['group_apps_multi'])){
817       $this->save_object(); 
818       plugin::multiple_save_object();    
819   
820       /* Get posts */
821       foreach(array("apps") as $attr){
822         if(isset($_POST['use_'.$attr])) {
823           $this->multi_boxes[] = $attr;
824         }
825       }
826     }
827   }
828   
830   function get_multi_edit_values()
831   {
832     $ret = plugin::get_multi_edit_values();
834     if(in_array("apps",$this->multi_boxes)){
835       $ret['gosaApplicationParameter'] = $this->gosaApplicationParameter;
836       $ret['Categories']               = $this->Categories;
837       $ret['gosaMemberApplication']    = $this->gosaMemberApplication;
838       $ret['FAIrelease']               = $this->FAIrelease;
839       $ret['appoption']                = $this->appoption;
840     }
841     return($ret);
842   }
844 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
845 ?>