本文整理汇总了PHP中Permission::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Permission::add方法的具体用法?PHP Permission::add怎么用?PHP Permission::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Permission
的用法示例。
在下文中一共展示了Permission::add方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: install
public static function install(array $options = array())
{
$toret = parent::install($options);
$toret = Hook::add('output', 'pre', get_called_class(), array('global' => 1)) && $toret;
$toret = Permission::add('anonymous', 'add', get_called_class()) && $toret;
$toret = Permission::add('authenticated', 'add', get_called_class()) && $toret;
return $toret;
}
示例2: install
public static function install(array $options = array())
{
$result = parent::install($options);
if (!Backend::getDB('default')) {
return $result;
}
$result = Permission::add('anonymous', 'index', 'home') && $result;
$result = Permission::add('anonymous', 'error', 'home') && $result;
//TODO Keep this here until we have role hierarchies
$result = Permission::add('authenticated', 'index', 'home') && $result;
$result = Permission::add('authenticated', 'error', 'home') && $result;
return $result;
}
示例3: install
public static function install(array $options = array())
{
$toret = parent::install($options);
$toret = Permission::add('anonymous', 'display', get_called_class()) && $toret;
$toret = Permission::add('authenticated', 'display', get_called_class()) && $toret;
$toret = Permission::add('anonymous', 'list', get_called_class()) && $toret;
$toret = Permission::add('authenticated', 'list', get_called_class()) && $toret;
$toret = Hook::add('table_display', 'post', get_called_class(), array('global' => 1)) && $toret;
$toret = Hook::add('table_update', 'pre', get_called_class(), array('global' => 1)) && $toret;
$toret = Hook::add('table_update', 'post', get_called_class(), array('global' => 1)) && $toret;
$toret = Hook::add('table_create', 'post', get_called_class(), array('global' => 1)) && $toret;
return $toret;
}
示例4: install
public static function install(array $options = array())
{
$toret = parent::install($options);
$toret = Permission::add('anonymous', 'display', 'image') && $toret;
return $toret;
}
示例5: install
public static function install(array $options = array())
{
$toret = parent::install($options);
$toret = Permission::add('nobody', 'define', __CLASS__) && $toret;
$toret = Permission::add('authenticated', 'define', __CLASS__) && $toret;
$toret = Permission::add('bi', 'define', __CLASS__) && $toret;
$toret = Permission::add('bisp', 'define', __CLASS__) && $toret;
$toret = Permission::add('user', 'define', __CLASS__) && $toret;
$toret = Permission::add('nobody', 'index', __CLASS__) && $toret;
$toret = Permission::add('authenticated', 'index', __CLASS__) && $toret;
$toret = Permission::add('bi', 'index', __CLASS__) && $toret;
$toret = Permission::add('bisp', 'index', __CLASS__) && $toret;
$toret = Permission::add('user', 'index', __CLASS__) && $toret;
return $toret;
}
示例6: install
public static function install(array $options = array())
{
$result = parent::install($options);
if (!Backend::getDB('default')) {
return $result;
}
$result = Hook::add('init', 'pre', get_called_class(), array('global' => true)) && $result;
$result = Hook::add('table_display', 'pre', get_called_class()) && $result;
$result = Permission::add('anonymous', TableCtl::$P_READONLY, get_called_class()) && $result;
$result = Permission::add('authenticated', TableCtl::$P_READONLY, get_called_class()) && $result;
return $result;
}
示例7: install
public static function install(array $options = array())
{
$options['install_model'] = array_key_exists('install_model', $options) ? $options['install_model'] : true;
$result = parent::install($options);
if (!Backend::getDB('default')) {
return $result;
}
$result = Hook::add('init', 'post', get_called_class(), array('global' => true, 'sequence' => 0)) && $result;
$result = Hook::add('start', 'pre', get_called_class(), array('global' => true)) && $result;
$result = Hook::add('finish', 'post', get_called_class(), array('global' => true)) && $result;
$result = Permission::add('anonymous', 'super_signup', get_called_class()) && $result;
$result = Permission::add('anonymous', 'signup', get_called_class()) && $result;
$result = Permission::add('anonymous', 'confirm', get_called_class()) && $result;
$result = Permission::add('anonymous', 'login', get_called_class()) && $result;
$result = Permission::add('authenticated', 'login', get_called_class()) && $result;
$result = Permission::add('authenticated', 'logout', get_called_class()) && $result;
$result = Permission::add('authenticated', 'display', get_called_class()) && $result;
$result = Permission::add('authenticated', 'update', get_called_class()) && $result;
$result = Permission::add('authenticated', 'change_password', get_called_class()) && $result;
return $result;
}
示例8: actionAjax
public function actionAjax()
{
CHtml::$liveEvents = false;
if (Yii::app()->request->isAjaxRequest) {
Yii::app()->getClientScript()->scriptMap = array('jquery.js' => false, 'jquery.min.js' => false, 'jquery-ui.min.js' => false, 'jquery-ui.css' => false, 'jquery.ba-bbq.js' => false, 'jquery.yiigridview.js' => false);
}
$view = Yii::app()->request->getPost('view');
if ($view == 'index') {
// переше завантаження сторінки адміністрування
// завантаження прав зазамовчуванням тому підтягуємо дані із таблиці permission
$obj = new Permission();
$data = $obj->selectAll();
$ajaxContent = $this->renderPartial('permission', array('data' => $data), true);
echo CJSON::encode($this->renderPartial($view, array('ajaxContent' => $ajaxContent), true, true));
Yii::app()->end();
} elseif (!empty($view)) {
$data = array();
switch ($view) {
case 'permission':
$obj = new Permission();
$action = Yii::app()->request->getPost('action');
if (!empty($action) && $action == 'delete-permission') {
$obj->deleteById(Yii::app()->request->getPost('id'));
} elseif (!empty($action) && $action == 'add-permission') {
//error_log('request: '.print_r(Yii::app()->request->getPost('AddPermissionForm'),true));
$postData = Yii::app()->request->getPost('AddPermissionForm');
$obj->module = $postData['module'];
$obj->action = $postData['action'];
$obj->alias = $postData['alias'];
$obj->add();
}
$data = $obj->selectAll();
break;
case 'role':
$role = new Role();
$action = Yii::app()->request->getPost('action');
if (!empty($action) && $action == 'delete-role') {
//$role->deleteByPk(Yii::app()->request->getPost('id'));
$role->deleteRole(Yii::app()->request->getPost('id'));
} elseif (!empty($action) && $action == 'add-role') {
$postData = Yii::app()->request->getPost('AddRoleForm');
$role->name = $postData['module'];
$role->alias = $postData['alias'];
$role->add();
}
$data = $role->selectAll();
break;
case 'role_permission':
$role = new Role();
$id = Yii::app()->request->getPost('id');
$action = Yii::app()->request->getPost('action');
if (!empty($action) && $action == 'change-role') {
$permissionId = Yii::app()->request->getPost('permissionId');
$change = Yii::app()->request->getPost('change');
$role->changeRole($id, $permissionId, $change);
break;
} else {
$data = $role->selectPremissionByRole($id);
}
break;
case 'users':
$user = new User();
$action = Yii::app()->request->getPost('action');
if (empty($action) || $action == 'all') {
$data = $user->selectAllUsers();
} elseif ($action == 'with-roles') {
$data = $user->selectAllUsersWithRole();
}
break;
case 'users_role':
$user = new User();
$action = Yii::app()->request->getPost('action');
$userId = Yii::app()->request->getPost('userId');
$roleId = Yii::app()->request->getPost('roleId');
$change = Yii::app()->request->getPost('change');
if ($action == 'add-role-by-user') {
$user->addRoleByUsers($userId, $roleId, $change);
} else {
$data = $user->selectRoleByUser($userId);
}
break;
}
echo CJSON::encode($this->renderPartial($view, array('data' => $data), true, true));
Yii::app()->end();
} else {
echo CJSON::encode(array('text' => 'hi', 'val' => 1));
Yii::app()->end();
}
}
示例9: install
public static function install(array $options = array())
{
$result = parent::install($options);
if (!Backend::getDB('default')) {
return $result;
}
$result = Hook::add('display', 'post', __CLASS__, array('global' => true, 'mode' => 'html')) && $result;
$result = Permission::add('anonymous', 'continual', 'admin') && $result;
$result = Permission::add('anonymous', 'daily', 'admin') && $result;
$result = Permission::add('anonymous', 'weekly', 'admin') && $result;
$result = Permission::add('authenticated', 'continual', 'admin') && $result;
$result = Permission::add('authenticated', 'daily', 'admin') && $result;
$result = Permission::add('authenticated', 'weekly', 'admin') && $result;
return $result;
}
示例10: install
public static function install(array $options = array())
{
if (!Backend::getDB('default')) {
return true;
}
$class = get_called_class();
if (!$class || !class_exists($class, true)) {
return false;
}
//Purge permissions first
$query = new DeleteQuery('Permission');
$query->filter('`subject` = :subject')->filter('`system` = 0');
$query->execute(array(':subject' => class_for_url($class)));
$methods = get_class_methods($class);
$methods = array_filter($methods, create_function('$var', '$temp = explode(\'_\', $var, 2); return count($temp) == 2 && in_array(strtolower($temp[0]), array(\'action\', \'get\', \'post\', \'put\', \'delete\'));'));
$methods = array_map(create_function('$var', 'return preg_replace(\'/^(action|get|post|put|delete)_/\', \'\', $var);'), $methods);
$result = true;
foreach ($methods as $action) {
$result = Permission::add('nobody', $action, class_for_url($class)) && $result;
}
return $result;
}