/** * Class constructor * * The request and response objects should be registered with the * controller, as should be any additional optional arguments; these will be * available via {@link getRequest()}, {@link getResponse()}, and * {@link getInvokeArgs()}, respectively. * * When overriding the constructor, please consider this usage as a best * practice and ensure that each is registered appropriately; the easiest * way to do so is to simply call parent::__construct($request, $response, * $invokeArgs). * * After the request, response, and invokeArgs are set, the * {@link $_helper helper broker} is initialized. * * Finally, {@link init()} is called as the final action of * instantiation, and may be safely overridden to perform initialization * tasks; as a general rule, override {@link init()} instead of the * constructor to customize an action controller's instantiation. * * @param Zend_Controller_Request_Abstract $request * @param Zend_Controller_Response_Abstract $response * @param array $invokeArgs Any additional invocation arguments * @return void */ public function __construct(Zend_Controller_Request_Abstract $request, Zend_Controller_Response_Abstract $response, array $invokeArgs = array()) { $this->setRequest($request)->setResponse($response)->_setInvokeArgs($invokeArgs); $this->_helper = new Zend_Controller_Action_HelperBroker($this); // $language = "en_GB"; // $translate = new Zend_Translate( // array( // 'adapter' => 'gettext', // 'content' => APPLICATION_PATH .'/languages/' .$language .'.mo', // 'locale' => $language // ) // ); // $this->_translator = $translate; // Zend_Registry::set('Zend_Translate', $translate); // $controller = $this->getRequest()->getControllerName(); $action = $this->getRequest()->getActionName(); if ($action != 'main') { if (!Admin_View_Helper_Authentication::isUserAdmin()) { $this->_redirect('/enlighten/'); } } $this->init(); }
public function mainAction() { if (Admin_View_Helper_Authentication::isUserAdmin()) { $form = new Admin_Form_ChangePasswordForm(); if ($this->_request->isPost()) { $formData = $this->_request->getPost(); if ($form->isValid($formData)) { $data = $this->_user->changePassword($formData); if ($data['status'] == 0) { $this->view->error = $data['message']; } else { $this->view->message = $data['message']; } } else { $form->populate($formData); } } $this->view->form = $form; } else { $form = new Admin_Form_LoginForm(); if ($this->_request->isPost()) { $formData = $this->_request->getPost(); if ($form->isValid($formData)) { $data = $this->_user->login($formData); if ($data['status'] == 0) { $this->view->error = "Login failed"; } else { $this->redirect("enlighten/panel/main/"); } } else { $form->populate($formData); } } $this->view->form = $form; } }
/** * Update user * * @param array $data data to be updated * @param int $userID (optional) * @return bool Update succesfull or not */ public function updateUser($data, $userID = null) { $userID = $userID == null ? Admin_View_Helper_Authentication::getLoggedUserID() : (int) $userID; $where = $this->_adapter->quoteInto('UserID = ?', $userID); return Admin_View_Helper_DB::save(new Admin_Resource_User(), $data, $where); }
/** * Insert article * * @param array $data * @return bool */ public function insertArticle($data) { $data['AuthorID'] = Admin_View_Helper_Authentication::getLoggedUserID(); $data['CreateTime'] = Site_View_Helper_Date::formatDate(); return Admin_View_Helper_DB::save(new Admin_Resource_Article(), $data); }