Elgg
Version 1.11
|
Go to the source code of this file.
Namespaces | |
Elgg\Core | |
Activate a plugin or plugins. | |
Functions | |
_elgg_disable_caching_for_entity ($guid) | |
Remove this entity from the entity cache and make sure it is not re-added. More... | |
_elgg_enable_caching_for_entity ($guid) | |
Allow this entity to be stored in the entity cache. More... | |
_elgg_invalidate_cache_for_entity ($guid) | |
Invalidate this class's entry in the cache. More... | |
_elgg_cache_entity (\ElggEntity $entity) | |
Cache an entity. More... | |
_elgg_retrieve_cached_entity ($guid) | |
Retrieve a entity from the cache. More... | |
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... | |
_elgg_retrieve_cached_subtype ($type, $subtype) | |
Retrieve subtype from the cache. More... | |
_elgg_populate_subtype_cache () | |
Fetch all suptypes from DB to local cache. 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_fetch_entities_from_sql ($sql,\ElggBatch $batch=null) | |
Return entities from an SQL query generated by elgg_get_entities. More... | |
_elgg_get_entity_type_subtype_where_sql ($table, $types, $subtypes, $pairs) | |
Returns SQL where clause for type and subtype on main entity table. 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 | |
global | $ENTITY_CACHE = array() |
Cache entities in memory once loaded. More... | |
global | $ENTITY_CACHE_DISABLED_GUIDS = array() |
GUIDs of entities banned from the entity cache (during this request) More... | |
return | function (\Elgg\EventsService $events,\Elgg\HooksRegistrationService $hooks) |
_elgg_cache_entity | ( | \ElggEntity | $entity | ) |
Cache an entity.
Stores an entity in $ENTITY_CACHE;
\ElggEntity | $entity | Entity to cache |
Definition at line 92 of file entities.php.
_elgg_disable_caching_for_entity | ( | $guid | ) |
Remove this entity from the entity cache and make sure it is not re-added.
int | $guid | The entity guid |
private
Definition at line 35 of file entities.php.
_elgg_enable_caching_for_entity | ( | $guid | ) |
Allow this entity to be stored in the entity cache.
int | $guid | The entity guid |
private
Definition at line 49 of file entities.php.
_elgg_entities_init | ( | ) |
Entities init function; establishes the default entity page handler.
Definition at line 988 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 967 of file entities.php.
_elgg_fetch_entities_from_sql | ( | $sql, | |
\ElggBatch | $batch = null |
||
) |
Return entities from an SQL query generated by elgg_get_entities.
string | $sql | |
\ElggBatch | $batch |
private
LogicException |
Definition at line 504 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 670 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 553 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 520 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 535 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 63 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 125 of file entities.php.
_elgg_retrieve_cached_subtype | ( | $type, | |
$subtype | |||
) |
Retrieve subtype from the cache.
string | $type | |
string | $subtype |
private
Definition at line 182 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 248 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 299 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 412 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 399 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 (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.
Definition at line 490 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 658 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 922 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' or 'gallery' 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 586 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 851 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 711 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 746 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 371 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 382 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 352 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 691 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 784 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 210 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 224 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 169 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 157 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 812 of file entities.php.
remove_subtype | ( | $type, | |
$subtype | |||
) |
Removes a registered type, subtype, and classname.
string | $type | Type |
string | $subtype | Subtype |
Definition at line 266 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 953 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 279 of file entities.php.
$ENTITY_CACHE = array() |
Cache entities in memory once loaded.
[] $ENTITY_CACHE private
Definition at line 15 of file entities.php.
$ENTITY_CACHE_DISABLED_GUIDS = array() |
GUIDs of entities banned from the entity cache (during this request)
array $ENTITY_CACHE_DISABLED_GUIDS private
Definition at line 24 of file entities.php.
return function(\Elgg\EventsService $events,\Elgg\HooksRegistrationService $hooks) |
Definition at line 992 of file entities.php.