'auto channel creation' - if the corresponding config variable is set, create a channel when an account is created.
Plugins can provide the necessary channel details (probably from an extended registration form). If no details are provided, a social (mostly public) channel will be created using the LHS of the email address and you will be directed to your channel page (unless email verification is required, in which case this step will be delayed until successful validation and login). If the reddress is already assigned a random name(1000-9999) reddress will be assigned.
This commit is contained in:
parent
bbc1a1f1fb
commit
baedd25309
2
boot.php
2
boot.php
@ -48,7 +48,7 @@ require_once('include/AccessList.php');
|
||||
|
||||
define ( 'PLATFORM_NAME', 'hubzilla' );
|
||||
define ( 'RED_VERSION', trim(file_get_contents('version.inc')));
|
||||
define ( 'STD_VERSION', '1.1' );
|
||||
define ( 'STD_VERSION', '1.1.1' );
|
||||
define ( 'ZOT_REVISION', 1 );
|
||||
|
||||
define ( 'DB_UPDATE_VERSION', 1161 );
|
||||
|
@ -11,6 +11,7 @@ require_once('include/text.php');
|
||||
require_once('include/language.php');
|
||||
require_once('include/datetime.php');
|
||||
require_once('include/crypto.php');
|
||||
require_once('include/identity.php');
|
||||
|
||||
|
||||
function check_account_email($email) {
|
||||
@ -329,7 +330,7 @@ function send_reg_approval_email($arr) {
|
||||
return($delivered ? true : false);
|
||||
}
|
||||
|
||||
function send_verification_email($email,$password) {
|
||||
function send_register_success_email($email,$password) {
|
||||
|
||||
$email_msg = replace_macros(get_intltext_template('register_open_eml.tpl'), array(
|
||||
'$sitename' => get_config('system','sitename'),
|
||||
@ -353,7 +354,7 @@ function send_verification_email($email,$password) {
|
||||
* @param string $hash
|
||||
* @return array|boolean
|
||||
*/
|
||||
function user_allow($hash) {
|
||||
function account_allow($hash) {
|
||||
|
||||
$ret = array('success' => false);
|
||||
|
||||
@ -406,6 +407,9 @@ function user_allow($hash) {
|
||||
|
||||
pop_lang();
|
||||
|
||||
if(get_config('system','auto_channel_create'))
|
||||
auto_channel_create($register[0]['uid']);
|
||||
|
||||
if ($res) {
|
||||
info( t('Account approved.') . EOL );
|
||||
return true;
|
||||
@ -414,7 +418,7 @@ function user_allow($hash) {
|
||||
|
||||
|
||||
/**
|
||||
* @brief Denies a user registration.
|
||||
* @brief Denies an account registration.
|
||||
*
|
||||
* This does not have to go through user_remove() and save the nickname
|
||||
* permanently against re-registration, as the person was not yet
|
||||
@ -423,7 +427,8 @@ function user_allow($hash) {
|
||||
* @param string $hash
|
||||
* @return boolean
|
||||
*/
|
||||
function user_deny($hash) {
|
||||
|
||||
function account_deny($hash) {
|
||||
|
||||
$register = q("SELECT * FROM register WHERE hash = '%s' LIMIT 1",
|
||||
dbesc($hash)
|
||||
@ -452,11 +457,14 @@ function user_deny($hash) {
|
||||
|
||||
}
|
||||
|
||||
// called from regver to activate an account from the email verification link
|
||||
|
||||
function user_approve($hash) {
|
||||
function account_approve($hash) {
|
||||
|
||||
$ret = array('success' => false);
|
||||
|
||||
// Note: when the password in the register table is 'verify', the uid actually contains the account_id
|
||||
|
||||
$register = q("SELECT * FROM `register` WHERE `hash` = '%s' and password = 'verify' LIMIT 1",
|
||||
dbesc($hash)
|
||||
);
|
||||
@ -491,6 +499,10 @@ function user_approve($hash) {
|
||||
intval($register[0]['uid'])
|
||||
);
|
||||
|
||||
|
||||
if(get_config('system','auto_channel_create'))
|
||||
auto_channel_create($register[0]['uid']);
|
||||
|
||||
info( t('Account verified. Please login.') . EOL );
|
||||
|
||||
return true;
|
||||
|
@ -1695,3 +1695,45 @@ function profiles_build_sync($channel_id) {
|
||||
build_sync_packet($channel_id,array('profile' => $r));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function auto_channel_create($account_id) {
|
||||
|
||||
if(! $account_id)
|
||||
return false;
|
||||
|
||||
$arr = array();
|
||||
$arr['account_id'] = $account_id;
|
||||
$arr['name'] = get_aconfig($account_id,'register','channel_name');
|
||||
$arr['nickname'] = legal_webbie(get_aconfig($account_id,'register','channel_address'));
|
||||
$arr['permissions_role'] = get_aconfig($account_id,'register','permissions_role');
|
||||
|
||||
del_aconfig($account_id,'register','channel_name');
|
||||
del_aconfig($account_id,'register','channel_address');
|
||||
del_aconfig($account_id,'register','permissions_role');
|
||||
|
||||
if((! $arr['name']) || (! $arr['nickname'])) {
|
||||
$x = q("select * from account where account_id = %d limit 1",
|
||||
intval($account_id)
|
||||
);
|
||||
if($x) {
|
||||
if(! $arr['name'])
|
||||
$arr['name'] = substr($x[0]['account_email'],0,strpos($x[0]['account_email'],'@'));
|
||||
if(! $arr['nickname'])
|
||||
$arr['nickname'] = legal_webbie(substr($x[0]['account_email'],0,strpos($x[0]['account_email'],'@')));
|
||||
}
|
||||
}
|
||||
if(! $arr['permissions_role'])
|
||||
$arr['permissions_role'] = 'social';
|
||||
|
||||
if(validate_channelname($arr['name']))
|
||||
return false;
|
||||
if($arr['nickname'] === 'sys')
|
||||
$arr['nickname'] = $arr['nickname'] . mt_rand(1000,9999);
|
||||
|
||||
$arr['nickname'] = check_webbie(array($arr['nickname'], $arr['nickname'] . mt_rand(1000,9999)));
|
||||
|
||||
return create_identity($arr);
|
||||
|
||||
}
|
||||
|
||||
|
@ -336,11 +336,13 @@ if($a->module_loaded) {
|
||||
}
|
||||
|
||||
if((! $a->error) && (function_exists($a->module . '_content'))) {
|
||||
$arr = array('content' => $a->page['content']);
|
||||
$arr = array('content' => $a->page['content'], 'replace' => false);
|
||||
call_hooks($a->module . '_mod_content', $arr);
|
||||
$a->page['content'] = $arr['content'];
|
||||
$func = $a->module . '_content';
|
||||
$arr = array('content' => $func($a));
|
||||
if(! $arr['replace']) {
|
||||
$func = $a->module . '_content';
|
||||
$arr = array('content' => $func($a));
|
||||
}
|
||||
call_hooks($a->module . '_mod_aftercontent', $arr);
|
||||
$a->page['content'] .= $arr['content'];
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
require_once('include/identity.php');
|
||||
|
||||
function register_init(&$a) {
|
||||
|
||||
@ -103,9 +104,8 @@ function register_post(&$a) {
|
||||
|
||||
if($using_invites && $invite_code) {
|
||||
q("delete * from register where hash = '%s'", dbesc($invite_code));
|
||||
// @FIXME - this total needs to be stored by account, but pconfig operates on channels
|
||||
// This also needs to be considered when using 'invites_remaining' in mod/invite.php
|
||||
// set_pconfig($result['account']['account_id'],'system','invites_remaining',$num_invites);
|
||||
// @FIXME - this also needs to be considered when using 'invites_remaining' in mod/invite.php
|
||||
set_aconfig($result['account']['account_id'],'system','invites_remaining',$num_invites);
|
||||
}
|
||||
|
||||
if($policy == REGISTER_OPEN ) {
|
||||
@ -113,7 +113,7 @@ function register_post(&$a) {
|
||||
$res = verify_email_address($result);
|
||||
}
|
||||
else {
|
||||
$res = send_verification_email($result['email'],$result['password']);
|
||||
$res = send_register_success_email($result['email'],$result['password']);
|
||||
}
|
||||
if($res) {
|
||||
info( t('Registration successful. Please check your email for validation instructions.') . EOL ) ;
|
||||
@ -135,28 +135,43 @@ function register_post(&$a) {
|
||||
}
|
||||
|
||||
authenticate_success($result['account'],true,false,true);
|
||||
|
||||
if(! strlen($next_page = get_config('system','workflow_register_next')))
|
||||
$next_page = 'new_channel';
|
||||
|
||||
$_SESSION['workflow'] = true;
|
||||
|
||||
$new_channel = false;
|
||||
|
||||
if(get_config('system','auto_channel_create')) {
|
||||
$new_channel = auto_channel_create($result['account']['account_id']);
|
||||
if($new_channel['success']) {
|
||||
$channel_id = $new_channel['channel']['channel_id'];
|
||||
change_channel($channel_id);
|
||||
$next_page = '~';
|
||||
}
|
||||
else
|
||||
$new_channel = false;
|
||||
}
|
||||
if(! $new_channel) {
|
||||
if(! strlen($next_page = get_config('system','workflow_register_next')))
|
||||
$next_page = 'new_channel';
|
||||
|
||||
$_SESSION['workflow'] = true;
|
||||
}
|
||||
|
||||
goaway(z_root() . '/' . $next_page);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function register_content(&$a) {
|
||||
|
||||
$registration_is = '';
|
||||
$other_sites = '';
|
||||
|
||||
if(get_config('system','register_policy') == REGISTER_CLOSED) {
|
||||
if(get_config('system','directory_mode') == DIRECTORY_MODE_STANDALONE) {
|
||||
notice( t('Registration on this site is disabled.') . EOL);
|
||||
return;
|
||||
}
|
||||
|
||||
require_once('mod/pubsites.php');
|
||||
return pubsites_content($a);
|
||||
}
|
||||
|
@ -25,10 +25,10 @@ function regmod_content(&$a) {
|
||||
$hash = argv(2);
|
||||
|
||||
if($cmd === 'deny') {
|
||||
if (!user_deny($hash)) killme();
|
||||
if (! account_deny($hash)) killme();
|
||||
}
|
||||
|
||||
if($cmd === 'allow') {
|
||||
if (!user_allow($hash)) killme();
|
||||
if (! account_allow($hash)) killme();
|
||||
}
|
||||
}
|
||||
|
@ -13,10 +13,10 @@ function regver_content(&$a) {
|
||||
$hash = argv(2);
|
||||
|
||||
if($cmd === 'deny') {
|
||||
if (!user_deny($hash)) killme();
|
||||
if (! account_deny($hash)) killme();
|
||||
}
|
||||
|
||||
if($cmd === 'allow') {
|
||||
if (!user_approve($hash)) killme();
|
||||
if (! account_approve($hash)) killme();
|
||||
}
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
2016-01-11.1275H
|
||||
2016-01-12.1276H
|
||||
|
Reference in New Issue
Block a user