From 625136ac2e609575c849bfa86723626711b2d54a Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Thu, 21 May 2015 23:14:09 +0200 Subject: [PATCH] Add missing trait files --- .../lib/data/TDatabaseObjectOptions.class.php | 34 ++++++++++++++++++ .../data/TDatabaseObjectPermissions.class.php | 36 +++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 wcfsetup/install/files/lib/data/TDatabaseObjectOptions.class.php create mode 100644 wcfsetup/install/files/lib/data/TDatabaseObjectPermissions.class.php diff --git a/wcfsetup/install/files/lib/data/TDatabaseObjectOptions.class.php b/wcfsetup/install/files/lib/data/TDatabaseObjectOptions.class.php new file mode 100644 index 0000000000..e95d5f5bfc --- /dev/null +++ b/wcfsetup/install/files/lib/data/TDatabaseObjectOptions.class.php @@ -0,0 +1,34 @@ + + * @package com.woltlab.wcf + * @subpackage data + * @category Community Framework + */ +trait TDatabaseObjectOptions { + /** + * Returns true if at least one of the options required by this object is set. + * + * @return boolean + */ + public function validateOptions() { + if ($this->options) { + $options = explode(',', strtoupper($this->options)); + foreach ($options as $option) { + if (defined($option) && constant($option)) { + return true; + } + } + + return false; + } + + return true; + } +} diff --git a/wcfsetup/install/files/lib/data/TDatabaseObjectPermissions.class.php b/wcfsetup/install/files/lib/data/TDatabaseObjectPermissions.class.php new file mode 100644 index 0000000000..2d8e015c01 --- /dev/null +++ b/wcfsetup/install/files/lib/data/TDatabaseObjectPermissions.class.php @@ -0,0 +1,36 @@ + + * @package com.woltlab.wcf + * @subpackage data + * @category Community Framework + */ +trait TDatabaseObjectPermissions { + /** + * Returns true if the active user has at least one permission required + * by this object. + * + * @return boolean + */ + public function validatePermissions() { + if ($this->permissions) { + $permissions = explode(',', $this->permissions); + foreach ($permissions as $permission) { + if (WCF::getSession()->getPermission($permission)) { + return true; + } + } + + return false; + } + + return true; + } +} -- 2.20.1