public function index() { // Set title $this->title = _('Search'); if ($this->FOGCore->getSetting('FOG_DATA_RETURNED') > 0 && $this->getClass('LocationManager')->count() > $this->FOGCore->getSetting('FOG_DATA_RETURNED') && $_REQUEST['sub'] != 'list') { $this->FOGCore->redirect(sprintf('%s?node=%s&sub=search', $_SERVER['PHP_SELF'], $this->node)); } // Find data $Locations = $this->getClass('LocationManager')->find(); // Row data foreach ((array) $Locations as $Location) { $StorageGroup = new StorageGroup($Location->get('storageGroupID')); $this->data[] = array('id' => $Location->get('id'), 'name' => $Location->get('name'), 'storageNode' => $Location->get('storageNodeID') ? $this->getClass('StorageNode', $Location->get('storageNodeID'))->get('name') : 'Not Set', 'storageGroup' => $StorageGroup->get('name'), 'tftp' => $Location->get('tftp') ? _('Yes') : _('No')); } // Hook $this->HookManager->event[] = 'LOCATION_DATA'; $this->HookManager->processEvent('LOCATION_DATA', array('headerData' => &$this->headerData, 'data' => &$this->data, 'templates' => &$this->templates, 'attributes' => &$this->attributes)); // Output $this->render(); }
public function add_storage_group_post() { // Hook $this->HookManager->processEvent('STORAGE_GROUP_ADD_POST'); // POST try { // Error checking if (empty($_REQUEST['name'])) { throw new Exception($this->foglang['SGNameReq']); } if ($this->getClass('StorageGroupManager')->exists($_REQUEST['name'])) { throw new Exception($this->foglang['SGExist']); } // Create new Object $StorageGroup = new StorageGroup(array('name' => $_REQUEST['name'], 'description' => $_REQUEST['description'])); // Save if ($StorageGroup->save()) { // Hook $this->HookManager->processEvent('STORAGE_GROUP_ADD_POST_SUCCESS', array('StorageGroup' => &$StorageGroup)); // Log History event $this->FOGCore->logHistory(sprintf('%s: ID: %s, Name: %s', $this->foglang['SGCreated'], $StorageGroup->get('id'), $StorageGroup->get('name'))); // Set session message $this->FOGCore->setMessage($this->foglang['SGCreated']); // Redirect to new entry $this->FOGCore->redirect(sprintf('?node=%s&sub=edit-storage-group&%s=%s', $_REQUEST['node'], $this->id, $StorageGroup->get('id'))); } else { throw new Exception($this->foglang['DBupfailed']); } } catch (Exception $e) { // Hook $this->HookManager->processEvent('STORAGE_GROUP_ADD_POST_FAIL', array('StorageGroup' => &$StorageGroup)); // Log History event $this->FOGCore->logHistory(sprintf('%s add failed: Name: %s, Error: %s', $this->foglang['SG'], $_REQUEST['name'], $e->getMessage())); // Set session message $this->FOGCore->setMessage($e->getMessage()); // Redirect to new entry $this->FOGCore->redirect($this->formAction); } }