/** Submits the e-mail and redirects based on validation. */ public function submit($language = L::Dutch) { // E-mail = NOT OK -> return to index with error message if (!$this->validate_email($language)) { $this->index($language); } else { $email = $this->input->post('email'); $code = $language . '/' . bin2hex(openssl_random_pseudo_bytes(8)); $update = array('selfservicecode' => $code, 'selfservicetime' => input_datetime('+1 day')); $participants = $this->participantModel->get_participants_by_email($email); foreach ($participants as $p) { $this->participantModel->update_participant($p->id, $update); $parent_name = parent_name($p); } $message_data['name_parent'] = $parent_name; $message_data['url'] = 'selfservice/auth/' . $code; $message = $this->load->view('mail/selfservice', $message_data, TRUE); $this->email->clear(); $this->email->from(FROM_EMAIL, FROM_EMAIL_NAME); $this->email->to(in_development() ? TO_EMAIL_OVERRIDE : $email); $this->email->subject(lang('selfservice_mail_subject')); $this->email->message($message); $this->email->send(); flashdata(sprintf(lang('selfservice_mail_sent'), $email)); redirect('selfservice'); } }
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 callers. */ public function callers() { if (!$this->input->is_cli_request()) { echo "This script can only be accessed via the command line" . PHP_EOL; return; } $users = $this->userModel->get_all_callers(); foreach ($users as $user) { reset_language(user_language($user)); $this->email->clear(); $this->email->from(FROM_EMAIL, FROM_EMAIL_NAME); $this->email->to(in_development() ? TO_EMAIL_OVERRIDE : $user->email); $this->email->subject(lang('rem_subject')); $call_messages = array(); $experiments = $this->callerModel->get_experiments_by_caller($user->id); foreach ($experiments as $experiment) { if ($experiment->archived != 1) { $count = count($this->participantModel->find_participants($experiment)); if ($count > 0) { array_push($call_messages, sprintf(lang('rem_exp_call'), $experiment->name, $count)); } } } if ($call_messages) { $message = sprintf(lang('mail_heading'), $user->username); $message .= br(2); $message .= lang('rem_body'); $message .= br(1); $message .= ul($call_messages); $message .= lang('mail_ending'); $message .= br(2); $message .= lang('mail_disclaimer'); $this->email->message($message); $this->email->send(); // DEBUG: echo $this->email->print_debugger(); } } }
/** * 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); } } }
/** * * Submits the password reset request * @param $language */ public function forgot_password_submit($language = L::English) { reset_language($language); // Validation rules $this->form_validation->set_rules('email', lang('email'), 'trim|required|valid_email|callback_email_exists|callback_reset_request_sent'); // Run validation if ($this->form_validation->run() == FALSE) { // If not succeeded, show form again with error messages $this->forgot_password(); } else { // If succeeded, lookup user by e-mail address and send password reset e-mail. $user = $this->userModel->get_user_by_email($this->input->post('email')); $url = bin2hex(openssl_random_pseudo_bytes(8)); $reset_request = array('activated' => NULL, 'resetrequeststring' => $url, 'resetrequesttime' => input_datetime()); $this->userModel->update_user($user->id, $reset_request); // Send out reset e-mail reset_language(user_language($user)); $this->email->clear(); $this->email->from(FROM_EMAIL, FROM_EMAIL_NAME); $this->email->to(in_development() ? TO_EMAIL_OVERRIDE : $user->email); $this->email->subject(lang('resetpw_subject')); $message = sprintf(lang('mail_heading'), $user->username); $message .= br(2); $message .= sprintf(lang('resetpw_body'), anchor(base_url() . 'resetpw/' . $url)); $message .= br(2); $message .= lang('mail_ending'); $message .= br(2); $message .= lang('mail_disclaimer'); $this->email->message($message); $this->email->send(); // Show success flashdata(sprintf(lang('forgot_pw_sent'), $user->email)); redirect('login', 'refresh'); } }
/** Deactivates the specified participant */ public function deactivate($participant_id) { $this->participantModel->deactivate($participant_id, DeactivateReason::Manual); $p = $this->participantModel->get_participant_by_id($participant_id); // Inform all admins of this deactivation $url = $this->config->site_url() . 'participant/get/' . $participant_id; $users = $this->userModel->get_all_admins(); foreach ($users as $user) { reset_language(user_language($user)); $this->email->clear(); $this->email->from(FROM_EMAIL, FROM_EMAIL_NAME); $this->email->to(in_development() ? TO_EMAIL_OVERRIDE : $user->email); $this->email->subject(lang('dereg_pp_subject')); $message = sprintf(lang('mail_heading'), $user->username); $message .= br(2); $message .= sprintf(lang('deac_pp_body'), name($p), $p->phone, current_username(), $url, $url); $message .= br(2); $message .= lang('mail_ending'); $message .= br(2); $message .= lang('mail_disclaimer'); $this->email->message($message); $this->email->send(); } flashdata(sprintf(lang('p_deactivated'), name($p))); redirect($this->agent->referrer(), 'refresh'); }
/** 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(); }