/** * Execute the action */ public function execute() { parent::execute(); // action to execute $action = \SpoonFilter::getGetValue('action', array('delete'), ''); // get passed group ID $id = \SpoonFilter::getGetValue('group_id', null, 0, 'int'); // fetch group record $this->group = BackendMailmotorModel::getGroup($id); // set redirect URL $redirectURL = BackendModel::createURLForAction('CustomFields') . '&group_id=' . $this->group['id']; // no id's provided if (!$action) { $this->redirect($redirectURL . '&error=no-action-selected'); } if (!isset($_GET['fields'])) { $this->redirect($redirectURL . '&error=no-items-selected'); } if (empty($this->group)) { $this->redirect(BackendModel::createURLForAction('Groups') . '&error=non-existing'); } else { // redefine id's $this->fields = (array) $_GET['fields']; // evaluate $action, see what action was triggered switch ($action) { case 'delete': $this->deleteCustomFields(); break; } } }
/** * Get the data */ private function getData() { // get the record $this->record = (array) BackendMailmotorModel::getGroup($this->id); // no item found, throw an exceptions, because somebody is f*****g with our URL if (empty($this->record)) { $this->redirect(BackendModel::createURLForAction('Groups') . '&error=non-existing'); } }
/** * Gets data related to custom fields */ private function getData() { // get passed group ID $id = \SpoonFilter::getGetValue('group_id', null, 0, 'int'); // fetch group record $this->group = BackendMailmotorModel::getGroup($id); // group doesn't exist if (empty($this->group)) { $this->redirect(BackendModel::createURLForAction('Groups') . '&error=non-existing'); } }
/** * Get the data */ private function getData() { // get the record $this->record = (array) BackendMailmotorModel::getAddress($this->email); // no item found, throw an exceptions, because somebody is f*****g with our URL if (empty($this->record)) { $this->redirect(BackendModel::createURLForAction('Addresses') . '&error=non-existing'); } // get subscriptions (key/pair values) $this->subscriptions = BackendMailmotorModel::getGroupsByEmailAsPairs($this->email); // the allowed groups $allowedGroups = array_keys($this->subscriptions); // set the passed group ID $this->id = \SpoonFilter::getGetValue('group_id', $allowedGroups, key($this->subscriptions), 'int'); // get group record $this->group = BackendMailmotorModel::getGroup($this->id); }
/** * Gets data related to custom fields */ private function getData() { // get passed group ID $id = \SpoonFilter::getGetValue('group_id', null, 0, 'int'); // fetch group record $this->group = BackendMailmotorModel::getGroup($id); // group doesn't exist if (empty($this->group)) { $this->redirect(BackendModel::createURLForAction('Groups') . '&error=non-existing'); } // no custom fields for this group if (empty($this->group['custom_fields'])) { $this->group['custom_fields'] = array(); } // loop the record's custom fields foreach ($this->group['custom_fields'] as $key => $field) { // reformat the custom fields so they work in a datagrid $this->group['custom_fields'][$key] = array('name' => $field); } }
/** * Sets the group record */ private function setGroup() { // set the passed group ID $id = \SpoonFilter::getGetValue('group_id', null, 0, 'int'); // group was set if (!empty($id)) { // get group record $this->group = BackendMailmotorModel::getGroup($id); // assign the group record $this->tpl->assign('group', $this->group); } }