136 $where->guids =
$guid;
140 $select->select(
"{$select->getTableAlias()}.*");
141 $select->addClause($where);
143 return $this->db->getDataRow($select) ?: null;
163 'container_guid' => $insert->param($row->container_guid,
ELGG_VALUE_GUID),
164 'access_id' => $insert->param($row->access_id,
ELGG_VALUE_ID),
170 return $this->db->insertData($insert);
183 $update->set(
'owner_guid', $update->param($row->owner_guid,
ELGG_VALUE_GUID))
184 ->
set(
'container_guid', $update->param($row->container_guid,
ELGG_VALUE_GUID))
185 ->
set(
'access_id', $update->param($row->access_id,
ELGG_VALUE_ID))
190 return $this->db->updateData($update);
205 if (!isset($row->guid) || !isset($row->subtype)) {
210 if ($class_name && !class_exists($class_name)) {
211 $this->
getLogger()->error(
"Class '{$class_name}' was not found, missing plugin?");
217 'object' => \ElggObject::class,
218 'user' => \ElggUser::class,
219 'group' => \ElggGroup::class,
220 'site' => \ElggSite::class,
223 if (isset($map[$row->type])) {
224 $class_name = $map[$row->type];
226 throw new DomainException(
"Entity type {$row->type} is not supported.");
230 $entity =
new $class_name($row);
232 throw new ClassException(
"{$class_name} must extend " . \ElggEntity::class);
268 $entity = $this->entity_cache->load($guid);
270 (!isset($type) ||
$entity->type === $type) &&
271 (!isset($subtype) ||
$entity->subtype === $subtype)
276 $row = $this->
getRow($guid);
281 if (isset($type) && $row->type !== $type) {
285 if (isset($subtype) && $row->subtype !== $subtype) {
291 if (
$entity instanceof \stdClass) {
313 public function exists(
int $guid): bool {
316 return !empty($this->
getRow($guid));
340 $preload = array_filter(
$results,
function ($e) {
341 return $e instanceof \ElggEntity;
344 $this->metadata_cache->populateFromEntities($preload);
346 $props_to_preload = [];
348 $props_to_preload[] =
'owner_guid';
352 $props_to_preload[] =
'container_guid';
355 if (!empty($props_to_preload)) {
356 _elgg_services()->entityPreloader->preload($preload, $props_to_preload);
377 ->where($update->compare(
'guid',
'=', $entity->guid,
ELGG_VALUE_GUID));
379 $this->db->updateData($update);
402 ->where($update->compare(
'guid',
'=', $entity->guid,
ELGG_VALUE_GUID));
404 $this->db->updateData($update);
418 if (empty($guid) || $guid === $this->session_manager->getLoggedInUserGuid()) {
419 return $this->session_manager->getLoggedInUser();
424 return $this->
get(
$guid,
'user');
430 $message = $this->translator->translate(
'UserFetchFailureException', [$guid]);
451 return $this->db->updateData(
$qb);
466 return $this->db->updateData(
$qb);
481 return $this->db->updateData(
$qb);
493 if (!$entity->guid) {
499 return $this->events->triggerSequence(
'delete', $entity->type, $entity,
function(\
ElggEntity $entity) use ($recursive) {
506 $this->deleted_guids[] = $entity->guid;
517 return (
bool) $this->db->deleteData(
$qb);
530 if (!$entity->guid) {
534 if (!$this->config->trash_enabled) {
535 return $this->
delete(
$entity, $recursive);
543 return $this->events->triggerSequence(
'trash', $entity->type, $entity,
function(\
ElggEntity $entity) use ($recursive) {
544 $unban_after =
false;
545 if ($entity instanceof \
ElggUser && !$entity->isBanned()) {
551 $this->trashed_guids[] = $entity->guid;
560 if (!empty($deleter_guid)) {
568 $trashed = $this->db->updateData(
$qb);
609 'batch_inc_offset' =>
false,
614 if (in_array($e->guid, $this->deleted_guids)) {
620 if (!$e->delete(
true,
true)) {
652 'batch_inc_offset' =>
false,
657 if (in_array($e->guid, $this->trashed_guids)) {
663 if (!$e->delete(
true,
false)) {
667 $e->addRelationship($entity->guid,
'deleted_with');
687 _elgg_services()->relationshipsTable->removeAll($entity->guid,
'',
false,
'',
false);
688 _elgg_services()->relationshipsTable->removeAll($entity->guid,
'',
true,
'',
false);
692 _elgg_services()->delayedEmailQueueTable->deleteAllRecipientRows($entity->guid);
695 $dir = new \Elgg\EntityDirLocator($entity->guid);
enable(\ElggEntity $entity)
Enables entity.
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.
const ELGG_DISABLE_SYSTEM_LOG
static table(string $table)
Returns a QueryBuilder for updating data in a given table.
invalidateCache()
Invalidate cache for entity.
SessionManagerService $session_manager
deleteOwnedAnnotations(string $name=null)
Deletes all annotations owned by this object (annotations.owner_guid = $this->guid).
EntityCache $entity_cache
disable(\ElggEntity $entity)
Disables entity.
c Accompany it with the information you received as to the offer to distribute corresponding source complete source code means all the source code for all modules it plus any associated interface definition plus the scripts used to control compilation and installation of the executable as a special the source code distributed need not include anything that is normally and so on of the operating system on which the executable unless that component itself accompanies the executable If distribution of executable or object code is made by offering access to copy from a designated then offering equivalent access to copy the source code from the same place counts as distribution of the source even though third parties are not compelled to copy the source along with the object code You may not or distribute the Program except as expressly provided under this License Any attempt otherwise to sublicense or distribute the Program is void
Exception thrown if a value does not adhere to a defined valid data domain.
Database abstraction query builder.
fetch(QueryBuilder $query, array $options=[])
Returns an array of entities with optional filtering.
deleteAnnotations(string $name=null)
Deletes all annotations on this object (annotations.entity_guid = $this->guid).
trait TimeUsing
Adds methods for setting the current time (for testing)
addRelationship(int $guid_two, string $relationship)
Add a relationship between this and another entity.
deleteRelatedEntities(\ElggEntity $entity)
Deletes entities owned or contained by the entity being deletes.
static intoTable(string $table)
Returns a QueryBuilder for inserting data in a given table.
getUserForPermissionsCheck(int $guid=null)
Get a user by GUID even if the entity is hidden or disabled.
elgg_extract($key, $array, $default=null, bool $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
MetadataCache $metadata_cache
getCurrentTime($modifier= '')
Get the (cloned) time.
if($who_can_change_language=== 'nobody') elseif($who_can_change_language=== 'admin_only'&&!elgg_is_admin_logged_in()) $options
trait Loggable
Enables adding a logger.
const ELGG_IGNORE_ACCESS
elgg_call() flags
invalidateCache(int $guid)
Invalidate cache for entity.
getEntityClass(string $type, string $subtype)
Returns class name registered as a constructor for a given type and subtype.
trashRelatedEntities(\ElggEntity $entity)
Trash entities owned or contained by the entity being trashed.
A generic parent class for Class exceptions.
const ELGG_SHOW_DISABLED_ENTITIES
removeAllRelatedRiverItems()
Removes all river items related to this entity.
elgg_get_entities(array $options=[])
Fetches/counts entities or performs a calculation on their properties.
Builds queries for filtering entities by their properties in the entities table.
rowToElggStar(\stdClass $row)
Create an Elgg* object from a given entity row.
Exception indicating a user could not be looked up for a permissions check.
Volatile cache for entities.
updateTimeDeleted(\ElggEntity $entity, int $deleted=null)
Update the time_deleted column in the entities table for $entity.
compare(string $x, string $comparison, $y=null, string $type=null, bool $case_sensitive=null)
Build value comparison clause.
deleteMetadata(string $name=null)
Deletes all metadata on this object (metadata.entity_guid = $this->guid).
static fromTable(string $table)
Returns a QueryBuilder for deleting data from a given table.
updateLastAction(\ElggEntity $entity, int $posted=null)
Update the last_action column in the entities table for $entity.
isDeleted()
Is the entity marked as deleted.
restore(\ElggEntity $entity)
Restore entity.
deleteAccessCollectionMemberships()
Remove the membership of all access collections for this entity (if the entity is a user) ...
trash(\ElggEntity $entity, bool $recursive=true)
Trash an entity (not quite delete but close)
const ELGG_SHOW_DELETED_ENTITIES
const ELGG_VALUE_TIMESTAMP
elgg_delete_directory(string $directory, bool $leave_base_directory=false)
Delete a directory and all its contents.
exists(int $guid)
Does an entity exist?
getLogger()
Returns logger.
merge($parts=null, $boolean= 'AND')
Merges multiple composite expressions with a boolean.
updateRow(int $guid,\stdClass $row)
Update entity table row.
updateTimeDeleted(int $deleted=null)
Update the time_deleted column in the entities table.
__construct(Config $config, Database $db, EntityCache $entity_cache, MetadataCache $metadata_cache, EventsService $events, SessionManagerService $session_manager, Translator $translator)
Constructor.
static fromTable(string $table, string $alias=null)
Returns a QueryBuilder for selecting data from a given table.
deleteEntityProperties(\ElggEntity $entity)
Clear data from secondary tables.
_elgg_services()
Get the global service provider.
getRow(int $guid, int $user_guid=null)
Returns a database row from the entities table.
$attributes
Elgg AJAX loader.
setEntityClass(string $type, string $subtype, string $class= '')
Sets class constructor name for entities with given type and subtype.
insertRow(\stdClass $row, array $attributes=[])
Adds a new row to the entity table.
elgg_get_logged_in_user_guid()
Return the current logged in user by guid.
Entity table database service.
$guid
Reset an ElggUpgrade.