From 0b2a1d2d617456dab58cb9928d0f61dac56fcaba Mon Sep 17 00:00:00 2001 From: marcus Date: Wed, 13 Aug 2008 12:14:40 +0000 Subject: Added a reason for disabled objects. git-svn-id: https://code.elgg.org/elgg/trunk@1891 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/entities.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/engine/lib/entities.php b/engine/lib/entities.php index fe43832ff..29c347690 100644 --- a/engine/lib/entities.php +++ b/engine/lib/entities.php @@ -657,10 +657,12 @@ /** * Disable this entity. + * + * @param string $reason Optional reason */ - public function disable() + public function disable($reason = "") { - return disable_entity($this->get('guid')); + return disable_entity($this->get('guid'), $reason); } /** @@ -1454,17 +1456,23 @@ /** * Disable an entity but not delete it. * - * @param int $guid + * @param int $guid The guid + * @param string $reason Optional reason */ - function disable_entity($guid) + function disable_entity($guid, $reason = "") { global $CONFIG; $guid = (int)$guid; + $reason = sanitise_string($reason); + if ($entity = get_entity($guid)) { if (trigger_elgg_event('delete',$entity->type,$entity)) { if ($entity->canEdit()) { + if ($reason) + $entity->disable_reason = $reason; + $res = update_data("UPDATE {$CONFIG->dbprefix}entities set enabled='no' where guid={$guid}"); return $res; -- cgit v1.2.3