Пример #1
0
             $errorString[] = "Name exists for number {$i} (try adding by email)<br />";
         }
     }
 }
 if (!empty($errorString)) {
     $add_form = true;
 } else {
     // no errors add members
     $resultString = "";
     for ($i = 1; $i < $membersize + 1; $i++) {
         if (!empty($_POST["invite-name-{$i}"]) && !in_array($_POST["invite-email-{$i}"], $existing_users)) {
             $newuserid = add_member($_POST["invite-name-{$i}"], $_POST["invite-email-{$i}"], $groupdetails['group_id']);
             if ($newuserid != false) {
                 $resultString[] = "Added " . $_POST["invite-name-{$i}"] . "<br />";
                 if (isset($_POST["email_invite"]) && $_POST["email_invite"] == 1) {
                     invite_member($_POST["invite-email-{$i}"], $newuserid, $groupdetails['group_id'], $groupdetails['name']);
                 }
             } else {
                 $resultString[] = "Cannot add " . $_POST["invite-name-{$i}"] . "<br />";
             }
         }
     }
     foreach ($existing_users as $key => $value) {
         if (add_member_to_group($key, $groupdetails['group_id'])) {
             $resultString[] = "User with email {$value} already registered. Added this user.<br />";
         } else {
             $resultString[] = "Cannot add existing user with email: {$value} <br />";
         }
     }
     $showmembers = true;
     $ask_add = true;
     continue;
 }
 // This is a 'do not add' stipulation
 //  error_log("Selection : $email => $role | $member_id |" . strlen($member_id));
 // If they're already a member, add to project and send confirmation email
 if (strlen($member_id) > 0) {
     add_project_member($sa_url, $user, $project_id, $member_id, $role);
     $num_members_added = $num_members_added + 1;
 } else {
     $email = filter_var($email, FILTER_SANITIZE_EMAIL);
     if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
         error_log("do-upload-project-members Skipping invitee " . $email . " that seems invalid");
         $num_emails_skipped = $num_emails_skipped + 1;
         continue;
     }
     $invite_data = invite_member($sa_url, $user, $project_id, $role);
     $invite_id = $invite_data[PA_PROJECT_MEMBER_INVITATION_TABLE_FIELDNAME::INVITE_ID];
     // If not, send an inviation email
     $email_subject = "Invitation to GENI project: " . $project_name;
     $hostname = $_SERVER['SERVER_NAME'];
     $confirmation_url = "https://{$hostname}/secure/accept-project-invite?invite_id={$invite_id}&project_name={$project_name}";
     $email_text = "Dear {$user_name}, \n" . "You are invited to join GENI project {$project_name} whose lead is {$lead_name}. \n\n" . "If you would like to join the project, click on this URL " . $confirmation_url . ". " . "Once you authenticate you will directed to a page to confirm your choice to join the project. \n" . "If you have not used the GENI Portal before, see http://groups.geni.net/geni/wiki/SignMeUp for instructions on logging in to the GENI Portal." . "\n\n" . "Sincerely,\n" . $user->prettyName();
     //    error_log("EMAIL_ADDRESS : $email");
     //    error_log("EMAIL_SUBJECT : $email_subject");
     //    error_log("EMAIL_TEXT : $email_text");
     $userEmail = $user->email();
     $name = $user->prettyName();
     $headers = "Reply-To: {$userEmail}" . "\r\n" . "From: \"{$name} (via the GENI Portal)\" <*****@*****.**>\r\nContent-Type: text/plain; charset=UTF-8\r\nContent-Transfer-Encoding: 8bit";
     mail($email, $email_subject, $email_text, $headers, "-f {$userEmail}");
     $num_members_invited = $num_members_invited + 1;
 }