mode = PUB; $obj->uid = $login_uid; $obj->block_type = 'media_management'; if ($module=='InvitationStatusModule') { $groups = Group::get_user_groups($login_uid, FALSE, 'ALL'); $user_groups = array(); for ( $i=0; $icollection_id_array = $user_groups; } else if ($module=='GroupInvitationModule') { $obj->entered_people = $entered_people; } break; } } // array of first names / last names / email addresses to be displayed if there was an error $entered_people = array(); $array_msg = array(); if($_POST['do']=='SendInvite') { filter_all_post($_POST); $error = FALSE; $msg = array(); // check if groups are there if ( empty( $_POST['groups'] ) ) { $error = TRUE; $array_msg[]= "Please select group"; } //check email and first name $empty = TRUE; foreach ($_POST['email'] as $i => $email) { $login_name = ''; $email = trim($email); $included = (@$_POST['included'][$i] == "on"); $fname = trim($_POST['firstname'][$i]); $lname = trim($_POST['lastname'][$i]); if (!$included || (!$email && !$fname && !$lname)) continue; $e = NULL; if (empty($email)) { $e = "Please enter an email address or login name"; } else if ($email == $_SESSION['user']['email']) { $e = "You can't invite yourself"; } else if (!validate_email($email)) { $user_obj = new User(); try { $user_obj->load( $email );// if $email is not a valid email then it could be a login name $login_name = $email; $email = $user_obj->email; if ($email == $_SESSION['user']['email']) { $e = "You can't invite yourself"; } $internal_account = TRUE; } catch( PAException $e ) { $e = "Please enter a valid email address or login name"; } } else if (empty($fname)) { $e = "Please enter a first name for this person"; } if (!empty($email) || !empty($fname) || !empty($lname)) { $empty = FALSE; } $entered_people[] = array( 'email' => $email, 'firstname' => $fname, 'lastname' => $lname, 'error' => $e, 'login_name'=>$login_name ); if ($e) { $error = TRUE; $array_msg[] = $e; } } if ($empty) { $error = TRUE; $array_msg[] = "Please enter at least one person to invite"; } $subject = GROUP_INVITE_SUBJECT; $subject = str_replace("%first_name%", $_SESSION['user']['first_name'], $subject); $subject = str_replace("%last_name%", $_SESSION['user']['last_name'], $subject); $message = trim($_POST['message']); if ( empty( $message ) ) { $error = TRUE; $array_msg[] = "Message can't be left blank"; } // if no error send the invitation if ( !$error ) { /* for ( $i = 0; $i < count($_POST['groups']); $i++ ) {*/ foreach ($entered_people as $person) { if (!$person['email']) continue; $gid = (!empty($_GET['gid']))?(int)$_GET['gid']:(int)$_POST['groups']; $group = new Group(); $group->load($gid); $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 = $_POST['groups'][$i]; $inv->inv_collection_id = $gid; $inv->inv_group_name = $group->title; $inv->inv_status = INVITATION_PENDING; $inv->register_url = $base_url."/register.php?GInvID=".$inv->inv_id; $inv->accept_url = $base_url."/login.php?action=accept&GInvID=".$inv->inv_id; $inv->inv_user_id = NULL; $inv->inv_username = NULL; $inv->inv_user_first_name = $person['firstname']; $inv->inv_user_last_name = $person['lastname']; $inv->inv_email = $person['email']; $inv->inv_summary = "Invitation from $user->first_name $user->last_name to join PeopleAggregator"; $inv->inv_message = $message; try { $inv->send(); $success = 1; if( $person['login_name']!='') { $person['email'] = $person['login_name']; } $person_mail_list .= $person['email']; $person_mail_list .="
,"; } catch (PAException $e) { $array_msg[] = "$e->message"; $error = TRUE; } }//..foreach $array_msg[] = "Successfully sent invitation to ".substr($person_mail_list,0,-1); $_POST = array(); } //..$error if if ( count($array_msg)>0 ) { $msg = ""; for ($i=0;$iset('message', $msg); $page->add_module("middle", "top", $msg_tpl->fetch()); } $css_array = get_network_css(); if (is_array($css_array)) { foreach ($css_array as $key => $value) { $page->add_header_css($value); } } if ($show_options) { $page->header->show_options = TRUE; } echo $page->render(); ?>