当前位置: 首页>>代码示例>>PHP>>正文


PHP BackendUser::isGod方法代码示例

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


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

示例1: execute

 /**
  * Execute the action
  */
 public function execute()
 {
     // get parameters
     $this->id = $this->getParameter('id', 'int');
     // does the user exist
     if ($this->id !== null && BackendUsersModel::exists($this->id) && BackendAuthentication::getUser()->getUserId() != $this->id) {
         parent::execute();
         // get data
         $user = new BackendUser($this->id);
         // God-users can't be deleted
         if ($user->isGod()) {
             $this->redirect(BackendModel::createURLForAction('index') . '&error=cant-delete-god');
         }
         // delete item
         BackendUsersModel::delete($this->id);
         // trigger event
         BackendModel::triggerEvent($this->getModule(), 'after_delete', array('id' => $this->id));
         // item was deleted, so redirect
         $this->redirect(BackendModel::createURLForAction('index') . '&report=deleted&var=' . $user->getSetting('nickname'));
     } else {
         $this->redirect(BackendModel::createURLForAction('index') . '&error=non-existing');
     }
 }
开发者ID:naujasdizainas,项目名称:forkcms,代码行数:26,代码来源:delete.php

示例2: authorize

 /**
  * Default authentication
  *
  * @return	bool
  */
 public static function authorize()
 {
     // grab data
     $email = SpoonFilter::getGetValue('email', null, '');
     $nonce = SpoonFilter::getGetValue('nonce', null, '');
     $secret = SpoonFilter::getGetValue('secret', null, '');
     // data can be available in the POST, so check it
     if ($email == '') {
         $email = SpoonFilter::getPostValue('email', null, '');
     }
     if ($nonce == '') {
         $nonce = SpoonFilter::getPostValue('nonce', null, '');
     }
     if ($secret == '') {
         $secret = SpoonFilter::getPostValue('secret', null, '');
     }
     // check if needed elements are available
     if ($email == '') {
         self::output(self::BAD_REQUEST, array('message' => 'No email-parameter provided.'));
     }
     if ($nonce == '') {
         self::output(self::BAD_REQUEST, array('message' => 'No nonce-parameter provided.'));
     }
     if ($secret == '') {
         self::output(self::BAD_REQUEST, array('message' => 'No secret-parameter provided.'));
     }
     // get the user
     $user = new BackendUser(null, $email);
     // user is god!
     if ($user->isGod()) {
         return true;
     }
     // get settings
     $apiAccess = $user->getSetting('api_access', false);
     $apiKey = $user->getSetting('api_key');
     // no API-access
     if (!$apiAccess) {
         self::output(self::FORBIDDEN, array('message' => 'Your account isn\'t allowed to use the API. Contact an administrator.'));
     }
     // create hash
     $hash = BackendAuthentication::getEncryptedString($email . $apiKey, $nonce);
     // output
     if ($secret != $hash) {
         self::output(self::FORBIDDEN, array('message' => 'Invalid secret.'));
     }
     // return
     return true;
 }
开发者ID:netconstructor,项目名称:forkcms,代码行数:53,代码来源:api.php

示例3: validateForm

 /**
  * Validate the form
  */
 private function validateForm()
 {
     // is the form submitted?
     if ($this->frm->isSubmitted()) {
         // cleanup the submitted fields, ignore fields that were added by hackers
         $this->frm->cleanupFields();
         $fields = $this->frm->getFields();
         // email is present
         if (!$this->user->isGod()) {
             if ($fields['email']->isFilled(BL::err('EmailIsRequired'))) {
                 // is this an email-address
                 if ($fields['email']->isEmail(BL::err('EmailIsInvalid'))) {
                     // was this emailaddress deleted before
                     if (BackendUsersModel::emailDeletedBefore($fields['email']->getValue())) {
                         $fields['email']->addError(sprintf(BL::err('EmailWasDeletedBefore'), BackendModel::createURLForAction('undo_delete', null, null, array('email' => $fields['email']->getValue()))));
                     } elseif (BackendUsersModel::existsEmail($fields['email']->getValue(), $this->id)) {
                         $fields['email']->addError(BL::err('EmailAlreadyExists'));
                     }
                 }
             }
         }
         // required fields
         if ($this->user->isGod() && $fields['email']->getValue() != '' && $this->user->getEmail() != $fields['email']->getValue()) {
             $fields['email']->addError(BL::err('CantChangeGodsEmail'));
         }
         if (!$this->user->isGod()) {
             $fields['email']->isEmail(BL::err('EmailIsInvalid'));
         }
         $fields['nickname']->isFilled(BL::err('NicknameIsRequired'));
         $fields['name']->isFilled(BL::err('NameIsRequired'));
         $fields['surname']->isFilled(BL::err('SurnameIsRequired'));
         $fields['interface_language']->isFilled(BL::err('FieldIsRequired'));
         $fields['date_format']->isFilled(BL::err('FieldIsRequired'));
         $fields['time_format']->isFilled(BL::err('FieldIsRequired'));
         $fields['number_format']->isFilled(BL::err('FieldIsRequired'));
         $fields['groups']->isFilled(BL::err('FieldIsRequired'));
         if (isset($fields['new_password']) && $fields['new_password']->isFilled()) {
             if ($fields['new_password']->getValue() !== $fields['confirm_password']->getValue()) {
                 $fields['confirm_password']->addError(BL::err('ValuesDontMatch'));
             }
         }
         // validate avatar
         if ($fields['avatar']->isFilled()) {
             // correct extension
             if ($fields['avatar']->isAllowedExtension(array('jpg', 'jpeg', 'gif', 'png'), BL::err('JPGGIFAndPNGOnly'))) {
                 // correct mimetype?
                 $fields['avatar']->isAllowedMimeType(array('image/gif', 'image/jpg', 'image/jpeg', 'image/png'), BL::err('JPGGIFAndPNGOnly'));
             }
         }
         // no errors?
         if ($this->frm->isCorrect()) {
             // build user-array
             $user['id'] = $this->id;
             if (!$this->user->isGod()) {
                 $user['email'] = $fields['email']->getValue(true);
             }
             if (BackendAuthentication::getUser()->getUserId() != $this->record['id']) {
                 $user['active'] = $fields['active']->isChecked() ? 'Y' : 'N';
             }
             // update password (only if filled in)
             if (isset($fields['new_password']) && $fields['new_password']->isFilled()) {
                 $user['password'] = BackendAuthentication::getEncryptedString($fields['new_password']->getValue(), $this->record['settings']['password_key']);
             }
             // build settings-array
             $settings['nickname'] = $fields['nickname']->getValue();
             $settings['name'] = $fields['name']->getValue();
             $settings['surname'] = $fields['surname']->getValue();
             $settings['interface_language'] = $fields['interface_language']->getValue();
             $settings['date_format'] = $fields['date_format']->getValue();
             $settings['time_format'] = $fields['time_format']->getValue();
             $settings['datetime_format'] = $settings['date_format'] . ' ' . $settings['time_format'];
             $settings['number_format'] = $fields['number_format']->getValue();
             $settings['csv_split_character'] = $fields['csv_split_character']->getValue();
             $settings['csv_line_ending'] = $fields['csv_line_ending']->getValue();
             $settings['api_access'] = (bool) $fields['api_access']->getChecked();
             // get selected groups
             $groups = $fields['groups']->getChecked();
             // init var
             $newSequence = BackendGroupsModel::getSetting($groups[0], 'dashboard_sequence');
             // loop through groups and collect all dashboard widget sequences
             foreach ($groups as $group) {
                 $sequences[] = BackendGroupsModel::getSetting($group, 'dashboard_sequence');
             }
             // loop through sequences
             foreach ($sequences as $sequence) {
                 // loop through modules inside a sequence
                 foreach ($sequence as $moduleKey => $module) {
                     // loop through widgets inside a module
                     foreach ($module as $widgetKey => $widget) {
                         // if widget present set true
                         if ($widget['present']) {
                             $newSequence[$moduleKey][$widgetKey]['present'] = true;
                         }
                     }
                 }
             }
             // add new sequence to settings
//.........这里部分代码省略.........
开发者ID:naujasdizainas,项目名称:forkcms,代码行数:101,代码来源:edit.php


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