engine/lib/relationships.php File Reference

Go to the source code of this file.

Namespaces

namespace  Elgg::Core
 

Activate a plugin or plugins.


Functions

 row_to_elggrelationship ($row)
 Convert a database row to a new ElggRelationship.
 get_relationship ($id)
 Return a relationship.
 delete_relationship ($id)
 Delete a specific relationship.
 add_entity_relationship ($guid_one, $relationship, $guid_two)
 Define an arbitrary relationship between two entities.
 check_entity_relationship ($guid_one, $relationship, $guid_two)
 Determine if a relationship between two entities exists and returns the relationship object if it does.
 remove_entity_relationship ($guid_one, $relationship, $guid_two)
 Remove an arbitrary relationship between two entities.
 remove_entity_relationships ($guid_one, $relationship="", $inverse=false, $type= '')
 Removes all arbitrary relationships originating from a particular entity.
 get_entity_relationships ($guid, $inverse_relationship=FALSE)
 Get all the relationships for a given guid.
 elgg_get_entities_from_relationship ($options)
 Return entities matching a given query joining against a relationship.
 elgg_get_entity_relationship_where_sql ($column, $relationship=NULL, $relationship_guid=NULL, $inverse_relationship=FALSE)
 Returns sql appropriate for relationship joins and wheres.
 elgg_list_entities_from_relationship (array $options=array())
 Returns a viewable list of entities by relationship.
 elgg_get_entities_from_relationship_count (array $options=array())
 Gets the number of entities by a the number of entities related to them in a particular way.
 elgg_list_entities_from_relationship_count ($options)
 Returns a list of entities by relationship count.
 elgg_register_relationship_url_handler ($relationship_type, $function_name)
 Sets the URL handler for a particular relationship type.
 get_relationship_url ($id)
 Get the url for a given relationship.
 already_attached ($guid_one, $guid_two)
 Function to determine if the object trying to attach to other, has already done so.
 get_attachments ($guid, $type="")
 Function to get all objects attached to a particular object.
 remove_attachment ($guid_one, $guid_two)
 Function to remove a particular attachment between two objects.
 make_attachment ($guid_one, $guid_two)
 Function to start the process of attaching one object to another.
 import_relationship_plugin_hook ($hook, $entity_type, $returnvalue, $params)
 Handler called by trigger_plugin_hook on the "import" event.
 export_relationship_plugin_hook ($hook, $entity_type, $returnvalue, $params)
 Handler called by trigger_plugin_hook on the "export" event.
 relationship_notification_hook ($event, $type, $object)
 Notify user that someone has friended them.

Function Documentation

add_entity_relationship ( guid_one,
relationship,
guid_two 
)

Define an arbitrary relationship between two entities.

This relationship could be a friendship, a group membership or a site membership.

This function lets you make the statement "$guid_one is a $relationship of $guid_two".

Parameters:
int $guid_one First GUID
string $relationship Relationship name
int $guid_two Second GUID
Returns:
bool

Definition at line 75 of file relationships.php.

already_attached ( guid_one,
guid_two 
)

Function to determine if the object trying to attach to other, has already done so.

Parameters:
int $guid_one This is the target object
int $guid_two This is the object trying to attach to $guid_one
Returns:
bool private

Definition at line 488 of file relationships.php.

check_entity_relationship ( guid_one,
relationship,
guid_two 
)

Determine if a relationship between two entities exists and returns the relationship object if it does.

Parameters:
int $guid_one The GUID of the entity "owning" the relationship
string $relationship The type of relationship
int $guid_two The GUID of the entity the relationship is with
Returns:
ElggRelationship|false Depending on success

Definition at line 114 of file relationships.php.

delete_relationship ( id  ) 

Delete a specific relationship.

Parameters:
int $id The relationship ID
Returns:
bool

Definition at line 49 of file relationships.php.

elgg_get_entities_from_relationship ( options  ) 

Return entities matching a given query joining against a relationship.

Also accepts all options available to elgg_get_entities() and elgg_get_entities_from_metadata().

To ask for entities that do not have a particulat relationship to an entity, use a custom where clause like the following:

$options['wheres'][] = "NOT EXISTS ( SELECT 1 FROM {$db_prefix}entity_relationships WHERE guid_one = e.guid AND relationship = '$relationship' )";

See also:
elgg_get_entities
elgg_get_entities_from_metadata
Parameters:
array $options Array in format:

relationship => NULL|STR relationship

relationship_guid => NULL|INT Guid of relationship to test

inverse_relationship => BOOL Inverse the relationship

Returns:
ElggEntity[]|mixed If count, int. If not count, array. false on errors.
Since:
1.7.0

Definition at line 265 of file relationships.php.

elgg_get_entities_from_relationship_count ( array $  options = array()  ) 

Gets the number of entities by a the number of entities related to them in a particular way.

This is a good way to get out the users with the most friends, or the groups with the most members.

Parameters:
array $options An options array compatible with elgg_get_entities_from_relationship()
Returns:
ElggEntity[]|mixed int If count, int. If not count, array. false on errors.
Since:
1.8.0

Definition at line 387 of file relationships.php.

elgg_get_entity_relationship_where_sql ( column,
relationship = NULL,
relationship_guid = NULL,
inverse_relationship = FALSE 
)

Returns sql appropriate for relationship joins and wheres.

Parameters:
string $column Column name the guid should be checked against. Provide in table.column format.
string $relationship Relationship string
int $relationship_guid Entity guid to check
bool $inverse_relationship Inverse relationship check?
Returns:
mixed
Since:
1.7.0 private

Definition at line 325 of file relationships.php.

elgg_list_entities_from_relationship ( array $  options = array()  ) 

Returns a viewable list of entities by relationship.

Parameters:
array $options Options array for retrieval of entities
See also:
elgg_list_entities()
elgg_get_entities_from_relationship()
Returns:
string The viewable list of entities

Definition at line 373 of file relationships.php.

elgg_list_entities_from_relationship_count ( options  ) 

Returns a list of entities by relationship count.

See also:
elgg_get_entities_from_relationship_count()
Parameters:
array $options Options array
Returns:
string
Since:
1.8.0

Definition at line 404 of file relationships.php.

elgg_register_relationship_url_handler ( relationship_type,
function_name 
)

Sets the URL handler for a particular relationship type.

Parameters:
string $relationship_type The relationship type.
string $function_name The function to register
Returns:
bool Depending on success

Definition at line 416 of file relationships.php.

export_relationship_plugin_hook ( hook,
entity_type,
returnvalue,
params 
)

Handler called by trigger_plugin_hook on the "export" event.

Parameters:
string $hook export
string $entity_type all
mixed $returnvalue Previous hook return value
array $params Parameters

export all

Returns:
mixed
Exceptions:
InvalidParameterException private

Definition at line 591 of file relationships.php.

get_attachments ( guid,
type = "" 
)

Function to get all objects attached to a particular object.

Parameters:
int $guid Entity GUID
string $type The type of object to return e.g. 'file', 'friend_of' etc
Returns:
ElggEntity[] private

Definition at line 505 of file relationships.php.

get_entity_relationships ( guid,
inverse_relationship = FALSE 
)

Get all the relationships for a given guid.

Parameters:
int $guid The GUID of the relationship owner
bool $inverse_relationship Inverse relationship owners?
Returns:
ElggRelationship[]

Definition at line 225 of file relationships.php.

get_relationship ( id  ) 

Return a relationship.

Parameters:
int $id The ID of a relationship
Returns:
ElggRelationship|false

Definition at line 33 of file relationships.php.

get_relationship_url ( id  ) 

Get the url for a given relationship.

Parameters:
int $id Relationship ID
Returns:
string

Definition at line 439 of file relationships.php.

import_relationship_plugin_hook ( hook,
entity_type,
returnvalue,
params 
)

Handler called by trigger_plugin_hook on the "import" event.

Parameters:
string $hook import
string $entity_type all
mixed $returnvalue Value from previous hook
mixed $params Array of params
Returns:
mixed private

Definition at line 566 of file relationships.php.

make_attachment ( guid_one,
guid_two 
)

Function to start the process of attaching one object to another.

Parameters:
int $guid_one This is the target object
int $guid_two This is the object trying to attach to $guid_one
Returns:
true|void private

Definition at line 547 of file relationships.php.

relationship_notification_hook ( event,
type,
object 
)

Notify user that someone has friended them.

Parameters:
string $event Event name
string $type Object type
mixed $object Object
Returns:
bool private

Definition at line 624 of file relationships.php.

remove_attachment ( guid_one,
guid_two 
)

Function to remove a particular attachment between two objects.

Parameters:
int $guid_one This is the target object
int $guid_two This is the object to remove from $guid_one
Returns:
void private

Definition at line 532 of file relationships.php.

remove_entity_relationship ( guid_one,
relationship,
guid_two 
)

Remove an arbitrary relationship between two entities.

Parameters:
int $guid_one First GUID
string $relationship Relationship name
int $guid_two Second GUID
Returns:
bool

Definition at line 143 of file relationships.php.

remove_entity_relationships ( guid_one,
relationship = "",
inverse = false,
type = '' 
)

Removes all arbitrary relationships originating from a particular entity.

Parameters:
int $guid_one The GUID of the entity
string $relationship The name of the relationship (optional)
bool $inverse Whether we're deleting inverse relationships (default false)
string $type The type of entity to the delete to (defaults to all)
Returns:
bool Depending on success

Definition at line 177 of file relationships.php.

row_to_elggrelationship ( row  ) 

Convert a database row to a new ElggRelationship.

Parameters:
stdClass $row Database row from the relationship table
Returns:
ElggRelationship|stdClass private

Definition at line 18 of file relationships.php.

 All Classes Namespaces Files Functions Variables Enumerations
Generated on Mon May 20 00:01:23 2013 for Elgg by  doxygen 1.6.3