14 $url = $request->getSchemeAndHttpHost();
19 $quotes = array(
'\'',
'"');
20 $encoded = array(
'%27',
'%22');
21 return $url . str_replace($quotes, $encoded, $request->getRequestUri());
38 elgg_deprecated_notice(__FUNCTION__ .
' is deprecated. Use the plugin hook in \ElggEntity::getURL()', 1.9);
41 if (!is_callable($function_name,
true)) {
45 if (!isset($CONFIG->entity_url_handler)) {
46 $CONFIG->entity_url_handler = array();
49 if (!isset($CONFIG->entity_url_handler[$entity_type])) {
50 $CONFIG->entity_url_handler[$entity_type] = array();
53 $CONFIG->entity_url_handler[$entity_type][$entity_subtype] = $function_name;
71 if (!is_callable($function_name,
true)) {
75 if (!isset($CONFIG->relationship_url_handler)) {
76 $CONFIG->relationship_url_handler = array();
79 $CONFIG->relationship_url_handler[$relationship_type] = $function_name;
101 $guid = $relationship->guid_one;
102 $type = $relationship->relationship;
107 if (isset($CONFIG->relationship_url_handler[
$type])) {
108 $function = $CONFIG->relationship_url_handler[
$type];
110 if (isset($CONFIG->relationship_url_handler[
'all'])) {
111 $function = $CONFIG->relationship_url_handler[
'all'];
114 if (is_callable($function)) {
115 $url = call_user_func($function, $relationship);
119 $nameid = $relationship->id;
147 if (!is_callable($function_name,
true)) {
151 if (!isset($CONFIG->extender_url_handler)) {
152 $CONFIG->extender_url_handler = array();
154 if (!isset($CONFIG->extender_url_handler[$extender_type])) {
155 $CONFIG->extender_url_handler[$extender_type] = array();
157 $CONFIG->extender_url_handler[$extender_type][$extender_name] = $function_name;
177 $guid = $extender->entity_guid;
178 $type = $extender->type;
183 if (isset($CONFIG->extender_url_handler[
$type][$extender->name])) {
184 $function = $CONFIG->extender_url_handler[
$type][$extender->name];
187 if (isset($CONFIG->extender_url_handler[
$type][
'all'])) {
188 $function = $CONFIG->extender_url_handler[
$type][
'all'];
191 if (isset($CONFIG->extender_url_handler[
'all'][
'all'])) {
192 $function = $CONFIG->extender_url_handler[
'all'][
'all'];
195 if (is_callable($function)) {
196 $url = call_user_func($function, $extender);
200 $nameid = $extender->id;
201 if (
$type ==
'volatile') {
202 $nameid = $extender->name;
204 $url =
"export/$view/$guid/$type/$nameid/";
277 'relationship' =>
'member',
278 'relationship_guid' => $group_guid,
279 'inverse_relationship' =>
true,
284 'site_guid' => $site_guid
300 $group_guid = (int)$group_guid;
301 $object_guid = (int)$object_guid;
311 $msg =
"GUID:" . $group_guid .
" is not a valid " .
'\ElggGroup';
312 throw new \InvalidClassException($msg);
316 $msg =
"GUID:" . $object_guid .
" is not a valid " .
'\ElggObject';
317 throw new \InvalidClassException($msg);
320 $object->container_guid = $group_guid;
336 $group_guid = (int)$group_guid;
337 $object_guid = (int)$object_guid;
347 $msg =
"GUID:" . $group_guid .
" is not a valid " .
'\ElggGroup';
348 throw new \InvalidClassException($msg);
352 $msg =
"GUID:" . $object_guid .
" is not a valid " .
'\ElggObject';
353 throw new \InvalidClassException($msg);
392 'relationship' =>
'member',
394 'inverse_relationship' =>
false,
410 elgg_deprecated_notice(__FUNCTION__ .
' is deprecated. Use \ElggUser::isFriendsOf() or \ElggUser::isFriendsWith()', 1.9);
430 'relationship' =>
'friend',
455 'relationship' =>
'friend',
457 'inverse_relationship' =>
true,
529 $site_guid = (int)$site_guid;
546 $site_guid = (int)$site_guid;
563 $site_guid = (int)$site_guid;
564 $object_guid = (int)$object_guid;
580 $site_guid = (int)$site_guid;
581 $object_guid = (int)$object_guid;
599 $site_guid = (int)$site_guid;
604 'relationship' =>
'member_of_site',
605 'relationship_guid' => $site_guid,
606 'inverse_relationship' =>
true,
626 $object_guid = (int)$object_guid;
631 'relationship' =>
'member_of_site',
632 'relationship_guid' => $object_guid,
657 'relationship' =>
'member_of_site',
659 'inverse_relationship' =>
false,
695 $functionname =
"elgg_get_{$type}_from_id";
696 if (is_callable($functionname)) {
697 $extender = call_user_func($functionname, $extender_id);
708 if ($extender->getOwnerGUID() ==
$user_guid) {
713 $entity = $extender->getEntity();
738 $delta = ((
$max - $min) / $buckets);
739 $thresholds = array();
741 for (
$n = 1;
$n <= $buckets;
$n++) {
742 $thresholds[
$n - 1] = ($min +
$n) * $delta;
746 if ($thresholds[$buckets - 1] >
$max) {
747 $thresholds[$buckets - 1] =
$max;
751 for (
$n = 0;
$n < count($thresholds);
$n++) {
752 if ($number_of_tags >= $thresholds[
$n]) {
777 foreach ($tags as $tag) {
780 if ($cloud[$tag] >
$max) {
784 if ($cloud[$tag] < $min) {
789 foreach ($cloud as $k => $v) {
856 if (isset($METASTRINGS_CACHE[
$id])) {
857 return $METASTRINGS_CACHE[
$id];
860 $row =
get_data_row(
"SELECT * from {$CONFIG->dbprefix}metastrings where id='$id' limit 1");
862 $METASTRINGS_CACHE[
$id] =
$row->string;
883 $offset = 0, $timelower = 0, $timeupper = 0) {
891 'created_time_lower' => $timelower,
892 'created_time_upper' => $timeupper,
893 'relationship' =>
'friend',
895 'relationship_join_on' =>
'container_guid',
911 $timelower = 0, $timeupper = 0) {
917 'created_time_lower' => $timelower,
918 'created_time_upper' => $timeupper,
919 'relationship' =>
'friend',
921 'relationship_join_on' =>
'container_guid',
944 $listtypetoggle =
true,
$pagination =
true, $timelower = 0, $timeupper = 0) {
951 'created_time_lower' => $timelower,
952 'created_time_upper' => $timeupper,
954 'list_type_toggle' => $listtypetoggle,
956 'relationship' =>
'friend',
958 'relationship_join_on' =>
'container_guid',
976 if (is_array($location)) {
983 $query =
"SELECT * from {$CONFIG->dbprefix}geocode_cache WHERE location='$location'";
986 if ($cached_location) {
987 return array(
'lat' => $cached_location->lat,
'long' => $cached_location->long);
997 $long = (float)
$return[
'long'];
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}'";
1045 if (!is_array(
$options[
'distance'])) {
1046 $lat_distance = (float)
$options[
'distance'];
1047 $long_distance = (float)
$options[
'distance'];
1049 $lat_distance = (float)
$options[
'distance'][
'latitude'];
1050 $long_distance = (float)
$options[
'distance'][
'longitude'];
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;
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";
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";
1079 } elseif (!isset(
$options[
'wheres'])) {
1087 } elseif (!isset(
$options[
'joins'])) {
1144 for (
$n = 0;
$n < strlen($extra_escapeable);
$n++) {
1145 $string = str_replace($extra_escapeable[
$n],
"\\" . $extra_escapeable[$n],
$string);
1180 return _elgg_services()->db->updateData(
"OPTIMIZE TABLE $table");
1192 function get_db_tables() {
1196 if (isset($tables)) {
1206 $row = (array) $row;
1207 if (is_array($row) && !empty($row)) {
1208 foreach ($row as $element) {
1209 $tables[] = $element;
1231 return mktime(0, 0, 0, $month, $day, $year);
1247 return mktime(23, 59, 59, $month, $day, $year);
1281 $start_time = (int)$start_time;
1282 $end_time = (int)$end_time;
1286 $site_guid = (int) $site_guid;
1287 if ($site_guid == 0) {
1288 $site_guid = $CONFIG->site_guid;
1293 if (is_array(
$type)) {
1295 if (
sizeof(
$type)) {
1296 foreach (
$type as $typekey => $subtypearray) {
1297 foreach ($subtypearray as $subtypeval) {
1299 if (!empty($subtypeval)) {
1304 if (!empty($tempwhere)) {
1305 $tempwhere .=
" or ";
1307 $tempwhere .=
"(e.type = '{$typekey}' and e.subtype = {$subtypeval})";
1311 if (!empty($tempwhere)) {
1312 $where[] =
"({$tempwhere})";
1319 $where[] =
"e.type='$type'";
1323 $where[] =
"e.subtype=$subtype";
1331 $where[] =
"e.owner_guid = '$owner_guid'";
1333 $owner_array = array_map(
'sanitise_int',
$owner_guid);
1336 $where[] =
"e.owner_guid in ({$owner_guid})";
1343 if ($site_guid > 0) {
1344 $where[] =
"e.site_guid = {$site_guid}";
1352 $where[] =
"e.container_guid in (" . implode(
",",
$container_guid) .
")";
1355 $where[] =
"e.container_guid = {$container_guid}";
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 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 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";
1376 $query =
"SELECT e.* from {$CONFIG->dbprefix}entities e $cal_join where ";
1378 $query =
"SELECT count(e.guid) as total from {$CONFIG->dbprefix}entities e $cal_join where ";
1380 foreach ($where as $w) {
1381 $query .=
" $w and ";
1387 $query .=
" order by n.calendar_start $order_by";
1390 $query .=
" limit $offset, $limit";
1392 $dt =
get_data($query,
"entity_row_to_elggstar");
1397 return $total->total;
1423 $site_guid = 0,
$count =
false) {
1431 $start_time = (int)$start_time;
1432 $end_time = (int)$end_time;
1437 if ($order_by ==
"") {
1438 $order_by =
"e.time_created desc";
1441 $site_guid = (int) $site_guid;
1450 if ($site_guid == 0) {
1451 $site_guid = $CONFIG->site_guid;
1458 if ($entity_type !=
"") {
1459 $where[] =
"e.type='$entity_type'";
1462 if ($entity_subtype) {
1463 $where[] =
"e.subtype=$entity_subtype";
1466 if ($meta_name !=
"") {
1467 $where[] =
"m.name_id='$meta_n'";
1470 if ($meta_value !=
"") {
1471 $where[] =
"m.value_id='$meta_v'";
1474 if ($site_guid > 0) {
1475 $where[] =
"e.site_guid = {$site_guid}";
1479 $where[] =
"e.container_guid in (" . implode(
",",
$owner_guid) .
")";
1481 $where[] =
"e.container_guid = {$owner_guid}";
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 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 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";
1501 $query =
"SELECT distinct e.* ";
1503 $query =
"SELECT count(distinct e.guid) as total ";
1506 $query .=
"from {$CONFIG->dbprefix}entities e" 1507 .
" JOIN {$CONFIG->dbprefix}metadata m on e.guid = m.entity_guid $cal_join where";
1509 foreach ($where as $w) {
1510 $query .=
" $w and ";
1519 $query .=
" order by $order_by limit $offset, $limit";
1520 return get_data($query,
"entity_row_to_elggstar");
1560 $start_time = (int)$start_time;
1561 $end_time = (int)$end_time;
1563 $relationship_guid = (int)$relationship_guid;
1564 $inverse_relationship = (bool)$inverse_relationship;
1568 if ($order_by ==
"") {
1569 $order_by =
"time_created desc";
1574 $site_guid = (int) $site_guid;
1575 if ($site_guid == 0) {
1576 $site_guid = $CONFIG->site_guid;
1583 if ($relationship !=
"") {
1584 $where[] =
"r.relationship='$relationship'";
1586 if ($relationship_guid) {
1587 $where[] = $inverse_relationship ?
1588 "r.guid_two='$relationship_guid'" :
"r.guid_one='$relationship_guid'";
1591 $where[] =
"e.type='$type'";
1594 $where[] =
"e.subtype=$subtype";
1597 $where[] =
"e.container_guid='$owner_guid'";
1599 if ($site_guid > 0) {
1600 $where[] =
"e.site_guid = {$site_guid}";
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 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 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";
1619 $joinon =
"e.guid = r.guid_one";
1620 if (!$inverse_relationship) {
1621 $joinon =
"e.guid = r.guid_two";
1625 $query =
"SELECT count(distinct e.guid) as total ";
1627 $query =
"SELECT distinct e.* ";
1629 $query .=
" from {$CONFIG->dbprefix}entity_relationships r" 1630 .
" JOIN {$CONFIG->dbprefix}entities e on $joinon $cal_join where ";
1632 foreach ($where as $w) {
1633 $query .=
" $w and ";
1638 $query .=
" order by $order_by limit $offset, $limit";
1639 return get_data($query,
"entity_row_to_elggstar");
1735 return get_notable_entities_from_relationship($day_start, $day_end, $relationship,
1760 $limit = 10, $fullview =
true, $listtypetoggle =
false, $navigation =
true) {
1771 $fullview, $listtypetoggle, $navigation);
1792 $fullview =
true, $listtypetoggle =
false, $navigation =
true) {
1799 $fullview, $listtypetoggle, $navigation);
1918 'relationship' =>
'attached',
1919 'relationship_guid' =>
$guid,
1920 'inverse_relationship' =>
false,
1924 'order_by' =>
'time_created desc',
2011 return $entity->delete($recursive);
2062 elgg_deprecated_notice(
'can_edit_entity_metadata has been deprecated in favor of \ElggEntity::canEditMetadata',
'1.9');
2094 return $entity->disable($reason, $recursive);
2138 return $group->join(
$user);
2159 return $group->leave(
$user);
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);
2187 You must enable this plugin and update your web services to use elgg_ws_expose_function().");
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);
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);
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);
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);
2266 $query =
"SELECT guid from {$CONFIG->dbprefix}sites_entity where guid = {$guid}";
2268 $query =
"UPDATE {$CONFIG->dbprefix}sites_entity 2269 set name='$name', description='$description', url='$url' where guid=$guid";
2284 $query =
"INSERT into {$CONFIG->dbprefix}sites_entity 2285 (guid, name, description, url) values ($guid, '$name', '$description', '$url')";
2327 $exists =
get_data_row(
"SELECT guid from {$CONFIG->dbprefix}groups_entity WHERE guid = {$guid}");
2329 $query =
"UPDATE {$CONFIG->dbprefix}groups_entity set" 2330 .
" name='$name', description='$description' where guid=$guid";
2343 $query =
"INSERT into {$CONFIG->dbprefix}groups_entity" 2344 .
" (guid, name, description) values ($guid, '$name', '$description')";
2393 $query =
"SELECT guid from {$CONFIG->dbprefix}users_entity where guid = {$guid}";
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";
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')";
2455 $query =
"SELECT guid from {$CONFIG->dbprefix}objects_entity where guid = {$guid}";
2457 $query =
"UPDATE {$CONFIG->dbprefix}objects_entity 2458 set title='$title', description='$description' where guid=$guid";
2469 $query =
"INSERT into {$CONFIG->dbprefix}objects_entity 2470 (guid, title, description) values ($guid, '$title','$description')";
2498 $name = $element->name;
2508 case 'relationship' :
2516 foreach ($element->attributes as $k => $v) {
2517 $odd->setAttribute($k, $v);
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));
2528 $odd->setBody(
$body);
2559 if (class_exists($classname)) {
2560 $tmp =
new $classname();
2563 $msg = $classname .
" is not a " . get_class() .
".";
2564 throw new \ClassException($msg);
2567 error_log(
"Class '" . $classname .
"' was not found, missing plugin?");
2572 $tmp = new \ElggObject();
2578 $tmp = new \ElggGroup();
2581 $tmp = new \ElggSite();
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);
2591 if (!$tmp->import($element)) {
2592 $msg =
"Could not import element " . $element->
getAttribute(
'uuid');
2593 throw new \ImportException($msg);
2617 if ((!$elements) || (!$elements->children)) {
2627 foreach ($elements->children as $child) {
2631 $document->addElement($odd);
2672 if (
$type ==
'volatile') {
2728 $options = array(
'metadata_name' =>
'import_uuid',
'metadata_value' => $uuid);
2732 return $entities[0];
2777 $to_be_serialised = null;
2784 $IMPORTED_OBJECT_COUNTER ++;
2786 $IMPORTED_DATA[] = $handled;
2813 if ((!is_array($to_be_serialised)) || (count($to_be_serialised) == 0)) {
2814 throw new \ExportException(
"No such entity GUID:" .
$guid);
2817 return $to_be_serialised;
2853 function import($xml) {
2857 $IMPORTED_DATA = array();
2858 $IMPORTED_OBJECT_COUNTER = 0;
2862 throw new \ImportException(
"No OpenDD elements found in import data, import failed.");
2865 foreach ($document as $element) {
2869 if ($IMPORTED_OBJECT_COUNTER != count($IMPORTED_DATA)) {
2870 throw new \ImportException(
"Not all elements were imported.");
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)) {
2915 $view = str_replace(
'.php',
'', $view);
2943 static $treecache = array();
2951 if (!empty($treecache[$view_root])) {
2952 return $treecache[$view_root];
2956 if (isset($CONFIG->views->locations[$viewtype])) {
2957 foreach ($CONFIG->views->locations[$viewtype] as
$view =>
$path) {
2958 $pos = strpos(
$view, $view_root);
2960 $treecache[$view_root][] =
$view;
2968 $root = $location . $viewtype .
'/' . $view_root;
2970 if (file_exists($root) && is_dir($root)) {
2972 if (!is_array($treecache[$view_root])) {
2973 $treecache[$view_root] = array();
2975 $treecache[$view_root] = array_merge($treecache[$view_root], $val);
2978 return $treecache[$view_root];
2997 $posted = 0, $annotation_id = 0, $target_guid = 0) {
3001 $access_id = ($access_id ==
'') ? null : $access_id;
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,
3012 'annotation_id' => $annotation_id,
3035 $vars = method_exists(
$data,
"export") ? get_object_vars(
$data->export()) : get_object_vars(
$data);
3048 }
else if (is_array(
$value)) {
3050 }
else if (gettype(
$value) ==
"boolean") {
3059 if ((
$n == 0) || (is_object(
$data) && !(
$data instanceof \stdClass))) {
3085 $item =
"array_item";
3087 if (is_numeric(
$key)) {
3088 $output .=
"<$item name=\"$key\" type=\"" . gettype(
$value) .
"\">";
3096 }
else if (is_array(
$value)) {
3098 }
else if (gettype(
$value) ==
"boolean") {
3124 return new \ElggXMLElement($xml);
3142 return $breakdown[
'host'];
3165 _elgg_services()->notifications->setDeprecatedNotificationSubject($entity_type, $object_subtype, $language_name);
3211 throw new \BadFunctionCallException(
"object_notifications is a private function and should not be called directly");
3269 $element =
$params[
'element'];
3278 if (!$tmp->save()) {
3279 $msg =
"There was a problem saving " . $element->getAttribute(
'uuid');
3280 throw new \ImportException($msg);
3285 throw new \ImportException(
"New entity created but has no GUID, this should not happen.");
3316 throw new \InvalidParameterException(
"GUID has not been specified during export, this should never happen.");
3319 if (!is_array($returnvalue)) {
3320 throw new \InvalidParameterException(
"Entity serialisation function passed a non-array returnvalue parameter");
3328 $msg =
"GUID:" .
$guid .
" is not a valid " . get_class();
3329 throw new \InvalidClassException($msg);
3336 $returnvalue[] =
$e;
3342 return $returnvalue;
3364 if (($hook ==
'volatile') && ($entity_type ==
'metadata')) {
3365 if ((
$guid) && ($variable_name)) {
3366 switch ($variable_name) {
3367 case 'renderedentity' :
3372 $tmp = new \ElggMetadata();
3373 $tmp->type =
'volatile';
3374 $tmp->name =
'renderedentity';
3375 $tmp->value =
$view;
3376 $tmp->entity_guid =
$guid;
3404 throw new \InvalidParameterException(
"GUID has not been specified during export, this should never happen.");
3407 if (!is_array($returnvalue)) {
3408 throw new \InvalidParameterException(
"Entity serialization function passed a non-array returnvalue parameter");
3421 $returnvalue[] = $r->export();
3425 return $returnvalue;
3444 $element =
$params[
'element'];
3451 $entity_uuid = $element->getAttribute(
'entity_uuid');
3454 throw new \ImportException(
"Entity '" . $entity_uuid .
"' could not be found.");
3461 $attr_name = $element->getAttribute(
'name');
3462 $msg =
"There was a problem updating '" . $attr_name .
"' on entity '" . $entity_uuid .
"'";
3463 throw new \ImportException($msg);
3486 $attr_val = $element->
getBody();
3493 $entity->
annotate($attr_name, $attr_val);
3496 $entity->
setMetadata($attr_name, $attr_val,
"",
true);
3499 $entity->
set($attr_name, $attr_val);
3505 $entity->
set(
'time_updated', $attr_time);
3528 throw new \InvalidParameterException(
"GUID has not been specified during export, this should never happen.");
3531 if (!is_array($returnvalue)) {
3532 throw new \InvalidParameterException(
"Entity serialisation function passed a non-array returnvalue parameter");
3536 'guid' => (
int)
$params[
'guid'],
3543 $returnvalue[] = $r->export();
3547 return $returnvalue;
3567 throw new \InvalidParameterException(
"GUID has not been specified during export, this should never happen.");
3570 if (!is_array($returnvalue)) {
3571 throw new \InvalidParameterException(
"Entity serialisation function passed a non-array returnvalue parameter");
3580 $returnvalue[] = $r->export();
3584 return $returnvalue;
3600 $element =
$params[
'element'];
3605 $tmp = new \ElggRelationship();
3606 $tmp->import($element);
3631 'table_alias' => $table_prefix,
3632 'user_guid' => (
int)
$owner,
3653 if (!$mainfilename) {
3654 if ($backtrace = debug_backtrace()) {
3655 foreach ($backtrace as $step) {
3656 $file = $step[
'file'];
3659 if (preg_match(
"/mod\/([a-zA-Z0-9\-\_]*)\/start\.php$/",
$file, $matches)) {
3669 $file = $_SERVER[
"SCRIPT_NAME"];
3672 if (preg_match(
"/mod\/([a-zA-Z0-9\-\_]*)\//",
$file, $matches)) {
3701 $events->registerHandler(
'init',
'system',
'_export_init', 100);
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);
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);
3715 $hooks->registerHandler(
'volatile',
'metadata',
'volatile_data_export_plugin_hook');
insert_data($query, array $params=[])
Insert a row into the database.
elgg_enable_filepath_cache()
private
elgg_admin_notice_exists($id)
Check if an admin notice is currently active.
elgg_enable_system_cache()
Enables the system disk cache.
$object
These two snippets demonstrates triggering an event and how to register for that event.
elgg_get_config($name, $site_guid=0)
Get an Elgg configuration value.
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.
exportAsArray($guid)
Exports an entity as an array.
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.
elgg_is_logged_in()
Returns whether or not the user is currently logged in.
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.
if(!array_key_exists($filename, $text_files)) $file
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...
get_group_members($group_guid, $limit=10, $offset=0, $site_guid=0, $count=false)
Return a list of this group's members.
add_entity_relationship($guid_one, $relationship, $guid_two)
Create a relationship between two entities.
list_user_friends_objects($user_guid, $subtype="", $limit=10, $full_view=true, $listtypetoggle=true, $pagination=true, $timelower=0, $timeupper=0)
Displays a list of a user's friends' objects of a particular subtype, with navigation.
is_uuid_this_domain($uuid)
Test to see if a given uuid is for this domain, returning true if so.
get_object_sites($object_guid, $limit=10, $offset=0)
Get the sites this object is part of.
get_uuid_from_object($object)
Get a UUID from a given object.
if($guid==elgg_get_logged_in_user_guid()) $name
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.
get_subtype_id($type, $subtype)
Return the id for a given subtype.
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.
elgg_add_admin_notice($id, $message)
Write a persistent message to the admin view.
user_add_friend($user_guid, $friend_guid)
Adds a user to another user's friends list.
elgg_invalidate_metadata_cache($action, array $options)
Invalidate the metadata cache based on options passed to various *_metadata functions.
elgg_get_system_cache()
Returns an object suitable for caching system information.
setMetadata($name, $value, $value_type= '', $multiple=false, $owner_guid=0, $access_id=null)
Set metadata on this entity.
_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.
if($title=== ''&&$entity instanceof ElggEntity) $tags
add_site_object($site_guid, $object_guid)
Add an object to a site.
elgg_unregister_entity_type($type, $subtype=null)
Unregisters an entity type and subtype as a public-facing type.
get_todays_entities($type="", $subtype="", $owner_guid=0, $order_by="", $limit=10, $offset=0, $count=false, $site_guid=0, $container_guid=null)
Get all entities for today.
get_user_friends_of($user_guid, $subtype=ELGG_ENTITIES_ANY_VALUE, $limit=10, $offset=0)
Obtains the people who have made a given user a friend.
export_metadata_plugin_hook($hook, $entity_type, $returnvalue, $params)
Handler called by trigger_plugin_hook on the "export" event.
create_group_entity($guid, $name, $description)
Create or update the entities table for a given group.
$guid
Removes an admin notice.
elgg parse_url
Parse a URL into its parts.
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
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 'create' events that looks at registered objects and attempts...
export_annotation_plugin_hook($hook, $type, $returnvalue, $params)
Export the annotations for the specified entity.
remove_notification_interest($user_guid, $author_guid)
Remove a 'notify' relationship between the user and a content author.
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.
elgg_get_views($dir, $base)
Returns the name of views for in a directory.
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.
getAttribute($key)
Returns an attribute.
get_day_end($day=null, $month=null, $year=null)
Return a timestamp for the end of a given day (defaults today).
get_notable_entities_from_metadata($start_time, $end_time, $meta_name, $meta_value="", $entity_type="", $entity_subtype="", $owner_guid=0, $limit=10, $offset=0, $order_by="", $site_guid=0, $count=false)
Return the notable entities for a given time period based on an item of metadata. ...
user_is_friend($user_guid, $friend_guid)
Determines whether or not a user is another user's friend.
elgg_disable_filepath_cache()
private
serialise_object_to_xml($data, $name="", $n=0)
This function serialises an object recursively into an XML representation.
elgg_get_viewtype()
Return the current view type.
get_metastring($id)
When given an ID, returns the corresponding metastring.
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.
already_attached($guid_one, $guid_two)
Function to determine if the object trying to attach to other, has already done so.
register_notification_interest($user_guid, $author_guid)
Establish a 'notify' relationship between the user and a content author.
enable_entity($guid, $recursive=true)
Enable an entity.
get_access_sql_suffix($table_prefix= '', $owner=null)
Returns the SQL where clause for a table with access_id and enabled columns.
export_relationship_plugin_hook($hook, $entity_type, $returnvalue, $params)
Handler called by trigger_plugin_hook on the "export" event.
export($guid)
Export a GUID.
_export_init()
Register the OpenDD import action.
elgg_register_annotation_url_handler($extender_name="all", $function_name)
Register an annotation url handler.
get_annotation_url($id)
Get the URL for this annotation.
delete_entity($guid, $recursive=true)
Delete an entity.
get_user_access_collections($owner_guid, $site_guid=0)
Returns an array of database row objects of the access collections owned by $owner_guid.
get_entity_relationships($guid, $inverse_relationship=false)
Get all the relationships for a given GUID.
elgg_unregister_notification_method($name)
Unregister a delivery method for notifications.
get_user_friends_objects($user_guid, $subtype=ELGG_ENTITIES_ANY_VALUE, $limit=10, $offset=0, $timelower=0, $timeupper=0)
Obtains a list of objects owned by a user's friends.
annotate($name, $value, $access_id=ACCESS_PRIVATE, $owner_guid=0, $vartype="")
Adds an annotation to an entity.
if($categories) $description
get_data_row($query, $callback=null, array $params=[])
Retrieve a single row from the database.
elgg_get_annotation_from_id($id)
Get a specific annotation by its id.
full_url()
Return the full URL of the current page.
elgg_autop($string)
Create paragraphs from text with line spacing.
elgg_create_river_item(array $options=array())
Adds an item to the river.
elgg_check_access_overrides($user_guid=0)
Decides if the access system should be ignored for a user.
get_user($guid)
Get a user object from a GUID.
update_data($query, array $params=[], $get_num_rows=false)
Update a row in the database.
ODD_factory(XmlElement $element)
Attempt to construct an ODD object out of a XmlElement or sub-elements.
elgg_view_entity(\ElggEntity $entity, array $vars=array(), $bypass=false, $debug=false)
Returns a string of a rendered entity.
register_notification_object($entity_type, $object_subtype, $language_name)
Register an entity type and subtype to be eligible for notifications.
execute_delayed_write_query($query, $callback=null, array $params=[])
Queue a query for running during shutdown that writes to the database.
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.
elgg_set_viewtype($viewtype="")
Manually set the viewtype.
const ELGG_ENTITIES_ANY_VALUE
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)
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.
elgg global
Pointer to the global context.
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.
get_data($query, $callback=null, array $params=[])
Retrieve rows from the database.
_elgg_services(\Elgg\Di\ServiceProvider $services=null)
Get the global service provider.
access_get_show_hidden_status()
Return current status of showing disabled entities.
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.
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.
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.
elgg_view_entity_list($entities, array $vars=array())
Returns a rendered list of entities with pagination.
elgg_list_entities(array $options=array(), $getter= 'elgg_get_entities', $viewer= 'elgg_view_entity_list')
Returns a string of rendered entities.
elgg_load_system_cache($type)
Retrieve the contents of a system cache.
elgg_get_version($human_readable=false)
Get the current Elgg version information.
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.
user_remove_friend($user_guid, $friend_guid)
Removes a user from another user's friends list.
elgg_register_notification_event($object_type, $object_subtype, array $actions=array())
Register a notification event.
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.
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.
list_todays_entities($type="", $subtype="", $owner_guid=0, $limit=10, $fullview=true, $listtypetoggle=false, $navigation=true)
Return a list of today's entities.
can_edit_extender($extender_id, $type, $user_guid=0)
Determines whether or not the specified user can edit the specified piece of extender.
get_users_membership($user_guid)
Return all groups a user is a member of.
setup_db_connections()
Establish database connections.
join_group($group_guid, $user_guid)
Join a user to a group.
disable_entity($guid, $reason="", $recursive=true)
Disable an entity.
global $METASTRINGS_DEADNAME_CACHE
set($name, $value)
Sets the value of an attribute or metadata.
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 ...
elgg_get_logged_in_user_entity()
Return the current logged in user, or null if no user is logged in.
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.
elgg_register_action($action, $filename="", $access= 'logged_in')
Registers an action.
elgg_get_entities_from_relationship($options)
Return entities matching a given query joining against a relationship.
can_edit_entity_metadata($entity_guid, $user_guid=0, $metadata=null)
Returns if $user_guid can edit the metadata on $entity_guid.
register_notification_handler($method, $handler, $params=NULL)
This function registers a handler for a given notification type (eg "email")
get_user_friends($user_guid, $subtype=ELGG_ENTITIES_ANY_VALUE, $limit=10, $offset=0)
Obtains a given user's friends.
$user_guid
Avatar remove action.
count_user_friends_objects($user_guid, $subtype=ELGG_ENTITIES_ANY_VALUE, $timelower=0, $timeupper=0)
Counts the number of objects owned by a user's friends.
_elgg_get_access_where_sql(array $options=array())
Returns the SQL where clause for enforcing read access to data.
elgg_trigger_event($event, $object_type, $object=null)
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
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_get_logged_in_user_guid()
Return the current logged in user by guid.
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.
unexpose_function($method)
Unregister a web services method.
get_entity($guid)
Loads and returns an entity object from a guid.
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.
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.