diff --git a/config/local-sample.config.php b/config/local-sample.config.php
index 996c27a66..9b977ff53 100644
--- a/config/local-sample.config.php
+++ b/config/local-sample.config.php
@@ -34,7 +34,7 @@ return [
'config' => [
'admin_email' => '',
'sitename' => 'Friendica Social Network',
- 'register_policy' => REGISTER_OPEN,
+ 'register_policy' => \Friendica\Module\Register::OPEN,
'register_text' => '',
],
'system' => [
diff --git a/config/settings.config.php b/config/settings.config.php
index 2893b3f20..6e3fa6a89 100644
--- a/config/settings.config.php
+++ b/config/settings.config.php
@@ -16,10 +16,11 @@ return [
'info' => '',
// register_policy (Constant)
- // Your choices are REGISTER_OPEN, REGISTER_APPROVE, or REGISTER_CLOSED.
- // Be certain to create your own personal account before setting REGISTER_CLOSED.
- // REGISTER_APPROVE requires you set system.admin_email to the email address of an already registered person who can authorize and/or approve/deny the request.
- 'register_policy' => REGISTER_CLOSED,
+ // Your choices are OPEN, APPROVE, or CLOSED.
+ // Be certain to create your own personal account before setting CLOSED.
+ // APPROVE requires you set system.admin_email to the email address of an
+ // already registered person who can authorize and/or approve/deny the request.
+ 'register_policy' => \Friendica\Module\Register::CLOSED,
// register_text (String)
// Will be displayed prominently on the registration page.
diff --git a/include/api.php b/include/api.php
index 4452ebfb9..052d32b17 100644
--- a/include/api.php
+++ b/include/api.php
@@ -3557,7 +3557,7 @@ function api_statusnet_config($type)
$server = $a->getHostName();
$logo = System::baseUrl() . '/images/friendica-64.png';
$email = Config::get('config', 'admin_email');
- $closed = intval(Config::get('config', 'register_policy')) === REGISTER_CLOSED ? 'true' : 'false';
+ $closed = intval(Config::get('config', 'register_policy')) === \Friendica\Module\Register::CLOSED ? '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));
$ssl = Config::get('system', 'have_ssl') ? 'true' : 'false';
diff --git a/mod/admin.php b/mod/admin.php
index e5dbf12f2..97d7a8bfd 100644
--- a/mod/admin.php
+++ b/mod/admin.php
@@ -26,6 +26,7 @@ use Friendica\Model\Contact;
use Friendica\Model\Item;
use Friendica\Model\Register;
use Friendica\Model\User;
+use Friendica\Module;
use Friendica\Module\Login;
use Friendica\Module\Tos;
use Friendica\Util\Arrays;
@@ -1509,9 +1510,9 @@ function admin_page_site(App $a)
/* Register policy */
$register_choices = [
- REGISTER_CLOSED => L10n::t("Closed"),
- REGISTER_APPROVE => L10n::t("Requires approval"),
- REGISTER_OPEN => L10n::t("Open")
+ Module\Register::CLOSED => L10n::t("Closed"),
+ Module\Register::APPROVE => L10n::t("Requires approval"),
+ Module\Register::OPEN => L10n::t("Open")
];
$ssl_choices = [
diff --git a/mod/bookmarklet.php b/mod/bookmarklet.php
index be3e1fd33..1c4d191c4 100644
--- a/mod/bookmarklet.php
+++ b/mod/bookmarklet.php
@@ -20,7 +20,7 @@ function bookmarklet_content(App $a)
{
if (!local_user()) {
$o = '
' . L10n::t('Login') . '
';
- $o .= Login::form($a->query_string, intval(Config::get('config', 'register_policy')) === REGISTER_CLOSED ? false : true);
+ $o .= Login::form($a->query_string, intval(Config::get('config', 'register_policy')) === \Friendica\Module\Register::CLOSED ? false : true);
return $o;
}
diff --git a/mod/friendica.php b/mod/friendica.php
index 686e2e804..2b51ac858 100644
--- a/mod/friendica.php
+++ b/mod/friendica.php
@@ -10,16 +10,22 @@ use Friendica\Core\Hook;
use Friendica\Core\L10n;
use Friendica\Core\System;
use Friendica\Database\DBA;
+use Friendica\Module\Register;
function friendica_init(App $a)
{
if (!empty($a->argv[1]) && ($a->argv[1] == "json")) {
- $register_policies = ['REGISTER_CLOSED', 'REGISTER_APPROVE', 'REGISTER_OPEN'];
+ $register_policies = [
+ Register::CLOSED => 'REGISTER_CLOSED',
+ Register::APPROVE => 'REGISTER_APPROVE',
+ Register::OPEN => 'REGISTER_OPEN'
+ ];
- $register_policy = $register_policies[intval(Config::get('config', 'register_policy'))];
-
- if ($register_policy == 'REGISTER_OPEN' && Config::get('config', 'invitation_only')) {
+ $register_policy_int = intval(Config::get('config', 'register_policy'));
+ if ($register_policy_int === Register::OPEN && Config::get('config', 'invitation_only')) {
$register_policy = 'REGISTER_INVITATION';
+ } else {
+ $register_policy = $register_policies[$register_policy_int];
}
$sql_extra = '';
diff --git a/mod/home.php b/mod/home.php
index 34f6d4368..9f1810120 100644
--- a/mod/home.php
+++ b/mod/home.php
@@ -48,7 +48,7 @@ function home_content(App $a) {
}
}
- $login = Login::form($a->query_string, intval(Config::get('config', 'register_policy')) === REGISTER_CLOSED ? 0 : 1);
+ $login = Login::form($a->query_string, intval(Config::get('config', 'register_policy')) === \Friendica\Module\Register::CLOSED ? 0 : 1);
$content = '';
Hook::callAll("home_content",$content);
diff --git a/mod/invite.php b/mod/invite.php
index 3b1667a79..e8901d071 100644
--- a/mod/invite.php
+++ b/mod/invite.php
@@ -13,6 +13,7 @@ use Friendica\Core\L10n;
use Friendica\Core\PConfig;
use Friendica\Core\Renderer;
use Friendica\Core\System;
+use Friendica\Module\Register;
use Friendica\Protocol\Email;
use Friendica\Util\Strings;
@@ -125,14 +126,14 @@ function invite_content(App $a) {
$dirloc = Config::get('system', 'directory');
if (strlen($dirloc)) {
- if (intval(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');
} else {
$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');
}
} else { // there is no global directory URL defined
- if (intval(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.');
return $o;
} else {
diff --git a/mod/nodeinfo.php b/mod/nodeinfo.php
index 5c25b6e55..39f430f92 100644
--- a/mod/nodeinfo.php
+++ b/mod/nodeinfo.php
@@ -59,7 +59,7 @@ function nodeinfo_init(App $a) {
$nodeinfo['usage'] = [];
- $nodeinfo['openRegistrations'] = intval(Config::get('config', 'register_policy')) !== REGISTER_CLOSED;
+ $nodeinfo['openRegistrations'] = intval(Config::get('config', 'register_policy')) !== \Friendica\Module\Register::CLOSED;
$nodeinfo['metadata'] = ['nodeName' => Config::get('config', 'sitename')];
diff --git a/mod/openid.php b/mod/openid.php
index d20258fa9..7300c686b 100644
--- a/mod/openid.php
+++ b/mod/openid.php
@@ -63,7 +63,7 @@ function openid_content(App $a) {
// Successful OpenID login - but we can't match it to an existing account.
// New registration?
- if (intval(Config::get('config', 'register_policy')) === REGISTER_CLOSED) {
+ if (intval(Config::get('config', 'register_policy')) === \Friendica\Module\Register::CLOSED) {
notice(L10n::t('Account not found and OpenID registration is not permitted on this site.') . EOL);
$a->internalRedirect();
}
diff --git a/mod/ping.php b/mod/ping.php
index 8b50b78c8..b89cb9246 100644
--- a/mod/ping.php
+++ b/mod/ping.php
@@ -188,7 +188,7 @@ function ping_init(App $a)
);
$mail_count = count($mails);
- if (intval(Config::get('config', 'register_policy')) === REGISTER_APPROVE && is_site_admin()) {
+ if (intval(Config::get('config', 'register_policy')) === \Friendica\Module\Register::APPROVE && is_site_admin()) {
$regs = Friendica\Model\Register::getPending();
if (DBA::isResult($regs)) {
diff --git a/mod/regmod.php b/mod/regmod.php
index e03f28e85..6cf4c8836 100644
--- a/mod/regmod.php
+++ b/mod/regmod.php
@@ -82,7 +82,7 @@ function regmod_content(App $a)
{
if (!local_user()) {
info(L10n::t('Please login.') . EOL);
- return Login::form($a->query_string, intval(Config::get('config', 'register_policy')) === REGISTER_CLOSED ? 0 : 1);
+ return Login::form($a->query_string, intval(Config::get('config', 'register_policy')) === \Friendica\Module\Register::CLOSED ? 0 : 1);
}
if (!is_site_admin() || !empty($_SESSION['submanage'])) {
diff --git a/mod/statistics_json.php b/mod/statistics_json.php
index 833b2e9a8..a8d3c8a5f 100644
--- a/mod/statistics_json.php
+++ b/mod/statistics_json.php
@@ -16,11 +16,15 @@ function statistics_json_init(App $a) {
System::httpExit(404);
}
+ $registration_open =
+ intval(Config::get('config', 'register_policy')) !== \Friendica\Module\Register::CLOSED
+ && ! Config::get('config', 'invitation_only');
+
$statistics = [
"name" => Config::get('config', 'sitename'),
"network" => FRIENDICA_PLATFORM,
"version" => FRIENDICA_VERSION . "-" . DB_UPDATE_VERSION,
- "registrations_open" => intval(Config::get('config', 'register_policy')) !== REGISTER_CLOSED,
+ "registrations_open" => $registration_open,
"total_users" => Config::get('nodeinfo', 'total_users'),
"active_users_halfyear" => Config::get('nodeinfo', 'active_users_halfyear'),
"active_users_monthly" => Config::get('nodeinfo', 'active_users_monthly'),
diff --git a/mod/uimport.php b/mod/uimport.php
index dfeab8a2f..22a316155 100644
--- a/mod/uimport.php
+++ b/mod/uimport.php
@@ -13,7 +13,7 @@ use Friendica\Core\Renderer;
function uimport_post(App $a)
{
- if ((Config::get('config', 'register_policy') != REGISTER_OPEN) && !is_site_admin()) {
+ if ((Config::get('config', 'register_policy') != \Friendica\Module\Register::OPEN) && !is_site_admin()) {
notice(L10n::t('Permission denied.') . EOL);
return;
}
@@ -26,7 +26,7 @@ function uimport_post(App $a)
function uimport_content(App $a)
{
- if ((Config::get('config', 'register_policy') != REGISTER_OPEN) && !is_site_admin()) {
+ if ((Config::get('config', 'register_policy') != \Friendica\Module\Register::OPEN) && !is_site_admin()) {
notice(L10n::t('User imports on closed servers can only be done by an administrator.') . EOL);
return;
}
diff --git a/mods/local.config.vagrant.php b/mods/local.config.vagrant.php
index 099500200..a9b95d02d 100644
--- a/mods/local.config.vagrant.php
+++ b/mods/local.config.vagrant.php
@@ -31,7 +31,7 @@ return [
'config' => [
'admin_email' => 'admin@friendica.local',
'sitename' => 'Friendica Social Network',
- 'register_policy' => REGISTER_OPEN,
+ 'register_policy' => \Friendica\Module\Register::OPEN,
'register_text' => '',
],
'system' => [
diff --git a/src/Content/Nav.php b/src/Content/Nav.php
index b72f4dc04..1eae2a3e3 100644
--- a/src/Content/Nav.php
+++ b/src/Content/Nav.php
@@ -180,7 +180,7 @@ class Nav
$nav['home'] = [$homelink, L10n::t('Home'), '', L10n::t('Home Page')];
}
- if (intval(Config::get('config', 'register_policy')) === REGISTER_OPEN && !local_user() && !remote_user()) {
+ if (intval(Config::get('config', 'register_policy')) === \Friendica\Module\Register::OPEN && !local_user() && !remote_user()) {
$nav['register'] = ['register', L10n::t('Register'), '', L10n::t('Create an account')];
}
diff --git a/src/Module/Login.php b/src/Module/Login.php
index 96b0c428f..b0897f2d7 100644
--- a/src/Module/Login.php
+++ b/src/Module/Login.php
@@ -43,7 +43,7 @@ class Login extends BaseModule
$a->internalRedirect();
}
- return self::form(defaults($_SESSION, 'return_path', null), intval(Config::get('config', 'register_policy')) !== REGISTER_CLOSED);
+ return self::form(defaults($_SESSION, 'return_path', null), intval(Config::get('config', 'register_policy')) !== \Friendica\Module\Register::CLOSED);
}
public static function post()
diff --git a/src/Protocol/PortableContact.php b/src/Protocol/PortableContact.php
index 4b8b6fff6..0bc17d3dc 100644
--- a/src/Protocol/PortableContact.php
+++ b/src/Protocol/PortableContact.php
@@ -20,6 +20,7 @@ use Friendica\Core\Worker;
use Friendica\Database\DBA;
use Friendica\Model\GContact;
use Friendica\Model\Profile;
+use Friendica\Module\Register;
use Friendica\Network\Probe;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network;
@@ -705,10 +706,10 @@ class PortableContact
$server = [];
- $server['register_policy'] = REGISTER_CLOSED;
+ $server['register_policy'] = Register::CLOSED;
if (is_bool($nodeinfo['openRegistrations']) && $nodeinfo['openRegistrations']) {
- $server['register_policy'] = REGISTER_OPEN;
+ $server['register_policy'] = Register::OPEN;
}
if (is_array($nodeinfo['software'])) {
@@ -789,10 +790,10 @@ class PortableContact
$server = [];
- $server['register_policy'] = REGISTER_CLOSED;
+ $server['register_policy'] = Register::CLOSED;
if (is_bool($nodeinfo['openRegistrations']) && $nodeinfo['openRegistrations']) {
- $server['register_policy'] = REGISTER_OPEN;
+ $server['register_policy'] = Register::OPEN;
}
if (is_array($nodeinfo['software'])) {
@@ -1192,16 +1193,16 @@ class PortableContact
if (!empty($data['register_policy'])) {
switch ($data['register_policy']) {
case "REGISTER_OPEN":
- $register_policy = REGISTER_OPEN;
+ $register_policy = Register::OPEN;
break;
case "REGISTER_APPROVE":
- $register_policy = REGISTER_APPROVE;
+ $register_policy = Register::APPROVE;
break;
case "REGISTER_CLOSED":
default:
- $register_policy = REGISTER_CLOSED;
+ $register_policy = Register::CLOSED;
break;
}
}
@@ -1267,11 +1268,11 @@ class PortableContact
}
if (!$closed && !$private and $inviteonly) {
- $register_policy = REGISTER_APPROVE;
+ $register_policy = Register::APPROVE;
} elseif (!$closed && !$private) {
- $register_policy = REGISTER_OPEN;
+ $register_policy = Register::OPEN;
} else {
- $register_policy = REGISTER_CLOSED;
+ $register_policy = Register::CLOSED;
}
}
}
@@ -1305,9 +1306,9 @@ class PortableContact
}
if (!empty($data['registrations_open']) && $data['registrations_open']) {
- $register_policy = REGISTER_OPEN;
+ $register_policy = Register::OPEN;
} else {
- $register_policy = REGISTER_CLOSED;
+ $register_policy = Register::CLOSED;
}
}
}
@@ -1367,13 +1368,27 @@ class PortableContact
}
$info = defaults($data, 'info', '');
- $register_policy = defaults($data, 'register_policy', REGISTER_CLOSED);
- if (in_array($register_policy, ['REGISTER_CLOSED', 'REGISTER_APPROVE', 'REGISTER_OPEN'])) {
- $register_policy = constant($register_policy);
- } else {
- Logger::log("Register policy '$register_policy' from $server_url is invalid.");
- $register_policy = REGISTER_CLOSED; // set a default value
+
+ $register_policy = defaults($data, 'register_policy', 'REGISTER_CLOSED');
+ switch ($register_policy) {
+ case 'REGISTER_OPEN':
+ $register_policy = Register::OPEN;
+ break;
+
+ case 'REGISTER_APPROVE':
+ $register_policy = Register::APPROVE;
+ break;
+
+ default:
+ Logger::log("Register policy '$register_policy' from $server_url is invalid.");
+ // Defaulting to closed
+
+ case 'REGISTER_CLOSED':
+ case 'REGISTER_INVITATION':
+ $register_policy = Register::CLOSED;
+ break;
}
+
$platform = defaults($data, 'platform', '');
}
}
diff --git a/tests/src/Core/Console/AutomaticInstallationConsoleTest.php b/tests/src/Core/Console/AutomaticInstallationConsoleTest.php
index 813277ebb..361608d37 100644
--- a/tests/src/Core/Console/AutomaticInstallationConsoleTest.php
+++ b/tests/src/Core/Console/AutomaticInstallationConsoleTest.php
@@ -209,7 +209,7 @@ return [
'config' => [
'admin_email' => '',
'sitename' => 'Friendica Social Network',
- 'register_policy' => REGISTER_OPEN,
+ 'register_policy' => \Friendica\Module\Register::OPEN,
'register_text' => '',
],
'system' => [
diff --git a/view/templates/local.config.tpl b/view/templates/local.config.tpl
index 54ff279f3..c4c4afba4 100644
--- a/view/templates/local.config.tpl
+++ b/view/templates/local.config.tpl
@@ -24,7 +24,7 @@ return [
'php_path' => '{{$phpath}}',
'admin_email' => '{{$adminmail}}',
'sitename' => 'Friendica Social Network',
- 'register_policy' => REGISTER_OPEN,
+ 'register_policy' => \Friendica\Module\Register::OPEN,
'max_import_size' => 200000,
],
'system' => [