2 namespace wcf\data\user\option
;
3 use wcf\data\option\Option
;
4 use wcf\data\user\User
;
8 * Represents a user option.
11 * @copyright 2001-2014 WoltLab GmbH
12 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
13 * @package com.woltlab.wcf
14 * @subpackage data.user.option
15 * @category Community Framework
17 class UserOption
extends Option
{
19 * visible for no one (no valid bit)
22 const VISIBILITY_NONE
= 0;
25 * visible for the owner
28 const VISIBILITY_OWNER
= 1;
34 const VISIBILITY_ADMINISTRATOR
= 2;
40 const VISIBILITY_REGISTERED
= 4;
46 const VISIBILITY_GUEST
= 8;
49 * visible for all (no valid bit)
52 const VISIBILITY_ALL
= 15;
55 * editable for no one (no valid bit)
58 const EDITABILITY_NONE
= 0;
61 * editable for the owner
64 const EDITABILITY_OWNER
= 1;
70 const EDITABILITY_ADMINISTRATOR
= 2;
73 * editable for all (no valid bit)
76 const EDITABILITY_ALL
= 3;
79 * @see \wcf\data\DatabaseObject::$databaseTableName
81 protected static $databaseTableName = 'user_option';
84 * @see \wcf\data\DatabaseObject::$databaseTableIndexName
86 protected static $databaseTableIndexName = 'optionID';
92 public $optionValue = '';
96 * @var \wcf\data\user\User
101 * Sets target user object.
103 * @param \wcf\data\user\User $user
105 public function setUser(User
$user) {
110 * @see \wcf\data\option\Option::isVisible()
112 public function isVisible() {
113 // proceed if option is visible for all
114 if ($this->visible
& self
::VISIBILITY_GUEST
) {
118 // proceed if option is visible for registered users and current user is logged in
119 if (($this->visible
& self
::VISIBILITY_REGISTERED
) && WCF
::getUser()->userID
) {
123 // check admin permissions
124 if ($this->visible
& self
::VISIBILITY_ADMINISTRATOR
) {
125 if (WCF
::getSession()->getPermission('admin.general.canViewPrivateUserOptions')) {
131 if ($this->visible
& self
::VISIBILITY_OWNER
) {
132 if ($this->user
!== null && $this->user
->userID
== WCF
::getUser()->userID
) {
141 * Returns true if this option is editable.
145 public function isEditable() {
146 // check admin permissions
147 if ($this->editable
& self
::EDITABILITY_ADMINISTRATOR
) {
148 if (WCF
::getSession()->getPermission('admin.general.canViewPrivateUserOptions')) {
154 if ($this->editable
& self
::EDITABILITY_OWNER
) {
155 if ($this->user
=== null ||
$this->user
->userID
== WCF
::getUser()->userID
) {
164 * Returns true if this user option can be deleted.
168 public function canDelete() {
169 if ($this->originIsSystem
) {