Go to the source code of this file.
Namespaces | |
| namespace | Elgg::Core |
Activate a plugin or plugins. | |
Functions | |
| _elgg_invalidate_cache_for_entity ($guid) | |
| Invalidate this class's entry in the cache. | |
| _elgg_cache_entity (ElggEntity $entity) | |
| Cache an entity. | |
| _elgg_retrieve_cached_entity ($guid) | |
| Retrieve a entity from the cache. | |
| get_subtype_id ($type, $subtype) | |
| Return the id for a given subtype. | |
| get_subtype_from_id ($subtype_id) | |
| Return string name for a given subtype ID. | |
| _elgg_retrieve_cached_subtype ($type, $subtype) | |
| Retrieve subtype from the cache. | |
| _elgg_populate_subtype_cache () | |
| Fetch all suptypes from DB to local cache. | |
| get_subtype_class ($type, $subtype) | |
| Return the class name for a registered type and subtype. | |
| get_subtype_class_from_id ($subtype_id) | |
| Returns the class name for a subtype id. | |
| add_subtype ($type, $subtype, $class="") | |
| Register ElggEntities with a certain type and subtype to be loaded as a specific class. | |
| remove_subtype ($type, $subtype) | |
| Removes a registered ElggEntity type, subtype, and classname. | |
| update_subtype ($type, $subtype, $class= '') | |
| Update a registered ElggEntity type, subtype, and class name. | |
| update_entity ($guid, $owner_guid, $access_id, $container_guid=null, $time_created=null) | |
| Update an entity in the database. | |
| 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. | |
| create_entity ($type, $subtype, $owner_guid, $access_id, $site_guid=0, $container_guid=0) | |
| Create a new entry in the entities table. | |
| get_entity_as_row ($guid) | |
| Returns a database row from the entities table. | |
| entity_row_to_elggstar ($row) | |
| Create an Elgg* object from a given entity row. | |
| get_entity ($guid) | |
| Loads and returns an entity object from a guid. | |
| elgg_entity_exists ($guid) | |
| Does an entity exist? | |
| elgg_get_entities (array $options=array()) | |
| Returns an array of entities with optional filtering. | |
| _elgg_fetch_entities_from_sql ($sql) | |
| Return entities from an SQL query generated by elgg_get_entities. | |
| elgg_get_entity_type_subtype_where_sql ($table, $types, $subtypes, $pairs) | |
| Returns SQL where clause for type and subtype on main entity table. | |
| elgg_get_guid_based_where_sql ($column, $guids) | |
| Returns SQL where clause for owner and containers. | |
| 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. | |
| elgg_list_entities (array $options=array(), $getter= 'elgg_get_entities', $viewer= 'elgg_view_entity_list') | |
| Returns a string of parsed entities. | |
| 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. | |
| disable_entity ($guid, $reason="", $recursive=true) | |
| Disable an entity. | |
| enable_entity ($guid, $recursive=true) | |
| Enable an entity. | |
| delete_entity ($guid, $recursive=true) | |
| Delete an entity. | |
| volatile_data_export_plugin_hook ($hook, $entity_type, $returnvalue, $params) | |
| Exports attributes generated on the fly (volatile) about an entity. | |
| export_entity_plugin_hook ($hook, $entity_type, $returnvalue, $params) | |
| Exports all attributes of an entity. | |
| oddentity_to_elggentity (ODDEntity $element) | |
| Utility function used by import_entity_plugin_hook() to process an ODDEntity into an unsaved ElggEntity. | |
| import_entity_plugin_hook ($hook, $entity_type, $returnvalue, $params) | |
| Import an entity. | |
| can_edit_entity ($entity_guid, $user_guid=0) | |
| Returns if $user_guid is able to edit $entity_guid. | |
| can_edit_entity_metadata ($entity_guid, $user_guid=0, $metadata=null) | |
| Returns if $user_guid can edit the metadata on $entity_guid. | |
| get_entity_url ($entity_guid) | |
| Returns the URL for an entity. | |
| elgg_register_entity_url_handler ($entity_type, $entity_subtype, $function_name) | |
| Sets the URL handler for a particular entity type and subtype. | |
| 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(). | |
| unregister_entity_type ($type, $subtype) | |
| Unregisters an entity type and subtype as a public-facing entity. | |
| get_registered_entity_types ($type=null) | |
| Returns registered entity types and subtypes. | |
| is_registered_entity_type ($type, $subtype=null) | |
| Returns if the entity type and subtype have been registered with {. | |
| entities_page_handler ($page) | |
| Page handler for generic entities view system. | |
| elgg_list_registered_entities (array $options=array()) | |
| Returns a viewable list of entities based on the registered types. | |
| elgg_instanceof ($entity, $type=NULL, $subtype=NULL, $class=NULL) | |
| Checks if $entity is an ElggEntity and optionally for type and subtype. | |
| update_entity_last_action ($guid, $posted=NULL) | |
| Update the last_action column in the entities table for $guid. | |
| entities_gc () | |
| Garbage collect stub and fragments from any broken delete/create calls. | |
| entities_test ($hook, $type, $value, $params) | |
| Runs unit tests for the entity objects. | |
| entities_init () | |
| Entities init function; establishes the default entity page handler. | |
Variables | |
| global | $ENTITY_CACHE = array() |
| Cache entities in memory once loaded. | |
| global | $SUBTYPE_CACHE = null |
| Cache subtypes and related class names. | |
| _elgg_cache_entity | ( | ElggEntity $ | entity | ) |
Cache an entity.
Stores an entity in $ENTITY_CACHE;
| ElggEntity | $entity Entity to cache |
Definition at line 59 of file entities.php.
| _elgg_fetch_entities_from_sql | ( | $ | sql | ) |
Return entities from an SQL query generated by elgg_get_entities.
| string | $sql |
private
| LogicException |
Definition at line 1045 of file entities.php.
| _elgg_invalidate_cache_for_entity | ( | $ | guid | ) |
Invalidate this class's entry in the cache.
| int | $guid The entity guid |
Definition at line 36 of file entities.php.
| _elgg_populate_subtype_cache | ( | ) |
| _elgg_retrieve_cached_entity | ( | $ | guid | ) |
Retrieve a entity from the cache.
| int | $guid The guid |
Definition at line 95 of file entities.php.
| _elgg_retrieve_cached_subtype | ( | $ | type, | |
| $ | subtype | |||
| ) |
Retrieve subtype from the cache.
| string | $type | |
| string | $subtype |
private
Definition at line 188 of file entities.php.
| add_subtype | ( | $ | type, | |
| $ | subtype, | |||
| $ | class = "" | |||
| ) |
Register ElggEntities 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 300 of file entities.php.
| can_edit_entity | ( | $ | entity_guid, | |
| $ | user_guid = 0 | |||
| ) |
Returns if $user_guid is able to edit $entity_guid.
Can be overridden by by registering for the permissions_check plugin hook.
Use ElggEntity::canEdit() instead.
| int | $entity_guid The GUID of the entity | |
| int | $user_guid The GUID of the user |
Definition at line 2019 of file entities.php.
| can_edit_entity_metadata | ( | $ | entity_guid, | |
| $ | user_guid = 0, |
|||
| $ | metadata = null | |||
| ) |
Returns if $user_guid can edit the metadata on $entity_guid.
Can be overridden by by registering for the permissions_check:metadata plugin hook.
| int | $entity_guid The GUID of the entity | |
| int | $user_guid The GUID of the user | |
| ElggMetadata | $metadata The metadata to specifically check (if any; default null) |
Definition at line 2067 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're looking to write | |
| string | $subtype The subtype of the entity we're looking to write |
Definition at line 480 of file entities.php.
| create_entity | ( | $ | type, | |
| $ | subtype, | |||
| $ | owner_guid, | |||
| $ | access_id, | |||
| $ | site_guid = 0, |
|||
| $ | container_guid = 0 | |||
| ) |
Create a new entry in the entities table.
Saves the base information in the entities table for the entity. Saving the type information is handled in the calling class method.
| string | $type The type of the entity (site, user, object, group). | |
| string | $subtype The subtype of the entity. | |
| int | $owner_guid The GUID of the object's owner. | |
| int | $access_id The access control group to create the entity with. | |
| int | $site_guid The site to add this entity to. 0 for current. | |
| int | $container_guid The container GUID |
| InvalidParameterException | private |
Definition at line 551 of file entities.php.
| delete_entity | ( | $ | guid, | |
| $ | recursive = true | |||
| ) |
Delete an entity.
Removes an entity and its metadata, annotations, relationships, river entries, and private data.
Optionally can remove entities contained and owned by $guid.
Use ElggEntity::delete() instead.
| int | $guid The guid of the entity to delete | |
| bool | $recursive If true (default) then all entities which are owned or contained by $guid will also be deleted. |
Definition at line 1694 of file entities.php.
| disable_entity | ( | $ | guid, | |
| $ | reason = "", |
|||
| $ | recursive = true | |||
| ) |
Disable an entity.
Disabled entities do not show up in list or elgg_get_entity() calls, but still exist in the database.
Entities are disabled by setting disabled = yes in the entities table.
You can ignore the disabled field by using access_show_hidden_entities().
| int | $guid The guid | |
| string | $reason Optional reason | |
| bool | $recursive Recursively disable all entities owned or contained by $guid? |
Definition at line 1569 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 778 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 for no subtype.
type_subtype_pairs => NULL|ARR (array('type' => 'subtype')) (type = '$type' AND subtype = '$subtype') pairs
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 (10)|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
callback => string A callback function to pass each row through
Definition at line 858 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 1358 of file entities.php.
| elgg_get_entity_type_subtype_where_sql | ( | $ | table, | |
| $ | types, | |||
| $ | subtypes, | |||
| $ | pairs | |||
| ) |
Returns SQL where clause for type and subtype on main entity table.
| string | $table Entity table prefix as defined in SELECT...FROM entities $table | |
| NULL|array | $types Array of types or NULL if none. | |
| NULL|array | $subtypes Array of subtypes or NULL if none | |
| NULL|array | $pairs Array of pairs of types and subtypes |
Definition at line 1140 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 1309 of file entities.php.
| elgg_instanceof | ( | $ | entity, | |
| $ | type = NULL, |
|||
| $ | subtype = NULL, |
|||
| $ | class = NULL | |||
| ) |
Checks if $entity is an ElggEntity 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 2409 of file entities.php.
| elgg_list_entities | ( | array $ | options = array(), |
|
| $ | getter = 'elgg_get_entities', |
|||
| $ | viewer = 'elgg_view_entity_list' | |||
| ) |
Returns a string of parsed entities.
Displays list of entities with formatting specified by the entity view.
Pagination is handled automatically.
Definition at line 1413 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 2343 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 2184 of file entities.php.
| elgg_register_entity_url_handler | ( | $ | entity_type, | |
| $ | entity_subtype, | |||
| $ | function_name | |||
| ) |
Sets the URL handler for a particular entity type and subtype.
| string | $entity_type The entity type | |
| string | $entity_subtype The entity subtype | |
| string | $function_name The function to register |
Definition at line 2148 of file entities.php.
| 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 1630 of file entities.php.
| entities_gc | ( | ) |
Garbage collect stub and fragments from any broken delete/create calls.
Definition at line 2470 of file entities.php.
| entities_init | ( | ) |
Entities init function; establishes the default entity page handler.
Definition at line 2505 of file entities.php.
| entities_page_handler | ( | $ | page | ) |
Page handler for generic entities view system.
| array | $page Page elements from pain page handler |
Definition at line 2315 of file entities.php.
| entities_test | ( | $ | hook, | |
| $ | type, | |||
| $ | value, | |||
| $ | params | |||
| ) |
Runs unit tests for the entity objects.
| string | $hook unit_test | |
| string | $type system | |
| mixed | $value Array of tests | |
| mixed | $params Params |
Definition at line 2492 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. |
Definition at line 634 of file entities.php.
| export_entity_plugin_hook | ( | $ | hook, | |
| $ | entity_type, | |||
| $ | returnvalue, | |||
| $ | params | |||
| ) |
Exports all attributes of an entity.
| string | $hook export | |
| string | $entity_type all | |
| mixed | $returnvalue Previous hook return value | |
| array | $params Parameters |
export all
| InvalidParameterException|InvalidClassException |
Definition at line 1858 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 709 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 605 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 1462 of file entities.php.
| get_entity_url | ( | $ | entity_guid | ) |
Returns the URL for an entity.
Can be overridden with register_entity_url_handler().
| int | $entity_guid The GUID of the entity |
Definition at line 2103 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 2257 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 234 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 260 of file entities.php.
| get_subtype_from_id | ( | $ | subtype_id | ) |
Return string name for a given subtype ID.
| int | $subtype_id Subtype ID |
Definition at line 161 of file entities.php.
| get_subtype_id | ( | $ | type, | |
| $ | subtype | |||
| ) |
Return the id for a given subtype.
ElggEntity 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() to return the string subtype.
Definition at line 131 of file entities.php.
| import_entity_plugin_hook | ( | $ | hook, | |
| $ | entity_type, | |||
| $ | returnvalue, | |||
| $ | params | |||
| ) |
Import an entity.
This function checks the passed XML doc (as array) to see if it is a user, if so it constructs a new elgg user and returns "true" to inform the importer that it's been handled.
| string | $hook import | |
| string | $entity_type all | |
| mixed | $returnvalue Value from previous hook | |
| mixed | $params Array of params |
| ImportException |
Definition at line 1975 of file entities.php.
| is_registered_entity_type | ( | $ | type, | |
| $ | subtype = null | |||
| ) |
Returns if the entity type and subtype have been registered with {.
| string | $type The type of entity (object, site, user, group) | |
| string | $subtype The subtype (may be blank) |
Definition at line 2285 of file entities.php.
| oddentity_to_elggentity | ( | ODDEntity $ | element | ) |
Utility function used by import_entity_plugin_hook() to process an ODDEntity into an unsaved ElggEntity.
| ODDEntity | $element The OpenDD element |
| ClassException|InstallationException|ImportException |
Definition at line 1902 of file entities.php.
| remove_subtype | ( | $ | type, | |
| $ | subtype | |||
| ) |
Removes a registered ElggEntity type, subtype, and classname.
| string | $type Type | |
| string | $subtype Subtype |
Definition at line 346 of file entities.php.
| unregister_entity_type | ( | $ | type, | |
| $ | subtype | |||
| ) |
Unregisters an entity type and subtype as a public-facing entity.
| string | $type The type of entity (object, site, user, group) | |
| string | $subtype The subtype to register (may be blank) |
Definition at line 2219 of file entities.php.
| update_entity | ( | $ | guid, | |
| $ | owner_guid, | |||
| $ | access_id, | |||
| $ | container_guid = null, |
|||
| $ | time_created = null | |||
| ) |
Update an entity in the database.
There are 4 basic entity types: site, user, object, and group. All entities are split between two tables: the entities table and their type table.
| int | $guid The guid of the entity to update | |
| int | $owner_guid The new owner guid | |
| int | $access_id The new access id | |
| int | $container_guid The new container guid | |
| int | $time_created The time creation timestamp |
Definition at line 413 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 2440 of file entities.php.
| update_subtype | ( | $ | type, | |
| $ | subtype, | |||
| $ | class = '' | |||
| ) |
Update a registered ElggEntity type, subtype, and class name.
| string | $type Type | |
| string | $subtype Subtype | |
| string | $class Class name to use when loading this entity |
Definition at line 365 of file entities.php.
| volatile_data_export_plugin_hook | ( | $ | hook, | |
| $ | entity_type, | |||
| $ | returnvalue, | |||
| $ | params | |||
| ) |
Exports attributes generated on the fly (volatile) about an entity.
| string | $hook volatile | |
| string | $entity_type metadata | |
| string | $returnvalue Return value from previous hook | |
| array | $params The parameters, passed 'guid' and 'varname' |
Definition at line 1816 of file entities.php.
| $ENTITY_CACHE = array() |
Cache entities in memory once loaded.
array $ENTITY_CACHE private
Definition at line 16 of file entities.php.
| $SUBTYPE_CACHE = null |
Cache subtypes and related class names.
array|null $SUBTYPE_CACHE array once populated from DB, initially null private
Definition at line 25 of file entities.php.
1.6.3