diff options
-rw-r--r-- | actions/admin/user/ban.php | 15 | ||||
-rw-r--r-- | actions/admin/user/delete.php | 5 | ||||
-rw-r--r-- | engine/lib/entities.php | 31 |
3 files changed, 45 insertions, 6 deletions
diff --git a/actions/admin/user/ban.php b/actions/admin/user/ban.php index 100854062..256803bf5 100644 --- a/actions/admin/user/ban.php +++ b/actions/admin/user/ban.php @@ -10,6 +10,8 @@ * @link http://elgg.org/ */ + require_once("../../../engine/start.php"); + // block non-admin users admin_gatekeeper(); @@ -19,13 +21,14 @@ if ( ($obj instanceof ElggUser) && ($obj->canEdit())) { - - // TODO: Ban user - throw new NotImplementedException("WRITEME"); - - - + if ($obj->disable()) + system_message(elgg_echo('admin:user:ban:yes')); + else + system_message(elgg_echo('admin:user:ban:no')); } else system_message(elgg_echo('admin:user:ban:no')); + + header("Location: {$CONFIG->wwwroot}admin/user/"); + exit; ?>
\ No newline at end of file diff --git a/actions/admin/user/delete.php b/actions/admin/user/delete.php index c449bfe57..d3a3fd90a 100644 --- a/actions/admin/user/delete.php +++ b/actions/admin/user/delete.php @@ -10,6 +10,8 @@ * @link http://elgg.org/ */ + require_once("../../../engine/start.php"); + // block non-admin users admin_gatekeeper(); @@ -26,4 +28,7 @@ } else system_message(elgg_echo('admin:user:delete:no')); + + header("Location: {$CONFIG->wwwroot}admin/user/"); + exit; ?>
\ No newline at end of file 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 |