public function processScreenSettingsAction()
 {
     $return = array();
     $screenSettingGateway = new Settings_Model_ScreenSettingGateway();
     $form = $screenSettingGateway->getForm('ModifyScreenSettings');
     if ($controller = $this->_request->getPost('controller')) {
         $module = $this->_request->getPost('module');
     } else {
         throw new FFR_Exception('No valid controller passed');
     }
     $form->buildFormByController($module, $controller);
     if ($form->isValid($this->_request->getPost())) {
         $nonInsertElements = array('module', 'controller', 'screen_setting_submit');
         foreach ($form as $element) {
             if (!in_array($element->getName(), $nonInsertElements)) {
                 $screenSetting = $screenSettingGateway->fetchScreenSetting($element->getName());
                 $screenSetting->screen_setting_value = $element->getValue();
                 $screenSetting->save();
             }
             $return['notification']['target'] = '.notifications';
             $return['notification']['content'] = $this->view->displayMessages(true);
             $return['refresh'] = true;
         }
     } else {
         $return['formErrors'] = $form->getMessages();
     }
     $this->_helper->json->sendJson($return);
 }
 public function screenSetting()
 {
     $updateService = new FFR_Service_Update();
     if ($updateService->currentSchemaVersion('settings') < 2) {
         return $this;
     }
     $request = Zend_Controller_Front::getInstance()->getRequest();
     $module = $request->getModuleName();
     $controller = $request->getControllerName();
     $this->_setModuleController($module, $controller);
     $screenSettingGateway = new Settings_Model_ScreenSettingGateway();
     $this->view->screenForm = $screenSettingGateway->getForm('ModifyScreenSettings');
     $noSettings = $this->view->screenForm->buildFormByController($this->_module, $this->_controller);
     $path = APPLICATION_PATH . '/modules/settings/views/scripts/';
     $this->view->addScriptPath($path);
     if ($noSettings !== null) {
         $this->_renderedOutput = $this->view->render('helpers/screen-settings.phtml');
     }
     return $this;
 }
 public function buildFormByController($module, $controller)
 {
     if (!$module || !$controller) {
         throw new Exception('Must specify valid module and controller');
     }
     $this->_module->setValue($module);
     $this->_controller->setValue($controller);
     $this->addElement($this->_module);
     $this->addElement($this->_controller);
     $screenSettingsGateway = new Settings_Model_ScreenSettingGateway();
     $screenSettings = $screenSettingsGateway->fetchScreenSettingsByController($module, $controller);
     if (count($screenSettings) == 0) {
         return null;
     }
     foreach ($screenSettings as $screenSetting) {
         if ($screenSetting->screen_setting_active) {
             $this->_convertSettingToElementAndAdd($screenSetting);
         }
     }
     return true;
 }