diff options
Diffstat (limited to 'engine')
-rw-r--r-- | engine/lib/entities.php | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/engine/lib/entities.php b/engine/lib/entities.php index c53161e7f..96a622227 100644 --- a/engine/lib/entities.php +++ b/engine/lib/entities.php @@ -473,6 +473,14 @@ } /** + * Disable this entity. + */ + public function disable() + { + return disable_entity($this->get('guid')); + } + + /** * Delete this entity. */ public function delete() @@ -1096,6 +1104,29 @@ }
/** + * Disable an entity but not delete it. + * + * @param int $guid + */ + function disable_entity($guid) + { + global $CONFIG; + + $guid = (int)$guid; + if ($entity = get_entity($guid)) { + if (trigger_elgg_event('delete',$entity->type,$entity)) { + if ($entity->canEdit()) { + + $res = update_data("UPDATE {$CONFIG->dbprefix}entities set enabled='no' where guid={$guid}"); + + return $res; + } + } + } + return false; + } + + /** * Delete a given entity. * * @param int $guid |