128 $this->table = $this->db->prefix .
'entities';
196 $where->guids = (int)
$guid;
200 $select->select(
'e.*');
201 $select->addClause($where);
203 return $this->db->getDataRow($select);
220 INSERT INTO {$this->db->prefix}entities 221 (type, subtype, owner_guid, container_guid, access_id, time_created, time_updated, last_action) 223 (:type, :subtype, :owner_guid, :container_guid, :access_id, :time_created, :time_updated, :last_action) 226 return $this->db->insertData($sql, [
227 ':type' => $row->type,
228 ':subtype' => $row->subtype,
229 ':owner_guid' => $row->owner_guid,
230 ':container_guid' => $row->container_guid,
231 ':access_id' => $row->access_id,
232 ':time_created' => $row->time_created,
233 ':time_updated' => $row->time_updated,
234 ':last_action' => $row->last_action,
248 UPDATE {$this->db->prefix}entities 249 SET owner_guid = :owner_guid, 250 access_id = :access_id, 251 container_guid = :container_guid, 252 time_created = :time_created, 253 time_updated = :time_updated 258 ':owner_guid' => $row->owner_guid,
259 ':access_id' => $row->access_id,
260 ':container_guid' => $row->container_guid,
261 ':time_created' => $row->time_created,
262 ':time_updated' => $row->time_updated,
266 return $this->db->updateData($sql,
false,
$params);
284 if (!isset($row->guid) || !isset($row->subtype)) {
289 if ($class_name && !class_exists($class_name)) {
290 $this->logger->error(
"Class '$class_name' was not found, missing plugin?");
302 if (isset($map[$row->type])) {
303 $class_name = $map[$row->type];
309 $entity =
new $class_name($row);
353 $ia = $this->session->setIgnoreAccess(
true);
354 $ha = $this->session->getDisabledEntityVisibility();
355 $this->session->setDisabledEntityVisibility(
true);
360 $this->session->setDisabledEntityVisibility($ha);
361 $this->session->setIgnoreAccess($ia);
399 if ($type && $row->type != $type) {
403 if ($subtype && $row->subtype !== $subtype) {
433 $ia = $this->session->setIgnoreAccess(
true);
434 $show_hidden = $this->session->setDisabledEntityVisibility(
true);
438 $this->session->setIgnoreAccess($ia);
439 $this->session->setDisabledEntityVisibility($show_hidden);
455 $old_access_status = $this->session->getDisabledEntityVisibility();
456 $this->session->setDisabledEntityVisibility(
true);
464 $this->session->setDisabledEntityVisibility($old_access_status);
484 $results = $this->db->getData($query,
$options[
'callback']);
486 if (empty($results)) {
490 $preload = array_filter($results,
function ($e) {
495 $this->metadata_cache->populateFromEntities($preload);
498 $this->private_settings_cache->populateFromEntities($preload);
501 $props_to_preload = [];
503 $props_to_preload[] =
'owner_guid';
506 $props_to_preload[] =
'container_guid';
509 if ($props_to_preload) {
510 _elgg_services()->entityPreloader->preload($preload, $props_to_preload);
534 UPDATE {$this->db->prefix}entities 535 SET last_action = :last_action 540 ':last_action' => (int)
$posted,
541 ':guid' => (
int) $entity->guid,
560 return $this->session->getLoggedInUser();
564 $ia = $this->session->setIgnoreAccess(
true);
565 $show_hidden = $this->session->setDisabledEntityVisibility(
true);
569 $this->metadata_cache->populateFromEntities([
$user->guid]);
572 $this->session->setIgnoreAccess($ia);
573 $this->session->setDisabledEntityVisibility($show_hidden);
578 $message = $this->translator->translate(
'UserFetchFailureException', [
$guid]);
600 if (!$this->events->trigger(
'disable', $entity->type, $entity)) {
609 $this->db->updateData($qb,
true);
626 $guid = $entity->guid;
631 if (!
_elgg_services()->events->triggerBefore(
'delete', $entity->type, $entity)) {
637 if (!
_elgg_services()->events->triggerDeprecated(
'delete', $entity->type, $entity)) {
655 $this->db->deleteData($qb);
657 _elgg_services()->events->triggerAfter(
'delete', $entity->type, $entity);
672 $entity_disable_override = $this->session->getDisabledEntityVisibility();
673 $this->session->setDisabledEntityVisibility(
true);
674 $ia = $this->session->setIgnoreAccess(
true);
677 'wheres' =>
function (
QueryBuilder $qb, $main_alias) use ($entity) {
692 $batch->setIncrementOffset(
false);
696 $this->
delete($e,
true);
699 $this->session->setDisabledEntityVisibility($entity_disable_override);
700 $this->session->setIgnoreAccess($ia);
722 $dir = new \Elgg\EntityDirLocator($entity->guid);
elgg_call(int $flags, Closure $closure)
Calls a callable autowiring the arguments using public DI services and applying logic based on flags...
deleteOwnedAccessCollections()
Remove all access collections owned by this entity.
disableEntities(ElggEntity $entity)
Disables all entities owned and contained by a user (or another entity)
removeAllPrivateSettings()
Removes all private settings.
enable($guid, $recursive=true)
Enable an entity.
$params
Saves global plugin settings.
rowToElggStar(stdClass $row)
Create an Elgg* object from a given entity row.
__construct(Config $config, Database $db, EntityCache $entity_cache, MetadataCache $metadata_cache, PrivateSettingsCache $private_settings_cache, EventsService $events, ElggSession $session, Translator $translator, LoggerInterface $logger)
Constructor.
getRow($guid, $user_guid=null)
Returns a database row from the entities table.
static getEntityTypes()
Get the core entity types.
getEntityClass($type, $subtype)
Returns class name registered as a constructor for a given type and subtype.
deleteMetadata($name=null)
Deletes all metadata on this object (metadata.entity_guid = $this->guid).
static table($table, $alias=null)
{}
deleteAnnotations($name=null)
Deletes all annotations on this object (annotations.entity_guid = $this->guid).
invalidateCache()
Invalidate cache for entity.
const ELGG_VALUE_INTEGER
Value types.
deleteOwnedAnnotations($name=null)
Deletes all annotations owned by this object (annotations.owner_guid = $this->guid).
Database abstraction query builder.
getCurrentTime($modifier= '')
Get the (cloned) time.
fetch(QueryBuilder $query, array $options=[])
Returns an array of entities with optional filtering.
$guid
Removes an admin notice.
insertRow(stdClass $row, array $attributes=[])
Adds a new row to the entity table.
updateLastAction(ElggEntity $entity, $posted=null)
Update the last_action column in the entities table for $guid.
canEdit($user_guid=0)
Can a user edit this entity?
elgg_instanceof($entity, $type=null, $subtype=null)
Checks if $entity is an and optionally for type and subtype.
elgg_get_ignore_access()
Get current ignore access setting.
$user_guid
Validate a user.
const ELGG_IGNORE_ACCESS
elgg_call() flags
deleteRelatedEntities(ElggEntity $entity)
Deletes entities owned or contained by the entity being deletes.
deleteRelationships($relationship=null)
Remove all relationships to and from this entity.
const ELGG_SHOW_DISABLED_ENTITIES
removeAllRelatedRiverItems()
Removes all river items related to this entity.
deleteEntityProperties(ElggEntity $entity)
Clear data from secondary tables.
invalidateCache($guid)
Invalidate cache for entity.
Builds queries for filtering entities by their properties in the entities table.
In memory cache of known private settings values stored by entity.
Volatile cache for entities.
Exception indicating a user could not be looked up for a permissions check.
compare($x, $comparison, $y=null, $type=null, $case_sensitive=null)
Build value comparison clause.
updateRow($guid, stdClass $row)
Update entity table row.
deleteAccessCollectionMemberships()
Remove the membership of all access collections for this entity (if the entity is a user) ...
exists($guid)
Does an entity exist?
elgg_extract($key, $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
static fromTable($table, $alias=null)
{}
_elgg_config()
Get the Elgg config service.
merge($parts=null, $boolean= 'AND')
Merges multiple composite expressions with a boolean.
setEntityClass($type, $subtype, $class= '')
Sets class constructor name for entities with given type and subtype.
getFromCache($guid)
Get an entity from the in-memory or memcache caches.
has_access_to_entity($entity, $user=null)
Can a user access an entity.
_elgg_services()
Get the global service provider.
trait TimeUsing
Adds methods for setting the current time (for testing)
delete_directory($directory)
Delete a directory and all its contents.
static fromTable($table, $alias=null)
{}
get_entity($guid)
Loads and returns an entity object from a guid.
getUserForPermissionsCheck($guid=0)
Get a user by GUID even if the entity is hidden or disabled.