function email_testinvite($participant, $testinvite, $auto = FALSE, $concept = FALSE) { $CI =& get_instance(); $test = $CI->testInviteModel->get_test_by_testinvite($testinvite); $template = $CI->testTemplateModel->get_testtemplate_by_test($test->id, L::Dutch); // TODO: set to current language? $email = $concept ? TO_EMAIL_OVERRIDE : $participant->email; $message = email_replace($template->template, $participant, NULL, NULL, $testinvite, NULL, $auto); $CI->email->clear(); $CI->email->from(FROM_EMAIL, FROM_EMAIL_NAME); $CI->email->to(in_development() ? TO_EMAIL_OVERRIDE : $email); $CI->email->subject('Babylab Utrecht: Uitnodiging voor vragenlijst'); $CI->email->message($message); $CI->email->send(); return sprintf(lang('testinvite_added'), name($participant), $test->name, $email); }
/** * Sends out reminders for surveys */ public function reminder() { if (!$this->input->is_cli_request()) { echo "This script can only be accessed via the command line" . PHP_EOL; return; } // Set the language to Dutch (TODO: set to language of participant?) reset_language(L::Dutch); // Get all testinvites that have not yet been reminded $testinvites = $this->testInviteModel->get_not_reminded_testinvites(); foreach ($testinvites as $testinvite) { $date_sent = new DateTime($testinvite->datesent); $diff_days = $date_sent->diff(new DateTime())->days; // Check with LimeSurvey whether the survey has actually been completed $testsurvey = $this->testInviteModel->get_testsurvey_by_testinvite($testinvite); $result = $this->surveyModel->get_result_by_token($testsurvey->limesurvey_id, $testinvite->token); if ($result) { // If there is actually a result row, set the survey to completed $this->testInviteModel->set_completed($testinvite->id, $result->submitdate); continue; } // If no reminder has yet been sent and it's been some days, send a reminder e-mail if ($diff_days >= SEND_REMINDER_AFTER_DAYS) { $test = $this->testInviteModel->get_test_by_testinvite($testinvite); $template = $this->testTemplateModel->get_testtemplate_by_test($test->id, L::Dutch); $participant = $this->testInviteModel->get_participant_by_testinvite($testinvite); $message = email_replace($template->template . '_reminder', $participant, NULL, NULL, $testinvite); $this->email->clear(); $this->email->from(FROM_EMAIL, FROM_EMAIL_NAME); $this->email->to(in_development() ? TO_EMAIL_OVERRIDE : $participant->email); $this->email->subject('Babylab Utrecht: Herinnering uitnodiging voor vragenlijst'); $this->email->message($message); $this->email->send(); $this->testInviteModel->set_reminded($testinvite->id); } } }
/** * Sends out reminders for appointments (that are tomorrow) */ public function appointments() { if (!$this->input->is_cli_request()) { echo "This script can only be accessed via the command line" . PHP_EOL; return; } $participations = $this->participationModel->get_confirmed_participations(); foreach ($participations as $participation) { $appointment = strtotime($participation->appointment); if ($appointment > strtotime('tomorrow') && $appointment <= strtotime('tomorrow + 1 day')) { reset_language(L::Dutch); $participant = $this->participationModel->get_participant_by_participation($participation->id); $experiment = $this->participationModel->get_experiment_by_participation($participation->id); $message = email_replace('mail/reminder', $participant, $participation, $experiment); $this->email->clear(); $this->email->from(FROM_EMAIL, FROM_EMAIL_NAME); $this->email->to(in_development() ? TO_EMAIL_OVERRIDE : $participant->email); $this->email->subject('Babylab Utrecht: Herinnering deelname'); $this->email->message($message); $this->email->send(); // DEBUG: $this->email->print_debugger(); } } }
/** Send a mail to the technical folks */ private function send_technical_email($participation_id, $tech_comment) { $participation = $this->participationModel->get_participation_by_id($participation_id); $participant = $this->participationModel->get_participant_by_participation($participation_id); $experiment = $this->participationModel->get_experiment_by_participation($participation_id); $message = email_replace('mail/tech_comment', $participant, $participation, $experiment, NULL, NULL, FALSE, $tech_comment, L::English); $this->email->clear(); $this->email->from(FROM_EMAIL, FROM_EMAIL_NAME); $this->email->to(in_development() ? TO_EMAIL_OVERRIDE : LAB_EMAIL); $this->email->subject('Babylab Utrecht: Technisch probleem'); $this->email->message($message); $this->email->send(); }
/** Send request for participation e-mail */ private function send_request_participation_email($participation_id) { $participation = $this->participationModel->get_participation_by_id($participation_id); $participant = $this->participationModel->get_participant_by_participation($participation_id); $experiment = $this->participationModel->get_experiment_by_participation($participation_id); $message = email_replace('mail/request_participation', $participant, $participation, $experiment); $this->email->clear(); $this->email->from(FROM_EMAIL, FROM_EMAIL_NAME); $this->email->to(in_development() ? TO_EMAIL_OVERRIDE : $participant->email); $this->email->subject('Babylab Utrecht: Verzoek tot deelname aan onderzoek'); $this->email->message($message); // Add attachment if ($experiment->attachment && file_exists('uploads/' . $experiment->attachment)) { $this->email->attach('uploads/' . $experiment->attachment); } $this->email->send(); return sprintf(lang('request_participation_sent'), in_development() ? TO_EMAIL_OVERRIDE : $participant->email); }
/** Resend the reminder */ public function manual_reminder_submit($testinvite_id) { $testinvite = $this->testInviteModel->get_testinvite_by_id($testinvite_id); $participant = $this->testInviteModel->get_participant_by_testinvite($testinvite); $testsurvey = $this->testInviteModel->get_testsurvey_by_testinvite($testinvite); $test = $this->testInviteModel->get_test_by_testinvite($testinvite); $template = $this->testTemplateModel->get_testtemplate_by_test($test->id, L::Dutch); // Email to participant $message = email_replace($template->template . '_reminder', $participant, NULL, NULL, $testinvite); $this->email->clear(); $this->email->from(FROM_EMAIL, FROM_EMAIL_NAME); $this->email->to(in_development() ? TO_EMAIL_OVERRIDE : $participant->email); $this->email->subject('Babylab Utrecht: Herinnering uitnodiging voor vragenlijst'); $this->email->message($message); $this->email->send(); $this->testInviteModel->set_manually_reminded($testinvite->id); // Send reminder flashdata(sprintf(lang('manual_reminder_sent'), testsurvey_name($testsurvey), $participant->email)); redirect('/testinvite/', 'refresh'); }
private function send_completion_email($testinvite) { $participant = $this->testInviteModel->get_participant_by_testinvite($testinvite); $test = $this->testInviteModel->get_test_by_testinvite($testinvite); $template = $this->testTemplateModel->get_testtemplate_by_test($test->id, L::Dutch); // Email to participant $message = email_replace($template->template . '_completion', $participant, NULL, NULL, $testinvite); $this->email->clear(); $this->email->from(FROM_EMAIL, FROM_EMAIL_NAME); $this->email->to(in_development() ? TO_EMAIL_OVERRIDE : $participant->email); $this->email->subject('Babylab Utrecht: Bedankt voor het invullen van de vragenlijst'); $this->email->message($message); $this->email->send(); }