Commit | Line | Data |
---|---|---|
11ade432 | 1 | <?php |
a9229942 | 2 | |
11ade432 | 3 | namespace wcf\data\user\option\category; |
a9229942 | 4 | |
11ade432 | 5 | use wcf\data\DatabaseObject; |
a41ce945 | 6 | use wcf\data\ITitledObject; |
11ade432 AE |
7 | use wcf\system\WCF; |
8 | ||
9 | /** | |
10 | * Represents a user option category. | |
e9335ed9 | 11 | * |
a9229942 TD |
12 | * @author Marcel Werk |
13 | * @copyright 2001-2019 WoltLab GmbH | |
14 | * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php> | |
15 | * @package WoltLabSuite\Core\Data\User\Option\Category | |
16 | * | |
17 | * @property-read int $categoryID unique id of the user option category | |
18 | * @property-read int $packageID id of the package which delivers the user option category | |
19 | * @property-read string $categoryName name and textual identifier of the user option category | |
20 | * @property-read string $parentCategoryName name of the user option category's parent category or empty if it has no parent category | |
21 | * @property-read int $showOrder position of the user option category in relation to its siblings | |
22 | * @property-read string $permissions comma separated list of user group permissions of which the active user needs to have at least one to see the user option category | |
23 | * @property-read string $options comma separated list of options of which at least one needs to be enabled for the user option category to be shown | |
11ade432 | 24 | */ |
a9229942 TD |
25 | class UserOptionCategory extends DatabaseObject implements ITitledObject |
26 | { | |
27 | /** | |
28 | * Returns the title of this category. | |
29 | * | |
30 | * @return string | |
31 | */ | |
32 | public function __toString() | |
33 | { | |
34 | return $this->categoryName; | |
35 | } | |
36 | ||
37 | /** | |
38 | * @inheritDoc | |
39 | */ | |
40 | public function getTitle() | |
41 | { | |
42 | return WCF::getLanguage()->get('wcf.user.option.category.' . $this->categoryName); | |
43 | } | |
44 | ||
45 | /** | |
46 | * Returns an instance of UserOptionCategory by name. | |
47 | * | |
48 | * @param string $categoryName | |
c0b28aa2 | 49 | * @return UserOptionCategory|null |
a9229942 TD |
50 | */ |
51 | public static function getCategoryByName($categoryName) | |
52 | { | |
53 | $sql = "SELECT * | |
54 | FROM wcf" . WCF_N . "_user_option_category | |
55 | WHERE categoryName = ?"; | |
56 | $statement = WCF::getDB()->prepareStatement($sql); | |
57 | $statement->execute([$categoryName]); | |
58 | $row = $statement->fetchArray(); | |
59 | if ($row === false) { | |
c0b28aa2 | 60 | return null; |
a9229942 TD |
61 | } |
62 | ||
63 | return new self(null, $row); | |
64 | } | |
11ade432 | 65 | } |