PageRenderTime 74ms CodeModel.GetById 22ms 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

Large files files are truncated, but you can click here to view the full file

  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_o

Large files files are truncated, but you can click here to view the full file