foreach ($sel_lists as $list_id) { $query = "INSERT IGNORE INTO rel_subj_list (`list_id`, `subj_id`) VALUES ('" . $list_id . "', '" . $subj_id . "')"; $result = mysql_query($query, $dbconnect); confirm_query($result); if (mysql_affected_rows() == 1) { $list_name = get_list_name($list_id, $lang); $mesaj[] = "Subject has been added to list {$list_name}."; } if ($subj_status == 1) { //get studies that include the list $studies = get_all_study_ids_for_list($list_id); foreach ($studies as $study_id) { $template_id = get_rel_template_id_for_study($study_id); $study_name = get_study_name($study_id, $lang); if ($template_id != null) { $template_body = get_template_body($template_id, $lang); $query = "INSERT IGNORE INTO mails (`study_id`, `subj_id`, `nume`, `email`, `titlu`, `body`)\n\t\t\t\t\t\t\t\tVALUES ('" . $study_id . "', '" . $subj_id . "', '" . $subj_name . "', '" . $subj_email . "', '" . $study_name . "', '" . $template_body . "');"; $result = mysql_query($query, $dbconnect); } $sel_studies[] = $study_id; } } } $rel_lists = get_rel_list_for_subj($subj_id); foreach ($rel_lists as $list_id) { if (!in_array((int) $list_id, $sel_lists)) { $query = "DELETE FROM rel_subj_list WHERE `list_id` = '" . $list_id . "' "; $result = mysql_query($query, $dbconnect); confirm_query($result); if (mysql_affected_rows() == 1) { $list_name = get_list_name($list_id, $lang);
if (!empty($sel_questionnaires)) { foreach ($sel_questionnaires as $questionnaire_id) { $query = "INSERT INTO rel_questionnaire_study (`questionnaire_id`, `study_id`) VALUES ('" . $questionnaire_id . "', '" . $study_id . "')"; $result = mysql_query($query, $dbconnect); confirm_query($result); } } if (!empty($sel_list)) { foreach ($sel_list as $list_id) { $query = "INSERT INTO rel_list_study (`list_id`, `study_id`) VALUES ('" . $list_id . "', '" . $study_id . "')"; $result = mysql_query($query, $dbconnect); confirm_query($result); $subjects = get_active_subj_for_list($list_id); while ($row = mysql_fetch_array($subjects)) { if ($sel_template != null) { $template_body = get_template_body($sel_template, $lang); $subj_id = $row['subj_id']; $subj_name = $row['first_name'] . " " . $row['last_name']; $subj_email = $row['email']; $query = "INSERT IGNORE INTO mails (`study_id`, `subj_id`, `nume`, `email`, `titlu`, `body`)\n\t\t\t\t\t\t\t\t\t\t\tVALUES ('" . $study_id . "', '" . $subj_id . "', '" . $subj_name . "', '" . $subj_email . "', '" . $title . "', '" . $template_body . "');\n\t\t\t\t\t\t\t\t\t\t\t"; $result = mysql_query($query, $dbconnect); confirm_query($result); } } } } if ($sel_template != null) { $rel_template = get_rel_template_id_for_study($study_id); $query = "INSERT INTO rel_studies_email (`study_id`, `email_id`) VALUES ('" . $study_id . "', '" . $sel_template . "')"; $result = mysql_query($query, $dbconnect); confirm_query($result);
function update_template($service, $tableID, $templateId) { $result = $service->template->listTemplate($tableID); print_r($result); $postBody = new Google_Service_Fusiontables_Template(); $postBody->body = get_template_body(); $result = $service->template->update($tableID, $templateId, $postBody); //working OK print_r($result); }