19 $quotes = array(
'\'',
'"');
20 $encoded = array(
'%27',
'%22');
21 return $url . str_replace($quotes, $encoded,
$request->getRequestUri());
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';
316 $msg =
"GUID:" . $object_guid .
" is not a valid " .
'ElggObject';
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';
352 $msg =
"GUID:" . $object_guid .
" is not a valid " .
'ElggObject';
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++) {
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) {
829 if ($case_sensitive) {
837 if (in_array(
$string, $METASTRINGS_DEADNAME_CACHE,
true)) {
843 static $metastrings_memcache;
845 $metastrings_memcache =
new ElggMemcache(
'metastrings_memcache');
847 if ($metastrings_memcache) {
848 $msfc = $metastrings_memcache->load(
$string);
856 if ($case_sensitive) {
857 $query =
"SELECT * from {$CONFIG->dbprefix}metastrings where string= BINARY '$string' limit 1";
859 $query =
"SELECT * from {$CONFIG->dbprefix}metastrings where string = '$string'";
864 if (is_array($metaStrings)) {
865 if (
sizeof($metaStrings) > 1) {
867 foreach ($metaStrings as $metaString) {
868 $ids[] = $metaString->id;
871 }
else if (isset($metaStrings[0])) {
872 $row = $metaStrings[0];
877 $METASTRINGS_CACHE[
$row->id] =
$row->string;
880 if ($metastrings_memcache) {
881 $metastrings_memcache->save(
$row->string,
$row->id);
913 $result =
insert_data(
"INSERT into {$CONFIG->dbprefix}metastrings (string) values ('$sanstring')");
916 if (isset($METASTRINGS_DEADNAME_CACHE[
$string])) {
917 unset($METASTRINGS_DEADNAME_CACHE[$string]);
938 if (isset($METASTRINGS_CACHE[
$id])) {
939 return $METASTRINGS_CACHE[
$id];
942 $row =
get_data_row(
"SELECT * from {$CONFIG->dbprefix}metastrings where id='$id' limit 1");
944 $METASTRINGS_CACHE[
$id] =
$row->string;
965 $offset = 0, $timelower = 0, $timeupper = 0) {
973 'created_time_lower' => $timelower,
974 'created_time_upper' => $timeupper,
975 'relationship' =>
'friend',
977 'relationship_join_on' =>
'container_guid',
993 $timelower = 0, $timeupper = 0) {
999 'created_time_lower' => $timelower,
1000 'created_time_upper' => $timeupper,
1001 'relationship' =>
'friend',
1003 'relationship_join_on' =>
'container_guid',
1026 $listtypetoggle =
true,
$pagination =
true, $timelower = 0, $timeupper = 0) {
1028 elgg_deprecated_notice(__FUNCTION__ .
' is deprecated. Use elgg_list_entities_from_relationship()', 1.9);
1033 'created_time_lower' => $timelower,
1034 'created_time_upper' => $timeupper,
1036 'list_type_toggle' => $listtypetoggle,
1038 'relationship' =>
'friend',
1040 'relationship_join_on' =>
'container_guid',
1058 if (is_array($location)) {
1065 $query =
"SELECT * from {$CONFIG->dbprefix}geocode_cache WHERE location='$location'";
1068 if ($cached_location) {
1069 return array(
'lat' => $cached_location->lat,
'long' => $cached_location->long);
1079 $long = (float)
$return[
'long'];
1082 $query =
"INSERT DELAYED INTO {$CONFIG->dbprefix}geocode_cache " 1083 .
" (location, lat, `long`) VALUES ('$location', '{$lat}', '{$long}')" 1084 .
" ON DUPLICATE KEY UPDATE lat='{$lat}', `long`='{$long}'";
1127 if (!is_array(
$options[
'distance'])) {
1128 $lat_distance = (float)
$options[
'distance'];
1129 $long_distance = (float)
$options[
'distance'];
1131 $lat_distance = (float)
$options[
'distance'][
'latitude'];
1132 $long_distance = (float)
$options[
'distance'][
'longitude'];
1135 $lat = (float)
$options[
'latitude'];
1136 $long = (float)
$options[
'longitude'];
1137 $lat_min = $lat - $lat_distance;
1138 $lat_max = $lat + $lat_distance;
1139 $long_min = $long - $long_distance;
1140 $long_max = $long + $long_distance;
1143 $wheres[] =
"lat_name.string='geo:lat'";
1144 $wheres[] =
"lat_value.string >= $lat_min";
1145 $wheres[] =
"lat_value.string <= $lat_max";
1146 $wheres[] =
"lon_name.string='geo:long'";
1147 $wheres[] =
"lon_value.string >= $long_min";
1148 $wheres[] =
"lon_value.string <= $long_max";
1151 $joins[] =
"JOIN {$CONFIG->dbprefix}metadata lat on e.guid=lat.entity_guid";
1152 $joins[] =
"JOIN {$CONFIG->dbprefix}metastrings lat_name on lat.name_id=lat_name.id";
1153 $joins[] =
"JOIN {$CONFIG->dbprefix}metastrings lat_value on lat.value_id=lat_value.id";
1154 $joins[] =
"JOIN {$CONFIG->dbprefix}metadata lon on e.guid=lon.entity_guid";
1155 $joins[] =
"JOIN {$CONFIG->dbprefix}metastrings lon_name on lon.name_id=lon_name.id";
1156 $joins[] =
"JOIN {$CONFIG->dbprefix}metastrings lon_value on lon.value_id=lon_value.id";
1161 } elseif (!isset(
$options[
'wheres'])) {
1169 } elseif (!isset(
$options[
'joins'])) {
1197 define(
"MILE", 0.01515);
1198 define(
"KILOMETER", 0.00932);
1226 for (
$n = 0;
$n < strlen($extra_escapeable);
$n++) {
1227 $string = str_replace($extra_escapeable[
$n],
"\\" . $extra_escapeable[$n],
$string);
1280 return _elgg_services()->db->updateData(
"OPTIMIZE TABLE $table");
1292 function get_db_tables() {
1296 if (isset($tables)) {
1306 $row = (array) $row;
1307 if (is_array($row) && !empty($row)) {
1308 foreach ($row as $element) {
1309 $tables[] = $element;
1329 return mysql_error($dblink);
1363 return mktime(0, 0, 0, $month, $day, $year);
1379 return mktime(23, 59, 59, $month, $day, $year);
1405 $container_guid = null) {
1413 $start_time = (int)$start_time;
1414 $end_time = (int)$end_time;
1418 $site_guid = (int) $site_guid;
1419 if ($site_guid == 0) {
1420 $site_guid = $CONFIG->site_guid;
1425 if (is_array(
$type)) {
1427 if (
sizeof(
$type)) {
1428 foreach (
$type as $typekey => $subtypearray) {
1429 foreach ($subtypearray as $subtypeval) {
1431 if (!empty($subtypeval)) {
1436 if (!empty($tempwhere)) {
1437 $tempwhere .=
" or ";
1439 $tempwhere .=
"(e.type = '{$typekey}' and e.subtype = {$subtypeval})";
1443 if (!empty($tempwhere)) {
1444 $where[] =
"({$tempwhere})";
1451 $where[] =
"e.type='$type'";
1455 $where[] =
"e.subtype=$subtype";
1463 $where[] =
"e.owner_guid = '$owner_guid'";
1465 $owner_array = array_map(
'sanitise_int',
$owner_guid);
1468 $where[] =
"e.owner_guid in ({$owner_guid})";
1470 if (is_null($container_guid)) {
1471 $container_guid = $owner_array;
1475 if ($site_guid > 0) {
1476 $where[] =
"e.site_guid = {$site_guid}";
1479 if (!is_null($container_guid)) {
1480 if (is_array($container_guid)) {
1481 foreach ($container_guid as
$key => $val) {
1482 $container_guid[
$key] = (int) $val;
1484 $where[] =
"e.container_guid in (" . implode(
",", $container_guid) .
")";
1486 $container_guid = (int) $container_guid;
1487 $where[] =
"e.container_guid = {$container_guid}";
1493 JOIN {$CONFIG->dbprefix}metadata cal_start on e.guid=cal_start.entity_guid 1494 JOIN {$CONFIG->dbprefix}metastrings cal_start_name on cal_start.name_id=cal_start_name.id 1495 JOIN {$CONFIG->dbprefix}metastrings cal_start_value on cal_start.value_id=cal_start_value.id 1497 JOIN {$CONFIG->dbprefix}metadata cal_end on e.guid=cal_end.entity_guid 1498 JOIN {$CONFIG->dbprefix}metastrings cal_end_name on cal_end.name_id=cal_end_name.id 1499 JOIN {$CONFIG->dbprefix}metastrings cal_end_value on cal_end.value_id=cal_end_value.id 1501 $where[] =
"cal_start_name.string='calendar_start'";
1502 $where[] =
"cal_start_value.string>=$start_time";
1503 $where[] =
"cal_end_name.string='calendar_end'";
1504 $where[] =
"cal_end_value.string <= $end_time";
1508 $query =
"SELECT e.* from {$CONFIG->dbprefix}entities e $cal_join where ";
1510 $query =
"SELECT count(e.guid) as total from {$CONFIG->dbprefix}entities e $cal_join where ";
1512 foreach ($where as $w) {
1513 $query .=
" $w and ";
1519 $query .=
" order by n.calendar_start $order_by";
1522 $query .=
" limit $offset, $limit";
1524 $dt =
get_data($query,
"entity_row_to_elggstar");
1529 return $total->total;
1555 $site_guid = 0,
$count =
false) {
1563 $start_time = (int)$start_time;
1564 $end_time = (int)$end_time;
1569 if ($order_by ==
"") {
1570 $order_by =
"e.time_created desc";
1573 $site_guid = (int) $site_guid;
1582 if ($site_guid == 0) {
1583 $site_guid = $CONFIG->site_guid;
1590 if ($entity_type !=
"") {
1591 $where[] =
"e.type='$entity_type'";
1594 if ($entity_subtype) {
1595 $where[] =
"e.subtype=$entity_subtype";
1598 if ($meta_name !=
"") {
1599 $where[] =
"m.name_id='$meta_n'";
1602 if ($meta_value !=
"") {
1603 $where[] =
"m.value_id='$meta_v'";
1606 if ($site_guid > 0) {
1607 $where[] =
"e.site_guid = {$site_guid}";
1611 $where[] =
"e.container_guid in (" . implode(
",",
$owner_guid) .
")";
1613 $where[] =
"e.container_guid = {$owner_guid}";
1618 JOIN {$CONFIG->dbprefix}metadata cal_start on e.guid=cal_start.entity_guid 1619 JOIN {$CONFIG->dbprefix}metastrings cal_start_name on cal_start.name_id=cal_start_name.id 1620 JOIN {$CONFIG->dbprefix}metastrings cal_start_value on cal_start.value_id=cal_start_value.id 1622 JOIN {$CONFIG->dbprefix}metadata cal_end on e.guid=cal_end.entity_guid 1623 JOIN {$CONFIG->dbprefix}metastrings cal_end_name on cal_end.name_id=cal_end_name.id 1624 JOIN {$CONFIG->dbprefix}metastrings cal_end_value on cal_end.value_id=cal_end_value.id 1627 $where[] =
"cal_start_name.string='calendar_start'";
1628 $where[] =
"cal_start_value.string>=$start_time";
1629 $where[] =
"cal_end_name.string='calendar_end'";
1630 $where[] =
"cal_end_value.string <= $end_time";
1633 $query =
"SELECT distinct e.* ";
1635 $query =
"SELECT count(distinct e.guid) as total ";
1638 $query .=
"from {$CONFIG->dbprefix}entities e" 1639 .
" JOIN {$CONFIG->dbprefix}metadata m on e.guid = m.entity_guid $cal_join where";
1641 foreach ($where as $w) {
1642 $query .=
" $w and ";
1651 $query .=
" order by $order_by limit $offset, $limit";
1652 return get_data($query,
"entity_row_to_elggstar");
1692 $start_time = (int)$start_time;
1693 $end_time = (int)$end_time;
1695 $relationship_guid = (int)$relationship_guid;
1696 $inverse_relationship = (bool)$inverse_relationship;
1700 if ($order_by ==
"") {
1701 $order_by =
"time_created desc";
1706 $site_guid = (int) $site_guid;
1707 if ($site_guid == 0) {
1708 $site_guid = $CONFIG->site_guid;
1715 if ($relationship !=
"") {
1716 $where[] =
"r.relationship='$relationship'";
1718 if ($relationship_guid) {
1719 $where[] = $inverse_relationship ?
1720 "r.guid_two='$relationship_guid'" :
"r.guid_one='$relationship_guid'";
1723 $where[] =
"e.type='$type'";
1726 $where[] =
"e.subtype=$subtype";
1729 $where[] =
"e.container_guid='$owner_guid'";
1731 if ($site_guid > 0) {
1732 $where[] =
"e.site_guid = {$site_guid}";
1737 JOIN {$CONFIG->dbprefix}metadata cal_start on e.guid=cal_start.entity_guid 1738 JOIN {$CONFIG->dbprefix}metastrings cal_start_name on cal_start.name_id=cal_start_name.id 1739 JOIN {$CONFIG->dbprefix}metastrings cal_start_value on cal_start.value_id=cal_start_value.id 1741 JOIN {$CONFIG->dbprefix}metadata cal_end on e.guid=cal_end.entity_guid 1742 JOIN {$CONFIG->dbprefix}metastrings cal_end_name on cal_end.name_id=cal_end_name.id 1743 JOIN {$CONFIG->dbprefix}metastrings cal_end_value on cal_end.value_id=cal_end_value.id 1745 $where[] =
"cal_start_name.string='calendar_start'";
1746 $where[] =
"cal_start_value.string>=$start_time";
1747 $where[] =
"cal_end_name.string='calendar_end'";
1748 $where[] =
"cal_end_value.string <= $end_time";
1751 $joinon =
"e.guid = r.guid_one";
1752 if (!$inverse_relationship) {
1753 $joinon =
"e.guid = r.guid_two";
1757 $query =
"SELECT count(distinct e.guid) as total ";
1759 $query =
"SELECT distinct e.* ";
1761 $query .=
" from {$CONFIG->dbprefix}entity_relationships r" 1762 .
" JOIN {$CONFIG->dbprefix}entities e on $joinon $cal_join where ";
1764 foreach ($where as $w) {
1765 $query .=
" $w and ";
1770 $query .=
" order by $order_by limit $offset, $limit";
1771 return get_data($query,
"entity_row_to_elggstar");
1867 return get_notable_entities_from_relationship($day_start, $day_end, $relationship,
1892 $limit = 10, $fullview =
true, $listtypetoggle =
false, $navigation =
true) {
1903 $fullview, $listtypetoggle, $navigation);
1924 $fullview =
true, $listtypetoggle =
false, $navigation =
true) {
1931 $fullview, $listtypetoggle, $navigation);
2050 'relationship' =>
'attached',
2051 'relationship_guid' =>
$guid,
2052 'inverse_relationship' =>
false,
2056 'order_by' =>
'time_created desc',
2143 return $entity->delete($recursive);
2194 elgg_deprecated_notice(
'can_edit_entity_metadata has been deprecated in favor of ElggEntity::canEditMetadata',
'1.9');
2226 return $entity->disable($reason, $recursive);
2270 return $group->join(
$user);
2291 return $group->leave(
$user);
2315 $call_method =
"GET", $require_api_auth =
false, $require_user_auth =
false) {
2316 elgg_deprecated_notice(
"expose_function() deprecated for the function elgg_ws_expose_function() in web_services plugin", 1.9);
2319 You must enable this plugin and update your web services to use elgg_ws_expose_function().");
2322 if (function_exists(
"elgg_ws_expose_function")) {
2323 return elgg_ws_expose_function(
$method, $function, $parameters,
$description, $call_method, $require_api_auth, $require_user_auth);
2335 elgg_deprecated_notice(
"unexpose_function() deprecated for the function elgg_ws_unexpose_function() in web_services plugin", 1.9);
2336 if (function_exists(
"elgg_ws_unexpose_function")) {
2337 return elgg_ws_unexpose_function(
$method);
2350 elgg_deprecated_notice(
"register_service_handler() deprecated for the function elgg_ws_register_service_handler() in web_services plugin", 1.9);
2351 if (function_exists(
"elgg_ws_register_service_handler")) {
2352 return elgg_ws_register_service_handler(
$handler, $function);
2366 elgg_deprecated_notice(
"unregister_service_handler() deprecated for the function elgg_ws_unregister_service_handler() in web_services plugin", 1.9);
2367 if (function_exists(
"elgg_ws_unregister_service_handler")) {
2368 return elgg_ws_unregister_service_handler(
$handler);
2398 $query =
"SELECT guid from {$CONFIG->dbprefix}sites_entity where guid = {$guid}";
2400 $query =
"UPDATE {$CONFIG->dbprefix}sites_entity 2401 set name='$name', description='$description', url='$url' where guid=$guid";
2416 $query =
"INSERT into {$CONFIG->dbprefix}sites_entity 2417 (guid, name, description, url) values ($guid, '$name', '$description', '$url')";
2459 $exists =
get_data_row(
"SELECT guid from {$CONFIG->dbprefix}groups_entity WHERE guid = {$guid}");
2461 $query =
"UPDATE {$CONFIG->dbprefix}groups_entity set" 2462 .
" name='$name', description='$description' where guid=$guid";
2475 $query =
"INSERT into {$CONFIG->dbprefix}groups_entity" 2476 .
" (guid, name, description) values ($guid, '$name', '$description')";
2525 $query =
"SELECT guid from {$CONFIG->dbprefix}users_entity where guid = {$guid}";
2527 $query =
"UPDATE {$CONFIG->dbprefix}users_entity 2528 SET name='$name', username='$username', password='$password', salt='$salt', 2529 email='$email', language='$language' 2530 WHERE guid = $guid";
2544 $query =
"INSERT into {$CONFIG->dbprefix}users_entity 2545 (guid, name, username, password, salt, email, language) 2546 values ($guid, '$name', '$username', '$password', '$salt', '$email', '$language')";
2587 $query =
"SELECT guid from {$CONFIG->dbprefix}objects_entity where guid = {$guid}";
2589 $query =
"UPDATE {$CONFIG->dbprefix}objects_entity 2590 set title='$title', description='$description' where guid=$guid";
2601 $query =
"INSERT into {$CONFIG->dbprefix}objects_entity 2602 (guid, title, description) values ($guid, '$title','$description')";
2630 $name = $element->name;
2640 case 'relationship' :
2648 foreach ($element->attributes as $k => $v) {
2649 $odd->setAttribute($k, $v);
2653 $body = $element->content;
2654 $a = stripos(
$body,
"<![CDATA");
2655 $b = strripos(
$body,
"]]>");
2656 if ((
$body) && ($a !==
false) && ($b !==
false)) {
2657 $body = substr(
$body, $a + 8, $b - ($a + 8));
2660 $odd->setBody(
$body);
2691 if (class_exists($classname)) {
2692 $tmp =
new $classname();
2695 $msg = $classname .
" is not a " . get_class() .
".";
2699 error_log(
"Class '" . $classname .
"' was not found, missing plugin?");
2716 $msg =
"Type " .
$class .
" is not supported. This indicates an error in your installation, most likely caused by an incomplete upgrade.";
2723 if (!$tmp->import($element)) {
2724 $msg =
"Could not import element " . $element->
getAttribute(
'uuid');
2749 if ((!$elements) || (!$elements->children)) {
2759 foreach ($elements->children as $child) {
2763 $document->addElement($odd);
2804 if (
$type ==
'volatile') {
2860 $options = array(
'metadata_name' =>
'import_uuid',
'metadata_value' => $uuid);
2864 return $entities[0];
2909 $to_be_serialised = null;
2916 $IMPORTED_OBJECT_COUNTER ++;
2918 $IMPORTED_DATA[] = $handled;
2945 if ((!is_array($to_be_serialised)) || (count($to_be_serialised) == 0)) {
2949 return $to_be_serialised;
2985 function import($xml) {
2989 $IMPORTED_DATA = array();
2990 $IMPORTED_OBJECT_COUNTER = 0;
2994 throw new ImportException(
"No OpenDD elements found in import data, import failed.");
2997 foreach ($document as $element) {
3001 if ($IMPORTED_OBJECT_COUNTER != count($IMPORTED_DATA)) {
3041 if (file_exists($dir) && is_dir($dir)) {
3042 if ($handle = opendir($dir)) {
3043 while (
$view = readdir($handle)) {
3044 if (!in_array(
$view, array(
'.',
'..',
'.svn',
'CVS'))) {
3045 if (is_dir($dir .
'/' .
$view)) {
3046 if ($val =
elgg_get_views($dir .
'/' . $view, $base .
'/' . $view)) {
3050 $view = str_replace(
'.php',
'', $view);
3078 static $treecache = array();
3086 if (!empty($treecache[$view_root])) {
3087 return $treecache[$view_root];
3091 if (isset($CONFIG->views->locations[
$viewtype])) {
3093 $pos = strpos(
$view, $view_root);
3095 $treecache[$view_root][] =
$view;
3101 $location = $CONFIG->viewpath;
3103 $root = $location .
$viewtype .
'/' . $view_root;
3105 if (file_exists($root) && is_dir($root)) {
3107 if (!is_array($treecache[$view_root])) {
3108 $treecache[$view_root] = array();
3110 $treecache[$view_root] = array_merge($treecache[$view_root], $val);
3113 return $treecache[$view_root];
3132 $posted = 0, $annotation_id = 0, $target_guid = 0) {
3136 $access_id = ($access_id ==
'') ? null : $access_id;
3141 'action_type' => $action_type,
3142 'subject_guid' => $subject_guid,
3143 'object_guid' => $object_guid,
3144 'target_guid' => $target_guid,
3145 'access_id' => $access_id,
3147 'annotation_id' => $annotation_id,
3170 $vars = method_exists(
$data,
"export") ? get_object_vars(
$data->export()) : get_object_vars(
$data);
3174 if ((
$n == 0) || ( is_object(
$data) && !(
$data instanceof stdClass))) {
3183 }
else if (is_array(
$value)) {
3185 }
else if (gettype(
$value) ==
"boolean") {
3194 if ((
$n == 0) || (is_object(
$data) && !(
$data instanceof stdClass))) {
3220 $item =
"array_item";
3222 if (is_numeric(
$key)) {
3223 $output .=
"<$item name=\"$key\" type=\"" . gettype(
$value) .
"\">";
3231 }
else if (is_array(
$value)) {
3233 }
else if (gettype(
$value) ==
"boolean") {
3277 return $breakdown[
'host'];
3300 _elgg_services()->notifications->setDeprecatedNotificationSubject($entity_type, $object_subtype, $language_name);
3346 throw new BadFunctionCallException(
"object_notifications is a private function and should not be called directly");
3404 $element =
$params[
'element'];
3413 if (!$tmp->save()) {
3414 $msg =
"There was a problem saving " . $element->getAttribute(
'uuid');
3420 throw new ImportException(
"New entity created but has no GUID, this should not happen.");
3454 if (!is_array($returnvalue)) {
3463 $msg =
"GUID:" .
$guid .
" is not a valid " . get_class();
3471 $returnvalue[] =
$e;
3477 return $returnvalue;
3499 if (($hook ==
'volatile') && ($entity_type ==
'metadata')) {
3500 if ((
$guid) && ($variable_name)) {
3501 switch ($variable_name) {
3502 case 'renderedentity' :
3508 $tmp->type =
'volatile';
3509 $tmp->name =
'renderedentity';
3510 $tmp->value =
$view;
3511 $tmp->entity_guid =
$guid;
3542 if (!is_array($returnvalue)) {
3556 $returnvalue[] = $r->export();
3560 return $returnvalue;
3579 $element =
$params[
'element'];
3586 $entity_uuid = $element->getAttribute(
'entity_uuid');
3589 throw new ImportException(
"Entity '" . $entity_uuid .
"' could not be found.");
3596 $attr_name = $element->getAttribute(
'name');
3597 $msg =
"There was a problem updating '" . $attr_name .
"' on entity '" . $entity_uuid .
"'";
3621 $attr_val = $element->
getBody();
3628 $entity->
annotate($attr_name, $attr_val);
3631 $entity->
setMetadata($attr_name, $attr_val,
"",
true);
3634 $entity->
set($attr_name, $attr_val);
3640 $entity->
set(
'time_updated', $attr_time);
3666 if (!is_array($returnvalue)) {
3671 'guid' => (
int)
$params[
'guid'],
3678 $returnvalue[] = $r->export();
3682 return $returnvalue;
3705 if (!is_array($returnvalue)) {
3715 $returnvalue[] = $r->export();
3719 return $returnvalue;
3735 $element =
$params[
'element'];
3741 $tmp->import($element);
3780 'table_alias' => $table_prefix,
3781 'user_guid' => (
int)
$owner,
3802 if (!$mainfilename) {
3803 if ($backtrace = debug_backtrace()) {
3804 foreach ($backtrace as
$step) {
3805 $file = $step[
'file'];
3806 $file = str_replace(
"\\",
"/", $file);
3807 $file = str_replace(
"//",
"/", $file);
3808 if (preg_match(
"/mod\/([a-zA-Z0-9\-\_]*)\/start\.php$/", $file, $matches)) {
3818 $file = $_SERVER[
"SCRIPT_NAME"];
3819 $file = str_replace(
"\\",
"/", $file);
3820 $file = str_replace(
"//",
"/", $file);
3821 if (preg_match(
"/mod\/([a-zA-Z0-9\-\_]*)\//", $file, $matches)) {
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.
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.
get_relationship($id)
Get a relationship by its ID.
elgg_view_entity(ElggEntity $entity, $vars=array(), $bypass=false, $debug=false)
Returns a string of a rendered entity.
elgg_register_notification_method($name)
Register a delivery method for notifications.
get_data_row($query, $callback="")
Retrieve a single row from the database.
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_extender_url(ElggExtender $extender)
Get the URL of a given elgg extender.
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.
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_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_view_entity_list($entities, $vars=array(), $offset=0, $limit=10, $full_view=true, $list_type_toggle=true, $pagination=true)
Returns a rendered list of entities with pagination.
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 ElggCache 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.
add_site_object($site_guid, $object_guid)
Add an object to a site.
if($screenshots) $description
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_register_plugin_hook_handler($hook, $type, $callback, $priority=500)
Register a callback as a plugin hook handler.
elgg_get_entities_from_location(array $options=array())
Return entities within a given geographic area.
xml_to_object($xml)
Parse an XML file into an object.
if(isset($vars['id'])) $class
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.
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.
update_data($query)
Update a row in the database.
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.
insert_data($query)
Insert a row into the database.
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.
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.
elgg_set_viewtype($viewtype="")
Manually set the viewtype.
annotate($name, $value, $access_id=ACCESS_PRIVATE, $owner_guid=0, $vartype="")
Adds an annotation to an entity.
elgg_get_viewtype()
Return the current view type.
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.
execute_delayed_write_query($query, $handler="")
Queue a query for running during shutdown that writes to the database.
ODD_factory(XmlElement $element)
Attempt to construct an ODD object out of a XmlElement or sub-elements.
register_notification_object($entity_type, $object_subtype, $language_name)
Register an entity type and subtype to be eligible for notifications.
get_site_domain($guid)
Retrieve a site and return the domain portion of its url.
elgg_geocode_location($location)
Encode a location into a latitude and longitude, caching the result.
get_db_link($dblinktype)
Returns (if required, also creates) a database link resource.
sanitise_string($string)
Wrapper function for alternate English spelling (.
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)
Trigger a Plugin Hook and run all handler callbacks registered to that hook:type. ...
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)
Sends 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.
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.
elgg_register_event_handler($event, $object_type, $callback, $priority=500)
Register a callback as an Elgg event handler.
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.
get_db_error($dblink)
Get the last database error for a particular database link.
elgg_view_tree($view_root, $viewtype="")
Returns all views below a partial view.
elgg_list_entities(array $options=array(), $getter= 'elgg_get_entities', $viewer= 'elgg_view_entity_list')
Returns a string of rendered entities.
get_data($query, $callback="")
Retrieve rows from the database.
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 ElggEnti...
elgg_get_logged_in_user_entity()
Return the current logged in user, or null if no user is logged in.
is_memcache_available()
Return true if memcache is available and configured.
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")
execute_delayed_query($query, $dblink, $handler="")
Queue a query for execution upon shutdown.
get_user_friends($user_guid, $subtype=ELGG_ENTITIES_ANY_VALUE, $limit=10, $offset=0)
Obtains a given user'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.
$language
$vars['language'] $vars['lc'] if present, client will be sent long expires headers ...
elgg_trigger_event($event, $object_type, $object=null)
Trigger an Elgg Event and attempt to run all handler callbacks registered to that event...
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.
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.
if(file_exists($welcome)) $vars
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.