/** * * @param $role */ public function addRoleParents($role) { $rolesModel = new Z_Model_Roles(); $parents = $rolesModel->getParents($role['id']); foreach ($parents as $parent) { $this->addRoleParents($parent); if (!$this->_getRoleRegistry()->has($parent['roleId'])) { $this->addRole($parent['roleId'], $rolesModel->getParentsArray($parent['id'])); } } }
/** * Создает пользователя */ public static function create($login, $password, $params = array()) { $modelUsers = new Z_Model_Users(); $modelRoles = new Z_Model_Roles(); if ($modelUsers->fetchRow(array('login=?' => $login))) { return false; } $params['login'] = $login; $params['password'] = self::_cryptPassword($password); if (!isset($params['role_id'])) { $params['role_id'] = $modelRoles->fetchRow(array('roleId=?' => 'guest'))->id; } $userRow = $modelUsers->createRow($params); $userRow->save(); return new Z_User($userRow->login); }