Code

Updated activation queue
[gosa.git] / gosa-plugins / systems / admin / systems / class_systemManagement.inc
1 <?php
2 /*
3  * This code is part of GOsa (http://www.gosa-project.org)
4  * Copyright (C) 2003-2008 GONICUS GmbH
5  *
6  * ID: $$Id$$
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  */
23 class systemManagement extends management
24 {
25   var $plHeadline     = "Systems";
26   var $plDescription  = "List of systems";
27   var $plIcon  = "plugins/systems/images/plugin.png";
29   // Tab definition 
30   protected $tabClass = "";
31   protected $tabType = "";
32   protected $aclCategory = "";
33   protected $aclPlugin   = "";
34   protected $objectName   = "";
36   protected $objectInfo = array();
38   protected $opsi = NULL;
41   protected $activationQueue  = array();
42   
43   function __construct($config,$ui)
44   {
45     $this->config = $config;
46     $this->ui = $ui;
48     // Set storage points 
49     $tD = $this->getObjectDefinitions(); 
50     $sP = array();
51     foreach($tD as $entry){
52       if(!empty($entry['ou']))
53         $sP[] = $entry['ou'];
54     }
55     $this->storagePoints = array_unique($sP);
57     // Build filter
58 #    if (session::global_is_set(get_class($this)."_filter")){
59 #      $filter= session::global_get(get_class($this)."_filter");
60 #    } else {
61       $filter = new filter(get_template_path("system-filter.xml", true));
62       $filter->setObjectStorage($this->storagePoints);
63 #    }
64     $this->setFilter($filter);
66     // Build headpage
67     $headpage = new listing(get_template_path("system-list.xml", true));
68     $headpage->setFilter($filter);
69     $filter->setConverter('INCOMING', 'systemManagement::incomingFilterConverter');
71     // Register Daemon Events
72     if(class_available("DaemonEvent") && class_available("gosaSupportDaemon")){
73       $events = DaemonEvent::get_event_types(SYSTEM_EVENT | HIDDEN_EVENT);
74       foreach($events['TRIGGERED'] as $name => $data){
75         $this->registerAction("T_".$name,"handleEvent");
76         $this->registerAction("S_".$name,"handleEvent");
77       }
78       $this->registerAction("activateMultiple","activateMultiple");
79     }
80     $this->registerAction("saveEvent","saveEventDialog");
81     $this->registerAction("createISO","createISO");
82     $this->registerAction("initiateISOcreation","initiateISOcreation");
83     $this->registerAction("performIsoCreation","performIsoCreation");
84     $this->registerAction("systemTypeChosen","systemTypeChosen");
85     $this->registerAction("handleActivationQueue","handleActivationQueue");
87     // Add copy&paste and snapshot handler.
88     if ($this->config->boolValueIsTrue("main", "copyPaste")){
89       $this->cpHandler = new CopyPasteHandler($this->config);
90     }
91     if($this->config->get_cfg_value("enableSnapshots") == "true"){
92       $this->snapHandler = new SnapshotHandler($this->config);
93     }
95     // Check if we are able to communicate with the GOsa supprot daemon
96     if(class_available("gosaSupportDaemon")){
97       $o = new gosaSupportDaemon();
98       $this->si_active = $o->connect() && class_available("DaemonEvent");
99     }
101     // Check if we are able to communicate with the GOsa supprot daemon
102     if(class_available("opsi")){
103       $this->opsi = new opsi($this->config);
104     }
107     parent::__construct($config, $ui, "systems", $headpage);
108   }
111   function createISO($action,$target)
112   {
113     if(count($target) == 1){
114       $smarty = get_smarty();
115       $this->dn= array_pop($target);
116       set_object_info($this->dn);
117       return ($smarty->fetch(get_template_path('goto/gencd.tpl', TRUE)));
119     }
120   }
121   
122   function initiateISOcreation()
123   {
124     $smarty = get_smarty();
125     $smarty->assign("src", "?plug=".$_GET['plug']."&amp;PerformIsoCreation");
126     return ($smarty->fetch(get_template_path('goto/gencd_frame.tpl', TRUE)));  
127   }
130   function performIsoCreation()
131   {
132     $return_button   = "<form method='get' action='main.php' target='_parent'>
133       <input type='submit' value='"._("Back")."'>
134       <input type='hidden' name='plug' value='".$_GET['plug']."'/>
135       </form>";
137     $dsc   = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("pipe", "w"));
139     /* Get and check command */
140     $command= $this->config->search("workgeneric", "SYSTEMISOHOOK",array('tabs'));
141     if (check_command($command)){
142       @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__, $command, "Execute");
144       /* Print out html introduction */
145       echo '  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
146         <html>
147         <head>
148         <title></title>
149         <style type="text/css">@import url("themes/default/style.css");</style>
150         <script language="javascript" src="include/focus.js" type="text/javascript"></script>
151         </head>
152         <body style="background: none; margin:4px;" id="body" >
153         <pre>';
155       /* Open process handle and check if it is a valid process */
156       $process= proc_open($command." '".$this->dn."'", $dsc, $pipes);
157       if (is_resource($process)) {
158         fclose($pipes[0]);
160         /* Print out returned lines && write JS to scroll down each line */
161         while (!feof($pipes[1])){
162           $cur_dat = fgets($pipes[1], 1024);
163           echo $cur_dat;
164           echo '<script language="javascript" type="text/javascript">scrollDown2();</script>' ;
165           flush();
166         }
167       }
169       /* Get error string && close streams */
170       $buffer= stream_get_contents($pipes[2]);
172       fclose($pipes[1]);
173       fclose($pipes[2]);
174       echo "</pre>";
176       /* Check return code */
177       $ret= proc_close($process);
178       if ($ret != 0){
179         echo "<h1 style='color:red'>"._("Creating the image failed. Please see the report below.")."</h1>";
180         echo "<pre style='color:red'>$buffer</pre>";
181       }
182       echo $return_button."<br>";
183     } else {
184       $tmp= "<h1 style='color:red'>".sprintf(_("Command '%s', specified for ISO creation doesn't seem to exist."), $command)."</h1>";
185       echo $tmp;
186       echo $return_button."<br>";
187     }
189     /* Scroll down completly */
190     echo '<script language="javascript" type="text/javascript">scrollDown2();</script>' ;
191     echo '</body></html>';
192     flush();
193     exit;
194   }
197   /*! \brief    Handle GOsa-si events
198    *            All events are handled here.
199    */
200   function handleEvent($action="",$target=array(),$all=array())
201   {
202     // Detect whether this event is scheduled or triggered.
203     $triggered = TRUE;
204     if(preg_match("/^S_/",$action)){
205       $triggered = FALSE;
206     }
208     // Detect triggere or scheduled actions 
209     $headpage = $this->getHeadpage();
210     if(preg_match("/^[TS]_/", $action)){
212       // Send special reinstall action for opsi hosts
213       $event = preg_replace("/^[TS]_/","",$action); 
214       if($event == "DaemonEvent_reinstall" && $this->si_active && $this->opsi){
215         foreach($target as $key => $dn){
216           $type = $headpage->getType($dn);
218           // Send Reinstall event for opsi hosts
219           if($type == "FAKE_OC_OpsiHost"){
220             $obj = $headpage->getEntry($dn);
221             $this->opsi->job_opsi_install_client($obj['cn'][0],$obj['macAddress'][0]);
222             unset($target[$key]);
223           }
224         }
225       }
226     } 
228     // Now send remaining FAI/GOsa-si events here.
229     if(count($target) && $this->si_active){
230       $mac= array();
232       // Collect target mac addresses
233       $ldap = $this->config->get_ldap_link();
234       $tD = $this->getObjectDefinitions();
235       $events = DaemonEvent::get_event_types(SYSTEM_EVENT);
236       $o_queue = new gosaSupportDaemon();
237       foreach($target as $dn){
238         $type = $headpage->getType($dn);
239         if($tD[$type]['sendEvents']){
240           $obj = $headpage->getEntry($dn);
241           if(isset($obj['macAddress'][0])){
242             $mac[] = $obj['macAddress'][0];
243           }
244         }
245       }
247       /* Skip installation or update trigerred events,
248        *  if this entry is currently processing.
249        */
250       if($triggered && in_array($event,array("DaemonEvent_reinstall","DaemonEvent_update"))){
251         foreach($mac as $key => $mac_address){
252           foreach($o_queue->get_entries_by_mac(array($mac_address)) as $entry){
253             $entry['STATUS'] = strtoupper($entry['STATUS']);
254             if($entry['STATUS'] == "PROCESSING" &&
255                 isset($events['QUEUED'][$entry['HEADERTAG']]) &&
256                 in_array($events['QUEUED'][$entry['HEADERTAG']],array("DaemonEvent_reinstall","DaemonEvent_update"))){
257               unset($mac[$key]);
259               new log("security","systems/".get_class($this),"",array(),"Skip adding 'DaemonEvent::".$type."' for mac '".$mac_address."', there is already a job in progress.");
260               break;
261             }
262           }
263         }
264       }
266       // Prepare event to be added
267       if(count($mac) && isset($events['BY_CLASS'][$event]) && $this->si_active){
268         $event = $events['BY_CLASS'][$event];
269         $this->dialogObject = new $event['CLASS_NAME']($this->config);
270         $this->dialogObject->add_targets($mac);
272         if($triggered){
273           $this->dialogObject->set_type(TRIGGERED_EVENT);
274           $o_queue->append($this->dialogObject);
275           if($o_queue->is_error()){
276             msg_dialog::display(_("Service infrastructure"),msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
277           }else{
278             $this->closeDialogs();
279           }
280         }else{
281           $this->dialogObject->set_type(SCHEDULED_EVENT);
282         }
283       }
284     }
285   }
287   function cancelEdit()
288   {
289     management::cancelEdit();
290     $this->activationQueue = array();
291   }
292   
293   
294   function saveEventDialog()
295   {
296     $o_queue = new gosaSupportDaemon();
297     $o_queue->append($this->dialogObject);
298     if($o_queue->is_error()){
299       msg_dialog::display(_("Service infrastructure"),msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
300     }else{
301       $this->closeDialogs();
302     }
303  
304   }
305  
307   /*! \brief    Update filter part for INCOMING.
308    *            Allows us to search for "systemIncomingRDN".
309    */
310   static function incomingFilterConverter($filter)
311   {
312     $rdn = preg_replace("/^[^=]*=/", "", get_ou('systemIncomingRDN'));
313     $rdn = preg_replace("/,.*$/","",$rdn);
314     return(preg_replace("/%systemIncomingRDN/", $rdn,$filter));
315   }
317  
318   /*! \brief    Queue selected objects to be removed. 
319    *            Checks ACLs, Locks and ask for confirmation.
320    */
321   protected function removeEntryRequested($action="",$target=array(),$all=array())
322   {
323     $disallowed = array();
324     $this->dns = array();
326     @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,$target,"Entry removel requested!");
328     // Check permissons for each target
329     $tInfo = $this->getObjectDefinitions();
330     $headpage = $this->getHeadpage();
331     foreach($target as $dn){
332       $type = $headpage->getType($dn);
333       if(!isset($tInfo[$type])){
334         trigger_error("Unknown object type received '".$type."' please update systemManagement::getObjectDefinitions()!");
335       }else{
336         $info = $tInfo[$type];
337         $acl = $this->ui->get_permissions($dn, $info['aclCategory']."/".$info['aclClass']);
338         if(preg_match("/d/",$acl)){
339           $this->dns[] = $dn;
340         }else{
341           $disallowed[] = $dn;
342         }
343       }
344     }
345     if(count($disallowed)){
346       msg_dialog::display(_("Permission"),msgPool::permDelete($disallowed),INFO_DIALOG);
347     }
349     // We've at least one entry to delete.
350     if(count($this->dns)){
352       // check locks
353       if ($user= get_multiple_locks($this->dns)){
354         return(gen_locked_message($user,$this->dns));
355       }
357       // Add locks
358       $dns_names = array();
359       foreach($this->dns as $dn){
360         $dns_names[] =LDAP::fix($dn);
361       }
362       add_lock ($this->dns, $this->ui->dn);
364       // Display confirmation dialog.
365       $smarty = get_smarty();
366       $smarty->assign("info", msgPool::deleteInfo($dns_names,_($this->objectName)));
367       $smarty->assign("multiple", true);
368       return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
369     }
370   }
373   /*! \brief  Object removal was confirmed, now remove the requested entries.
374    *
375    *  @param  String  'action'  The name of the action which was the used as trigger.
376    *  @param  Array   'target'  A list of object dns, which should be affected by this method.
377    *  @param  Array   'all'     A combination of both 'action' and 'target'.
378    */
379   function removeEntryConfirmed($action="",$target=array(),$all=array(),
380       $altTabClass="",$altTabType="",$altAclCategory="")
381   {
382     @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,$target,"Entry removel confirmed!");
384     // Check permissons for each target
385     $tInfo = $this->getObjectDefinitions();
386     $headpage = $this->getHeadpage();
387     $disallowed = array();
388     foreach($this->dns as $key => $dn){
389       $type = $headpage->getType($dn);
390       if(!isset($tInfo[$type])){
391         trigger_error("Unknown object type received '".$type."' please update systemManagement::getObjectDefinitions()!");
392       }else{
394         $info = $tInfo[$type];
395         $acl = $this->ui->get_permissions($dn, $info['aclCategory']."/".$info['aclClass']);
396         if(preg_match("/d/",$acl)){
398           // Delete the object
399           $this->dn = $dn;
400           $this->tabObject= new $info['tabClass']($this->config,$this->config->data['TABS'][$info['tabDesc']], 
401               $this->dn, $info['aclCategory'], true, true);
402           $this->tabObject->set_acl_base($this->dn);
403           $this->tabObject->parent = &$this;
404           $this->tabObject->delete ();
406           // Remove the lock for the current object.
407           del_lock($this->dn);
409         }else{
410           $disallowed[] = $dn;
411           new log("security","groups/".get_class($this),$dn,array(),"Tried to trick deletion.");
412         }
413       }
414     }
415     if(count($disallowed)){
416       msg_dialog::display(_("Permission"),msgPool::permDelete($disallowed),INFO_DIALOG);
417     }
419     // Cleanup
420     $this->remove_lock();
421     $this->closeDialogs();
422   }
425   /*! \brief  Edit the selected system type.
426    *
427    *  @param  String  'action'  The name of the action which was the used as trigger.
428    *  @param  Array   'target'  A list of object dns, which should be affected by this method.
429    *  @param  Array   'all'     A combination of both 'action' and 'target'.
430    */
431   function editEntry($action="",$target=array(),$all=array(), $altTabClass ="", $altTabType = "", $altAclCategory="")
432   {
433     if(count($target) == 1){
434       $tInfo = $this->getObjectDefinitions();
435       $headpage = $this->getHeadpage();
436       $dn = $target[0];
437       $type =$headpage->getType($dn);
438       $tData = $tInfo[$type];
440       if($type == "FAKE_OC_ArpNewDevice"){
441         if(!class_available("ArpNewDeviceTabs")){
442           msg_dialog::display(_("Error"), msgPool::class_not_found("ArpNewDevice"), ERROR_DIALOG);
443         }else{
444           $this->system_activation_object= array($dn);
445           return(management::editEntry($action,$target,$all,"ArpNewDeviceTabs","ARPNEWDEVICETABS","incoming"));
446         }
447       }elseif($type == "FAKE_OC_NewDevice"){
448         if(!class_available("SelectDeviceType")){
449           msg_dialog::display(_("Error"), msgPool::class_not_found("SelectDeviceType"), ERROR_DIALOG);
450         }else{
451           $this->system_activation_object= array($dn);
452           $this->dialogObject = new SelectDeviceType($this->config,$dn);
453           $this->skipFooter = TRUE;
454           $this->displayApplyBtn = FALSE;
455           // see condition  -$s_action == "::systemTypeChosen"-  for further handling
456         }
457       }else{
458          return(management::editEntry($action,$target,$all,$tData['tabClass'],$tData['tabDesc'],$tData['aclCategory']));
459       }
460     }
461   }
464   function activateMultiple($action,$target)
465   {
466     $headpage = $this->getHeadpage();
467     foreach($target as $dn) {
468       if($headpage->getType($dn) == "FAKE_OC_NewDevice"){
469         $this->activationQueue[$dn] = array();
470       }
471     }
472     if(count($this->activationQueue)){
473       $this->dialogObject = new SelectDeviceType($this->config, array_keys($this->activationQueue));
474       $this->skipFooter = TRUE;
475     }
476   }
481   function systemTypeChosen()
482   {
483     // Detect the systems target type 
484     $tInfo = $this->getObjectDefinitions();
485     $selected_group = "none";
486     if(isset($_POST['ObjectGroup'])){
487       $selected_group = $_POST['ObjectGroup'];
488     }
489     $selected_system = $_POST['SystemType'];
490     $tmp = array();
491     foreach($this->activationQueue as $dn => $data){
492       $tmp[$dn]['OG'] = $selected_group;
493       $tmp[$dn]['SS'] = $selected_system;
494     }
495     $this->closeDialogs();
496     $this->activationQueue = $tmp;
497     return($this->handleActivationQueue());
498   }
501   function handleActivationQueue()
502   {
503     if(!count($this->activationQueue)) return("");
505     $ldap     = $this->config->get_ldap_link();
506     $pInfo    = $this->getObjectDefinitions(); 
507     $ui       = get_userinfo();
508     $headpage = $this->getHeadpage();
509     $ldap->cd($this->config->current['BASE']);
511     // Walk through systems to activate
512     while(count($this->activationQueue)){
513  
514       // Get next entry 
515       reset($this->activationQueue);
516       $dn = key($this->activationQueue);
517       $data= $this->activationQueue[$dn];
519       if(!isset($data['SS'])) continue;
521       $sysType = $data['SS'];
522       $type = $pInfo[$sysType];
524       // Get target type definition 
525       $plugClass    = $type["plugClass"];
526       $tabClass     = $type["tabClass"];
527       $aclCategory  = $type["aclCategory"];
528       $tabDesc      = $type["tabDesc"];
530       if(!class_available($tabClass)){
531         msg_dialog::display(_("Error"), msgPool::class_not_found($tabclass), ERROR_DIALOG);
532       }else{
534         // Load permissions for selected 'dn' and check if we're allowed to create this 'dn' 
535         $this->dn = $dn;
536         $acls   = $ui->get_permissions($this->dn,$aclCategory."/".$plugClass);
538         // Check permissions
539         if(!preg_match("/c/",$acls)){
540           unset($this->activationQueue[$dn]);
541           msg_dialog::display(_("Error"), msgPool::permCreate(), ERROR_DIALOG);
542           continue;
543         }else{
545           // Open object an preset some values like the objects base 
546           del_lock($dn);
547           management::editEntry('editEntry',array($dn),array(),$tabClass,$tabDesc, $aclCategory);
548           $this->displayApplyBtn = FALSE;
549           $this->tabObject->set_acl_base($headpage->getBase());
550           if($data['OG'] != "none"){
551             $this->tabObject->base = preg_replace("/^[^,]+,".preg_quote(get_ou('ogroupRDN'), '/')."/i", "", $data['OG']);
552             $this->tabObject->by_object[$plugClass]->base = $this->tabObject->base;
553           } else {
554             $this->tabObject->by_object[$plugClass]->base = $headpage->getBase();
555             $this->tabObject->base = $headpage->getBase();
556           }
558           // Assign some default values for opsi hosts
559           if($this->tabObject instanceOf opsi_tabs){
560             $ldap = $this->config->get_ldap_link();
561             $ldap->cat($dn);
562             $source_attrs = $ldap->fetch();
563             foreach(array("macAddress" => "mac" ,"cn" => "hostId","description" => "description") as $src => $attr){
564               if(isset($source_attrs[$src][0])){
565                 $this->tabObject->by_object['opsiGeneric']->$attr = $source_attrs[$src][0];
566               }
567             }
568           }
570           // Queue entry to be activated, when it is saved.
571           if($data['OG'] != "none"){
573             // Set gotoMode to active if there was an ogroup selected.
574             $found = false;
575             foreach(array("workgeneric"=>"active","servgeneric"=>"active","termgeneric"=>"active") as $tab => $value){
576               if(isset($this->tabObject->by_object[$tab]->gotoMode)) {
577                 $found = true;
578                 $this->tabObject->by_object[$tab]->gotoMode = $value;
579               }
580             }
581             if(!$found){
582               msg_dialog::display(_("Internal error"), _("Cannot set mode to 'active'!"), ERROR_DIALOG);
583             }
585             // Update object group membership
586             $og = new ogroup($this->config,$data['OG']);
587             if($og){
588               $og->AddDelMembership($this->tabObject->dn);
589               $og->save();
590             }
592             // Set default system specific attributes
593             foreach (array("workgeneric", "termgeneric") as $cls){
594               if (isset($this->tabObject->by_object[$cls])){
595                 $this->tabObject->by_object[$cls]->set_everything_to_inherited();
596               }
597             }
599             // Enable activation
600             foreach (array("servgeneric", "workgeneric", "termgeneric") as $cls){
601               if (isset($this->tabObject->by_object[$cls])){
602                 $this->tabObject->by_object[$cls]->auto_activate= TRUE;
603               }
604             }
606             // Enable sending of LDAP events
607             if (isset($this->tabObject->by_object["workstartup"])){
608               $this->tabObject->by_object["workstartup"]->gotoLdap_inherit= TRUE;
609             }
610           }
612           // Try to inherit everythin from the selected object group and then save
613           //  the entry, normally this should work without any problems. 
614           // But if there is any, then display the dialogs.
615           if($data['OG'] != "none"){
616             $str = $this->saveChanges();
618             // There was a problem, skip activation here and allow to fix the problems..
619             if(is_object($this->tabObject)){
620               return;
621             }
622           }else{
623             return;
624           }
625         }
626       }
627     }
628   }
631   protected function saveChanges()
632   {
633     $str = management::saveChanges();
634     if($this->tabObject) return("");
636     if(isset($this->activationQueue[$this->last_dn])){
637       $this->activate_new_device($this->last_dn);
638       unset($this->activationQueue[$this->last_dn]);
639     }
641     // Avoid using values from an older input dialog
642     $_POST = array();
643     $this->handleActivationQueue();
644   }
647   /*! \brief  Sets FAIstate to "install" for "New Devices".
648     This function is some kind of "Post handler" for activated systems,
649     it is called directly after the object (workstabs,servtabs) gets saved.
650     @param  String  $dn   The dn of the newly activated object.
651     @return Boolean TRUE if activated else FALSE
652    */
653   function activate_new_device($dn)
654   {
655     $ldap = $this->config->get_ldap_link();
656     $ldap->cd($this->config->current['BASE']);
657     $ldap->cat($dn);
658     if($ldap->count()){
659       $attrs = $ldap->fetch();
660       if(count(array_intersect(array('goServer','gotoTerminal'), $attrs['objectClass']))){
661         $ocs = $attrs['objectClass'];
662         unset($ocs['count']);
663         $new_attrs = array();
664         if(!in_array("FAIobject",$ocs)){
665           $ocs[] = "FAIobject";
666           $new_attrs['objectClass'] = $ocs;
667         }
668         $new_attrs['FAIstate'] = "install";
669         $ldap->cd($dn);
670         $ldap->modify($new_attrs);
671         if (!$ldap->success()){
672           msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn,
673                 LDAP_MOD, "activate_new_device($dn)"));
674         }else{
675           return(TRUE);
676         }
677       }
678     }
679     return(FALSE);
680   }
684  /*! \brief  Detects actions/events send by the ui
685    *           and the corresponding targets.
686    */
687   function detectPostActions()
688   {
689     $action= management::detectPostActions();
690     if(isset($_POST['abort_event_dialog']))  $action['action'] = "cancel";
691     if(isset($_POST['save_event_dialog']))  $action['action'] = "saveEvent";
692     if(isset($_POST['cd_create']))  $action['action'] = "initiateISOcreation";
693     if(isset($_GET['PerformIsoCreation']))  $action['action'] = "performIsoCreation";
694     if(isset($_POST['SystemTypeAborted']))  $action['action'] = "cancel";
696     if(!is_object($this->tabObject) && !is_object($this->dialogObject)){
697       if(count($this->activationQueue)) $action['action'] = "handleActivationQueue";
698     }
700     if(isset($_POST['systemTypeChosen']))  $action['action'] = "systemTypeChosen";
702     return($action);
703   }
706   /*! \brief   Overridden render method of class management.
707    *            this allows us to add a release selection box.
708    */
709   function renderList()
710   {
711     $headpage = $this->getHeadpage();
712     $headpage->update();
714     $tD = $this->getObjectDefinitions();
715     $smarty = get_smarty();
716     foreach($tD as $name => $obj){
717       $smarty->assign("USE_".$name, (empty($obj['TABNAME']) || class_available($obj['TABNAME'])));
718     }
720     $display = $headpage->render();
721     return($this->getHeader().$display);
722   }
725   public function getObjectDefinitions()
726   {
727     $tabs = array(
728         "FAKE_OC_OpsiHost" => array(
729           "ou"          => "",
730           "plugClass"   => "opsiGeneric",
731           "tabClass"    => "opsi_tabs",
732           "tabDesc"     => "OPSITABS",
733           "aclClass"    => "opsiGeneric",
734           "sendEvents"  => TRUE,
735           "aclCategory" => "opsi"),
737         "goServer" => array(
738           "ou"          => get_ou('serverRDN'),
739           "plugClass"   => "servgeneric",
740           "tabClass"    => "servtabs",
741           "tabDesc"     => "SERVTABS",
742           "aclClass"    => "servgeneric",
743           "sendEvents"  => TRUE,
744           "aclCategory" => "server"),
746         "gotoWorkstation" => array(
747           "ou"          => get_ou('workstationRDN'),
748           "plugClass"   => "workgeneric",
749           "tabClass"    => "worktabs",
750           "tabDesc"     => "WORKTABS",
751           "aclClass"    => "workstation",
752           "sendEvents"  => TRUE,
753           "aclCategory" => "workgeneric"),
755         "gotoTerminal" => array(
756             "ou"          => get_ou('terminalRDN'),
757             "plugClass"   => "termgeneric",
758             "tabClass"    => "termtabs",
759             "sendEvents"  => TRUE,
760             "tabDesc"     => "TERMTABS",
761             "aclClass"    => "terminal",
762             "aclCategory" => "termgeneric"),
764         "gotoPrinter" => array(
765             "ou"          => get_ou('printerRDN'),
766             "plugClass"   => "printgeneric",
767             "tabClass"    => "printtabs",
768             "tabDesc"     => "PRINTTABS",
769             "aclClass"    => "printer",
770             "sendEvents"  => FALSE,
771             "aclCategory" => "printgeneric"),
773         "FAKE_OC_NewDevice" => array(
774             "ou"          => get_ou('systemIncomingRDN'),
775             "plugClass"   => "termgeneric",
776             "tabClass"    => "termtabs",
777             "sendEvents"  => TRUE,
778             "tabDesc"     => "TERMTABS",
779             "aclClass"    => "terminal",
780             "aclCategory" => "termgeneric"),
782         "goFonHardware" => array(
783             "ou"          => get_ou('phoneRDN'),
784             "plugClass"   => "phoneGeneric",
785             "tabClass"    => "phonetabs",
786             "tabDesc"     => "PHONETABS",
787             "sendEvents"  => FALSE,
788             "aclClass"    => "phone",
789             "aclCategory" => "phoneGeneric"),
791         "FAKE_OC_winstation" => array(
792             "ou"          => get_winstations_ou(),
793             "plugClass"   => "wingeneric",
794             "sendEvents"  => TRUE,
795             "tabClass"    => "wintabs",
796             "tabDesc"     => "WINTABS",
797             "aclClass"    => "wingeneric",
798             "aclCategory" => "winworkstation"),
800         "ieee802Device" => array(
801             "ou"          => get_ou('componentRDN'),
802             "plugClass"   => "componentGeneric",
803             "sendEvents"  => FALSE,
804             "tabClass"    => "componenttabs",
805             "tabDesc"     => "COMPONENTTABS",
806             "aclClass"    => "componentGeneric",
807             "aclCategory" => "component"),
808         );
810     // Now map some special types
811     $tabs['FAKE_OC_NewWorkstation'] = &$tabs['gotoWorkstation'];
812     $tabs['FAKE_OC_NewTerminal'] = &$tabs['gotoTerminal'];
813     $tabs['FAKE_OC_NewServer'] = &$tabs['gotoWorkstation'];
814     $tabs['gotoWorkstation__IS_BUSY'] = &$tabs['gotoWorkstation'];
815     $tabs['gotoWorkstation__IS_ERROR'] = &$tabs['gotoWorkstation'];
816     $tabs['gotoWorkstation__IS_LOCKED'] = &$tabs['gotoWorkstation'];
817     $tabs['gotoTerminal__IS_BUSY'] = &$tabs['gotoTerminal'];
818     $tabs['gotoTerminal__IS_ERROR'] = &$tabs['gotoTerminal'];
819     $tabs['gotoTerminal__IS_LOCKED'] = &$tabs['gotoTerminal'];
820     $tabs['goServer__IS_BUSY'] = &$tabs['goServer'];
821     $tabs['goServer__IS_ERROR'] = &$tabs['goServer'];
822     $tabs['goServer__IS_LOCKED'] = &$tabs['goServer'];
824     $tabs['FAKE_OC_ArpNewDevice'] = &$tabs['FAKE_OC_NewDevice'];
826     return($tabs);
827   }
828
829 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
830 ?>