Completed
Push — stable10 ( e55881...b0ab3b )
by Joas
36:13 queued 35:48
created
lib/public/SystemTag/MapperEvent.php 1 patch
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -32,63 +32,63 @@
 block discarded – undo
32 32
  */
33 33
 class MapperEvent extends Event {
34 34
 
35
-	const EVENT_ASSIGN = 'OCP\SystemTag\ISystemTagObjectMapper::assignTags';
36
-	const EVENT_UNASSIGN = 'OCP\SystemTag\ISystemTagObjectMapper::unassignTags';
35
+    const EVENT_ASSIGN = 'OCP\SystemTag\ISystemTagObjectMapper::assignTags';
36
+    const EVENT_UNASSIGN = 'OCP\SystemTag\ISystemTagObjectMapper::unassignTags';
37 37
 
38
-	/** @var string */
39
-	protected $event;
40
-	/** @var string */
41
-	protected $objectType;
42
-	/** @var string */
43
-	protected $objectId;
44
-	/** @var int[] */
45
-	protected $tags;
38
+    /** @var string */
39
+    protected $event;
40
+    /** @var string */
41
+    protected $objectType;
42
+    /** @var string */
43
+    protected $objectId;
44
+    /** @var int[] */
45
+    protected $tags;
46 46
 
47
-	/**
48
-	 * DispatcherEvent constructor.
49
-	 *
50
-	 * @param string $event
51
-	 * @param string $objectType
52
-	 * @param string $objectId
53
-	 * @param int[] $tags
54
-	 * @since 9.0.0
55
-	 */
56
-	public function __construct($event, $objectType, $objectId, array $tags) {
57
-		$this->event = $event;
58
-		$this->objectType = $objectType;
59
-		$this->objectId = $objectId;
60
-		$this->tags = $tags;
61
-	}
47
+    /**
48
+     * DispatcherEvent constructor.
49
+     *
50
+     * @param string $event
51
+     * @param string $objectType
52
+     * @param string $objectId
53
+     * @param int[] $tags
54
+     * @since 9.0.0
55
+     */
56
+    public function __construct($event, $objectType, $objectId, array $tags) {
57
+        $this->event = $event;
58
+        $this->objectType = $objectType;
59
+        $this->objectId = $objectId;
60
+        $this->tags = $tags;
61
+    }
62 62
 
63
-	/**
64
-	 * @return string
65
-	 * @since 9.0.0
66
-	 */
67
-	public function getEvent() {
68
-		return $this->event;
69
-	}
63
+    /**
64
+     * @return string
65
+     * @since 9.0.0
66
+     */
67
+    public function getEvent() {
68
+        return $this->event;
69
+    }
70 70
 
71
-	/**
72
-	 * @return string
73
-	 * @since 9.0.0
74
-	 */
75
-	public function getObjectType() {
76
-		return $this->objectType;
77
-	}
71
+    /**
72
+     * @return string
73
+     * @since 9.0.0
74
+     */
75
+    public function getObjectType() {
76
+        return $this->objectType;
77
+    }
78 78
 
79
-	/**
80
-	 * @return string
81
-	 * @since 9.0.0
82
-	 */
83
-	public function getObjectId() {
84
-		return $this->objectId;
85
-	}
79
+    /**
80
+     * @return string
81
+     * @since 9.0.0
82
+     */
83
+    public function getObjectId() {
84
+        return $this->objectId;
85
+    }
86 86
 
87
-	/**
88
-	 * @return int[]
89
-	 * @since 9.0.0
90
-	 */
91
-	public function getTags() {
92
-		return $this->tags;
93
-	}
87
+    /**
88
+     * @return int[]
89
+     * @since 9.0.0
90
+     */
91
+    public function getTags() {
92
+        return $this->tags;
93
+    }
94 94
 }
Please login to merge, or discard this patch.
lib/public/SystemTag/ManagerEvent.php 1 patch
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -32,55 +32,55 @@
 block discarded – undo
32 32
  */
33 33
 class ManagerEvent extends Event {
34 34
 
35
-	const EVENT_CREATE = 'OCP\SystemTag\ISystemTagManager::createTag';
36
-	const EVENT_UPDATE = 'OCP\SystemTag\ISystemTagManager::updateTag';
37
-	const EVENT_DELETE = 'OCP\SystemTag\ISystemTagManager::deleteTag';
35
+    const EVENT_CREATE = 'OCP\SystemTag\ISystemTagManager::createTag';
36
+    const EVENT_UPDATE = 'OCP\SystemTag\ISystemTagManager::updateTag';
37
+    const EVENT_DELETE = 'OCP\SystemTag\ISystemTagManager::deleteTag';
38 38
 
39
-	/** @var string */
40
-	protected $event;
41
-	/** @var ISystemTag */
42
-	protected $tag;
43
-	/** @var ISystemTag */
44
-	protected $beforeTag;
39
+    /** @var string */
40
+    protected $event;
41
+    /** @var ISystemTag */
42
+    protected $tag;
43
+    /** @var ISystemTag */
44
+    protected $beforeTag;
45 45
 
46
-	/**
47
-	 * DispatcherEvent constructor.
48
-	 *
49
-	 * @param string $event
50
-	 * @param ISystemTag $tag
51
-	 * @param ISystemTag $beforeTag
52
-	 * @since 9.0.0
53
-	 */
54
-	public function __construct($event, ISystemTag $tag, ISystemTag $beforeTag = null) {
55
-		$this->event = $event;
56
-		$this->tag = $tag;
57
-		$this->beforeTag = $beforeTag;
58
-	}
46
+    /**
47
+     * DispatcherEvent constructor.
48
+     *
49
+     * @param string $event
50
+     * @param ISystemTag $tag
51
+     * @param ISystemTag $beforeTag
52
+     * @since 9.0.0
53
+     */
54
+    public function __construct($event, ISystemTag $tag, ISystemTag $beforeTag = null) {
55
+        $this->event = $event;
56
+        $this->tag = $tag;
57
+        $this->beforeTag = $beforeTag;
58
+    }
59 59
 
60
-	/**
61
-	 * @return string
62
-	 * @since 9.0.0
63
-	 */
64
-	public function getEvent() {
65
-		return $this->event;
66
-	}
60
+    /**
61
+     * @return string
62
+     * @since 9.0.0
63
+     */
64
+    public function getEvent() {
65
+        return $this->event;
66
+    }
67 67
 
68
-	/**
69
-	 * @return ISystemTag
70
-	 * @since 9.0.0
71
-	 */
72
-	public function getTag() {
73
-		return $this->tag;
74
-	}
68
+    /**
69
+     * @return ISystemTag
70
+     * @since 9.0.0
71
+     */
72
+    public function getTag() {
73
+        return $this->tag;
74
+    }
75 75
 
76
-	/**
77
-	 * @return ISystemTag
78
-	 * @since 9.0.0
79
-	 */
80
-	public function getTagBefore() {
81
-		if ($this->event !== self::EVENT_UPDATE) {
82
-			throw new \BadMethodCallException('getTagBefore is only available on the update Event');
83
-		}
84
-		return $this->beforeTag;
85
-	}
76
+    /**
77
+     * @return ISystemTag
78
+     * @since 9.0.0
79
+     */
80
+    public function getTagBefore() {
81
+        if ($this->event !== self::EVENT_UPDATE) {
82
+            throw new \BadMethodCallException('getTagBefore is only available on the update Event');
83
+        }
84
+        return $this->beforeTag;
85
+    }
86 86
 }
Please login to merge, or discard this patch.
lib/public/SystemTag/ISystemTagManagerFactory.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -33,28 +33,28 @@
 block discarded – undo
33 33
  */
34 34
 interface ISystemTagManagerFactory {
35 35
 
36
-	/**
37
-	 * Constructor for the system tag manager factory
38
-	 *
39
-	 * @param IServerContainer $serverContainer server container
40
-	 * @since 9.0.0
41
-	 */
42
-	public function __construct(IServerContainer $serverContainer);
36
+    /**
37
+     * Constructor for the system tag manager factory
38
+     *
39
+     * @param IServerContainer $serverContainer server container
40
+     * @since 9.0.0
41
+     */
42
+    public function __construct(IServerContainer $serverContainer);
43 43
 
44
-	/**
45
-	 * creates and returns an instance of the system tag manager
46
-	 *
47
-	 * @return ISystemTagManager
48
-	 * @since 9.0.0
49
-	 */
50
-	public function getManager();
44
+    /**
45
+     * creates and returns an instance of the system tag manager
46
+     *
47
+     * @return ISystemTagManager
48
+     * @since 9.0.0
49
+     */
50
+    public function getManager();
51 51
 
52
-	/**
53
-	 * creates and returns an instance of the system tag object
54
-	 * mapper
55
-	 *
56
-	 * @return ISystemTagObjectMapper
57
-	 * @since 9.0.0
58
-	 */
59
-	public function getObjectMapper();
52
+    /**
53
+     * creates and returns an instance of the system tag object
54
+     * mapper
55
+     *
56
+     * @return ISystemTagObjectMapper
57
+     * @since 9.0.0
58
+     */
59
+    public function getObjectMapper();
60 60
 }
Please login to merge, or discard this patch.
lib/public/SystemTag/ISystemTagObjectMapper.php 1 patch
Indentation   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -30,102 +30,102 @@
 block discarded – undo
30 30
  */
31 31
 interface ISystemTagObjectMapper {
32 32
 
33
-	/**
34
-	 * Get a list of tag ids for the given object ids.
35
-	 *
36
-	 * This returns an array that maps object id to tag ids
37
-	 * [
38
-	 *   1 => array('id1', 'id2'),
39
-	 *   2 => array('id3', 'id2'),
40
-	 *   3 => array('id5'),
41
-	 *   4 => array()
42
-	 * ]
43
-	 *
44
-	 * Untagged objects will have an empty array associated.
45
-	 *
46
-	 * @param string|array $objIds object ids
47
-	 * @param string $objectType object type
48
-	 *
49
-	 * @return array with object id as key and an array
50
-	 * of tag ids as value
51
-	 *
52
-	 * @since 9.0.0
53
-	 */
54
-	public function getTagIdsForObjects($objIds, $objectType);
33
+    /**
34
+     * Get a list of tag ids for the given object ids.
35
+     *
36
+     * This returns an array that maps object id to tag ids
37
+     * [
38
+     *   1 => array('id1', 'id2'),
39
+     *   2 => array('id3', 'id2'),
40
+     *   3 => array('id5'),
41
+     *   4 => array()
42
+     * ]
43
+     *
44
+     * Untagged objects will have an empty array associated.
45
+     *
46
+     * @param string|array $objIds object ids
47
+     * @param string $objectType object type
48
+     *
49
+     * @return array with object id as key and an array
50
+     * of tag ids as value
51
+     *
52
+     * @since 9.0.0
53
+     */
54
+    public function getTagIdsForObjects($objIds, $objectType);
55 55
 
56
-	/**
57
-	 * Get a list of objects tagged with $tagIds.
58
-	 *
59
-	 * @param string|array $tagIds Tag id or array of tag ids.
60
-	 * @param string $objectType object type
61
-	 * @param int $limit Count of object ids you want to get
62
-	 * @param string $offset The last object id you already received
63
-	 *
64
-	 * @return string[] array of object ids or empty array if none found
65
-	 *
66
-	 * @throws \OCP\SystemTag\TagNotFoundException if at least one of the
67
-	 * given tags does not exist
68
-	 * @throws \InvalidArgumentException When a limit is specified together with
69
-	 * multiple tag ids
70
-	 *
71
-	 * @since 9.0.0
72
-	 */
73
-	public function getObjectIdsForTags($tagIds, $objectType, $limit = 0, $offset = '');
56
+    /**
57
+     * Get a list of objects tagged with $tagIds.
58
+     *
59
+     * @param string|array $tagIds Tag id or array of tag ids.
60
+     * @param string $objectType object type
61
+     * @param int $limit Count of object ids you want to get
62
+     * @param string $offset The last object id you already received
63
+     *
64
+     * @return string[] array of object ids or empty array if none found
65
+     *
66
+     * @throws \OCP\SystemTag\TagNotFoundException if at least one of the
67
+     * given tags does not exist
68
+     * @throws \InvalidArgumentException When a limit is specified together with
69
+     * multiple tag ids
70
+     *
71
+     * @since 9.0.0
72
+     */
73
+    public function getObjectIdsForTags($tagIds, $objectType, $limit = 0, $offset = '');
74 74
 
75
-	/**
76
-	 * Assign the given tags to the given object.
77
-	 *
78
-	 * If at least one of the given tag ids doesn't exist, none of the tags
79
-	 * will be assigned.
80
-	 *
81
-	 * If the relationship already existed, fail silently.
82
-	 *
83
-	 * @param string $objId object id
84
-	 * @param string $objectType object type
85
-	 * @param string|array $tagIds tag id or array of tag ids to assign
86
-	 *
87
-	 * @throws \OCP\SystemTag\TagNotFoundException if at least one of the
88
-	 * given tags does not exist
89
-	 *
90
-	 * @since 9.0.0
91
-	 */
92
-	public function assignTags($objId, $objectType, $tagIds);
75
+    /**
76
+     * Assign the given tags to the given object.
77
+     *
78
+     * If at least one of the given tag ids doesn't exist, none of the tags
79
+     * will be assigned.
80
+     *
81
+     * If the relationship already existed, fail silently.
82
+     *
83
+     * @param string $objId object id
84
+     * @param string $objectType object type
85
+     * @param string|array $tagIds tag id or array of tag ids to assign
86
+     *
87
+     * @throws \OCP\SystemTag\TagNotFoundException if at least one of the
88
+     * given tags does not exist
89
+     *
90
+     * @since 9.0.0
91
+     */
92
+    public function assignTags($objId, $objectType, $tagIds);
93 93
 
94
-	/**
95
-	 * Unassign the given tags from the given object.
96
-	 *
97
-	 * If at least one of the given tag ids doesn't exist, none of the tags
98
-	 * will be unassigned.
99
-	 *
100
-	 * If the relationship did not exist in the first place, fail silently.
101
-	 *
102
-	 * @param string $objId object id
103
-	 * @param string $objectType object type
104
-	 * @param string|array $tagIds tag id or array of tag ids to unassign
105
-	 *
106
-	 * @throws \OCP\SystemTag\TagNotFoundException if at least one of the
107
-	 * given tags does not exist
108
-	 *
109
-	 * @since 9.0.0
110
-	 */
111
-	public function unassignTags($objId, $objectType, $tagIds);
94
+    /**
95
+     * Unassign the given tags from the given object.
96
+     *
97
+     * If at least one of the given tag ids doesn't exist, none of the tags
98
+     * will be unassigned.
99
+     *
100
+     * If the relationship did not exist in the first place, fail silently.
101
+     *
102
+     * @param string $objId object id
103
+     * @param string $objectType object type
104
+     * @param string|array $tagIds tag id or array of tag ids to unassign
105
+     *
106
+     * @throws \OCP\SystemTag\TagNotFoundException if at least one of the
107
+     * given tags does not exist
108
+     *
109
+     * @since 9.0.0
110
+     */
111
+    public function unassignTags($objId, $objectType, $tagIds);
112 112
 
113
-	/**
114
-	 * Checks whether the given objects have the given tag.
115
-	 *
116
-	 * @param string|array $objIds object ids
117
-	 * @param string $objectType object type
118
-	 * @param string $tagId tag id to check
119
-	 * @param bool $all true to check that ALL objects have the tag assigned,
120
-	 * false to check that at least ONE object has the tag.
121
-	 *
122
-	 * @return bool true if the condition set by $all is matched, false
123
-	 * otherwise
124
-	 *
125
-	 * @throws \OCP\SystemTag\TagNotFoundException if the tag does not exist
126
-	 *
127
-	 * @since 9.0.0
128
-	 */
129
-	public function haveTag($objIds, $objectType, $tagId, $all = true);
113
+    /**
114
+     * Checks whether the given objects have the given tag.
115
+     *
116
+     * @param string|array $objIds object ids
117
+     * @param string $objectType object type
118
+     * @param string $tagId tag id to check
119
+     * @param bool $all true to check that ALL objects have the tag assigned,
120
+     * false to check that at least ONE object has the tag.
121
+     *
122
+     * @return bool true if the condition set by $all is matched, false
123
+     * otherwise
124
+     *
125
+     * @throws \OCP\SystemTag\TagNotFoundException if the tag does not exist
126
+     *
127
+     * @since 9.0.0
128
+     */
129
+    public function haveTag($objIds, $objectType, $tagId, $all = true);
130 130
 
131 131
 }
Please login to merge, or discard this patch.
lib/public/SystemTag/SystemTagsEntityEvent.php 1 patch
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -32,46 +32,46 @@
 block discarded – undo
32 32
  */
33 33
 class SystemTagsEntityEvent extends Event {
34 34
 
35
-	const EVENT_ENTITY = 'OCP\SystemTag\ISystemTagManager::registerEntity';
35
+    const EVENT_ENTITY = 'OCP\SystemTag\ISystemTagManager::registerEntity';
36 36
 
37
-	/** @var string */
38
-	protected $event;
39
-	/** @var \Closure[] */
40
-	protected $collections;
37
+    /** @var string */
38
+    protected $event;
39
+    /** @var \Closure[] */
40
+    protected $collections;
41 41
 
42
-	/**
43
-	 * SystemTagsEntityEvent constructor.
44
-	 *
45
-	 * @param string $event
46
-	 * @since 9.1.0
47
-	 */
48
-	public function __construct($event) {
49
-		$this->event = $event;
50
-		$this->collections = [];
51
-	}
42
+    /**
43
+     * SystemTagsEntityEvent constructor.
44
+     *
45
+     * @param string $event
46
+     * @since 9.1.0
47
+     */
48
+    public function __construct($event) {
49
+        $this->event = $event;
50
+        $this->collections = [];
51
+    }
52 52
 
53
-	/**
54
-	 * @param string $name
55
-	 * @param \Closure $entityExistsFunction The closure should take one
56
-	 *                 argument, which is the id of the entity, that tags
57
-	 *                 should be handled for. The return should then be bool,
58
-	 *                 depending on whether tags are allowed (true) or not.
59
-	 * @throws \OutOfBoundsException when the entity name is already taken
60
-	 * @since 9.1.0
61
-	 */
62
-	public function addEntityCollection($name, \Closure $entityExistsFunction) {
63
-		if (isset($this->collections[$name])) {
64
-			throw new \OutOfBoundsException('Duplicate entity name "' . $name . '"');
65
-		}
53
+    /**
54
+     * @param string $name
55
+     * @param \Closure $entityExistsFunction The closure should take one
56
+     *                 argument, which is the id of the entity, that tags
57
+     *                 should be handled for. The return should then be bool,
58
+     *                 depending on whether tags are allowed (true) or not.
59
+     * @throws \OutOfBoundsException when the entity name is already taken
60
+     * @since 9.1.0
61
+     */
62
+    public function addEntityCollection($name, \Closure $entityExistsFunction) {
63
+        if (isset($this->collections[$name])) {
64
+            throw new \OutOfBoundsException('Duplicate entity name "' . $name . '"');
65
+        }
66 66
 
67
-		$this->collections[$name] = $entityExistsFunction;
68
-	}
67
+        $this->collections[$name] = $entityExistsFunction;
68
+    }
69 69
 
70
-	/**
71
-	 * @return \Closure[]
72
-	 * @since 9.1.0
73
-	 */
74
-	public function getEntityCollections() {
75
-		return $this->collections;
76
-	}
70
+    /**
71
+     * @return \Closure[]
72
+     * @since 9.1.0
73
+     */
74
+    public function getEntityCollections() {
75
+        return $this->collections;
76
+    }
77 77
 }
Please login to merge, or discard this patch.
lib/public/SystemTag/ISystemTagManager.php 1 patch
Indentation   +120 added lines, -120 removed lines patch added patch discarded remove patch
@@ -33,133 +33,133 @@
 block discarded – undo
33 33
  */
34 34
 interface ISystemTagManager {
35 35
 
36
-	/**
37
-	 * Returns the tag objects matching the given tag ids.
38
-	 *
39
-	 * @param array|string $tagIds id or array of unique ids of the tag to retrieve
40
-	 *
41
-	 * @return \OCP\SystemTag\ISystemTag[] array of system tags with tag id as key
42
-	 *
43
-	 * @throws \InvalidArgumentException if at least one given tag ids is invalid (string instead of integer, etc.)
44
-	 * @throws \OCP\SystemTag\TagNotFoundException if at least one given tag ids did no exist
45
-	 * 			The message contains a json_encoded array of the ids that could not be found
46
-	 *
47
-	 * @since 9.0.0
48
-	 */
49
-	public function getTagsByIds($tagIds);
36
+    /**
37
+     * Returns the tag objects matching the given tag ids.
38
+     *
39
+     * @param array|string $tagIds id or array of unique ids of the tag to retrieve
40
+     *
41
+     * @return \OCP\SystemTag\ISystemTag[] array of system tags with tag id as key
42
+     *
43
+     * @throws \InvalidArgumentException if at least one given tag ids is invalid (string instead of integer, etc.)
44
+     * @throws \OCP\SystemTag\TagNotFoundException if at least one given tag ids did no exist
45
+     * 			The message contains a json_encoded array of the ids that could not be found
46
+     *
47
+     * @since 9.0.0
48
+     */
49
+    public function getTagsByIds($tagIds);
50 50
 
51
-	/**
52
-	 * Returns the tag object matching the given attributes.
53
-	 *
54
-	 * @param string $tagName tag name
55
-	 * @param bool $userVisible whether the tag is visible by users
56
-	 * @param bool $userAssignable whether the tag is assignable by users
57
-	 *
58
-	 * @return \OCP\SystemTag\ISystemTag system tag
59
-	 *
60
-	 * @throws \OCP\SystemTag\TagNotFoundException if tag does not exist
61
-	 *
62
-	 * @since 9.0.0
63
-	 */
64
-	public function getTag($tagName, $userVisible, $userAssignable);
51
+    /**
52
+     * Returns the tag object matching the given attributes.
53
+     *
54
+     * @param string $tagName tag name
55
+     * @param bool $userVisible whether the tag is visible by users
56
+     * @param bool $userAssignable whether the tag is assignable by users
57
+     *
58
+     * @return \OCP\SystemTag\ISystemTag system tag
59
+     *
60
+     * @throws \OCP\SystemTag\TagNotFoundException if tag does not exist
61
+     *
62
+     * @since 9.0.0
63
+     */
64
+    public function getTag($tagName, $userVisible, $userAssignable);
65 65
 
66
-	/**
67
-	 * Creates the tag object using the given attributes.
68
-	 *
69
-	 * @param string $tagName tag name
70
-	 * @param bool $userVisible whether the tag is visible by users
71
-	 * @param bool $userAssignable whether the tag is assignable by users
72
-	 *
73
-	 * @return \OCP\SystemTag\ISystemTag system tag
74
-	 *
75
-	 * @throws \OCP\SystemTag\TagAlreadyExistsException if tag already exists
76
-	 *
77
-	 * @since 9.0.0
78
-	 */
79
-	public function createTag($tagName, $userVisible, $userAssignable);
66
+    /**
67
+     * Creates the tag object using the given attributes.
68
+     *
69
+     * @param string $tagName tag name
70
+     * @param bool $userVisible whether the tag is visible by users
71
+     * @param bool $userAssignable whether the tag is assignable by users
72
+     *
73
+     * @return \OCP\SystemTag\ISystemTag system tag
74
+     *
75
+     * @throws \OCP\SystemTag\TagAlreadyExistsException if tag already exists
76
+     *
77
+     * @since 9.0.0
78
+     */
79
+    public function createTag($tagName, $userVisible, $userAssignable);
80 80
 
81
-	/**
82
-	 * Returns all known tags, optionally filtered by visibility.
83
-	 *
84
-	 * @param bool|null $visibilityFilter filter by visibility if non-null
85
-	 * @param string $nameSearchPattern optional search pattern for the tag name
86
-	 *
87
-	 * @return \OCP\SystemTag\ISystemTag[] array of system tags or empty array if none found
88
-	 *
89
-	 * @since 9.0.0
90
-	 */
91
-	public function getAllTags($visibilityFilter = null, $nameSearchPattern = null);
81
+    /**
82
+     * Returns all known tags, optionally filtered by visibility.
83
+     *
84
+     * @param bool|null $visibilityFilter filter by visibility if non-null
85
+     * @param string $nameSearchPattern optional search pattern for the tag name
86
+     *
87
+     * @return \OCP\SystemTag\ISystemTag[] array of system tags or empty array if none found
88
+     *
89
+     * @since 9.0.0
90
+     */
91
+    public function getAllTags($visibilityFilter = null, $nameSearchPattern = null);
92 92
 
93
-	/**
94
-	 * Updates the given tag
95
-	 *
96
-	 * @param string $tagId tag id
97
-	 * @param string $newName the new tag name
98
-	 * @param bool $userVisible whether the tag is visible by users
99
-	 * @param bool $userAssignable whether the tag is assignable by users
100
-	 *
101
-	 * @throws \OCP\SystemTag\TagNotFoundException if tag with the given id does not exist
102
-	 * @throws \OCP\SystemTag\TagAlreadyExistsException if there is already another tag
103
-	 * with the same attributes
104
-	 *
105
-	 * @since 9.0.0
106
-	 */
107
-	public function updateTag($tagId, $newName, $userVisible, $userAssignable);
93
+    /**
94
+     * Updates the given tag
95
+     *
96
+     * @param string $tagId tag id
97
+     * @param string $newName the new tag name
98
+     * @param bool $userVisible whether the tag is visible by users
99
+     * @param bool $userAssignable whether the tag is assignable by users
100
+     *
101
+     * @throws \OCP\SystemTag\TagNotFoundException if tag with the given id does not exist
102
+     * @throws \OCP\SystemTag\TagAlreadyExistsException if there is already another tag
103
+     * with the same attributes
104
+     *
105
+     * @since 9.0.0
106
+     */
107
+    public function updateTag($tagId, $newName, $userVisible, $userAssignable);
108 108
 
109
-	/**
110
-	 * Delete the given tags from the database and all their relationships.
111
-	 *
112
-	 * @param string|array $tagIds array of tag ids
113
-	 *
114
-	 * @throws \OCP\SystemTag\TagNotFoundException if at least one tag did not exist
115
-	 *
116
-	 * @since 9.0.0
117
-	 */
118
-	public function deleteTags($tagIds);
109
+    /**
110
+     * Delete the given tags from the database and all their relationships.
111
+     *
112
+     * @param string|array $tagIds array of tag ids
113
+     *
114
+     * @throws \OCP\SystemTag\TagNotFoundException if at least one tag did not exist
115
+     *
116
+     * @since 9.0.0
117
+     */
118
+    public function deleteTags($tagIds);
119 119
 
120
-	/**
121
-	 * Checks whether the given user is allowed to assign/unassign the tag with the
122
-	 * given id.
123
-	 *
124
-	 * @param ISystemTag $tag tag to check permission for
125
-	 * @param IUser $user user to check permission for
126
-	 *
127
-	 * @return true if the user is allowed to assign/unassign the tag, false otherwise
128
-	 *
129
-	 * @since 9.1.0
130
-	 */
131
-	public function canUserAssignTag(ISystemTag $tag, IUser $user);
120
+    /**
121
+     * Checks whether the given user is allowed to assign/unassign the tag with the
122
+     * given id.
123
+     *
124
+     * @param ISystemTag $tag tag to check permission for
125
+     * @param IUser $user user to check permission for
126
+     *
127
+     * @return true if the user is allowed to assign/unassign the tag, false otherwise
128
+     *
129
+     * @since 9.1.0
130
+     */
131
+    public function canUserAssignTag(ISystemTag $tag, IUser $user);
132 132
 
133
-	/**
134
-	 * Checks whether the given user is allowed to see the tag with the given id.
135
-	 *
136
-	 * @param ISystemTag $tag tag to check permission for
137
-	 * @param IUser $user user to check permission for
138
-	 *
139
-	 * @return true if the user can see the tag, false otherwise
140
-	 *
141
-	 * @since 9.1.0
142
-	 */
143
-	public function canUserSeeTag(ISystemTag $tag, IUser $userId);
133
+    /**
134
+     * Checks whether the given user is allowed to see the tag with the given id.
135
+     *
136
+     * @param ISystemTag $tag tag to check permission for
137
+     * @param IUser $user user to check permission for
138
+     *
139
+     * @return true if the user can see the tag, false otherwise
140
+     *
141
+     * @since 9.1.0
142
+     */
143
+    public function canUserSeeTag(ISystemTag $tag, IUser $userId);
144 144
 
145
-	/**
146
-	 * Set groups that can assign a given tag.
147
-	 *
148
-	 * @param ISystemTag $tag tag for group assignment
149
-	 * @param string[] $groupIds group ids of groups that can assign/unassign the tag
150
-	 *
151
-	 * @since 9.1.0
152
-	 */
153
-	public function setTagGroups(ISystemTag $tag, $groupIds);
145
+    /**
146
+     * Set groups that can assign a given tag.
147
+     *
148
+     * @param ISystemTag $tag tag for group assignment
149
+     * @param string[] $groupIds group ids of groups that can assign/unassign the tag
150
+     *
151
+     * @since 9.1.0
152
+     */
153
+    public function setTagGroups(ISystemTag $tag, $groupIds);
154 154
 
155
-	/**
156
-	 * Get groups that can assign a given tag.
157
-	 *
158
-	 * @param ISystemTag $tag tag for group assignment
159
-	 *
160
-	 * @return string[] group ids of groups that can assign/unassign the tag
161
-	 *
162
-	 * @since 9.1.0
163
-	 */
164
-	public function getTagGroups(ISystemTag $tag);
155
+    /**
156
+     * Get groups that can assign a given tag.
157
+     *
158
+     * @param ISystemTag $tag tag for group assignment
159
+     *
160
+     * @return string[] group ids of groups that can assign/unassign the tag
161
+     *
162
+     * @since 9.1.0
163
+     */
164
+    public function getTagGroups(ISystemTag $tag);
165 165
 }
Please login to merge, or discard this patch.
lib/private/RedisFactory.php 1 patch
Indentation   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -23,64 +23,64 @@
 block discarded – undo
23 23
 namespace OC;
24 24
 
25 25
 class RedisFactory {
26
-	/** @var  \Redis */
27
-	private $instance;
26
+    /** @var  \Redis */
27
+    private $instance;
28 28
 
29
-	/** @var  SystemConfig */
30
-	private $config;
29
+    /** @var  SystemConfig */
30
+    private $config;
31 31
 
32
-	/**
33
-	 * RedisFactory constructor.
34
-	 *
35
-	 * @param SystemConfig $config
36
-	 */
37
-	public function __construct(SystemConfig $config) {
38
-		$this->config = $config;
39
-	}
32
+    /**
33
+     * RedisFactory constructor.
34
+     *
35
+     * @param SystemConfig $config
36
+     */
37
+    public function __construct(SystemConfig $config) {
38
+        $this->config = $config;
39
+    }
40 40
 
41
-	private function create() {
42
-		$this->instance = new \Redis();
43
-		// TODO allow configuring a RedisArray, see https://github.com/nicolasff/phpredis/blob/master/arrays.markdown#redis-arrays
44
-		$config = $this->config->getValue('redis', array());
45
-		if (isset($config['host'])) {
46
-			$host = $config['host'];
47
-		} else {
48
-			$host = '127.0.0.1';
49
-		}
50
-		if (isset($config['port'])) {
51
-			$port = $config['port'];
52
-		} else {
53
-			$port = 6379;
54
-		}
55
-		if (isset($config['timeout'])) {
56
-			$timeout = $config['timeout'];
57
-		} else {
58
-			$timeout = 0.0; // unlimited
59
-		}
41
+    private function create() {
42
+        $this->instance = new \Redis();
43
+        // TODO allow configuring a RedisArray, see https://github.com/nicolasff/phpredis/blob/master/arrays.markdown#redis-arrays
44
+        $config = $this->config->getValue('redis', array());
45
+        if (isset($config['host'])) {
46
+            $host = $config['host'];
47
+        } else {
48
+            $host = '127.0.0.1';
49
+        }
50
+        if (isset($config['port'])) {
51
+            $port = $config['port'];
52
+        } else {
53
+            $port = 6379;
54
+        }
55
+        if (isset($config['timeout'])) {
56
+            $timeout = $config['timeout'];
57
+        } else {
58
+            $timeout = 0.0; // unlimited
59
+        }
60 60
 
61
-		$this->instance->connect($host, $port, $timeout);
62
-		if (isset($config['password']) && $config['password'] !== '') {
63
-			$this->instance->auth($config['password']);
64
-		}
61
+        $this->instance->connect($host, $port, $timeout);
62
+        if (isset($config['password']) && $config['password'] !== '') {
63
+            $this->instance->auth($config['password']);
64
+        }
65 65
 
66
-		if (isset($config['dbindex'])) {
67
-			$this->instance->select($config['dbindex']);
68
-		}
69
-	}
66
+        if (isset($config['dbindex'])) {
67
+            $this->instance->select($config['dbindex']);
68
+        }
69
+    }
70 70
 
71
-	public function getInstance() {
72
-		if (!$this->isAvailable()) {
73
-			throw new \Exception('Redis support is not available');
74
-		}
75
-		if (!$this->instance instanceof \Redis) {
76
-			$this->create();
77
-		}
71
+    public function getInstance() {
72
+        if (!$this->isAvailable()) {
73
+            throw new \Exception('Redis support is not available');
74
+        }
75
+        if (!$this->instance instanceof \Redis) {
76
+            $this->create();
77
+        }
78 78
 
79
-		return $this->instance;
80
-	}
79
+        return $this->instance;
80
+    }
81 81
 
82
-	public function isAvailable() {
83
-		return extension_loaded('redis')
84
-		&& version_compare(phpversion('redis'), '2.2.5', '>=');
85
-	}
82
+    public function isAvailable() {
83
+        return extension_loaded('redis')
84
+        && version_compare(phpversion('redis'), '2.2.5', '>=');
85
+    }
86 86
 }
Please login to merge, or discard this patch.
lib/private/Tags.php 1 patch
Indentation   +757 added lines, -757 removed lines patch added patch discarded remove patch
@@ -48,761 +48,761 @@
 block discarded – undo
48 48
 
49 49
 class Tags implements \OCP\ITags {
50 50
 
51
-	/**
52
-	 * Tags
53
-	 *
54
-	 * @var array
55
-	 */
56
-	private $tags = array();
57
-
58
-	/**
59
-	 * Used for storing objectid/categoryname pairs while rescanning.
60
-	 *
61
-	 * @var array
62
-	 */
63
-	private static $relations = array();
64
-
65
-	/**
66
-	 * Type
67
-	 *
68
-	 * @var string
69
-	 */
70
-	private $type;
71
-
72
-	/**
73
-	 * User
74
-	 *
75
-	 * @var string
76
-	 */
77
-	private $user;
78
-
79
-	/**
80
-	 * Are we including tags for shared items?
81
-	 *
82
-	 * @var bool
83
-	 */
84
-	private $includeShared = false;
85
-
86
-	/**
87
-	 * The current user, plus any owners of the items shared with the current
88
-	 * user, if $this->includeShared === true.
89
-	 *
90
-	 * @var array
91
-	 */
92
-	private $owners = array();
93
-
94
-	/**
95
-	 * The Mapper we're using to communicate our Tag objects to the database.
96
-	 *
97
-	 * @var TagMapper
98
-	 */
99
-	private $mapper;
100
-
101
-	/**
102
-	 * The sharing backend for objects of $this->type. Required if
103
-	 * $this->includeShared === true to determine ownership of items.
104
-	 *
105
-	 * @var \OCP\Share_Backend
106
-	 */
107
-	private $backend;
108
-
109
-	const TAG_TABLE = '*PREFIX*vcategory';
110
-	const RELATION_TABLE = '*PREFIX*vcategory_to_object';
111
-
112
-	const TAG_FAVORITE = '_$!<Favorite>!$_';
113
-
114
-	/**
115
-	* Constructor.
116
-	*
117
-	* @param TagMapper $mapper Instance of the TagMapper abstraction layer.
118
-	* @param string $user The user whose data the object will operate on.
119
-	* @param string $type The type of items for which tags will be loaded.
120
-	* @param array $defaultTags Tags that should be created at construction.
121
-	* @param boolean $includeShared Whether to include tags for items shared with this user by others.
122
-	*/
123
-	public function __construct(TagMapper $mapper, $user, $type, $defaultTags = array(), $includeShared = false) {
124
-		$this->mapper = $mapper;
125
-		$this->user = $user;
126
-		$this->type = $type;
127
-		$this->includeShared = $includeShared;
128
-		$this->owners = array($this->user);
129
-		if ($this->includeShared) {
130
-			$this->owners = array_merge($this->owners, \OC\Share\Share::getSharedItemsOwners($this->user, $this->type, true));
131
-			$this->backend = \OC\Share\Share::getBackend($this->type);
132
-		}
133
-		$this->tags = $this->mapper->loadTags($this->owners, $this->type);
134
-
135
-		if(count($defaultTags) > 0 && count($this->tags) === 0) {
136
-			$this->addMultiple($defaultTags, true);
137
-		}
138
-	}
139
-
140
-	/**
141
-	* Check if any tags are saved for this type and user.
142
-	*
143
-	* @return boolean.
144
-	*/
145
-	public function isEmpty() {
146
-		return count($this->tags) === 0;
147
-	}
148
-
149
-	/**
150
-	* Returns an array mapping a given tag's properties to its values:
151
-	* ['id' => 0, 'name' = 'Tag', 'owner' = 'User', 'type' => 'tagtype']
152
-	*
153
-	* @param string $id The ID of the tag that is going to be mapped
154
-	* @return array|false
155
-	*/
156
-	public function getTag($id) {
157
-		$key = $this->getTagById($id);
158
-		if ($key !== false) {
159
-			return $this->tagMap($this->tags[$key]);
160
-		}
161
-		return false;
162
-	}
163
-
164
-	/**
165
-	* Get the tags for a specific user.
166
-	*
167
-	* This returns an array with maps containing each tag's properties:
168
-	* [
169
-	* 	['id' => 0, 'name' = 'First tag', 'owner' = 'User', 'type' => 'tagtype'],
170
-	* 	['id' => 1, 'name' = 'Shared tag', 'owner' = 'Other user', 'type' => 'tagtype'],
171
-	* ]
172
-	*
173
-	* @return array
174
-	*/
175
-	public function getTags() {
176
-		if(!count($this->tags)) {
177
-			return array();
178
-		}
179
-
180
-		usort($this->tags, function($a, $b) {
181
-			return strnatcasecmp($a->getName(), $b->getName());
182
-		});
183
-		$tagMap = array();
184
-
185
-		foreach($this->tags as $tag) {
186
-			if($tag->getName() !== self::TAG_FAVORITE) {
187
-				$tagMap[] = $this->tagMap($tag);
188
-			}
189
-		}
190
-		return $tagMap;
191
-
192
-	}
193
-
194
-	/**
195
-	* Return only the tags owned by the given user, omitting any tags shared
196
-	* by other users.
197
-	*
198
-	* @param string $user The user whose tags are to be checked.
199
-	* @return array An array of Tag objects.
200
-	*/
201
-	public function getTagsForUser($user) {
202
-		return array_filter($this->tags,
203
-			function($tag) use($user) {
204
-				return $tag->getOwner() === $user;
205
-			}
206
-		);
207
-	}
208
-
209
-	/**
210
-	 * Get the list of tags for the given ids.
211
-	 *
212
-	 * @param array $objIds array of object ids
213
-	 * @return array|boolean of tags id as key to array of tag names
214
-	 * or false if an error occurred
215
-	 */
216
-	public function getTagsForObjects(array $objIds) {
217
-		$entries = array();
218
-
219
-		try {
220
-			$conn = \OC::$server->getDatabaseConnection();
221
-			$chunks = array_chunk($objIds, 900, false);
222
-			foreach ($chunks as $chunk) {
223
-				$result = $conn->executeQuery(
224
-					'SELECT `category`, `categoryid`, `objid` ' .
225
-					'FROM `' . self::RELATION_TABLE . '` r, `' . self::TAG_TABLE . '` ' .
226
-					'WHERE `categoryid` = `id` AND `uid` = ? AND r.`type` = ? AND `objid` IN (?)',
227
-					array($this->user, $this->type, $chunk),
228
-					array(null, null, IQueryBuilder::PARAM_INT_ARRAY)
229
-				);
230
-				while ($row = $result->fetch()) {
231
-					$objId = (int)$row['objid'];
232
-					if (!isset($entries[$objId])) {
233
-						$entries[$objId] = array();
234
-					}
235
-					$entries[$objId][] = $row['category'];
236
-				}
237
-				if (\OCP\DB::isError($result)) {
238
-					\OCP\Util::writeLog('core', __METHOD__. 'DB error: ' . \OCP\DB::getErrorMessage(), \OCP\Util::ERROR);
239
-					return false;
240
-				}
241
-			}
242
-		} catch(\Exception $e) {
243
-			\OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(),
244
-				\OCP\Util::ERROR);
245
-			return false;
246
-		}
247
-
248
-		return $entries;
249
-	}
250
-
251
-	/**
252
-	* Get the a list if items tagged with $tag.
253
-	*
254
-	* Throws an exception if the tag could not be found.
255
-	*
256
-	* @param string $tag Tag id or name.
257
-	* @return array|false An array of object ids or false on error.
258
-	* @throws \Exception
259
-	*/
260
-	public function getIdsForTag($tag) {
261
-		$result = null;
262
-		$tagId = false;
263
-		if(is_numeric($tag)) {
264
-			$tagId = $tag;
265
-		} elseif(is_string($tag)) {
266
-			$tag = trim($tag);
267
-			if($tag === '') {
268
-				\OCP\Util::writeLog('core', __METHOD__.', Cannot use empty tag names', \OCP\Util::DEBUG);
269
-				return false;
270
-			}
271
-			$tagId = $this->getTagId($tag);
272
-		}
273
-
274
-		if($tagId === false) {
275
-			$l10n = \OC::$server->getL10N('core');
276
-			throw new \Exception(
277
-				$l10n->t('Could not find category "%s"', $tag)
278
-			);
279
-		}
280
-
281
-		$ids = array();
282
-		$sql = 'SELECT `objid` FROM `' . self::RELATION_TABLE
283
-			. '` WHERE `categoryid` = ?';
284
-
285
-		try {
286
-			$stmt = \OCP\DB::prepare($sql);
287
-			$result = $stmt->execute(array($tagId));
288
-			if (\OCP\DB::isError($result)) {
289
-				\OCP\Util::writeLog('core', __METHOD__. 'DB error: ' . \OCP\DB::getErrorMessage(), \OCP\Util::ERROR);
290
-				return false;
291
-			}
292
-		} catch(\Exception $e) {
293
-			\OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(),
294
-				\OCP\Util::ERROR);
295
-			return false;
296
-		}
297
-
298
-		if(!is_null($result)) {
299
-			while( $row = $result->fetchRow()) {
300
-				$id = (int)$row['objid'];
301
-
302
-				if ($this->includeShared) {
303
-					// We have to check if we are really allowed to access the
304
-					// items that are tagged with $tag. To that end, we ask the
305
-					// corresponding sharing backend if the item identified by $id
306
-					// is owned by any of $this->owners.
307
-					foreach ($this->owners as $owner) {
308
-						if ($this->backend->isValidSource($id, $owner)) {
309
-							$ids[] = $id;
310
-							break;
311
-						}
312
-					}
313
-				} else {
314
-					$ids[] = $id;
315
-				}
316
-			}
317
-		}
318
-
319
-		return $ids;
320
-	}
321
-
322
-	/**
323
-	* Checks whether a tag is saved for the given user,
324
-	* disregarding the ones shared with him or her.
325
-	*
326
-	* @param string $name The tag name to check for.
327
-	* @param string $user The user whose tags are to be checked.
328
-	* @return bool
329
-	*/
330
-	public function userHasTag($name, $user) {
331
-		$key = $this->array_searchi($name, $this->getTagsForUser($user));
332
-		return ($key !== false) ? $this->tags[$key]->getId() : false;
333
-	}
334
-
335
-	/**
336
-	* Checks whether a tag is saved for or shared with the current user.
337
-	*
338
-	* @param string $name The tag name to check for.
339
-	* @return bool
340
-	*/
341
-	public function hasTag($name) {
342
-		return $this->getTagId($name) !== false;
343
-	}
344
-
345
-	/**
346
-	* Add a new tag.
347
-	*
348
-	* @param string $name A string with a name of the tag
349
-	* @return false|int the id of the added tag or false on error.
350
-	*/
351
-	public function add($name) {
352
-		$name = trim($name);
353
-
354
-		if($name === '') {
355
-			\OCP\Util::writeLog('core', __METHOD__.', Cannot add an empty tag', \OCP\Util::DEBUG);
356
-			return false;
357
-		}
358
-		if($this->userHasTag($name, $this->user)) {
359
-			\OCP\Util::writeLog('core', __METHOD__.', name: ' . $name. ' exists already', \OCP\Util::DEBUG);
360
-			return false;
361
-		}
362
-		try {
363
-			$tag = new Tag($this->user, $this->type, $name);
364
-			$tag = $this->mapper->insert($tag);
365
-			$this->tags[] = $tag;
366
-		} catch(\Exception $e) {
367
-			\OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(),
368
-				\OCP\Util::ERROR);
369
-			return false;
370
-		}
371
-		\OCP\Util::writeLog('core', __METHOD__.', id: ' . $tag->getId(), \OCP\Util::DEBUG);
372
-		return $tag->getId();
373
-	}
374
-
375
-	/**
376
-	* Rename tag.
377
-	*
378
-	* @param string|integer $from The name or ID of the existing tag
379
-	* @param string $to The new name of the tag.
380
-	* @return bool
381
-	*/
382
-	public function rename($from, $to) {
383
-		$from = trim($from);
384
-		$to = trim($to);
385
-
386
-		if($to === '' || $from === '') {
387
-			\OCP\Util::writeLog('core', __METHOD__.', Cannot use empty tag names', \OCP\Util::DEBUG);
388
-			return false;
389
-		}
390
-
391
-		if (is_numeric($from)) {
392
-			$key = $this->getTagById($from);
393
-		} else {
394
-			$key = $this->getTagByName($from);
395
-		}
396
-		if($key === false) {
397
-			\OCP\Util::writeLog('core', __METHOD__.', tag: ' . $from. ' does not exist', \OCP\Util::DEBUG);
398
-			return false;
399
-		}
400
-		$tag = $this->tags[$key];
401
-
402
-		if($this->userHasTag($to, $tag->getOwner())) {
403
-			\OCP\Util::writeLog('core', __METHOD__.', A tag named ' . $to. ' already exists for user ' . $tag->getOwner() . '.', \OCP\Util::DEBUG);
404
-			return false;
405
-		}
406
-
407
-		try {
408
-			$tag->setName($to);
409
-			$this->tags[$key] = $this->mapper->update($tag);
410
-		} catch(\Exception $e) {
411
-			\OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(),
412
-				\OCP\Util::ERROR);
413
-			return false;
414
-		}
415
-		return true;
416
-	}
417
-
418
-	/**
419
-	* Add a list of new tags.
420
-	*
421
-	* @param string[] $names A string with a name or an array of strings containing
422
-	* the name(s) of the tag(s) to add.
423
-	* @param bool $sync When true, save the tags
424
-	* @param int|null $id int Optional object id to add to this|these tag(s)
425
-	* @return bool Returns false on error.
426
-	*/
427
-	public function addMultiple($names, $sync=false, $id = null) {
428
-		if(!is_array($names)) {
429
-			$names = array($names);
430
-		}
431
-		$names = array_map('trim', $names);
432
-		array_filter($names);
433
-
434
-		$newones = array();
435
-		foreach($names as $name) {
436
-			if(!$this->hasTag($name) && $name !== '') {
437
-				$newones[] = new Tag($this->user, $this->type, $name);
438
-			}
439
-			if(!is_null($id) ) {
440
-				// Insert $objectid, $categoryid  pairs if not exist.
441
-				self::$relations[] = array('objid' => $id, 'tag' => $name);
442
-			}
443
-		}
444
-		$this->tags = array_merge($this->tags, $newones);
445
-		if($sync === true) {
446
-			$this->save();
447
-		}
448
-
449
-		return true;
450
-	}
451
-
452
-	/**
453
-	 * Save the list of tags and their object relations
454
-	 */
455
-	protected function save() {
456
-		if(is_array($this->tags)) {
457
-			foreach($this->tags as $tag) {
458
-				try {
459
-					if (!$this->mapper->tagExists($tag)) {
460
-						$this->mapper->insert($tag);
461
-					}
462
-				} catch(\Exception $e) {
463
-					\OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(),
464
-						\OCP\Util::ERROR);
465
-				}
466
-			}
467
-
468
-			// reload tags to get the proper ids.
469
-			$this->tags = $this->mapper->loadTags($this->owners, $this->type);
470
-			\OCP\Util::writeLog('core', __METHOD__.', tags: ' . print_r($this->tags, true),
471
-				\OCP\Util::DEBUG);
472
-			// Loop through temporarily cached objectid/tagname pairs
473
-			// and save relations.
474
-			$tags = $this->tags;
475
-			// For some reason this is needed or array_search(i) will return 0..?
476
-			ksort($tags);
477
-			foreach(self::$relations as $relation) {
478
-				$tagId = $this->getTagId($relation['tag']);
479
-				\OCP\Util::writeLog('core', __METHOD__ . 'catid, ' . $relation['tag'] . ' ' . $tagId, \OCP\Util::DEBUG);
480
-				if($tagId) {
481
-					try {
482
-						\OCP\DB::insertIfNotExist(self::RELATION_TABLE,
483
-							array(
484
-								'objid' => $relation['objid'],
485
-								'categoryid' => $tagId,
486
-								'type' => $this->type,
487
-								));
488
-					} catch(\Exception $e) {
489
-						\OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(),
490
-							\OCP\Util::ERROR);
491
-					}
492
-				}
493
-			}
494
-			self::$relations = array(); // reset
495
-		} else {
496
-			\OCP\Util::writeLog('core', __METHOD__.', $this->tags is not an array! '
497
-				. print_r($this->tags, true), \OCP\Util::ERROR);
498
-		}
499
-	}
500
-
501
-	/**
502
-	* Delete tags and tag/object relations for a user.
503
-	*
504
-	* For hooking up on post_deleteUser
505
-	*
506
-	* @param array $arguments
507
-	*/
508
-	public static function post_deleteUser($arguments) {
509
-		// Find all objectid/tagId pairs.
510
-		$result = null;
511
-		try {
512
-			$stmt = \OCP\DB::prepare('SELECT `id` FROM `' . self::TAG_TABLE . '` '
513
-				. 'WHERE `uid` = ?');
514
-			$result = $stmt->execute(array($arguments['uid']));
515
-			if (\OCP\DB::isError($result)) {
516
-				\OCP\Util::writeLog('core', __METHOD__. 'DB error: ' . \OCP\DB::getErrorMessage(), \OCP\Util::ERROR);
517
-			}
518
-		} catch(\Exception $e) {
519
-			\OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(),
520
-				\OCP\Util::ERROR);
521
-		}
522
-
523
-		if(!is_null($result)) {
524
-			try {
525
-				$stmt = \OCP\DB::prepare('DELETE FROM `' . self::RELATION_TABLE . '` '
526
-					. 'WHERE `categoryid` = ?');
527
-				while( $row = $result->fetchRow()) {
528
-					try {
529
-						$stmt->execute(array($row['id']));
530
-					} catch(\Exception $e) {
531
-						\OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(),
532
-							\OCP\Util::ERROR);
533
-					}
534
-				}
535
-			} catch(\Exception $e) {
536
-				\OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(),
537
-					\OCP\Util::ERROR);
538
-			}
539
-		}
540
-		try {
541
-			$stmt = \OCP\DB::prepare('DELETE FROM `' . self::TAG_TABLE . '` '
542
-				. 'WHERE `uid` = ?');
543
-			$result = $stmt->execute(array($arguments['uid']));
544
-			if (\OCP\DB::isError($result)) {
545
-				\OCP\Util::writeLog('core', __METHOD__. ', DB error: ' . \OCP\DB::getErrorMessage(), \OCP\Util::ERROR);
546
-			}
547
-		} catch(\Exception $e) {
548
-			\OCP\Util::writeLog('core', __METHOD__ . ', exception: '
549
-				. $e->getMessage(), \OCP\Util::ERROR);
550
-		}
551
-	}
552
-
553
-	/**
554
-	* Delete tag/object relations from the db
555
-	*
556
-	* @param array $ids The ids of the objects
557
-	* @return boolean Returns false on error.
558
-	*/
559
-	public function purgeObjects(array $ids) {
560
-		if(count($ids) === 0) {
561
-			// job done ;)
562
-			return true;
563
-		}
564
-		$updates = $ids;
565
-		try {
566
-			$query = 'DELETE FROM `' . self::RELATION_TABLE . '` ';
567
-			$query .= 'WHERE `objid` IN (' . str_repeat('?,', count($ids)-1) . '?) ';
568
-			$query .= 'AND `type`= ?';
569
-			$updates[] = $this->type;
570
-			$stmt = \OCP\DB::prepare($query);
571
-			$result = $stmt->execute($updates);
572
-			if (\OCP\DB::isError($result)) {
573
-				\OCP\Util::writeLog('core', __METHOD__. 'DB error: ' . \OCP\DB::getErrorMessage(), \OCP\Util::ERROR);
574
-				return false;
575
-			}
576
-		} catch(\Exception $e) {
577
-			\OCP\Util::writeLog('core', __METHOD__.', exception: ' . $e->getMessage(),
578
-				\OCP\Util::ERROR);
579
-			return false;
580
-		}
581
-		return true;
582
-	}
583
-
584
-	/**
585
-	* Get favorites for an object type
586
-	*
587
-	* @return array|false An array of object ids.
588
-	*/
589
-	public function getFavorites() {
590
-		try {
591
-			return $this->getIdsForTag(self::TAG_FAVORITE);
592
-		} catch(\Exception $e) {
593
-			\OCP\Util::writeLog('core', __METHOD__.', exception: ' . $e->getMessage(),
594
-				\OCP\Util::DEBUG);
595
-			return array();
596
-		}
597
-	}
598
-
599
-	/**
600
-	* Add an object to favorites
601
-	*
602
-	* @param int $objid The id of the object
603
-	* @return boolean
604
-	*/
605
-	public function addToFavorites($objid) {
606
-		if(!$this->userHasTag(self::TAG_FAVORITE, $this->user)) {
607
-			$this->add(self::TAG_FAVORITE);
608
-		}
609
-		return $this->tagAs($objid, self::TAG_FAVORITE);
610
-	}
611
-
612
-	/**
613
-	* Remove an object from favorites
614
-	*
615
-	* @param int $objid The id of the object
616
-	* @return boolean
617
-	*/
618
-	public function removeFromFavorites($objid) {
619
-		return $this->unTag($objid, self::TAG_FAVORITE);
620
-	}
621
-
622
-	/**
623
-	* Creates a tag/object relation.
624
-	*
625
-	* @param int $objid The id of the object
626
-	* @param string $tag The id or name of the tag
627
-	* @return boolean Returns false on error.
628
-	*/
629
-	public function tagAs($objid, $tag) {
630
-		if(is_string($tag) && !is_numeric($tag)) {
631
-			$tag = trim($tag);
632
-			if($tag === '') {
633
-				\OCP\Util::writeLog('core', __METHOD__.', Cannot add an empty tag', \OCP\Util::DEBUG);
634
-				return false;
635
-			}
636
-			if(!$this->hasTag($tag)) {
637
-				$this->add($tag);
638
-			}
639
-			$tagId =  $this->getTagId($tag);
640
-		} else {
641
-			$tagId = $tag;
642
-		}
643
-		try {
644
-			\OCP\DB::insertIfNotExist(self::RELATION_TABLE,
645
-				array(
646
-					'objid' => $objid,
647
-					'categoryid' => $tagId,
648
-					'type' => $this->type,
649
-				));
650
-		} catch(\Exception $e) {
651
-			\OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(),
652
-				\OCP\Util::ERROR);
653
-			return false;
654
-		}
655
-		return true;
656
-	}
657
-
658
-	/**
659
-	* Delete single tag/object relation from the db
660
-	*
661
-	* @param int $objid The id of the object
662
-	* @param string $tag The id or name of the tag
663
-	* @return boolean
664
-	*/
665
-	public function unTag($objid, $tag) {
666
-		if(is_string($tag) && !is_numeric($tag)) {
667
-			$tag = trim($tag);
668
-			if($tag === '') {
669
-				\OCP\Util::writeLog('core', __METHOD__.', Tag name is empty', \OCP\Util::DEBUG);
670
-				return false;
671
-			}
672
-			$tagId =  $this->getTagId($tag);
673
-		} else {
674
-			$tagId = $tag;
675
-		}
676
-
677
-		try {
678
-			$sql = 'DELETE FROM `' . self::RELATION_TABLE . '` '
679
-					. 'WHERE `objid` = ? AND `categoryid` = ? AND `type` = ?';
680
-			$stmt = \OCP\DB::prepare($sql);
681
-			$stmt->execute(array($objid, $tagId, $this->type));
682
-		} catch(\Exception $e) {
683
-			\OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(),
684
-				\OCP\Util::ERROR);
685
-			return false;
686
-		}
687
-		return true;
688
-	}
689
-
690
-	/**
691
-	* Delete tags from the database.
692
-	*
693
-	* @param string[]|integer[] $names An array of tags (names or IDs) to delete
694
-	* @return bool Returns false on error
695
-	*/
696
-	public function delete($names) {
697
-		if(!is_array($names)) {
698
-			$names = array($names);
699
-		}
700
-
701
-		$names = array_map('trim', $names);
702
-		array_filter($names);
703
-
704
-		\OCP\Util::writeLog('core', __METHOD__ . ', before: '
705
-			. print_r($this->tags, true), \OCP\Util::DEBUG);
706
-		foreach($names as $name) {
707
-			$id = null;
708
-
709
-			if (is_numeric($name)) {
710
-				$key = $this->getTagById($name);
711
-			} else {
712
-				$key = $this->getTagByName($name);
713
-			}
714
-			if ($key !== false) {
715
-				$tag = $this->tags[$key];
716
-				$id = $tag->getId();
717
-				unset($this->tags[$key]);
718
-				$this->mapper->delete($tag);
719
-			} else {
720
-				\OCP\Util::writeLog('core', __METHOD__ . 'Cannot delete tag ' . $name
721
-					. ': not found.', \OCP\Util::ERROR);
722
-			}
723
-			if(!is_null($id) && $id !== false) {
724
-				try {
725
-					$sql = 'DELETE FROM `' . self::RELATION_TABLE . '` '
726
-							. 'WHERE `categoryid` = ?';
727
-					$stmt = \OCP\DB::prepare($sql);
728
-					$result = $stmt->execute(array($id));
729
-					if (\OCP\DB::isError($result)) {
730
-						\OCP\Util::writeLog('core',
731
-							__METHOD__. 'DB error: ' . \OCP\DB::getErrorMessage(),
732
-							\OCP\Util::ERROR);
733
-						return false;
734
-					}
735
-				} catch(\Exception $e) {
736
-					\OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(),
737
-						\OCP\Util::ERROR);
738
-					return false;
739
-				}
740
-			}
741
-		}
742
-		return true;
743
-	}
744
-
745
-	// case-insensitive array_search
746
-	protected function array_searchi($needle, $haystack, $mem='getName') {
747
-		if(!is_array($haystack)) {
748
-			return false;
749
-		}
750
-		return array_search(strtolower($needle), array_map(
751
-			function($tag) use($mem) {
752
-				return strtolower(call_user_func(array($tag, $mem)));
753
-			}, $haystack)
754
-		);
755
-	}
756
-
757
-	/**
758
-	* Get a tag's ID.
759
-	*
760
-	* @param string $name The tag name to look for.
761
-	* @return string|bool The tag's id or false if no matching tag is found.
762
-	*/
763
-	private function getTagId($name) {
764
-		$key = $this->array_searchi($name, $this->tags);
765
-		if ($key !== false) {
766
-			return $this->tags[$key]->getId();
767
-		}
768
-		return false;
769
-	}
770
-
771
-	/**
772
-	* Get a tag by its name.
773
-	*
774
-	* @param string $name The tag name.
775
-	* @return integer|bool The tag object's offset within the $this->tags
776
-	*                      array or false if it doesn't exist.
777
-	*/
778
-	private function getTagByName($name) {
779
-		return $this->array_searchi($name, $this->tags, 'getName');
780
-	}
781
-
782
-	/**
783
-	* Get a tag by its ID.
784
-	*
785
-	* @param string $id The tag ID to look for.
786
-	* @return integer|bool The tag object's offset within the $this->tags
787
-	*                      array or false if it doesn't exist.
788
-	*/
789
-	private function getTagById($id) {
790
-		return $this->array_searchi($id, $this->tags, 'getId');
791
-	}
792
-
793
-	/**
794
-	* Returns an array mapping a given tag's properties to its values:
795
-	* ['id' => 0, 'name' = 'Tag', 'owner' = 'User', 'type' => 'tagtype']
796
-	*
797
-	* @param Tag $tag The tag that is going to be mapped
798
-	* @return array
799
-	*/
800
-	private function tagMap(Tag $tag) {
801
-		return array(
802
-			'id'    => $tag->getId(),
803
-			'name'  => $tag->getName(),
804
-			'owner' => $tag->getOwner(),
805
-			'type'  => $tag->getType()
806
-		);
807
-	}
51
+    /**
52
+     * Tags
53
+     *
54
+     * @var array
55
+     */
56
+    private $tags = array();
57
+
58
+    /**
59
+     * Used for storing objectid/categoryname pairs while rescanning.
60
+     *
61
+     * @var array
62
+     */
63
+    private static $relations = array();
64
+
65
+    /**
66
+     * Type
67
+     *
68
+     * @var string
69
+     */
70
+    private $type;
71
+
72
+    /**
73
+     * User
74
+     *
75
+     * @var string
76
+     */
77
+    private $user;
78
+
79
+    /**
80
+     * Are we including tags for shared items?
81
+     *
82
+     * @var bool
83
+     */
84
+    private $includeShared = false;
85
+
86
+    /**
87
+     * The current user, plus any owners of the items shared with the current
88
+     * user, if $this->includeShared === true.
89
+     *
90
+     * @var array
91
+     */
92
+    private $owners = array();
93
+
94
+    /**
95
+     * The Mapper we're using to communicate our Tag objects to the database.
96
+     *
97
+     * @var TagMapper
98
+     */
99
+    private $mapper;
100
+
101
+    /**
102
+     * The sharing backend for objects of $this->type. Required if
103
+     * $this->includeShared === true to determine ownership of items.
104
+     *
105
+     * @var \OCP\Share_Backend
106
+     */
107
+    private $backend;
108
+
109
+    const TAG_TABLE = '*PREFIX*vcategory';
110
+    const RELATION_TABLE = '*PREFIX*vcategory_to_object';
111
+
112
+    const TAG_FAVORITE = '_$!<Favorite>!$_';
113
+
114
+    /**
115
+     * Constructor.
116
+     *
117
+     * @param TagMapper $mapper Instance of the TagMapper abstraction layer.
118
+     * @param string $user The user whose data the object will operate on.
119
+     * @param string $type The type of items for which tags will be loaded.
120
+     * @param array $defaultTags Tags that should be created at construction.
121
+     * @param boolean $includeShared Whether to include tags for items shared with this user by others.
122
+     */
123
+    public function __construct(TagMapper $mapper, $user, $type, $defaultTags = array(), $includeShared = false) {
124
+        $this->mapper = $mapper;
125
+        $this->user = $user;
126
+        $this->type = $type;
127
+        $this->includeShared = $includeShared;
128
+        $this->owners = array($this->user);
129
+        if ($this->includeShared) {
130
+            $this->owners = array_merge($this->owners, \OC\Share\Share::getSharedItemsOwners($this->user, $this->type, true));
131
+            $this->backend = \OC\Share\Share::getBackend($this->type);
132
+        }
133
+        $this->tags = $this->mapper->loadTags($this->owners, $this->type);
134
+
135
+        if(count($defaultTags) > 0 && count($this->tags) === 0) {
136
+            $this->addMultiple($defaultTags, true);
137
+        }
138
+    }
139
+
140
+    /**
141
+     * Check if any tags are saved for this type and user.
142
+     *
143
+     * @return boolean.
144
+     */
145
+    public function isEmpty() {
146
+        return count($this->tags) === 0;
147
+    }
148
+
149
+    /**
150
+     * Returns an array mapping a given tag's properties to its values:
151
+     * ['id' => 0, 'name' = 'Tag', 'owner' = 'User', 'type' => 'tagtype']
152
+     *
153
+     * @param string $id The ID of the tag that is going to be mapped
154
+     * @return array|false
155
+     */
156
+    public function getTag($id) {
157
+        $key = $this->getTagById($id);
158
+        if ($key !== false) {
159
+            return $this->tagMap($this->tags[$key]);
160
+        }
161
+        return false;
162
+    }
163
+
164
+    /**
165
+     * Get the tags for a specific user.
166
+     *
167
+     * This returns an array with maps containing each tag's properties:
168
+     * [
169
+     * 	['id' => 0, 'name' = 'First tag', 'owner' = 'User', 'type' => 'tagtype'],
170
+     * 	['id' => 1, 'name' = 'Shared tag', 'owner' = 'Other user', 'type' => 'tagtype'],
171
+     * ]
172
+     *
173
+     * @return array
174
+     */
175
+    public function getTags() {
176
+        if(!count($this->tags)) {
177
+            return array();
178
+        }
179
+
180
+        usort($this->tags, function($a, $b) {
181
+            return strnatcasecmp($a->getName(), $b->getName());
182
+        });
183
+        $tagMap = array();
184
+
185
+        foreach($this->tags as $tag) {
186
+            if($tag->getName() !== self::TAG_FAVORITE) {
187
+                $tagMap[] = $this->tagMap($tag);
188
+            }
189
+        }
190
+        return $tagMap;
191
+
192
+    }
193
+
194
+    /**
195
+     * Return only the tags owned by the given user, omitting any tags shared
196
+     * by other users.
197
+     *
198
+     * @param string $user The user whose tags are to be checked.
199
+     * @return array An array of Tag objects.
200
+     */
201
+    public function getTagsForUser($user) {
202
+        return array_filter($this->tags,
203
+            function($tag) use($user) {
204
+                return $tag->getOwner() === $user;
205
+            }
206
+        );
207
+    }
208
+
209
+    /**
210
+     * Get the list of tags for the given ids.
211
+     *
212
+     * @param array $objIds array of object ids
213
+     * @return array|boolean of tags id as key to array of tag names
214
+     * or false if an error occurred
215
+     */
216
+    public function getTagsForObjects(array $objIds) {
217
+        $entries = array();
218
+
219
+        try {
220
+            $conn = \OC::$server->getDatabaseConnection();
221
+            $chunks = array_chunk($objIds, 900, false);
222
+            foreach ($chunks as $chunk) {
223
+                $result = $conn->executeQuery(
224
+                    'SELECT `category`, `categoryid`, `objid` ' .
225
+                    'FROM `' . self::RELATION_TABLE . '` r, `' . self::TAG_TABLE . '` ' .
226
+                    'WHERE `categoryid` = `id` AND `uid` = ? AND r.`type` = ? AND `objid` IN (?)',
227
+                    array($this->user, $this->type, $chunk),
228
+                    array(null, null, IQueryBuilder::PARAM_INT_ARRAY)
229
+                );
230
+                while ($row = $result->fetch()) {
231
+                    $objId = (int)$row['objid'];
232
+                    if (!isset($entries[$objId])) {
233
+                        $entries[$objId] = array();
234
+                    }
235
+                    $entries[$objId][] = $row['category'];
236
+                }
237
+                if (\OCP\DB::isError($result)) {
238
+                    \OCP\Util::writeLog('core', __METHOD__. 'DB error: ' . \OCP\DB::getErrorMessage(), \OCP\Util::ERROR);
239
+                    return false;
240
+                }
241
+            }
242
+        } catch(\Exception $e) {
243
+            \OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(),
244
+                \OCP\Util::ERROR);
245
+            return false;
246
+        }
247
+
248
+        return $entries;
249
+    }
250
+
251
+    /**
252
+     * Get the a list if items tagged with $tag.
253
+     *
254
+     * Throws an exception if the tag could not be found.
255
+     *
256
+     * @param string $tag Tag id or name.
257
+     * @return array|false An array of object ids or false on error.
258
+     * @throws \Exception
259
+     */
260
+    public function getIdsForTag($tag) {
261
+        $result = null;
262
+        $tagId = false;
263
+        if(is_numeric($tag)) {
264
+            $tagId = $tag;
265
+        } elseif(is_string($tag)) {
266
+            $tag = trim($tag);
267
+            if($tag === '') {
268
+                \OCP\Util::writeLog('core', __METHOD__.', Cannot use empty tag names', \OCP\Util::DEBUG);
269
+                return false;
270
+            }
271
+            $tagId = $this->getTagId($tag);
272
+        }
273
+
274
+        if($tagId === false) {
275
+            $l10n = \OC::$server->getL10N('core');
276
+            throw new \Exception(
277
+                $l10n->t('Could not find category "%s"', $tag)
278
+            );
279
+        }
280
+
281
+        $ids = array();
282
+        $sql = 'SELECT `objid` FROM `' . self::RELATION_TABLE
283
+            . '` WHERE `categoryid` = ?';
284
+
285
+        try {
286
+            $stmt = \OCP\DB::prepare($sql);
287
+            $result = $stmt->execute(array($tagId));
288
+            if (\OCP\DB::isError($result)) {
289
+                \OCP\Util::writeLog('core', __METHOD__. 'DB error: ' . \OCP\DB::getErrorMessage(), \OCP\Util::ERROR);
290
+                return false;
291
+            }
292
+        } catch(\Exception $e) {
293
+            \OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(),
294
+                \OCP\Util::ERROR);
295
+            return false;
296
+        }
297
+
298
+        if(!is_null($result)) {
299
+            while( $row = $result->fetchRow()) {
300
+                $id = (int)$row['objid'];
301
+
302
+                if ($this->includeShared) {
303
+                    // We have to check if we are really allowed to access the
304
+                    // items that are tagged with $tag. To that end, we ask the
305
+                    // corresponding sharing backend if the item identified by $id
306
+                    // is owned by any of $this->owners.
307
+                    foreach ($this->owners as $owner) {
308
+                        if ($this->backend->isValidSource($id, $owner)) {
309
+                            $ids[] = $id;
310
+                            break;
311
+                        }
312
+                    }
313
+                } else {
314
+                    $ids[] = $id;
315
+                }
316
+            }
317
+        }
318
+
319
+        return $ids;
320
+    }
321
+
322
+    /**
323
+     * Checks whether a tag is saved for the given user,
324
+     * disregarding the ones shared with him or her.
325
+     *
326
+     * @param string $name The tag name to check for.
327
+     * @param string $user The user whose tags are to be checked.
328
+     * @return bool
329
+     */
330
+    public function userHasTag($name, $user) {
331
+        $key = $this->array_searchi($name, $this->getTagsForUser($user));
332
+        return ($key !== false) ? $this->tags[$key]->getId() : false;
333
+    }
334
+
335
+    /**
336
+     * Checks whether a tag is saved for or shared with the current user.
337
+     *
338
+     * @param string $name The tag name to check for.
339
+     * @return bool
340
+     */
341
+    public function hasTag($name) {
342
+        return $this->getTagId($name) !== false;
343
+    }
344
+
345
+    /**
346
+     * Add a new tag.
347
+     *
348
+     * @param string $name A string with a name of the tag
349
+     * @return false|int the id of the added tag or false on error.
350
+     */
351
+    public function add($name) {
352
+        $name = trim($name);
353
+
354
+        if($name === '') {
355
+            \OCP\Util::writeLog('core', __METHOD__.', Cannot add an empty tag', \OCP\Util::DEBUG);
356
+            return false;
357
+        }
358
+        if($this->userHasTag($name, $this->user)) {
359
+            \OCP\Util::writeLog('core', __METHOD__.', name: ' . $name. ' exists already', \OCP\Util::DEBUG);
360
+            return false;
361
+        }
362
+        try {
363
+            $tag = new Tag($this->user, $this->type, $name);
364
+            $tag = $this->mapper->insert($tag);
365
+            $this->tags[] = $tag;
366
+        } catch(\Exception $e) {
367
+            \OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(),
368
+                \OCP\Util::ERROR);
369
+            return false;
370
+        }
371
+        \OCP\Util::writeLog('core', __METHOD__.', id: ' . $tag->getId(), \OCP\Util::DEBUG);
372
+        return $tag->getId();
373
+    }
374
+
375
+    /**
376
+     * Rename tag.
377
+     *
378
+     * @param string|integer $from The name or ID of the existing tag
379
+     * @param string $to The new name of the tag.
380
+     * @return bool
381
+     */
382
+    public function rename($from, $to) {
383
+        $from = trim($from);
384
+        $to = trim($to);
385
+
386
+        if($to === '' || $from === '') {
387
+            \OCP\Util::writeLog('core', __METHOD__.', Cannot use empty tag names', \OCP\Util::DEBUG);
388
+            return false;
389
+        }
390
+
391
+        if (is_numeric($from)) {
392
+            $key = $this->getTagById($from);
393
+        } else {
394
+            $key = $this->getTagByName($from);
395
+        }
396
+        if($key === false) {
397
+            \OCP\Util::writeLog('core', __METHOD__.', tag: ' . $from. ' does not exist', \OCP\Util::DEBUG);
398
+            return false;
399
+        }
400
+        $tag = $this->tags[$key];
401
+
402
+        if($this->userHasTag($to, $tag->getOwner())) {
403
+            \OCP\Util::writeLog('core', __METHOD__.', A tag named ' . $to. ' already exists for user ' . $tag->getOwner() . '.', \OCP\Util::DEBUG);
404
+            return false;
405
+        }
406
+
407
+        try {
408
+            $tag->setName($to);
409
+            $this->tags[$key] = $this->mapper->update($tag);
410
+        } catch(\Exception $e) {
411
+            \OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(),
412
+                \OCP\Util::ERROR);
413
+            return false;
414
+        }
415
+        return true;
416
+    }
417
+
418
+    /**
419
+     * Add a list of new tags.
420
+     *
421
+     * @param string[] $names A string with a name or an array of strings containing
422
+     * the name(s) of the tag(s) to add.
423
+     * @param bool $sync When true, save the tags
424
+     * @param int|null $id int Optional object id to add to this|these tag(s)
425
+     * @return bool Returns false on error.
426
+     */
427
+    public function addMultiple($names, $sync=false, $id = null) {
428
+        if(!is_array($names)) {
429
+            $names = array($names);
430
+        }
431
+        $names = array_map('trim', $names);
432
+        array_filter($names);
433
+
434
+        $newones = array();
435
+        foreach($names as $name) {
436
+            if(!$this->hasTag($name) && $name !== '') {
437
+                $newones[] = new Tag($this->user, $this->type, $name);
438
+            }
439
+            if(!is_null($id) ) {
440
+                // Insert $objectid, $categoryid  pairs if not exist.
441
+                self::$relations[] = array('objid' => $id, 'tag' => $name);
442
+            }
443
+        }
444
+        $this->tags = array_merge($this->tags, $newones);
445
+        if($sync === true) {
446
+            $this->save();
447
+        }
448
+
449
+        return true;
450
+    }
451
+
452
+    /**
453
+     * Save the list of tags and their object relations
454
+     */
455
+    protected function save() {
456
+        if(is_array($this->tags)) {
457
+            foreach($this->tags as $tag) {
458
+                try {
459
+                    if (!$this->mapper->tagExists($tag)) {
460
+                        $this->mapper->insert($tag);
461
+                    }
462
+                } catch(\Exception $e) {
463
+                    \OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(),
464
+                        \OCP\Util::ERROR);
465
+                }
466
+            }
467
+
468
+            // reload tags to get the proper ids.
469
+            $this->tags = $this->mapper->loadTags($this->owners, $this->type);
470
+            \OCP\Util::writeLog('core', __METHOD__.', tags: ' . print_r($this->tags, true),
471
+                \OCP\Util::DEBUG);
472
+            // Loop through temporarily cached objectid/tagname pairs
473
+            // and save relations.
474
+            $tags = $this->tags;
475
+            // For some reason this is needed or array_search(i) will return 0..?
476
+            ksort($tags);
477
+            foreach(self::$relations as $relation) {
478
+                $tagId = $this->getTagId($relation['tag']);
479
+                \OCP\Util::writeLog('core', __METHOD__ . 'catid, ' . $relation['tag'] . ' ' . $tagId, \OCP\Util::DEBUG);
480
+                if($tagId) {
481
+                    try {
482
+                        \OCP\DB::insertIfNotExist(self::RELATION_TABLE,
483
+                            array(
484
+                                'objid' => $relation['objid'],
485
+                                'categoryid' => $tagId,
486
+                                'type' => $this->type,
487
+                                ));
488
+                    } catch(\Exception $e) {
489
+                        \OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(),
490
+                            \OCP\Util::ERROR);
491
+                    }
492
+                }
493
+            }
494
+            self::$relations = array(); // reset
495
+        } else {
496
+            \OCP\Util::writeLog('core', __METHOD__.', $this->tags is not an array! '
497
+                . print_r($this->tags, true), \OCP\Util::ERROR);
498
+        }
499
+    }
500
+
501
+    /**
502
+     * Delete tags and tag/object relations for a user.
503
+     *
504
+     * For hooking up on post_deleteUser
505
+     *
506
+     * @param array $arguments
507
+     */
508
+    public static function post_deleteUser($arguments) {
509
+        // Find all objectid/tagId pairs.
510
+        $result = null;
511
+        try {
512
+            $stmt = \OCP\DB::prepare('SELECT `id` FROM `' . self::TAG_TABLE . '` '
513
+                . 'WHERE `uid` = ?');
514
+            $result = $stmt->execute(array($arguments['uid']));
515
+            if (\OCP\DB::isError($result)) {
516
+                \OCP\Util::writeLog('core', __METHOD__. 'DB error: ' . \OCP\DB::getErrorMessage(), \OCP\Util::ERROR);
517
+            }
518
+        } catch(\Exception $e) {
519
+            \OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(),
520
+                \OCP\Util::ERROR);
521
+        }
522
+
523
+        if(!is_null($result)) {
524
+            try {
525
+                $stmt = \OCP\DB::prepare('DELETE FROM `' . self::RELATION_TABLE . '` '
526
+                    . 'WHERE `categoryid` = ?');
527
+                while( $row = $result->fetchRow()) {
528
+                    try {
529
+                        $stmt->execute(array($row['id']));
530
+                    } catch(\Exception $e) {
531
+                        \OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(),
532
+                            \OCP\Util::ERROR);
533
+                    }
534
+                }
535
+            } catch(\Exception $e) {
536
+                \OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(),
537
+                    \OCP\Util::ERROR);
538
+            }
539
+        }
540
+        try {
541
+            $stmt = \OCP\DB::prepare('DELETE FROM `' . self::TAG_TABLE . '` '
542
+                . 'WHERE `uid` = ?');
543
+            $result = $stmt->execute(array($arguments['uid']));
544
+            if (\OCP\DB::isError($result)) {
545
+                \OCP\Util::writeLog('core', __METHOD__. ', DB error: ' . \OCP\DB::getErrorMessage(), \OCP\Util::ERROR);
546
+            }
547
+        } catch(\Exception $e) {
548
+            \OCP\Util::writeLog('core', __METHOD__ . ', exception: '
549
+                . $e->getMessage(), \OCP\Util::ERROR);
550
+        }
551
+    }
552
+
553
+    /**
554
+     * Delete tag/object relations from the db
555
+     *
556
+     * @param array $ids The ids of the objects
557
+     * @return boolean Returns false on error.
558
+     */
559
+    public function purgeObjects(array $ids) {
560
+        if(count($ids) === 0) {
561
+            // job done ;)
562
+            return true;
563
+        }
564
+        $updates = $ids;
565
+        try {
566
+            $query = 'DELETE FROM `' . self::RELATION_TABLE . '` ';
567
+            $query .= 'WHERE `objid` IN (' . str_repeat('?,', count($ids)-1) . '?) ';
568
+            $query .= 'AND `type`= ?';
569
+            $updates[] = $this->type;
570
+            $stmt = \OCP\DB::prepare($query);
571
+            $result = $stmt->execute($updates);
572
+            if (\OCP\DB::isError($result)) {
573
+                \OCP\Util::writeLog('core', __METHOD__. 'DB error: ' . \OCP\DB::getErrorMessage(), \OCP\Util::ERROR);
574
+                return false;
575
+            }
576
+        } catch(\Exception $e) {
577
+            \OCP\Util::writeLog('core', __METHOD__.', exception: ' . $e->getMessage(),
578
+                \OCP\Util::ERROR);
579
+            return false;
580
+        }
581
+        return true;
582
+    }
583
+
584
+    /**
585
+     * Get favorites for an object type
586
+     *
587
+     * @return array|false An array of object ids.
588
+     */
589
+    public function getFavorites() {
590
+        try {
591
+            return $this->getIdsForTag(self::TAG_FAVORITE);
592
+        } catch(\Exception $e) {
593
+            \OCP\Util::writeLog('core', __METHOD__.', exception: ' . $e->getMessage(),
594
+                \OCP\Util::DEBUG);
595
+            return array();
596
+        }
597
+    }
598
+
599
+    /**
600
+     * Add an object to favorites
601
+     *
602
+     * @param int $objid The id of the object
603
+     * @return boolean
604
+     */
605
+    public function addToFavorites($objid) {
606
+        if(!$this->userHasTag(self::TAG_FAVORITE, $this->user)) {
607
+            $this->add(self::TAG_FAVORITE);
608
+        }
609
+        return $this->tagAs($objid, self::TAG_FAVORITE);
610
+    }
611
+
612
+    /**
613
+     * Remove an object from favorites
614
+     *
615
+     * @param int $objid The id of the object
616
+     * @return boolean
617
+     */
618
+    public function removeFromFavorites($objid) {
619
+        return $this->unTag($objid, self::TAG_FAVORITE);
620
+    }
621
+
622
+    /**
623
+     * Creates a tag/object relation.
624
+     *
625
+     * @param int $objid The id of the object
626
+     * @param string $tag The id or name of the tag
627
+     * @return boolean Returns false on error.
628
+     */
629
+    public function tagAs($objid, $tag) {
630
+        if(is_string($tag) && !is_numeric($tag)) {
631
+            $tag = trim($tag);
632
+            if($tag === '') {
633
+                \OCP\Util::writeLog('core', __METHOD__.', Cannot add an empty tag', \OCP\Util::DEBUG);
634
+                return false;
635
+            }
636
+            if(!$this->hasTag($tag)) {
637
+                $this->add($tag);
638
+            }
639
+            $tagId =  $this->getTagId($tag);
640
+        } else {
641
+            $tagId = $tag;
642
+        }
643
+        try {
644
+            \OCP\DB::insertIfNotExist(self::RELATION_TABLE,
645
+                array(
646
+                    'objid' => $objid,
647
+                    'categoryid' => $tagId,
648
+                    'type' => $this->type,
649
+                ));
650
+        } catch(\Exception $e) {
651
+            \OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(),
652
+                \OCP\Util::ERROR);
653
+            return false;
654
+        }
655
+        return true;
656
+    }
657
+
658
+    /**
659
+     * Delete single tag/object relation from the db
660
+     *
661
+     * @param int $objid The id of the object
662
+     * @param string $tag The id or name of the tag
663
+     * @return boolean
664
+     */
665
+    public function unTag($objid, $tag) {
666
+        if(is_string($tag) && !is_numeric($tag)) {
667
+            $tag = trim($tag);
668
+            if($tag === '') {
669
+                \OCP\Util::writeLog('core', __METHOD__.', Tag name is empty', \OCP\Util::DEBUG);
670
+                return false;
671
+            }
672
+            $tagId =  $this->getTagId($tag);
673
+        } else {
674
+            $tagId = $tag;
675
+        }
676
+
677
+        try {
678
+            $sql = 'DELETE FROM `' . self::RELATION_TABLE . '` '
679
+                    . 'WHERE `objid` = ? AND `categoryid` = ? AND `type` = ?';
680
+            $stmt = \OCP\DB::prepare($sql);
681
+            $stmt->execute(array($objid, $tagId, $this->type));
682
+        } catch(\Exception $e) {
683
+            \OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(),
684
+                \OCP\Util::ERROR);
685
+            return false;
686
+        }
687
+        return true;
688
+    }
689
+
690
+    /**
691
+     * Delete tags from the database.
692
+     *
693
+     * @param string[]|integer[] $names An array of tags (names or IDs) to delete
694
+     * @return bool Returns false on error
695
+     */
696
+    public function delete($names) {
697
+        if(!is_array($names)) {
698
+            $names = array($names);
699
+        }
700
+
701
+        $names = array_map('trim', $names);
702
+        array_filter($names);
703
+
704
+        \OCP\Util::writeLog('core', __METHOD__ . ', before: '
705
+            . print_r($this->tags, true), \OCP\Util::DEBUG);
706
+        foreach($names as $name) {
707
+            $id = null;
708
+
709
+            if (is_numeric($name)) {
710
+                $key = $this->getTagById($name);
711
+            } else {
712
+                $key = $this->getTagByName($name);
713
+            }
714
+            if ($key !== false) {
715
+                $tag = $this->tags[$key];
716
+                $id = $tag->getId();
717
+                unset($this->tags[$key]);
718
+                $this->mapper->delete($tag);
719
+            } else {
720
+                \OCP\Util::writeLog('core', __METHOD__ . 'Cannot delete tag ' . $name
721
+                    . ': not found.', \OCP\Util::ERROR);
722
+            }
723
+            if(!is_null($id) && $id !== false) {
724
+                try {
725
+                    $sql = 'DELETE FROM `' . self::RELATION_TABLE . '` '
726
+                            . 'WHERE `categoryid` = ?';
727
+                    $stmt = \OCP\DB::prepare($sql);
728
+                    $result = $stmt->execute(array($id));
729
+                    if (\OCP\DB::isError($result)) {
730
+                        \OCP\Util::writeLog('core',
731
+                            __METHOD__. 'DB error: ' . \OCP\DB::getErrorMessage(),
732
+                            \OCP\Util::ERROR);
733
+                        return false;
734
+                    }
735
+                } catch(\Exception $e) {
736
+                    \OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(),
737
+                        \OCP\Util::ERROR);
738
+                    return false;
739
+                }
740
+            }
741
+        }
742
+        return true;
743
+    }
744
+
745
+    // case-insensitive array_search
746
+    protected function array_searchi($needle, $haystack, $mem='getName') {
747
+        if(!is_array($haystack)) {
748
+            return false;
749
+        }
750
+        return array_search(strtolower($needle), array_map(
751
+            function($tag) use($mem) {
752
+                return strtolower(call_user_func(array($tag, $mem)));
753
+            }, $haystack)
754
+        );
755
+    }
756
+
757
+    /**
758
+     * Get a tag's ID.
759
+     *
760
+     * @param string $name The tag name to look for.
761
+     * @return string|bool The tag's id or false if no matching tag is found.
762
+     */
763
+    private function getTagId($name) {
764
+        $key = $this->array_searchi($name, $this->tags);
765
+        if ($key !== false) {
766
+            return $this->tags[$key]->getId();
767
+        }
768
+        return false;
769
+    }
770
+
771
+    /**
772
+     * Get a tag by its name.
773
+     *
774
+     * @param string $name The tag name.
775
+     * @return integer|bool The tag object's offset within the $this->tags
776
+     *                      array or false if it doesn't exist.
777
+     */
778
+    private function getTagByName($name) {
779
+        return $this->array_searchi($name, $this->tags, 'getName');
780
+    }
781
+
782
+    /**
783
+     * Get a tag by its ID.
784
+     *
785
+     * @param string $id The tag ID to look for.
786
+     * @return integer|bool The tag object's offset within the $this->tags
787
+     *                      array or false if it doesn't exist.
788
+     */
789
+    private function getTagById($id) {
790
+        return $this->array_searchi($id, $this->tags, 'getId');
791
+    }
792
+
793
+    /**
794
+     * Returns an array mapping a given tag's properties to its values:
795
+     * ['id' => 0, 'name' = 'Tag', 'owner' = 'User', 'type' => 'tagtype']
796
+     *
797
+     * @param Tag $tag The tag that is going to be mapped
798
+     * @return array
799
+     */
800
+    private function tagMap(Tag $tag) {
801
+        return array(
802
+            'id'    => $tag->getId(),
803
+            'name'  => $tag->getName(),
804
+            'owner' => $tag->getOwner(),
805
+            'type'  => $tag->getType()
806
+        );
807
+    }
808 808
 }
Please login to merge, or discard this patch.
lib/private/Security/CSP/ContentSecurityPolicy.php 1 patch
Indentation   +167 added lines, -167 removed lines patch added patch discarded remove patch
@@ -29,172 +29,172 @@
 block discarded – undo
29 29
  * @package OC\Security\CSP
30 30
  */
31 31
 class ContentSecurityPolicy extends \OCP\AppFramework\Http\ContentSecurityPolicy {
32
-	/**
33
-	 * @return boolean
34
-	 */
35
-	public function isInlineScriptAllowed() {
36
-		return $this->inlineScriptAllowed;
37
-	}
38
-
39
-	/**
40
-	 * @param boolean $inlineScriptAllowed
41
-	 */
42
-	public function setInlineScriptAllowed($inlineScriptAllowed) {
43
-		$this->inlineScriptAllowed = $inlineScriptAllowed;
44
-	}
45
-
46
-	/**
47
-	 * @return boolean
48
-	 */
49
-	public function isEvalScriptAllowed() {
50
-		return $this->evalScriptAllowed;
51
-	}
52
-
53
-	/**
54
-	 * @param boolean $evalScriptAllowed
55
-	 */
56
-	public function setEvalScriptAllowed($evalScriptAllowed) {
57
-		$this->evalScriptAllowed = $evalScriptAllowed;
58
-	}
59
-
60
-	/**
61
-	 * @return array
62
-	 */
63
-	public function getAllowedScriptDomains() {
64
-		return $this->allowedScriptDomains;
65
-	}
66
-
67
-	/**
68
-	 * @param array $allowedScriptDomains
69
-	 */
70
-	public function setAllowedScriptDomains($allowedScriptDomains) {
71
-		$this->allowedScriptDomains = $allowedScriptDomains;
72
-	}
73
-
74
-	/**
75
-	 * @return boolean
76
-	 */
77
-	public function isInlineStyleAllowed() {
78
-		return $this->inlineStyleAllowed;
79
-	}
80
-
81
-	/**
82
-	 * @param boolean $inlineStyleAllowed
83
-	 */
84
-	public function setInlineStyleAllowed($inlineStyleAllowed) {
85
-		$this->inlineStyleAllowed = $inlineStyleAllowed;
86
-	}
87
-
88
-	/**
89
-	 * @return array
90
-	 */
91
-	public function getAllowedStyleDomains() {
92
-		return $this->allowedStyleDomains;
93
-	}
94
-
95
-	/**
96
-	 * @param array $allowedStyleDomains
97
-	 */
98
-	public function setAllowedStyleDomains($allowedStyleDomains) {
99
-		$this->allowedStyleDomains = $allowedStyleDomains;
100
-	}
101
-
102
-	/**
103
-	 * @return array
104
-	 */
105
-	public function getAllowedImageDomains() {
106
-		return $this->allowedImageDomains;
107
-	}
108
-
109
-	/**
110
-	 * @param array $allowedImageDomains
111
-	 */
112
-	public function setAllowedImageDomains($allowedImageDomains) {
113
-		$this->allowedImageDomains = $allowedImageDomains;
114
-	}
115
-
116
-	/**
117
-	 * @return array
118
-	 */
119
-	public function getAllowedConnectDomains() {
120
-		return $this->allowedConnectDomains;
121
-	}
122
-
123
-	/**
124
-	 * @param array $allowedConnectDomains
125
-	 */
126
-	public function setAllowedConnectDomains($allowedConnectDomains) {
127
-		$this->allowedConnectDomains = $allowedConnectDomains;
128
-	}
129
-
130
-	/**
131
-	 * @return array
132
-	 */
133
-	public function getAllowedMediaDomains() {
134
-		return $this->allowedMediaDomains;
135
-	}
136
-
137
-	/**
138
-	 * @param array $allowedMediaDomains
139
-	 */
140
-	public function setAllowedMediaDomains($allowedMediaDomains) {
141
-		$this->allowedMediaDomains = $allowedMediaDomains;
142
-	}
143
-
144
-	/**
145
-	 * @return array
146
-	 */
147
-	public function getAllowedObjectDomains() {
148
-		return $this->allowedObjectDomains;
149
-	}
150
-
151
-	/**
152
-	 * @param array $allowedObjectDomains
153
-	 */
154
-	public function setAllowedObjectDomains($allowedObjectDomains) {
155
-		$this->allowedObjectDomains = $allowedObjectDomains;
156
-	}
157
-
158
-	/**
159
-	 * @return array
160
-	 */
161
-	public function getAllowedFrameDomains() {
162
-		return $this->allowedFrameDomains;
163
-	}
164
-
165
-	/**
166
-	 * @param array $allowedFrameDomains
167
-	 */
168
-	public function setAllowedFrameDomains($allowedFrameDomains) {
169
-		$this->allowedFrameDomains = $allowedFrameDomains;
170
-	}
171
-
172
-	/**
173
-	 * @return array
174
-	 */
175
-	public function getAllowedFontDomains() {
176
-		return $this->allowedFontDomains;
177
-	}
178
-
179
-	/**
180
-	 * @param array $allowedFontDomains
181
-	 */
182
-	public function setAllowedFontDomains($allowedFontDomains) {
183
-		$this->allowedFontDomains = $allowedFontDomains;
184
-	}
185
-
186
-	/**
187
-	 * @return array
188
-	 */
189
-	public function getAllowedChildSrcDomains() {
190
-		return $this->allowedChildSrcDomains;
191
-	}
192
-
193
-	/**
194
-	 * @param array $allowedChildSrcDomains
195
-	 */
196
-	public function setAllowedChildSrcDomains($allowedChildSrcDomains) {
197
-		$this->allowedChildSrcDomains = $allowedChildSrcDomains;
198
-	}
32
+    /**
33
+     * @return boolean
34
+     */
35
+    public function isInlineScriptAllowed() {
36
+        return $this->inlineScriptAllowed;
37
+    }
38
+
39
+    /**
40
+     * @param boolean $inlineScriptAllowed
41
+     */
42
+    public function setInlineScriptAllowed($inlineScriptAllowed) {
43
+        $this->inlineScriptAllowed = $inlineScriptAllowed;
44
+    }
45
+
46
+    /**
47
+     * @return boolean
48
+     */
49
+    public function isEvalScriptAllowed() {
50
+        return $this->evalScriptAllowed;
51
+    }
52
+
53
+    /**
54
+     * @param boolean $evalScriptAllowed
55
+     */
56
+    public function setEvalScriptAllowed($evalScriptAllowed) {
57
+        $this->evalScriptAllowed = $evalScriptAllowed;
58
+    }
59
+
60
+    /**
61
+     * @return array
62
+     */
63
+    public function getAllowedScriptDomains() {
64
+        return $this->allowedScriptDomains;
65
+    }
66
+
67
+    /**
68
+     * @param array $allowedScriptDomains
69
+     */
70
+    public function setAllowedScriptDomains($allowedScriptDomains) {
71
+        $this->allowedScriptDomains = $allowedScriptDomains;
72
+    }
73
+
74
+    /**
75
+     * @return boolean
76
+     */
77
+    public function isInlineStyleAllowed() {
78
+        return $this->inlineStyleAllowed;
79
+    }
80
+
81
+    /**
82
+     * @param boolean $inlineStyleAllowed
83
+     */
84
+    public function setInlineStyleAllowed($inlineStyleAllowed) {
85
+        $this->inlineStyleAllowed = $inlineStyleAllowed;
86
+    }
87
+
88
+    /**
89
+     * @return array
90
+     */
91
+    public function getAllowedStyleDomains() {
92
+        return $this->allowedStyleDomains;
93
+    }
94
+
95
+    /**
96
+     * @param array $allowedStyleDomains
97
+     */
98
+    public function setAllowedStyleDomains($allowedStyleDomains) {
99
+        $this->allowedStyleDomains = $allowedStyleDomains;
100
+    }
101
+
102
+    /**
103
+     * @return array
104
+     */
105
+    public function getAllowedImageDomains() {
106
+        return $this->allowedImageDomains;
107
+    }
108
+
109
+    /**
110
+     * @param array $allowedImageDomains
111
+     */
112
+    public function setAllowedImageDomains($allowedImageDomains) {
113
+        $this->allowedImageDomains = $allowedImageDomains;
114
+    }
115
+
116
+    /**
117
+     * @return array
118
+     */
119
+    public function getAllowedConnectDomains() {
120
+        return $this->allowedConnectDomains;
121
+    }
122
+
123
+    /**
124
+     * @param array $allowedConnectDomains
125
+     */
126
+    public function setAllowedConnectDomains($allowedConnectDomains) {
127
+        $this->allowedConnectDomains = $allowedConnectDomains;
128
+    }
129
+
130
+    /**
131
+     * @return array
132
+     */
133
+    public function getAllowedMediaDomains() {
134
+        return $this->allowedMediaDomains;
135
+    }
136
+
137
+    /**
138
+     * @param array $allowedMediaDomains
139
+     */
140
+    public function setAllowedMediaDomains($allowedMediaDomains) {
141
+        $this->allowedMediaDomains = $allowedMediaDomains;
142
+    }
143
+
144
+    /**
145
+     * @return array
146
+     */
147
+    public function getAllowedObjectDomains() {
148
+        return $this->allowedObjectDomains;
149
+    }
150
+
151
+    /**
152
+     * @param array $allowedObjectDomains
153
+     */
154
+    public function setAllowedObjectDomains($allowedObjectDomains) {
155
+        $this->allowedObjectDomains = $allowedObjectDomains;
156
+    }
157
+
158
+    /**
159
+     * @return array
160
+     */
161
+    public function getAllowedFrameDomains() {
162
+        return $this->allowedFrameDomains;
163
+    }
164
+
165
+    /**
166
+     * @param array $allowedFrameDomains
167
+     */
168
+    public function setAllowedFrameDomains($allowedFrameDomains) {
169
+        $this->allowedFrameDomains = $allowedFrameDomains;
170
+    }
171
+
172
+    /**
173
+     * @return array
174
+     */
175
+    public function getAllowedFontDomains() {
176
+        return $this->allowedFontDomains;
177
+    }
178
+
179
+    /**
180
+     * @param array $allowedFontDomains
181
+     */
182
+    public function setAllowedFontDomains($allowedFontDomains) {
183
+        $this->allowedFontDomains = $allowedFontDomains;
184
+    }
185
+
186
+    /**
187
+     * @return array
188
+     */
189
+    public function getAllowedChildSrcDomains() {
190
+        return $this->allowedChildSrcDomains;
191
+    }
192
+
193
+    /**
194
+     * @param array $allowedChildSrcDomains
195
+     */
196
+    public function setAllowedChildSrcDomains($allowedChildSrcDomains) {
197
+        $this->allowedChildSrcDomains = $allowedChildSrcDomains;
198
+    }
199 199
 
200 200
 }
Please login to merge, or discard this patch.