aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--actions/useradd.php49
-rw-r--r--engine/lib/users.php3
-rw-r--r--languages/en.php7
-rw-r--r--views/default/account/forms/useradd.php35
-rw-r--r--views/default/admin/user_opt/adduser.php8
5 files changed, 98 insertions, 4 deletions
diff --git a/actions/useradd.php b/actions/useradd.php
new file mode 100644
index 000000000..fd89f0b5d
--- /dev/null
+++ b/actions/useradd.php
@@ -0,0 +1,49 @@
+<?php
+
+ /**
+ * Elgg add action
+ *
+ * @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/
+ */
+
+ require_once(dirname(dirname(__FILE__)) . "/engine/start.php");
+
+ admin_gatekeeper(); // Only admins can make someone an admin
+
+ // Get variables
+ $username = get_input('username');
+ $password = get_input('password');
+ $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 (
+ (
+ (trim($password)!="") &&
+ (strcmp($password, $password2)==0)
+ ) &&
+ ($guid = register_user($username, $password, $name, $email))
+ ) {
+ if (($guid) && ($admin))
+ {
+
+ $new_user = get_entity($guid);
+ $new_user->admin = 'yes';
+ }
+
+ system_message(sprintf(elgg_echo("adduser:ok"),$CONFIG->sitename));
+ } else {
+ system_message(elgg_echo("adduser:bad"));
+ }
+
+ forward($_SERVER['HTTP_REFERER']);
+ exit;
+?> \ No newline at end of file
diff --git a/engine/lib/users.php b/engine/lib/users.php
index 54b79b8e2..bc308ff82 100644
--- a/engine/lib/users.php
+++ b/engine/lib/users.php
@@ -943,7 +943,8 @@
register_page_handler('friends','friends_page_handler');
register_page_handler('friendsof','friends_of_page_handler');
register_action("register",true);
- register_action("friends/add");
+ register_action("useradd",true);
+ register_action("friends/add");
register_action("friends/remove");
register_action("email/confirm");
diff --git a/languages/en.php b/languages/en.php
index df4b3b0c5..49b2a6d9d 100644
--- a/languages/en.php
+++ b/languages/en.php
@@ -240,6 +240,10 @@
'registerok' => "You have successfully registered for %s.",
'registerbad' => "Your registration was unsuccessful. The username may already exist, or your passwords might not match.",
+ 'adduser' => "Add User",
+ 'adduser:ok' => "You have successfully added a new user.",
+ 'adduser:bad' => "The new user could not be created.",
+
'user:set:name' => "Account name settings",
'user:name:label' => "Your name",
'user:name:success' => "Successfully changed your name on the system.",
@@ -269,7 +273,8 @@
'admin:description' => "The admin panel allows you to control all aspects of the system, from user management to how plugins behave. Choose an option below to get started.",
'admin:user' => "User Administration",
- 'admin:user:description' => "This admin panel allows you to control user settings for your site. Choose an option below to get started.",
+ 'admin:user:description' => "This admin panel allows you to control user settings for your site. Choose an option below to get started.",
+ 'admin:user:adduser:label' => "Click here to add a new user...",
'admin:user:opt:linktext' => "Configure users...",
'admin:user:opt:description' => "Configure users and account information. ",
diff --git a/views/default/account/forms/useradd.php b/views/default/account/forms/useradd.php
new file mode 100644
index 000000000..daf645437
--- /dev/null
+++ b/views/default/account/forms/useradd.php
@@ -0,0 +1,35 @@
+<?php
+ /**
+ * Elgg add user form.
+ *
+ * @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/
+ */
+
+ $admin_option = false;
+ if (($_SESSION['user']->admin) && ($vars['show_admin']))
+ $admin_option = true;
+?>
+
+ <h2><?php echo elgg_echo('adduser'); ?></h2>
+ <div id="add-box">
+ <form action="<?php echo $vars['url']; ?>action/useradd" method="POST">
+ <p><label><?php echo elgg_echo('name'); ?>: <input name="name" type="text" class="general-textarea" /></label><br />
+ <label><?php echo elgg_echo('email'); ?>: <input name="email" type="text" class="general-textarea" /></label><br />
+ <label><?php echo elgg_echo('username'); ?>: <input name="username" type="text" class="general-textarea" /></label><br />
+ <label><?php echo elgg_echo('password'); ?>: <input name="password" type="password" class="general-textarea" /></label><br />
+ <label><?php echo elgg_echo('passwordagain'); ?>: <input name="password2" type="password" class="general-textarea" /></label><br />
+ <?php
+ if ($admin_option) {
+?>
+ <label><?php echo elgg_echo('admin_option'); ?> <input type="checkbox" name="admin" /></label> <br />
+<?php
+ }
+ ?>
+ <input type="submit" name="submit" class="submit_button" value="<?php echo elgg_echo('adduser'); ?>" /></p>
+ </form>
+ </div> \ No newline at end of file
diff --git a/views/default/admin/user_opt/adduser.php b/views/default/admin/user_opt/adduser.php
index 4774c64a2..29827d798 100644
--- a/views/default/admin/user_opt/adduser.php
+++ b/views/default/admin/user_opt/adduser.php
@@ -12,5 +12,9 @@
*/
?>
-
-<?php echo elgg_view('account/forms/register', array('show_admin'=>true)); ?> \ No newline at end of file
+<div>
+ <?php echo elgg_echo('admin:user:adduser:label'); ?>
+</div>
+<div id="add_user_showhide">
+<?php echo elgg_view('account/forms/useradd', array('show_admin'=>true)); ?>
+</div> \ No newline at end of file