diff options
author | mrjive <mrjive@mrjive.it> | 2018-01-30 16:13:30 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-30 16:13:30 +0100 |
commit | 7ac4b477020689572a50dbc777c968263e86f6c4 (patch) | |
tree | 470336bcbdf0f989d48fb2c3349bd0ac0513da42 /Zotlabs/Module | |
parent | c2abbe2c238fa4d66e8a088c7d271acaa7e20876 (diff) | |
parent | d24cf0b85b24cb8d6d10e9fe66fed568f9fb08b2 (diff) | |
download | volse-hubzilla-7ac4b477020689572a50dbc777c968263e86f6c4.tar.gz volse-hubzilla-7ac4b477020689572a50dbc777c968263e86f6c4.tar.bz2 volse-hubzilla-7ac4b477020689572a50dbc777c968263e86f6c4.zip |
Merge pull request #13 from redmatrix/dev
Dev
Diffstat (limited to 'Zotlabs/Module')
-rw-r--r-- | Zotlabs/Module/Admin/Accounts.php | 7 | ||||
-rw-r--r-- | Zotlabs/Module/Admin/Site.php | 3 | ||||
-rw-r--r-- | Zotlabs/Module/Cards.php | 79 | ||||
-rw-r--r-- | Zotlabs/Module/Email_resend.php | 46 | ||||
-rw-r--r-- | Zotlabs/Module/Email_validation.php | 47 | ||||
-rw-r--r-- | Zotlabs/Module/Go.php | 66 | ||||
-rw-r--r-- | Zotlabs/Module/Hq.php | 8 | ||||
-rw-r--r-- | Zotlabs/Module/Item.php | 1 | ||||
-rw-r--r-- | Zotlabs/Module/Linkinfo.php | 4 | ||||
-rw-r--r-- | Zotlabs/Module/New_channel.php | 4 | ||||
-rw-r--r-- | Zotlabs/Module/Ping.php | 8 | ||||
-rw-r--r-- | Zotlabs/Module/Register.php | 20 |
12 files changed, 237 insertions, 56 deletions
diff --git a/Zotlabs/Module/Admin/Accounts.php b/Zotlabs/Module/Admin/Accounts.php index 2043550fc..2e417edd1 100644 --- a/Zotlabs/Module/Admin/Accounts.php +++ b/Zotlabs/Module/Admin/Accounts.php @@ -16,6 +16,7 @@ class Accounts { */ function post() { + $pending = ( x($_POST, 'pending') ? $_POST['pending'] : array() ); $users = ( x($_POST, 'user') ? $_POST['user'] : array() ); $blocked = ( x($_POST, 'blocked') ? $_POST['blocked'] : array() ); @@ -24,7 +25,7 @@ class Accounts { // change to switch structure? // account block/unblock button was submitted - if (x($_POST, 'page_users_block')) { + 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]) ? '& ~' : '| '; @@ -43,13 +44,13 @@ class Accounts { notice( sprintf( tt("%s account deleted", "%s accounts deleted", count($users)), count($users)) ); } // registration approved button was submitted - if (x($_POST, 'page_users_approve')) { + if (x($_POST, 'page_accounts_approve')) { foreach ($pending as $hash) { account_allow($hash); } } // registration deny button was submitted - if (x($_POST, 'page_users_deny')) { + if (x($_POST, 'page_accounts_deny')) { foreach ($pending as $hash) { account_deny($hash); } diff --git a/Zotlabs/Module/Admin/Site.php b/Zotlabs/Module/Admin/Site.php index 037f49277..52b36e03e 100644 --- a/Zotlabs/Module/Admin/Site.php +++ b/Zotlabs/Module/Admin/Site.php @@ -38,6 +38,7 @@ class Site { $site_sellpage = ((x($_POST,'site_sellpage')) ? notags(trim($_POST['site_sellpage'])) : ''); $site_location = ((x($_POST,'site_location')) ? notags(trim($_POST['site_location'])) : ''); $frontpage = ((x($_POST,'frontpage')) ? notags(trim($_POST['frontpage'])) : ''); + $firstpage = ((x(trim($_POST,'firstpage'))) ? notags(trim($_POST['firstpage'])) : 'profiles'); $mirror_frontpage = ((x($_POST,'mirror_frontpage')) ? intval(trim($_POST['mirror_frontpage'])) : 0); $directory_server = ((x($_POST,'directory_server')) ? trim($_POST['directory_server']) : ''); $allowed_sites = ((x($_POST,'allowed_sites')) ? notags(trim($_POST['allowed_sites'])) : ''); @@ -80,6 +81,7 @@ class Site { set_config('system', 'maxloadavg', $maxloadavg); set_config('system', 'frontpage', $frontpage); set_config('system', 'sellpage', $site_sellpage); + set_config('system', 'workflow_channel_next', $firstpage); set_config('system', 'site_location', $site_location); set_config('system', 'mirror_frontpage', $mirror_frontpage); set_config('system', 'sitename', $sitename); @@ -340,6 +342,7 @@ class Site { '$default_expire_days' => array('default_expire_days', t('Expiration period in days for imported (grid/network) content'), intval(get_config('system','default_expire_days')), t('0 for no expiration of imported content')), '$sellpage' => array('site_sellpage', t('Public servers: Optional landing (marketing) webpage for new registrants'), get_config('system','sellpage',''), sprintf( t('Create this page first. Default is %s/register'),z_root())), + '$firstpage' => array('firstpage', t('Page to display after creating a new channel'), get_config('system','workflow_channel_next','profiles'), t('Recommend: profiles, go, or settings')), '$location' => array('site_location', t('Optional: site location'), get_config('system','site_location',''), t('Region or country')), diff --git a/Zotlabs/Module/Cards.php b/Zotlabs/Module/Cards.php index 22c5d673c..8eff6c80d 100644 --- a/Zotlabs/Module/Cards.php +++ b/Zotlabs/Module/Cards.php @@ -9,18 +9,22 @@ require_once('include/acl_selectors.php'); class Cards extends \Zotlabs\Web\Controller { function init() { - + if(argc() > 1) $which = argv(1); else return; - + profile_load($which); - + } - + + /** + * {@inheritDoc} + * @see \Zotlabs\Web\Controller::get() + */ function get($update = 0, $load = false) { - + if(observer_prohibited(true)) { return login(); } @@ -31,13 +35,13 @@ class Cards extends \Zotlabs\Web\Controller { return; } - if(! feature_enabled(\App::$profile_uid,'cards')) { + if(! feature_enabled(\App::$profile_uid, 'cards')) { return; } nav_set_selected(t('Cards')); - head_add_link([ + head_add_link([ 'rel' => 'alternate', 'type' => 'application/json+oembed', 'href' => z_root() . '/oep?f=&url=' . urlencode(z_root() . '/' . \App::$query_string), @@ -46,48 +50,48 @@ class Cards extends \Zotlabs\Web\Controller { $category = (($_REQUEST['cat']) ? escape_tags(trim($_REQUEST['cat'])) : ''); - + if($category) { - $sql_extra2 .= protect_sprintf(term_item_parent_query(\App::$profile['profile_uid'],'item', $category, TERM_CATEGORY)); + $sql_extra2 .= protect_sprintf(term_item_parent_query(\App::$profile['profile_uid'], 'item', $category, TERM_CATEGORY)); } $which = argv(1); - + $selected_card = ((argc() > 2) ? argv(2) : ''); $_SESSION['return_url'] = \App::$query_string; - + $uid = local_channel(); $owner = \App::$profile_uid; $observer = \App::get_observer(); - + $ob_hash = (($observer) ? $observer['xchan_hash'] : ''); - - if(! perm_is_allowed($owner,$ob_hash,'view_pages')) { + + if(! perm_is_allowed($owner, $ob_hash, 'view_pages')) { notice( t('Permission denied.') . EOL); return; } - + $is_owner = ($uid && $uid == $owner); - + $channel = channelx_by_n($owner); if($channel) { - $channel_acl = array( + $channel_acl = [ 'allow_cid' => $channel['channel_allow_cid'], 'allow_gid' => $channel['channel_allow_gid'], 'deny_cid' => $channel['channel_deny_cid'], 'deny_gid' => $channel['channel_deny_gid'] - ); + ]; } else { $channel_acl = [ 'allow_cid' => '', 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => '' ]; } - - if(perm_is_allowed($owner,$ob_hash,'write_pages')) { + + if(perm_is_allowed($owner, $ob_hash, 'write_pages')) { $x = [ 'webpage' => ITEM_TYPE_CARD, @@ -95,9 +99,9 @@ class Cards extends \Zotlabs\Web\Controller { 'content_label' => t('Add Card'), 'button' => t('Create'), 'nickname' => $channel['channel_address'], - 'lockstate' => (($channel['channel_allow_cid'] || $channel['channel_allow_gid'] + 'lockstate' => (($channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'), - 'acl' => (($is_owner) ? populate_acl($channel_acl, false, + 'acl' => (($is_owner) ? populate_acl($channel_acl, false, \Zotlabs\Lib\PermissionDescription::fromGlobalPermission('view_pages')) : ''), 'permissions' => $channel_acl, 'showacl' => (($is_owner) ? true : false), @@ -110,7 +114,7 @@ class Cards extends \Zotlabs\Web\Controller { 'layoutselect' => false, 'expanded' => false, 'novoting' => false, - 'catsenabled' => feature_enabled($owner,'categories'), + 'catsenabled' => feature_enabled($owner, 'categories'), 'bbco_autocomplete' => 'bbcode', 'bbcode' => true ]; @@ -119,14 +123,14 @@ class Cards extends \Zotlabs\Web\Controller { $x['title'] = $_REQUEST['title']; if($_REQUEST['body']) $x['body'] = $_REQUEST['body']; - $editor = status_editor($a,$x); + $editor = status_editor($a, $x); } else { $editor = ''; } - - + + $sql_extra = item_permissions_sql($owner); if($selected_card) { @@ -137,9 +141,9 @@ class Cards extends \Zotlabs\Web\Controller { $sql_extra .= "and item.id = " . intval($r[0]['iid']) . " "; } } - - $r = q("select * from item - where item.uid = %d and item_type = %d + + $r = q("select * from item + where item.uid = %d and item_type = %d $sql_extra order by item.created desc", intval($owner), intval(ITEM_TYPE_CARD) @@ -149,9 +153,10 @@ class Cards extends \Zotlabs\Web\Controller { and item.item_unpublished = 0 and item.item_delayed = 0 and item.item_pending_remove = 0 and item.item_blocked = 0 "; + $items_result = []; if($r) { - $parents_str = ids_to_querystr($r,'id'); + $parents_str = ids_to_querystr($r, 'id'); $items = q("SELECT item.*, item.id AS item_id FROM item @@ -164,24 +169,22 @@ class Cards extends \Zotlabs\Web\Controller { if($items) { xchan_query($items); $items = fetch_post_tags($items, true); - $items = conv_sort($items,'updated'); + $items_result = conv_sort($items, 'updated'); } - else - $items = []; } $mode = 'cards'; - - $content = conversation($items,$mode,false,'traditional'); + + $content = conversation($items_result, $mode, false, 'traditional'); $o = replace_macros(get_markup_template('cards.tpl'), [ '$title' => t('Cards'), '$editor' => $editor, '$content' => $content, - '$pager' => alt_pager($a,count($items)) + '$pager' => alt_pager($a, count($items_result)) ]); - return $o; - } + return $o; + } } diff --git a/Zotlabs/Module/Email_resend.php b/Zotlabs/Module/Email_resend.php new file mode 100644 index 000000000..f8a336be0 --- /dev/null +++ b/Zotlabs/Module/Email_resend.php @@ -0,0 +1,46 @@ +<?php + +namespace Zotlabs\Module; + + +class Email_resend extends \Zotlabs\Web\Controller { + + function post() { + + if($_POST['token']) { + if(! account_approve(trim($_POST['token']))) { + notice(t('Token verification failed.')); + } + } + + } + + + function get() { + + if(argc() > 1) { + $result = false; + $email = hex2bin(argv(1)); + + if($email) { + $result = verify_email_address( [ 'resend' => true, 'email' => $email ] ); + } + + if($result) { + notice(t('Email verification resent')); + } + else { + notice(t('Unable to resend email verification message.')); + } + + goaway(z_root() . '/email_validation/' . bin2hex($email)); + + } + + // @todo - one can provide a form here to resend the mail + // after directing to here if a succesful login was attempted from an unverified address. + + + } + +} diff --git a/Zotlabs/Module/Email_validation.php b/Zotlabs/Module/Email_validation.php new file mode 100644 index 000000000..b8bb720cd --- /dev/null +++ b/Zotlabs/Module/Email_validation.php @@ -0,0 +1,47 @@ +<?php + +namespace Zotlabs\Module; + + +class Email_validation extends \Zotlabs\Web\Controller { + + function post() { + + if($_POST['token']) { + // This will redirect internally on success unless the channel is auto_created + if(! account_approve(trim(basename($_POST['token'])))) { + notice('Token verification failed.'); + } + else { + if(get_config('system','auto_channel_create')) { + $next_page = get_config('system', 'workflow_channel_next', 'profiles'); + } + if($next_page) { + goaway(z_root() . '/' . $next_page); + } + } + } + + } + + + function get() { + + if(argc() > 1) { + $email = hex2bin(argv(1)); + } + + $o = replace_macros(get_markup_template('email_validation.tpl'), [ + '$title' => t('Email Verification Required'), + '$desc' => sprintf( t('A verification token was sent to your email address [%s]. Enter that token here to complete the account verification step. Please allow a few minutes for delivery, and check your spam folder if you do not see the message.'),$email), + '$resend' => t('Resend Email'), + '$email' => bin2hex($email), + '$submit' => t('Submit'), + '$token' => [ 'token', t('Validation token'),'','' ], + ]); + + return $o; + + } + +}
\ No newline at end of file diff --git a/Zotlabs/Module/Go.php b/Zotlabs/Module/Go.php new file mode 100644 index 000000000..2c2dcf460 --- /dev/null +++ b/Zotlabs/Module/Go.php @@ -0,0 +1,66 @@ +<?php + +namespace Zotlabs\Module; + + +class Go extends \Zotlabs\Web\Controller { + + function init() { + if(local_channel()) { + $channel = \App::get_channel(); + if($channel) { + profile_load($channel['channel_address'],0); + } + } + } + + + + function get() { + if(! local_channel()) { + notify( t('This page is available only to site members') . EOL); + } + + $channel = \App::get_channel(); + + + $title = t('Welcome'); + + $m = t('What would you like to do?'); + + $m1 = t('Please bookmark this page if you would like to return to it in the future'); + + + $options = [ + 'profile_photo' => t('Upload a profile photo'), + 'profiles' => t('Edit your default profile'), + 'suggest' => t('View friend suggestions'), + 'directory' => t('View the directory to find other interesting channels'), + 'settings' => t('View/edit your channel settings'), + 'help' => t('View the site or project documentation'), + 'channel/' . $channel['channel_address'] => t('Visit your channel homepage'), + 'connections' => t('View your connections and/or add somebody whose address you already know'), + 'network' => t('View your personal stream (this may be empty until you add some connections)'), + + ]; + + $site_firehose = ((intval(get_config('system','site_firehose',0))) ? true : false); + $net_firehose = ((get_config('system','disable_discover_tab',1)) ? false : true); + + if($site_firehose || $net_firehose) { + $options['pubstream'] = t('View the public stream. Warning: this content is not moderated'); + } + + $o = replace_macros(get_markup_template('go.tpl'), [ + '$title' => $title, + '$m' => $m, + '$m1' => $m1, + '$options' => $options + + ]); + + return $o; + + } + +}
\ No newline at end of file diff --git a/Zotlabs/Module/Hq.php b/Zotlabs/Module/Hq.php index a9c3bb8e2..c46695b65 100644 --- a/Zotlabs/Module/Hq.php +++ b/Zotlabs/Module/Hq.php @@ -29,6 +29,8 @@ class Hq extends \Zotlabs\Web\Controller { ); } + killme(); + } function get($update = 0, $load = false) { @@ -49,9 +51,11 @@ class Hq extends \Zotlabs\Web\Controller { $item_normal = item_normal(); $item_normal_update = item_normal_update(); + $use_index = db_use_index('created'); + if(! $item_hash) { - $r = q("SELECT mid FROM item - WHERE uid = %d + $r = q("SELECT mid FROM item $use_index + WHERE uid = %d $item_normal AND mid = parent_mid ORDER BY created DESC LIMIT 1", intval(local_channel()) diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index ad829137a..db2d64d70 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -753,6 +753,7 @@ class Item extends \Zotlabs\Web\Controller { if ((! $plink) && ($item_thread_top)) { $plink = z_root() . '/channel/' . $channel['channel_address'] . '/?f=&mid=' . $mid; + $plink = substr($plink,0,190); } $datarray['aid'] = $channel['channel_account_id']; diff --git a/Zotlabs/Module/Linkinfo.php b/Zotlabs/Module/Linkinfo.php index 78c34583e..3392e4114 100644 --- a/Zotlabs/Module/Linkinfo.php +++ b/Zotlabs/Module/Linkinfo.php @@ -120,9 +120,9 @@ class Linkinfo extends \Zotlabs\Web\Controller { $siteinfo = self::parseurl_getsiteinfo($url); - // If this is a Red site, use zrl rather than url so they get zids sent to them by default + // If the site uses this platform, use zrl rather than url so they get zids sent to them by default - if( x($siteinfo,'generator') && (strpos($siteinfo['generator'], \Zotlabs\Lib\System::get_platform_name() . ' ') === 0)) + if(is_matrix_url($url)) $template = str_replace('url','zrl',$template); if($siteinfo["title"] == "") { diff --git a/Zotlabs/Module/New_channel.php b/Zotlabs/Module/New_channel.php index 2b73fa191..9f2fea802 100644 --- a/Zotlabs/Module/New_channel.php +++ b/Zotlabs/Module/New_channel.php @@ -89,9 +89,7 @@ class New_channel extends \Zotlabs\Web\Controller { change_channel($result['channel']['channel_id']); - if(! strlen($next_page = get_config('system','workflow_channel_next'))) - $next_page = 'settings'; - + $next_page = get_config('system', 'workflow_channel_next', 'profiles'); goaway(z_root() . '/' . $next_page); } diff --git a/Zotlabs/Module/Ping.php b/Zotlabs/Module/Ping.php index a3f6cdfec..f8399d871 100644 --- a/Zotlabs/Module/Ping.php +++ b/Zotlabs/Module/Ping.php @@ -320,7 +320,9 @@ class Ping extends \Zotlabs\Web\Controller { if(argc() > 1 && (argv(1) === 'network' || argv(1) === 'home')) { $result = array(); - $r = q("SELECT * FROM item + $use_index = db_use_index('uid_item_unseen'); + + $r = q("SELECT * FROM item $use_index WHERE item_unseen = 1 and uid = %d $item_normal AND author_xchan != '%s' ORDER BY created DESC limit 300", @@ -492,8 +494,10 @@ class Ping extends \Zotlabs\Web\Controller { $t3 = dba_timer(); if($vnotify & (VNOTIFY_NETWORK|VNOTIFY_CHANNEL)) { + + $use_index = db_use_index('uid_item_unseen'); - $r = q("SELECT id, item_wall FROM item + $r = q("SELECT id, item_wall FROM item $use_index WHERE item_unseen = 1 and uid = %d $item_normal AND author_xchan != '%s'", diff --git a/Zotlabs/Module/Register.php b/Zotlabs/Module/Register.php index deaee31bf..c7fa1cee8 100644 --- a/Zotlabs/Module/Register.php +++ b/Zotlabs/Module/Register.php @@ -150,9 +150,11 @@ class Register extends \Zotlabs\Web\Controller { } if($email_verify) { - goaway(z_root()); + goaway(z_root() . '/email_validation/' . bin2hex($result['email'])); } - + + // fall through and authenticate if no approvals or verifications were required. + authenticate_success($result['account'],null,true,false,true); $new_channel = false; @@ -217,6 +219,9 @@ class Register extends \Zotlabs\Web\Controller { $privacy_role = ((x($_REQUEST,'permissions_role')) ? $_REQUEST['permissions_role'] : ""); $perm_roles = \Zotlabs\Access\PermissionRoles::roles(); + + // A new account will not have a techlevel, but accounts can also be created by the administrator. + if((get_account_techlevel() < 4) && $privacy_role !== 'custom') unset($perm_roles[t('Other')]); @@ -231,15 +236,17 @@ class Register extends \Zotlabs\Web\Controller { // Configurable whether to restrict age or not - default is based on international legal requirements // This can be relaxed if you are on a restricted server that does not share with public servers - if(get_config('system','no_age_restriction')) + if(get_config('system','no_age_restriction')) { $label_tos = sprintf( t('I accept the %s for this website'), $toslink); - else + } + else { $age = get_config('system','minimum_age'); if(!$age) { $age = 13; } $label_tos = sprintf( t('I am over %s years of age and accept the %s for this website'), $age, $toslink); - + } + $enable_tos = 1 - intval(get_config('system','no_termsofservice')); $email = array('email', t('Your email address'), ((x($_REQUEST,'email')) ? strip_tags(trim($_REQUEST['email'])) : "")); @@ -255,6 +262,7 @@ class Register extends \Zotlabs\Web\Controller { $auto_create = (get_config('system','auto_channel_create') ? true : false); $default_role = get_config('system','default_permissions_role'); + $email_verify = get_config('system','verify_email'); require_once('include/bbcode.php'); @@ -278,7 +286,7 @@ class Register extends \Zotlabs\Web\Controller { '$pass1' => $password, '$pass2' => $password2, '$submit' => t('Register'), - '$verify_note' => t('This site may require email verification after submitting this form. If you are returned to a login page, please check your email for instructions.') + '$verify_note' => (($email_verify) ? t('This site requires email verification. After completing this form, please check your email for further instructions.') : ''), )); return $o; |