$EventManager->notify('HOST_IMAGE_Fail', array(HostName => $Host->get('name'))); throw new Exception('Failed to update task.'); } $EventManager->notify('HOST_IMAGE_COMPLETE', array(HostName => $Host->get('name'))); ////============================== Email Notification Start ============================== if ($FOGCore->getSetting('FOG_EMAIL_ACTION')) { $Inventory = current($FOGCore->getClass('InventoryManager')->find(array('hostID' => $Host->get('id')))); //Get inventory Data if ($Inventory && $Inventory->isValid()) { $SnapinJob = $Host->get('snapinjob'); //Get Snapin(s) Used/Queued if ($SnapinJob && $SnapinJob->isValid()) { $SnapinTasks = $FOGCore->getClass('SnapinTaskManager')->find(array('stateID' => array(-1, 0, 1), 'jobID' => $SnapinJob->get('id'))); foreach ($SnapinTasks as $SnapinTask) { if ($SnapinTask && $SnapinTask->isValid()) { $Snapin = new Snapin($SnapinTask->get('snapinID')); if ($Snapin && $Snapin->isValid()) { $SnapinNames[] = $Snapin->get('name'); } } } } $StorageNode = new StorageNode($Task->get('NFSMemberID')); $emailbinary = $FOGCore->getSetting('FOG_EMAIL_BINARY') ? preg_replace('#\\$\\{server-name\\}#', $StorageNode && $StorageNode->isValid() ? $StorageNode->get('name') : 'fogserver', $FOGCore->getSetting('FOG_EMAIL_BINARY')) : '/usr/sbin/sendmail -t -f noreply@fogserver.com -i'; ini_set('sendmail_path', $emailbinary); $snpusd = implode(', ', (array) $SnapinNames); //to list snapins as 1, 2, 3, etc $engineer = ucwords($Task->get('createdBy')); //ucwords purely aesthetics $puser = ucwords($Inventory->get('primaryUser')); //ucwords purely aesthetics
/** snapin_log_post() Display's the dates to filter through. */ public function snapin_log_post() { // Set title $this->title = _('FOG Snapin Log'); // This gets the download links for which type of file you want. print "\n\t\t\t\t<h2>" . '<a href="export.php?type=csv&filename=SnapinLog" alt="Export CSV" title="Export CSV" target="_blank">' . $this->csvfile . '</a> <a href="export.php?type=pdf&filename=SnapinLog" alt="Export PDF" title="Export PDF" target="_blank">' . $this->pdffile . '</a></h2>'; // Header Data $this->headerData = array(_('Snapin Name'), _('State'), _('Return Code'), _('Return Desc'), _('Create Date'), _('Create Time')); // Templates $this->templates = array('${snap_name}', '${snap_state}', '${snap_return}', '${snap_detail}', '${snap_create}', '${snap_time}'); // Setup Report Maker for this class. $ReportMaker = new ReportMaker(); // Set dates and check order is proper $date1 = $_REQUEST['date1']; $date2 = $_REQUEST['date2']; if ($date1 > $date2) { $date1 = $_REQUEST['date2']; $date2 = $_REQUEST['date1']; } $date2 = date('Y-m-d', strtotime($date2 . '+1 day')); // This is just for the header in the CSV: $csvHead = array(_('Host ID'), _('Host Name'), _('Host MAC'), _('Snapin ID'), _('Snapin Name'), _('Snapin Description'), _('Snapin File'), _('Snapin Args'), _('Snapin Run With'), _('Snapin Run With Args'), _('Snapin State'), _('Snapin Return Code'), _('Snapin Return Detail'), _('Snapin Creation Date'), _('Snapin Creation Time'), _('Job Create Date'), _('Job Create Time'), _('Task Checkin Date'), _('Task Checkin Time')); foreach ((array) $csvHead as $csvHeader) { $ReportMaker->addCSVCell($csvHeader); } $ReportMaker->endCSVLine(); // Find all snapin tasks $SnapinTasks = $this->getClass('SnapinTaskManager')->find(array('checkin' => '', 'complete' => ''), 'OR', '', '', "BETWEEN '{$date1}' AND '{$date2}'"); foreach ((array) $SnapinTasks as $SnapinTask) { $SnapinCheckin1 = $this->nice_date($SnapinTask->get('checkin')); $SnapinCheckin2 = $this->nice_date($SnapinTask->get('complete')); // Get the Task based on create date thru complete date // Get the snapin $Snapin = new Snapin($SnapinTask->get('snapinID')); // Get the Job $SnapinJob = new SnapinJob($SnapinTask->get('jobID')); // Get the Host $Host = new Host($SnapinJob->get('hostID')); $hostID = $SnapinJob->get('hostID'); $hostName = $Host->isValid() ? $Host->get('name') : ''; $hostMac = $Host->isValid() ? $Host->get('mac') : ''; $snapinID = $SnapinTask->get('snapinID'); $snapinName = $Snapin->isValid() ? $Snapin->get('name') : ''; $snapinDesc = $Snapin->isValid() ? $Snapin->get('description') : ''; $snapinFile = $Snapin->isValid() ? $Snapin->get('file') : ''; $snapinArgs = $Snapin->isValid() ? $Snapin->get('args') : ''; $snapinRw = $Snapin->isValid() ? $Snapin->get('runWith') : ''; $snapinRwa = $Snapin->isValid() ? $Snapin->get('runWithArgs') : ''; $snapinState = $SnapinTask->get('stateID'); $snapinReturn = $SnapinTask->get('return'); $snapinDetail = $SnapinTask->get('detail'); $snapinCreateDate = $Snapin->isValid() ? $this->formatTime($Snapin->get('createdTime'), 'Y-m-d') : ''; $snapinCreateTime = $Snapin->isValid() ? $this->formatTime($Snapin->get('createdTime'), 'H:i:s') : ''; $jobCreateDate = $this->formatTime($SnapinJob->get('createdTime'), 'Y-m-d'); $jobCreateTime = $this->formatTime($SnapinJob->get('createdTime'), 'H:i:s'); $TaskCheckinDate = $SnapinCheckin1->format('Y-m-d'); $TaskCheckinTime = $SnapinCheckin2->format('H:i:s'); $this->data[] = array('snap_name' => $snapinName, 'snap_state' => $snapinState, 'snap_return' => $snapinReturn, 'snap_detail' => $snapinDetail, 'snap_create' => $snapinCreateDate, 'snap_time' => $snapinCreateTime); $ReportMaker->addCSVCell($hostID); $ReportMaker->addCSVCell($hostName); $ReportMaker->addCSVCell($HostMac); $ReportMaker->addCSVCell($snapinID); $ReportMaker->addCSVCell($snapinName); $ReportMaker->addCSVCell($snapinDesc); $ReportMaker->addCSVCell($snapinFile); $ReportMaker->addCSVCell($snapinArgs); $ReportMaker->addCSVCell($snapinRw); $ReportMaker->addCSVCell($snapinRwa); $ReportMaker->addCSVCell($snapinState); $ReportMaker->addCSVCell($snapinReturn); $ReportMaker->addCSVCell($snapinDetail); $ReportMaker->addCSVCell($snapinCreateDate); $ReportMaker->addCSVCell($snapinCreateTime); $ReportMaker->addCSVCell($jobCreateDate); $ReportMaker->addCSVCell($jobCreateTime); $ReportMaker->addCSVCell($TaskCheckinDate); $ReportMaker->addCSVCell($TaskCheckinTime); $ReportMaker->endCSVLine(); } // This is for the pdf. $ReportMaker->appendHTML($this->process()); $ReportMaker->outputReport(false); $_SESSION['foglastreport'] = serialize($ReportMaker); }
/** edit() Edit host form information. */ public function edit() { // Find $Host = $this->obj; // Inventory find for host. $Inventory = $Host->get('inventory'); // Image for this host $Image = $Host->getImage(); // Get the associated Groups. // Title - set title for page title in window $this->title = sprintf('%s: %s', 'Edit', $Host->get('name')); if ($_REQUEST['approveHost']) { $Host->set('pending', null); if ($Host->save()) { $this->FOGCore->setMessage(_('Host approved')); } else { $this->FOGCore->setMessage(_('Host approval failed.')); } $this->FOGCore->redirect('?node=' . $_REQUEST['node'] . '&sub=' . $_REQUEST['sub'] . '&id=' . $_REQUEST['id']); } if ($Host->get('pending')) { print '<h2><a href="' . $this->formAction . '&approveHost=1">' . _('Approve this host?') . '</a></h2>'; } unset($this->headerData); $this->attributes = array(array(), array()); $this->templates = array('${field}', '${input}'); if ($_REQUEST['confirmMac']) { try { $MAC = new MACAddress($_REQUEST['confirmMac']); if (!$MAC->isValid()) { throw new Exception(_('Invalid MAC Address')); } $Host->addPendtoAdd($MAC); if ($Host->save()) { $this->FOGCore->setMessage('MAC: ' . $MAC . ' Approved!'); } } catch (Exception $e) { $this->FOGCore->setMessage($e->getMessage()); } $this->FOGCore->redirect('?node=' . $_REQUEST['node'] . '&sub=' . $_REQUEST['sub'] . '&id=' . $_REQUEST['id']); } if ($_REQUEST['approveAll'] == 1) { $Host->addPendtoAdd($Host->get('pendingMACs')); if ($Host->save()) { $this->FOGCore->setMessage('All Pending MACs approved.'); $this->FOGCore->redirect('?node=' . $_REQUEST['node'] . '&sub=' . $_REQUEST['sub'] . '&id=' . $_REQUEST['id']); } } foreach ((array) $Host->get('additionalMACs') as $MAC) { if ($MAC && $MAC->isValid()) { $addMACs .= '<div><input class="additionalMAC" type="text" name="additionalMACs[]" value="' . $MAC . '" /><input title="' . _('Remove MAC') . '" type="checkbox" onclick="this.form.submit()" class="delvid" id="rm' . $MAC . '" name="additionalMACsRM[]" value="' . $MAC . '" /><label for="rm' . $MAC . '" class="icon fa fa-minus-circle hand"> </label><span class="icon icon-hand" title="' . _('Make Primary') . '"><input type="radio" name="primaryMAC" value="' . $MAC . '" /></span><span class="icon icon-hand" title="' . _('Ignore MAC on Client') . '"><input type="checkbox" name="igclient[]" value="' . $MAC . '" ' . $Host->clientMacCheck($MAC) . ' /></span><span class="icon icon-hand" title="' . _('Ignore MAC for imaging') . '"><input type="checkbox" name="igimage[]" value="' . $MAC . '" ' . $Host->imageMacCheck($MAC) . '/></span><br/><span class="mac-manufactor"></span></div>'; } } foreach ((array) $Host->get('pendingMACs') as $MAC) { if ($MAC && $MAC->isValid()) { $pending .= '<div><input class="pending-mac" type="text" name="pendingMACs[]" value="' . $MAC . '" /><a href="${link}&confirmMac=' . $MAC . '"><i class="icon fa fa-check-circle"></i></a><span class="mac-manufactor"></span></div>'; } } if ($pending != null && $pending != '') { $pending .= '<div>' . _('Approve All MACs?') . '<a href="${link}&approveAll=1"><i class="icon fa fa-check-circle"></i></a></div>'; } $fields = array(_('Host Name') => '<input type="text" name="host" value="${host_name}" maxlength="15" class="hostname-input" />*', _('Primary MAC') => '<input type="text" name="mac" id="mac" value="${host_mac}" />*<span id="priMaker"></span><i class="icon add-mac fa fa-plus-circle hand" title="' . _('Add MAC') . '"></i> <span class="icon icon-hand" title="' . _('Ignore MAC on Client') . '"><input type="checkbox" name="igclient[]" value="${host_mac}" ' . $Host->clientMacCheck() . ' /></span><span class="icon icon-hand" title="' . _('Ignore MAC for imaging') . '"><input type="checkbox" name="igimage[]" value="${host_mac}" ' . $Host->imageMacCheck() . '/></span><br/><span class="mac-manufactor"></span>', '<div id="additionalMACsRow">' . _('Additional MACs') . '</div>' => '<div id="additionalMACsCell">' . $addMACs . '</div>', $Host->get('pendingMACs') ? _('Pending MACs') : null => $Host->get('pendingMACs') ? $pending : null, _('Host Description') => '<textarea name="description" rows="8" cols="40">${host_desc}</textarea>', _('Host Product Key') => '<input id="productKey" type="text" name="key" value="${host_key}" />', _('Host Image') => '${host_image}', _('Host Kernel') => '<input type="text" name="kern" value="${host_kern}" />', _('Host Kernel Arguments') => '<input type="text" name="args" value="${host_args}" />', _('Host Primary Disk') => '<input type="text" name="dev" value="${host_devs}" />', ' ' => '<input type="submit" value="' . _('Update') . '" />'); $this->HookManager->processEvent('HOST_FIELDS', array('fields' => &$fields)); print '<div id="tab-container">'; print "<!-- General -->"; print '<div id="host-general">'; if ($Host->get('pub_key') || $Host->get('sec_tok')) { $this->form = '<center><div id="resetSecDataBox"></div><input type="button" id="resetSecData" /></center><br/>'; } print '<form method="post" action="' . $this->formAction . '&tab=host-general">'; print '<h2>' . _('Edit host definition') . '</h2>'; $imageSelect = $this->getClass('ImageManager')->buildSelectBox($Image->get('id')); foreach ($fields as $field => $input) { $this->data[] = array('field' => $field, 'input' => $input, 'host_id' => $Host->get('id'), 'host_name' => $Host->get('name'), 'host_mac' => $Host->get('mac'), 'link' => $this->formAction, 'host_desc' => $Host->get('description'), 'host_image' => $imageSelect, 'host_kern' => $Host->get('kernel'), 'host_args' => $Host->get('kernelArgs'), 'host_devs' => $Host->get('kernelDevice'), 'host_key' => base64_decode($Host->get('productKey'))); } // Hook $this->HookManager->processEvent('HOST_EDIT_GEN', array('headerData' => &$this->headerData, 'data' => &$this->data, 'templates' => &$this->templates, 'attributes' => &$this->attributes)); $this->render(); print '</form></div>'; unset($this->data, $this->form); print "<!-- Group Relationships -->"; print '<div id="host-grouprel" class="organic-tabs-hidden">'; print '<h2>' . _('Group Relationships') . '</h2>'; // Create the Header: $this->headerData = array('<input type="checkbox" name="toggle-checkboxgroup" class="toggle-checkboxgroup" />', _('Name'), _('Members')); // Create the template: $this->templates = array('<input type="checkbox" name="group[]" value="${group_id}" class="toggle-group" />', sprintf('<a href="?node=group&sub=edit&id=${group_id}" title="Edit">${group_name}</a>'), '${group_count}'); // Create the attributes: $this->attributes = array(array('width' => 16, 'class' => 'c'), array('width' => 90, 'class' => 'l'), array('width' => 40, 'class' => 'c')); foreach ($Host->get('groupsnotinme') as $Group) { if ($Group && $Group->isValid()) { $this->data[] = array('group_id' => $Group->get('id'), 'group_name' => $Group->get('name'), 'group_count' => $Group->getHostCount()); } } if (count($this->data) > 0) { $this->HookManager->processEvent('HOST_GROUP_JOIN', array('headerData' => &$this->headerData, 'templates' => &$this->templates, 'attributes' => &$this->attributes, 'data' => &$this->data)); print '<center><label for="hostGroupShow">' . _('Check here to see groups this host is not associated with') . ' <input type="checkbox" name="hostGroupShow" id="hostGroupShow" /></label></center>'; print '<center><div id="hostGroupDisplay">'; print '<form method="post" action="' . $this->formAction . '&tab=host-grouprel">'; $this->render(); print '<input type="submit" name="addGroups" value="' . _('Add to Group(s)') . '" />'; print '</form></div></center>'; } unset($this->data); $this->headerData = array('<input type="checkbox" name="toggle-checkbox" class="toggle-checkboxAction" checked/>', _('Group Name'), _('Total Members')); $this->attributes = array(array('class' => 'c', 'width' => 16), array(), array()); $this->templates = array('<input type="checkbox" name="groupdel[]" value="${group_id}" class="toggle-action" checked/>', '<a href="?node=group&sub=edit&id=${group_id}" title="' . _('Edit Group') . ':${group_name}">${group_name}</a>', '${group_count}'); // Find Group Relationships foreach ((array) $Host->get('groups') as $Group) { if ($Group && $Group->isValid()) { $this->data[] = array('group_id' => $Group->get('id'), 'group_name' => $Group->get('name'), 'group_count' => $Group->getHostCount()); } } // Hook $this->HookManager->processEvent('HOST_EDIT_GROUP', array('headerData' => &$this->headerData, 'data' => &$this->data, 'templates' => &$this->templates, 'attributes' => &$this->attributes)); print '<form method="post" action="' . $this->formAction . '&tab=host-grouprel">'; $this->render(); if (count($this->data) > 0) { print '<center><input type="submit" value="' . _('Delete Selected Group Associations') . '" name="remgroups"/></center>'; } unset($this->data, $this->headerData, $this->attributes); print '</form></div>'; if (!$Host->get('pending')) { $this->basictasksOptions(); } $this->adFieldsToDisplay(); print "<!-- Printers -->"; print '<div id="host-printers" class="organic-tabs-hidden">'; print '<form method="post" action="' . $this->formAction . '&tab=host-printers">'; // Create Header for non associated printers $this->headerData = array('<input type="checkbox" name="toggle-checkboxprint" class="toggle-checkboxprint" />', _('Printer Name'), _('Configuration')); // Template for these printers: $this->templates = array('<input type="checkbox" name="printer[]" value="${printer_id}" class="toggle-print" />', '<a href="?node=printer&sub=edit&id=${printer_id}">${printer_name}</a>', '${printer_type}'); $this->attributes = array(array('width' => 16, 'class' => 'c'), array('width' => 50, 'class' => 'l'), array('width' => 50, 'class' => 'r')); foreach ((array) $Host->get('printersnotinme') as $Printer) { if ($Printer && $Printer->isValid() && !in_array($Printer->get('id'), (array) $PrinterIDs)) { $this->data[] = array('printer_id' => $Printer->get('id'), 'printer_name' => addslashes($Printer->get('name')), 'printer_type' => $Printer->get('config')); } } $PrintersFound = false; if (count($this->data) > 0) { $PrintersFound = true; print '<center><label for="hostPrinterShow">' . _('Check here to see what printers can be added') . ' <input type="checkbox" name="hostPrinterShow" id="hostPrinterShow" /></label></center>'; print '<div id="printerNotInHost">'; print '<h2>' . _('Add new printer(s) to this host') . '</h2>'; $this->HookManager->processEvent('HOST_ADD_PRINTER', array('headerData' => &$this->headerData, 'data' => &$this->data, 'templates' => &$this->templates, 'attributes' => &$this->attributes)); // Output $this->render(); print "</div>"; } unset($this->data); $this->headerData = array('<input type="checkbox" name="toggle-checkbox" class="toggle-checkboxAction" checked/>', _('Default'), _('Printer Alias'), _('Printer Type')); $this->attributes = array(array('class' => 'c', 'width' => 16), array(), array(), array()); $this->templates = array('<input type="checkbox" name="printerRemove[]" value="${printer_id}" class="toggle-action" checked/>', '<input class="default" type="radio" name="default" id="printer${printer_id}" value="${printer_id}"${is_default} /><label for="printer${printer_id}" class="icon icon-hand" title="' . _('Default Printer Select') . '"> </label><input type="hidden" name="printerid[]" value="${printer_id}" />', '<a href="?node=printer&sub=edit&id=${printer_id}">${printer_name}</a>', '${printer_type}'); print "<h2>" . _('Host Printer Configuration') . '</h2>'; print "<p>" . _('Select Management Level for this Host') . '</p>'; print "<p>"; print '<input type="radio" name="level" value="0"' . ($Host->get('printerLevel') == 0 ? 'checked' : '') . ' />' . _('No Printer Management') . '<br/>'; print '<input type="radio" name="level" value="1"' . ($Host->get('printerLevel') == 1 ? 'checked' : '') . ' />' . _('Add Only') . '<br/>'; print '<input type="radio" name="level" value="2"' . ($Host->get('printerLevel') == 2 ? 'checked' : '') . ' />' . _('Add and Remove') . '<br/></p>'; foreach ((array) $Host->get('printers') as $Printer) { if ($Printer && $Printer->isValid()) { $this->data[] = array('printer_id' => $Printer->get('id'), 'is_default' => $Host->getDefault($Printer->get('id')) ? 'checked' : '', 'printer_name' => addslashes($Printer->get('name')), 'printer_type' => $Printer->get('config')); } } // Hook $this->HookManager->processEvent('HOST_EDIT_PRINTER', array('headerData' => &$this->headerData, 'data' => &$this->data, 'templates' => &$this->templates, 'attributes' => &$this->attributes)); // Output $this->render(); if ($PrintersFound || count($this->data) > 0) { print '<center><input type="submit" value="' . _('Update') . '" name="updateprinters"/>'; } if (count($this->data) > 0) { print ' <input type="submit" value="' . _('Remove selected printers') . '" name="printdel"/>'; } print "</center>"; // Reset for next tab unset($this->data, $this->headerData); print '</form></div><!-- Snapins --><div id="host-snapins" class="organic-tabs-hidden">'; print '<h2>' . _('Snapins') . '</h2>'; print '<form method="post" action="' . $this->formAction . '&tab=host-snapins">'; // Create the header: $this->headerData = array('<input type="checkbox" name="toggle-checkboxsnapin" class="toggle-checkboxsnapin" />', _('Snapin Name'), _('Created')); // Create the template: $this->templates = array('<input type="checkbox" name="snapin[]" value="${snapin_id}" class="toggle-snapin" />', sprintf('<a href="?node=%s&sub=edit&id=${snapin_id}" title="%s">${snapin_name}</a>', 'snapin', _('Edit')), '${snapin_created}'); // Create the attributes: $this->attributes = array(array('width' => 16, 'class' => 'c'), array('width' => 90, 'class' => 'l'), array('width' => 20, 'class' => 'r')); foreach ((array) $Host->get('snapinsnotinme') as $Snapin) { if ($Snapin && $Snapin->isValid()) { $this->data[] = array('snapin_id' => $Snapin->get('id'), 'snapin_name' => $Snapin->get('name'), 'snapin_created' => $Snapin->get('createdTime')); } } if (count($this->data) > 0) { print '<center><label for="hostSnapinShow">' . _('Check here to see what snapins can be added') . ' <input type="checkbox" name="hostSnapinShow" id="hostSnapinShow" /></label>'; print '<div id="snapinNotInHost">'; $this->HookManager->processEvent('HOST_SNAPIN_JOIN', array('headerData' => &$this->headerData, 'data' => &$this->data, 'templates' => &$this->templates, 'attributes' => &$this->attributes)); $this->render(); print '<input type="submit" value="' . _('Add Snapin(s)') . '" /></form></div></center>'; print '<form method="post" action="' . $this->formAction . '&tab=host-snapins">'; unset($this->data); } $this->headerData = array('<input type="checkbox" name="toggle-checkbox" class="toggle-checkboxAction" checked/>', _('Snapin Name')); $this->attributes = array(array('class' => 'c', 'width' => 16), array()); $this->templates = array('<input type="checkbox" name="snapinRemove[]" value="${snap_id}" class="toggle-action" checked/>', '<a href="?node=snapin&sub=edit&id=${snap_id}">${snap_name}</a>'); foreach ((array) $Host->get('snapins') as $Snapin) { if ($Snapin && $Snapin->isValid()) { $this->data[] = array('snap_id' => $Snapin->get('id'), 'snap_name' => $Snapin->get('name')); } } // Hook $this->HookManager->processEvent('HOST_EDIT_SNAPIN', array('headerData' => &$this->headerData, 'data' => &$this->data, 'templates' => &$this->templates, 'attributes' => &$this->attributes)); // Output $this->render(); print '<center><input type="submit" name="snaprem" value="' . _('Remove selected snapins') . '"/></center></form></div>'; // Reset for next tab unset($this->data, $this->headerData); print '<!-- Service Configuration -->'; $this->attributes = array(array('width' => 270), array('class' => 'c'), array('class' => 'r')); $this->templates = array('${mod_name}', '${input}', '${span}'); $this->data[] = array('mod_name' => 'Select/Deselect All', 'input' => '<input type="checkbox" class="checkboxes" id="checkAll" name="checkAll" value="checkAll" />', 'span' => ''); print '<div id="host-service" class="organic-tabs-hidden">'; print '<form method="post" action="' . $this->formAction . '&tab=host-service">'; print '<h2>' . _('Service Configuration') . '</h2><fieldset>'; print "<legend>" . _('General') . '</legend>'; $ModOns = $this->getClass('ModuleAssociationManager')->find(array('hostID' => $Host->get('id')), '', '', '', '', '', '', 'moduleID'); $moduleName = $this->getGlobalModuleStatus(); foreach ($this->getClass('ModuleManager')->find() as $Module) { if ($Module && $Module->isValid()) { $this->data[] = array('input' => '<input type="checkbox" ' . ($moduleName[$Module->get('shortName')] || $moduleName[$Module->get('shortName')] && $Module->get('isDefault') ? 'class="checkboxes"' : '') . ' name="modules[]" value="${mod_id}" ${checked} ' . (!$moduleName[$Module->get('shortName')] ? 'disabled' : '') . ' />', 'span' => '<span class="icon fa fa-question fa-1x hand" title="${mod_desc}"></span>', 'checked' => in_array($Module->get('id'), $ModOns) ? 'checked' : '', 'mod_name' => $Module->get('name'), 'mod_shname' => $Module->get('shortName'), 'mod_id' => $Module->get('id'), 'mod_desc' => str_replace('"', '\\"', $Module->get('description'))); } } unset($ModOns, $Module); $this->data[] = array('mod_name' => ' ', 'input' => '', 'span' => '<input type="submit" name="updatestatus" value="' . _('Update') . '" />'); // Hook $this->HookManager->processEvent('HOST_EDIT_SERVICE', array('headerData' => &$this->headerData, 'data' => &$this->data, 'templates' => &$this->templates, 'attributes' => &$this->attributes)); // Output $this->render(); // Reset for next tab unset($this->data); print '</fieldset></form>'; print '<form method="post" action="' . $this->formAction . '&tab=host-service">'; print "<fieldset>"; print "<legend>" . _('Host Screen Resolution') . '</legend>'; $this->attributes = array(array('class' => 'l', 'style' => 'padding-right: 25px'), array('class' => 'c'), array('class' => 'r')); $this->templates = array('${field}', '${input}', '${span}'); $Services = $this->getClass('ServiceManager')->find(array('name' => array('FOG_SERVICE_DISPLAYMANAGER_X', 'FOG_SERVICE_DISPLAYMANAGER_Y', 'FOG_SERVICE_DISPLAYMANAGER_R')), 'OR', 'id'); foreach ((array) $Services as $Service) { if ($Service && $Service->isValid()) { $this->data[] = array('input' => '<input type="text" name="${type}" value="${disp}" />', 'span' => '<span class="icon fa fa-question fa-1x hand" title="${desc}"></span>', 'field' => $Service->get('name') == 'FOG_SERVICE_DISPLAYMANAGER_X' ? _('Screen Width (in pixels)') : ($Service->get('name') == 'FOG_SERVICE_DISPLAY_MANAGER_Y' ? _('Screen Height (in pixels)') : ($Service->get('name') == 'FOG_SERVICE_DISPLAYMANAGER_R' ? _('Screen Refresh Rate (in Hz)') : '')), 'type' => $Service->get('name') == 'FOG_SERVICE_DISPLAYMANAGER_X' ? 'x' : ($Service->get('name') == 'FOG_SERVICE_DISPLAYMANAGER_Y' ? 'y' : ($Service->get('name') == 'FOG_SERVICE_DISPLAYMANAGER_R' ? 'r' : '')), 'disp' => $Service->get('name') == 'FOG_SERVICE_DISPLAYMANAGER_X' ? $Host->getDispVals('width') : ($Service->get('name') == 'FOG_SERVICE_DISPLAYMANAGER_Y' ? $Host->getDispVals('height') : ($Service->get('name') == 'FOG_SERVICE_DISPLAYMANAGER_R' ? $Host->getDispVals('refresh') : '')), 'desc' => $Service->get('description')); } } $this->data[] = array('field' => '', 'input' => '', 'span' => '<input type="submit" name="updatedisplay" value="' . _('Update') . '" />'); // Hook $this->HookManager->processEvent('HOST_EDIT_DISPSERV', array('headerData' => &$this->headerData, 'data' => &$this->data, 'templates' => &$this->templates, 'attributes' => &$this->attributes)); // Output $this->render(); // Reset for next tab unset($this->data); print '</fieldset></form>'; print '<form method="post" action="' . $this->formAction . '&tab=host-service">'; print '<fieldset>'; print "\n\t\t\t<legend>" . _('Auto Log Out Settings') . '</legend>'; $this->attributes = array(array('width' => 270), array('class' => 'c'), array('class' => 'r')); $this->templates = array('${field}', '${input}', '${desc}'); $Service = current($this->getClass('ServiceManager')->find(array('name' => 'FOG_SERVICE_AUTOLOGOFF_MIN'))); $this->data[] = array('field' => _('Auto Log Out Time (in minutes)'), 'input' => '<input type="text" name="tme" value="${value}" />', 'desc' => '<span class="icon fa fa-question fa-1x hand" title="${serv_desc}"></span>', 'value' => $Host->getAlo() ? $Host->getAlo() : $Service->get('value'), 'serv_desc' => $Service->get('description')); $this->data[] = array('field' => '', 'input' => '', 'desc' => '<input type="submit" name="updatealo" value="' . _('Update') . '" />'); // Hook $this->HookManager->processEvent('HOST_EDIT_ALO', array('headerData' => &$this->headerData, 'data' => &$this->data, 'templates' => &$this->templates, 'attributes' => &$this->attributes)); // Output $this->render(); // Reset for next tab unset($this->data, $fields); print "</fieldset>"; print "\n\t\t\t</form>"; print "\n\t\t\t</div>"; print "\n\t\t\t<!-- Inventory -->"; $this->attributes = array(array(), array()); $this->templates = array('${field}', '${input}'); $fields = array(_('Primary User') => '<input type="text" value="${inv_user}" name="pu" />', _('Other Tag #1') => '<input type="text" value="${inv_oth1}" name="other1" />', _('Other Tag #2') => '<input type="text" value="${inv_oth2}" name="other2" />', _('System Manufacturer') => '${inv_sysman}', _('System Product') => '${inv_sysprod}', _('System Version') => '${inv_sysver}', _('System Serial Number') => '${inv_sysser}', _('System Type') => '${inv_systype}', _('BIOS Vendor') => '${bios_ven}', _('BIOS Version') => '${bios_ver}', _('BIOS Date') => '${bios_date}', _('Motherboard Manufacturer') => '${mb_man}', _('Motherboard Product Name') => '${mb_name}', _('Motherboard Version') => '${mb_ver}', _('Motherboard Serial Number') => '${mb_ser}', _('Motherboard Asset Tag') => '${mb_asset}', _('CPU Manufacturer') => '${cpu_man}', _('CPU Version') => '${cpu_ver}', _('CPU Normal Speed') => '${cpu_nspeed}', _('CPU Max Speed') => '${cpu_mspeed}', _('Memory') => '${inv_mem}', _('Hard Disk Model') => '${hd_model}', _('Hard Disk Firmware') => '${hd_firm}', _('Hard Disk Serial Number') => '${hd_ser}', _('Chassis Manufacturer') => '${case_man}', _('Chassis Version') => '${case_ver}', _('Chassis Serial') => '${case_ser}', _('Chassis Asset') => '${case_asset}', '<input type="hidden" name="update" value="1" />' => '<input type="submit" value="' . _('Update') . '" />'); print "\n\t\t\t" . '<div id="host-hardware-inventory" class="organic-tabs-hidden">'; print "\n\t\t\t" . '<form method="post" action="' . $this->formAction . '&tab=host-hardware-inventory">'; print "\n\t\t\t<h2>" . _('Host Hardware Inventory') . '</h2>'; if ($Inventory && $Inventory->isValid()) { foreach (array('cpuman', 'cpuversion') as $x) { $Inventory->set($x, implode(' ', array_unique(explode(' ', $Inventory->get($x))))); } foreach ((array) $fields as $field => $input) { $this->data[] = array('field' => $field, 'input' => $input, 'inv_user' => $Inventory->get('primaryUser'), 'inv_oth1' => $Inventory->get('other1'), 'inv_oth2' => $Inventory->get('other2'), 'inv_sysman' => $Inventory->get('sysman'), 'inv_sysprod' => $Inventory->get('sysproduct'), 'inv_sysver' => $Inventory->get('sysversion'), 'inv_sysser' => $Inventory->get('sysserial'), 'inv_systype' => $Inventory->get('systype'), 'bios_ven' => $Inventory->get('biosvendor'), 'bios_ver' => $Inventory->get('biosversion'), 'bios_date' => $Inventory->get('biosdate'), 'mb_man' => $Inventory->get('mbman'), 'mb_name' => $Inventory->get('mbproductname'), 'mb_ver' => $Inventory->get('mbversion'), 'mb_ser' => $Inventory->get('mbserial'), 'mb_asset' => $Inventory->get('mbasset'), 'cpu_man' => $Inventory->get('cpuman'), 'cpu_ver' => $Inventory->get('cpuversion'), 'cpu_nspeed' => $Inventory->get('cpucurrent'), 'cpu_mspeed' => $Inventory->get('cpumax'), 'inv_mem' => $Inventory->getMem(), 'hd_model' => $Inventory->get('hdmodel'), 'hd_firm' => $Inventory->get('hdfirmware'), 'hd_ser' => $Inventory->get('hdserial'), 'case_man' => $Inventory->get('caseman'), 'case_ver' => $Inventory->get('caseversion'), 'case_ser' => $Inventory->get('caseserial'), 'case_asset' => $Inventory->get('caseasset')); } } else { unset($this->data); } // Hook $this->HookManager->processEvent('HOST_INVENTORY', array('headerData' => &$this->headerData, 'data' => &$this->data, 'templates' => &$this->templates, 'attributes' => &$this->attributes)); // Output $this->render(); // Reset for next tab unset($this->data, $fields); print "</form>"; print "\n\t\t\t</div>"; print "\n\t\t\t<!-- Virus -->"; $this->headerData = array(_('Virus Name'), _('File'), _('Mode'), _('Date'), _('Clear')); $this->attributes = array(array(), array(), array(), array(), array()); $this->templates = array('<a href="http://www.google.com/search?q=${virus_name}" target="_blank">${virus_name}</a>', '${virus_file}', '${virus_mode}', '${virus_date}', '<input type="checkbox" id="vir_del${virus_id}" class="delvid" name="delvid" onclick="this.form.submit()" value="${virus_id}" /><label for="${virus_id}" class="icon icon-hand" title="' . _('Delete') . ' ${virus_name}"><i class="icon fa fa-minus-circle link"></i> </label>'); print "\n\t\t\t" . '<div id="host-virus-history" class="organic-tabs-hidden">'; print "\n\t\t\t" . '<form method="post" action="' . $this->formAction . '&tab=host-virus-history">'; print "\n\t\t\t" . '<h2>' . _('Virus History') . '</h2>'; print "\n\t\t\t" . '<h2><a href="#"><input type="checkbox" class="delvid" id="all" name="delvid" value="all" onclick="this.form.submit()" /><label for="all">(' . _('clear all history') . ')</label></a></h2>'; $Viruses = $this->getClass('VirusManager')->find(array('hostMAC' => $Host->get('mac'))); foreach ((array) $Viruses as $Virus) { if ($Virus && $Virus->isValid()) { $this->data[] = array('virus_name' => $Virus->get('name'), 'virus_file' => $Virus->get('file'), 'virus_mode' => $Virus->get('mode') == 'q' ? _('Quarantine') : ($Virus->get('mode') == 's' ? _('Report') : 'N/A'), 'virus_date' => $Virus->get('date'), 'virus_id' => $Virus->get('id')); } } // Hook $this->HookManager->processEvent('HOST_VIRUS', array('headerData' => &$this->headerData, 'data' => &$this->data, 'templates' => &$this->templates, 'attributes' => &$this->attributes)); // Output $this->render(); // Reset for next tab unset($this->data, $this->headerData); print "</form>"; print "\n\t\t\t</div>"; print "\n\t\t\t<!-- Login History -->"; print "\n\t\t\t" . '<div id="host-login-history" class="organic-tabs-hidden">'; print "\n\t\t\t<h2>" . _('Host Login History') . '</h2>'; print "\n\t\t\t" . '<form id="dte" method="post" action="' . $this->formAction . '&tab=host-login-history">'; $this->headerData = array(_('Time'), _('Action'), _('Username'), _('Description')); $this->attributes = array(array(), array(), array(), array()); $this->templates = array('${user_time}', '${action}', '${user_name}', '${user_desc}'); foreach ((array) $Host->get('users') as $UserLogin) { if ($UserLogin && $UserLogin->isValid()) { $Dates[] = $UserLogin->get('date'); } } $Dates = array_unique((array) $Dates); if ($Dates) { rsort($Dates); print "\n\t\t\t<p>" . _('View History for') . '</p>'; foreach ((array) $Dates as $Date) { if ($_REQUEST['dte'] == '') { $_REQUEST['dte'] = $Date; } $optionDate[] = '<option value="' . $Date . '" ' . ($Date == $_REQUEST['dte'] ? 'selected="selected"' : '') . '>' . $Date . '</option>'; } print "\n\t\t\t" . '<select name="dte" id="loghist-date" size="1" onchange="document.getElementById(\'dte\').submit()">' . implode($optionDate) . '</select>'; print "\n\t\t\t" . '<a href="#" onclick="document.getElementByID(\'dte\').submit()"><i class="icon fa fa-play noBorder"></i></a></p>'; foreach ((array) $Host->get('users') as $UserLogin) { if ($UserLogin && $UserLogin->isValid() && $UserLogin->get('date') == $_REQUEST['dte']) { $this->data[] = array('action' => $UserLogin->get('action') == 1 ? _('Login') : ($UserLogin->get('action') == 0 ? _('Logout') : ''), 'user_name' => $UserLogin->get('username'), 'user_time' => $UserLogin->get('datetime'), 'user_desc' => $UserLogin->get('description')); } } // Hook $this->HookManager->processEvent('HOST_USER_LOGIN', array('headerData' => &$this->headerData, 'data' => &$this->data, 'templates' => &$this->templates, 'attributes' => &$this->attributes)); // Output $this->render(); } else { print "\n\t\t\t<p>" . _('No user history data found!') . '</p>'; } // Reset for next tab unset($this->data, $this->headerData); print '<div id="login-history" style="width:575px;height:200px;" /></div>'; print "\n\t\t\t</form>"; print "\n\t\t\t</div>"; print "\n\t\t\t" . '<div id="host-image-history" class="organic-tabs-hidden">'; print "\n\t\t\t<h2>" . _('Host Imaging History') . '</h2>'; // Header Data for host image history $this->headerData = array(_('Image Name'), _('Imaging Type'), '<small>' . _('Start - End') . '</small><br />' . _('Duration')); // Templates for the host image history $this->templates = array('${image_name}', '${image_type}', '<small>${start_time} - ${end_time}</small><br />${duration}'); // Attributes $this->attributes = array(array(), array(), array()); $ImagingLogs = $this->getClass('ImagingLogManager')->find(array('hostID' => $Host->get('id'))); foreach ((array) $ImagingLogs as $ImageLog) { if ($ImageLog && $ImageLog->isValid()) { $Start = $ImageLog->get('start'); $End = $ImageLog->get('finish'); $this->data[] = array('start_time' => $this->formatTime($Start), 'end_time' => $this->formatTime($End), 'duration' => $this->diff($Start, $End), 'image_name' => $ImageLog->get('image'), 'image_type' => $ImageLog->get('type')); } } // Hook $this->HookManager->processEvent('HOST_IMAGE_HIST', array('headerData' => &$this->headerData, 'data' => &$this->data, 'templates' => &$this->templates, 'attributes' => &$this->attributes)); // Output $this->render(); unset($this->data); print "\n\t\t\t" . '</div>'; print "\n\t\t\t" . '<div id="host-snapin-history">'; $this->headerData = array(_('Snapin Name'), _('Start Time'), _('Complete'), _('Duration'), _('Return Code')); $this->templates = array('${snapin_name}', '${snapin_start}', '${snapin_end}', '${snapin_duration}', '${snapin_return}'); $SnapinJobs = $this->getClass('SnapinJobManager')->find(array('hostID' => $Host->get('id'))); foreach ((array) $SnapinJobs as $SnapinJob) { $SnapinTasks[] = $this->getClass('SnapinTaskManager')->find(array('jobID' => $SnapinJob->get('id'))); } foreach ((array) $SnapinTasks as $SnapinTask1) { foreach ($SnapinTask1 as $SnapinTask) { if ($SnapinTask && $SnapinTask->isValid()) { $Snapin = new Snapin($SnapinTask->get('snapinID')); $this->data[] = array('snapin_name' => $Snapin && $Snapin->isValid() ? $Snapin->get('name') : _('Snapin No longer exists'), 'snapin_start' => $this->formatTime($SnapinTask->get('checkin')), 'snapin_end' => $this->formatTime($SnapinTask->get('complete')), 'snapin_duration' => $this->diff($SnapinTask->get('checkin'), $SnapinTask->get('complete')), 'snapin_return' => $SnapinTask->get('return')); } } } // Hook $this->HookManager->processEvent('HOST_SNAPIN_HIST', array('headerData' => &$this->headerData, 'data' => &$this->data, 'templates' => &$this->templates, 'attributes' => &$this->attributes)); // Output $this->render(); print "\n\t\t\t" . '</div>'; print "\n\t\t\t</div>"; }
} // Get the Jobs if possible $SnapinJob = $Host->get('snapinjob'); // Get the Snapin Tasks if possible $SnapinTasks = $FOGCore->getClass('SnapinTaskManager')->find(array('stateID' => array(-1, 0, 1), 'jobID' => $SnapinJob->get('id'))); // Cycle through all the host jobs that have awaiting snapin tasks. if ($SnapinJob && $SnapinJob->isValid()) { if ($_REQUEST['getSnapnames']) { foreach ((array) $SnapinTasks as $SnapinTask) { $Snapin = new Snapin($SnapinTask->get('snapinID')); $SnapinNames[] = $Snapin->get('name'); } $Snapins = implode(' ', (array) $SnapinNames); } else { if ($_REQUEST['getSnapargs']) { foreach ((array) $SnapinTasks as $SnapinTask) { $Snapin = new Snapin($SnapinTask->get('snapinID')); $SnapinArgs[] = $Snapin->get('args'); } $Snapins = implode(' ', (array) $SnapinArgs); } else { // Get the tasks of the job so long as they're active. $SnapinTasks = count($SnapinTasks); $Snapins = $SnapinTasks ? 1 : 0; } } } print $Snapins; } catch (Exception $e) { print $e->getMessage(); }
<?php require_once '../commons/base.inc.php'; try { $Host = $FOGCore->getHostItem(); // Try and get the task. $Task = $Host->get('task'); // Work on the current Snapin Task. $SnapinTask = new SnapinTask($_REQUEST['taskid']); if (!$SnapinTask->isValid()) { throw new Exception('#!ns'); } //Get the snapin to work off of. $Snapin = new Snapin($SnapinTask->get('snapinID')); // Find the Storage Group if ($Snapin && $Snapin->getStorageGroup() && $Snapin->isValid() && $Snapin->getStorageGroup()->isValid()) { $StorageGroup = $Snapin->getStorageGroup(); } // Allow plugins to enact against this. (e.g. location) $HookManager->processEvent('SNAPIN_GROUP', array('Host' => &$Host, 'StorageGroup' => &$StorageGroup)); // Assign the file for sending. if (!$StorageGroup || !$StorageGroup->isValid()) { if (file_exists(rtrim($FOGCore->getSetting('FOG_SNAPINDIR'), '/') . '/' . $Snapin->get('file'))) { $SnapinFile = rtrim($FOGCore->getSetting('FOG_SNAPINDIR'), '/') . '/' . $Snapin->get('file'); } elseif (file_exists($Snapin->get('file'))) { $SnapinFile = $Snapin->get('file'); } } else { $StorageNode = $StorageGroup->getMasterStorageNode(); // Allow plugins to enact against this. (e.g. location) $HookManager->processEvent('SNAPIN_NODE', array('Host' => &$Host, 'StorageNode' => &$StorageNode));
// Only worry about if the Task is queued, in line, or in progress (for reporting reasons). $Task = $Host->get('task'); // If the task is Valid and is not of type 12 or 13 report that it's waiting for other tasks. if ($Task && $Task->isValid() && $Task->get('typeID') != 12 && $Task->get('typeID') != 13) { throw new Exception('#!it'); } //Get the snapin job. There should be tasks if the Job is still viable. $SnapinJob = $Host->get('snapinjob'); if (!$SnapinJob || !$SnapinJob->isValid()) { throw new Exception('#!ns'); } // Work on the current Snapin Task. $SnapinTask = current($FOGCore->getClass('SnapinTaskManager')->find(array('jobID' => $SnapinJob->get('id'), 'stateID' => array(-1, 0, 1)), '', 'name')); if ($SnapinTask && $SnapinTask->isValid()) { // Get the information (the Snapin itself) $Snapin = new Snapin($SnapinTask->get('snapinID')); // Check for task status. If it's got a numeric exitcode if (strlen($_REQUEST['exitcode']) > 0 && is_numeric($_REQUEST['exitcode'])) { // Place the task for records, but outside of recognizable as Complete or Done! $SnapinTask->set('stateID', '2')->set('return', $_REQUEST['exitcode'])->set('details', $_REQUEST['exitdesc'])->set('complete', $FOGCore->nice_date()->format('Y-m-d H:i:s')); if ($SnapinTask->save()) { print "#!ok"; } // If that was the last task, delete the job. if ($FOGCore->getClass('SnapinTaskManager')->count(array('stateID' => array(-1, 0, 1), 'jobID' => $SnapinJob->get('id'))) < 1) { // If it's part of a task deployment update the task information. $SnapinJob->set('stateID', 2)->save(); if ($Task->isValid()) { $Task->set('stateID', 4)->save(); } }
public function add_post() { // Hook $this->HookManager->processEvent('SNAPIN_ADD_POST'); // POST try { // SnapinManager $SnapinManager = $this->getClass('SnapinManager'); // Error checking $snapinName = trim($_REQUEST['name']); if (!$snapinName) { throw new Exception(_('Please enter a name to give this Snapin')); } if ($SnapinManager->exists($snapinName)) { throw new Exception(_('Snapin already exists')); } if (!$_REQUEST['storagegroup']) { throw new Exception(_('Please select a storage group for this snapin to reside in')); } if ($_REQUEST['snapin'] || $_FILES['snapin']['name']) { if (!$_REQUEST['storagegroup']) { $uploadfile = rtrim($_SESSION['FOG_SNAPINDIR'], '/') . '/' . basename($_FILES['snapin']['name']); if (!is_dir($_SESSION['FOG_SNAPINDIR']) && !is_writeable($_SESSION['FOG_SNAPINDIR'])) { throw new Exception('Failed to add snapin, unable to locate snapin directory.'); } else { if (!is_writeable($_SESSION['FOG_SNAPINDIR'])) { throw new Exception('Failed to add snapin, snapin directory is not writeable.'); } else { if (file_exists($uploadfile)) { throw new Exception('Failed to add snapin, file already exists.'); } else { if (!move_uploaded_file($_FILES['snapin']['tmp_name'], $uploadfile)) { throw new Exception('Failed to add snapin, file upload failed.'); } } } } } else { // Will fail if the storage group is not assigned or found. $StorageNode = $this->getClass('StorageGroup', $_REQUEST['storagegroup'])->getMasterStorageNode(); $src = $_FILES['snapin']['tmp_name']; $dest = rtrim($StorageNode->get('snapinpath'), '/') . '/' . $_FILES['snapin']['name']; $this->FOGFTP->set('host', $this->FOGCore->resolveHostname($StorageNode->get('ip')))->set('username', $StorageNode->get('user'))->set('password', $StorageNode->get('pass')); if (!$this->FOGFTP->connect()) { throw new Exception(_('Storage Node: ' . $this->FOGCore->resolveHostname($StorageNode->get('ip')) . ' FTP Connection has failed!')); } if (!$this->FOGFTP->chdir($StorageNode->get('snapinpath'))) { if (!$this->FOGFTP->mkdir($StorageNode->get('snapinpath'))) { throw new Exception(_('Failed to add snapin, unable to locate snapin directory.')); } } // Try to delete the file. $this->FOGFTP->delete($dest); if (!$this->FOGFTP->put($dest, $src)) { throw new Exception(_('Failed to add snapin')); } $this->FOGFTP->close(); } } else { if (empty($_REQUEST['snapinfileexist'])) { throw new Exception('Failed to add snapin, no file was uploaded or selected for use'); } } // Create new Object $Snapin = new Snapin(array('name' => $snapinName, 'description' => $_REQUEST['description'], 'file' => $_REQUEST['snapinfileexist'] ? $_REQUEST['snapinfileexist'] : $_FILES['snapin']['name'], 'args' => $_REQUEST['args'], 'createdTime' => $this->formatTime('now', 'Y-m-d H:i:s'), 'createdBy' => $_SESSION['FOG_USERNAME'], 'reboot' => isset($_REQUEST['reboot']) ? 1 : 0, 'runWith' => $_REQUEST['rw'], 'runWithArgs' => $_REQUEST['rwa'])); $Snapin->addGroup($_REQUEST['storagegroup']); // Save if ($Snapin->save()) { // Hook $this->HookManager->processEvent('SNAPIN_ADD_SUCCESS', array('Snapin' => &$Snapin)); // Log History event $this->FOGCore->logHistory(sprintf('%s: ID: %s, Name: %s', _('Snapin created'), $Snapin->get('id'), $Snapin->get('name'))); // Set session message $this->FOGCore->setMessage('Snapin added, Editing now!'); // Redirect to new entry $this->FOGCore->redirect(sprintf('?node=%s&sub=edit&%s=%s', $this->request['node'], $this->id, $Snapin->get('id'))); } else { // Database save failed throw new Exception('Add snapin failed.'); } } catch (Exception $e) { // Hook $this->HookManager->processEvent('SNAPIN_ADD_FAIL', array('Snapin' => &$Snapin)); // Log History event $this->FOGCore->logHistory(sprintf('%s add failed: Name: %s, Error: %s', _('Storage'), $_REQUEST['name'], $e->getMessage())); // Set session message $this->FOGCore->setMessage($e->getMessage()); // Redirect to new entry $this->FOGCore->redirect($this->formAction); } }