refactor the 'where does the register link point?' logic

This commit is contained in:
zotlabs 2018-05-14 19:19:25 -07:00
parent 301e405769
commit c8fc3ad7cd
5 changed files with 43 additions and 18 deletions

View file

@ -89,11 +89,11 @@ class Home extends \Zotlabs\Web\Controller {
$sitename = get_config('system','sitename'); $sitename = get_config('system','sitename');
if($sitename) if($sitename)
$o .= '<h1 class="home-welcome">' . sprintf( t("Welcome to %s") ,$sitename) . '</h1>'; $o .= '<h1 class="home-welcome">' . sprintf( t('Welcome to %s') ,$sitename) . '</h1>';
$loginbox = get_config('system','login_on_homepage'); $loginbox = get_config('system','login_on_homepage');
if(intval($loginbox) || $loginbox === false) if(intval($loginbox) || $loginbox === false)
$o .= login((\App::$config['system']['register_policy'] == REGISTER_CLOSED) ? 0 : 1); $o .= login(true);
return $o; return $o;

View file

@ -10,7 +10,7 @@ class Login extends \Zotlabs\Web\Controller {
if(remote_channel() && $_SESSION['atoken']) if(remote_channel() && $_SESSION['atoken'])
goaway(z_root()); goaway(z_root());
return login((\App::$config['system']['register_policy'] == REGISTER_CLOSED) ? false : true); return login(true);
} }
} }

View file

@ -187,8 +187,8 @@ class Register extends \Zotlabs\Web\Controller {
$registration_is = ''; $registration_is = '';
$other_sites = ''; $other_sites = '';
if(get_config('system','register_policy') == REGISTER_CLOSED) { if(intval(get_config('system','register_policy')) === REGISTER_CLOSED) {
if(get_config('system','directory_mode') == DIRECTORY_MODE_STANDALONE) { if(intval(get_config('system','directory_mode')) === DIRECTORY_MODE_STANDALONE) {
notice( t('Registration on this hub is disabled.') . EOL); notice( t('Registration on this hub is disabled.') . EOL);
return; return;
} }
@ -197,7 +197,7 @@ class Register extends \Zotlabs\Web\Controller {
return $mod->get(); return $mod->get();
} }
if(get_config('system','register_policy') == REGISTER_APPROVE) { if(intval(get_config('system','register_policy')) == REGISTER_APPROVE) {
$registration_is = t('Registration on this hub is by approval only.'); $registration_is = t('Registration on this hub is by approval only.');
$other_sites = t('<a href="pubsites">Register at another affiliated hub.</a>'); $other_sites = t('<a href="pubsites">Register at another affiliated hub.</a>');
} }

View file

@ -13,8 +13,7 @@ class Regmod extends \Zotlabs\Web\Controller {
if(! local_channel()) { if(! local_channel()) {
info( t('Please login.') . EOL); info( t('Please login.') . EOL);
$o .= '<br /><br />' . login((\App::$config['system']['register_policy'] == REGISTER_CLOSED) ? 0 : 1); return login();
return $o;
} }
if(! is_site_admin()) { if(! is_site_admin()) {

View file

@ -1559,17 +1559,43 @@ function fix_system_urls($oldurl, $newurl) {
* @return string Parsed HTML code. * @return string Parsed HTML code.
*/ */
function login($register = false, $form_id = 'main-login', $hiddens = false, $login_page = true) { function login($register = false, $form_id = 'main-login', $hiddens = false, $login_page = true) {
$o = '';
$reg = false;
$reglink = get_config('system', 'register_link');
if(! strlen($reglink))
$reglink = 'register';
$reg = array( $o = '';
'title' => t('Create an account to access services and applications'), $reg = null;
'desc' => t('Register'),
'link' => (($register) ? $reglink : 'pubsites') // Here's the current description of how the register link works (2018-05-15)
);
// Register links are enabled on the site home page and login page and navbar.
// They are not shown by default on other pages which may require login.
// If the register link is enabled and registration is closed, the request is directed
// to /pubsites. If registration is allowed, /register is the default destination
// system.register_link can over-ride the default behaviour and redirect to an arbitrary
// webpage for paid/custom or organisational registrations, regardless of whether
// registration is allowed.
// system.register_link may or may not be the same destination as system.sellpage
// system.sellpage is the destination linked from the /pubsites page on other sites. If
// system.sellpage is not set, the 'register' link in /pubsites will go to 'register' on your
// site.
// If system.register_link is set to the word 'none', no registration link will be shown on
// your site.
$register_policy = get_config('system','register_policy');
$reglink = get_config('system', 'register_link', z_root() . '/' . ((intval($register_policy) === REGISTER_CLOSED) ? 'pubsites' : 'register'));
if($reglink !== 'none') {
$reg = [
'title' => t('Create an account to access services and applications'),
'desc' => t('Register'),
'link' => $reglink
];
}
$dest_url = z_root() . '/' . App::$query_string; $dest_url = z_root() . '/' . App::$query_string;