Elgg  Version 1.11
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);
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);
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);
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 
1261 function get_db_link($dblinktype) {
1262  elgg_deprecated_notice(__FUNCTION__ . ' is a private function and should not be used.', 1.9);
1263  return _elgg_services()->db->getLink($dblinktype);
1264 }
1265 
1278  elgg_deprecated_notice(__FUNCTION__ . ' is a private function and should not be used.', 1.9);
1280  return _elgg_services()->db->updateData("OPTIMIZE TABLE $table");
1281 }
1282 
1292 function get_db_tables() {
1293  elgg_deprecated_notice(__FUNCTION__ . ' is a private function and should not be used.', 1.9);
1294  static $tables;
1295 
1296  if (isset($tables)) {
1297  return $tables;
1298  }
1299 
1300  $table_prefix = elgg_get_config('dbprefix');
1301  $result = get_data("SHOW TABLES LIKE '$table_prefix%'");
1302 
1303  $tables = array();
1304  if (is_array($result) && !empty($result)) {
1305  foreach ($result as $row) {
1306  $row = (array) $row;
1307  if (is_array($row) && !empty($row)) {
1308  foreach ($row as $element) {
1309  $tables[] = $element;
1310  }
1311  }
1312  }
1313  }
1314 
1315  return $tables;
1316 }
1317 
1327 function get_db_error($dblink) {
1328  elgg_deprecated_notice(__FUNCTION__ . ' is a private function and should not be used.', 1.9);
1329  return mysql_error($dblink);
1330 }
1331 
1345 function execute_delayed_query($query, $dblink, $handler = "") {
1346  elgg_deprecated_notice("execute_delayed_query() has been deprecated", 1.9);
1347  return _elgg_services()->db->registerDelayedQuery($query, $dblink, $handler);
1348 }
1349 
1361 function get_day_start($day = null, $month = null, $year = null) {
1362  elgg_deprecated_notice('get_day_start() has been deprecated', 1.9);
1363  return mktime(0, 0, 0, $month, $day, $year);
1364 }
1365 
1377 function get_day_end($day = null, $month = null, $year = null) {
1378  elgg_deprecated_notice('get_day_end() has been deprecated', 1.9);
1379  return mktime(23, 59, 59, $month, $day, $year);
1380 }
1381 
1403 function get_notable_entities($start_time, $end_time, $type = "", $subtype = "", $owner_guid = 0,
1404 $order_by = "asc", $limit = 10, $offset = 0, $count = false, $site_guid = 0,
1405 $container_guid = null) {
1406  elgg_deprecated_notice('get_notable_entities() has been deprecated', 1.9);
1407  global $CONFIG;
1408 
1409  if ($subtype === false || $subtype === null || $subtype === 0) {
1410  return false;
1411  }
1412 
1413  $start_time = (int)$start_time;
1414  $end_time = (int)$end_time;
1415  $order_by = sanitise_string($order_by);
1416  $limit = (int)$limit;
1417  $offset = (int)$offset;
1418  $site_guid = (int) $site_guid;
1419  if ($site_guid == 0) {
1420  $site_guid = $CONFIG->site_guid;
1421  }
1422 
1423  $where = array();
1424 
1425  if (is_array($type)) {
1426  $tempwhere = "";
1427  if (sizeof($type)) {
1428  foreach ($type as $typekey => $subtypearray) {
1429  foreach ($subtypearray as $subtypeval) {
1430  $typekey = sanitise_string($typekey);
1431  if (!empty($subtypeval)) {
1432  $subtypeval = (int) get_subtype_id($typekey, $subtypeval);
1433  } else {
1434  $subtypeval = 0;
1435  }
1436  if (!empty($tempwhere)) {
1437  $tempwhere .= " or ";
1438  }
1439  $tempwhere .= "(e.type = '{$typekey}' and e.subtype = {$subtypeval})";
1440  }
1441  }
1442  }
1443  if (!empty($tempwhere)) {
1444  $where[] = "({$tempwhere})";
1445  }
1446  } else {
1449 
1450  if ($type != "") {
1451  $where[] = "e.type='$type'";
1452  }
1453 
1454  if ($subtype !== "") {
1455  $where[] = "e.subtype=$subtype";
1456  }
1457  }
1458 
1459  if ($owner_guid != "") {
1460  if (!is_array($owner_guid)) {
1461  $owner_array = array($owner_guid);
1462  $owner_guid = (int) $owner_guid;
1463  $where[] = "e.owner_guid = '$owner_guid'";
1464  } else if (sizeof($owner_guid) > 0) {
1465  $owner_array = array_map('sanitise_int', $owner_guid);
1466  // Cast every element to the owner_guid array to int
1467  $owner_guid = implode(",", $owner_guid);
1468  $where[] = "e.owner_guid in ({$owner_guid})";
1469  }
1470  if (is_null($container_guid)) {
1471  $container_guid = $owner_array;
1472  }
1473  }
1474 
1475  if ($site_guid > 0) {
1476  $where[] = "e.site_guid = {$site_guid}";
1477  }
1478 
1479  if (!is_null($container_guid)) {
1480  if (is_array($container_guid)) {
1481  foreach ($container_guid as $key => $val) {
1482  $container_guid[$key] = (int) $val;
1483  }
1484  $where[] = "e.container_guid in (" . implode(",", $container_guid) . ")";
1485  } else {
1487  $where[] = "e.container_guid = {$container_guid}";
1488  }
1489  }
1490 
1491  // Add the calendar stuff
1492  $cal_join = "
1493  JOIN {$CONFIG->dbprefix}metadata cal_start on e.guid=cal_start.entity_guid
1494  JOIN {$CONFIG->dbprefix}metastrings cal_start_name on cal_start.name_id=cal_start_name.id
1495  JOIN {$CONFIG->dbprefix}metastrings cal_start_value on cal_start.value_id=cal_start_value.id
1496 
1497  JOIN {$CONFIG->dbprefix}metadata cal_end on e.guid=cal_end.entity_guid
1498  JOIN {$CONFIG->dbprefix}metastrings cal_end_name on cal_end.name_id=cal_end_name.id
1499  JOIN {$CONFIG->dbprefix}metastrings cal_end_value on cal_end.value_id=cal_end_value.id
1500  ";
1501  $where[] = "cal_start_name.string='calendar_start'";
1502  $where[] = "cal_start_value.string>=$start_time";
1503  $where[] = "cal_end_name.string='calendar_end'";
1504  $where[] = "cal_end_value.string <= $end_time";
1505 
1506 
1507  if (!$count) {
1508  $query = "SELECT e.* from {$CONFIG->dbprefix}entities e $cal_join where ";
1509  } else {
1510  $query = "SELECT count(e.guid) as total from {$CONFIG->dbprefix}entities e $cal_join where ";
1511  }
1512  foreach ($where as $w) {
1513  $query .= " $w and ";
1514  }
1515 
1516  $query .= _elgg_get_access_where_sql();
1517 
1518  if (!$count) {
1519  $query .= " order by n.calendar_start $order_by";
1520  // Add order and limit
1521  if ($limit) {
1522  $query .= " limit $offset, $limit";
1523  }
1524  $dt = get_data($query, "entity_row_to_elggstar");
1525 
1526  return $dt;
1527  } else {
1528  $total = get_data_row($query);
1529  return $total->total;
1530  }
1531 }
1532 
1553 function get_notable_entities_from_metadata($start_time, $end_time, $meta_name, $meta_value = "",
1554 $entity_type = "", $entity_subtype = "", $owner_guid = 0, $limit = 10, $offset = 0, $order_by = "",
1555 $site_guid = 0, $count = false) {
1556  elgg_deprecated_notice('get_notable_entities_from_metadata() has been deprecated', 1.9);
1557 
1558  global $CONFIG;
1559 
1560  $meta_n = get_metastring_id($meta_name);
1561  $meta_v = get_metastring_id($meta_value);
1562 
1563  $start_time = (int)$start_time;
1564  $end_time = (int)$end_time;
1565  $entity_type = sanitise_string($entity_type);
1566  $entity_subtype = get_subtype_id($entity_type, $entity_subtype);
1567  $limit = (int)$limit;
1568  $offset = (int)$offset;
1569  if ($order_by == "") {
1570  $order_by = "e.time_created desc";
1571  }
1572  $order_by = sanitise_string($order_by);
1573  $site_guid = (int) $site_guid;
1574  if ((is_array($owner_guid) && (count($owner_guid)))) {
1575  foreach ($owner_guid as $key => $guid) {
1576  $owner_guid[$key] = (int) $guid;
1577  }
1578  } else {
1579  $owner_guid = (int) $owner_guid;
1580  }
1581 
1582  if ($site_guid == 0) {
1583  $site_guid = $CONFIG->site_guid;
1584  }
1585 
1586  //$access = get_access_list();
1587 
1588  $where = array();
1589 
1590  if ($entity_type != "") {
1591  $where[] = "e.type='$entity_type'";
1592  }
1593 
1594  if ($entity_subtype) {
1595  $where[] = "e.subtype=$entity_subtype";
1596  }
1597 
1598  if ($meta_name != "") {
1599  $where[] = "m.name_id='$meta_n'";
1600  }
1601 
1602  if ($meta_value != "") {
1603  $where[] = "m.value_id='$meta_v'";
1604  }
1605 
1606  if ($site_guid > 0) {
1607  $where[] = "e.site_guid = {$site_guid}";
1608  }
1609 
1610  if (is_array($owner_guid)) {
1611  $where[] = "e.container_guid in (" . implode(",", $owner_guid) . ")";
1612  } else if ($owner_guid > 0) {
1613  $where[] = "e.container_guid = {$owner_guid}";
1614  }
1615 
1616  // Add the calendar stuff
1617  $cal_join = "
1618  JOIN {$CONFIG->dbprefix}metadata cal_start on e.guid=cal_start.entity_guid
1619  JOIN {$CONFIG->dbprefix}metastrings cal_start_name on cal_start.name_id=cal_start_name.id
1620  JOIN {$CONFIG->dbprefix}metastrings cal_start_value on cal_start.value_id=cal_start_value.id
1621 
1622  JOIN {$CONFIG->dbprefix}metadata cal_end on e.guid=cal_end.entity_guid
1623  JOIN {$CONFIG->dbprefix}metastrings cal_end_name on cal_end.name_id=cal_end_name.id
1624  JOIN {$CONFIG->dbprefix}metastrings cal_end_value on cal_end.value_id=cal_end_value.id
1625  ";
1626 
1627  $where[] = "cal_start_name.string='calendar_start'";
1628  $where[] = "cal_start_value.string>=$start_time";
1629  $where[] = "cal_end_name.string='calendar_end'";
1630  $where[] = "cal_end_value.string <= $end_time";
1631 
1632  if (!$count) {
1633  $query = "SELECT distinct e.* ";
1634  } else {
1635  $query = "SELECT count(distinct e.guid) as total ";
1636  }
1637 
1638  $query .= "from {$CONFIG->dbprefix}entities e"
1639  . " JOIN {$CONFIG->dbprefix}metadata m on e.guid = m.entity_guid $cal_join where";
1640 
1641  foreach ($where as $w) {
1642  $query .= " $w and ";
1643  }
1644 
1645  // Add access controls
1646  $query .= _elgg_get_access_where_sql(array('table_alias' => 'e'));
1647  $query .= ' and ' . _elgg_get_access_where_sql(array('table_alias' => "m"));
1648 
1649  if (!$count) {
1650  // Add order and limit
1651  $query .= " order by $order_by limit $offset, $limit";
1652  return get_data($query, "entity_row_to_elggstar");
1653  } else {
1654  if ($row = get_data_row($query)) {
1655  return $row->total;
1656  }
1657  }
1658 
1659  return false;
1660 }
1661 
1685 function get_noteable_entities_from_relationship($start_time, $end_time, $relationship,
1686 $relationship_guid, $inverse_relationship = false, $type = "", $subtype = "", $owner_guid = 0,
1687 $order_by = "", $limit = 10, $offset = 0, $count = false, $site_guid = 0) {
1688  elgg_deprecated_notice('get_noteable_entities_from_relationship() has been deprecated', 1.9);
1689 
1690  global $CONFIG;
1691 
1692  $start_time = (int)$start_time;
1693  $end_time = (int)$end_time;
1694  $relationship = sanitise_string($relationship);
1695  $relationship_guid = (int)$relationship_guid;
1696  $inverse_relationship = (bool)$inverse_relationship;
1699  $owner_guid = (int)$owner_guid;
1700  if ($order_by == "") {
1701  $order_by = "time_created desc";
1702  }
1703  $order_by = sanitise_string($order_by);
1704  $limit = (int)$limit;
1705  $offset = (int)$offset;
1706  $site_guid = (int) $site_guid;
1707  if ($site_guid == 0) {
1708  $site_guid = $CONFIG->site_guid;
1709  }
1710 
1711  //$access = get_access_list();
1712 
1713  $where = array();
1714 
1715  if ($relationship != "") {
1716  $where[] = "r.relationship='$relationship'";
1717  }
1718  if ($relationship_guid) {
1719  $where[] = $inverse_relationship ?
1720  "r.guid_two='$relationship_guid'" : "r.guid_one='$relationship_guid'";
1721  }
1722  if ($type != "") {
1723  $where[] = "e.type='$type'";
1724  }
1725  if ($subtype) {
1726  $where[] = "e.subtype=$subtype";
1727  }
1728  if ($owner_guid != "") {
1729  $where[] = "e.container_guid='$owner_guid'";
1730  }
1731  if ($site_guid > 0) {
1732  $where[] = "e.site_guid = {$site_guid}";
1733  }
1734 
1735  // Add the calendar stuff
1736  $cal_join = "
1737  JOIN {$CONFIG->dbprefix}metadata cal_start on e.guid=cal_start.entity_guid
1738  JOIN {$CONFIG->dbprefix}metastrings cal_start_name on cal_start.name_id=cal_start_name.id
1739  JOIN {$CONFIG->dbprefix}metastrings cal_start_value on cal_start.value_id=cal_start_value.id
1740 
1741  JOIN {$CONFIG->dbprefix}metadata cal_end on e.guid=cal_end.entity_guid
1742  JOIN {$CONFIG->dbprefix}metastrings cal_end_name on cal_end.name_id=cal_end_name.id
1743  JOIN {$CONFIG->dbprefix}metastrings cal_end_value on cal_end.value_id=cal_end_value.id
1744  ";
1745  $where[] = "cal_start_name.string='calendar_start'";
1746  $where[] = "cal_start_value.string>=$start_time";
1747  $where[] = "cal_end_name.string='calendar_end'";
1748  $where[] = "cal_end_value.string <= $end_time";
1749 
1750  // Select what we're joining based on the options
1751  $joinon = "e.guid = r.guid_one";
1752  if (!$inverse_relationship) {
1753  $joinon = "e.guid = r.guid_two";
1754  }
1755 
1756  if ($count) {
1757  $query = "SELECT count(distinct e.guid) as total ";
1758  } else {
1759  $query = "SELECT distinct e.* ";
1760  }
1761  $query .= " from {$CONFIG->dbprefix}entity_relationships r"
1762  . " JOIN {$CONFIG->dbprefix}entities e on $joinon $cal_join where ";
1763 
1764  foreach ($where as $w) {
1765  $query .= " $w and ";
1766  }
1767  // Add access controls
1768  $query .= _elgg_get_access_where_sql();
1769  if (!$count) {
1770  $query .= " order by $order_by limit $offset, $limit"; // Add order and limit
1771  return get_data($query, "entity_row_to_elggstar");
1772  } else {
1773  if ($count = get_data_row($query)) {
1774  return $count->total;
1775  }
1776  }
1777  return false;
1778 }
1779 
1797 function get_todays_entities($type = "", $subtype = "", $owner_guid = 0, $order_by = "",
1798 $limit = 10, $offset = 0, $count = false, $site_guid = 0, $container_guid = null) {
1799  elgg_deprecated_notice('get_todays_entities() has been deprecated', 1.9);
1800 
1801  $day_start = get_day_start();
1802  $day_end = get_day_end();
1803 
1804  return get_notable_entities($day_start, $day_end, $type, $subtype, $owner_guid, $order_by,
1805  $limit, $offset, $count, $site_guid, $container_guid);
1806 }
1807 
1826 function get_todays_entities_from_metadata($meta_name, $meta_value = "", $entity_type = "",
1827 $entity_subtype = "", $owner_guid = 0, $limit = 10, $offset = 0, $order_by = "", $site_guid = 0,
1828 $count = false) {
1829  elgg_deprecated_notice('get_todays_entities_from_metadata() has been deprecated', 1.9);
1830 
1831  $day_start = get_day_start();
1832  $day_end = get_day_end();
1833 
1834  return get_notable_entities_from_metadata($day_start, $day_end, $meta_name, $meta_value,
1835  $entity_type, $entity_subtype, $owner_guid, $limit, $offset, $order_by, $site_guid, $count);
1836 }
1837 
1859 function get_todays_entities_from_relationship($relationship, $relationship_guid,
1860 $inverse_relationship = false, $type = "", $subtype = "", $owner_guid = 0,
1861 $order_by = "", $limit = 10, $offset = 0, $count = false, $site_guid = 0) {
1862  elgg_deprecated_notice('get_todays_entities_from_relationship() has been deprecated', 1.9);
1863 
1864  $day_start = get_day_start();
1865  $day_end = get_day_end();
1866 
1867  return get_notable_entities_from_relationship($day_start, $day_end, $relationship,
1868  $relationship_guid, $inverse_relationship, $type, $subtype, $owner_guid, $order_by,
1869  $limit, $offset, $count, $site_guid);
1870 }
1871 
1891 function list_notable_entities($start_time, $end_time, $type= "", $subtype = "", $owner_guid = 0,
1892 $limit = 10, $fullview = true, $listtypetoggle = false, $navigation = true) {
1893  elgg_deprecated_notice('list_notable_entities() has been deprecated', 1.9);
1894 
1895  $offset = (int) get_input('offset');
1896  $count = get_notable_entities($start_time, $end_time, $type, $subtype,
1897  $owner_guid, "", $limit, $offset, true);
1898 
1899  $entities = get_notable_entities($start_time, $end_time, $type, $subtype,
1900  $owner_guid, "", $limit, $offset);
1901 
1902  return elgg_view_entity_list($entities, $count, $offset, $limit,
1903  $fullview, $listtypetoggle, $navigation);
1904 }
1905 
1923 function list_todays_entities($type= "", $subtype = "", $owner_guid = 0, $limit = 10,
1924 $fullview = true, $listtypetoggle = false, $navigation = true) {
1925  elgg_deprecated_notice('list_todays_entities() has been deprecated', 1.9);
1926 
1927  $day_start = get_day_start();
1928  $day_end = get_day_end();
1929 
1930  return list_notable_entities($day_start, $day_end, $type, $subtype, $owner_guid, $limit,
1931  $fullview, $listtypetoggle, $navigation);
1932 }
1933 
1948  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated by elgg_invalidate_simplecache()', 1.9);
1950 }
1951 
1957  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated by elgg_get_system_cache()', 1.9);
1958  return elgg_get_system_cache();
1959 }
1965  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated by elgg_reset_system_cache()', 1.9);
1967 }
1973  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated by elgg_save_system_cache()', 1.9);
1975 }
1981  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated by elgg_load_system_cache()', 1.9);
1982  return elgg_load_system_cache($type);
1983 }
1989  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated by elgg_enable_system_cache()', 1.9);
1991 }
1997  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated by elgg_disable_system_cache()', 1.9);
1999 }
2000 
2014  elgg_deprecated_notice("unregister_entity_type() was deprecated by elgg_unregister_entity_type()", 1.9);
2016 }
2017 
2028 function already_attached($guid_one, $guid_two) {
2029  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated', 1.9);
2030  if ($attached = check_entity_relationship($guid_one, "attached", $guid_two)) {
2031  return true;
2032  } else {
2033  return false;
2034  }
2035 }
2036 
2047 function get_attachments($guid, $type = "") {
2048  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated', 1.9);
2049  $options = array(
2050  'relationship' => 'attached',
2051  'relationship_guid' => $guid,
2052  'inverse_relationship' => false,
2053  'types' => $type,
2054  'subtypes' => '',
2055  'owner_guid' => 0,
2056  'order_by' => 'time_created desc',
2057  'limit' => 10,
2058  'offset' => 0,
2059  'count' => false,
2060  'site_guid' => 0
2061  );
2063  return $attached;
2064 }
2065 
2076 function remove_attachment($guid_one, $guid_two) {
2077  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated', 1.9);
2078  if (already_attached($guid_one, $guid_two)) {
2079  remove_entity_relationship($guid_one, "attached", $guid_two);
2080  }
2081 }
2082 
2093 function make_attachment($guid_one, $guid_two) {
2094  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated', 1.9);
2095  if (!(already_attached($guid_one, $guid_two))) {
2096  if (add_entity_relationship($guid_one, "attached", $guid_two)) {
2097  return true;
2098  }
2099  }
2100 }
2101 
2111  elgg_deprecated_notice('get_entity_url has been deprecated in favor of \ElggEntity::getURL', '1.9');
2112  if ($entity = get_entity($entity_guid)) {
2113  return $entity->getURL();
2114  }
2115 
2116  return false;
2117 }
2118 
2139 function delete_entity($guid, $recursive = true) {
2140  elgg_deprecated_notice('delete_entity has been deprecated in favor of \ElggEntity::delete', '1.9');
2141  $guid = (int)$guid;
2142  if ($entity = get_entity($guid)) {
2143  return $entity->delete($recursive);
2144  }
2145  return false;
2146 }
2147 
2160 function enable_entity($guid, $recursive = true) {
2161  elgg_deprecated_notice('enable_entity has been deprecated in favor of elgg_enable_entity', '1.9');
2162 
2163  $guid = (int)$guid;
2164 
2165  // Override access only visible entities
2166  $old_access_status = access_get_show_hidden_status();
2168 
2169  $result = false;
2170  if ($entity = get_entity($guid)) {
2171  $result = $entity->enable($recursive);
2172  }
2173 
2174  access_show_hidden_entities($old_access_status);
2175  return $result;
2176 }
2177 
2194  elgg_deprecated_notice('can_edit_entity_metadata has been deprecated in favor of \ElggEntity::canEditMetadata', '1.9');
2195  if ($entity = get_entity($entity_guid)) {
2196  return $entity->canEditMetadata($metadata, $user_guid);
2197  } else {
2198  return false;
2199  }
2200 }
2201 
2222 function disable_entity($guid, $reason = "", $recursive = true) {
2223  elgg_deprecated_notice('disable_entity was deprecated in favor of \ElggEntity::disable', '1.9');
2224 
2225  if ($entity = get_entity($guid)) {
2226  return $entity->disable($reason, $recursive);
2227  }
2228 
2229  return false;
2230 }
2231 
2246  elgg_deprecated_notice('can_edit_entity was deprecated in favor of \ElggEntity::canEdit', '1.9');
2247  if ($entity = get_entity($entity_guid)) {
2248  return $entity->canEdit($user_guid);
2249  }
2250 
2251  return false;
2252 }
2253 
2263 function join_group($group_guid, $user_guid) {
2264  elgg_deprecated_notice('join_group was deprecated in favor of \ElggGroup::join', '1.9');
2265 
2266  $group = get_entity($group_guid);
2268 
2269  if ($group instanceof \ElggGroup && $user instanceof \ElggUser) {
2270  return $group->join($user);
2271  }
2272 
2273  return false;
2274 }
2275 
2285 function leave_group($group_guid, $user_guid) {
2286  elgg_deprecated_notice('leave_group was deprecated in favor of \ElggGroup::leave', '1.9');
2287  $group = get_entity($group_guid);
2289 
2290  if ($group instanceof \ElggGroup && $user instanceof \ElggUser) {
2291  return $group->leave($user);
2292  }
2293 
2294  return false;
2295 }
2296 
2304 function autop($string) {
2305  elgg_deprecated_notice('autop has been deprecated in favor of elgg_autop', '1.9');
2306  return elgg_autop($string);
2307 }
2308 
2314 function expose_function($method, $function, array $parameters = NULL, $description = "",
2315  $call_method = "GET", $require_api_auth = false, $require_user_auth = false) {
2316  elgg_deprecated_notice("expose_function() deprecated for the function elgg_ws_expose_function() in web_services plugin", 1.9);
2317  if (!elgg_admin_notice_exists("elgg:ws:1.9")) {
2318  elgg_add_admin_notice("elgg:ws:1.9", "The web services are now a plugin in Elgg 1.9.
2319  You must enable this plugin and update your web services to use elgg_ws_expose_function().");
2320  }
2321 
2322  if (function_exists("elgg_ws_expose_function")) {
2323  return elgg_ws_expose_function($method, $function, $parameters, $description, $call_method, $require_api_auth, $require_user_auth);
2324  }
2325 }
2326 
2335  elgg_deprecated_notice("unexpose_function() deprecated for the function elgg_ws_unexpose_function() in web_services plugin", 1.9);
2336  if (function_exists("elgg_ws_unexpose_function")) {
2337  return elgg_ws_unexpose_function($method);
2338  }
2339 }
2340 
2349 function register_service_handler($handler, $function) {
2350  elgg_deprecated_notice("register_service_handler() deprecated for the function elgg_ws_register_service_handler() in web_services plugin", 1.9);
2351  if (function_exists("elgg_ws_register_service_handler")) {
2352  return elgg_ws_register_service_handler($handler, $function);
2353  }
2354 }
2355 
2366  elgg_deprecated_notice("unregister_service_handler() deprecated for the function elgg_ws_unregister_service_handler() in web_services plugin", 1.9);
2367  if (function_exists("elgg_ws_unregister_service_handler")) {
2368  return elgg_ws_unregister_service_handler($handler);
2369  }
2370 }
2371 
2386  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use \ElggSite constructor', 1.9);
2387  global $CONFIG;
2388 
2389  $guid = (int)$guid;
2393 
2395 
2396  if ($row) {
2397  // Exists and you have access to it
2398  $query = "SELECT guid from {$CONFIG->dbprefix}sites_entity where guid = {$guid}";
2399  if ($exists = get_data_row($query)) {
2400  $query = "UPDATE {$CONFIG->dbprefix}sites_entity
2401  set name='$name', description='$description', url='$url' where guid=$guid";
2402  $result = update_data($query);
2403 
2404  if ($result != false) {
2405  // Update succeeded, continue
2407  if (elgg_trigger_event('update', $entity->type, $entity)) {
2408  return $guid;
2409  } else {
2410  $entity->delete();
2411  //delete_entity($guid);
2412  }
2413  }
2414  } else {
2415  // Update failed, attempt an insert.
2416  $query = "INSERT into {$CONFIG->dbprefix}sites_entity
2417  (guid, name, description, url) values ($guid, '$name', '$description', '$url')";
2418  $result = insert_data($query);
2419 
2420  if ($result !== false) {
2422  if (elgg_trigger_event('create', $entity->type, $entity)) {
2423  return $guid;
2424  } else {
2425  $entity->delete();
2426  //delete_entity($guid);
2427  }
2428  }
2429  }
2430  }
2431 
2432  return false;
2433 }
2434 
2448  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use \ElggGroup constructor', 1.9);
2449  global $CONFIG;
2450 
2451  $guid = (int)$guid;
2454 
2456 
2457  if ($row) {
2458  // Exists and you have access to it
2459  $exists = get_data_row("SELECT guid from {$CONFIG->dbprefix}groups_entity WHERE guid = {$guid}");
2460  if ($exists) {
2461  $query = "UPDATE {$CONFIG->dbprefix}groups_entity set"
2462  . " name='$name', description='$description' where guid=$guid";
2463  $result = update_data($query);
2464  if ($result != false) {
2465  // Update succeeded, continue
2467  if (elgg_trigger_event('update', $entity->type, $entity)) {
2468  return $guid;
2469  } else {
2470  $entity->delete();
2471  }
2472  }
2473  } else {
2474  // Update failed, attempt an insert.
2475  $query = "INSERT into {$CONFIG->dbprefix}groups_entity"
2476  . " (guid, name, description) values ($guid, '$name', '$description')";
2477 
2478  $result = insert_data($query);
2479  if ($result !== false) {
2481  if (elgg_trigger_event('create', $entity->type, $entity)) {
2482  return $guid;
2483  } else {
2484  $entity->delete();
2485  }
2486  }
2487  }
2488  }
2489 
2490  return false;
2491 }
2492 
2511  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use \ElggUser constructor', 1.9);
2512  global $CONFIG;
2513 
2514  $guid = (int)$guid;
2518  $salt = sanitise_string($salt);
2521 
2523  if ($row) {
2524  // Exists and you have access to it
2525  $query = "SELECT guid from {$CONFIG->dbprefix}users_entity where guid = {$guid}";
2526  if ($exists = get_data_row($query)) {
2527  $query = "UPDATE {$CONFIG->dbprefix}users_entity
2528  SET name='$name', username='$username', password='$password', salt='$salt',
2529  email='$email', language='$language'
2530  WHERE guid = $guid";
2531 
2532  $result = update_data($query);
2533  if ($result != false) {
2534  // Update succeeded, continue
2536  if (elgg_trigger_event('update', $entity->type, $entity)) {
2537  return $guid;
2538  } else {
2539  $entity->delete();
2540  }
2541  }
2542  } else {
2543  // Exists query failed, attempt an insert.
2544  $query = "INSERT into {$CONFIG->dbprefix}users_entity
2545  (guid, name, username, password, salt, email, language)
2546  values ($guid, '$name', '$username', '$password', '$salt', '$email', '$language')";
2547 
2548  $result = insert_data($query);
2549  if ($result !== false) {
2551  if (elgg_trigger_event('create', $entity->type, $entity)) {
2552  return $guid;
2553  } else {
2554  $entity->delete();
2555  }
2556  }
2557  }
2558  }
2559 
2560  return false;
2561 }
2562 
2576  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use \ElggObject constructor', 1.9);
2577  global $CONFIG;
2578 
2579  $guid = (int)$guid;
2582 
2584 
2585  if ($row) {
2586  // Core entities row exists and we have access to it
2587  $query = "SELECT guid from {$CONFIG->dbprefix}objects_entity where guid = {$guid}";
2588  if ($exists = get_data_row($query)) {
2589  $query = "UPDATE {$CONFIG->dbprefix}objects_entity
2590  set title='$title', description='$description' where guid=$guid";
2591 
2592  $result = update_data($query);
2593  if ($result != false) {
2594  // Update succeeded, continue
2596  elgg_trigger_event('update', $entity->type, $entity);
2597  return $guid;
2598  }
2599  } else {
2600  // Update failed, attempt an insert.
2601  $query = "INSERT into {$CONFIG->dbprefix}objects_entity
2602  (guid, title, description) values ($guid, '$title','$description')";
2603 
2604  $result = insert_data($query);
2605  if ($result !== false) {
2607  if (elgg_trigger_event('create', $entity->type, $entity)) {
2608  return $guid;
2609  } else {
2610  $entity->delete();
2611  }
2612  }
2613  }
2614  }
2615 
2616  return false;
2617 }
2618 
2628 function ODD_factory (XmlElement $element) {
2629  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated', 1.9);
2630  $name = $element->name;
2631  $odd = false;
2632 
2633  switch ($name) {
2634  case 'entity' :
2635  $odd = new ODDEntity("", "", "");
2636  break;
2637  case 'metadata' :
2638  $odd = new ODDMetaData("", "", "", "");
2639  break;
2640  case 'relationship' :
2641  $odd = new ODDRelationship("", "", "");
2642  break;
2643  }
2644 
2645  // Now populate values
2646  if ($odd) {
2647  // Attributes
2648  foreach ($element->attributes as $k => $v) {
2649  $odd->setAttribute($k, $v);
2650  }
2651 
2652  // Body
2653  $body = $element->content;
2654  $a = stripos($body, "<![CDATA");
2655  $b = strripos($body, "]]>");
2656  if (($body) && ($a !== false) && ($b !== false)) {
2657  $body = substr($body, $a + 8, $b - ($a + 8));
2658  }
2659 
2660  $odd->setBody($body);
2661  }
2662 
2663  return $odd;
2664 }
2665 
2680  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated', 1.9);
2681  $class = $element->getAttribute('class');
2682  $subclass = $element->getAttribute('subclass');
2683 
2684  // See if we already have imported this uuid
2685  $tmp = get_entity_from_uuid($element->getAttribute('uuid'));
2686 
2687  if (!$tmp) {
2688  // Construct new class with owner from session
2689  $classname = get_subtype_class($class, $subclass);
2690  if ($classname) {
2691  if (class_exists($classname)) {
2692  $tmp = new $classname();
2693 
2694  if (!($tmp instanceof \ElggEntity)) {
2695  $msg = $classname . " is not a " . get_class() . ".";
2696  throw new \ClassException($msg);
2697  }
2698  } else {
2699  error_log("Class '" . $classname . "' was not found, missing plugin?");
2700  }
2701  } else {
2702  switch ($class) {
2703  case 'object' :
2704  $tmp = new \ElggObject();
2705  break;
2706  case 'user' :
2707  $tmp = new \ElggUser();
2708  break;
2709  case 'group' :
2710  $tmp = new \ElggGroup();
2711  break;
2712  case 'site' :
2713  $tmp = new \ElggSite();
2714  break;
2715  default:
2716  $msg = "Type " . $class . " is not supported. This indicates an error in your installation, most likely caused by an incomplete upgrade.";
2717  throw new \InstallationException($msg);
2718  }
2719  }
2720  }
2721 
2722  if ($tmp) {
2723  if (!$tmp->import($element)) {
2724  $msg = "Could not import element " . $element->getAttribute('uuid');
2725  throw new \ImportException($msg);
2726  }
2727 
2728  return $tmp;
2729  }
2730 
2731  return NULL;
2732 }
2733 
2743 function ODD_Import($xml) {
2744  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated', 1.9);
2745  // Parse XML to an array
2746  $elements = xml_to_object($xml);
2747 
2748  // Sanity check 1, was this actually XML?
2749  if ((!$elements) || (!$elements->children)) {
2750  return false;
2751  }
2752 
2753  // Create ODDDocument
2754  $document = new ODDDocument();
2755 
2756  // Itterate through array of elements and construct ODD document
2757  $cnt = 0;
2758 
2759  foreach ($elements->children as $child) {
2760  $odd = ODD_factory($child);
2761 
2762  if ($odd) {
2763  $document->addElement($odd);
2764  $cnt++;
2765  }
2766  }
2767 
2768  // Check that we actually found something
2769  if ($cnt == 0) {
2770  return false;
2771  }
2772 
2773  return $document;
2774 }
2775 
2785 function ODD_Export(ODDDocument $document) {
2786  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated', 1.9);
2787  return "$document";
2788 }
2789 
2799  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated', 1.9);
2800  if ($object instanceof \ElggEntity) {
2801  return guid_to_uuid($object->guid);
2802  } else if ($object instanceof \ElggExtender) {
2803  $type = $object->type;
2804  if ($type == 'volatile') {
2805  $uuid = guid_to_uuid($object->entity_guid) . $type . "/{$object->name}/";
2806  } else {
2807  $uuid = guid_to_uuid($object->entity_guid) . $type . "/{$object->id}/";
2808  }
2809 
2810  return $uuid;
2811  } else if ($object instanceof \ElggRelationship) {
2812  return guid_to_uuid($object->guid_one) . "relationship/{$object->id}/";
2813  }
2814 
2815  return false;
2816 }
2817 
2826 function guid_to_uuid($guid) {
2827  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated', 1.9);
2828  return elgg_get_site_url() . "export/opendd/$guid/";
2829 }
2830 
2839 function is_uuid_this_domain($uuid) {
2840  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated', 1.9);
2841  if (strpos($uuid, elgg_get_site_url()) === 0) {
2842  return true;
2843  }
2844 
2845  return false;
2846 }
2847 
2856 function get_entity_from_uuid($uuid) {
2857  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated', 1.9);
2858  $uuid = sanitise_string($uuid);
2859 
2860  $options = array('metadata_name' => 'import_uuid', 'metadata_value' => $uuid);
2862 
2863  if ($entities) {
2864  return $entities[0];
2865  }
2866 
2867  return false;
2868 }
2869 
2879 function add_uuid_to_guid($guid, $uuid) {
2880  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated', 1.9);
2881  $guid = (int)$guid;
2882  $uuid = sanitise_string($uuid);
2883 
2884  $result = create_metadata($guid, "import_uuid", $uuid);
2885  return (bool)$result;
2886 }
2887 
2888 
2889 $IMPORTED_DATA = array();
2891 
2904 function _process_element(ODD $odd) {
2905  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated', 1.9);
2907 
2908  // See if anyone handles this element, return true if it is.
2909  $to_be_serialised = null;
2910  if ($odd) {
2911  $handled = elgg_trigger_plugin_hook("import", "all", array("element" => $odd), $to_be_serialised);
2912 
2913  // If not, then see if any of its sub elements are handled
2914  if ($handled) {
2915  // Increment validation counter
2916  $IMPORTED_OBJECT_COUNTER ++;
2917  // Return the constructed object
2918  $IMPORTED_DATA[] = $handled;
2919 
2920  return true;
2921  }
2922  }
2923 
2924  return false;
2925 }
2926 
2938  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated', 1.9);
2939  $guid = (int)$guid;
2940 
2941  // Trigger a hook to
2942  $to_be_serialised = elgg_trigger_plugin_hook("export", "all", array("guid" => $guid), array());
2943 
2944  // Sanity check
2945  if ((!is_array($to_be_serialised)) || (count($to_be_serialised) == 0)) {
2946  throw new \ExportException("No such entity GUID:" . $guid);
2947  }
2948 
2949  return $to_be_serialised;
2950 }
2951 
2967 function export($guid) {
2968  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated', 1.9);
2969  $odd = new ODDDocument(exportAsArray($guid));
2970 
2971  return ODD_Export($odd);
2972 }
2973 
2985 function import($xml) {
2986  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated', 1.9);
2988 
2989  $IMPORTED_DATA = array();
2990  $IMPORTED_OBJECT_COUNTER = 0;
2991 
2992  $document = ODD_Import($xml);
2993  if (!$document) {
2994  throw new \ImportException("No OpenDD elements found in import data, import failed.");
2995  }
2996 
2997  foreach ($document as $element) {
2998  _process_element($element);
2999  }
3000 
3001  if ($IMPORTED_OBJECT_COUNTER != count($IMPORTED_DATA)) {
3002  throw new \ImportException("Not all elements were imported.");
3003  }
3004 
3005  return true;
3006 }
3007 
3015 function _export_init() {
3016  global $CONFIG;
3017 
3018  elgg_register_action("import/opendd");
3019 }
3020 
3036 function elgg_get_views($dir, $base) {
3037  $return = array();
3038  if (file_exists($dir) && is_dir($dir)) {
3039  if ($handle = opendir($dir)) {
3040  while ($view = readdir($handle)) {
3041  if (!in_array($view, array('.', '..', '.svn', 'CVS'))) {
3042  if (is_dir($dir . '/' . $view)) {
3043  if ($val = elgg_get_views($dir . '/' . $view, $base . '/' . $view)) {
3044  $return = array_merge($return, $val);
3045  }
3046  } else {
3047  $view = str_replace('.php', '', $view);
3048  $return[] = $base . '/' . $view;
3049  }
3050  }
3051  }
3052  }
3053  }
3054 
3055  return $return;
3056 }
3057 
3073 function elgg_view_tree($view_root, $viewtype = "") {
3074  global $CONFIG;
3075  static $treecache = array();
3076 
3077  // Get viewtype
3078  if (!$viewtype) {
3080  }
3081 
3082  // A little light internal caching
3083  if (!empty($treecache[$view_root])) {
3084  return $treecache[$view_root];
3085  }
3086 
3087  // Examine $CONFIG->views->locations
3088  if (isset($CONFIG->views->locations[$viewtype])) {
3089  foreach ($CONFIG->views->locations[$viewtype] as $view => $path) {
3090  $pos = strpos($view, $view_root);
3091  if ($pos === 0) {
3092  $treecache[$view_root][] = $view;
3093  }
3094  }
3095  }
3096 
3097  // Now examine core
3098  $location = $CONFIG->viewpath;
3100  $root = $location . $viewtype . '/' . $view_root;
3101 
3102  if (file_exists($root) && is_dir($root)) {
3103  $val = elgg_get_views($root, $view_root);
3104  if (!is_array($treecache[$view_root])) {
3105  $treecache[$view_root] = array();
3106  }
3107  $treecache[$view_root] = array_merge($treecache[$view_root], $val);
3108  }
3109 
3110  return $treecache[$view_root];
3111 }
3112 
3128 function add_to_river($view, $action_type, $subject_guid, $object_guid, $access_id = "",
3129 $posted = 0, $annotation_id = 0, $target_guid = 0) {
3130  elgg_deprecated_notice('add_to_river was deprecated in favor of elgg_create_river_item', '1.9');
3131 
3132  // Make sure old parameters are passed in correct format
3133  $access_id = ($access_id == '') ? null : $access_id;
3134  $posted = ($posted == 0) ? null : $posted;
3135 
3136  return elgg_create_river_item(array(
3137  'view' => $view,
3138  'action_type' => $action_type,
3139  'subject_guid' => $subject_guid,
3140  'object_guid' => $object_guid,
3141  'target_guid' => $target_guid,
3142  'access_id' => $access_id,
3143  'posted' => $posted,
3144  'annotation_id' => $annotation_id,
3145  ));
3146 }
3147 
3162 function serialise_object_to_xml($data, $name = "", $n = 0) {
3163  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated.', 1.9);
3164 
3165  $classname = ($name == "" ? get_class($data) : $name);
3166 
3167  $vars = method_exists($data, "export") ? get_object_vars($data->export()) : get_object_vars($data);
3168 
3169  $output = "";
3170 
3171  if (($n == 0) || ( is_object($data) && !($data instanceof \stdClass))) {
3172  $output = "<$classname>";
3173  }
3174 
3175  foreach ($vars as $key => $value) {
3176  $output .= "<$key type=\"" . gettype($value) . "\">";
3177 
3178  if (is_object($value)) {
3180  } else if (is_array($value)) {
3182  } else if (gettype($value) == "boolean") {
3183  $output .= $value ? "true" : "false";
3184  } else {
3185  $output .= htmlspecialchars($value, ENT_NOQUOTES, 'UTF-8');
3186  }
3187 
3188  $output .= "</$key>\n";
3189  }
3190 
3191  if (($n == 0) || (is_object($data) && !($data instanceof \stdClass))) {
3192  $output .= "</$classname>\n";
3193  }
3194 
3195  return $output;
3196 }
3197 
3207 function serialise_array_to_xml(array $data, $n = 0) {
3208  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated.', 1.9);
3209 
3210  $output = "";
3211 
3212  if ($n == 0) {
3213  $output = "<array>\n";
3214  }
3215 
3216  foreach ($data as $key => $value) {
3217  $item = "array_item";
3218 
3219  if (is_numeric($key)) {
3220  $output .= "<$item name=\"$key\" type=\"" . gettype($value) . "\">";
3221  } else {
3222  $item = $key;
3223  $output .= "<$item type=\"" . gettype($value) . "\">";
3224  }
3225 
3226  if (is_object($value)) {
3228  } else if (is_array($value)) {
3230  } else if (gettype($value) == "boolean") {
3231  $output .= $value ? "true" : "false";
3232  } else {
3233  $output .= htmlspecialchars($value, ENT_NOQUOTES, 'UTF-8');
3234  }
3235 
3236  $output .= "</$item>\n";
3237  }
3238 
3239  if ($n == 0) {
3240  $output .= "</array>\n";
3241  }
3242 
3243  return $output;
3244 }
3245 
3254 function xml_to_object($xml) {
3255  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated by \ElggXMLElement', 1.9);
3256  return new \ElggXMLElement($xml);
3257 }
3258 
3268  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use \ElggSite::getDomain()', 1.9);
3269  $guid = (int)$guid;
3270 
3271  $site = get_entity($guid);
3272  if ($site instanceof \ElggSite) {
3273  $breakdown = parse_url($site->url);
3274  return $breakdown['host'];
3275  }
3276 
3277  return false;
3278 }
3279 
3293 function register_notification_object($entity_type, $object_subtype, $language_name) {
3294  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated by elgg_register_notification_event()', 1.9);
3295 
3296  elgg_register_notification_event($entity_type, $object_subtype);
3297  _elgg_services()->notifications->setDeprecatedNotificationSubject($entity_type, $object_subtype, $language_name);
3298 }
3299 
3310  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated by elgg_add_subscription()', 1.9);
3311  return add_entity_relationship($user_guid, 'notify', $author_guid);
3312 }
3313 
3323 function remove_notification_interest($user_guid, $author_guid) {
3324  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated by elgg_remove_subscription()', 1.9);
3325  return remove_entity_relationship($user_guid, 'notify', $author_guid);
3326 }
3327 
3342 function object_notifications($event, $object_type, $object) {
3343  throw new \BadFunctionCallException("object_notifications is a private function and should not be called directly");
3344 }
3345 
3361  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated by elgg_register_notification_method()', 1.9);
3363  _elgg_services()->notifications->registerDeprecatedHandler($method, $handler);
3364 }
3365 
3376  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated by elgg_unregister_notification_method()', 1.9);
3378 }
3379 
3400 function import_entity_plugin_hook($hook, $entity_type, $returnvalue, $params) {
3401  $element = $params['element'];
3402 
3403  $tmp = null;
3404 
3405  if ($element instanceof ODDEntity) {
3406  $tmp = oddentity_to_elggentity($element);
3407 
3408  if ($tmp) {
3409  // Make sure its saved
3410  if (!$tmp->save()) {
3411  $msg = "There was a problem saving " . $element->getAttribute('uuid');
3412  throw new \ImportException($msg);
3413  }
3414 
3415  // Belts and braces
3416  if (!$tmp->guid) {
3417  throw new \ImportException("New entity created but has no GUID, this should not happen.");
3418  }
3419 
3420  // We have saved, so now tag
3421  add_uuid_to_guid($tmp->guid, $element->getAttribute('uuid'));
3422 
3423  return $tmp;
3424  }
3425  }
3426 }
3427 
3445 function export_entity_plugin_hook($hook, $entity_type, $returnvalue, $params) {
3446  // Sanity check values
3447  if ((!is_array($params)) && (!isset($params['guid']))) {
3448  throw new \InvalidParameterException("GUID has not been specified during export, this should never happen.");
3449  }
3450 
3451  if (!is_array($returnvalue)) {
3452  throw new \InvalidParameterException("Entity serialisation function passed a non-array returnvalue parameter");
3453  }
3454 
3455  $guid = (int)$params['guid'];
3456 
3457  // Get the entity
3459  if (!($entity instanceof \ElggEntity)) {
3460  $msg = "GUID:" . $guid . " is not a valid " . get_class();
3461  throw new \InvalidClassException($msg);
3462  }
3463 
3464  $export = $entity->export();
3465 
3466  if (is_array($export)) {
3467  foreach ($export as $e) {
3468  $returnvalue[] = $e;
3469  }
3470  } else {
3471  $returnvalue[] = $export;
3472  }
3473 
3474  return $returnvalue;
3475 }
3476 
3492 function volatile_data_export_plugin_hook($hook, $entity_type, $returnvalue, $params) {
3493  $guid = (int)$params['guid'];
3494  $variable_name = sanitise_string($params['varname']);
3495 
3496  if (($hook == 'volatile') && ($entity_type == 'metadata')) {
3497  if (($guid) && ($variable_name)) {
3498  switch ($variable_name) {
3499  case 'renderedentity' :
3500  elgg_set_viewtype('default');
3503 
3504  $tmp = new \ElggMetadata();
3505  $tmp->type = 'volatile';
3506  $tmp->name = 'renderedentity';
3507  $tmp->value = $view;
3508  $tmp->entity_guid = $guid;
3509 
3510  return $tmp;
3511 
3512  break;
3513  }
3514  }
3515  }
3516 }
3517 
3533 function export_annotation_plugin_hook($hook, $type, $returnvalue, $params) {
3534  // Sanity check values
3535  if ((!is_array($params)) && (!isset($params['guid']))) {
3536  throw new \InvalidParameterException("GUID has not been specified during export, this should never happen.");
3537  }
3538 
3539  if (!is_array($returnvalue)) {
3540  throw new \InvalidParameterException("Entity serialization function passed a non-array returnvalue parameter");
3541  }
3542 
3543  $guid = (int)$params['guid'];
3544  $options = array('guid' => $guid, 'limit' => 0);
3545  if (isset($params['name'])) {
3546  $options['annotation_name'] = $params['name'];
3547  }
3548 
3550 
3551  if ($result) {
3552  foreach ($result as $r) {
3553  $returnvalue[] = $r->export();
3554  }
3555  }
3556 
3557  return $returnvalue;
3558 }
3559 
3575 function import_extender_plugin_hook($hook, $entity_type, $returnvalue, $params) {
3576  $element = $params['element'];
3577 
3578  $tmp = NULL;
3579 
3580  if ($element instanceof ODDMetaData) {
3581  /* @var ODDMetaData $element */
3582  // Recall entity
3583  $entity_uuid = $element->getAttribute('entity_uuid');
3584  $entity = get_entity_from_uuid($entity_uuid);
3585  if (!$entity) {
3586  throw new \ImportException("Entity '" . $entity_uuid . "' could not be found.");
3587  }
3588 
3590 
3591  // Save
3592  if (!$entity->save()) {
3593  $attr_name = $element->getAttribute('name');
3594  $msg = "There was a problem updating '" . $attr_name . "' on entity '" . $entity_uuid . "'";
3595  throw new \ImportException($msg);
3596  }
3597 
3598  return true;
3599  }
3600 }
3601 
3615  // Get the type of extender (metadata, type, attribute etc)
3616  $type = $element->getAttribute('type');
3617  $attr_name = $element->getAttribute('name');
3618  $attr_val = $element->getBody();
3619 
3620  switch ($type) {
3621  // Ignore volatile items
3622  case 'volatile' :
3623  break;
3624  case 'annotation' :
3625  $entity->annotate($attr_name, $attr_val);
3626  break;
3627  case 'metadata' :
3628  $entity->setMetadata($attr_name, $attr_val, "", true);
3629  break;
3630  default : // Anything else assume attribute
3631  $entity->set($attr_name, $attr_val);
3632  }
3633 
3634  // Set time if appropriate
3635  $attr_time = $element->getAttribute('published');
3636  if ($attr_time) {
3637  $entity->set('time_updated', $attr_time);
3638  }
3639 
3640  return true;
3641 }
3642 
3657 function export_metadata_plugin_hook($hook, $entity_type, $returnvalue, $params) {
3658  // Sanity check values
3659  if ((!is_array($params)) && (!isset($params['guid']))) {
3660  throw new \InvalidParameterException("GUID has not been specified during export, this should never happen.");
3661  }
3662 
3663  if (!is_array($returnvalue)) {
3664  throw new \InvalidParameterException("Entity serialisation function passed a non-array returnvalue parameter");
3665  }
3666 
3667  $result = elgg_get_metadata(array(
3668  'guid' => (int)$params['guid'],
3669  'limit' => 0,
3670  ));
3671 
3672  if ($result) {
3673  /* @var \ElggMetadata[] $result */
3674  foreach ($result as $r) {
3675  $returnvalue[] = $r->export();
3676  }
3677  }
3678 
3679  return $returnvalue;
3680 }
3681 
3696 function export_relationship_plugin_hook($hook, $entity_type, $returnvalue, $params) {
3697  // Sanity check values
3698  if ((!is_array($params)) && (!isset($params['guid']))) {
3699  throw new \InvalidParameterException("GUID has not been specified during export, this should never happen.");
3700  }
3701 
3702  if (!is_array($returnvalue)) {
3703  throw new \InvalidParameterException("Entity serialisation function passed a non-array returnvalue parameter");
3704  }
3705 
3706  $guid = (int)$params['guid'];
3707 
3709 
3710  if ($result) {
3711  foreach ($result as $r) {
3712  $returnvalue[] = $r->export();
3713  }
3714  }
3715 
3716  return $returnvalue;
3717 }
3718 
3731 function import_relationship_plugin_hook($hook, $entity_type, $returnvalue, $params) {
3732  $element = $params['element'];
3733 
3734  $tmp = NULL;
3735 
3736  if ($element instanceof ODDRelationship) {
3737  $tmp = new \ElggRelationship();
3738  $tmp->import($element);
3739 
3740  return $tmp;
3741  }
3742  return $tmp;
3743 }
3744 
3760 function get_access_sql_suffix($table_prefix = '', $owner = null) {
3761  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated by _elgg_get_access_where_sql()', 1.9);
3762  return _elgg_get_access_where_sql(array(
3763  'table_alias' => $table_prefix,
3764  'user_guid' => (int)$owner,
3765  ));
3766 }
3767 
3783 function elgg_get_calling_plugin_id($mainfilename = false) {
3784  elgg_deprecated_notice('elgg_get_calling_plugin_id() is deprecated', 1.9);
3785  if (!$mainfilename) {
3786  if ($backtrace = debug_backtrace()) {
3787  foreach ($backtrace as $step) {
3788  $file = $step['file'];
3789  $file = str_replace("\\", "/", $file);
3790  $file = str_replace("//", "/", $file);
3791  if (preg_match("/mod\/([a-zA-Z0-9\-\_]*)\/start\.php$/", $file, $matches)) {
3792  return $matches[1];
3793  }
3794  }
3795  }
3796  } else {
3797  //@todo this is a hack -- plugins do not have to match their page handler names!
3798  if ($handler = get_input('handler', false)) {
3799  return $handler;
3800  } else {
3801  $file = $_SERVER["SCRIPT_NAME"];
3802  $file = str_replace("\\", "/", $file);
3803  $file = str_replace("//", "/", $file);
3804  if (preg_match("/mod\/([a-zA-Z0-9\-\_]*)\//", $file, $matches)) {
3805  return $matches[1];
3806  }
3807  }
3808  }
3809  return false;
3810 }
3811 
3821  elgg_deprecated_notice("elgg_get_calling_plugin_entity() is deprecated.", 1.9);
3823 
3824  if ($plugin_id) {
3826  }
3827 
3828  return false;
3829 }
3830 
3831 return function(\Elgg\EventsService $events, \Elgg\HooksRegistrationService $hooks) {
3832  // Register a startup event
3833  $events->registerHandler('init', 'system', '_export_init', 100);
3834 
3836  $hooks->registerHandler("import", "all", "import_entity_plugin_hook", 0);
3837  $hooks->registerHandler("import", "all", "import_extender_plugin_hook", 2);
3838  $hooks->registerHandler("import", "all", "import_relationship_plugin_hook", 3);
3839 
3841  $hooks->registerHandler("export", "all", "export_entity_plugin_hook", 0);
3842  $hooks->registerHandler("export", "all", "export_annotation_plugin_hook", 2);
3843  $hooks->registerHandler("export", "all", "export_metadata_plugin_hook", 2);
3844  $hooks->registerHandler("export", "all", "export_relationship_plugin_hook", 3);
3845 
3847  $hooks->registerHandler('volatile', 'metadata', 'volatile_data_export_plugin_hook');
3848 };
elgg_enable_filepath_cache()
private
elgg_admin_notice_exists($id)
Check if an admin notice is currently active.
Definition: admin.php:118
elgg_enable_system_cache()
Enables the system disk cache.
Definition: cache.php:62
$tags
Definition: summary.php:41
elgg_get_config($name, $site_guid=0)
Get an Elgg configuration value.
$view
Definition: crop.php:68
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
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
get_input($variable, $default=null, $filter_result=true)
Get some input from variables passed submitted through GET or POST.
Definition: input.php:27
$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.
get_data_row($query, $callback="")
Retrieve a single row from the database.
Definition: database.php:66
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:220
get_group_members($group_guid, $limit=10, $offset=0, $site_guid=0, $count=false)
Return a list of this group&#39;s members.
$table
Definition: cron.php:28
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&#39;s friends&#39; 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:311
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
$size
Definition: view.php:10
$e
Definition: metadata.php:12
get_subtype_id($type, $subtype)
Return the id for a given subtype.
Definition: entities.php:157
$object
Definition: upgrade.php:12
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:74
elgg_add_admin_notice($id, $message)
Write a persistent message to the admin view.
Definition: admin.php:77
$metadata
Definition: entity.php:19
user_add_friend($user_guid, $friend_guid)
Adds a user to another user&#39;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:385
_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
$value
Definition: longtext.php:26
add_site_object($site_guid, $object_guid)
Add an object to a site.
if($screenshots) $description
Definition: full.php:173
elgg_unregister_entity_type($type, $subtype=null)
Unregisters an entity type and subtype as a public-facing type.
Definition: entities.php:746
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.
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:25
$pagination
Definition: gallery.php:22
$step
Definition: install.php:23
$guid
Removes an admin notice.
$collection
elgg parse_url
Parse a URL into its parts.
Definition: elgglib.js:432
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 &#39;create&#39; 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 &#39;notify&#39; relationship between the user and a content author.
$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:391
elgg_get_views($dir, $base)
Returns the name of views for in a directory.
$title
Definition: save.php:24
update_data($query)
Update a row in the database.
Definition: database.php:93
$action
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
insert_data($query)
Insert a row into the database.
Definition: database.php:80
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&#39;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.
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.
$options
Definition: index.php:14
get_subtype_class($type, $subtype)
Return the class name for a registered type and subtype.
Definition: entities.php:210
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 &#39;notify&#39; 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:85
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:405
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&#39;s friends.
$limit
Definition: userpicker.php:31
elgg_set_viewtype($viewtype="")
Manually set the viewtype.
Definition: views.php:70
annotate($name, $value, $access_id=ACCESS_PRIVATE, $owner_guid=0, $vartype="")
Adds an annotation to an entity.
Definition: ElggEntity.php:827
elgg_get_viewtype()
Return the current view type.
Definition: views.php:91
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:505
$key
Definition: summary.php:34
get_user($guid)
Get a user object from a GUID.
Definition: users.php:87
execute_delayed_write_query($query, $handler="")
Queue a query for running during shutdown that writes to the database.
Definition: database.php:19
ODD_factory(XmlElement $element)
Attempt to construct an ODD object out of a XmlElement or sub-elements.
register_notification_object($entity_type, $object_subtype, $language_name)
Register an entity type and subtype to be eligible for notifications.
_elgg_services()
Definition: autoloader.php:14
$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.
get_db_link($dblinktype)
Returns (if required, also creates) a database link resource.
sanitise_string($string)
Wrapper function for alternate English spelling (.
Definition: database.php:150
$user
Definition: ban.php:13
const ELGG_ENTITIES_ANY_VALUE
Definition: elgglib.php:1967
elgg ElggUser
Definition: ElggUser.js:12
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:775
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:1006
elgg global
Pointer to the global context.
Definition: elgglib.js:12
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
$type
Definition: add.php:8
access_get_show_hidden_status()
Return current status of showing disabled entities.
Definition: access.php:172
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:352
$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.
get_db_error($dblink)
Get the last database error for a particular database link.
elgg_view_tree($view_root, $viewtype="")
Returns all views below a partial view.
$posted
Definition: comment.php:69
elgg_list_entities(array $options=array(), $getter= 'elgg_get_entities', $viewer= 'elgg_view_entity_list')
Returns a string of rendered entities.
Definition: entities.php:586
get_data($query, $callback="")
Retrieve rows from the database.
Definition: database.php:50
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:976
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:159
user_remove_friend($user_guid, $friend_guid)
Removes a user from another user&#39;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&#39;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.
elgg_view_entity(\ElggEntity $entity, $vars=array(), $bypass=false, $debug=false)
Returns a string of a rendered entity.
Definition: views.php:793
disable_entity($guid, $reason="", $recursive=true)
Disable an entity.
global $METASTRINGS_DEADNAME_CACHE
set($name, $value)
Sets the value of an attribute or metadata.
Definition: ElggEntity.php:233
if(elgg_in_context('widget')) $count
Definition: pagination.php:20
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")
execute_delayed_query($query, $dblink, $handler="")
Queue a query for execution upon shutdown.
get_user_friends($user_guid, $subtype=ELGG_ENTITIES_ANY_VALUE, $limit=10, $offset=0)
Obtains a given user&#39;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&#39;s friends.
$entity
Definition: delete.php:10
$request
_elgg_get_access_where_sql(array $options=array())
Returns the SQL where clause for enforcing read access to data.
Definition: access.php:216
$language
$vars[&#39;language&#39;]
Definition: languages.php:6
elgg_view_entity_list($entities, $vars=array(), $offset=0, $limit=null, $full_view=true, $list_type_toggle=true, $pagination=true)
Returns a rendered list of entities with pagination.
Definition: views.php:984
elgg_trigger_event($event, $object_type, $object=null)
Definition: elgglib.php:570
$subtype
Definition: river.php:12
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
$path
Definition: invalid.php:17
$viewtype
Definition: start.php:76
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.
define(function(require){var $=require('jquery');var active=false;var SHOW_DELAY=20;$('body').append('< div class="elgg-spinner">< div class="elgg-ajax-loader"></div ></div >');return{start:function(){active=true;setTimeout(function(){if(active){$('body').addClass('elgg-spinner-active');}}, SHOW_DELAY);}, stop:function(){active=false;$('body').removeClass('elgg-spinner-active');}};})
elgg_get_plugin_from_id($plugin_id)
Returns an object with the path $path.
Definition: plugins.php:97
unexpose_function($method)
Unregister a web services method.
get_entity($guid)
Loads and returns an entity object from a guid.
Definition: entities.php:382
elgg_filepath_cache_reset()
private
remove_object_from_group($group_guid, $object_guid)
Remove an object from the given group.
if(file_exists($welcome)) $vars
Definition: upgrade.php:93
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.
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.