aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-06-18 18:33:34 +0000
committermarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-06-18 18:33:34 +0000
commita33fdc7d15a9c8edd3fcff736a23857f4b1e0885 (patch)
tree707bb6f2b2a1f319d9dc78e6ac25f3c5b70843c4
parent9d4db97e2750a4fb0fecb839f5d1939433654c3f (diff)
downloadelgg-a33fdc7d15a9c8edd3fcff736a23857f4b1e0885.tar.gz
elgg-a33fdc7d15a9c8edd3fcff736a23857f4b1e0885.tar.bz2
Fixes #15: Ban user functionality
git-svn-id: https://code.elgg.org/elgg/trunk@981 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r--actions/admin/user/ban.php15
-rw-r--r--actions/admin/user/delete.php5
-rw-r--r--engine/lib/entities.php31
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