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); } }