function email__participant_select($email, $participant = array(), $guess_parts = array()) { $cols = participant__get_result_table_columns('email_participant_guesses_list'); echo '<SELECT name="participant_id"> <OPTION value="0">' . lang('unknown') . '</OPTION>'; if (isset($participant['participant_id'])) { echo '<OPTION value="' . $participant['participant_id'] . '" SELECTED>'; $items = array(); foreach ($cols as $k => $c) { $items[] = $participant[$k]; } echo implode(" ", $items); echo '</OPTION>'; } if (!$email['session_id']) { foreach ($guess_parts as $gp) { if ($gp['participant_id'] != $participant['participant_id']) { echo '<OPTION value="' . $gp['participant_id'] . '">'; $items = array(); foreach ($cols as $k => $c) { $items[] = $gp[$k]; } echo implode(" ", $items); echo '</OPTION>'; } } } if (count($guess_parts) > 0 && $email['session_id']) { $sort = query__load_default_sort('email_participant_guesses_list'); $pars = array(':session_id' => $email['session_id']); $query = "SELECT * from " . table('participants') . "\n WHERE participant_id IN (\n SELECT participant_id FROM " . table('participate_at') . "\n WHERE session_id= :session_id)\n ORDER BY " . $sort; $result = or_query($query, $pars); while ($p = pdo_fetch_assoc($result)) { echo '<OPTION value="' . $p['participant_id'] . '">'; $items = array(); foreach ($cols as $k => $c) { $items[] = $p[$k]; } echo implode(" ", $items); echo '</OPTION>'; } } echo '</SELECT>'; }
$query_id = $_SESSION['lastqueryid_assign_' . $experiment_id]; $posted_query = $json->decode($posted_query_json); $sort = query__get_sort('assign', $_REQUEST['search_sort']); // sanitize sort } else { // store new query in session $query_id = time(); if (isset($_REQUEST['form'])) { $posted_query = $_REQUEST['form']; } else { $posted_query = array('query' => array()); } $posted_query_json = $json->encodeUnsafe($posted_query); $_SESSION['lastquery_assign_' . $experiment_id] = $posted_query_json; $_SESSION['lastqueryid_assign_' . $experiment_id] = $query_id; $sort = query__load_default_sort('assign', $experiment_id); } if (check_allow('participants_edit')) { echo javascript__edit_popup(); } // show query in human-readable form $pseudo_query_array = query__get_pseudo_query_array($posted_query['query']); $pseudo_query_display = query__display_pseudo_query($pseudo_query_array, true); echo '<TABLE border=0>'; echo '<TR><TD style="outline: 1px solid black; background: ' . $color['search__pseudo_query_background'] . '">'; echo $pseudo_query_display; echo '</TD><TD align="center">'; // permanent query button if ($settings['allow_permanent_queries'] == 'y' && check_allow('experiment_assign_query_permanent_activate')) { $cgivars = array(); $cgivars[] = "make_permanent=true";
function query__get_sort($type, $search_sort, $experiment_id = 0) { //sanitizes sort string //type can be: participants_search_active, participants_search_all, assign, deassign, session_list if ($type == 'participants_search_active') { $cols = participant__get_result_table_columns('result_table_search_active'); } elseif ($type == 'participants_search_all') { $cols = participant__get_result_table_columns('result_table_search_all'); } elseif ($type == 'session_participants_list') { $cols = participant__get_result_table_columns('session_participants_list'); } elseif ($type == 'session_participants_list_pdf') { $cols = participant__get_result_table_columns('session_participants_list_pdf'); } else { $cols = participant__get_result_table_columns('result_table_assign'); } $pform_columns = participant__load_all_pform_fields(); $search_ok = false; foreach ($cols as $k => $arr) { if (isset($pform_columns[$k]['sort_order']) && $pform_columns[$k]['sort_order']) { if ($search_sort == $pform_columns[$k]['sort_order']) { $search_ok = true; } } elseif (isset($cols[$k]['sort_order']) && $search_sort == $cols[$k]['sort_order']) { $search_ok = true; } elseif ($search_sort == $k) { $search_ok = true; } } if (!$search_ok) { $search_sort = query__load_default_sort($type, $experiment_id); } return $search_sort; }
// store new query in session $query_id = time(); if (isset($_REQUEST['form'])) { $posted_query = $_REQUEST['form']; } else { $posted_query = array('query' => array()); } $posted_query_json = $json->encodeUnsafe($posted_query); if ($active) { $_SESSION['lastquery_participants_search_active'] = $posted_query_json; $_SESSION['lastqueryid_participants_search_active'] = $query_id; $sort = query__load_default_sort('participants_search_active'); } else { $_SESSION['lastquery_participants_search_all'] = $posted_query_json; $_SESSION['lastqueryid_participants_search_all'] = $query_id; $sort = query__load_default_sort('participants_search_all'); } } // show query in human-readable form $pseudo_query_array = query__get_pseudo_query_array($posted_query['query']); $pseudo_query_display = query__display_pseudo_query($pseudo_query_array, $active); echo '<TABLE border=0>'; echo '<TR><TD style="outline: 1px solid black; background: ' . $color['search__pseudo_query_background'] . '">'; echo $pseudo_query_display; echo '</TD></TR></TABLE>'; echo '<BR><BR>'; $query_array = query__get_query_array($posted_query['query']); //dump_array($query_array); if ($active) { $active_clause = array('query' => participant_status__get_pquery_snippet("eligible_for_experiments"), 'pars' => array()); $additional_clauses = array($active_clause);