/** Returns the get link for a testsurvey */
 function testsurvey_get_link($testsurvey)
 {
     if (current_role() === UserRole::Caller) {
         return testsurvey_name($testsurvey);
     }
     return anchor('testsurvey/get/' . $testsurvey->id, testsurvey_name($testsurvey));
 }
 /** 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);
 }
Example #3
0
 /** Specifies the content for the admin interface view. */
 public function index()
 {
     switch (current_role()) {
         case UserRole::Caller:
             $this->caller_interface(current_user_id());
             break;
         case UserRole::Leader:
             $this->leader_interface(current_user_id());
             break;
         case UserRole::Admin:
             $this->admin_interface();
             break;
         case UserRole::System:
             redirect('appointment');
             break;
         default:
             show_404();
             break;
     }
 }
 public function table()
 {
     $participant_ids = array();
     if (current_role() == UserRole::Caller) {
         $experiments = $this->callerModel->get_experiments_by_caller(current_user_id());
         foreach ($experiments as $experiment) {
             $find_p = $this->participantModel->find_participants($experiment);
             $part_p = $this->experimentModel->get_participants_by_experiment($experiment->id);
             $participant_ids = array_merge($participant_ids, get_object_ids($find_p));
             $participant_ids = array_merge($participant_ids, get_object_ids($part_p));
         }
     }
     if (current_role() == UserRole::Leader) {
         $experiments = $this->leaderModel->get_experiments_by_leader(current_user_id());
         foreach ($experiments as $experiment) {
             $part_p = $this->experimentModel->get_participants_by_experiment($experiment->id);
             $participant_ids = array_merge($participant_ids, get_object_ids($part_p));
         }
     }
     $this->datatables->select('CONCAT(firstname, " ", lastname) AS p, dateofbirth, dateofbirth as age, dyslexicparent, multilingual, phone, id, CONCAT(parentfirstname, " ", parentlastname)', FALSE);
     $this->datatables->from('participant');
     if (!is_admin()) {
         if (empty($participant_ids)) {
             $this->datatables->where('id', 0);
         } else {
             $this->datatables->where('id IN (' . implode(',', $participant_ids) . ')');
         }
     }
     $this->datatables->edit_column('p', '$1', 'participant_get_link_by_id(id)');
     $this->datatables->edit_column('dateofbirth', '$1', 'dob(dateofbirth)');
     $this->datatables->edit_column('age', '$1', 'age_in_months_and_days(age)');
     $this->datatables->edit_column('dyslexicparent', '$1', 'img_tick(dyslexicparent)');
     $this->datatables->edit_column('multilingual', '$1', 'img_tick(multilingual)');
     $this->datatables->edit_column('id', '$1', 'participant_actions(id)');
     echo $this->datatables->generate();
 }
Example #5
0
<!-- Experiments -->
<?php 
if (is_admin()) {
    echo heading(lang('experiments'), 3);
    create_experiment_table('experiments');
    $experiments['id'] = 'experiments';
    $experiments['ajax_source'] = 'experiment/table_by_user/' . $user->id;
    echo $this->load->view('templates/list_view', $experiments);
}
?>

<!-- Comments -->
<?php 
echo heading(lang('comments'), 3);
create_comment_table('comments');
$comments['id'] = 'comments';
$comments['ajax_source'] = 'comment/table_by_user/' . $user->id;
echo $this->load->view('templates/list_view', $comments);
?>

<!-- Calls -->
<?php 
if (current_role() === UserRole::Caller) {
    echo heading(lang('calls'), 3);
    create_call_table('calls', FALSE);
    $calls['id'] = 'calls';
    $calls['sort_column'] = 4;
    $calls['sort_order'] = 'desc';
    $calls['ajax_source'] = 'call/table_by_user/' . $user->id;
    echo $this->load->view('templates/list_view', $calls);
}
 /** Shows the page for a specific experiment */
 public function experiment($experiment_id)
 {
     switch (current_role()) {
         case UserRole::Leader:
             create_participation_leader_table();
             $source = 'participation/table_by_leader/' . $experiment_id;
             break;
         default:
             create_participation_table();
             $add_url = array('url' => 'participation/add', 'title' => lang('ad_hoc_participation'));
             $source = 'participation/table/0/' . $experiment_id;
             $data['action_urls'] = array($add_url);
             break;
     }
     $experiment = $this->experimentModel->get_experiment_by_id($experiment_id);
     $data['page_title'] = sprintf(lang('participations_for'), $experiment->name);
     $data['ajax_source'] = $source;
     $this->load->view('templates/header', $data);
     $this->load->view('templates/list_view', $data);
     $this->load->view('templates/footer');
 }
Example #7
0
 /**
  * Downloads all dyslexia scores as a .csv-file.
  */
 public function download()
 {
     if (current_role() !== UserRole::Admin) {
         flashdata(lang('not_authorized'));
         redirect('/dyslexia/', 'refresh');
     }
     $csv = dyslexia_to_csv($this->dyslexiaModel->get_all_dyslexias());
     // Generate filename
     $filename = 'dyslexia_' . mdate("%Y%m%d_%H%i", time()) . '.csv';
     // Download the file
     force_download($filename, $csv);
 }
Example #8
0
				<li><?php 
    echo anchor('availability', lang('availability'));
    ?>
</li>
			</ul>
		</div>
		<?php 
}
?>

		<?php 
if (current_user_id() > 0) {
    ?>
		<div id="welcome">
		<?php 
    echo "<em>" . current_username() . " (" . strtolower(lang(current_role())) . ")" . "</em>";
    echo " | ";
    echo anchor('user/edit/' . current_user_id(), lang('edit_user_profile'));
    echo " | ";
    echo anchor('user/change_password/' . current_user_id(), lang('change_password'));
    echo " | ";
    if (user_role() === UserRole::Admin && !is_admin()) {
        echo anchor('login/switch_to/admin', lang('login_admin'));
        echo " | ";
    }
    if ((user_role() === UserRole::Admin || user_role() === UserRole::Leader) && !is_leader()) {
        echo anchor('login/switch_to/leader', lang('login_leader'));
        echo " | ";
    }
    if ((user_role() === UserRole::Admin || user_role() === UserRole::Leader) && !is_caller()) {
        echo anchor('login/switch_to/caller', lang('login_caller'));
 /** Returns whether or not the current user is a caller */
 function is_caller()
 {
     return current_role() === UserRole::Caller;
 }