use wcf\data\label\group\LabelGroup;
use wcf\data\label\group\ViewableLabelGroup;
use wcf\data\object\type\ObjectTypeCache;
+use wcf\data\user\User;
use wcf\system\cache\builder\LabelCacheBuilder;
use wcf\system\database\util\PreparedStatementConditionBuilder;
use wcf\system\exception\SystemException;
/**
* Manages labels and label-to-object associations.
*
- * @author Alexander Ebert
+ * @author Alexander Ebert, Joshua Ruesweg
* @copyright 2001-2016 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package WoltLabSuite\Core\System\Label
* Returns an array with view permissions for the labels with the given id.
*
* @param integer[] $labelIDs
+ * @param User $user
* @return array
* @see \wcf\system\label\LabelHandler::getPermissions()
*/
- public function validateCanView(array $labelIDs) {
- return $this->getPermissions('canViewLabel', $labelIDs);
+ public function validateCanView(array $labelIDs, User $user = null) {
+ return $this->getPermissions('canViewLabel', $labelIDs, $user);
}
/**
* Returns an array with use permissions for the labels with the given id.
*
* @param integer[] $labelIDs
+ * @param User $user
* @return array
* @see \wcf\system\label\LabelHandler::getPermissions()
*/
- public function validateCanUse(array $labelIDs) {
- return $this->getPermissions('canUseLabel', $labelIDs);
+ public function validateCanUse(array $labelIDs, User $user = null) {
+ return $this->getPermissions('canUseLabel', $labelIDs, $user);
}
/**
*
* @param string $optionName
* @param integer[] $labelIDs
+ * @param User $user
* @return array
* @throws SystemException
*/
- public function getPermissions($optionName, array $labelIDs) {
+ public function getPermissions($optionName, array $labelIDs, User $user = null) {
if (empty($labelIDs)) {
// nothing to validate anyway
return [];
continue;
}
- if (!$group->hasPermissions() || $group->getPermission($optionID)) {
+ if (!$group->hasPermissions() || $group->getPermission($optionID, $user)) {
$isValid = true;
}
}
* @param boolean $validatePermissions
*/
public function setLabels(array $labelIDs, $objectTypeID, $objectID, $validatePermissions = true) {
- // get accessible label ids to prevent unaccessible ones to be removed
+ // get accessible label ids to prevent inaccessible ones to be removed
$accessibleLabelIDs = $this->getAccessibleLabelIDs();
// delete previous labels