echo '
     <TR>
         <TD valign="top">
             ' . lang('budget_limit') . ':
         </TD>
         <TD>
             <INPUT name="budget_limit" type=text size=40 maxlength=200 value="' . $budget['budget_limit'] . '">
         </TD>
     </TR>';
 echo '
     <TR>
         <TD valign="top">
             ' . lang('experimenter') . ':
         </TD>
         <TD>';
 echo experiment__experimenters_select_field('experimenter', db_string_to_id_array($budget['experimenter']), true);
 echo '  </TD>
     </TR>';
 echo '<TR>
             <TD>
                 ' . lang('enabled?') . '
             </TD>
             <TD>
                 <INPUT type=radio name="enabled" value="1"';
 if ($budget['enabled']) {
     echo ' CHECKED';
 }
 echo '>' . lang('yes') . '
                 &nbsp;&nbsp;
                 <INPUT type=radio name="enabled" value="0"';
 if (!$budget['enabled']) {
Exemple #2
0
function email__show_email($email, $open_reply = false, $open_note = false)
{
    global $color, $settings, $expadmindata;
    // load remaining email thread
    $pars = array(':thread_id' => $email['thread_id']);
    $query = "SELECT * FROM " . table('emails') . "\n            WHERE thread_id = :thread_id\n            AND message_id != thread_id\n            ORDER BY timestamp";
    $result = or_query($query, $pars);
    $replies = array();
    while ($r = pdo_fetch_assoc($result)) {
        $replies[] = $r;
    }
    // set mail thread as read when is unread
    if (!$email['flag_read'] || !$email['flag_assigned_to_read']) {
        $flags = array();
        if (!$email['flag_read']) {
            $flags['read'] = 1;
        }
        if ($settings['email_module_allow_assign_emails'] == 'y') {
            if (!$email['flag_assigned_to_read']) {
                global $expadmindata;
                $assigned_to = db_string_to_id_array($email['assigned_to']);
                if (in_array($expadmindata['admin_id'], $assigned_to)) {
                    $flags['assigned_to_read'] = 1;
                }
            }
        } else {
            if (!$email['flag_assigned_to_read']) {
                $flags['assigned_to_read'] = 1;
            }
        }
        if (count($flags) > 0) {
            email__update_flags($email['thread_id'], $flags);
        }
    }
    // guess participant if not already set
    $guess_parts = array();
    $guess_part_message = "";
    if (!$email['participant_id']) {
        $guess_parts = email__guess_participant($email);
        if (count($guess_parts) == 0) {
            $guess_part_message = lang('cannot_guess');
        } else {
            $guess_part_message = lang('guess');
            $email['participant_id'] = $guess_parts[0]['participant_id'];
            $participant = $guess_parts[0];
        }
    } else {
        $participant = orsee_db_load_array("participants", $email['participant_id'], "participant_id");
    }
    if (!isset($participant['participant_id'])) {
        $participant = array();
    }
    // guess experiment/session if not already set
    $guess_exp_sess = array();
    $guess_expsess_message = "";
    if (!$email['mailbox'] && !$email['experiment_id']) {
        $guess_exp_sess = email__guess_expsess($email);
        if (count($guess_exp_sess) == 0) {
            $guess_expsess_message = lang('cannot_guess');
        } else {
            $guess_expsess_message = lang('guess');
            $email['experiment_id'] = $guess_exp_sess[0]['experiment_id'];
            $email['session_id'] = $guess_exp_sess[0]['session_id'];
        }
    } else {
        if ($email['session_id']) {
            $session = orsee_db_load_array("sessions", $email['session_id'], "session_id");
        }
        if (isset($session['experiment_id'])) {
            $email['experiment_id'] = $session['experiment_id'];
        }
        if ($email['experiment_id']) {
            $experiment = orsee_db_load_array("experiments", $email['experiment_id'], "experiment_id");
        }
        if (!isset($session['session_id'])) {
            $session = array();
        }
    }
    if (!isset($session['session_id'])) {
        $session = array();
    }
    if (!isset($experiment['experiment_id'])) {
        $experiment = array();
    }
    $orig_to = explode(",", $email['to_address']);
    if ($email['cc_address']) {
        $orig_cc = explode(",", $email['cc_address']);
    } else {
        $orig_cc = array();
    }
    echo '<table class="or_formtable" style="background: ' . $color['options_box_background'] . '" CELLPADDING="3" CELLSPACING="3" >
        <TR class="emailtable"><TD align="right">';
    $allow_change = email__is_allowed($email, $experiment, 'change');
    $allow_reply = email__is_allowed($email, $experiment, 'reply');
    $allow_note = email__is_allowed($email, $experiment, 'note');
    $allow_delete = email__is_allowed($email, $experiment, 'delete');
    if ($allow_reply && count($orig_to) + count($orig_cc) > 1) {
        $reply_all_button = true;
    } else {
        $reply_all_button = false;
    }
    email__show_buttons($email, $reply_all_button, $allow_delete, $allow_reply, $allow_note);
    echo '</TD></TR>';
    echo '<TR class="emailtable"><TD>';
    echo '  <FORM action="' . thisdoc() . '" METHOD="POST"">
        <INPUT type="hidden" name="message_id" value="' . $email['message_id'] . '">';
    if (isset($_REQUEST['hide_header']) && $_REQUEST['hide_header']) {
        echo '<INPUT type="hidden" name="hide_header" value="true">';
    }
    echo '<TABLE  class="or_panel" style="background: ' . $color['content_background_color'] . '; width: 100%; padding: 2px;" CELLPADDING="3" CELLSPACING="0">';
    // show settings to classify this email
    echo '<TR style="background: ' . $color['panel_title_background'] . '; color: ' . $color['panel_title_textcolor'] . ';">
        <TD align=right>' . lang('mailbox_experiment_session') . ':</TD>
        <TD align=left valign=middle>';
    if ($allow_change) {
        email__expsess_select($email, $session, $experiment, $participant);
        if ($guess_expsess_message) {
            echo '<span class="small" style="border: 1px solid ' . $color['message_border'] . '; background: ' . $color['message_background'] . '; color: ' . $color['message_text'] . '"> (' . str_replace(" ", "&nbsp", $guess_expsess_message) . ')</span>';
        }
    } else {
        if ($email['experiment_id']) {
            echo $experiment['experiment_name'];
            if ($email['session_id']) {
                echo ', ' . session__build_name($related_sessions[$email['session_id']]);
            }
        } elseif ($email['mailbox']) {
            $mailboxes = email__load_mailboxes();
            echo $mailboxes[$email['mailbox']];
        } else {
            echo lang('mailbox_not_assigned');
        }
    }
    if ($email['experiment_id']) {
        echo '<BR><A HREF="experiment_show.php?experiment_id=' . urlencode($email['experiment_id']) . '" style="color: ' . $color['panel_title_textcolor'] . ';">[' . str_replace(" ", "&nbsp", lang('view_experiment')) . ']</A>';
    }
    if ($email['session_id']) {
        echo ' <A HREF="experiment_participants_show.php?experiment_id=' . urlencode($email['experiment_id']) . '&session_id=' . urlencode($email['session_id']) . '" style="color: ' . $color['panel_title_textcolor'] . ';">[' . str_replace(" ", "&nbsp", lang('view_session')) . ']</A>';
    }
    echo '  </TD>
            <TD align=center valign=middle rowspan=3>';
    echo lang('email_processed?') . '<BR>';
    if ($allow_change) {
        echo '<select id="processed_switch" name="flag_processed">';
        echo '<option value="0"';
        if (!$email['flag_processed']) {
            echo ' SELECTED';
        }
        echo '></option>';
        echo '<option value="1"';
        if ($email['flag_processed']) {
            echo ' SELECTED';
        }
        echo '></option>';
        echo '</select>';
        $out = "<script type=\"text/javascript\">\n        \$(function() {\n            \$('#processed_switch').switchy();\n            \$('#processed_switch').on('change', function(){\n                var firstOption = \$(this).children('option').first().val();\n                var lastOption = \$(this).children('option').last().val();\n                var bgColor = '#bababa';\n                if (\$(this).val() == firstOption){\n                    bgColor = '#DC143C';\n                } else if (\$(this).val() == lastOption){\n                    bgColor = '#008000';\n                }\n                \$(this).next().next().children().first().css(\"background-color\", bgColor);\n            });\n            \$('#processed_switch').trigger('change');\n        });\n        </script>";
        echo $out;
    } else {
        if ($email['flag_processed']) {
            echo lang('y');
        } else {
            echo lang('n');
        }
    }
    echo '  </TD>
            <TD align=center valign=middle rowspan=3>';
    if ($allow_change) {
        echo '<INPUT class="button small" type="submit" name="update" value="' . lang('save') . '">';
    }
    echo '  </TD>
            </TR>';
    echo '  <TR style="background: ' . $color['panel_title_background'] . '; color: ' . $color['panel_title_textcolor'] . ';">
            <TD align=right>' . lang('participant') . ':</TD>
            <TD align=left valign=middle>';
    if ($allow_change) {
        email__participant_select($email, $participant, $guess_parts);
        if ($guess_part_message) {
            echo '<span class="small" style="border: 1px solid ' . $color['message_border'] . '; background: ' . $color['message_background'] . '; color: ' . $color['message_text'] . '"> (' . str_replace(" ", "&nbsp", $guess_part_message) . ')</span>';
        }
    } else {
        if ($email['participant_id']) {
            $cols = participant__get_result_table_columns('email_participant_guesses_list');
            $items = array();
            foreach ($cols as $k => $c) {
                $items[] = $participant[$k];
            }
            echo implode(" ", $items);
        } else {
            echo lang('mailbox_not_assigned');
        }
    }
    if ($email['participant_id']) {
        echo '&nbsp;<A HREF="participants_edit.php?participant_id=' . urlencode($email['participant_id']) . '" style="color: ' . $color['panel_title_textcolor'] . ';">[' . str_replace(" ", "&nbsp", lang('view_profile')) . ']</A> ';
    }
    echo '</TD>
        </TR>';
    if ($settings['email_module_allow_assign_emails'] == 'y') {
        echo '  <TR style="background: ' . $color['panel_title_background'] . '; color: ' . $color['panel_title_textcolor'] . ';">
                <TD align=right>' . lang('assign_email_to') . ':</TD>
                <TD align=left valign=middle class="small">';
        if ($allow_change) {
            echo '<span style="color: ' . $color['body_text'] . ';">' . experiment__experimenters_select_field("assigned_to", db_string_to_id_array($email['assigned_to']), true, array('cols' => 30)) . '</span>';
        } else {
            if ($email['assigned_to']) {
                echo experiment__list_experimenters($email['assigned_to'], false, true);
            } else {
                echo '-';
            }
        }
        echo '</TD>
            </TR>';
    }
    // show headers
    email__show_headers($email);
    // show email body
    email__show_body($email);
    // attachments
    email__show_attachments($email);
    echo '
        </TABLE>
        </FORM>
        </TD></TR>
        ';
    echo '<TR><TD>';
    echo '<TABLE width=100% border=0>';
    foreach ($replies as $remail) {
        echo '<TR><TD valign="top">';
        if ($remail['message_type'] == 'reply') {
            echo icon('reply', '', ' fa-2x', ' color: #666666;', 'reply');
        } elseif ($remail['message_type'] == 'note') {
            echo icon('file-text-o', '', ' fa-2x', ' color: #666666;', 'internal note');
        } elseif ($remail['message_type'] == 'incoming') {
            echo icon('envelope-square', '', ' fa-2x', ' color: #666666;', 'incoming');
        }
        echo '</TD><TD>&nbsp;&nbsp;</TD><TD>';
        echo '<TABLE  class="or_panel" style="background: ' . $color['content_background_color'] . '; width: 100%; padding: 2px;" CELLPADDING="3" CELLSPACING="0">';
        // show headers
        email__show_headers($remail);
        // show email body
        email__show_body($remail);
        // attachments
        email__show_attachments($remail);
        echo '</TABLE>
        </TD></TR>
        ';
    }
    echo '</TABLE></TD></TR>';
    if (count($replies) > 0) {
        echo '<TR class="emailtable"><TD align="right">';
        email__show_buttons($email, $reply_all_button, false, $allow_reply, $allow_note);
        echo '</TD></TR>';
    }
    // reply field
    if ($allow_reply) {
        echo '<TR id="replyfield"><TD>';
        echo '<A name="replyform"></A>';
        show_message();
        echo '<FORM name="send_email" action="' . thisdoc() . '#replyform" method="POST">
             <INPUT type="hidden" name="message_id" value="' . $email['message_id'] . '">';
        if (isset($_REQUEST['hide_header']) && $_REQUEST['hide_header']) {
            echo '<INPUT type="hidden" name="hide_header" value="true">';
        }
        if (isset($_REQUEST['replytype']) && $_REQUEST['replytype'] == 'reply') {
            $replytype = 'reply';
        } else {
            $replytype = 'replyall';
        }
        echo '<INPUT id="replytype" type="hidden" name="replytype" value="' . $replytype . '">';
        echo '<TABLE class="or_panel" style="background: ' . $color['content_background_color'] . '; width: 100%;">';
        echo '<TR><TD colspan=2 align=right>
                <I id="close_reply" class="fa fa-times-circle-o fa-2x"></I>
                </TD></TR>';
        echo '<TR><TD align=right>' . lang('email_from') . ':</TD>
                    <TD width=90% align=left>' . $settings['support_mail'] . '</TD>
                </TR>';
        if (isset($_REQUEST['send_to'])) {
            $to = $_REQUEST['send_to'];
        } elseif (isset($email['reply_to_address']) && $email['reply_to_address']) {
            $to = $email['reply_to_address'];
        } else {
            $to = $email['from_address'];
        }
        echo '<TR>
                 <TD align=right>' . lang('email_to') . ':</TD><TD align=left>
                    <INPUT type="text" name="send_to" size=60 maxlength=255 value="' . $to . '">
                </TD>
                </TR>';
        if (isset($_REQUEST['send_cc_replyall'])) {
            $cc_replyall = $_REQUEST['send_cc_replyall'];
        } else {
            $cc_arr = array();
            if (count($orig_to) > 1) {
                foreach ($orig_to as $oto) {
                    if ($oto != $settings['support_mail'] && !in_array($oto, $cc_arr)) {
                        $cc_arr[] = $oto;
                    }
                }
            }
            foreach ($orig_cc as $occ) {
                if ($occ != $settings['support_mail'] && !in_array($occ, $cc_arr)) {
                    $cc_arr[] = $occ;
                }
            }
            $cc_replyall = implode(",", $cc_arr);
        }
        echo '<TR id="ccfield_replyall">
                 <TD align=right>' . lang('email_cc') . ':</TD><TD align=left>
                    <INPUT type="text" name="send_cc_replyall" rows=2 cols=60 value="' . $cc_replyall . '">
                </TD>
                </TR>';
        if (isset($_REQUEST['send_cc_reply'])) {
            $cc_reply = $_REQUEST['send_cc_reply'];
        } else {
            $cc_reply = '';
        }
        echo '<TR id="ccfield_reply">
                 <TD align=right>' . lang('email_cc') . ':</TD><TD align=left>
                    <INPUT type="text" name="send_cc_reply" rows=2 cols=60 value="' . $cc_reply . '">
                </TD>
                </TR>';
        if (isset($_REQUEST['send_subject'])) {
            $subject = $_REQUEST['send_subject'];
        } else {
            $subject = lang('email_subject_re:') . ' ' . $email['subject'];
        }
        echo '<TR>
                <TD align=right>' . lang('email_subject') . ':</TD>
                <TD align=left><INPUT type="text" name="send_subject" size=60 maxlength=255 value="' . $subject . '"></TD>
                </TR>';
        if (isset($_REQUEST['send_body'])) {
            $body = $_REQUEST['send_body'];
        } else {
            $body = "\n\n\n\n" . $email['from_name'] . ' <' . $email['from_address'] . '> ' . lang('email_xxx_wrote') . ':' . "\n" . email__cite_text($email['body']);
        }
        echo '<TR><TD></TD><TD>
                <textarea name="send_body" wrap="virtual" rows="20" cols="60">' . $body . '</textarea>
            </TD></TR>';
        echo '<TR><TD colspan="2" align="center"><INPUT type="submit" class="button" name="send" value="' . lang('send_email') . '"></TD></TR>';
        echo '</TABLE>';
        echo '</FORM>';
        echo '</TD></TR>';
    }
    // note field
    if ($allow_note) {
        echo '<TR id="notefield"><TD>';
        echo '<A name="noteform"></A>';
        show_message();
        echo '<FORM name="add_note" action="' . thisdoc() . '#noteform" method="POST">
             <INPUT type="hidden" name="message_id" value="' . $email['message_id'] . '">';
        if (isset($_REQUEST['hide_header']) && $_REQUEST['hide_header']) {
            echo '<INPUT type="hidden" name="hide_header" value="true">';
        }
        echo '<TABLE class="or_panel" style="background: ' . $color['content_background_color'] . '; width: 100%;">';
        echo '<TR><TD colspan="3" align=right>
                <I id="close_note" class="fa fa-times-circle-o fa-2x"></I>
                </TD></TR>';
        echo '<TR><TD valign="top" rowspan="3">';
        echo icon('file-text-o', '', ' fa-2x', ' color: #666666;', 'internal note');
        echo '</TD><TD rowspan="3">&nbsp;&nbsp;</TD>';
        echo '<TD>' . lang('email_internal_note_by') . ' ' . $expadmindata['fname'] . ' ' . $expadmindata['lname'] . '</TD>
                </TR>';
        if (isset($_REQUEST['note_body'])) {
            $body = $_REQUEST['note_body'];
        } else {
            $body = "";
        }
        echo '<TR><TD>
                <textarea name="note_body" wrap="virtual" rows="20" cols="60">' . $body . '</textarea>
            </TD></TR>';
        echo '<TR><TD align="center"><INPUT type="submit" class="button" name="addnote" value="' . lang('add') . '"></TD></TR>';
        echo '</TABLE>';
        echo '</FORM>';
        echo '</TD></TR>';
    }
    echo '</TABLE>';
    echo '  <script type="text/javascript"> ';
    if (!$open_reply) {
        echo '$("#replyfield").hide(); ';
    } else {
        if ($replytype == 'reply') {
            echo ' $("#ccfield_replyall").hide(); ';
        } else {
            echo ' $("#ccfield_reply").hide(); ';
        }
    }
    if ($allow_note && !$open_note) {
        echo '$("#notefield").hide(); ';
    }
    if ($allow_note) {
        echo '
                $(".note_button").click(function() {
                    $(".emailtable :input").attr("disabled", true);
                    $("#notefield").show();
                    $("html, body").animate({
                        scrollTop: $("#notefield").offset().top
                    }, 1000);
                });
                $("#close_note").click(function() {
                    $("#notefield").hide();
                    $(".emailtable :input").attr("disabled", false);
                });';
    }
    if ($allow_reply) {
        echo '
                $(".reply_button").click(function() {
                    $(".emailtable :input").attr("disabled", true);
                    $("#replytype").val("reply");
                    $("#ccfield_replyall").hide();
                    $("#ccfield_reply").show();
                    $("#replyfield").show();
                    $("html, body").animate({
                        scrollTop: $("#replyfield").offset().top
                    }, 1000);
                });
                $(".replyall_button").click(function() {
                    $(".emailtable :input").attr("disabled", true);
                    $("#replytype").val("replyall");
                    $("#ccfield_replyall").show();
                    $("#ccfield_reply").hide();
                    $("#replyfield").show();
                    $("html, body").animate({
                        scrollTop: $("#replyfield").offset().top
                    }, 1000);
                });
                $("#close_reply").click(function() {
                    $("#ccfield").hide();
                    $("#replyfield").hide();
                    $("#ccfield_replyall").hide();
                    $("#ccfield_reply").hide();
                    $(".emailtable :input").attr("disabled", false);
                });';
    }
    echo '
            </script>';
}
Exemple #3
0
function query__get_query_form_prototypes($hide_modules = array(), $experiment_id = "", $status_query = "")
{
    global $lang, $settings, $all_orsee_query_modules;
    $formfields = participantform__load();
    $orsee_query_modules = $all_orsee_query_modules;
    $protoypes = array();
    foreach ($orsee_query_modules as $module) {
        if (!in_array($module, $hide_modules)) {
            switch ($module) {
                case "brackets":
                    $prototype = array('type' => 'brackets', 'displayname' => lang('query_brackets'), 'field_name_placeholder' => '#brackets#');
                    $content = "";
                    $prototype['content'] = $content;
                    $prototypes[] = $prototype;
                    break;
                case "experimentclasses":
                    $prototype = array('type' => 'experimentclasses_multiselect', 'displayname' => lang('query_experiment_class'), 'field_name_placeholder' => '#experiment_class#');
                    $content = "";
                    $content .= '<SELECT name="not">
                        <OPTION value="NOT" SELECTED>' . lang('without') . '</OPTION>
                        <OPTION value="">' . lang('only') . '</OPTION>
					</SELECT> ';
                    $content .= lang('participants_participated_expclass') . '<BR>';
                    $content .= experiment__experiment_class_select_field('#experiment_class#_ms_classes', array(), true, array('cols' => 40, 'picker_maxnumcols' => 3));
                    $prototype['content'] = $content;
                    $prototypes[] = $prototype;
                    break;
                case "experimenters":
                    $prototype = array('type' => 'experimenters_multiselect', 'displayname' => lang('query_experimenters'), 'field_name_placeholder' => '#experimenters#');
                    $content = "";
                    $content .= '<SELECT name="not">
                        <OPTION value="NOT" SELECTED>' . lang('without') . '</OPTION>
                        <OPTION value="">' . lang('only') . '</OPTION>
					</SELECT> ';
                    $content .= lang('participants_participated_experimenters') . '<BR>';
                    $content .= experiment__experimenters_select_field("#experimenters#_ms_experimenters", array(), true, array('cols' => 40, 'tag_color' => '#f1c06f', 'picker_color' => '#c58720', 'picker_maxnumcols' => 3));
                    $prototype['content'] = $content;
                    $prototypes[] = $prototype;
                    break;
                case "experimentsassigned":
                    $prototype = array('type' => 'experimentsassigned_multiselect', 'displayname' => lang('query_experiments_assigned'), 'field_name_placeholder' => '#experiments_assigned#');
                    $content = "";
                    $content .= '<SELECT name="not">
                        <OPTION value="NOT" SELECTED>' . lang('without') . '</OPTION>
                        <OPTION value="">' . lang('only') . '</OPTION>
					</SELECT> ';
                    $content .= lang('participants_were_assigned_to') . '<BR>';
                    $content .= experiment__other_experiments_select_field("#experiments_assigned#_ms_experiments", "assigned", $experiment_id, array(), true, array('cols' => 80, 'tag_color' => '#b3ffb3', 'picker_color' => '#00a300', 'picker_maxnumcols' => $settings['query_experiment_list_nr_columns']));
                    $prototype['content'] = $content;
                    $prototypes[] = $prototype;
                    break;
                case "experimentsparticipated":
                    $prototype = array('type' => 'experimentsparticipated_multiselect', 'displayname' => lang('query_experiments_participated'), 'field_name_placeholder' => '#experiments_participated#');
                    $content = "";
                    $content .= '<SELECT name="not">
                        <OPTION value="NOT" SELECTED>' . lang('without') . '</OPTION>
                        <OPTION value="">' . lang('only') . '</OPTION>
					</SELECT> ';
                    $content .= lang('participants_have_participated_on') . '<BR>';
                    $content .= experiment__other_experiments_select_field("#experiments_participated#_ms_experiments", "participated", $experiment_id, array(), true, array('cols' => 80, 'tag_color' => '#a8a8ff', 'picker_color' => '#0000ff', 'picker_maxnumcols' => $settings['query_experiment_list_nr_columns']));
                    $prototype['content'] = $content;
                    $prototypes[] = $prototype;
                    break;
                case "statusids":
                    $prototype = array('type' => 'statusids_multiselect', 'displayname' => lang('query_participant_status'), 'field_name_placeholder' => '#statusids#');
                    $content = "";
                    $content .= '<SELECT name="not">
                        <OPTION value="NOT" SELECTED>' . lang('without') . '</OPTION>
                        <OPTION value="">' . lang('only') . '</OPTION>
					</SELECT> ';
                    $content .= lang('participants_of_status') . ' ';
                    $content .= participant_status__multi_select_field("#statusids#_ms_status", array(), array('cols' => 80, 'tag_color' => '#a8a8ff', 'picker_color' => '#0000ff', 'picker_maxnumcols' => 2));
                    $prototype['content'] = $content;
                    $prototypes[] = $prototype;
                    break;
                case "pformtextfields":
                    $prototype = array('type' => 'pformtextfields_freetextsearch', 'displayname' => lang('query_participant_form_textfields'), 'field_name_placeholder' => '#participant_form_textfields#');
                    $form_query_fields = array();
                    foreach ($formfields as $f) {
                        if (preg_match("/(textline|textarea)/i", $f['type']) && (!$experiment_id && $f['search_include_in_participant_query'] == 'y' || $experiment_id && $f['search_include_in_experiment_assign_query'] == 'y')) {
                            $tfield = array();
                            $tfield['value'] = $f['mysql_column_name'];
                            $tfield['name'] = lang($f['name_lang']);
                            $form_query_fields[] = $tfield;
                        }
                    }
                    $content = "";
                    $content .= lang('where');
                    $content .= ' <INPUT type="text" size="20" maxlength="100" name="search_string" value="">';
                    $content .= '<SELECT name="not">
                        <OPTION value="NOT">' . lang('not') . '</OPTION>
                        <OPTION value="" SELECTED></OPTION>
					</SELECT> ';
                    $content .= ' ' . lang('in') . ' ';
                    $content .= '<SELECT name="search_field">
       	        	<OPTION value="all" SELECTED>' . lang('any_field') . '</OPTION>';
                    foreach ($form_query_fields as $tf) {
                        $content .= '<OPTION value="' . $tf['value'] . '">' . $tf['name'] . '</OPTION>';
                    }
                    $content .= '</SELECT>';
                    $prototype['content'] = $content;
                    $prototypes[] = $prototype;
                    break;
                case "pformselects":
                    $pform_selects = array();
                    foreach ($formfields as $f) {
                        if (!preg_match("/(textline|textarea)/i", $f['type']) && (!$experiment_id && $f['search_include_in_participant_query'] == 'y' || $experiment_id && $f['search_include_in_experiment_assign_query'] == 'y')) {
                            $pform_selects[] = $f['mysql_column_name'];
                        }
                    }
                    // $existing=true;
                    //if ($experiment_id) $show_count=false; else $show_count=true;
                    // needs too much time for queries. So  better:
                    $existing = false;
                    $show_count = false;
                    foreach ($pform_selects as $fieldname) {
                        $f = array();
                        foreach ($formfields as $p) {
                            if ($p['mysql_column_name'] == $fieldname) {
                                $f = $p;
                            }
                        }
                        $f = form__replace_funcs_in_field($f);
                        if (isset($f['mysql_column_name'])) {
                            $fieldname_lang = lang($f['name_lang']);
                            $fname_ph = '#pform_select_' . $fieldname . '#';
                            $prototype = array('type' => 'pform_select_' . $fieldname, 'displayname' => lang('query_participant_form_selectfield') . $fieldname_lang, 'field_name_placeholder' => $fname_ph);
                            $content = "";
                            $content .= lang('where') . ' ' . $fieldname_lang . ' ';
                            if ($f['type'] == 'select_numbers') {
                                $content .= '<select name="sign">
                      <OPTION value="<="><=</OPTION>
					  <OPTION value="=" SELECTED>=</OPTION>
                      <OPTION value=">">></OPTION>
					  </select>';
                            } else {
                                $content .= '<select name="not">
				 	<OPTION value="" SELECTED>=</OPTION>
				 	<OPTION value="NOT">' . lang('not') . ' =</OPTION>
				 	</select> ';
                            }
                            if (preg_match("/(select_lang|radioline_lang)/", $f['type'])) {
                                $content .= language__multiselectfield_item($fieldname, $fieldname, $fname_ph . '_ms_' . $fieldname, array(), "", $existing, $status_query, $show_count, true, array('cols' => 80, 'tag_color' => '#bbbbbb', 'picker_color' => '#444444', 'picker_maxnumcols' => 3));
                                $prototype['type'] = 'pform_multiselect_' . $fieldname;
                            } elseif ($f['type'] == 'select_numbers') {
                                if ($f['values_reverse'] == 'y') {
                                    $reverse = true;
                                } else {
                                    $reverse = false;
                                }
                                $content .= participant__select_numbers($fieldname, 'fieldvalue', '', $f['value_begin'], $f['value_end'], 0, $f['value_step'], $reverse, false, $existing, $status_query, $show_count);
                                $prototype['type'] = 'pform_numberselect_' . $fieldname;
                            } elseif (preg_match("/(select_list|radioline)/i", $f['type']) && !$existing) {
                                $f['value'] = '';
                                $content .= form__render_select_list($f, 'fieldvalue');
                                $prototype['type'] = 'pform_simpleselect_' . $fieldname;
                            } else {
                                $content .= participant__select_existing($fieldname, 'fieldvalue', '', $status_query, $show_count);
                                $prototype['type'] = 'pform_simpleselect_' . $fieldname;
                            }
                            $prototype['content'] = $content;
                            $prototypes[] = $prototype;
                        }
                    }
                    break;
                case "noshows":
                    $prototype = array('type' => 'noshows_numbercompare', 'displayname' => lang('query_noshows'), 'field_name_placeholder' => '#noshows#');
                    $query = "SELECT max(number_noshowup) as maxnoshow FROM " . table('participants');
                    if ($status_query) {
                        $query .= " WHERE " . $status_query;
                    }
                    $line = orsee_query($query);
                    $content = "";
                    $content .= lang('where_nr_noshowups_is') . ' ';
                    $content .= '<select name="sign">
                    	<OPTION value="<=" SELECTED><=</OPTION>
               			<OPTION value=">">></OPTION>
                    	</select> ';
                    $content .= helpers__select_number("count", '0', 0, $line['maxnoshow'], 0);
                    $prototype['content'] = $content;
                    $prototypes[] = $prototype;
                    break;
                case "participations":
                    $prototype = array('type' => 'participations_numbercompare', 'displayname' => lang('query_participations'), 'field_name_placeholder' => '#participations#');
                    $query = "SELECT max(number_reg) as maxnumreg FROM " . table('participants');
                    if ($status_query) {
                        $query .= " WHERE " . $status_query;
                    }
                    $line = orsee_query($query);
                    $content = "";
                    $content .= lang('where_nr_participations_is') . ' ';
                    $content .= '<select name="sign">
                    	<OPTION value="<=" SELECTED><=</OPTION>
               			<OPTION value=">">></OPTION>
                    	</select> ';
                    $content .= helpers__select_number("count", '0', 0, $line['maxnumreg'], 0);
                    $prototype['content'] = $content;
                    $prototypes[] = $prototype;
                    break;
                case "updaterequest":
                    $prototype = array('type' => 'updaterequest_simpleselect', 'displayname' => lang('query_profile_update_request'), 'field_name_placeholder' => '#updaterequest#');
                    $content = "";
                    $content .= lang('where_profile_update_request_is') . ' ';
                    $content .= '<select name="update_request_status">
					<OPTION value="y">' . lang('active') . '</OPTION>
					<OPTION value="n">' . lang('inactive') . '</OPTION>
                   	</select> ';
                    $prototype['content'] = $content;
                    $prototypes[] = $prototype;
                    break;
                case "activity":
                    $prototype = array('type' => 'activity_numbercompare', 'displayname' => lang('query_activity'), 'field_name_placeholder' => '#activity#');
                    $content = lang('where');
                    $content .= '<SELECT name="activity_type">
                        <OPTION value="last_activity" SELECTED>' . lang('last_activity') . '</OPTION>
                        <OPTION value="last_enrolment">' . lang('last_enrolment') . '</OPTION>
                        <OPTION value="last_profile_update">' . lang('last_profile_update') . '</OPTION>
        			    <OPTION value="creation_time">' . lang('creation_time') . '</OPTION>';
                    //$content.='    <OPTION value="deletion_time">'.lang('deletion_time').'</OPTION>';
                    $content .= '</SELECT> ';
                    $content .= '<SELECT name="not">
						<OPTION value="" SELECTED></OPTION>
						<OPTION value="NOT">' . lang('not') . '</OPTION>
					</SELECT> ';
                    $content .= lang('before_date') . ' ';
                    $content .= formhelpers__pick_date('#activity#_dt_activity');
                    $prototype['content'] = $content;
                    $prototypes[] = $prototype;
                    break;
                case "randsubset":
                    $prototype = array('type' => 'randsubset_limitnumber', 'displayname' => lang('query_rand_subset'), 'field_name_placeholder' => '#rand_subset#');
                    $query_limit = !isset($_REQUEST['query_limit']) || !$_REQUEST['query_limit'] ? $settings['query_random_subset_default_size'] : $_REQUEST['query_limit'];
                    $content = "";
                    $content .= lang('limit_to_randomly_drawn') . ' ';
                    $content .= '<INPUT type="text" data-elem-name="limit" value="' . $settings['query_random_subset_default_size'] . '" size="5" maxlength="10">';
                    $prototype['content'] = $content;
                    $prototypes[] = $prototype;
                    break;
                case "subsubjectpool":
                    $prototype = array('type' => 'subsubjectpool_multiselect', 'displayname' => lang('query_subsubjectpool'), 'field_name_placeholder' => '#subsubjectpool#', 'defaults' => array('#subsubjectpool#_not' => '', '#subsubjectpool#_ms_subpool' => ''));
                    $content = "";
                    $content .= '<SELECT name="not">
                        <OPTION value="NOT" SELECTED>' . lang('without') . '</OPTION>
                        <OPTION value="">' . lang('only') . '</OPTION>
					</SELECT> ';
                    $content .= lang('who_are_in_subjectpool') . ' ';
                    $content .= subpools__multi_select_field("#subsubjectpool#_ms_subpool", array(), array('cols' => 80, 'tag_color' => '#a8a8ff', 'picker_color' => '#0000ff', 'picker_maxnumcols' => 1));
                    $prototype['content'] = $content;
                    $prototypes[] = $prototype;
                    break;
            }
        }
    }
    return $prototypes;
}
Exemple #4
0
                                <TD>
					<INPUT name="access_restricted" type=checkbox value="y"';
        if ($edit['access_restricted'] == "y") {
            echo " CHECKED";
        }
        echo '>
        			</TD>
                        </TR>';
    }
    echo '		<TR>
				<TD>' . lang('get_emails') . ':</TD>
				<TD>';
    if (!isset($_REQUEST['experiment_id']) || !$_REQUEST['experiment_id']) {
        $edit['experimenter_mail'] = '|' . $expadmindata['admin_id'] . '|';
    }
    echo experiment__experimenters_select_field("experimenter_mail", db_string_to_id_array($edit['experimenter_mail']), true, array('tag_color' => '#c4e79d', 'picker_icon' => 'user', 'picker_color' => '#90d841', 'picker_maxnumcols' => 2));
    echo '			</TD>
			</TR>';
    if ($settings['enable_editing_of_experiment_sender_email'] == 'y' && check_allow('experiment_change_sender_address')) {
        echo '		<TR>
				<TD>' . lang('email_sender_address') . ':</TD>
				<TD><INPUT name="sender_mail" type="text" size=40 maxlength=60
					value="';
        if ($edit['sender_mail']) {
            echo stripslashes($edit['sender_mail']);
        } else {
            echo $settings['support_mail'];
        }
        echo '"></TD>
			</TR>';
    }
Exemple #5
0
function experiment__current_experiment_summary($experimenter = "", $finished = "n", $show_filter = false, $addbutton = true)
{
    global $lang, $expadmindata, $color;
    $experimentclasses = experiment__load_experimentclassnames();
    $experimenters = experiment__load_experimenters();
    $pars = array();
    $experimenter_arr = array();
    if (isset($_REQUEST['experimenter_search']) && $_REQUEST['experimenter_search']) {
        $experimenter_arr = multipicker_json_to_array($_REQUEST['experimenter_search']);
    }
    if ($experimenter && count($experimenter_arr) == 0) {
        $experimenter_arr = array($experimenter);
    }
    $exp_clause = query__get_experimenter_or_clause($experimenter_arr);
    if ($exp_clause['clause']) {
        $expq = ' AND ' . $exp_clause['clause'];
        foreach ($exp_clause['pars'] as $k => $v) {
            $pars[$k] = $v;
        }
    } else {
        $expq = "";
    }
    $class_arr = array();
    if (isset($_REQUEST['class_search']) && $_REQUEST['class_search']) {
        $class_arr = multipicker_json_to_array($_REQUEST['class_search']);
    }
    $class_clause = query__get_class_or_clause($class_arr);
    if ($class_clause['clause']) {
        $classq = ' AND ' . $class_clause['clause'];
        foreach ($class_clause['pars'] as $k => $v) {
            $pars[$k] = $v;
        }
    } else {
        $classq = "";
    }
    $finq = " " . table('experiments') . ".experiment_finished= :finished";
    $pars[':finished'] = $finished;
    $aquery = $finq . $expq . $classq;
    $query = "SELECT " . table('experiments') . ".*,\n\t\t\t\tcount(*) as num_sessions,\n\t\t\t\tif(session_start IS NULL, 1,0) as no_sessions,\n\t\t\t\tmin(if(session_start > date_format(now(),'%Y%m%d%H%i'), \n\t\t\t\tsession_start,NULL)) as time,\n      \t\t\tmin(session_start) as first_session_date,\n      \t\t\tmax(session_start) as last_session_date\n      \t\t\tFROM " . table('experiments') . "\n      \t\t\tLEFT JOIN " . table('sessions') . " ON " . table('experiments') . ".experiment_id=" . table('sessions') . ".experiment_id \n      \t\t\tWHERE " . table('experiments') . ".experiment_id IS NOT NULL \n      \t\t\tAND " . $aquery . " \n      \t\t\tGROUP BY experiment_id \n      \t\t\tORDER BY no_sessions, time, last_session_date DESC, experiment_id";
    $result = or_query($query, $pars);
    $experiments = array();
    $eids = array();
    while ($line = pdo_fetch_assoc($result)) {
        $line['sessions'] = array();
        $experiments[$line['experiment_id']] = $line;
        $eids[] = $line['experiment_id'];
    }
    if (count($eids) > 0) {
        $query = "SELECT * \n\t      \t\t\tFROM " . table('sessions') . " \n\t\t\t\t\tWHERE (session_status='planned' OR session_status='live') \n\t\t\t\t\tAND experiment_id IN (" . implode(',', $eids) . ") \n\t\t\t\t\tORDER BY session_start, session_id";
        $result = or_query($query);
        $sids = array();
        while ($line = pdo_fetch_assoc($result)) {
            $experiments[$line['experiment_id']]['sessions'][$line['session_id']] = $line;
            $sids[] = $line['session_id'];
        }
        // get counts at experiment level
        // performance is better if doing this separately
        $query = "SELECT experiment_id, \n\t\t\t\t\tcount(*) as num_assigned \n\t\t\t\t\tFROM " . table('participate_at') . "  \n\t\t\t\t\tWHERE experiment_id IN (" . implode(',', $eids) . ")\n\t\t\t\t\tGROUP BY experiment_id";
        $result = or_query($query);
        while ($line = pdo_fetch_assoc($result)) {
            $experiments[$line['experiment_id']]['num_assigned'] = $line['num_assigned'];
        }
        $query = "SELECT experiment_id, \n\t\t\t\t\tcount(*) as num_registered \n\t\t\t\t\tFROM " . table('participate_at') . "  \n\t\t\t\t\tWHERE session_id!=0 \n\t\t\t\t\tAND experiment_id IN (" . implode(',', $eids) . ")\n\t\t\t\t\tGROUP BY experiment_id";
        $result = or_query($query);
        while ($line = pdo_fetch_assoc($result)) {
            $experiments[$line['experiment_id']]['num_registered'] = $line['num_registered'];
        }
        $participated_clause = expregister__get_pstatus_query_snippet("participated");
        $query = "SELECT experiment_id, \n\t\t\t\t\tcount(*) as num_participated \n\t\t\t\t\tFROM " . table('participate_at') . "  \n\t\t\t\t\tWHERE " . $participated_clause . " \n\t\t\t\t\tAND experiment_id IN (" . implode(',', $eids) . ")\n\t\t\t\t\tGROUP BY experiment_id";
        $result = or_query($query);
        while ($line = pdo_fetch_assoc($result)) {
            $experiments[$line['experiment_id']]['num_participated'] = $line['num_participated'];
        }
        //
        if ($finished == 'y') {
            $noshow_clause = expregister__get_pstatus_query_snippet("noshow");
            // get showup counts at session level
            // couldn't get much better performance if separating counts
            $query = "SELECT " . table('participate_at') . ".experiment_id, \n\t\t\t\t\t\tcount(*) as comp_num_registered,\n\t\t\t\t\t\tsum(if(" . $noshow_clause . ",1,0)) as comp_num_noshow  \n\t\t\t\t\t\tFROM " . table('participate_at') . ", " . table('sessions') . " \n\t\t\t\t\t\tWHERE " . table('participate_at') . ".session_id=" . table('sessions') . ".session_id \n\t\t\t\t\t\tAND (" . table('sessions') . ".session_status='completed' OR " . table('sessions') . ".session_status='balanced') \n\t\t\t\t\t\tAND " . table('participate_at') . ".experiment_id IN (" . implode(',', $eids) . ")\n\t\t\t\t\t\tGROUP BY " . table('participate_at') . ".experiment_id";
            $result = or_query($query);
            while ($line = pdo_fetch_assoc($result)) {
                $experiments[$line['experiment_id']]['comp_num_registered'] = $line['comp_num_registered'];
                $experiments[$line['experiment_id']]['comp_num_noshow'] = $line['comp_num_noshow'];
            }
        }
        if (count($sids) > 0) {
            $query = "SELECT experiment_id, session_id, \n\t\t\t\t\t\tcount(*) as num_registered \n\t\t\t\t\t\tFROM " . table('participate_at') . " \n\t\t\t\t\t\tWHERE session_id IN (" . implode(',', $sids) . ")\n\t\t\t\t\t\tGROUP BY experiment_id, session_id";
            $result = or_query($query);
            while ($line = pdo_fetch_assoc($result)) {
                $experiments[$line['experiment_id']]['sessions'][$line['session_id']]['num_registered'] = $line['num_registered'];
            }
        }
    }
    echo '
 		
 		<center>
		<BR>
		<table class="or_panel">';
    if ($show_filter) {
        echo '<TR><TD colspan=2>
					<FORM action="' . thisdoc() . '"><TABLE border=0><TR><TD>' . lang('restrict_list_to_experiments_of_class') . '</TD><TD>';
        echo experiment__experiment_class_select_field('class_search', $class_arr, true, array('cols' => 30, 'picker_maxnumcols' => 3));
        echo '	</TD><TD rowspan=2 valign=middle>
					<INPUT class="button" style="font-size: 8pt; margin: 0;" type=submit name="show" value="' . lang('show') . '">
					</TD></TR><TR><TD>' . lang('restrict_list_to_experimenters') . '</TD><TD>';
        echo experiment__experimenters_select_field("experimenter_search", $experimenter_arr, true, array('cols' => 30, 'tag_color' => '#f1c06f', 'picker_color' => '#c58720', 'picker_maxnumcols' => 3));
        echo '	</TD></TR></TABLE></FORM>
			</TD></TR>';
    }
    echo '
		<TR>
		<TD colspan=2>
			<TABLE width="100%" border=0 class="or_panel_title"><TR><TD style="background: ' . $color['panel_title_background'] . '; color: ' . $color['panel_title_textcolor'] . '">';
    if ($finished == "y") {
        echo lang('finished_experiments');
    } elseif ($experimenter) {
        echo lang('my_experiments');
    } else {
        echo lang('experiments');
    }
    echo '</TD><TD style="background: ' . $color['panel_title_background'] . '; color: ' . $color['panel_title_textcolor'] . '">';
    if ($addbutton && check_allow('experiment_edit')) {
        echo button_link("experiment_edit.php?addit=true", lang('register_new_experiment'), 'plus-circle');
    }
    if (!$experimenter) {
        if ($finished == "n") {
            echo button_link("experiment_old.php", lang('finished_experiments'), 'fast-backward');
        } else {
            echo button_link("experiment_main.php", lang('current_experiments'), 'fast-forward');
        }
    }
    echo '</TD></TR>
			</TABLE>
		</TD></TR>
		<TR><TD colspan=2>';
    echo count($experiments) . ' ';
    if ($finished == "n") {
        echo lang('xxx_current_experiments');
    } else {
        echo lang('xxx_finished_experiments');
    }
    echo '
		</TD></TR>
		<TR><TD width="5%">&nbsp;&nbsp;&nbsp;</TD>
		<TD width="95%" colspan=2>

			<TABLE border=0 width="100%" cellspacing="0">';
    foreach ($experiments as $id => $exp) {
        if ($finished == "n") {
            experiment__experiments_format_alist($exp);
        } else {
            experiment__old_experiments_format_alist($exp);
        }
    }
    echo '</TABLE>
		</TD></TR>
		</TABLE>
		</center>
		<BR><BR>
		';
}
Exemple #6
0
    echo '</TD>
		</TR>';
    echo '  <TR><TD>' . lang('stop_date_and_time') . ':</TD>
            <TD>';
    echo formhelpers__pick_date('event_stop', $edit['event_stop'], $settings['session_start_years_backward'], $settings['session_start_years_forward']);
    echo '&nbsp;&nbsp;';
    echo formhelpers__pick_time('event_stop', $edit['event_stop']);
    echo '	</TD>
        </TR>';
    echo '  <TR>
             <TD>' . lang('experimenter') . ':</TD>
             <TD>';
    if (!isset($_REQUEST['event_id']) || !$_REQUEST['event_id']) {
        $edit['experimenter'] = '|' . $expadmindata['admin_id'] . '|';
    }
    echo experiment__experimenters_select_field("experimenter", db_string_to_id_array($edit['experimenter']));
    echo '	</TD>
        </TR>';
    echo '	<TR>
			<TD>' . lang('description') . ':</TD>
			<TD><INPUT type="text" name="reason" size=40 maxlength=200 value="' . $edit['reason'] . '"></TD>
		</TR>';
    echo '  <TR>
            <TD>' . lang('labspace_public_description') . ':<BR>
				<FONT class="small">' . lang('labspace_public_description_note') . '</FONT></TD>
            <TD><INPUT type="text" name="reason_public" size=40 maxlength=200 value="' . $edit['reason_public'] . '"></TD>
            </TR>';
    if ($settings['enable_event_participant_numbers'] == 'y') {
        echo '  <TR>
				<TD>' . lang('number_of_participants') . ':</TD>
				<TD><INPUT type="text" name="number_of_participants" size=5 maxlength=5 value="' . $edit['number_of_participants'] . '"></TD>