From 440196f2a505d91937af3ee17ebb58d3a3702d1a Mon Sep 17 00:00:00 2001
From: marcus
Date: Thu, 26 Jun 2008 14:03:44 +0000
Subject: Refs #96: Administration: Add user (with optional admin flag)
http://trac.elgg.org/elgg/ticket/96
git-svn-id: https://code.elgg.org/elgg/trunk@1146 36083f99-b078-4883-b0ff-0f9b5a30f544
---
actions/register.php | 13 +++++++++++--
languages/en.php | 3 ++-
views/default/account/forms/register.php | 12 +++++++++++-
views/default/admin/user.php | 2 ++
views/default/admin/user_opt/adduser.php | 16 ++++++++++++++++
5 files changed, 42 insertions(+), 4 deletions(-)
create mode 100644 views/default/admin/user_opt/adduser.php
diff --git a/actions/register.php b/actions/register.php
index 88cbf0348..7f49f4924 100644
--- a/actions/register.php
+++ b/actions/register.php
@@ -19,6 +19,8 @@
$password2 = get_input('password2');
$email = get_input('email');
$name = get_input('name');
+
+ $admin = get_input('admin');
// For now, just try and register the user
if (
@@ -26,8 +28,15 @@
(trim($password)!="") &&
(strcmp($password, $password2)==0)
) &&
- (register_user($username, $password, $name, $email))
- ) {
+ ($guid = register_user($username, $password, $name, $email))
+ ) {
+ if (($guid) && ($admin))
+ {
+ admin_gatekeeper(); // Only admins can make someone an admin
+ $new_user = get_entity($guid);
+ $new_user->admin = 'yes';
+ }
+
system_message(sprintf(elgg_echo("registerok"),$CONFIG->sitename));
} else {
system_message(elgg_echo("registerbad"));
diff --git a/languages/en.php b/languages/en.php
index 7b05f1141..7b780eb27 100644
--- a/languages/en.php
+++ b/languages/en.php
@@ -145,7 +145,8 @@
'email' => "Email address",
'username' => "Username",
'password' => "Password",
- 'passwordagain' => "Password (again for verification)",
+ 'passwordagain' => "Password (again for verification)",
+ 'admin_option' => "Make this user an admin?",
/**
* Access
diff --git a/views/default/account/forms/register.php b/views/default/account/forms/register.php
index 1d9421282..2305f18d1 100644
--- a/views/default/account/forms/register.php
+++ b/views/default/account/forms/register.php
@@ -10,7 +10,10 @@
* @copyright Curverider Ltd 2008
* @link http://elgg.org/
*/
-
+
+ $admin_option = false;
+ if (($_SESSION['user']->admin) && ($vars['show_admin']))
+ $admin_option = true;
?>
@@ -21,6 +24,13 @@
+
+
+
diff --git a/views/default/admin/user.php b/views/default/admin/user.php
index 5cfc4adff..2e5445628 100644
--- a/views/default/admin/user.php
+++ b/views/default/admin/user.php
@@ -14,6 +14,8 @@
// Description of what's going on
echo "" . nl2br(elgg_echo("admin:user:description")) . "
";
+ echo elgg_view("admin/user_opt/adduser");
+
echo elgg_view("admin/user_opt/search");
if ($vars['list']) echo $vars['list'];
diff --git a/views/default/admin/user_opt/adduser.php b/views/default/admin/user_opt/adduser.php
new file mode 100644
index 000000000..2891a98da
--- /dev/null
+++ b/views/default/admin/user_opt/adduser.php
@@ -0,0 +1,16 @@
+
+
+
+
\ No newline at end of file
--
cgit v1.2.3