本文整理汇总了PHP中UserProfile::canViewProfile方法的典型用法代码示例。如果您正苦于以下问题:PHP UserProfile::canViewProfile方法的具体用法?PHP UserProfile::canViewProfile怎么用?PHP UserProfile::canViewProfile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserProfile
的用法示例。
在下文中一共展示了UserProfile::canViewProfile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: readParameters
/**
* @see Page::readParameters()
*/
public function readParameters()
{
parent::readParameters();
// check permission
WCF::getUser()->checkPermission('user.profile.canView');
// get user
if (isset($_REQUEST['userID'])) {
$this->userID = intval($_REQUEST['userID']);
}
$this->user = new UserProfile($this->userID);
if (!$this->user->userID || !$this->user->canViewProfile()) {
throw new IllegalLinkException();
}
}
示例2: init
//.........这里部分代码省略.........
if (WCF::getUser()->buddies) {
// one step
$sql = "SELECT\t\tfriends_2nd.userID\n\t\t\t\t\t\tFROM\t\twcf" . WCF_N . "_user_whitelist my_friends,\n\t\t\t\t\t\t\t\twcf" . WCF_N . "_user_whitelist friends_2nd\n\t\t\t\t\t\tWHERE\t\tmy_friends.userID = " . WCF::getUser()->userID . " AND my_friends.confirmed = 1\n\t\t\t\t\t\t\t\tAND friends_2nd.userID = my_friends.whiteUserID AND friends_2nd.confirmed = 1\n\t\t\t\t\t\t\t\tAND friends_2nd.whiteUserID = " . $this->userID;
$row = WCF::getDB()->getFirstRow($sql);
if (!empty($row['userID'])) {
$connectionUserIDArray[] = WCF::getUser()->userID;
$connectionUserIDArray[] = $row['userID'];
} else {
// two steps
$sql = "SELECT\t\tfriends_2nd.userID AS 1st, friends_3rd.userID AS 2nd\n\t\t\t\t\t\t\tFROM\t\twcf" . WCF_N . "_user_whitelist my_friends,\n\t\t\t\t\t\t\t\t\twcf" . WCF_N . "_user_whitelist friends_2nd,\n\t\t\t\t\t\t\t\t\twcf" . WCF_N . "_user_whitelist friends_3rd\n\t\t\t\t\t\t\tWHERE\t\tmy_friends.userID = " . WCF::getUser()->userID . " AND my_friends.confirmed = 1\n\t\t\t\t\t\t\t\t\tAND friends_2nd.userID = my_friends.whiteUserID AND friends_2nd.confirmed = 1\n\t\t\t\t\t\t\t\t\tAND friends_3rd.userID = friends_2nd.whiteUserID AND friends_3rd.confirmed = 1\n\t\t\t\t\t\t\t\t\tAND friends_3rd.whiteUserID = " . $this->userID;
$row = WCF::getDB()->getFirstRow($sql);
if (!empty($row['1st'])) {
$connectionUserIDArray[] = WCF::getUser()->userID;
$connectionUserIDArray[] = $row['1st'];
$connectionUserIDArray[] = $row['2nd'];
} else {
// three steps
$sql = "SELECT\t\tfriends_2nd.userID AS 1st, friends_3rd.userID AS 2nd, friends_4th.userID AS 3rd\n\t\t\t\t\t\t\t\tFROM\t\twcf" . WCF_N . "_user_whitelist my_friends,\n\t\t\t\t\t\t\t\t\t\twcf" . WCF_N . "_user_whitelist friends_2nd,\n\t\t\t\t\t\t\t\t\t\twcf" . WCF_N . "_user_whitelist friends_3rd,\n\t\t\t\t\t\t\t\t\t\twcf" . WCF_N . "_user_whitelist friends_4th\n\t\t\t\t\t\t\t\tWHERE\t\tmy_friends.userID = " . WCF::getUser()->userID . " AND my_friends.confirmed = 1\n\t\t\t\t\t\t\t\t\t\tAND friends_2nd.userID = my_friends.whiteUserID AND friends_2nd.confirmed = 1\n\t\t\t\t\t\t\t\t\t\tAND friends_3rd.userID = friends_2nd.whiteUserID AND friends_3rd.confirmed = 1\n\t\t\t\t\t\t\t\t\t\tAND friends_4th.userID = friends_3rd.whiteUserID AND friends_4th.confirmed = 1\n\t\t\t\t\t\t\t\t\t\tAND friends_4th.whiteUserID = " . $this->userID;
$row = WCF::getDB()->getFirstRow($sql);
if (!empty($row['1st'])) {
$connectionUserIDArray[] = WCF::getUser()->userID;
$connectionUserIDArray[] = $row['1st'];
$connectionUserIDArray[] = $row['2nd'];
$connectionUserIDArray[] = $row['3rd'];
}
/*else {
// four steps
$sql = "SELECT friends_2nd.userID AS 1st, friends_3rd.userID AS 2nd, friends_4th.userID AS 3rd, friends_5th.userID AS 4th
FROM wcf".WCF_N."_user_whitelist my_friends,
wcf".WCF_N."_user_whitelist friends_2nd,
wcf".WCF_N."_user_whitelist friends_3rd,
wcf".WCF_N."_user_whitelist friends_4th,
wcf".WCF_N."_user_whitelist friends_5th
WHERE my_friends.userID = ".WCF::getUser()->userID." AND my_friends.confirmed = 1
AND friends_2nd.userID = my_friends.whiteUserID AND friends_2nd.confirmed = 1
AND friends_3rd.userID = friends_2nd.whiteUserID AND friends_3rd.confirmed = 1
AND friends_4th.userID = friends_3rd.whiteUserID AND friends_4th.confirmed = 1
AND friends_5th.userID = friends_4th.whiteUserID AND friends_5th.confirmed = 1
AND friends_5th.whiteUserID = ".$this->userID;
$row = WCF::getDB()->getFirstRow($sql);
if (!empty($row['1st'])) {
$connectionUserIDArray[] = WCF::getUser()->userID;
$connectionUserIDArray[] = $row['1st'];
$connectionUserIDArray[] = $row['2nd'];
$connectionUserIDArray[] = $row['3rd'];
$connectionUserIDArray[] = $row['4th'];
}
}*/
}
}
}
}
if (count($connectionUserIDArray) > 0) {
$sql = "SELECT\t\tavatar.*, user_table.*\n\t\t\t\t\t\tFROM\t\twcf" . WCF_N . "_user user_table\n\t\t\t\t\t\tLEFT JOIN \twcf" . WCF_N . "_avatar avatar\n\t\t\t\t\t\tON \t\t(avatar.avatarID = user_table.avatarID)\n\t\t\t\t\t\tWHERE\t\tuser_table.userID IN (" . implode(',', $connectionUserIDArray) . ")";
$result = WCF::getDB()->sendQuery($sql);
while ($row = WCF::getDB()->fetchArray($result)) {
$this->connection[array_search($row['userID'], $connectionUserIDArray)] = new UserProfile(null, $row);
}
// sorting
ksort($this->connection);
$this->connection = array_reverse($this->connection);
}
} else {
// get network
$sql = "SELECT\tCOUNT(*) AS count\n\t\t\t\t\tFROM\twcf" . WCF_N . "_user_whitelist\n\t\t\t\t\tWHERE\tuserID = " . $this->userID . "\n\t\t\t\t\t\tAND confirmed = 1";
$row = WCF::getDB()->getFirstRow($sql);
if ($row['count']) {
$this->network['friends'] = $row['count'];
$sql = "SELECT\t\tCOUNT(DISTINCT friends_2nd.whiteUserID) AS count\n\t\t\t\t\t\tFROM\t\twcf" . WCF_N . "_user_whitelist my_friends\n\t\t\t\t\t\tLEFT JOIN\twcf" . WCF_N . "_user_whitelist friends_2nd\n\t\t\t\t\t\tON\t\t(friends_2nd.userID = my_friends.whiteUserID AND friends_2nd.confirmed = 1)\n\t\t\t\t\t\tWHERE\t\tmy_friends.userID = " . $this->userID . "\n\t\t\t\t\t\t\t\tAND my_friends.confirmed = 1";
$row = WCF::getDB()->getFirstRow($sql);
if ($row['count']) {
$this->network['friendsOfFriends'] = $row['count'];
$sql = "SELECT\t\tCOUNT(DISTINCT friends_3rd.whiteUserID) AS count\n\t\t\t\t\t\t\tFROM\t\twcf" . WCF_N . "_user_whitelist my_friends\n\t\t\t\t\t\t\tLEFT JOIN\twcf" . WCF_N . "_user_whitelist friends_2nd\n\t\t\t\t\t\t\tON\t\t(friends_2nd.userID = my_friends.whiteUserID AND friends_2nd.confirmed = 1)\n\t\t\t\t\t\t\tLEFT JOIN\twcf" . WCF_N . "_user_whitelist friends_3rd\n\t\t\t\t\t\t\tON\t\t(friends_3rd.userID = friends_2nd.whiteUserID AND friends_3rd.confirmed = 1)\n\t\t\t\t\t\t\tWHERE\t\tmy_friends.userID = " . $this->userID . "\n\t\t\t\t\t\t\t\t\tAND my_friends.confirmed = 1";
$row = WCF::getDB()->getFirstRow($sql);
if ($row['count']) {
$this->network['friends3rdGrade'] = $row['count'];
} else {
$this->network['friends3rdGrade'] = 0;
}
} else {
$this->network['friendsOfFriends'] = 0;
}
}
}
}
// check permission
WCF::getUser()->checkPermission('user.profile.canView');
try {
if ($this->user->ignoredUser) {
throw new NamedUserException(WCF::getLanguage()->getDynamicVariable('wcf.user.profile.error.ignoredUser', array('username' => $this->user->username)));
}
if (!$this->user->canViewProfile()) {
throw new NamedUserException(WCF::getLanguage()->getDynamicVariable('wcf.user.profile.error.protectedProfile', array('username' => $this->user->username)));
}
} catch (NamedUserException $e) {
WCF::getTPL()->assign(array('user' => $this->user, 'userID' => $this->userID, 'connection' => $this->connection, 'network' => $this->network, 'userSymbols' => $this->userSymbols, 'errorMessage' => $e->getMessage()));
WCF::getTPL()->display('userProfileAccessDenied');
exit;
}
}