Elgg  Version 2.3
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  return elgg_get_metastring_id($string, $case_sensitive);
825 }
826 
837 function add_metastring($string, $case_sensitive = true) {
838  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use elgg_get_metastring_id()', 1.9);
839  return elgg_get_metastring_id($string, $case_sensitive);
840 }
841 
850 function get_metastring($id) {
851  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated.', 1.9);
852  global $CONFIG, $METASTRINGS_CACHE;
853 
854  $id = (int) $id;
855 
856  if (isset($METASTRINGS_CACHE[$id])) {
857  return $METASTRINGS_CACHE[$id];
858  }
859 
860  $row = get_data_row("SELECT * from {$CONFIG->dbprefix}metastrings where id='$id' limit 1");
861  if ($row) {
862  $METASTRINGS_CACHE[$id] = $row->string;
863  return $row->string;
864  }
865 
866  return false;
867 }
868 
883  $offset = 0, $timelower = 0, $timeupper = 0) {
884 
885  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use elgg_get_entities_from_relationship()', 1.9);
887  'type' => 'object',
888  'subtype' => $subtype,
889  'limit' => $limit,
890  'offset' => $offset,
891  'created_time_lower' => $timelower,
892  'created_time_upper' => $timeupper,
893  'relationship' => 'friend',
894  'relationship_guid' => $user_guid,
895  'relationship_join_on' => 'container_guid',
896  ));
897 }
898 
911 $timelower = 0, $timeupper = 0) {
912 
913  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use elgg_get_entities_from_relationship()', 1.9);
915  'type' => 'object',
916  'subtype' => $subtype,
917  'created_time_lower' => $timelower,
918  'created_time_upper' => $timeupper,
919  'relationship' => 'friend',
920  'relationship_guid' => $user_guid,
921  'relationship_join_on' => 'container_guid',
922  'count' => true,
923  ));
924 }
925 
944  $listtypetoggle = true, $pagination = true, $timelower = 0, $timeupper = 0) {
945 
946  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use elgg_list_entities_from_relationship()', 1.9);
948  'type' => 'object',
949  'subtype' => $subtype,
950  'limit' => $limit,
951  'created_time_lower' => $timelower,
952  'created_time_upper' => $timeupper,
953  'full_view' => $full_view,
954  'list_type_toggle' => $listtypetoggle,
955  'pagination' => $pagination,
956  'relationship' => 'friend',
957  'relationship_guid' => $user_guid,
958  'relationship_join_on' => 'container_guid',
959  ));
960 }
961 
972 function elgg_geocode_location($location) {
973  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. See geolocation plugin on github', 1.9);
974  global $CONFIG;
975 
976  if (is_array($location)) {
977  return false;
978  }
979 
980  $location = sanitise_string($location);
981 
982  // Look for cached version
983  $query = "SELECT * from {$CONFIG->dbprefix}geocode_cache WHERE location='$location'";
984  $cached_location = get_data_row($query);
985 
986  if ($cached_location) {
987  return array('lat' => $cached_location->lat, 'long' => $cached_location->long);
988  }
989 
990  // Trigger geocode event if not cached
991  $return = false;
992  $return = elgg_trigger_plugin_hook('geocode', 'location', array('location' => $location), $return);
993 
994  // If returned, cache and return value
995  if (($return) && (is_array($return))) {
996  $lat = (float)$return['lat'];
997  $long = (float)$return['long'];
998 
999  // Put into cache at the end of the page since we don't really care that much
1000  $query = "INSERT DELAYED INTO {$CONFIG->dbprefix}geocode_cache "
1001  . " (location, lat, `long`) VALUES ('$location', '{$lat}', '{$long}')"
1002  . " ON DUPLICATE KEY UPDATE lat='{$lat}', `long`='{$long}'";
1004  }
1005 
1006  return $return;
1007 }
1008 
1036 function elgg_get_entities_from_location(array $options = array()) {
1037  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. See geolocation plugin on github', 1.9);
1038  global $CONFIG;
1039 
1040  if (!isset($options['latitude']) || !isset($options['longitude']) ||
1041  !isset($options['distance'])) {
1042  return false;
1043  }
1044 
1045  if (!is_array($options['distance'])) {
1046  $lat_distance = (float)$options['distance'];
1047  $long_distance = (float)$options['distance'];
1048  } else {
1049  $lat_distance = (float)$options['distance']['latitude'];
1050  $long_distance = (float)$options['distance']['longitude'];
1051  }
1052 
1053  $lat = (float)$options['latitude'];
1054  $long = (float)$options['longitude'];
1055  $lat_min = $lat - $lat_distance;
1056  $lat_max = $lat + $lat_distance;
1057  $long_min = $long - $long_distance;
1058  $long_max = $long + $long_distance;
1059 
1060  $wheres = array();
1061  $wheres[] = "lat_name.string='geo:lat'";
1062  $wheres[] = "lat_value.string >= $lat_min";
1063  $wheres[] = "lat_value.string <= $lat_max";
1064  $wheres[] = "lon_name.string='geo:long'";
1065  $wheres[] = "lon_value.string >= $long_min";
1066  $wheres[] = "lon_value.string <= $long_max";
1067 
1068  $joins = array();
1069  $joins[] = "JOIN {$CONFIG->dbprefix}metadata lat on e.guid=lat.entity_guid";
1070  $joins[] = "JOIN {$CONFIG->dbprefix}metastrings lat_name on lat.name_id=lat_name.id";
1071  $joins[] = "JOIN {$CONFIG->dbprefix}metastrings lat_value on lat.value_id=lat_value.id";
1072  $joins[] = "JOIN {$CONFIG->dbprefix}metadata lon on e.guid=lon.entity_guid";
1073  $joins[] = "JOIN {$CONFIG->dbprefix}metastrings lon_name on lon.name_id=lon_name.id";
1074  $joins[] = "JOIN {$CONFIG->dbprefix}metastrings lon_value on lon.value_id=lon_value.id";
1075 
1076  // merge wheres to pass to get_entities()
1077  if (isset($options['wheres']) && !is_array($options['wheres'])) {
1078  $options['wheres'] = array($options['wheres']);
1079  } elseif (!isset($options['wheres'])) {
1080  $options['wheres'] = array();
1081  }
1082  $options['wheres'] = array_merge($options['wheres'], $wheres);
1083 
1084  // merge joins to pass to get_entities()
1085  if (isset($options['joins']) && !is_array($options['joins'])) {
1086  $options['joins'] = array($options['joins']);
1087  } elseif (!isset($options['joins'])) {
1088  $options['joins'] = array();
1089  }
1090  $options['joins'] = array_merge($options['joins'], $joins);
1091 
1093 }
1094 
1107 function elgg_list_entities_from_location(array $options = array()) {
1108  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. See geolocation plugin on github', 1.9);
1109  return elgg_list_entities($options, 'elgg_get_entities_from_location');
1110 }
1111 
1112 // Some distances in degrees (approximate)
1113 // @todo huh? see warning on elgg_get_entities_from_location()
1114 // @deprecated 1.9.0
1115 define("MILE", 0.01515);
1116 define("KILOMETER", 0.00932);
1117 
1126 function get_version($humanreadable = false) {
1127  elgg_deprecated_notice('get_version() has been deprecated by elgg_get_version()', 1.9);
1128  return elgg_get_version($humanreadable);
1129 }
1130 
1140 function sanitise_string_special($string, $extra_escapeable = '') {
1141  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated.', 1.9);
1143 
1144  for ($n = 0; $n < strlen($extra_escapeable); $n++) {
1145  $string = str_replace($extra_escapeable[$n], "\\" . $extra_escapeable[$n], $string);
1146  }
1147 
1148  return $string;
1149 }
1150 
1162  elgg_deprecated_notice(__FUNCTION__ . ' is a private function and should not be used.', 1.9);
1163  _elgg_services()->db->setupConnections();
1164 }
1165 
1178  elgg_deprecated_notice(__FUNCTION__ . ' is a private function and should not be used.', 1.9);
1180  return _elgg_services()->db->updateData("OPTIMIZE TABLE $table");
1181 }
1182 
1192 function get_db_tables() {
1193  elgg_deprecated_notice(__FUNCTION__ . ' is a private function and should not be used.', 1.9);
1194  static $tables;
1195 
1196  if (isset($tables)) {
1197  return $tables;
1198  }
1199 
1200  $table_prefix = elgg_get_config('dbprefix');
1201  $result = get_data("SHOW TABLES LIKE '$table_prefix%'");
1202 
1203  $tables = array();
1204  if (is_array($result) && !empty($result)) {
1205  foreach ($result as $row) {
1206  $row = (array) $row;
1207  if (is_array($row) && !empty($row)) {
1208  foreach ($row as $element) {
1209  $tables[] = $element;
1210  }
1211  }
1212  }
1213  }
1214 
1215  return $tables;
1216 }
1217 
1229 function get_day_start($day = null, $month = null, $year = null) {
1230  elgg_deprecated_notice('get_day_start() has been deprecated', 1.9);
1231  return mktime(0, 0, 0, $month, $day, $year);
1232 }
1233 
1245 function get_day_end($day = null, $month = null, $year = null) {
1246  elgg_deprecated_notice('get_day_end() has been deprecated', 1.9);
1247  return mktime(23, 59, 59, $month, $day, $year);
1248 }
1249 
1271 function get_notable_entities($start_time, $end_time, $type = "", $subtype = "", $owner_guid = 0,
1272 $order_by = "asc", $limit = 10, $offset = 0, $count = false, $site_guid = 0,
1273 $container_guid = null) {
1274  elgg_deprecated_notice('get_notable_entities() has been deprecated', 1.9);
1275  global $CONFIG;
1276 
1277  if ($subtype === false || $subtype === null || $subtype === 0) {
1278  return false;
1279  }
1280 
1281  $start_time = (int)$start_time;
1282  $end_time = (int)$end_time;
1283  $order_by = sanitise_string($order_by);
1284  $limit = (int)$limit;
1285  $offset = (int)$offset;
1286  $site_guid = (int) $site_guid;
1287  if ($site_guid == 0) {
1288  $site_guid = $CONFIG->site_guid;
1289  }
1290 
1291  $where = array();
1292 
1293  if (is_array($type)) {
1294  $tempwhere = "";
1295  if (sizeof($type)) {
1296  foreach ($type as $typekey => $subtypearray) {
1297  foreach ($subtypearray as $subtypeval) {
1298  $typekey = sanitise_string($typekey);
1299  if (!empty($subtypeval)) {
1300  $subtypeval = (int) get_subtype_id($typekey, $subtypeval);
1301  } else {
1302  $subtypeval = 0;
1303  }
1304  if (!empty($tempwhere)) {
1305  $tempwhere .= " or ";
1306  }
1307  $tempwhere .= "(e.type = '{$typekey}' and e.subtype = {$subtypeval})";
1308  }
1309  }
1310  }
1311  if (!empty($tempwhere)) {
1312  $where[] = "({$tempwhere})";
1313  }
1314  } else {
1317 
1318  if ($type != "") {
1319  $where[] = "e.type='$type'";
1320  }
1321 
1322  if ($subtype !== "") {
1323  $where[] = "e.subtype=$subtype";
1324  }
1325  }
1326 
1327  if ($owner_guid != "") {
1328  if (!is_array($owner_guid)) {
1329  $owner_array = array($owner_guid);
1330  $owner_guid = (int) $owner_guid;
1331  $where[] = "e.owner_guid = '$owner_guid'";
1332  } else if (sizeof($owner_guid) > 0) {
1333  $owner_array = array_map('sanitise_int', $owner_guid);
1334  // Cast every element to the owner_guid array to int
1335  $owner_guid = implode(",", $owner_guid);
1336  $where[] = "e.owner_guid in ({$owner_guid})";
1337  }
1338  if (is_null($container_guid)) {
1339  $container_guid = $owner_array;
1340  }
1341  }
1342 
1343  if ($site_guid > 0) {
1344  $where[] = "e.site_guid = {$site_guid}";
1345  }
1346 
1347  if (!is_null($container_guid)) {
1348  if (is_array($container_guid)) {
1349  foreach ($container_guid as $key => $val) {
1350  $container_guid[$key] = (int) $val;
1351  }
1352  $where[] = "e.container_guid in (" . implode(",", $container_guid) . ")";
1353  } else {
1355  $where[] = "e.container_guid = {$container_guid}";
1356  }
1357  }
1358 
1359  // Add the calendar stuff
1360  $cal_join = "
1361  JOIN {$CONFIG->dbprefix}metadata cal_start on e.guid=cal_start.entity_guid
1362  JOIN {$CONFIG->dbprefix}metastrings cal_start_name on cal_start.name_id=cal_start_name.id
1363  JOIN {$CONFIG->dbprefix}metastrings cal_start_value on cal_start.value_id=cal_start_value.id
1364 
1365  JOIN {$CONFIG->dbprefix}metadata cal_end on e.guid=cal_end.entity_guid
1366  JOIN {$CONFIG->dbprefix}metastrings cal_end_name on cal_end.name_id=cal_end_name.id
1367  JOIN {$CONFIG->dbprefix}metastrings cal_end_value on cal_end.value_id=cal_end_value.id
1368  ";
1369  $where[] = "cal_start_name.string='calendar_start'";
1370  $where[] = "cal_start_value.string>=$start_time";
1371  $where[] = "cal_end_name.string='calendar_end'";
1372  $where[] = "cal_end_value.string <= $end_time";
1373 
1374 
1375  if (!$count) {
1376  $query = "SELECT e.* from {$CONFIG->dbprefix}entities e $cal_join where ";
1377  } else {
1378  $query = "SELECT count(e.guid) as total from {$CONFIG->dbprefix}entities e $cal_join where ";
1379  }
1380  foreach ($where as $w) {
1381  $query .= " $w and ";
1382  }
1383 
1384  $query .= _elgg_get_access_where_sql();
1385 
1386  if (!$count) {
1387  $query .= " order by n.calendar_start $order_by";
1388  // Add order and limit
1389  if ($limit) {
1390  $query .= " limit $offset, $limit";
1391  }
1392  $dt = get_data($query, "entity_row_to_elggstar");
1393 
1394  return $dt;
1395  } else {
1396  $total = get_data_row($query);
1397  return $total->total;
1398  }
1399 }
1400 
1421 function get_notable_entities_from_metadata($start_time, $end_time, $meta_name, $meta_value = "",
1422 $entity_type = "", $entity_subtype = "", $owner_guid = 0, $limit = 10, $offset = 0, $order_by = "",
1423 $site_guid = 0, $count = false) {
1424  elgg_deprecated_notice('get_notable_entities_from_metadata() has been deprecated', 1.9);
1425 
1426  global $CONFIG;
1427 
1428  $meta_n = get_metastring_id($meta_name);
1429  $meta_v = get_metastring_id($meta_value);
1430 
1431  $start_time = (int)$start_time;
1432  $end_time = (int)$end_time;
1433  $entity_type = sanitise_string($entity_type);
1434  $entity_subtype = get_subtype_id($entity_type, $entity_subtype);
1435  $limit = (int)$limit;
1436  $offset = (int)$offset;
1437  if ($order_by == "") {
1438  $order_by = "e.time_created desc";
1439  }
1440  $order_by = sanitise_string($order_by);
1441  $site_guid = (int) $site_guid;
1442  if ((is_array($owner_guid) && (count($owner_guid)))) {
1443  foreach ($owner_guid as $key => $guid) {
1444  $owner_guid[$key] = (int) $guid;
1445  }
1446  } else {
1447  $owner_guid = (int) $owner_guid;
1448  }
1449 
1450  if ($site_guid == 0) {
1451  $site_guid = $CONFIG->site_guid;
1452  }
1453 
1454  //$access = get_access_list();
1455 
1456  $where = array();
1457 
1458  if ($entity_type != "") {
1459  $where[] = "e.type='$entity_type'";
1460  }
1461 
1462  if ($entity_subtype) {
1463  $where[] = "e.subtype=$entity_subtype";
1464  }
1465 
1466  if ($meta_name != "") {
1467  $where[] = "m.name_id='$meta_n'";
1468  }
1469 
1470  if ($meta_value != "") {
1471  $where[] = "m.value_id='$meta_v'";
1472  }
1473 
1474  if ($site_guid > 0) {
1475  $where[] = "e.site_guid = {$site_guid}";
1476  }
1477 
1478  if (is_array($owner_guid)) {
1479  $where[] = "e.container_guid in (" . implode(",", $owner_guid) . ")";
1480  } else if ($owner_guid > 0) {
1481  $where[] = "e.container_guid = {$owner_guid}";
1482  }
1483 
1484  // Add the calendar stuff
1485  $cal_join = "
1486  JOIN {$CONFIG->dbprefix}metadata cal_start on e.guid=cal_start.entity_guid
1487  JOIN {$CONFIG->dbprefix}metastrings cal_start_name on cal_start.name_id=cal_start_name.id
1488  JOIN {$CONFIG->dbprefix}metastrings cal_start_value on cal_start.value_id=cal_start_value.id
1489 
1490  JOIN {$CONFIG->dbprefix}metadata cal_end on e.guid=cal_end.entity_guid
1491  JOIN {$CONFIG->dbprefix}metastrings cal_end_name on cal_end.name_id=cal_end_name.id
1492  JOIN {$CONFIG->dbprefix}metastrings cal_end_value on cal_end.value_id=cal_end_value.id
1493  ";
1494 
1495  $where[] = "cal_start_name.string='calendar_start'";
1496  $where[] = "cal_start_value.string>=$start_time";
1497  $where[] = "cal_end_name.string='calendar_end'";
1498  $where[] = "cal_end_value.string <= $end_time";
1499 
1500  if (!$count) {
1501  $query = "SELECT distinct e.* ";
1502  } else {
1503  $query = "SELECT count(distinct e.guid) as total ";
1504  }
1505 
1506  $query .= "from {$CONFIG->dbprefix}entities e"
1507  . " JOIN {$CONFIG->dbprefix}metadata m on e.guid = m.entity_guid $cal_join where";
1508 
1509  foreach ($where as $w) {
1510  $query .= " $w and ";
1511  }
1512 
1513  // Add access controls
1514  $query .= _elgg_get_access_where_sql(array('table_alias' => 'e'));
1515  $query .= ' and ' . _elgg_get_access_where_sql(array('table_alias' => "m"));
1516 
1517  if (!$count) {
1518  // Add order and limit
1519  $query .= " order by $order_by limit $offset, $limit";
1520  return get_data($query, "entity_row_to_elggstar");
1521  } else {
1522  if ($row = get_data_row($query)) {
1523  return $row->total;
1524  }
1525  }
1526 
1527  return false;
1528 }
1529 
1553 function get_noteable_entities_from_relationship($start_time, $end_time, $relationship,
1554 $relationship_guid, $inverse_relationship = false, $type = "", $subtype = "", $owner_guid = 0,
1555 $order_by = "", $limit = 10, $offset = 0, $count = false, $site_guid = 0) {
1556  elgg_deprecated_notice('get_noteable_entities_from_relationship() has been deprecated', 1.9);
1557 
1558  global $CONFIG;
1559 
1560  $start_time = (int)$start_time;
1561  $end_time = (int)$end_time;
1562  $relationship = sanitise_string($relationship);
1563  $relationship_guid = (int)$relationship_guid;
1564  $inverse_relationship = (bool)$inverse_relationship;
1567  $owner_guid = (int)$owner_guid;
1568  if ($order_by == "") {
1569  $order_by = "time_created desc";
1570  }
1571  $order_by = sanitise_string($order_by);
1572  $limit = (int)$limit;
1573  $offset = (int)$offset;
1574  $site_guid = (int) $site_guid;
1575  if ($site_guid == 0) {
1576  $site_guid = $CONFIG->site_guid;
1577  }
1578 
1579  //$access = get_access_list();
1580 
1581  $where = array();
1582 
1583  if ($relationship != "") {
1584  $where[] = "r.relationship='$relationship'";
1585  }
1586  if ($relationship_guid) {
1587  $where[] = $inverse_relationship ?
1588  "r.guid_two='$relationship_guid'" : "r.guid_one='$relationship_guid'";
1589  }
1590  if ($type != "") {
1591  $where[] = "e.type='$type'";
1592  }
1593  if ($subtype) {
1594  $where[] = "e.subtype=$subtype";
1595  }
1596  if ($owner_guid != "") {
1597  $where[] = "e.container_guid='$owner_guid'";
1598  }
1599  if ($site_guid > 0) {
1600  $where[] = "e.site_guid = {$site_guid}";
1601  }
1602 
1603  // Add the calendar stuff
1604  $cal_join = "
1605  JOIN {$CONFIG->dbprefix}metadata cal_start on e.guid=cal_start.entity_guid
1606  JOIN {$CONFIG->dbprefix}metastrings cal_start_name on cal_start.name_id=cal_start_name.id
1607  JOIN {$CONFIG->dbprefix}metastrings cal_start_value on cal_start.value_id=cal_start_value.id
1608 
1609  JOIN {$CONFIG->dbprefix}metadata cal_end on e.guid=cal_end.entity_guid
1610  JOIN {$CONFIG->dbprefix}metastrings cal_end_name on cal_end.name_id=cal_end_name.id
1611  JOIN {$CONFIG->dbprefix}metastrings cal_end_value on cal_end.value_id=cal_end_value.id
1612  ";
1613  $where[] = "cal_start_name.string='calendar_start'";
1614  $where[] = "cal_start_value.string>=$start_time";
1615  $where[] = "cal_end_name.string='calendar_end'";
1616  $where[] = "cal_end_value.string <= $end_time";
1617 
1618  // Select what we're joining based on the options
1619  $joinon = "e.guid = r.guid_one";
1620  if (!$inverse_relationship) {
1621  $joinon = "e.guid = r.guid_two";
1622  }
1623 
1624  if ($count) {
1625  $query = "SELECT count(distinct e.guid) as total ";
1626  } else {
1627  $query = "SELECT distinct e.* ";
1628  }
1629  $query .= " from {$CONFIG->dbprefix}entity_relationships r"
1630  . " JOIN {$CONFIG->dbprefix}entities e on $joinon $cal_join where ";
1631 
1632  foreach ($where as $w) {
1633  $query .= " $w and ";
1634  }
1635  // Add access controls
1636  $query .= _elgg_get_access_where_sql();
1637  if (!$count) {
1638  $query .= " order by $order_by limit $offset, $limit"; // Add order and limit
1639  return get_data($query, "entity_row_to_elggstar");
1640  } else {
1641  if ($count = get_data_row($query)) {
1642  return $count->total;
1643  }
1644  }
1645  return false;
1646 }
1647 
1665 function get_todays_entities($type = "", $subtype = "", $owner_guid = 0, $order_by = "",
1666 $limit = 10, $offset = 0, $count = false, $site_guid = 0, $container_guid = null) {
1667  elgg_deprecated_notice('get_todays_entities() has been deprecated', 1.9);
1668 
1669  $day_start = get_day_start();
1670  $day_end = get_day_end();
1671 
1672  return get_notable_entities($day_start, $day_end, $type, $subtype, $owner_guid, $order_by,
1673  $limit, $offset, $count, $site_guid, $container_guid);
1674 }
1675 
1694 function get_todays_entities_from_metadata($meta_name, $meta_value = "", $entity_type = "",
1695 $entity_subtype = "", $owner_guid = 0, $limit = 10, $offset = 0, $order_by = "", $site_guid = 0,
1696 $count = false) {
1697  elgg_deprecated_notice('get_todays_entities_from_metadata() has been deprecated', 1.9);
1698 
1699  $day_start = get_day_start();
1700  $day_end = get_day_end();
1701 
1702  return get_notable_entities_from_metadata($day_start, $day_end, $meta_name, $meta_value,
1703  $entity_type, $entity_subtype, $owner_guid, $limit, $offset, $order_by, $site_guid, $count);
1704 }
1705 
1727 function get_todays_entities_from_relationship($relationship, $relationship_guid,
1728 $inverse_relationship = false, $type = "", $subtype = "", $owner_guid = 0,
1729 $order_by = "", $limit = 10, $offset = 0, $count = false, $site_guid = 0) {
1730  elgg_deprecated_notice('get_todays_entities_from_relationship() has been deprecated', 1.9);
1731 
1732  $day_start = get_day_start();
1733  $day_end = get_day_end();
1734 
1735  return get_notable_entities_from_relationship($day_start, $day_end, $relationship,
1736  $relationship_guid, $inverse_relationship, $type, $subtype, $owner_guid, $order_by,
1737  $limit, $offset, $count, $site_guid);
1738 }
1739 
1759 function list_notable_entities($start_time, $end_time, $type= "", $subtype = "", $owner_guid = 0,
1760 $limit = 10, $fullview = true, $listtypetoggle = false, $navigation = true) {
1761  elgg_deprecated_notice('list_notable_entities() has been deprecated', 1.9);
1762 
1763  $offset = (int) get_input('offset');
1764  $count = get_notable_entities($start_time, $end_time, $type, $subtype,
1765  $owner_guid, "", $limit, $offset, true);
1766 
1767  $entities = get_notable_entities($start_time, $end_time, $type, $subtype,
1768  $owner_guid, "", $limit, $offset);
1769 
1770  return elgg_view_entity_list($entities, $count, $offset, $limit,
1771  $fullview, $listtypetoggle, $navigation);
1772 }
1773 
1791 function list_todays_entities($type= "", $subtype = "", $owner_guid = 0, $limit = 10,
1792 $fullview = true, $listtypetoggle = false, $navigation = true) {
1793  elgg_deprecated_notice('list_todays_entities() has been deprecated', 1.9);
1794 
1795  $day_start = get_day_start();
1796  $day_end = get_day_end();
1797 
1798  return list_notable_entities($day_start, $day_end, $type, $subtype, $owner_guid, $limit,
1799  $fullview, $listtypetoggle, $navigation);
1800 }
1801 
1815 function elgg_regenerate_simplecache($viewtype = NULL) {
1816  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated by elgg_invalidate_simplecache()', 1.9);
1818 }
1819 
1825  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated by elgg_get_system_cache()', 1.9);
1826  return elgg_get_system_cache();
1827 }
1833  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated by elgg_reset_system_cache()', 1.9);
1835 }
1841  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated by elgg_save_system_cache()', 1.9);
1843 }
1849  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated by elgg_load_system_cache()', 1.9);
1850  return elgg_load_system_cache($type);
1851 }
1857  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated by elgg_enable_system_cache()', 1.9);
1859 }
1865  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated by elgg_disable_system_cache()', 1.9);
1867 }
1868 
1882  elgg_deprecated_notice("unregister_entity_type() was deprecated by elgg_unregister_entity_type()", 1.9);
1884 }
1885 
1896 function already_attached($guid_one, $guid_two) {
1897  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated', 1.9);
1898  if ($attached = check_entity_relationship($guid_one, "attached", $guid_two)) {
1899  return true;
1900  } else {
1901  return false;
1902  }
1903 }
1904 
1915 function get_attachments($guid, $type = "") {
1916  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated', 1.9);
1917  $options = array(
1918  'relationship' => 'attached',
1919  'relationship_guid' => $guid,
1920  'inverse_relationship' => false,
1921  'types' => $type,
1922  'subtypes' => '',
1923  'owner_guid' => 0,
1924  'order_by' => 'time_created desc',
1925  'limit' => 10,
1926  'offset' => 0,
1927  'count' => false,
1928  'site_guid' => 0
1929  );
1931  return $attached;
1932 }
1933 
1944 function remove_attachment($guid_one, $guid_two) {
1945  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated', 1.9);
1946  if (already_attached($guid_one, $guid_two)) {
1947  remove_entity_relationship($guid_one, "attached", $guid_two);
1948  }
1949 }
1950 
1961 function make_attachment($guid_one, $guid_two) {
1962  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated', 1.9);
1963  if (!(already_attached($guid_one, $guid_two))) {
1964  if (add_entity_relationship($guid_one, "attached", $guid_two)) {
1965  return true;
1966  }
1967  }
1968 }
1969 
1979  elgg_deprecated_notice('get_entity_url has been deprecated in favor of \ElggEntity::getURL', '1.9');
1980  if ($entity = get_entity($entity_guid)) {
1981  return $entity->getURL();
1982  }
1983 
1984  return false;
1985 }
1986 
2007 function delete_entity($guid, $recursive = true) {
2008  elgg_deprecated_notice('delete_entity has been deprecated in favor of \ElggEntity::delete', '1.9');
2009  $guid = (int)$guid;
2010  if ($entity = get_entity($guid)) {
2011  return $entity->delete($recursive);
2012  }
2013  return false;
2014 }
2015 
2028 function enable_entity($guid, $recursive = true) {
2029  elgg_deprecated_notice('enable_entity has been deprecated in favor of elgg_enable_entity', '1.9');
2030 
2031  $guid = (int)$guid;
2032 
2033  // Override access only visible entities
2034  $old_access_status = access_get_show_hidden_status();
2036 
2037  $result = false;
2038  if ($entity = get_entity($guid)) {
2039  $result = $entity->enable($recursive);
2040  }
2041 
2042  access_show_hidden_entities($old_access_status);
2043  return $result;
2044 }
2045 
2062  elgg_deprecated_notice('can_edit_entity_metadata has been deprecated in favor of \ElggEntity::canEditMetadata', '1.9');
2063  if ($entity = get_entity($entity_guid)) {
2064  return $entity->canEditMetadata($metadata, $user_guid);
2065  } else {
2066  return false;
2067  }
2068 }
2069 
2090 function disable_entity($guid, $reason = "", $recursive = true) {
2091  elgg_deprecated_notice('disable_entity was deprecated in favor of \ElggEntity::disable', '1.9');
2092 
2093  if ($entity = get_entity($guid)) {
2094  return $entity->disable($reason, $recursive);
2095  }
2096 
2097  return false;
2098 }
2099 
2114  elgg_deprecated_notice('can_edit_entity was deprecated in favor of \ElggEntity::canEdit', '1.9');
2115  if ($entity = get_entity($entity_guid)) {
2116  return $entity->canEdit($user_guid);
2117  }
2118 
2119  return false;
2120 }
2121 
2131 function join_group($group_guid, $user_guid) {
2132  elgg_deprecated_notice('join_group was deprecated in favor of \ElggGroup::join', '1.9');
2133 
2134  $group = get_entity($group_guid);
2136 
2137  if ($group instanceof \ElggGroup && $user instanceof \ElggUser) {
2138  return $group->join($user);
2139  }
2140 
2141  return false;
2142 }
2143 
2153 function leave_group($group_guid, $user_guid) {
2154  elgg_deprecated_notice('leave_group was deprecated in favor of \ElggGroup::leave', '1.9');
2155  $group = get_entity($group_guid);
2157 
2158  if ($group instanceof \ElggGroup && $user instanceof \ElggUser) {
2159  return $group->leave($user);
2160  }
2161 
2162  return false;
2163 }
2164 
2172 function autop($string) {
2173  elgg_deprecated_notice('autop has been deprecated in favor of elgg_autop', '1.9');
2174  return elgg_autop($string);
2175 }
2176 
2182 function expose_function($method, $function, array $parameters = NULL, $description = "",
2183  $call_method = "GET", $require_api_auth = false, $require_user_auth = false) {
2184  elgg_deprecated_notice("expose_function() deprecated for the function elgg_ws_expose_function() in web_services plugin", 1.9);
2185  if (!elgg_admin_notice_exists("elgg:ws:1.9")) {
2186  elgg_add_admin_notice("elgg:ws:1.9", "The web services are now a plugin in Elgg 1.9.
2187  You must enable this plugin and update your web services to use elgg_ws_expose_function().");
2188  }
2189 
2190  if (function_exists("elgg_ws_expose_function")) {
2191  return elgg_ws_expose_function($method, $function, $parameters, $description, $call_method, $require_api_auth, $require_user_auth);
2192  }
2193 }
2194 
2203  elgg_deprecated_notice("unexpose_function() deprecated for the function elgg_ws_unexpose_function() in web_services plugin", 1.9);
2204  if (function_exists("elgg_ws_unexpose_function")) {
2205  return elgg_ws_unexpose_function($method);
2206  }
2207 }
2208 
2217 function register_service_handler($handler, $function) {
2218  elgg_deprecated_notice("register_service_handler() deprecated for the function elgg_ws_register_service_handler() in web_services plugin", 1.9);
2219  if (function_exists("elgg_ws_register_service_handler")) {
2220  return elgg_ws_register_service_handler($handler, $function);
2221  }
2222 }
2223 
2234  elgg_deprecated_notice("unregister_service_handler() deprecated for the function elgg_ws_unregister_service_handler() in web_services plugin", 1.9);
2235  if (function_exists("elgg_ws_unregister_service_handler")) {
2236  return elgg_ws_unregister_service_handler($handler);
2237  }
2238 }
2239 
2254  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use \ElggSite constructor', 1.9);
2255  global $CONFIG;
2256 
2257  $guid = (int)$guid;
2261 
2263 
2264  if ($row) {
2265  // Exists and you have access to it
2266  $query = "SELECT guid from {$CONFIG->dbprefix}sites_entity where guid = {$guid}";
2267  if ($exists = get_data_row($query)) {
2268  $query = "UPDATE {$CONFIG->dbprefix}sites_entity
2269  set name='$name', description='$description', url='$url' where guid=$guid";
2270  $result = update_data($query);
2271 
2272  if ($result != false) {
2273  // Update succeeded, continue
2275  if (elgg_trigger_event('update', $entity->type, $entity)) {
2276  return $guid;
2277  } else {
2278  $entity->delete();
2279  //delete_entity($guid);
2280  }
2281  }
2282  } else {
2283  // Update failed, attempt an insert.
2284  $query = "INSERT into {$CONFIG->dbprefix}sites_entity
2285  (guid, name, description, url) values ($guid, '$name', '$description', '$url')";
2286  $result = insert_data($query);
2287 
2288  if ($result !== false) {
2290  if (elgg_trigger_event('create', $entity->type, $entity)) {
2291  return $guid;
2292  } else {
2293  $entity->delete();
2294  //delete_entity($guid);
2295  }
2296  }
2297  }
2298  }
2299 
2300  return false;
2301 }
2302 
2316  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use \ElggGroup constructor', 1.9);
2317  global $CONFIG;
2318 
2319  $guid = (int)$guid;
2322 
2324 
2325  if ($row) {
2326  // Exists and you have access to it
2327  $exists = get_data_row("SELECT guid from {$CONFIG->dbprefix}groups_entity WHERE guid = {$guid}");
2328  if ($exists) {
2329  $query = "UPDATE {$CONFIG->dbprefix}groups_entity set"
2330  . " name='$name', description='$description' where guid=$guid";
2331  $result = update_data($query);
2332  if ($result != false) {
2333  // Update succeeded, continue
2335  if (elgg_trigger_event('update', $entity->type, $entity)) {
2336  return $guid;
2337  } else {
2338  $entity->delete();
2339  }
2340  }
2341  } else {
2342  // Update failed, attempt an insert.
2343  $query = "INSERT into {$CONFIG->dbprefix}groups_entity"
2344  . " (guid, name, description) values ($guid, '$name', '$description')";
2345 
2346  $result = insert_data($query);
2347  if ($result !== false) {
2349  if (elgg_trigger_event('create', $entity->type, $entity)) {
2350  return $guid;
2351  } else {
2352  $entity->delete();
2353  }
2354  }
2355  }
2356  }
2357 
2358  return false;
2359 }
2360 
2379  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use \ElggUser constructor', 1.9);
2380  global $CONFIG;
2381 
2382  $guid = (int)$guid;
2386  $salt = sanitise_string($salt);
2389 
2391  if ($row) {
2392  // Exists and you have access to it
2393  $query = "SELECT guid from {$CONFIG->dbprefix}users_entity where guid = {$guid}";
2394  if ($exists = get_data_row($query)) {
2395  $query = "UPDATE {$CONFIG->dbprefix}users_entity
2396  SET name='$name', username='$username', password='$password', salt='$salt',
2397  email='$email', language='$language'
2398  WHERE guid = $guid";
2399 
2400  $result = update_data($query);
2401  if ($result != false) {
2402  // Update succeeded, continue
2404  if (elgg_trigger_event('update', $entity->type, $entity)) {
2405  return $guid;
2406  } else {
2407  $entity->delete();
2408  }
2409  }
2410  } else {
2411  // Exists query failed, attempt an insert.
2412  $query = "INSERT into {$CONFIG->dbprefix}users_entity
2413  (guid, name, username, password, salt, email, language)
2414  values ($guid, '$name', '$username', '$password', '$salt', '$email', '$language')";
2415 
2416  $result = insert_data($query);
2417  if ($result !== false) {
2419  if (elgg_trigger_event('create', $entity->type, $entity)) {
2420  return $guid;
2421  } else {
2422  $entity->delete();
2423  }
2424  }
2425  }
2426  }
2427 
2428  return false;
2429 }
2430 
2444  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use \ElggObject constructor', 1.9);
2445  global $CONFIG;
2446 
2447  $guid = (int)$guid;
2450 
2452 
2453  if ($row) {
2454  // Core entities row exists and we have access to it
2455  $query = "SELECT guid from {$CONFIG->dbprefix}objects_entity where guid = {$guid}";
2456  if ($exists = get_data_row($query)) {
2457  $query = "UPDATE {$CONFIG->dbprefix}objects_entity
2458  set title='$title', description='$description' where guid=$guid";
2459 
2460  $result = update_data($query);
2461  if ($result != false) {
2462  // Update succeeded, continue
2464  elgg_trigger_event('update', $entity->type, $entity);
2465  return $guid;
2466  }
2467  } else {
2468  // Update failed, attempt an insert.
2469  $query = "INSERT into {$CONFIG->dbprefix}objects_entity
2470  (guid, title, description) values ($guid, '$title','$description')";
2471 
2472  $result = insert_data($query);
2473  if ($result !== false) {
2475  if (elgg_trigger_event('create', $entity->type, $entity)) {
2476  return $guid;
2477  } else {
2478  $entity->delete();
2479  }
2480  }
2481  }
2482  }
2483 
2484  return false;
2485 }
2486 
2496 function ODD_factory (XmlElement $element) {
2497  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated', 1.9);
2498  $name = $element->name;
2499  $odd = false;
2500 
2501  switch ($name) {
2502  case 'entity' :
2503  $odd = new ODDEntity("", "", "");
2504  break;
2505  case 'metadata' :
2506  $odd = new ODDMetaData("", "", "", "");
2507  break;
2508  case 'relationship' :
2509  $odd = new ODDRelationship("", "", "");
2510  break;
2511  }
2512 
2513  // Now populate values
2514  if ($odd) {
2515  // Attributes
2516  foreach ($element->attributes as $k => $v) {
2517  $odd->setAttribute($k, $v);
2518  }
2519 
2520  // Body
2521  $body = $element->content;
2522  $a = stripos($body, "<![CDATA");
2523  $b = strripos($body, "]]>");
2524  if (($body) && ($a !== false) && ($b !== false)) {
2525  $body = substr($body, $a + 8, $b - ($a + 8));
2526  }
2527 
2528  $odd->setBody($body);
2529  }
2530 
2531  return $odd;
2532 }
2533 
2548  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated', 1.9);
2549  $class = $element->getAttribute('class');
2550  $subclass = $element->getAttribute('subclass');
2551 
2552  // See if we already have imported this uuid
2553  $tmp = get_entity_from_uuid($element->getAttribute('uuid'));
2554 
2555  if (!$tmp) {
2556  // Construct new class with owner from session
2557  $classname = get_subtype_class($class, $subclass);
2558  if ($classname) {
2559  if (class_exists($classname)) {
2560  $tmp = new $classname();
2561 
2562  if (!($tmp instanceof \ElggEntity)) {
2563  $msg = $classname . " is not a " . get_class() . ".";
2564  throw new \ClassException($msg);
2565  }
2566  } else {
2567  error_log("Class '" . $classname . "' was not found, missing plugin?");
2568  }
2569  } else {
2570  switch ($class) {
2571  case 'object' :
2572  $tmp = new \ElggObject();
2573  break;
2574  case 'user' :
2575  $tmp = new \ElggUser();
2576  break;
2577  case 'group' :
2578  $tmp = new \ElggGroup();
2579  break;
2580  case 'site' :
2581  $tmp = new \ElggSite();
2582  break;
2583  default:
2584  $msg = "Type " . $class . " is not supported. This indicates an error in your installation, most likely caused by an incomplete upgrade.";
2585  throw new \InstallationException($msg);
2586  }
2587  }
2588  }
2589 
2590  if ($tmp) {
2591  if (!$tmp->import($element)) {
2592  $msg = "Could not import element " . $element->getAttribute('uuid');
2593  throw new \ImportException($msg);
2594  }
2595 
2596  return $tmp;
2597  }
2598 
2599  return NULL;
2600 }
2601 
2611 function ODD_Import($xml) {
2612  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated', 1.9);
2613  // Parse XML to an array
2614  $elements = xml_to_object($xml);
2615 
2616  // Sanity check 1, was this actually XML?
2617  if ((!$elements) || (!$elements->children)) {
2618  return false;
2619  }
2620 
2621  // Create ODDDocument
2622  $document = new ODDDocument();
2623 
2624  // Itterate through array of elements and construct ODD document
2625  $cnt = 0;
2626 
2627  foreach ($elements->children as $child) {
2628  $odd = ODD_factory($child);
2629 
2630  if ($odd) {
2631  $document->addElement($odd);
2632  $cnt++;
2633  }
2634  }
2635 
2636  // Check that we actually found something
2637  if ($cnt == 0) {
2638  return false;
2639  }
2640 
2641  return $document;
2642 }
2643 
2653 function ODD_Export(ODDDocument $document) {
2654  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated', 1.9);
2655  return "$document";
2656 }
2657 
2667  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated', 1.9);
2668  if ($object instanceof \ElggEntity) {
2669  return guid_to_uuid($object->guid);
2670  } else if ($object instanceof \ElggExtender) {
2671  $type = $object->type;
2672  if ($type == 'volatile') {
2673  $uuid = guid_to_uuid($object->entity_guid) . $type . "/{$object->name}/";
2674  } else {
2675  $uuid = guid_to_uuid($object->entity_guid) . $type . "/{$object->id}/";
2676  }
2677 
2678  return $uuid;
2679  } else if ($object instanceof \ElggRelationship) {
2680  return guid_to_uuid($object->guid_one) . "relationship/{$object->id}/";
2681  }
2682 
2683  return false;
2684 }
2685 
2694 function guid_to_uuid($guid) {
2695  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated', 1.9);
2696  return elgg_get_site_url() . "export/opendd/$guid/";
2697 }
2698 
2707 function is_uuid_this_domain($uuid) {
2708  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated', 1.9);
2709  if (strpos($uuid, elgg_get_site_url()) === 0) {
2710  return true;
2711  }
2712 
2713  return false;
2714 }
2715 
2724 function get_entity_from_uuid($uuid) {
2725  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated', 1.9);
2726  $uuid = sanitise_string($uuid);
2727 
2728  $options = array('metadata_name' => 'import_uuid', 'metadata_value' => $uuid);
2730 
2731  if ($entities) {
2732  return $entities[0];
2733  }
2734 
2735  return false;
2736 }
2737 
2747 function add_uuid_to_guid($guid, $uuid) {
2748  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated', 1.9);
2749  $guid = (int)$guid;
2750  $uuid = sanitise_string($uuid);
2751 
2752  $result = create_metadata($guid, "import_uuid", $uuid);
2753  return (bool)$result;
2754 }
2755 
2756 
2757 $IMPORTED_DATA = array();
2759 
2772 function _process_element(ODD $odd) {
2773  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated', 1.9);
2775 
2776  // See if anyone handles this element, return true if it is.
2777  $to_be_serialised = null;
2778  if ($odd) {
2779  $handled = elgg_trigger_plugin_hook("import", "all", array("element" => $odd), $to_be_serialised);
2780 
2781  // If not, then see if any of its sub elements are handled
2782  if ($handled) {
2783  // Increment validation counter
2784  $IMPORTED_OBJECT_COUNTER ++;
2785  // Return the constructed object
2786  $IMPORTED_DATA[] = $handled;
2787 
2788  return true;
2789  }
2790  }
2791 
2792  return false;
2793 }
2794 
2806  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated', 1.9);
2807  $guid = (int)$guid;
2808 
2809  // Trigger a hook to
2810  $to_be_serialised = elgg_trigger_plugin_hook("export", "all", array("guid" => $guid), array());
2811 
2812  // Sanity check
2813  if ((!is_array($to_be_serialised)) || (count($to_be_serialised) == 0)) {
2814  throw new \ExportException("No such entity GUID:" . $guid);
2815  }
2816 
2817  return $to_be_serialised;
2818 }
2819 
2835 function export($guid) {
2836  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated', 1.9);
2837  $odd = new ODDDocument(exportAsArray($guid));
2838 
2839  return ODD_Export($odd);
2840 }
2841 
2853 function import($xml) {
2854  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated', 1.9);
2856 
2857  $IMPORTED_DATA = array();
2858  $IMPORTED_OBJECT_COUNTER = 0;
2859 
2860  $document = ODD_Import($xml);
2861  if (!$document) {
2862  throw new \ImportException("No OpenDD elements found in import data, import failed.");
2863  }
2864 
2865  foreach ($document as $element) {
2866  _process_element($element);
2867  }
2868 
2869  if ($IMPORTED_OBJECT_COUNTER != count($IMPORTED_DATA)) {
2870  throw new \ImportException("Not all elements were imported.");
2871  }
2872 
2873  return true;
2874 }
2875 
2883 function _export_init() {
2884  global $CONFIG;
2885 
2886  elgg_register_action("import/opendd");
2887 }
2888 
2904 function elgg_get_views($dir, $base) {
2905  $return = array();
2906  if (file_exists($dir) && is_dir($dir)) {
2907  if ($handle = opendir($dir)) {
2908  while ($view = readdir($handle)) {
2909  if (!in_array($view, array('.', '..', '.svn', 'CVS'))) {
2910  if (is_dir($dir . '/' . $view)) {
2911  if ($val = elgg_get_views($dir . '/' . $view, $base . '/' . $view)) {
2912  $return = array_merge($return, $val);
2913  }
2914  } else {
2915  $view = str_replace('.php', '', $view);
2916  $return[] = $base . '/' . $view;
2917  }
2918  }
2919  }
2920  }
2921  }
2922 
2923  return $return;
2924 }
2925 
2941 function elgg_view_tree($view_root, $viewtype = "") {
2942  global $CONFIG;
2943  static $treecache = array();
2944 
2945  // Get viewtype
2946  if (!$viewtype) {
2947  $viewtype = elgg_get_viewtype();
2948  }
2949 
2950  // A little light internal caching
2951  if (!empty($treecache[$view_root])) {
2952  return $treecache[$view_root];
2953  }
2954 
2955  // Examine $CONFIG->views->locations
2956  if (isset($CONFIG->views->locations[$viewtype])) {
2957  foreach ($CONFIG->views->locations[$viewtype] as $view => $path) {
2958  $pos = strpos($view, $view_root);
2959  if ($pos === 0) {
2960  $treecache[$view_root][] = $view;
2961  }
2962  }
2963  }
2964 
2965  // Now examine core
2966  $location = _elgg_services()->views->view_path;
2967  $viewtype = elgg_get_viewtype();
2968  $root = $location . $viewtype . '/' . $view_root;
2969 
2970  if (file_exists($root) && is_dir($root)) {
2971  $val = elgg_get_views($root, $view_root);
2972  if (!is_array($treecache[$view_root])) {
2973  $treecache[$view_root] = array();
2974  }
2975  $treecache[$view_root] = array_merge($treecache[$view_root], $val);
2976  }
2977 
2978  return $treecache[$view_root];
2979 }
2980 
2996 function add_to_river($view, $action_type, $subject_guid, $object_guid, $access_id = "",
2997 $posted = 0, $annotation_id = 0, $target_guid = 0) {
2998  elgg_deprecated_notice('add_to_river was deprecated in favor of elgg_create_river_item', '1.9');
2999 
3000  // Make sure old parameters are passed in correct format
3001  $access_id = ($access_id == '') ? null : $access_id;
3002  $posted = ($posted == 0) ? null : $posted;
3003 
3004  return elgg_create_river_item(array(
3005  'view' => $view,
3006  'action_type' => $action_type,
3007  'subject_guid' => $subject_guid,
3008  'object_guid' => $object_guid,
3009  'target_guid' => $target_guid,
3010  'access_id' => $access_id,
3011  'posted' => $posted,
3012  'annotation_id' => $annotation_id,
3013  ));
3014 }
3015 
3030 function serialise_object_to_xml($data, $name = "", $n = 0) {
3031  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated.', 1.9);
3032 
3033  $classname = ($name == "" ? get_class($data) : $name);
3034 
3035  $vars = method_exists($data, "export") ? get_object_vars($data->export()) : get_object_vars($data);
3036 
3037  $output = "";
3038 
3039  if (($n == 0) || ( is_object($data) && !($data instanceof \stdClass))) {
3040  $output = "<$classname>";
3041  }
3042 
3043  foreach ($vars as $key => $value) {
3044  $output .= "<$key type=\"" . gettype($value) . "\">";
3045 
3046  if (is_object($value)) {
3048  } else if (is_array($value)) {
3050  } else if (gettype($value) == "boolean") {
3051  $output .= $value ? "true" : "false";
3052  } else {
3053  $output .= htmlspecialchars($value, ENT_NOQUOTES, 'UTF-8');
3054  }
3055 
3056  $output .= "</$key>\n";
3057  }
3058 
3059  if (($n == 0) || (is_object($data) && !($data instanceof \stdClass))) {
3060  $output .= "</$classname>\n";
3061  }
3062 
3063  return $output;
3064 }
3065 
3075 function serialise_array_to_xml(array $data, $n = 0) {
3076  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated.', 1.9);
3077 
3078  $output = "";
3079 
3080  if ($n == 0) {
3081  $output = "<array>\n";
3082  }
3083 
3084  foreach ($data as $key => $value) {
3085  $item = "array_item";
3086 
3087  if (is_numeric($key)) {
3088  $output .= "<$item name=\"$key\" type=\"" . gettype($value) . "\">";
3089  } else {
3090  $item = $key;
3091  $output .= "<$item type=\"" . gettype($value) . "\">";
3092  }
3093 
3094  if (is_object($value)) {
3096  } else if (is_array($value)) {
3098  } else if (gettype($value) == "boolean") {
3099  $output .= $value ? "true" : "false";
3100  } else {
3101  $output .= htmlspecialchars($value, ENT_NOQUOTES, 'UTF-8');
3102  }
3103 
3104  $output .= "</$item>\n";
3105  }
3106 
3107  if ($n == 0) {
3108  $output .= "</array>\n";
3109  }
3110 
3111  return $output;
3112 }
3113 
3122 function xml_to_object($xml) {
3123  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated by \ElggXMLElement', 1.9);
3124  return new \ElggXMLElement($xml);
3125 }
3126 
3136  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use \ElggSite::getDomain()', 1.9);
3137  $guid = (int)$guid;
3138 
3139  $site = get_entity($guid);
3140  if ($site instanceof \ElggSite) {
3141  $breakdown = parse_url($site->url);
3142  return $breakdown['host'];
3143  }
3144 
3145  return false;
3146 }
3147 
3161 function register_notification_object($entity_type, $object_subtype, $language_name) {
3162  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated by elgg_register_notification_event()', 1.9);
3163 
3164  elgg_register_notification_event($entity_type, $object_subtype);
3165  _elgg_services()->notifications->setDeprecatedNotificationSubject($entity_type, $object_subtype, $language_name);
3166 }
3167 
3178  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated by elgg_add_subscription()', 1.9);
3179  return add_entity_relationship($user_guid, 'notify', $author_guid);
3180 }
3181 
3191 function remove_notification_interest($user_guid, $author_guid) {
3192  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated by elgg_remove_subscription()', 1.9);
3193  return remove_entity_relationship($user_guid, 'notify', $author_guid);
3194 }
3195 
3210 function object_notifications($event, $object_type, $object) {
3211  throw new \BadFunctionCallException("object_notifications is a private function and should not be called directly");
3212 }
3213 
3229  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated by elgg_register_notification_method()', 1.9);
3231  _elgg_services()->notifications->registerDeprecatedHandler($method, $handler);
3232 }
3233 
3244  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated by elgg_unregister_notification_method()', 1.9);
3246 }
3247 
3268 function import_entity_plugin_hook($hook, $entity_type, $returnvalue, $params) {
3269  $element = $params['element'];
3270 
3271  $tmp = null;
3272 
3273  if ($element instanceof ODDEntity) {
3274  $tmp = oddentity_to_elggentity($element);
3275 
3276  if ($tmp) {
3277  // Make sure its saved
3278  if (!$tmp->save()) {
3279  $msg = "There was a problem saving " . $element->getAttribute('uuid');
3280  throw new \ImportException($msg);
3281  }
3282 
3283  // Belts and braces
3284  if (!$tmp->guid) {
3285  throw new \ImportException("New entity created but has no GUID, this should not happen.");
3286  }
3287 
3288  // We have saved, so now tag
3289  add_uuid_to_guid($tmp->guid, $element->getAttribute('uuid'));
3290 
3291  return $tmp;
3292  }
3293  }
3294 }
3295 
3313 function export_entity_plugin_hook($hook, $entity_type, $returnvalue, $params) {
3314  // Sanity check values
3315  if ((!is_array($params)) && (!isset($params['guid']))) {
3316  throw new \InvalidParameterException("GUID has not been specified during export, this should never happen.");
3317  }
3318 
3319  if (!is_array($returnvalue)) {
3320  throw new \InvalidParameterException("Entity serialisation function passed a non-array returnvalue parameter");
3321  }
3322 
3323  $guid = (int)$params['guid'];
3324 
3325  // Get the entity
3327  if (!($entity instanceof \ElggEntity)) {
3328  $msg = "GUID:" . $guid . " is not a valid " . get_class();
3329  throw new \InvalidClassException($msg);
3330  }
3331 
3332  $export = $entity->export();
3333 
3334  if (is_array($export)) {
3335  foreach ($export as $e) {
3336  $returnvalue[] = $e;
3337  }
3338  } else {
3339  $returnvalue[] = $export;
3340  }
3341 
3342  return $returnvalue;
3343 }
3344 
3360 function volatile_data_export_plugin_hook($hook, $entity_type, $returnvalue, $params) {
3361  $guid = (int)$params['guid'];
3362  $variable_name = sanitise_string($params['varname']);
3363 
3364  if (($hook == 'volatile') && ($entity_type == 'metadata')) {
3365  if (($guid) && ($variable_name)) {
3366  switch ($variable_name) {
3367  case 'renderedentity' :
3368  elgg_set_viewtype('default');
3371 
3372  $tmp = new \ElggMetadata();
3373  $tmp->type = 'volatile';
3374  $tmp->name = 'renderedentity';
3375  $tmp->value = $view;
3376  $tmp->entity_guid = $guid;
3377 
3378  return $tmp;
3379 
3380  break;
3381  }
3382  }
3383  }
3384 }
3385 
3401 function export_annotation_plugin_hook($hook, $type, $returnvalue, $params) {
3402  // Sanity check values
3403  if ((!is_array($params)) && (!isset($params['guid']))) {
3404  throw new \InvalidParameterException("GUID has not been specified during export, this should never happen.");
3405  }
3406 
3407  if (!is_array($returnvalue)) {
3408  throw new \InvalidParameterException("Entity serialization function passed a non-array returnvalue parameter");
3409  }
3410 
3411  $guid = (int)$params['guid'];
3412  $options = array('guid' => $guid, 'limit' => 0);
3413  if (isset($params['name'])) {
3414  $options['annotation_name'] = $params['name'];
3415  }
3416 
3418 
3419  if ($result) {
3420  foreach ($result as $r) {
3421  $returnvalue[] = $r->export();
3422  }
3423  }
3424 
3425  return $returnvalue;
3426 }
3427 
3443 function import_extender_plugin_hook($hook, $entity_type, $returnvalue, $params) {
3444  $element = $params['element'];
3445 
3446  $tmp = NULL;
3447 
3448  if ($element instanceof ODDMetaData) {
3449  /* @var ODDMetaData $element */
3450  // Recall entity
3451  $entity_uuid = $element->getAttribute('entity_uuid');
3452  $entity = get_entity_from_uuid($entity_uuid);
3453  if (!$entity) {
3454  throw new \ImportException("Entity '" . $entity_uuid . "' could not be found.");
3455  }
3456 
3458 
3459  // Save
3460  if (!$entity->save()) {
3461  $attr_name = $element->getAttribute('name');
3462  $msg = "There was a problem updating '" . $attr_name . "' on entity '" . $entity_uuid . "'";
3463  throw new \ImportException($msg);
3464  }
3465 
3466  return true;
3467  }
3468 }
3469 
3483  // Get the type of extender (metadata, type, attribute etc)
3484  $type = $element->getAttribute('type');
3485  $attr_name = $element->getAttribute('name');
3486  $attr_val = $element->getBody();
3487 
3488  switch ($type) {
3489  // Ignore volatile items
3490  case 'volatile' :
3491  break;
3492  case 'annotation' :
3493  $entity->annotate($attr_name, $attr_val);
3494  break;
3495  case 'metadata' :
3496  $entity->setMetadata($attr_name, $attr_val, "", true);
3497  break;
3498  default : // Anything else assume attribute
3499  $entity->set($attr_name, $attr_val);
3500  }
3501 
3502  // Set time if appropriate
3503  $attr_time = $element->getAttribute('published');
3504  if ($attr_time) {
3505  $entity->set('time_updated', $attr_time);
3506  }
3507 
3508  return true;
3509 }
3510 
3525 function export_metadata_plugin_hook($hook, $entity_type, $returnvalue, $params) {
3526  // Sanity check values
3527  if ((!is_array($params)) && (!isset($params['guid']))) {
3528  throw new \InvalidParameterException("GUID has not been specified during export, this should never happen.");
3529  }
3530 
3531  if (!is_array($returnvalue)) {
3532  throw new \InvalidParameterException("Entity serialisation function passed a non-array returnvalue parameter");
3533  }
3534 
3535  $result = elgg_get_metadata(array(
3536  'guid' => (int)$params['guid'],
3537  'limit' => 0,
3538  ));
3539 
3540  if ($result) {
3541  /* @var \ElggMetadata[] $result */
3542  foreach ($result as $r) {
3543  $returnvalue[] = $r->export();
3544  }
3545  }
3546 
3547  return $returnvalue;
3548 }
3549 
3564 function export_relationship_plugin_hook($hook, $entity_type, $returnvalue, $params) {
3565  // Sanity check values
3566  if ((!is_array($params)) && (!isset($params['guid']))) {
3567  throw new \InvalidParameterException("GUID has not been specified during export, this should never happen.");
3568  }
3569 
3570  if (!is_array($returnvalue)) {
3571  throw new \InvalidParameterException("Entity serialisation function passed a non-array returnvalue parameter");
3572  }
3573 
3574  $guid = (int)$params['guid'];
3575 
3577 
3578  if ($result) {
3579  foreach ($result as $r) {
3580  $returnvalue[] = $r->export();
3581  }
3582  }
3583 
3584  return $returnvalue;
3585 }
3586 
3599 function import_relationship_plugin_hook($hook, $entity_type, $returnvalue, $params) {
3600  $element = $params['element'];
3601 
3602  $tmp = NULL;
3603 
3604  if ($element instanceof ODDRelationship) {
3605  $tmp = new \ElggRelationship();
3606  $tmp->import($element);
3607 
3608  return $tmp;
3609  }
3610  return $tmp;
3611 }
3612 
3628 function get_access_sql_suffix($table_prefix = '', $owner = null) {
3629  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated by _elgg_get_access_where_sql()', 1.9);
3630  return _elgg_get_access_where_sql(array(
3631  'table_alias' => $table_prefix,
3632  'user_guid' => (int)$owner,
3633  ));
3634 }
3635 
3651 function elgg_get_calling_plugin_id($mainfilename = false) {
3652  elgg_deprecated_notice('elgg_get_calling_plugin_id() is deprecated', 1.9);
3653  if (!$mainfilename) {
3654  if ($backtrace = debug_backtrace()) {
3655  foreach ($backtrace as $step) {
3656  $file = $step['file'];
3657  $file = str_replace("\\", "/", $file);
3658  $file = str_replace("//", "/", $file);
3659  if (preg_match("/mod\/([a-zA-Z0-9\-\_]*)\/start\.php$/", $file, $matches)) {
3660  return $matches[1];
3661  }
3662  }
3663  }
3664  } else {
3665  //@todo this is a hack -- plugins do not have to match their page handler names!
3666  if ($handler = get_input('handler', false)) {
3667  return $handler;
3668  } else {
3669  $file = $_SERVER["SCRIPT_NAME"];
3670  $file = str_replace("\\", "/", $file);
3671  $file = str_replace("//", "/", $file);
3672  if (preg_match("/mod\/([a-zA-Z0-9\-\_]*)\//", $file, $matches)) {
3673  return $matches[1];
3674  }
3675  }
3676  }
3677  return false;
3678 }
3679 
3689  elgg_deprecated_notice("elgg_get_calling_plugin_entity() is deprecated.", 1.9);
3691 
3692  if ($plugin_id) {
3694  }
3695 
3696  return false;
3697 }
3698 
3699 return function(\Elgg\EventsService $events, \Elgg\HooksRegistrationService $hooks) {
3700  // Register a startup event
3701  $events->registerHandler('init', 'system', '_export_init', 100);
3702 
3704  $hooks->registerHandler("import", "all", "import_entity_plugin_hook", 0);
3705  $hooks->registerHandler("import", "all", "import_extender_plugin_hook", 2);
3706  $hooks->registerHandler("import", "all", "import_relationship_plugin_hook", 3);
3707 
3709  $hooks->registerHandler("export", "all", "export_entity_plugin_hook", 0);
3710  $hooks->registerHandler("export", "all", "export_annotation_plugin_hook", 2);
3711  $hooks->registerHandler("export", "all", "export_metadata_plugin_hook", 2);
3712  $hooks->registerHandler("export", "all", "export_relationship_plugin_hook", 3);
3713 
3715  $hooks->registerHandler('volatile', 'metadata', 'volatile_data_export_plugin_hook');
3716 };
insert_data($query, array $params=[])
Insert a row into the database.
Definition: database.php:87
elgg_enable_filepath_cache()
private
elgg_admin_notice_exists($id)
Check if an admin notice is currently active.
Definition: admin.php:116
elgg_enable_system_cache()
Enables the system disk cache.
Definition: cache.php:72
$object
These two snippets demonstrates triggering an event and how to register for that event.
Definition: trigger.php:7
elgg_get_config($name, $site_guid=0)
Get an Elgg configuration value.
$view
Definition: crop.php:34
optimize_table($table)
Optimize a table.
elgg_get_calling_plugin_id($mainfilename=false)
Get the name of the most recent plugin to be called in the call stack (or the plugin that owns the cu...
get_metastring_id($string, $case_sensitive=TRUE)
Return the meta string id for a given tag, or false.
$n
Profile fields.
Definition: list.php:9
exportAsArray($guid)
Exports an entity as an array.
$r
remove_site_user($site_guid, $user_guid)
Remove a user from a site.
elgg_reset_system_cache()
Reset the system cache by deleting the caches.
Definition: cache.php:29
elgg_is_logged_in()
Returns whether or not the user is currently logged in.
Definition: sessions.php:51
$action
Definition: full.php:133
elgg_get_entities_from_metadata(array $options=array())
interfaces
Definition: metadata.php:276
get_version($humanreadable=false)
Get the current Elgg version information.
get_attachments($guid, $type="")
Function to get all objects attached to a particular object.
remove_site_object($site_guid, $object_guid)
Remove an object from a site.
calculate_tag_size($min, $max, $number_of_tags, $buckets=6)
The algorithm working out the size of font based on the number of tags.
getBody()
Gets the body of the ODD.
Definition: ODD.php:79
if(!array_key_exists($filename, $text_files)) $file
$username
Definition: delete.php:22
elgg_get_metastring_id($string, $case_sensitive=true)
Gets the metastring identifier for a value.
Definition: metastrings.php:25
get_relationship($id)
Get a relationship by its ID.
elgg_register_notification_method($name)
Register a delivery method for notifications.
export_entity_plugin_hook($hook, $entity_type, $returnvalue, $params)
Exports all attributes of an entity.
get_noteable_entities_from_relationship($start_time, $end_time, $relationship, $relationship_guid, $inverse_relationship=false, $type="", $subtype="", $owner_guid=0, $order_by="", $limit=10, $offset=0, $count=false, $site_guid=0)
Return the notable entities for a given time period based on their relationship.
get_site_objects($site_guid, $subtype="", $limit=10, $offset=0)
Get the objects belonging to a site.
elgg_invalidate_simplecache()
Deletes all cached views in the simplecache and sets the lastcache and lastupdate time to 0 for every...
Definition: cache.php:215
get_group_members($group_guid, $limit=10, $offset=0, $site_guid=0, $count=false)
Return a list of this group&#39;s members.
$table
Definition: cron.php:34
add_entity_relationship($guid_one, $relationship, $guid_two)
Create a relationship between two entities.
list_user_friends_objects($user_guid, $subtype="", $limit=10, $full_view=true, $listtypetoggle=true, $pagination=true, $timelower=0, $timeupper=0)
Displays a list of a user&#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:280
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(!$items) $item
Definition: delete.php:17
if($guid==elgg_get_logged_in_user_guid()) $name
Definition: delete.php:21
create_metadata($entity_guid, $name, $value, $value_type= '', $owner_guid=0, $access_id=null, $allow_multiple=false)
Create a new metadata object, or update an existing one.
Definition: metadata.php:66
unregister_notification_handler($method)
This function unregisters a handler for a given notification type (eg "email")
ODD_Export(ODDDocument $document)
Export an ODD Document.
remove_entity_relationship($guid_one, $relationship, $guid_two)
Delete a relationship between two entities.
$method
Definition: form.php:25
$e
Definition: metadata.php:12
get_subtype_id($type, $subtype)
Return the id for a given subtype.
Definition: entities.php:27
import_relationship_plugin_hook($hook, $entity_type, $returnvalue, $params)
Handler called by trigger_plugin_hook on the "import" event.
ODD_Import($xml)
Import an ODD document.
get_todays_entities_from_relationship($relationship, $relationship_guid, $inverse_relationship=false, $type="", $subtype="", $owner_guid=0, $order_by="", $limit=10, $offset=0, $count=false, $site_guid=0)
Get entities for today from a relationship.
elgg_filepath_cache_save($type, $data)
private
autop($string)
Create paragraphs from text with line spacing.
get_todays_entities_from_metadata($meta_name, $meta_value="", $entity_type="", $entity_subtype="", $owner_guid=0, $limit=10, $offset=0, $order_by="", $site_guid=0, $count=false)
Get entities for today from metadata.
elgg_disable_system_cache()
Disables the system disk cache.
Definition: cache.php:84
elgg_add_admin_notice($id, $message)
Write a persistent message to the admin view.
Definition: admin.php:75
$metadata
Definition: entity.php:19
user_add_friend($user_guid, $friend_guid)
Adds a user to another user&#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:402
_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
if($title=== ''&&$entity instanceof ElggEntity) $tags
Definition: summary.php:31
$path
Definition: details.php:88
$value
Definition: longtext.php:42
add_site_object($site_guid, $object_guid)
Add an object to a site.
$class
Definition: field.php:20
elgg_unregister_entity_type($type, $subtype=null)
Unregisters an entity type and subtype as a public-facing type.
Definition: entities.php:561
get_todays_entities($type="", $subtype="", $owner_guid=0, $order_by="", $limit=10, $offset=0, $count=false, $site_guid=0, $container_guid=null)
Get all entities for today.
get_user_friends_of($user_guid, $subtype=ELGG_ENTITIES_ANY_VALUE, $limit=10, $offset=0)
Obtains the people who have made a given user a friend.
$subtype
Definition: delete.php:28
export_metadata_plugin_hook($hook, $entity_type, $returnvalue, $params)
Handler called by trigger_plugin_hook on the "export" event.
$friend
Definition: add.php:12
$return
Definition: opendd.php:15
create_group_entity($guid, $name, $description)
Create or update the entities table for a given group.
if(!$count) $offset
Definition: pagination.php:26
$pagination
Definition: gallery.php:22
$guid
Removes an admin notice.
$collection
elgg parse_url
Parse a URL into its parts.
Definition: elgglib.js:450
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.
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.
$vars['entity']
$IMPORTED_OBJECT_COUNTER
elgg_get_calling_plugin_entity()
Returns the entity of the last plugin called.
add_metastring($string, $case_sensitive=true)
Add a metastring.
remove_user_from_access_collection($user_guid, $collection_id)
Removes a user from an access collection.
Definition: access.php:389
elgg_get_views($dir, $base)
Returns the name of views for in a directory.
$title
Definition: save.php:22
$options
Elgg admin footer.
Definition: footer.php:6
get_extender_url(\ElggExtender $extender)
Get the URL of a given elgg extender.
elgg_register_extender_url_handler($extender_type, $extender_name, $function_name)
Sets the URL handler for a particular extender type and name.
leave_group($group_guid, $user_guid)
Remove a user from a group.
create_user_entity($guid, $name, $username, $password, $salt, $email, $language, $code)
Create or update the entities table for a given user.
$string
getAttribute($key)
Returns an attribute.
Definition: ODD.php:55
get_day_end($day=null, $month=null, $year=null)
Return a timestamp for the end of a given day (defaults today).
get_notable_entities_from_metadata($start_time, $end_time, $meta_name, $meta_value="", $entity_type="", $entity_subtype="", $owner_guid=0, $limit=10, $offset=0, $order_by="", $site_guid=0, $count=false)
Return the notable entities for a given time period based on an item of metadata. ...
user_is_friend($user_guid, $friend_guid)
Determines whether or not a user is another user&#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.
elgg_get_viewtype()
Return the current view type.
Definition: views.php:95
get_metastring($id)
When given an ID, returns the corresponding metastring.
$params
Definition: login.php:72
$entity_guid
Definition: save.php:9
volatile_data_export_plugin_hook($hook, $entity_type, $returnvalue, $params)
Exports attributes generated on the fly (volatile) about an entity.
get_subtype_class($type, $subtype)
Return the class name for a registered type and subtype.
Definition: entities.php:57
already_attached($guid_one, $guid_two)
Function to determine if the object trying to attach to other, has already done so.
register_notification_interest($user_guid, $author_guid)
Establish a &#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:95
get_user_access_collections($owner_guid, $site_guid=0)
Returns an array of database row objects of the access collections owned by $owner_guid.
Definition: access.php:403
get_entity_relationships($guid, $inverse_relationship=false)
Get all the relationships for a given GUID.
elgg_unregister_notification_method($name)
Unregister a delivery method for notifications.
get_user_friends_objects($user_guid, $subtype=ELGG_ENTITIES_ANY_VALUE, $limit=10, $offset=0, $timelower=0, $timeupper=0)
Obtains a list of objects owned by a user&#39;s friends.
$limit
Definition: userpicker.php:38
annotate($name, $value, $access_id=ACCESS_PRIVATE, $owner_guid=0, $vartype="")
Adds an annotation to an entity.
Definition: ElggEntity.php:834
if($categories) $description
Definition: full.php:176
get_data_row($query, $callback=null, array $params=[])
Retrieve a single row from the database.
Definition: database.php:72
elgg_get_annotation_from_id($id)
Get a specific annotation by its id.
Definition: annotations.php:36
full_url()
Return the full URL of the current page.
elgg_autop($string)
Create paragraphs from text with line spacing.
Definition: output.php:46
elgg_create_river_item(array $options=array())
Adds an item to the river.
Definition: river.php:39
$owner
Definition: crop.php:8
elgg_check_access_overrides($user_guid=0)
Decides if the access system should be ignored for a user.
Definition: access.php:503
$key
Definition: summary.php:34
get_user($guid)
Get a user object from a GUID.
Definition: users.php:87
update_data($query, array $params=[], $get_num_rows=false)
Update a row in the database.
Definition: database.php:102
ODD_factory(XmlElement $element)
Attempt to construct an ODD object out of a XmlElement or sub-elements.
$language
Definition: useradd.php:20
elgg_view_entity(\ElggEntity $entity, array $vars=array(), $bypass=false, $debug=false)
Returns a string of a rendered entity.
Definition: views.php:873
register_notification_object($entity_type, $object_subtype, $language_name)
Register an entity type and subtype to be eligible for notifications.
get_input($variable, $default=null, $filter_result=true)
Get some input from variables passed submitted through GET or POST.
Definition: input.php:27
execute_delayed_write_query($query, $callback=null, array $params=[])
Queue a query for running during shutdown that writes to the database.
Definition: database.php:21
$plugin_id
Definition: save.php:16
global $CONFIG
get_site_domain($guid)
Retrieve a site and return the domain portion of its url.
elgg_geocode_location($location)
Encode a location into a latitude and longitude, caching the result.
sanitise_string($string)
Alias of sanitize_string.
Definition: database.php:166
$user
Definition: ban.php:13
elgg_set_viewtype($viewtype="")
Manually set the viewtype.
Definition: views.php:74
const ELGG_ENTITIES_ANY_VALUE
Definition: elgglib.php:2095
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:826
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:1098
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
get_data($query, $callback=null, array $params=[])
Retrieve rows from the database.
Definition: database.php:55
_elgg_services(\Elgg\Di\ServiceProvider $services=null)
Get the global service provider.
Definition: autoloader.php:17
access_get_show_hidden_status()
Return current status of showing disabled entities.
Definition: access.php:170
elgg_list_entities_from_location(array $options=array())
Returns a viewable list of entities from location.
generate_tag_cloud(array $tags, $buckets=6)
This function generates an array of tags with a weighting.
get_entity_as_row($guid)
Returns a database row from the entities table.
Definition: entities.php:174
$password
Definition: login.php:25
oddmetadata_to_elggextender(\ElggEntity $entity, ODDMetaData $element)
Utility function used by import_extender_plugin_hook() to process an ODDMetaData and add it to an ent...
get_entity_url($entity_guid)
Returns the URL for an entity.
list_notable_entities($start_time, $end_time, $type="", $subtype="", $owner_guid=0, $limit=10, $fullview=true, $listtypetoggle=false, $navigation=true)
Returns a viewable list of entities for a given time period.
guid_to_uuid($guid)
Generate a UUID from a given GUID.
elgg_register_entity_url_handler($entity_type, $entity_subtype, $function_name)
Sets the URL handler for a particular entity type and subtype.
$IMPORTED_DATA
elgg_list_entities_from_relationship(array $options=array())
Returns a viewable list of entities by relationship.
elgg_view_tree($view_root, $viewtype="")
Returns all views below a partial view.
$posted
Definition: comment.php:83
elgg_view_entity_list($entities, array $vars=array())
Returns a rendered list of entities with pagination.
Definition: views.php:1048
elgg_list_entities(array $options=array(), $getter= 'elgg_get_entities', $viewer= 'elgg_view_entity_list')
Returns a string of rendered entities.
Definition: entities.php:393
$size
Definition: default.php:20
elgg_load_system_cache($type)
Retrieve the contents of a system cache.
Definition: cache.php:50
elgg_get_version($human_readable=false)
Get the current Elgg version information.
Definition: elgglib.php:1071
add_object_to_group($group_guid, $object_guid)
Add an object to the given group.
access_show_hidden_entities($show_hidden)
Show or hide disabled entities.
Definition: access.php:158
user_remove_friend($user_guid, $friend_guid)
Removes a user from another user&#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:164
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.
disable_entity($guid, $reason="", $recursive=true)
Disable an entity.
global $METASTRINGS_DEADNAME_CACHE
$entity
Definition: delete.php:7
set($name, $value)
Sets the value of an attribute or metadata.
Definition: ElggEntity.php:235
if(elgg_in_context('widget')) $count
Definition: pagination.php:21
serialise_array_to_xml(array $data, $n=0)
Serialise an array.
oddentity_to_elggentity(ODDEntity $element)
Utility function used by import_entity_plugin_hook() to process an ODDEntity into an unsaved ...
$row
elgg_get_logged_in_user_entity()
Return the current logged in user, or null if no user is logged in.
Definition: sessions.php:32
define(function(require){var $=require('jquery');$(document).on('change', '#elgg-river-selector', function(){var url=window.location.href;if(window.location.search.length){url=url.substring(0, url.indexOf('?'));}url+= '?'+$(this).val();window.location.href=url;});})
Initiates page reload when river selector value changes core/river/filter.
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:96
elgg_get_entities_from_relationship($options)
Return entities matching a given query joining against a relationship.
$output
Definition: item.php:10
can_edit_entity_metadata($entity_guid, $user_guid=0, $metadata=null)
Returns if $user_guid can edit the metadata on $entity_guid.
register_notification_handler($method, $handler, $params=NULL)
This function registers a handler for a given notification type (eg "email")
get_user_friends($user_guid, $subtype=ELGG_ENTITIES_ANY_VALUE, $limit=10, $offset=0)
Obtains a given user&#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.
_elgg_get_access_where_sql(array $options=array())
Returns the SQL where clause for enforcing read access to data.
Definition: access.php:214
elgg_trigger_event($event, $object_type, $object=null)
Definition: elgglib.php:614
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:406
elgg_get_logged_in_user_guid()
Return the current logged in user by guid.
Definition: sessions.php:42
get_user_sites($user_guid, $limit=10, $offset=0)
Get the sites this user is part of.
elgg_get_plugin_from_id($plugin_id)
Returns an object with the path $path.
Definition: plugins.php:82
unexpose_function($method)
Unregister a web services method.
get_entity($guid)
Loads and returns an entity object from a guid.
Definition: entities.php:204
elgg_filepath_cache_reset()
private
remove_object_from_group($group_guid, $object_guid)
Remove an object from the given group.
create_site_entity($guid, $name, $description, $url)
Create or update the entities table for a given site.
remove_attachment($guid_one, $guid_two)
Function to remove a particular attachment between two objects.
if(!$display_name) $type
Definition: delete.php:27
unregister_entity_type($type, $subtype)
Unregisters an entity type and subtype as a public-facing type.
create_object_entity($guid, $title, $description)
Create or update the extras table for a given object.