From 0972189372b9220fe0d46ab9c1a964fee18ea330 Mon Sep 17 00:00:00 2001 From: Tobias Diekershoff Date: Sun, 21 Jul 2013 08:46:57 +0200 Subject: [PATCH] allow admins to add a new user from the admin panel (eventually fixing oldbug #383) --- mod/admin.php | 37 ++++++++++++++++++++++- view/de/smarty3/register_adminadd_eml.tpl | 32 ++++++++++++++++++++ view/smarty3/register_adminadd_eml.tpl | 32 ++++++++++++++++++++ view/templates/admin_users.tpl | 18 +++++++++++ 4 files changed, 118 insertions(+), 1 deletion(-) create mode 100644 view/de/smarty3/register_adminadd_eml.tpl create mode 100644 view/smarty3/register_adminadd_eml.tpl diff --git a/mod/admin.php b/mod/admin.php index fefe13abb6..1042bbd502 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -622,8 +622,39 @@ function admin_page_dbsync(&$a) { function admin_page_users_post(&$a){ $pending = ( x($_POST, 'pending') ? $_POST['pending'] : Array() ); $users = ( x($_POST, 'user') ? $_POST['user'] : Array() ); + $nu_name = ( x($_POST, 'new_user_name') ? $_POST['new_user_name'] : ''); + $nu_nickname = ( x($_POST, 'new_user_nickname') ? $_POST['new_user_nickname'] : ''); + $nu_email = ( x($_POST, 'new_user_email') ? $_POST['new_user_email'] : ''); - check_form_security_token_redirectOnErr('/admin/users', 'admin_users'); + check_form_security_token_redirectOnErr('/admin/users', 'admin_users'); + + if (!($nu_name==="") && !($nu_email==="") && !($nu_nickname==="")) { + require_once('include/user.php'); + require_once('include/email.php'); + $result = create_user( array('username'=>$nu_name, 'email'=>$nu_email, 'nickname'=>$nu_nickname, 'verified'=>1) ); + if(! $result['success']) { + notice($result['message']); + return; + } + $nu = $result['user']; + $email_tpl = get_intltext_template("register_adminadd_eml.tpl"); + $email_tpl = replace_macros($email_tpl, array( + '$sitename' => $a->config['sitename'], + '$siteurl' => $a->get_baseurl(), + '$username' => $nu['username'], + '$email' => $nu['email'], + '$password' => $result['password'], + '$uid' => $nu['uid'] )); + + $res = mail($nu['email'], email_header_encode( sprintf( t('Registration details for %s'), $a->config['sitename']),'UTF-8'), + $email_tpl, + 'From: ' . 'Administrator' . '@' . $_SERVER['SERVER_NAME'] . "\n" + . 'Content-type: text/plain; charset=UTF-8' . "\n" + . 'Content-transfer-encoding: 8bit' ); + if ($res) { + info( t('Registration successful. Email send to user').EOL ); + } + } if (x($_POST,'page_users_block')){ foreach($users as $uid){ @@ -774,6 +805,7 @@ function admin_page_users(&$a){ '$accountexpired' => t('Account expired'), '$h_users' => t('Users'), + '$h_newuser' => t('New User'), '$th_users' => array( t('Name'), t('Email'), t('Register date'), t('Last login'), t('Last item'), t('Account') ), '$confirm_delete_multi' => t('Selected users will be deleted!\n\nEverything these users had posted on this site will be permanently deleted!\n\nAre you sure?'), @@ -786,6 +818,9 @@ function admin_page_users(&$a){ '$pending' => $pending, '$users' => $users, + '$newusername' => array('new_user_name', t("Name"), '', t("Name of the new user.")), + '$newusernickname' => array('new_user_nickname', t("Nickname"), '', t("Nickname of the new user.")), + '$newuseremail' => array('new_user_email', t("Email"), '', t("Email address of the new user.")), )); $o .= paginate($a); return $o; diff --git a/view/de/smarty3/register_adminadd_eml.tpl b/view/de/smarty3/register_adminadd_eml.tpl new file mode 100644 index 0000000000..dbe1412b90 --- /dev/null +++ b/view/de/smarty3/register_adminadd_eml.tpl @@ -0,0 +1,32 @@ +Hallo {{$username}}, + der Administrator von {{$sitename}} hat einen Account für dich eingerichtet. + +Hier die Login Details: + + +Adresse der Seite: {{$siteurl}} +Login Name: {{$email}} +Passwort: {{$password}} + +Du kannst und solltest das Passwort in den "Einstellungen" zu deinem Account ändern, +nachdem du dich erstmalig eingeloggt hast. + +Bitte nimm dir einige Augenblicke Zeit, um die anderen Einstellungen auf der Seite kennenzulernen und zu überprüfen. + +Eventuell möchtest du außerdem einige grundlegende Informationen in deinem Standardprofil (auf der "Profile" Seite) eintragen, +damit andere Leute dich einfacher finden können. + +Wir empfehlen den kompletten Namen anzugeben, ein eigenes Profilbild hochzuladen, +sowie ein paar "Profil-Schlüsselwörter" einzutragen (um leichter Menschen mit gleichen Interessen zu finden) - und +vielleicht auch in welchen Land du lebst; falls du nicht konkreter +werden möchtest. + +Wir respektieren dein Recht auf Privatsphäre und keine dieser Angaben ist notwendig. +Wenn du ganz neu bei Friendica bist und niemanden kennst, werden sie dir aber helfen +ein paar neue und interessante Freunde zu finden. + + +Danke und willkommen auf {{$sitename}}. + +Beste Grüße, + {{$sitename}} Administrator diff --git a/view/smarty3/register_adminadd_eml.tpl b/view/smarty3/register_adminadd_eml.tpl new file mode 100644 index 0000000000..6d324809cb --- /dev/null +++ b/view/smarty3/register_adminadd_eml.tpl @@ -0,0 +1,32 @@ +Dear {{$username}}, + the administrator of {{$sitename}} has set up an account for you. + +The login details are as follows: + + +Site Location: {{$siteurl}} +Login Name: {{$email}} +Password: {{$password}} + +You may change your password from your account "Settings" page after logging +in. + +Please take a few moments to review the other account settings on that page. + +You may also wish to add some basic information to your default profile +(on the "Profiles" page) so that other people can easily find you. + +We recommend setting your full name, adding a profile photo, +adding some profile "keywords" (very useful in making new friends) - and +perhaps what country you live in; if you do not wish to be more specific +than that. + +We fully respect your right to privacy, and none of these items are necessary. +If you are new and do not know anybody here, they may help +you to make some new and interesting friends. + + +Thank you and welcome to {{$sitename}}. + +Sincerely, + {{$sitename}} Administrator diff --git a/view/templates/admin_users.tpl b/view/templates/admin_users.tpl index 80345b78bd..67ad40768f 100644 --- a/view/templates/admin_users.tpl +++ b/view/templates/admin_users.tpl @@ -100,4 +100,22 @@ NO USERS?!? {{/if}} +

{{$h_newuser}}

+
+ + + + + + + + + + + + + +
{{include file="field_input.tpl" field=$newusername}}
{{include file="field_input.tpl" field=$newusernickname}}
{{include file="field_input.tpl" field=$newuseremail}}
+
+