aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2021-04-08 12:38:38 +0000
committerMario <mario@mariovavti.com>2021-04-08 12:38:38 +0000
commitcf62e07bec8ffe6b9e5c92d56c13ee3cbe06b5bf (patch)
treef9842fdf61038c023bd6088576f40f893850256c
parentec4526b5f47af05bc0ffe0bb5f997d3d82b14b5a (diff)
downloadvolse-hubzilla-cf62e07bec8ffe6b9e5c92d56c13ee3cbe06b5bf.tar.gz
volse-hubzilla-cf62e07bec8ffe6b9e5c92d56c13ee3cbe06b5bf.tar.bz2
volse-hubzilla-cf62e07bec8ffe6b9e5c92d56c13ee3cbe06b5bf.zip
register: default to auto-create channel and fix auto create channel if register approval is configured
-rw-r--r--Zotlabs/Module/Admin/Accounts.php38
-rw-r--r--Zotlabs/Module/Admin/Site.php2
-rw-r--r--Zotlabs/Module/Regate.php14
-rw-r--r--Zotlabs/Module/Register.php11
-rw-r--r--include/account.php2
5 files changed, 48 insertions, 19 deletions
diff --git a/Zotlabs/Module/Admin/Accounts.php b/Zotlabs/Module/Admin/Accounts.php
index 856ff9155..ac46c43aa 100644
--- a/Zotlabs/Module/Admin/Accounts.php
+++ b/Zotlabs/Module/Admin/Accounts.php
@@ -70,18 +70,44 @@ class Accounts {
intval($_SESSION[self::MYP]['i'][$zarat])
);
if ($rs && ($rs[0]['reg_flags'] & ~ 48) == 0) {
-
// create account
- $rc='ok'.$rs[0]['reg_id'];
+ $rc = 'ok'.$rs[0]['reg_id'];
$ac = create_account_from_register($rs[0]);
- if ( $ac['success'] ) $rc .= '✔';
+ if ( $ac['success'] ) {
+ $rc .= '✔';
+
+ $auto_create = get_config('system','auto_channel_create',1);
+
+ if($auto_create) {
+ $reonar = json_decode($rs[0]['reg_stuff'], true);
+ // prepare channel creation
+ if($reonar['chan.name'])
+ set_aconfig($ac['account']['account_id'], 'register', 'channel_name', $reonar['chan.name']);
+
+ if($reonar['chan.did1'])
+ set_aconfig($ac['account']['account_id'], 'register', 'channel_address', $reonar['chan.did1']);
+
+ $permissions_role = get_config('system','default_permissions_role');
+ if($permissions_role)
+ set_aconfig($ac['account']['account_id'], 'register', 'permissions_role', $permissions_role);
+ // create channel
+ $new_channel = auto_channel_create($ac['account']['account_id']);
+
+ if($new_channel['success']) {
+ $rc .= ' c,ok' . $new_channel['channel']['channel_id'] . '✔';
+ }
+ else {
+ $rc .= ' c ×';
+ }
+ }
+
+
+ }
} else {
- $rc='oh×';
+ $rc='oh ×';
}
}
-
- //
echo json_encode(array('re' => $zarop, 'at' => '_' . $zarat, 'rc' => $rc));
}
killme();
diff --git a/Zotlabs/Module/Admin/Site.php b/Zotlabs/Module/Admin/Site.php
index 87226295b..73c24897f 100644
--- a/Zotlabs/Module/Admin/Site.php
+++ b/Zotlabs/Module/Admin/Site.php
@@ -491,7 +491,7 @@ class Site {
'$reg_expire'=>$reg_expire,
'$reg_autochannel' => array('auto_channel_create',
t("Auto channel create"),
- get_config('system','auto_channel_create'),
+ get_config('system','auto_channel_create', 1),
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'),
diff --git a/Zotlabs/Module/Regate.php b/Zotlabs/Module/Regate.php
index d51927de1..6d9d5dc28 100644
--- a/Zotlabs/Module/Regate.php
+++ b/Zotlabs/Module/Regate.php
@@ -139,18 +139,22 @@ class Regate extends \Zotlabs\Web\Controller {
// zar_log($msg . ':' . print_r($cra, true));
zar_log($msg . ' ' . $cra['account']['account_email']
. ' ' . $cra['account']['account_language']);
+
$nextpage = 'new_channel';
- $auto_create = (get_config('system','auto_channel_create') ? true : false);
+ $auto_create = get_config('system','auto_channel_create',1);
if($auto_create) {
// prepare channel creation
if($reonar['chan.name'])
- set_aconfig($cra['account']['account_id'],
- 'register','channel_name',$reonar['chan.name']);
+ set_aconfig($cra['account']['account_id'], 'register', 'channel_name', $reonar['chan.name']);
+
if($reonar['chan.did1'])
- set_aconfig($cra['account']['account_id'],
- 'register','channel_address',$reonar['chan.did1']);
+ set_aconfig($cra['account']['account_id'], 'register', 'channel_address', $reonar['chan.did1']);
+
+ $permissions_role = get_config('system','default_permissions_role');
+ if($permissions_role)
+ set_aconfig($cra['account']['account_id'], 'register', 'permissions_role', $permissions_role);
}
authenticate_success($cra['account'],null,true,false,true);
diff --git a/Zotlabs/Module/Register.php b/Zotlabs/Module/Register.php
index 373695c9d..d076d9ccf 100644
--- a/Zotlabs/Module/Register.php
+++ b/Zotlabs/Module/Register.php
@@ -171,11 +171,10 @@ class Register extends Controller {
}
- $policy = intval(get_config('system','register_policy'));
- $invonly = intval(get_config('system','invitation_only'));
- $invalso = intval(get_config('system','invitation_also'));
- $auto_create = (get_config('system','auto_channel_create') ? true : false);
- $auto_create = true;
+ $policy = get_config('system','register_policy');
+ $invonly = get_config('system','invitation_only');
+ $invalso = get_config('system','invitation_also');
+ $auto_create = get_config('system','auto_channel_create', 1);
switch($policy) {
@@ -521,7 +520,7 @@ class Register extends Controller {
$enable_tos = 1 - intval(get_config('system','no_termsofservice'));
- $auto_create = (get_config('system','auto_channel_create') ? true : false);
+ $auto_create = get_config('system', 'auto_channel_create', 1);
$default_role = get_config('system','default_permissions_role');
$email_verify = get_config('system','verify_email');
diff --git a/include/account.php b/include/account.php
index 7f8a8a2bf..10131c5d4 100644
--- a/include/account.php
+++ b/include/account.php
@@ -688,7 +688,7 @@ function account_allow($hash) {
pop_lang();
- if(get_config('system','auto_channel_create'))
+ if(get_config('system', 'auto_channel_create', 1))
auto_channel_create($register[0]['uid']);
if ($res) {