Beispiel #1
0
 protected function _initView()
 {
     // Start initail view
     $this->bootstrap('layout');
     $config = $this->getOption('views');
     $resources = $this->getOption('resources');
     $view = new Zend_View();
     if (isset($resources['layout']['layoutPath'])) {
         $view->assign('layoutRootPath', $resources['layout']['layoutPath']);
     }
     $this->bootstrap('db');
     Zend_Loader::loadClass('Ht_Utils_SystemSetting');
     $sysSetting = Ht_Utils_SystemSetting::getSettings();
     $view->assign('sysSetting', $sysSetting);
     $view->assign('profile', Zend_Auth::getInstance()->getIdentity());
     Zend_Loader::loadClass("Ht_Model_SystemSetting");
     $this->setSystemLogConfiguration($sysSetting);
     // use the viewrenderer to keep the code DRY
     // instantiate and add the helper in one go
     $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer');
     $viewRenderer->setView($view);
     $viewRenderer->setViewSuffix('phtml');
     // add it to the action helper broker
     Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
     /**
      * Set inflector for Zend_Layout
      */
     $inflector = new Zend_Filter_Inflector(':script.:suffix');
     $inflector->addRules(array(':script' => array('Word_CamelCaseToDash', 'StringToLower'), 'suffix' => 'phtml'));
     // Initialise Zend_Layout's MVC helpers
     $this->getResource('layout')->setLayoutPath(realpath($resources['layout']['layoutPath']))->setView($view)->setContentKey('content')->setInflector($inflector);
     return $this->getResource('layout')->getView();
 }
Beispiel #2
0
 /**
  *
  * @param array|string|null $filter
  * @return array
  */
 public static function getSettingsByFilter($filter = null)
 {
     if (null == self::$_model) {
         self::$_model = new Ht_Model_DbTable_SystemSetting();
     }
     return self::$_model->getSettingsByFilter($filter);
 }
Beispiel #3
0
 public function logoutAction()
 {
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender();
     $auth = Zend_Auth::getInstance();
     $identity = $auth->getIdentity();
     /* clear cookie language */
     $dfLang = Ht_Utils_SystemSetting::getSetting(Ht_Model_SystemSetting::KEY_DEFAULT_LANGUAGE, self::DEFAULT_LANG);
     setcookie("_lang", $dfLang, time() + 2592000, "/");
     try {
         $sysaccess = new Default_Model_DbTable_SysAccess();
         $sysaccess->update(array("logout_time" => new Zend_Db_Expr("NOW()")), $sysaccess->getAdapter()->quoteInto("access_id=?", $identity->access_id));
         $this->_dispatcher->notify(new sfEvent($this, 'authentication.log', array('message' => array(sprintf('`%s` logout success.', trim($identity->u_name . ' ' . $identity->u_lastname))), 'priority' => Zend_Log::INFO)));
         $auth->clearIdentity();
     } catch (Exception $e) {
         $this->_dispatcher->notify(new sfEvent($this, 'authentication.log', array('message' => array(sprintf('`%s` logout error.', trim($identity->u_name . ' ' . $identity->u_lastname)), $e->getMessage()), 'priority' => Zend_Log::ERR)));
     }
     $this->_redirect($this->_baseUrl);
 }
Beispiel #4
0
 protected function _compile()
 {
     $moConvert = new Ht_Utils_MoConverter();
     $langAvalid = $this->getSysSetting(Ht_Model_SystemSetting::KEY_LANGUAGES_AVAILABLE, array());
     $language = count($langAvalid) > 0 ? explode(",", $langAvalid) : array();
     if (is_array($language)) {
         foreach ($language as $lang) {
             $local_dir = APPLICATION_PATH . '/languages/' . $lang . '/';
             if (!realpath($local_dir)) {
                 mkdir($local_dir, true);
             }
             $po_creater = new Ht_Utils_PoCreator(array(Ht_Utils_PoCreator::LANGUAGE_KEY => $lang, Ht_Utils_PoCreator::LOCAL_DIR_KEY => APPLICATION_PATH . '/languages/' . $lang . '/', Ht_Utils_PoCreator::ADAPTER_KEY => new Zend_Db_Table(array('name' => 'sys_languages'))));
             $po_creater->setProperties(array(Ht_Utils_PoCreator::PROPERTY_CREATE_DATE => date("Y-m-d H:i:s"), Ht_Utils_PoCreator::PROPERTY_REVISION_DATE => date("Y-m-d H:i:s"), Ht_Utils_PoCreator::PROPERTY_PROJECT_ID => Ht_Utils_SystemSetting::getSetting(Ht_Model_SystemSetting::KEY_SOFTWARE_VERSION)));
             $pofile = $po_creater->create();
             $moConvert->convert($pofile);
         }
     }
 }
Beispiel #5
0
 protected function _processAuthWithDb($username, $password)
 {
     $defaultHomepage = Ht_Utils_SystemSetting::getSetting(Ht_Model_SystemSetting::KEY_DEFAULT_ADMIN_PAGE, $this->_firstPage);
     $db = Zend_Db_Table::getDefaultAdapter();
     // setup Zend_Auth adapter for a database table;
     //Zend_Loader :: loadClass("Ht_Auth_Adapter_DbTable");
     $adapter = new Zend_Auth_Adapter_DbTable($db, 'ht_user', 'use_login', 'use_password_hash', 'MD5(CONCAT(?, salt))');
     //     	$adapter = new Zend_Auth_Adapter_DbTable($db);
     //     	$adapter->setTableName('ht_user');
     //     	$adapter->setIdentityColumn('use_login');
     //     	$adapter->setCredentialColumn('use_password');
     //     	$adapter->setCredentialTreatment('CONCAT(SUBSTRING(use_password, 1, 40), SHA1(CONCAT(SUBSTRING(use_password, 1, 40), ?)))');
     // Set the input credential values to authenticate against
     $adapter->setIdentity($username);
     $adapter->setCredential($password);
     // do the authentication
     $auth = Zend_Auth::getInstance();
     $auth->setStorage(new Zend_Auth_Storage_Session());
     if ($auth->hasIdentity()) {
         $auth->clearIdentity();
     }
     $result = $auth->authenticate($adapter);
     if ($result->isValid()) {
         $storage = $auth->getStorage();
         // store the identity as an object where the password column has
         // been omitted
         $resultRow = $adapter->getResultRowObject(null, array('use_password_hash', 'salt'));
         if ($resultRow->use_status == 'N') {
             $this->redirecWithErrorCode(self::ERR_CODE_INACTIVE_USER);
             return;
         }
         // Set access log.
         $this->setSystemAccessLog($resultRow);
         $storage->write($resultRow);
         $this->_dispatcher->notify(new sfEvent($this, 'authentication.log', array('message' => array(sprintf('`%s` login success.', trim($resultRow->use_name . ' ' . $resultRow->use_lastname))), 'priority' => 6)));
         $this->_redirect($defaultHomepage);
     } else {
         $this->_dispatcher->notify(new sfEvent($this, 'authentication.log', array('message' => array(sprintf('User name `%s` login fail.', trim($username)), implode(", ", (array) $result->getMessages())), 'priority' => Zend_Log::WARN)));
         $this->redirecWithErrorCode(self::ERR_CODE_USER_PASS_INVALID);
     }
     return;
 }