Elgg  Version 2.2
 All Classes Namespaces Files Functions Variables Pages
deprecated-1.9.php
Go to the documentation of this file.
1 <?php
2 
11 function full_url() {
12  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use current_page_url()', 1.9);
13  $request = _elgg_services()->request;
14  $url = $request->getSchemeAndHttpHost();
15 
16  // This is here to prevent XSS in poorly written browsers used by 80% of the population.
17  // svn commit [5813]: https://github.com/Elgg/Elgg/commit/0c947e80f512cb0a482b1864fd0a6965c8a0cd4a
18  // @todo encoding like this should occur when inserting into web page, not here
19  $quotes = array('\'', '"');
20  $encoded = array('%27', '%22');
21  return $url . str_replace($quotes, $encoded, $request->getRequestUri());
22 }
23 
37 function elgg_register_entity_url_handler($entity_type, $entity_subtype, $function_name) {
38  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use the plugin hook in \ElggEntity::getURL()', 1.9);
39  global $CONFIG;
40 
41  if (!is_callable($function_name, true)) {
42  return false;
43  }
44 
45  if (!isset($CONFIG->entity_url_handler)) {
46  $CONFIG->entity_url_handler = array();
47  }
48 
49  if (!isset($CONFIG->entity_url_handler[$entity_type])) {
50  $CONFIG->entity_url_handler[$entity_type] = array();
51  }
52 
53  $CONFIG->entity_url_handler[$entity_type][$entity_subtype] = $function_name;
54 
55  return true;
56 }
57 
67 function elgg_register_relationship_url_handler($relationship_type, $function_name) {
68  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use the plugin hook in getURL()', 1.9);
69  global $CONFIG;
70 
71  if (!is_callable($function_name, true)) {
72  return false;
73  }
74 
75  if (!isset($CONFIG->relationship_url_handler)) {
76  $CONFIG->relationship_url_handler = array();
77  }
78 
79  $CONFIG->relationship_url_handler[$relationship_type] = $function_name;
80 
81  return true;
82 }
83 
93  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use \ElggRelationship::getURL()', 1.9);
94  global $CONFIG;
95 
96  $id = (int)$id;
97 
98  if ($relationship = get_relationship($id)) {
100 
101  $guid = $relationship->guid_one;
102  $type = $relationship->relationship;
103 
104  $url = "";
105 
106  $function = "";
107  if (isset($CONFIG->relationship_url_handler[$type])) {
108  $function = $CONFIG->relationship_url_handler[$type];
109  }
110  if (isset($CONFIG->relationship_url_handler['all'])) {
111  $function = $CONFIG->relationship_url_handler['all'];
112  }
113 
114  if (is_callable($function)) {
115  $url = call_user_func($function, $relationship);
116  }
117 
118  if ($url == "") {
119  $nameid = $relationship->id;
120 
121  $url = elgg_get_site_url() . "export/$view/$guid/relationship/$nameid/";
122  }
123 
124  return $url;
125  }
126 
127  return false;
128 }
129 
142 function elgg_register_extender_url_handler($extender_type, $extender_name, $function_name) {
143  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use the plugin hook in getURL()', 1.9, 2);
144 
145  global $CONFIG;
146 
147  if (!is_callable($function_name, true)) {
148  return false;
149  }
150 
151  if (!isset($CONFIG->extender_url_handler)) {
152  $CONFIG->extender_url_handler = array();
153  }
154  if (!isset($CONFIG->extender_url_handler[$extender_type])) {
155  $CONFIG->extender_url_handler[$extender_type] = array();
156  }
157  $CONFIG->extender_url_handler[$extender_type][$extender_name] = $function_name;
158 
159  return true;
160 }
161 
171 function get_extender_url(\ElggExtender $extender) {
172  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use \ElggExtender::getURL()', 1.9);
173  global $CONFIG;
174 
176 
177  $guid = $extender->entity_guid;
178  $type = $extender->type;
179 
180  $url = "";
181 
182  $function = "";
183  if (isset($CONFIG->extender_url_handler[$type][$extender->name])) {
184  $function = $CONFIG->extender_url_handler[$type][$extender->name];
185  }
186 
187  if (isset($CONFIG->extender_url_handler[$type]['all'])) {
188  $function = $CONFIG->extender_url_handler[$type]['all'];
189  }
190 
191  if (isset($CONFIG->extender_url_handler['all']['all'])) {
192  $function = $CONFIG->extender_url_handler['all']['all'];
193  }
194 
195  if (is_callable($function)) {
196  $url = call_user_func($function, $extender);
197  }
198 
199  if ($url == "") {
200  $nameid = $extender->id;
201  if ($type == 'volatile') {
202  $nameid = $extender->name;
203  }
204  $url = "export/$view/$guid/$type/$nameid/";
205  }
206 
207  return elgg_normalize_url($url);
208 }
209 
219  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use \ElggAnnotation::getURL()', 1.9);
220  $id = (int)$id;
221 
222  if ($extender = elgg_get_annotation_from_id($id)) {
223  return get_extender_url($extender);
224  }
225  return false;
226 }
227 
237 function elgg_register_metadata_url_handler($extender_name, $function) {
238  // deprecation notice comes from elgg_register_extender_url_handler()
239  return elgg_register_extender_url_handler('metadata', $extender_name, $function);
240 }
241 
251 function elgg_register_annotation_url_handler($extender_name = "all", $function_name) {
252  // deprecation notice comes from elgg_register_extender_url_handler()
253  return elgg_register_extender_url_handler('annotation', $extender_name, $function_name);
254 }
255 
268 function get_group_members($group_guid, $limit = 10, $offset = 0, $site_guid = 0, $count = false) {
269  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use \ElggGroup::getMembers()', 1.9);
270 
271  // in 1.7 0 means "not set." rewrite to make sense.
272  if (!$site_guid) {
273  $site_guid = ELGG_ENTITIES_ANY_VALUE;
274  }
275 
277  'relationship' => 'member',
278  'relationship_guid' => $group_guid,
279  'inverse_relationship' => true,
280  'type' => 'user',
281  'limit' => $limit,
282  'offset' => $offset,
283  'count' => $count,
284  'site_guid' => $site_guid
285  ));
286 }
287 
298 function add_object_to_group($group_guid, $object_guid) {
299  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use \ElggGroup::addObjectToGroup()', 1.9);
300  $group_guid = (int)$group_guid;
301  $object_guid = (int)$object_guid;
302 
303  $group = get_entity($group_guid);
304  $object = get_entity($object_guid);
305 
306  if ((!$group) || (!$object)) {
307  return false;
308  }
309 
310  if (!($group instanceof \ElggGroup)) {
311  $msg = "GUID:" . $group_guid . " is not a valid " . '\ElggGroup';
312  throw new \InvalidClassException($msg);
313  }
314 
315  if (!($object instanceof \ElggObject)) {
316  $msg = "GUID:" . $object_guid . " is not a valid " . '\ElggObject';
317  throw new \InvalidClassException($msg);
318  }
319 
320  $object->container_guid = $group_guid;
321  return $object->save();
322 }
323 
334 function remove_object_from_group($group_guid, $object_guid) {
335  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use \ElggGroup::removeObjectFromGroup()', 1.9);
336  $group_guid = (int)$group_guid;
337  $object_guid = (int)$object_guid;
338 
339  $group = get_entity($group_guid);
340  $object = get_entity($object_guid);
341 
342  if ((!$group) || (!$object)) {
343  return false;
344  }
345 
346  if (!($group instanceof \ElggGroup)) {
347  $msg = "GUID:" . $group_guid . " is not a valid " . '\ElggGroup';
348  throw new \InvalidClassException($msg);
349  }
350 
351  if (!($object instanceof \ElggObject)) {
352  $msg = "GUID:" . $object_guid . " is not a valid " . '\ElggObject';
353  throw new \InvalidClassException($msg);
354  }
355 
356  $object->container_guid = $object->owner_guid;
357  return $object->save();
358 }
359 
369 function is_group_member($group_guid, $user_guid) {
370  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use \ElggGroup::isMember()', 1.9);
371  $object = check_entity_relationship($user_guid, 'member', $group_guid);
372  if ($object) {
373  return true;
374  } else {
375  return false;
376  }
377 }
378 
379 
389  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use \ElggUser::getGroups()', 1.9);
390  $options = array(
391  'type' => 'group',
392  'relationship' => 'member',
393  'relationship_guid' => $user_guid,
394  'inverse_relationship' => false,
395  'limit' => false,
396  );
398 }
399 
410  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use \ElggUser::isFriendsOf() or \ElggUser::isFriendsWith()', 1.9);
411  return check_entity_relationship($user_guid, "friend", $friend_guid) !== false;
412 }
413 
426 $offset = 0) {
427  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use \ElggUser::getFriends()', 1.9);
428 
430  'relationship' => 'friend',
431  'relationship_guid' => $user_guid,
432  'type' => 'user',
433  'subtype' => $subtype,
434  'limit' => $limit,
435  'offset' => $offset
436  ));
437 }
438 
451 $offset = 0) {
452  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use \ElggUser::getFriendsOf()', 1.9);
453 
455  'relationship' => 'friend',
456  'relationship_guid' => $user_guid,
457  'inverse_relationship' => true,
458  'type' => 'user',
459  'subtype' => $subtype,
460  'limit' => $limit,
461  'offset' => $offset
462  ));
463 }
464 
475  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use \ElggUser::addFriend()', 1.9);
476  $user_guid = (int) $user_guid;
477  $friend_guid = (int) $friend_guid;
478  if ($user_guid == $friend_guid) {
479  return false;
480  }
481  if (!$friend = get_entity($friend_guid)) {
482  return false;
483  }
484  if (!$user = get_entity($user_guid)) {
485  return false;
486  }
487  if ((!($user instanceof \ElggUser)) || (!($friend instanceof \ElggUser))) {
488  return false;
489  }
491 }
492 
503  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use \ElggUser::removeFriend()', 1.9);
504  $user_guid = (int) $user_guid;
505  $friend_guid = (int) $friend_guid;
506 
507  // perform cleanup for access lists.
508  $collections = get_user_access_collections($user_guid);
509  if ($collections) {
510  foreach ($collections as $collection) {
512  }
513  }
514 
516 }
517 
527 function add_site_user($site_guid, $user_guid) {
528  elgg_deprecated_notice('add_site_user() is deprecated. Use \ElggEntity::addEntity()', 1.9);
529  $site_guid = (int)$site_guid;
530  $user_guid = (int)$user_guid;
531 
532  return add_entity_relationship($user_guid, "member_of_site", $site_guid);
533 }
534 
544 function remove_site_user($site_guid, $user_guid) {
545  elgg_deprecated_notice('remove_site_user() is deprecated. Use \ElggEntity::removeEntity()', 1.9);
546  $site_guid = (int)$site_guid;
547  $user_guid = (int)$user_guid;
548 
549  return remove_entity_relationship($user_guid, "member_of_site", $site_guid);
550 }
551 
561 function add_site_object($site_guid, $object_guid) {
562  elgg_deprecated_notice('add_site_object() is deprecated. Use \ElggEntity::addEntity()', 1.9);
563  $site_guid = (int)$site_guid;
564  $object_guid = (int)$object_guid;
565 
566  return add_entity_relationship($object_guid, "member_of_site", $site_guid);
567 }
568 
578 function remove_site_object($site_guid, $object_guid) {
579  elgg_deprecated_notice('remove_site_object() is deprecated. Use \ElggEntity::removeEntity()', 1.9);
580  $site_guid = (int)$site_guid;
581  $object_guid = (int)$object_guid;
582 
583  return remove_entity_relationship($object_guid, "member_of_site", $site_guid);
584 }
585 
597 function get_site_objects($site_guid, $subtype = "", $limit = 10, $offset = 0) {
598  elgg_deprecated_notice('get_site_objects() is deprecated. Use \ElggSite::getEntities()', 1.9);
599  $site_guid = (int)$site_guid;
600  $limit = (int)$limit;
601  $offset = (int)$offset;
602 
604  'relationship' => 'member_of_site',
605  'relationship_guid' => $site_guid,
606  'inverse_relationship' => true,
607  'type' => 'object',
608  'subtype' => $subtype,
609  'limit' => $limit,
610  'offset' => $offset
611  ));
612 }
613 
624 function get_object_sites($object_guid, $limit = 10, $offset = 0) {
625  elgg_deprecated_notice('get_object_sites() is deprecated. Use \ElggEntity::getSites()', 1.9);
626  $object_guid = (int)$object_guid;
627  $limit = (int)$limit;
628  $offset = (int)$offset;
629 
631  'relationship' => 'member_of_site',
632  'relationship_guid' => $object_guid,
633  'type' => 'site',
634  'limit' => $limit,
635  'offset' => $offset,
636  ));
637 }
638 
649 function get_user_sites($user_guid, $limit = 10, $offset = 0) {
650  elgg_deprecated_notice('get_user_sites() is deprecated. Use \ElggEntity::getSites()', 1.9);
651  $user_guid = (int)$user_guid;
652  $limit = (int)$limit;
653  $offset = (int)$offset;
654 
656  'site_guids' => ELGG_ENTITIES_ANY_VALUE,
657  'relationship' => 'member_of_site',
658  'relationship_guid' => $user_guid,
659  'inverse_relationship' => false,
660  'type' => 'site',
661  'limit' => $limit,
662  'offset' => $offset,
663  ));
664 }
665 
676 function can_edit_extender($extender_id, $type, $user_guid = 0) {
677  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use \ElggExtender::canEdit()', 1.9);
678 
679  // Since Elgg 1.0, Elgg has returned false from can_edit_extender()
680  // if no user was logged in. This breaks the access override so we add this
681  // special check here.
683  if (!elgg_is_logged_in()) {
684  return false;
685  }
686  }
687 
688  $user_guid = (int)$user_guid;
690  if (!$user) {
693  }
694 
695  $functionname = "elgg_get_{$type}_from_id";
696  if (is_callable($functionname)) {
697  $extender = call_user_func($functionname, $extender_id);
698  } else {
699  return false;
700  }
701 
702  if (!($extender instanceof \ElggExtender)) {
703  return false;
704  }
705  /* @var \ElggExtender $extender */
706 
707  // If the owner is the specified user, great! They can edit.
708  if ($extender->getOwnerGUID() == $user_guid) {
709  return true;
710  }
711 
712  // If the user can edit the entity this is attached to, great! They can edit.
713  $entity = $extender->getEntity();
714  if ($entity->canEdit($user_guid)) {
715  return true;
716  }
717 
718  // Trigger plugin hook - note that $user may be null
719  $params = array('entity' => $entity, 'user' => $user);
720  return elgg_trigger_plugin_hook('permissions_check', $type, $params, false);
721 }
722 
736 function calculate_tag_size($min, $max, $number_of_tags, $buckets = 6) {
737  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated', 1.9);
738  $delta = (($max - $min) / $buckets);
739  $thresholds = array();
740 
741  for ($n = 1; $n <= $buckets; $n++) {
742  $thresholds[$n - 1] = ($min + $n) * $delta;
743  }
744 
745  // Correction
746  if ($thresholds[$buckets - 1] > $max) {
747  $thresholds[$buckets - 1] = $max;
748  }
749 
750  $size = 0;
751  for ($n = 0; $n < count($thresholds); $n++) {
752  if ($number_of_tags >= $thresholds[$n]) {
753  $size = $n;
754  }
755  }
756 
757  return $size;
758 }
759 
770 function generate_tag_cloud(array $tags, $buckets = 6) {
771  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated', 1.9);
772  $cloud = array();
773 
774  $min = 65535;
775  $max = 0;
776 
777  foreach ($tags as $tag) {
778  $cloud[$tag]++;
779 
780  if ($cloud[$tag] > $max) {
781  $max = $cloud[$tag];
782  }
783 
784  if ($cloud[$tag] < $min) {
785  $min = $cloud[$tag];
786  }
787  }
788 
789  foreach ($cloud as $k => $v) {
790  $cloud[$k] = calculate_tag_size($min, $max, $v, $buckets);
791  }
792 
793  return $cloud;
794 }
795 
805  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated', 1.9);
807 }
808 
811 
822 function get_metastring_id($string, $case_sensitive = TRUE) {
823  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use elgg_get_metastring_id()', 1.9);
824  global $CONFIG, $METASTRINGS_CACHE, $METASTRINGS_DEADNAME_CACHE;
825 
827 
828  // caching doesn't work for case insensitive searches
829  if ($case_sensitive) {
830  $result = array_search($string, $METASTRINGS_CACHE, true);
831 
832  if ($result !== false) {
833  return $result;
834  }
835 
836  // See if we have previously looked for this and found nothing
837  if (in_array($string, $METASTRINGS_DEADNAME_CACHE, true)) {
838  return false;
839  }
840 
841  // Experimental memcache
842  $msfc = null;
843  static $metastrings_memcache;
844  if ((!$metastrings_memcache) && (is_memcache_available())) {
845  $metastrings_memcache = new \ElggMemcache('metastrings_memcache');
846  }
847  if ($metastrings_memcache) {
848  $msfc = $metastrings_memcache->load($string);
849  }
850  if ($msfc) {
851  return $msfc;
852  }
853  }
854 
855  // Case sensitive
856  if ($case_sensitive) {
857  $query = "SELECT * from {$CONFIG->dbprefix}metastrings where string= BINARY '$string' limit 1";
858  } else {
859  $query = "SELECT * from {$CONFIG->dbprefix}metastrings where string = '$string'";
860  }
861 
862  $row = FALSE;
863  $metaStrings = get_data($query);
864  if (is_array($metaStrings)) {
865  if (sizeof($metaStrings) > 1) {
866  $ids = array();
867  foreach ($metaStrings as $metaString) {
868  $ids[] = $metaString->id;
869  }
870  return $ids;
871  } else if (isset($metaStrings[0])) {
872  $row = $metaStrings[0];
873  }
874  }
875 
876  if ($row) {
877  $METASTRINGS_CACHE[$row->id] = $row->string; // Cache it
878 
879  // Attempt to memcache it if memcache is available
880  if ($metastrings_memcache) {
881  $metastrings_memcache->save($row->string, $row->id);
882  }
883 
884  return $row->id;
885  } else {
886  $METASTRINGS_DEADNAME_CACHE[$string] = $string;
887  }
888 
889  return false;
890 }
891 
902 function add_metastring($string, $case_sensitive = true) {
903  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use elgg_get_metastring_id()', 1.9);
904  global $CONFIG, $METASTRINGS_CACHE, $METASTRINGS_DEADNAME_CACHE;
905 
906  $sanstring = sanitise_string($string);
907 
908  $id = get_metastring_id($string, $case_sensitive);
909  if ($id) {
910  return $id;
911  }
912 
913  $result = insert_data("INSERT into {$CONFIG->dbprefix}metastrings (string) values ('$sanstring')");
914  if ($result) {
915  $METASTRINGS_CACHE[$result] = $string;
916  if (isset($METASTRINGS_DEADNAME_CACHE[$string])) {
917  unset($METASTRINGS_DEADNAME_CACHE[$string]);
918  }
919  }
920 
921  return $result;
922 }
923 
932 function get_metastring($id) {
933  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated.', 1.9);
934  global $CONFIG, $METASTRINGS_CACHE;
935 
936  $id = (int) $id;
937 
938  if (isset($METASTRINGS_CACHE[$id])) {
939  return $METASTRINGS_CACHE[$id];
940  }
941 
942  $row = get_data_row("SELECT * from {$CONFIG->dbprefix}metastrings where id='$id' limit 1");
943  if ($row) {
944  $METASTRINGS_CACHE[$id] = $row->string;
945  return $row->string;
946  }
947 
948  return false;
949 }
950 
965  $offset = 0, $timelower = 0, $timeupper = 0) {
966 
967  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use elgg_get_entities_from_relationship()', 1.9);
969  'type' => 'object',
970  'subtype' => $subtype,
971  'limit' => $limit,
972  'offset' => $offset,
973  'created_time_lower' => $timelower,
974  'created_time_upper' => $timeupper,
975  'relationship' => 'friend',
976  'relationship_guid' => $user_guid,
977  'relationship_join_on' => 'container_guid',
978  ));
979 }
980 
993 $timelower = 0, $timeupper = 0) {
994 
995  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use elgg_get_entities_from_relationship()', 1.9);
997  'type' => 'object',
998  'subtype' => $subtype,
999  'created_time_lower' => $timelower,
1000  'created_time_upper' => $timeupper,
1001  'relationship' => 'friend',
1002  'relationship_guid' => $user_guid,
1003  'relationship_join_on' => 'container_guid',
1004  'count' => true,
1005  ));
1006 }
1007 
1026  $listtypetoggle = true, $pagination = true, $timelower = 0, $timeupper = 0) {
1027 
1028  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use elgg_list_entities_from_relationship()', 1.9);
1030  'type' => 'object',
1031  'subtype' => $subtype,
1032  'limit' => $limit,
1033  'created_time_lower' => $timelower,
1034  'created_time_upper' => $timeupper,
1035  'full_view' => $full_view,
1036  'list_type_toggle' => $listtypetoggle,
1037  'pagination' => $pagination,
1038  'relationship' => 'friend',
1039  'relationship_guid' => $user_guid,
1040  'relationship_join_on' => 'container_guid',
1041  ));
1042 }
1043 
1054 function elgg_geocode_location($location) {
1055  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. See geolocation plugin on github', 1.9);
1056  global $CONFIG;
1057 
1058  if (is_array($location)) {
1059  return false;
1060  }
1061 
1062  $location = sanitise_string($location);
1063 
1064  // Look for cached version
1065  $query = "SELECT * from {$CONFIG->dbprefix}geocode_cache WHERE location='$location'";
1066  $cached_location = get_data_row($query);
1067 
1068  if ($cached_location) {
1069  return array('lat' => $cached_location->lat, 'long' => $cached_location->long);
1070  }
1071 
1072  // Trigger geocode event if not cached
1073  $return = false;
1074  $return = elgg_trigger_plugin_hook('geocode', 'location', array('location' => $location), $return);
1075 
1076  // If returned, cache and return value
1077  if (($return) && (is_array($return))) {
1078  $lat = (float)$return['lat'];
1079  $long = (float)$return['long'];
1080 
1081  // Put into cache at the end of the page since we don't really care that much
1082  $query = "INSERT DELAYED INTO {$CONFIG->dbprefix}geocode_cache "
1083  . " (location, lat, `long`) VALUES ('$location', '{$lat}', '{$long}')"
1084  . " ON DUPLICATE KEY UPDATE lat='{$lat}', `long`='{$long}'";
1086  }
1087 
1088  return $return;
1089 }
1090 
1118 function elgg_get_entities_from_location(array $options = array()) {
1119  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. See geolocation plugin on github', 1.9);
1120  global $CONFIG;
1121 
1122  if (!isset($options['latitude']) || !isset($options['longitude']) ||
1123  !isset($options['distance'])) {
1124  return false;
1125  }
1126 
1127  if (!is_array($options['distance'])) {
1128  $lat_distance = (float)$options['distance'];
1129  $long_distance = (float)$options['distance'];
1130  } else {
1131  $lat_distance = (float)$options['distance']['latitude'];
1132  $long_distance = (float)$options['distance']['longitude'];
1133  }
1134 
1135  $lat = (float)$options['latitude'];
1136  $long = (float)$options['longitude'];
1137  $lat_min = $lat - $lat_distance;
1138  $lat_max = $lat + $lat_distance;
1139  $long_min = $long - $long_distance;
1140  $long_max = $long + $long_distance;
1141 
1142  $wheres = array();
1143  $wheres[] = "lat_name.string='geo:lat'";
1144  $wheres[] = "lat_value.string >= $lat_min";
1145  $wheres[] = "lat_value.string <= $lat_max";
1146  $wheres[] = "lon_name.string='geo:long'";
1147  $wheres[] = "lon_value.string >= $long_min";
1148  $wheres[] = "lon_value.string <= $long_max";
1149 
1150  $joins = array();
1151  $joins[] = "JOIN {$CONFIG->dbprefix}metadata lat on e.guid=lat.entity_guid";
1152  $joins[] = "JOIN {$CONFIG->dbprefix}metastrings lat_name on lat.name_id=lat_name.id";
1153  $joins[] = "JOIN {$CONFIG->dbprefix}metastrings lat_value on lat.value_id=lat_value.id";
1154  $joins[] = "JOIN {$CONFIG->dbprefix}metadata lon on e.guid=lon.entity_guid";
1155  $joins[] = "JOIN {$CONFIG->dbprefix}metastrings lon_name on lon.name_id=lon_name.id";
1156  $joins[] = "JOIN {$CONFIG->dbprefix}metastrings lon_value on lon.value_id=lon_value.id";
1157 
1158  // merge wheres to pass to get_entities()
1159  if (isset($options['wheres']) && !is_array($options['wheres'])) {
1160  $options['wheres'] = array($options['wheres']);
1161  } elseif (!isset($options['wheres'])) {
1162  $options['wheres'] = array();
1163  }
1164  $options['wheres'] = array_merge($options['wheres'], $wheres);
1165 
1166  // merge joins to pass to get_entities()
1167  if (isset($options['joins']) && !is_array($options['joins'])) {
1168  $options['joins'] = array($options['joins']);
1169  } elseif (!isset($options['joins'])) {
1170  $options['joins'] = array();
1171  }
1172  $options['joins'] = array_merge($options['joins'], $joins);
1173 
1175 }
1176 
1189 function elgg_list_entities_from_location(array $options = array()) {
1190  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. See geolocation plugin on github', 1.9);
1191  return elgg_list_entities($options, 'elgg_get_entities_from_location');
1192 }
1193 
1194 // Some distances in degrees (approximate)
1195 // @todo huh? see warning on elgg_get_entities_from_location()
1196 // @deprecated 1.9.0
1197 define("MILE", 0.01515);
1198 define("KILOMETER", 0.00932);
1199 
1208 function get_version($humanreadable = false) {
1209  elgg_deprecated_notice('get_version() has been deprecated by elgg_get_version()', 1.9);
1210  return elgg_get_version($humanreadable);
1211 }
1212 
1222 function sanitise_string_special($string, $extra_escapeable = '') {
1223  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated.', 1.9);
1225 
1226  for ($n = 0; $n < strlen($extra_escapeable); $n++) {
1227  $string = str_replace($extra_escapeable[$n], "\\" . $extra_escapeable[$n], $string);
1228  }
1229 
1230  return $string;
1231 }
1232 
1244  elgg_deprecated_notice(__FUNCTION__ . ' is a private function and should not be used.', 1.9);
1245  _elgg_services()->db->setupConnections();
1246 }
1247 
1260  elgg_deprecated_notice(__FUNCTION__ . ' is a private function and should not be used.', 1.9);
1262  return _elgg_services()->db->updateData("OPTIMIZE TABLE $table");
1263 }
1264 
1274 function get_db_tables() {
1275  elgg_deprecated_notice(__FUNCTION__ . ' is a private function and should not be used.', 1.9);
1276  static $tables;
1277 
1278  if (isset($tables)) {
1279  return $tables;
1280  }
1281 
1282  $table_prefix = elgg_get_config('dbprefix');
1283  $result = get_data("SHOW TABLES LIKE '$table_prefix%'");
1284 
1285  $tables = array();
1286  if (is_array($result) && !empty($result)) {
1287  foreach ($result as $row) {
1288  $row = (array) $row;
1289  if (is_array($row) && !empty($row)) {
1290  foreach ($row as $element) {
1291  $tables[] = $element;
1292  }
1293  }
1294  }
1295  }
1296 
1297  return $tables;
1298 }
1299 
1311 function get_day_start($day = null, $month = null, $year = null) {
1312  elgg_deprecated_notice('get_day_start() has been deprecated', 1.9);
1313  return mktime(0, 0, 0, $month, $day, $year);
1314 }
1315 
1327 function get_day_end($day = null, $month = null, $year = null) {
1328  elgg_deprecated_notice('get_day_end() has been deprecated', 1.9);
1329  return mktime(23, 59, 59, $month, $day, $year);
1330 }
1331 
1353 function get_notable_entities($start_time, $end_time, $type = "", $subtype = "", $owner_guid = 0,
1354 $order_by = "asc", $limit = 10, $offset = 0, $count = false, $site_guid = 0,
1355 $container_guid = null) {
1356  elgg_deprecated_notice('get_notable_entities() has been deprecated', 1.9);
1357  global $CONFIG;
1358 
1359  if ($subtype === false || $subtype === null || $subtype === 0) {
1360  return false;
1361  }
1362 
1363  $start_time = (int)$start_time;
1364  $end_time = (int)$end_time;
1365  $order_by = sanitise_string($order_by);
1366  $limit = (int)$limit;
1367  $offset = (int)$offset;
1368  $site_guid = (int) $site_guid;
1369  if ($site_guid == 0) {
1370  $site_guid = $CONFIG->site_guid;
1371  }
1372 
1373  $where = array();
1374 
1375  if (is_array($type)) {
1376  $tempwhere = "";
1377  if (sizeof($type)) {
1378  foreach ($type as $typekey => $subtypearray) {
1379  foreach ($subtypearray as $subtypeval) {
1380  $typekey = sanitise_string($typekey);
1381  if (!empty($subtypeval)) {
1382  $subtypeval = (int) get_subtype_id($typekey, $subtypeval);
1383  } else {
1384  $subtypeval = 0;
1385  }
1386  if (!empty($tempwhere)) {
1387  $tempwhere .= " or ";
1388  }
1389  $tempwhere .= "(e.type = '{$typekey}' and e.subtype = {$subtypeval})";
1390  }
1391  }
1392  }
1393  if (!empty($tempwhere)) {
1394  $where[] = "({$tempwhere})";
1395  }
1396  } else {
1399 
1400  if ($type != "") {
1401  $where[] = "e.type='$type'";
1402  }
1403 
1404  if ($subtype !== "") {
1405  $where[] = "e.subtype=$subtype";
1406  }
1407  }
1408 
1409  if ($owner_guid != "") {
1410  if (!is_array($owner_guid)) {
1411  $owner_array = array($owner_guid);
1412  $owner_guid = (int) $owner_guid;
1413  $where[] = "e.owner_guid = '$owner_guid'";
1414  } else if (sizeof($owner_guid) > 0) {
1415  $owner_array = array_map('sanitise_int', $owner_guid);
1416  // Cast every element to the owner_guid array to int
1417  $owner_guid = implode(",", $owner_guid);
1418  $where[] = "e.owner_guid in ({$owner_guid})";
1419  }
1420  if (is_null($container_guid)) {
1421  $container_guid = $owner_array;
1422  }
1423  }
1424 
1425  if ($site_guid > 0) {
1426  $where[] = "e.site_guid = {$site_guid}";
1427  }
1428 
1429  if (!is_null($container_guid)) {
1430  if (is_array($container_guid)) {
1431  foreach ($container_guid as $key => $val) {
1432  $container_guid[$key] = (int) $val;
1433  }
1434  $where[] = "e.container_guid in (" . implode(",", $container_guid) . ")";
1435  } else {
1437  $where[] = "e.container_guid = {$container_guid}";
1438  }
1439  }
1440 
1441  // Add the calendar stuff
1442  $cal_join = "
1443  JOIN {$CONFIG->dbprefix}metadata cal_start on e.guid=cal_start.entity_guid
1444  JOIN {$CONFIG->dbprefix}metastrings cal_start_name on cal_start.name_id=cal_start_name.id
1445  JOIN {$CONFIG->dbprefix}metastrings cal_start_value on cal_start.value_id=cal_start_value.id
1446 
1447  JOIN {$CONFIG->dbprefix}metadata cal_end on e.guid=cal_end.entity_guid
1448  JOIN {$CONFIG->dbprefix}metastrings cal_end_name on cal_end.name_id=cal_end_name.id
1449  JOIN {$CONFIG->dbprefix}metastrings cal_end_value on cal_end.value_id=cal_end_value.id
1450  ";
1451  $where[] = "cal_start_name.string='calendar_start'";
1452  $where[] = "cal_start_value.string>=$start_time";
1453  $where[] = "cal_end_name.string='calendar_end'";
1454  $where[] = "cal_end_value.string <= $end_time";
1455 
1456 
1457  if (!$count) {
1458  $query = "SELECT e.* from {$CONFIG->dbprefix}entities e $cal_join where ";
1459  } else {
1460  $query = "SELECT count(e.guid) as total from {$CONFIG->dbprefix}entities e $cal_join where ";
1461  }
1462  foreach ($where as $w) {
1463  $query .= " $w and ";
1464  }
1465 
1466  $query .= _elgg_get_access_where_sql();
1467 
1468  if (!$count) {
1469  $query .= " order by n.calendar_start $order_by";
1470  // Add order and limit
1471  if ($limit) {
1472  $query .= " limit $offset, $limit";
1473  }
1474  $dt = get_data($query, "entity_row_to_elggstar");
1475 
1476  return $dt;
1477  } else {
1478  $total = get_data_row($query);
1479  return $total->total;
1480  }
1481 }
1482 
1503 function get_notable_entities_from_metadata($start_time, $end_time, $meta_name, $meta_value = "",
1504 $entity_type = "", $entity_subtype = "", $owner_guid = 0, $limit = 10, $offset = 0, $order_by = "",
1505 $site_guid = 0, $count = false) {
1506  elgg_deprecated_notice('get_notable_entities_from_metadata() has been deprecated', 1.9);
1507 
1508  global $CONFIG;
1509 
1510  $meta_n = get_metastring_id($meta_name);
1511  $meta_v = get_metastring_id($meta_value);
1512 
1513  $start_time = (int)$start_time;
1514  $end_time = (int)$end_time;
1515  $entity_type = sanitise_string($entity_type);
1516  $entity_subtype = get_subtype_id($entity_type, $entity_subtype);
1517  $limit = (int)$limit;
1518  $offset = (int)$offset;
1519  if ($order_by == "") {
1520  $order_by = "e.time_created desc";
1521  }
1522  $order_by = sanitise_string($order_by);
1523  $site_guid = (int) $site_guid;
1524  if ((is_array($owner_guid) && (count($owner_guid)))) {
1525  foreach ($owner_guid as $key => $guid) {
1526  $owner_guid[$key] = (int) $guid;
1527  }
1528  } else {
1529  $owner_guid = (int) $owner_guid;
1530  }
1531 
1532  if ($site_guid == 0) {
1533  $site_guid = $CONFIG->site_guid;
1534  }
1535 
1536  //$access = get_access_list();
1537 
1538  $where = array();
1539 
1540  if ($entity_type != "") {
1541  $where[] = "e.type='$entity_type'";
1542  }
1543 
1544  if ($entity_subtype) {
1545  $where[] = "e.subtype=$entity_subtype";
1546  }
1547 
1548  if ($meta_name != "") {
1549  $where[] = "m.name_id='$meta_n'";
1550  }
1551 
1552  if ($meta_value != "") {
1553  $where[] = "m.value_id='$meta_v'";
1554  }
1555 
1556  if ($site_guid > 0) {
1557  $where[] = "e.site_guid = {$site_guid}";
1558  }
1559 
1560  if (is_array($owner_guid)) {
1561  $where[] = "e.container_guid in (" . implode(",", $owner_guid) . ")";
1562  } else if ($owner_guid > 0) {
1563  $where[] = "e.container_guid = {$owner_guid}";
1564  }
1565 
1566  // Add the calendar stuff
1567  $cal_join = "
1568  JOIN {$CONFIG->dbprefix}metadata cal_start on e.guid=cal_start.entity_guid
1569  JOIN {$CONFIG->dbprefix}metastrings cal_start_name on cal_start.name_id=cal_start_name.id
1570  JOIN {$CONFIG->dbprefix}metastrings cal_start_value on cal_start.value_id=cal_start_value.id
1571 
1572  JOIN {$CONFIG->dbprefix}metadata cal_end on e.guid=cal_end.entity_guid
1573  JOIN {$CONFIG->dbprefix}metastrings cal_end_name on cal_end.name_id=cal_end_name.id
1574  JOIN {$CONFIG->dbprefix}metastrings cal_end_value on cal_end.value_id=cal_end_value.id
1575  ";
1576 
1577  $where[] = "cal_start_name.string='calendar_start'";
1578  $where[] = "cal_start_value.string>=$start_time";
1579  $where[] = "cal_end_name.string='calendar_end'";
1580  $where[] = "cal_end_value.string <= $end_time";
1581 
1582  if (!$count) {
1583  $query = "SELECT distinct e.* ";
1584  } else {
1585  $query = "SELECT count(distinct e.guid) as total ";
1586  }
1587 
1588  $query .= "from {$CONFIG->dbprefix}entities e"
1589  . " JOIN {$CONFIG->dbprefix}metadata m on e.guid = m.entity_guid $cal_join where";
1590 
1591  foreach ($where as $w) {
1592  $query .= " $w and ";
1593  }
1594 
1595  // Add access controls
1596  $query .= _elgg_get_access_where_sql(array('table_alias' => 'e'));
1597  $query .= ' and ' . _elgg_get_access_where_sql(array('table_alias' => "m"));
1598 
1599  if (!$count) {
1600  // Add order and limit
1601  $query .= " order by $order_by limit $offset, $limit";
1602  return get_data($query, "entity_row_to_elggstar");
1603  } else {
1604  if ($row = get_data_row($query)) {
1605  return $row->total;
1606  }
1607  }
1608 
1609  return false;
1610 }
1611 
1635 function get_noteable_entities_from_relationship($start_time, $end_time, $relationship,
1636 $relationship_guid, $inverse_relationship = false, $type = "", $subtype = "", $owner_guid = 0,
1637 $order_by = "", $limit = 10, $offset = 0, $count = false, $site_guid = 0) {
1638  elgg_deprecated_notice('get_noteable_entities_from_relationship() has been deprecated', 1.9);
1639 
1640  global $CONFIG;
1641 
1642  $start_time = (int)$start_time;
1643  $end_time = (int)$end_time;
1644  $relationship = sanitise_string($relationship);
1645  $relationship_guid = (int)$relationship_guid;
1646  $inverse_relationship = (bool)$inverse_relationship;
1649  $owner_guid = (int)$owner_guid;
1650  if ($order_by == "") {
1651  $order_by = "time_created desc";
1652  }
1653  $order_by = sanitise_string($order_by);
1654  $limit = (int)$limit;
1655  $offset = (int)$offset;
1656  $site_guid = (int) $site_guid;
1657  if ($site_guid == 0) {
1658  $site_guid = $CONFIG->site_guid;
1659  }
1660 
1661  //$access = get_access_list();
1662 
1663  $where = array();
1664 
1665  if ($relationship != "") {
1666  $where[] = "r.relationship='$relationship'";
1667  }
1668  if ($relationship_guid) {
1669  $where[] = $inverse_relationship ?
1670  "r.guid_two='$relationship_guid'" : "r.guid_one='$relationship_guid'";
1671  }
1672  if ($type != "") {
1673  $where[] = "e.type='$type'";
1674  }
1675  if ($subtype) {
1676  $where[] = "e.subtype=$subtype";
1677  }
1678  if ($owner_guid != "") {
1679  $where[] = "e.container_guid='$owner_guid'";
1680  }
1681  if ($site_guid > 0) {
1682  $where[] = "e.site_guid = {$site_guid}";
1683  }
1684 
1685  // Add the calendar stuff
1686  $cal_join = "
1687  JOIN {$CONFIG->dbprefix}metadata cal_start on e.guid=cal_start.entity_guid
1688  JOIN {$CONFIG->dbprefix}metastrings cal_start_name on cal_start.name_id=cal_start_name.id
1689  JOIN {$CONFIG->dbprefix}metastrings cal_start_value on cal_start.value_id=cal_start_value.id
1690 
1691  JOIN {$CONFIG->dbprefix}metadata cal_end on e.guid=cal_end.entity_guid
1692  JOIN {$CONFIG->dbprefix}metastrings cal_end_name on cal_end.name_id=cal_end_name.id
1693  JOIN {$CONFIG->dbprefix}metastrings cal_end_value on cal_end.value_id=cal_end_value.id
1694  ";
1695  $where[] = "cal_start_name.string='calendar_start'";
1696  $where[] = "cal_start_value.string>=$start_time";
1697  $where[] = "cal_end_name.string='calendar_end'";
1698  $where[] = "cal_end_value.string <= $end_time";
1699 
1700  // Select what we're joining based on the options
1701  $joinon = "e.guid = r.guid_one";
1702  if (!$inverse_relationship) {
1703  $joinon = "e.guid = r.guid_two";
1704  }
1705 
1706  if ($count) {
1707  $query = "SELECT count(distinct e.guid) as total ";
1708  } else {
1709  $query = "SELECT distinct e.* ";
1710  }
1711  $query .= " from {$CONFIG->dbprefix}entity_relationships r"
1712  . " JOIN {$CONFIG->dbprefix}entities e on $joinon $cal_join where ";
1713 
1714  foreach ($where as $w) {
1715  $query .= " $w and ";
1716  }
1717  // Add access controls
1718  $query .= _elgg_get_access_where_sql();
1719  if (!$count) {
1720  $query .= " order by $order_by limit $offset, $limit"; // Add order and limit
1721  return get_data($query, "entity_row_to_elggstar");
1722  } else {
1723  if ($count = get_data_row($query)) {
1724  return $count->total;
1725  }
1726  }
1727  return false;
1728 }
1729 
1747 function get_todays_entities($type = "", $subtype = "", $owner_guid = 0, $order_by = "",
1748 $limit = 10, $offset = 0, $count = false, $site_guid = 0, $container_guid = null) {
1749  elgg_deprecated_notice('get_todays_entities() has been deprecated', 1.9);
1750 
1751  $day_start = get_day_start();
1752  $day_end = get_day_end();
1753 
1754  return get_notable_entities($day_start, $day_end, $type, $subtype, $owner_guid, $order_by,
1755  $limit, $offset, $count, $site_guid, $container_guid);
1756 }
1757 
1776 function get_todays_entities_from_metadata($meta_name, $meta_value = "", $entity_type = "",
1777 $entity_subtype = "", $owner_guid = 0, $limit = 10, $offset = 0, $order_by = "", $site_guid = 0,
1778 $count = false) {
1779  elgg_deprecated_notice('get_todays_entities_from_metadata() has been deprecated', 1.9);
1780 
1781  $day_start = get_day_start();
1782  $day_end = get_day_end();
1783 
1784  return get_notable_entities_from_metadata($day_start, $day_end, $meta_name, $meta_value,
1785  $entity_type, $entity_subtype, $owner_guid, $limit, $offset, $order_by, $site_guid, $count);
1786 }
1787 
1809 function get_todays_entities_from_relationship($relationship, $relationship_guid,
1810 $inverse_relationship = false, $type = "", $subtype = "", $owner_guid = 0,
1811 $order_by = "", $limit = 10, $offset = 0, $count = false, $site_guid = 0) {
1812  elgg_deprecated_notice('get_todays_entities_from_relationship() has been deprecated', 1.9);
1813 
1814  $day_start = get_day_start();
1815  $day_end = get_day_end();
1816 
1817  return get_notable_entities_from_relationship($day_start, $day_end, $relationship,
1818  $relationship_guid, $inverse_relationship, $type, $subtype, $owner_guid, $order_by,
1819  $limit, $offset, $count, $site_guid);
1820 }
1821 
1841 function list_notable_entities($start_time, $end_time, $type= "", $subtype = "", $owner_guid = 0,
1842 $limit = 10, $fullview = true, $listtypetoggle = false, $navigation = true) {
1843  elgg_deprecated_notice('list_notable_entities() has been deprecated', 1.9);
1844 
1845  $offset = (int) get_input('offset');
1846  $count = get_notable_entities($start_time, $end_time, $type, $subtype,
1847  $owner_guid, "", $limit, $offset, true);
1848 
1849  $entities = get_notable_entities($start_time, $end_time, $type, $subtype,
1850  $owner_guid, "", $limit, $offset);
1851 
1852  return elgg_view_entity_list($entities, $count, $offset, $limit,
1853  $fullview, $listtypetoggle, $navigation);
1854 }
1855 
1873 function list_todays_entities($type= "", $subtype = "", $owner_guid = 0, $limit = 10,
1874 $fullview = true, $listtypetoggle = false, $navigation = true) {
1875  elgg_deprecated_notice('list_todays_entities() has been deprecated', 1.9);
1876 
1877  $day_start = get_day_start();
1878  $day_end = get_day_end();
1879 
1880  return list_notable_entities($day_start, $day_end, $type, $subtype, $owner_guid, $limit,
1881  $fullview, $listtypetoggle, $navigation);
1882 }
1883 
1897 function elgg_regenerate_simplecache($viewtype = NULL) {
1898  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated by elgg_invalidate_simplecache()', 1.9);
1900 }
1901 
1907  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated by elgg_get_system_cache()', 1.9);
1908  return elgg_get_system_cache();
1909 }
1915  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated by elgg_reset_system_cache()', 1.9);
1917 }
1923  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated by elgg_save_system_cache()', 1.9);
1925 }
1931  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated by elgg_load_system_cache()', 1.9);
1932  return elgg_load_system_cache($type);
1933 }
1939  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated by elgg_enable_system_cache()', 1.9);
1941 }
1947  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated by elgg_disable_system_cache()', 1.9);
1949 }
1950 
1964  elgg_deprecated_notice("unregister_entity_type() was deprecated by elgg_unregister_entity_type()", 1.9);
1966 }
1967 
1978 function already_attached($guid_one, $guid_two) {
1979  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated', 1.9);
1980  if ($attached = check_entity_relationship($guid_one, "attached", $guid_two)) {
1981  return true;
1982  } else {
1983  return false;
1984  }
1985 }
1986 
1997 function get_attachments($guid, $type = "") {
1998  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated', 1.9);
1999  $options = array(
2000  'relationship' => 'attached',
2001  'relationship_guid' => $guid,
2002  'inverse_relationship' => false,
2003  'types' => $type,
2004  'subtypes' => '',
2005  'owner_guid' => 0,
2006  'order_by' => 'time_created desc',
2007  'limit' => 10,
2008  'offset' => 0,
2009  'count' => false,
2010  'site_guid' => 0
2011  );
2013  return $attached;
2014 }
2015 
2026 function remove_attachment($guid_one, $guid_two) {
2027  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated', 1.9);
2028  if (already_attached($guid_one, $guid_two)) {
2029  remove_entity_relationship($guid_one, "attached", $guid_two);
2030  }
2031 }
2032 
2043 function make_attachment($guid_one, $guid_two) {
2044  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated', 1.9);
2045  if (!(already_attached($guid_one, $guid_two))) {
2046  if (add_entity_relationship($guid_one, "attached", $guid_two)) {
2047  return true;
2048  }
2049  }
2050 }
2051 
2061  elgg_deprecated_notice('get_entity_url has been deprecated in favor of \ElggEntity::getURL', '1.9');
2062  if ($entity = get_entity($entity_guid)) {
2063  return $entity->getURL();
2064  }
2065 
2066  return false;
2067 }
2068 
2089 function delete_entity($guid, $recursive = true) {
2090  elgg_deprecated_notice('delete_entity has been deprecated in favor of \ElggEntity::delete', '1.9');
2091  $guid = (int)$guid;
2092  if ($entity = get_entity($guid)) {
2093  return $entity->delete($recursive);
2094  }
2095  return false;
2096 }
2097 
2110 function enable_entity($guid, $recursive = true) {
2111  elgg_deprecated_notice('enable_entity has been deprecated in favor of elgg_enable_entity', '1.9');
2112 
2113  $guid = (int)$guid;
2114 
2115  // Override access only visible entities
2116  $old_access_status = access_get_show_hidden_status();
2118 
2119  $result = false;
2120  if ($entity = get_entity($guid)) {
2121  $result = $entity->enable($recursive);
2122  }
2123 
2124  access_show_hidden_entities($old_access_status);
2125  return $result;
2126 }
2127 
2144  elgg_deprecated_notice('can_edit_entity_metadata has been deprecated in favor of \ElggEntity::canEditMetadata', '1.9');
2145  if ($entity = get_entity($entity_guid)) {
2146  return $entity->canEditMetadata($metadata, $user_guid);
2147  } else {
2148  return false;
2149  }
2150 }
2151 
2172 function disable_entity($guid, $reason = "", $recursive = true) {
2173  elgg_deprecated_notice('disable_entity was deprecated in favor of \ElggEntity::disable', '1.9');
2174 
2175  if ($entity = get_entity($guid)) {
2176  return $entity->disable($reason, $recursive);
2177  }
2178 
2179  return false;
2180 }
2181 
2196  elgg_deprecated_notice('can_edit_entity was deprecated in favor of \ElggEntity::canEdit', '1.9');
2197  if ($entity = get_entity($entity_guid)) {
2198  return $entity->canEdit($user_guid);
2199  }
2200 
2201  return false;
2202 }
2203 
2213 function join_group($group_guid, $user_guid) {
2214  elgg_deprecated_notice('join_group was deprecated in favor of \ElggGroup::join', '1.9');
2215 
2216  $group = get_entity($group_guid);
2218 
2219  if ($group instanceof \ElggGroup && $user instanceof \ElggUser) {
2220  return $group->join($user);
2221  }
2222 
2223  return false;
2224 }
2225 
2235 function leave_group($group_guid, $user_guid) {
2236  elgg_deprecated_notice('leave_group was deprecated in favor of \ElggGroup::leave', '1.9');
2237  $group = get_entity($group_guid);
2239 
2240  if ($group instanceof \ElggGroup && $user instanceof \ElggUser) {
2241  return $group->leave($user);
2242  }
2243 
2244  return false;
2245 }
2246 
2254 function autop($string) {
2255  elgg_deprecated_notice('autop has been deprecated in favor of elgg_autop', '1.9');
2256  return elgg_autop($string);
2257 }
2258 
2264 function expose_function($method, $function, array $parameters = NULL, $description = "",
2265  $call_method = "GET", $require_api_auth = false, $require_user_auth = false) {
2266  elgg_deprecated_notice("expose_function() deprecated for the function elgg_ws_expose_function() in web_services plugin", 1.9);
2267  if (!elgg_admin_notice_exists("elgg:ws:1.9")) {
2268  elgg_add_admin_notice("elgg:ws:1.9", "The web services are now a plugin in Elgg 1.9.
2269  You must enable this plugin and update your web services to use elgg_ws_expose_function().");
2270  }
2271 
2272  if (function_exists("elgg_ws_expose_function")) {
2273  return elgg_ws_expose_function($method, $function, $parameters, $description, $call_method, $require_api_auth, $require_user_auth);
2274  }
2275 }
2276 
2285  elgg_deprecated_notice("unexpose_function() deprecated for the function elgg_ws_unexpose_function() in web_services plugin", 1.9);
2286  if (function_exists("elgg_ws_unexpose_function")) {
2287  return elgg_ws_unexpose_function($method);
2288  }
2289 }
2290 
2299 function register_service_handler($handler, $function) {
2300  elgg_deprecated_notice("register_service_handler() deprecated for the function elgg_ws_register_service_handler() in web_services plugin", 1.9);
2301  if (function_exists("elgg_ws_register_service_handler")) {
2302  return elgg_ws_register_service_handler($handler, $function);
2303  }
2304 }
2305 
2316  elgg_deprecated_notice("unregister_service_handler() deprecated for the function elgg_ws_unregister_service_handler() in web_services plugin", 1.9);
2317  if (function_exists("elgg_ws_unregister_service_handler")) {
2318  return elgg_ws_unregister_service_handler($handler);
2319  }
2320 }
2321 
2336  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use \ElggSite constructor', 1.9);
2337  global $CONFIG;
2338 
2339  $guid = (int)$guid;
2343 
2344  $row = get_entity_as_row($guid);
2345 
2346  if ($row) {
2347  // Exists and you have access to it
2348  $query = "SELECT guid from {$CONFIG->dbprefix}sites_entity where guid = {$guid}";
2349  if ($exists = get_data_row($query)) {
2350  $query = "UPDATE {$CONFIG->dbprefix}sites_entity
2351  set name='$name', description='$description', url='$url' where guid=$guid";
2352  $result = update_data($query);
2353 
2354  if ($result != false) {
2355  // Update succeeded, continue
2357  if (elgg_trigger_event('update', $entity->type, $entity)) {
2358  return $guid;
2359  } else {
2360  $entity->delete();
2361  //delete_entity($guid);
2362  }
2363  }
2364  } else {
2365  // Update failed, attempt an insert.
2366  $query = "INSERT into {$CONFIG->dbprefix}sites_entity
2367  (guid, name, description, url) values ($guid, '$name', '$description', '$url')";
2368  $result = insert_data($query);
2369 
2370  if ($result !== false) {
2372  if (elgg_trigger_event('create', $entity->type, $entity)) {
2373  return $guid;
2374  } else {
2375  $entity->delete();
2376  //delete_entity($guid);
2377  }
2378  }
2379  }
2380  }
2381 
2382  return false;
2383 }
2384 
2398  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use \ElggGroup constructor', 1.9);
2399  global $CONFIG;
2400 
2401  $guid = (int)$guid;
2404 
2405  $row = get_entity_as_row($guid);
2406 
2407  if ($row) {
2408  // Exists and you have access to it
2409  $exists = get_data_row("SELECT guid from {$CONFIG->dbprefix}groups_entity WHERE guid = {$guid}");
2410  if ($exists) {
2411  $query = "UPDATE {$CONFIG->dbprefix}groups_entity set"
2412  . " name='$name', description='$description' where guid=$guid";
2413  $result = update_data($query);
2414  if ($result != false) {
2415  // Update succeeded, continue
2417  if (elgg_trigger_event('update', $entity->type, $entity)) {
2418  return $guid;
2419  } else {
2420  $entity->delete();
2421  }
2422  }
2423  } else {
2424  // Update failed, attempt an insert.
2425  $query = "INSERT into {$CONFIG->dbprefix}groups_entity"
2426  . " (guid, name, description) values ($guid, '$name', '$description')";
2427 
2428  $result = insert_data($query);
2429  if ($result !== false) {
2431  if (elgg_trigger_event('create', $entity->type, $entity)) {
2432  return $guid;
2433  } else {
2434  $entity->delete();
2435  }
2436  }
2437  }
2438  }
2439 
2440  return false;
2441 }
2442 
2461  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use \ElggUser constructor', 1.9);
2462  global $CONFIG;
2463 
2464  $guid = (int)$guid;
2468  $salt = sanitise_string($salt);
2471 
2472  $row = get_entity_as_row($guid);
2473  if ($row) {
2474  // Exists and you have access to it
2475  $query = "SELECT guid from {$CONFIG->dbprefix}users_entity where guid = {$guid}";
2476  if ($exists = get_data_row($query)) {
2477  $query = "UPDATE {$CONFIG->dbprefix}users_entity
2478  SET name='$name', username='$username', password='$password', salt='$salt',
2479  email='$email', language='$language'
2480  WHERE guid = $guid";
2481 
2482  $result = update_data($query);
2483  if ($result != false) {
2484  // Update succeeded, continue
2486  if (elgg_trigger_event('update', $entity->type, $entity)) {
2487  return $guid;
2488  } else {
2489  $entity->delete();
2490  }
2491  }
2492  } else {
2493  // Exists query failed, attempt an insert.
2494  $query = "INSERT into {$CONFIG->dbprefix}users_entity
2495  (guid, name, username, password, salt, email, language)
2496  values ($guid, '$name', '$username', '$password', '$salt', '$email', '$language')";
2497 
2498  $result = insert_data($query);
2499  if ($result !== false) {
2501  if (elgg_trigger_event('create', $entity->type, $entity)) {
2502  return $guid;
2503  } else {
2504  $entity->delete();
2505  }
2506  }
2507  }
2508  }
2509 
2510  return false;
2511 }
2512 
2526  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use \ElggObject constructor', 1.9);
2527  global $CONFIG;
2528 
2529  $guid = (int)$guid;
2532 
2533  $row = get_entity_as_row($guid);
2534 
2535  if ($row) {
2536  // Core entities row exists and we have access to it
2537  $query = "SELECT guid from {$CONFIG->dbprefix}objects_entity where guid = {$guid}";
2538  if ($exists = get_data_row($query)) {
2539  $query = "UPDATE {$CONFIG->dbprefix}objects_entity
2540  set title='$title', description='$description' where guid=$guid";
2541 
2542  $result = update_data($query);
2543  if ($result != false) {
2544  // Update succeeded, continue
2546  elgg_trigger_event('update', $entity->type, $entity);
2547  return $guid;
2548  }
2549  } else {
2550  // Update failed, attempt an insert.
2551  $query = "INSERT into {$CONFIG->dbprefix}objects_entity
2552  (guid, title, description) values ($guid, '$title','$description')";
2553 
2554  $result = insert_data($query);
2555  if ($result !== false) {
2557  if (elgg_trigger_event('create', $entity->type, $entity)) {
2558  return $guid;
2559  } else {
2560  $entity->delete();
2561  }
2562  }
2563  }
2564  }
2565 
2566  return false;
2567 }
2568 
2578 function ODD_factory (XmlElement $element) {
2579  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated', 1.9);
2580  $name = $element->name;
2581  $odd = false;
2582 
2583  switch ($name) {
2584  case 'entity' :
2585  $odd = new ODDEntity("", "", "");
2586  break;
2587  case 'metadata' :
2588  $odd = new ODDMetaData("", "", "", "");
2589  break;
2590  case 'relationship' :
2591  $odd = new ODDRelationship("", "", "");
2592  break;
2593  }
2594 
2595  // Now populate values
2596  if ($odd) {
2597  // Attributes
2598  foreach ($element->attributes as $k => $v) {
2599  $odd->setAttribute($k, $v);
2600  }
2601 
2602  // Body
2603  $body = $element->content;
2604  $a = stripos($body, "<![CDATA");
2605  $b = strripos($body, "]]>");
2606  if (($body) && ($a !== false) && ($b !== false)) {
2607  $body = substr($body, $a + 8, $b - ($a + 8));
2608  }
2609 
2610  $odd->setBody($body);
2611  }
2612 
2613  return $odd;
2614 }
2615 
2630  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated', 1.9);
2631  $class = $element->getAttribute('class');
2632  $subclass = $element->getAttribute('subclass');
2633 
2634  // See if we already have imported this uuid
2635  $tmp = get_entity_from_uuid($element->getAttribute('uuid'));
2636 
2637  if (!$tmp) {
2638  // Construct new class with owner from session
2639  $classname = get_subtype_class($class, $subclass);
2640  if ($classname) {
2641  if (class_exists($classname)) {
2642  $tmp = new $classname();
2643 
2644  if (!($tmp instanceof \ElggEntity)) {
2645  $msg = $classname . " is not a " . get_class() . ".";
2646  throw new \ClassException($msg);
2647  }
2648  } else {
2649  error_log("Class '" . $classname . "' was not found, missing plugin?");
2650  }
2651  } else {
2652  switch ($class) {
2653  case 'object' :
2654  $tmp = new \ElggObject();
2655  break;
2656  case 'user' :
2657  $tmp = new \ElggUser();
2658  break;
2659  case 'group' :
2660  $tmp = new \ElggGroup();
2661  break;
2662  case 'site' :
2663  $tmp = new \ElggSite();
2664  break;
2665  default:
2666  $msg = "Type " . $class . " is not supported. This indicates an error in your installation, most likely caused by an incomplete upgrade.";
2667  throw new \InstallationException($msg);
2668  }
2669  }
2670  }
2671 
2672  if ($tmp) {
2673  if (!$tmp->import($element)) {
2674  $msg = "Could not import element " . $element->getAttribute('uuid');
2675  throw new \ImportException($msg);
2676  }
2677 
2678  return $tmp;
2679  }
2680 
2681  return NULL;
2682 }
2683 
2693 function ODD_Import($xml) {
2694  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated', 1.9);
2695  // Parse XML to an array
2696  $elements = xml_to_object($xml);
2697 
2698  // Sanity check 1, was this actually XML?
2699  if ((!$elements) || (!$elements->children)) {
2700  return false;
2701  }
2702 
2703  // Create ODDDocument
2704  $document = new ODDDocument();
2705 
2706  // Itterate through array of elements and construct ODD document
2707  $cnt = 0;
2708 
2709  foreach ($elements->children as $child) {
2710  $odd = ODD_factory($child);
2711 
2712  if ($odd) {
2713  $document->addElement($odd);
2714  $cnt++;
2715  }
2716  }
2717 
2718  // Check that we actually found something
2719  if ($cnt == 0) {
2720  return false;
2721  }
2722 
2723  return $document;
2724 }
2725 
2735 function ODD_Export(ODDDocument $document) {
2736  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated', 1.9);
2737  return "$document";
2738 }
2739 
2749  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated', 1.9);
2750  if ($object instanceof \ElggEntity) {
2751  return guid_to_uuid($object->guid);
2752  } else if ($object instanceof \ElggExtender) {
2753  $type = $object->type;
2754  if ($type == 'volatile') {
2755  $uuid = guid_to_uuid($object->entity_guid) . $type . "/{$object->name}/";
2756  } else {
2757  $uuid = guid_to_uuid($object->entity_guid) . $type . "/{$object->id}/";
2758  }
2759 
2760  return $uuid;
2761  } else if ($object instanceof \ElggRelationship) {
2762  return guid_to_uuid($object->guid_one) . "relationship/{$object->id}/";
2763  }
2764 
2765  return false;
2766 }
2767 
2776 function guid_to_uuid($guid) {
2777  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated', 1.9);
2778  return elgg_get_site_url() . "export/opendd/$guid/";
2779 }
2780 
2789 function is_uuid_this_domain($uuid) {
2790  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated', 1.9);
2791  if (strpos($uuid, elgg_get_site_url()) === 0) {
2792  return true;
2793  }
2794 
2795  return false;
2796 }
2797 
2806 function get_entity_from_uuid($uuid) {
2807  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated', 1.9);
2808  $uuid = sanitise_string($uuid);
2809 
2810  $options = array('metadata_name' => 'import_uuid', 'metadata_value' => $uuid);
2812 
2813  if ($entities) {
2814  return $entities[0];
2815  }
2816 
2817  return false;
2818 }
2819 
2829 function add_uuid_to_guid($guid, $uuid) {
2830  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated', 1.9);
2831  $guid = (int)$guid;
2832  $uuid = sanitise_string($uuid);
2833 
2834  $result = create_metadata($guid, "import_uuid", $uuid);
2835  return (bool)$result;
2836 }
2837 
2838 
2839 $IMPORTED_DATA = array();
2841 
2854 function _process_element(ODD $odd) {
2855  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated', 1.9);
2857 
2858  // See if anyone handles this element, return true if it is.
2859  $to_be_serialised = null;
2860  if ($odd) {
2861  $handled = elgg_trigger_plugin_hook("import", "all", array("element" => $odd), $to_be_serialised);
2862 
2863  // If not, then see if any of its sub elements are handled
2864  if ($handled) {
2865  // Increment validation counter
2866  $IMPORTED_OBJECT_COUNTER ++;
2867  // Return the constructed object
2868  $IMPORTED_DATA[] = $handled;
2869 
2870  return true;
2871  }
2872  }
2873 
2874  return false;
2875 }
2876 
2888  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated', 1.9);
2889  $guid = (int)$guid;
2890 
2891  // Trigger a hook to
2892  $to_be_serialised = elgg_trigger_plugin_hook("export", "all", array("guid" => $guid), array());
2893 
2894  // Sanity check
2895  if ((!is_array($to_be_serialised)) || (count($to_be_serialised) == 0)) {
2896  throw new \ExportException("No such entity GUID:" . $guid);
2897  }
2898 
2899  return $to_be_serialised;
2900 }
2901 
2917 function export($guid) {
2918  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated', 1.9);
2919  $odd = new ODDDocument(exportAsArray($guid));
2920 
2921  return ODD_Export($odd);
2922 }
2923 
2935 function import($xml) {
2936  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated', 1.9);
2938 
2939  $IMPORTED_DATA = array();
2940  $IMPORTED_OBJECT_COUNTER = 0;
2941 
2942  $document = ODD_Import($xml);
2943  if (!$document) {
2944  throw new \ImportException("No OpenDD elements found in import data, import failed.");
2945  }
2946 
2947  foreach ($document as $element) {
2948  _process_element($element);
2949  }
2950 
2951  if ($IMPORTED_OBJECT_COUNTER != count($IMPORTED_DATA)) {
2952  throw new \ImportException("Not all elements were imported.");
2953  }
2954 
2955  return true;
2956 }
2957 
2965 function _export_init() {
2966  global $CONFIG;
2967 
2968  elgg_register_action("import/opendd");
2969 }
2970 
2986 function elgg_get_views($dir, $base) {
2987  $return = array();
2988  if (file_exists($dir) && is_dir($dir)) {
2989  if ($handle = opendir($dir)) {
2990  while ($view = readdir($handle)) {
2991  if (!in_array($view, array('.', '..', '.svn', 'CVS'))) {
2992  if (is_dir($dir . '/' . $view)) {
2993  if ($val = elgg_get_views($dir . '/' . $view, $base . '/' . $view)) {
2994  $return = array_merge($return, $val);
2995  }
2996  } else {
2997  $view = str_replace('.php', '', $view);
2998  $return[] = $base . '/' . $view;
2999  }
3000  }
3001  }
3002  }
3003  }
3004 
3005  return $return;
3006 }
3007 
3023 function elgg_view_tree($view_root, $viewtype = "") {
3024  global $CONFIG;
3025  static $treecache = array();
3026 
3027  // Get viewtype
3028  if (!$viewtype) {
3029  $viewtype = elgg_get_viewtype();
3030  }
3031 
3032  // A little light internal caching
3033  if (!empty($treecache[$view_root])) {
3034  return $treecache[$view_root];
3035  }
3036 
3037  // Examine $CONFIG->views->locations
3038  if (isset($CONFIG->views->locations[$viewtype])) {
3039  foreach ($CONFIG->views->locations[$viewtype] as $view => $path) {
3040  $pos = strpos($view, $view_root);
3041  if ($pos === 0) {
3042  $treecache[$view_root][] = $view;
3043  }
3044  }
3045  }
3046 
3047  // Now examine core
3048  $location = $GLOBALS['_ELGG']->view_path;
3049  $viewtype = elgg_get_viewtype();
3050  $root = $location . $viewtype . '/' . $view_root;
3051 
3052  if (file_exists($root) && is_dir($root)) {
3053  $val = elgg_get_views($root, $view_root);
3054  if (!is_array($treecache[$view_root])) {
3055  $treecache[$view_root] = array();
3056  }
3057  $treecache[$view_root] = array_merge($treecache[$view_root], $val);
3058  }
3059 
3060  return $treecache[$view_root];
3061 }
3062 
3078 function add_to_river($view, $action_type, $subject_guid, $object_guid, $access_id = "",
3079 $posted = 0, $annotation_id = 0, $target_guid = 0) {
3080  elgg_deprecated_notice('add_to_river was deprecated in favor of elgg_create_river_item', '1.9');
3081 
3082  // Make sure old parameters are passed in correct format
3083  $access_id = ($access_id == '') ? null : $access_id;
3084  $posted = ($posted == 0) ? null : $posted;
3085 
3086  return elgg_create_river_item(array(
3087  'view' => $view,
3088  'action_type' => $action_type,
3089  'subject_guid' => $subject_guid,
3090  'object_guid' => $object_guid,
3091  'target_guid' => $target_guid,
3092  'access_id' => $access_id,
3093  'posted' => $posted,
3094  'annotation_id' => $annotation_id,
3095  ));
3096 }
3097 
3112 function serialise_object_to_xml($data, $name = "", $n = 0) {
3113  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated.', 1.9);
3114 
3115  $classname = ($name == "" ? get_class($data) : $name);
3116 
3117  $vars = method_exists($data, "export") ? get_object_vars($data->export()) : get_object_vars($data);
3118 
3119  $output = "";
3120 
3121  if (($n == 0) || ( is_object($data) && !($data instanceof \stdClass))) {
3122  $output = "<$classname>";
3123  }
3124 
3125  foreach ($vars as $key => $value) {
3126  $output .= "<$key type=\"" . gettype($value) . "\">";
3127 
3128  if (is_object($value)) {
3130  } else if (is_array($value)) {
3132  } else if (gettype($value) == "boolean") {
3133  $output .= $value ? "true" : "false";
3134  } else {
3135  $output .= htmlspecialchars($value, ENT_NOQUOTES, 'UTF-8');
3136  }
3137 
3138  $output .= "</$key>\n";
3139  }
3140 
3141  if (($n == 0) || (is_object($data) && !($data instanceof \stdClass))) {
3142  $output .= "</$classname>\n";
3143  }
3144 
3145  return $output;
3146 }
3147 
3157 function serialise_array_to_xml(array $data, $n = 0) {
3158  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated.', 1.9);
3159 
3160  $output = "";
3161 
3162  if ($n == 0) {
3163  $output = "<array>\n";
3164  }
3165 
3166  foreach ($data as $key => $value) {
3167  $item = "array_item";
3168 
3169  if (is_numeric($key)) {
3170  $output .= "<$item name=\"$key\" type=\"" . gettype($value) . "\">";
3171  } else {
3172  $item = $key;
3173  $output .= "<$item type=\"" . gettype($value) . "\">";
3174  }
3175 
3176  if (is_object($value)) {
3178  } else if (is_array($value)) {
3180  } else if (gettype($value) == "boolean") {
3181  $output .= $value ? "true" : "false";
3182  } else {
3183  $output .= htmlspecialchars($value, ENT_NOQUOTES, 'UTF-8');
3184  }
3185 
3186  $output .= "</$item>\n";
3187  }
3188 
3189  if ($n == 0) {
3190  $output .= "</array>\n";
3191  }
3192 
3193  return $output;
3194 }
3195 
3204 function xml_to_object($xml) {
3205  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated by \ElggXMLElement', 1.9);
3206  return new \ElggXMLElement($xml);
3207 }
3208 
3218  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use \ElggSite::getDomain()', 1.9);
3219  $guid = (int)$guid;
3220 
3221  $site = get_entity($guid);
3222  if ($site instanceof \ElggSite) {
3223  $breakdown = parse_url($site->url);
3224  return $breakdown['host'];
3225  }
3226 
3227  return false;
3228 }
3229 
3243 function register_notification_object($entity_type, $object_subtype, $language_name) {
3244  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated by elgg_register_notification_event()', 1.9);
3245 
3246  elgg_register_notification_event($entity_type, $object_subtype);
3247  _elgg_services()->notifications->setDeprecatedNotificationSubject($entity_type, $object_subtype, $language_name);
3248 }
3249 
3260  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated by elgg_add_subscription()', 1.9);
3261  return add_entity_relationship($user_guid, 'notify', $author_guid);
3262 }
3263 
3273 function remove_notification_interest($user_guid, $author_guid) {
3274  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated by elgg_remove_subscription()', 1.9);
3275  return remove_entity_relationship($user_guid, 'notify', $author_guid);
3276 }
3277 
3292 function object_notifications($event, $object_type, $object) {
3293  throw new \BadFunctionCallException("object_notifications is a private function and should not be called directly");
3294 }
3295 
3311  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated by elgg_register_notification_method()', 1.9);
3313  _elgg_services()->notifications->registerDeprecatedHandler($method, $handler);
3314 }
3315 
3326  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated by elgg_unregister_notification_method()', 1.9);
3328 }
3329 
3350 function import_entity_plugin_hook($hook, $entity_type, $returnvalue, $params) {
3351  $element = $params['element'];
3352 
3353  $tmp = null;
3354 
3355  if ($element instanceof ODDEntity) {
3356  $tmp = oddentity_to_elggentity($element);
3357 
3358  if ($tmp) {
3359  // Make sure its saved
3360  if (!$tmp->save()) {
3361  $msg = "There was a problem saving " . $element->getAttribute('uuid');
3362  throw new \ImportException($msg);
3363  }
3364 
3365  // Belts and braces
3366  if (!$tmp->guid) {
3367  throw new \ImportException("New entity created but has no GUID, this should not happen.");
3368  }
3369 
3370  // We have saved, so now tag
3371  add_uuid_to_guid($tmp->guid, $element->getAttribute('uuid'));
3372 
3373  return $tmp;
3374  }
3375  }
3376 }
3377 
3395 function export_entity_plugin_hook($hook, $entity_type, $returnvalue, $params) {
3396  // Sanity check values
3397  if ((!is_array($params)) && (!isset($params['guid']))) {
3398  throw new \InvalidParameterException("GUID has not been specified during export, this should never happen.");
3399  }
3400 
3401  if (!is_array($returnvalue)) {
3402  throw new \InvalidParameterException("Entity serialisation function passed a non-array returnvalue parameter");
3403  }
3404 
3405  $guid = (int)$params['guid'];
3406 
3407  // Get the entity
3409  if (!($entity instanceof \ElggEntity)) {
3410  $msg = "GUID:" . $guid . " is not a valid " . get_class();
3411  throw new \InvalidClassException($msg);
3412  }
3413 
3414  $export = $entity->export();
3415 
3416  if (is_array($export)) {
3417  foreach ($export as $e) {
3418  $returnvalue[] = $e;
3419  }
3420  } else {
3421  $returnvalue[] = $export;
3422  }
3423 
3424  return $returnvalue;
3425 }
3426 
3442 function volatile_data_export_plugin_hook($hook, $entity_type, $returnvalue, $params) {
3443  $guid = (int)$params['guid'];
3444  $variable_name = sanitise_string($params['varname']);
3445 
3446  if (($hook == 'volatile') && ($entity_type == 'metadata')) {
3447  if (($guid) && ($variable_name)) {
3448  switch ($variable_name) {
3449  case 'renderedentity' :
3450  elgg_set_viewtype('default');
3453 
3454  $tmp = new \ElggMetadata();
3455  $tmp->type = 'volatile';
3456  $tmp->name = 'renderedentity';
3457  $tmp->value = $view;
3458  $tmp->entity_guid = $guid;
3459 
3460  return $tmp;
3461 
3462  break;
3463  }
3464  }
3465  }
3466 }
3467 
3483 function export_annotation_plugin_hook($hook, $type, $returnvalue, $params) {
3484  // Sanity check values
3485  if ((!is_array($params)) && (!isset($params['guid']))) {
3486  throw new \InvalidParameterException("GUID has not been specified during export, this should never happen.");
3487  }
3488 
3489  if (!is_array($returnvalue)) {
3490  throw new \InvalidParameterException("Entity serialization function passed a non-array returnvalue parameter");
3491  }
3492 
3493  $guid = (int)$params['guid'];
3494  $options = array('guid' => $guid, 'limit' => 0);
3495  if (isset($params['name'])) {
3496  $options['annotation_name'] = $params['name'];
3497  }
3498 
3500 
3501  if ($result) {
3502  foreach ($result as $r) {
3503  $returnvalue[] = $r->export();
3504  }
3505  }
3506 
3507  return $returnvalue;
3508 }
3509 
3525 function import_extender_plugin_hook($hook, $entity_type, $returnvalue, $params) {
3526  $element = $params['element'];
3527 
3528  $tmp = NULL;
3529 
3530  if ($element instanceof ODDMetaData) {
3531  /* @var ODDMetaData $element */
3532  // Recall entity
3533  $entity_uuid = $element->getAttribute('entity_uuid');
3534  $entity = get_entity_from_uuid($entity_uuid);
3535  if (!$entity) {
3536  throw new \ImportException("Entity '" . $entity_uuid . "' could not be found.");
3537  }
3538 
3540 
3541  // Save
3542  if (!$entity->save()) {
3543  $attr_name = $element->getAttribute('name');
3544  $msg = "There was a problem updating '" . $attr_name . "' on entity '" . $entity_uuid . "'";
3545  throw new \ImportException($msg);
3546  }
3547 
3548  return true;
3549  }
3550 }
3551 
3565  // Get the type of extender (metadata, type, attribute etc)
3566  $type = $element->getAttribute('type');
3567  $attr_name = $element->getAttribute('name');
3568  $attr_val = $element->getBody();
3569 
3570  switch ($type) {
3571  // Ignore volatile items
3572  case 'volatile' :
3573  break;
3574  case 'annotation' :
3575  $entity->annotate($attr_name, $attr_val);
3576  break;
3577  case 'metadata' :
3578  $entity->setMetadata($attr_name, $attr_val, "", true);
3579  break;
3580  default : // Anything else assume attribute
3581  $entity->set($attr_name, $attr_val);
3582  }
3583 
3584  // Set time if appropriate
3585  $attr_time = $element->getAttribute('published');
3586  if ($attr_time) {
3587  $entity->set('time_updated', $attr_time);
3588  }
3589 
3590  return true;
3591 }
3592 
3607 function export_metadata_plugin_hook($hook, $entity_type, $returnvalue, $params) {
3608  // Sanity check values
3609  if ((!is_array($params)) && (!isset($params['guid']))) {
3610  throw new \InvalidParameterException("GUID has not been specified during export, this should never happen.");
3611  }
3612 
3613  if (!is_array($returnvalue)) {
3614  throw new \InvalidParameterException("Entity serialisation function passed a non-array returnvalue parameter");
3615  }
3616 
3617  $result = elgg_get_metadata(array(
3618  'guid' => (int)$params['guid'],
3619  'limit' => 0,
3620  ));
3621 
3622  if ($result) {
3623  /* @var \ElggMetadata[] $result */
3624  foreach ($result as $r) {
3625  $returnvalue[] = $r->export();
3626  }
3627  }
3628 
3629  return $returnvalue;
3630 }
3631 
3646 function export_relationship_plugin_hook($hook, $entity_type, $returnvalue, $params) {
3647  // Sanity check values
3648  if ((!is_array($params)) && (!isset($params['guid']))) {
3649  throw new \InvalidParameterException("GUID has not been specified during export, this should never happen.");
3650  }
3651 
3652  if (!is_array($returnvalue)) {
3653  throw new \InvalidParameterException("Entity serialisation function passed a non-array returnvalue parameter");
3654  }
3655 
3656  $guid = (int)$params['guid'];
3657 
3659 
3660  if ($result) {
3661  foreach ($result as $r) {
3662  $returnvalue[] = $r->export();
3663  }
3664  }
3665 
3666  return $returnvalue;
3667 }
3668 
3681 function import_relationship_plugin_hook($hook, $entity_type, $returnvalue, $params) {
3682  $element = $params['element'];
3683 
3684  $tmp = NULL;
3685 
3686  if ($element instanceof ODDRelationship) {
3687  $tmp = new \ElggRelationship();
3688  $tmp->import($element);
3689 
3690  return $tmp;
3691  }
3692  return $tmp;
3693 }
3694 
3710 function get_access_sql_suffix($table_prefix = '', $owner = null) {
3711  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated by _elgg_get_access_where_sql()', 1.9);
3712  return _elgg_get_access_where_sql(array(
3713  'table_alias' => $table_prefix,
3714  'user_guid' => (int)$owner,
3715  ));
3716 }
3717 
3733 function elgg_get_calling_plugin_id($mainfilename = false) {
3734  elgg_deprecated_notice('elgg_get_calling_plugin_id() is deprecated', 1.9);
3735  if (!$mainfilename) {
3736  if ($backtrace = debug_backtrace()) {
3737  foreach ($backtrace as $step) {
3738  $file = $step['file'];
3739  $file = str_replace("\\", "/", $file);
3740  $file = str_replace("//", "/", $file);
3741  if (preg_match("/mod\/([a-zA-Z0-9\-\_]*)\/start\.php$/", $file, $matches)) {
3742  return $matches[1];
3743  }
3744  }
3745  }
3746  } else {
3747  //@todo this is a hack -- plugins do not have to match their page handler names!
3748  if ($handler = get_input('handler', false)) {
3749  return $handler;
3750  } else {
3751  $file = $_SERVER["SCRIPT_NAME"];
3752  $file = str_replace("\\", "/", $file);
3753  $file = str_replace("//", "/", $file);
3754  if (preg_match("/mod\/([a-zA-Z0-9\-\_]*)\//", $file, $matches)) {
3755  return $matches[1];
3756  }
3757  }
3758  }
3759  return false;
3760 }
3761 
3771  elgg_deprecated_notice("elgg_get_calling_plugin_entity() is deprecated.", 1.9);
3773 
3774  if ($plugin_id) {
3776  }
3777 
3778  return false;
3779 }
3780 
3781 return function(\Elgg\EventsService $events, \Elgg\HooksRegistrationService $hooks) {
3782  // Register a startup event
3783  $events->registerHandler('init', 'system', '_export_init', 100);
3784 
3786  $hooks->registerHandler("import", "all", "import_entity_plugin_hook", 0);
3787  $hooks->registerHandler("import", "all", "import_extender_plugin_hook", 2);
3788  $hooks->registerHandler("import", "all", "import_relationship_plugin_hook", 3);
3789 
3791  $hooks->registerHandler("export", "all", "export_entity_plugin_hook", 0);
3792  $hooks->registerHandler("export", "all", "export_annotation_plugin_hook", 2);
3793  $hooks->registerHandler("export", "all", "export_metadata_plugin_hook", 2);
3794  $hooks->registerHandler("export", "all", "export_relationship_plugin_hook", 3);
3795 
3797  $hooks->registerHandler('volatile', 'metadata', 'volatile_data_export_plugin_hook');
3798 };
insert_data($query, array $params=[])
Insert a row into the database.
Definition: database.php:87
elgg_enable_filepath_cache()
private
elgg_admin_notice_exists($id)
Check if an admin notice is currently active.
Definition: admin.php:116
elgg_enable_system_cache()
Enables the system disk cache.
Definition: cache.php:72
$tags
Definition: summary.php:41
$object
These two snippets demonstrates triggering an event and how to register for that event.
Definition: trigger.php:7
elgg_get_config($name, $site_guid=0)
Get an Elgg configuration value.
$view
Definition: crop.php:34
optimize_table($table)
Optimize a table.
elgg_get_calling_plugin_id($mainfilename=false)
Get the name of the most recent plugin to be called in the call stack (or the plugin that owns the cu...
get_metastring_id($string, $case_sensitive=TRUE)
Return the meta string id for a given tag, or false.
$n
Profile fields.
Definition: list.php:9
exportAsArray($guid)
Exports an entity as an array.
$r
remove_site_user($site_guid, $user_guid)
Remove a user from a site.
elgg_reset_system_cache()
Reset the system cache by deleting the caches.
Definition: cache.php:29
elgg_is_logged_in()
Returns whether or not the user is currently logged in.
Definition: sessions.php:51
$action
Definition: full.php:125
elgg_get_entities_from_metadata(array $options=array())
interfaces
Definition: metadata.php:255
get_version($humanreadable=false)
Get the current Elgg version information.
get_attachments($guid, $type="")
Function to get all objects attached to a particular object.
remove_site_object($site_guid, $object_guid)
Remove an object from a site.
calculate_tag_size($min, $max, $number_of_tags, $buckets=6)
The algorithm working out the size of font based on the number of tags.
getBody()
Gets the body of the ODD.
Definition: ODD.php:79
if(!array_key_exists($filename, $text_files)) $file
$username
Definition: delete.php:22
get_relationship($id)
Get a relationship by its ID.
elgg_register_notification_method($name)
Register a delivery method for notifications.
export_entity_plugin_hook($hook, $entity_type, $returnvalue, $params)
Exports all attributes of an entity.
get_noteable_entities_from_relationship($start_time, $end_time, $relationship, $relationship_guid, $inverse_relationship=false, $type="", $subtype="", $owner_guid=0, $order_by="", $limit=10, $offset=0, $count=false, $site_guid=0)
Return the notable entities for a given time period based on their relationship.
get_site_objects($site_guid, $subtype="", $limit=10, $offset=0)
Get the objects belonging to a site.
elgg_invalidate_simplecache()
Deletes all cached views in the simplecache and sets the lastcache and lastupdate time to 0 for every...
Definition: cache.php:215
get_group_members($group_guid, $limit=10, $offset=0, $site_guid=0, $count=false)
Return a list of this group's members.
$table
Definition: cron.php:34
add_entity_relationship($guid_one, $relationship, $guid_two)
Create a relationship between two entities.
list_user_friends_objects($user_guid, $subtype="", $limit=10, $full_view=true, $listtypetoggle=true, $pagination=true, $timelower=0, $timeupper=0)
Displays a list of a user's friends' objects of a particular subtype, with navigation.
is_uuid_this_domain($uuid)
Test to see if a given uuid is for this domain, returning true if so.
elgg_normalize_url($url)
Definition: output.php:290
get_object_sites($object_guid, $limit=10, $offset=0)
Get the sites this object is part of.
get_uuid_from_object($object)
Get a UUID from a given object.
if($guid==elgg_get_logged_in_user_guid()) $name
Definition: delete.php:21
unregister_notification_handler($method)
This function unregisters a handler for a given notification type (eg "email")
ODD_Export(ODDDocument $document)
Export an ODD Document.
remove_entity_relationship($guid_one, $relationship, $guid_two)
Delete a relationship between two entities.
$method
Definition: form.php:25
$e
Definition: metadata.php:12
get_subtype_id($type, $subtype)
Return the id for a given subtype.
Definition: entities.php:27
import_relationship_plugin_hook($hook, $entity_type, $returnvalue, $params)
Handler called by trigger_plugin_hook on the "import" event.
ODD_Import($xml)
Import an ODD document.
get_todays_entities_from_relationship($relationship, $relationship_guid, $inverse_relationship=false, $type="", $subtype="", $owner_guid=0, $order_by="", $limit=10, $offset=0, $count=false, $site_guid=0)
Get entities for today from a relationship.
elgg_filepath_cache_save($type, $data)
private
autop($string)
Create paragraphs from text with line spacing.
get_todays_entities_from_metadata($meta_name, $meta_value="", $entity_type="", $entity_subtype="", $owner_guid=0, $limit=10, $offset=0, $order_by="", $site_guid=0, $count=false)
Get entities for today from metadata.
elgg_disable_system_cache()
Disables the system disk cache.
Definition: cache.php:84
elgg_add_admin_notice($id, $message)
Write a persistent message to the admin view.
Definition: admin.php:75
$metadata
Definition: entity.php:19
user_add_friend($user_guid, $friend_guid)
Adds a user to another user's friends list.
elgg_invalidate_metadata_cache($action, array $options)
Invalidate the metadata cache based on options passed to various *_metadata functions.
elgg_get_system_cache()
Returns an object suitable for caching system information.
Definition: cache.php:20
setMetadata($name, $value, $value_type= '', $multiple=false, $owner_guid=0, $access_id=null)
Set metadata on this entity.
Definition: ElggEntity.php:400
_process_element(ODD $odd)
This function processes an element, passing elements to the plugin stack to see if someone will proce...
get_entity_from_uuid($uuid)
This function attempts to retrieve a previously imported entity via its UUID.
$data
Definition: opendd.php:13
$full_view
Elgg comment view.
Definition: comment.php:9
$path
Definition: details.php:88
$value
Definition: longtext.php:26
add_site_object($site_guid, $object_guid)
Add an object to a site.
elgg_unregister_entity_type($type, $subtype=null)
Unregisters an entity type and subtype as a public-facing type.
Definition: entities.php:541
get_todays_entities($type="", $subtype="", $owner_guid=0, $order_by="", $limit=10, $offset=0, $count=false, $site_guid=0, $container_guid=null)
Get all entities for today.
get_user_friends_of($user_guid, $subtype=ELGG_ENTITIES_ANY_VALUE, $limit=10, $offset=0)
Obtains the people who have made a given user a friend.
$subtype
Definition: delete.php:28
export_metadata_plugin_hook($hook, $entity_type, $returnvalue, $params)
Handler called by trigger_plugin_hook on the "export" event.
$friend
Definition: add.php:11
$return
Definition: opendd.php:15
create_group_entity($guid, $name, $description)
Create or update the entities table for a given group.
if(!$count) $offset
Definition: pagination.php:26
$pagination
Definition: gallery.php:22
$guid
Removes an admin notice.
$collection
add_site_user($site_guid, $user_guid)
Add a user to a site.
add_uuid_to_guid($guid, $uuid)
Tag a previously created guid with the uuid it was imported on.
elgg_register_metadata_url_handler($extender_name, $function)
Register a metadata url handler.
elgg_get_filepath_cache()
private
$email
Definition: register.php:15
$export
Definition: entity.php:13
elgg_get_entities_from_location(array $options=array())
Return entities within a given geographic area.
xml_to_object($xml)
Parse an XML file into an object.
if(isset($vars['id'])) $class
Definition: ajax_loader.php:19
elgg_filepath_cache_load($type)
private
object_notifications($event, $object_type, $object)
Automatically triggered notification on 'create' events that looks at registered objects and attempts...
export_annotation_plugin_hook($hook, $type, $returnvalue, $params)
Export the annotations for the specified entity.
$url
Definition: exceptions.php:24
remove_notification_interest($user_guid, $author_guid)
Remove a 'notify' relationship between the user and a content author.
$vars['entity']
$IMPORTED_OBJECT_COUNTER
elgg_get_calling_plugin_entity()
Returns the entity of the last plugin called.
add_metastring($string, $case_sensitive=true)
Add a metastring.
remove_user_from_access_collection($user_guid, $collection_id)
Removes a user from an access collection.
Definition: access.php:389
elgg_get_views($dir, $base)
Returns the name of views for in a directory.
$title
Definition: save.php:22
$options
Elgg admin footer.
Definition: footer.php:6
get_extender_url(\ElggExtender $extender)
Get the URL of a given elgg extender.
elgg_register_extender_url_handler($extender_type, $extender_name, $function_name)
Sets the URL handler for a particular extender type and name.
leave_group($group_guid, $user_guid)
Remove a user from a group.
create_user_entity($guid, $name, $username, $password, $salt, $email, $language, $code)
Create or update the entities table for a given user.
$string
getAttribute($key)
Returns an attribute.
Definition: ODD.php:55
get_day_end($day=null, $month=null, $year=null)
Return a timestamp for the end of a given day (defaults today).
get_notable_entities_from_metadata($start_time, $end_time, $meta_name, $meta_value="", $entity_type="", $entity_subtype="", $owner_guid=0, $limit=10, $offset=0, $order_by="", $site_guid=0, $count=false)
Return the notable entities for a given time period based on an item of metadata. ...
user_is_friend($user_guid, $friend_guid)
Determines whether or not a user is another user's friend.
elgg_disable_filepath_cache()
private
serialise_object_to_xml($data, $name="", $n=0)
This function serialises an object recursively into an XML representation.
elgg_get_viewtype()
Return the current view type.
Definition: views.php:94
get_metastring($id)
When given an ID, returns the corresponding metastring.
$params
Definition: login.php:72
$entity_guid
Definition: save.php:9
volatile_data_export_plugin_hook($hook, $entity_type, $returnvalue, $params)
Exports attributes generated on the fly (volatile) about an entity.
get_subtype_class($type, $subtype)
Return the class name for a registered type and subtype.
Definition: entities.php:57
already_attached($guid_one, $guid_two)
Function to determine if the object trying to attach to other, has already done so.
register_notification_interest($user_guid, $author_guid)
Establish a 'notify' relationship between the user and a content author.
enable_entity($guid, $recursive=true)
Enable an entity.
get_access_sql_suffix($table_prefix= '', $owner=null)
Returns the SQL where clause for a table with access_id and enabled columns.
export_relationship_plugin_hook($hook, $entity_type, $returnvalue, $params)
Handler called by trigger_plugin_hook on the "export" event.
export($guid)
Export a GUID.
_export_init()
Register the OpenDD import action.
elgg_register_annotation_url_handler($extender_name="all", $function_name)
Register an annotation url handler.
get_annotation_url($id)
Get the URL for this annotation.
delete_entity($guid, $recursive=true)
Delete an entity.
$owner_guid
if($prev_offset< 1) if($current_page==1) if(1< $start_page) if(1< ($start_page-2)) elseif($start_page==3) $max
Definition: pagination.php:95
get_user_access_collections($owner_guid, $site_guid=0)
Returns an array of database row objects of the access collections owned by $owner_guid.
Definition: access.php:403
get_entity_relationships($guid, $inverse_relationship=false)
Get all the relationships for a given GUID.
elgg_unregister_notification_method($name)
Unregister a delivery method for notifications.
get_user_friends_objects($user_guid, $subtype=ELGG_ENTITIES_ANY_VALUE, $limit=10, $offset=0, $timelower=0, $timeupper=0)
Obtains a list of objects owned by a user's friends.
$limit
Definition: userpicker.php:38
annotate($name, $value, $access_id=ACCESS_PRIVATE, $owner_guid=0, $vartype="")
Adds an annotation to an entity.
Definition: ElggEntity.php:815
if($categories) $description
Definition: full.php:166
get_data_row($query, $callback=null, array $params=[])
Retrieve a single row from the database.
Definition: database.php:72
elgg_get_annotation_from_id($id)
Get a specific annotation by its id.
Definition: annotations.php:36
full_url()
Return the full URL of the current page.
elgg_autop($string)
Create paragraphs from text with line spacing.
Definition: output.php:56
elgg_create_river_item(array $options=array())
Adds an item to the river.
Definition: river.php:37
$owner
Definition: crop.php:8
elgg_check_access_overrides($user_guid=0)
Decides if the access system should be ignored for a user.
Definition: access.php:503
$key
Definition: summary.php:34
get_user($guid)
Get a user object from a GUID.
Definition: users.php:87
update_data($query, array $params=[], $get_num_rows=false)
Update a row in the database.
Definition: database.php:102
ODD_factory(XmlElement $element)
Attempt to construct an ODD object out of a XmlElement or sub-elements.
$language
Definition: useradd.php:20
elgg_view_entity(\ElggEntity $entity, array $vars=array(), $bypass=false, $debug=false)
Returns a string of a rendered entity.
Definition: views.php:832
register_notification_object($entity_type, $object_subtype, $language_name)
Register an entity type and subtype to be eligible for notifications.
get_input($variable, $default=null, $filter_result=true)
Get some input from variables passed submitted through GET or POST.
Definition: input.php:27
execute_delayed_write_query($query, $callback=null, array $params=[])
Queue a query for running during shutdown that writes to the database.
Definition: database.php:21
$plugin_id
Definition: save.php:16
$item
Definition: item.php:12
global $CONFIG
create_metadata($entity_guid, $name, $value, $value_type= '', $owner_guid=0, $access_id=ACCESS_PRIVATE, $allow_multiple=false)
Create a new metadata object, or update an existing one.
Definition: metadata.php:65
get_site_domain($guid)
Retrieve a site and return the domain portion of its url.
elgg_geocode_location($location)
Encode a location into a latitude and longitude, caching the result.
sanitise_string($string)
Alias of sanitize_string.
Definition: database.php:166
$user
Definition: ban.php:13
elgg_set_viewtype($viewtype="")
Manually set the viewtype.
Definition: views.php:73
const ELGG_ENTITIES_ANY_VALUE
Definition: elgglib.php:2001
expose_function($method, $function, array $parameters=NULL, $description="", $call_method="GET", $require_api_auth=false, $require_user_auth=false)
Register a function as a web service method.
elgg_trigger_plugin_hook($hook, $type, $params=null, $returnvalue=null)
Definition: elgglib.php:801
get_day_start($day=null, $month=null, $year=null)
Return a timestamp for the start of a given day (defaults today).
elgg_regenerate_simplecache($viewtype=NULL)
Regenerates the simple cache.
check_entity_relationship($guid_one, $relationship, $guid_two)
Check if a relationship exists between two entities.
elgg_deprecated_notice($msg, $dep_version, $backtrace_level=1)
Log a notice about deprecated use of a function, view, etc.
Definition: elgglib.php:1070
elgg_get_site_url($site_guid=0)
Get the URL for the current (or specified) site.
get_relationship_url($id)
Get the url for a given relationship.
$friend_guid
Definition: add.php:10
get_data($query, $callback=null, array $params=[])
Retrieve rows from the database.
Definition: database.php:55
_elgg_services(\Elgg\Di\ServiceProvider $services=null)
Get the global service provider.
Definition: autoloader.php:17
access_get_show_hidden_status()
Return current status of showing disabled entities.
Definition: access.php:170
elgg_list_entities_from_location(array $options=array())
Returns a viewable list of entities from location.
generate_tag_cloud(array $tags, $buckets=6)
This function generates an array of tags with a weighting.
get_entity_as_row($guid)
Returns a database row from the entities table.
Definition: entities.php:174
$password
Definition: login.php:25
oddmetadata_to_elggextender(\ElggEntity $entity, ODDMetaData $element)
Utility function used by import_extender_plugin_hook() to process an ODDMetaData and add it to an ent...
get_entity_url($entity_guid)
Returns the URL for an entity.
list_notable_entities($start_time, $end_time, $type="", $subtype="", $owner_guid=0, $limit=10, $fullview=true, $listtypetoggle=false, $navigation=true)
Returns a viewable list of entities for a given time period.
guid_to_uuid($guid)
Generate a UUID from a given GUID.
elgg_register_entity_url_handler($entity_type, $entity_subtype, $function_name)
Sets the URL handler for a particular entity type and subtype.
$IMPORTED_DATA
elgg_list_entities_from_relationship(array $options=array())
Returns a viewable list of entities by relationship.
elgg_view_tree($view_root, $viewtype="")
Returns all views below a partial view.
$posted
Definition: comment.php:83
elgg_view_entity_list($entities, array $vars=array())
Returns a rendered list of entities with pagination.
Definition: views.php:1007
elgg_list_entities(array $options=array(), $getter= 'elgg_get_entities', $viewer= 'elgg_view_entity_list')
Returns a string of rendered entities.
Definition: entities.php:382
$size
Definition: default.php:20
elgg_load_system_cache($type)
Retrieve the contents of a system cache.
Definition: cache.php:50
elgg_get_version($human_readable=false)
Get the current Elgg version information.
Definition: elgglib.php:1043
add_object_to_group($group_guid, $object_guid)
Add an object to the given group.
access_show_hidden_entities($show_hidden)
Show or hide disabled entities.
Definition: access.php:158
user_remove_friend($user_guid, $friend_guid)
Removes a user from another user's friends list.
elgg_register_notification_event($object_type, $object_subtype, array $actions=array())
Register a notification event.
elgg_get_metadata(array $options=array())
Returns metadata.
Definition: metadata.php:143
can_edit_entity($entity_guid, $user_guid=0)
Returns if $user_guid is able to edit $entity_guid.
import_entity_plugin_hook($hook, $entity_type, $returnvalue, $params)
Import an entity.
make_attachment($guid_one, $guid_two)
Function to start the process of attaching one object to another.
elgg_get_annotations(array $options=array())
Returns annotations.
Definition: ODD.php:9
unregister_service_handler($handler)
Remove a web service To replace a web service handler, register the desired handler over the old on w...
elgg_save_system_cache($type, $data)
Saves a system cache.
Definition: cache.php:40
list_todays_entities($type="", $subtype="", $owner_guid=0, $limit=10, $fullview=true, $listtypetoggle=false, $navigation=true)
Return a list of today's entities.
can_edit_extender($extender_id, $type, $user_guid=0)
Determines whether or not the specified user can edit the specified piece of extender.
get_users_membership($user_guid)
Return all groups a user is a member of.
setup_db_connections()
Establish database connections.
join_group($group_guid, $user_guid)
Join a user to a group.
disable_entity($guid, $reason="", $recursive=true)
Disable an entity.
global $METASTRINGS_DEADNAME_CACHE
$entity
Definition: delete.php:7
set($name, $value)
Sets the value of an attribute or metadata.
Definition: ElggEntity.php:234
if(elgg_in_context('widget')) $count
Definition: pagination.php:21
serialise_array_to_xml(array $data, $n=0)
Serialise an array.
oddentity_to_elggentity(ODDEntity $element)
Utility function used by import_entity_plugin_hook() to process an ODDEntity into an unsaved ...
$row
elgg_get_logged_in_user_entity()
Return the current logged in user, or null if no user is logged in.
Definition: sessions.php:32
is_memcache_available()
Return true if memcache is available and configured.
Definition: memcache.php:16
import_extender_plugin_hook($hook, $entity_type, $returnvalue, $params)
Handler called by trigger_plugin_hook on the "import" event.
elgg_register_relationship_url_handler($relationship_type, $function_name)
Sets the URL handler for a particular relationship type.
$container_guid
$handler
Definition: add.php:10
elgg_register_action($action, $filename="", $access= 'logged_in')
Registers an action.
Definition: actions.php:85
elgg_get_entities_from_relationship($options)
Return entities matching a given query joining against a relationship.
$output
Definition: item.php:10
can_edit_entity_metadata($entity_guid, $user_guid=0, $metadata=null)
Returns if $user_guid can edit the metadata on $entity_guid.
register_notification_handler($method, $handler, $params=NULL)
This function registers a handler for a given notification type (eg "email")
get_user_friends($user_guid, $subtype=ELGG_ENTITIES_ANY_VALUE, $limit=10, $offset=0)
Obtains a given user's friends.
$user_guid
Avatar remove action.
Definition: remove.php:6
count_user_friends_objects($user_guid, $subtype=ELGG_ENTITIES_ANY_VALUE, $timelower=0, $timeupper=0)
Counts the number of objects owned by a user's friends.
_elgg_get_access_where_sql(array $options=array())
Returns the SQL where clause for enforcing read access to data.
Definition: access.php:214
elgg_trigger_event($event, $object_type, $object=null)
Definition: elgglib.php:589
add_to_river($view, $action_type, $subject_guid, $object_guid, $access_id="", $posted=0, $annotation_id=0, $target_guid=0)
Adds an item to the river.
if(!$collection_name) $id
Definition: add.php:17
get_notable_entities($start_time, $end_time, $type="", $subtype="", $owner_guid=0, $order_by="asc", $limit=10, $offset=0, $count=false, $site_guid=0, $container_guid=null)
Return the notable entities for a given time period.
sanitise_string_special($string, $extra_escapeable= '')
Sanitise a string for database use, but with the option of escaping extra characters.
register_service_handler($handler, $function)
Registers a web services handler.
is_group_member($group_guid, $user_guid)
Return whether a given user is a member of the group or not.
_elgg_invalidate_metadata_cache($action, array $options)
Invalidate the metadata cache based on options passed to various *_metadata functions.
Definition: metadata.php:385
elgg_get_logged_in_user_guid()
Return the current logged in user by guid.
Definition: sessions.php:42
get_user_sites($user_guid, $limit=10, $offset=0)
Get the sites this user is part of.
elgg_get_plugin_from_id($plugin_id)
Returns an object with the path $path.
Definition: plugins.php:82
unexpose_function($method)
Unregister a web services method.
get_entity($guid)
Loads and returns an entity object from a guid.
Definition: entities.php:204
elgg_filepath_cache_reset()
private
remove_object_from_group($group_guid, $object_guid)
Remove an object from the given group.
create_site_entity($guid, $name, $description, $url)
Create or update the entities table for a given site.
remove_attachment($guid_one, $guid_two)
Function to remove a particular attachment between two objects.
if(!$display_name) $type
Definition: delete.php:27
unregister_entity_type($type, $subtype)
Unregisters an entity type and subtype as a public-facing type.
create_object_entity($guid, $title, $description)
Create or update the extras table for a given object.