public function generalAction() { // Make form $this->view->form = $form = new Activity_Form_Admin_Settings_General(); // Populate settings $settings = Engine_Api::_()->getApi('settings', 'core'); $values = $settings->activity; unset($values['allowed']); $form->populate($values); if (!$this->getRequest()->isPost()) { return; } if (!$form->isValid($this->getRequest()->getPost())) { return; } // Process $values = $form->getValues(); $allowed = $values['allowed']; $list = array_keys($form->getElement('allowed')->getMultiOptions()); $disallowed = array_diff($list, $allowed); unset($values['allowed']); // Save settings $settings->activity = $values; // Save action type settings if (!empty($disallowed) && is_array($disallowed)) { $actionTypesTable = Engine_Api::_()->getDbTable('actionTypes', 'activity'); $actionTypesTable->update(array('enabled' => 0), array('type IN(?)' => (array) $disallowed)); } if (!empty($allowed) && is_array($allowed)) { $actionTypesTable = Engine_Api::_()->getDbTable('actionTypes', 'activity'); $actionTypesTable->update(array('enabled' => 1), array('type IN(?)' => (array) $allowed)); } }
public function indexAction() { // Make form $this->view->form = $form = new Activity_Form_Admin_Settings_General(); // Populate settings $settings = Engine_Api::_()->getApi('settings', 'core'); $values = $settings->activity; unset($values['allowed']); $form->populate($values); if (!$this->getRequest()->isPost()) { return; } if (!$form->isValid($this->getRequest()->getPost())) { return; } // Process $values = $form->getValues(); // Save settings $settings->activity = $values; $form->addNotice('Your changes have been saved.'); }