aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2012-08-16 03:16:55 -0700
committerfriendica <info@friendica.com>2012-08-16 03:16:55 -0700
commit434bcfef8ba816805df29736efb36f8c95c20769 (patch)
treef17a7d5c609b0160fcc908df30a0ee5fa045920f /include
parentadba0bd98ac8c3fd5d2210e5e14f6a3ebfb00cd4 (diff)
downloadvolse-hubzilla-434bcfef8ba816805df29736efb36f8c95c20769.tar.gz
volse-hubzilla-434bcfef8ba816805df29736efb36f8c95c20769.tar.bz2
volse-hubzilla-434bcfef8ba816805df29736efb36f8c95c20769.zip
add invitiation logic to registrations - this is starting to look good
Diffstat (limited to 'include')
-rw-r--r--include/account.php57
1 files changed, 37 insertions, 20 deletions
diff --git a/include/account.php b/include/account.php
index 652048e29..ead8ce862 100644
--- a/include/account.php
+++ b/include/account.php
@@ -53,39 +53,56 @@ function check_account_password($password) {
}
-function create_account($arr) {
-
- // Required: { email, password }
-
- $result = array('success' => false, 'email' => '', 'password' => '', 'message' => '');
+function check_account_invite($invite_code) {
+ $result = array('error' => false, 'message' => '');
$using_invites = get_config('system','invitation_only');
- $num_invites = get_config('system','number_invites');
-
- $invite_id = ((x($arr,'invite_id')) ? notags(trim($arr['invite_id'])) : '');
- $email = ((x($arr,'email')) ? notags(trim($arr['email'])) : '');
- $password = ((x($arr,'password')) ? trim($arr['password']) : '');
- $password2 = ((x($arr,'password2')) ? trim($arr['password2']) : '');
- $parent = ((x($arr,'parent')) ? intval($arr['parent']) : 0 );
- $flags = ((x($arr,'account_flags')) ? intval($arr['account_flags']) : ACCOUNT_OK);
if($using_invites) {
- if(! $invite_id) {
+ if(! $invite_code) {
$result['message'] .= t('An invitation is required.') . EOL;
- return $result;
}
- $r = q("select * from register where `hash` = '%s' limit 1", dbesc($invite_id));
+ $r = q("select * from register where `hash` = '%s' limit 1", dbesc($invite_code));
if(! results($r)) {
$result['message'] .= t('Invitation could not be verified.') . EOL;
- return $result;
}
- }
+ }
+ if(strlen($result['message']))
+ $result['error'] = true;
+
+ $arr = array('invite_code' => $invite_code, 'result' => $result);
+ call_hooks('check_account_invite', $arr);
+
+ return $arr['result'];
+
+}
+
+
+function create_account($arr) {
+
+ // Required: { email, password }
+
+ $result = array('success' => false, 'email' => '', 'password' => '', 'message' => '');
+
+ $invite_code = ((x($arr,'invite_code')) ? notags(trim($arr['invite_code'])) : '');
+ $email = ((x($arr,'email')) ? notags(trim($arr['email'])) : '');
+ $password = ((x($arr,'password')) ? trim($arr['password']) : '');
+ $password2 = ((x($arr,'password2')) ? trim($arr['password2']) : '');
+ $parent = ((x($arr,'parent')) ? intval($arr['parent']) : 0 );
+ $flags = ((x($arr,'account_flags')) ? intval($arr['account_flags']) : ACCOUNT_OK);
if((! x($email)) || (! x($password))) {
- notice( t('Please enter the required information.') . EOL );
- return;
+ $result['message'] = t('Please enter the required information.');
+ return $result;
+ }
+
+ $invite_result = check_account_invite($invite_code);
+ if(! $invite_result['error']) {
+ $result['message'] = $invite_result['message'];
+ return $result;
}
+
$email_result = check_account_email($email);
if(! $email_result['error']) {