network_id, $u );
if( $user_type == DISABLED_MEMBER ) {
$msg = 'Your account has been temporarily disabled by the administrator.';
$u = NULL;
}
} catch (PAException $e) {
$msg = "Error: $e->message";
$error = TRUE;
}
/* Code for remember me */
$expire = time() + 31536000; // Will expire after 1 year.
if(isset($_POST['remember']) && $_POST['remember'] == 1) {
setcookie('pa_username', $username, $expire, "/");
setcookie('pa_password', $password, $expire, "/");
} else {
$expire = 0;
setcookie('pa_username', '', $expire, "/");
setcookie('pa_password', '', $expire, "/");
}
if ($u > 0) {
if($invitation_id) {
try {
$new_invite = new Invitation();
$new_invite->inv_id = $invitation_id;
$new_invite->inv_user_id = $u;
$new_invite->accept();
if(!empty($network_info) && $network_info->type!=MOTHER_NETWORK_TYPE) {
Network::join($network_info->network_id, $u);
$params['uid'] = $u;
auto_email_notification('some_joins_a_network', $params );
}
} catch (PAException $e) {
$msg = "$e->message";
$error_inv = TRUE;
}
if ($error_inv == TRUE) {
header("Location:login.php?msg=$msg&return=$return_url");
exit;
}
}
if ($error == TRUE ) {
$msg = "Sorry: your login failed.
".$msg;
}
else {
$logged_user = new User();
try {
$logged_user->load($u);
$logged_user->set_last_login();
} catch (PAException $e) {
$msg = "$e->message";
$load_error = TRUE;
header("Location:homepage.php?msg=$msg");
}
if ($load_error == TRUE ) {
$msg = "Sorry: your login failed.
".$msg;
}
else {
register_session($logged_user->login_name,$logged_user->user_id,$logged_user->role,$logged_user->first_name,$logged_user->last_name,$logged_user->email,$logged_user->picture);
if($group_invitation_id) {
// make user the member of group
$is_valid_ginv = Invitation::validate_group_invitation_id($group_invitation_id);
if (!$is_valid_ginv) {
throw new PAException(INVALID_INV, "Sorry you cant join this group. May be group no longer exists or you are using old invitation.");
}
try {
$gid_invite = Invitation::load($group_invitation_id);
if( Group::is_admin( $gid_invite->inv_collection_id, $_SESSION['user']['id'])) {
throw new PAException(INVALID_INV, "You are the moderator, you can not accept invitation of same group");
}
} catch(PAException $e) {
$msg="You are the moderator, you can not accept invitation of same group";
header("Location:login.php?msg=".$msg);exit;
}
try {
$new_invite = new Invitation();
$new_invite->inv_id = $group_invitation_id;
$new_invite->inv_user_id = $u;
$new_invite->accept();
//get collection_id
$Ginv = Invitation::load($group_invitation_id);
$gid = $Ginv->inv_collection_id;
} catch (PAException $e) {
$msg = "$e->message";
$error = TRUE;
print $msg;
}
header("Location:group.php?gid=$gid&action=join&GInvID=$group_invitation_id");exit;
}
if ($return_url)
header("Location: $return_url");
else
if ($invitation_id)
header("Location: user.php?msg_id=7016");
else
header("Location: user.php");
}
}
}
else {
$msg = ( !empty( $msg ) ) ? $msg : 'Error: Invalid login name or password';
$r = 'login.php?msg='.$msg;
if ($invitation_id) {
$r .= "&InvID=$invitation_id";
}
else if ($group_invitation_id) {
$r .= "&GInvID=$group_invitation_id";
}
if ( $return_url ) {
$r .= "&return=$return_url";
}
header("Location:$r");
exit;
}
}
}
?>