PageRenderTime 74ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 1ms

/engine/lib/deprecated-1.8.php

https://github.com/fragilbert/Elgg
PHP | 4701 lines | 2449 code | 570 blank | 1682 comment | 350 complexity | 274ed8a9958d464992fead2e2eb0b719 MD5 | raw file
Possible License(s): MIT, BSD-3-Clause, LGPL-2.1, GPL-2.0
  1. <?php
  2. /**
  3. * Lists entities from an access collection
  4. *
  5. * @deprecated 1.8 Use elgg_list_entities_from_access_id()
  6. *
  7. * @return str
  8. */
  9. function list_entities_from_access_id($access_id, $entity_type = "", $entity_subtype = "", $owner_guid = 0, $limit = 10, $fullview = true, $listtypetoggle = true, $pagination = true) {
  10. elgg_deprecated_notice("All list_entities* functions were deprecated in 1.8. Use elgg_list_entities* instead.", 1.8);
  11. echo elgg_list_entities_from_access_id(array('access_id' => $access_id,
  12. 'type' => $entity_type, 'subtype' => $entity_subtype, 'owner_guids' => $owner_guid,
  13. 'limit' => $limit, 'full_view' => $fullview, 'list_type_toggle' => $listtypetoggle,
  14. 'pagination' => $pagination,));
  15. }
  16. /**
  17. * Registers a particular action in memory
  18. *
  19. * @deprecated 1.8 Use {@link elgg_register_action()} instead
  20. *
  21. * @param string $action The name of the action (eg "register", "account/settings/save")
  22. * @param boolean $public Can this action be accessed by people not logged into the system?
  23. * @param string $filename Optionally, the filename where this action is located
  24. * @param boolean $admin_only Whether this action is only available to admin users.
  25. */
  26. function register_action($action, $public = false, $filename = "", $admin_only = false) {
  27. elgg_deprecated_notice("register_action() was deprecated by elgg_register_action()", 1.8);
  28. if ($admin_only) {
  29. $access = 'admin';
  30. } elseif ($public) {
  31. $access = 'public';
  32. } else {
  33. $access = 'logged_in';
  34. }
  35. return elgg_register_action($action, $filename, $access);
  36. }
  37. /**
  38. * Register an admin page with the admin panel.
  39. * This function extends the view "admin/main" with the provided view.
  40. * This view should provide a description and either a control or a link to.
  41. *
  42. * @deprecated 1.8 Extend admin views manually
  43. *
  44. * Usage:
  45. * - To add a control to the main admin panel then extend admin/main
  46. * - To add a control to a new page create a page which renders a view admin/subpage
  47. * (where subpage is your new page -
  48. * nb. some pages already exist that you can extend), extend the main view to point to it,
  49. * and add controls to your new view.
  50. *
  51. * At the moment this is essentially a wrapper around elgg_extend_view().
  52. *
  53. * @param string $new_admin_view The view associated with the control you're adding
  54. * @param string $view The view to extend, by default this is 'admin/main'.
  55. * @param int $priority Optional priority to govern the appearance in the list.
  56. *
  57. * @return void
  58. */
  59. function extend_elgg_admin_page($new_admin_view, $view = 'admin/main', $priority = 500) {
  60. elgg_deprecated_notice('extend_elgg_admin_page() does nothing. Extend admin views manually.', 1.8);
  61. }
  62. /**
  63. * Get entities ordered by a mathematical calculation
  64. *
  65. * @deprecated 1.8 Use elgg_get_entities_from_annotation_calculation()
  66. *
  67. * @param string $sum What sort of calculation to perform
  68. * @param string $entity_type Type of Entity
  69. * @param string $entity_subtype Subtype of Entity
  70. * @param string $name Name of annotation
  71. * @param string $mdname Metadata name
  72. * @param string $mdvalue Metadata value
  73. * @param int $owner_guid GUID of owner of annotation
  74. * @param int $limit Limit of results
  75. * @param int $offset Offset of results
  76. * @param string $orderdir Order of results
  77. * @param bool $count Return count or entities
  78. *
  79. * @return mixed
  80. */
  81. function get_entities_from_annotations_calculate_x($sum = "sum", $entity_type = "", $entity_subtype = "", $name = "", $mdname = '', $mdvalue = '', $owner_guid = 0, $limit = 10, $offset = 0, $orderdir = 'desc', $count = false) {
  82. $msg = 'get_entities_from_annotations_calculate_x() is deprecated by elgg_get_entities_from_annotation_calculation().';
  83. elgg_deprecated_notice($msg, 1.8);
  84. $options = array();
  85. $options['calculation'] = $sum;
  86. if ($entity_type) {
  87. $options['types'] = $entity_type;
  88. }
  89. if ($entity_subtype) {
  90. $options['subtypes'] = $entity_subtype;
  91. }
  92. $options['annotation_names'] = $name;
  93. if ($mdname) {
  94. $options['metadata_names'] = $mdname;
  95. }
  96. if ($mdvalue) {
  97. $options['metadata_values'] = $mdvalue;
  98. }
  99. // original function rewrote this to container guid.
  100. if ($owner_guid) {
  101. if (is_array($owner_guid)) {
  102. $options['container_guids'] = $owner_guid;
  103. } else {
  104. $options['container_guid'] = $owner_guid;
  105. }
  106. }
  107. $options['limit'] = $limit;
  108. $options['offset'] = $offset;
  109. $options['order_by'] = "annotation_calculation $orderdir";
  110. $options['count'] = $count;
  111. return elgg_get_entities_from_annotation_calculation($options);
  112. }
  113. /**
  114. * Returns entities ordered by the sum of an annotation
  115. *
  116. * @warning This is function uses sum instead of count. THIS IS SLOW. See #3366.
  117. * This should be used when you have annotations with different values and you
  118. * want a list of entities ordered by the sum of all of those values.
  119. * If you want a list of entities ordered by the number of annotations on each entity,
  120. * use __get_entities_from_annotations_calculate_x() and pass 'count' as the first param.
  121. *
  122. * @deprecated 1.8 Use elgg_get_entities_from_annotation_calculation()
  123. *
  124. * @param string $entity_type Type of Entity
  125. * @param string $entity_subtype Subtype of Entity
  126. * @param string $name Name of annotation
  127. * @param string $mdname Metadata name
  128. * @param string $mdvalue Metadata value
  129. * @param int $owner_guid GUID of owner of annotation
  130. * @param int $limit Limit of results
  131. * @param int $offset Offset of results
  132. * @param string $orderdir Order of results
  133. * @param bool $count Return count or entities
  134. *
  135. * @return unknown
  136. */
  137. function get_entities_from_annotation_count($entity_type = "", $entity_subtype = "", $name = "", $mdname = '', $mdvalue = '', $owner_guid = 0, $limit = 10, $offset = 0, $orderdir = 'desc', $count = false) {
  138. $msg = 'get_entities_from_annotation_count() is deprecated by elgg_get_entities_from_annotation_calculation().';
  139. elgg_deprecated_notice($msg, 1.8);
  140. $options = array();
  141. $options['calculation'] = 'sum';
  142. if ($entity_type) {
  143. $options['types'] = $entity_type;
  144. }
  145. if ($entity_subtype) {
  146. $options['subtypes'] = $entity_subtype;
  147. }
  148. $options['annotation_names'] = $name;
  149. if ($mdname) {
  150. $options['metadata_names'] = $mdname;
  151. }
  152. if ($mdvalue) {
  153. $options['metadata_values'] = $mdvalue;
  154. }
  155. if ($owner_guid) {
  156. if (is_array($owner_guid)) {
  157. $options['owner_guids'] = $owner_guid;
  158. } else {
  159. $options['owner_guid'] = $owner_guid;
  160. }
  161. }
  162. $options['limit'] = $limit;
  163. $options['offset'] = $offset;
  164. $options['order_by'] = "annotation_calculation $orderdir";
  165. $options['count'] = $count;
  166. return elgg_get_entities_from_annotation_calculation($options);
  167. }
  168. /**
  169. * Lists entities by the totals of a particular kind of annotation
  170. *
  171. * @deprecated 1.8 Use elgg_list_entities_from_annotation_calculation()
  172. *
  173. * @param string $entity_type Type of entity.
  174. * @param string $entity_subtype Subtype of entity.
  175. * @param string $name Name of annotation.
  176. * @param int $limit Maximum number of results to return.
  177. * @param int $owner_guid Owner.
  178. * @param int $group_guid Group container. Currently only supported if entity_type is object
  179. * @param boolean $asc Whether to list in ascending or descending order (default: desc)
  180. * @param boolean $fullview Whether to display the entities in full
  181. * @param boolean $listtypetoggle Can the 'gallery' view can be displayed (default: no)
  182. * @param boolean $pagination Add pagination
  183. * @param string $orderdir Order desc or asc
  184. *
  185. * @return string Formatted entity list
  186. */
  187. function list_entities_from_annotation_count($entity_type = "", $entity_subtype = "", $name = "", $limit = 10, $owner_guid = 0, $group_guid = 0, $asc = false, $fullview = true, $listtypetoggle = false, $pagination = true, $orderdir = 'desc') {
  188. $msg = 'list_entities_from_annotation_count() is deprecated by elgg_list_entities_from_annotation_calculation().';
  189. elgg_deprecated_notice($msg, 1.8);
  190. $options = array();
  191. $options['calculation'] = 'sum';
  192. if ($entity_type) {
  193. $options['types'] = $entity_type;
  194. }
  195. if ($entity_subtype) {
  196. $options['subtypes'] = $entity_subtype;
  197. }
  198. $options['annotation_names'] = $name;
  199. if ($owner_guid) {
  200. if (is_array($owner_guid)) {
  201. $options['owner_guids'] = $owner_guid;
  202. } else {
  203. $options['owner_guid'] = $owner_guid;
  204. }
  205. }
  206. $options['full_view'] = $fullview;
  207. $options['list_type_toggle'] = $listtypetoggle;
  208. $options['pagination'] = $pagination;
  209. $options['limit'] = $limit;
  210. $options['order_by'] = "annotation_calculation $orderdir";
  211. return elgg_get_entities_from_annotation_calculation($options);
  212. }
  213. /**
  214. * Adds an entry in $CONFIG[$register_name][$subregister_name].
  215. *
  216. * @deprecated 1.8 Use the new menu system.
  217. *
  218. * This is only used for the site-wide menu. See {@link add_menu()}.
  219. *
  220. * @param string $register_name The name of the top-level register
  221. * @param string $subregister_name The name of the subregister
  222. * @param mixed $subregister_value The value of the subregister
  223. * @param array $children_array Optionally, an array of children
  224. *
  225. * @return true|false Depending on success
  226. */
  227. function add_to_register($register_name, $subregister_name, $subregister_value, $children_array = array()) {
  228. elgg_deprecated_notice("add_to_register() has been deprecated", 1.8);
  229. global $CONFIG;
  230. if (empty($register_name) || empty($subregister_name)) {
  231. return false;
  232. }
  233. if (!isset($CONFIG->registers)) {
  234. $CONFIG->registers = array();
  235. }
  236. if (!isset($CONFIG->registers[$register_name])) {
  237. $CONFIG->registers[$register_name] = array();
  238. }
  239. $subregister = new stdClass;
  240. $subregister->name = $subregister_name;
  241. $subregister->value = $subregister_value;
  242. if (is_array($children_array)) {
  243. $subregister->children = $children_array;
  244. }
  245. $CONFIG->registers[$register_name][$subregister_name] = $subregister;
  246. return true;
  247. }
  248. /**
  249. * Removes a register entry from $CONFIG[register_name][subregister_name]
  250. *
  251. * @deprecated 1.8 Use the new menu system.
  252. *
  253. * This is used to by {@link remove_menu()} to remove site-wide menu items.
  254. *
  255. * @param string $register_name The name of the top-level register
  256. * @param string $subregister_name The name of the subregister
  257. *
  258. * @return true|false Depending on success
  259. * @since 1.7.0
  260. */
  261. function remove_from_register($register_name, $subregister_name) {
  262. elgg_deprecated_notice("remove_from_register() has been deprecated", 1.8);
  263. global $CONFIG;
  264. if (empty($register_name) || empty($subregister_name)) {
  265. return false;
  266. }
  267. if (!isset($CONFIG->registers)) {
  268. return false;
  269. }
  270. if (!isset($CONFIG->registers[$register_name])) {
  271. return false;
  272. }
  273. if (isset($CONFIG->registers[$register_name][$subregister_name])) {
  274. unset($CONFIG->registers[$register_name][$subregister_name]);
  275. return true;
  276. }
  277. return false;
  278. }
  279. /**
  280. * If it exists, returns a particular register as an array
  281. *
  282. * @deprecated 1.8 Use the new menu system
  283. *
  284. * @param string $register_name The name of the register
  285. *
  286. * @return array|false Depending on success
  287. */
  288. function get_register($register_name) {
  289. elgg_deprecated_notice("get_register() has been deprecated", 1.8);
  290. global $CONFIG;
  291. if ($register_name == 'menu') {
  292. // backward compatible code for site menu
  293. $menu = $CONFIG->menus['site'];
  294. $builder = new ElggMenuBuilder($menu);
  295. $menu_items = $builder->getMenu('text');
  296. $menu_items = $menu_items['default'];
  297. $menu = array();
  298. foreach ($menu_items as $item) {
  299. $subregister = new stdClass;
  300. $subregister->name = $item->getText();
  301. $subregister->value = $item->getHref();
  302. $menu[$subregister->name] = $subregister;
  303. }
  304. return $menu;
  305. }
  306. if (isset($CONFIG->registers[$register_name])) {
  307. return $CONFIG->registers[$register_name];
  308. }
  309. return false;
  310. }
  311. /**
  312. * Deprecated events core function. Code divided between elgg_register_event_handler()
  313. * and trigger_elgg_event().
  314. *
  315. * @deprecated 1.8 Use explicit register/trigger event functions
  316. *
  317. * @param string $event The type of event (eg 'init', 'update', 'delete')
  318. * @param string $object_type The type of object (eg 'system', 'blog', 'user')
  319. * @param string $function The name of the function that will handle the event
  320. * @param int $priority Priority to call handler. Lower numbers called first (default 500)
  321. * @param boolean $call Set to true to call the event rather than add to it (default false)
  322. * @param mixed $object Optionally, the object the event is being performed on (eg a user)
  323. *
  324. * @return true|false Depending on success
  325. */
  326. function events($event = "", $object_type = "", $function = "", $priority = 500, $call = false, $object = null) {
  327. elgg_deprecated_notice('events() has been deprecated.', 1.8);
  328. // leaving this here just in case someone was directly calling this internal function
  329. if (!$call) {
  330. return elgg_register_event_handler($event, $object_type, $function, $priority);
  331. } else {
  332. return trigger_elgg_event($event, $object_type, $object);
  333. }
  334. }
  335. /**
  336. * Alias function for events, that registers a function to a particular kind of event
  337. *
  338. * @deprecated 1.8 Use elgg_register_event_handler() instead
  339. *
  340. * @param string $event The event type
  341. * @param string $object_type The object type
  342. * @param string $function The function name
  343. * @return true|false Depending on success
  344. */
  345. function register_elgg_event_handler($event, $object_type, $callback, $priority = 500) {
  346. elgg_deprecated_notice("register_elgg_event_handler() was deprecated by elgg_register_event_handler()", 1.8);
  347. return elgg_register_event_handler($event, $object_type, $callback, $priority);
  348. }
  349. /**
  350. * Unregisters a function to a particular kind of event
  351. *
  352. * @deprecated 1.8 Use elgg_unregister_event_handler instead
  353. *
  354. * @param string $event The event type
  355. * @param string $object_type The object type
  356. * @param string $function The function name
  357. * @since 1.7.0
  358. */
  359. function unregister_elgg_event_handler($event, $object_type, $callback) {
  360. elgg_deprecated_notice('unregister_elgg_event_handler => elgg_unregister_event_handler', 1.8);
  361. elgg_unregister_event_handler($event, $object_type, $callback);
  362. }
  363. /**
  364. * Alias function for events, that triggers a particular kind of event
  365. *
  366. * @deprecated 1.8 Use elgg_trigger_event() instead
  367. *
  368. * @param string $event The event type
  369. * @param string $object_type The object type
  370. * @param string $function The function name
  371. * @return true|false Depending on success
  372. */
  373. function trigger_elgg_event($event, $object_type, $object = null) {
  374. elgg_deprecated_notice('trigger_elgg_event() was deprecated by elgg_trigger_event()', 1.8);
  375. return elgg_trigger_event($event, $object_type, $object);
  376. }
  377. /**
  378. * Register a function to a plugin hook for a particular entity type, with a given priority.
  379. *
  380. * @deprecated 1.8 Use elgg_register_plugin_hook_handler() instead
  381. *
  382. * eg if you want the function "export_user" to be called when the hook "export" for "user" entities
  383. * is run, use:
  384. *
  385. * register_plugin_hook("export", "user", "export_user");
  386. *
  387. * "all" is a valid value for both $hook and $entity_type. "none" is a valid value for $entity_type.
  388. *
  389. * The export_user function would then be defined as:
  390. *
  391. * function export_user($hook, $entity_type, $returnvalue, $params);
  392. *
  393. * Where $returnvalue is the return value returned by the last function returned by the hook, and
  394. * $params is an array containing a set of parameters (or nothing).
  395. *
  396. * @param string $hook The name of the hook
  397. * @param string $entity_type The name of the type of entity (eg "user", "object" etc)
  398. * @param string $function The name of a valid function to be run
  399. * @param string $priority The priority - 0 is first, 1000 last, default is 500
  400. * @return true|false Depending on success
  401. */
  402. function register_plugin_hook($hook, $type, $callback, $priority = 500) {
  403. elgg_deprecated_notice("register_plugin_hook() was deprecated by elgg_register_plugin_hook_handler()", 1.8);
  404. return elgg_register_plugin_hook_handler($hook, $type, $callback, $priority);
  405. }
  406. /**
  407. * Unregister a function to a plugin hook for a particular entity type
  408. *
  409. * @deprecated 1.8 Use elgg_unregister_plugin_hook_handler() instead
  410. *
  411. * @param string $hook The name of the hook
  412. * @param string $entity_type The name of the type of entity (eg "user", "object" etc)
  413. * @param string $function The name of a valid function to be run
  414. * @since 1.7.0
  415. */
  416. function unregister_plugin_hook($hook, $entity_type, $callback) {
  417. elgg_deprecated_notice("unregister_plugin_hook() was deprecated by elgg_unregister_plugin_hook_handler()", 1.8);
  418. elgg_unregister_plugin_hook_handler($hook, $entity_type, $callback);
  419. }
  420. /**
  421. * Triggers a plugin hook, with various parameters as an array. For example, to provide
  422. * a 'foo' hook that concerns an entity of type 'bar', with a parameter called 'param1'
  423. * with value 'value1', that by default returns true, you'd call:
  424. *
  425. * @deprecated 1.8 Use elgg_trigger_plugin_hook() instead
  426. *
  427. * trigger_plugin_hook('foo', 'bar', array('param1' => 'value1'), true);
  428. *
  429. * @see register_plugin_hook
  430. * @param string $hook The name of the hook to trigger
  431. * @param string $entity_type The name of the entity type to trigger it for (or "all", or "none")
  432. * @param array $params Any parameters. It's good practice to name the keys, i.e. by using array('name' => 'value', 'name2' => 'value2')
  433. * @param mixed $returnvalue An initial return value
  434. * @return mixed|null The cumulative return value for the plugin hook functions
  435. */
  436. function trigger_plugin_hook($hook, $type, $params = null, $returnvalue = null) {
  437. elgg_deprecated_notice("trigger_plugin_hook() was deprecated by elgg_trigger_plugin_hook()", 1.8);
  438. return elgg_trigger_plugin_hook($hook, $type, $params, $returnvalue);
  439. }
  440. /**
  441. * Checks if code is being called from a certain function.
  442. *
  443. * To use, call this function with the function name (and optional
  444. * file location) that it has to be called from, it will either
  445. * return true or false.
  446. *
  447. * e.g.
  448. *
  449. * function my_secure_function()
  450. * {
  451. * if (!call_gatekeeper("my_call_function"))
  452. * return false;
  453. *
  454. * ... do secure stuff ...
  455. * }
  456. *
  457. * function my_call_function()
  458. * {
  459. * // will work
  460. * my_secure_function();
  461. * }
  462. *
  463. * function bad_function()
  464. * {
  465. * // Will not work
  466. * my_secure_function();
  467. * }
  468. *
  469. * @param mixed $function The function that this function must have in its call stack,
  470. * to test against a method pass an array containing a class and
  471. * method name.
  472. * @param string $file Optional file that the function must reside in.
  473. *
  474. * @return bool
  475. *
  476. * @deprecated 1.8 A neat but pointless function
  477. */
  478. function call_gatekeeper($function, $file = "") {
  479. elgg_deprecated_notice("call_gatekeeper() is neat but pointless", 1.8);
  480. // Sanity check
  481. if (!$function) {
  482. return false;
  483. }
  484. // Check against call stack to see if this is being called from the correct location
  485. $callstack = debug_backtrace();
  486. $stack_element = false;
  487. foreach ($callstack as $call) {
  488. if (is_array($function)) {
  489. if ((strcmp($call['class'], $function[0]) == 0) && (strcmp($call['function'], $function[1]) == 0)) {
  490. $stack_element = $call;
  491. }
  492. } else {
  493. if (strcmp($call['function'], $function) == 0) {
  494. $stack_element = $call;
  495. }
  496. }
  497. }
  498. if (!$stack_element) {
  499. return false;
  500. }
  501. // If file then check that this it is being called from this function
  502. if ($file) {
  503. $mirror = null;
  504. if (is_array($function)) {
  505. $mirror = new ReflectionMethod($function[0], $function[1]);
  506. } else {
  507. $mirror = new ReflectionFunction($function);
  508. }
  509. if ((!$mirror) || (strcmp($file, $mirror->getFileName()) != 0)) {
  510. return false;
  511. }
  512. }
  513. return true;
  514. }
  515. /**
  516. * This function checks to see if it is being called at somepoint by a function defined somewhere
  517. * on a given path (optionally including subdirectories).
  518. *
  519. * This function is similar to call_gatekeeper() but returns true if it is being called
  520. * by a method or function which has been defined on a given path or by a specified file.
  521. *
  522. * @param string $path The full path and filename that this function must have
  523. * in its call stack If a partial path is given and
  524. * $include_subdirs is true, then the function will return
  525. * true if called by any function in or below the specified path.
  526. * @param bool $include_subdirs Are subdirectories of the path ok, or must you specify an
  527. * absolute path and filename.
  528. * @param bool $strict_mode If true then the calling method or function must be directly
  529. * called by something on $path, if false the whole call stack is
  530. * searched.
  531. *
  532. * @return void
  533. *
  534. * @deprecated 1.8 A neat but pointless function
  535. */
  536. function callpath_gatekeeper($path, $include_subdirs = true, $strict_mode = false) {
  537. elgg_deprecated_notice("callpath_gatekeeper() is neat but pointless", 1.8);
  538. global $CONFIG;
  539. $path = sanitise_string($path);
  540. if ($path) {
  541. $callstack = debug_backtrace();
  542. foreach ($callstack as $call) {
  543. $call['file'] = str_replace("\\", "/", $call['file']);
  544. if ($include_subdirs) {
  545. if (strpos($call['file'], $path) === 0) {
  546. if ($strict_mode) {
  547. $callstack[1]['file'] = str_replace("\\", "/", $callstack[1]['file']);
  548. if ($callstack[1] === $call) {
  549. return true;
  550. }
  551. } else {
  552. return true;
  553. }
  554. }
  555. } else {
  556. if (strcmp($path, $call['file']) == 0) {
  557. if ($strict_mode) {
  558. if ($callstack[1] === $call) {
  559. return true;
  560. }
  561. } else {
  562. return true;
  563. }
  564. }
  565. }
  566. }
  567. return false;
  568. }
  569. if (isset($CONFIG->debug)) {
  570. system_message("Gatekeeper'd function called from {$callstack[1]['file']}:" . "{$callstack[1]['line']}\n\nStack trace:\n\n" . print_r($callstack, true));
  571. }
  572. return false;
  573. }
  574. /**
  575. * Returns SQL where clause for owner and containers.
  576. *
  577. * @deprecated 1.8 Use elgg_get_guid_based_where_sql();
  578. *
  579. * @param string $table Entity table prefix as defined in SELECT...FROM entities $table
  580. * @param NULL|array $owner_guids Owner GUIDs
  581. *
  582. * @return FALSE|str
  583. * @since 1.7.0
  584. * @access private
  585. */
  586. function elgg_get_entity_owner_where_sql($table, $owner_guids) {
  587. elgg_deprecated_notice('elgg_get_entity_owner_where_sql() is deprecated by elgg_get_guid_based_where_sql().', 1.8);
  588. return elgg_get_guid_based_where_sql("{$table}.owner_guid", $owner_guids);
  589. }
  590. /**
  591. * Returns SQL where clause for containers.
  592. *
  593. * @deprecated 1.8 Use elgg_get_guid_based_where_sql();
  594. *
  595. * @param string $table Entity table prefix as defined in
  596. * SELECT...FROM entities $table
  597. * @param NULL|array $container_guids Array of container guids
  598. *
  599. * @return FALSE|string
  600. * @since 1.7.0
  601. * @access private
  602. */
  603. function elgg_get_entity_container_where_sql($table, $container_guids) {
  604. elgg_deprecated_notice('elgg_get_entity_container_where_sql() is deprecated by elgg_get_guid_based_where_sql().', 1.8);
  605. return elgg_get_guid_based_where_sql("{$table}.container_guid", $container_guids);
  606. }
  607. /**
  608. * Returns SQL where clause for site entities
  609. *
  610. * @deprecated 1.8 Use elgg_get_guid_based_where_sql()
  611. *
  612. * @param string $table Entity table prefix as defined in SELECT...FROM entities $table
  613. * @param NULL|array $site_guids Array of site guids
  614. *
  615. * @return FALSE|string
  616. * @since 1.7.0
  617. * @access private
  618. */
  619. function elgg_get_entity_site_where_sql($table, $site_guids) {
  620. elgg_deprecated_notice('elgg_get_entity_site_where_sql() is deprecated by elgg_get_guid_based_where_sql().', 1.8);
  621. return elgg_get_guid_based_where_sql("{$table}.site_guid", $site_guids);
  622. }
  623. /**
  624. * Return an array of objects in a given container.
  625. *
  626. * @see get_entities()
  627. *
  628. * @param int $group_guid The container (defaults to current page owner)
  629. * @param string $subtype The subtype
  630. * @param int $owner_guid Owner
  631. * @param int $site_guid The site
  632. * @param string $order_by Order
  633. * @param int $limit Limit on number of elements to return, by default 10.
  634. * @param int $offset Where to start, by default 0.
  635. * @param bool $count Whether to return the entities or a count of them.
  636. *
  637. * @return array|false
  638. * @deprecated 1.8 Use elgg_get_entities() instead
  639. */
  640. function get_objects_in_group($group_guid, $subtype = "", $owner_guid = 0, $site_guid = 0, $order_by = "", $limit = 10, $offset = 0, $count = FALSE) {
  641. elgg_deprecated_notice("get_objects_in_group was deprected in 1.8. Use elgg_get_entities() instead", 1.8);
  642. global $CONFIG;
  643. if ($subtype === FALSE || $subtype === null || $subtype === 0) {
  644. return FALSE;
  645. }
  646. if ($order_by == "") {
  647. $order_by = "e.time_created desc";
  648. }
  649. $order_by = sanitise_string($order_by);
  650. $limit = (int)$limit;
  651. $offset = (int)$offset;
  652. $site_guid = (int)$site_guid;
  653. if ($site_guid == 0) {
  654. $site_guid = $CONFIG->site_guid;
  655. }
  656. $container_guid = (int)$group_guid;
  657. if ($container_guid == 0) {
  658. $container_guid = elgg_get_page_owner_guid();
  659. }
  660. $where = array();
  661. $where[] = "e.type='object'";
  662. if (!empty($subtype)) {
  663. if (!$subtype = get_subtype_id('object', $subtype)) {
  664. return FALSE;
  665. }
  666. $where[] = "e.subtype=$subtype";
  667. }
  668. if ($owner_guid != "") {
  669. if (!is_array($owner_guid)) {
  670. $owner_guid = (int)$owner_guid;
  671. $where[] = "e.container_guid = '$owner_guid'";
  672. } else if (sizeof($owner_guid) > 0) {
  673. // Cast every element to the owner_guid array to int
  674. $owner_guid = array_map("sanitise_int", $owner_guid);
  675. $owner_guid = implode(",", $owner_guid);
  676. $where[] = "e.container_guid in ({$owner_guid})";
  677. }
  678. }
  679. if ($site_guid > 0) {
  680. $where[] = "e.site_guid = {$site_guid}";
  681. }
  682. if ($container_guid > 0) {
  683. $where[] = "e.container_guid = {$container_guid}";
  684. }
  685. if (!$count) {
  686. $query = "SELECT * from {$CONFIG->dbprefix}entities e" . " join {$CONFIG->dbprefix}objects_entity o on e.guid=o.guid where ";
  687. } else {
  688. $query = "SELECT count(e.guid) as total from {$CONFIG->dbprefix}entities e" . " join {$CONFIG->dbprefix}objects_entity o on e.guid=o.guid where ";
  689. }
  690. foreach ($where as $w) {
  691. $query .= " $w and ";
  692. }
  693. // Add access controls
  694. $query .= get_access_sql_suffix('e');
  695. if (!$count) {
  696. $query .= " order by $order_by";
  697. // Add order and limit
  698. if ($limit) {
  699. $query .= " limit $offset, $limit";
  700. }
  701. $dt = get_data($query, "entity_row_to_elggstar");
  702. return $dt;
  703. } else {
  704. $total = get_data_row($query);
  705. return $total->total;
  706. }
  707. }
  708. /**
  709. * Lists entities that belong to a group.
  710. *
  711. * @param string $subtype The arbitrary subtype of the entity
  712. * @param int $owner_guid The GUID of the owning user
  713. * @param int $container_guid The GUID of the containing group
  714. * @param int $limit The number of entities to display per page (default: 10)
  715. * @param bool $fullview Whether or not to display the full view (default: true)
  716. * @param bool $listtypetoggle Whether or not to allow gallery view (default: true)
  717. * @param bool $pagination Whether to display pagination (default: true)
  718. *
  719. * @return string List of parsed entities
  720. *
  721. * @see elgg_list_entities()
  722. * @deprecated 1.8 Use elgg_list_entities() instead
  723. */
  724. function list_entities_groups($subtype = "", $owner_guid = 0, $container_guid = 0, $limit = 10, $fullview = true, $listtypetoggle = true, $pagination = true) {
  725. elgg_deprecated_notice("list_entities_groups was deprecated in 1.8. Use elgg_list_entities() instead.", 1.8);
  726. $offset = (int)get_input('offset');
  727. $count = get_objects_in_group($container_guid, $subtype, $owner_guid, 0, "", $limit, $offset, true);
  728. $entities = get_objects_in_group($container_guid, $subtype, $owner_guid, 0, "", $limit, $offset);
  729. return elgg_view_entity_list($entities, $count, $offset, $limit, $fullview, $listtypetoggle, $pagination);
  730. }
  731. /**
  732. * Get all the entities from metadata from a group.
  733. *
  734. * @param int $group_guid The ID of the group.
  735. * @param mixed $meta_name Metadata name
  736. * @param mixed $meta_value Metadata value
  737. * @param string $entity_type The type of entity to look for, eg 'site' or 'object'
  738. * @param string $entity_subtype The subtype of the entity.
  739. * @param int $owner_guid Owner guid
  740. * @param int $limit Limit
  741. * @param int $offset Offset
  742. * @param string $order_by Optional ordering.
  743. * @param int $site_guid Site GUID. 0 for current, -1 for any
  744. * @param bool $count Return count instead of entities
  745. *
  746. * @return array|false
  747. * @deprecated 1.8 Use elgg_get_entities_from_metadata()
  748. */
  749. function get_entities_from_metadata_groups($group_guid, $meta_name, $meta_value = "", $entity_type = "", $entity_subtype = "", $owner_guid = 0, $limit = 10, $offset = 0, $order_by = "", $site_guid = 0, $count = false) {
  750. elgg_deprecated_notice("get_entities_from_metadata_groups was deprecated in 1.8.", 1.8);
  751. global $CONFIG;
  752. $meta_n = get_metastring_id($meta_name);
  753. $meta_v = get_metastring_id($meta_value);
  754. $entity_type = sanitise_string($entity_type);
  755. $entity_subtype = get_subtype_id($entity_type, $entity_subtype);
  756. $limit = (int)$limit;
  757. $offset = (int)$offset;
  758. if ($order_by == "") {
  759. $order_by = "e.time_created desc";
  760. }
  761. $order_by = sanitise_string($order_by);
  762. $site_guid = (int)$site_guid;
  763. if (is_array($owner_guid)) {
  764. foreach ($owner_guid as $key => $guid) {
  765. $owner_guid[$key] = (int)$guid;
  766. }
  767. } else {
  768. $owner_guid = (int)$owner_guid;
  769. }
  770. if ($site_guid == 0) {
  771. $site_guid = $CONFIG->site_guid;
  772. }
  773. $container_guid = (int)$group_guid;
  774. if ($container_guid == 0) {
  775. $container_guid = elgg_get_page_owner_guid();
  776. }
  777. $where = array();
  778. if ($entity_type != "") {
  779. $where[] = "e.type='$entity_type'";
  780. }
  781. if ($entity_subtype) {
  782. $where[] = "e.subtype=$entity_subtype";
  783. }
  784. if ($meta_name != "") {
  785. $where[] = "m.name_id='$meta_n'";
  786. }
  787. if ($meta_value != "") {
  788. $where[] = "m.value_id='$meta_v'";
  789. }
  790. if ($site_guid > 0) {
  791. $where[] = "e.site_guid = {$site_guid}";
  792. }
  793. if ($container_guid > 0) {
  794. $where[] = "e.container_guid = {$container_guid}";
  795. }
  796. if (is_array($owner_guid)) {
  797. $where[] = "e.container_guid in (" . implode(",", $owner_guid) . ")";
  798. } else if ($owner_guid > 0) {
  799. $where[] = "e.container_guid = {$owner_guid}";
  800. }
  801. if (!$count) {
  802. $query = "SELECT distinct e.* ";
  803. } else {
  804. $query = "SELECT count(e.guid) as total ";
  805. }
  806. $query .= "from {$CONFIG->dbprefix}entities e" . " JOIN {$CONFIG->dbprefix}metadata m on e.guid = m.entity_guid " . " JOIN {$CONFIG->dbprefix}objects_entity o on e.guid = o.guid where";
  807. foreach ($where as $w) {
  808. $query .= " $w and ";
  809. }
  810. // Add access controls
  811. $query .= get_access_sql_suffix("e");
  812. if (!$count) {
  813. $query .= " order by $order_by limit $offset, $limit"; // Add order and limit
  814. return get_data($query, "entity_row_to_elggstar");
  815. } else {
  816. if ($row = get_data_row($query)) {
  817. return $row->total;
  818. }
  819. }
  820. return false;
  821. }
  822. /**
  823. * As get_entities_from_metadata_groups() but with multiple entities.
  824. *
  825. * @param int $group_guid The ID of the group.
  826. * @param array $meta_array Array of 'name' => 'value' pairs
  827. * @param string $entity_type The type of entity to look for, eg 'site' or 'object'
  828. * @param string $entity_subtype The subtype of the entity.
  829. * @param int $owner_guid Owner GUID
  830. * @param int $limit Limit
  831. * @param int $offset Offset
  832. * @param string $order_by Optional ordering.
  833. * @param int $site_guid Site GUID. 0 for current, -1 for any
  834. * @param bool $count Return count of entities instead of entities
  835. *
  836. * @return int|array List of ElggEntities, or the total number if count is set to false
  837. * @deprecated 1.8 Use elgg_get_entities_from_metadata()
  838. */
  839. function get_entities_from_metadata_groups_multi($group_guid, $meta_array, $entity_type = "", $entity_subtype = "", $owner_guid = 0, $limit = 10, $offset = 0, $order_by = "", $site_guid = 0, $count = false) {
  840. elgg_deprecated_notice("get_entities_from_metadata_groups_multi was deprecated in 1.8.", 1.8);
  841. global $CONFIG;
  842. if (!is_array($meta_array) || sizeof($meta_array) == 0) {
  843. return false;
  844. }
  845. $where = array();
  846. $mindex = 1;
  847. $join = "";
  848. foreach ($meta_array as $meta_name => $meta_value) {
  849. $meta_n = get_metastring_id($meta_name);
  850. $meta_v = get_metastring_id($meta_value);
  851. $join .= " JOIN {$CONFIG->dbprefix}metadata m{$mindex} on e.guid = m{$mindex}.entity_guid" . " JOIN {$CONFIG->dbprefix}objects_entity o on e.guid = o.guid ";
  852. if ($meta_name != "") {
  853. $where[] = "m{$mindex}.name_id='$meta_n'";
  854. }
  855. if ($meta_value != "") {
  856. $where[] = "m{$mindex}.value_id='$meta_v'";
  857. }
  858. $mindex++;
  859. }
  860. $entity_type = sanitise_string($entity_type);
  861. $entity_subtype = get_subtype_id($entity_type, $entity_subtype);
  862. $limit = (int)$limit;
  863. $offset = (int)$offset;
  864. if ($order_by == "") {
  865. $order_by = "e.time_created desc";
  866. }
  867. $order_by = sanitise_string($order_by);
  868. $owner_guid = (int)$owner_guid;
  869. $site_guid = (int)$site_guid;
  870. if ($site_guid == 0) {
  871. $site_guid = $CONFIG->site_guid;
  872. }
  873. //$access = get_access_list();
  874. if ($entity_type != "") {
  875. $where[] = "e.type = '{$entity_type}'";
  876. }
  877. if ($entity_subtype) {
  878. $where[] = "e.subtype = {$entity_subtype}";
  879. }
  880. if ($site_guid > 0) {
  881. $where[] = "e.site_guid = {$site_guid}";
  882. }
  883. if ($owner_guid > 0) {
  884. $where[] = "e.owner_guid = {$owner_guid}";
  885. }
  886. if ($container_guid > 0) {
  887. $where[] = "e.container_guid = {$container_guid}";
  888. }
  889. if ($count) {
  890. $query = "SELECT count(e.guid) as total ";
  891. } else {
  892. $query = "SELECT distinct e.* ";
  893. }
  894. $query .= " from {$CONFIG->dbprefix}entities e {$join} where";
  895. foreach ($where as $w) {
  896. $query .= " $w and ";
  897. }
  898. $query .= get_access_sql_suffix("e"); // Add access controls
  899. if (!$count) {
  900. $query .= " order by $order_by limit $offset, $limit"; // Add order and limit
  901. return get_data($query, "entity_row_to_elggstar");
  902. } else {
  903. if ($count = get_data_row($query)) {
  904. return $count->total;
  905. }
  906. }
  907. return false;
  908. }
  909. /**
  910. * List items within a given geographic area.
  911. *
  912. * @param real $lat Latitude
  913. * @param real $long Longitude
  914. * @param real $radius The radius
  915. * @param string $type The type of entity (eg "user", "object" etc)
  916. * @param string $subtype The arbitrary subtype of the entity
  917. * @param int $owner_guid The GUID of the owning user
  918. * @param int $limit The number of entities to display per page (default: 10)
  919. * @param bool $fullview Whether or not to display the full view (default: true)
  920. * @param bool $listtypetoggle Whether or not to allow gallery view
  921. * @param bool $navigation Display pagination? Default: true
  922. *
  923. * @return string A viewable list of entities
  924. * @deprecated 1.8 Use elgg_get_entities_from_location()
  925. */
  926. function list_entities_in_area($lat, $long, $radius, $type = "", $subtype = "", $owner_guid = 0, $limit = 10, $fullview = true, $listtypetoggle = false, $navigation = true) {
  927. elgg_deprecated_notice('list_entities_in_area() was deprecated. Use elgg_list_entities_from_location()', 1.8);
  928. $options = array();
  929. $options['latitude'] = $lat;
  930. $options['longitude'] = $long;
  931. $options['distance'] = $radius;
  932. if ($type) {
  933. $options['types'] = $type;
  934. }
  935. if ($subtype) {
  936. $options['subtypes'] = $subtype;
  937. }
  938. if ($owner_guid) {
  939. if (is_array($owner_guid)) {
  940. $options['owner_guids'] = $owner_guid;
  941. } else {
  942. $options['owner_guid'] = $owner_guid;
  943. }
  944. }
  945. $options['limit'] = $limit;
  946. $options['full_view'] = $fullview;
  947. $options['list_type_toggle'] = $listtypetoggle;
  948. $options['pagination'] = $pagination;
  949. return elgg_list_entities_from_location($options);
  950. }
  951. /**
  952. * List entities in a given location
  953. *
  954. * @param string $location Location
  955. * @param string $type The type of entity (eg "user", "object" etc)
  956. * @param string $subtype The arbitrary subtype of the entity
  957. * @param int $owner_guid The GUID of the owning user
  958. * @param int $limit The number of entities to display per page (default: 10)
  959. * @param bool $fullview Whether or not to display the full view (default: true)
  960. * @param bool $listtypetoggle Whether or not to allow gallery view
  961. * @param bool $navigation Display pagination? Default: true
  962. *
  963. * @return string A viewable list of entities
  964. * @deprecated 1.8 Use elgg_list_entities_from_location()
  965. */
  966. function list_entities_location($location, $type = "", $subtype = "", $owner_guid = 0, $limit = 10, $fullview = true, $listtypetoggle = false, $navigation = true) {
  967. elgg_deprecated_notice('list_entities_location() was deprecated. Use elgg_list_entities_from_metadata()', 1.8);
  968. return list_entities_from_metadata('location', $location, $type, $subtype, $owner_guid, $limit, $fullview, $listtypetoggle, $navigation);
  969. }
  970. /**
  971. * Return entities within a given geographic area.
  972. *
  973. * @param float $lat Latitude
  974. * @param float $long Longitude
  975. * @param float $radius The radius
  976. * @param string $type The type of entity (eg "user", "object" etc)
  977. * @param string $subtype The arbitrary subtype of the entity
  978. * @param int $owner_guid The GUID of the owning user
  979. * @param string $order_by The field to order by; by default, time_created desc
  980. * @param int $limit The number of entities to return; 10 by default
  981. * @param int $offset The indexing offset, 0 by default
  982. * @param boolean $count Count entities
  983. * @param int $site_guid Site GUID. 0 for current, -1 for any
  984. * @param int|array $container_guid Container GUID
  985. *
  986. * @return array A list of entities.
  987. * @deprecated 1.8 Use elgg_get_entities_from_location()
  988. */
  989. function get_entities_in_area($lat, $long, $radius, $type = "", $subtype = "", $owner_guid = 0, $order_by = "", $limit = 10, $offset = 0, $count = false, $site_guid = 0, $container_guid = NULL) {
  990. elgg_deprecated_notice('get_entities_in_area() was deprecated by elgg_get_entities_from_location()!', 1.8);
  991. $options = array();
  992. $options['latitude'] = $lat;
  993. $options['longitude'] = $long;
  994. $options['distance'] = $radius;
  995. // set container_guid to owner_guid to emulate old functionality
  996. if ($owner_guid != "") {
  997. if (is_null($container_guid)) {
  998. $container_guid = $owner_guid;
  999. }
  1000. }
  1001. if ($type) {
  1002. $options['types'] = $type;
  1003. }
  1004. if ($subtype) {
  1005. $options['subtypes'] = $subtype;
  1006. }
  1007. if ($owner_guid) {
  1008. if (is_array($owner_guid)) {
  1009. $options['owner_guids'] = $owner_guid;
  1010. } else {
  1011. $options['owner_guid'] = $owner_guid;
  1012. }
  1013. }
  1014. if ($container_guid) {
  1015. if (is_array($container_guid)) {
  1016. $options['container_guids'] = $container_guid;
  1017. } else {
  1018. $options['container_guid'] = $container_guid;
  1019. }
  1020. }
  1021. $options['limit'] = $limit;
  1022. if ($offset) {
  1023. $options['offset'] = $offset;
  1024. }
  1025. if ($order_by) {
  1026. $options['order_by'];
  1027. }
  1028. if ($site_guid) {
  1029. $options['site_guid'];
  1030. }
  1031. if ($count) {
  1032. $options['count'] = $count;
  1033. }
  1034. return elgg_get_entities_from_location($options);
  1035. }
  1036. /**
  1037. * Return a list of entities suitable for display based on the given search criteria.
  1038. *
  1039. * @see elgg_view_entity_list
  1040. *
  1041. * @deprecated 1.8 Use elgg_list_entities_from_metadata
  1042. *
  1043. * @param mixed $meta_name Metadata name to search on
  1044. * @param mixed $meta_value The value to match, optionally
  1045. * @param string $entity_type The type of entity to look for, eg 'site' or 'object'
  1046. * @param string $entity_subtype The subtype of the entity
  1047. * @param int $owner_guid Owner GUID
  1048. * @param int $limit Number of entities to display per page
  1049. * @param bool $fullview WDisplay the full view (default: true)
  1050. * @param bool $listtypetoggle Allow users to toggle to the gallery view. Default: true
  1051. * @param bool $pagination Display pagination? Default: true
  1052. * @param bool $case_sensitive Case sensitive metadata names?
  1053. *
  1054. * @return string
  1055. *
  1056. * @return string A list of entities suitable for display
  1057. */
  1058. function list_entities_from_metadata($meta_name, $meta_value = "", $entity_type = ELGG_ENTITIES_ANY_VALUE, $entity_subtype = ELGG_ENTITIES_ANY_VALUE, $owner_guid = 0, $limit = 10, $fullview = true, $listtypetoggle = true, $pagination = true, $case_sensitive = true) {
  1059. elgg_deprecated_notice('list_entities_from_metadata() was deprecated by elgg_list_entities_from_metadata()!', 1.8);
  1060. $offset = (int)get_input('offset');
  1061. $limit = (int)$limit;
  1062. $options = array(
  1063. 'metadata_name' => $meta_name,
  1064. 'metadata_value' => $meta_value,
  1065. 'type' => $entity_type,
  1066. 'subtype' => $entity_subtype,
  1067. 'limit' => $limit,
  1068. 'offset' => $offset,
  1069. 'count' => TRUE,
  1070. 'metadata_case_sensitive' => $case_sensitive
  1071. );
  1072. // previous function allowed falsy $owner_guid for anything
  1073. if ($owner_guid) {
  1074. $options['owner_guid'] = $owner_guid;
  1075. }
  1076. $count = elgg_get_entities_from_metadata($options);
  1077. $options['count'] = FALSE;
  1078. $entities = elgg_get_entities_from_metadata($options);
  1079. return elgg_view_entity_list($entities, $count, $offset, $limit, $fullview, $listtypetoggle, $pagination);
  1080. }
  1081. /**
  1082. * Returns a viewable list of entities based on the given search criteria.
  1083. *
  1084. * @see elgg_view_entity_list
  1085. *
  1086. * @param array $meta_array Array of 'name' => 'value' pairs
  1087. * @param string $entity_type The type of entity to look for, eg 'site' or 'object'
  1088. * @param string $entity_subtype The subtype of the entity.
  1089. * @param int $owner_guid Owner GUID
  1090. * @param int $limit Limit
  1091. * @param bool $fullview WDisplay the full view (default: true)
  1092. * @param bool $listtypetoggle Allow users to toggle to the gallery view. Default: true
  1093. * @param bool $pagination Display pagination? Default: true
  1094. *
  1095. * @return string List of ElggEntities suitable for display
  1096. *
  1097. * @deprecated 1.8 Use elgg_list_entities_from_metadata() instead
  1098. */
  1099. function list_entities_from_metadata_multi($meta_array, $entity_type = "", $entity_subtype = "", $owner_guid = 0, $limit = 10, $fullview = true, $listtypetoggle = true, $pagination = true) {
  1100. elgg_deprecated_notice(elgg_echo('deprecated:function', array(
  1101. 'list_entities_from_metadata_multi', 'elgg_get_entities_from_metadata')), 1.8);
  1102. $offset = (int)get_input('offset');
  1103. $limit = (int)$limit;
  1104. $count = get_entities_from_metadata_multi($meta_array, $entity_type, $entity_subtype, $owner_guid, $limit, $offset, "", $site_guid, true);
  1105. $entities = get_entities_from_metadata_multi($meta_array, $entity_type, $entity_subtype, $owner_guid, $limit, $offset, "", $site_guid, false);
  1106. return elgg_view_entity_list($entities, $count, $offset, $limit, $fullview, $listtypetoggle, $pagination);
  1107. }
  1108. /**
  1109. * Deprecated by elgg_register_menu_item(). Set $menu_name to 'page'.
  1110. *
  1111. * @see elgg_register_menu_item()
  1112. * @deprecated 1.8 Use the new menu system
  1113. *
  1114. * @param string $label The label
  1115. * @param string $link The link
  1116. * @param string $group The group to store item in
  1117. * @param boolean $onclick Add a confirmation when clicked?
  1118. * @param boolean $selected Is menu item selected
  1119. *
  1120. * @return bool
  1121. */
  1122. function add_submenu_item($label, $link, $group = 'default', $onclick = false, $selected = NULL) {
  1123. elgg_deprecated_notice('add_submenu_item was deprecated by elgg_register_menu_item', 1.8);
  1124. // submenu items were added in the page setup hook usually by checking
  1125. // the context. We'll pass in the current context here, which will
  1126. // emulate that effect.
  1127. // if context == 'main' (default) it probably means they always wanted
  1128. // the menu item to show up everywhere.
  1129. $context = elgg_get_context();
  1130. if ($context == 'main') {
  1131. $context = 'all';
  1132. }
  1133. $item = array('name' => $label, 'text' => $label, 'href' => $link, 'context' => $context,
  1134. 'section' => $group,);
  1135. if ($selected) {
  1136. $item['selected'] = true;
  1137. }
  1138. if ($onclick) {
  1139. $js = "onclick=\"javascript:return confirm('" . elgg_echo('deleteconfirm') . "')\"";
  1140. $item['vars'] = array('js' => $js);
  1141. }
  1142. return elgg_register_menu_item('page', $item);
  1143. }
  1144. /**
  1145. * Remove an item from submenu by label
  1146. *
  1147. * @deprecated 1.8 Use the new menu system
  1148. * @see elgg_unregister_menu_item()
  1149. *
  1150. * @param string $label The item label
  1151. * @param string $group The submenu group (default "a")
  1152. * @return bool whether the item was removed or not
  1153. * @since 1.7.8
  1154. */
  1155. function remove_submenu_item($label, $group = 'a') {
  1156. elgg_deprecated_notice('remove_submenu_item was deprecated by elgg_unregister_menu_item', 1.8);
  1157. return elgg_unregister_menu_item('page', $label);
  1158. }
  1159. /**
  1160. * Use elgg_view_menu(). Set $menu_name to 'owner_block'.
  1161. *
  1162. * @see elgg_view_menu()
  1163. * @deprecated 1.8 Use the new menu system. elgg_view_menu()
  1164. *
  1165. * @return string
  1166. */
  1167. function get_submenu() {
  1168. elgg_deprecated_notice("get_submenu() has been deprecated by elgg_view_menu()", 1.8);
  1169. return elgg_view_menu('owner_block', array('entity' => $owner,
  1170. 'class' => 'elgg-menu-owner-block',));
  1171. }
  1172. /**
  1173. * Adds an item to the site-wide menu.
  1174. *
  1175. * You can obtain the menu array by calling {@link get_register('menu')}
  1176. *
  1177. * @param string $menu_name The name of the menu item
  1178. * @param string $menu_url The URL of the page
  1179. * @param array $menu_children Optionally, an array of submenu items (not used)
  1180. * @param string $context (not used)
  1181. *
  1182. * @return true|false Depending on success
  1183. * @deprecated 1.8 use elgg_register_menu_item() for the menu 'site'
  1184. */
  1185. function add_menu($menu_name, $menu_url, $menu_children = array(), $context = "") {
  1186. elgg_deprecated_notice('add_menu() deprecated by elgg_register_menu_item()', 1.8);
  1187. return elgg_register_menu_item('site', array('name' => $menu_name, 'text' => $menu_name,
  1188. 'href' => $menu_url,));
  1189. }
  1190. /**
  1191. * Removes an item from the menu register
  1192. *
  1193. * @param string $menu_name The name of the menu item
  1194. *
  1195. * @return true|false Depending on success
  1196. * @deprecated 1.8 Use the new menu system
  1197. */
  1198. function remove_menu($menu_name) {
  1199. elgg_deprecated_notice("remove_menu() deprecated by elgg_unregister_menu_item()", 1.8);
  1200. return elgg_unregister_menu_item('site', $menu_name);
  1201. }
  1202. /**
  1203. * When given a title, returns a version suitable for inclusion in a URL
  1204. *
  1205. * @param string $title The title
  1206. *
  1207. * @return string The optimised title
  1208. * @deprecated 1.8 Use elgg_get_friendly_title()
  1209. */
  1210. function friendly_title($title) {
  1211. elgg_deprecated_notice('friendly_title was deprecated by elgg_get_friendly_title', 1.8);
  1212. return elgg_get_friendly_title($title);
  1213. }
  1214. /**
  1215. * Displays a UNIX timestamp in a friendly way (eg "less than a minute ago")
  1216. *
  1217. * @param int $time A UNIX epoch timestamp
  1218. *
  1219. * @return string The friendly time
  1220. * @deprecated 1.8 Use elgg_view_friendly_time()
  1221. */
  1222. function friendly_time($time) {
  1223. elgg_deprecated_notice('friendly_time was deprecated by elgg_view_friendly_time', 1.8);
  1224. return elgg_view_friendly_time($time);
  1225. }
  1226. /**
  1227. * Filters a string into an array of significant words
  1228. *
  1229. * @deprecated 1.8 Don't use this.
  1230. *
  1231. * @param string $string A string
  1232. *
  1233. * @return array
  1234. */
  1235. function filter_string($string) {
  1236. elgg_deprecated_notice('filter_string() was deprecated!', 1.8);
  1237. // Convert it to lower and trim
  1238. $string = strtolower($string);
  1239. $string = trim($string);
  1240. // Remove links and email addresses
  1241. // match protocol://address/path/file.extension?some=variable&another=asf%
  1242. $string = preg_replace("/\s([a-zA-Z]+:\/\/[a-z][a-z0-9\_\.\-]*[a-z]{2,6}" . "[a-zA-Z0-9\/\*\-\?\&\%\=]*)([\s|\.|\,])/iu", " ", $string);
  1243. // match www.something.domain/path/file.extension?some=variable&another=asf%
  1244. $string = preg_replace("/\s(www\.[a-z][a-z0-9\_\.\-]*[a-z]{2,6}" . "[a-zA-Z0-9\/\*\-\?\&\%\=]*)([\s|\.|\,])/iu", " ", $string);
  1245. // match name@address
  1246. $string = preg_replace("/\s([a-zA-Z][a-zA-Z0-9\_\.\-]*[a-zA-Z]" . "*\@[a-zA-Z][a-zA-Z0-9\_\.\-]*[a-zA-Z]{2,6})([\s|\.|\,])/iu", " ", $string);
  1247. // Sanitise the string; remove unwanted characters
  1248. $string = preg_replace('/\W/ui', ' ', $string);
  1249. // Explode it into an array
  1250. $terms = explode(' ', $string);
  1251. // Remove any blacklist terms
  1252. //$terms = array_filter($terms, 'remove_blacklist');
  1253. return $terms;
  1254. }
  1255. /**
  1256. * Returns true if the word in $input is considered significant
  1257. *
  1258. * @deprecated 1.8 Don't use this.
  1259. *
  1260. * @param string $input A word
  1261. *
  1262. * @return true|false
  1263. */
  1264. function remove_blacklist($input) {
  1265. elgg_deprecated_notice('remove_blacklist() was deprecated!', 1.8);
  1266. global $CONFIG;
  1267. if (!is_array($CONFIG->wordblacklist)) {
  1268. return $input;
  1269. }
  1270. if (strlen($input) < 3 || in_array($input, $CONFIG->wordblacklist)) {
  1271. return false;
  1272. }
  1273. return true;
  1274. }
  1275. /**
  1276. * Gets the guid of the entity that owns the current page.
  1277. *
  1278. * @deprecated 1.8 Use elgg_get_page_owner_guid()
  1279. *
  1280. * @return int The current page owner guid (0 if none).
  1281. */
  1282. function page_owner() {
  1283. elgg_deprecated_notice('page_owner() was deprecated by elgg_get_page_owner_guid().', 1.8);
  1284. return elgg_get_page_owner_guid();
  1285. }
  1286. /**
  1287. * Gets the owner entity for the current page.
  1288. *
  1289. * @deprecated 1.8 Use elgg_get_page_owner_entity()
  1290. * @return ElggEntity|false The current page owner or false if none.
  1291. */
  1292. function page_owner_entity() {
  1293. elgg_deprecated_notice('page_owner_entity() was deprecated by elgg_get_page_owner_entity().', 1.8);
  1294. return elgg_get_page_owner_entity();
  1295. }
  1296. /**
  1297. * Registers a page owner handler function
  1298. *
  1299. * @param string $functionname The callback function
  1300. *
  1301. * @deprecated 1.8 Use the 'page_owner', 'system' plugin hook
  1302. * @return void
  1303. */
  1304. function add_page_owner_handler($functionname) {
  1305. elgg_deprecated_notice("add_page_owner_handler() was deprecated by the plugin hook 'page_owner', 'system'.", 1.8);
  1306. }
  1307. /**
  1308. * Set a page owner entity
  1309. *
  1310. * @param int $entitytoset The GUID of the entity
  1311. *
  1312. * @deprecated 1.8 Use elgg_set_page_owner_guid()
  1313. * @return void
  1314. */
  1315. function set_page_owner($entitytoset = -1) {
  1316. elgg_deprecated_notice('set_page_owner() was deprecated by elgg_set_page_owner_guid().', 1.8);
  1317. elgg_set_page_owner_guid($entitytoset);
  1318. }
  1319. /**
  1320. * Sets the functional context of a page
  1321. *
  1322. * @deprecated 1.8 Use elgg_set_context()
  1323. *
  1324. * @param string $context The context of the page
  1325. *
  1326. * @return mixed Either the context string, or false on failure
  1327. */
  1328. function set_context($context) {
  1329. elgg_deprecated_notice('set_context() was deprecated by elgg_set_context().', 1.8);
  1330. elgg_set_context($context);
  1331. if (empty($context)) {
  1332. return false;
  1333. }
  1334. return $context;
  1335. }
  1336. /**
  1337. * Returns the functional context of a page
  1338. *
  1339. * @deprecated 1.8 Use elgg_get_context()
  1340. *
  1341. * @return string The context, or 'main' if no context has been provided
  1342. */
  1343. function get_context() {
  1344. elgg_deprecated_notice('get_context() was deprecated by elgg_get_context().', 1.8);
  1345. return elgg_get_context();
  1346. // @todo - used to set context based on calling script
  1347. // $context = get_plugin_name(true)
  1348. }
  1349. /**
  1350. * Returns a list of plugins to load, in the order that they should be loaded.
  1351. *
  1352. * @deprecated 1.8 Use elgg_get_plugin_ids_in_dir() or elgg_get_plugins()
  1353. *
  1354. * @return array List of plugins
  1355. */
  1356. function get_plugin_list() {
  1357. elgg_deprecated_notice('get_plugin_list() is deprecated by elgg_get_plugin_ids_in_dir() or elgg_get_plugins()', 1.8);
  1358. $plugins = elgg_get_plugins('any');
  1359. $list = array();
  1360. if ($plugins) {
  1361. foreach ($plugins as $i => $plugin) {
  1362. // in <=1.7 this returned indexed by multiples of 10.
  1363. // uh...sure...why not.
  1364. $index = ($i + 1) * 10;
  1365. $list[$index] = $plugin->getID();
  1366. }
  1367. }
  1368. return $list;
  1369. }
  1370. /**
  1371. * Regenerates the list of known plugins and saves it to the current site
  1372. *
  1373. * Important: You should regenerate simplecache and the viewpath cache after executing this function
  1374. * otherwise you may experience view display artifacts. Do this with the following code:
  1375. *
  1376. * elgg_regenerate_simplecache();
  1377. * elgg_reset_system_cache();
  1378. *
  1379. * @deprecated 1.8 Use elgg_generate_plugin_entities() and elgg_set_plugin_priorities()
  1380. *
  1381. * @param array $pluginorder Optionally, a list of existing plugins and their orders
  1382. *
  1383. * @return array The new list of plugins and their orders
  1384. */
  1385. function regenerate_plugin_list($pluginorder = FALSE) {
  1386. $msg = 'regenerate_plugin_list() is (sorta) deprecated by elgg_generate_plugin_entities() and'
  1387. . ' elgg_set_plugin_priorities().';
  1388. elgg_deprecated_notice($msg, 1.8);
  1389. // they're probably trying to set it?
  1390. if ($pluginorder) {
  1391. if (elgg_generate_plugin_entities()) {
  1392. // sort the plugins by the index numerically since we used
  1393. // weird indexes in the old system.
  1394. ksort($pluginorder, SORT_NUMERIC);
  1395. return elgg_set_plugin_priorities($pluginorder);
  1396. }
  1397. return false;
  1398. } else {
  1399. // they're probably trying to regenerate from disk?
  1400. return elgg_generate_plugin_entities();
  1401. }
  1402. }
  1403. /**
  1404. * Get the name of the most recent plugin to be called in the
  1405. * call stack (or the plugin that owns the current page, if any).
  1406. *
  1407. * i.e., if the last plugin was in /mod/foobar/, get_plugin_name would return foo_bar.
  1408. *
  1409. * @deprecated 1.8 Use elgg_get_calling_plugin_id()
  1410. *
  1411. * @param boolean $mainfilename If set to true, this will instead determine the
  1412. * context from the main script filename called by
  1413. * the browser. Default = false.
  1414. *
  1415. * @return string|false Plugin name, or false if no plugin name was called
  1416. */
  1417. function get_plugin_name($mainfilename = false) {
  1418. elgg_deprecated_notice('get_plugin_name() is deprecated by elgg_get_calling_plugin_id()', 1.8);
  1419. return elgg_get_calling_plugin_id($mainfilename);
  1420. }
  1421. /**
  1422. * Load and parse a plugin manifest from a plugin XML file.
  1423. *
  1424. * @example plugins/manifest.xml Example 1.8-style manifest file.
  1425. *
  1426. * @deprecated 1.8 Use ElggPlugin->getManifest()
  1427. *
  1428. * @param string $plugin Plugin name.
  1429. * @return array of values
  1430. */
  1431. function load_plugin_manifest($plugin) {
  1432. elgg_deprecated_notice('load_plugin_manifest() is deprecated by ElggPlugin->getManifest()', 1.8);
  1433. $xml_file = elgg_get_plugins_path() . "$plugin/manifest.xml";
  1434. try {
  1435. $manifest = new ElggPluginManifest($xml_file, $plugin);
  1436. } catch(Exception $e) {
  1437. return false;
  1438. }
  1439. return $manifest->getManifest();
  1440. }
  1441. /**
  1442. * This function checks a plugin manifest 'elgg_version' value against the current install
  1443. * returning TRUE if the elgg_version is >= the current install's version.
  1444. *
  1445. * @deprecated 1.8 Use ElggPlugin->canActivate()
  1446. *
  1447. * @param string $manifest_elgg_version_string The build version (eg 2009010201).
  1448. * @return bool
  1449. */
  1450. function check_plugin_compatibility($manifest_elgg_version_string) {
  1451. elgg_deprecated_notice('check_plugin_compatibility() is deprecated by ElggPlugin->canActivate()', 1.8);
  1452. $version = get_version();
  1453. if (strpos($manifest_elgg_version_string, '.') === false) {
  1454. // Using version
  1455. $req_version = (int)$manifest_elgg_version_string;
  1456. return ($version >= $req_version);
  1457. }
  1458. return false;
  1459. }
  1460. /**
  1461. * Shorthand function for finding the plugin settings.
  1462. *
  1463. * @deprecated 1.8 Use elgg_get_calling_plugin_entity() or elgg_get_plugin_from_id()
  1464. *
  1465. * @param string $plugin_id Optional plugin id, if not specified
  1466. * then it is detected from where you are calling.
  1467. *
  1468. * @return mixed
  1469. */
  1470. function find_plugin_settings($plugin_id = null) {
  1471. elgg_deprecated_notice('find_plugin_setting() is deprecated by elgg_get_calling_plugin_entity() or elgg_get_plugin_from_id()', 1.8);
  1472. if ($plugin_id) {
  1473. return elgg_get_plugin_from_id($plugin_id);
  1474. } else {
  1475. return elgg_get_calling_plugin_entity();
  1476. }
  1477. }
  1478. /**
  1479. * Return an array of installed plugins.
  1480. *
  1481. * @deprecated 1.8 use elgg_get_plugins()
  1482. *
  1483. * @param string $status any|enabled|disabled
  1484. * @return array
  1485. */
  1486. function get_installed_plugins($status = 'all') {
  1487. global $CONFIG;
  1488. elgg_deprecated_notice('get_installed_plugins() was deprecated by elgg_get_plugins()', 1.8);
  1489. $plugins = elgg_get_plugins($status);
  1490. if (!$plugins) {
  1491. return array();
  1492. }
  1493. $installed_plugins = array();
  1494. foreach ($plugins as $plugin) {
  1495. if (!$plugin->isValid()) {
  1496. continue;
  1497. }
  1498. $include = true;
  1499. if ($status == 'enabled' && !$plugin->isActive()) {
  1500. $include = false;
  1501. } elseif ($status == 'disabled' && $plugin->isActive()) {
  1502. $include = true;
  1503. }
  1504. if ($include) {
  1505. $installed_plugins[$plugin->getID()] = array(
  1506. 'active' => $plugin->isActive(),
  1507. 'manifest' => $plugin->getManifest()->getManifest()
  1508. );
  1509. }
  1510. }
  1511. return $installed_plugins;
  1512. }
  1513. /**
  1514. * Enable a plugin for a site (default current site)
  1515. *
  1516. * Important: You should regenerate simplecache and the viewpath cache after executing this function
  1517. * otherwise you may experience view display artifacts. Do this with the following code:
  1518. *
  1519. * elgg_regenerate_simplecache();
  1520. * elgg_reset_system_cache();
  1521. *
  1522. * @deprecated 1.8 Use ElggPlugin->activate()
  1523. *
  1524. * @param string $plugin The plugin name.
  1525. * @param int $site_guid The site id, if not specified then this is detected.
  1526. *
  1527. * @return array
  1528. * @throws InvalidClassException
  1529. */
  1530. function enable_plugin($plugin, $site_guid = null) {
  1531. elgg_deprecated_notice('enable_plugin() was deprecated by ElggPlugin->activate()', 1.8);
  1532. $plugin = sanitise_string($plugin);
  1533. $site_guid = (int) $site_guid;
  1534. if (!$site_guid) {
  1535. $site = get_config('site');
  1536. $site_guid = $site->guid;
  1537. }
  1538. try {
  1539. $plugin = new ElggPlugin($plugin);
  1540. } catch(Exception $e) {
  1541. return false;
  1542. }
  1543. if (!$plugin->canActivate($site_guid)) {
  1544. return false;
  1545. }
  1546. return $plugin->activate($site_guid);
  1547. }
  1548. /**
  1549. * Disable a plugin for a site (default current site)
  1550. *
  1551. * Important: You should regenerate simplecache and the viewpath cache after executing this function
  1552. * otherwise you may experience view display artifacts. Do this with the following code:
  1553. *
  1554. * elgg_regenerate_simplecache();
  1555. * elgg_reset_system_cache();
  1556. *
  1557. * @deprecated 1.8 Use ElggPlugin->deactivate()
  1558. *
  1559. * @param string $plugin The plugin name.
  1560. * @param int $site_guid The site id, if not specified then this is detected.
  1561. *
  1562. * @return bool
  1563. * @throws InvalidClassException
  1564. */
  1565. function disable_plugin($plugin, $site_guid = 0) {
  1566. elgg_deprecated_notice('disable_plugin() was deprecated by ElggPlugin->deactivate()', 1.8);
  1567. $plugin = sanitise_string($plugin);
  1568. $site_guid = (int) $site_guid;
  1569. if (!$site_guid) {
  1570. $site = get_config('site');
  1571. $site_guid = $site->guid;
  1572. }
  1573. try {
  1574. $plugin = new ElggPlugin($plugin);
  1575. } catch(Exception $e) {
  1576. return false;
  1577. }
  1578. return $plugin->deactivate($site_guid);
  1579. }
  1580. /**
  1581. * Return whether a plugin is enabled or not.
  1582. *
  1583. * @deprecated 1.8 Use elgg_is_active_plugin()
  1584. *
  1585. * @param string $plugin The plugin name.
  1586. * @param int $site_guid The site id, if not specified then this is detected.
  1587. *
  1588. * @return bool
  1589. */
  1590. function is_plugin_enabled($plugin, $site_guid = 0) {
  1591. elgg_deprecated_notice('is_plugin_enabled() was deprecated by elgg_is_active_plugin()', 1.8);
  1592. return elgg_is_active_plugin($plugin, $site_guid);
  1593. }
  1594. /**
  1595. * Get entities based on their private data.
  1596. *
  1597. * @param string $name The name of the setting
  1598. * @param string $value The value of the setting
  1599. * @param string $type The type of entity (eg "user", "object" etc)
  1600. * @param string $subtype The arbitrary subtype of the entity
  1601. * @param int $owner_guid The GUID of the owning user
  1602. * @param string $order_by The field to order by; by default, time_created desc
  1603. * @param int $limit The number of entities to return; 10 by default
  1604. * @param int $offset The indexing offset, 0 by default
  1605. * @param boolean $count Return a count of entities
  1606. * @param int $site_guid The site to get entities for. 0 for current, -1 for any
  1607. * @param mixed $container_guid The container(s) GUIDs
  1608. *
  1609. * @return array A list of entities.
  1610. * @deprecated 1.8 Use elgg_get_entities_from_private_settings()
  1611. */
  1612. function get_entities_from_private_setting($name = "", $value = "", $type = "", $subtype = "",
  1613. $owner_guid = 0, $order_by = "", $limit = 10, $offset = 0, $count = false, $site_guid = 0,
  1614. $container_guid = null) {
  1615. elgg_deprecated_notice('get_entities_from_private_setting() was deprecated by elgg_get_entities_from_private_setting()!', 1.8);
  1616. $options = array();
  1617. $options['private_setting_name'] = $name;
  1618. $options['private_setting_value'] = $value;
  1619. // set container_guid to owner_guid to emulate old functionality
  1620. if ($owner_guid != "") {
  1621. if (is_null($container_guid)) {
  1622. $container_guid = $owner_guid;
  1623. }
  1624. }
  1625. if ($type) {
  1626. $options['types'] = $type;
  1627. }
  1628. if ($subtype) {
  1629. $options['subtypes'] = $subtype;
  1630. }
  1631. if ($owner_guid) {
  1632. if (is_array($owner_guid)) {
  1633. $options['owner_guids'] = $owner_guid;
  1634. } else {
  1635. $options['owner_guid'] = $owner_guid;
  1636. }
  1637. }
  1638. if ($container_guid) {
  1639. if (is_array($container_guid)) {
  1640. $options['container_guids'] = $container_guid;
  1641. } else {
  1642. $options['container_guid'] = $container_guid;
  1643. }
  1644. }
  1645. $options['limit'] = $limit;
  1646. if ($offset) {
  1647. $options['offset'] = $offset;
  1648. }
  1649. if ($order_by) {
  1650. $options['order_by'];
  1651. }
  1652. if ($site_guid) {
  1653. $options['site_guid'];
  1654. }
  1655. if ($count) {
  1656. $options['count'] = $count;
  1657. }
  1658. return elgg_get_entities_from_private_settings($options);
  1659. }
  1660. /**
  1661. * Get entities based on their private data by multiple keys.
  1662. *
  1663. * @param string $name The name of the setting
  1664. * @param mixed $type Entity type
  1665. * @param string $subtype Entity subtype
  1666. * @param int $owner_guid The GUID of the owning user
  1667. * @param string $order_by The field to order by; by default, time_created desc
  1668. * @param int $limit The number of entities to return; 10 by default
  1669. * @param int $offset The indexing offset, 0 by default
  1670. * @param bool $count Count entities
  1671. * @param int $site_guid Site GUID. 0 for current, -1 for any.
  1672. * @param mixed $container_guid Container GUID
  1673. *
  1674. * @return array A list of entities.
  1675. * @deprecated 1.8 Use elgg_get_entities_from_private_settings()
  1676. */
  1677. function get_entities_from_private_setting_multi(array $name, $type = "", $subtype = "",
  1678. $owner_guid = 0, $order_by = "", $limit = 10, $offset = 0, $count = false,
  1679. $site_guid = 0, $container_guid = null) {
  1680. elgg_deprecated_notice('get_entities_from_private_setting_multi() was deprecated by elgg_get_entities_from_private_settings()!', 1.8);
  1681. $options = array();
  1682. $pairs = array();
  1683. foreach ($name as $setting_name => $setting_value) {
  1684. $pairs[] = array('name' => $setting_name, 'value' => $setting_value);
  1685. }
  1686. $options['private_setting_name_value_pairs'] = $pairs;
  1687. // set container_guid to owner_guid to emulate old functionality
  1688. if ($owner_guid != "") {
  1689. if (is_null($container_guid)) {
  1690. $container_guid = $owner_guid;
  1691. }
  1692. }
  1693. if ($type) {
  1694. $options['types'] = $type;
  1695. }
  1696. if ($subtype) {
  1697. $options['subtypes'] = $subtype;
  1698. }
  1699. if ($owner_guid) {
  1700. if (is_array($owner_guid)) {
  1701. $options['owner_guids'] = $owner_guid;
  1702. } else {
  1703. $options['owner_guid'] = $owner_guid;
  1704. }
  1705. }
  1706. if ($container_guid) {
  1707. if (is_array($container_guid)) {
  1708. $options['container_guids'] = $container_guid;
  1709. } else {
  1710. $options['container_guid'] = $container_guid;
  1711. }
  1712. }
  1713. $options['limit'] = $limit;
  1714. if ($offset) {
  1715. $options['offset'] = $offset;
  1716. }
  1717. if ($order_by) {
  1718. $options['order_by'];
  1719. }
  1720. if ($site_guid) {
  1721. $options['site_guid'];
  1722. }
  1723. if ($count) {
  1724. $options['count'] = $count;
  1725. }
  1726. return elgg_get_entities_from_private_settings($options);
  1727. }
  1728. /**
  1729. * Returns a viewable list of entities by relationship
  1730. *
  1731. * @see elgg_view_entity_list
  1732. *
  1733. * @deprecated 1.8 Use elgg_list_entities_from_relationship()
  1734. *
  1735. * @param string $relationship The relationship eg "friends_of"
  1736. * @param int $relationship_guid The guid of the entity to use query
  1737. * @param bool $inverse_relationship Reverse the normal function of the query to instead say "give me all entities for whome $relationship_guid is a $relationship of"
  1738. * @param string $type The type of entity (eg 'object')
  1739. * @param string $subtype The entity subtype
  1740. * @param int $owner_guid The owner (default: all)
  1741. * @param int $limit The number of entities to display on a page
  1742. * @param true|false $fullview Whether or not to display the full view (default: true)
  1743. * @param true|false $viewtypetoggle Whether or not to allow gallery view
  1744. * @param true|false $pagination Whether to display pagination (default: true)
  1745. * @param bool $order_by SQL order by clause
  1746. * @return string The viewable list of entities
  1747. */
  1748. function list_entities_from_relationship($relationship, $relationship_guid,
  1749. $inverse_relationship = false, $type = ELGG_ENTITIES_ANY_VALUE,
  1750. $subtype = ELGG_ENTITIES_ANY_VALUE, $owner_guid = 0, $limit = 10,
  1751. $fullview = true, $listtypetoggle = false, $pagination = true, $order_by = '') {
  1752. elgg_deprecated_notice("list_entities_from_relationship was deprecated by elgg_list_entities_from_relationship()!", 1.8);
  1753. return elgg_list_entities_from_relationship(array(
  1754. 'relationship' => $relationship,
  1755. 'relationship_guid' => $relationship_guid,
  1756. 'inverse_relationship' => $inverse_relationship,
  1757. 'type' => $type,
  1758. 'subtype' => $subtype,
  1759. 'owner_guid' => $owner_guid,
  1760. 'order_by' => $order_by,
  1761. 'limit' => $limit,
  1762. 'full_view' => $fullview,
  1763. 'list_type_toggle' => $listtypetoggle,
  1764. 'pagination' => $pagination,
  1765. ));
  1766. }
  1767. /**
  1768. * Gets the number of entities by a the number of entities related to them in a particular way.
  1769. * This is a good way to get out the users with the most friends, or the groups with the
  1770. * most members.
  1771. *
  1772. * @deprecated 1.8 Use elgg_get_entities_from_relationship_count()
  1773. *
  1774. * @param string $relationship The relationship eg "friends_of"
  1775. * @param bool $inverse_relationship Inverse relationship owners
  1776. * @param string $type The type of entity (default: all)
  1777. * @param string $subtype The entity subtype (default: all)
  1778. * @param int $owner_guid The owner of the entities (default: none)
  1779. * @param int $limit Limit
  1780. * @param int $offset Offset
  1781. * @param bool $count Return a count instead of entities
  1782. * @param int $site_guid Site GUID
  1783. *
  1784. * @return array|int|false An array of entities, or the number of entities, or false on failure
  1785. */
  1786. function get_entities_by_relationship_count($relationship, $inverse_relationship = true, $type = "",
  1787. $subtype = "", $owner_guid = 0, $limit = 10, $offset = 0, $count = false, $site_guid = 0) {
  1788. elgg_deprecated_notice('get_entities_by_relationship_count() is deprecated by elgg_get_entities_from_relationship_count()', 1.8);
  1789. $options = array();
  1790. $options['relationship'] = $relationship;
  1791. // this used to default to true, which is wrong.
  1792. // flip it for the new function
  1793. $options['inverse_relationship'] = !$inverse_relationship;
  1794. if ($type) {
  1795. $options['types'] = $type;
  1796. }
  1797. if ($subtype) {
  1798. $options['subtypes'] = $subtype;
  1799. }
  1800. if ($owner_guid) {
  1801. $options['owner_guid'] = $owner_guid;
  1802. }
  1803. $options['limit'] = $limit;
  1804. if ($offset) {
  1805. $options['offset'] = $offset;
  1806. }
  1807. if ($site_guid) {
  1808. $options['site_guid'];
  1809. }
  1810. if ($count) {
  1811. $options['count'] = $count;
  1812. }
  1813. return elgg_get_entities_from_relationship_count($options);
  1814. }
  1815. /**
  1816. * Displays a human-readable list of entities
  1817. *
  1818. * @deprecated 1.8 Use elgg_list_entities_from_relationship_count()
  1819. *
  1820. * @param string $relationship The relationship eg "friends_of"
  1821. * @param bool $inverse_relationship Inverse relationship owners
  1822. * @param string $type The type of entity (eg 'object')
  1823. * @param string $subtype The entity subtype
  1824. * @param int $owner_guid The owner (default: all)
  1825. * @param int $limit The number of entities to display on a page
  1826. * @param bool $fullview Whether or not to display the full view (default: true)
  1827. * @param bool $listtypetoggle Whether or not to allow gallery view
  1828. * @param bool $pagination Whether to display pagination (default: true)
  1829. *
  1830. * @return string The viewable list of entities
  1831. */
  1832. function list_entities_by_relationship_count($relationship, $inverse_relationship = true,
  1833. $type = "", $subtype = "", $owner_guid = 0, $limit = 10, $fullview = true,
  1834. $listtypetoggle = false, $pagination = true) {
  1835. elgg_deprecated_notice('list_entities_by_relationship_count() was deprecated by elgg_list_entities_from_relationship_count()', 1.8);
  1836. $options = array();
  1837. $options['relationship'] = $relationship;
  1838. // this used to default to true, which is wrong.
  1839. // flip it for the new function
  1840. $options['inverse_relationship'] = !$inverse_relationship;
  1841. if ($type) {
  1842. $options['types'] = $type;
  1843. }
  1844. if ($subtype) {
  1845. $options['subtypes'] = $subtype;
  1846. }
  1847. if ($owner_guid) {
  1848. $options['owner_guid'] = $owner_guid;
  1849. }
  1850. $options['limit'] = $limit;
  1851. $options['full_view'] = $fullview;
  1852. return elgg_list_entities_from_relationship_count($options);
  1853. }
  1854. /**
  1855. * Gets the number of entities by a the number of entities related to
  1856. * them in a particular way also constrained by metadata.
  1857. *
  1858. * @deprecated 1.8 Use elgg_get_entities_from_relationship()
  1859. *
  1860. * @param string $relationship The relationship eg "friends_of"
  1861. * @param int $relationship_guid The guid of the entity to use query
  1862. * @param bool $inverse_relationship Inverse relationship owner
  1863. * @param String $meta_name The metadata name
  1864. * @param String $meta_value The metadata value
  1865. * @param string $type The type of entity (default: all)
  1866. * @param string $subtype The entity subtype (default: all)
  1867. * @param int $owner_guid The owner of the entities (default: none)
  1868. * @param int $limit Limit
  1869. * @param int $offset Offset
  1870. * @param bool $count Return a count instead of entities
  1871. * @param int $site_guid Site GUID
  1872. *
  1873. * @return array|int|false An array of entities, or the number of entities, or false on failure
  1874. */
  1875. function get_entities_from_relationships_and_meta($relationship, $relationship_guid,
  1876. $inverse_relationship = false, $meta_name = "", $meta_value = "", $type = "",
  1877. $subtype = "", $owner_guid = 0, $limit = 10, $offset = 0, $count = false, $site_guid = 0) {
  1878. elgg_deprecated_notice('get_entities_from_relationship_and_meta() was deprecated by elgg_get_entities_from_relationship()!', 1.7);
  1879. $options = array();
  1880. $options['relationship'] = $relationship;
  1881. $options['relationship_guid'] = $relationship_guid;
  1882. $options['inverse_relationship'] = $inverse_relationship;
  1883. if ($meta_value) {
  1884. $options['values'] = $meta_value;
  1885. }
  1886. if ($entity_type) {
  1887. $options['types'] = $entity_type;
  1888. }
  1889. if ($type) {
  1890. $options['types'] = $type;
  1891. }
  1892. if ($subtype) {
  1893. $options['subtypes'] = $subtype;
  1894. }
  1895. if ($owner_guid) {
  1896. $options['owner_guid'] = $owner_guid;
  1897. }
  1898. if ($limit) {
  1899. $options['limit'] = $limit;
  1900. }
  1901. if ($offset) {
  1902. $options['offset'] = $offset;
  1903. }
  1904. if ($order_by) {
  1905. $options['order_by'];
  1906. }
  1907. if ($site_guid) {
  1908. $options['site_guid'];
  1909. }
  1910. if ($count) {
  1911. $options['count'] = $count;
  1912. }
  1913. return elgg_get_entities_from_relationship($options);
  1914. }
  1915. /**
  1916. * Retrieves items from the river. All parameters are optional.
  1917. *
  1918. * @param int|array $subject_guid Acting entity to restrict to. Default: all
  1919. * @param int|array $object_guid Entity being acted on to restrict to. Default: all
  1920. * @param string $subject_relationship If set to a relationship type, this will use
  1921. * $subject_guid as the starting point and set the
  1922. * subjects to be all users this
  1923. * entity has this relationship with (eg 'friend').
  1924. * Default: blank
  1925. * @param string $type The type of entity to restrict to. Default: all
  1926. * @param string $subtype The subtype of entity to restrict to. Default: all
  1927. * @param string $action_type The type of river action to restrict to. Default: all
  1928. * @param int $limit The number of items to retrieve. Default: 20
  1929. * @param int $offset The page offset. Default: 0
  1930. * @param int $posted_min The minimum time period to look at. Default: none
  1931. * @param int $posted_max The maximum time period to look at. Default: none
  1932. *
  1933. * @return array|false Depending on success
  1934. * @deprecated 1.8 Use elgg_get_river()
  1935. */
  1936. function get_river_items($subject_guid = 0, $object_guid = 0, $subject_relationship = '',
  1937. $type = '', $subtype = '', $action_type = '', $limit = 20, $offset = 0, $posted_min = 0,
  1938. $posted_max = 0) {
  1939. elgg_deprecated_notice("get_river_items deprecated by elgg_get_river", 1.8);
  1940. $options = array();
  1941. if ($subject_guid) {
  1942. $options['subject_guid'] = $subject_guid;
  1943. }
  1944. if ($object_guid) {
  1945. $options['object_guid'] = $object_guid;
  1946. }
  1947. if ($subject_relationship) {
  1948. $options['relationship'] = $subject_relationship;
  1949. unset($options['subject_guid']);
  1950. $options['relationship_guid'] = $subject_guid;
  1951. }
  1952. if ($type) {
  1953. $options['type'] = $type;
  1954. }
  1955. if ($subtype) {
  1956. $options['subtype'] = $subtype;
  1957. }
  1958. if ($action_type) {
  1959. $options['action_type'] = $action_type;
  1960. }
  1961. $options['limit'] = $limit;
  1962. $options['offset'] = $offset;
  1963. if ($posted_min) {
  1964. $options['posted_time_lower'] = $posted_min;
  1965. }
  1966. if ($posted_max) {
  1967. $options['posted_time_upper'] = $posted_max;
  1968. }
  1969. return elgg_get_river($options);
  1970. }
  1971. /**
  1972. * Returns a human-readable version of the river.
  1973. *
  1974. * @param int|array $subject_guid Acting entity to restrict to. Default: all
  1975. * @param int|array $object_guid Entity being acted on to restrict to. Default: all
  1976. * @param string $subject_relationship If set to a relationship type, this will use
  1977. * $subject_guid as the starting point and set
  1978. * the subjects to be all users this entity has this
  1979. * relationship with (eg 'friend'). Default: blank
  1980. * @param string $type The type of entity to restrict to. Default: all
  1981. * @param string $subtype The subtype of entity to restrict to. Default: all
  1982. * @param string $action_type The type of river action to restrict to. Default: all
  1983. * @param int $limit The number of items to retrieve. Default: 20
  1984. * @param int $posted_min The minimum time period to look at. Default: none
  1985. * @param int $posted_max The maximum time period to look at. Default: none
  1986. * @param bool $pagination Show pagination?
  1987. *
  1988. * @return string Human-readable river.
  1989. * @deprecated 1.8 Use elgg_list_river()
  1990. */
  1991. function elgg_view_river_items($subject_guid = 0, $object_guid = 0, $subject_relationship = '',
  1992. $type = '', $subtype = '', $action_type = '', $limit = 20, $posted_min = 0,
  1993. $posted_max = 0, $pagination = true) {
  1994. elgg_deprecated_notice("elgg_view_river_items deprecated for elgg_list_river", 1.8);
  1995. $river_items = get_river_items($subject_guid, $object_guid, $subject_relationship,
  1996. $type, $subtype, $action_type, $limit + 1, $posted_min, $posted_max);
  1997. // Get input from outside world and sanitise it
  1998. $offset = (int) get_input('offset', 0);
  1999. // view them
  2000. $params = array(
  2001. 'items' => $river_items,
  2002. 'count' => count($river_items),
  2003. 'offset' => $offset,
  2004. 'limit' => $limit,
  2005. 'pagination' => $pagination,
  2006. 'list-class' => 'elgg-list-river',
  2007. );
  2008. return elgg_view('page/components/list', $params);
  2009. }
  2010. /**
  2011. * Construct and execute the query required for the activity stream.
  2012. *
  2013. * @deprecated 1.8 This is outdated and uses the systemlog table instead of the river table.
  2014. * Don't use it.
  2015. */
  2016. function get_activity_stream_data($limit = 10, $offset = 0, $type = "", $subtype = "",
  2017. $owner_guid = "", $owner_relationship = "") {
  2018. elgg_deprecated_notice("get_activity_stream_data was deprecated", 1.8);
  2019. global $CONFIG;
  2020. $limit = (int)$limit;
  2021. $offset = (int)$offset;
  2022. if ($type) {
  2023. if (!is_array($type)) {
  2024. $type = array(sanitise_string($type));
  2025. } else {
  2026. foreach ($type as $k => $v) {
  2027. $type[$k] = sanitise_string($v);
  2028. }
  2029. }
  2030. }
  2031. if ($subtype) {
  2032. if (!is_array($subtype)) {
  2033. $subtype = array(sanitise_string($subtype));
  2034. } else {
  2035. foreach ($subtype as $k => $v) {
  2036. $subtype[$k] = sanitise_string($v);
  2037. }
  2038. }
  2039. }
  2040. if ($owner_guid) {
  2041. if (is_array($owner_guid)) {
  2042. foreach ($owner_guid as $k => $v) {
  2043. $owner_guid[$k] = (int)$v;
  2044. }
  2045. } else {
  2046. $owner_guid = array((int)$owner_guid);
  2047. }
  2048. }
  2049. $owner_relationship = sanitise_string($owner_relationship);
  2050. // Get a list of possible views
  2051. $activity_events = array();
  2052. $activity_views = array_merge(elgg_view_tree('activity', 'default'),
  2053. elgg_view_tree('river', 'default'));
  2054. $done = array();
  2055. foreach ($activity_views as $view) {
  2056. $fragments = explode('/', $view);
  2057. $tmp = explode('/', $view, 2);
  2058. $tmp = $tmp[1];
  2059. if ((isset($fragments[0])) && (($fragments[0] == 'river') || ($fragments[0] == 'activity'))
  2060. && (!in_array($tmp, $done))) {
  2061. if (isset($fragments[1])) {
  2062. $f = array();
  2063. for ($n = 1; $n < count($fragments); $n++) {
  2064. $val = sanitise_string($fragments[$n]);
  2065. switch($n) {
  2066. case 1: $key = 'type'; break;
  2067. case 2: $key = 'subtype'; break;
  2068. case 3: $key = 'event'; break;
  2069. }
  2070. $f[$key] = $val;
  2071. }
  2072. // Filter result based on parameters
  2073. $add = true;
  2074. if ($type) {
  2075. if (!in_array($f['type'], $type)) {
  2076. $add = false;
  2077. }
  2078. }
  2079. if (($add) && ($subtype)) {
  2080. if (!in_array($f['subtype'], $subtype)) {
  2081. $add = false;
  2082. }
  2083. }
  2084. if (($add) && ($event)) {
  2085. if (!in_array($f['event'], $event)) {
  2086. $add = false;
  2087. }
  2088. }
  2089. if ($add) {
  2090. $activity_events[] = $f;
  2091. }
  2092. }
  2093. $done[] = $tmp;
  2094. }
  2095. }
  2096. $n = 0;
  2097. foreach ($activity_events as $details) {
  2098. // Get what we're talking about
  2099. if ($details['subtype'] == 'default') {
  2100. $details['subtype'] = '';
  2101. }
  2102. if (($details['type']) && ($details['event'])) {
  2103. if ($n > 0) {
  2104. $obj_query .= " or ";
  2105. }
  2106. $access = "";
  2107. if ($details['type'] != 'relationship') {
  2108. $access = " and " . get_access_sql_suffix('sl');
  2109. }
  2110. $obj_query .= "( sl.object_type='{$details['type']}'
  2111. AND sl.object_subtype='{$details['subtype']}'
  2112. AND sl.event='{$details['event']}' $access )";
  2113. $n++;
  2114. }
  2115. }
  2116. // User
  2117. if ((count($owner_guid)) && ($owner_guid[0] != 0)) {
  2118. $user = " and sl.performed_by_guid in (" . implode(',', $owner_guid) . ")";
  2119. if ($owner_relationship) {
  2120. $friendsarray = "";
  2121. if ($friends = elgg_get_entities_from_relationship(array(
  2122. 'relationship' => $owner_relationship,
  2123. 'relationship_guid' => $owner_guid[0],
  2124. 'inverse_relationship' => FALSE,
  2125. 'type' => 'user',
  2126. 'subtype' => $subtype,
  2127. 'limit' => false))
  2128. ) {
  2129. $friendsarray = array();
  2130. foreach ($friends as $friend) {
  2131. $friendsarray[] = $friend->getGUID();
  2132. }
  2133. $user = " and sl.performed_by_guid in (" . implode(',', $friendsarray) . ")";
  2134. }
  2135. }
  2136. }
  2137. $query = "SELECT sl.* FROM {$CONFIG->dbprefix}system_log sl
  2138. WHERE 1 $user AND ($obj_query)
  2139. ORDER BY sl.time_created desc limit $offset, $limit";
  2140. return get_data($query);
  2141. }
  2142. /**
  2143. * Perform standard authentication with a given username and password.
  2144. * Returns an ElggUser object for use with login.
  2145. *
  2146. * @see login
  2147. *
  2148. * @param string $username The username, optionally (for standard logins)
  2149. * @param string $password The password, optionally (for standard logins)
  2150. *
  2151. * @return ElggUser|false The authenticated user object, or false on failure.
  2152. *
  2153. * @deprecated 1.8 Use elgg_authenticate
  2154. */
  2155. function authenticate($username, $password) {
  2156. elgg_deprecated_notice('authenticate() has been deprecated for elgg_authenticate()', 1.8);
  2157. $pam = new ElggPAM('user');
  2158. $credentials = array('username' => $username, 'password' => $password);
  2159. $result = $pam->authenticate($credentials);
  2160. if ($result) {
  2161. return get_user_by_username($username);
  2162. }
  2163. return false;
  2164. }
  2165. /**
  2166. * Get the members of a site.
  2167. *
  2168. * @param int $site_guid Site GUID
  2169. * @param int $limit User GUID
  2170. * @param int $offset Offset
  2171. *
  2172. * @return mixed
  2173. * @deprecated 1.8 Use ElggSite::getMembers()
  2174. */
  2175. function get_site_members($site_guid, $limit = 10, $offset = 0) {
  2176. elgg_deprecated_notice("get_site_members() deprecated.
  2177. Use ElggSite::getMembers()", 1.8);
  2178. $site = get_entity($site_guid);
  2179. if ($site) {
  2180. return $site->getMembers($limit, $offset);
  2181. }
  2182. return false;
  2183. }
  2184. /**
  2185. * Display a list of site members
  2186. *
  2187. * @param int $site_guid The GUID of the site
  2188. * @param int $limit The number of members to display on a page
  2189. * @param bool $fullview Whether or not to display the full view (default: true)
  2190. *
  2191. * @return string A displayable list of members
  2192. * @deprecated 1.8 Use ElggSite::listMembers()
  2193. */
  2194. function list_site_members($site_guid, $limit = 10, $fullview = true) {
  2195. elgg_deprecated_notice("list_site_members() deprecated.
  2196. Use ElggSite::listMembers()", 1.8);
  2197. $options = array(
  2198. 'limit' => $limit,
  2199. 'full_view' => $full_view,
  2200. );
  2201. $site = get_entity($site_guid);
  2202. if ($site) {
  2203. return $site->listMembers($options);
  2204. }
  2205. return '';
  2206. }
  2207. /**
  2208. * Add a collection to a site.
  2209. *
  2210. * @param int $site_guid Site GUID
  2211. * @param int $collection_guid Collection GUID
  2212. *
  2213. * @return mixed
  2214. * @deprecated 1.8 Don't use this.
  2215. */
  2216. function add_site_collection($site_guid, $collection_guid) {
  2217. elgg_deprecated_notice("add_site_collection has been deprecated", 1.8);
  2218. global $CONFIG;
  2219. $site_guid = (int)$site_guid;
  2220. $collection_guid = (int)$collection_guid;
  2221. return add_entity_relationship($collection_guid, "member_of_site", $site_guid);
  2222. }
  2223. /**
  2224. * Remove a collection from a site.
  2225. *
  2226. * @param int $site_guid Site GUID
  2227. * @param int $collection_guid Collection GUID
  2228. *
  2229. * @return mixed
  2230. * @deprecated 1.8 Don't use this.
  2231. */
  2232. function remove_site_collection($site_guid, $collection_guid) {
  2233. elgg_deprecated_notice("remove_site_collection has been deprecated", 1.8);
  2234. $site_guid = (int)$site_guid;
  2235. $collection_guid = (int)$collection_guid;
  2236. return remove_entity_relationship($collection_guid, "member_of_site", $site_guid);
  2237. }
  2238. /**
  2239. * Get the collections belonging to a site.
  2240. *
  2241. * @param int $site_guid Site GUID
  2242. * @param string $subtype Subtype
  2243. * @param int $limit Limit
  2244. * @param int $offset Offset
  2245. *
  2246. * @return mixed
  2247. * @deprecated 1.8 Don't use this.
  2248. */
  2249. function get_site_collections($site_guid, $subtype = "", $limit = 10, $offset = 0) {
  2250. elgg_deprecated_notice("get_site_collections has been deprecated", 1.8);
  2251. $site_guid = (int)$site_guid;
  2252. $subtype = sanitise_string($subtype);
  2253. $limit = (int)$limit;
  2254. $offset = (int)$offset;
  2255. // collection isn't a valid type. This won't work.
  2256. return elgg_get_entities_from_relationship(array(
  2257. 'relationship' => 'member_of_site',
  2258. 'relationship_guid' => $site_guid,
  2259. 'inverse_relationship' => TRUE,
  2260. 'type' => 'collection',
  2261. 'subtype' => $subtype,
  2262. 'limit' => $limit,
  2263. 'offset' => $offset
  2264. ));
  2265. }
  2266. /**
  2267. * Get an array of tags with weights for use with the output/tagcloud view.
  2268. *
  2269. * @deprecated 1.8 Use elgg_get_tags().
  2270. *
  2271. * @param int $threshold Get the threshold of minimum number of each tags to
  2272. * bother with (ie only show tags where there are more
  2273. * than $threshold occurances)
  2274. * @param int $limit Number of tags to return
  2275. * @param string $metadata_name Optionally, the name of the field you want to grab for
  2276. * @param string $entity_type Optionally, the entity type ('object' etc)
  2277. * @param string $entity_subtype The entity subtype, optionally
  2278. * @param int $owner_guid The GUID of the tags owner, optionally
  2279. * @param int $site_guid Optionally, the site to restrict to (default is the current site)
  2280. * @param int $start_ts Optionally specify a start timestamp for tags used to
  2281. * generate cloud.
  2282. * @param int $end_ts Optionally specify an end timestamp for tags used to generate cloud
  2283. *
  2284. * @return array|false Array of objects with ->tag and ->total values, or false on failure
  2285. */
  2286. function get_tags($threshold = 1, $limit = 10, $metadata_name = "", $entity_type = "object",
  2287. $entity_subtype = "", $owner_guid = "", $site_guid = -1, $start_ts = "", $end_ts = "") {
  2288. elgg_deprecated_notice('get_tags() has been replaced by elgg_get_tags()', 1.8);
  2289. if (is_array($metadata_name)) {
  2290. return false;
  2291. }
  2292. $options = array();
  2293. if ($metadata_name === '') {
  2294. $options['tag_names'] = array();
  2295. } else {
  2296. $options['tag_names'] = array($metadata_name);
  2297. }
  2298. $options['threshold'] = $threshold;
  2299. $options['limit'] = $limit;
  2300. // rewrite owner_guid to container_guid to emulate old functionality
  2301. $container_guid = $owner_guid;
  2302. if ($container_guid) {
  2303. $options['container_guids'] = $container_guid;
  2304. }
  2305. if ($entity_type) {
  2306. $options['type'] = $entity_type;
  2307. }
  2308. if ($entity_subtype) {
  2309. $options['subtype'] = $entity_subtype;
  2310. }
  2311. if ($site_guid != -1) {
  2312. $options['site_guids'] = $site_guid;
  2313. }
  2314. if ($end_ts) {
  2315. $options['created_time_upper'] = $end_ts;
  2316. }
  2317. if ($start_ts) {
  2318. $options['created_time_lower'] = $start_ts;
  2319. }
  2320. $r = elgg_get_tags($options);
  2321. return $r;
  2322. }
  2323. /**
  2324. * Loads and displays a tagcloud given particular criteria.
  2325. *
  2326. * @deprecated 1.8 use elgg_view_tagcloud()
  2327. *
  2328. * @param int $threshold Get the threshold of minimum number of each tags
  2329. * to bother with (ie only show tags where there are
  2330. * more than $threshold occurances)
  2331. * @param int $limit Number of tags to return
  2332. * @param string $metadata_name Optionally, the name of the field you want to grab for
  2333. * @param string $entity_type Optionally, the entity type ('object' etc)
  2334. * @param string $entity_subtype The entity subtype, optionally
  2335. * @param int $owner_guid The GUID of the tags owner, optionally
  2336. * @param int $site_guid Optionally, the site to restrict to (default is the current site)
  2337. * @param int $start_ts Optionally specify a start timestamp for tags used to
  2338. * generate cloud.
  2339. * @param int $end_ts Optionally specify an end timestamp for tags used to generate
  2340. * cloud.
  2341. *
  2342. * @return string The HTML (or other, depending on view type) of the tagcloud.
  2343. */
  2344. function display_tagcloud($threshold = 1, $limit = 10, $metadata_name = "", $entity_type = "object",
  2345. $entity_subtype = "", $owner_guid = "", $site_guid = -1, $start_ts = "", $end_ts = "") {
  2346. elgg_deprecated_notice('display_tagcloud() was deprecated by elgg_view_tagcloud()!', 1.8);
  2347. $tags = get_tags($threshold, $limit, $metadata_name, $entity_type,
  2348. $entity_subtype, $owner_guid, $site_guid, $start_ts, $end_ts);
  2349. return elgg_view('output/tagcloud', array(
  2350. 'value' => $tags,
  2351. 'type' => $entity_type,
  2352. 'subtype' => $entity_subtype,
  2353. ));
  2354. }
  2355. /**
  2356. * Obtains a list of objects owned by a user
  2357. *
  2358. * @param int $user_guid The GUID of the owning user
  2359. * @param string $subtype Optionally, the subtype of objects
  2360. * @param int $limit The number of results to return (default 10)
  2361. * @param int $offset Indexing offset, if any
  2362. * @param int $timelower The earliest time the entity can have been created. Default: all
  2363. * @param int $timeupper The latest time the entity can have been created. Default: all
  2364. *
  2365. * @return false|array An array of ElggObjects or false, depending on success
  2366. * @deprecated 1.8 Use elgg_get_entities() instead
  2367. */
  2368. function get_user_objects($user_guid, $subtype = ELGG_ENTITIES_ANY_VALUE, $limit = 10,
  2369. $offset = 0, $timelower = 0, $timeupper = 0) {
  2370. elgg_deprecated_notice("get_user_objects() was deprecated in favor of elgg_get_entities()", 1.8);
  2371. $ntt = elgg_get_entities(array(
  2372. 'type' => 'object',
  2373. 'subtype' => $subtype,
  2374. 'owner_guid' => $user_guid,
  2375. 'limit' => $limit,
  2376. 'offset' => $offset,
  2377. 'container_guid' => $user_guid,
  2378. 'created_time_lower' => $timelower,
  2379. 'created_time_upper' => $timeupper
  2380. ));
  2381. return $ntt;
  2382. }
  2383. /**
  2384. * Counts the objects (optionally of a particular subtype) owned by a user
  2385. *
  2386. * @param int $user_guid The GUID of the owning user
  2387. * @param string $subtype Optionally, the subtype of objects
  2388. * @param int $timelower The earliest time the entity can have been created. Default: all
  2389. * @param int $timeupper The latest time the entity can have been created. Default: all
  2390. *
  2391. * @return int The number of objects the user owns (of this subtype)
  2392. * @deprecated 1.8 Use elgg_get_entities() instead
  2393. */
  2394. function count_user_objects($user_guid, $subtype = ELGG_ENTITIES_ANY_VALUE, $timelower = 0,
  2395. $timeupper = 0) {
  2396. elgg_deprecated_notice("count_user_objects() was deprecated in favor of elgg_get_entities()", 1.8);
  2397. $total = elgg_get_entities(array(
  2398. 'type' => 'object',
  2399. 'subtype' => $subtype,
  2400. 'owner_guid' => $user_guid,
  2401. 'count' => TRUE,
  2402. 'container_guid' => $user_guid,
  2403. 'created_time_lower' => $timelower,
  2404. 'created_time_upper' => $timeupper
  2405. ));
  2406. return $total;
  2407. }
  2408. /**
  2409. * Displays a list of user objects of a particular subtype, with navigation.
  2410. *
  2411. * @see elgg_view_entity_list
  2412. *
  2413. * @param int $user_guid The GUID of the user
  2414. * @param string $subtype The object subtype
  2415. * @param int $limit The number of entities to display on a page
  2416. * @param bool $fullview Whether or not to display the full view (default: true)
  2417. * @param bool $listtypetoggle Whether or not to allow gallery view (default: true)
  2418. * @param bool $pagination Whether to display pagination (default: true)
  2419. * @param int $timelower The earliest time the entity can have been created. Default: all
  2420. * @param int $timeupper The latest time the entity can have been created. Default: all
  2421. *
  2422. * @return string The list in a form suitable to display
  2423. * @deprecated 1.8 Use elgg_list_entities() instead
  2424. */
  2425. function list_user_objects($user_guid, $subtype = ELGG_ENTITIES_ANY_VALUE, $limit = 10,
  2426. $fullview = true, $listtypetoggle = true, $pagination = true, $timelower = 0, $timeupper = 0) {
  2427. elgg_deprecated_notice("list_user_objects() was deprecated in favor of elgg_list_entities()", 1.8);
  2428. $offset = (int) get_input('offset');
  2429. $limit = (int) $limit;
  2430. $count = (int) count_user_objects($user_guid, $subtype, $timelower, $timeupper);
  2431. $entities = get_user_objects($user_guid, $subtype, $limit, $offset, $timelower, $timeupper);
  2432. return elgg_view_entity_list($entities, $count, $offset, $limit, $fullview, $listtypetoggle,
  2433. $pagination);
  2434. }
  2435. /**
  2436. * Get user objects by an array of metadata
  2437. *
  2438. * @param int $user_guid The GUID of the owning user
  2439. * @param string $subtype Optionally, the subtype of objects
  2440. * @param array $metadata An array of metadata
  2441. * @param int $limit The number of results to return (default 10)
  2442. * @param int $offset Indexing offset, if any
  2443. *
  2444. * @return false|array An array of ElggObjects or false, depending on success
  2445. * @deprecated 1.8 Use elgg_get_entities_from_metadata() instead
  2446. */
  2447. function get_user_objects_by_metadata($user_guid, $subtype = "", $metadata = array(),
  2448. $limit = 0, $offset = 0) {
  2449. elgg_deprecated_notice("get_user_objects_by_metadata() was deprecated in favor of elgg_get_entities_from_metadata()", 1.8);
  2450. return get_entities_from_metadata_multi($metadata, "object", $subtype, $user_guid,
  2451. $limit, $offset);
  2452. }
  2453. /**
  2454. * Set the validation status for a user.
  2455. *
  2456. * @param bool $status Validated (true) or false
  2457. * @param string $method Optional method to say how a user was validated
  2458. * @return bool
  2459. * @deprecated 1.8 Use elgg_set_user_validation_status()
  2460. */
  2461. function set_user_validation_status($user_guid, $status, $method = '') {
  2462. elgg_deprecated_notice("set_user_validation_status() is deprecated", 1.8);
  2463. return elgg_set_user_validation_status($user_guid, $status, $method);
  2464. }
  2465. /**
  2466. * Trigger an event requesting that a user guid be validated somehow - either by email address or some other way.
  2467. *
  2468. * This function invalidates any existing validation value.
  2469. *
  2470. * @param int $user_guid User's GUID
  2471. * @deprecated 1.8 Hook into the register, user plugin hook and request validation.
  2472. */
  2473. function request_user_validation($user_guid) {
  2474. elgg_deprecated_notice("request_user_validation() is deprecated.
  2475. Plugins should register for the 'register, user' plugin hook", 1.8);
  2476. $user = get_entity($user_guid);
  2477. if (($user) && ($user instanceof ElggUser)) {
  2478. // invalidate any existing validations
  2479. set_user_validation_status($user_guid, false);
  2480. // request validation
  2481. trigger_elgg_event('validate', 'user', $user);
  2482. }
  2483. }
  2484. /**
  2485. * Register a user settings page with the admin panel.
  2486. * This function extends the view "usersettings/main" with the provided view.
  2487. * This view should provide a description and either a control or a link to.
  2488. *
  2489. * Usage:
  2490. * - To add a control to the main admin panel then extend usersettings/main
  2491. * - To add a control to a new page create a page which renders a view
  2492. * usersettings/subpage (where subpage is your new page -
  2493. * nb. some pages already exist that you can extend), extend the main view
  2494. * to point to it, and add controls to your new view.
  2495. *
  2496. * At the moment this is essentially a wrapper around elgg_extend_view().
  2497. *
  2498. * @param string $new_settings_view The view associated with the control you're adding
  2499. * @param string $view The view to extend, by default this is 'usersettings/main'.
  2500. * @param int $priority Optional priority to govern the appearance in the list.
  2501. *
  2502. * @return bool
  2503. * @deprecated 1.8 Extend one of the views in core/settings
  2504. */
  2505. function extend_elgg_settings_page($new_settings_view, $view = 'usersettings/main',
  2506. $priority = 500) {
  2507. // see views: /core/settings
  2508. elgg_deprecated_notice("extend_elgg_settings_page has been deprecated. Extend one of the settings views instead", 1.8);
  2509. return elgg_extend_view($view, $new_settings_view, $priority);
  2510. }
  2511. /**
  2512. * Returns a representation of a full 'page' (which might be an HTML page,
  2513. * RSS file, etc, depending on the current viewtype)
  2514. *
  2515. * @param string $title
  2516. * @param string $body
  2517. * @return string
  2518. *
  2519. * @deprecated 1.8 Use elgg_view_page()
  2520. */
  2521. function page_draw($title, $body, $sidebar = "") {
  2522. elgg_deprecated_notice("page_draw() was deprecated in favor of elgg_view_page() in 1.8.", 1.8);
  2523. $vars = array(
  2524. 'sidebar' => $sidebar
  2525. );
  2526. echo elgg_view_page($title, $body, 'default', $vars);
  2527. }
  2528. /**
  2529. * Wrapper function to display search listings.
  2530. *
  2531. * @param string $icon The icon for the listing
  2532. * @param string $info Any information that needs to be displayed.
  2533. *
  2534. * @return string The HTML (etc) representing the listing
  2535. * @deprecated 1.8 use elgg_view_image_block()
  2536. */
  2537. function elgg_view_listing($icon, $info) {
  2538. elgg_deprecated_notice('elgg_view_listing deprecated by elgg_view_image_block', 1.8);
  2539. return elgg_view('page/components/image_block', array('image' => $icon, 'body' => $info));
  2540. }
  2541. /**
  2542. * Return the icon URL for an entity.
  2543. *
  2544. * @tip Can be overridden by registering a plugin hook for entity:icon:url, $entity_type.
  2545. *
  2546. * @internal This is passed an entity rather than a guid to handle non-created entities.
  2547. *
  2548. * @param ElggEntity $entity The entity
  2549. * @param string $size Icon size
  2550. *
  2551. * @return string URL to the entity icon.
  2552. * @deprecated 1.8 Use $entity->getIconURL()
  2553. */
  2554. function get_entity_icon_url(ElggEntity $entity, $size = 'medium') {
  2555. elgg_deprecated_notice("get_entity_icon_url() deprecated for getIconURL()", 1.8);
  2556. global $CONFIG;
  2557. $size = sanitise_string($size);
  2558. switch (strtolower($size)) {
  2559. case 'master':
  2560. $size = 'master';
  2561. break;
  2562. case 'large' :
  2563. $size = 'large';
  2564. break;
  2565. case 'topbar' :
  2566. $size = 'topbar';
  2567. break;
  2568. case 'tiny' :
  2569. $size = 'tiny';
  2570. break;
  2571. case 'small' :
  2572. $size = 'small';
  2573. break;
  2574. case 'medium' :
  2575. default:
  2576. $size = 'medium';
  2577. }
  2578. $url = false;
  2579. $viewtype = elgg_get_viewtype();
  2580. // Step one, see if anyone knows how to render this in the current view
  2581. $params = array('entity' => $entity, 'viewtype' => $viewtype, 'size' => $size);
  2582. $url = elgg_trigger_plugin_hook('entity:icon:url', $entity->getType(), $params, $url);
  2583. // Fail, so use default
  2584. if (!$url) {
  2585. $type = $entity->getType();
  2586. $subtype = $entity->getSubtype();
  2587. if (!empty($subtype)) {
  2588. $overrideurl = elgg_view("icon/{$type}/{$subtype}/{$size}", array('entity' => $entity));
  2589. if (!empty($overrideurl)) {
  2590. return $overrideurl;
  2591. }
  2592. }
  2593. $overrideurl = elgg_view("icon/{$type}/default/{$size}", array('entity' => $entity));
  2594. if (!empty($overrideurl)) {
  2595. return $overrideurl;
  2596. }
  2597. $url = "_graphics/icons/default/$size.png";
  2598. }
  2599. return elgg_normalize_url($url);
  2600. }
  2601. /**
  2602. * Return the current logged in user, or NULL if no user is logged in.
  2603. *
  2604. * If no user can be found in the current session, a plugin
  2605. * hook - 'session:get' 'user' to give plugin authors another
  2606. * way to provide user details to the ACL system without touching the session.
  2607. *
  2608. * @deprecated 1.8 Use elgg_get_logged_in_user_entity()
  2609. * @return ElggUser|NULL
  2610. */
  2611. function get_loggedin_user() {
  2612. elgg_deprecated_notice('get_loggedin_user() is deprecated by elgg_get_logged_in_user_entity()', 1.8);
  2613. return elgg_get_logged_in_user_entity();
  2614. }
  2615. /**
  2616. * Return the current logged in user by id.
  2617. *
  2618. * @deprecated 1.8 Use elgg_get_logged_in_user_guid()
  2619. * @see elgg_get_logged_in_user_entity()
  2620. * @return int
  2621. */
  2622. function get_loggedin_userid() {
  2623. elgg_deprecated_notice('get_loggedin_userid() is deprecated by elgg_get_logged_in_user_guid()', 1.8);
  2624. return elgg_get_logged_in_user_guid();
  2625. }
  2626. /**
  2627. * Returns whether or not the user is currently logged in
  2628. *
  2629. * @deprecated 1.8 Use elgg_is_logged_in();
  2630. * @return bool
  2631. */
  2632. function isloggedin() {
  2633. elgg_deprecated_notice('isloggedin() is deprecated by elgg_is_logged_in()', 1.8);
  2634. return elgg_is_logged_in();
  2635. }
  2636. /**
  2637. * Returns whether or not the user is currently logged in and that they are an admin user.
  2638. *
  2639. * @deprecated 1.8 Use elgg_is_admin_logged_in()
  2640. * @return bool
  2641. */
  2642. function isadminloggedin() {
  2643. elgg_deprecated_notice('isadminloggedin() is deprecated by elgg_is_admin_logged_in()', 1.8);
  2644. return elgg_is_admin_logged_in();
  2645. }
  2646. /**
  2647. * Loads plugins
  2648. *
  2649. * @deprecated 1.8 Use elgg_load_plugins()
  2650. *
  2651. * @return bool
  2652. */
  2653. function load_plugins() {
  2654. elgg_deprecated_notice('load_plugins() is deprecated by elgg_load_plugins()', 1.8);
  2655. return elgg_load_plugins();
  2656. }
  2657. /**
  2658. * Find the plugin settings for a user.
  2659. *
  2660. * @param string $plugin_id Plugin name.
  2661. * @param int $user_guid The guid who's settings to retrieve.
  2662. *
  2663. * @deprecated 1.8 Use elgg_get_all_plugin_user_settings() or ElggPlugin->getAllUserSettings()
  2664. * @return StdClass Object with all user settings.
  2665. */
  2666. function find_plugin_usersettings($plugin_id = null, $user_guid = 0) {
  2667. elgg_deprecated_notice('find_plugin_usersettings() is deprecated by elgg_get_all_plugin_user_settings()', 1.8);
  2668. return elgg_get_all_plugin_user_settings($user_guid, $plugin_id, true);
  2669. }
  2670. /**
  2671. * Set a user specific setting for a plugin.
  2672. *
  2673. * @param string $name The name - note, can't be "title".
  2674. * @param mixed $value The value.
  2675. * @param int $user_guid Optional user.
  2676. * @param string $plugin_id Optional plugin name, if not specified then it
  2677. * is detected from where you are calling from.
  2678. *
  2679. * @return bool
  2680. * @deprecated 1.8 Use elgg_set_plugin_user_setting() or ElggPlugin->setUserSetting()
  2681. */
  2682. function set_plugin_usersetting($name, $value, $user_guid = 0, $plugin_id = "") {
  2683. elgg_deprecated_notice('find_plugin_usersettings() is deprecated by elgg_get_all_plugin_user_settings()', 1.8);
  2684. return elgg_set_plugin_user_setting($name, $value, $user_guid, $plugin_id);
  2685. }
  2686. /**
  2687. * Clears a user-specific plugin setting
  2688. *
  2689. * @param str $name Name of the plugin setting
  2690. * @param int $user_guid Defaults to logged in user
  2691. * @param str $plugin_id Defaults to contextual plugin name
  2692. *
  2693. * @deprecated 1.8 Use elgg_unset_plugin_user_setting or ElggPlugin->unsetUserSetting().
  2694. * @return bool Success
  2695. */
  2696. function clear_plugin_usersetting($name, $user_guid = 0, $plugin_id = '') {
  2697. elgg_deprecated_notice('clear_plugin_usersetting() is deprecated by elgg_unset_plugin_usersetting()', 1.8);
  2698. return elgg_unset_plugin_user_setting($name, $user_guid, $plugin_id);
  2699. }
  2700. /**
  2701. * Get a user specific setting for a plugin.
  2702. *
  2703. * @param string $name The name.
  2704. * @param int $user_guid Guid of owning user
  2705. * @param string $plugin_id Optional plugin name, if not specified
  2706. * it is detected from where you are calling.
  2707. *
  2708. * @deprecated 1.8 Use elgg_get_plugin_user_setting() or ElggPlugin->getUserSetting()
  2709. * @return mixed
  2710. */
  2711. function get_plugin_usersetting($name, $user_guid = 0, $plugin_id = "") {
  2712. elgg_deprecated_notice('get_plugin_usersetting() is deprecated by elgg_get_plugin_user_setting()', 1.8);
  2713. return elgg_get_plugin_user_setting($name, $user_guid, $plugin_id);
  2714. }
  2715. /**
  2716. * Set a setting for a plugin.
  2717. *
  2718. * @param string $name The name - note, can't be "title".
  2719. * @param mixed $value The value.
  2720. * @param string $plugin_id Optional plugin name, if not specified
  2721. * then it is detected from where you are calling from.
  2722. *
  2723. * @deprecated 1.8 Use elgg_set_plugin_setting() or ElggPlugin->setSetting()
  2724. * @return int|false
  2725. */
  2726. function set_plugin_setting($name, $value, $plugin_id = null) {
  2727. elgg_deprecated_notice('set_plugin_setting() is deprecated by elgg_set_plugin_setting()', 1.8);
  2728. return elgg_set_plugin_setting($name, $value, $plugin_id);
  2729. }
  2730. /**
  2731. * Get setting for a plugin.
  2732. *
  2733. * @param string $name The name.
  2734. * @param string $plugin_id Optional plugin name, if not specified
  2735. * then it is detected from where you are calling from.
  2736. *
  2737. * @deprecated 1.8 Use elgg_get_plugin_setting() or ElggPlugin->getSetting()
  2738. * @return mixed
  2739. */
  2740. function get_plugin_setting($name, $plugin_id = "") {
  2741. elgg_deprecated_notice('get_plugin_setting() is deprecated by elgg_get_plugin_setting()', 1.8);
  2742. return elgg_get_plugin_setting($name, $plugin_id);
  2743. }
  2744. /**
  2745. * Clear a plugin setting.
  2746. *
  2747. * @param string $name The name.
  2748. * @param string $plugin_id Optional plugin name, if not specified
  2749. * then it is detected from where you are calling from.
  2750. *
  2751. * @deprecated 1.8 Use elgg_unset_plugin_setting() or ElggPlugin->unsetSetting()
  2752. * @return bool
  2753. */
  2754. function clear_plugin_setting($name, $plugin_id = "") {
  2755. elgg_deprecated_notice('clear_plugin_setting() is deprecated by elgg_unset_plugin_setting()', 1.8);
  2756. return elgg_unset_plugin_setting($name, $plugin_id);
  2757. }
  2758. /**
  2759. * Unsets all plugin settings for a plugin.
  2760. *
  2761. * @param string $plugin_id Optional plugin name, if not specified
  2762. * then it is detected from where you are calling from.
  2763. *
  2764. * @return bool
  2765. * @deprecated 1.8 Use elgg_unset_all_plugin_settings() or ElggPlugin->unsetAllSettings()
  2766. * @since 1.7.0
  2767. */
  2768. function clear_all_plugin_settings($plugin_id = "") {
  2769. elgg_deprecated_notice('clear_all_plugin_settings() is deprecated by elgg_unset_all_plugin_setting()', 1.8);
  2770. return elgg_unset_all_plugin_settings($plugin_id);
  2771. }
  2772. /**
  2773. * Get a list of annotations for a given object/user/annotation type.
  2774. *
  2775. * @param int|array $entity_guid GUID to return annotations of (falsey for any)
  2776. * @param string $entity_type Type of entity
  2777. * @param string $entity_subtype Subtype of entity
  2778. * @param string $name Name of annotation
  2779. * @param mixed $value Value of annotation
  2780. * @param int|array $owner_guid Owner(s) of annotation
  2781. * @param int $limit Limit
  2782. * @param int $offset Offset
  2783. * @param string $order_by Order annotations by SQL
  2784. * @param int $timelower Lower time limit
  2785. * @param int $timeupper Upper time limit
  2786. * @param int $entity_owner_guid Owner guid for the entity
  2787. *
  2788. * @return array
  2789. * @deprecated 1.8 Use elgg_get_annotations()
  2790. */
  2791. function get_annotations($entity_guid = 0, $entity_type = "", $entity_subtype = "", $name = "",
  2792. $value = "", $owner_guid = 0, $limit = 10, $offset = 0, $order_by = "asc", $timelower = 0,
  2793. $timeupper = 0, $entity_owner_guid = 0) {
  2794. elgg_deprecated_notice('get_annotations() is deprecated by elgg_get_annotations()', 1.8);
  2795. $options = array();
  2796. if ($entity_guid) {
  2797. $options['guid'] = $entity_guid;
  2798. }
  2799. if ($entity_type) {
  2800. $options['type'] = $entity_type;
  2801. }
  2802. if ($entity_subtype) {
  2803. $options['subtype'] = $entity_subtype;
  2804. }
  2805. if ($name) {
  2806. $options['annotation_name'] = $name;
  2807. }
  2808. if ($value) {
  2809. $options['annotation_value'] = $value;
  2810. }
  2811. if ($owner_guid) {
  2812. $options['annotation_owner_guid'] = $owner_guid;
  2813. }
  2814. $options['limit'] = $limit;
  2815. $options['offset'] = $offset;
  2816. if ($order_by == 'desc') {
  2817. $options['order_by'] = 'n_table.time_created desc';
  2818. }
  2819. if ($timelower) {
  2820. $options['annotation_time_lower'] = $timelower;
  2821. }
  2822. if ($timeupper) {
  2823. $options['annotation_time_upper'] = $timeupper;
  2824. }
  2825. if ($entity_owner_guid) {
  2826. $options['owner_guid'] = $entity_owner_guid;
  2827. }
  2828. return elgg_get_annotations($options);
  2829. }
  2830. /**
  2831. * Returns a human-readable list of annotations on a particular entity.
  2832. *
  2833. * @param int $entity_guid The entity GUID
  2834. * @param string $name The name of the kind of annotation
  2835. * @param int $limit The number of annotations to display at once
  2836. * @param true|false $asc Display annotations in ascending order. (Default: true)
  2837. *
  2838. * @return string HTML (etc) version of the annotation list
  2839. * @deprecated 1.8 Use elgg_list_annotations()
  2840. */
  2841. function list_annotations($entity_guid, $name = "", $limit = 25, $asc = true) {
  2842. elgg_deprecated_notice('list_annotations() is deprecated by elgg_list_annotations()', 1.8);
  2843. if ($asc) {
  2844. $asc = "asc";
  2845. } else {
  2846. $asc = "desc";
  2847. }
  2848. $options = array(
  2849. 'guid' => $entity_guid,
  2850. 'limit' => $limit,
  2851. 'order_by' => "n_table.time_created $asc"
  2852. );
  2853. return elgg_list_annotations($options);
  2854. }
  2855. /**
  2856. * Helper function to deprecate annotation calculation functions. Don't use.
  2857. *
  2858. * @param unknown_type $entity_guid
  2859. * @param unknown_type $entity_type
  2860. * @param unknown_type $entity_subtype
  2861. * @param unknown_type $name
  2862. * @param unknown_type $value
  2863. * @param unknown_type $value_type
  2864. * @param unknown_type $owner_guid
  2865. * @param unknown_type $timelower
  2866. * @param unknown_type $timeupper
  2867. * @param unknown_type $calculation
  2868. * @internal Don't use this at all.
  2869. */
  2870. function elgg_deprecated_annotation_calculation($entity_guid = 0, $entity_type = "", $entity_subtype = "",
  2871. $name = "", $value = "", $value_type = "", $owner_guid = 0, $timelower = 0,
  2872. $timeupper = 0, $calculation = '') {
  2873. $options = array('annotation_calculation' => $calculation);
  2874. if ($entity_guid) {
  2875. $options['guid'] = $entity_guid;
  2876. }
  2877. if ($entity_type) {
  2878. $options['type'] = $entity_type;
  2879. }
  2880. if ($entity_subtype) {
  2881. $options['subtype'] = $entity_subtype;
  2882. }
  2883. if ($name) {
  2884. $options['annotation_name'] = $name;
  2885. }
  2886. if ($value) {
  2887. $options['annotation_value'] = $value;
  2888. }
  2889. if ($owner_guid) {
  2890. $options['annotation_owner_guid'] = $owner_guid;
  2891. }
  2892. if ($order_by == 'desc') {
  2893. $options['order_by'] = 'n_table.time_created desc';
  2894. }
  2895. if ($timelower) {
  2896. $options['annotation_time_lower'] = $timelower;
  2897. }
  2898. if ($timeupper) {
  2899. $options['annotation_time_upper'] = $timeupper;
  2900. }
  2901. return elgg_get_annotations($options);
  2902. }
  2903. /**
  2904. * Count the number of annotations based on search parameters
  2905. *
  2906. * @param int $entity_guid Guid of Entity
  2907. * @param string $entity_type Type of Entity
  2908. * @param string $entity_subtype Subtype of Entity
  2909. * @param string $name Name of annotation
  2910. * @param string $value Value of annotation
  2911. * @param string $value_type Type of value
  2912. * @param int $owner_guid GUID of owner of annotation
  2913. * @param int $timelower Lower time limit
  2914. * @param int $timeupper Upper time limit
  2915. *
  2916. * @deprecated 1.8 Use elgg_get_annotations() and pass 'count' => true
  2917. * @return int
  2918. */
  2919. function count_annotations($entity_guid = 0, $entity_type = "", $entity_subtype = "",
  2920. $name = "", $value = "", $value_type = "", $owner_guid = 0, $timelower = 0,
  2921. $timeupper = 0) {
  2922. elgg_deprecated_notice('count_annotations() is deprecated by elgg_get_annotations() and passing "count" => true', 1.8);
  2923. return elgg_deprecated_annotation_calculation($entity_guid, $entity_type, $entity_subtype,
  2924. $name, $value, $value_type, $owner_guid, $timelower, $timeupper, 'count');
  2925. }
  2926. /**
  2927. * Return the sum of a given integer annotation.
  2928. *
  2929. * @param int $entity_guid Guid of Entity
  2930. * @param string $entity_type Type of Entity
  2931. * @param string $entity_subtype Subtype of Entity
  2932. * @param string $name Name of annotation
  2933. * @param string $value Value of annotation
  2934. * @param string $value_type Type of value
  2935. * @param int $owner_guid GUID of owner of annotation
  2936. *
  2937. * @deprecated 1.8 Use elgg_get_annotations() and pass 'annotation_calculation' => 'sum'
  2938. * @return int
  2939. */
  2940. function get_annotations_sum($entity_guid, $entity_type = "", $entity_subtype = "", $name = "",
  2941. $value = "", $value_type = "", $owner_guid = 0) {
  2942. elgg_deprecated_notice('get_annotations_sum() is deprecated by elgg_get_annotations() and passing "annotation_calculation" => "sum"', 1.8);
  2943. return elgg_deprecated_annotation_calculation($entity_guid, $entity_type, $entity_subtype,
  2944. $name, $value, $value_type, $owner_guid, $timelower, $timeupper, 'sum');
  2945. }
  2946. /**
  2947. * Return the max of a given integer annotation.
  2948. *
  2949. * @param int $entity_guid Guid of Entity
  2950. * @param string $entity_type Type of Entity
  2951. * @param string $entity_subtype Subtype of Entity
  2952. * @param string $name Name of annotation
  2953. * @param string $value Value of annotation
  2954. * @param string $value_type Type of value
  2955. * @param int $owner_guid GUID of owner of annotation
  2956. *
  2957. * @deprecated 1.8 Use elgg_get_annotations() and pass 'annotation_calculation' => 'max'
  2958. * @return int
  2959. */
  2960. function get_annotations_max($entity_guid, $entity_type = "", $entity_subtype = "", $name = "",
  2961. $value = "", $value_type = "", $owner_guid = 0) {
  2962. elgg_deprecated_notice('get_annotations_max() is deprecated by elgg_get_annotations() and passing "annotation_calculation" => "max"', 1.8);
  2963. return elgg_deprecated_annotation_calculation($entity_guid, $entity_type, $entity_subtype,
  2964. $name, $value, $value_type, $owner_guid, $timelower, $timeupper, 'max');
  2965. }
  2966. /**
  2967. * Return the minumum of a given integer annotation.
  2968. *
  2969. * @param int $entity_guid Guid of Entity
  2970. * @param string $entity_type Type of Entity
  2971. * @param string $entity_subtype Subtype of Entity
  2972. * @param string $name Name of annotation
  2973. * @param string $value Value of annotation
  2974. * @param string $value_type Type of value
  2975. * @param int $owner_guid GUID of owner of annotation
  2976. *
  2977. * @deprecated 1.8 Use elgg_get_annotations() and pass 'annotation_calculation' => 'min'
  2978. * @return int
  2979. */
  2980. function get_annotations_min($entity_guid, $entity_type = "", $entity_subtype = "", $name = "",
  2981. $value = "", $value_type = "", $owner_guid = 0) {
  2982. elgg_deprecated_notice('get_annotations_min() is deprecated by elgg_get_annotations() and passing "annotation_calculation" => "min"', 1.8);
  2983. return elgg_deprecated_annotation_calculation($entity_guid, $entity_type, $entity_subtype,
  2984. $name, $value, $value_type, $owner_guid, $timelower, $timeupper, 'min');
  2985. }
  2986. /**
  2987. * Return the average of a given integer annotation.
  2988. *
  2989. * @param int $entity_guid Guid of Entity
  2990. * @param string $entity_type Type of Entity
  2991. * @param string $entity_subtype Subtype of Entity
  2992. * @param string $name Name of annotation
  2993. * @param string $value Value of annotation
  2994. * @param string $value_type Type of value
  2995. * @param int $owner_guid GUID of owner of annotation
  2996. *
  2997. * @deprecated 1.8 Use elgg_get_annotations() and pass 'annotation_calculation' => 'min'
  2998. *
  2999. * @return int
  3000. */
  3001. function get_annotations_avg($entity_guid, $entity_type = "", $entity_subtype = "", $name = "",
  3002. $value = "", $value_type = "", $owner_guid = 0) {
  3003. elgg_deprecated_notice('get_annotations_avg() is deprecated by elgg_get_annotations() and passing "annotation_calculation" => "avg"', 1.8);
  3004. return elgg_deprecated_annotation_calculation($entity_guid, $entity_type, $entity_subtype,
  3005. $name, $value, $value_type, $owner_guid, $timelower, $timeupper, 'avg');
  3006. }
  3007. /**
  3008. * Perform a mathmatical calculation on integer annotations.
  3009. *
  3010. * @param string $sum What sort of calculation to perform
  3011. * @param int $entity_guid Guid of Entity
  3012. * @param string $entity_type Type of Entity
  3013. * @param string $entity_subtype Subtype of Entity
  3014. * @param string $name Name of annotation
  3015. * @param string $value Value of annotation
  3016. * @param string $value_type Type of value
  3017. * @param int $owner_guid GUID of owner of annotation
  3018. * @param int $timelower Lower time limit
  3019. * @param int $timeupper Upper time limit
  3020. *
  3021. * @return int
  3022. * @deprecated 1.8 Use elgg_get_annotations() and pass anntoation_calculation => <calculation>
  3023. */
  3024. function get_annotations_calculate_x($sum = "avg", $entity_guid, $entity_type = "",
  3025. $entity_subtype = "", $name = "", $value = "", $value_type = "", $owner_guid = 0,
  3026. $timelower = 0, $timeupper = 0) {
  3027. elgg_deprecated_notice('get_annotations_calculate_x() is deprecated by elgg_get_annotations() and passing "annotation_calculation" => "calculation"', 1.8);
  3028. return elgg_deprecated_annotation_calculation($entity_guid, $entity_type, $entity_subtype,
  3029. $name, $value, $value_type, $owner_guid, $timelower, $timeupper, $sum);
  3030. }
  3031. /**
  3032. * Lists entities by the totals of a particular kind of annotation AND
  3033. * the value of a piece of metadata
  3034. *
  3035. * @param string $entity_type Type of entity.
  3036. * @param string $entity_subtype Subtype of entity.
  3037. * @param string $name Name of annotation.
  3038. * @param string $mdname Metadata name
  3039. * @param string $mdvalue Metadata value
  3040. * @param int $limit Maximum number of results to return.
  3041. * @param int $owner_guid Owner.
  3042. * @param int $group_guid Group container. Currently only supported if entity_type is object
  3043. * @param boolean $asc Whether to list in ascending or descending order (default: desc)
  3044. * @param boolean $fullview Whether to display the entities in full
  3045. * @param boolean $listtypetoggle Can the 'gallery' view can be displayed (default: no)
  3046. * @param boolean $pagination Display pagination
  3047. * @param string $orderdir 'desc' or 'asc'
  3048. *
  3049. * @deprecated 1.8 Use elgg_list_entities_from_annotation_calculation().
  3050. *
  3051. * @return string Formatted entity list
  3052. */
  3053. function list_entities_from_annotation_count_by_metadata($entity_type = "", $entity_subtype = "",
  3054. $name = "", $mdname = '', $mdvalue = '', $limit = 10, $owner_guid = 0, $group_guid = 0,
  3055. $asc = false, $fullview = true, $listtypetoggle = false, $pagination = true, $orderdir = 'desc') {
  3056. $msg = 'list_entities_from_annotation_count_by_metadata() is deprecated by elgg_list_entities_from_annotation_calculation().';
  3057. elgg_deprecated_notice($msg, 1.8);
  3058. $options = array();
  3059. $options['calculation'] = 'sum';
  3060. if ($entity_type) {
  3061. $options['types'] = $entity_type;
  3062. }
  3063. if ($entity_subtype) {
  3064. $options['subtypes'] = $entity_subtype;
  3065. }
  3066. $options['annotation_names'] = $name;
  3067. if ($mdname) {
  3068. $options['metadata_name'] = $mdname;
  3069. }
  3070. if ($mdvalue) {
  3071. $options['metadata_value'] = $mdvalue;
  3072. }
  3073. if ($owner_guid) {
  3074. if (is_array($owner_guid)) {
  3075. $options['owner_guids'] = $owner_guid;
  3076. } else {
  3077. $options['owner_guid'] = $owner_guid;
  3078. }
  3079. }
  3080. $options['full_view'] = $fullview;
  3081. $options['list_type_toggle'] = $listtypetoggle;
  3082. $options['pagination'] = $pagination;
  3083. $options['limit'] = $limit;
  3084. $options['order_by'] = "annotation_calculation $orderdir";
  3085. return elgg_get_entities_from_annotation_calculation($options);
  3086. }
  3087. /**
  3088. * Set an alternative base location for a view (as opposed to the default of $CONFIG->viewpath)
  3089. *
  3090. * @param string $view The name of the view
  3091. * @param string $location The base location path
  3092. *
  3093. * @deprecated 1.8 Use elgg_set_view_location()
  3094. */
  3095. function set_view_location($view, $location, $viewtype = '') {
  3096. elgg_deprecated_notice("set_view_location() was deprecated by elgg_set_view_location()", 1.8);
  3097. return elgg_set_view_location($view, $location, $viewtype);
  3098. }
  3099. /**
  3100. * Sets the URL handler for a particular entity type and subtype
  3101. *
  3102. * @param string $function_name The function to register
  3103. * @param string $entity_type The entity type
  3104. * @param string $entity_subtype The entity subtype
  3105. * @return true|false Depending on success
  3106. *
  3107. * @deprecated 1.8 Use elgg_register_entity_url_handler()
  3108. */
  3109. function register_entity_url_handler($function_name, $entity_type = "all", $entity_subtype = "all") {
  3110. elgg_deprecated_notice("register_entity_url_handler() was deprecated by elgg_register_entity_url_handler()", 1.8);
  3111. return elgg_register_entity_url_handler($entity_type, $entity_subtype, $function_name);
  3112. }
  3113. /**
  3114. * Get the metadata where the entities they are referring to match a given criteria.
  3115. *
  3116. * @param mixed $meta_name Metadata name
  3117. * @param mixed $meta_value Metadata value
  3118. * @param string $entity_type The type of entity to look for, eg 'site' or 'object'
  3119. * @param string $entity_subtype The subtype of the entity.
  3120. * @param int $limit Limit
  3121. * @param int $offset Offset
  3122. * @param string $order_by Optional ordering.
  3123. * @param int $site_guid Site GUID. 0 for current, -1 for any
  3124. *
  3125. * @return mixed
  3126. * @deprecated 1.8 Use elgg_get_metadata()
  3127. */
  3128. function find_metadata($meta_name = "", $meta_value = "", $entity_type = "", $entity_subtype = "",
  3129. $limit = 10, $offset = 0, $order_by = "", $site_guid = 0) {
  3130. elgg_deprecated_notice('get_metadata() is deprecated by elgg_get_metadata()', 1.8);
  3131. $options = array();
  3132. if ($meta_name) {
  3133. $options['annotation_name'] = $meta_name;
  3134. }
  3135. if ($meta_value) {
  3136. $options['annotation_value'] = $meta_value;
  3137. }
  3138. if ($entity_type) {
  3139. $options['type'] = $entity_type;
  3140. }
  3141. if ($entity_subtype) {
  3142. $options['subtype'] = $entity_subtype;
  3143. }
  3144. $options['limit'] = $limit;
  3145. $options['offset'] = $offset;
  3146. if ($order_by == 'desc') {
  3147. $options['order_by'] = 'n_table.time_created desc';
  3148. }
  3149. if ($site_guid) {
  3150. $options['site_guid'] = $site_guid;
  3151. }
  3152. return elgg_get_metadata($options);
  3153. }
  3154. /**
  3155. * Get metadata objects by name.
  3156. *
  3157. * @param int $entity_guid Entity GUID
  3158. * @param string $meta_name Metadata name
  3159. *
  3160. * @return mixed ElggMetadata object, an array of ElggMetadata or false.
  3161. * @deprecated 1.8 Use elgg_get_metadata()
  3162. */
  3163. function get_metadata_byname($entity_guid, $meta_name) {
  3164. elgg_deprecated_notice('get_metadata_byname() is deprecated by elgg_get_metadata()', 1.8);
  3165. if (!$entity_guid || !$meta_name) {
  3166. return false;
  3167. }
  3168. $options = array(
  3169. 'guid' => $entity_guid,
  3170. 'metadata_name' => $meta_name,
  3171. 'limit' => 0
  3172. );
  3173. $md = elgg_get_metadata($options);
  3174. if ($md && count($md) == 1) {
  3175. return $md[0];
  3176. }
  3177. return $md;
  3178. }
  3179. /**
  3180. * Return all the metadata for a given GUID.
  3181. *
  3182. * @param int $entity_guid Entity GUID
  3183. *
  3184. * @return mixed
  3185. * @deprecated 1.8 Use elgg_get_metadata()
  3186. */
  3187. function get_metadata_for_entity($entity_guid) {
  3188. elgg_deprecated_notice('get_metadata_for_entity() is deprecated by elgg_get_metadata()', 1.8);
  3189. if (!$entity_guid) {
  3190. return false;
  3191. }
  3192. $options = array(
  3193. 'guid' => $entity_guid,
  3194. 'limit' => 0
  3195. );
  3196. return elgg_get_metadata($options);
  3197. }
  3198. /**
  3199. * Get a specific metadata object.
  3200. *
  3201. * @param int $id The id of the metadata being retrieved.
  3202. *
  3203. * @return mixed False on failure or ElggMetadata
  3204. * @deprecated 1.8 Use elgg_get_metadata_from_id()
  3205. */
  3206. function get_metadata($id) {
  3207. elgg_deprecated_notice('get_metadata() is deprecated by elgg_get_metadata_from_id()', 1.8);
  3208. return elgg_get_metadata_from_id($id);
  3209. }
  3210. /**
  3211. * Clear all the metadata for a given entity, assuming you have access to that entity.
  3212. *
  3213. * @param int $guid Entity GUID
  3214. *
  3215. * @return bool
  3216. * @deprecated 1.8 Use elgg_delete_metadata()
  3217. */
  3218. function clear_metadata($guid) {
  3219. elgg_deprecated_notice('clear_metadata() is deprecated by elgg_delete_metadata()', 1.8);
  3220. if (!$guid) {
  3221. return false;
  3222. }
  3223. return elgg_delete_metadata(array('guid' => $guid, 'limit' => 0));
  3224. }
  3225. /**
  3226. * Clear all metadata belonging to a given owner_guid
  3227. *
  3228. * @param int $owner_guid The owner
  3229. *
  3230. * @return bool
  3231. * @deprecated 1.8 Use elgg_delete_metadata()
  3232. */
  3233. function clear_metadata_by_owner($owner_guid) {
  3234. elgg_deprecated_notice('clear_metadata() is deprecated by elgg_delete_metadata()', 1.8);
  3235. if (!$owner_guid) {
  3236. return false;
  3237. }
  3238. return elgg_delete_metadata(array('metadata_owner_guid' => $owner_guid, 'limit' => 0));
  3239. }
  3240. /**
  3241. * Delete a piece of metadata, where the current user has access.
  3242. *
  3243. * @param int $id The id of metadata to delete.
  3244. *
  3245. * @return bool
  3246. * @deprecated 1.8 Use elgg_delete_metadata()
  3247. */
  3248. function delete_metadata($id) {
  3249. elgg_deprecated_notice('delete_metadata() is deprecated by elgg_delete_metadata()', 1.8);
  3250. if (!$id) {
  3251. return false;
  3252. }
  3253. return elgg_delete_metadata(array('metadata_id' => $id));
  3254. }
  3255. /**
  3256. * Removes metadata on an entity with a particular name, optionally with a given value.
  3257. *
  3258. * @param int $guid The entity GUID
  3259. * @param string $name The name of the metadata
  3260. * @param string $value The value of the metadata (useful to remove a single item of a set)
  3261. *
  3262. * @return bool Depending on success
  3263. * @deprecated 1.8 Use elgg_delete_metadata()
  3264. */
  3265. function remove_metadata($guid, $name, $value = "") {
  3266. elgg_deprecated_notice('delete_metadata() is deprecated by elgg_delete_metadata()', 1.8);
  3267. // prevent them from deleting everything
  3268. if (!$guid) {
  3269. return false;
  3270. }
  3271. $options = array(
  3272. 'guid' => $guid,
  3273. 'metadata_name' => $name,
  3274. 'limit' => 0
  3275. );
  3276. if ($value) {
  3277. $options['metadata_value'] = $value;
  3278. }
  3279. return elgg_delete_metadata($options);
  3280. }
  3281. /**
  3282. * Get a specific annotation.
  3283. *
  3284. * @param int $annotation_id Annotation ID
  3285. *
  3286. * @return ElggAnnotation
  3287. * @deprecated 1.8 Use elgg_get_annotation_from_id()
  3288. */
  3289. function get_annotation($annotation_id) {
  3290. elgg_deprecated_notice('get_annotation() is deprecated by elgg_get_annotation_from_id()', 1.8);
  3291. return elgg_get_annotation_from_id($annotation_id);
  3292. }
  3293. /**
  3294. * Delete a given annotation.
  3295. *
  3296. * @param int $id The annotation id
  3297. *
  3298. * @return bool
  3299. * @deprecated 1.8 Use elgg_delete_annotations()
  3300. */
  3301. function delete_annotation($id) {
  3302. elgg_deprecated_notice('delete_annotation() is deprecated by elgg_delete_annotations()', 1.8);
  3303. if (!$id) {
  3304. return false;
  3305. }
  3306. return elgg_delete_annotations(array('annotation_id' => $annotation_id));
  3307. }
  3308. /**
  3309. * Clear all the annotations for a given entity, assuming you have access to that metadata.
  3310. *
  3311. * @param int $guid The entity guid
  3312. * @param string $name The name of the annotation to delete.
  3313. *
  3314. * @return int Number of annotations deleted or false if an error
  3315. * @deprecated 1.8 Use elgg_delete_annotations()
  3316. */
  3317. function clear_annotations($guid, $name = "") {
  3318. elgg_deprecated_notice('clear_annotations() is deprecated by elgg_delete_annotations()', 1.8);
  3319. if (!$guid) {
  3320. return false;
  3321. }
  3322. $options = array(
  3323. 'guid' => $guid,
  3324. 'limit' => 0
  3325. );
  3326. if ($name) {
  3327. $options['annotation_name'] = $name;
  3328. }
  3329. return elgg_delete_annotations($options);
  3330. }
  3331. /**
  3332. * Clear all annotations belonging to a given owner_guid
  3333. *
  3334. * @param int $owner_guid The owner
  3335. *
  3336. * @return int Number of annotations deleted
  3337. * @deprecated 1.8 Use elgg_delete_annotations()
  3338. */
  3339. function clear_annotations_by_owner($owner_guid) {
  3340. elgg_deprecated_notice('clear_annotations_by_owner() is deprecated by elgg_delete_annotations()', 1.8);
  3341. if (!$owner_guid) {
  3342. return false;
  3343. }
  3344. $options = array(
  3345. 'annotation_owner_guid' => $guid,
  3346. 'limit' => 0
  3347. );
  3348. return elgg_delete_annotations($options);
  3349. }
  3350. /**
  3351. * Registers a page handler for a particular identifier
  3352. *
  3353. * For example, you can register a function called 'blog_page_handler' for handler type 'blog'
  3354. * Now for all URLs of type http://yoururl/pg/blog/*, the blog_page_handler() function will be called.
  3355. * The part of the URL marked with * above will be exploded on '/' characters and passed as an
  3356. * array to that function.
  3357. * For example, the URL http://yoururl/blog/username/friends/ would result in the call:
  3358. * blog_page_handler(array('username','friends'), blog);
  3359. *
  3360. * Page handler functions should return true or the default page handler will be called.
  3361. *
  3362. * A request to register a page handler with the same identifier as previously registered
  3363. * handler will replace the previous one.
  3364. *
  3365. * The context is set to the page handler identifier before the registered
  3366. * page handler function is called. For the above example, the context is set to 'blog'.
  3367. *
  3368. * @param string $handler The page type to handle
  3369. * @param string $function Your function name
  3370. * @return true|false Depending on success
  3371. *
  3372. * @deprecated 1.8 Use {@link elgg_register_page_handler()}
  3373. */
  3374. function register_page_handler($handler, $function){
  3375. elgg_deprecated_notice("register_page_handler() was deprecated by elgg_register_page_handler()", 1.8);
  3376. return elgg_register_page_handler($handler, $function);
  3377. }
  3378. /**
  3379. * Unregister a page handler for an identifier
  3380. *
  3381. * Note: to replace a page handler, call register_page_handler()
  3382. *
  3383. * @param string $handler The page type identifier
  3384. * @since 1.7.2
  3385. *
  3386. * @deprecated 1.8 Use {@link elgg_unregister_page_handler()}
  3387. */
  3388. function unregister_page_handler($handler) {
  3389. elgg_deprecated_notice("unregister_page_handler() was deprecated by elgg_unregister_page_handler()", 1.8);
  3390. return elgg_unregister_page_handler($handler);
  3391. }
  3392. /**
  3393. * Register an annotation url handler.
  3394. *
  3395. * @param string $function_name The function.
  3396. * @param string $extender_name The name, default 'all'.
  3397. *
  3398. * @deprecated 1.8 Use {@link elgg_register_annotation_url_handler()}
  3399. */
  3400. function register_annotation_url_handler($function, $extender_name) {
  3401. elgg_deprecated_notice("register_annotation_url_handler() was deprecated by elgg_register_annotation_url_handler()", 1.8);
  3402. return elgg_register_annotation_url_handler($extender_name, $function);
  3403. }
  3404. /**
  3405. * Sets the URL handler for a particular extender type and name.
  3406. * It is recommended that you do not call this directly, instead use one of the wrapper functions in the
  3407. * subtype files.
  3408. *
  3409. * @param string $function_name The function to register
  3410. * @param string $extender_type Extender type
  3411. * @param string $extender_name The name of the extender
  3412. * @return true|false Depending on success
  3413. *
  3414. * @deprecated 1.8 Use {@link elgg_register_extender_url_handler()}
  3415. */
  3416. function register_extender_url_handler($function, $type = "all", $name = "all") {
  3417. elgg_deprecated_notice("register_extender_url_handler() was deprecated by elgg_register_extender_url_handler()", 1.8);
  3418. return elgg_register_extender_url_handler($type, $name, $function);
  3419. }
  3420. /**
  3421. * Registers and entity type and subtype to return in search and other places.
  3422. * A description in the elgg_echo languages file of the form item:type:subtype
  3423. * is also expected.
  3424. *
  3425. * @param string $type The type of entity (object, site, user, group)
  3426. * @param string $subtype The subtype to register (may be blank)
  3427. * @return true|false Depending on success
  3428. *
  3429. * @deprecated 1.8 Use {@link elgg_register_entity_type()}
  3430. */
  3431. function register_entity_type($type, $subtype = null) {
  3432. elgg_deprecated_notice("register_entity_type() was deprecated by elgg_register_entity_type()", 1.8);
  3433. return elgg_register_entity_type($type, $subtype);
  3434. }
  3435. /**
  3436. * Register a metadata url handler.
  3437. *
  3438. * @param string $function_name The function.
  3439. * @param string $extender_name The name, default 'all'.
  3440. *
  3441. * @deprecated 1.8 Use {@link elgg_register_metadata_url_handler()}
  3442. */
  3443. function register_metadata_url_handler($function, $extender_name = "all") {
  3444. return elgg_register_metadata_url_handler($extender_name, $function);
  3445. }
  3446. /**
  3447. * Sets the URL handler for a particular relationship type
  3448. *
  3449. * @param string $function_name The function to register
  3450. * @param string $relationship_type The relationship type.
  3451. * @return true|false Depending on success
  3452. *
  3453. * @deprecated 1.8 Use {@link elgg_register_relationship_url_handler()}
  3454. */
  3455. function register_relationship_url_handler($function_name, $relationship_type = "all") {
  3456. elgg_deprecated_notice("register_relationship_url_handler() was deprecated by elgg_register_relationship_url_handler()", 1.8);
  3457. return elgg_register_relationship_url_handler($relationship_type, $function_name);
  3458. }
  3459. /**
  3460. * Registers a view to be simply cached
  3461. *
  3462. * Views cached in this manner must take no parameters and be login agnostic -
  3463. * that is to say, they look the same no matter who is logged in (or logged out).
  3464. *
  3465. * CSS and the basic jS views are automatically cached like this.
  3466. *
  3467. * @param string $viewname View name
  3468. *
  3469. * @deprecated 1.8 Use {@link elgg_register_simplecache_view()}
  3470. */
  3471. function elgg_view_register_simplecache($viewname) {
  3472. elgg_deprecated_notice("elgg_view_register_simplecache() was deprecated by elgg_register_simplecache_view()", 1.8);
  3473. return elgg_register_simplecache_view($viewname);
  3474. }
  3475. /**
  3476. * Regenerates the simple cache.
  3477. *
  3478. * @param string $viewtype Optional viewtype to regenerate
  3479. * @see elgg_view_register_simplecache()
  3480. *
  3481. * @deprecated 1.8 Use {@link elgg_regenerate_simplecache()}
  3482. */
  3483. function elgg_view_regenerate_simplecache($viewtype = NULL) {
  3484. elgg_deprecated_notice("elgg_view_regenerate_simplecache() was deprecated by elgg_regenerate_simplecache()", 1.8);
  3485. return elgg_regenerate_simplecache($viewtype);
  3486. }
  3487. /**
  3488. * Enables the simple cache.
  3489. *
  3490. * @see elgg_view_register_simplecache()
  3491. *
  3492. * @deprecated 1.8 Use {@link elgg_enable_simplecache()}
  3493. */
  3494. function elgg_view_enable_simplecache() {
  3495. elgg_deprecated_notice("elgg_view_enable_simplecache() was deprecated by elgg_enable_simplecache()", 1.8);
  3496. return elgg_enable_simplecache();
  3497. }
  3498. /**
  3499. * Disables the simple cache.
  3500. *
  3501. * @see elgg_view_register_simplecache()
  3502. *
  3503. * @deprecated 1.8 Use {@link elgg_disable_simplecache()}
  3504. */
  3505. function elgg_view_disable_simplecache() {
  3506. elgg_deprecated_notice("elgg_view_disable_simplecache() was deprecated by elgg_disable_simplecache()", 1.8);
  3507. return elgg_disable_simplecache();
  3508. }
  3509. // these were internal functions that perhaps can be removed rather than deprecated
  3510. /**
  3511. * @deprecated 1.8
  3512. */
  3513. function is_db_installed() {
  3514. elgg_deprecated_notice('is_db_installed() has been deprecated', 1.8);
  3515. return true;
  3516. }
  3517. /**
  3518. * @deprecated 1.8
  3519. */
  3520. function is_installed() {
  3521. elgg_deprecated_notice('is_installed() has been deprecated', 1.8);
  3522. return true;
  3523. }
  3524. /**
  3525. * Attempt to authenticate.
  3526. * This function will process all registered PAM handlers or stop when the first
  3527. * handler fails. A handler fails by either returning false or throwing an
  3528. * exception. The advantage of throwing an exception is that it returns a message
  3529. * through the global $_PAM_HANDLERS_MSG which can be used in communication with
  3530. * a user. The order that handlers are processed is determined by the order that
  3531. * they were registered.
  3532. *
  3533. * If $credentials are provided the PAM handler should authenticate using the
  3534. * provided credentials, if not then credentials should be prompted for or
  3535. * otherwise retrieved (eg from the HTTP header or $_SESSION).
  3536. *
  3537. * @param mixed $credentials Mixed PAM handler specific credentials (e.g. username, password)
  3538. * @param string $policy - the policy type, default is "user"
  3539. * @return bool true if authenticated, false if not.
  3540. *
  3541. * @deprecated 1.8 See {@link ElggPAM}
  3542. */
  3543. function pam_authenticate($credentials = NULL, $policy = "user") {
  3544. elgg_deprecated_notice('pam_authenticate has been deprecated for ElggPAM', 1.8);
  3545. global $_PAM_HANDLERS, $_PAM_HANDLERS_MSG;
  3546. $_PAM_HANDLERS_MSG = array();
  3547. $authenticated = false;
  3548. foreach ($_PAM_HANDLERS[$policy] as $k => $v) {
  3549. $handler = $v->handler;
  3550. $importance = $v->importance;
  3551. try {
  3552. // Execute the handler
  3553. if ($handler($credentials)) {
  3554. // Explicitly returned true
  3555. $_PAM_HANDLERS_MSG[$k] = "Authenticated!";
  3556. $authenticated = true;
  3557. } else {
  3558. $_PAM_HANDLERS_MSG[$k] = "Not Authenticated.";
  3559. // If this is required then abort.
  3560. if ($importance == 'required') {
  3561. return false;
  3562. }
  3563. }
  3564. } catch (Exception $e) {
  3565. $_PAM_HANDLERS_MSG[$k] = "$e";
  3566. // If this is required then abort.
  3567. if ($importance == 'required') {
  3568. return false;
  3569. }
  3570. }
  3571. }
  3572. return $authenticated;
  3573. }
  3574. /**
  3575. * When given a widget entity and a new requested location, saves the new location
  3576. * and also provides a sensible ordering for all widgets in that column
  3577. *
  3578. * @param ElggObject $widget The widget entity
  3579. * @param int $order The order within the column
  3580. * @param int $column The column (1, 2 or 3)
  3581. *
  3582. * @return bool Depending on success
  3583. * @deprecated 1.8 use ElggWidget::move()
  3584. */
  3585. function save_widget_location(ElggObject $widget, $order, $column) {
  3586. elgg_deprecated_notice('save_widget_location() is deprecated', 1.8);
  3587. if ($widget instanceof ElggObject) {
  3588. if ($widget->subtype == "widget") {
  3589. // If you can't move the widget, don't save a new location
  3590. if (!$widget->draggable) {
  3591. return false;
  3592. }
  3593. // Sanitise the column value
  3594. if ($column != 1 || $column != 2 || $column != 3) {
  3595. $column = 1;
  3596. }
  3597. $widget->column = (int) $column;
  3598. $ordertmp = array();
  3599. $params = array(
  3600. 'context' => $widget->context,
  3601. 'column' => $column,
  3602. );
  3603. if ($entities = get_entities_from_metadata_multi($params, 'object', 'widget')) {
  3604. foreach ($entities as $entity) {
  3605. $entityorder = $entity->order;
  3606. if ($entityorder < $order) {
  3607. $ordertmp[$entityorder] = $entity;
  3608. }
  3609. if ($entityorder >= $order) {
  3610. $ordertmp[$entityorder + 10000] = $entity;
  3611. }
  3612. }
  3613. }
  3614. $ordertmp[$order] = $widget;
  3615. ksort($ordertmp);
  3616. $orderticker = 10;
  3617. foreach ($ordertmp as $orderval => $entity) {
  3618. $entity->order = $orderticker;
  3619. $orderticker += 10;
  3620. }
  3621. return true;
  3622. } else {
  3623. register_error($widget->subtype);
  3624. }
  3625. }
  3626. return false;
  3627. }
  3628. /**
  3629. * Get widgets for a particular context and column, in order of display
  3630. *
  3631. * @param int $user_guid The owner user GUID
  3632. * @param string $context The context (profile, dashboard etc)
  3633. * @param int $column The column (1 or 2)
  3634. *
  3635. * @return array|false An array of widget ElggObjects, or false
  3636. * @deprecated 1.8 Use elgg_get_widgets()
  3637. */
  3638. function get_widgets($user_guid, $context, $column) {
  3639. elgg_deprecated_notice('get_widgets is depecated for elgg_get_widgets', 1.8);
  3640. $params = array(
  3641. 'column' => $column,
  3642. 'context' => $context
  3643. );
  3644. $widgets = get_entities_from_private_setting_multi($params, "object",
  3645. "widget", $user_guid, "", 10000);
  3646. if ($widgets) {
  3647. $widgetorder = array();
  3648. foreach ($widgets as $widget) {
  3649. $order = $widget->order;
  3650. while (isset($widgetorder[$order])) {
  3651. $order++;
  3652. }
  3653. $widgetorder[$order] = $widget;
  3654. }
  3655. ksort($widgetorder);
  3656. return $widgetorder;
  3657. }
  3658. return false;
  3659. }
  3660. /**
  3661. * Add a new widget instance
  3662. *
  3663. * @param int $entity_guid GUID of entity that owns this widget
  3664. * @param string $handler The handler for this widget
  3665. * @param string $context The page context for this widget
  3666. * @param int $order The order to display this widget in
  3667. * @param int $column The column to display this widget in (1, 2 or 3)
  3668. * @param int $access_id If not specified, it is set to the default access level
  3669. *
  3670. * @return int|false Widget GUID or false on failure
  3671. * @deprecated 1.8 use elgg_create_widget()
  3672. */
  3673. function add_widget($entity_guid, $handler, $context, $order = 0, $column = 1, $access_id = null) {
  3674. elgg_deprecated_notice('add_widget has been deprecated for elgg_create_widget', 1.8);
  3675. if (empty($entity_guid) || empty($context) || empty($handler) || !widget_type_exists($handler)) {
  3676. return false;
  3677. }
  3678. if ($entity = get_entity($entity_guid)) {
  3679. $widget = new ElggWidget;
  3680. $widget->owner_guid = $entity_guid;
  3681. $widget->container_guid = $entity_guid;
  3682. if (isset($access_id)) {
  3683. $widget->access_id = $access_id;
  3684. } else {
  3685. $widget->access_id = get_default_access();
  3686. }
  3687. $guid = $widget->save();
  3688. // private settings cannot be set until ElggWidget saved
  3689. $widget->handler = $handler;
  3690. $widget->context = $context;
  3691. $widget->column = $column;
  3692. $widget->order = $order;
  3693. return $guid;
  3694. }
  3695. return false;
  3696. }
  3697. /**
  3698. * Define a new widget type
  3699. *
  3700. * @param string $handler The identifier for the widget handler
  3701. * @param string $name The name of the widget type
  3702. * @param string $description A description for the widget type
  3703. * @param string $context A comma-separated list of contexts where this
  3704. * widget is allowed (default: 'all')
  3705. * @param bool $multiple Whether or not multiple instances of this widget
  3706. * are allowed on a single dashboard (default: false)
  3707. * @param string $positions A comma-separated list of positions on the page
  3708. * (side or main) where this widget is allowed (default: "side,main")
  3709. *
  3710. * @return bool Depending on success
  3711. * @deprecated 1.8 Use elgg_register_widget_type
  3712. */
  3713. function add_widget_type($handler, $name, $description, $context = "all",
  3714. $multiple = false, $positions = "side,main") {
  3715. elgg_deprecated_notice("add_widget_type deprecated for elgg_register_widget_type", 1.8);
  3716. return elgg_register_widget_type($handler, $name, $description, $context, $multiple);
  3717. }
  3718. /**
  3719. * Remove a widget type
  3720. *
  3721. * @param string $handler The identifier for the widget handler
  3722. *
  3723. * @return void
  3724. * @since 1.7.1
  3725. * @deprecated 1.8 Use elgg_unregister_widget_type
  3726. */
  3727. function remove_widget_type($handler) {
  3728. elgg_deprecated_notice("remove_widget_type deprecated for elgg_unregister_widget_type", 1.8);
  3729. return elgg_unregister_widget_type($handler);
  3730. }
  3731. /**
  3732. * Determines whether or not widgets with the specified handler have been defined
  3733. *
  3734. * @param string $handler The widget handler identifying string
  3735. *
  3736. * @return bool Whether or not those widgets exist
  3737. * @deprecated 1.8 Use elgg_is_widget_type
  3738. */
  3739. function widget_type_exists($handler) {
  3740. elgg_deprecated_notice("widget_type_exists deprecated for elgg_is_widget_type", 1.8);
  3741. return elgg_is_widget_type($handler);
  3742. }
  3743. /**
  3744. * Returns an array of stdClass objects representing the defined widget types
  3745. *
  3746. * @return array A list of types defined (if any)
  3747. * @deprecated 1.8 Use elgg_get_widget_types
  3748. */
  3749. function get_widget_types() {
  3750. elgg_deprecated_notice("get_widget_types deprecrated for elgg_get_widget_types", 1.8);
  3751. return elgg_get_widget_types();
  3752. }
  3753. /**
  3754. * Saves a widget's settings (by passing an array of
  3755. * (name => value) pairs to save_{$handler}_widget)
  3756. *
  3757. * @param int $widget_guid The GUID of the widget we're saving to
  3758. * @param array $params An array of name => value parameters
  3759. *
  3760. * @return bool
  3761. * @deprecated 1.8 Use elgg_save_widget_settings
  3762. */
  3763. function save_widget_info($widget_guid, $params) {
  3764. elgg_deprecated_notice("save_widget_info() is deprecated for elgg_save_widget_settings", 1.8);
  3765. if ($widget = get_entity($widget_guid)) {
  3766. $subtype = $widget->getSubtype();
  3767. if ($subtype != "widget") {
  3768. return false;
  3769. }
  3770. $handler = $widget->handler;
  3771. if (empty($handler) || !widget_type_exists($handler)) {
  3772. return false;
  3773. }
  3774. if (!$widget->canEdit()) {
  3775. return false;
  3776. }
  3777. // Save the params to the widget
  3778. if (is_array($params) && sizeof($params) > 0) {
  3779. foreach ($params as $name => $value) {
  3780. if (!empty($name) && !in_array($name, array(
  3781. 'guid', 'owner_guid', 'site_guid'
  3782. ))) {
  3783. if (is_array($value)) {
  3784. // @todo Handle arrays securely
  3785. $widget->setMetaData($name, $value, "", true);
  3786. } else {
  3787. $widget->$name = $value;
  3788. }
  3789. }
  3790. }
  3791. $widget->save();
  3792. }
  3793. $function = "save_{$handler}_widget";
  3794. if (is_callable($function)) {
  3795. return $function($params);
  3796. }
  3797. return true;
  3798. }
  3799. return false;
  3800. }
  3801. /**
  3802. * Reorders the widgets from a widget panel
  3803. *
  3804. * @param string $panelstring1 String of guids of ElggWidget objects separated by ::
  3805. * @param string $panelstring2 String of guids of ElggWidget objects separated by ::
  3806. * @param string $panelstring3 String of guids of ElggWidget objects separated by ::
  3807. * @param string $context Profile or dashboard
  3808. * @param int $owner Owner guid
  3809. *
  3810. * @return void
  3811. * @deprecated 1.8 Don't use.
  3812. */
  3813. function reorder_widgets_from_panel($panelstring1, $panelstring2, $panelstring3, $context, $owner) {
  3814. elgg_deprecated_notice("reorder_widgets_from_panel() is deprecated", 1.8);
  3815. $return = true;
  3816. $mainwidgets = explode('::', $panelstring1);
  3817. $sidewidgets = explode('::', $panelstring2);
  3818. $rightwidgets = explode('::', $panelstring3);
  3819. $handlers = array();
  3820. $guids = array();
  3821. if (is_array($mainwidgets) && sizeof($mainwidgets) > 0) {
  3822. foreach ($mainwidgets as $widget) {
  3823. $guid = (int) $widget;
  3824. if ("{$guid}" == "{$widget}") {
  3825. $guids[1][] = $widget;
  3826. } else {
  3827. $handlers[1][] = $widget;
  3828. }
  3829. }
  3830. }
  3831. if (is_array($sidewidgets) && sizeof($sidewidgets) > 0) {
  3832. foreach ($sidewidgets as $widget) {
  3833. $guid = (int) $widget;
  3834. if ("{$guid}" == "{$widget}") {
  3835. $guids[2][] = $widget;
  3836. } else {
  3837. $handlers[2][] = $widget;
  3838. }
  3839. }
  3840. }
  3841. if (is_array($rightwidgets) && sizeof($rightwidgets) > 0) {
  3842. foreach ($rightwidgets as $widget) {
  3843. $guid = (int) $widget;
  3844. if ("{$guid}" == "{$widget}") {
  3845. $guids[3][] = $widget;
  3846. } else {
  3847. $handlers[3][] = $widget;
  3848. }
  3849. }
  3850. }
  3851. // Reorder existing widgets or delete ones that have vanished
  3852. foreach (array(1, 2, 3) as $column) {
  3853. if ($dbwidgets = get_widgets($owner, $context, $column)) {
  3854. foreach ($dbwidgets as $dbwidget) {
  3855. if (in_array($dbwidget->getGUID(), $guids[1])
  3856. || in_array($dbwidget->getGUID(), $guids[2]) || in_array($dbwidget->getGUID(), $guids[3])) {
  3857. if (in_array($dbwidget->getGUID(), $guids[1])) {
  3858. $pos = array_search($dbwidget->getGUID(), $guids[1]);
  3859. $col = 1;
  3860. } else if (in_array($dbwidget->getGUID(), $guids[2])) {
  3861. $pos = array_search($dbwidget->getGUID(), $guids[2]);
  3862. $col = 2;
  3863. } else {
  3864. $pos = array_search($dbwidget->getGUID(), $guids[3]);
  3865. $col = 3;
  3866. }
  3867. $pos = ($pos + 1) * 10;
  3868. $dbwidget->column = $col;
  3869. $dbwidget->order = $pos;
  3870. } else {
  3871. $dbguid = $dbwidget->getGUID();
  3872. if (!$dbwidget->delete()) {
  3873. $return = false;
  3874. } else {
  3875. // Remove state cookie
  3876. $cookie = new ElggCookie("widget$dbguid");
  3877. $cookie->value = NULL;
  3878. elgg_set_cookie($cookie);
  3879. }
  3880. }
  3881. }
  3882. }
  3883. // Add new ones
  3884. if (sizeof($guids[$column]) > 0) {
  3885. foreach ($guids[$column] as $key => $guid) {
  3886. if ($guid == 0) {
  3887. $pos = ($key + 1) * 10;
  3888. $handler = $handlers[$column][$key];
  3889. if (!add_widget($owner, $handler, $context, $pos, $column)) {
  3890. $return = false;
  3891. }
  3892. }
  3893. }
  3894. }
  3895. }
  3896. return $return;
  3897. }
  3898. /**
  3899. * Register a particular context for use with widgets.
  3900. *
  3901. * @param string $context The context we wish to enable context for
  3902. *
  3903. * @return void
  3904. * @deprecated 1.8 Don't use.
  3905. */
  3906. function use_widgets($context) {
  3907. elgg_deprecated_notice("use_widgets is deprecated", 1.8);
  3908. global $CONFIG;
  3909. if (!isset($CONFIG->widgets)) {
  3910. $CONFIG->widgets = new stdClass;
  3911. }
  3912. if (!isset($CONFIG->widgets->contexts)) {
  3913. $CONFIG->widgets->contexts = array();
  3914. }
  3915. if (!empty($context)) {
  3916. $CONFIG->widgets->contexts[] = $context;
  3917. }
  3918. }
  3919. /**
  3920. * Determines whether or not the current context is using widgets
  3921. *
  3922. * @return bool Depending on widget status
  3923. * @deprecated 1.8 Don't use.
  3924. */
  3925. function using_widgets() {
  3926. elgg_deprecated_notice("using_widgets is deprecated", 1.8);
  3927. global $CONFIG;
  3928. $context = elgg_get_context();
  3929. if (isset($CONFIG->widgets->contexts) && is_array($CONFIG->widgets->contexts)) {
  3930. if (in_array($context, $CONFIG->widgets->contexts)) {
  3931. return true;
  3932. }
  3933. }
  3934. return false;
  3935. }
  3936. /**
  3937. * Displays a particular widget
  3938. *
  3939. * @param ElggObject $widget The widget to display
  3940. * @return string The HTML for the widget, including JavaScript wrapper
  3941. *
  3942. * @deprecated 1.8 Use elgg_view_entity()
  3943. */
  3944. function display_widget(ElggObject $widget) {
  3945. elgg_deprecated_notice("display_widget() was been deprecated. Use elgg_view_entity().", 1.8);
  3946. return elgg_view_entity($widget);
  3947. }
  3948. /**
  3949. * Count the number of comments attached to an entity
  3950. *
  3951. * @param ElggEntity $entity
  3952. * @return int Number of comments
  3953. */
  3954. function elgg_count_comments($entity) {
  3955. elgg_deprecated_notice('elgg_count_comments() is deprecated by ElggEntity->countComments()', 1.8);
  3956. if ($entity instanceof ElggEntity) {
  3957. return $entity->countComments();
  3958. }
  3959. return 0;
  3960. }
  3961. /**
  3962. * Removes all items relating to a particular acting entity from the river
  3963. *
  3964. * @param int $subject_guid The GUID of the entity
  3965. *
  3966. * @return bool Depending on success
  3967. * @deprecated 1.8 Use elgg_delete_river()
  3968. */
  3969. function remove_from_river_by_subject($subject_guid) {
  3970. elgg_deprecated_notice("remove_from_river_by_subject() deprecated by elgg_delete_river()", 1.8);
  3971. return elgg_delete_river(array('subject_guid' => $subject_guid));
  3972. }
  3973. /**
  3974. * Removes all items relating to a particular entity being acted upon from the river
  3975. *
  3976. * @param int $object_guid The GUID of the entity
  3977. *
  3978. * @return bool Depending on success
  3979. * @deprecated 1.8 Use elgg_delete_river()
  3980. */
  3981. function remove_from_river_by_object($object_guid) {
  3982. elgg_deprecated_notice("remove_from_river_by_object() deprecated by elgg_delete_river()", 1.8);
  3983. return elgg_delete_river(array('object_guid' => $object_guid));
  3984. }
  3985. /**
  3986. * Removes all items relating to a particular annotation being acted upon from the river
  3987. *
  3988. * @param int $annotation_id The ID of the annotation
  3989. *
  3990. * @return bool Depending on success
  3991. * @since 1.7.0
  3992. * @deprecated 1.8 Use elgg_delete_river()
  3993. */
  3994. function remove_from_river_by_annotation($annotation_id) {
  3995. elgg_deprecated_notice("remove_from_river_by_annotation() deprecated by elgg_delete_river()", 1.8);
  3996. return elgg_delete_river(array('annotation_id' => $annotation_id));
  3997. }
  3998. /**
  3999. * Removes a single river entry
  4000. *
  4001. * @param int $id The ID of the river entry
  4002. *
  4003. * @return bool Depending on success
  4004. * @since 1.7.2
  4005. * @deprecated 1.8 Use elgg_delete_river()
  4006. */
  4007. function remove_from_river_by_id($id) {
  4008. elgg_deprecated_notice("remove_from_river_by_id() deprecated by elgg_delete_river()", 1.8);
  4009. return elgg_delete_river(array('id' => $id));
  4010. }
  4011. /**
  4012. * A default page handler
  4013. * Tries to locate a suitable file to include. Only works for core pages, not plugins.
  4014. *
  4015. * @param array $page The page URL elements
  4016. * @param string $handler The base handler
  4017. *
  4018. * @return true|false Depending on success
  4019. * @deprecated 1.8
  4020. */
  4021. function default_page_handler($page, $handler) {
  4022. global $CONFIG;
  4023. elgg_deprecated_notice("default_page_handler is deprecated", "1.8");
  4024. $page = implode('/', $page);
  4025. // protect against including arbitary files
  4026. $page = str_replace("..", "", $page);
  4027. $callpath = $CONFIG->path . $handler . "/" . $page;
  4028. if (is_dir($callpath)) {
  4029. $callpath = sanitise_filepath($callpath);
  4030. $callpath .= "index.php";
  4031. if (file_exists($callpath)) {
  4032. if (include($callpath)) {
  4033. return TRUE;
  4034. }
  4035. }
  4036. } else if (file_exists($callpath)) {
  4037. include($callpath);
  4038. return TRUE;
  4039. }
  4040. return FALSE;
  4041. }