Elgg
Version 2.3
|
Go to the source code of this file.
Functions | |
get_subtype_id ($type, $subtype) | |
Return the id for a given subtype. More... | |
get_subtype_from_id ($subtype_id) | |
Gets the denormalized string for a given subtype ID. More... | |
get_subtype_class ($type, $subtype) | |
Return the class name for a registered type and subtype. More... | |
get_subtype_class_from_id ($subtype_id) | |
Returns the class name for a subtype id. More... | |
add_subtype ($type, $subtype, $class="") | |
Register with a certain type and subtype to be loaded as a specific class. More... | |
remove_subtype ($type, $subtype) | |
Removes a registered type, subtype, and classname. More... | |
update_subtype ($type, $subtype, $class= '') | |
Update a registered type, subtype, and class name. More... | |
can_write_to_container ($user_guid=0, $container_guid=0, $type= 'all', $subtype= 'all') | |
Determine if a given user can write to an entity container. More... | |
get_entity_as_row ($guid) | |
Returns a database row from the entities table. More... | |
entity_row_to_elggstar ($row) | |
Create an Elgg* object from a given entity row. More... | |
get_entity ($guid) | |
Loads and returns an entity object from a guid. More... | |
elgg_entity_exists ($guid) | |
Does an entity exist? More... | |
elgg_enable_entity ($guid, $recursive=true) | |
Enable an entity. More... | |
elgg_get_entities (array $options=array()) | |
Returns an array of entities with optional filtering. More... | |
_elgg_get_guid_based_where_sql ($column, $guids) | |
Returns SQL where clause for owner and containers. More... | |
_elgg_get_entity_time_where_sql ($table, $time_created_upper=null, $time_created_lower=null, $time_updated_upper=null, $time_updated_lower=null) | |
Returns SQL where clause for entity time limits. More... | |
elgg_list_entities (array $options=array(), $getter= 'elgg_get_entities', $viewer= 'elgg_view_entity_list') | |
Returns a string of rendered entities. More... | |
elgg_get_entities_from_attributes (array $options=array()) | |
Gets entities based upon attributes in secondary tables. More... | |
_elgg_get_entity_attribute_where_sql (array $options=array()) | |
Get the join and where clauses for working with entity attributes. More... | |
get_entity_dates ($type= '', $subtype= '', $container_guid=0, $site_guid=0, $order_by= 'time_created') | |
Returns a list of months in which entities were updated or created. More... | |
elgg_register_entity_type ($type, $subtype=null) | |
Registers an entity type and subtype as a public-facing entity that should be shown in search and by elgg_list_registered_entities(). More... | |
elgg_unregister_entity_type ($type, $subtype=null) | |
Unregisters an entity type and subtype as a public-facing type. More... | |
get_registered_entity_types ($type=null) | |
Returns registered entity types and subtypes. More... | |
is_registered_entity_type ($type, $subtype=null) | |
Returns if the entity type and subtype have been registered with elgg_register_entity_type(). More... | |
elgg_list_registered_entities (array $options=array()) | |
Returns a viewable list of entities based on the registered types. More... | |
elgg_instanceof ($entity, $type=null, $subtype=null, $class=null) | |
Checks if $entity is an and optionally for type and subtype. More... | |
update_entity_last_action ($guid, $posted=null) | |
Update the last_action column in the entities table for $guid. More... | |
_elgg_entities_test ($hook, $type, $value) | |
Runs unit tests for the entity objects. More... | |
_elgg_entities_init () | |
Entities init function; establishes the default entity page handler. More... | |
Variables | |
return | function (\Elgg\EventsService $events,\Elgg\HooksRegistrationService $hooks) |
_elgg_entities_init | ( | ) |
Entities init function; establishes the default entity page handler.
Definition at line 812 of file entities.php.
_elgg_entities_test | ( | $hook, | |
$type, | |||
$value | |||
) |
Runs unit tests for the entity objects.
string | $hook | unit_test |
string | $type | system |
array | $value | Array of tests |
Definition at line 791 of file entities.php.
_elgg_get_entity_attribute_where_sql | ( | array | $options = array() | ) |
Get the join and where clauses for working with entity attributes.
InvalidArgumentException |
Definition at line 485 of file entities.php.
_elgg_get_entity_time_where_sql | ( | $table, | |
$time_created_upper = null , |
|||
$time_created_lower = null , |
|||
$time_updated_upper = null , |
|||
$time_updated_lower = null |
|||
) |
Returns SQL where clause for entity time limits.
string | $table | Entity table prefix as defined in SELECT...FROM entities $table |
null | int | $time_created_upper | Time created upper limit |
null | int | $time_created_lower | Time created lower limit |
null | int | $time_updated_upper | Time updated upper limit |
null | int | $time_updated_lower | Time updated lower limit |
Definition at line 359 of file entities.php.
_elgg_get_guid_based_where_sql | ( | $column, | |
$guids | |||
) |
Returns SQL where clause for owner and containers.
string | $column | Column name the guids should be checked against. Usually best to provide in table.column format. |
null | array | $guids | Array of GUIDs. |
Definition at line 341 of file entities.php.
add_subtype | ( | $type, | |
$subtype, | |||
$class = "" |
|||
) |
Register with a certain type and subtype to be loaded as a specific class.
By default entities are loaded as one of the 4 parent objects: site, user, object, or group. If you subclass any of these you can register the classname with add_subtype() so it will be loaded as that class automatically when retrieved from the database with get_entity().
string | $type | The type you're subtyping (site, user, object, or group) |
string | $subtype | The subtype |
string | $class | Optional class name for the object |
Definition at line 95 of file entities.php.
can_write_to_container | ( | $user_guid = 0 , |
|
$container_guid = 0 , |
|||
$type = 'all' , |
|||
$subtype = 'all' |
|||
) |
Determine if a given user can write to an entity container.
An entity can be a container for any other entity by setting the container_guid. container_guid can differ from owner_guid.
A plugin hook container_permissions_check:$entity_type is emitted to allow granular access controls in plugins.
int | $user_guid | The user guid, or 0 for logged in user. |
int | $container_guid | The container, or 0 for the current page owner. |
string | $type | The type of entity we want to create (default: 'all') |
string | $subtype | The subtype of the entity we want to create (default: 'all') |
Definition at line 147 of file entities.php.
elgg_enable_entity | ( | $guid, | |
$recursive = true |
|||
) |
Enable an entity.
int | $guid | GUID of entity to enable |
bool | $recursive | Recursively enable all entities disabled with the entity? |
Definition at line 234 of file entities.php.
elgg_entity_exists | ( | $guid | ) |
Does an entity exist?
This function checks for the existence of an entity independent of access permissions. It is useful for situations when a user cannot access an entity and it must be determined whether entity has been deleted or the access level has changed.
int | $guid | The GUID of the entity |
Definition at line 221 of file entities.php.
elgg_get_entities | ( | array | $options = array() | ) |
Returns an array of entities with optional filtering.
Entities are the basic unit of storage in Elgg. This function provides the simplest way to get an array of entities. There are many options available that can be passed to filter what sorts of entities are returned.
To output formatted strings of entities, use elgg_list_entities() and its cousins.
Plural arguments can be written as singular if only specifying a single element. ('type' => 'object' vs 'types' => array('object')).
array | $options | Array in format: types => null|STR entity type (type IN ('type1', 'type2') Joined with subtypes by AND. See below) subtypes => null|STR entity subtype (SQL: subtype IN ('subtype1', 'subtype2)) Use ELGG_ENTITIES_NO_VALUE to match the default subtype. Use ELGG_ENTITIES_ANY_VALUE to match any subtype. type_subtype_pairs => null|ARR (array('type' => 'subtype')) array( 'object' => array('blog', 'file'), // All objects with subtype of 'blog' or 'file' 'user' => ELGG_ENTITY_ANY_VALUE, // All users irrespective of subtype ); |
guids => null|ARR Array of entity guids
owner_guids => null|ARR Array of owner guids
container_guids => null|ARR Array of container_guids
site_guids => null (current_site)|ARR Array of site_guid
order_by => null (time_created desc)|STR SQL order by clause
reverse_order_by => BOOL Reverse the default order by clause
limit => null (from settings)|INT SQL limit clause (0 means no limit)
offset => null (0)|INT SQL offset clause
created_time_lower => null|INT Created time lower boundary in epoch time
created_time_upper => null|INT Created time upper boundary in epoch time
modified_time_lower => null|INT Modified time lower boundary in epoch time
modified_time_upper => null|INT Modified time upper boundary in epoch time
count => true|false return a count instead of entities
wheres => array() Additional where clauses to AND together
joins => array() Additional joins
preload_owners => bool (false) If set to true, this function will preload all the owners of the returned entities resulting in better performance when displaying entities owned by several users
callback => string A callback function to pass each row through
distinct => bool (true) If set to false, Elgg will drop the DISTINCT clause from the MySQL query, which will improve performance in some situations. Avoid setting this option without a full understanding of the underlying SQL query Elgg creates.
batch => bool (false) If set to true, an Elgg object will be returned instead of an array. Since 2.3
batch_inc_offset => bool (true) If "batch" is used, this tells the batch to increment the offset on each fetch. This must be set to false if you delete the batched results.
batch_size => int (25) If "batch" is used, this is the number of entities/rows to pull in before requesting more.
Definition at line 326 of file entities.php.
elgg_get_entities_from_attributes | ( | array | $options = array() | ) |
Gets entities based upon attributes in secondary tables.
Also accepts all options available to elgg_get_entities(), elgg_get_entities_from_metadata(), and elgg_get_entities_from_relationship().
array | $options | Array in format: attribute_name_value_pairs => ARR ( 'name' => 'name', 'value' => 'value', 'operand' => '=', (optional) 'case_sensitive' => false (optional) ) If multiple values are sent via an array ('value' => array('value1', 'value2') the pair's operand will be forced to "IN". attribute_name_value_pairs_operator => null|STR The operator to use for combining (name = value) OPERATOR (name = value); default is AND |
InvalidArgumentException |
Definition at line 473 of file entities.php.
elgg_instanceof | ( | $entity, | |
$type = null , |
|||
$subtype = null , |
|||
$class = null |
|||
) |
Checks if $entity is an and optionally for type and subtype.
Use this function in actions and views to check that you are dealing with the correct type of entity.
mixed | $entity | Entity |
string | $type | Entity type |
string | $subtype | Entity subtype |
string | $class | Class name |
Definition at line 736 of file entities.php.
elgg_list_entities | ( | array | $options = array() , |
$getter = 'elgg_get_entities' , |
|||
$viewer = 'elgg_view_entity_list' |
|||
) |
Returns a string of rendered entities.
Displays list of entities with formatting specified by the entity view.
Pagination is handled automatically.
array | $options | Any options from $getter options plus: item_view => STR Optional. Alternative view used to render list items full_view => BOOL Display full view of entities (default: false) list_type => STR 'list', 'gallery', or 'table' columns => ARR instances of Elgg if list_type is "table" list_type_toggle => BOOL Display gallery / list switch pagination => BOOL Display pagination links no_results => STR|Closure Message to display when there are no entities |
callback | $getter | The entity getter function to use to fetch the entities. |
callback | $viewer | The function to use to view the entity list. |
Definition at line 393 of file entities.php.
elgg_list_registered_entities | ( | array | $options = array() | ) |
Returns a viewable list of entities based on the registered types.
array | $options | Any elgg_get_entity() options plus: full_view => BOOL Display full view entities list_type_toggle => BOOL Display gallery / list switch allowed_types => true|ARRAY True to show all types or an array of valid types. pagination => BOOL Display pagination links |
Definition at line 666 of file entities.php.
elgg_register_entity_type | ( | $type, | |
$subtype = null |
|||
) |
Registers an entity type and subtype as a public-facing entity that should be shown in search and by elgg_list_registered_entities().
Add a language string item:type:subtype to make sure the items are display properly.
string | $type | The type of entity (object, site, user, group) |
string | $subtype | The subtype to register (may be blank) |
Definition at line 526 of file entities.php.
elgg_unregister_entity_type | ( | $type, | |
$subtype = null |
|||
) |
Unregisters an entity type and subtype as a public-facing type.
string | $type | The type of entity (object, site, user, group) |
string | $subtype | The subtype to register (may be blank) |
Definition at line 561 of file entities.php.
entity_row_to_elggstar | ( | $row | ) |
Create an Elgg* object from a given entity row.
Handles loading all tables into the correct class.
\stdClass | $row | The row of the entry in the entities table. |
ClassException|InstallationException |
Definition at line 193 of file entities.php.
get_entity | ( | $guid | ) |
Loads and returns an entity object from a guid.
int | $guid | The GUID of the entity |
Definition at line 204 of file entities.php.
get_entity_as_row | ( | $guid | ) |
Returns a database row from the entities table.
Use get_entity() to return the fully loaded entity.
int | $guid | The GUID of the object to extract |
Definition at line 174 of file entities.php.
get_entity_dates | ( | $type = '' , |
|
$subtype = '' , |
|||
$container_guid = 0 , |
|||
$site_guid = 0 , |
|||
$order_by = 'time_created' |
|||
) |
Returns a list of months in which entities were updated or created.
Use this to generate a list of archives by month for when entities were added or updated.
string | $type | The type of entity |
string | $subtype | The subtype of entity |
int | $container_guid | The container GUID that the entities belong to |
int | $site_guid | The site GUID |
string | $order_by | Order_by SQL order by clause |
Definition at line 506 of file entities.php.
get_registered_entity_types | ( | $type = null | ) |
Returns registered entity types and subtypes.
string | $type | The type of entity (object, site, user, group) or blank for all |
Definition at line 599 of file entities.php.
get_subtype_class | ( | $type, | |
$subtype | |||
) |
Return the class name for a registered type and subtype.
Entities can be registered to always be loaded as a certain class with add_subtype() or update_subtype(). This function returns the class name if found and null if not.
string | $type | The type |
string | $subtype | The subtype |
Definition at line 57 of file entities.php.
get_subtype_class_from_id | ( | $subtype_id | ) |
Returns the class name for a subtype id.
int | $subtype_id | The subtype id |
Definition at line 71 of file entities.php.
get_subtype_from_id | ( | $subtype_id | ) |
Gets the denormalized string for a given subtype ID.
int | $subtype_id | Subtype ID from database |
Definition at line 39 of file entities.php.
get_subtype_id | ( | $type, | |
$subtype | |||
) |
Return the id for a given subtype.
objects have a type and a subtype. Subtypes are defined upon creation and cannot be changed.
Plugin authors generally don't need to use this function unless writing their own SQL queries. Use ElggEntity::getSubtype()toreturnthestringsubtype.
Definition at line 27 of file entities.php.
is_registered_entity_type | ( | $type, | |
$subtype = null |
|||
) |
Returns if the entity type and subtype have been registered with elgg_register_entity_type().
string | $type | The type of entity (object, site, user, group) |
string | $subtype | The subtype (may be blank) |
Definition at line 627 of file entities.php.
remove_subtype | ( | $type, | |
$subtype | |||
) |
Removes a registered type, subtype, and classname.
string | $type | Type |
string | $subtype | Subtype |
Definition at line 113 of file entities.php.
update_entity_last_action | ( | $guid, | |
$posted = null |
|||
) |
Update the last_action column in the entities table for $guid.
int | $guid | Entity annotation|relationship action carried out on |
int | $posted | Timestamp of last action |
Definition at line 768 of file entities.php.
update_subtype | ( | $type, | |
$subtype, | |||
$class = '' |
|||
) |
Update a registered type, subtype, and class name.
string | $type | Type |
string | $subtype | Subtype |
string | $class | Class name to use when loading this entity |
Definition at line 126 of file entities.php.
return function(\Elgg\EventsService $events,\Elgg\HooksRegistrationService $hooks) |
Definition at line 816 of file entities.php.