aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Zotlabs/Module/Admin/Account_edit.php64
-rw-r--r--view/tpl/admin_account_edit.tpl14
-rwxr-xr-xview/tpl/admin_accounts.tpl4
3 files changed, 80 insertions, 2 deletions
diff --git a/Zotlabs/Module/Admin/Account_edit.php b/Zotlabs/Module/Admin/Account_edit.php
new file mode 100644
index 000000000..ddb7e19f4
--- /dev/null
+++ b/Zotlabs/Module/Admin/Account_edit.php
@@ -0,0 +1,64 @@
+<?php
+
+namespace Zotlabs\Module\Admin;
+
+
+
+class Account_edit {
+
+ function post() {
+
+ $account_id = $_REQUEST['aid'];
+
+ if(! $account_id)
+ return;
+
+ $pass1 = trim($_REQUEST['pass1']);
+ $pass2 = trim($_REQUEST['pass2']);
+ if($pass1 && $pass2 && ($pass1 === $pass2)) {
+ $salt = random_string(32);
+ $password_encoded = hash('whirlpool', $salt . $pass1);
+ $r = q("update account set account_salt = '%s', account_password = '%s',
+ account_password_changed = '%s' where account_id = %d",
+ dbesc($salt),
+ dbesc($password_encoded),
+ dbesc(datetime_convert()),
+ intval($account_id)
+ );
+ if($r)
+ info( sprintf( t('Password changed for account %d.'), $account_id). EOL);
+
+ }
+ goaway(z_root() . '/admin/accounts');
+ }
+
+
+ function get() {
+ if(argc() > 2)
+ $account_id = argv(2);
+
+ $x = q("select * from account where account_id = %d limit 1",
+ intval($account_id)
+ );
+
+ if(! $x) {
+ notice ( t('Account not found.') . EOL);
+ return '';
+ }
+
+ $a = replace_macros(get_markup_template('admin_account_edit.tpl'), [
+ '$account' => $x[0],
+ '$title' => t('Account Edit'),
+ '$pass1' => [ 'pass1', t('New Password'), ' ','' ],
+ '$pass2' => [ 'pass2', t('New Password again'), ' ','' ],
+ '$submit' => t('Submit'),
+ ]
+ );
+
+ return $a;
+
+
+ }
+
+
+} \ No newline at end of file
diff --git a/view/tpl/admin_account_edit.tpl b/view/tpl/admin_account_edit.tpl
new file mode 100644
index 000000000..5e8cb5f47
--- /dev/null
+++ b/view/tpl/admin_account_edit.tpl
@@ -0,0 +1,14 @@
+<h2>{{$title}}</h2>
+
+<h3>{{$account.account_email}}</h3>
+
+
+<form action="admin/account_edit/{{$account.account_id}}" method="post" >
+<input type="hidden" name="aid" value="{{$account.account_id}}" />
+
+{{include file="field_password.tpl" field=$pass1}}
+{{include file="field_password.tpl" field=$pass2}}
+
+<input type="submit" name="submit" value="{{$submit}}" />
+
+</form>
diff --git a/view/tpl/admin_accounts.tpl b/view/tpl/admin_accounts.tpl
index 53f5f1aba..c2a50e3ff 100755
--- a/view/tpl/admin_accounts.tpl
+++ b/view/tpl/admin_accounts.tpl
@@ -62,9 +62,9 @@
<tr>
<td class="account_id">{{$u.account_id}}</td>
<td class="email">{{if $u.blocked}}
- <i>{{$u.account_email}}</i>
+ <a href="admin/account_edit/{{$u.account_id}}"><i>{{$u.account_email}}</i></a>
{{else}}
- <strong>{{$u.account_email}}</strong>
+ <a href="admin/account_edit/{{$u.account_id}}"><strong>{{$u.account_email}}</strong></a>
{{/if}}</td>
<td class="channels">{{$u.channels}}</td>
<td class="register_date">{{$u.account_created}}</td>