/** Possible actions for a participation: prioritize and delete */
 function participation_actions($participation_id)
 {
     $CI =& get_instance();
     $pp = $CI->participationModel->get_participation_by_id($participation_id);
     $not_cancelled = $pp->cancelled == 0;
     $is_confirmed = $pp->confirmed == 1 && $not_cancelled;
     $not_completed = $is_confirmed && $pp->noshow == 0 && $pp->completed == 0;
     $is_noshow = $pp->noshow == 1;
     $is_completed = $pp->completed == 1;
     $after_now = input_datetime($pp->appointment) > input_datetime('now');
     $get_link = participation_get_link($pp);
     $cancel_link = $not_completed && $not_cancelled ? anchor('participation/cancel/' . $pp->id, img_cancel(lang('cancelled'))) : img_cancel(lang('cancelled'), TRUE);
     $reschedule_link = $not_completed ? anchor('participation/reschedule/' . $pp->id, img_calendar()) : img_calendar(TRUE);
     $noshow_link = $is_confirmed && !$is_noshow && !$after_now ? anchor('participation/no_show/' . $pp->id, img_noshow()) : img_noshow(TRUE);
     $completed_link = $is_confirmed && !$after_now ? anchor('participation/completed/' . $pp->id, img_accept(lang('completed'))) : img_accept(lang('completed'), TRUE);
     $delete_link = anchor('participation/delete/' . $pp->id, img_p_delete(), warning(lang('sure_delete_part')));
     $comment_link = anchor('participation/edit_comment/' . $pp->id, img_comment());
     switch (current_role()) {
         case UserRole::Admin:
             $actions = array($get_link, $cancel_link, $reschedule_link, $noshow_link, $completed_link, $comment_link, $delete_link);
             break;
         case UserRole::Leader:
             $actions = array($get_link, $cancel_link, $reschedule_link, $noshow_link, $completed_link, $comment_link);
             break;
         default:
             $actions = array($get_link, $cancel_link, $reschedule_link, $comment_link);
             break;
     }
     return implode(' ', $actions);
 }
Esempio n. 2
0
 /** Authenticates the single-login code. Returns true if authentication was successful. */
 public function auth($language, $selfservicecode)
 {
     $participants = $this->participantModel->get_participants_by_selfservicecode($language . '/' . $selfservicecode);
     // If there are participants found, and request is not too old...
     if ($participants && $participants[0]->selfservicetime > input_datetime()) {
         // Create a fresh, brand new session
         $this->session->sess_create();
         // Set session data
         $session_data = array('email' => $participants[0]->email, 'participant_id' => $participants[0]->id, 'language' => $language, 'selfservice' => TRUE);
         $this->session->set_userdata($session_data);
         // Login was successful
         redirect('selfservice/welcome');
     } else {
         flashdata(lang('selfservice_incorrect_url'), FALSE);
         redirect('selfservice');
     }
 }
Esempio n. 3
0
 /**
  *
  * Checks whether there has already been sent a reset request
  * @param $email
  */
 public function reset_request_sent($email)
 {
     $user = $this->userModel->get_user_by_email($email);
     if ($user->resetrequesttime != NULL && $user->resetrequesttime > input_datetime('-1 day')) {
         $this->form_validation->set_message('reset_request_sent', lang('reset_request_sent'));
         return FALSE;
     }
     return TRUE;
 }
 /** Count testinvites that need to be manually reminded */
 public function count_to_be_reminded_testinvites()
 {
     $this->db->where('datecompleted', NULL);
     $this->db->where('datereminder < ', input_datetime('-1 week'));
     $this->db->where('datemanualreminder', NULL);
     return $this->db->count_all_results('testinvite');
 }
Esempio n. 5
0
 /** Checks whether the given date is within bounds of an existing closing for this location */
 public function check_within_bounds($date)
 {
     $locations = $this->input->post('lockdown') === '1' ? array(null) : $this->input->post('location');
     if ($locations) {
         foreach ($locations as $location_id) {
             // $location_id = $this->input->post('location');
             if ($this->closingModel->within_bounds(input_datetime($date), $location_id)) {
                 $this->form_validation->set_message('check_within_bounds', lang('closing_within_bounds'));
                 return FALSE;
             }
         }
     }
     return TRUE;
 }
Esempio n. 6
0
 /** Invalidates a token entry */
 public function invalidate_token($survey_id, $token)
 {
     $token_table = 'tokens_' . $survey_id;
     $token_update = array('usesleft' => 0, 'validuntil' => input_datetime());
     $this->survey_db->where('token', $token);
     $this->survey_db->update($token_table, $token_update);
 }
 /** Submits the rescheduling of a participation */
 public function reschedule_submit($participation_id)
 {
     $participant = $this->participationModel->get_participant_by_participation($participation_id);
     $experiment = $this->participationModel->get_experiment_by_participation($participation_id);
     $this->form_validation->set_rules('appointment', lang('appointment'), 'trim|required');
     // Run validation
     if (!$this->form_validation->run()) {
         // If not succeeded, return to previous page
         redirect('/participation/reschedule/' . $participation_id, 'refresh');
     } else {
         // If succeeded, insert data into database and send e-mail
         $appointment = input_datetime($this->input->post('appointment'));
         $this->participationModel->reschedule($participation_id, $appointment);
         $flashdata = br() . $this->send_reschedule_email($participation_id);
         flashdata(sprintf(lang('part_rescheduled'), name($participant), $experiment->name) . $flashdata);
         redirect('/participation/experiment/' . $experiment->id, 'refresh');
     }
 }
Esempio n. 8
0
 /** Ends a call */
 public function end_call($call_id, $call_status)
 {
     $this->db->where('id', $call_id);
     $this->db->update('call', array('status' => $call_status, 'timeend' => input_datetime()));
 }
 /** Deactivates a participant with a timestamp and reason */
 public function deactivate($participant_id, $reason)
 {
     $this->db->where('id', $participant_id);
     $this->db->update('participant', array('activated' => FALSE, 'deactivated' => input_datetime(), 'deactivated_reason' => $reason));
 }
 /** Checks whether the participation is locked */
 public function is_locked($participation)
 {
     if (empty($participation)) {
         return FALSE;
     }
     $time = $participation->locktime;
     if ($time == NULL) {
         return FALSE;
     }
     if ($time <= input_datetime()) {
         $this->release_lock($participation->id);
         return FALSE;
     }
     return TRUE;
 }
Esempio n. 11
0
 /** Returns whether or not the user is activated */
 function is_activated($user)
 {
     return $user->activated != NULL && $user->activated <= input_datetime();
 }
Esempio n. 12
0
 /** Checks whether the given date is within bounds of an existing closing for this location */
 public function check_closings($date, $location_id)
 {
     if ($this->closingModel->within_bounds(input_datetime($date), $location_id)) {
         $this->form_validation->set_message('check_closings', sprintf(lang('location_closed'), location_name($location_id)));
         return FALSE;
     }
     return TRUE;
 }
Esempio n. 13
0
    public function table($needs_manual_reminder = FALSE)
    {
        $this->datatables->select('test.name AS t, CONCAT(firstname, " ", lastname) AS p,
			token, datesent, datecompleted, datereminder, datemanualreminder, testinvite.id AS id, 
			testsurvey.id AS testsurvey_id, participant_id', FALSE);
        $this->datatables->from('testinvite');
        $this->datatables->join('participant', 'participant.id = testinvite.participant_id');
        $this->datatables->join('testsurvey', 'testsurvey.id = testinvite.testsurvey_id');
        $this->datatables->join('test', 'test.id = testsurvey.test_id');
        $this->datatables->edit_column('t', '$1', 'testsurvey_get_link_by_id(testsurvey_id)');
        $this->datatables->edit_column('p', '$1', 'participant_get_link_by_id(participant_id)');
        $this->datatables->edit_column('datesent', '$1', 'output_date(datesent)');
        $this->datatables->edit_column('datecompleted', '$1', 'output_date(datecompleted)');
        $this->datatables->edit_column('datereminder', '$1', 'output_date(datereminder)');
        $this->datatables->edit_column('datemanualreminder', '$1', 'output_date(datemanualreminder)');
        $this->datatables->edit_column('id', '$1', 'testinvite_actions(id)');
        if ($needs_manual_reminder) {
            $this->datatables->where('datecompleted', NULL);
            $this->datatables->where('datereminder < ', input_datetime('-1 week'));
            $this->datatables->where('datemanualreminder', NULL);
        }
        $this->datatables->unset_column('testsurvey_id');
        $this->datatables->unset_column('participant_id');
        echo $this->datatables->generate();
    }
Esempio n. 14
0
 /**
  * Creates an ad-hoc participant/testInvite and proceeds to fill the scores.
  * @param string $test_code
  * @param int $response_id
  */
 public function add_participant($test_code, $response_id)
 {
     if (!SURVEY_DEV_MODE) {
         $test = $this->testModel->get_test_by_code($test_code);
         $testsurveys = $this->testSurveyModel->get_testsurveys_by_test($test->id);
         // Set $testsurvey to the first item, unless we found none or multiple
         if (!$testsurveys) {
             echo 'We could not create an ad-hoc participant: no questionnaire link found.';
             return;
         } else {
             if (count($testsurveys) > 2) {
                 echo 'We could not create an ad-hoc participant: multiple questionnaire links found, so not clear which to use.';
                 return;
             }
         }
         $testsurvey = $testsurveys[0];
         sleep(2);
         // Explicitly wait some time to make sure results are stored
         $this->load->model('surveyModel');
         $result = $this->surveyModel->get_result_array_by_id($testsurvey->limesurvey_id, $response_id, FALSE);
         $mapping = $this->testSurveyMappingModel->get_mapping_by_testsurvey($testsurvey->id, 'participant');
         // Check if participant exists
         $firstname = $result[$mapping->firstname];
         $lastname = $result[$mapping->lastname];
         $gender = strtolower($result[$mapping->gender]);
         $dob = input_date($result[$mapping->dateofbirth]);
         $email = $result[$mapping->email];
         $participants = $this->participantModel->find_participants_by_name_gender_birth($firstname, $lastname, $gender, $dob);
         // If we find only one, set the $participant_id to the one found
         if (count($participants) === 1) {
             $participant_id = $participants[0]->id;
         } else {
             $m = $result[$mapping->multilingual] === 'Y';
             $d = !$result[$mapping->dyslexicparent] ? NULL : $result[$mapping->dyslexicparent];
             $p = !$result[$mapping->problemsparent] ? NULL : $result[$mapping->problemsparent];
             $l = !$result[$mapping->languagedisorderparent] ? NULL : $result[$mapping->languagedisorderparent];
             $a = !$result[$mapping->autisticparent] ? NULL : $result[$mapping->autisticparent];
             $at = !$result[$mapping->attentiondisorderparent] ? NULL : $result[$mapping->attentiondisorderparent];
             $participant = array('firstname' => $firstname, 'lastname' => $lastname, 'gender' => $gender, 'dateofbirth' => $dob, 'birthweight' => $result[$mapping->birthweight], 'pregnancyweeks' => $result[$mapping->pregnancyweeks], 'pregnancydays' => $result[$mapping->pregnancydays], 'phone' => '', 'email' => $email, 'multilingual' => $m, 'dyslexicparent' => $d, 'problemsparent' => $p, 'languagedisorderparent' => $l, 'autisticparent' => $a, 'attentiondisorderparent' => $at, 'deactivated' => input_datetime(), 'deactivated_reason' => DeactivateReason::FromSurvey);
             $participant_id = $this->participantModel->add_participant($participant);
         }
         // Create an ad-hoc testInvite and fill the scores
         $testinvite = $this->testInviteModel->create_testinvite($testsurvey->id, $participant_id);
         $this->add_scores($testinvite, $result, input_datetime());
         // Send an e-mail with the URL to the results page
         if ($email) {
             $this->send_completion_email($testinvite);
         }
         redirect('c/' . $test_code . '/' . $testinvite->token . '/home');
     }
 }
Esempio n. 15
0
 public function mark_handled($comment_id, $handled = TRUE)
 {
     $this->commentModel->mark_handled($comment_id, $handled ? input_datetime() : NULL);
     $message = $handled ? lang('comment_marked_handled') : lang('comment_marked_unsettled');
     flashdata($message, TRUE, 'comment_message');
     redirect($this->agent->referrer(), 'refresh');
 }