1 | <?php |
||
2 | |||
3 | use Elgg\Database\Entities; |
||
4 | use Elgg\Database\Clauses\OrderByClause; |
||
5 | |||
6 | /** |
||
7 | * Removes a config setting. |
||
8 | * |
||
9 | * @param string $name The name of the field. |
||
10 | * |
||
11 | * @return bool Success or failure |
||
12 | * |
||
13 | * @see get_config() |
||
14 | * @see set_config() |
||
15 | * |
||
16 | * @deprecated 3.0 Use elgg_remove_config() |
||
17 | */ |
||
18 | function unset_config($name) { |
||
19 | elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use elgg_remove_config().', '3.0'); |
||
20 | return elgg_remove_config($name); |
||
21 | } |
||
22 | |||
23 | /** |
||
24 | * Add or update a config setting. |
||
25 | * |
||
26 | * Plugin authors should use elgg_set_config(). |
||
27 | * |
||
28 | * If the config name already exists, it will be updated to the new value. |
||
29 | * |
||
30 | * @param string $name The name of the configuration value |
||
31 | * @param mixed $value Its value |
||
32 | * |
||
33 | * @return bool |
||
34 | * @see unset_config() |
||
35 | * @see get_config() |
||
36 | * @access private |
||
37 | * |
||
38 | * @deprecated 3.0 Use elgg_save_config() |
||
39 | */ |
||
40 | function set_config($name, $value) { |
||
41 | elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use elgg_save_config().', '3.0'); |
||
42 | return elgg_save_config($name, $value); |
||
43 | } |
||
44 | |||
45 | /** |
||
46 | * Gets a configuration value |
||
47 | * |
||
48 | * Plugin authors should use elgg_get_config(). |
||
49 | * |
||
50 | * @param string $name The name of the config value |
||
51 | * |
||
52 | * @return mixed|null |
||
53 | * @see set_config() |
||
54 | * @see unset_config() |
||
55 | * @access private |
||
56 | * |
||
57 | * @deprecated 3.0 Use elgg_get_config() |
||
58 | */ |
||
59 | function get_config($name) { |
||
60 | elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use elgg_get_config().', '3.0'); |
||
61 | return elgg_get_config($name); |
||
62 | } |
||
63 | |||
64 | /** |
||
65 | * Add an admin area section or child section. |
||
66 | * This is a wrapper for elgg_register_menu_item(). |
||
67 | * |
||
68 | * Used in conjuction with http://elgg.org/admin/section_id/child_section style |
||
69 | * page handler. See the documentation at the top of this file for more details |
||
70 | * on that. |
||
71 | * |
||
72 | * The text of the menu item is obtained from elgg_echo(admin:$parent_id:$menu_id) |
||
73 | * |
||
74 | * This function handles registering the parent if it has not been registered. |
||
75 | * |
||
76 | * @param string $section The menu section to add to |
||
77 | * @param string $menu_id The unique ID of section |
||
78 | * @param string $parent_id If a child section, the parent section id |
||
79 | * @param int $priority The menu item priority |
||
80 | * |
||
81 | * @return bool |
||
82 | * @since 1.8.0 |
||
83 | * |
||
84 | * @deprecated 3.0 Use elgg_register_menu_item() |
||
85 | */ |
||
86 | function elgg_register_admin_menu_item($section, $menu_id, $parent_id = null, $priority = 100) { |
||
87 | elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use elgg_register_menu_item().', '3.0'); |
||
88 | // make sure parent is registered |
||
89 | if ($parent_id && !elgg_is_menu_item_registered('page', $parent_id)) { |
||
90 | elgg_register_admin_menu_item($section, $parent_id); |
||
91 | } |
||
92 | |||
93 | // in the admin section parents never have links |
||
94 | if ($parent_id) { |
||
95 | $href = "admin/$parent_id/$menu_id"; |
||
96 | } else { |
||
97 | $href = "admin/$menu_id"; |
||
98 | } |
||
99 | |||
100 | $name = $menu_id; |
||
101 | if ($parent_id) { |
||
102 | $name = "$parent_id:$name"; |
||
103 | } |
||
104 | |||
105 | return elgg_register_menu_item('page', [ |
||
106 | 'name' => $name, |
||
107 | 'href' => $href, |
||
108 | 'text' => elgg_echo("admin:$name"), |
||
109 | 'context' => 'admin', |
||
110 | 'parent_name' => $parent_id, |
||
111 | 'priority' => $priority, |
||
112 | 'section' => $section |
||
113 | ]); |
||
114 | } |
||
115 | |||
116 | /** |
||
117 | * Mark entities with a particular type and subtype as having access permissions |
||
118 | * that can be changed independently from their parent entity |
||
119 | * |
||
120 | * @param string $type The type - object, user, etc |
||
121 | * @param string $subtype The subtype; all subtypes by default |
||
122 | * |
||
123 | * @return void |
||
124 | * |
||
125 | * @deprecated 3.0 |
||
126 | */ |
||
127 | function register_metadata_as_independent($type, $subtype = '*') { |
||
128 | elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Metadata no longer is access bound.', '3.0'); |
||
129 | } |
||
130 | |||
131 | /** |
||
132 | * Determines whether entities of a given type and subtype should not change |
||
133 | * their metadata in line with their parent entity |
||
134 | * |
||
135 | * @param string $type The type - object, user, etc |
||
136 | * @param string $subtype The entity subtype |
||
137 | * |
||
138 | * @return bool |
||
139 | * |
||
140 | * @deprecated 3.0 |
||
141 | */ |
||
142 | function is_metadata_independent($type, $subtype) { |
||
143 | elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Metadata no longer is access bound.', '3.0'); |
||
144 | |||
145 | return false; |
||
146 | } |
||
147 | |||
148 | /** |
||
149 | * Gets entities based upon attributes in secondary tables. |
||
150 | * |
||
151 | * @warning requires that the entity type be specified and there can only be one |
||
152 | * type. |
||
153 | * |
||
154 | * @see elgg_get_entities() |
||
155 | * |
||
156 | * @param array $options Array in format: |
||
157 | * |
||
158 | * attribute_name_value_pairs => ARR ( |
||
159 | * 'name' => 'name', |
||
160 | * 'value' => 'value', |
||
161 | * 'operand' => '=', (optional) |
||
162 | * 'case_sensitive' => false (optional) |
||
163 | * ) |
||
164 | * If multiple values are sent via |
||
165 | * an array ('value' => array('value1', 'value2') |
||
166 | * the pair's operand will be forced to "IN". |
||
167 | * |
||
168 | * attribute_name_value_pairs_operator => null|STR The operator to use for combining |
||
169 | * (name = value) OPERATOR (name = value); default is AND |
||
170 | * |
||
171 | * @return \ElggEntity[]|mixed If count, int. If not count, array. false on errors. |
||
172 | * @since 1.9.0 |
||
173 | * @throws InvalidArgumentException |
||
174 | * @deprecated 3.0 Use elgg_get_entities() |
||
175 | */ |
||
176 | function elgg_get_entities_from_attributes(array $options = []) { |
||
177 | elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use elgg_get_entities.', '3.0'); |
||
178 | |||
179 | $options['metadata_name_value_pairs'] = elgg_extract('attribute_name_value_pairs', $options, []); |
||
180 | $options['metadata_name_value_pairs_operator'] = elgg_extract('attribute_name_value_pairs_operator', $options, []); |
||
181 | |||
182 | unset($options['attribute_name_value_pairs']); |
||
183 | unset($options['attribute_name_value_pairs_operator']); |
||
184 | |||
185 | return elgg_get_entities($options); |
||
186 | } |
||
187 | |||
188 | /** |
||
189 | * Ban a user |
||
190 | * |
||
191 | * @param int $user_guid The user guid |
||
192 | * @param string $reason A reason |
||
193 | * |
||
194 | * @return bool |
||
195 | * |
||
196 | * @deprecated 3.0 Use \ElggUser->ban() |
||
197 | */ |
||
198 | function ban_user($user_guid, $reason = "") { |
||
199 | elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use \ElggUser::ban()', '3.0'); |
||
200 | |||
201 | $user = get_user($user_guid); |
||
202 | if (!$user) { |
||
203 | return false; |
||
204 | } |
||
205 | |||
206 | return $user->ban($reason); |
||
207 | } |
||
208 | |||
209 | /** |
||
210 | * Unban a user. |
||
211 | * |
||
212 | * @param int $user_guid Unban a user. |
||
213 | * |
||
214 | * @return bool |
||
215 | * |
||
216 | * @deprecated 3.0 Use \ElggUser->unban() |
||
217 | */ |
||
218 | function unban_user($user_guid) { |
||
219 | elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use \ElggUser::unban()', '3.0'); |
||
220 | |||
221 | $user = get_user($user_guid); |
||
222 | if (!$user) { |
||
223 | return false; |
||
224 | } |
||
225 | |||
226 | return $user->unban(); |
||
227 | } |
||
228 | |||
229 | /** |
||
230 | * Makes user $guid an admin. |
||
231 | * |
||
232 | * @param int $user_guid User guid |
||
233 | * |
||
234 | * @return bool |
||
235 | * |
||
236 | * @deprecated 3.0 Use \ElggUser->makeAdmin() |
||
237 | */ |
||
238 | function make_user_admin($user_guid) { |
||
239 | elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use \ElggUser::makeAdmin()', '3.0'); |
||
240 | |||
241 | $user = get_user($user_guid); |
||
242 | if (!$user) { |
||
243 | return false; |
||
244 | } |
||
245 | |||
246 | return $user->makeAdmin(); |
||
247 | } |
||
248 | |||
249 | /** |
||
250 | * Removes user $guid's admin flag. |
||
251 | * |
||
252 | * @param int $user_guid User GUID |
||
253 | * |
||
254 | * @return bool |
||
255 | * |
||
256 | * @deprecated 3.0 Use \ElggUser->removeAdmin() |
||
257 | */ |
||
258 | function remove_user_admin($user_guid) { |
||
259 | elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use \ElggUser::removeAdmin()', '3.0'); |
||
260 | |||
261 | $user = get_user($user_guid); |
||
262 | if (!$user) { |
||
263 | return false; |
||
264 | } |
||
265 | |||
266 | return $user->removeAdmin(); |
||
267 | } |
||
268 | |||
269 | /** |
||
270 | * Gets the validation status of a user. |
||
271 | * |
||
272 | * @param int $user_guid The user's GUID |
||
273 | * @return bool|null Null means status was not set for this user. |
||
274 | * @since 1.8.0 |
||
275 | * |
||
276 | * @deprecated 3.0 Use \ElggUser->isValidated() |
||
277 | */ |
||
278 | function elgg_get_user_validation_status($user_guid) { |
||
279 | elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use \ElggUser::isValidated()', '3.0'); |
||
280 | |||
281 | $user = get_user($user_guid); |
||
282 | if (!$user) { |
||
283 | return false; |
||
284 | } |
||
285 | |||
286 | return $user->isValidated(); |
||
287 | } |
||
288 | |||
289 | /** |
||
290 | * Set the validation status for a user. |
||
291 | * |
||
292 | * @param int $user_guid The user's GUID |
||
293 | * @param bool $status Validated (true) or unvalidated (false) |
||
294 | * @param string $method Optional method to say how a user was validated |
||
295 | * @return bool |
||
296 | * @since 1.8.0 |
||
297 | * |
||
298 | * @deprecated 3.0 Use \ElggUser->setValidationStatus() |
||
299 | */ |
||
300 | function elgg_set_user_validation_status($user_guid, $status, $method = '') { |
||
301 | elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use \ElggUser::setValidationStatus()', '3.0'); |
||
302 | |||
303 | $user = get_user($user_guid); |
||
304 | if (!$user) { |
||
305 | return false; |
||
306 | } |
||
307 | |||
308 | $user->setValidationStatus($status, $method); |
||
309 | return true; |
||
310 | } |
||
311 | |||
312 | /** |
||
313 | * Sets the last action time of the given user to right now. |
||
314 | * |
||
315 | * @param ElggUser|int $user The user or GUID |
||
316 | * @return void |
||
317 | * |
||
318 | * @deprecated 3.0 Use \ElggUser->setLastAction() |
||
319 | */ |
||
320 | function set_last_action($user) { |
||
321 | elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use \ElggUser::setLastAction()', '3.0'); |
||
322 | |||
323 | if (!$user instanceof ElggUser) { |
||
324 | $user = get_user($user); |
||
325 | } |
||
326 | if (!$user) { |
||
327 | return; |
||
328 | } |
||
329 | |||
330 | $user->setLastAction(); |
||
331 | } |
||
332 | |||
333 | /** |
||
334 | * Sets the last logon time of the given user to right now. |
||
335 | * |
||
336 | * @param int $user_guid The user GUID |
||
337 | * @return void |
||
338 | * |
||
339 | * @deprecated 3.0 Use \ElggUser->setLastLogin() |
||
340 | */ |
||
341 | function set_last_login($user_guid) { |
||
342 | elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use \ElggUser::setLastLogin()', '3.0'); |
||
343 | |||
344 | $user = get_user($user_guid); |
||
345 | if (!$user) { |
||
346 | return; |
||
347 | } |
||
348 | |||
349 | $user->setLastLogin(); |
||
350 | } |
||
351 | |||
352 | /** |
||
353 | * Update a specific piece of metadata. |
||
354 | * |
||
355 | * @param int $id ID of the metadata to update |
||
356 | * @param string $name Metadata name |
||
357 | * @param string $value Metadata value |
||
358 | * @param string $value_type Value type |
||
359 | * |
||
360 | * @return bool |
||
361 | * |
||
362 | * @deprecated 3.0 Use \ElggMetadata->save() |
||
363 | */ |
||
364 | function update_metadata($id, $name, $value, $value_type) { |
||
365 | elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use ElggEntity setter or ElggEntity::setMetadata()', '3.0'); |
||
366 | |||
367 | $metadata = elgg_get_metadata_from_id($id); |
||
368 | if (!$metadata) { |
||
369 | return false; |
||
370 | } |
||
371 | |||
372 | $metadata->name = $name; |
||
373 | $metadata->value_type = $value_type; |
||
374 | $metadata->value = $value; |
||
375 | |||
376 | return $metadata->save(); |
||
377 | } |
||
378 | |||
379 | /** |
||
380 | * Create a new metadata object, or update an existing one. |
||
381 | * |
||
382 | * Metadata can be an array by setting allow_multiple to true, but it is an |
||
383 | * indexed array with no control over the indexing. |
||
384 | * |
||
385 | * @param int $entity_guid The entity to attach the metadata to |
||
386 | * @param string $name Name of the metadata |
||
387 | * @param string $value Value of the metadata |
||
388 | * @param string $value_type 'text', 'integer', or '' for automatic detection |
||
389 | * @param int $ignored1 This argument is not used |
||
390 | * @param null $ignored2 This argument is not used |
||
391 | * @param bool $allow_multiple Allow multiple values for one key. Default is false |
||
392 | * |
||
393 | * @return int|false id of metadata or false if failure |
||
394 | * |
||
395 | * @deprecated 3.0 Use \ElggEntity setter or \Entity->setMetadata() |
||
396 | */ |
||
397 | function create_metadata($entity_guid, $name, $value, $value_type = '', $ignored1 = null, |
||
398 | $ignored2 = null, $allow_multiple = false) { |
||
399 | elgg_deprecated_notice( |
||
400 | __FUNCTION__ . ' is deprecated. |
||
401 | Use ElggEntity setter or ElggEntity::setMetadata()', |
||
402 | '3.0'); |
||
403 | |||
404 | $entity = get_entity($entity_guid); |
||
405 | if (!$entity) { |
||
406 | return false; |
||
407 | } |
||
408 | |||
409 | if ($allow_multiple) { |
||
410 | return $entity->setMetadata($name, $value, $value_type, $allow_multiple); |
||
411 | } |
||
412 | |||
413 | $metadata = new ElggMetadata(); |
||
414 | $metadata->entity_guid = $entity_guid; |
||
415 | $metadata->name = $name; |
||
416 | $metadata->value_type = $value_type; |
||
417 | $metadata->value = $value; |
||
418 | return $metadata->save(); |
||
419 | } |
||
420 | |||
421 | /** |
||
422 | * Returns access collections owned by the entity |
||
423 | * |
||
424 | * @see add_access_collection() |
||
425 | * @see get_members_of_access_collection() |
||
426 | * |
||
427 | * @param int $owner_guid GUID of the owner |
||
428 | * @return \ElggAccessCollection[]|false |
||
429 | * |
||
430 | * @deprecated 3.0 Use \Entity->getOwnedAccessCollections() or elgg_get_access_collections() |
||
431 | */ |
||
432 | function get_user_access_collections($owner_guid) { |
||
433 | elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use \ElggEntity->getOwnedAccessCollections() or elgg_get_access_collections()', '3.0'); |
||
434 | |||
435 | return _elgg_services()->accessCollections->getEntityCollections(['owner_guid' => $owner_guid]); |
||
436 | } |
||
437 | |||
438 | |||
439 | /** |
||
440 | * Returns entities based upon metadata. Also accepts all |
||
441 | * options available to elgg_get_entities(). Supports |
||
442 | * the singular option shortcut. |
||
443 | * |
||
444 | * @note Using metadata_names and metadata_values results in a |
||
445 | * "names IN (...) AND values IN (...)" clause. This is subtly |
||
446 | * differently than default multiple metadata_name_value_pairs, which use |
||
447 | * "(name = value) AND (name = value)" clauses. |
||
448 | * |
||
449 | * When in doubt, use name_value_pairs. |
||
450 | * |
||
451 | * To ask for entities that do not have a metadata value, use a custom |
||
452 | * where clause like this: |
||
453 | * |
||
454 | * $options['wheres'][] = "NOT EXISTS ( |
||
455 | * SELECT 1 FROM {$dbprefix}metadata md |
||
456 | * WHERE md.entity_guid = e.guid |
||
457 | * AND md.name = $name |
||
458 | * AND md.value = $value)"; |
||
459 | * |
||
460 | * @see elgg_get_entities() |
||
461 | * |
||
462 | * @param array $options Array in format: |
||
463 | * |
||
464 | * metadata_names => null|ARR metadata names |
||
465 | * |
||
466 | * metadata_values => null|ARR metadata values |
||
467 | * |
||
468 | * metadata_name_value_pairs => null|ARR ( |
||
469 | * name => 'name', |
||
470 | * value => 'value', |
||
471 | * 'operand' => '=', |
||
472 | * 'case_sensitive' => true |
||
473 | * ) |
||
474 | * Currently if multiple values are sent via |
||
475 | * an array (value => array('value1', 'value2') |
||
476 | * the pair's operand will be forced to "IN". |
||
477 | * If passing "IN" as the operand and a string as the value, |
||
478 | * the value must be a properly quoted and escaped string. |
||
479 | * |
||
480 | * metadata_name_value_pairs_operator => null|STR The operator to use for combining |
||
481 | * (name = value) OPERATOR (name = value); default AND |
||
482 | * |
||
483 | * metadata_case_sensitive => BOOL Overall Case sensitive |
||
484 | * |
||
485 | * order_by_metadata => null|ARR array( |
||
486 | * 'name' => 'metadata_text1', |
||
487 | * 'direction' => ASC|DESC, |
||
488 | * 'as' => text|integer |
||
489 | * ) |
||
490 | * Also supports array('name' => 'metadata_text1') |
||
491 | * |
||
492 | * @return \ElggEntity[]|mixed If count, int. If not count, array. false on errors. |
||
493 | * @since 1.7.0 |
||
494 | * |
||
495 | * @deprecated 3.0 Use elgg_get_entities() |
||
496 | */ |
||
497 | function elgg_get_entities_from_metadata(array $options = []) { |
||
498 | elgg_deprecated_notice( |
||
499 | __FUNCTION__ . ' has been deprecated. |
||
500 | elgg_get_entities() now accepts all metadata options. |
||
501 | ', '3.0'); |
||
502 | |||
503 | return elgg_get_entities($options); |
||
504 | } |
||
505 | |||
506 | /** |
||
507 | * Returns a list of entities filtered by provided metadata. |
||
508 | * |
||
509 | * @see elgg_get_entities() |
||
510 | * |
||
511 | * @param array $options Options array |
||
512 | * |
||
513 | * @return array |
||
514 | * @since 1.7.0 |
||
515 | * @deprecated 3.0 Use elgg_list_entities() |
||
516 | */ |
||
517 | function elgg_list_entities_from_metadata($options) { |
||
518 | elgg_deprecated_notice( |
||
519 | __FUNCTION__ . ' has been deprecated. Use elgg_list_entities(). |
||
520 | ', '3.0'); |
||
521 | |||
522 | return elgg_list_entities($options); |
||
523 | } |
||
524 | |||
525 | /** |
||
526 | * Returns entities based upon annotations. |
||
527 | * |
||
528 | * Entity creation time is selected as maxtime. To sort based upon |
||
529 | * this, pass 'order_by' => 'maxtime asc' || 'maxtime desc' |
||
530 | * |
||
531 | * @see elgg_get_entities() |
||
532 | * |
||
533 | * @param array $options Array in format: |
||
534 | * |
||
535 | * annotation_names => null|ARR annotations names |
||
536 | * |
||
537 | * annotation_values => null|ARR annotations values |
||
538 | * |
||
539 | * annotation_name_value_pairs => null|ARR (name = 'name', value => 'value', |
||
540 | * 'operator' => '=', 'case_sensitive' => true) entries. |
||
541 | * Currently if multiple values are sent via an array (value => array('value1', 'value2') |
||
542 | * the pair's operator will be forced to "IN". |
||
543 | * |
||
544 | * annotation_name_value_pairs_operator => null|STR The operator to use for combining |
||
545 | * (name = value) OPERATOR (name = value); default AND |
||
546 | * |
||
547 | * annotation_case_sensitive => BOOL Overall Case sensitive |
||
548 | * |
||
549 | * order_by_annotation => null|ARR (array('name' => 'annotation_text1', 'direction' => ASC|DESC, |
||
550 | * 'as' => text|integer), |
||
551 | * |
||
552 | * Also supports array('name' => 'annotation_text1') |
||
553 | * |
||
554 | * annotation_owner_guids => null|ARR guids for annotaiton owners |
||
555 | * |
||
556 | * @return mixed If count, int. If not count, array. false on errors. |
||
557 | * @since 1.7.0 |
||
558 | * @deprecated 3.0 Use elgg_get_entities() |
||
559 | */ |
||
560 | function elgg_get_entities_from_annotations(array $options = []) { |
||
561 | elgg_deprecated_notice( |
||
562 | __FUNCTION__ . ' has been deprecated. |
||
563 | elgg_get_entities() now accepts all annotation options |
||
564 | ', '3.0'); |
||
565 | |||
566 | return elgg_get_entities($options); |
||
567 | } |
||
568 | |||
569 | /** |
||
570 | * Returns a viewable list of entities from annotations. |
||
571 | * |
||
572 | * @param array $options Options array |
||
573 | * |
||
574 | * @see elgg_get_entities_from_annotations() |
||
575 | * @see elgg_list_entities() |
||
576 | * |
||
577 | * @return string |
||
578 | * @deprecated 3.0 Use elgg_list_entities() |
||
579 | */ |
||
580 | function elgg_list_entities_from_annotations($options = []) { |
||
581 | elgg_deprecated_notice( |
||
582 | __FUNCTION__ . ' has been deprecated. Use elgg_list_entities(). |
||
583 | ', '3.0'); |
||
584 | return elgg_list_entities($options); |
||
585 | } |
||
586 | |||
587 | |||
588 | /** |
||
589 | * Return entities matching a given query joining against a relationship. |
||
590 | * |
||
591 | * By default the function finds relationship targets. E.g.: |
||
592 | * |
||
593 | * // find groups with a particular member: |
||
594 | * $options = [ |
||
595 | * 'relationship' => 'member', |
||
596 | * 'relationship_guid' => $member->guid, |
||
597 | * ]; |
||
598 | * |
||
599 | * // find people the user has friended |
||
600 | * $options = [ |
||
601 | * 'relationship' => 'friend', |
||
602 | * 'relationship_guid' => $user->guid, |
||
603 | * ]; |
||
604 | * |
||
605 | * // find stuff created by friends (not in groups) |
||
606 | * $options = [ |
||
607 | * 'relationship' => 'friend', |
||
608 | * 'relationship_guid' => $user->guid, |
||
609 | * 'relationship_join_on' => 'container_guid', |
||
610 | * ]; |
||
611 | * |
||
612 | * To find relationship subjects, set "inverse_relationship" to true. E.g.: |
||
613 | * |
||
614 | * // find members of a particular group |
||
615 | * $options = [ |
||
616 | * 'relationship' => 'member', |
||
617 | * 'relationship_guid' => $group->guid, |
||
618 | * 'inverse_relationship' => true, |
||
619 | * ]; |
||
620 | * |
||
621 | * // find users who have friended the current user |
||
622 | * $options = [ |
||
623 | * 'relationship' => 'friend', |
||
624 | * 'relationship_guid' => $user->guid, |
||
625 | * 'inverse_relationship' => true, |
||
626 | * ]; |
||
627 | * |
||
628 | * @note You may want to specify "type" because relationship types might be used for other entities. |
||
629 | * |
||
630 | * To ask for entities that do not have a particular relationship to an entity, |
||
631 | * use a custom where clause like the following: |
||
632 | * |
||
633 | * $options['wheres'][] = "NOT EXISTS ( |
||
634 | * SELECT 1 FROM {$db_prefix}entity_relationships |
||
635 | * WHERE guid_one = e.guid |
||
636 | * AND relationship = '$relationship' |
||
637 | * )"; |
||
638 | * |
||
639 | * @see elgg_get_entities() |
||
640 | * |
||
641 | * @param array $options Array in format: |
||
642 | * |
||
643 | * relationship => null|STR Type of the relationship. E.g. "member" |
||
644 | * |
||
645 | * relationship_guid => null|INT GUID of the subject of the relationship, unless "inverse_relationship" is set |
||
646 | * to true, in which case this will specify the target. |
||
647 | * |
||
648 | * inverse_relationship => false|BOOL Are we searching for relationship subjects? By default, the query finds |
||
649 | * targets of relationships. |
||
650 | * |
||
651 | * relationship_join_on => null|STR How the entities relate: guid (default), container_guid, or owner_guid |
||
652 | * Examples using the relationship 'friend': |
||
653 | * 1. use 'guid' if you want the user's friends |
||
654 | * 2. use 'owner_guid' if you want the entities the user's friends own |
||
655 | * (including in groups) |
||
656 | * 3. use 'container_guid' if you want the entities in the user's personal |
||
657 | * space (non-group) |
||
658 | * |
||
659 | * relationship_created_time_lower => null|INT Relationship created time lower boundary in epoch time |
||
660 | * |
||
661 | * relationship_created_time_upper => null|INT Relationship created time upper boundary in epoch time |
||
662 | * |
||
663 | * @return \ElggEntity[]|mixed If count, int. If not count, array. false on errors. |
||
664 | * @since 1.7.0 |
||
665 | * |
||
666 | * @deprecated 3.0 Use elgg_get_entities() |
||
667 | */ |
||
668 | function elgg_get_entities_from_relationship($options) { |
||
669 | elgg_deprecated_notice( |
||
670 | __FUNCTION__ . ' has been deprecated. |
||
671 | elgg_get_entities() now accepts all relationship options. |
||
672 | ', '3.0'); |
||
673 | |||
674 | return elgg_get_entities($options); |
||
675 | } |
||
676 | |||
677 | /** |
||
678 | * Returns a viewable list of entities by relationship |
||
679 | * |
||
680 | * @param array $options Options array for retrieval of entities |
||
681 | * |
||
682 | * @see elgg_list_entities() |
||
683 | * @see elgg_get_entities_from_relationship() |
||
684 | * |
||
685 | * @return string The viewable list of entities |
||
686 | * @deprecated 3.0 Use elgg_list_entities() |
||
687 | */ |
||
688 | function elgg_list_entities_from_relationship(array $options = []) { |
||
689 | elgg_deprecated_notice( |
||
690 | __FUNCTION__ . ' has been deprecated. Use elgg_list_entities(). |
||
691 | ', '3.0'); |
||
692 | |||
693 | return elgg_list_entities($options); |
||
694 | } |
||
695 | |||
696 | /** |
||
697 | * Returns entities based upon private settings. Also accepts all |
||
698 | * options available to elgg_get_entities(). Supports |
||
699 | * the singular option shortcut. |
||
700 | * |
||
701 | * @see elgg_get_entities() |
||
702 | * |
||
703 | * @param array $options Array in format: |
||
704 | * |
||
705 | * private_setting_names => null|ARR private setting names |
||
706 | * |
||
707 | * private_setting_values => null|ARR metadata values |
||
708 | * |
||
709 | * private_setting_name_value_pairs => null|ARR ( |
||
710 | * name => 'name', |
||
711 | * value => 'value', |
||
712 | * 'operand' => '=', |
||
713 | * ) |
||
714 | * Currently if multiple values are sent via |
||
715 | * an array (value => array('value1', 'value2') |
||
716 | * the pair's operand will be forced to "IN". |
||
717 | * |
||
718 | * private_setting_name_value_pairs_operator => null|STR The operator to use for combining |
||
719 | * (name = value) OPERATOR (name = value); default AND |
||
720 | * |
||
721 | * private_setting_name_prefix => STR A prefix to apply to all private settings. Used to |
||
722 | * namespace plugin user settings or by plugins to namespace |
||
723 | * their own settings. |
||
724 | * |
||
725 | * |
||
726 | * @return mixed int If count, int. If not count, array. false on errors. |
||
727 | * @since 1.8.0 |
||
728 | * @deprecated 3.0 Use elgg_get_entities() |
||
729 | */ |
||
730 | function elgg_get_entities_from_private_settings(array $options = []) { |
||
731 | elgg_deprecated_notice( |
||
732 | __FUNCTION__ . ' has been deprecated. |
||
733 | elgg_get_entities() now accepts all private settings options. |
||
734 | ', '3.0'); |
||
735 | |||
736 | return elgg_get_entities($options); |
||
737 | } |
||
738 | |||
739 | /** |
||
740 | * Lists entities from an access collection |
||
741 | * |
||
742 | * @param array $options See elgg_list_entities() and elgg_get_entities_from_access_id() |
||
743 | * |
||
744 | * @see elgg_list_entities() |
||
745 | * @see elgg_get_entities_from_access_id() |
||
746 | * |
||
747 | * @return string |
||
748 | * @deprecated 3.0 Use elgg_list_entities() |
||
749 | */ |
||
750 | function elgg_list_entities_from_access_id(array $options = []) { |
||
751 | elgg_deprecated_notice( |
||
752 | __FUNCTION__ . ' has been deprecated. Use elgg_list_entities(). |
||
753 | ', '3.0'); |
||
754 | |||
755 | return elgg_list_entities($options); |
||
756 | } |
||
757 | |||
758 | /** |
||
759 | * Return entities based upon access id. |
||
760 | * |
||
761 | * @param array $options Any options accepted by {@link elgg_get_entities()} and |
||
762 | * access_id => int The access ID of the entity. |
||
763 | * |
||
764 | * @see elgg_get_entities() |
||
765 | * @return mixed If count, int. If not count, array. false on errors. |
||
766 | * @since 1.7.0 |
||
767 | * |
||
768 | * @deprected 3.0 Use elgg_get_entities() |
||
769 | */ |
||
770 | function elgg_get_entities_from_access_id(array $options = []) { |
||
771 | |||
772 | elgg_deprecated_notice( |
||
773 | __FUNCTION__ . ' has been deprecated. |
||
774 | Use elgg_get_entities() with "access_ids" option. |
||
775 | ', '3.0'); |
||
776 | |||
777 | // restrict the resultset to access collection provided |
||
778 | if (!isset($options['access_id']) && !isset($options['access_ids'])) { |
||
779 | return false; |
||
780 | } |
||
781 | |||
782 | return elgg_get_entities($options); |
||
783 | } |
||
784 | |||
785 | /** |
||
786 | * Get entities ordered by a mathematical calculation on annotation values |
||
787 | * |
||
788 | * @tip Note that this function uses { @link elgg_get_annotations() } to return a list of entities ordered by a mathematical |
||
789 | * calculation on annotation values, and { @link elgg_get_entities_from_annotations() } to return a count of entities |
||
790 | * if $options['count'] is set to a truthy value |
||
791 | * |
||
792 | * @param array $options An options array: |
||
793 | * 'calculation' => The calculation to use. Must be a valid MySQL function. |
||
794 | * Defaults to sum. Result selected as 'annotation_calculation'. |
||
795 | * Don't confuse this "calculation" option with the |
||
796 | * "annotation_calculation" option to elgg_get_annotations(). |
||
797 | * This "calculation" option is applied to each entity's set of |
||
798 | * annotations and is selected as annotation_calculation for that row. |
||
799 | * See the docs for elgg_get_annotations() for proper use of the |
||
800 | * "annotation_calculation" option. |
||
801 | * 'order_by' => The order for the sorting. Defaults to 'annotation_calculation desc'. |
||
802 | * 'annotation_names' => The names of annotations on the entity. |
||
803 | * 'annotation_values' => The values of annotations on the entity. |
||
804 | * |
||
805 | * 'metadata_names' => The name of metadata on the entity. |
||
806 | * 'metadata_values' => The value of metadata on the entitiy. |
||
807 | * 'callback' => Callback function to pass each row through. |
||
808 | * @tip This function is different from other ege* functions, |
||
809 | * as it uses a metastring-based getter function { @link elgg_get_annotations() }, |
||
810 | * therefore the callback function should be a derivative of { @link entity_row_to_elggstar() } |
||
811 | * and not of { @link row_to_annotation() } |
||
812 | * |
||
813 | * @return \ElggEntity[]|int An array or a count of entities |
||
814 | * @see elgg_get_annotations() |
||
815 | * @see elgg_get_entities_from_annotations() |
||
816 | * |
||
817 | * @deprecated 3.0 Use elgg_get_entities() |
||
818 | */ |
||
819 | function elgg_get_entities_from_annotation_calculation($options) { |
||
820 | elgg_deprecated_notice( |
||
821 | __FUNCTION__ . ' has been deprecated. |
||
822 | Use elgg_get_entities() with "annotation_sort_by_calculation" option. |
||
823 | To sort in an ascending order, pass "order_by" => new OrderByClause("annotation_calculation", "asc") |
||
824 | ', '3.0'); |
||
825 | |||
826 | if (empty($options['count'])) { |
||
827 | $options['annotation_sort_by_calculation'] = elgg_extract('calculation', $options, 'sum', false); |
||
828 | } |
||
829 | return Entities::find($options); |
||
830 | } |
||
831 | |||
832 | /** |
||
833 | * List entities from an annotation calculation. |
||
834 | * |
||
835 | * @see elgg_get_entities_from_annotation_calculation() |
||
836 | * |
||
837 | * @param array $options An options array. |
||
838 | * |
||
839 | * @return string |
||
840 | * |
||
841 | * @deprecated 3.0 Use elgg_list_entities() |
||
842 | */ |
||
843 | function elgg_list_entities_from_annotation_calculation($options) { |
||
844 | elgg_deprecated_notice( |
||
845 | __FUNCTION__ . ' has been deprecated. |
||
846 | Use elgg_list_entities() with "annotation_sort_by_calculation" option. |
||
847 | To sort in an ascending order, pass "order_by" => new OrderByClause("annotation_calculation", "asc") |
||
848 | ', '3.0'); |
||
849 | |||
850 | if (empty($options['count'])) { |
||
851 | $options['annotation_sort_by_calculation'] = elgg_extract('calculation', $options, 'sum', false); |
||
852 | } |
||
853 | |||
854 | return elgg_list_entities($options, 'elgg_get_entities'); |
||
855 | } |
||
856 | |||
857 | |||
858 | /** |
||
859 | * Enables or disables a metastrings-based object by its id. |
||
860 | * |
||
861 | * @warning To enable disabled metastrings you must first use |
||
862 | * {@link access_show_hidden_entities()}. |
||
863 | * |
||
864 | * @param int $id The object's ID |
||
865 | * @param string $enabled Value to set to: yes or no |
||
866 | * @param string $type Metastring type: metadata or annotation |
||
867 | * |
||
868 | * @return bool |
||
869 | * @throws InvalidParameterException |
||
870 | * @access private |
||
871 | * |
||
872 | * @deprecated 3.0 Use \ElggAnnotation::enable() |
||
873 | */ |
||
874 | function _elgg_set_metastring_based_object_enabled_by_id($id, $enabled, $type) { |
||
875 | |||
876 | elgg_deprecated_notice( |
||
877 | __FUNCTION__ . ' has been deprecated. |
||
878 | Use ElggAnnotation::enable() |
||
879 | ', '3.0'); |
||
880 | |||
881 | if (!in_array($type, ['annotation', 'annotations'])) { |
||
882 | return false; |
||
883 | } |
||
884 | |||
885 | $annotation = elgg_get_annotation_from_id($id); |
||
886 | if (!$annotation) { |
||
887 | return false; |
||
888 | } |
||
889 | |||
890 | if ($enabled === 'no' || $enabled === 0 || $enabled === false) { |
||
891 | return $annotation->disable(); |
||
892 | } else if ($enabled === 'yes' || $enabled === 1 || $enabled === true) { |
||
893 | return $annotation->enable(); |
||
894 | } |
||
895 | |||
896 | return false; |
||
897 | } |
||
898 | |||
899 | /** |
||
900 | * Returns a singular metastring-based object by its ID. |
||
901 | * |
||
902 | * @param int $id The metastring-based object's ID |
||
903 | * @param string $type The type: annotation or metadata |
||
904 | * @return \ElggExtender |
||
905 | * @access private |
||
906 | * |
||
907 | * @deprecated 3.0 Use elgg_get_metadata_from_id() |
||
908 | */ |
||
909 | function _elgg_get_metastring_based_object_from_id($id, $type) { |
||
910 | |||
911 | elgg_deprecated_notice( |
||
912 | __FUNCTION__ . ' has been deprecated. |
||
913 | Use elgg_get_metadata_from_id() and elgg_get_annotation_from_id() |
||
914 | ', '3.0'); |
||
915 | |||
916 | $id = (int) $id; |
||
917 | if (!$id) { |
||
918 | return false; |
||
919 | } |
||
920 | |||
921 | if ($type == 'metadata') { |
||
922 | $object = elgg_get_metadata_from_id($id); |
||
923 | } else { |
||
924 | $object = elgg_get_annotation_from_id($id); |
||
925 | } |
||
926 | |||
927 | return $object; |
||
928 | } |
||
929 | |||
930 | /** |
||
931 | * Deletes a metastring-based object by its id |
||
932 | * |
||
933 | * @param int $id The object's ID |
||
934 | * @param string $type The object's metastring type: annotation or metadata |
||
935 | * @return bool |
||
936 | * @access private |
||
937 | * |
||
938 | * @deprecated 3.0 Use \ElggMetadata::delete() |
||
939 | */ |
||
940 | function _elgg_delete_metastring_based_object_by_id($id, $type) { |
||
941 | |||
942 | elgg_deprecated_notice( |
||
943 | __FUNCTION__ . ' has been deprecated. |
||
944 | Use ElggMetadata::delete() and ElggAnnotation::delete() |
||
945 | ', '3.0'); |
||
946 | |||
947 | switch ($type) { |
||
948 | case 'annotations': |
||
949 | case 'annotation': |
||
950 | $object = elgg_get_annotation_from_id($id); |
||
951 | break; |
||
952 | |||
953 | case 'metadata': |
||
954 | $object = elgg_get_metadata_from_id($id); |
||
955 | break; |
||
956 | |||
957 | default: |
||
958 | return false; |
||
959 | } |
||
960 | |||
961 | if ($object) { |
||
962 | return $object->delete(); |
||
963 | } |
||
964 | |||
965 | return false; |
||
966 | } |
||
967 | |||
968 | /** |
||
969 | * Get the URL for this metadata |
||
970 | * |
||
971 | * By default this links to the export handler in the current view. |
||
972 | * |
||
973 | * @param int $id Metadata ID |
||
974 | * |
||
975 | * @return mixed |
||
976 | * @deprecated 3.0 |
||
977 | */ |
||
978 | function get_metadata_url($id) { |
||
979 | elgg_deprecated_notice(__FUNCTION__ . ' has been deprecated and will be removed', '3.0'); |
||
980 | $metadata = elgg_get_metadata_from_id($id); |
||
981 | if (!$metadata instanceof ElggMetadata) { |
||
982 | return; |
||
983 | } |
||
984 | |||
985 | return $metadata->getURL(); |
||
986 | } |
||
987 | |||
988 | |||
989 | /** |
||
990 | * Create a new annotation. |
||
991 | * |
||
992 | * @param int $entity_guid GUID of entity to be annotated |
||
993 | * @param string $name Name of annotation |
||
994 | * @param string $value Value of annotation |
||
995 | * @param string $value_type Type of value (default is auto detection) |
||
996 | * @param int $owner_guid Owner of annotation (default is logged in user) |
||
997 | * @param int $access_id Access level of annotation |
||
998 | * |
||
999 | * @return int|bool id on success or false on failure |
||
1000 | * @deprecated 3.0 Use \ElggAnnotation::save() or \ElggEntity::annotate() |
||
1001 | */ |
||
1002 | function create_annotation($entity_guid, $name, $value, $value_type = '', $owner_guid = 0, $access_id = ACCESS_PRIVATE) { |
||
1003 | elgg_deprecated_notice( |
||
1004 | __FUNCTION__ . ' has been deprecated. |
||
1005 | Use ElggAnnotation::save() or ElggEntity::annotate() |
||
1006 | ', '3.0' |
||
1007 | ); |
||
1008 | |||
1009 | $annotation = new ElggAnnotation(); |
||
1010 | $annotation->entity_guid = $entity_guid; |
||
1011 | $annotation->name = $name; |
||
1012 | $annotation->value_type = $value_type; |
||
1013 | $annotation->value = $value; |
||
1014 | $annotation->owner_guid = $owner_guid; |
||
1015 | $annotation->access_id = $access_id; |
||
1016 | |||
1017 | return $annotation->save(); |
||
1018 | } |
||
1019 | |||
1020 | /** |
||
1021 | * Update an annotation. |
||
1022 | * |
||
1023 | * @param int $annotation_id Annotation ID |
||
1024 | * @param string $name Name of annotation |
||
1025 | * @param string $value Value of annotation |
||
1026 | * @param string $value_type Type of value |
||
1027 | * @param int $owner_guid Owner of annotation |
||
1028 | * @param int $access_id Access level of annotation |
||
1029 | * |
||
1030 | * @return bool |
||
1031 | * @deprecated 3.0 Use \ElggAnnotation::save() or \ElggEntity::annotate() |
||
1032 | */ |
||
1033 | function update_annotation($annotation_id, $name, $value, $value_type, $owner_guid, $access_id) { |
||
1034 | elgg_deprecated_notice( |
||
1035 | __FUNCTION__ . ' has been deprecated. |
||
1036 | Use ElggAnnotation::save() or ElggEntity::annotate() |
||
1037 | ', '3.0' |
||
1038 | ); |
||
1039 | |||
1040 | $annotation = elgg_get_annotation_from_id($annotation_id); |
||
1041 | if (!$annotation) { |
||
1042 | return false; |
||
1043 | } |
||
1044 | |||
1045 | $annotation->name = $name; |
||
1046 | $annotation->value_type = $value_type; |
||
1047 | $annotation->value = $value; |
||
1048 | $annotation->owner_guid = $owner_guid; |
||
1049 | $annotation->access_id = $access_id; |
||
1050 | |||
1051 | return $annotation->save(); |
||
1052 | } |
||
1053 | |||
1054 | /** |
||
1055 | * Delete objects with a delete() method. |
||
1056 | * |
||
1057 | * Used as a callback for \ElggBatch. |
||
1058 | * |
||
1059 | * @param object $object The object to disable |
||
1060 | * @return bool |
||
1061 | * @access private |
||
1062 | * |
||
1063 | * @deprecated 3.0 |
||
1064 | */ |
||
1065 | function elgg_batch_delete_callback($object) { |
||
1066 | elgg_deprecated_notice(__FUNCTION__ . ' has been deprecated.', '3.0'); |
||
1067 | |||
1068 | // our db functions return the number of rows affected... |
||
1069 | return $object->delete() ? true : false; |
||
1070 | } |
||
1071 | |||
1072 | /** |
||
1073 | * Sanitise file paths ensuring that they begin and end with slashes etc. |
||
1074 | * |
||
1075 | * @param string $path The path |
||
1076 | * @param bool $append_slash Add tailing slash |
||
1077 | * |
||
1078 | * @return string |
||
1079 | * @deprecated 3.0 Use \Elgg\Project\Paths::sanitize() |
||
1080 | */ |
||
1081 | function sanitise_filepath($path, $append_slash = true) { |
||
1082 | elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use \\Elgg\\Project\\Paths::sanitize().', 3.0); |
||
1083 | |||
1084 | return \Elgg\Project\Paths::sanitize($path, $append_slash); |
||
1085 | } |
||
1086 | |||
1087 | /** |
||
1088 | * Gets a private setting for an entity. |
||
1089 | * |
||
1090 | * Plugin authors can set private data on entities. By default |
||
1091 | * private data will not be searched or exported. |
||
1092 | * |
||
1093 | * @note Internal: Private data is used to store settings for plugins |
||
1094 | * and user settings. |
||
1095 | * |
||
1096 | * @param int $entity_guid The entity GUID |
||
1097 | * @param string $name The name of the setting |
||
1098 | * |
||
1099 | * @return mixed The setting value, or null if does not exist |
||
1100 | * @see set_private_setting() |
||
1101 | * @see get_all_private_settings() |
||
1102 | * @see remove_private_setting() |
||
1103 | * @see remove_all_private_settings() |
||
1104 | * @deprecated 3.0 Use \ElggEntity::getPrivateSetting() |
||
1105 | */ |
||
1106 | function get_private_setting($entity_guid, $name) { |
||
1107 | elgg_deprecated_notice( |
||
1108 | __FUNCTION__ . ' has been deprecated. |
||
1109 | Use ElggEntity::getPrivateSetting() |
||
1110 | ', '3.0'); |
||
1111 | |||
1112 | $ia = elgg_set_ignore_access(true); |
||
1113 | $entity = get_entity($entity_guid); |
||
1114 | elgg_set_ignore_access($ia); |
||
1115 | |||
1116 | if (!$entity) { |
||
1117 | return null; |
||
1118 | } |
||
1119 | |||
1120 | return $entity->getPrivateSetting($name); |
||
1121 | } |
||
1122 | |||
1123 | /** |
||
1124 | * Return an array of all private settings. |
||
1125 | * |
||
1126 | * @param int $entity_guid The entity GUID |
||
1127 | * |
||
1128 | * @return string[] empty array if no settings |
||
1129 | * @see set_private_setting() |
||
1130 | * @see get_private_settings() |
||
1131 | * @see remove_private_setting() |
||
1132 | * @see remove_all_private_settings() |
||
1133 | * @deprecated 3.0 Use \ElggEntity::getAllPrivateSettings() |
||
1134 | */ |
||
1135 | function get_all_private_settings($entity_guid) { |
||
1136 | elgg_deprecated_notice( |
||
1137 | __FUNCTION__ . ' has been deprecated. |
||
1138 | Use ElggEntity::getAllPrivateSettings() |
||
1139 | ', '3.0'); |
||
1140 | |||
1141 | $ia = elgg_set_ignore_access(true); |
||
1142 | $entity = get_entity($entity_guid); |
||
1143 | elgg_set_ignore_access($ia); |
||
1144 | |||
1145 | if (!$entity) { |
||
1146 | return null; |
||
1147 | } |
||
1148 | |||
1149 | return $entity->getAllPrivateSettings(); |
||
1150 | } |
||
1151 | |||
1152 | /** |
||
1153 | * Sets a private setting for an entity. |
||
1154 | * |
||
1155 | * @param int $entity_guid The entity GUID |
||
1156 | * @param string $name The name of the setting |
||
1157 | * @param string $value The value of the setting |
||
1158 | * |
||
1159 | * @return bool |
||
1160 | * @see get_private_setting() |
||
1161 | * @see get_all_private_settings() |
||
1162 | * @see remove_private_setting() |
||
1163 | * @see remove_all_private_settings() |
||
1164 | * @deprecated 3.0 Use \ElggEntity::setPrivateSetting() |
||
1165 | */ |
||
1166 | function set_private_setting($entity_guid, $name, $value) { |
||
1167 | elgg_deprecated_notice( |
||
1168 | __FUNCTION__ . ' has been deprecated. |
||
1169 | Use ElggEntity::setPrivateSetting() |
||
1170 | ', '3.0'); |
||
1171 | |||
1172 | $ia = elgg_set_ignore_access(true); |
||
1173 | $entity = get_entity($entity_guid); |
||
1174 | elgg_set_ignore_access($ia); |
||
1175 | |||
1176 | if (!$entity) { |
||
1177 | return false; |
||
1178 | } |
||
1179 | |||
1180 | return $entity->setPrivateSetting($name, $value); |
||
1181 | } |
||
1182 | |||
1183 | /** |
||
1184 | * Deletes a private setting for an entity. |
||
1185 | * |
||
1186 | * @param int $entity_guid The Entity GUID |
||
1187 | * @param string $name The name of the setting |
||
1188 | * |
||
1189 | * @return bool |
||
1190 | * @see get_private_setting() |
||
1191 | * @see get_all_private_settings() |
||
1192 | * @see set_private_setting() |
||
1193 | * @see remove_all_private_settings() |
||
1194 | * @deprecated 3.0 Use \ElggEntity::removePrivateSetting() |
||
1195 | */ |
||
1196 | function remove_private_setting($entity_guid, $name) { |
||
1197 | elgg_deprecated_notice( |
||
1198 | __FUNCTION__ . ' has been deprecated. |
||
1199 | Use ElggEntity::removePrivateSetting() |
||
1200 | ', '3.0'); |
||
1201 | |||
1202 | $ia = elgg_set_ignore_access(true); |
||
1203 | $entity = get_entity($entity_guid); |
||
1204 | elgg_set_ignore_access($ia); |
||
1205 | |||
1206 | if (!$entity) { |
||
1207 | return null; |
||
1208 | } |
||
1209 | |||
1210 | return $entity->removePrivateSetting($name); |
||
1211 | } |
||
1212 | |||
1213 | /** |
||
1214 | * Deletes all private settings for an entity. |
||
1215 | * |
||
1216 | * @param int $entity_guid The Entity GUID |
||
1217 | * |
||
1218 | * @return bool |
||
1219 | * @see get_private_setting() |
||
1220 | * @see get_all_private_settings() |
||
1221 | * @see set_private_setting() |
||
1222 | * @see remove_private_settings() |
||
1223 | * @deprecated 3.0 \ElggEntity::removeAllPrivateSettings() |
||
1224 | */ |
||
1225 | function remove_all_private_settings($entity_guid) { |
||
1226 | elgg_deprecated_notice( |
||
1227 | __FUNCTION__ . ' has been deprecated. |
||
1228 | Use ElggEntity::removeAllPrivateSettings() |
||
1229 | ', '3.0'); |
||
1230 | |||
1231 | $ia = elgg_set_ignore_access(true); |
||
1232 | $entity = get_entity($entity_guid); |
||
1233 | elgg_set_ignore_access($ia); |
||
1234 | |||
1235 | if (!$entity) { |
||
1236 | return null; |
||
1237 | } |
||
1238 | |||
1239 | return $entity->removeAllPrivateSettings(); |
||
1240 | } |
||
1241 | |||
1242 | /** |
||
1243 | * Enable objects with an enable() method. |
||
1244 | * |
||
1245 | * Used as a callback for \ElggBatch. |
||
1246 | * |
||
1247 | * @param object $object The object to enable |
||
1248 | * @return bool |
||
1249 | * @access private |
||
1250 | * @deprecated 3.0 |
||
1251 | */ |
||
1252 | function elgg_batch_enable_callback($object) { |
||
1253 | elgg_deprecated_notice( |
||
1254 | __FUNCTION__ . ' has been deprecated. |
||
1255 | Perform batch operations on members of the batch. |
||
1256 | ', '3.0'); |
||
1257 | // our db functions return the number of rows affected... |
||
1258 | return $object->enable() ? true : false; |
||
1259 | } |
||
1260 | |||
1261 | /** |
||
1262 | * Disable objects with a disable() method. |
||
1263 | * |
||
1264 | * Used as a callback for \ElggBatch. |
||
1265 | * |
||
1266 | * @param object $object The object to disable |
||
1267 | * @return bool |
||
1268 | * @access private |
||
1269 | * @deprecated 3.0 |
||
1270 | */ |
||
1271 | function elgg_batch_disable_callback($object) { |
||
1272 | elgg_deprecated_notice( |
||
1273 | __FUNCTION__ . ' has been deprecated. |
||
1274 | Perform batch operations on members of the batch. |
||
1275 | ', '3.0'); |
||
1276 | // our db functions return the number of rows affected... |
||
1277 | return $object->disable() ? true : false; |
||
1278 | } |
||
1279 | |||
1280 | /** |
||
1281 | * Registers a page handler for a particular identifier |
||
1282 | * |
||
1283 | * For example, you can register a function called 'blog_page_handler' for the identifier 'blog' |
||
1284 | * For all URLs http://yoururl/blog/*, the blog_page_handler() function will be called. |
||
1285 | * The part of the URL marked with * above will be exploded on '/' characters and passed as an |
||
1286 | * array to that function. |
||
1287 | * For example, the URL http://yoururl/blog/username/friends/ would result in the call: |
||
1288 | * blog_page_handler(array('username','friends'), blog); |
||
1289 | * |
||
1290 | * A request to register a page handler with the same identifier as previously registered |
||
1291 | * handler will replace the previous one. |
||
1292 | * |
||
1293 | * The context is set to the identifier before the registered |
||
1294 | * page handler function is called. For the above example, the context is set to 'blog'. |
||
1295 | * |
||
1296 | * Page handlers should return true to indicate that they handled the request. |
||
1297 | * Requests not handled are forwarded to the front page with a reason of 404. |
||
1298 | * Plugins can register for the 'forward', '404' plugin hook. @see forward() |
||
1299 | * |
||
1300 | * @param string $identifier The page type identifier |
||
1301 | * @param string $function Your function name |
||
1302 | * |
||
1303 | * @return bool Depending on success |
||
1304 | * @deprecated 3.0 Use elgg_register_route() to register a named route |
||
1305 | * @see elgg_register_route() |
||
1306 | */ |
||
1307 | function elgg_register_page_handler($identifier, callable $function) { |
||
1308 | elgg_deprecated_notice( |
||
1309 | __FUNCTION__ . ' has been deprecated. |
||
1310 | Use elgg_register_route() to register a named route or define it in elgg-plugin.php', |
||
1311 | '3.0' |
||
1312 | ); |
||
1313 | return _elgg_services()->routes->registerPageHandler($identifier, $function); |
||
1314 | } |
||
1315 | |||
1316 | /** |
||
1317 | * Unregister a page handler for an identifier |
||
1318 | * |
||
1319 | * Note: to replace a page handler, call elgg_register_page_handler() |
||
1320 | * |
||
1321 | * @param string $identifier The page type identifier |
||
1322 | * |
||
1323 | * @since 1.7.2 |
||
1324 | * @return void |
||
1325 | * @deprecated 3.0 |
||
1326 | */ |
||
1327 | function elgg_unregister_page_handler($identifier) { |
||
1328 | elgg_deprecated_notice( |
||
1329 | __FUNCTION__ . ' has been deprecated. |
||
1330 | Use new routing API to register and unregister routes.', |
||
1331 | '3.0' |
||
1332 | ); |
||
1333 | _elgg_services()->routes->unregisterPageHandler($identifier); |
||
1334 | } |
||
1335 | |||
1336 | /** |
||
1337 | * Alias of elgg_gatekeeper() |
||
1338 | * |
||
1339 | * Used at the top of a page to mark it as logged in users only. |
||
1340 | * |
||
1341 | * @return void |
||
1342 | * @throws \Elgg\GatekeeperException |
||
1343 | * @deprecated 3.0 Use elgg_gatekeeper() |
||
1344 | */ |
||
1345 | function gatekeeper() { |
||
1346 | elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use elgg_gatekeeper()', '3.0'); |
||
1347 | elgg_gatekeeper(); |
||
1348 | } |
||
1349 | |||
1350 | /** |
||
1351 | * Alias of elgg_admin_gatekeeper() |
||
1352 | * |
||
1353 | * Used at the top of a page to mark it as logged in admin or siteadmin only. |
||
1354 | * |
||
1355 | * @return void |
||
1356 | * @throws \Elgg\GatekeeperException |
||
1357 | * @deprecated 3.0 Use elgg_admin_gatekeeper() |
||
1358 | */ |
||
1359 | function admin_gatekeeper() { |
||
1360 | elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use elgg_admin_gatekeeper()', '3.0'); |
||
1361 | elgg_admin_gatekeeper(); |
||
1362 | } |
||
1363 | |||
1364 | /** |
||
1365 | * May the current user access item(s) on this page? If the page owner is a group, |
||
1366 | * membership, visibility, and logged in status are taken into account. |
||
1367 | * |
||
1368 | * @param bool $forward If set to true (default), will forward the page; |
||
1369 | * if set to false, will return true or false. |
||
1370 | * |
||
1371 | * @param int $page_owner_guid The current page owner guid. If not set, this |
||
1372 | * will be pulled from elgg_get_page_owner_guid(). |
||
1373 | * |
||
1374 | * @return bool Will return if $forward is set to false. |
||
1375 | * @deprecated 3.0 Use elgg_group_gatekeeper() |
||
1376 | */ |
||
1377 | function group_gatekeeper($forward = true, $page_owner_guid = null) { |
||
1378 | elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use elgg_group_gatekeeper()', '3.0'); |
||
1379 | return elgg_group_gatekeeper($forward, $page_owner_guid); |
||
1380 | } |
||
1381 | |||
1382 | |||
1383 | /** |
||
1384 | * May the current user access item(s) on this page? If the page owner is a group, |
||
1385 | * membership, visibility, and logged in status are taken into account. |
||
1386 | * |
||
1387 | * @param bool $forward If set to true (default), will forward the page; |
||
1388 | * if set to false, will return true or false. |
||
1389 | * |
||
1390 | * @param int $group_guid The group that owns the page. If not set, this |
||
1391 | * will be pulled from elgg_get_page_owner_guid(). |
||
1392 | * |
||
1393 | * @return bool Will return if $forward is set to false. |
||
1394 | * @throws InvalidParameterException |
||
1395 | * @throws SecurityException |
||
1396 | * @since 1.9.0 |
||
1397 | * @deprecated 3.0 Use elgg_entity_gatekeeper() |
||
1398 | */ |
||
1399 | function elgg_group_gatekeeper($forward = true, $group_guid = null) { |
||
1400 | elgg_deprecated_notice(__FUNCTION__ . ' has been deprecated. Use elgg_entity_gatekeeper()', '3.0'); |
||
1401 | if (null === $group_guid) { |
||
1402 | $group_guid = elgg_get_page_owner_guid(); |
||
1403 | } |
||
1404 | |||
1405 | if (!$group_guid) { |
||
1406 | return true; |
||
1407 | } |
||
1408 | |||
1409 | try { |
||
1410 | return elgg_entity_gatekeeper($group_guid); |
||
1411 | } catch (Exception $ex) { |
||
1412 | if ($forward) { |
||
1413 | throw $ex; |
||
1414 | } else { |
||
1415 | return false; |
||
1416 | } |
||
1417 | } |
||
1418 | } |
||
1419 | |||
1420 | /** |
||
1421 | * Retrieve rows from the database. |
||
1422 | * |
||
1423 | * Queries are executed with {@link \Elgg\Database::getResults} and results |
||
1424 | * are retrieved with {@link \PDO::fetchObject()}. If a callback |
||
1425 | * function $callback is defined, each row will be passed as the single |
||
1426 | * argument to $callback. If no callback function is defined, the |
||
1427 | * entire result set is returned as an array. |
||
1428 | * |
||
1429 | * @param string $query The query being passed. |
||
1430 | * @param callable $callback Optionally, the name of a function to call back to on each row |
||
1431 | * @param array $params Query params. E.g. [1, 'steve'] or [':id' => 1, ':name' => 'steve'] |
||
1432 | * |
||
1433 | * @return array An array of database result objects or callback function results. If the query |
||
1434 | * returned nothing, an empty array. |
||
1435 | * @throws DatabaseException |
||
1436 | * @deprecated 3.0 Use elgg()->db->getData() |
||
1437 | */ |
||
1438 | function get_data($query, $callback = null, array $params = []) { |
||
1439 | elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use elgg()->db', '3.0'); |
||
1440 | return elgg()->db->getData($query, $callback, $params); |
||
1441 | } |
||
1442 | |||
1443 | /** |
||
1444 | * Retrieve a single row from the database. |
||
1445 | * |
||
1446 | * Similar to {@link get_data()} but returns only the first row |
||
1447 | * matched. If a callback function $callback is specified, the row will be passed |
||
1448 | * as the only argument to $callback. |
||
1449 | * |
||
1450 | * @param string $query The query to execute. |
||
1451 | * @param callable $callback A callback function to apply to the row |
||
1452 | * @param array $params Query params. E.g. [1, 'steve'] or [':id' => 1, ':name' => 'steve'] |
||
1453 | * |
||
1454 | * @return mixed A single database result object or the result of the callback function. |
||
1455 | * @throws DatabaseException |
||
1456 | * @deprecated 3.0 Use elgg()->db->getDataRow() |
||
1457 | */ |
||
1458 | function get_data_row($query, $callback = null, array $params = []) { |
||
1459 | elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use elgg()->db', '3.0'); |
||
1460 | return elgg()->db->getDataRow($query, $callback, $params); |
||
1461 | } |
||
1462 | |||
1463 | /** |
||
1464 | * Insert a row into the database. |
||
1465 | * |
||
1466 | * @note Altering the DB invalidates all queries in the query cache |
||
1467 | * |
||
1468 | * @param string $query The query to execute. |
||
1469 | * @param array $params Query params. E.g. [1, 'steve'] or [':id' => 1, ':name' => 'steve'] |
||
1470 | * |
||
1471 | * @return int|false The database id of the inserted row if a AUTO_INCREMENT field is |
||
1472 | * defined, 0 if not, and false on failure. |
||
1473 | * @throws DatabaseException |
||
1474 | * @deprecated 3.0 Use elgg()->db->insertData() |
||
1475 | */ |
||
1476 | function insert_data($query, array $params = []) { |
||
1477 | elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use elgg()->db', '3.0'); |
||
1478 | return elgg()->db->insertData($query, $params); |
||
1479 | } |
||
1480 | |||
1481 | /** |
||
1482 | * Update a row in the database. |
||
1483 | * |
||
1484 | * @note Altering the DB invalidates all queries in the query cache |
||
1485 | * |
||
1486 | * @param string $query The query to run. |
||
1487 | * @param array $params Query params. E.g. [1, 'steve'] or [':id' => 1, ':name' => 'steve'] |
||
1488 | * @param bool $get_num_rows Return the number of rows affected (default: false). |
||
1489 | * |
||
1490 | * @return bool |
||
1491 | * @throws DatabaseException |
||
1492 | * @deprecated 3.0 Use elgg()->db->updateData() |
||
1493 | */ |
||
1494 | function update_data($query, array $params = [], $get_num_rows = false) { |
||
1495 | elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use elgg()->db', '3.0'); |
||
1496 | return elgg()->db->updateData($query, $get_num_rows, $params); |
||
1497 | } |
||
1498 | |||
1499 | /** |
||
1500 | * Remove a row from the database. |
||
1501 | * |
||
1502 | * @note Altering the DB invalidates all queries in the query cache |
||
1503 | * |
||
1504 | * @param string $query The SQL query to run |
||
1505 | * @param array $params Query params. E.g. [1, 'steve'] or [':id' => 1, ':name' => 'steve'] |
||
1506 | * |
||
1507 | * @return int|false The number of affected rows or false on failure |
||
1508 | * @throws DatabaseException |
||
1509 | * @deprecated 3.0 Use elgg()->db->deleteData() |
||
1510 | */ |
||
1511 | function delete_data($query, array $params = []) { |
||
1512 | elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use elgg()->db', '3.0'); |
||
1513 | return elgg()->db->deleteData($query, $params); |
||
1514 | } |
||
1515 | |||
1516 | /** |
||
1517 | * When given a full path, finds translation files and loads them |
||
1518 | * |
||
1519 | * @param string $path Full path |
||
1520 | * @param bool $load_all If true all languages are loaded, if |
||
1521 | * false only the current language + en are loaded |
||
1522 | * @param string $language Language code if other than current + en |
||
1523 | * |
||
1524 | * @return bool success |
||
1525 | * @deprecated 3.0 |
||
1526 | */ |
||
1527 | function register_translations($path, $load_all = false, $language = null) { |
||
1528 | elgg_deprecated_notice(__FUNCTION__ . ' is deprecated and should not be used', '3.0'); |
||
1529 | |||
1530 | return elgg()->translator->registerTranslations($path, $load_all, $language); |
||
1531 | } |
||
1532 | |||
1533 | /** |
||
1534 | * Reload all translations from all registered paths. |
||
1535 | * |
||
1536 | * This is only called by functions which need to know all possible translations. |
||
1537 | * |
||
1538 | * @todo Better on demand loading based on language_paths array |
||
1539 | * |
||
1540 | * @return void |
||
1541 | * @deprecated 3.0 |
||
1542 | */ |
||
1543 | function reload_all_translations() { |
||
1544 | elgg_deprecated_notice(__FUNCTION__ . ' is deprecated and should not be used', '3.0'); |
||
1545 | |||
1546 | return elgg()->translator->reloadAllTranslations(); |
||
1547 | } |
||
1548 | |||
1549 | /** |
||
1550 | * Returns a viewable list of entities based on the registered types. |
||
1551 | * |
||
1552 | * @see elgg_view_entity_list() |
||
1553 | * |
||
1554 | * @param array $options Any elgg_get_entity() options plus: |
||
1555 | * |
||
1556 | * full_view => BOOL Display full view entities |
||
1557 | * |
||
1558 | * list_type_toggle => BOOL Display gallery / list switch |
||
1559 | * |
||
1560 | * allowed_types => true|ARRAY True to show all types or an array of valid types. |
||
1561 | * |
||
1562 | * pagination => BOOL Display pagination links |
||
1563 | * |
||
1564 | * @return string A viewable list of entities |
||
1565 | * @since 1.7.0 |
||
1566 | * |
||
1567 | * @deprecated 3.0 Use elgg_list_entities() |
||
1568 | */ |
||
1569 | function elgg_list_registered_entities(array $options = []) { |
||
1570 | elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use elgg_list_entities()', '3.0'); |
||
1571 | |||
1572 | elgg_register_rss_link(); |
||
1573 | |||
1574 | $defaults = [ |
||
1575 | 'full_view' => false, |
||
1576 | 'allowed_types' => true, |
||
1577 | 'list_type_toggle' => false, |
||
1578 | 'pagination' => true, |
||
1579 | 'offset' => 0, |
||
1580 | 'types' => [], |
||
1581 | 'type_subtype_pairs' => [], |
||
1582 | ]; |
||
1583 | |||
1584 | $options = array_merge($defaults, $options); |
||
1585 | |||
1586 | $types = get_registered_entity_types(); |
||
1587 | |||
1588 | foreach ($types as $type => $subtype_array) { |
||
1589 | if (in_array($type, $options['allowed_types']) || $options['allowed_types'] === true) { |
||
1590 | // you must explicitly register types to show up in here and in search for objects |
||
1591 | if ($type == 'object') { |
||
1592 | if (is_array($subtype_array) && count($subtype_array)) { |
||
1593 | $options['type_subtype_pairs'][$type] = $subtype_array; |
||
1594 | } |
||
1595 | } else { |
||
1596 | if (is_array($subtype_array) && count($subtype_array)) { |
||
1597 | $options['type_subtype_pairs'][$type] = $subtype_array; |
||
1598 | } else { |
||
1599 | $options['type_subtype_pairs'][$type] = ELGG_ENTITIES_ANY_VALUE; |
||
1600 | } |
||
1601 | } |
||
1602 | } |
||
1603 | } |
||
1604 | |||
1605 | if (!empty($options['type_subtype_pairs'])) { |
||
1606 | $count = elgg_get_entities(array_merge(['count' => true], $options)); |
||
1607 | if ($count > 0) { |
||
1608 | $entities = elgg_get_entities($options); |
||
1609 | } else { |
||
1610 | $entities = []; |
||
1611 | } |
||
1612 | } else { |
||
1613 | $count = 0; |
||
1614 | $entities = []; |
||
1615 | } |
||
1616 | |||
1617 | $options['count'] = $count; |
||
1618 | return elgg_view_entity_list($entities, $options); |
||
1619 | } |
||
1620 | |||
1621 | /** |
||
1622 | * Returns the version of the upgrade filename. |
||
1623 | * |
||
1624 | * @param string $filename The upgrade filename. No full path. |
||
1625 | * @return int|false |
||
1626 | * @since 1.8.0 |
||
1627 | * @deprecated 3.0 Use asynchronous upgrades |
||
1628 | */ |
||
1629 | function elgg_get_upgrade_file_version($filename) { |
||
1630 | elgg_deprecated_notice(__FUNCTION__ . ' has been deprecated. Use asynchronous upgrades instead', '3.0'); |
||
1631 | |||
1632 | preg_match('/^([0-9]{10})([\.a-z0-9-_]+)?\.(php)$/i', $filename, $matches); |
||
1633 | |||
1634 | if (isset($matches[1])) { |
||
1635 | return (int) $matches[1]; |
||
1636 | } |
||
1637 | |||
1638 | return false; |
||
1639 | } |
||
1640 | |||
1641 | /** |
||
1642 | * Returns a list of upgrade files relative to the $upgrade_path dir. |
||
1643 | * |
||
1644 | * @param string $upgrade_path The directory that has upgrade scripts |
||
1645 | * @return array|false |
||
1646 | * @access private |
||
1647 | * @deprecated 3.0 Use asynchronous upgrades |
||
1648 | */ |
||
1649 | function elgg_get_upgrade_files($upgrade_path = null) { |
||
1650 | elgg_deprecated_notice(__FUNCTION__ . ' has been deprecated. Use asynchronous upgrades instead', '3.0'); |
||
1651 | |||
1652 | if (!$upgrade_path) { |
||
1653 | $upgrade_path = elgg_get_engine_path() . '/lib/upgrades/'; |
||
1654 | } |
||
1655 | $upgrade_path = \Elgg\Project\Paths::sanitize($upgrade_path); |
||
1656 | $handle = opendir($upgrade_path); |
||
1657 | |||
1658 | if (!$handle) { |
||
1659 | return false; |
||
1660 | } |
||
1661 | |||
1662 | $upgrade_files = []; |
||
1663 | |||
1664 | while ($upgrade_file = readdir($handle)) { |
||
1665 | // make sure this is a well formed upgrade. |
||
1666 | if (is_dir($upgrade_path . '$upgrade_file')) { |
||
1667 | continue; |
||
1668 | } |
||
1669 | $upgrade_version = elgg_get_upgrade_file_version($upgrade_file); |
||
1670 | if (!$upgrade_version) { |
||
1671 | continue; |
||
1672 | } |
||
1673 | $upgrade_files[] = $upgrade_file; |
||
1674 | } |
||
1675 | |||
1676 | sort($upgrade_files); |
||
1677 | |||
1678 | return $upgrade_files; |
||
1679 | } |
||
1680 | |||
1681 | /** |
||
1682 | * Returns a list of months in which entities were updated or created. |
||
1683 | * |
||
1684 | * @tip Use this to generate a list of archives by month for when entities were added or updated. |
||
1685 | * |
||
1686 | * @warning Months are returned in the form YYYYMM. |
||
1687 | * |
||
1688 | * @param string $type The type of entity |
||
1689 | * @param string $subtype The subtype of entity |
||
1690 | * @param int $container_guid The container GUID that the entities belong to |
||
1691 | * @param int $ignored Ignored parameter |
||
1692 | * @param string $order_by Order_by SQL order by clause |
||
1693 | * |
||
1694 | * @deprecated 3.0 use elgg_get_entity_dates() |
||
1695 | * |
||
1696 | * @return array|false Either an array months as YYYYMM, or false on failure |
||
1697 | */ |
||
1698 | function get_entity_dates($type = '', $subtype = '', $container_guid = 0, $ignored = 0, $order_by = 'e.time_created') { |
||
1699 | elgg_deprecated_notice(__FUNCTION__ . ' is deprecated, please use elgg_get_entity_dates()', '3.0'); |
||
1700 | |||
1701 | $options = [ |
||
1702 | 'types' => $type, |
||
1703 | 'subtypes' => $subtype, |
||
1704 | 'container_guids' => $container_guid, |
||
1705 | 'order_by' => [ |
||
1706 | new OrderByClause($order_by), |
||
1707 | ], |
||
1708 | ]; |
||
1709 | |||
1710 | return elgg_get_entity_dates($options); |
||
1711 | } |
||
1712 | |||
1713 | /** |
||
1714 | * Adds a group tool option |
||
1715 | * |
||
1716 | * @see remove_group_tool_option() |
||
1717 | * |
||
1718 | * @param string $name Tool ID |
||
1719 | * @param array $options Tool config options |
||
1720 | * |
||
1721 | * @option string $label Label to appear on the group edit form |
||
1722 | * @option bool $default_on Is the tool enabled by default? |
||
1723 | * @option int $priority Module priority |
||
1724 | * @return void |
||
1725 | * |
||
1726 | * @since 1.5.0 |
||
1727 | * @deprecated 3.0 Use elgg()->group_tools |
||
1728 | */ |
||
1729 | function add_group_tool_option($name, $options = []) { |
||
1730 | elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use elgg()->group_tools service', '3.0'); |
||
1731 | |||
1732 | if (!is_array($options)) { |
||
1733 | $arguments = func_get_args(); |
||
1734 | $options = [ |
||
1735 | 'label' => elgg_extract(1, $arguments), |
||
1736 | 'default_on' => elgg_extract(2, $arguments), |
||
1737 | 'priority' => null, |
||
1738 | ]; |
||
1739 | } |
||
1740 | |||
1741 | elgg()->group_tools->register($name, $options); |
||
1742 | } |
||
1743 | |||
1744 | /** |
||
1745 | * Removes a group tool option based on name |
||
1746 | * |
||
1747 | * @see add_group_tool_option() |
||
1748 | * |
||
1749 | * @param string $name Name of the group tool option |
||
1750 | * |
||
1751 | * @return void |
||
1752 | * @since 1.7.5 |
||
1753 | * @deprecated 3.0 Use elgg()->group_tools |
||
1754 | */ |
||
1755 | function remove_group_tool_option($name) { |
||
1756 | elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use elgg()->group_tools service', '3.0'); |
||
1757 | |||
1758 | elgg()->group_tools->unregister($name); |
||
1759 | } |
||
1760 | |||
1761 | /** |
||
1762 | * Function to return available group tool options |
||
1763 | * |
||
1764 | * @param \ElggGroup $group optional group |
||
1765 | * |
||
1766 | * @return Collection|Tool[] |
||
1767 | * @deprecated 3.0 |
||
1768 | */ |
||
1769 | function elgg_get_group_tool_options(\ElggGroup $group = null) { |
||
1770 | elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use elgg()->group_tools service', '3.0'); |
||
1771 | |||
1772 | if ($group) { |
||
1773 | return elgg()->group_tools->group($group); |
||
1 ignored issue
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
1774 | } |
||
1775 | |||
1776 | return elgg()->group_tools->all(); |
||
1 ignored issue
–
show
|
|||
1777 | } |
||
1778 |