Exemple #1
0
            redirect("public/" . thisdoc());
        }
        $proceed = false;
    }
}
if ($proceed) {
    echo '<center>';
    $form = true;
    $errors__dataform = array();
    if (isset($_REQUEST['add'])) {
        $continue = true;
        if (!isset($_REQUEST['captcha']) || !isset($_SESSION['captcha_string']) || $_REQUEST['captcha'] != $_SESSION['captcha_string']) {
            if (!isset($_REQUEST['subscriptions']) || !is_array($_REQUEST['subscriptions'])) {
                $_REQUEST['subscriptions'] = array();
            }
            $_REQUEST['subscriptions'] = id_array_to_db_string($_REQUEST['subscriptions']);
            $continue = false;
            message(lang('error_wrong_captcha'));
        }
        if ($continue) {
            // checks and errors
            foreach ($_REQUEST as $k => $v) {
                if (!is_array($v)) {
                    $_REQUEST[$k] = trim($v);
                }
            }
            $_REQUEST['subpool_id'] = $_SESSION['subpool_id'];
            $errors__dataform = participantform__check_fields($_REQUEST, false);
            $error_count = count($errors__dataform);
            if ($error_count > 0) {
                $continue = false;
Exemple #2
0
}
if ($proceed) {
    // form
    if (isset($_REQUEST['copy']) && $_REQUEST['copy']) {
        $session_id = "";
    }
    if (!$session_id) {
        $addit = true;
        $button_name = lang('add');
        if (isset($_REQUEST['copy']) && $_REQUEST['copy']) {
            if ($settings['enable_payment_module'] == 'y') {
                if (isset($_REQUEST['payment_types'])) {
                    $_REQUEST['payment_types'] = id_array_to_db_string(multipicker_json_to_array($_REQUEST['payment_types']));
                }
                if (isset($_REQUEST['payment_budgets'])) {
                    $_REQUEST['payment_budgets'] = id_array_to_db_string(multipicker_json_to_array($_REQUEST['payment_budgets']));
                }
            }
            $_REQUEST['session_start'] = ortime__array_to_sesstime($_REQUEST, 'session_start_');
            $edit = $_REQUEST;
            $edit['session_id'] = time();
            $edit['session_status'] = 'planned';
            $session_time = 0;
        } else {
            $edit['experiment_id'] = $_REQUEST['experiment_id'];
            $edit['session_id'] = time();
            $edit['laboratory_id'] = "";
            $edit['session_remarks'] = "";
            $edit['public_session_note'] = "";
            $edit['session_start'] = ortime__unixtime_to_sesstime();
            $edit['session_duration_hour'] = $settings['session_duration_hour_default'];
Exemple #3
0
function experimentercommalist_to_newdbstring($commalist)
{
    global $old_experimenters, $old_db_name;
    if (!(isset($old_experimenters) && is_array($old_experimenters) && count($old_experimenters) > 0)) {
        $squery = "SELECT * FROM " . $old_db_name . "." . table('admin') . "";
        $result = or_query($squery);
        $old_experimenters = array();
        while ($line = pdo_fetch_assoc($result)) {
            $old_experimenters[trim($line['adminname'])] = $line['admin_id'];
        }
    }
    $c_arr = explode(",", $commalist);
    $n_arr = array();
    foreach ($c_arr as $k => $v) {
        if (isset($old_experimenters[trim($v)])) {
            $n_arr[] = $old_experimenters[trim($v)];
        }
    }
    return id_array_to_db_string($n_arr);
}
Exemple #4
0
function email__update_email($email)
{
    $new_experiment_id = 0;
    $new_session_id = 0;
    if (isset($_REQUEST['expsess']) && $_REQUEST['expsess']) {
        $sent_expsess = $_REQUEST['expsess'];
    } else {
        $sent_expsess = '';
    }
    if (isset($_REQUEST['participant_id']) && $_REQUEST['participant_id']) {
        $sent_participant_id = $_REQUEST['participant_id'];
    } else {
        $sent_participant_id = 0;
    }
    if (isset($_REQUEST['assigned_to']) && $_REQUEST['assigned_to']) {
        $sent_assigned_to = id_array_to_db_string(multipicker_json_to_array($_REQUEST['assigned_to']));
    } else {
        $sent_assigned_to = '';
    }
    if (isset($_REQUEST['flag_processed']) && $_REQUEST['flag_processed']) {
        $flag_processed = 1;
    } else {
        $flag_processed = 0;
    }
    $abox = explode(",", $sent_expsess);
    if ($abox[0] == 'box') {
        $new_mailbox = $abox[1];
        $new_experiment_id = 0;
        $new_session_id = 0;
    } elseif ($abox[0] > 0) {
        $new_mailbox = '';
        $new_experiment_id = $abox[0];
        $new_session_id = $abox[1];
    } else {
        $new_mailbox = 'not_assigned';
        $new_experiment_id = 0;
        $new_session_id = 0;
    }
    $new_participant_id = $sent_participant_id;
    $new_assigned_to = $sent_assigned_to;
    $pars = array(':mailbox' => $new_mailbox, ':experiment_id' => $new_experiment_id, ':session_id' => $new_session_id, ':participant_id' => $new_participant_id, ':assigned_to' => $new_assigned_to, ':flag_processed' => $flag_processed, ':thread_id' => $email['message_id']);
    $query = "UPDATE " . table('emails') . "\n            SET mailbox= :mailbox,\n                experiment_id= :experiment_id,\n                session_id= :session_id,\n                participant_id= :participant_id,\n                assigned_to= :assigned_to,\n                flag_processed = :flag_processed\n                WHERE thread_id = :thread_id";
    $done = or_query($query, $pars);
    $redir = 'admin/emails_view.php?message_id=' . urlencode($email['message_id']);
    if (isset($_REQUEST['hide_header']) && $_REQUEST['hide_header']) {
        $redir .= '&hide_header=true';
    }
    return $redir;
}
        if (!isset($budget['budget_id'])) {
            redirect('admin/payments_budget_main.php');
        }
    } else {
        $budget = array('budget_name' => '', 'budget_limit' => '', 'enabled' => 0, 'experimenter' => '');
    }
}
if ($proceed) {
    $continue = true;
    if (isset($_REQUEST['edit']) && $_REQUEST['edit']) {
        if (!isset($_REQUEST['budget_name']) || !$_REQUEST['budget_name']) {
            message(lang('error_you_have_to_provide_budget_name'));
            $continue = false;
        }
        if ($continue) {
            $_REQUEST['experimenter'] = id_array_to_db_string(multipicker_json_to_array($_REQUEST['experimenter']));
            if (!isset($budget_id)) {
                $new = true;
                $query = "SELECT max(budget_id)+1 as new_budget_id FROM " . table('budgets');
                $line = orsee_query($query);
                if (isset($line['new_budget_id'])) {
                    $budget_id = $line['new_budget_id'];
                } else {
                    $budget_id = 1;
                }
            } else {
                $new = false;
            }
            $budget = $_REQUEST;
            $budget['budget_id'] = $budget_id;
            if (!$budget['budget_limit']) {
            // update experiments
            $upars = array();
            $pars = array(':payment_budget' => '%|' . $budget_id . '|%');
            $query = "SELECT experiment_id, payment_budgets\n\t\t\t\t\tFROM " . table('experiments') . "\n\t\t\t\t\tWHERE payment_budgets LIKE :payment_budget";
            $result = or_query($query, $pars);
            while ($line = pdo_fetch_assoc($result)) {
                $ids = db_string_to_id_array($line['payment_budgets']);
                foreach ($ids as $k => $v) {
                    if ($v == $budget_id) {
                        unset($ids[$k]);
                    }
                }
                if (!in_array($merge_with, $ids)) {
                    $ids[] = $merge_with;
                }
                $upars[] = array(':experiment_id' => $line['experiment_id'], ':payment_budgets' => id_array_to_db_string($ids));
            }
            $query = "UPDATE " . table('experiments') . " \n\t\t\t\t\tSET payment_budgets= :payment_budgets \n\t\t\t\t\tWHERE experiment_id= :experiment_id";
            $done = or_query($query, $upars);
            // delete from budgets
            $pars = array(':budget_id' => $budget_id);
            $query = "DELETE FROM " . table('budgets') . " \n\t\t\t\t\tWHERE budget_id= :budget_id";
            $result = or_query($query, $pars);
            log__admin("payments_budget_delete", "budget_id:" . $budget['budget_id'] . ", merge_with:" . $merge_with);
            message(lang('payments_budget_deleted_exp_sess_part_moved_to') . ' "' . $budgets[$merge_with]['budget_name'] . '".');
            redirect("admin/payments_budget_main.php");
        }
    }
}
if ($proceed) {
    // form
Exemple #7
0
 if ($continue) {
     if (!$subpool_id) {
         $new = true;
         $query = "SELECT subpool_id+1 as new_sub FROM " . table('subpools') . "\n              \t\t\tORDER BY subpool_id DESC LIMIT 1";
         $line = orsee_query($query);
         $subpool_id = $line['new_sub'];
         $lsub['content_type'] = "subjectpool";
         $lsub['content_name'] = $subpool_id;
     } else {
         $new = false;
         $pars = array(':subpool_id' => $subpool_id);
         $query = "SELECT * from " . table('lang') . " \n\t\t\t\t\t\tWHERE content_type='subjectpool' \n\t\t\t\t\t\tAND content_name= :subpool_id";
         $lsub = orsee_query($query, $pars);
     }
     $subpool = $_REQUEST;
     $subpool['experiment_types'] = id_array_to_db_string($exptype_ids);
     foreach ($languages as $language) {
         $lsub[$language] = $selfdesc[$language];
     }
     $done = orsee_db_save_array($subpool, "subpools", $subpool_id, "subpool_id");
     if ($new) {
         $lsub['lang_id'] = lang__insert_to_lang($lsub);
     } else {
         $done = orsee_db_save_array($lsub, "lang", $lsub['lang_id'], "lang_id");
     }
     message(lang('changes_saved'));
     log__admin("subjectpool_edit", "subjectpool:" . $subpool['subpool_name'] . "\nsubpool_id:" . $subpool['subpool_id']);
     redirect("admin/subpool_edit.php?subpool_id=" . $subpool_id);
 } else {
     $subpool = $_REQUEST;
     $subpool['exptypes'] = array();
Exemple #8
0
function participantform__check_fields($edit, $admin)
{
    global $lang, $settings;
    $errors_dataform = array();
    if (!isset($edit['subpool_id']) || !$edit['subpool_id']) {
        $edit['subpool_id'] = $settings['subpool_default_registration_id'];
    }
    $subpool = orsee_db_load_array("subpools", $edit['subpool_id'], "subpool_id");
    if (!$subpool['subpool_id']) {
        $subpool = orsee_db_load_array("subpools", 1, "subpool_id");
    }
    $edit['subpool_id'] = $subpool['subpool_id'];
    $formfields = participantform__load();
    foreach ($formfields as $f) {
        if ($f['subpools'] == 'all' | in_array($subpool['subpool_id'], explode(",", $f['subpools']))) {
            if ($admin || $f['admin_only'] != 'y') {
                if ($f['compulsory'] == 'y') {
                    if (!isset($edit[$f['mysql_column_name']]) || !$edit[$f['mysql_column_name']]) {
                        $errors_dataform[] = $f['mysql_column_name'];
                        if (isset($lang[$f['error_message_if_empty_lang']])) {
                            message($lang[$f['error_message_if_empty_lang']]);
                        } else {
                            message($f['error_message_if_empty_lang']);
                        }
                    }
                }
                if ($f['perl_regexp'] != '') {
                    if (!preg_match($f['perl_regexp'], $edit[$f['mysql_column_name']])) {
                        $errors_dataform[] = $f['mysql_column_name'];
                        if (isset($lang[$f['error_message_if_no_regexp_match_lang']])) {
                            message($lang[$f['error_message_if_no_regexp_match_lang']]);
                        } else {
                            message($f['error_message_if_no_regexp_match_lang']);
                        }
                    }
                }
            }
        }
    }
    if (!isset($_REQUEST['subscriptions']) || !is_array($_REQUEST['subscriptions'])) {
        $_REQUEST['subscriptions'] = array();
    }
    $_REQUEST['subscriptions'] = id_array_to_db_string($_REQUEST['subscriptions']);
    $edit['subscriptions'] = $_REQUEST['subscriptions'];
    if (!$edit['subscriptions']) {
        $errors_dataform[] = 'subscriptions';
        message(lang('at_least_one_exptype_has_to_be_selected'));
    }
    return $errors_dataform;
}
         $tq = array();
         $tq['pars'] = array();
         $pars = array(':exptype_id' => '%|' . $exptype_id . '|%');
         $query = "SELECT participant_id, subscriptions\n\t\t\t\t\tFROM " . table('participants') . "\n\t\t\t\t\tWHERE subscriptions LIKE :exptype_id";
         $result = or_query($query, $pars);
         while ($line = pdo_fetch_assoc($result)) {
             $subs = db_string_to_id_array($line['subscriptions']);
             foreach ($subs as $k => $et) {
                 if ($et == $exptype_id) {
                     unset($subs[$k]);
                 }
             }
             if (!in_array($merge_with, $subs)) {
                 $subs[] = $merge_with;
             }
             $tq['pars'][] = array(':participant_id' => $line['participant_id'], ':subscriptions' => id_array_to_db_string($subs));
         }
         $affected_participants = count($tq['pars']);
         $tq['query'] = "UPDATE " . table('participants') . " \n    \t           \tSET subscriptions= :subscriptions\n        \t       \tWHERE participant_id= :participant_id";
         $queries[] = $tq;
         $tq = array();
         $tq['pars'] = array(':merge_with' => $merge_with, ':exptype_id' => $exptype_id);
         $tq['query'] = "UPDATE " . table('experiments') . "\n    \t            SET experiment_ext_type= :merge_with \n        \t        WHERE experiment_ext_type= :exptype_id";
         $queries[] = $tq;
         $done = pdo_transaction($queries);
         log__admin("experimenttype_delete", "experimenttype:" . $exptype['exptype_name']);
         message(lang('experimenttype_deleted'));
         message($affected_participants . ' ' . lang('xx_participants_assigned_to_exptype') . ' "' . $merge_with_type['exptype_name'] . '".');
         redirect("admin/experiment_type_main.php");
     }
 }
Exemple #10
0
    }
}
if ($continue) {
    echo "All checks succeeded.\n";
    foreach ($participants as $participant) {
        $new_id = participant__create_participant_id($participant);
        $participant['participant_id'] = $new_id['participant_id'];
        $participant['participant_id_crypt'] = $new_id['participant_id_crypt'];
        $participant['status_id'] = $participant_status_id;
        $participant['creation_time'] = time();
        $participant['deletion_time'] = 0;
        $participant['last_profile_update'] = $participant['creation_time'];
        $participant['last_activity'] = $participant['creation_time'];
        $participant['last_enrolment'] = 0;
        $participant['subpool_id'] = $subpool_id;
        $participant['subscriptions'] = id_array_to_db_string($cexptypes);
        if (!isset($participant['language']) || !$participant['language']) {
            $participant['language'] = $settings['public_standard_language'];
        }
        $participant = convert_array_to_UTF8($participant);
        //var_dump($participant);
        if (!$debug) {
            $done = orsee_db_save_array($participant, "participants", $participant['participant_id'], "participant_id");
        }
    }
    if (!$debug) {
        echo "Imported " . $pcount . " participant profiles.\n";
    } else {
        echo "Debugging run. Nothing imported.\n";
    }
}