load(trim($friend_user_name_array[$counter])); if ($user_obj->email == $_SESSION['user']['email']) { $msg = 6002; //you can not invite your self } else { $valid_user_login_names[] = $user_obj->login_name; $valid_usr_name_email[] = $user_obj->email; } } catch (PAException $e) { if (!empty($friend_user_name_array[$counter])) { $msg .= '
' . $friend_user_name_array[$counter]; } } } // end for if (!empty($msg) && !(is_int($msg))) { $msg = 'Following user names are not valid
' . $msg; } } // end if : if user names are supplied. if (!empty($_POST['email_id'])) { $friend_email = trim($_POST['email_id']); $friend_email_array = explode(',', $friend_email); $cnt_email = count($friend_email_array); $self_invite = FALSE; $error = FALSE; $user_id = $uid; // Check for valid-invalid email addresses start for ($counter = 0; $counter < $cnt_email; $counter++) { $email_validation = validate_email(trim($friend_email_array[$counter])); if ($email_validation == '0') { $invalid[] = trim($friend_email_array[$counter]); } else if ($friend_email_array[$counter] == $_SESSION["user"]["email"]) { $self_invite = TRUE; } else { $valid_user_first_emails[] = $friend_email_array[$counter]; $valid_email[] = trim($friend_email_array[$counter]); } } } // Check for valid-invalid email addresses end // Action for valid-invalid email addresses start if (empty($friend_email) && empty($friend_user_name)) { // if email field is left empty if ($network_info->type == MOTHER_NETWORK_TYPE) { $msg = 6003; } else { $msg = 6001; } $error_email = TRUE; $error = TRUE; } elseif ($self_invite) { // if self invitation is made $msg = 6002; $error_email = TRUE; $error = TRUE; } elseif (sizeof($invalid) > 0) { // if invalid email addresses are supplied $invalid_cnt = count($invalid); $msg = ''; for ($counter = 0; $counter < $invalid_cnt; $counter++) { if (!empty($invalid[$counter])) { $msg .= '
'.$invalid[$counter]; } } if (!empty($msg)) { $msg = "
Following email addresses are not valid:" . $msg; } else { $msg = '
Invalid Email addresses'; } $error_email = TRUE; $error = TRUE; } else if (empty($msg)) { // At this point invitation could be made $msg = ''; if (!empty($valid_email) && !empty($valid_usr_name_email)) { $valid_email = array_merge($valid_email, $valid_usr_name_email); $valid_user_first_emails = array_merge($valid_user_first_emails, $valid_user_login_names); } else if( !empty($valid_usr_name_email)) { $valid_email = $valid_usr_name_email; $valid_user_first_emails = $valid_user_login_names; } $valid_cnt = count($valid_email); $message = trim($_POST['message']); for ($counter = 0; $counter < $valid_cnt; $counter++) { $inv = new Invitation(); $inv->user_id = $_SESSION['user']['id']; $inv->username = $_SESSION['user']['name']; // for invitation not for any group invitation collection id is -1 $inv->inv_collection_id = -1; $inv->inv_status = INVITATION_PENDING; $inv->register_url = $base_url."/register.php?InvID=".$inv->inv_id; $inv->accept_url = $base_url."/login.php?action=accept&InvID=".$inv->inv_id; $inv->inv_user_id = NULL; $inv->inv_user_first_name = $valid_user_first_emails[$counter]; $inv->inv_email = $valid_email[$counter]; $inv->inv_summary = "Invitation from $user->first_name $user->last_name to join PeopleAggregator"; $inv->inv_message = $message; if ($error != TRUE) { try { $inv->send(); } catch (PAException $e) { $msg = "$e->message"; $save_error = TRUE; } } if ($save_error == TRUE) { $msg = "Sorry: you are unable to invite a friend.
Reason: " . $msg; } else { $msg .= '
'.$valid_email[$counter]; if ($counter == ($valid_cnt - 1)) { $msg = "
An Invitation has been sent to following email address-" . $msg; } } } // end for : invitation to multiple email $_POST = array(); // unset $_POST, if invitation has been successfully made. } // end else invitation could be made } // end if form is posted // invitation.php-specific module initialization code function setup_module($column, $moduleName, $obj) { switch ($column) { case 'left': if ($moduleName=='RecentCommentsModule') { $obj->cid = $_REQUEST['cid']; $obj->block_type = HOMEPAGE; $obj->mode = PRI; } break; case 'middle': $obj->content_id = $_REQUEST['cid']; $obj->mode = PUB; $obj->uid = $uid; $obj->block_type = 'media_management'; if ($moduleName == 'InvitationModule') { global $msg; $obj->msg = $msg; } break; } } $page = new PageRenderer("setup_module", PAGE_INVITATION, "Invite people into PeopleAggregator", 'container_three_column.tpl', 'header.tpl', PRI, HOMEPAGE, $network_info); $css_array = get_network_css(); if (is_array($css_array)) { foreach ($css_array as $key => $value) { $page->add_header_css($value); } } $page->add_header_html(js_includes('common.js')); if (!empty($msg)) { if (is_int($msg)) { $msg_obj = new MessagesHandler(); $msg = $msg_obj->get_message((int)$msg); } $msg_tpl = & new Template(CURRENT_THEME_FSPATH."/display_message.tpl"); $msg_tpl->set('message', $msg); $page->add_module("middle", "top", $msg_tpl->fetch()); } echo $page->render(); ?>