13 use Elgg\Traits\TimeUsing;
68 $singulars = [
'tag_name'];
81 return "{$main_alias}.value AS tag";
84 return "COUNT({$main_alias}.id) AS total";
101 return "{$main_alias}.value";
118 $options[
'callback'] =
function($row) {
121 $result->total = (int) $row->total;
144 $qb->addClause($where);
146 $row = $this->db->getDataRow(
$qb);
147 return $row ? new \ElggMetadata($row) :
null;
162 if (!$this->events->trigger(
'delete',
'metadata',
$metadata)) {
172 $metadata->getEntity()?->invalidateCache();
192 elgg_log(
'Metadata must have a value and entity guid', \Psr\Log\LogLevel::ERROR);
196 if (!$this->entityTable->exists(
$metadata->entity_guid)) {
197 elgg_log(
"Can't create metadata on a non-existing entity_guid", \Psr\Log\LogLevel::ERROR);
202 elgg_log(
'To set multiple metadata values use ElggEntity::setMetadata', \Psr\Log\LogLevel::ERROR);
212 if (!$allow_multiple) {
216 throw new LogicException(
"
217 Multiple '{$metadata->name}' metadata values exist for entity [guid: {$metadata->entity_guid}].
218 Use ElggEntity::setMetadata()
231 if (!$this->events->triggerBefore(
'create',
'metadata',
$metadata)) {
246 $id = $this->db->insertData(
$qb);
255 if (!$this->events->trigger(
'create',
'metadata',
$metadata)) {
261 $metadata->getEntity()?->invalidateCache();
263 $this->events->triggerAfter(
'create',
'metadata',
$metadata);
276 if (!$this->entityTable->exists(
$metadata->entity_guid)) {
277 elgg_log(
"Can't update metadata to a non-existing entity_guid", \Psr\Log\LogLevel::ERROR);
281 if (!$this->events->triggerBefore(
'update',
'metadata',
$metadata)) {
297 $metadata->getEntity()?->invalidateCache();
299 $this->events->trigger(
'update',
'metadata',
$metadata);
300 $this->events->triggerAfter(
'update',
'metadata',
$metadata);
317 $options[
'metastring_type'] =
'metadata';
335 $qb =
Select::fromTable(self::TABLE_NAME);
338 ->orderBy(
'entity_guid',
'asc')
339 ->addOrderBy(
'time_created',
'asc')
340 ->addOrderBy(
'id',
'asc');
342 return $this->db->getData(
$qb,
function ($row) {
343 return new \ElggMetadata($row);
365 'metadata_name',
'metadata_names',
366 'metadata_value',
'metadata_values',
386 $this->access_cache->clear();
387 $this->metadata_cache->clear();
389 $this->entityTable->invalidateCache(
$options[
'guid']);
394 $options[
'batch_inc_offset'] =
false;
411 return $success ===
$count;
423 $cached_metadata = $this->metadata_cache->load(
$entity_guid);
424 if ($cached_metadata !==
null) {
426 foreach ($cached_metadata as $md) {
427 if ($md->name !==
$name) {
434 $qb = Select::fromTable(self::TABLE_NAME);
439 $callback =
function (\stdClass $row) {
440 return (
int) $row->id;
443 $ids = $this->db->getData(
$qb, $callback);
450 if (is_array($ids) && count($ids) === 1) {
451 return array_shift($ids);
getCurrentTime($modifier='')
Get the (cloned) time.
if(! $user||! $user->canDelete()) $name
$id
Generic annotation delete action.
$guids
Activates all specified installed and inactive plugins.
Extends QueryBuilder with ORDER BY clauses.
static fromTable(string $table)
Returns a QueryBuilder for deleting data from a given table.
Entity table database service.
static intoTable(string $table)
Returns a QueryBuilder for inserting data in a given table.
Database abstraction query builder.
Query builder for fetching data from the database.
static fromTable(string $table, ?string $alias=null)
Returns a QueryBuilder for selecting data from a given table.
static table(string $table)
Returns a QueryBuilder for updating data in a given table.
Exception thrown if an argument is not of the expected type.
Exception that represents error in the program logic.
const ELGG_VALUE_INTEGER
Value types.
if($who_can_change_language==='nobody') elseif($who_can_change_language==='admin_only' &&!elgg_is_admin_logged_in()) $options
if(! $user instanceof \ElggUser) $time_created
foreach($recommendedExtensions as $extension) if(empty(ini_get('session.gc_probability'))||empty(ini_get('session.gc_divisor'))) $db
elgg_log($message, $level=\Psr\Log\LogLevel::NOTICE)
Log a message.
elgg_extract($key, $array, $default=null, bool $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
if($container instanceof ElggGroup && $container->guid !=elgg_get_page_owner_guid()) $key
if(parse_url(elgg_get_site_url(), PHP_URL_PATH) !=='/') if(file_exists(elgg_get_root_path() . 'robots.txt'))
Set robots.txt.