deprecated-1.7.php 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163
  1. <?php
  2. /**
  3. * Get entities with the specified access collection id.
  4. *
  5. * @deprecated 1.7. Use elgg_get_entities_from_access_id()
  6. *
  7. * @param int $collection_id ID of collection
  8. * @param string $entity_type Type of entities
  9. * @param string $entity_subtype Subtype of entities
  10. * @param int $owner_guid Guid of owner
  11. * @param int $limit Limit of number of entities to return
  12. * @param int $offset Skip this many entities
  13. * @param string $order_by Column to order by
  14. * @param int $site_guid The site guid
  15. * @param bool $count Return a count or entities
  16. *
  17. * @return array
  18. */
  19. function get_entities_from_access_id($collection_id, $entity_type = "", $entity_subtype = "",
  20. $owner_guid = 0, $limit = 10, $offset = 0, $order_by = "", $site_guid = 0, $count = false) {
  21. // log deprecated warning
  22. elgg_deprecated_notice('get_entities_from_access_id() was deprecated by elgg_get_entities()', 1.7);
  23. if (!$collection_id) {
  24. return FALSE;
  25. }
  26. // build the options using given parameters
  27. $options = array();
  28. $options['limit'] = $limit;
  29. $options['offset'] = $offset;
  30. $options['count'] = $count;
  31. if ($entity_type) {
  32. $options['type'] = sanitise_string($entity_type);
  33. }
  34. if ($entity_subtype) {
  35. $options['subtype'] = $entity_subtype;
  36. }
  37. if ($site_guid) {
  38. $options['site_guid'] = $site_guid;
  39. }
  40. if ($order_by) {
  41. $options['order_by'] = sanitise_string("e.time_created, $order_by");
  42. }
  43. if ($owner_guid) {
  44. if (is_array($owner_guid)) {
  45. $options['owner_guids'] = $owner_guid;
  46. } else {
  47. $options['owner_guid'] = $owner_guid;
  48. }
  49. }
  50. if ($site_guid) {
  51. $options['site_guid'] = $site_guid;
  52. }
  53. $options['access_id'] = $collection_id;
  54. return elgg_get_entities_from_access_id($options);
  55. }
  56. /**
  57. * @deprecated 1.7
  58. */
  59. function get_entities_from_access_collection($collection_id, $entity_type = "", $entity_subtype = "",
  60. $owner_guid = 0, $limit = 10, $offset = 0, $order_by = "", $site_guid = 0, $count = false) {
  61. elgg_deprecated_notice('get_entities_from_access_collection() was deprecated by elgg_get_entities()', 1.7);
  62. return get_entities_from_access_id($collection_id, $entity_type, $entity_subtype,
  63. $owner_guid, $limit, $offset, $order_by, $site_guid, $count);
  64. }
  65. /**
  66. * Get entities from annotations
  67. *
  68. * No longer used.
  69. *
  70. * @deprecated 1.7 Use elgg_get_entities_from_annotations()
  71. *
  72. * @param mixed $entity_type Type of entity
  73. * @param mixed $entity_subtype Subtype of entity
  74. * @param string $name Name of annotation
  75. * @param string $value Value of annotation
  76. * @param int $owner_guid Guid of owner of annotation
  77. * @param int $group_guid Guid of group
  78. * @param int $limit Limit
  79. * @param int $offset Offset
  80. * @param string $order_by SQL order by string
  81. * @param bool $count Count or return entities
  82. * @param int $timelower Lower time limit
  83. * @param int $timeupper Upper time limit
  84. *
  85. * @return ElggEntity[]|int
  86. */
  87. function get_entities_from_annotations($entity_type = "", $entity_subtype = "", $name = "",
  88. $value = "", $owner_guid = 0, $group_guid = 0, $limit = 10, $offset = 0, $order_by = "asc",
  89. $count = false, $timelower = 0, $timeupper = 0) {
  90. $msg = 'get_entities_from_annotations() is deprecated by elgg_get_entities_from_annotations().';
  91. elgg_deprecated_notice($msg, 1.7);
  92. $options = array();
  93. if ($entity_type) {
  94. $options['types'] = $entity_type;
  95. }
  96. if ($entity_subtype) {
  97. $options['subtypes'] = $entity_subtype;
  98. }
  99. $options['annotation_names'] = $name;
  100. if ($value) {
  101. $options['annotation_values'] = $value;
  102. }
  103. if ($owner_guid) {
  104. if (is_array($owner_guid)) {
  105. $options['annotation_owner_guids'] = $owner_guid;
  106. } else {
  107. $options['annotation_owner_guid'] = $owner_guid;
  108. }
  109. }
  110. if ($group_guid) {
  111. $options['container_guid'] = $group_guid;
  112. }
  113. if ($limit) {
  114. $options['limit'] = $limit;
  115. }
  116. if ($offset) {
  117. $options['offset'] = $offset;
  118. }
  119. if ($order_by) {
  120. $options['order_by'] = "maxtime $order_by";
  121. }
  122. if ($count) {
  123. $options['count'] = $count;
  124. }
  125. if ($timelower) {
  126. $options['annotation_created_time_lower'] = $timelower;
  127. }
  128. if ($timeupper) {
  129. $options['annotation_created_time_upper'] = $timeupper;
  130. }
  131. return elgg_get_entities_from_annotations($options);
  132. }
  133. /**
  134. * Lists entities
  135. *
  136. * @see elgg_view_entity_list
  137. *
  138. * @param string $entity_type Type of entity.
  139. * @param string $entity_subtype Subtype of entity.
  140. * @param string $name Name of annotation.
  141. * @param string $value Value of annotation.
  142. * @param int $limit Maximum number of results to return.
  143. * @param int $owner_guid Owner.
  144. * @param int $group_guid Group container. Currently only supported if entity_type is object
  145. * @param boolean $asc Whether to list in ascending or descending order (default: desc)
  146. * @param boolean $fullview Whether to display the entities in full
  147. * @param boolean $listtypetoggle Can 'gallery' view can be displayed (default: no)
  148. *
  149. * @deprecated 1.7 Use elgg_list_entities_from_annotations()
  150. * @return string Formatted entity list
  151. */
  152. function list_entities_from_annotations($entity_type = "", $entity_subtype = "", $name = "",
  153. $value = "", $limit = 10, $owner_guid = 0, $group_guid = 0, $asc = false, $fullview = true,
  154. $listtypetoggle = false) {
  155. $msg = 'list_entities_from_annotations is deprecated by elgg_list_entities_from_annotations';
  156. elgg_deprecated_notice($msg, 1.8);
  157. $options = array();
  158. if ($entity_type) {
  159. $options['types'] = $entity_type;
  160. }
  161. if ($entity_subtype) {
  162. $options['subtypes'] = $entity_subtype;
  163. }
  164. if ($name) {
  165. $options['annotation_names'] = $name;
  166. }
  167. if ($value) {
  168. $options['annotation_values'] = $value;
  169. }
  170. if ($limit) {
  171. $options['limit'] = $limit;
  172. }
  173. if ($owner_guid) {
  174. $options['annotation_owner_guid'] = $owner_guid;
  175. }
  176. if ($group_guid) {
  177. $options['container_guid'] = $group_guid;
  178. }
  179. if ($asc) {
  180. $options['order_by'] = 'maxtime desc';
  181. }
  182. if ($offset = sanitise_int(get_input('offset', null))) {
  183. $options['offset'] = $offset;
  184. }
  185. $options['full_view'] = $fullview;
  186. $options['list_type_toggle'] = $listtypetoggle;
  187. $options['pagination'] = true;
  188. return elgg_list_entities_from_annotations($options);
  189. }
  190. /**
  191. * Returns all php files in a directory.
  192. *
  193. * @deprecated 1.7 Use elgg_get_file_list() instead
  194. *
  195. * @param string $directory Directory to look in
  196. * @param array $exceptions Array of extensions (with .!) to ignore
  197. * @param array $list A list files to include in the return
  198. *
  199. * @return array
  200. */
  201. function get_library_files($directory, $exceptions = array(), $list = array()) {
  202. elgg_deprecated_notice('get_library_files() deprecated by elgg_get_file_list()', 1.7);
  203. return elgg_get_file_list($directory, $exceptions, $list, array('.php'));
  204. }
  205. /**
  206. * Add action tokens to URL.
  207. *
  208. * @param string $url URL
  209. *
  210. * @return string
  211. *
  212. * @deprecated 1.7 final
  213. */
  214. function elgg_validate_action_url($url) {
  215. elgg_deprecated_notice('elgg_validate_action_url() deprecated by elgg_add_action_tokens_to_url().',
  216. 1.7);
  217. return elgg_add_action_tokens_to_url($url);
  218. }
  219. /**
  220. * Does nothing.
  221. *
  222. * @deprecated 1.7
  223. * @return 0
  224. */
  225. function test_ip() {
  226. elgg_deprecated_notice('test_ip() was removed because of licensing issues.', 1.7);
  227. return 0;
  228. }
  229. /**
  230. * Does nothing.
  231. *
  232. * @return bool
  233. * @deprecated 1.7
  234. */
  235. function is_ip_in_array() {
  236. elgg_deprecated_notice('is_ip_in_array() was removed because of licensing issues.', 1.7);
  237. return false;
  238. }
  239. /**
  240. * Returns entities.
  241. *
  242. * @deprecated 1.7. Use elgg_get_entities().
  243. *
  244. * @param string $type Entity type
  245. * @param string $subtype Entity subtype
  246. * @param int $owner_guid Owner GUID
  247. * @param string $order_by Order by clause
  248. * @param int $limit Limit
  249. * @param int $offset Offset
  250. * @param bool $count Return a count or an array of entities
  251. * @param int $site_guid Site GUID
  252. * @param int $container_guid Container GUID
  253. * @param int $timelower Lower time limit
  254. * @param int $timeupper Upper time limit
  255. *
  256. * @return array
  257. */
  258. function get_entities($type = "", $subtype = "", $owner_guid = 0, $order_by = "", $limit = 10,
  259. $offset = 0, $count = false, $site_guid = 0, $container_guid = null, $timelower = 0,
  260. $timeupper = 0) {
  261. elgg_deprecated_notice('get_entities() was deprecated by elgg_get_entities().', 1.7);
  262. // rewrite owner_guid to container_guid to emulate old functionality
  263. if ($owner_guid != "") {
  264. if (is_null($container_guid)) {
  265. $container_guid = $owner_guid;
  266. $owner_guid = NULL;
  267. }
  268. }
  269. $options = array();
  270. if ($type) {
  271. if (is_array($type)) {
  272. $options['types'] = $type;
  273. } else {
  274. $options['type'] = $type;
  275. }
  276. }
  277. if ($subtype) {
  278. if (is_array($subtype)) {
  279. $options['subtypes'] = $subtype;
  280. } else {
  281. $options['subtype'] = $subtype;
  282. }
  283. }
  284. if ($owner_guid) {
  285. if (is_array($owner_guid)) {
  286. $options['owner_guids'] = $owner_guid;
  287. } else {
  288. $options['owner_guid'] = $owner_guid;
  289. }
  290. }
  291. if ($order_by) {
  292. $options['order_by'] = $order_by;
  293. }
  294. // need to pass 0 for all option
  295. $options['limit'] = $limit;
  296. if ($offset) {
  297. $options['offset'] = $offset;
  298. }
  299. if ($count) {
  300. $options['count'] = $count;
  301. }
  302. if ($site_guid) {
  303. $options['site_guids'] = $site_guid;
  304. }
  305. if ($container_guid) {
  306. $options['container_guids'] = $container_guid;
  307. }
  308. if ($timeupper) {
  309. $options['created_time_upper'] = $timeupper;
  310. }
  311. if ($timelower) {
  312. $options['created_time_lower'] = $timelower;
  313. }
  314. $r = elgg_get_entities($options);
  315. return $r;
  316. }
  317. /**
  318. * Delete multiple entities that match a given query.
  319. * This function iterates through and calls delete_entity on
  320. * each one, this is somewhat inefficient but lets
  321. * the 'delete' event be called for each entity.
  322. *
  323. * @deprecated 1.7. This is a dangerous function as it defaults to deleting everything.
  324. *
  325. * @param string $type The type of entity (eg "user", "object" etc)
  326. * @param string $subtype The arbitrary subtype of the entity
  327. * @param int $owner_guid The GUID of the owning user
  328. *
  329. * @return false
  330. */
  331. function delete_entities($type = "", $subtype = "", $owner_guid = 0) {
  332. elgg_deprecated_notice('delete_entities() was deprecated because no one should use it.', 1.7);
  333. return false;
  334. }
  335. /**
  336. * Lists entities.
  337. *
  338. * @param int $owner_guid Owner GUID
  339. * @param int $limit Limit
  340. * @param bool $fullview Show entity full views
  341. * @param bool $listtypetoggle Show list type toggle
  342. * @param bool $allowedtypes A string of the allowed types
  343. *
  344. * @return string
  345. * @deprecated 1.7. Use elgg_list_registered_entities().
  346. */
  347. function list_registered_entities($owner_guid = 0, $limit = 10, $fullview = true,
  348. $listtypetoggle = false, $allowedtypes = true) {
  349. elgg_deprecated_notice('list_registered_entities() was deprecated by elgg_list_registered_entities().', 1.7);
  350. $options = array();
  351. // don't want to send anything if not being used.
  352. if ($owner_guid) {
  353. $options['owner_guid'] = $owner_guid;
  354. }
  355. if ($limit) {
  356. $options['limit'] = $limit;
  357. }
  358. if ($allowedtypes) {
  359. $options['allowed_types'] = $allowedtypes;
  360. }
  361. // need to send because might be BOOL
  362. $options['full_view'] = $fullview;
  363. $options['list_type_toggle'] = $listtypetoggle;
  364. $options['offset'] = get_input('offset', 0);
  365. return elgg_list_registered_entities($options);
  366. }
  367. /**
  368. * Lists entities
  369. *
  370. * @deprecated 1.7. Use elgg_list_entities().
  371. *
  372. * @param string $type Entity type
  373. * @param string $subtype Entity subtype
  374. * @param int $owner_guid Owner GUID
  375. * @param int $limit Limit
  376. * @param bool $fullview Display entity full views?
  377. * @param bool $listtypetoggle Allow switching to gallery mode?
  378. * @param bool $pagination Show pagination?
  379. *
  380. * @return string
  381. */
  382. function list_entities($type= "", $subtype = "", $owner_guid = 0, $limit = 10, $fullview = true,
  383. $listtypetoggle = false, $pagination = true) {
  384. elgg_deprecated_notice('list_entities() was deprecated by elgg_list_entities()!', 1.7);
  385. $options = array();
  386. // rewrite owner_guid to container_guid to emulate old functionality
  387. if ($owner_guid) {
  388. $options['container_guids'] = $owner_guid;
  389. }
  390. if ($type) {
  391. $options['types'] = $type;
  392. }
  393. if ($subtype) {
  394. $options['subtypes'] = $subtype;
  395. }
  396. if ($limit) {
  397. $options['limit'] = $limit;
  398. }
  399. if ($offset = sanitise_int(get_input('offset', null))) {
  400. $options['offset'] = $offset;
  401. }
  402. $options['full_view'] = $fullview;
  403. $options['list_type_toggle'] = $listtypetoggle;
  404. $options['pagination'] = $pagination;
  405. return elgg_list_entities($options);
  406. }
  407. /**
  408. * Searches for a group based on a complete or partial name or description
  409. *
  410. * @param string $criteria The partial or full name or description
  411. * @param int $limit Limit of the search.
  412. * @param int $offset Offset.
  413. * @param string $order_by The order.
  414. * @param boolean $count Whether to return the count of results or just the results.
  415. *
  416. * @return mixed
  417. * @deprecated 1.7
  418. */
  419. function search_for_group($criteria, $limit = 10, $offset = 0, $order_by = "", $count = false) {
  420. elgg_deprecated_notice('search_for_group() was deprecated by new search plugin.', 1.7);
  421. global $CONFIG;
  422. $criteria = sanitise_string($criteria);
  423. $limit = (int)$limit;
  424. $offset = (int)$offset;
  425. $order_by = sanitise_string($order_by);
  426. $access = _elgg_get_access_where_sql();
  427. if ($order_by == "") {
  428. $order_by = "e.time_created desc";
  429. }
  430. if ($count) {
  431. $query = "SELECT count(e.guid) as total ";
  432. } else {
  433. $query = "SELECT e.* ";
  434. }
  435. $query .= "from {$CONFIG->dbprefix}entities e"
  436. . " JOIN {$CONFIG->dbprefix}groups_entity g on e.guid=g.guid where ";
  437. $query .= "(g.name like \"%{$criteria}%\" or g.description like \"%{$criteria}%\")";
  438. $query .= " and $access";
  439. if (!$count) {
  440. $query .= " order by $order_by limit $offset, $limit"; // Add order and limit
  441. return get_data($query, "entity_row_to_elggstar");
  442. } else {
  443. if ($count = get_data_row($query)) {
  444. return $count->total;
  445. }
  446. }
  447. return false;
  448. }
  449. /**
  450. * Returns a formatted list of groups suitable for injecting into search.
  451. *
  452. * @deprecated 1.7
  453. *
  454. * @param string $hook Hook name
  455. * @param string $user User
  456. * @param mixed $returnvalue Previous hook's return value
  457. * @param string $tag Tag to search on
  458. *
  459. * @return string
  460. */
  461. function search_list_groups_by_name($hook, $user, $returnvalue, $tag) {
  462. elgg_deprecated_notice('search_list_groups_by_name() was deprecated by new search plugin', 1.7);
  463. // Change this to set the number of groups that display on the search page
  464. $threshold = 4;
  465. $object = get_input('object');
  466. if (!get_input('offset') && (empty($object) || $object == 'group')) {
  467. if ($groups = search_for_group($tag, $threshold)) {
  468. $countgroups = search_for_group($tag, 0, 0, "", true);
  469. $return = elgg_view('group/search/startblurb', array('count' => $countgroups, 'tag' => $tag));
  470. foreach ($groups as $group) {
  471. $return .= elgg_view_entity($group);
  472. }
  473. $vars = array('count' => $countgroups, 'threshold' => $threshold, 'tag' => $tag);
  474. $return .= elgg_view('group/search/finishblurb', $vars);
  475. return $return;
  476. }
  477. }
  478. }
  479. /**
  480. * Displays a list of group objects that have been searched for.
  481. *
  482. * @see elgg_view_entity_list
  483. *
  484. * @param string $tag Search criteria
  485. * @param int $limit The number of entities to display on a page
  486. *
  487. * @return string The list in a form suitable to display
  488. * @deprecated 1.7
  489. */
  490. function list_group_search($tag, $limit = 10) {
  491. elgg_deprecated_notice('list_group_search() was deprecated by new search plugin.', 1.7);
  492. $offset = (int) get_input('offset');
  493. $limit = (int) $limit;
  494. $count = (int) search_for_group($tag, 10, 0, '', true);
  495. $entities = search_for_group($tag, $limit, $offset);
  496. return elgg_view_entity_list($entities, $count, $offset, $limit, true, false);
  497. }
  498. /**
  499. * Return a list of entities based on the given search criteria.
  500. *
  501. * @deprecated 1.7 use elgg_get_entities_from_metadata().
  502. *
  503. * @param mixed $meta_name Metadat name
  504. * @param mixed $meta_value Metadata value
  505. * @param string $entity_type The type of entity to look for, eg 'site' or 'object'
  506. * @param string $entity_subtype The subtype of the entity.
  507. * @param int $owner_guid Owner GUID
  508. * @param int $limit Limit
  509. * @param int $offset Offset
  510. * @param string $order_by Optional ordering.
  511. * @param int $site_guid Site GUID. 0 for current, -1 for any.
  512. * @param bool $count Return a count instead of entities
  513. * @param bool $case_sensitive Metadata names case sensitivity
  514. *
  515. * @return int|array A list of entities, or a count if $count is set to true
  516. */
  517. function get_entities_from_metadata($meta_name, $meta_value = "", $entity_type = "",
  518. $entity_subtype = "", $owner_guid = 0, $limit = 10, $offset = 0, $order_by = "",
  519. $site_guid = 0, $count = FALSE, $case_sensitive = TRUE) {
  520. elgg_deprecated_notice('get_entities_from_metadata() was deprecated by elgg_get_entities_from_metadata()!', 1.7);
  521. $options = array();
  522. $options['metadata_names'] = $meta_name;
  523. if ($meta_value) {
  524. $options['metadata_values'] = $meta_value;
  525. }
  526. if ($entity_type) {
  527. $options['types'] = $entity_type;
  528. }
  529. if ($entity_subtype) {
  530. $options['subtypes'] = $entity_subtype;
  531. }
  532. if ($owner_guid) {
  533. if (is_array($owner_guid)) {
  534. $options['owner_guids'] = $owner_guid;
  535. } else {
  536. $options['owner_guid'] = $owner_guid;
  537. }
  538. }
  539. if ($limit) {
  540. $options['limit'] = $limit;
  541. }
  542. if ($offset) {
  543. $options['offset'] = $offset;
  544. }
  545. if ($order_by) {
  546. $options['order_by'];
  547. }
  548. if ($site_guid) {
  549. $options['site_guid'];
  550. }
  551. if ($count) {
  552. $options['count'] = $count;
  553. }
  554. // need to be able to pass false
  555. $options['metadata_case_sensitive'] = $case_sensitive;
  556. return elgg_get_entities_from_metadata($options);
  557. }
  558. /**
  559. * Return entities from metadata
  560. *
  561. * @deprecated 1.7. Use elgg_get_entities_from_metadata().
  562. *
  563. * @param mixed $meta_array Metadata name
  564. * @param string $entity_type The type of entity to look for, eg 'site' or 'object'
  565. * @param string $entity_subtype The subtype of the entity.
  566. * @param int $owner_guid Owner GUID
  567. * @param int $limit Limit
  568. * @param int $offset Offset
  569. * @param string $order_by Optional ordering.
  570. * @param int $site_guid Site GUID. 0 for current, -1 for any.
  571. * @param bool $count Return a count instead of entities
  572. * @param bool $meta_array_operator Operator for metadata values
  573. *
  574. * @return int|array A list of entities, or a count if $count is set to true
  575. */
  576. function get_entities_from_metadata_multi($meta_array, $entity_type = "", $entity_subtype = "",
  577. $owner_guid = 0, $limit = 10, $offset = 0, $order_by = "", $site_guid = 0,
  578. $count = false, $meta_array_operator = 'and') {
  579. elgg_deprecated_notice('get_entities_from_metadata_multi() was deprecated by elgg_get_entities_from_metadata()!', 1.7);
  580. if (!is_array($meta_array) || sizeof($meta_array) == 0) {
  581. return false;
  582. }
  583. $options = array();
  584. $options['metadata_name_value_pairs'] = $meta_array;
  585. if ($entity_type) {
  586. $options['types'] = $entity_type;
  587. }
  588. if ($entity_subtype) {
  589. $options['subtypes'] = $entity_subtype;
  590. }
  591. if ($owner_guid) {
  592. if (is_array($owner_guid)) {
  593. $options['owner_guids'] = $owner_guid;
  594. } else {
  595. $options['owner_guid'] = $owner_guid;
  596. }
  597. }
  598. if ($limit) {
  599. $options['limit'] = $limit;
  600. }
  601. if ($offset) {
  602. $options['offset'] = $offset;
  603. }
  604. if ($order_by) {
  605. $options['order_by'];
  606. }
  607. if ($site_guid) {
  608. $options['site_guid'];
  609. }
  610. if ($count) {
  611. $options['count'] = $count;
  612. }
  613. $options['metadata_name_value_pairs_operator'] = $meta_array_operator;
  614. return elgg_get_entities_from_metadata($options);
  615. }
  616. /**
  617. * Returns a menu item for use in the children section of add_menu()
  618. * This is not currently used in the Elgg core.
  619. *
  620. * @param string $menu_name The name of the menu item
  621. * @param string $menu_url Its URL
  622. *
  623. * @return \stdClass|false Depending on success
  624. * @deprecated 1.7
  625. */
  626. function menu_item($menu_name, $menu_url) {
  627. elgg_deprecated_notice('menu_item() is deprecated by add_submenu_item', 1.7);
  628. return make_register_object($menu_name, $menu_url);
  629. }
  630. /**
  631. * Searches for an object based on a complete or partial title
  632. * or description using full text searching.
  633. *
  634. * IMPORTANT NOTE: With MySQL's default setup:
  635. * 1) $criteria must be 4 or more characters long
  636. * 2) If $criteria matches greater than 50% of results NO RESULTS ARE RETURNED!
  637. *
  638. * @param string $criteria The partial or full name or username.
  639. * @param int $limit Limit of the search.
  640. * @param int $offset Offset.
  641. * @param string $order_by The order.
  642. * @param boolean $count Whether to return the count of results or just the results.
  643. *
  644. * @return int|false
  645. * @deprecated 1.7
  646. */
  647. function search_for_object($criteria, $limit = 10, $offset = 0, $order_by = "", $count = false) {
  648. elgg_deprecated_notice('search_for_object() was deprecated by new search plugin.', 1.7);
  649. global $CONFIG;
  650. $criteria = sanitise_string($criteria);
  651. $limit = (int)$limit;
  652. $offset = (int)$offset;
  653. $order_by = sanitise_string($order_by);
  654. $access = _elgg_get_access_where_sql();
  655. if ($order_by == "") {
  656. $order_by = "e.time_created desc";
  657. }
  658. if ($count) {
  659. $query = "SELECT count(e.guid) as total ";
  660. } else {
  661. $query = "SELECT e.* ";
  662. }
  663. $query .= "from {$CONFIG->dbprefix}entities e
  664. join {$CONFIG->dbprefix}objects_entity o on e.guid=o.guid
  665. where match(o.title,o.description) against ('$criteria') and $access";
  666. if (!$count) {
  667. $query .= " order by $order_by limit $offset, $limit"; // Add order and limit
  668. return get_data($query, "entity_row_to_elggstar");
  669. } else {
  670. if ($count = get_data_row($query)) {
  671. return $count->total;
  672. }
  673. }
  674. return false;
  675. }
  676. /**
  677. * Returns a formatted list of objects suitable for injecting into search.
  678. *
  679. * @deprecated 1.7
  680. *
  681. * @param sting $hook Hook
  682. * @param string $user user
  683. * @param mixed $returnvalue Previous return value
  684. * @param mixed $tag Search term
  685. *
  686. * @return array
  687. */
  688. function search_list_objects_by_name($hook, $user, $returnvalue, $tag) {
  689. elgg_deprecated_notice('search_list_objects_by_name was deprecated by new search plugin.', 1.7);
  690. // Change this to set the number of users that display on the search page
  691. $threshold = 4;
  692. $object = get_input('object');
  693. if (!get_input('offset') && (empty($object) || $object == 'user')) {
  694. if ($users = search_for_user($tag, $threshold)) {
  695. $countusers = search_for_user($tag, 0, 0, "", true);
  696. $return = elgg_view('user/search/startblurb', array('count' => $countusers, 'tag' => $tag));
  697. foreach ($users as $user) {
  698. $return .= elgg_view_entity($user);
  699. }
  700. $return .= elgg_view('user/search/finishblurb',
  701. array('count' => $countusers, 'threshold' => $threshold, 'tag' => $tag));
  702. return $return;
  703. }
  704. }
  705. }
  706. /**
  707. * Return entities from relationships
  708. *
  709. * @deprecated 1.7 Use elgg_get_entities_from_relationship()
  710. *
  711. * @param string $relationship The relationship type
  712. * @param int $relationship_guid The GUID of the relationship owner
  713. * @param bool $inverse_relationship Invert relationship?
  714. * @param string $type Entity type
  715. * @param string $subtype Entity subtype
  716. * @param int $owner_guid Entity owner GUID
  717. * @param string $order_by Order by clause
  718. * @param int $limit Limit
  719. * @param int $offset Offset
  720. * @param bool $count Return a count instead of entities?
  721. * @param int $site_guid Site GUID
  722. *
  723. * @return mixed
  724. */
  725. function get_entities_from_relationship($relationship, $relationship_guid,
  726. $inverse_relationship = false, $type = "", $subtype = "", $owner_guid = 0,
  727. $order_by = "", $limit = 10, $offset = 0, $count = false, $site_guid = 0) {
  728. elgg_deprecated_notice('get_entities_from_relationship() was deprecated by elgg_get_entities_from_relationship()!', 1.7);
  729. $options = array();
  730. $options['relationship'] = $relationship;
  731. $options['relationship_guid'] = $relationship_guid;
  732. $options['inverse_relationship'] = $inverse_relationship;
  733. if ($type) {
  734. $options['types'] = $type;
  735. }
  736. if ($subtype) {
  737. $options['subtypes'] = $subtype;
  738. }
  739. if ($owner_guid) {
  740. $options['owner_guid'] = $owner_guid;
  741. }
  742. $options['limit'] = $limit;
  743. if ($offset) {
  744. $options['offset'] = $offset;
  745. }
  746. if ($order_by) {
  747. $options['order_by'];
  748. }
  749. if ($site_guid) {
  750. $options['site_guid'];
  751. }
  752. if ($count) {
  753. $options['count'] = $count;
  754. }
  755. return elgg_get_entities_from_relationship($options);
  756. }
  757. /**
  758. * Searches for a site based on a complete or partial name
  759. * or description or url using full text searching.
  760. *
  761. * IMPORTANT NOTE: With MySQL's default setup:
  762. * 1) $criteria must be 4 or more characters long
  763. * 2) If $criteria matches greater than 50% of results NO RESULTS ARE RETURNED!
  764. *
  765. * @param string $criteria The partial or full name or username.
  766. * @param int $limit Limit of the search.
  767. * @param int $offset Offset.
  768. * @param string $order_by The order.
  769. * @param boolean $count Whether to return the count of results or just the results.
  770. *
  771. * @return mixed
  772. * @deprecated 1.7
  773. */
  774. function search_for_site($criteria, $limit = 10, $offset = 0, $order_by = "", $count = false) {
  775. elgg_deprecated_notice('search_for_site() was deprecated by new search plugin.', 1.7);
  776. global $CONFIG;
  777. $criteria = sanitise_string($criteria);
  778. $limit = (int)$limit;
  779. $offset = (int)$offset;
  780. $order_by = sanitise_string($order_by);
  781. $access = _elgg_get_access_where_sql();
  782. if ($order_by == "") {
  783. $order_by = "e.time_created desc";
  784. }
  785. if ($count) {
  786. $query = "SELECT count(e.guid) as total ";
  787. } else {
  788. $query = "SELECT e.* ";
  789. }
  790. $query .= "from {$CONFIG->dbprefix}entities e
  791. join {$CONFIG->dbprefix}sites_entity s on e.guid=s.guid
  792. where match(s.name, s.description, s.url) against ('$criteria') and $access";
  793. if (!$count) {
  794. $query .= " order by $order_by limit $offset, $limit"; // Add order and limit
  795. return get_data($query, "entity_row_to_elggstar");
  796. } else {
  797. if ($count = get_data_row($query)) {
  798. return $count->total;
  799. }
  800. }
  801. return false;
  802. }
  803. /**
  804. * Searches for a user based on a complete or partial name or username.
  805. *
  806. * @param string $criteria The partial or full name or username.
  807. * @param int $limit Limit of the search.
  808. * @param int $offset Offset.
  809. * @param string $order_by The order.
  810. * @param boolean $count Whether to return the count of results or just the results.
  811. *
  812. * @return mixed
  813. * @deprecated 1.7
  814. */
  815. function search_for_user($criteria, $limit = 10, $offset = 0, $order_by = "", $count = false) {
  816. elgg_deprecated_notice('search_for_user() was deprecated by new search.', 1.7);
  817. global $CONFIG;
  818. $criteria = sanitise_string($criteria);
  819. $limit = (int)$limit;
  820. $offset = (int)$offset;
  821. $order_by = sanitise_string($order_by);
  822. $access = _elgg_get_access_where_sql();
  823. if ($order_by == "") {
  824. $order_by = "e.time_created desc";
  825. }
  826. if ($count) {
  827. $query = "SELECT count(e.guid) as total ";
  828. } else {
  829. $query = "SELECT e.* ";
  830. }
  831. $query .= "from {$CONFIG->dbprefix}entities e
  832. join {$CONFIG->dbprefix}users_entity u on e.guid=u.guid where ";
  833. $query .= "(u.name like \"%{$criteria}%\" or u.username like \"%{$criteria}%\")";
  834. $query .= " and $access";
  835. if (!$count) {
  836. $query .= " order by $order_by limit $offset, $limit";
  837. return get_data($query, "entity_row_to_elggstar");
  838. } else {
  839. if ($count = get_data_row($query)) {
  840. return $count->total;
  841. }
  842. }
  843. return false;
  844. }
  845. /**
  846. * Displays a list of user objects that have been searched for.
  847. *
  848. * @see elgg_view_entity_list
  849. *
  850. * @param string $tag Search criteria
  851. * @param int $limit The number of entities to display on a page
  852. *
  853. * @return string The list in a form suitable to display
  854. *
  855. * @deprecated 1.7
  856. */
  857. function list_user_search($tag, $limit = 10) {
  858. elgg_deprecated_notice('list_user_search() deprecated by new search', 1.7);
  859. $offset = (int) get_input('offset');
  860. $limit = (int) $limit;
  861. $count = (int) search_for_user($tag, 10, 0, '', true);
  862. $entities = search_for_user($tag, $limit, $offset);
  863. return elgg_view_entity_list($entities, $count, $offset, $limit, true, false);
  864. }
  865. /**
  866. * Returns a formatted list of users suitable for injecting into search.
  867. *
  868. * @deprecated 1.7
  869. *
  870. * @param string $hook Hook name
  871. * @param string $user User?
  872. * @param mixed $returnvalue Previous hook's return value
  873. * @param mixed $tag Tag to search against
  874. *
  875. * @return void
  876. */
  877. function search_list_users_by_name($hook, $user, $returnvalue, $tag) {
  878. elgg_deprecated_notice('search_list_users_by_name() was deprecated by new search', 1.7);
  879. // Change this to set the number of users that display on the search page
  880. $threshold = 4;
  881. $object = get_input('object');
  882. if (!get_input('offset') && (empty($object) || $object == 'user')) {
  883. if ($users = search_for_user($tag, $threshold)) {
  884. $countusers = search_for_user($tag, 0, 0, "", true);
  885. $return = elgg_view('user/search/startblurb', array('count' => $countusers, 'tag' => $tag));
  886. foreach ($users as $user) {
  887. $return .= elgg_view_entity($user);
  888. }
  889. $vars = array('count' => $countusers, 'threshold' => $threshold, 'tag' => $tag);
  890. $return .= elgg_view('user/search/finishblurb', $vars);
  891. return $return;
  892. }
  893. }
  894. }
  895. /**
  896. * Extend a view
  897. *
  898. * @deprecated 1.7. Use elgg_extend_view().
  899. *
  900. * @param string $view The view to extend.
  901. * @param string $view_name This view is added to $view
  902. * @param int $priority The priority, from 0 to 1000,
  903. * to add at (lowest numbers displayed first)
  904. * @param string $viewtype Not used
  905. *
  906. * @return void
  907. */
  908. function extend_view($view, $view_name, $priority = 501, $viewtype = '') {
  909. elgg_deprecated_notice('extend_view() was deprecated by elgg_extend_view()!', 1.7);
  910. elgg_extend_view($view, $view_name, $priority, $viewtype);
  911. }
  912. /**
  913. * Get views in a dir
  914. *
  915. * @deprecated 1.7. Use elgg_get_views().
  916. *
  917. * @param string $dir Dir
  918. * @param string $base Base view
  919. *
  920. * @return array
  921. */
  922. function get_views($dir, $base) {
  923. elgg_deprecated_notice('get_views() was deprecated by elgg_get_views()!', 1.7);
  924. elgg_get_views($dir, $base);
  925. }
  926. /**
  927. * Constructs and returns a register object.
  928. *
  929. * @param string $register_name The name of the register
  930. * @param mixed $register_value The value of the register
  931. * @param array $children_array Optionally, an array of children
  932. *
  933. * @return false|\stdClass Depending on success
  934. * @deprecated 1.7 Use {@link add_submenu_item()}
  935. */
  936. function make_register_object($register_name, $register_value, $children_array = array()) {
  937. elgg_deprecated_notice('make_register_object() is deprecated by add_submenu_item()', 1.7);
  938. if (empty($register_name) || empty($register_value)) {
  939. return false;
  940. }
  941. $register = new \stdClass;
  942. $register->name = $register_name;
  943. $register->value = $register_value;
  944. $register->children = $children_array;
  945. return $register;
  946. }
  947. /**
  948. * THIS FUNCTION IS DEPRECATED.
  949. *
  950. * Delete a object's extra data.
  951. *
  952. * @todo - this should be removed - was deprecated in 1.5 or earlier
  953. *
  954. * @param int $guid GUID
  955. *
  956. * @return 1
  957. * @deprecated 1.7
  958. */
  959. function delete_object_entity($guid) {
  960. system_message(elgg_echo('deprecatedfunction', array('delete_user_entity')));
  961. return 1; // Always return that we have deleted one row in order to not break existing code.
  962. }
  963. /**
  964. * THIS FUNCTION IS DEPRECATED.
  965. *
  966. * Delete a user's extra data.
  967. *
  968. * @todo remove
  969. *
  970. * @param int $guid User GUID
  971. *
  972. * @return 1
  973. * @deprecated 1.7
  974. */
  975. function delete_user_entity($guid) {
  976. system_message(elgg_echo('deprecatedfunction', array('delete_user_entity')));
  977. return 1; // Always return that we have deleted one row in order to not break existing code.
  978. }