public function searchByAuthItem($authItemName, $pageSize = 20, $defaultOrder = null) { $criteria = new CDbCriteria(); $criteria->distinct = true; $authMan = new CrugeAuthManager(); $table_assign = $authMan->getTableName("authassignment"); $criteria->join = "left join " . $table_assign . " ASG " . "on ASG.userid = t.iduser"; $criteria->compare("ASG.itemname", $authItemName); // extra optionals, for filtering: $criteria->compare('username', $this->username, true); $criteria->compare('email', $this->email, true); return new CActiveDataProvider($this, array('criteria' => $criteria, 'pagination' => array('pageSize' => $pageSize), 'sort' => array('defaultOrder' => $defaultOrder == null ? array('username' => false) : $defaultOrder))); }
/** * autoDetect * lee todos los controllers y actions y los almacena si previamente * no estaban registrados. * * metodo invocado por cruge automaticamente * * @access public * @return array una lista con todos los authitems detectados */ public function autoDetect() { parent::autoDetect(); // para que haga lo que esta predefinido $authItems = array(); // agrega cada controller detectado foreach ($this->enumModuleControllers() as $moduleName => $controllers) { foreach ($controllers as $controllerName) { // agrega cada controller como un authItem $itemName = "controller_" . strtolower($moduleName) . "_" . strtolower($controllerName); $authItems[] = $itemName; } } // agrega cada action dentro de cada controller detectado // pero en una forma especial: /modname/contrllname/action foreach ($this->enumModuleControllers() as $moduleName => $controllers) { foreach ($controllers as $controllerName) { foreach ($this->enumModuleActions($moduleName, $controllerName) as $actionName) { $authItems[] = strtolower(sprintf("action_%s_%s_%s", $moduleName, $controllerName, $actionName)); } } } foreach ($authItems as $itemName) { if (!$this->getAuthItem($itemName)) { $this->createAuthItem($itemName, CAuthItem::TYPE_OPERATION, ""); } } $this->ensureMenuItemIntegrity(); return $authItems; }