allow admins to add a new user from the admin panel (eventually fixing oldbug #383)

This commit is contained in:
Tobias Diekershoff 2013-07-21 08:46:57 +02:00
parent 98105afffb
commit 0972189372
4 changed files with 118 additions and 1 deletions

View file

@ -622,9 +622,40 @@ 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');
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){
q("UPDATE `user` SET `blocked`=1-`blocked` WHERE `uid`=%s",
@ -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;

View file

@ -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

View file

@ -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

View file

@ -100,4 +100,22 @@
NO USERS?!?
{{/if}}
</form>
<h3>{{$h_newuser}}</h3>
<form action="{{$baseurl}}/admin/users" method="post">
<input type='hidden' name='form_security_token' value='{{$form_security_token}}'>
<table id='users'>
<tbody>
<tr>
<td>{{include file="field_input.tpl" field=$newusername}}</td>
</tr>
<tr>
<td>{{include file="field_input.tpl" field=$newusernickname}}</td>
</tr>
<tr>
<td>{{include file="field_input.tpl" field=$newuseremail}}</td>
</tr>
</tbody>
</table>
<div class="submit"><input type="submit" name="add_new_user_submit" value="{{$submit}}" /></div>
</form>
</div>