@@ -33,208 +33,208 @@ |
||
33 | 33 | */ |
34 | 34 | interface ICommentsManager { |
35 | 35 | |
36 | - /** |
|
37 | - * @const DELETED_USER type and id for a user that has been deleted |
|
38 | - * @see deleteReferencesOfActor |
|
39 | - * @since 9.0.0 |
|
40 | - * |
|
41 | - * To be used as replacement for user type actors in deleteReferencesOfActor(). |
|
42 | - * |
|
43 | - * User interfaces shall show "Deleted user" as display name, if needed. |
|
44 | - */ |
|
45 | - const DELETED_USER = 'deleted_users'; |
|
46 | - |
|
47 | - /** |
|
48 | - * returns a comment instance |
|
49 | - * |
|
50 | - * @param string $id the ID of the comment |
|
51 | - * @return IComment |
|
52 | - * @throws NotFoundException |
|
53 | - * @since 9.0.0 |
|
54 | - */ |
|
55 | - public function get($id); |
|
56 | - |
|
57 | - /** |
|
58 | - * returns the comment specified by the id and all it's child comments |
|
59 | - * |
|
60 | - * @param string $id |
|
61 | - * @param int $limit max number of entries to return, 0 returns all |
|
62 | - * @param int $offset the start entry |
|
63 | - * @return array |
|
64 | - * @since 9.0.0 |
|
65 | - * |
|
66 | - * The return array looks like this |
|
67 | - * [ |
|
68 | - * 'comment' => IComment, // root comment |
|
69 | - * 'replies' => |
|
70 | - * [ |
|
71 | - * 0 => |
|
72 | - * [ |
|
73 | - * 'comment' => IComment, |
|
74 | - * 'replies' => |
|
75 | - * [ |
|
76 | - * 0 => |
|
77 | - * [ |
|
78 | - * 'comment' => IComment, |
|
79 | - * 'replies' => [ … ] |
|
80 | - * ], |
|
81 | - * … |
|
82 | - * ] |
|
83 | - * ] |
|
84 | - * 1 => |
|
85 | - * [ |
|
86 | - * 'comment' => IComment, |
|
87 | - * 'replies'=> [ … ] |
|
88 | - * ], |
|
89 | - * … |
|
90 | - * ] |
|
91 | - * ] |
|
92 | - */ |
|
93 | - public function getTree($id, $limit = 0, $offset = 0); |
|
94 | - |
|
95 | - /** |
|
96 | - * returns comments for a specific object (e.g. a file). |
|
97 | - * |
|
98 | - * The sort order is always newest to oldest. |
|
99 | - * |
|
100 | - * @param string $objectType the object type, e.g. 'files' |
|
101 | - * @param string $objectId the id of the object |
|
102 | - * @param int $limit optional, number of maximum comments to be returned. if |
|
103 | - * not specified, all comments are returned. |
|
104 | - * @param int $offset optional, starting point |
|
105 | - * @param \DateTime $notOlderThan optional, timestamp of the oldest comments |
|
106 | - * that may be returned |
|
107 | - * @return IComment[] |
|
108 | - * @since 9.0.0 |
|
109 | - */ |
|
110 | - public function getForObject( |
|
111 | - $objectType, |
|
112 | - $objectId, |
|
113 | - $limit = 0, |
|
114 | - $offset = 0, |
|
115 | - \DateTime $notOlderThan = null |
|
116 | - ); |
|
117 | - |
|
118 | - /** |
|
119 | - * @param $objectType string the object type, e.g. 'files' |
|
120 | - * @param $objectId string the id of the object |
|
121 | - * @param \DateTime $notOlderThan optional, timestamp of the oldest comments |
|
122 | - * that may be returned |
|
123 | - * @return Int |
|
124 | - * @since 9.0.0 |
|
125 | - */ |
|
126 | - public function getNumberOfCommentsForObject($objectType, $objectId, \DateTime $notOlderThan = null); |
|
127 | - |
|
128 | - /** |
|
129 | - * creates a new comment and returns it. At this point of time, it is not |
|
130 | - * saved in the used data storage. Use save() after setting other fields |
|
131 | - * of the comment (e.g. message or verb). |
|
132 | - * |
|
133 | - * @param string $actorType the actor type (e.g. 'users') |
|
134 | - * @param string $actorId a user id |
|
135 | - * @param string $objectType the object type the comment is attached to |
|
136 | - * @param string $objectId the object id the comment is attached to |
|
137 | - * @return IComment |
|
138 | - * @since 9.0.0 |
|
139 | - */ |
|
140 | - public function create($actorType, $actorId, $objectType, $objectId); |
|
141 | - |
|
142 | - /** |
|
143 | - * permanently deletes the comment specified by the ID |
|
144 | - * |
|
145 | - * When the comment has child comments, their parent ID will be changed to |
|
146 | - * the parent ID of the item that is to be deleted. |
|
147 | - * |
|
148 | - * @param string $id |
|
149 | - * @return bool |
|
150 | - * @since 9.0.0 |
|
151 | - */ |
|
152 | - public function delete($id); |
|
153 | - |
|
154 | - /** |
|
155 | - * saves the comment permanently |
|
156 | - * |
|
157 | - * if the supplied comment has an empty ID, a new entry comment will be |
|
158 | - * saved and the instance updated with the new ID. |
|
159 | - * |
|
160 | - * Otherwise, an existing comment will be updated. |
|
161 | - * |
|
162 | - * Throws NotFoundException when a comment that is to be updated does not |
|
163 | - * exist anymore at this point of time. |
|
164 | - * |
|
165 | - * @param IComment $comment |
|
166 | - * @return bool |
|
167 | - * @throws NotFoundException |
|
168 | - * @since 9.0.0 |
|
169 | - */ |
|
170 | - public function save(IComment $comment); |
|
171 | - |
|
172 | - /** |
|
173 | - * removes references to specific actor (e.g. on user delete) of a comment. |
|
174 | - * The comment itself must not get lost/deleted. |
|
175 | - * |
|
176 | - * A 'users' type actor (type and id) should get replaced by the |
|
177 | - * value of the DELETED_USER constant of this interface. |
|
178 | - * |
|
179 | - * @param string $actorType the actor type (e.g. 'users') |
|
180 | - * @param string $actorId a user id |
|
181 | - * @return boolean |
|
182 | - * @since 9.0.0 |
|
183 | - */ |
|
184 | - public function deleteReferencesOfActor($actorType, $actorId); |
|
185 | - |
|
186 | - /** |
|
187 | - * deletes all comments made of a specific object (e.g. on file delete) |
|
188 | - * |
|
189 | - * @param string $objectType the object type (e.g. 'files') |
|
190 | - * @param string $objectId e.g. the file id |
|
191 | - * @return boolean |
|
192 | - * @since 9.0.0 |
|
193 | - */ |
|
194 | - public function deleteCommentsAtObject($objectType, $objectId); |
|
195 | - |
|
196 | - /** |
|
197 | - * sets the read marker for a given file to the specified date for the |
|
198 | - * provided user |
|
199 | - * |
|
200 | - * @param string $objectType |
|
201 | - * @param string $objectId |
|
202 | - * @param \DateTime $dateTime |
|
203 | - * @param \OCP\IUser $user |
|
204 | - * @since 9.0.0 |
|
205 | - */ |
|
206 | - public function setReadMark($objectType, $objectId, \DateTime $dateTime, \OCP\IUser $user); |
|
207 | - |
|
208 | - /** |
|
209 | - * returns the read marker for a given file to the specified date for the |
|
210 | - * provided user. It returns null, when the marker is not present, i.e. |
|
211 | - * no comments were marked as read. |
|
212 | - * |
|
213 | - * @param string $objectType |
|
214 | - * @param string $objectId |
|
215 | - * @param \OCP\IUser $user |
|
216 | - * @return \DateTime|null |
|
217 | - * @since 9.0.0 |
|
218 | - */ |
|
219 | - public function getReadMark($objectType, $objectId, \OCP\IUser $user); |
|
220 | - |
|
221 | - /** |
|
222 | - * deletes the read markers for the specified user |
|
223 | - * |
|
224 | - * @param \OCP\IUser $user |
|
225 | - * @return bool |
|
226 | - * @since 9.0.0 |
|
227 | - */ |
|
228 | - public function deleteReadMarksFromUser(\OCP\IUser $user); |
|
229 | - |
|
230 | - /** |
|
231 | - * deletes the read markers on the specified object |
|
232 | - * |
|
233 | - * @param string $objectType |
|
234 | - * @param string $objectId |
|
235 | - * @return bool |
|
236 | - * @since 9.0.0 |
|
237 | - */ |
|
238 | - public function deleteReadMarksOnObject($objectType, $objectId); |
|
36 | + /** |
|
37 | + * @const DELETED_USER type and id for a user that has been deleted |
|
38 | + * @see deleteReferencesOfActor |
|
39 | + * @since 9.0.0 |
|
40 | + * |
|
41 | + * To be used as replacement for user type actors in deleteReferencesOfActor(). |
|
42 | + * |
|
43 | + * User interfaces shall show "Deleted user" as display name, if needed. |
|
44 | + */ |
|
45 | + const DELETED_USER = 'deleted_users'; |
|
46 | + |
|
47 | + /** |
|
48 | + * returns a comment instance |
|
49 | + * |
|
50 | + * @param string $id the ID of the comment |
|
51 | + * @return IComment |
|
52 | + * @throws NotFoundException |
|
53 | + * @since 9.0.0 |
|
54 | + */ |
|
55 | + public function get($id); |
|
56 | + |
|
57 | + /** |
|
58 | + * returns the comment specified by the id and all it's child comments |
|
59 | + * |
|
60 | + * @param string $id |
|
61 | + * @param int $limit max number of entries to return, 0 returns all |
|
62 | + * @param int $offset the start entry |
|
63 | + * @return array |
|
64 | + * @since 9.0.0 |
|
65 | + * |
|
66 | + * The return array looks like this |
|
67 | + * [ |
|
68 | + * 'comment' => IComment, // root comment |
|
69 | + * 'replies' => |
|
70 | + * [ |
|
71 | + * 0 => |
|
72 | + * [ |
|
73 | + * 'comment' => IComment, |
|
74 | + * 'replies' => |
|
75 | + * [ |
|
76 | + * 0 => |
|
77 | + * [ |
|
78 | + * 'comment' => IComment, |
|
79 | + * 'replies' => [ … ] |
|
80 | + * ], |
|
81 | + * … |
|
82 | + * ] |
|
83 | + * ] |
|
84 | + * 1 => |
|
85 | + * [ |
|
86 | + * 'comment' => IComment, |
|
87 | + * 'replies'=> [ … ] |
|
88 | + * ], |
|
89 | + * … |
|
90 | + * ] |
|
91 | + * ] |
|
92 | + */ |
|
93 | + public function getTree($id, $limit = 0, $offset = 0); |
|
94 | + |
|
95 | + /** |
|
96 | + * returns comments for a specific object (e.g. a file). |
|
97 | + * |
|
98 | + * The sort order is always newest to oldest. |
|
99 | + * |
|
100 | + * @param string $objectType the object type, e.g. 'files' |
|
101 | + * @param string $objectId the id of the object |
|
102 | + * @param int $limit optional, number of maximum comments to be returned. if |
|
103 | + * not specified, all comments are returned. |
|
104 | + * @param int $offset optional, starting point |
|
105 | + * @param \DateTime $notOlderThan optional, timestamp of the oldest comments |
|
106 | + * that may be returned |
|
107 | + * @return IComment[] |
|
108 | + * @since 9.0.0 |
|
109 | + */ |
|
110 | + public function getForObject( |
|
111 | + $objectType, |
|
112 | + $objectId, |
|
113 | + $limit = 0, |
|
114 | + $offset = 0, |
|
115 | + \DateTime $notOlderThan = null |
|
116 | + ); |
|
117 | + |
|
118 | + /** |
|
119 | + * @param $objectType string the object type, e.g. 'files' |
|
120 | + * @param $objectId string the id of the object |
|
121 | + * @param \DateTime $notOlderThan optional, timestamp of the oldest comments |
|
122 | + * that may be returned |
|
123 | + * @return Int |
|
124 | + * @since 9.0.0 |
|
125 | + */ |
|
126 | + public function getNumberOfCommentsForObject($objectType, $objectId, \DateTime $notOlderThan = null); |
|
127 | + |
|
128 | + /** |
|
129 | + * creates a new comment and returns it. At this point of time, it is not |
|
130 | + * saved in the used data storage. Use save() after setting other fields |
|
131 | + * of the comment (e.g. message or verb). |
|
132 | + * |
|
133 | + * @param string $actorType the actor type (e.g. 'users') |
|
134 | + * @param string $actorId a user id |
|
135 | + * @param string $objectType the object type the comment is attached to |
|
136 | + * @param string $objectId the object id the comment is attached to |
|
137 | + * @return IComment |
|
138 | + * @since 9.0.0 |
|
139 | + */ |
|
140 | + public function create($actorType, $actorId, $objectType, $objectId); |
|
141 | + |
|
142 | + /** |
|
143 | + * permanently deletes the comment specified by the ID |
|
144 | + * |
|
145 | + * When the comment has child comments, their parent ID will be changed to |
|
146 | + * the parent ID of the item that is to be deleted. |
|
147 | + * |
|
148 | + * @param string $id |
|
149 | + * @return bool |
|
150 | + * @since 9.0.0 |
|
151 | + */ |
|
152 | + public function delete($id); |
|
153 | + |
|
154 | + /** |
|
155 | + * saves the comment permanently |
|
156 | + * |
|
157 | + * if the supplied comment has an empty ID, a new entry comment will be |
|
158 | + * saved and the instance updated with the new ID. |
|
159 | + * |
|
160 | + * Otherwise, an existing comment will be updated. |
|
161 | + * |
|
162 | + * Throws NotFoundException when a comment that is to be updated does not |
|
163 | + * exist anymore at this point of time. |
|
164 | + * |
|
165 | + * @param IComment $comment |
|
166 | + * @return bool |
|
167 | + * @throws NotFoundException |
|
168 | + * @since 9.0.0 |
|
169 | + */ |
|
170 | + public function save(IComment $comment); |
|
171 | + |
|
172 | + /** |
|
173 | + * removes references to specific actor (e.g. on user delete) of a comment. |
|
174 | + * The comment itself must not get lost/deleted. |
|
175 | + * |
|
176 | + * A 'users' type actor (type and id) should get replaced by the |
|
177 | + * value of the DELETED_USER constant of this interface. |
|
178 | + * |
|
179 | + * @param string $actorType the actor type (e.g. 'users') |
|
180 | + * @param string $actorId a user id |
|
181 | + * @return boolean |
|
182 | + * @since 9.0.0 |
|
183 | + */ |
|
184 | + public function deleteReferencesOfActor($actorType, $actorId); |
|
185 | + |
|
186 | + /** |
|
187 | + * deletes all comments made of a specific object (e.g. on file delete) |
|
188 | + * |
|
189 | + * @param string $objectType the object type (e.g. 'files') |
|
190 | + * @param string $objectId e.g. the file id |
|
191 | + * @return boolean |
|
192 | + * @since 9.0.0 |
|
193 | + */ |
|
194 | + public function deleteCommentsAtObject($objectType, $objectId); |
|
195 | + |
|
196 | + /** |
|
197 | + * sets the read marker for a given file to the specified date for the |
|
198 | + * provided user |
|
199 | + * |
|
200 | + * @param string $objectType |
|
201 | + * @param string $objectId |
|
202 | + * @param \DateTime $dateTime |
|
203 | + * @param \OCP\IUser $user |
|
204 | + * @since 9.0.0 |
|
205 | + */ |
|
206 | + public function setReadMark($objectType, $objectId, \DateTime $dateTime, \OCP\IUser $user); |
|
207 | + |
|
208 | + /** |
|
209 | + * returns the read marker for a given file to the specified date for the |
|
210 | + * provided user. It returns null, when the marker is not present, i.e. |
|
211 | + * no comments were marked as read. |
|
212 | + * |
|
213 | + * @param string $objectType |
|
214 | + * @param string $objectId |
|
215 | + * @param \OCP\IUser $user |
|
216 | + * @return \DateTime|null |
|
217 | + * @since 9.0.0 |
|
218 | + */ |
|
219 | + public function getReadMark($objectType, $objectId, \OCP\IUser $user); |
|
220 | + |
|
221 | + /** |
|
222 | + * deletes the read markers for the specified user |
|
223 | + * |
|
224 | + * @param \OCP\IUser $user |
|
225 | + * @return bool |
|
226 | + * @since 9.0.0 |
|
227 | + */ |
|
228 | + public function deleteReadMarksFromUser(\OCP\IUser $user); |
|
229 | + |
|
230 | + /** |
|
231 | + * deletes the read markers on the specified object |
|
232 | + * |
|
233 | + * @param string $objectType |
|
234 | + * @param string $objectId |
|
235 | + * @return bool |
|
236 | + * @since 9.0.0 |
|
237 | + */ |
|
238 | + public function deleteReadMarksOnObject($objectType, $objectId); |
|
239 | 239 | |
240 | 240 | } |
@@ -32,40 +32,40 @@ |
||
32 | 32 | */ |
33 | 33 | class CommentsEvent extends Event { |
34 | 34 | |
35 | - const EVENT_ADD = 'OCP\Comments\ICommentsManager::addComment'; |
|
36 | - const EVENT_UPDATE = 'OCP\Comments\ICommentsManager::updateComment'; |
|
37 | - const EVENT_DELETE = 'OCP\Comments\ICommentsManager::deleteComment'; |
|
35 | + const EVENT_ADD = 'OCP\Comments\ICommentsManager::addComment'; |
|
36 | + const EVENT_UPDATE = 'OCP\Comments\ICommentsManager::updateComment'; |
|
37 | + const EVENT_DELETE = 'OCP\Comments\ICommentsManager::deleteComment'; |
|
38 | 38 | |
39 | - /** @var string */ |
|
40 | - protected $event; |
|
41 | - /** @var IComment */ |
|
42 | - protected $comment; |
|
39 | + /** @var string */ |
|
40 | + protected $event; |
|
41 | + /** @var IComment */ |
|
42 | + protected $comment; |
|
43 | 43 | |
44 | - /** |
|
45 | - * DispatcherEvent constructor. |
|
46 | - * |
|
47 | - * @param string $event |
|
48 | - * @param IComment $comment |
|
49 | - * @since 9.0.0 |
|
50 | - */ |
|
51 | - public function __construct($event, IComment $comment) { |
|
52 | - $this->event = $event; |
|
53 | - $this->comment = $comment; |
|
54 | - } |
|
44 | + /** |
|
45 | + * DispatcherEvent constructor. |
|
46 | + * |
|
47 | + * @param string $event |
|
48 | + * @param IComment $comment |
|
49 | + * @since 9.0.0 |
|
50 | + */ |
|
51 | + public function __construct($event, IComment $comment) { |
|
52 | + $this->event = $event; |
|
53 | + $this->comment = $comment; |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * @return string |
|
58 | - * @since 9.0.0 |
|
59 | - */ |
|
60 | - public function getEvent() { |
|
61 | - return $this->event; |
|
62 | - } |
|
56 | + /** |
|
57 | + * @return string |
|
58 | + * @since 9.0.0 |
|
59 | + */ |
|
60 | + public function getEvent() { |
|
61 | + return $this->event; |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * @return IComment |
|
66 | - * @since 9.0.0 |
|
67 | - */ |
|
68 | - public function getComment() { |
|
69 | - return $this->comment; |
|
70 | - } |
|
64 | + /** |
|
65 | + * @return IComment |
|
66 | + * @since 9.0.0 |
|
67 | + */ |
|
68 | + public function getComment() { |
|
69 | + return $this->comment; |
|
70 | + } |
|
71 | 71 | } |
@@ -36,19 +36,19 @@ |
||
36 | 36 | */ |
37 | 37 | interface ICommentsManagerFactory { |
38 | 38 | |
39 | - /** |
|
40 | - * Constructor for the comments manager factory |
|
41 | - * |
|
42 | - * @param IServerContainer $serverContainer server container |
|
43 | - * @since 9.0.0 |
|
44 | - */ |
|
45 | - public function __construct(IServerContainer $serverContainer); |
|
39 | + /** |
|
40 | + * Constructor for the comments manager factory |
|
41 | + * |
|
42 | + * @param IServerContainer $serverContainer server container |
|
43 | + * @since 9.0.0 |
|
44 | + */ |
|
45 | + public function __construct(IServerContainer $serverContainer); |
|
46 | 46 | |
47 | - /** |
|
48 | - * creates and returns an instance of the ICommentsManager |
|
49 | - * |
|
50 | - * @return ICommentsManager |
|
51 | - * @since 9.0.0 |
|
52 | - */ |
|
53 | - public function getManager(); |
|
47 | + /** |
|
48 | + * creates and returns an instance of the ICommentsManager |
|
49 | + * |
|
50 | + * @return ICommentsManager |
|
51 | + * @since 9.0.0 |
|
52 | + */ |
|
53 | + public function getManager(); |
|
54 | 54 | } |
@@ -40,158 +40,158 @@ |
||
40 | 40 | * @deprecated 8.1.0 Use a AppFramework JSONResponse instead |
41 | 41 | */ |
42 | 42 | class JSON { |
43 | - /** |
|
44 | - * Encode and print $data in JSON format |
|
45 | - * @param array $data The data to use |
|
46 | - * @param bool $setContentType the optional content type |
|
47 | - * @deprecated 8.1.0 Use a AppFramework JSONResponse instead |
|
48 | - */ |
|
49 | - public static function encodedPrint( $data, $setContentType=true ) { |
|
50 | - \OC_JSON::encodedPrint($data, $setContentType); |
|
51 | - } |
|
43 | + /** |
|
44 | + * Encode and print $data in JSON format |
|
45 | + * @param array $data The data to use |
|
46 | + * @param bool $setContentType the optional content type |
|
47 | + * @deprecated 8.1.0 Use a AppFramework JSONResponse instead |
|
48 | + */ |
|
49 | + public static function encodedPrint( $data, $setContentType=true ) { |
|
50 | + \OC_JSON::encodedPrint($data, $setContentType); |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * Check if the user is logged in, send json error msg if not. |
|
55 | - * |
|
56 | - * This method checks if a user is logged in. If not, a json error |
|
57 | - * response will be return and the method will exit from execution |
|
58 | - * of the script. |
|
59 | - * The returned json will be in the format: |
|
60 | - * |
|
61 | - * {"status":"error","data":{"message":"Authentication error."}} |
|
62 | - * |
|
63 | - * Add this call to the start of all ajax method files that requires |
|
64 | - * an authenticated user. |
|
65 | - * @deprecated 8.1.0 Use annotation based ACLs from the AppFramework instead |
|
66 | - */ |
|
67 | - public static function checkLoggedIn() { |
|
68 | - \OC_JSON::checkLoggedIn(); |
|
69 | - } |
|
53 | + /** |
|
54 | + * Check if the user is logged in, send json error msg if not. |
|
55 | + * |
|
56 | + * This method checks if a user is logged in. If not, a json error |
|
57 | + * response will be return and the method will exit from execution |
|
58 | + * of the script. |
|
59 | + * The returned json will be in the format: |
|
60 | + * |
|
61 | + * {"status":"error","data":{"message":"Authentication error."}} |
|
62 | + * |
|
63 | + * Add this call to the start of all ajax method files that requires |
|
64 | + * an authenticated user. |
|
65 | + * @deprecated 8.1.0 Use annotation based ACLs from the AppFramework instead |
|
66 | + */ |
|
67 | + public static function checkLoggedIn() { |
|
68 | + \OC_JSON::checkLoggedIn(); |
|
69 | + } |
|
70 | 70 | |
71 | - /** |
|
72 | - * Check an ajax get/post call if the request token is valid. |
|
73 | - * |
|
74 | - * This method checks for a valid variable 'requesttoken' in $_GET, |
|
75 | - * $_POST and $_SERVER. If a valid token is not found, a json error |
|
76 | - * response will be return and the method will exit from execution |
|
77 | - * of the script. |
|
78 | - * The returned json will be in the format: |
|
79 | - * |
|
80 | - * {"status":"error","data":{"message":"Token expired. Please reload page."}} |
|
81 | - * |
|
82 | - * Add this call to the start of all ajax method files that creates, |
|
83 | - * updates or deletes anything. |
|
84 | - * In cases where you e.g. use an ajax call to load a dialog containing |
|
85 | - * a submittable form, you will need to add the requesttoken first as a |
|
86 | - * parameter to the ajax call, then assign it to the template and finally |
|
87 | - * add a hidden input field also named 'requesttoken' containing the value. |
|
88 | - * @deprecated 8.1.0 Use annotation based CSRF checks from the AppFramework instead |
|
89 | - */ |
|
90 | - public static function callCheck() { |
|
91 | - \OC_JSON::callCheck(); |
|
92 | - } |
|
71 | + /** |
|
72 | + * Check an ajax get/post call if the request token is valid. |
|
73 | + * |
|
74 | + * This method checks for a valid variable 'requesttoken' in $_GET, |
|
75 | + * $_POST and $_SERVER. If a valid token is not found, a json error |
|
76 | + * response will be return and the method will exit from execution |
|
77 | + * of the script. |
|
78 | + * The returned json will be in the format: |
|
79 | + * |
|
80 | + * {"status":"error","data":{"message":"Token expired. Please reload page."}} |
|
81 | + * |
|
82 | + * Add this call to the start of all ajax method files that creates, |
|
83 | + * updates or deletes anything. |
|
84 | + * In cases where you e.g. use an ajax call to load a dialog containing |
|
85 | + * a submittable form, you will need to add the requesttoken first as a |
|
86 | + * parameter to the ajax call, then assign it to the template and finally |
|
87 | + * add a hidden input field also named 'requesttoken' containing the value. |
|
88 | + * @deprecated 8.1.0 Use annotation based CSRF checks from the AppFramework instead |
|
89 | + */ |
|
90 | + public static function callCheck() { |
|
91 | + \OC_JSON::callCheck(); |
|
92 | + } |
|
93 | 93 | |
94 | - /** |
|
95 | - * Send json success msg |
|
96 | - * |
|
97 | - * Return a json success message with optional extra data. |
|
98 | - * @see OCP\JSON::error() for the format to use. |
|
99 | - * |
|
100 | - * @param array $data The data to use |
|
101 | - * @return string json formatted string. |
|
102 | - * @deprecated 8.1.0 Use a AppFramework JSONResponse instead |
|
103 | - */ |
|
104 | - public static function success( $data = array() ) { |
|
105 | - \OC_JSON::success($data); |
|
106 | - } |
|
94 | + /** |
|
95 | + * Send json success msg |
|
96 | + * |
|
97 | + * Return a json success message with optional extra data. |
|
98 | + * @see OCP\JSON::error() for the format to use. |
|
99 | + * |
|
100 | + * @param array $data The data to use |
|
101 | + * @return string json formatted string. |
|
102 | + * @deprecated 8.1.0 Use a AppFramework JSONResponse instead |
|
103 | + */ |
|
104 | + public static function success( $data = array() ) { |
|
105 | + \OC_JSON::success($data); |
|
106 | + } |
|
107 | 107 | |
108 | - /** |
|
109 | - * Send json error msg |
|
110 | - * |
|
111 | - * Return a json error message with optional extra data for |
|
112 | - * error message or app specific data. |
|
113 | - * |
|
114 | - * Example use: |
|
115 | - * |
|
116 | - * $id = [some value] |
|
117 | - * OCP\JSON::error(array('data':array('message':'An error happened', 'id': $id))); |
|
118 | - * |
|
119 | - * Will return the json formatted string: |
|
120 | - * |
|
121 | - * {"status":"error","data":{"message":"An error happened", "id":[some value]}} |
|
122 | - * |
|
123 | - * @param array $data The data to use |
|
124 | - * @return string json formatted error string. |
|
125 | - * @deprecated 8.1.0 Use a AppFramework JSONResponse instead |
|
126 | - */ |
|
127 | - public static function error( $data = array() ) { |
|
128 | - \OC_JSON::error( $data ); |
|
129 | - } |
|
108 | + /** |
|
109 | + * Send json error msg |
|
110 | + * |
|
111 | + * Return a json error message with optional extra data for |
|
112 | + * error message or app specific data. |
|
113 | + * |
|
114 | + * Example use: |
|
115 | + * |
|
116 | + * $id = [some value] |
|
117 | + * OCP\JSON::error(array('data':array('message':'An error happened', 'id': $id))); |
|
118 | + * |
|
119 | + * Will return the json formatted string: |
|
120 | + * |
|
121 | + * {"status":"error","data":{"message":"An error happened", "id":[some value]}} |
|
122 | + * |
|
123 | + * @param array $data The data to use |
|
124 | + * @return string json formatted error string. |
|
125 | + * @deprecated 8.1.0 Use a AppFramework JSONResponse instead |
|
126 | + */ |
|
127 | + public static function error( $data = array() ) { |
|
128 | + \OC_JSON::error( $data ); |
|
129 | + } |
|
130 | 130 | |
131 | - /** |
|
132 | - * Set Content-Type header to jsonrequest |
|
133 | - * @param string $type The content type header |
|
134 | - * @deprecated 8.1.0 Use a AppFramework JSONResponse instead |
|
135 | - */ |
|
136 | - public static function setContentTypeHeader( $type='application/json' ) { |
|
137 | - \OC_JSON::setContentTypeHeader($type); |
|
138 | - } |
|
131 | + /** |
|
132 | + * Set Content-Type header to jsonrequest |
|
133 | + * @param string $type The content type header |
|
134 | + * @deprecated 8.1.0 Use a AppFramework JSONResponse instead |
|
135 | + */ |
|
136 | + public static function setContentTypeHeader( $type='application/json' ) { |
|
137 | + \OC_JSON::setContentTypeHeader($type); |
|
138 | + } |
|
139 | 139 | |
140 | - /** |
|
141 | - * Check if the App is enabled and send JSON error message instead |
|
142 | - * |
|
143 | - * This method checks if a specific app is enabled. If not, a json error |
|
144 | - * response will be return and the method will exit from execution |
|
145 | - * of the script. |
|
146 | - * The returned json will be in the format: |
|
147 | - * |
|
148 | - * {"status":"error","data":{"message":"Application is not enabled."}} |
|
149 | - * |
|
150 | - * Add this call to the start of all ajax method files that requires |
|
151 | - * a specific app to be enabled. |
|
152 | - * |
|
153 | - * @param string $app The app to check |
|
154 | - * @deprecated 8.1.0 Use the AppFramework instead. It will automatically check if the app is enabled. |
|
155 | - */ |
|
156 | - public static function checkAppEnabled( $app ) { |
|
157 | - \OC_JSON::checkAppEnabled($app); |
|
158 | - } |
|
140 | + /** |
|
141 | + * Check if the App is enabled and send JSON error message instead |
|
142 | + * |
|
143 | + * This method checks if a specific app is enabled. If not, a json error |
|
144 | + * response will be return and the method will exit from execution |
|
145 | + * of the script. |
|
146 | + * The returned json will be in the format: |
|
147 | + * |
|
148 | + * {"status":"error","data":{"message":"Application is not enabled."}} |
|
149 | + * |
|
150 | + * Add this call to the start of all ajax method files that requires |
|
151 | + * a specific app to be enabled. |
|
152 | + * |
|
153 | + * @param string $app The app to check |
|
154 | + * @deprecated 8.1.0 Use the AppFramework instead. It will automatically check if the app is enabled. |
|
155 | + */ |
|
156 | + public static function checkAppEnabled( $app ) { |
|
157 | + \OC_JSON::checkAppEnabled($app); |
|
158 | + } |
|
159 | 159 | |
160 | - /** |
|
161 | - * Check if the user is a admin, send json error msg if not |
|
162 | - * |
|
163 | - * This method checks if the current user has admin rights. If not, a json error |
|
164 | - * response will be return and the method will exit from execution |
|
165 | - * of the script. |
|
166 | - * The returned json will be in the format: |
|
167 | - * |
|
168 | - * {"status":"error","data":{"message":"Authentication error."}} |
|
169 | - * |
|
170 | - * Add this call to the start of all ajax method files that requires |
|
171 | - * administrative rights. |
|
172 | - * |
|
173 | - * @deprecated 8.1.0 Use annotation based ACLs from the AppFramework instead |
|
174 | - */ |
|
175 | - public static function checkAdminUser() { |
|
176 | - \OC_JSON::checkAdminUser(); |
|
177 | - } |
|
160 | + /** |
|
161 | + * Check if the user is a admin, send json error msg if not |
|
162 | + * |
|
163 | + * This method checks if the current user has admin rights. If not, a json error |
|
164 | + * response will be return and the method will exit from execution |
|
165 | + * of the script. |
|
166 | + * The returned json will be in the format: |
|
167 | + * |
|
168 | + * {"status":"error","data":{"message":"Authentication error."}} |
|
169 | + * |
|
170 | + * Add this call to the start of all ajax method files that requires |
|
171 | + * administrative rights. |
|
172 | + * |
|
173 | + * @deprecated 8.1.0 Use annotation based ACLs from the AppFramework instead |
|
174 | + */ |
|
175 | + public static function checkAdminUser() { |
|
176 | + \OC_JSON::checkAdminUser(); |
|
177 | + } |
|
178 | 178 | |
179 | - /** |
|
180 | - * Encode JSON |
|
181 | - * @param array $data |
|
182 | - * @return string |
|
183 | - * @deprecated 8.1.0 Use a AppFramework JSONResponse instead |
|
184 | - */ |
|
185 | - public static function encode($data) { |
|
186 | - return \OC_JSON::encode($data); |
|
187 | - } |
|
179 | + /** |
|
180 | + * Encode JSON |
|
181 | + * @param array $data |
|
182 | + * @return string |
|
183 | + * @deprecated 8.1.0 Use a AppFramework JSONResponse instead |
|
184 | + */ |
|
185 | + public static function encode($data) { |
|
186 | + return \OC_JSON::encode($data); |
|
187 | + } |
|
188 | 188 | |
189 | - /** |
|
190 | - * Check is a given user exists - send json error msg if not |
|
191 | - * @param string $user |
|
192 | - * @deprecated 8.1.0 Use a AppFramework JSONResponse instead |
|
193 | - */ |
|
194 | - public static function checkUserExists($user) { |
|
195 | - \OC_JSON::checkUserExists($user); |
|
196 | - } |
|
189 | + /** |
|
190 | + * Check is a given user exists - send json error msg if not |
|
191 | + * @param string $user |
|
192 | + * @deprecated 8.1.0 Use a AppFramework JSONResponse instead |
|
193 | + */ |
|
194 | + public static function checkUserExists($user) { |
|
195 | + \OC_JSON::checkUserExists($user); |
|
196 | + } |
|
197 | 197 | } |
@@ -32,39 +32,39 @@ |
||
32 | 32 | */ |
33 | 33 | class ConsoleEvent extends Event { |
34 | 34 | |
35 | - const EVENT_RUN = 'OC\Console\Application::run'; |
|
35 | + const EVENT_RUN = 'OC\Console\Application::run'; |
|
36 | 36 | |
37 | - /** @var string */ |
|
38 | - protected $event; |
|
37 | + /** @var string */ |
|
38 | + protected $event; |
|
39 | 39 | |
40 | - /** @var string[] */ |
|
41 | - protected $arguments; |
|
40 | + /** @var string[] */ |
|
41 | + protected $arguments; |
|
42 | 42 | |
43 | - /** |
|
44 | - * DispatcherEvent constructor. |
|
45 | - * |
|
46 | - * @param string $event |
|
47 | - * @param string[] $arguments |
|
48 | - * @since 9.0.0 |
|
49 | - */ |
|
50 | - public function __construct($event, array $arguments) { |
|
51 | - $this->event = $event; |
|
52 | - $this->arguments = $arguments; |
|
53 | - } |
|
43 | + /** |
|
44 | + * DispatcherEvent constructor. |
|
45 | + * |
|
46 | + * @param string $event |
|
47 | + * @param string[] $arguments |
|
48 | + * @since 9.0.0 |
|
49 | + */ |
|
50 | + public function __construct($event, array $arguments) { |
|
51 | + $this->event = $event; |
|
52 | + $this->arguments = $arguments; |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * @return string |
|
57 | - * @since 9.0.0 |
|
58 | - */ |
|
59 | - public function getEvent() { |
|
60 | - return $this->event; |
|
61 | - } |
|
55 | + /** |
|
56 | + * @return string |
|
57 | + * @since 9.0.0 |
|
58 | + */ |
|
59 | + public function getEvent() { |
|
60 | + return $this->event; |
|
61 | + } |
|
62 | 62 | |
63 | - /** |
|
64 | - * @return string[] |
|
65 | - * @since 9.0.0 |
|
66 | - */ |
|
67 | - public function getArguments() { |
|
68 | - return $this->arguments; |
|
69 | - } |
|
63 | + /** |
|
64 | + * @return string[] |
|
65 | + * @since 9.0.0 |
|
66 | + */ |
|
67 | + public function getArguments() { |
|
68 | + return $this->arguments; |
|
69 | + } |
|
70 | 70 | } |
@@ -41,106 +41,106 @@ |
||
41 | 41 | * @since 8.0.0 |
42 | 42 | */ |
43 | 43 | interface IUserManager { |
44 | - /** |
|
45 | - * register a user backend |
|
46 | - * |
|
47 | - * @param \OCP\UserInterface $backend |
|
48 | - * @since 8.0.0 |
|
49 | - */ |
|
50 | - public function registerBackend($backend); |
|
44 | + /** |
|
45 | + * register a user backend |
|
46 | + * |
|
47 | + * @param \OCP\UserInterface $backend |
|
48 | + * @since 8.0.0 |
|
49 | + */ |
|
50 | + public function registerBackend($backend); |
|
51 | 51 | |
52 | - /** |
|
53 | - * Get the active backends |
|
54 | - * @return \OCP\UserInterface[] |
|
55 | - * @since 8.0.0 |
|
56 | - */ |
|
57 | - public function getBackends(); |
|
52 | + /** |
|
53 | + * Get the active backends |
|
54 | + * @return \OCP\UserInterface[] |
|
55 | + * @since 8.0.0 |
|
56 | + */ |
|
57 | + public function getBackends(); |
|
58 | 58 | |
59 | - /** |
|
60 | - * remove a user backend |
|
61 | - * |
|
62 | - * @param \OCP\UserInterface $backend |
|
63 | - * @since 8.0.0 |
|
64 | - */ |
|
65 | - public function removeBackend($backend); |
|
59 | + /** |
|
60 | + * remove a user backend |
|
61 | + * |
|
62 | + * @param \OCP\UserInterface $backend |
|
63 | + * @since 8.0.0 |
|
64 | + */ |
|
65 | + public function removeBackend($backend); |
|
66 | 66 | |
67 | - /** |
|
68 | - * remove all user backends |
|
69 | - * @since 8.0.0 |
|
70 | - */ |
|
71 | - public function clearBackends() ; |
|
67 | + /** |
|
68 | + * remove all user backends |
|
69 | + * @since 8.0.0 |
|
70 | + */ |
|
71 | + public function clearBackends() ; |
|
72 | 72 | |
73 | - /** |
|
74 | - * get a user by user id |
|
75 | - * |
|
76 | - * @param string $uid |
|
77 | - * @return \OCP\IUser|null Either the user or null if the specified user does not exist |
|
78 | - * @since 8.0.0 |
|
79 | - */ |
|
80 | - public function get($uid); |
|
73 | + /** |
|
74 | + * get a user by user id |
|
75 | + * |
|
76 | + * @param string $uid |
|
77 | + * @return \OCP\IUser|null Either the user or null if the specified user does not exist |
|
78 | + * @since 8.0.0 |
|
79 | + */ |
|
80 | + public function get($uid); |
|
81 | 81 | |
82 | - /** |
|
83 | - * check if a user exists |
|
84 | - * |
|
85 | - * @param string $uid |
|
86 | - * @return bool |
|
87 | - * @since 8.0.0 |
|
88 | - */ |
|
89 | - public function userExists($uid); |
|
82 | + /** |
|
83 | + * check if a user exists |
|
84 | + * |
|
85 | + * @param string $uid |
|
86 | + * @return bool |
|
87 | + * @since 8.0.0 |
|
88 | + */ |
|
89 | + public function userExists($uid); |
|
90 | 90 | |
91 | - /** |
|
92 | - * Check if the password is valid for the user |
|
93 | - * |
|
94 | - * @param string $loginName |
|
95 | - * @param string $password |
|
96 | - * @return mixed the User object on success, false otherwise |
|
97 | - * @since 8.0.0 |
|
98 | - */ |
|
99 | - public function checkPassword($loginName, $password); |
|
91 | + /** |
|
92 | + * Check if the password is valid for the user |
|
93 | + * |
|
94 | + * @param string $loginName |
|
95 | + * @param string $password |
|
96 | + * @return mixed the User object on success, false otherwise |
|
97 | + * @since 8.0.0 |
|
98 | + */ |
|
99 | + public function checkPassword($loginName, $password); |
|
100 | 100 | |
101 | - /** |
|
102 | - * search by user id |
|
103 | - * |
|
104 | - * @param string $pattern |
|
105 | - * @param int $limit |
|
106 | - * @param int $offset |
|
107 | - * @return \OCP\IUser[] |
|
108 | - * @since 8.0.0 |
|
109 | - */ |
|
110 | - public function search($pattern, $limit = null, $offset = null); |
|
101 | + /** |
|
102 | + * search by user id |
|
103 | + * |
|
104 | + * @param string $pattern |
|
105 | + * @param int $limit |
|
106 | + * @param int $offset |
|
107 | + * @return \OCP\IUser[] |
|
108 | + * @since 8.0.0 |
|
109 | + */ |
|
110 | + public function search($pattern, $limit = null, $offset = null); |
|
111 | 111 | |
112 | - /** |
|
113 | - * search by displayName |
|
114 | - * |
|
115 | - * @param string $pattern |
|
116 | - * @param int $limit |
|
117 | - * @param int $offset |
|
118 | - * @return \OCP\IUser[] |
|
119 | - * @since 8.0.0 |
|
120 | - */ |
|
121 | - public function searchDisplayName($pattern, $limit = null, $offset = null); |
|
112 | + /** |
|
113 | + * search by displayName |
|
114 | + * |
|
115 | + * @param string $pattern |
|
116 | + * @param int $limit |
|
117 | + * @param int $offset |
|
118 | + * @return \OCP\IUser[] |
|
119 | + * @since 8.0.0 |
|
120 | + */ |
|
121 | + public function searchDisplayName($pattern, $limit = null, $offset = null); |
|
122 | 122 | |
123 | - /** |
|
124 | - * @param string $uid |
|
125 | - * @param string $password |
|
126 | - * @throws \Exception |
|
127 | - * @return bool|\OCP\IUser the created user of false |
|
128 | - * @since 8.0.0 |
|
129 | - */ |
|
130 | - public function createUser($uid, $password); |
|
123 | + /** |
|
124 | + * @param string $uid |
|
125 | + * @param string $password |
|
126 | + * @throws \Exception |
|
127 | + * @return bool|\OCP\IUser the created user of false |
|
128 | + * @since 8.0.0 |
|
129 | + */ |
|
130 | + public function createUser($uid, $password); |
|
131 | 131 | |
132 | - /** |
|
133 | - * returns how many users per backend exist (if supported by backend) |
|
134 | - * |
|
135 | - * @return array an array of backend class as key and count number as value |
|
136 | - * @since 8.0.0 |
|
137 | - */ |
|
138 | - public function countUsers(); |
|
132 | + /** |
|
133 | + * returns how many users per backend exist (if supported by backend) |
|
134 | + * |
|
135 | + * @return array an array of backend class as key and count number as value |
|
136 | + * @since 8.0.0 |
|
137 | + */ |
|
138 | + public function countUsers(); |
|
139 | 139 | |
140 | - /** |
|
141 | - * @param \Closure $callback |
|
142 | - * @param string $search |
|
143 | - * @since 9.0.0 |
|
144 | - */ |
|
145 | - public function callForAllUsers (\Closure $callback, $search = ''); |
|
140 | + /** |
|
141 | + * @param \Closure $callback |
|
142 | + * @param string $search |
|
143 | + * @since 9.0.0 |
|
144 | + */ |
|
145 | + public function callForAllUsers (\Closure $callback, $search = ''); |
|
146 | 146 | } |
@@ -31,41 +31,41 @@ |
||
31 | 31 | * @since 8.0.0 |
32 | 32 | */ |
33 | 33 | interface ITempManager { |
34 | - /** |
|
35 | - * Create a temporary file and return the path |
|
36 | - * |
|
37 | - * @param string $postFix |
|
38 | - * @return string |
|
39 | - * @since 8.0.0 |
|
40 | - */ |
|
41 | - public function getTemporaryFile($postFix = ''); |
|
34 | + /** |
|
35 | + * Create a temporary file and return the path |
|
36 | + * |
|
37 | + * @param string $postFix |
|
38 | + * @return string |
|
39 | + * @since 8.0.0 |
|
40 | + */ |
|
41 | + public function getTemporaryFile($postFix = ''); |
|
42 | 42 | |
43 | - /** |
|
44 | - * Create a temporary folder and return the path |
|
45 | - * |
|
46 | - * @param string $postFix |
|
47 | - * @return string |
|
48 | - * @since 8.0.0 |
|
49 | - */ |
|
50 | - public function getTemporaryFolder($postFix = ''); |
|
43 | + /** |
|
44 | + * Create a temporary folder and return the path |
|
45 | + * |
|
46 | + * @param string $postFix |
|
47 | + * @return string |
|
48 | + * @since 8.0.0 |
|
49 | + */ |
|
50 | + public function getTemporaryFolder($postFix = ''); |
|
51 | 51 | |
52 | - /** |
|
53 | - * Remove the temporary files and folders generated during this request |
|
54 | - * @since 8.0.0 |
|
55 | - */ |
|
56 | - public function clean(); |
|
52 | + /** |
|
53 | + * Remove the temporary files and folders generated during this request |
|
54 | + * @since 8.0.0 |
|
55 | + */ |
|
56 | + public function clean(); |
|
57 | 57 | |
58 | - /** |
|
59 | - * Remove old temporary files and folders that were failed to be cleaned |
|
60 | - * @since 8.0.0 |
|
61 | - */ |
|
62 | - public function cleanOld(); |
|
58 | + /** |
|
59 | + * Remove old temporary files and folders that were failed to be cleaned |
|
60 | + * @since 8.0.0 |
|
61 | + */ |
|
62 | + public function cleanOld(); |
|
63 | 63 | |
64 | - /** |
|
65 | - * Get the temporary base directory |
|
66 | - * |
|
67 | - * @return string |
|
68 | - * @since 8.2.0 |
|
69 | - */ |
|
70 | - public function getTempBaseDir(); |
|
64 | + /** |
|
65 | + * Get the temporary base directory |
|
66 | + * |
|
67 | + * @return string |
|
68 | + * @since 8.2.0 |
|
69 | + */ |
|
70 | + public function getTempBaseDir(); |
|
71 | 71 | } |
@@ -34,138 +34,138 @@ |
||
34 | 34 | // This means that they should be used by apps instead of the internal ownCloud classes |
35 | 35 | namespace OCP\Contacts { |
36 | 36 | |
37 | - /** |
|
38 | - * This class provides access to the contacts app. Use this class exclusively if you want to access contacts. |
|
39 | - * |
|
40 | - * Contacts in general will be expressed as an array of key-value-pairs. |
|
41 | - * The keys will match the property names defined in https://tools.ietf.org/html/rfc2426#section-1 |
|
42 | - * |
|
43 | - * Proposed workflow for working with contacts: |
|
44 | - * - search for the contacts |
|
45 | - * - manipulate the results array |
|
46 | - * - createOrUpdate will save the given contacts overwriting the existing data |
|
47 | - * |
|
48 | - * For updating it is mandatory to keep the id. |
|
49 | - * Without an id a new contact will be created. |
|
50 | - * |
|
51 | - * @since 6.0.0 |
|
52 | - */ |
|
53 | - interface IManager { |
|
37 | + /** |
|
38 | + * This class provides access to the contacts app. Use this class exclusively if you want to access contacts. |
|
39 | + * |
|
40 | + * Contacts in general will be expressed as an array of key-value-pairs. |
|
41 | + * The keys will match the property names defined in https://tools.ietf.org/html/rfc2426#section-1 |
|
42 | + * |
|
43 | + * Proposed workflow for working with contacts: |
|
44 | + * - search for the contacts |
|
45 | + * - manipulate the results array |
|
46 | + * - createOrUpdate will save the given contacts overwriting the existing data |
|
47 | + * |
|
48 | + * For updating it is mandatory to keep the id. |
|
49 | + * Without an id a new contact will be created. |
|
50 | + * |
|
51 | + * @since 6.0.0 |
|
52 | + */ |
|
53 | + interface IManager { |
|
54 | 54 | |
55 | - /** |
|
56 | - * This function is used to search and find contacts within the users address books. |
|
57 | - * In case $pattern is empty all contacts will be returned. |
|
58 | - * |
|
59 | - * Example: |
|
60 | - * Following function shows how to search for contacts for the name and the email address. |
|
61 | - * |
|
62 | - * public static function getMatchingRecipient($term) { |
|
63 | - * $cm = \OC::$server->getContactsManager(); |
|
64 | - * // The API is not active -> nothing to do |
|
65 | - * if (!$cm->isEnabled()) { |
|
66 | - * return array(); |
|
67 | - * } |
|
68 | - * |
|
69 | - * $result = $cm->search($term, array('FN', 'EMAIL')); |
|
70 | - * $receivers = array(); |
|
71 | - * foreach ($result as $r) { |
|
72 | - * $id = $r['id']; |
|
73 | - * $fn = $r['FN']; |
|
74 | - * $email = $r['EMAIL']; |
|
75 | - * if (!is_array($email)) { |
|
76 | - * $email = array($email); |
|
77 | - * } |
|
78 | - * |
|
79 | - * // loop through all email addresses of this contact |
|
80 | - * foreach ($email as $e) { |
|
81 | - * $displayName = $fn . " <$e>"; |
|
82 | - * $receivers[] = array( |
|
83 | - * 'id' => $id, |
|
84 | - * 'label' => $displayName, |
|
85 | - * 'value' => $displayName); |
|
86 | - * } |
|
87 | - * } |
|
88 | - * |
|
89 | - * return $receivers; |
|
90 | - * } |
|
91 | - * |
|
92 | - * |
|
93 | - * @param string $pattern which should match within the $searchProperties |
|
94 | - * @param array $searchProperties defines the properties within the query pattern should match |
|
95 | - * @param array $options - for future use. One should always have options! |
|
96 | - * @return array an array of contacts which are arrays of key-value-pairs |
|
97 | - * @since 6.0.0 |
|
98 | - */ |
|
99 | - function search($pattern, $searchProperties = array(), $options = array()); |
|
55 | + /** |
|
56 | + * This function is used to search and find contacts within the users address books. |
|
57 | + * In case $pattern is empty all contacts will be returned. |
|
58 | + * |
|
59 | + * Example: |
|
60 | + * Following function shows how to search for contacts for the name and the email address. |
|
61 | + * |
|
62 | + * public static function getMatchingRecipient($term) { |
|
63 | + * $cm = \OC::$server->getContactsManager(); |
|
64 | + * // The API is not active -> nothing to do |
|
65 | + * if (!$cm->isEnabled()) { |
|
66 | + * return array(); |
|
67 | + * } |
|
68 | + * |
|
69 | + * $result = $cm->search($term, array('FN', 'EMAIL')); |
|
70 | + * $receivers = array(); |
|
71 | + * foreach ($result as $r) { |
|
72 | + * $id = $r['id']; |
|
73 | + * $fn = $r['FN']; |
|
74 | + * $email = $r['EMAIL']; |
|
75 | + * if (!is_array($email)) { |
|
76 | + * $email = array($email); |
|
77 | + * } |
|
78 | + * |
|
79 | + * // loop through all email addresses of this contact |
|
80 | + * foreach ($email as $e) { |
|
81 | + * $displayName = $fn . " <$e>"; |
|
82 | + * $receivers[] = array( |
|
83 | + * 'id' => $id, |
|
84 | + * 'label' => $displayName, |
|
85 | + * 'value' => $displayName); |
|
86 | + * } |
|
87 | + * } |
|
88 | + * |
|
89 | + * return $receivers; |
|
90 | + * } |
|
91 | + * |
|
92 | + * |
|
93 | + * @param string $pattern which should match within the $searchProperties |
|
94 | + * @param array $searchProperties defines the properties within the query pattern should match |
|
95 | + * @param array $options - for future use. One should always have options! |
|
96 | + * @return array an array of contacts which are arrays of key-value-pairs |
|
97 | + * @since 6.0.0 |
|
98 | + */ |
|
99 | + function search($pattern, $searchProperties = array(), $options = array()); |
|
100 | 100 | |
101 | - /** |
|
102 | - * This function can be used to delete the contact identified by the given id |
|
103 | - * |
|
104 | - * @param object $id the unique identifier to a contact |
|
105 | - * @param string $address_book_key identifier of the address book in which the contact shall be deleted |
|
106 | - * @return bool successful or not |
|
107 | - * @since 6.0.0 |
|
108 | - */ |
|
109 | - function delete($id, $address_book_key); |
|
101 | + /** |
|
102 | + * This function can be used to delete the contact identified by the given id |
|
103 | + * |
|
104 | + * @param object $id the unique identifier to a contact |
|
105 | + * @param string $address_book_key identifier of the address book in which the contact shall be deleted |
|
106 | + * @return bool successful or not |
|
107 | + * @since 6.0.0 |
|
108 | + */ |
|
109 | + function delete($id, $address_book_key); |
|
110 | 110 | |
111 | - /** |
|
112 | - * This function is used to create a new contact if 'id' is not given or not present. |
|
113 | - * Otherwise the contact will be updated by replacing the entire data set. |
|
114 | - * |
|
115 | - * @param array $properties this array if key-value-pairs defines a contact |
|
116 | - * @param string $address_book_key identifier of the address book in which the contact shall be created or updated |
|
117 | - * @return array an array representing the contact just created or updated |
|
118 | - * @since 6.0.0 |
|
119 | - */ |
|
120 | - function createOrUpdate($properties, $address_book_key); |
|
111 | + /** |
|
112 | + * This function is used to create a new contact if 'id' is not given or not present. |
|
113 | + * Otherwise the contact will be updated by replacing the entire data set. |
|
114 | + * |
|
115 | + * @param array $properties this array if key-value-pairs defines a contact |
|
116 | + * @param string $address_book_key identifier of the address book in which the contact shall be created or updated |
|
117 | + * @return array an array representing the contact just created or updated |
|
118 | + * @since 6.0.0 |
|
119 | + */ |
|
120 | + function createOrUpdate($properties, $address_book_key); |
|
121 | 121 | |
122 | - /** |
|
123 | - * Check if contacts are available (e.g. contacts app enabled) |
|
124 | - * |
|
125 | - * @return bool true if enabled, false if not |
|
126 | - * @since 6.0.0 |
|
127 | - */ |
|
128 | - function isEnabled(); |
|
122 | + /** |
|
123 | + * Check if contacts are available (e.g. contacts app enabled) |
|
124 | + * |
|
125 | + * @return bool true if enabled, false if not |
|
126 | + * @since 6.0.0 |
|
127 | + */ |
|
128 | + function isEnabled(); |
|
129 | 129 | |
130 | - /** |
|
131 | - * Registers an address book |
|
132 | - * |
|
133 | - * @param \OCP\IAddressBook $address_book |
|
134 | - * @return void |
|
135 | - * @since 6.0.0 |
|
136 | - */ |
|
137 | - function registerAddressBook(\OCP\IAddressBook $address_book); |
|
130 | + /** |
|
131 | + * Registers an address book |
|
132 | + * |
|
133 | + * @param \OCP\IAddressBook $address_book |
|
134 | + * @return void |
|
135 | + * @since 6.0.0 |
|
136 | + */ |
|
137 | + function registerAddressBook(\OCP\IAddressBook $address_book); |
|
138 | 138 | |
139 | - /** |
|
140 | - * Unregisters an address book |
|
141 | - * |
|
142 | - * @param \OCP\IAddressBook $address_book |
|
143 | - * @return void |
|
144 | - * @since 6.0.0 |
|
145 | - */ |
|
146 | - function unregisterAddressBook(\OCP\IAddressBook $address_book); |
|
139 | + /** |
|
140 | + * Unregisters an address book |
|
141 | + * |
|
142 | + * @param \OCP\IAddressBook $address_book |
|
143 | + * @return void |
|
144 | + * @since 6.0.0 |
|
145 | + */ |
|
146 | + function unregisterAddressBook(\OCP\IAddressBook $address_book); |
|
147 | 147 | |
148 | - /** |
|
149 | - * In order to improve lazy loading a closure can be registered which will be called in case |
|
150 | - * address books are actually requested |
|
151 | - * |
|
152 | - * @param \Closure $callable |
|
153 | - * @return void |
|
154 | - * @since 6.0.0 |
|
155 | - */ |
|
156 | - function register(\Closure $callable); |
|
148 | + /** |
|
149 | + * In order to improve lazy loading a closure can be registered which will be called in case |
|
150 | + * address books are actually requested |
|
151 | + * |
|
152 | + * @param \Closure $callable |
|
153 | + * @return void |
|
154 | + * @since 6.0.0 |
|
155 | + */ |
|
156 | + function register(\Closure $callable); |
|
157 | 157 | |
158 | - /** |
|
159 | - * @return array |
|
160 | - * @since 6.0.0 |
|
161 | - */ |
|
162 | - function getAddressBooks(); |
|
158 | + /** |
|
159 | + * @return array |
|
160 | + * @since 6.0.0 |
|
161 | + */ |
|
162 | + function getAddressBooks(); |
|
163 | 163 | |
164 | - /** |
|
165 | - * removes all registered address book instances |
|
166 | - * @return void |
|
167 | - * @since 6.0.0 |
|
168 | - */ |
|
169 | - function clear(); |
|
170 | - } |
|
164 | + /** |
|
165 | + * removes all registered address book instances |
|
166 | + * @return void |
|
167 | + * @since 6.0.0 |
|
168 | + */ |
|
169 | + function clear(); |
|
170 | + } |
|
171 | 171 | } |
@@ -43,193 +43,193 @@ |
||
43 | 43 | * @since 6.0.0 |
44 | 44 | */ |
45 | 45 | interface IDBConnection { |
46 | - /** |
|
47 | - * Gets the QueryBuilder for the connection. |
|
48 | - * |
|
49 | - * @return \OCP\DB\QueryBuilder\IQueryBuilder |
|
50 | - * @since 8.2.0 |
|
51 | - */ |
|
52 | - public function getQueryBuilder(); |
|
53 | - |
|
54 | - /** |
|
55 | - * Used to abstract the ownCloud database access away |
|
56 | - * @param string $sql the sql query with ? placeholder for params |
|
57 | - * @param int $limit the maximum number of rows |
|
58 | - * @param int $offset from which row we want to start |
|
59 | - * @return \Doctrine\DBAL\Driver\Statement The prepared statement. |
|
60 | - * @since 6.0.0 |
|
61 | - */ |
|
62 | - public function prepare($sql, $limit=null, $offset=null); |
|
63 | - |
|
64 | - /** |
|
65 | - * Executes an, optionally parameterized, SQL query. |
|
66 | - * |
|
67 | - * If the query is parameterized, a prepared statement is used. |
|
68 | - * If an SQLLogger is configured, the execution is logged. |
|
69 | - * |
|
70 | - * @param string $query The SQL query to execute. |
|
71 | - * @param string[] $params The parameters to bind to the query, if any. |
|
72 | - * @param array $types The types the previous parameters are in. |
|
73 | - * @return \Doctrine\DBAL\Driver\Statement The executed statement. |
|
74 | - * @since 8.0.0 |
|
75 | - */ |
|
76 | - public function executeQuery($query, array $params = array(), $types = array()); |
|
77 | - |
|
78 | - /** |
|
79 | - * Executes an SQL INSERT/UPDATE/DELETE query with the given parameters |
|
80 | - * and returns the number of affected rows. |
|
81 | - * |
|
82 | - * This method supports PDO binding types as well as DBAL mapping types. |
|
83 | - * |
|
84 | - * @param string $query The SQL query. |
|
85 | - * @param array $params The query parameters. |
|
86 | - * @param array $types The parameter types. |
|
87 | - * @return integer The number of affected rows. |
|
88 | - * @since 8.0.0 |
|
89 | - */ |
|
90 | - public function executeUpdate($query, array $params = array(), array $types = array()); |
|
91 | - |
|
92 | - /** |
|
93 | - * Used to get the id of the just inserted element |
|
94 | - * @param string $table the name of the table where we inserted the item |
|
95 | - * @return int the id of the inserted element |
|
96 | - * @since 6.0.0 |
|
97 | - */ |
|
98 | - public function lastInsertId($table = null); |
|
99 | - |
|
100 | - /** |
|
101 | - * Insert a row if the matching row does not exists. |
|
102 | - * |
|
103 | - * @param string $table The table name (will replace *PREFIX* with the actual prefix) |
|
104 | - * @param array $input data that should be inserted into the table (column name => value) |
|
105 | - * @param array|null $compare List of values that should be checked for "if not exists" |
|
106 | - * If this is null or an empty array, all keys of $input will be compared |
|
107 | - * Please note: text fields (clob) must not be used in the compare array |
|
108 | - * @return int number of inserted rows |
|
109 | - * @throws \Doctrine\DBAL\DBALException |
|
110 | - * @since 6.0.0 - parameter $compare was added in 8.1.0, return type changed from boolean in 8.1.0 |
|
111 | - */ |
|
112 | - public function insertIfNotExist($table, $input, array $compare = null); |
|
113 | - |
|
114 | - /** |
|
115 | - * Insert or update a row value |
|
116 | - * |
|
117 | - * @param string $table |
|
118 | - * @param array $keys (column name => value) |
|
119 | - * @param array $values (column name => value) |
|
120 | - * @param array $updatePreconditionValues ensure values match preconditions (column name => value) |
|
121 | - * @return int number of new rows |
|
122 | - * @throws \Doctrine\DBAL\DBALException |
|
123 | - * @throws PreconditionNotMetException |
|
124 | - * @since 9.0.0 |
|
125 | - */ |
|
126 | - public function setValues($table, array $keys, array $values, array $updatePreconditionValues = []); |
|
127 | - |
|
128 | - /** |
|
129 | - * Start a transaction |
|
130 | - * @since 6.0.0 |
|
131 | - */ |
|
132 | - public function beginTransaction(); |
|
133 | - |
|
134 | - /** |
|
135 | - * Check if a transaction is active |
|
136 | - * |
|
137 | - * @return bool |
|
138 | - * @since 8.2.0 |
|
139 | - */ |
|
140 | - public function inTransaction(); |
|
141 | - |
|
142 | - /** |
|
143 | - * Commit the database changes done during a transaction that is in progress |
|
144 | - * @since 6.0.0 |
|
145 | - */ |
|
146 | - public function commit(); |
|
147 | - |
|
148 | - /** |
|
149 | - * Rollback the database changes done during a transaction that is in progress |
|
150 | - * @since 6.0.0 |
|
151 | - */ |
|
152 | - public function rollBack(); |
|
153 | - |
|
154 | - /** |
|
155 | - * Gets the error code and message as a string for logging |
|
156 | - * @return string |
|
157 | - * @since 6.0.0 |
|
158 | - */ |
|
159 | - public function getError(); |
|
160 | - |
|
161 | - /** |
|
162 | - * Fetch the SQLSTATE associated with the last database operation. |
|
163 | - * |
|
164 | - * @return integer The last error code. |
|
165 | - * @since 8.0.0 |
|
166 | - */ |
|
167 | - public function errorCode(); |
|
168 | - |
|
169 | - /** |
|
170 | - * Fetch extended error information associated with the last database operation. |
|
171 | - * |
|
172 | - * @return array The last error information. |
|
173 | - * @since 8.0.0 |
|
174 | - */ |
|
175 | - public function errorInfo(); |
|
176 | - |
|
177 | - /** |
|
178 | - * Establishes the connection with the database. |
|
179 | - * |
|
180 | - * @return bool |
|
181 | - * @since 8.0.0 |
|
182 | - */ |
|
183 | - public function connect(); |
|
184 | - |
|
185 | - /** |
|
186 | - * Close the database connection |
|
187 | - * @since 8.0.0 |
|
188 | - */ |
|
189 | - public function close(); |
|
190 | - |
|
191 | - /** |
|
192 | - * Quotes a given input parameter. |
|
193 | - * |
|
194 | - * @param mixed $input Parameter to be quoted. |
|
195 | - * @param int $type Type of the parameter. |
|
196 | - * @return string The quoted parameter. |
|
197 | - * @since 8.0.0 |
|
198 | - */ |
|
199 | - public function quote($input, $type = IQueryBuilder::PARAM_STR); |
|
200 | - |
|
201 | - /** |
|
202 | - * Gets the DatabasePlatform instance that provides all the metadata about |
|
203 | - * the platform this driver connects to. |
|
204 | - * |
|
205 | - * @return \Doctrine\DBAL\Platforms\AbstractPlatform The database platform. |
|
206 | - * @since 8.0.0 |
|
207 | - */ |
|
208 | - public function getDatabasePlatform(); |
|
209 | - |
|
210 | - /** |
|
211 | - * Drop a table from the database if it exists |
|
212 | - * |
|
213 | - * @param string $table table name without the prefix |
|
214 | - * @since 8.0.0 |
|
215 | - */ |
|
216 | - public function dropTable($table); |
|
217 | - |
|
218 | - /** |
|
219 | - * Check if a table exists |
|
220 | - * |
|
221 | - * @param string $table table name without the prefix |
|
222 | - * @return bool |
|
223 | - * @since 8.0.0 |
|
224 | - */ |
|
225 | - public function tableExists($table); |
|
226 | - |
|
227 | - /** |
|
228 | - * Escape a parameter to be used in a LIKE query |
|
229 | - * |
|
230 | - * @param string $param |
|
231 | - * @return string |
|
232 | - * @since 9.0.0 |
|
233 | - */ |
|
234 | - public function escapeLikeParameter($param); |
|
46 | + /** |
|
47 | + * Gets the QueryBuilder for the connection. |
|
48 | + * |
|
49 | + * @return \OCP\DB\QueryBuilder\IQueryBuilder |
|
50 | + * @since 8.2.0 |
|
51 | + */ |
|
52 | + public function getQueryBuilder(); |
|
53 | + |
|
54 | + /** |
|
55 | + * Used to abstract the ownCloud database access away |
|
56 | + * @param string $sql the sql query with ? placeholder for params |
|
57 | + * @param int $limit the maximum number of rows |
|
58 | + * @param int $offset from which row we want to start |
|
59 | + * @return \Doctrine\DBAL\Driver\Statement The prepared statement. |
|
60 | + * @since 6.0.0 |
|
61 | + */ |
|
62 | + public function prepare($sql, $limit=null, $offset=null); |
|
63 | + |
|
64 | + /** |
|
65 | + * Executes an, optionally parameterized, SQL query. |
|
66 | + * |
|
67 | + * If the query is parameterized, a prepared statement is used. |
|
68 | + * If an SQLLogger is configured, the execution is logged. |
|
69 | + * |
|
70 | + * @param string $query The SQL query to execute. |
|
71 | + * @param string[] $params The parameters to bind to the query, if any. |
|
72 | + * @param array $types The types the previous parameters are in. |
|
73 | + * @return \Doctrine\DBAL\Driver\Statement The executed statement. |
|
74 | + * @since 8.0.0 |
|
75 | + */ |
|
76 | + public function executeQuery($query, array $params = array(), $types = array()); |
|
77 | + |
|
78 | + /** |
|
79 | + * Executes an SQL INSERT/UPDATE/DELETE query with the given parameters |
|
80 | + * and returns the number of affected rows. |
|
81 | + * |
|
82 | + * This method supports PDO binding types as well as DBAL mapping types. |
|
83 | + * |
|
84 | + * @param string $query The SQL query. |
|
85 | + * @param array $params The query parameters. |
|
86 | + * @param array $types The parameter types. |
|
87 | + * @return integer The number of affected rows. |
|
88 | + * @since 8.0.0 |
|
89 | + */ |
|
90 | + public function executeUpdate($query, array $params = array(), array $types = array()); |
|
91 | + |
|
92 | + /** |
|
93 | + * Used to get the id of the just inserted element |
|
94 | + * @param string $table the name of the table where we inserted the item |
|
95 | + * @return int the id of the inserted element |
|
96 | + * @since 6.0.0 |
|
97 | + */ |
|
98 | + public function lastInsertId($table = null); |
|
99 | + |
|
100 | + /** |
|
101 | + * Insert a row if the matching row does not exists. |
|
102 | + * |
|
103 | + * @param string $table The table name (will replace *PREFIX* with the actual prefix) |
|
104 | + * @param array $input data that should be inserted into the table (column name => value) |
|
105 | + * @param array|null $compare List of values that should be checked for "if not exists" |
|
106 | + * If this is null or an empty array, all keys of $input will be compared |
|
107 | + * Please note: text fields (clob) must not be used in the compare array |
|
108 | + * @return int number of inserted rows |
|
109 | + * @throws \Doctrine\DBAL\DBALException |
|
110 | + * @since 6.0.0 - parameter $compare was added in 8.1.0, return type changed from boolean in 8.1.0 |
|
111 | + */ |
|
112 | + public function insertIfNotExist($table, $input, array $compare = null); |
|
113 | + |
|
114 | + /** |
|
115 | + * Insert or update a row value |
|
116 | + * |
|
117 | + * @param string $table |
|
118 | + * @param array $keys (column name => value) |
|
119 | + * @param array $values (column name => value) |
|
120 | + * @param array $updatePreconditionValues ensure values match preconditions (column name => value) |
|
121 | + * @return int number of new rows |
|
122 | + * @throws \Doctrine\DBAL\DBALException |
|
123 | + * @throws PreconditionNotMetException |
|
124 | + * @since 9.0.0 |
|
125 | + */ |
|
126 | + public function setValues($table, array $keys, array $values, array $updatePreconditionValues = []); |
|
127 | + |
|
128 | + /** |
|
129 | + * Start a transaction |
|
130 | + * @since 6.0.0 |
|
131 | + */ |
|
132 | + public function beginTransaction(); |
|
133 | + |
|
134 | + /** |
|
135 | + * Check if a transaction is active |
|
136 | + * |
|
137 | + * @return bool |
|
138 | + * @since 8.2.0 |
|
139 | + */ |
|
140 | + public function inTransaction(); |
|
141 | + |
|
142 | + /** |
|
143 | + * Commit the database changes done during a transaction that is in progress |
|
144 | + * @since 6.0.0 |
|
145 | + */ |
|
146 | + public function commit(); |
|
147 | + |
|
148 | + /** |
|
149 | + * Rollback the database changes done during a transaction that is in progress |
|
150 | + * @since 6.0.0 |
|
151 | + */ |
|
152 | + public function rollBack(); |
|
153 | + |
|
154 | + /** |
|
155 | + * Gets the error code and message as a string for logging |
|
156 | + * @return string |
|
157 | + * @since 6.0.0 |
|
158 | + */ |
|
159 | + public function getError(); |
|
160 | + |
|
161 | + /** |
|
162 | + * Fetch the SQLSTATE associated with the last database operation. |
|
163 | + * |
|
164 | + * @return integer The last error code. |
|
165 | + * @since 8.0.0 |
|
166 | + */ |
|
167 | + public function errorCode(); |
|
168 | + |
|
169 | + /** |
|
170 | + * Fetch extended error information associated with the last database operation. |
|
171 | + * |
|
172 | + * @return array The last error information. |
|
173 | + * @since 8.0.0 |
|
174 | + */ |
|
175 | + public function errorInfo(); |
|
176 | + |
|
177 | + /** |
|
178 | + * Establishes the connection with the database. |
|
179 | + * |
|
180 | + * @return bool |
|
181 | + * @since 8.0.0 |
|
182 | + */ |
|
183 | + public function connect(); |
|
184 | + |
|
185 | + /** |
|
186 | + * Close the database connection |
|
187 | + * @since 8.0.0 |
|
188 | + */ |
|
189 | + public function close(); |
|
190 | + |
|
191 | + /** |
|
192 | + * Quotes a given input parameter. |
|
193 | + * |
|
194 | + * @param mixed $input Parameter to be quoted. |
|
195 | + * @param int $type Type of the parameter. |
|
196 | + * @return string The quoted parameter. |
|
197 | + * @since 8.0.0 |
|
198 | + */ |
|
199 | + public function quote($input, $type = IQueryBuilder::PARAM_STR); |
|
200 | + |
|
201 | + /** |
|
202 | + * Gets the DatabasePlatform instance that provides all the metadata about |
|
203 | + * the platform this driver connects to. |
|
204 | + * |
|
205 | + * @return \Doctrine\DBAL\Platforms\AbstractPlatform The database platform. |
|
206 | + * @since 8.0.0 |
|
207 | + */ |
|
208 | + public function getDatabasePlatform(); |
|
209 | + |
|
210 | + /** |
|
211 | + * Drop a table from the database if it exists |
|
212 | + * |
|
213 | + * @param string $table table name without the prefix |
|
214 | + * @since 8.0.0 |
|
215 | + */ |
|
216 | + public function dropTable($table); |
|
217 | + |
|
218 | + /** |
|
219 | + * Check if a table exists |
|
220 | + * |
|
221 | + * @param string $table table name without the prefix |
|
222 | + * @return bool |
|
223 | + * @since 8.0.0 |
|
224 | + */ |
|
225 | + public function tableExists($table); |
|
226 | + |
|
227 | + /** |
|
228 | + * Escape a parameter to be used in a LIKE query |
|
229 | + * |
|
230 | + * @param string $param |
|
231 | + * @return string |
|
232 | + * @since 9.0.0 |
|
233 | + */ |
|
234 | + public function escapeLikeParameter($param); |
|
235 | 235 | } |