diff options
-rwxr-xr-x | boot.php | 2 | ||||
-rw-r--r-- | include/account.php | 22 | ||||
-rw-r--r-- | include/identity.php | 42 | ||||
-rwxr-xr-x | index.php | 8 | ||||
-rw-r--r-- | mod/register.php | 39 | ||||
-rw-r--r-- | mod/regmod.php | 4 | ||||
-rw-r--r-- | mod/regver.php | 4 | ||||
-rw-r--r-- | version.inc | 2 |
8 files changed, 97 insertions, 26 deletions
@@ -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 ); diff --git a/include/account.php b/include/account.php index e448bdcc6..dae0f4895 100644 --- a/include/account.php +++ b/include/account.php @@ -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; diff --git a/include/identity.php b/include/identity.php index cfedd243a..1d908056f 100644 --- a/include/identity.php +++ b/include/identity.php @@ -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']; } diff --git a/mod/register.php b/mod/register.php index 2e9967c60..3a4d5bcb9 100644 --- a/mod/register.php +++ b/mod/register.php @@ -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); + + $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'; - if(! strlen($next_page = get_config('system','workflow_register_next'))) - $next_page = 'new_channel'; + $_SESSION['workflow'] = true; + } - $_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); } diff --git a/mod/regmod.php b/mod/regmod.php index c0a75ef48..a1d300e56 100644 --- a/mod/regmod.php +++ b/mod/regmod.php @@ -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(); } } diff --git a/mod/regver.php b/mod/regver.php index c3ade2ee1..78f146ec5 100644 --- a/mod/regver.php +++ b/mod/regver.php @@ -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(); } } diff --git a/version.inc b/version.inc index c17fa0d99..99ad03d87 100644 --- a/version.inc +++ b/version.inc @@ -1 +1 @@ -2016-01-11.1275H +2016-01-12.1276H |