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


PHP Gdn_Upload::isUploadUri方法代码示例

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


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

示例1: edit

 /**
  * Edit user account.
  *
  * @since 2.0.0
  * @access public
  * @param mixed $UserReference Username or User ID.
  */
 public function edit($UserReference = '', $Username = '', $UserID = '')
 {
     $this->permission('Garden.SignIn.Allow');
     $this->getUserInfo($UserReference, $Username, $UserID, true);
     $UserID = valr('User.UserID', $this);
     $Settings = array();
     // Set up form
     $User = Gdn::userModel()->getID($UserID, DATASET_TYPE_ARRAY);
     $this->Form->setModel(Gdn::userModel());
     $this->Form->setData($User);
     // Decide if they have ability to edit the username
     $CanEditUsername = (bool) c("Garden.Profile.EditUsernames") || Gdn::session()->checkPermission('Garden.Users.Edit');
     $this->setData('_CanEditUsername', $CanEditUsername);
     // Decide if they have ability to edit the email
     $EmailEnabled = (bool) c('Garden.Profile.EditEmails', true) && !UserModel::noEmail();
     $CanEditEmail = $EmailEnabled && $UserID == Gdn::session()->UserID || checkPermission('Garden.Users.Edit');
     $this->setData('_CanEditEmail', $CanEditEmail);
     // Decide if they have ability to confirm users
     $Confirmed = (bool) valr('User.Confirmed', $this);
     $CanConfirmEmail = UserModel::requireConfirmEmail() && checkPermission('Garden.Users.Edit');
     $this->setData('_CanConfirmEmail', $CanConfirmEmail);
     $this->setData('_EmailConfirmed', $Confirmed);
     $this->Form->setValue('ConfirmEmail', (int) $Confirmed);
     // Decide if we can *see* email
     $this->setData('_CanViewPersonalInfo', Gdn::session()->UserID == val('UserID', $User) || checkPermission('Garden.PersonalInfo.View') || checkPermission('Garden.Users.Edit'));
     // Define gender dropdown options
     $this->GenderOptions = array('u' => t('Unspecified'), 'm' => t('Male'), 'f' => t('Female'));
     $this->fireEvent('BeforeEdit');
     // If seeing the form for the first time...
     if ($this->Form->authenticatedPostBack(true)) {
         $this->Form->setFormValue('UserID', $UserID);
         if (!$CanEditUsername) {
             $this->Form->setFormValue("Name", $User['Name']);
         } else {
             $UsernameError = t('UsernameError', 'Username can only contain letters, numbers, underscores, and must be between 3 and 20 characters long.');
             Gdn::userModel()->Validation->applyRule('Name', 'Username', $UsernameError);
         }
         // API
         // These options become available when POSTing as a user with Garden.Settings.Manage permissions
         if (Gdn::session()->checkPermission('Garden.Settings.Manage')) {
             // Role change
             $RequestedRoles = $this->Form->getFormValue('RoleID', null);
             if (!is_null($RequestedRoles)) {
                 $RoleModel = new RoleModel();
                 $AllRoles = $RoleModel->getArray();
                 if (!is_array($RequestedRoles)) {
                     $RequestedRoles = is_numeric($RequestedRoles) ? array($RequestedRoles) : array();
                 }
                 $RequestedRoles = array_flip($RequestedRoles);
                 $UserNewRoles = array_intersect_key($AllRoles, $RequestedRoles);
                 // Put the data back into the forum object as if the user had submitted
                 // this themselves
                 $this->Form->setFormValue('RoleID', array_keys($UserNewRoles));
                 // Allow saving roles
                 $Settings['SaveRoles'] = true;
             }
             // Password change
             $NewPassword = $this->Form->getFormValue('Password', null);
             if (!is_null($NewPassword)) {
             }
         }
         // Allow mods to confirm emails
         $this->Form->removeFormValue('Confirmed');
         $Confirmation = $this->Form->getFormValue('ConfirmEmail', null);
         $Confirmation = !is_null($Confirmation) ? (bool) $Confirmation : null;
         if ($CanConfirmEmail && is_bool($Confirmation)) {
             $this->Form->setFormValue('Confirmed', (int) $Confirmation);
         }
         // Don't allow non-mods to set an explicit photo.
         if ($photo = $this->Form->getFormValue('Photo')) {
             if (!Gdn_Upload::isUploadUri($photo)) {
                 if (!checkPermission('Garden.Users.Edit')) {
                     $this->Form->removeFormValue('Photo');
                 } elseif (!filter_var($photo, FILTER_VALIDATE_URL)) {
                     $this->Form->addError('Invalid photo URL.');
                 }
             }
         }
         if ($this->Form->save($Settings) !== false) {
             $User = Gdn::userModel()->getID($UserID, DATASET_TYPE_ARRAY);
             $this->setData('Profile', $User);
             $this->informMessage(sprite('Check', 'InformSprite') . t('Your changes have been saved.'), 'Dismissable AutoDismiss HasSprite');
         }
         if (!$CanEditEmail) {
             $this->Form->setFormValue("Email", $User['Email']);
         }
     }
     $this->title(t('Edit Profile'));
     $this->_setBreadcrumbs(t('Edit Profile'), '/profile/edit');
     $this->render();
 }
开发者ID:vanilla,项目名称:vanilla,代码行数:98,代码来源:class.profilecontroller.php


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