本文整理汇总了PHP中Permission::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Permission::model方法的具体用法?PHP Permission::model怎么用?PHP Permission::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Permission
的用法示例。
在下文中一共展示了Permission::model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: project
public function project()
{
$clang = Yii::app()->lang;
if (!Permission::model()->hasGlobalPermission('Reports', 'read')) {
Yii::app()->setFlashMessage($clang->gT("You do not have sufficient rights to access this page."), 'error');
$this->getController()->redirect(array("admin/index"));
}
App()->getClientScript()->registerCssFile(Yii::app()->getConfig('styleurl') . "jquery.dataTables.css");
App()->getClientScript()->registerScriptFile(Yii::app()->getConfig('adminscripts') . 'jquery.dataTables.min.js');
$sql = "SELECT Company_name,AVG(IFNULL(cpc,0)) AS avg_ven_cpc, AVG(IFNULL(proj_CPC,0)) AS avg_comp_cpc\n , SUM(IFNULL(cpc*total_completed,0)) AS tot_cost, SUM(IFNULL(proj_CPC,0)) AS tot_revenues\n , SUM(IFNULL(proj_CPC*total_completed,0)-IFNULL(cpc*total_completed,0)) AS tot_profit, SUM(IFNULL(total_completed,0)) AS tot_completed\n FROM {{view_project_master_vendors}} WHERE ifnull(total_completed,0)>0 GROUP BY company_name";
$sqlsum = ' SELECT SUM(IFNULL(tot_completed,0)) AS total_completed, SUM(IFNULL(tot_profit,0)) AS total_profit
, SUM(IFNULL(tot_cost,0)) AS total_cost,SUM(IFNULL(tot_revenues,0)) AS total_revenues
FROM ( ' . $sql . ' ) AS totals';
$dr_det1 = Yii::app()->db->createCommand($sql . ' ORDER BY tot_profit ')->query()->readAll();
$dr_sum1 = Yii::app()->db->createCommand($sqlsum)->query()->readAll();
$sql = "SELECT sales_name,AVG(IFNULL(cpc,0)) AS avg_ven_cpc, AVG(IFNULL(proj_CPC,0)) AS avg_comp_cpc\n , SUM(IFNULL(cpc*total_completed,0)) AS tot_cost, SUM(IFNULL(proj_CPC,0)) AS tot_revenues\n , SUM(IFNULL(proj_CPC*total_completed,0)-IFNULL(cpc*total_completed,0)) AS tot_profit, SUM(IFNULL(total_completed,0)) AS tot_completed\n FROM {{view_project_master_vendors}} WHERE ifnull(total_completed,0)>0 GROUP BY sales_name";
$dr_det2 = Yii::app()->db->createCommand($sql . ' ORDER BY tot_profit ')->query()->readAll();
$aData['row'] = 0;
$aData['dr_det1'] = $dr_det1;
$aData['dr_det2'] = $dr_det2;
$aData['dr_sum1'] = $dr_sum1;
$aData['imageurl'] = Yii::app()->getConfig("adminimageurl");
if (strpos($_SERVER['REQUEST_URI'], '/print')) {
$aData['display']['header'] = false;
$aData['display']['menu_bars'] = false;
$aData['display']['footer'] = false;
} else {
$aData['display']['header'] = true;
$aData['display']['menu_bars'] = true;
$aData['display']['footer'] = true;
}
$this->_renderWrappedTemplate('reports', 'view_project', $aData);
}
示例2: actionSetpermission
/**
* Displays a particular model.
* @param integer $id the ID of the model to be displayed
*/
public function actionSetpermission()
{
// echo "set permission";
$user = $_REQUEST['user'];
$permission_id = $_REQUEST['per_id'];
$bool = $_REQUEST['bool'];
echo $bool;
if ($bool == "true") {
$bool = 1;
} else {
$bool = 0;
}
// $ = $_REQUEST['per_id'];
$model = Permission::model()->count("username = '{$user}' and permission_id = '{$permission_id}' ");
if ($model == 0) {
$p = new Permission();
$p->username = $user;
$p->permission_id = $permission_id;
$p->status = 1;
if ($p->save()) {
echo "added";
} else {
print_r($p->getErrors());
}
} else {
$p = Permission::model()->find("username = '{$user}' and permission_id = '{$permission_id}' ");
$p->status = $bool;
if ($p->save()) {
echo "updated";
} else {
print_r($p->getErrors());
}
}
}
示例3: isAllowPermission
public static function isAllowPermission($uid, $module, $controller, $action)
{
if ($action == 'login' || $action == 'logout') {
return true;
}
if (!isset(Yii::app()->user->isAdmin)) {
header('location:' . Yii::app()->homeUrl . 'adminuser/default/login');
exit;
}
if ($action == 'error') {
return true;
}
$criteria = new CDbCriteria();
$criteria->select = '*';
$criteria->join = 'INNER JOIN user_permissions ON `t`.id=user_permissions.permission_id';
$criteria->condition = 'userid = :uid';
$criteria->params = array(":uid" => $uid);
$permissions = Permission::model()->findAll($criteria);
foreach ($permissions as $item) {
if ($item->module == $module && $item->controller == $controller && $item->action == $action) {
return true;
}
}
return false;
}
示例4: run
public function run()
{
App()->loadHelper('surveytranslator');
$aData['issuperadmin'] = false;
if (Permission::model()->hasGlobalPermission('superadmin', 'read')) {
$aData['issuperadmin'] = true;
}
// We get the last survey visited by user
$setting_entry = 'last_survey_' . Yii::app()->user->getId();
$lastsurvey = getGlobalSetting($setting_entry);
$survey = Survey::model()->findByPk($lastsurvey);
if ($lastsurvey != null && $survey) {
$aData['showLastSurvey'] = true;
$iSurveyID = $lastsurvey;
$surveyinfo = $survey->surveyinfo;
$aData['surveyTitle'] = $surveyinfo['surveyls_title'] . "(" . gT("ID") . ":" . $iSurveyID . ")";
$aData['surveyUrl'] = $this->getController()->createUrl("admin/survey/sa/view/surveyid/{$iSurveyID}");
} else {
$aData['showLastSurvey'] = false;
}
// We get the last question visited by user
$setting_entry = 'last_question_' . Yii::app()->user->getId();
$lastquestion = getGlobalSetting($setting_entry);
// the question group of this question
$setting_entry = 'last_question_gid_' . Yii::app()->user->getId();
$lastquestiongroup = getGlobalSetting($setting_entry);
// the sid of this question : last_question_sid_1
$setting_entry = 'last_question_sid_' . Yii::app()->user->getId();
$lastquestionsid = getGlobalSetting($setting_entry);
$survey = Survey::model()->findByPk($lastquestionsid);
if ($lastquestion && $lastquestiongroup && $survey) {
$baselang = $survey->language;
$aData['showLastQuestion'] = true;
$qid = $lastquestion;
$gid = $lastquestiongroup;
$sid = $lastquestionsid;
$qrrow = Question::model()->findByAttributes(array('qid' => $qid, 'gid' => $gid, 'sid' => $sid, 'language' => $baselang));
if ($qrrow) {
$aData['last_question_name'] = $qrrow['title'];
if ($qrrow['question']) {
$aData['last_question_name'] .= ' : ' . $qrrow['question'];
}
$aData['last_question_link'] = $this->getController()->createUrl("admin/questions/sa/view/surveyid/{$sid}/gid/{$gid}/qid/{$qid}");
} else {
$aData['showLastQuestion'] = false;
}
} else {
$aData['showLastQuestion'] = false;
}
$aData['countSurveyList'] = count(getSurveyList(true));
// We get the home page display setting
$aData['bShowSurveyList'] = getGlobalSetting('show_survey_list') == "show";
$aData['bShowSurveyListSearch'] = getGlobalSetting('show_survey_list_search') == "show";
$aData['bShowLogo'] = getGlobalSetting('show_logo') == "show";
$aData['oSurveySearch'] = new Survey('search');
$aData['bShowLastSurveyAndQuestion'] = getGlobalSetting('show_last_survey_and_question') == "show";
$aData['iBoxesByRow'] = (int) getGlobalSetting('boxes_by_row');
$aData['sBoxesOffSet'] = (string) getGlobalSetting('boxes_offset');
$this->_renderWrappedTemplate('super', 'welcome', $aData);
}
示例5: add
/**
* Usergroups::delete()
* Function responsible to delete a user group.
* @return void
*/
public function add()
{
$clang = Yii::app()->lang;
$aData = array();
$aViewUrls = array();
if (Permission::model()->hasGlobalPermission('CMS', 'create')) {
//echo $test = getBasePath();
$controllername = $this->getId();
$newPath = "application.views.";
$newPath = YiiBase::getPathOfAlias($newPath);
//$filepath = $newPath . '\admin\cms\template\default.tpl.php';
$filepath = $newPath . '/admin/cms/template/default.tpl.php';
$page_content = $_POST['template_editor'];
// $page_content = html_entity_decode($page_content, ENT_QUOTES, "UTF-8");
// $page_content = fixCKeditorText($page_content);
if (file_put_contents($filepath, $page_content, LOCK_EX)) {
Yii::app()->setFlashMessage($clang->gT("Template updated successfully"));
$this->getController()->redirect(array("admin/template/index"));
}
} else {
Yii::app()->setFlashMessage($clang->gT("You do not have sufficient rights to access page."), 'error');
$this->getController()->redirect(array("admin/index"));
}
$this->_renderWrappedTemplate('cms/cms', $aViewUrls, $aData);
}
示例6: index
function index()
{
$aData = array();
$needpermission = false;
$aData['surveyid'] = $surveyid = sanitize_int(Yii::app()->request->getQuery('sid'));
$aData['sa'] = $sa = sanitize_paranoid_string(Yii::app()->request->getQuery('sa', 'index'));
if (($aData['sa'] == 'survey_logic_file' || $aData['sa'] == 'navigation_test') && $surveyid) {
$needpermission = true;
}
if ($needpermission && !Permission::model()->hasSurveyPermission($surveyid, 'surveycontent', 'read')) {
App()->getClientScript()->registerPackage('jquery-superfish');
$message['title'] = gT('Access denied!');
$message['message'] = gT('You do not have sufficient rights to access this page.');
$message['class'] = "error";
$this->_renderWrappedTemplate('survey', array("message" => $message), $aData);
} else {
App()->getClientScript()->registerPackage('jqueryui');
App()->getClientScript()->registerScriptFile(Yii::app()->getConfig('generalscripts') . "survey_runtime.js");
App()->getClientScript()->registerScriptFile(Yii::app()->getConfig('generalscripts') . "expressions/em_javascript.js");
App()->getClientScript()->registerCssFile(Yii::app()->getConfig('adminstyleurl') . "adminstyle.css");
$this->_printOnLoad(Yii::app()->request->getQuery('sa', 'index'));
$aData['pagetitle'] = "ExpressionManager: {$aData['sa']}";
//header("Content-type: text/html; charset=UTF-8"); // needed for correct UTF-8 encoding
if (isset($_GET['sa'])) {
$this->test($aData['sa'], $aData);
} else {
$this->_renderWrappedTemplate('expressions', 'test_view', $aData);
}
}
}
示例7: checkAccess
public function checkAccess($operation, $params = array(), $allowCaching = true)
{
if ($operation == 'administrator') {
return Permission::model()->hasGlobalPermission('superadmin', 'read');
} else {
return parent::checkAccess($operation, $params, $allowCaching);
}
}
示例8: __construct
public function __construct()
{
if (Yii::app()->getConfig('DBVersion') < 172) {
// Permission::model exist only after 172 DB version
return $this->xssfilter = $this->xssfilter && Yii::app()->getConfig('filterxsshtml');
}
$this->xssfilter = $this->xssfilter && Yii::app()->getConfig('filterxsshtml') && !Permission::model()->hasGlobalPermission('superadmin', 'read');
}
示例9: __construct
function __construct($controller, $id)
{
parent::__construct($controller, $id);
if (!Permission::model()->hasGlobalPermission('superadmin', 'read')) {
die;
}
if (!in_array(Yii::app()->db->getDriverName(), array('mysql', 'mysqli')) || Yii::app()->getConfig('demoMode') == true) {
die($this->getController()->lang->gT('This feature is only available for MySQL databases.'));
}
}
示例10: mod
function mod()
{
$clang = Yii::app()->lang;
if (!Permission::model()->hasGlobalPermission('panellist', 'update')) {
Yii::app()->setFlashMessage($clang->gT("You do not have sufficient rights to access this page."), 'error');
$this->getController()->redirect(array("admin/index"));
}
$clang = Yii::app()->lang;
$action = isset($_POST['action']) ? $_POST['action'] : '';
$aData = array();
$aViewUrls = array();
if (Permission::model()->hasGlobalPermission('', 'create')) {
if ($action == "editcategory") {
// Project details
$category_id = (int) Yii::app()->request->getPost("category_id");
$category_title = flattenText($_POST['category_title'], false, true, 'UTF-8', true);
$sort_order = flattenText($_POST['sort_order'], false, true, 'UTF-8', true);
$IsActive = flattenText(Yii::app()->request->getPost("IsActive"));
$is_Active = 0;
if ($IsActive) {
$is_Active = 1;
}
if ($category_title == '') {
$aViewUrls['message'] = array('title' => $clang->gT("Failed to add Category"), 'message' => $clang->gT("Category Name is invalid."), 'class' => 'warningheader');
} else {
$oUser = category::model()->findByPk($category_id);
$oUser->title = $category_title;
$oUser->sorder = $sort_order;
$oUser->IsActive = $is_Active;
$oUser->modified_date = Date('y-m-d h:i:s');
$NewCategory = $oUser->save();
if ($NewCategory) {
Yii::app()->setFlashMessage($clang->gT("Profile Category Updated successfully"));
$this->getController()->redirect(array("admin/profilecategory/index"));
}
}
} else {
if (isset($_POST['category_id'])) {
$aData['row'] = 0;
$aData['usr_arr'] = array();
// Project detail
$category_id = (int) Yii::app()->request->getPost("category_id");
$action = Yii::app()->request->getPost("action");
$sresult = profilecategoryview($category_id);
// only use in view_editcompany
$aData['category_id'] = $category_id;
$aData['mur'] = $sresult;
$this->_renderWrappedTemplate('panellist/category', 'editcategory_view', $aData);
return;
}
}
}
Yii::app()->setFlashMessage(Yii::app()->lang->gT("You do not have sufficient rights to access this page."), 'error');
$this->getController()->redirect(array("admin/profilecategory/index"));
}
示例11: selectPermissionsByName
public function selectPermissionsByName($name = 'Guest')
{
// пошук прав за назвою ролі
$permissionList = Role::model()->findByAttributes(array('name' => $name));
$data = array(array());
if ($permissionList->permission_list[0] != ',' && $permissionList->permission_list != '') {
$data = Permission::model()->selectByRole($permissionList->permission_list);
} elseif ($permissionList->permission_list != '') {
$list = substr($permissionList->permission_list, 1);
$data = Permission::model()->selectByRole($list);
}
/*error_log(print_r($data,1));*/
return $data;
}
示例12: index
/**
* Show users table
*/
public function index()
{
App()->getClientScript()->registerCssFile(Yii::app()->getConfig('styleurl') . "jquery.dataTables.css");
App()->getClientScript()->registerScriptFile(Yii::app()->getConfig('adminscripts') . 'jquery.dataTables.min.js');
if (Permission::model()->hasGlobalPermission('superadmin', 'read')) {
$msglist = Supoort_center::model()->findAll(array('condition' => 'parent = 0'));
} else {
$msglist = Supoort_center::model()->findAll(array('condition' => 'email_to = ' . Yii::app()->session['loginID'] . ' AND parent = 0'));
}
//$msglist = getCountry();
$aData['row'] = 0;
$aData['msglist'] = $msglist;
$aData['imageurl'] = Yii::app()->getConfig("adminimageurl");
$this->_renderWrappedTemplate('message', 'view_addmessage', $aData);
}
示例13: index
public function index()
{
$clang = Yii::app()->lang;
if (!Permission::model()->hasGlobalPermission('superadmin', 'read') && !Permission::model()->hasGlobalPermission('panellist', 'read')) {
Yii::app()->setFlashMessage($clang->gT("You do not have sufficient rights to access page."), 'error');
$this->getController()->redirect(array("admin/index"));
}
App()->getClientScript()->registerCssFile(Yii::app()->getConfig('styleurl') . "jquery.dataTables.css");
App()->getClientScript()->registerScriptFile(Yii::app()->getConfig('adminscripts') . 'jquery.dataTables.min.js');
//$userlist = profilecategoryview();
$aData['row'] = 0;
//$aData['usr_arr'] = $userlist;
$aData['imageurl'] = Yii::app()->getConfig("adminimageurl");
$this->_renderWrappedTemplate('panellist', 'view_panellist', $aData);
}
示例14: newUserSession
public function newUserSession()
{
// Do nothing if this user is not Authwebserver type
$identity = $this->getEvent()->get('identity');
if ($identity->plugin != 'Authwebserver') {
return;
}
/* @var $identity LSUserIdentity */
$sUser = $this->getUserName();
$oUser = $this->api->getUserByName($sUser);
if (is_null($oUser)) {
if (function_exists("hook_get_auth_webserver_profile")) {
// If defined this function returns an array
// describing the default profile for this user
$aUserProfile = hook_get_auth_webserver_profile($sUser);
} elseif ($this->api->getConfigKey('auth_webserver_autocreate_user')) {
$aUserProfile = $this->api->getConfigKey('auth_webserver_autocreate_profile');
}
} else {
if (Permission::model()->hasGlobalPermission('auth_webserver', 'read', $oUser->uid)) {
$this->setAuthSuccess($oUser);
return;
} else {
$this->setAuthFailure(self::ERROR_AUTH_METHOD_INVALID, gT('Web server authentication method is not allowed for this user'));
return;
}
}
if ($this->api->getConfigKey('auth_webserver_autocreate_user') && isset($aUserProfile) && is_null($oUser)) {
// user doesn't exist but auto-create user is set
$oUser = new User();
$oUser->users_name = $sUser;
$oUser->password = hash('sha256', createPassword());
$oUser->full_name = $aUserProfile['full_name'];
$oUser->parent_id = 1;
$oUser->lang = $aUserProfile['lang'];
$oUser->email = $aUserProfile['email'];
if ($oUser->save()) {
$permission = new Permission();
$permission->setPermissions($oUser->uid, 0, 'global', $this->api->getConfigKey('auth_webserver_autocreate_permissions'), true);
Permission::model()->setGlobalPermission($oUser->uid, 'auth_webserver');
// read again user from newly created entry
$this->setAuthSuccess($oUser);
return;
} else {
$this->setAuthFailure(self::ERROR_USERNAME_INVALID);
}
}
}
示例15: run
public function run()
{
App()->loadHelper('surveytranslator');
App()->getClientScript()->registerPackage('panel-clickable');
App()->getClientScript()->registerPackage('panels-animation');
$aData['issuperadmin'] = false;
if (Permission::model()->hasGlobalPermission('superadmin', 'read')) {
$aData['issuperadmin'] = true;
}
// We get the last survey visited by user
$setting_entry = 'last_survey_' . Yii::app()->user->getId();
$lastsurvey = getGlobalSetting($setting_entry);
if ($lastsurvey != null) {
$aData['showLastSurvey'] = true;
$iSurveyID = $lastsurvey;
$surveyinfo = Survey::model()->findByPk($iSurveyID)->surveyinfo;
$aData['surveyTitle'] = $surveyinfo['surveyls_title'] . "(" . gT("ID") . ":" . $iSurveyID . ")";
$aData['surveyUrl'] = $this->getController()->createUrl("admin/survey/sa/view/surveyid/{$iSurveyID}");
} else {
$aData['showLastSurvey'] = false;
}
// We get the last question visited by user
$setting_entry = 'last_question_' . Yii::app()->user->getId();
$lastquestion = getGlobalSetting($setting_entry);
// the question group of this question
$setting_entry = 'last_question_gid_' . Yii::app()->user->getId();
$lastquestiongroup = getGlobalSetting($setting_entry);
// the sid of this question : last_question_sid_1
$setting_entry = 'last_question_sid_' . Yii::app()->user->getId();
$lastquestionsid = getGlobalSetting($setting_entry);
if ($lastquestion != null && $lastquestiongroup != null) {
$baselang = Survey::model()->findByPk($iSurveyID)->language;
$aData['showLastQuestion'] = true;
$qid = $lastquestion;
$gid = $lastquestiongroup;
$sid = $lastquestionsid;
$qrrow = Question::model()->findByAttributes(array('qid' => $qid, 'gid' => $gid, 'sid' => $sid, 'language' => $baselang));
$aData['last_question_name'] = $qrrow['title'];
if ($qrrow['question']) {
$aData['last_question_name'] .= ' : ' . $qrrow['question'];
}
$aData['last_question_link'] = $this->getController()->createUrl("admin/questions/sa/view/surveyid/{$iSurveyID}/gid/{$gid}/qid/{$qid}");
} else {
$aData['showLastQuestion'] = false;
}
$aData['countSurveyList'] = count(getSurveyList(true));
$this->_renderWrappedTemplate('super', 'welcome', $aData);
}