91 parent::initializeAttributes();
93 $this->attributes[
'guid'] =
null;
94 $this->attributes[
'type'] =
null;
95 $this->attributes[
'subtype'] =
null;
97 $this->attributes[
'owner_guid'] =
_elgg_services()->session->getLoggedInUserGuid();
98 $this->attributes[
'container_guid'] =
_elgg_services()->session->getLoggedInUserGuid();
100 $this->attributes[
'site_guid'] =
null;
102 $this->attributes[
'time_updated'] =
null;
103 $this->attributes[
'last_action'] =
null;
104 $this->attributes[
'enabled'] =
"yes";
123 _elgg_services()->logger->error(
"Failed to clone entity with GUID $this->guid");
128 'guid' => $this->guid,
132 $this->attributes[
'guid'] =
"";
134 $this->attributes[
'subtype'] = $orig_entity->getSubtype();
138 if (is_array($metadata_array)) {
140 $metadata_names = array();
145 $metadata_names = array_unique($metadata_names);
148 foreach ($metadata_names as
$name) {
149 $this->
__set($name, $orig_entity->$name);
173 if (array_key_exists(
$name, $this->attributes)) {
175 if (is_int($this->attributes[
$name])
177 && ((
string)$this->attributes[
$name] ===
$value)) {
184 if (in_array(
$name, [
'title',
'name',
'description'])
185 && $this->attributes[
$name] ===
null
191 if ($this->guid && !array_key_exists(
$name, $this->orig_attributes)) {
192 $this->orig_attributes[
$name] = $this->attributes[
$name];
204 case 'container_guid':
208 $this->attributes[
$name] =
null;
218 if (
$name ===
'tables_split' ||
$name ===
'tables_loaded') {
264 if (array_key_exists(
$name, $this->attributes)) {
265 if (
$name ===
'subtype' && $this->attributes[
'guid']) {
269 return $this->attributes[
$name];
272 if (
$name ===
'tables_split' ||
$name ===
'tables_loaded') {
318 if (isset($this->temp_metadata[
$name])) {
320 if (count($this->temp_metadata[
$name]) == 1) {
321 return $this->temp_metadata[
$name][0];
323 return $this->temp_metadata[
$name];
333 if ($cache->isLoaded(
$guid)) {
336 $cache->populateFromEntities(array(
$guid));
338 if ($cache->isLoaded(
$guid)) {
345 'metadata_name' =>
$name,
352 if ($md && !is_array($md)) {
354 } elseif (count($md) == 1) {
356 }
else if ($md && is_array($md)) {
374 if (array_key_exists(
$name, $this->attributes)) {
375 $this->attributes[
$name] =
"";
418 'metadata_name' =>
$name,
435 if ($access_id ===
null) {
436 $access_id = $this->access_id;
438 $access_id = (int)$access_id;
440 .
'All metadata will be public in 3.0.',
'2.3');
445 foreach (
$value as $value_tmp) {
447 $md_id =
_elgg_services()->metadataTable->create($this->guid,
$name, $value_tmp, $value_type,
462 $msg =
"owner guid and access id cannot be used in \ElggEntity::setMetadata() until entity is saved.";
463 throw new \InvalidArgumentException($msg);
467 if (!$multiple || !isset($this->temp_metadata[
$name])) {
468 $this->temp_metadata[
$name] = array();
472 $this->temp_metadata[
$name] = array_merge($this->temp_metadata[
$name],
$value);
494 'guid' => $this->guid,
517 'metadata_owner_guid' => $this->guid,
538 'guid' => $this->guid,
559 'guid' => $this->guid,
577 return array_key_exists(
$name, $this->
volatile) ? $this->
volatile[
$name] :
null;
606 $this->
volatile = [];
608 $this->attributes[
'last_action'] = (int)$last_action;
610 $cache->
save($this->guid, $this);
612 $this->
volatile = $tmp;
629 $relationship = (string)$relationship;
676 if ((
int) $this->guid > 0) {
692 if ((
int) ($this->guid) > 0) {
695 if (isset($this->temp_private_settings[
$name])) {
696 return $this->temp_private_settings[
$name];
725 'guid' => $this->guid,
748 'annotation_owner_guid' => $this->guid,
769 'guid' => $this->guid,
790 'guid' => $this->guid,
807 private function getAnnotationCalculation(
$name, $calculation) {
811 'annotation_name' =>
$name,
812 'annotation_calculation' => $calculation
835 if ((
int) $this->guid > 0) {
863 if ((
int) ($this->guid) > 0) {
866 'guid' => $this->guid,
872 if ($order !=
'asc') {
873 $options[
'reverse_order_by'] =
true;
887 if (isset($this->temp_annotations[
$name])) {
888 return array($this->temp_annotations[
$name]);
903 return $this->getAnnotationCalculation(
$name,
'count');
914 return $this->getAnnotationCalculation(
$name,
'avg');
925 return $this->getAnnotationCalculation(
$name,
'sum');
936 return $this->getAnnotationCalculation(
$name,
'min');
947 return $this->getAnnotationCalculation(
$name,
'max');
957 $params = array(
'entity' => $this);
965 'subtype' =>
'comment',
966 'container_guid' => $this->
getGUID(),
994 'relationship_guid' => $this->
getGUID(),
995 'inverse_relationship' => $inverse,
1012 'relationship' => $relationship,
1013 'relationship_guid' => $this->
getGUID(),
1014 'inverse_relationship' => $inverse_relationship,
1119 return $this->access_id;
1147 if ($this->attributes[
'guid']) {
1150 return $this->attributes[
'subtype'];
1207 return $this->time_updated;
1225 if (isset(
$CONFIG->entity_url_handler[$this->getType()][$this->getSubtype()])) {
1227 if (is_callable($function)) {
1228 $url = call_user_func($function, $this);
1230 } elseif (isset(
$CONFIG->entity_url_handler[$this->getType()][
'all'])) {
1231 $function =
$CONFIG->entity_url_handler[$this->
getType()][
'all'];
1232 if (is_callable($function)) {
1233 $url = call_user_func($function, $this);
1235 } elseif (isset(
$CONFIG->entity_url_handler[
'all'][
'all'])) {
1236 $function =
$CONFIG->entity_url_handler[
'all'][
'all'];
1237 if (is_callable($function)) {
1238 $url = call_user_func($function, $this);
1248 $params = array(
'entity' => $this);
1252 if (!empty($this->url_override)) {
1271 $this->url_override =
$url;
1387 return $site->addEntity($this);
1405 return $site->removeEntity($this);
1421 $options[
'relationship'] =
'member_of_site';
1423 $options[
'inverse_relationship'] =
false;
1487 if (!in_array(
$type, $allowed_types)) {
1488 throw new \InvalidParameterException(
'Entity type must be one of the allowed types: '
1489 . implode(
', ', $allowed_types));
1492 $subtype = $this->attributes[
'subtype'];
1494 $owner_guid = (int)$this->attributes[
'owner_guid'];
1495 $access_id = (int)$this->attributes[
'access_id'];
1497 $time_created = isset($this->attributes[
'time_created']) ? (int)$this->attributes[
'time_created'] : $now;
1499 $site_guid = $this->attributes[
'site_guid'];
1500 if ($site_guid == 0) {
1503 $site_guid = (int)$site_guid;
1513 throw new \InvalidParameterException(
'ACCESS_DEFAULT is not a valid access level. See its documentation in elgglib.h');
1522 _elgg_services()->logger->error(
"User $user_guid tried to create a ($type, $subtype), but the given"
1523 .
" owner $owner_guid could not be loaded.");
1530 _elgg_services()->logger->error(
"User $user_guid tried to create a ($type, $subtype) with owner"
1531 .
" $owner_guid, but the user wasn't permitted to write to the owner's container.");
1540 _elgg_services()->logger->error(
"User $user_guid tried to create a ($type, $subtype), but the given"
1541 .
" container $container_guid could not be loaded.");
1546 _elgg_services()->logger->error(
"User $user_guid tried to create a ($type, $subtype), but was not"
1547 .
" permitted to write to container $container_guid.");
1554 'subtype_id' => $subtype_id,
1557 'site_guid' => $site_guid,
1558 'access_id' => $access_id,
1560 'time_updated' => $now,
1561 'last_action' => $now,
1565 throw new \IOException(
"Unable to save new object's base entity information!");
1569 $this->attributes[
'subtype'] = (int)$subtype_id;
1570 $this->attributes[
'guid'] = (int)
$result;
1572 $this->attributes[
'time_updated'] = (int)$now;
1573 $this->attributes[
'last_action'] = (int)$now;
1574 $this->attributes[
'site_guid'] = (int)$site_guid;
1584 if (
sizeof($this->temp_metadata) > 0) {
1585 foreach ($this->temp_metadata as
$name =>
$value) {
1589 $this->temp_metadata = array();
1593 if (
sizeof($this->temp_annotations) > 0) {
1594 foreach ($this->temp_annotations as
$name =>
$value) {
1598 $this->temp_annotations = array();
1602 if (
sizeof($this->temp_private_settings) > 0) {
1603 foreach ($this->temp_private_settings as
$name =>
$value) {
1607 $this->temp_private_settings = array();
1629 if (!
_elgg_services()->events->trigger(
'update', $this->type, $this)) {
1634 $guid = (int)$this->guid;
1642 throw new \InvalidParameterException(
'ACCESS_DEFAULT is not a valid access level. See its documentation in elgglib.php');
1648 'access_id' => $access_id,
1650 'time_updated' => $time,
1661 if ($ret !==
false) {
1662 $this->attributes[
'time_updated'] = $time;
1665 $this->orig_attributes = [];
1668 return $ret !==
false;
1679 if (
$guid instanceof \stdClass) {
1687 if (!is_array($this->attributes)) {
1688 $this->attributes = array();
1692 $objarray = (array)
$row;
1698 $this->attributes[
'guid'] = (int)$this->attributes[
'guid'];
1701 $this->attributes[
'subtype'] = (int)$this->attributes[
'subtype'];
1704 if ($this->attributes[
'guid']) {
1739 if (
$row instanceof \stdClass) {
1740 return $this->
load($row);
1764 public function disable($reason =
"", $recursive =
true) {
1769 if (!
_elgg_services()->events->trigger(
'disable', $this->type, $this)) {
1777 if ($this instanceof
ElggUser && $this->banned ===
'no') {
1780 $unban_after =
true;
1782 $unban_after =
false;
1786 $this->disable_reason = $reason;
1791 $guid = (int) $this->guid;
1807 foreach ([
'owner_guid',
'container_guid',
'site_guid'] as $db_column) {
1811 $subentities = new \ElggBatch(
'elgg_get_entities',
$options);
1812 $subentities->setIncrementOffset(
false);
1814 foreach ($subentities as $subentity) {
1816 if (!$subentity->isEnabled()) {
1820 $subentity->disable($reason);
1834 UPDATE {$dbprefix}entities
1848 $this->attributes[
'enabled'] =
'no';
1852 return (
bool) $disabled;
1866 $guid = (int)$this->guid;
1887 WHERE guid = $guid");
1895 'relationship' =>
'disabled_with',
1896 'relationship_guid' =>
$guid,
1897 'inverse_relationship' =>
true,
1901 foreach ($disabled_with_it as
$e) {
1910 $this->attributes[
'enabled'] =
'yes';
1923 return $this->enabled ==
'yes';
1943 public function delete($recursive =
true) {
1985 foreach ([
'owner_guid',
'container_guid',
'site_guid'] as $db_column) {
1989 $batch = new \ElggBatch(
'elgg_get_entities',
$options);
1990 $batch->setIncrementOffset(
false);
1993 foreach ($batch as
$e) {
2029 DELETE FROM {$dbprefix}entities
2038 if ($deleted && in_array($this->
type, [
'object',
'user',
'group',
'site'])) {
2041 DELETE FROM {$dbprefix}{$this->type}s_entity
2049 return (
bool)$deleted;
2057 $params = array(
'entity' => $this);
2092 return $this->location;
2103 $this->location = $location;
2116 $this->{
"geo:lat"} = $lat;
2117 $this->{
"geo:long"} = $long;
2127 return (
float)$this->{
"geo:lat"};
2137 return (
float)$this->{
"geo:long"};
2182 $this->attributes[
'type'],
2191 foreach ($this->attributes as $k => $v) {
2201 case 'time_created':
2202 $odd->setAttribute(
'published', date(
"r", $v));
2208 $meta =
new ODDMetaData($uuid .
"attr/$k/", $uuid, $k, $v);
2211 case 'container_guid':
2212 $k =
'container_uuid';
2214 $meta =
new ODDMetaData($uuid .
"attr/$k/", $uuid, $k, $v);
2220 $meta =
new ODDMetaData($uuid .
"attr/$k/", $uuid, $k, $v);
2224 $meta =
new ODDMetaData($uuid .
"attr/$k/", $uuid, $k, $v);
2229 $meta->setAttribute(
'published', date(
"r", $this->time_created));
2244 $tmp[] =
new ODDMetaData($uuid .
"volatile/renderedentity/", $uuid,
2245 'renderedentity',
$view,
'volatile');
2267 throw new \InvalidParameterException(
"import() passed an unexpected ODD class");
2271 $this->attributes[
'type'] =
$data->getAttribute(
'class');
2272 $this->attributes[
'subtype'] =
$data->getAttribute(
'subclass');
2275 $this->attributes[
'owner_guid'] =
_elgg_services()->session->getLoggedInUserGuid();
2278 $this->attributes[
'time_created'] = strtotime(
$data->getAttribute(
'published'));
2279 $this->attributes[
'time_updated'] = $this->
getCurrentTime()->getTimestamp();
2319 if ($tag_names && !is_array($tag_names)) {
2320 $tag_names = array($tag_names);
2324 $entity_tags = array();
2326 foreach ($valid_tags as $tag_name) {
2327 if (is_array($tag_names) && !in_array($tag_name, $tag_names)) {
2331 if (
$tags = $this->$tag_name) {
2334 if (is_array(
$tags)) {
2335 $entity_tags = array_merge($entity_tags,
$tags);
2337 $entity_tags[] =
$tags;
2342 return $entity_tags;
2357 if ($this->
type !==
'user') {
2363 $collections = $ac->getCollectionsByMember($this->guid);
2364 if (empty($collections)) {
2390 $collections = $ac->getEntityCollections($this->guid);
2391 if (empty($collections)) {
2416 $this->attributes[
'last_action'] =
$posted;
if(! $owner||!($owner instanceof ElggUser)||! $owner->canEdit()) $coords
if(! $collection_name) $id
if($guid==elgg_get_logged_in_user_guid()) $name
elgg_delete_annotations(array $options)
Deletes annotations based on $options.
elgg_enable_annotations(array $options)
Enables annotations based on $options.
elgg_disable_annotations(array $options)
Disables annotations based on $options.
create_annotation($entity_guid, $name, $value, $value_type='', $owner_guid=0, $access_id=ACCESS_PRIVATE)
Create a new annotation.
elgg_get_annotations(array $options=array())
Returns annotations.
$user_guid
Avatar remove action.
_elgg_invalidate_cache_for_entity($entity_guid)
Invalidate entity cache.
save($key, $data)
Save data in a cache.
getDatabase()
Provides a pointer to the database object.
getTimeCreated()
Returns the UNIX epoch time that this entity was created.
initializeAttributes()
Initialize the attributes array.
setLocation($location)
Sets the 'location' metadata for the entity.
getSites($options=array())
Gets the sites this entity is a member of.
$url_override
If set, overrides the value of getURL()
getType()
Returns the entity type.
storeInPersistedCache(\ElggSharedMemoryCache $cache, $last_action=0)
Cache the entity in a persisted cache.
deleteRelationships($relationship=null)
Remove all relationships to and from this entity.
__set($name, $value)
Set an attribute or metadata value for this entity.
saveIconFromElggFile(\ElggFile $file, $type='icon', array $coords=array())
Saves icons using a file located in the data store as the source.
toObject()
{Get a plain old object copy for public consumption.\stdClass}
countEntitiesFromRelationship($relationship, $inverse_relationship=false)
Gets the number of entities from a specific relationship type.
$volatile
Volatile data structure for this object, allows for storage of data in-memory that isn't sync'd back ...
getSystemLogID()
Return an identification for the object for storage in the system log.
refresh(\stdClass $row)
Load new data from database into existing entity.
$temp_private_settings
Holds private settings until entity is saved.
$temp_annotations
Holds annotations until entity is saved.
annotate($name, $value, $access_id=ACCESS_PRIVATE, $owner_guid=0, $vartype="")
Adds an annotation to an entity.
setPrivateSetting($name, $value)
Adds a private setting to this entity.
removePrivateSetting($name)
Removes private setting.
getSubtype()
Get the entity subtype.
saveIconFromLocalFile($filename, $type='icon', array $coords=array())
Saves icons using a local file as the source.
getTags($tag_names=null)
Returns tags for this entity.
canEditMetadata($metadata=null, $user_guid=0)
Can a user edit metadata on this entity?
getExportableValues()
Returns an array of fields which can be exported.
getOriginalAttributes()
Get the original values of attribute(s) that have been modified since the entity was persisted.
enableAnnotations($name='')
Enables annotations for this entity, optionally based on name.
getContainerGUID()
Gets the container GUID for this entity.
__get($name)
Get an attribute or metadata value.
canAnnotate($user_guid=0, $annotation_name='')
Can a user annotate an entity?
getIcon($size, $type='icon')
Returns entity icon as an ElggIcon object The icon file may or may not exist on filestore.
hasIcon($size, $type='icon')
Returns if the entity has an icon of the passed type.
$temp_metadata
Holds metadata until entity is saved.
getVolatileData($name)
Get a piece of volatile (non-persisted) data on this entity.
countAnnotations($name="")
Count annotations.
enable($recursive=true)
Enable the entity.
prepareObject($object)
Prepare an object copy for toObject()
setDisplayName($displayName)
Sets the title or name of this entity.
load($guid)
Loads attributes from the entities table into the object.
export()
Export this class into an array of ODD Elements containing all necessary fields.
deleteOwnedAccessCollections()
Remove all access collections owned by this entity.
update()
Update the entity in the database.
getDisplayName()
Get the entity's display name.
getOwnerEntity()
Gets the \ElggEntity that owns this entity.
create()
Create a new entry in the entities table.
addToSite($site)
Add this entity to a site.
addRelationship($guid_two, $relationship)
Add a relationship between this an another entity.
deleteOwnedAnnotations($name=null)
Deletes all annotations owned by this object (annotations.owner_guid = $this->guid).
getContainerEntity()
Get the container entity for this object.
getIconLastChange($size, $type='icon')
Returns the timestamp of when the icon was changed.
saveIconFromUploadedFile($input_name, $type='icon', array $coords=array())
Saves icons using an uploaded file as the source.
getURL()
Gets the URL for this entity.
deleteAccessCollectionMemberships()
Remove the membership of all access collections for this entity (if the entity is a user)
disable($reason="", $recursive=true)
Disable this entity.
__unset($name)
Unset a property from metadata or attribute.
getLongitude()
Return the entity's longitude.
canEdit($user_guid=0)
Can a user edit this entity?
loadAdditionalSelectValues(array $data)
Stores non-attributes from the loading of the entity as volatile data.
getAnnotationsMax($name)
Get the maximum of integer type annotations of a given name.
deleteMetadata($name=null)
Deletes all metadata on this object (metadata.entity_guid = $this->guid).
getTimeUpdated()
Returns the UNIX epoch time that this entity was last updated.
removeRelationship($guid_two, $relationship)
Remove a relationship.
isEnabled()
Is this entity enabled?
canComment($user_guid=0, $default=null)
Can a user comment on an entity?
getPrivateSetting($name)
Returns a private setting value.
getLocation()
Gets the 'location' metadata for the entity.
canWriteToContainer($user_guid=0, $type='all', $subtype='all')
Can a user add an entity to this container.
disableMetadata($name='')
Disables metadata for this entity, optionally based on name.
getAnnotations($options=array(), $limit=50, $offset=0, $order="asc")
Gets an array of annotations.
$orig_attributes
Holds the original (persisted) attribute values that have been changed but not yet saved.
getAnnotationsSum($name)
Get the sum of integer type annotations of a given name.
getGUID()
Returns the guid.
deleteIcon($type='icon')
Removes all icon files and metadata for the passed type of icon.
setURL($url)
Overrides the URL returned by getURL()
deleteAnnotations($name=null)
Deletes all annotations on this object (annotations.entity_guid = $this->guid).
getObjectFromID($id)
For a given ID, return the object associated with it.
isFullyLoaded()
Tests to see whether the object has been persisted.
updateLastAction($posted=null)
Update the last_action column in the entities table.
disableAnnotations($name='')
Disables annotations for this entity, optionally based on name.
getAnnotationsMin($name)
Get the minimum of integer type annotations of given name.
setContainerGUID($container_guid)
Set the container for this object.
removeFromSite($site)
Remove this entity from a site.
getAnnotationsAvg($name)
Get the average of an integer type annotation.
enableMetadata($name='')
Enables metadata for this entity, optionally based on name.
setVolatileData($name, $value)
Set a piece of volatile (non-persisted) data on this entity.
__clone()
Clone an entity.
getOwnerGUID()
Get the guid of the entity's owner.
canDelete($user_guid=0)
Can a user delete this entity?
setMetadata($name, $value, $value_type='', $multiple=false, $owner_guid=0, $access_id=null)
Set metadata on this entity.
getLatitude()
Return the entity's latitude.
countComments()
Count the number of comments attached to this entity.
getAccessID()
Returns the access_id.
getEntitiesFromRelationship($options=array(), $inverse=false, $limit=50, $offset=0)
Gets an array of entities with a relationship to this entity.
getMetadata($name)
Return the value of a piece of metadata.
deleteOwnedMetadata($name=null)
Deletes all metadata owned by this object (metadata.owner_guid = $this->guid).
getIconURL($params=array())
Get the URL for this entity's icon.
setLatLong($lat, $long)
Set latitude and longitude metadata tags for a given entity.
$CONFIG site_guid
The guid of the current site object.
elgg_get_config($name, $site_guid=0)
Get an Elgg configuration value.
$guid
Removes an admin notice.
guid_to_uuid($guid)
Generate a UUID from a given GUID.
_elgg_delete_river(array $options=[])
Alias of elgg_delete_river() that doesn't raise notices.
const ELGG_ENTITIES_ANY_VALUE
elgg_extract($key, $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
elgg_trigger_after_event($event, $object_type, $object=null)
Trigger an "After event" indicating a process has finished.
elgg_deprecated_notice($msg, $dep_version, $backtrace_level=1)
Log a notice about deprecated use of a function, view, etc.
access_get_show_hidden_status()
Return current status of showing disabled entities.
access_show_hidden_entities($show_hidden)
Show or hide disabled entities.
elgg_set_ignore_access($ignore=true)
Set if Elgg's access system should be ignored.
_elgg_services(\Elgg\Di\ServiceProvider $services=null)
Get the global service provider.
_elgg_invalidate_memcache_for_entity($entity_guid)
Invalidate an entity in memcache.
_elgg_get_memcache($namespace='default')
Get a namespaced ElggMemcache object (if memcache is available) or a null cache.
update_river_access_by_object($object_guid, $access_id)
Sets the access ID on river items for a particular object.
elgg_instanceof($entity, $type=null, $subtype=null, $class=null)
Checks if $entity is an \ElggEntity and optionally for type and subtype.
get_entity($guid)
Loads and returns an entity object from a guid.
get_subtype_from_id($subtype_id)
Gets the denormalized string for a given subtype ID.
get_entity_as_row($guid)
Returns a database row from the entities table.
add_subtype($type, $subtype, $class="")
Register \ElggEntities with a certain type and subtype to be loaded as a specific class.
elgg_get_entities(array $options=array())
Returns an array of entities with optional filtering.
if(! $display_name) $type
$object
These two snippets demonstrates triggering an event and how to register for that event.
_elgg_clear_entity_files($entity)
Removes all entity files.
Entities that support icons should implement this interface.
elgg_view_entity(\ElggEntity $entity, array $vars=array(), $bypass=false, $debug=false)
Returns a string of a rendered entity.
elgg_set_viewtype($viewtype="")
Manually set the viewtype.
getCurrentTime($modifier='')
Get the (cloned) time.
if($title==='' && $entity instanceof ElggEntity) $tags
if(!array_key_exists($filename, $text_files)) $file
remove_private_setting($entity_guid, $name)
Deletes a private setting for an entity.
remove_all_private_settings($entity_guid)
Deletes all private settings for an entity.
get_private_setting($entity_guid, $name)
Gets a private setting for an entity.
set_private_setting($entity_guid, $name, $value)
Sets a private setting for an entity.
remove_entity_relationships($guid, $relationship="", $inverse_relationship=false, $type='')
Removes all relationships originating from a particular entity.
elgg_get_entities_from_relationship($options)
Return entities matching a given query joining against a relationship.
add_entity_relationship($guid_one, $relationship, $guid_two)
Create a relationship between two entities.
remove_entity_relationship($guid_one, $relationship, $guid_two)
Delete a relationship between two entities.
elgg_get_logged_in_user_guid()
Return the current logged in user by guid.