tasks and notes

This commit is contained in:
zotlabs 2019-06-24 17:35:12 -07:00
parent 17599db5c9
commit 8cc49657f9
6 changed files with 84 additions and 56 deletions

View file

@ -331,6 +331,7 @@ class Apps {
'Suggest Channels' => t('Suggest Channels'),
'Login' => t('Login'),
'Channel Manager' => t('Channel Manager'),
'Notes' => t('Notes'),
'Network' => t('Stream'),
'Settings' => t('Settings'),
'Files' => t('Files'),

View file

@ -2,7 +2,7 @@
namespace Zotlabs\Module\Admin;
use App;
class Accounts {
@ -23,19 +23,20 @@ class Accounts {
check_form_security_token_redirectOnErr('/admin/accounts', 'admin_accounts');
// change to switch structure?
// account block/unblock button was submitted
if (x($_POST, 'page_accounts_block')) {
for ($i = 0; $i < count($users); $i++) {
// if account is blocked remove blocked bit-flag, otherwise add blocked bit-flag
$op = ($blocked[$i]) ? '& ~' : '| ';
q("UPDATE account SET account_flags = (account_flags $op%d) WHERE account_id = %d",
q("UPDATE account SET account_flags = (account_flags $op %d) WHERE account_id = %d",
intval(ACCOUNT_BLOCKED),
intval($users[$i])
);
}
notice( sprintf( tt("%s account blocked/unblocked", "%s account blocked/unblocked", count($users)), count($users)) );
}
// account delete button was submitted
if (x($_POST, 'page_accounts_delete')) {
foreach ($users as $uid){
@ -43,12 +44,14 @@ class Accounts {
}
notice( sprintf( tt("%s account deleted", "%s accounts deleted", count($users)), count($users)) );
}
// registration approved button was submitted
if (x($_POST, 'page_accounts_approve')) {
foreach ($pending as $hash) {
account_allow($hash);
}
}
// registration deny button was submitted
if (x($_POST, 'page_accounts_deny')) {
foreach ($pending as $hash) {
@ -83,7 +86,7 @@ class Accounts {
check_form_security_token_redirectOnErr('/admin/accounts', 'admin_accounts', 't');
switch (argv(2)){
switch (argv(2)) {
case 'delete':
// delete user
account_remove($uid,true,false);
@ -99,9 +102,9 @@ class Accounts {
notice( sprintf( t("Account '%s' blocked") , $account[0]['account_email']) . EOL);
break;
case 'unblock':
q("UPDATE account SET account_flags = ( account_flags & ~%d ) WHERE account_id = %d",
intval(ACCOUNT_BLOCKED),
intval($uid)
q("UPDATE account SET account_flags = ( account_flags & ~ %d ) WHERE account_id = %d",
intval(ACCOUNT_BLOCKED),
intval($uid)
);
notice( sprintf( t("Account '%s' unblocked"), $account[0]['account_email']) . EOL);
@ -112,7 +115,7 @@ class Accounts {
}
/* get pending */
$pending = q("SELECT account.*, register.hash from account left join register on account_id = register.uid where (account_flags & %d )>0 ",
$pending = q("SELECT account.*, register.hash from account left join register on account_id = register.uid where (account_flags & %d ) != 0 ",
intval(ACCOUNT_PENDING)
);
@ -120,17 +123,18 @@ class Accounts {
$total = q("SELECT count(*) as total FROM account");
if (count($total)) {
\App::set_pager_total($total[0]['total']);
\App::set_pager_itemspage(100);
App::set_pager_total($total[0]['total']);
App::set_pager_itemspage(100);
}
$serviceclass = (($_REQUEST['class']) ? " and account_service_class = '" . dbesc($_REQUEST['class']) . "' " : '');
$key = (($_REQUEST['key']) ? dbesc($_REQUEST['key']) : 'account_id');
$dir = 'asc';
if(array_key_exists('dir',$_REQUEST))
if (array_key_exists('dir',$_REQUEST)) {
$dir = ((intval($_REQUEST['dir'])) ? 'asc' : 'desc');
}
$base = z_root() . '/admin/accounts?f=';
$odir = (($dir === 'asc') ? '0' : '1');
@ -140,29 +144,25 @@ class Accounts {
intval(ACCOUNT_BLOCKED),
db_concat('ch.channel_address', ' '),
intval(ACCOUNT_BLOCKED | ACCOUNT_PENDING),
intval(\App::$pager['itemspage']),
intval(\App::$pager['start'])
intval(App::$pager['itemspage']),
intval(App::$pager['start'])
);
// function _setup_users($e){
// $accounts = Array(
// t('Normal Account'),
// t('Soapbox Account'),
// t('Community/Celebrity Account'),
// t('Automatic Friend Account')
// );
// $e['page_flags'] = $accounts[$e['page-flags']];
// $e['register_date'] = relative_date($e['register_date']);
// $e['login_date'] = relative_date($e['login_date']);
// $e['lastitem_date'] = relative_date($e['lastitem_date']);
// return $e;
// }
// $users = array_map("_setup_users", $users);
$t = get_markup_template('admin_accounts.tpl');
$o = replace_macros($t, array(
// strings //
if ($users) {
for($x = 0; $x < count($users); $x ++) {
$channel_arr = explode(' ',$users[$x]['channels']);
if ($channel_arr) {
$linked = [];
foreach ( $channel_arr as $c) {
$linked[] = '<a href="' . z_root() . '/channel/' . $c . '">' . $c . '</a>';
}
$users[$x]['channels'] = implode(' ',$linked);
}
}
}
$t =
$o = replace_macros(get_markup_template('admin_accounts.tpl'), [
'$title' => t('Administration'),
'$page' => t('Accounts'),
'$submit' => t('Submit'),
@ -178,30 +178,25 @@ class Accounts {
'$odir' => $odir,
'$base' => $base,
'$h_users' => t('Accounts'),
'$th_users' => array(
'$th_users' => [
[ t('ID'), 'account_id' ],
[ t('Email'), 'account_email' ],
[ t('All Channels'), 'channels' ],
[ t('Register date'), 'account_created' ],
[ t('Last login'), 'account_lastlog' ],
[ t('Expires'), 'account_expires' ],
[ t('Service Class'), 'account_service_class'] ),
[ t('Service Class'), 'account_service_class']
],
'$confirm_delete_multi' => t('Selected accounts will be deleted!\n\nEverything these accounts had posted on this site will be permanently deleted!\n\nAre you sure?'),
'$confirm_delete' => t('The account {0} will be deleted!\n\nEverything this account has posted on this site will be permanently deleted!\n\nAre you sure?'),
'$form_security_token' => get_form_security_token("admin_accounts"),
// values //
'$baseurl' => z_root(),
'$pending' => $pending,
'$users' => $users,
));
]);
$o .= paginate($a);
return $o;
}
}

View file

@ -3,7 +3,7 @@ namespace Zotlabs\Module; /** @file */
use Zotlabs\Lib\Libsync;
use Zotlabs\Web\Controller;
use Zotlabs\Lib\Apps;
class Notes extends Controller {
@ -26,17 +26,38 @@ class Notes extends Controller {
set_pconfig(local_channel(),'notes','text.bak',$old_text);
}
set_pconfig(local_channel(),'notes','text',$body);
}
// push updates to channel clones
// push updates to channel clones
if((argc() > 1) && (argv(1) === 'sync')) {
Libsync::build_sync_packet();
}
if((argc() > 1) && (argv(1) === 'sync')) {
Libsync::build_sync_packet();
}
logger('notes saved.', LOGGER_DEBUG);
json_return_and_die($ret);
logger('notes saved.', LOGGER_DEBUG);
json_return_and_die($ret);
}
}
function get() {
$desc = t('This app allows you to create private notes for your personal use.');
$text = '<div class="section-content-info-wrapper">' . $desc . '</div>';
if(! ( local_channel() && Apps::system_app_installed(local_channel(),'Notes'))) {
return $text;
}
$desc = t('This app is installed. The Notes tool can be found on your network stream page.');
$text = '<div class="section-content-info-wrapper">' . $desc . '</div>';
return $text;
}
}

View file

@ -2,21 +2,25 @@
namespace Zotlabs\Widget;
use Zotlabs\Lib\Apps;
class Notes {
function widget($arr) {
if(! local_channel())
if (! local_channel()) {
return '';
if(! feature_enabled(local_channel(),'private_notes'))
}
if (! Apps::system_app_installed(local_channel(),'Notes')) {
return '';
}
$text = get_pconfig(local_channel(),'notes','text');
$o = replace_macros(get_markup_template('notes.tpl'), array(
$o = replace_macros(get_markup_template('notes.tpl'), [
'$banner' => t('Notes'),
'$text' => $text,
'$save' => t('Save'),
));
]);
return $o;
}

6
app/notes.apd Normal file
View file

@ -0,0 +1,6 @@
version: 1
url: $baseurl/notes
requires: local_channel
name: Notes
photo: icon:pencil
categories: Productivity

View file

@ -3,6 +3,7 @@
[widget=activity_filter][/widget]
[widget=savedsearch][/widget]
[widget=suggestions][/widget]
[widget=tasklist][/widget]
[widget=notes][/widget]
[/region]