Beispiel #1
0
function cron__check_for_session_reminders()
{
    global $settings;
    $now = time();
    $query = "SELECT " . table('sessions') . ".*, " . table('experiments') . ".*, count(participate_id) as num_reg\n      \t\tFROM " . table('sessions') . ", " . table('participate_at') . ", " . table('experiments') . "  \n      \t\tWHERE " . table('sessions') . ".session_id=" . table('participate_at') . ".session_id\n\t\t\tAND " . table('sessions') . ".experiment_id = " . table('experiments') . ".experiment_id \n      \t\tAND session_status='live' AND reminder_sent = 'n' AND reminder_checked='n' \n\t\t\tGROUP BY " . table('participate_at') . ".session_id";
    $result = or_query($query);
    $mess = "";
    while ($line = pdo_fetch_assoc($result)) {
        // is due?
        if (sessions__get_reminder_time($line) < $now && ortime__sesstime_to_unixtime($line['session_start']) > $now) {
            // ok: and now what to do?
            $number = -1;
            $done = false;
            $disclaimer = "";
            switch ($line['send_reminder_on']) {
                case '0':
                case 'enough_participants_needed_plus_reserve':
                    if ($line['num_reg'] >= $line['part_needed'] + $line['part_reserve']) {
                        $number = experimentmail__send_session_reminders_to_queue($line);
                        $done = experimentmail__send_reminder_notice($line, $number, true);
                    } else {
                        $done = experimentmail__send_reminder_notice($line, $number, false, 'part_reserve');
                    }
                    break;
                case '1':
                case 'enough_participants_needed':
                    if ($line['num_reg'] >= $line['part_needed']) {
                        $number = experimentmail__send_session_reminders_to_queue($line);
                        $done = experimentmail__send_reminder_notice($line, $number, true);
                    } else {
                        $disclaimer = lang('reminder_not_sent_part_needed');
                        $done = experimentmail__send_reminder_notice($line, $number, false, 'part_needed');
                    }
                    break;
                case '2':
                case 'in_any_case_dont_ask':
                    $number = experimentmail__send_session_reminders_to_queue($line);
                    $done = experimentmail__send_reminder_notice($line, $number, true);
                    break;
                default:
                    // nothing
            }
            $done2 = experimentmail__set_reminder_checked($line['session_id']);
            $mess .= "found session " . session__build_name($line, $settings['admin_standard_language']) . "\n";
            if ($number >= 0) {
                $mess .= "send " . $number . " mails to mail queue\n";
            }
            if ($disclaimer) {
                $mess .= $disclaimer . "\n";
            }
            if ($done) {
                $mess .= "sent notice to experimenter\n";
            }
        }
    }
    return $mess;
}
Beispiel #2
0
function ortime__add_hourmin_to_sesstime($t, $h, $m = 0)
{
    $old_utime = ortime__sesstime_to_unixtime($t);
    $new_utime = $old_utime + (int) $h * 3600 + (int) $m * 60;
    return ortime__unixtime_to_sesstime($new_utime);
}
Beispiel #3
0
                $line['upload_type'] = 7;
            }
            $line = convert_array_to_UTF8($line);
            if ($do_insert) {
                $done = orsee_db_save_array($line, "uploads", $line['upload_id'], "upload_id");
            }
        }
        $dquery = "DELETE FROM " . $new_db_name . "." . table('uploads_data') . "";
        if ($do_delete) {
            $done = or_query($dquery);
        }
        $iquery = "INSERT INTO " . $new_db_name . "." . table('uploads_data') . " \n\t\t\t\tSELECT * FROM " . $old_db_name . "." . table('uploads_data') . "";
        if ($do_insert) {
            $done = or_query($iquery);
        }
    }
    if ($update_last_enrolment_date) {
        echo "Updating last_enrolment in " . table('participants') . " with last session's date\n";
        // last enrolements separately
        $squery = "SELECT p.participant_id, max(s.session_start) as last_sess \n\t\t\t\tFROM " . $new_db_name . "." . table('participate_at') . " as p,  " . $new_db_name . "." . table('sessions') . " as s\n\t\t\t\tWHERE p.session_id>0\n\t\t\t\tAND p.session_id=s.session_id\n\t\t\t\tGROUP BY p.participant_id";
        $result = or_query($squery);
        $pars = array();
        while ($line = pdo_fetch_assoc($result)) {
            $pars[] = array(':participant_id' => $line['participant_id'], ':last_enrolment' => ortime__sesstime_to_unixtime($line['last_sess']));
        }
        $uquery = "UPDATE " . $new_db_name . "." . table('participants') . " \n\t\t\t\t SET last_enrolment = :last_enrolment\n\t\t\t\t WHERE participant_id = :participant_id";
        if ($do_insert) {
            $result = or_query($uquery, $pars);
        }
    }
}
    echo '</table>';
    echo '</TD></TR>';
    /////////////////////////////
    /// SUBJECT POOL STATISTICS
    /////////////////////////////
    echo '<TR><TD>';
    echo '<TABLE class="or_orr_section_head"><TR><TD align="center" valign="middle">
			' . lang('subject_pool_statistics') . '
			</TD></TR></TABLE>';
    echo '</TD></TR>
			<TR><TD>';
    $pars = array(':experiment_id' => $experiment['experiment_id']);
    $query = "SELECT max(session_start) as max_time, min(session_start) as min_time\n\t\t\tFROM " . table('sessions') . " \n\t\t\tWHERE experiment_id = :experiment_id";
    $line = orsee_query($query, $pars);
    $min_session_time = ortime__sesstime_to_unixtime($line['min_time']);
    $max_session_time = ortime__sesstime_to_unixtime($line['max_time']);
    $total_data = array();
    // pool
    $options = array('upper_experience_limit' => $min_session_time);
    $condition = array('clause' => " status_id > 0 AND creation_time < '" . $max_session_time . "' AND  \n\t\t\t\t  (deletion_time=0 OR deletion_time > '" . $min_session_time . "') ", 'pars' => array());
    $total_data['pool'] = stats__get_data($condition, 'report', array(), $options);
    // experiment eligible
    $options = array('upper_experience_limit' => $min_session_time, 'condition_only_on_pid' => true);
    $condition = array('clause' => "participant_id IN (SELECT participant_id FROM " . table('participate_at') . " \n\t\t\t\t\t\t\t\tWHERE experiment_id= :experiment_id )", 'pars' => array(':experiment_id' => $experiment_id));
    $total_data['exp'] = stats__get_data($condition, 'report', array(), $options);
    // participated
    $options = array('upper_experience_limit' => $min_session_time, 'condition_only_on_pid' => true);
    $participated_clause = expregister__get_pstatus_query_snippet("participated");
    $condition = array('clause' => "participant_id IN (SELECT participant_id FROM " . table('participate_at') . " \n\t\t\t\t\t\t\t\tWHERE experiment_id= :experiment_id AND session_id > 0 AND " . $participated_clause . ")", 'pars' => array(':experiment_id' => $experiment_id));
    $total_data['part'] = stats__get_data($condition, 'report', array(), $options);
    echo '<TABLE class="or_orr_section_content">';
Beispiel #5
0
         $edit['public_session_note'] = "";
         $edit['session_start'] = ortime__unixtime_to_sesstime();
         $edit['session_duration_hour'] = $settings['session_duration_hour_default'];
         $edit['session_duration_minute'] = $settings['session_duration_minute_default'];
         $edit['session_reminder_hours'] = $settings['session_reminder_hours_default'];
         $edit['send_reminder_on'] = $settings['session_reminder_send_on_default'];
         $edit['registration_end_hours'] = $settings['session_registration_end_hours_default'];
         $session_time = 0;
         $edit['part_needed'] = $settings['lab_participants_default'];
         $edit['part_reserve'] = $settings['reserve_participants_default'];
         $edit['session_status'] = 'planned';
         $edit['payment_types'] = "";
         $edit['payment_budgets'] = "";
     }
 } else {
     $session_time = ortime__sesstime_to_unixtime($edit['session_start']);
     $button_name = lang('change');
     session__check_lab_time_clash($edit);
 }
 echo '<center>';
 show_message();
 echo '<FORM action="session_edit.php" method="POST">
         <INPUT type=hidden name=session_id value="' . $edit['session_id'] . '">
         <INPUT type=hidden name=experiment_id value="' . $edit['experiment_id'] . '">';
 if (isset($addit) && $addit) {
     echo '<INPUT type=hidden name="addit" value="true">';
 }
 echo '
     <TABLE class="or_formtable">
     <TR>
         <TD>' . lang('id') . ':</TD>
Beispiel #6
0
function email__expsess_select($email, $session = array(), $experiment = array(), $participant = array())
{
    global $lang;
    if (isset($session['session_id'])) {
        $selected = $session['experiment_id'] . ',' . $session['session_id'];
    } elseif (isset($experiment['experiment_id'])) {
        $selected = $experiment['experiment_id'] . ',0';
    } elseif (!$email['mailbox']) {
        $selected = '0,0';
    } else {
        $selected = '';
    }
    $pars = array();
    $query = "SELECT " . table('experiments') . ".*, " . table('sessions') . ".*\n            FROM " . table('experiments') . " LEFT JOIN " . table('sessions') . "\n            ON " . table('experiments') . ".experiment_id=" . table('sessions') . ".experiment_id\n            WHERE (" . table('experiments') . ".experiment_finished='n')";
    if (isset($session['experiment_id'])) {
        $query .= " OR (" . table('experiments') . ".experiment_id= :experiment_id) ";
        $pars[':experiment_id'] = $session['experiment_id'];
    } elseif (isset($experiment['experiment_id'])) {
        $query .= " OR (" . table('experiments') . ".experiment_id= :experiment_id) ";
        $pars[':experiment_id'] = $experiment['experiment_id'];
    }
    if (isset($participant['participant_id'])) {
        $query .= " OR (" . table('experiments') . ".experiment_id IN (\n                    SELECT experiment_id FROM " . table('participate_at') . "\n                    WHERE participant_id= :participant_id) ) ";
        $pars[':participant_id'] = $participant['participant_id'];
    }
    $query .= "ORDER BY session_start DESC ";
    $result = or_query($query, $pars);
    $experiments = array();
    while ($e = pdo_fetch_assoc($result)) {
        if ($e['session_id'] == NULL) {
            $e['session_id'] = 0;
        }
        $experiments[$e['experiment_id']]['sessions'][$e['session_id']] = $e;
        $experiments[$e['experiment_id']]['experiment_name'] = $e['experiment_name'];
        if (!isset($experiments[$e['experiment_id']]['lastsesstime']) || $e['session_start'] > $experiments[$e['experiment_id']]['lastsesstime']) {
            $experiments[$e['experiment_id']]['lastsesstime'] = $e['session_start'];
        }
    }
    // now order experiments by the date of the last session of the experiment, DESC!
    foreach ($experiments as $id => $arr) {
        $experiments[$id]['lastsesstime_reversed'] = 0 - $arr['lastsesstime'];
    }
    multi_array_sort($experiments, 'lastsesstime_reversed');
    echo '<SELECT name="expsess"><OPTION value="0,0">' . lang('select_none') . '</OPTION>';
    // list special mail boxes
    $mailboxes = email__load_mailboxes();
    foreach ($mailboxes as $k => $mb) {
        if ($k != 'trash' && $k != 'not_assigned') {
            echo '<OPTION value="box,' . $k . '"';
            if ($email['mailbox'] == $k) {
                echo ' SELECTED';
            }
            echo '>' . $mb . '</OPTION>';
        }
    }
    foreach ($experiments as $exp_id => $texperiment) {
        echo '<OPTION value="' . $exp_id . ',0"';
        if ($selected == $exp_id . ',0') {
            echo ' SELECTED';
        }
        echo '>' . $texperiment['experiment_name'] . '</OPTION>' . "\n";
        foreach ($texperiment['sessions'] as $tsession) {
            if ($tsession['session_id'] > 0) {
                $tsess_name = ortime__format(ortime__sesstime_to_unixtime($tsession['session_start']));
                echo '<OPTION value="' . $tsession['experiment_id'] . ',' . $tsession['session_id'] . '"';
                if ($selected == $tsession['experiment_id'] . ',' . $tsession['session_id']) {
                    echo ' SELECTED';
                }
                echo '>' . $tsession['experiment_name'] . ' - ' . $tsess_name . '</OPTION>';
            }
        }
    }
    if (isset($session['session_id']) && !isset($experiments[$session['experiment_id']]['sessions'][$session['session_id']])) {
        echo '<OPTION value="' . $session['experiment_id'] . ',' . $session['session_id'] . '" SELECTED>' . $experiment['experiment_name'] . ' - ' . ortime__format(ortime__sesstime_to_unixtime($session['session_start'])) . '</OPTION>';
    } elseif (isset($experiment['experiment_id']) && !isset($experiments[$experiment['experiment_id']])) {
        echo '<OPTION value="' . $experiment['experiment_id'] . ',0" SELECTED>' . $experiment['experiment_name'] . '</OPTION>';
    }
    echo '</SELECT>';
}
Beispiel #7
0
function sessions__get_reminder_time($alist, $session_id = "")
{
    if ($session_id) {
        $pars = array(':session_id' => $session_id);
        $query = "SELECT * FROM " . table('sessions') . " WHERE session_id=:session_id";
        $alist = orsee_query($query, $pars);
    }
    $reminder_time = ortime__add_hourmin_to_sesstime($alist['session_start'], 0 - $alist['session_reminder_hours']);
    return ortime__sesstime_to_unixtime($reminder_time);
}
Beispiel #8
0
function downloads__list_experiments($showsize = false, $showtype = false, $showdate = false)
{
    global $lang, $color, $expadmindata;
    $out = '';
    $continue = true;
    if (check_allow('file_view_experiment_all')) {
        $experimenter_clause = '';
        $pars = array();
    } elseif (check_allow('file_view_experiment_my')) {
        $experimenter_clause = " AND " . table('experiments') . ".experimenter LIKE :experimenter ";
        $pars = array(':experimenter' => '%|' . $expadmindata['admin_id'] . '|%');
    } else {
        $continue = false;
    }
    if ($continue) {
        $query = "SELECT " . table('experiments') . ".*,\n                (SELECT min(session_start) from or_sessions as s1 WHERE s1.experiment_id=" . table('experiments') . ".experiment_id) as first_session_date,\n                (SELECT max(session_start) from or_sessions as s2 WHERE s2.experiment_id=" . table('experiments') . ".experiment_id) as last_session_date\n                FROM " . table('experiments') . "\n                WHERE " . table('experiments') . ".experiment_id IN\n                (SELECT DISTINCT experiment_id FROM " . table('uploads') . ")\n                " . $experimenter_clause . "\n                ORDER BY last_session_date DESC";
        $result = or_query($query, $pars);
        $experiments = array();
        while ($line = pdo_fetch_assoc($result)) {
            $experiments[] = $line;
        }
        if (count($experiments) > 0) {
            $out .= '<TABLE width=100% border=0>';
            $shade = true;
            foreach ($experiments as $exp) {
                if ($shade) {
                    $bgcolor = ' bgcolor="' . $color['list_shade1'] . '"';
                    $shade = false;
                } else {
                    $bgcolor = ' bgcolor="' . $color['list_shade2'] . '"';
                    $shade = true;
                }
                $out .= '<TR' . $bgcolor . '><TD>';
                $out .= $exp['experiment_name'] . '</TD><TD>(';
                $out .= lang('from') . ' ';
                if ($exp['first_session_date'] == 0) {
                    $out .= '???';
                } else {
                    $out .= ortime__format(ortime__sesstime_to_unixtime($exp['first_session_date']), 'hide_time:true');
                }
                $out .= ' ' . lang('to') . ' ';
                if ($exp['last_session_date'] == 0) {
                    $out .= '???';
                } else {
                    $out .= ortime__format(ortime__sesstime_to_unixtime($exp['last_session_date']), 'hide_time:true');
                }
                $out .= ')</TD><TD>';
                $out .= experiment__list_experimenters($exp['experimenter'], true, true);
                $out .= '</TD><TD><A HREF="download_main.php?experiment_id=' . $exp['experiment_id'] . '">' . lang('show_files') . '</A>';
                $out .= '</TD></TR>';
            }
            $out .= '</TABLE>';
        }
    }
    return $out;
}
Beispiel #9
0
function calendar__get_events($admin = false, $start_time = 0, $end_time = 0, $admin_id = false, $split_events = false)
{
    $events = array();
    global $lang, $settings, $settings__root_url, $color;
    $labs = laboratories__get_laboratories();
    $sessions = array();
    $signed_up = array();
    $lines = array();
    //build query to get all sessions
    $query = "SELECT * FROM " . table('sessions') . ", " . table('experiments') . " WHERE " . table('sessions') . ".experiment_id=" . table('experiments') . ".experiment_id";
    //don't include hidden if not admin
    if (!$admin) {
        $query .= " AND " . table('experiments') . ".hide_in_cal='n' ";
    }
    //only events between start and end time parameters
    $pars = array(':end_time' => date("Ym320000", $end_time), ':start_time' => date("Ym000000", $start_time));
    // larger than "0st day" of start time month
    $query .= " AND session_start <= :end_time ";
    $query .= " AND session_start >= :start_time ";
    if ($admin_id) {
        $query .= " AND " . table('experiments') . ".experimenter LIKE :admin_id ";
        $pars[':admin_id'] = '%|".$admin_id."|%';
    }
    $result = or_query($query, $pars);
    $exp_colors = array();
    $exp_colors_used = 0;
    $exp_colors_defined_list = explode(",", $color['calendar_public_experiment_sessions']);
    while ($line = pdo_fetch_assoc($result)) {
        $lines[] = $line;
        $sessions[] = $line['session_id'];
    }
    if (count($sessions) > 0) {
        $query = "SELECT session_id, COUNT(*) as regcount FROM " . table('participate_at') . "\n                WHERE session_id IN (" . implode(",", $sessions) . ")\n                GROUP BY session_id";
        $result = or_query($query);
        while ($line = pdo_fetch_assoc($result)) {
            $signed_up[$line['session_id']] = $line['regcount'];
        }
    }
    foreach ($lines as $line) {
        $tmp_new_event = array();
        //get colour
        if (!isset($exp_colors[$line['experiment_id']])) {
            $exp_colors[$line['experiment_id']] = $exp_colors_defined_list[$exp_colors_used];
            $exp_colors_used += 1;
            if ($exp_colors_used > count($exp_colors_defined_list) - 1) {
                $exp_colors_used = 0;
            }
        }
        $tmp_new_event['color'] = $exp_colors[$line['experiment_id']];
        //convert to unix time
        $unix_time = ortime__sesstime_to_unixtime($line['session_start']);
        $tmp_new_event['start_time'] = $unix_time;
        //add duration to start time to create end time (in seconds)
        $duration = ($line['session_duration_hour'] * 60 + $line['session_duration_minute']) * 60;
        $tmp_new_event['end_time'] = $unix_time + $duration;
        //formatted time with language features
        $tmp_new_event['display_time'] = ortime__format($unix_time, 'hide_date:true,hide_second:true', $lang['lang']) . '-' . ortime__format($unix_time + $duration, 'hide_date:true,hide_second:true', $lang['lang']);
        if ($admin) {
            $tmp_new_event['title'] = $line['experiment_name'];
        } else {
            $tmp_new_event['title'] = $line['experiment_public_name'];
        }
        if (check_allow('experiment_show')) {
            $tmp_new_event['title_link'] = $settings__root_url . '/admin/experiment_show.php?experiment_id=' . $line['experiment_id'];
        }
        $tmp_new_event['participants_link'] = $settings__root_url . '/admin/experiment_participants_show.php?experiment_id=' . $line['experiment_id'] . '&session_id=' . $line['session_id'];
        if (isset($labs[$line['laboratory_id']]['lab_name'])) {
            $tmp_new_event['location'] = $labs[$line['laboratory_id']]['lab_name'];
        } else {
            $tmp_new_event['location'] = lang('unknown_laboratory');
        }
        if (isset($signed_up[$line['session_id']])) {
            $participating = $signed_up[$line['session_id']];
        } else {
            $participating = 0;
        }
        $tmp_new_event['participants_needed'] = $line['part_needed'];
        $tmp_new_event['participants_reserve'] = $line['part_reserve'];
        $tmp_new_event['participants_registered'] = $participating;
        //uid (unique identifier) for use by ICS
        $tmp_new_event['uid'] = "session_" . $line['session_id'] . "@" . $settings__root_url;
        $tmp_new_event['type'] = "experiment_session";
        if ($participating < $line['part_needed']) {
            $tmp_new_event['status'] = "not_enough_participants";
        } elseif ($participating < $line['part_needed'] + $line['part_reserve']) {
            $tmp_new_event['status'] = "not_enough_reserve";
        } else {
            $tmp_new_event['status'] = "complete";
        }
        $tmp_new_event['experimenters'] = $line['experimenter'];
        $tmp_new_event['id'] = $line['session_id'];
        $events[date("Y", $tmp_new_event['start_time']) * 10000 + date("n", $tmp_new_event['start_time']) * 100 + date("j", $tmp_new_event['start_time'])][] = $tmp_new_event;
    }
    //non-experimental laboratory booking events
    $event_categories = lang__load_lang_cat('events_category');
    $pars = array(':end_time' => date("Ym320000", $end_time), ':start_time' => date("Ym000000", $start_time));
    // larger than "0st day" of start time month
    $query = "SELECT *  FROM " . table('events') . " WHERE event_start <= :end_time\n              AND event_stop >= :start_time";
    if ($admin_id) {
        $query .= " AND " . table('events') . ".experimenter LIKE :admin_id ";
        $pars[':admin_id'] = '%|".$admin_id."|%';
    }
    $result = or_query($query, $pars);
    $exp_colors = array();
    $exp_colors_used = 0;
    $exp_colors_defined_list = explode(",", $color['calendar_event_reservation']);
    while ($line = pdo_fetch_assoc($result)) {
        if ($admin || trim($line['reason_public'])) {
            //get color
            if (!isset($exp_colors[$line['laboratory_id']])) {
                $exp_colors[$line['laboratory_id']] = $exp_colors_defined_list[$exp_colors_used];
                $exp_colors_used += 1;
                if ($exp_colors_used > count($exp_colors_defined_list) - 1) {
                    $exp_colors_used = 0;
                }
            }
            $tmp_new_event = array();
            $tmp_new_event['color'] = $exp_colors[$line['laboratory_id']];
            $unix_start_time = ortime__sesstime_to_unixtime($line['event_start']);
            $unix_stop_time = ortime__sesstime_to_unixtime($line['event_stop']);
            $tmp_new_event['start_time'] = $unix_start_time;
            $tmp_new_event['end_time'] = $unix_stop_time;
            $tmp_new_event['display_time'] = ortime__format($unix_start_time, 'hide_second:true', $lang['lang']) . '-' . ortime__format($unix_stop_time, 'hide_second:true', $lang['lang']);
            if (isset($labs[$line['laboratory_id']]['lab_name'])) {
                $tmp_new_event['location'] = $labs[$line['laboratory_id']]['lab_name'];
            } else {
                $tmp_new_event['location'] = $lang['unknown_laboratory'];
            }
            $tmp_new_event['type'] = "location_reserved";
            if ($admin) {
                $tmp_new_event['title'] = $line['reason'];
                if (trim($line['reason_public'])) {
                    $tmp_new_event['title'] .= ' (' . $line['reason_public'] . ')';
                }
                if ($line['event_category'] && isset($event_categories[$line['event_category']])) {
                    $tmp = $event_categories[$line['event_category']];
                    if ($tmp_new_event['title']) {
                        $tmp .= ", " . $tmp_new_event['title'];
                    }
                    $tmp_new_event['title'] = $tmp;
                }
                if (!$tmp_new_event['title']) {
                    $tmp_new_event['title'] = lang('laboratory_booked');
                }
            } else {
                $tmp_new_event['title'] = $line['reason_public'];
                if (!$tmp_new_event['title']) {
                    $tmp_new_event['title'] = lang('laboratory_booked');
                }
            }
            $tmp_new_event['edit_link'] = $settings__root_url . "/admin/events_edit.php?event_id=" . $line['event_id'];
            $tmp_new_event['experimenters'] = $line['experimenter'];
            $tmp_new_event['id'] = $line['event_id'];
            $tmp_new_event['uid'] = "booking_" . $line['event_id'] . "@" . $settings__root_url;
            if ($split_events) {
                $continue = true;
                $today = $unix_start_time;
                while ($continue) {
                    if (date("Ymd", $today) == date("Ymd", $unix_start_time)) {
                        $tmp_new_event['start_time'] = $unix_start_time;
                    } else {
                        $tmp_new_event['start_time'] = mktime($settings['laboratory_opening_time_hour'], $settings['laboratory_opening_time_minute'], 0, date("n", $today), date("j", $today), date("Y", $today));
                    }
                    if (date("Ymd", $today) >= date("Ymd", $unix_stop_time)) {
                        $tmp_new_event['end_time'] = $unix_stop_time;
                        $continue = false;
                    } else {
                        $tmp_new_event['end_time'] = mktime($settings['laboratory_closing_time_hour'], $settings['laboratory_closing_time_minute'], 0, date("n", $today), date("j", $today), date("Y", $today));
                    }
                    $tmp_new_event['display_time'] = ortime__format($tmp_new_event['start_time'], 'hide_date:true,hide_second:true', lang('lang')) . '-' . ortime__format($tmp_new_event['end_time'], 'hide_date:true,hide_second:true', lang('lang'));
                    $events[date("Y", $today) * 10000 + date("n", $today) * 100 + date("j", $today)][] = $tmp_new_event;
                    $today = strtotime("+1 day", $today);
                }
            } else {
                $events[date("Y", $tmp_new_event['start_time']) * 10000 + date("n", $tmp_new_event['start_time']) * 100 + date("j", $tmp_new_event['start_time'])][] = $tmp_new_event;
            }
        }
    }
    return $events;
}
Beispiel #10
0
function query__get_pseudo_query_array($posted_array)
{
    global $lang;
    $formfields = participantform__load();
    $pseudo_query_array = array();
    $clevel = 1;
    foreach ($posted_array as $num => $entry) {
        $temp_keys = array_keys($entry);
        $module_string = $temp_keys[0];
        $module_string_array = explode("_", $module_string);
        $module = $module_string_array[0];
        $type = $module_string_array[1];
        if ($module == 'pform') {
            unset($module_string_array[0]);
            unset($module_string_array[1]);
            $pform_formfield = implode("_", $module_string_array);
        } else {
            $pform_formfield = "";
        }
        $params = $entry[$module_string];
        $level = $clevel;
        $op_text = "";
        $text = '';
        $add = true;
        if (isset($params['logical_op']) && $params['logical_op']) {
            $op_text = lang($params['logical_op']);
        }
        switch ($module) {
            case "bracket":
                if ($type == 'open') {
                    $level = $clevel;
                    $clevel++;
                    $text = '(';
                } else {
                    $clevel--;
                    $level = $clevel;
                    $text = ')';
                }
                break;
            case "experimentclasses":
                $text = query__pseudo_query_not_without($params);
                $text .= ' ' . lang('participants_participated_expclass');
                $text .= ': ' . experiment__experiment_class_field_to_list($params['ms_classes']);
                break;
            case "experimenters":
                $text = query__pseudo_query_not_without($params);
                $text .= ' ' . lang('participants_participated_experimenters');
                $text .= ': ' . experiment__list_experimenters($params['ms_experimenters'], false, true);
                break;
            case "experimentsassigned":
                $text = query__pseudo_query_not_without($params);
                $text .= ' ' . lang('participants_were_assigned_to');
                $text .= ': ' . experiment__exp_id_list_to_exp_names($params['ms_experiments']);
                break;
            case "experimentsparticipated":
                $text = query__pseudo_query_not_without($params);
                $text .= ' ' . lang('participants_have_participated_on');
                $text .= ': ' . experiment__exp_id_list_to_exp_names($params['ms_experiments']);
                break;
            case "statusids":
                $text = query__pseudo_query_not_without($params);
                $text .= ' ' . lang('participants_of_status');
                $text .= ': ' . participant__status_id_list_to_status_names($params['ms_status']);
                break;
            case "pformtextfields":
                $text = lang('where');
                $text .= ' "' . $params['search_string'] . '" ';
                $text .= query__pseudo_query_not_not($params);
                $text .= lang('in') . ' ';
                if ($params['search_field'] == 'all') {
                    $text .= lang('any_field');
                } else {
                    $text .= $params['search_field'];
                }
                break;
            case "pform":
                $f = array();
                foreach ($formfields as $p) {
                    if ($p['mysql_column_name'] == $pform_formfield) {
                        $f = $p;
                    }
                }
                if (isset($f['mysql_column_name'])) {
                    $text = lang('where') . ' ' . lang($f['name_lang']) . ' ';
                    if ($type == 'numberselect') {
                        $text .= $params['sign'] . $params['fieldvalue'];
                    } elseif ($type == 'simpleselect') {
                        $text .= query__pseudo_query_not_not($params) . '= "' . $params['fieldvalue'] . '"';
                    } else {
                        $text .= query__pseudo_query_not_not($params) . lang('in') . ': ' . participant__select_lang_idlist_to_names($f['mysql_column_name'], $params['ms_' . $pform_formfield]);
                    }
                } else {
                    $add = false;
                }
                break;
            case "noshows":
                $text = lang('where_nr_noshowups_is') . ' ';
                $text .= $params['sign'] . ' ' . $params['count'];
                break;
            case "participations":
                $text = lang('where_nr_participations_is') . ' ';
                $text .= $params['sign'] . ' ' . $params['count'];
                break;
            case "updaterequest":
                $text = lang('where_profile_update_request_is') . ' ';
                if ($params['update_request_status'] == 'y') {
                    $text .= lang('active');
                } else {
                    $text .= lang('inactive');
                }
                break;
            case "activity":
                $text = lang('where') . ' ' . lang($params['activity_type']) . ' ';
                $text .= query__pseudo_query_not_not($params);
                $text .= lang('before_date') . ' ';
                $sesstime_act = ortime__array_to_sesstime($params, 'dt_activity_');
                $text .= ortime__format(ortime__sesstime_to_unixtime($sesstime_act), 'hide_time:true');
                break;
            case "randsubset":
                $text = lang('limit_to_randomly_drawn') . ' ';
                $text .= $params['limit'];
                break;
            case "subsubjectpool":
                $text = query__pseudo_query_not_without($params);
                $text .= ' ' . lang('who_are_in_subjectpool');
                $text .= ': ' . subpools__idlist_to_namelist($params['ms_subpool']);
                break;
        }
        if ($add) {
            $pseudo_query_array[] = array('level' => $level, 'op_text' => $op_text, 'text' => $text);
        }
    }
    return $pseudo_query_array;
}
Beispiel #11
0
 echo '</TABLE></TD></TR>';
 echo '
 </TABLE>
 </center><BR><BR>';
 if ($experiment['experiment_type'] == "laboratory") {
     // session summary
     echo '<center>
     <BR>
     <table class="or_panel">
     <TR>
         <TD>
             <TABLE width="100%" border=0 class="or_panel_title"><TR>
             <TD style="background: ' . $color['panel_title_background'] . '; color: ' . $color['panel_title_textcolor'] . '">' . lang('sessions') . '</TD>';
     if ($min > 0) {
         echo '<TD style="background: ' . $color['panel_title_background'] . '; color: ' . $color['panel_title_textcolor'] . '">' . lang('from') . ': ' . ortime__format(ortime__sesstime_to_unixtime($min), 'hide_time') . '
                     ' . lang('to') . ': ' . ortime__format(ortime__sesstime_to_unixtime($max), 'hide_time') . '
                     </TD>';
     }
     echo '      <TD style="background: ' . $color['panel_title_background'] . '; color: ' . $color['panel_title_textcolor'] . '">';
     if (check_allow('session_edit')) {
         echo button_link('session_edit.php?experiment_id=' . $experiment['experiment_id'], lang('create_new'), 'plus-circle');
     }
     echo '      </TD>
             </TR></TABLE>
         </TD>
     </TR>
     <TR>
         <TD>
             ' . count($sessions) . ' ' . lang('xxx_sessions_registered') . '<BR>
         </TD>
     </TR>
Beispiel #12
0
function expregister__get_history($participant_id)
{
    $pars = array(':participant_id' => $participant_id);
    $query = "SELECT * FROM " . table('experiments') . ", \n\t\t" . table('sessions') . ", " . table('participate_at') . "\n    \tWHERE " . table('experiments') . ".experiment_id=" . table('sessions') . ".experiment_id\n\t    AND " . table('experiments') . ".experiment_id=" . table('participate_at') . ".experiment_id\n    \tAND " . table('participate_at') . ".participant_id = :participant_id \n    \tAND " . table('sessions') . ".session_id = " . table('participate_at') . ".session_id\n    \tAND " . table('participate_at') . ".session_id!=0\n\t\tAND " . table('experiments') . ".experiment_type='laboratory' \n    \tORDER BY session_start DESC";
    $result = or_query($query, $pars);
    $history = array();
    while ($varray = pdo_fetch_assoc($result)) {
        $varray['session_unixtime'] = ortime__sesstime_to_unixtime($varray['session_start']);
        $now = time();
        if ($now >= $varray['session_unixtime']) {
            $varray['session_name'] = session__build_name($varray);
            $history[] = $varray;
        }
    }
    return $history;
}
Beispiel #13
0
function select__sessions($preval, $varname, $sessions, $hide_nosession = false, $with_exp = false)
{
    global $lang, $expadmindata;
    if (!$preval) {
        $preval = 0;
    }
    if (!$varname) {
        $varname = "session";
    }
    $out = '';
    $out .= '<SELECT name="' . $varname . '">';
    if (!$hide_nosession) {
        $out .= '<OPTION value="0"';
        if ($preval == 0) {
            $out .= " SELECTED";
        }
        $out .= '>' . lang('no_session') . '</OPTION>';
    }
    foreach ($sessions as $line) {
        $out .= '<OPTION value="' . $line['session_id'] . '"';
        if ($preval == $line['session_id']) {
            $out .= " SELECTED";
        }
        $out .= '>';
        if ($with_exp) {
            $out .= $line['experiment_name'] . ' - ';
        }
        $out .= ortime__format(ortime__sesstime_to_unixtime($line['session_start']), 'hide_second:true', lang('lang'));
        if (isset($line['p_is_assigned'])) {
            if ($line['p_is_assigned']) {
                $out .= ' - ' . lang('is_assigned_to_experiment_short');
            } else {
                $out .= ' - ' . lang('is_not_yet_assigned_to_experiment_short');
            }
        }
        $out .= '</OPTION>';
    }
    $out .= '</SELECT>';
    return $out;
}
Beispiel #14
0
function experiment__other_experiments_select_field($postvarname, $type = "assigned", $experiment_id = "", $selected, $multi = true, $mpoptions = array())
{
    // $postvarname - name of form field
    // selected - array of pre-selected experimenter usernames
    global $lang, $preloaded_experiments, $settings;
    $out = "";
    if (!(is_array($preloaded_experiments) && count($preloaded_experiments) > 0)) {
        $preloaded_experiments = experiment__preload_experiments();
    }
    $mylist = array();
    foreach ($preloaded_experiments as $e) {
        if ($e['experiment_id'] != $experiment_id && ($type == 'all' || $type == 'assigned' && $e['assigned'] == 'y' || $type == 'participated' && $e['participated'] == 'y')) {
            $ename = $e['experiment_name'];
            if ($e['time'] || $e['experimenter']) {
                $ename .= ' (';
            }
            if ($e['experimenter']) {
                $ename .= experiment__list_experimenters($e['experimenter'], false, false);
            }
            if ($e['time'] && $e['experimenter']) {
                $ename .= ', ';
            }
            if ($e['time']) {
                $ename .= ortime__format(ortime__sesstime_to_unixtime($e['start_date']), 'hide_time:true') . '-' . ortime__format(ortime__sesstime_to_unixtime($e['end_date']), 'hide_time:true');
            }
            if ($e['time'] || $e['experimenter']) {
                $ename .= ')';
            }
            $mylist[$e['experiment_id']] = $ename;
        }
    }
    if (!is_array($mpoptions)) {
        $mpoptions = array();
    }
    if (!isset($mpoptions['picker_icon'])) {
        $mpoptions['picker_icon'] = 'cogs';
    }
    if ($multi) {
        $out .= get_multi_picker($postvarname, $mylist, $selected, $mpoptions);
    } else {
        $out .= '<SELECT name="' . $postvarname . '">
				<OPTION value=""';
        if (!$selected) {
            $out .= ' SELECTED';
        }
        $out .= '>-</OPTION>
				';
        foreach ($mylist as $k => $v) {
            $out .= '<OPTION value="' . $k . '"';
            if ($selected == $k) {
                $out .= ' SELECTED';
            }
            $out .= '>' . $v . '</OPTION>
				';
        }
        $out .= '</SELECT>
		';
    }
    return $out;
}