$query = "DELETE FROM " . table('participants') . "\n WHERE status_id='0' " . $in_clause; $done = or_query($query, $pars); $number = pdo_num_rows($done); message($number . ' ' . lang('xxx_temp_participants_deleted')); foreach ($del_emails as $participant_id => $email) { log__admin("participant_unconfirmed_delete", "participant_id: " . $participant_id . ', email: ' . $email); } redirect("admin/participants_unconfirmed.php"); } } } if ($proceed) { echo '<center>'; echo '<FORM action="participants_unconfirmed.php" method="POST">'; $posted_query = array('query' => array(0 => array("statusids_multiselect" => array("not" => "", "ms_status" => "0")))); $query_array = query__get_query_array($posted_query['query']); $query = query__get_query($query_array, 0, array(), 'creation_time DESC', false); echo '<BR> <TABLE width="80%" border="0"> <TR><TD> <TABLE width="100%" border="0"> <TR><TD width="50%" align="right"> <input class="button" type=submit name="deleteall" value="' . lang('delete_all') . '"> </TD><TD width="50%" align="right"> <input class="button" type=submit name="deletesel" value="' . lang('delete_selected') . '"> </TD></TR> </TABLE> </TD></TR> <TR><TD colspan="2">'; $emails = query_show_query_result($query, "participants_unconfirmed", false); echo '</FORM>';
function query__apply_permanent_queries() { global $settings; $continue = true; $target = ''; $num_queries = 0; $num_p = 0; $num_assigned = 0; if ($continue) { if ($settings['allow_permanent_queries'] != 'y') { $continue = false; } } if ($continue) { $ppart = array(); $ppart = participant__get_permanent_query_participants(); if (count($ppart) == 0) { $continue = false; } } if ($continue) { $pqu = array(); $pqu = query__get_permanent(); if (count($pqu) == 0) { $continue = false; } else { $num_queries = count($pqu); } } if ($continue) { $json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE); $query_assigned = array(); foreach ($ppart as $p) { $num_p++; foreach ($pqu as $q) { $experiment = orsee_db_load_array("experiments", $q['experiment_id'], "experiment_id"); if (!isset($experiment['experiment_id'])) { $continue = false; } if ($continue) { $posted_query = $json->decode($q['json_query']); $query_array = query__get_query_array($posted_query['query']); $active_clause = array('query' => participant_status__get_pquery_snippet("eligible_for_experiments"), 'pars' => array()); $exptype_clause = array('query' => "subscriptions LIKE (:experiment_ext_type)", 'pars' => array(':experiment_ext_type' => "%|" . $experiment['experiment_ext_type'] . "|%")); $notyetassigned_clause = array('query' => "participant_id NOT IN (SELECT participant_id FROM " . table('participate_at') . " WHERE experiment_id= :experiment_id)", 'pars' => array(':experiment_id' => $experiment['experiment_id'])); $additional_clauses = array($active_clause, $exptype_clause, $notyetassigned_clause); $query = query__get_query($query_array, time(), $additional_clauses, ''); $result = or_query($query['query'], $query['pars']); $p_is_eligibe = false; while ($pc = pdo_fetch_assoc($result)) { if ($pc['participant_id'] = $p['participant_id']) { $p_is_eligibe = true; } } if (!$p_is_eligibe) { $continue = false; } } if ($continue) { // assign participant $pars = array(':participant_id' => $p['participant_id'], ':experiment_id' => $experiment['experiment_id']); $query = "INSERT INTO " . table('participate_at') . " (participant_id,experiment_id)\n VALUES (:participant_id , :experiment_id)"; $done = or_query($query, $pars); $num_assigned++; if ($settings['permanent_queries_invite'] == 'y') { // send invitation into mail queue $pars = array(':experiment_id' => $experiment['experiment_id'], ':now' => time(), ':recipient' => $p['participant_id']); $query = "INSERT INTO " . table('mail_queue') . "\n SET timestamp = :now,\n mail_type = 'invitation',\n mail_recipient = :recipient,\n experiment_id = :experiment_id "; $done = or_query($query, $pars); } if (!isset($query_assigned[$q['query_id']])) { $query_assigned[$q['query_id']] = 0; } $query_assigned[$q['query_id']]++; } } // done with participant, reset permanent status $pars = array(':participant_id' => $p['participant_id']); $query = "UPDATE " . table('participants') . "\n SET apply_permanent_queries = 0\n WHERE participant_id = :participant_id"; $done = or_query($query, $pars); } // and now update permanent queries with assignment numbers foreach ($pqu as $q) { if (!isset($query_assigned[$q['query_id']])) { $query_assigned[$q['query_id']] = 0; } $done = query__update_permanent_query($q['query_id'], $query_assigned[$q['query_id']]); } } $target = 'Participants checked: ' . $num_p; if ($num_p > 0) { $target .= ', PermQueries found: ' . $num_queries; } if ($num_queries > 0) { $target .= ', Assignments made: ' . $num_assigned; } return $target; }