Ejemplo n.º 1
0
    $emails = array($emails);
}
//fordebug register_error("emails ".$emails[0]);
$group = get_entity($group_guid);
//($group->canEdit() || zhgroups_allow_members_invite($group))
if (!empty($group) && $group instanceof ElggGroup && $group->isMember($logged_in_user)) {
    // show hidden (unvalidated) users
    $hidden = access_get_show_hidden_status();
    access_show_hidden_entities(true);
    $invited = 0;
    // counters
    // Invite member by e-mail address
    if (!empty($emails)) {
        foreach ($emails as $email) {
            //fordebug register_error("groupid " . $group->guid . " email " . $email. " text " . $text);
            $invite_result = send_invite_email($logged_in_user, $group, $email, $text);
            //fordebug register_error("invite_result  ".$invite_result );
            if ($invite_result === true) {
                $invited++;
            }
        }
    }
    // restore hidden users
    access_show_hidden_entities($hidden);
    // which message to show
    if ($invited) {
        system_message(elgg_echo("zhaohu:invite:ok"));
    } else {
        register_error(elgg_echo('zhaohu:invite:err') . elgg_echo("zhaohu:sorry"));
        elgg_log("ZHError , zhgroups:invite, error sending invitations, group_id {$group_guid} , user_id " . elgg_get_logged_in_user_guid() . " , emails " . implode("|", $emails), "ERROR");
    }
Ejemplo n.º 2
0
$text = get_input("comment");
$emails = get_input("email2invite");
if (empty($emails)) {
    register_error(elgg_echo("zhaohu:emails:empty"));
    forward(REFERER);
}
if (!is_array($emails)) {
    $emails = array($emails);
}
//fordebug register_error("emails ".$emails[0]);
$invited = 0;
// counters
// Invite by e-mail address
if (!empty($emails)) {
    foreach ($emails as $email) {
        //fordebug register_error("$zhaohuid " . $zhaohu->guid . " email " . $email. " text " . $text . ' resend ' . $resend);
        $invite_result = send_invite_email($logged_in_user, $zhaohu, $email, $text);
        //fordebug register_error("invite_result  ".$invite_result );
        if ($invite_result === true) {
            $invited++;
        }
    }
}
// which message to show
if ($invited) {
    system_message(elgg_echo("zhaohu:invite:ok"));
} else {
    register_error(elgg_echo('zhaohu:invite:err') . elgg_echo("zhaohu:sorry"));
    elgg_log("ZHError , zhgroups:invite, error sending invitations, user_id " . elgg_get_logged_in_user_guid() . " , emails " . implode("|", $emails), "ERROR");
}
forward(REFERER);
             $is_accepted = "1";
         }
     } else {
         $user_client_rel_qry = "INSERT INTO users_clients_relation SET user_email= '{$email}', client_id='{$client_id}'";
         //echo $sql; die;
         $result = $conn->query($user_client_rel_qry);
     }
     // ---------- Email Send to Invite emails -----------
     // -------- Check Email of Mobile App user already exists in db or not --------- -->
     $sql_chk_mbl_email = "SELECT email from users WHERE email='{$email}'";
     //echo $sql; die;
     $result = $conn->query($sql_chk_mbl_email);
     if ($result->num_rows > 0) {
         // Email for invitation on app will not be sent in this case
     } else {
         send_invite_email($email);
         // Send email to join app.
     }
     // Insert a record in db that invitation has been sent to this user wheter he exists in db or not
     $team_id = $last_team_id;
     $chk_already_team_member = chkTeamMemAlreadyExists($email, $team_id);
     if ($chk_already_team_member < 1) {
         $sql = "INSERT INTO invites (email,is_accepted, team_id)\n\t\t\tVALUES ('{$email}', '{$is_accepted}', {$team_id})";
         if ($conn->query($sql) === TRUE) {
             //$last_team_id = $conn->insert_id;
         } else {
             echo "Error: " . $sql . "<br>" . $conn->error;
         }
     }
 }
 // End Foreach