aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-06-26 14:03:44 +0000
committermarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-06-26 14:03:44 +0000
commit440196f2a505d91937af3ee17ebb58d3a3702d1a (patch)
treead86ff4eecef0405fc107f8502879dd195541e2e
parentf750cdf33e7717fdb4fc6caf72361e76385fd6ae (diff)
downloadelgg-440196f2a505d91937af3ee17ebb58d3a3702d1a.tar.gz
elgg-440196f2a505d91937af3ee17ebb58d3a3702d1a.tar.bz2
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
-rw-r--r--actions/register.php13
-rw-r--r--languages/en.php3
-rw-r--r--views/default/account/forms/register.php12
-rw-r--r--views/default/admin/user.php2
-rw-r--r--views/default/admin/user_opt/adduser.php16
5 files changed, 42 insertions, 4 deletions
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;
?>
<h2><?php echo elgg_echo('register'); ?></h2>
@@ -21,6 +24,13 @@
<label><?php echo elgg_echo('username'); ?><br /><input name="username" type="text" class="general-textarea" /></label><br />
<label><?php echo elgg_echo('password'); ?><br /><input name="password" type="password" class="general-textarea" /></label><br />
<label><?php echo elgg_echo('passwordagain'); ?><br /><input name="password2" type="password" class="general-textarea" /></label><br />
+ <?php
+ if ($admin_option) {
+?>
+ <label><?php echo elgg_echo('admin_option'); ?><br /><input type="checkbox" name="admin" /></label>
+<?php
+ }
+ ?>
<input type="submit" name="submit" class="submit_button" value="<?php echo elgg_echo('register'); ?>" /></p>
<input type="hidden" name="action" value="register" />
</form>
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 "<p>" . nl2br(elgg_echo("admin:user:description")) . "</p>";
+ 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 @@
+<?php
+ /**
+ * Add a user.
+ * Form to add a new user.
+ *
+ * @package Elgg
+ * @subpackage Core
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Marcus Povey
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.org/
+ */
+?>
+
+
+<?php echo elgg_view('account/forms/register'); ?> \ No newline at end of file