/**
  * Gets all the user permissions for the currently logged in user in 
  * the guestbook owned by the given owner.
  * 
  * @var		UserProfile	$guestbookOwner
  * @return	array<bool>
  */
 public static function getUserPermissions(UserProfile $guestbookOwner)
 {
     $permissions = array();
     $permissions['isOwner'] = WCF::getUser()->userID === $guestbookOwner->userID;
     $permissions['canUseGuestbook'] = (bool) WCF::getUser()->getPermission('user.guestbook.canUseGuestbook');
     $permissions['canViewGuestbook'] = $permissions['canUseGuestbook'] && ($permissions['isOwner'] || ($guestbookOwner->guestbookAccess & UserGuestbookUtil::ACCESS_FRIENDS ? UserProfile::isBuddy($guestbookOwner->userID) : (bool) ($guestbookOwner->guestbookAccess & UserGuestbookUtil::ACCESS_EVERYONE)));
     $permissions['canWriteEntry'] = WCF::getUser()->getPermission('user.guestbook.canWriteEntry') && ($guestbookOwner->guestbookWriteEntryAccess & UserGuestbookUtil::ACCESS_FRIENDS ? UserProfile::isBuddy($guestbookOwner->userID) : (bool) ($guestbookOwner->guestbookWriteEntryAccess & UserGuestbookUtil::ACCESS_EVERYONE));
     $permissions['canWriteComment'] = WCF::getUser()->getPermission('user.guestbook.canWriteComment') && ($guestbookOwner->guestbookWriteCommentAccess & UserGuestbookUtil::ACCESS_FRIENDS ? UserProfile::isBuddy($guestbookOwner->userID) : (bool) ($guestbookOwner->guestbookWriteCommentAccess & UserGuestbookUtil::ACCESS_EVERYONE));
     return $permissions;
 }
 /**
  * Formats the username of the given user.
  * 
  * @param	array		$row
  * @param	User	$user
  * @return	string		formatted username
  */
 public static function getFormattedUsername($row, User $user)
 {
     $row['username'] = StringUtil::encodeHTML($row['username']);
     if (UserProfile::isBuddy($user->userID)) {
         $row['username'] = '******' . $row['username'] . '</span>';
     }
     if (!empty($row['userOnlineMarking'])) {
         $row['username'] = sprintf($row['userOnlineMarking'], $row['username']);
     }
     if ($user->invisible) {
         $row['username'] .= WCF::getLanguage()->get('wcf.usersOnline.invisible');
     }
     return $row['username'];
 }
 /**
  * Returns true, if the active user can see the profile of this user.
  * 
  * @return	boolean
  */
 public function canViewProfile()
 {
     return !$this->protectedProfile || WCF::getUser()->userID == $this->userID || UserProfile::isBuddy($this->userID) || WCF::getUser()->getPermission('admin.general.canViewPrivateUserOptions');
 }
 /**
  * Creates a new MessageSidebar object.
  *
  * @param	UserProfile	$user
  */
 public function __construct(MessageSidebarObject $object)
 {
     $this->object = $object;
     // init user options
     if ($this->getUser()->userID) {
         if (!$this->getUser()->protectedProfile || $this->getUser()->userID == WCF::getUser()->userID) {
             $userOptions = self::getUserOptions();
             $categories = $userOptions->getOptionTree('profile', $this->getUser());
             // add registration date
             if (MESSAGE_SIDEBAR_ENABLE_REGISTRATION_DATE == 1) {
                 $this->addUserCredit(WCF::getLanguage()->get('wcf.user.registrationDate'), DateUtil::formatDate(null, $this->getUser()->registrationDate));
             }
             // user options
             foreach ($categories as $category) {
                 if ($category['categoryName'] == 'profile.contact' || $category['categoryName'] == 'profile.messenger') {
                     foreach ($category['options'] as $userOption) {
                         $this->addUserContact($userOption['optionValue']);
                     }
                 } else {
                     foreach ($category['options'] as $userOption) {
                         if ($userOption['optionName'] == 'birthday' || $userOption['optionName'] == 'gender') {
                             $this->addUserSymbol($userOption['optionValue']);
                         } else {
                             $this->addUserCredit(WCF::getLanguage()->get('wcf.user.option.' . $userOption['optionName']), $userOption['optionValue']);
                         }
                     }
                 }
             }
             // add friend icon
             if (MESSAGE_SIDEBAR_ENABLE_FRIEND_ICON) {
                 if (WCF::getUser()->userID && UserProfile::isBuddy($this->getUser()->userID)) {
                     $this->addUserSymbol('<img src="' . StyleManager::getStyle()->getIconPath('friendsS.png') . '" alt="' . WCF::getLanguage()->getDynamicVariable('wcf.user.profile.friend', array('username' => $this->getUser()->username)) . '" title="' . WCF::getLanguage()->getDynamicVariable('wcf.user.profile.friend', array('username' => $this->getUser()->username)) . '" />');
                 }
             }
         }
         // banned icon
         if ($object->getUser()->banned) {
             $this->addUserSymbol('<img src="' . StyleManager::getStyle()->getIconPath('bannedS.png') . '" alt="' . WCF::getLanguage()->getDynamicVariable('wcf.user.profile.banned', array('username' => $this->getUser()->username)) . '" title="' . WCF::getLanguage()->getDynamicVariable('wcf.user.profile.banned', array('username' => $this->getUser()->username)) . '" />');
         }
     }
 }