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


PHP UserProfile::getPermission方法代码示例

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


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

示例1: execute

 /**
  * @see EventListener::execute()
  */
 public function execute($eventObj, $className, $eventName)
 {
     if (!USERGUESTBOOK_SHOWINSIDEBAR) {
         return;
     }
     if (!WCF::getUser()->getPermission('user.guestbook.canRead')) {
         return;
     }
     if (empty($eventObj->postList->posts)) {
         return;
     }
     $seen = $ret = array();
     $ret = WCF::getTPL()->get('additionalSidebarUserContacts');
     $link = '<a href="index.php?page=UserGuestbook&amp;userID=%1$d' . SID_ARG_2ND . '"><img src="' . RELATIVE_WCF_DIR . 'icon/guestbookS.png" alt="" title="%2$s" /></a>';
     $curUserID = WCF::getUser()->userID;
     $curUserCanUse = WCF::getUser()->getPermission('user.guestbook.canUseOwn');
     $gbEnableOption = 'userOption' . User::getUserOptionID('userGuestbook_enable');
     require_once WCF_DIR . 'lib/data/user/UserProfile.class.php';
     foreach ($eventObj->postList->posts as $post) {
         if ($post->userID) {
             if ($curUserID == $post->userID && !$curUserCanUse) {
                 continue;
             } else {
                 if (!$post->{$gbEnableOption}) {
                     continue;
                 } else {
                     if (array_key_exists($post->userID, $seen)) {
                         if (!empty($seen[$post->userID])) {
                             if (isset($ret[$post->postID])) {
                                 $ret[$post->postID] .= ' ' . $seen[$post->userID];
                             } else {
                                 $ret[$post->postID] = $seen[$post->userID];
                             }
                         }
                     } else {
                         $add = '';
                         $user = new UserProfile($post->userID, null, null, null);
                         if ($user->getPermission('user.guestbook.canUseOwn')) {
                             $username = StringUtil::encodeHTML($user->username);
                             $title = WCF::getLanguage()->get('wcf.user.guestbook.title', array('$user->username' => $username));
                             $add = sprintf($link, $post->userID, $title);
                             if (isset($ret[$post->postID])) {
                                 $ret[$post->postID] .= ' ' . $add;
                             } else {
                                 $ret[$post->postID] = $add;
                             }
                         }
                         $seen[$post->userID] = $add;
                     }
                 }
             }
         }
     }
     if (count($ret)) {
         WCF::getTPL()->assign('additionalSidebarUserContacts', $ret);
     }
 }
开发者ID:Maggan22,项目名称:wbb3addons,代码行数:60,代码来源:UserGuestBookThreadListener.class.php

示例2: validateRecipients

 /**
  * Checks the given recipients.
  */
 protected function validateRecipients($recipients, $field = 'recipients')
 {
     // explode multiple recipients to an array
     $recipientArray = explode(',', $recipients);
     $result = array();
     $error = array();
     // loop through recipients and check their settings
     foreach ($recipientArray as $recipient) {
         $recipient = StringUtil::trim($recipient);
         if (empty($recipient)) {
             continue;
         }
         try {
             // get recipient's profile
             $user = new UserProfile(null, null, $recipient);
             if (!$user->userID) {
                 throw new UserInputException('recipient', 'notFound');
             }
             $reply = $this->pm && $this->reply && $this->pm->userID == $user->userID && !$this->pm->isReplied;
             // check recipient's settings and permissions
             // can use pm
             if (!$user->getPermission('user.pm.canUsePm')) {
                 throw new UserInputException('recipient', 'canNotUsePm');
             }
             if (!$reply) {
                 // accepts messages
                 if (!$user->acceptPm) {
                     throw new UserInputException('recipient', 'doesNotAcceptPm');
                 }
                 // recipient only accept private messages from buddies
                 if ($user->onlyBuddyCanPm && !$user->buddy && $user->userID != WCF::getUser()->userID && !WCF::getUser()->getPermission('user.profile.blacklist.canNotBeIgnored')) {
                     throw new UserInputException('recipient', 'onlyAcceptsPmFromBuddies');
                 }
             }
             // active user is ignored by recipient
             if ($user->ignoredUser) {
                 throw new UserInputException('recipient', 'ignoresYou');
             }
             // check recipient's mailbox quota
             if ($user->pmTotalCount >= $user->getPermission('user.pm.maxPm') && !WCF::getUser()->getPermission('user.profile.blacklist.canNotBeIgnored')) {
                 throw new UserInputException('recipient', 'recipientsMailboxIsFull');
             }
             // no error
             $result[] = array('userID' => $user->userID, 'username' => $user->username);
             if ($user->emailOnPm) {
                 $this->notificationRecipients[$user->userID] = $user;
             }
         } catch (UserInputException $e) {
             $error[] = array('type' => $e->getType(), 'username' => $recipient);
         }
     }
     if (count($error)) {
         throw new UserInputException($field, $error);
     }
     return $result;
 }
开发者ID:joaocustodio,项目名称:EmuDevstore-1,代码行数:59,代码来源:PMNewForm.class.php

示例3: execute

 /**
  * @see EventListener::execute()
  */
 public function execute($eventObj, $className, $eventName)
 {
     if (!USERWANTEDPOSTER_SHOWINSIDEBAR) {
         return;
     }
     if (!WCF::getUser()->getPermission('user.wantedPoster.canViewWantedPoster')) {
         return;
     }
     if (empty($eventObj->postList->posts)) {
         return;
     }
     $seen = $wpUserIDs = $postUserIDs = array();
     $uwpIDinStr = '';
     $ret = WCF::getTPL()->get('additionalSidebarUserContacts');
     $link = '<a href="index.php?page=UserWantedPoster&amp;userID=%1$d"><img src="' . RELATIVE_WCF_DIR . 'icon/userWantedPosterS.png" alt="" title="%2$s" /></a>';
     $curUserID = WCF::getUser()->userID;
     $curUserCanUse = WCF::getUser()->getPermission('user.wantedPoster.canUseWantedPoster');
     require_once WCF_DIR . 'lib/data/user/UserProfile.class.php';
     foreach ($eventObj->postList->posts as $post) {
         if ($post->userID && !in_array($post->userID, $postUserIDs)) {
             $postUserIDs[] = $post->userID;
         }
     }
     $uwpIDinStr = implode(',', $postUserIDs);
     if (empty($uwpIDinStr) || $uwpIDinStr == ',') {
         return;
     }
     $sql = "SELECT userID" . "\n  FROM wcf" . WCF_N . "_user_wanted_poster" . "\n WHERE userID IN (" . $uwpIDinStr . ")";
     $result = WCF::getDB()->sendQuery($sql);
     while ($row = WCF::getDB()->fetchArray($result)) {
         $wpUserIDs[] = $row['userID'];
     }
     if (!count($wpUserIDs)) {
         return;
     }
     foreach ($eventObj->postList->posts as $post) {
         if ($post->userID) {
             if ($curUserID == $post->userID && !$curUserCanUse) {
                 continue;
             } else {
                 if (!in_array($post->userID, $wpUserIDs, true)) {
                     continue;
                 } else {
                     if (array_key_exists($post->userID, $seen)) {
                         if (!empty($seen[$post->userID])) {
                             if (isset($ret[$post->postID])) {
                                 $ret[$post->postID] .= ' ' . $seen[$post->userID];
                             } else {
                                 $ret[$post->postID] = $seen[$post->userID];
                             }
                         }
                     } else {
                         $add = '';
                         $user = new UserProfile($post->userID, null, null, null);
                         if ($user->getPermission('user.wantedPoster.canUseWantedPoster')) {
                             $username = StringUtil::encodeHTML($user->username);
                             $title = WCF::getLanguage()->get('wcf.user.wantedPoster.title', array('$user->username' => $username));
                             $add = sprintf($link, $post->userID, $title);
                             if (isset($ret[$post->postID])) {
                                 $ret[$post->postID] .= ' ' . $add;
                             } else {
                                 $ret[$post->postID] = $add;
                             }
                         }
                         $seen[$post->userID] = $add;
                     }
                 }
             }
         }
     }
     if (count($ret)) {
         WCF::getTPL()->assign('additionalSidebarUserContacts', $ret);
     }
 }
开发者ID:Maggan22,项目名称:wbb3addons,代码行数:77,代码来源:UserWantedPosterThreadListener.class.php


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