• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Rights类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Rights的典型用法代码示例。如果您正苦于以下问题:PHP Rights类的具体用法?PHP Rights怎么用?PHP Rights使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Rights类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: __construct

 /**
  * constructor
  * order rights object to set roles ,resources, allow, deny
  * 
  * $identity must have $identity->id and $identity->role
  * 
  * $rights must have methods:
  * set_roles
  * set_allow
  * set_deny
  *
  * @param Identity $identity
  * @param Rights $rights
  */
 public function __construct($identity, $rights)
 {
     // store identity
     $this->_identity = $identity;
     // let the rights set the vars on this
     $rights->set_roles($this);
     $rights->set_allow($this);
     $rights->set_deny($this);
 }
开发者ID:yubinchen18,项目名称:A-basic-website-project-for-a-company-using-the-MVC-pattern-in-Kohana-framework,代码行数:23,代码来源:Acl.php


示例2: handler_ajax_modify

 function handler_ajax_modify($page)
 {
     S::assert_xsrf_token();
     if (!S::user()->hasRights(Group::from('qdj'), Rights::admin())) {
         return PL_FORBIDDEN;
     }
     $qdj = new QDJ(Json::i('id'));
     $page->jsonAssign('success', false);
     if (Json::has('date')) {
         $date = Json::t('date');
         if (!$date) {
             $qdj->date(false);
             $page->jsonAssign('success', true);
         } else {
             try {
                 $qdj->date(new FrankizDateTime($date));
                 $page->jsonAssign('success', true);
             } catch (Exception $e) {
             }
         }
     } else {
         if (Json::has('delete')) {
             if (Json::b('delete')) {
                 $qdj->delete();
                 $page->jsonAssign('success', true);
             }
         }
     }
     return PL_JSON;
 }
开发者ID:netixx,项目名称:frankiz,代码行数:30,代码来源:qdj.php


示例3: smarty_block_canEdit

function smarty_block_canEdit($params, $content, &$smarty, &$repeat)
{
    $group = $params['target']->group();
    if (S::user()->hasRights($group, Rights::admin()) || S::user()->isWeb()) {
        return $content;
    }
}
开发者ID:netixx,项目名称:frankiz,代码行数:7,代码来源:block.canEdit.php


示例4: execute

 function execute()
 {
     $action = Request::post('contact_action');
     if (!$action) {
         return;
     }
     $model = new contactsUsersModel();
     if ($action == 'create') {
         if (sizeof($model->where(array('login' => Request::post('login')))->fetchAll()) > 0) {
             return;
         }
         $data = array('name' => Request::post('name'), 'login' => Request::post('login'), 'date' => time(), 'block' => false);
         if (Request::post('password')) {
             $data['password'] = md5(Request::post('password'));
         }
         $model->insert($data);
     } else {
         if ($action == 'update') {
             if (sizeof($model->where(array('login' => Request::post('login')))->fetchAll()) <= 0) {
                 return;
             }
             $data = array('name' => Request::post('name'));
             if (Request::post('password')) {
                 $data['password'] = md5(Request::post('password'));
             }
             $model->where(array('login' => Request::post('login')))->update($data);
         }
     }
     if (Rights::isHave('contacts', 'add_right')) {
         $this->setRights(Request::post('login'), Request::post('rights') ? Request::post('rights') : array());
     }
 }
开发者ID:Yogurt933,项目名称:Made-Easy,代码行数:32,代码来源:contactsBackendCreate.action.php


示例5: beforeSave

 public function beforeSave()
 {
     $roles = Rights::getAssignedRoles(Yii::app()->user->Id);
     // check for single role
     foreach ($roles as $role) {
         if ($role->name == 'Editor' or $role->name == 'Administrator' or $role->name == 'Superadmin') {
             $this->post_editor = Yii::app()->user->id;
         } else {
             $this->post_author = Yii::app()->user->id;
         }
     }
     if ($this->isNewRecord) {
         // jika record baru jalankan
         $this->post_created = date('Y-m-d H:i:s');
     }
     if ($this->post_name == '') {
         $this->post_name = 'No Title';
     }
     if ($this->post_link == '') {
         $this->post_link = $this->post_name;
     }
     if ($this->post_title == '') {
         $this->post_title = $this->post_name;
     }
     $this->post_type = $this->_type;
     $this->post_image = str_replace(Helper::rootImg('content'), '', $this->post_image);
     return parent::beforeSave();
 }
开发者ID:beckblurry,项目名称:Yii1-Base-Core-V.Alpha.1,代码行数:28,代码来源:Video.php


示例6: authenticate

 /**
  * Authenticates a user.
  * The example implementation makes sure if the username and password
  * are both 'demo'.
  * In practical applications, this should be changed to authenticate
  * against some persistent user identity storage (e.g. database).
  * @return boolean whether authentication succeeds.
  */
 public function authenticate()
 {
     /**
      * @var $user XfUser
      */
     $user = XfUser::model()->find('LOWER(username)=?', array(strtolower($this->username)));
     $xfAuth = new XfAuthentication();
     if ($user === null) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } else {
         if (!$xfAuth->checkAuth($this->username, $this->password)) {
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
         } else {
             $userInfo = $xfAuth->login($this->username, $this->password);
             //var_dump($userInfo);die;
             if ($userInfo) {
                 $this->_id = $userInfo['user_id'];
                 $this->username = $userInfo['username'];
                 Rights::assign($user['role'], $this->_id);
                 $this->errorCode = self::ERROR_NONE;
             } else {
                 $this->errorCode = self::ERROR_USERNAME_INVALID;
             }
         }
     }
     //unset($xfAuth);
     return !$this->errorCode;
 }
开发者ID:ngdvan,项目名称:lntguitar,代码行数:36,代码来源:UserIdentity.php


示例7: beforeControllerAction

 public function beforeControllerAction($controller, $action)
 {
     $roles = Rights::getAssignedRoles(Yii::app()->user->Id);
     // check for single role
     foreach ($roles as $role) {
         if (sizeof($roles) == 1 and $role->name == 'parent') {
             $controller->layout = 'none';
         }
         if (sizeof($roles) == 1 and $role->name == 'student') {
             $controller->layout = 'studentmain';
         }
     }
     if (Yii::app()->user->isGuest) {
         if (Yii::app()->user->loginUrl) {
             $controller->redirect($controller->createUrl(reset(Yii::app()->user->loginUrl)));
         } else {
             $controller->redirect($controller->createUrl('/'));
         }
     } else {
         if (parent::beforeControllerAction($controller, $action)) {
             // this method is called before any module controller action is performed
             // you may place customized code here
             return true;
         } else {
             return false;
         }
     }
 }
开发者ID:SoftScape,项目名称:open-school-CE,代码行数:28,代码来源:MessageModule.php


示例8: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new User();
     $profile = new Profile();
     if (isset($_POST['User'])) {
         $model->attributes = $_POST['User'];
         $model->activkey = Yii::app()->controller->module->encrypting(microtime() . $model->password);
         $model->createtime = time();
         $model->lastvisit = time();
         $profile->attributes = $_POST['Profile'];
         $profile->user_id = 0;
         if ($model->validate() && $profile->validate()) {
             $model->password = Yii::app()->controller->module->encrypting($model->password);
             if ($model->save()) {
                 $profile->user_id = $model->id;
                 $profile->save();
                 // assign user the 'Authenticated' role for Rights module
                 $authenticatedName = Rights::module()->authenticatedName;
                 Rights::assign($authenticatedName, $model->id);
                 // end of change
             }
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model, 'profile' => $profile));
 }
开发者ID:Cynabal,项目名称:postimer,代码行数:30,代码来源:AdminController.php


示例9: __construct

 /**
  * Constructor.
  * (e.g. <code>Post::model()</code>, <code>Post::model()->published()</code>).
  * @param array $config configuration (name=>value) to be applied as the initial property values of this class.
  */
 public function __construct($config = array())
 {
     $module = Rights::module();
     $userClass = $module->userClass;
     parent::__construct($userClass, $config);
     $this->_authorizer = $module->getAuthorizer();
 }
开发者ID:eco-systems,项目名称:eclearance,代码行数:12,代码来源:RAssignmentDataProvider.php


示例10: afterLogin

 /**
  * Actions to be taken after logging in.
  * Overloads the parent method in order to mark superusers.
  * @param boolean $fromCookie whether the login is based on cookie.
  */
 public function afterLogin($fromCookie)
 {
     parent::afterLogin($fromCookie);
     // Mark the user as a superuser if necessary.
     if (Rights::getAuthorizer()->isSuperuser($this->getId()) === true) {
         $this->isSuperuser = true;
     }
 }
开发者ID:fobihz,项目名称:cndiesel,代码行数:13,代码来源:RWebUser.php


示例11: isRole

 public function isRole($roleParam)
 {
     $allroles = Rights::getAssignedRoles($this->id);
     foreach ($allroles as $ii) {
         if ($ii->name == $roleParam) {
             return true;
         }
     }
     return false;
 }
开发者ID:beckblurry,项目名称:Yii1-Base-Core-V.Alpha.1,代码行数:10,代码来源:RWebUser.php


示例12: init

 /**
  * Initializes the data provider.
  */
 public function init()
 {
     $this->_authorizer = Rights::getAuthorizer();
     // Set properties and generate the data
     $this->setRoles();
     $this->setItems();
     $this->setPermissions();
     $this->setParents();
     $this->generateData();
 }
开发者ID:sharmarakesh,项目名称:edusec-college-management-system,代码行数:13,代码来源:RPermissionDataProvider.php


示例13: actionEdit

 /**
  * Edit a user.
  */
 public function actionEdit($id = 0)
 {
     if (isset($_POST['User'])) {
         $data = $_POST['User'];
         if ($id > 0) {
             $model = User::model()->findByPk($id);
         } else {
             $model = new User();
             $model->email = $data['email'];
         }
         $model->name = $data['name'];
         $model->publisherid = $data['publisherid'];
         $newPassword1 = $_POST['newpassword1'];
         $newPassword2 = $_POST['newpassword2'];
         // if new password is entered
         if ($newPassword1 != '' || $newPassword2 != '') {
             if ($newPassword1 != $newPassword2) {
                 Yii::app()->user->setFlash('errormsg', 'New passwords are not the same');
                 $this->redirect('/user/edit/id/' . $id);
                 exit;
             } else {
                 $model->password = $newPassword1;
             }
         }
         // if new email is entered
         if ($model->email != $data['email']) {
             $emailmodel = User::model()->findAllByAttributes(array(), 'email = :email AND id <> :userId', array(':userId' => $id, ':email' => $data['email']));
             if ($emailmodel != null) {
                 Yii::app()->user->setFlash('errormsg', 'New email already exists');
                 $this->redirect('/user/edit/id/' . $id);
                 exit;
             } else {
                 $model->email = $data['email'];
             }
         }
         if ($model->validate() && $model->save()) {
             // if a new user, assign the 'Publisher' role for Rights module
             if ($id == 0) {
                 Rights::assign('Publisher', $model->id);
             }
             Yii::app()->user->setFlash('successmsg', 'The changes have been saved.');
             $this->redirect('/user/index');
         } else {
             Yii::app()->user->setFlash('errormsg', 'Error saving the changes');
             $this->render('edit', array('model' => $model));
         }
     } else {
         if ($id > 0) {
             $model = User::model()->findByPk($id);
         } else {
             $model = new User();
         }
         $this->render('edit', array('model' => $model));
     }
 }
开发者ID:sundgaarden,项目名称:dashboard,代码行数:58,代码来源:UserController.php


示例14: actionRegistration

 /**
  * Registration user
  */
 public function actionRegistration()
 {
     $model = new RegistrationForm();
     $profile = new Profile();
     $profile->regMode = true;
     if (Yii::app()->user->id) {
         $this->redirect(Yii::app()->controller->module->profileUrl);
     } else {
         if (isset($_POST['RegistrationForm'])) {
             $model->attributes = $_POST['RegistrationForm'];
             $profile->attributes = $_POST['Profile'];
             if ($model->validate() && $profile->validate()) {
                 $soucePassword = $model->password;
                 $model->activkey = UserModule::encrypting(microtime() . $model->password);
                 $model->password = UserModule::encrypting($model->password);
                 $model->verifyPassword = UserModule::encrypting($model->verifyPassword);
                 $model->createtime = time();
                 $model->lastvisit = (Yii::app()->controller->module->loginNotActiv || Yii::app()->controller->module->activeAfterRegister && Yii::app()->controller->module->sendActivationMail == false) && Yii::app()->controller->module->autoLogin ? time() : 0;
                 $model->superuser = 0;
                 $model->status = Yii::app()->controller->module->activeAfterRegister ? User::STATUS_ACTIVE : User::STATUS_NOACTIVE;
                 if ($model->save()) {
                     $profile->user_id = $model->id;
                     $profile->save();
                     // assign user the 'Authenticated' role for Rights module
                     $authenticatedName = Rights::module()->authenticatedName;
                     Rights::assign($authenticatedName, $model->id);
                     // end of change
                     if (Yii::app()->controller->module->sendActivationMail) {
                         $activation_url = 'http://' . $_SERVER['HTTP_HOST'] . $this->createUrl('/user/activation/activation', array("activkey" => $model->activkey, "email" => $model->email));
                         UserModule::sendMail($model->email, UserModule::t("You have registered at {site_name}", array('{site_name}' => Yii::app()->name)), UserModule::t("Please activate your account. Go to {activation_url}", array('{activation_url}' => $activation_url)));
                     }
                     if ((Yii::app()->controller->module->loginNotActiv || Yii::app()->controller->module->activeAfterRegister && Yii::app()->controller->module->sendActivationMail == false) && Yii::app()->controller->module->autoLogin) {
                         $identity = new UserIdentity($model->username, $soucePassword);
                         $identity->authenticate();
                         Yii::app()->user->login($identity, 0);
                         $this->redirect(Yii::app()->controller->module->returnUrl);
                     } else {
                         if (!Yii::app()->controller->module->activeAfterRegister && !Yii::app()->controller->module->sendActivationMail) {
                             Yii::app()->user->setFlash('registration', UserModule::t("Thank you for registering. Contact Admin to activate your account."));
                         } elseif (Yii::app()->controller->module->activeAfterRegister && Yii::app()->controller->module->sendActivationMail == false) {
                             Yii::app()->user->setFlash('registration', UserModule::t("Thank you for registering. Please {{login}}.", array('{{login}}' => CHtml::link(UserModule::t('Login'), Yii::app()->controller->module->loginUrl))));
                         } elseif (Yii::app()->controller->module->loginNotActiv) {
                             Yii::app()->user->setFlash('registration', UserModule::t("Thank you for registering. Please check your email or login."));
                         } else {
                             Yii::app()->user->setFlash('registration', UserModule::t("Thank you for registering. Please check your email."));
                         }
                         $this->refresh();
                     }
                 }
             }
         }
         $this->render('/user/registration', array('form' => $model, 'profile' => $profile));
     }
 }
开发者ID:Cynabal,项目名称:postimer,代码行数:57,代码来源:RegistrationController.php


示例15: actionIndex

 public function actionIndex()
 {
     $criteria = new CDbCriteria();
     $criteria->condition = '`file`<>:null';
     $criteria->params = array(':null' => '');
     $roles = Rights::getAssignedRoles(Yii::app()->user->id);
     // check for single role
     $user_roles = array();
     foreach ($roles as $role) {
         $user_roles[] = '"' . $role->name . '"';
     }
     $teacher = Employees::model()->findByAttributes(array('uid' => Yii::app()->user->id));
     $batches = Batches::model()->findAllByAttributes(array('employee_id' => $teacher->id));
     foreach ($batches as $classteacher) {
         $batch[] = $classteacher->id;
     }
     $timetable = TimetableEntries::model()->findAllByAttributes(array('employee_id' => $teacher->id));
     foreach ($timetable as $period) {
         $batch[] = $period->batch_id;
     }
     $unique_batch = array_unique($batch);
     if (count($unique_batch) > 0) {
         $criteria->condition .= ' AND (`placeholder`=:null OR `created_by`=:user_id OR (`placeholder` IN (' . implode(',', $user_roles) . ')) AND (`batch` IS NULL OR `batch` IN (' . implode(',', $unique_batch) . '))) ';
     } else {
         $criteria->condition .= ' AND (`placeholder`=:null OR `created_by`=:user_id) OR (`placeholder` IN (' . implode(',', $user_roles) . '))';
     }
     $criteria->params[':user_id'] = Yii::app()->user->id;
     $criteria->order = '`created_at` DESC';
     $files = FileUploads::model()->findAll($criteria);
     if (isset($_POST['Downfiles'])) {
         $selected_files = $_POST['Downfiles'];
         $slfiles = array();
         foreach ($selected_files as $s_file) {
             $model = FileUploads::model()->findByPk($s_file);
             if ($model != NULL) {
                 $slfiles[] = 'uploads/shared/' . $model->id . '/' . $model->file;
             }
         }
         $zip = Yii::app()->zip;
         $fName = $this->generateRandomString(rand(10, 20)) . '.zip';
         $zipFile = 'compressed/' . $fName;
         if ($zip->makeZip($slfiles, $zipFile)) {
             $fcon = file_get_contents($zipFile);
             header('Content-type:text/plain');
             header('Content-disposition:attachment; filename=' . $fName);
             header('Pragma:no-cache');
             echo $fcon;
             unlink($zipFile);
         } else {
             Yii::app()->user->setFlash('success', 'Can\'t download');
         }
     }
     $this->render('/fileUploads/index', array('files' => $files));
 }
开发者ID:akilraj1255,项目名称:rajeshwari,代码行数:54,代码来源:TeachersController.php


示例16: actions

 public function actions()
 {
     $disabled = array();
     $roles = Rights::getAssignedRoles(Yii::app()->user->Id);
     // check for single role
     foreach ($roles as $role) {
         if ($role->name != 'Editor' and $role->name != 'Administrator' and $role->name != 'Superadmin') {
             $disabled = array('copy', 'paste', 'archive', 'extract', 'mkdir', 'mkfile', 'rm', 'duplicate', 'resize', 'rename', 'edit');
         }
     }
     return array('connector' => array('class' => 'ElFinderConnectorAction', 'settings' => array('root' => ROOT_DIR . '/uploads/content/', 'URL' => rootUrl . 'uploads/content/', 'rootAlias' => 'Home', 'mimeDetect' => 'internal', 'tmbDir' => '.tmb', 'debug' => '', 'uploadAllow' => array('image'), 'uploadDeny' => array('all'), 'uploadOrder' => 'deny,allow', 'perms' => array('/\\.(txt|html|php|py|pl|sh|xml)$/i' => array('read' => true, 'write' => false, 'rm' => true)), 'disabled' => $disabled)));
 }
开发者ID:beckblurry,项目名称:Yii1-Base-Core-V.Alpha.1,代码行数:12,代码来源:ElfinderController.php


示例17: accessDenied

 /**
  * Denies the access of the user.
  * @param string $message the message to display to the user.
  * This method may be invoked when access check fails.
  * @throws CHttpException when called unless login is required.
  */
 public function accessDenied($message = null)
 {
     if ($message === null) {
         $message = Rights::t('core', 'Bạn không được phép thực hiện hành động này.');
     }
     $user = Yii::app()->getUser();
     if ($user->isGuest === true) {
         $user->loginRequired();
     } else {
         throw new CHttpException(403, $message);
     }
 }
开发者ID:hntvu,项目名称:db_for_site,代码行数:18,代码来源:RController.php


示例18: fetchData

 /**
  * Fetches the data from the persistent data storage.
  * @return array list of data items
  */
 public function fetchData()
 {
     if ($this->sortable !== null) {
         $this->processSortable();
     }
     if ($this->items === null) {
         $this->items = Rights::getAuthorizer()->getAuthItems($this->type, $this->userId, $this->parent, true, $this->exclude);
     }
     $data = array();
     foreach ($this->items as $name => $item) {
         $data[] = $item;
     }
     return $data;
 }
开发者ID:PTZ2002,项目名称:decoram,代码行数:18,代码来源:RAuthItemDataProvider.php


示例19: handler_upload

 function handler_upload($page)
 {
     $page->assign('exception', false);
     $page->assign('image', false);
     if (FrankizUpload::has('file')) {
         $g = Group::from('temp')->select(GroupSelect::castes());
         $temp = $g->caste(Rights::everybody());
         try {
             $upload = FrankizUpload::v('file');
             $secret = uniqid();
             $i = new FrankizImage();
             $i->insert();
             $i->caste($temp);
             $i->label($secret);
             $i->image($upload);
             $page->assign('image', $i);
             $page->assign('secret', $secret);
         } catch (Exception $e) {
             try {
                 if ($i) {
                     $i->delete();
                 }
             } catch (Exception $eb) {
                 $page->assign('exception', $eb);
             }
             $page->assign('exception', $e);
             if ($e instanceof ImageSizeException) {
                 $page->assign('pixels', true);
             } else {
                 if ($e instanceof UploadSizeException) {
                     $page->assign('bytes', true);
                 } else {
                     if ($e instanceof ImageFormatException) {
                         $page->assign('format', true);
                     }
                 }
             }
         }
     }
     if (Env::has('delete')) {
         $image = new FrankizImage(Env::i('iid'));
         $image->select(FrankizImageSelect::base());
         if ($image->label() == Env::s('secret')) {
             $image->delete();
         }
     }
     $page->addCssLink('upload.css');
     $page->changeTpl('images/upload.tpl', SIMPLE);
 }
开发者ID:netixx,项目名称:frankiz,代码行数:49,代码来源:images.php


示例20: smarty_function_origin_picker

function smarty_function_origin_picker($params, &$smarty)
{
    $gf = new GroupFilter(new PFC_And(new PFC_Not(new GFC_Namespace(Group::NS_USER)), new GFC_User(S::user(), Rights::admin())), new GFO_Score());
    $gs = $gf->get();
    if ($params['not_only_admin']) {
        $gfo = new GroupFilter(new PFC_And(new GFC_Namespace(array(Group::NS_BINET, Group::NS_FREE)), new GFC_User(S::user(), Rights::restricted())), new GFO_Score());
        $gso = $gfo->get()->diff($gs);
        $temp = new Collection();
        $temp->merge($gs)->merge($gso);
        $temp->select(GroupSelect::base());
        $smarty->assign('not_admin', $gso);
    } else {
        $gs = $gf->get()->select(GroupSelect::base());
    }
    $smarty->assign($params['out'], $gs);
}
开发者ID:netixx,项目名称:frankiz,代码行数:16,代码来源:function.origin_picker.php



注:本文中的Rights类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP RightsUtil类代码示例发布时间:2022-05-23
下一篇:
PHP Rewrite类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap