aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Module
diff options
context:
space:
mode:
Diffstat (limited to 'Zotlabs/Module')
-rw-r--r--Zotlabs/Module/Admin/Site.php29
-rw-r--r--Zotlabs/Module/Register.php38
2 files changed, 43 insertions, 24 deletions
diff --git a/Zotlabs/Module/Admin/Site.php b/Zotlabs/Module/Admin/Site.php
index cb919746b..879923132 100644
--- a/Zotlabs/Module/Admin/Site.php
+++ b/Zotlabs/Module/Admin/Site.php
@@ -5,6 +5,10 @@ namespace Zotlabs\Module\Admin;
class Site {
+ // system cfgs
+ const ivo = 'invitation_only';
+ const iva = 'invitation_also';
+
/**
* @brief POST handler for Admin Site Page.
*
@@ -42,8 +46,8 @@ class Site {
$minimum_age = ((x($_POST,'minimum_age')) ? intval(trim($_POST['minimum_age'])) : 13);
$access_policy = ((x($_POST,'access_policy')) ? intval(trim($_POST['access_policy'])) : 0);
$reg_autochannel = ((x($_POST,'auto_channel_create')) ? True : False);
- $invite_only = ((x($_POST,'invite_only')) ? True : False);
- $invite_also = ((x($_POST,'invite_also')) ? True : False);
+ $invitation_only = ((x($_POST,'invitation_only')) ? True : False);
+ $invitation_also = ((x($_POST,'invitation_also')) ? True : False);
$abandon_days = ((x($_POST,'abandon_days')) ? intval(trim($_POST['abandon_days'])) : 0);
$register_text = ((x($_POST,'register_text')) ? notags(trim($_POST['register_text'])) : '');
@@ -192,8 +196,8 @@ class Site {
set_config('system','register_policy', $register_policy);
set_config('system','minimum_age', $minimum_age);
set_config('system','auto_channel_create', $reg_autochannel);
- set_config('system','invitation_only', $invite_only);
- set_config('system','invitation_also', $invite_also);
+ set_config('system',self::ivo, $invitation_only);
+ set_config('system',self::iva, $invitation_also);
set_config('system','access_policy', $access_policy);
set_config('system','account_abandon_days', $abandon_days);
set_config('system','register_text', $register_text);
@@ -399,6 +403,8 @@ class Site {
'rabot' => $reg_rabots
)
);
+ $invitation_only = get_config('system',self::ivo);
+ $invitation_also = get_config('system',self::iva);
$tao = '';
$t = get_markup_template("admin_site.tpl");
@@ -478,16 +484,19 @@ class Site {
get_config('system','auto_channel_create'),
t("Auto create a channel when register a new account. When On, the register form will show additional fields for the channel-name and the nickname."),
"", "", 'ZAR0870C'),
- '$invite_only' => array('invite_only',
- t("Invitation only"),
- get_config('system','invitation_only'),
+
+ '$invitation_only' => array(self::ivo,
+ ($invitation_only === false ? '✗' : '✓') . ' ' . t("Invitation only"),
+ $invitation_only,
t("Only allow new member registrations with an invitation code. Above register policy must be set to Yes."),
"", "", 'ZAR0880C'),
- '$invite_also' => array('invite_also',
- t("Invitation also"),
- get_config('system','invitation_also'),
+
+ '$invitation_also' => array(self::iva,
+ ($invitation_also === false ? '✗' : '✓') . ' ' . t("Invitation also"),
+ $invitation_also,
t("Also allow new member registrations with an invitation code. Above register policy must be set to Yes."),
"", "", 'ZAR0881C'),
+
'$verify_email' => array('verify_email',
t("Verify Email Addresses"),
get_config('system','verify_email'),
diff --git a/Zotlabs/Module/Register.php b/Zotlabs/Module/Register.php
index 60d08caf0..64db7a253 100644
--- a/Zotlabs/Module/Register.php
+++ b/Zotlabs/Module/Register.php
@@ -109,7 +109,7 @@ class Register extends Controller {
}
// s2 max daily
- if ( self::check_max_daily_exceeded() ) return;
+ if ( self::check_reg_limits() ) return;
// accept tos
if(! x($_POST,'tos')) {
@@ -423,8 +423,9 @@ class Register extends Controller {
$invitations = true;
}
- if ( self::check_max_daily_exceeded() )
- $duty['atform'] = 'disabled';
+ $opal = self::check_reg_limits();
+ if ( $opal['is'])
+ $duty['atform'] = 'disabled';
$privacy_role = ((x($_REQUEST,'permissions_role')) ? $_REQUEST['permissions_role'] : "");
@@ -496,6 +497,7 @@ class Register extends Controller {
'$reg_is' => $registration_is,
'$registertext' => bbcode(get_config('system','register_text')),
'$other_sites' => $other_sites,
+ '$msg' => $opal['rn'] . ',' . $opal['an'],
'$invitations' => $invitations,
'$invite_code' => $invite_code,
'$haveivc' => t('I have an invite code') . '.<sup>ZAR0134I</sup>',
@@ -521,28 +523,36 @@ class Register extends Controller {
return $o;
}
- function check_max_daily_exceeded() {
+ function check_reg_limits() {
// check against register, account
+ $rear = array( 'is' => false, 'rn' => 0, 'an' => 0, 'msg' => '' );
+
$max_dailies = intval(get_config('system','max_daily_registrations'));
+
if ( $max_dailies ) {
+
$r = q("SELECT COUNT(reg_id) AS nr FROM register WHERE reg_vital = 1 AND reg_created > %s - INTERVAL %s",
db_utcnow(), db_quoteinterval('1 day')
);
- $re = ( $r && $r[0]['nr'] >= $max_dailies ) ? true : false;
- if ( !$re ) {
+
+ $rear['is'] = ( $r && $r[0]['nr'] >= $max_dailies ) ? true : false;
+ $rear['rn'] = $r[0]['nr'];
+
+ if ( !$rear['is']) {
$r = q("SELECT COUNT(account_id) AS nr FROM account WHERE account_created > %s - INTERVAL %s",
db_utcnow(), db_quoteinterval('1 day')
);
- $re = ( $r && $r[0]['nr'] >= $max_dailies ) ? true : false;
+
+ $rear['is'] = ( $r && ($r[0]['nr'] + $rear['rn']) >= $max_dailies ) ? true : false;
+ $rear['ra'] = $r[0]['nr'];
}
- if ( $re ) {
- zar_log('ZAR0333W max daily registrations exceeded.');
- notice( 'ZAR0333W '
- . t('This site has exceeded the number of allowed daily account registrations. Please try again tomorrow.')
- . EOL);
- return true;
+
+ if ( $rear['is']) {
+ $rear['msg'] = 'ZAR0333W ' . t('This site has exceeded the number of allowed daily account registrations');
+ zar_log($msg);
+ $rear['is'] = true;
}
}
- return false;
+ return $rear;
}
}