public function authenticate() { $q = Yii::app()->dbAdmin->createCommand(); $q->from(AutoAdminAccess::sqlAdminTableName('users')); $q->where(array('AND', 'login = :userName', ), array(':userName'=>$this->username) ); $user = $q->queryRow(); if(!$user) $this->errorCode = self::ERROR_USERNAME_INVALID; elseif($user['password'] != self::hashPassword($this->password)) $this->errorCode = self::ERROR_PASSWORD_INVALID; elseif($user['disabled']) $this->errorCode = self::ERROR_USER_DISABLED; else { $this->errorCode = self::ERROR_NONE; $this->_id = $user['id']; $this->setState('level', $user['level']); $this->setState('interfaceLevel', $user['interface_level']); $this->setState('surname', $user['surname']); $this->setState('firstname', $user['firstname']); Yii::app()->dbAdmin->createCommand()->insert(AutoAdminAccess::sqlAdminTableName('authorizations'), array( 'user_id' => $user['id'], 'when_enter' => date('Y-m-d H:i:s'), 'ip'=> Yii::app()->request->getUserHostAddress(), )); $tableSchema = Yii::app()->dbAdmin->schema->getTable(AutoAdminAccess::sqlAdminTableName('authorizations')); $this->setState('authID', Yii::app()->dbAdmin->getLastInsertID(($tableSchema->sequenceName ? $tableSchema->sequenceName : null))); } return !$this->errorCode; }
/** * Gets default aliases from all user-defined controllers. * @param bool $filterWithExisting Whether to filter the result list with existing (recorded in DB). * @return array An array contains information about interfaces. Format of an element: {defaultAlias}=>array({controllerName}, {actionName}). */ public function getInterfaces($filterWithExisting=false) { $interfaces = array(); $controllersDir = Yii::import('application.modules.autoadmin.controllers.*'); if(is_dir($controllersDir)) { $cFiles = CFileHelper::findFiles($controllersDir, array('fileTypes'=>array('php'))); foreach($cFiles as $cfile) { $controllerName = substr($cfile, strrpos($cfile, DIRECTORY_SEPARATOR)+1, -4); $methods = @get_class_methods($controllerName); if($methods) { $controllerID = substr($controllerName, 0, strrpos($controllerName, 'Controller')); foreach($methods as $methodName) { if($methodName == 'actions' || !preg_match('/^action([a-z_]+)$/i', $methodName, $m)) continue; $actionID = $m[1]; $interfaces[AutoAdmin::interfaceID($controllerID, $actionID)] = array($controllerID, $actionID); } } } } if($interfaces && $filterWithExisting) { $exInterfaces = Yii::app()->dbAdmin->createCommand() ->select('id, alias')->from(AutoAdminAccess::sqlAdminTableName('interfaces')) ->queryAll(); foreach($exInterfaces as $exInterface) { if(isset($interfaces[$exInterface['alias']])) unset($interfaces[$exInterface['alias']]); } } return $interfaces; }
/** * Inits of the class. */ public function init() { Yii::app()->user->setStateKeyPrefix('AUTOADMIN'); $this->controllerMap['aafile'] = array('class'=>'ext.autoadmin.controllers.AAFileController'); $this->controllerMap['aaajax'] = array('class'=>'ext.autoadmin.controllers.AAAjaxController'); $this->controllerMap['aaauth'] = array('class'=>'ext.autoadmin.controllers.AAAuthController'); $this->controllerMap['aagenerator'] = array('class'=>'ext.autoadmin.controllers.AAGeneratorController'); self::$assetPath = Yii::app()->assetManager->publish(Yii::getPathOfAlias('ext.autoadmin.assets')); $this->cache = new AACache(); $this->_data = new AAData(); $this->_db = new AADb($this->_data); //Link AADb properties with AutoAdmin properties for more convenient configurating these properties by a user. AADb::$dbConnection =& $this->dbConnection; $this->_db->dbSchema =& $this->dbSchema; AutoAdminAccess::$dbTablePrefix = $this->dbAdminTablePrefix; if($this->extensions) { foreach($this->extensions as $key=>$value) { if(is_string($key)) { $extension = $key; $initData = &$value; } else { $extension = $value; $initData = array(); } Yii::import("ext.autoAdminE{$extension}.*"); //Yii::import("ext.autoAdminE{$extension}.AutoAdminE{$extension}"); //fix for "E"-prefix for case-sensitive file systems $extClass = "AutoAdminE{$extension}"; $extClass::init($initData); } } }