Enforce systen.register_policy value type

This commit is contained in:
Hypolite Petovan 2018-07-15 15:04:48 -04:00
parent 9b01a23c9b
commit 67dc08d120
14 changed files with 19 additions and 19 deletions

View file

@ -3345,7 +3345,7 @@ function api_statusnet_config($type)
$server = $a->get_hostname(); $server = $a->get_hostname();
$logo = System::baseUrl() . '/images/friendica-64.png'; $logo = System::baseUrl() . '/images/friendica-64.png';
$email = Config::get('config', 'admin_email'); $email = Config::get('config', 'admin_email');
$closed = Config::get('config', 'register_policy') == REGISTER_CLOSED ? 'true' : 'false'; $closed = intval(Config::get('config', 'register_policy')) === REGISTER_CLOSED ? 'true' : 'false';
$private = Config::get('system', 'block_public') ? 'true' : 'false'; $private = Config::get('system', 'block_public') ? 'true' : 'false';
$textlimit = (string) Config::get('config', 'api_import_size', Config::get('config', 'max_import_size', 200000)); $textlimit = (string) Config::get('config', 'api_import_size', Config::get('config', 'max_import_size', 200000));
$ssl = Config::get('system', 'have_ssl') ? 'true' : 'false'; $ssl = Config::get('system', 'have_ssl') ? 'true' : 'false';

View file

@ -22,7 +22,7 @@ function bookmarklet_content(App $a)
{ {
if (!local_user()) { if (!local_user()) {
$o = '<h2>' . L10n::t('Login') . '</h2>'; $o = '<h2>' . L10n::t('Login') . '</h2>';
$o .= Login::form($a->query_string, Config::get('config', 'register_policy') === REGISTER_CLOSED ? false : true); $o .= Login::form($a->query_string, intval(Config::get('config', 'register_policy')) === REGISTER_CLOSED ? false : true);
return $o; return $o;
} }

View file

@ -58,7 +58,7 @@ function friendica_init(App $a)
'url' => System::baseUrl(), 'url' => System::baseUrl(),
'addons' => $visible_addons, 'addons' => $visible_addons,
'locked_features' => $locked_features, 'locked_features' => $locked_features,
'register_policy' => $register_policy[Config::get('config', 'register_policy')], 'register_policy' => $register_policy[intval(Config::get('config', 'register_policy'))],
'admin' => $admin, 'admin' => $admin,
'site_name' => Config::get('config', 'sitename'), 'site_name' => Config::get('config', 'sitename'),
'platform' => FRIENDICA_PLATFORM, 'platform' => FRIENDICA_PLATFORM,

View file

@ -47,7 +47,7 @@ function home_content(App $a) {
} }
} }
$login = Login::form($a->query_string, Config::get('config', 'register_policy') === REGISTER_CLOSED ? 0 : 1); $login = Login::form($a->query_string, intval(Config::get('config', 'register_policy')) === REGISTER_CLOSED ? 0 : 1);
$content = ''; $content = '';
Addon::callHooks("home_content",$content); Addon::callHooks("home_content",$content);

View file

@ -126,14 +126,14 @@ function invite_content(App $a) {
$dirloc = Config::get('system', 'directory'); $dirloc = Config::get('system', 'directory');
if (strlen($dirloc)) { if (strlen($dirloc)) {
if (Config::get('config', 'register_policy') === REGISTER_CLOSED) { if (intval(Config::get('config', 'register_policy')) === REGISTER_CLOSED) {
$linktxt = L10n::t('Visit %s for a list of public sites that you can join. Friendica members on other sites can all connect with each other, as well as with members of many other social networks.', $dirloc . '/servers'); $linktxt = L10n::t('Visit %s for a list of public sites that you can join. Friendica members on other sites can all connect with each other, as well as with members of many other social networks.', $dirloc . '/servers');
} else { } else {
$linktxt = L10n::t('To accept this invitation, please visit and register at %s or any other public Friendica website.', System::baseUrl()) $linktxt = L10n::t('To accept this invitation, please visit and register at %s or any other public Friendica website.', System::baseUrl())
. "\r\n" . "\r\n" . L10n::t('Friendica sites all inter-connect to create a huge privacy-enhanced social web that is owned and controlled by its members. They can also connect with many traditional social networks. See %s for a list of alternate Friendica sites you can join.', $dirloc . '/servers'); . "\r\n" . "\r\n" . L10n::t('Friendica sites all inter-connect to create a huge privacy-enhanced social web that is owned and controlled by its members. They can also connect with many traditional social networks. See %s for a list of alternate Friendica sites you can join.', $dirloc . '/servers');
} }
} else { // there is no global directory URL defined } else { // there is no global directory URL defined
if (Config::get('config', 'register_policy') === REGISTER_CLOSED) { if (intval(Config::get('config', 'register_policy')) === REGISTER_CLOSED) {
$o = L10n::t('Our apologies. This system is not currently configured to connect with other public sites or invite members.'); $o = L10n::t('Our apologies. This system is not currently configured to connect with other public sites or invite members.');
return $o; return $o;
} else { } else {

View file

@ -61,7 +61,7 @@ function nodeinfo_init(App $a) {
$nodeinfo['usage'] = []; $nodeinfo['usage'] = [];
$nodeinfo['openRegistrations'] = Config::get('config', 'register_policy') !== REGISTER_CLOSED; $nodeinfo['openRegistrations'] = intval(Config::get('config', 'register_policy')) !== REGISTER_CLOSED;
$nodeinfo['metadata'] = ['nodeName' => Config::get('config', 'sitename')]; $nodeinfo['metadata'] = ['nodeName' => Config::get('config', 'sitename')];

View file

@ -62,7 +62,7 @@ function openid_content(App $a) {
// Successful OpenID login - but we can't match it to an existing account. // Successful OpenID login - but we can't match it to an existing account.
// New registration? // New registration?
if (Config::get('config', 'register_policy') === REGISTER_CLOSED) { if (intval(Config::get('config', 'register_policy')) === REGISTER_CLOSED) {
notice(L10n::t('Account not found and OpenID registration is not permitted on this site.') . EOL); notice(L10n::t('Account not found and OpenID registration is not permitted on this site.') . EOL);
goaway(System::baseUrl()); goaway(System::baseUrl());
} }

View file

@ -201,7 +201,7 @@ function ping_init(App $a)
); );
$mail_count = count($mails); $mail_count = count($mails);
if (Config::get('config', 'register_policy') === REGISTER_APPROVE && is_site_admin()) { if (intval(Config::get('config', 'register_policy')) === REGISTER_APPROVE && is_site_admin()) {
$regs = q( $regs = q(
"SELECT `contact`.`name`, `contact`.`url`, `contact`.`micro`, `register`.`created` "SELECT `contact`.`name`, `contact`.`url`, `contact`.`micro`, `register`.`created`
FROM `contact` RIGHT JOIN `register` ON `register`.`uid` = `contact`.`uid` FROM `contact` RIGHT JOIN `register` ON `register`.`uid` = `contact`.`uid`

View file

@ -74,7 +74,7 @@ function register_post(App $a)
$user = $result['user']; $user = $result['user'];
if ($netpublish && Config::get('config', 'register_policy') !== REGISTER_APPROVE) { if ($netpublish && intval(Config::get('config', 'register_policy')) !== REGISTER_APPROVE) {
$url = System::baseUrl() . '/profile/' . $user['nickname']; $url = System::baseUrl() . '/profile/' . $user['nickname'];
Worker::add(PRIORITY_LOW, "Directory", $url); Worker::add(PRIORITY_LOW, "Directory", $url);
} }
@ -83,7 +83,7 @@ function register_post(App $a)
$num_invites = Config::get('system', 'number_invites'); $num_invites = Config::get('system', 'number_invites');
$invite_id = ((x($_POST, 'invite_id')) ? notags(trim($_POST['invite_id'])) : ''); $invite_id = ((x($_POST, 'invite_id')) ? notags(trim($_POST['invite_id'])) : '');
if (Config::get('config', 'register_policy') === REGISTER_OPEN) { if (intval(Config::get('config', 'register_policy')) === REGISTER_OPEN) {
if ($using_invites && $invite_id) { if ($using_invites && $invite_id) {
q("delete * from register where hash = '%s' limit 1", dbesc($invite_id)); q("delete * from register where hash = '%s' limit 1", dbesc($invite_id));
PConfig::set($user['uid'], 'system', 'invites_remaining', $num_invites); PConfig::set($user['uid'], 'system', 'invites_remaining', $num_invites);
@ -109,7 +109,7 @@ function register_post(App $a)
info(L10n::t('Registration successful.') . EOL); info(L10n::t('Registration successful.') . EOL);
goaway(System::baseUrl()); goaway(System::baseUrl());
} }
} elseif (Config::get('config', 'register_policy') === REGISTER_APPROVE) { } elseif (intval(Config::get('config', 'register_policy')) === REGISTER_APPROVE) {
if (!strlen(Config::get('config', 'admin_email'))) { if (!strlen(Config::get('config', 'admin_email'))) {
notice(L10n::t('Your registration can not be processed.') . EOL); notice(L10n::t('Your registration can not be processed.') . EOL);
goaway(System::baseUrl()); goaway(System::baseUrl());
@ -177,7 +177,7 @@ function register_content(App $a)
return; return;
} }
if ((!local_user()) && (Config::get('config', 'register_policy') === REGISTER_CLOSED)) { if ((!local_user()) && (intval(Config::get('config', 'register_policy')) === REGISTER_CLOSED)) {
notice("Permission denied." . EOL); notice("Permission denied." . EOL);
return; return;
} }
@ -256,7 +256,7 @@ function register_content(App $a)
$o = replace_macros($tpl, [ $o = replace_macros($tpl, [
'$oidhtml' => $oidhtml, '$oidhtml' => $oidhtml,
'$invitations' => Config::get('system', 'invitation_only'), '$invitations' => Config::get('system', 'invitation_only'),
'$permonly' => Config::get('config', 'register_policy') === REGISTER_APPROVE, '$permonly' => intval(Config::get('config', 'register_policy')) === REGISTER_APPROVE,
'$permonlybox' => ['permonlybox', L10n::t('Note for the admin'), '', L10n::t('Leave a message for the admin, why you want to join this node')], '$permonlybox' => ['permonlybox', L10n::t('Note for the admin'), '', L10n::t('Leave a message for the admin, why you want to join this node')],
'$invite_desc' => L10n::t('Membership on this site is by invitation only.'), '$invite_desc' => L10n::t('Membership on this site is by invitation only.'),
'$invite_label' => L10n::t('Your invitation code: '), '$invite_label' => L10n::t('Your invitation code: '),

View file

@ -99,7 +99,7 @@ function regmod_content(App $a)
{ {
if (!local_user()) { if (!local_user()) {
info(L10n::t('Please login.') . EOL); info(L10n::t('Please login.') . EOL);
$o = '<br /><br />' . Login::form($a->query_string, Config::get('config', 'register_policy') === REGISTER_CLOSED ? 0 : 1); $o = '<br /><br />' . Login::form($a->query_string, intval(Config::get('config', 'register_policy')) === REGISTER_CLOSED ? 0 : 1);
return $o; return $o;
} }

View file

@ -20,7 +20,7 @@ function statistics_json_init(App $a) {
"name" => Config::get('config', 'sitename'), "name" => Config::get('config', 'sitename'),
"network" => FRIENDICA_PLATFORM, "network" => FRIENDICA_PLATFORM,
"version" => FRIENDICA_VERSION . "-" . DB_UPDATE_VERSION, "version" => FRIENDICA_VERSION . "-" . DB_UPDATE_VERSION,
"registrations_open" => Config::get('config', 'register_policy') !== REGISTER_CLOSED, "registrations_open" => intval(Config::get('config', 'register_policy')) !== REGISTER_CLOSED,
"total_users" => Config::get('nodeinfo', 'total_users'), "total_users" => Config::get('nodeinfo', 'total_users'),
"active_users_halfyear" => Config::get('nodeinfo', 'active_users_halfyear'), "active_users_halfyear" => Config::get('nodeinfo', 'active_users_halfyear'),
"active_users_monthly" => Config::get('nodeinfo', 'active_users_monthly'), "active_users_monthly" => Config::get('nodeinfo', 'active_users_monthly'),

View file

@ -42,7 +42,7 @@ function uimport_post(App $a)
function uimport_content(App $a) { function uimport_content(App $a) {
if ((!local_user()) && (Config::get('config', 'register_policy') === REGISTER_CLOSED)) { if ((!local_user()) && (intval(Config::get('config', 'register_policy')) === REGISTER_CLOSED)) {
notice("Permission denied." . EOL); notice("Permission denied." . EOL);
return; return;
} }

View file

@ -124,7 +124,7 @@ class Nav
$nav['home'] = [$homelink, L10n::t('Home'), '', L10n::t('Home Page')]; $nav['home'] = [$homelink, L10n::t('Home'), '', L10n::t('Home Page')];
} }
if ((Config::get('config', 'register_policy') === REGISTER_OPEN) && (! local_user()) && (! remote_user())) { if (intval(Config::get('config', 'register_policy')) === REGISTER_OPEN && !local_user() && !remote_user()) {
$nav['register'] = ['register', L10n::t('Register'), '', L10n::t('Create an account')]; $nav['register'] = ['register', L10n::t('Register'), '', L10n::t('Create an account')];
} }

View file

@ -43,7 +43,7 @@ class Login extends BaseModule
goaway(self::getApp()->get_baseurl()); goaway(self::getApp()->get_baseurl());
} }
return self::form(self::getApp()->get_baseurl(), Config::get('config', 'register_policy') !== REGISTER_CLOSED); return self::form(self::getApp()->get_baseurl(), intval(Config::get('config', 'register_policy')) !== REGISTER_CLOSED);
} }
public static function post() public static function post()