15 use Elgg\Traits\Loggable;
16 use Elgg\Traits\TimeUsing;
94 if ($class_name && !class_exists($class_name)) {
95 $this->getLogger()->error(
"Class '{$class_name}' was not found");
99 if (empty($class_name)) {
101 'object' => \ElggObject::class,
102 'user' => \ElggUser::class,
103 'group' => \ElggGroup::class,
104 'site' => \ElggSite::class,
106 if (isset($map[
$type])) {
107 $class_name = $map[
$type];
111 $parents = class_parents($class_name);
112 if ($parents ===
false || !isset($parents[\ElggEntity::class])) {
113 $this->getLogger()->error(
"{$class_name} must extend " . \ElggEntity::class);
140 $where->guids =
$guid;
143 $select = Select::fromTable(self::TABLE_NAME, self::DEFAULT_JOIN_ALIAS);
144 $select->select(
"{$select->getTableAlias()}.*");
145 $select->addClause($where);
147 return $this->db->getDataRow($select) ?:
null;
162 $insert =
Insert::intoTable(self::TABLE_NAME);
167 'container_guid' => $insert->param($row->container_guid,
ELGG_VALUE_GUID),
168 'access_id' => $insert->param($row->access_id,
ELGG_VALUE_ID),
174 return $this->db->insertData($insert);
186 $update =
Update::table(self::TABLE_NAME);
187 $update->set(
'owner_guid', $update->param($row->owner_guid,
ELGG_VALUE_GUID))
188 ->set(
'container_guid', $update->param($row->container_guid,
ELGG_VALUE_GUID))
189 ->set(
'access_id', $update->param($row->access_id,
ELGG_VALUE_ID))
194 return $this->db->updateData($update);
207 if (!isset($row->type) || !isset($row->subtype)) {
211 $class_name = $this->getEntityClass($row->type, $row->subtype);
216 return new $class_name($row);
257 $row = $this->getRow(
$guid);
270 $entity = $this->rowToElggStar($row);
293 return !empty($this->getRow(
$guid));
317 $preload = array_filter(
$results,
function ($e) {
318 return $e instanceof \ElggEntity;
321 $this->metadata_cache->populateFromEntities($preload);
323 $props_to_preload = [];
325 $props_to_preload[] =
'owner_guid';
329 $props_to_preload[] =
'container_guid';
332 if (!empty($props_to_preload)) {
333 _elgg_services()->entityPreloader->preload($preload, $props_to_preload);
349 $deleted = $this->getCurrentTime()->getTimestamp();
352 $update = Update::table(self::TABLE_NAME);
356 $this->db->updateData($update);
374 $posted = $this->getCurrentTime()->getTimestamp();
377 $update = Update::table(self::TABLE_NAME);
381 $this->db->updateData($update);
395 if (empty(
$guid) ||
$guid === $this->session_manager->getLoggedInUserGuid()) {
396 return $this->session_manager->getLoggedInUser();
401 return $this->
get(
$guid,
'user');
407 $message = $this->translator->translate(
'UserFetchFailureException', [
$guid]);
428 return $this->db->updateData(
$qb);
443 return $this->db->updateData(
$qb);
458 return $this->db->updateData(
$qb);
483 $this->deleted_guids[] =
$entity->guid;
486 $this->deleteRelatedEntities(
$entity);
489 $this->deleteEntityProperties(
$entity);
491 $qb = Delete::fromTable(self::TABLE_NAME);
494 return (
bool) $this->db->deleteData(
$qb);
511 if (!$this->config->trash_enabled) {
512 return $this->
delete(
$entity, $recursive);
521 $unban_after =
false;
528 $this->trashed_guids[] =
$entity->guid;
533 $this->trashRelatedEntities(
$entity);
537 if (!empty($deleter_guid)) {
538 $entity->addRelationship($deleter_guid,
'deleted_by');
541 $qb = Update::table(self::TABLE_NAME);
545 $trashed = $this->db->updateData(
$qb);
586 'batch_inc_offset' =>
false,
591 if (in_array($e->guid, $this->deleted_guids)) {
597 if (!$e->delete(
true,
true)) {
629 'batch_inc_offset' =>
false,
634 if (in_array($e->guid, $this->trashed_guids)) {
640 if (!$e->delete(
true,
false)) {
644 $e->addRelationship(
$entity->guid,
'deleted_with');
659 $entity->removeAllRelatedRiverItems();
660 $entity->deleteOwnedAccessCollections();
661 $entity->deleteAccessCollectionMemberships();
666 $entity->deleteOwnedAnnotations();
672 $dir = new \Elgg\EntityDirLocator(
$entity->guid);
$guid
Reset an ElggUpgrade.
return[ 'admin/delete_admin_notices'=>['access'=> 'admin'], 'admin/menu/save'=>['access'=> 'admin'], 'admin/plugins/activate'=>['access'=> 'admin'], 'admin/plugins/activate_all'=>['access'=> 'admin'], 'admin/plugins/deactivate'=>['access'=> 'admin'], 'admin/plugins/deactivate_all'=>['access'=> 'admin'], 'admin/plugins/set_priority'=>['access'=> 'admin'], 'admin/security/security_txt'=>['access'=> 'admin'], 'admin/security/settings'=>['access'=> 'admin'], 'admin/security/regenerate_site_secret'=>['access'=> 'admin'], 'admin/site/cache/invalidate'=>['access'=> 'admin'], 'admin/site/flush_cache'=>['access'=> 'admin'], 'admin/site/icons'=>['access'=> 'admin'], 'admin/site/set_maintenance_mode'=>['access'=> 'admin'], 'admin/site/set_robots'=>['access'=> 'admin'], 'admin/site/theme'=>['access'=> 'admin'], 'admin/site/unlock_upgrade'=>['access'=> 'admin'], 'admin/site/settings'=>['access'=> 'admin'], 'admin/upgrade'=>['access'=> 'admin'], 'admin/upgrade/reset'=>['access'=> 'admin'], 'admin/user/ban'=>['access'=> 'admin'], 'admin/user/bulk/ban'=>['access'=> 'admin'], 'admin/user/bulk/delete'=>['access'=> 'admin'], 'admin/user/bulk/unban'=>['access'=> 'admin'], 'admin/user/bulk/validate'=>['access'=> 'admin'], 'admin/user/change_email'=>['access'=> 'admin'], 'admin/user/delete'=>['access'=> 'admin'], 'admin/user/login_as'=>['access'=> 'admin'], 'admin/user/logout_as'=>[], 'admin/user/makeadmin'=>['access'=> 'admin'], 'admin/user/resetpassword'=>['access'=> 'admin'], 'admin/user/removeadmin'=>['access'=> 'admin'], 'admin/user/unban'=>['access'=> 'admin'], 'admin/user/validate'=>['access'=> 'admin'], 'annotation/delete'=>[], 'avatar/upload'=>[], 'comment/save'=>[], 'diagnostics/download'=>['access'=> 'admin'], 'entity/chooserestoredestination'=>[], 'entity/delete'=>[], 'entity/mute'=>[], 'entity/restore'=>[], 'entity/subscribe'=>[], 'entity/trash'=>[], 'entity/unmute'=>[], 'entity/unsubscribe'=>[], 'login'=>['access'=> 'logged_out'], 'logout'=>[], 'notifications/mute'=>['access'=> 'public'], 'plugins/settings/remove'=>['access'=> 'admin'], 'plugins/settings/save'=>['access'=> 'admin'], 'plugins/usersettings/save'=>[], 'register'=>['access'=> 'logged_out', 'middleware'=>[\Elgg\Router\Middleware\RegistrationAllowedGatekeeper::class,],], 'river/delete'=>[], 'settings/notifications'=>[], 'settings/notifications/subscriptions'=>[], 'user/changepassword'=>['access'=> 'public'], 'user/requestnewpassword'=>['access'=> 'public'], 'useradd'=>['access'=> 'admin'], 'usersettings/save'=>[], 'widgets/add'=>[], 'widgets/delete'=>[], 'widgets/move'=>[], 'widgets/save'=>[],]
$attributes
Elgg AJAX loader.
Volatile cache for entities.
Builds queries for filtering entities by their properties in the entities table.
Entity table database service.
updateRow(int $guid, \stdClass $row)
Update entity table row.
fetch(QueryBuilder $query, array $options=[])
Returns an array of entities with optional filtering.
insertRow(\stdClass $row, array $attributes=[])
Adds a new row to the entity table.
invalidateCache(int $guid)
Invalidate cache for entity.
getUserForPermissionsCheck(?int $guid=null)
Get a user by GUID even if the entity is hidden or disabled.
setEntityClass(string $type, string $subtype, string $class='')
Sets class constructor name for entities with given type and subtype.
deleteRelatedEntities(\ElggEntity $entity)
Deletes entities owned or contained by the entity being deletes.
getEntityClass(string $type, string $subtype)
Returns class name registered as a constructor for a given type and subtype The classname is also val...
__construct(protected Config $config, protected Database $db, protected EntityCache $entity_cache, protected MetadataCache $metadata_cache, protected EventsService $events, protected SessionManagerService $session_manager, protected Translator $translator)
Constructor.
exists(int $guid)
Does an entity exist?
updateLastAction(\ElggEntity $entity, ?int $posted=null)
Update the last_action column in the entities table for $entity.
rowToElggStar(\stdClass $row)
Create an Elgg* object from a given entity row.
trash(\ElggEntity $entity, bool $recursive=true)
Trash an entity (not quite delete but close)
enable(\ElggEntity $entity)
Enables entity.
getRow(int $guid, ?int $user_guid=null)
Returns a database row from the entities table.
restore(\ElggEntity $entity)
Restore entity.
deleteEntityProperties(\ElggEntity $entity)
Clear data from secondary tables.
updateTimeDeleted(\ElggEntity $entity, ?int $deleted=null)
Update the time_deleted column in the entities table for $entity.
trashRelatedEntities(\ElggEntity $entity)
Trash entities owned or contained by the entity being trashed.
disable(\ElggEntity $entity)
Disables entity.
Query builder for inserting data into the database.
Database abstraction query builder.
Query builder for updating data in the database.
Exception indicating a user could not be looked up for a permissions check.
Exception thrown if a value does not adhere to a defined valid data domain.
const ELGG_IGNORE_ACCESS
elgg_call() flags
const ELGG_SHOW_DISABLED_ENTITIES
const ELGG_DISABLE_SYSTEM_LOG
const ELGG_VALUE_TIMESTAMP
const ELGG_SHOW_DELETED_ENTITIES
if($who_can_change_language==='nobody') elseif($who_can_change_language==='admin_only' &&!elgg_is_admin_logged_in()) $options
$config
Advanced site settings, debugging section.
foreach($recommendedExtensions as $extension) if(empty(ini_get('session.gc_probability'))||empty(ini_get('session.gc_divisor'))) $db
_elgg_services()
Get the global service provider.
elgg_call(int $flags, Closure $closure)
Calls a callable autowiring the arguments using public DI services and applying logic based on flags.
elgg_extract($key, $array, $default=null, bool $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
elgg_get_entities(array $options=[])
Fetches/counts entities or performs a calculation on their properties.
elgg_delete_directory(string $directory, bool $leave_base_directory=false)
Delete a directory and all its contents.
if(parse_url(elgg_get_site_url(), PHP_URL_PATH) !=='/') if(file_exists(elgg_get_root_path() . 'robots.txt'))
Set robots.txt.
elgg_get_logged_in_user_guid()
Return the current logged in user by guid.