Communication'; $action = ''; if(array_key_exists('action', $_POST)) { $action = $_POST['action']; } switch($action) { case 'send': $eid = (int)$_POST['eid']; $to = $_POST['list']; $year = $_POST['year']; if($year != 'all') { $year = (int)$year; if($year == 0) { form_ajax_response(array('status'=>1, 'error'=>'Please select a year')); exit(); } $year_q = "year='$year'"; } else { $year_q = '1'; } if(!array_key_exists($to, $email_lists)) { exit(); } $q = $mysqli->query("SELECT * FROM emails WHERE id=$eid"); $e = $q->fetch_assoc(); $elist = &$email_lists[$to]; if($to == 'one_user') { $usernames = explode(',', $_POST['username']); $users = array(); foreach($usernames as $username) { $username = $mysqli->real_escape_string(trim($username)); $uu = user_load_by_username($mysqli, $username); if($uu === NULL) { form_ajax_response(array('status'=>1, 'error'=>"Unknown username $username, no email sent to any user")); exit; } $users[] = $uu; } foreach($users as $uu) { email_send($mysqli, $e['name'], $uu); } } else { /* Query all users, fetch only email per username */ $query = "SELECT * FROM users WHERE $year_q AND {$elist['where']} ORDER BY `year` DESC"; // print($query); $r = $mysqli->query($query); print($mysqli->error); $users = array(); $emails = array(); while($ua = $r->fetch_assoc()) { $u = user_load_from_data($mysqli, $ua); if(array_key_exists($u['email'], $emails)) { /* Email already seen, send to the same email only in the same year * e.g., multiple registrations int he same year using the same email */ if($emails[$u['email']] != $u['year']) { continue; } } /* Tag this email with the year to avoid dupes */ $emails[$u['email']] = $u['year']; /* Add this user to the list of recipients */ $users[] = $u; } email_send_to_list($mysqli, $e['name'], $users); } form_ajax_response(array('status'=>0, 'location'=>'c_communication_queue.php')); exit(); } sfiab_page_begin($u, "Send Email", $page_id, $help); ?>
query("SELECT MIN(year) AS M FROM users"); $u = $q->fetch_assoc(); $min_year = (int)$u['M']; $year_list = array(); for($y=$config['year']; $y>=$min_year; $y--) { $year_list[$y] = $y; } $year_list['all'] = "All Years"; $q = $mysqli->query("SELECT * FROM emails WHERE id=$eid"); $e = $q->fetch_assoc(); form_page_begin($page_id, array()); $current_list = ''; $username = ''; ?>

Send Email




Note: It may take a few minutes (literally minutes) of seemingly doing nothing to inject mail to lots of recipients. When it's done the page will change to the email send queue page.

Cancel, Don't Send