本文整理汇总了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&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);
}
}
示例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;
}
示例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&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);
}
}