Example #1
0
function faq__load_answer($faq_id = "")
{
    $pars = array(':faq_id' => $faq_id);
    $query = "SELECT * from " . table('lang') . "\n            WHERE content_type='faq_answer'\n            AND content_name= :faq_id";
    $line = orsee_query($query, $pars);
    return $line;
}
Example #2
0
function content__get_content($content_name)
{
    global $lang;
    $this_lang = lang('lang');
    $pars = array(':content_name' => $content_name);
    $query = "SELECT * FROM " . table('lang') . "\n              WHERE content_type='public_content'\n              AND content_name=:content_name";
    $line = orsee_query($query, $pars);
    return $line[$this_lang];
}
Example #3
0
function admin__check_login($username, $password)
{
    global $lang;
    $pars = array(':adminname' => $username);
    $query = "SELECT * FROM " . table('admin') . " \n            WHERE adminname= :adminname";
    $admin = orsee_query($query, $pars);
    $continue = true;
    $not_allowed = false;
    $locked = false;
    if ($continue) {
        if (!isset($admin['admin_id'])) {
            $continue = false;
            log__admin('login_admin_wrong_username', 'used_username:'******'id');
        }
    }
    if ($continue) {
        $admin = admin__check_has_lockout($admin);
        if ($admin['locked']) {
            $continue = false;
            log__admin('login_admin_locked_out', 'username:'******'locked');
        }
    }
    if ($continue) {
        $check_pw = crypt_verify($password, $admin['password_crypt']);
        if (!$check_pw) {
            $continue = false;
            log__admin('login_admin_wrong_password', 'username:'******'wrong_pw');
        }
    }
    if ($continue) {
        $expadmindata = $admin;
        // load admin rights
        $expadmindata['rights'] = admin__load_admin_rights($expadmindata['admin_type']);
        if (!$expadmindata['rights']['login'] || $expadmindata['disabled'] == 'y') {
            $continue = false;
            $not_allowed = true;
            //message('not_allowed');
        }
    }
    if ($continue) {
        $_SESSION['expadmindata'] = $expadmindata;
        $done = admin__track_successful_login($admin);
        return true;
    } else {
        //if ($locked) message(lang('error_locked_out'));
        if ($not_allowed) {
            message(lang('error_not_allowed_to_login'));
        }
        return false;
    }
}
Example #4
0
function laboratories__get_laboratory_text($laboratory_id, $tlang = "")
{
    if (!$tlang) {
        global $lang;
        $tlang = lang('lang');
    }
    $pars = array(':laboratory_id' => $laboratory_id);
    $query = "SELECT * FROM " . table('lang') . " WHERE content_type='laboratory' AND content_name=:laboratory_id";
    $lab = orsee_query($query, $pars);
    return stripslashes($lab[$tlang]);
}
Example #5
0
         $selfdesc[$language] = '';
     }
 }
 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);
Example #6
0
function experiment__count_participate_at($experiment_id, $session_id = "", $condition = "", $cond_pars = array())
{
    $query = "";
    $pars = array();
    $query = "SELECT COUNT(*) as regcount FROM " . table('participate_at') . " WHERE ";
    if ($session_id) {
        $query .= "session_id= :tsession_id";
        $pars[':tsession_id'] = $session_id;
    } else {
        $query .= "experiment_id= :texperiment_id";
        $pars[':texperiment_id'] = $experiment_id;
    }
    if ($condition) {
        $query .= " AND (" . $condition . ")";
        foreach ($cond_pars as $p => $v) {
            $pars[$p] = $v;
        }
    }
    $line = orsee_query($query, $pars);
    return $line['regcount'];
}
Example #7
0
    // load subject pool
    $subpool = orsee_db_load_array("subpools", $subpool_id, "subpool_id");
    if (!isset($subpool['subpool_id'])) {
        redirect("admin/subpool_main.php");
    }
}
if ($proceed) {
    $exptype_ids = db_string_to_id_array($subpool['experiment_types']);
    $subpool['exptypes'] = array();
    foreach ($exptype_ids as $exptype_id) {
        $subpool['exptypes'][] = $exptypes[$exptype_id][lang('lang')];
    }
    unset($subpool['experiment_types']);
    $pars = array(':subpool_id' => $subpool_id);
    $query = "SELECT * from " . table('lang') . " WHERE content_type='subjectpool' AND content_name= :subpool_id";
    $selfdesc = orsee_query($query, $pars);
    foreach ($languages as $language) {
        $subpool['selfdesc_' . $language] = $selfdesc[$language];
    }
    echo '<center>';
    if ($reallydelete) {
        if (isset($_REQUEST['merge_with']) && $_REQUEST['merge_with']) {
            $merge_with = $_REQUEST['merge_with'];
        } else {
            $merge_with = 1;
        }
        $subpools = subpools__get_subpools();
        if (!isset($subpools[$merge_with])) {
            redirect("admin/subpool_main.php");
        } else {
            // transaction?
Example #8
0
            $pubs_string = implode(",", $pubs);
            $parts_string = implode(",", $parts);
            $query = "SELECT * FROM " . table('options') . "\n\t\t\t\t\tWHERE option_type='general' AND option_name='language_enabled_public'";
            $result = orsee_query($query);
            $now = time();
            if (isset($result['option_id'])) {
                $pars = array(':pubs_string' => $pubs_string);
                $query = "UPDATE " . table('options') . " SET option_value= :pubs_string  \n\t\t\t\t\t\tWHERE option_type='general' AND option_name='language_enabled_public'";
                $done = or_query($query, $pars);
            } else {
                $pars = array(':pubs_string' => $pubs_string, ':option_id' => $now + 1);
                $query = "INSERT INTO " . table('options') . " \n\t\t\t\t\t\tSET option_id=:option_id,\n\t\t\t\t\t\toption_type='general',\n\t\t\t\t\t\toption_name='language_enabled_public',\n\t\t\t\t\t\toption_value= :pubs_string";
                $done = or_query($query, $pars);
            }
            $query = "SELECT * FROM " . table('options') . "\n\t\t\t\t\tWHERE option_type='general' AND option_name='language_enabled_participants'";
            $result2 = orsee_query($query);
            if (isset($result2['option_id'])) {
                $pars = array(':parts_string' => $parts_string);
                $query = "UPDATE " . table('options') . " SET option_value= :parts_string \n\t\t\t\t\t\tWHERE option_type='general' AND option_name='language_enabled_participants'";
                $done = or_query($query, $pars);
            } else {
                $pars = array(':parts_string' => $parts_string, ':option_id' => $now + 2);
                $query = "INSERT INTO " . table('options') . " \n\t\t\t\t\t\tSET option_id=:option_id,\n\t\t\t\t\t\toption_type='general',\n\t\t\t\t\t\toption_name='language_enabled_participants',\n\t\t\t\t\t\toption_value= :parts_string";
                $done = or_query($query, $pars);
            }
            log__admin("language_availability_edit");
            message(lang('changes_saved'));
            redirect("admin/lang_main.php");
        }
    }
}
Example #9
0
function orsee_db_load_array($table, $key, $keyname)
{
    $query = "SELECT * FROM " . table($table) . " where " . $keyname . "=:key";
    $pars = array(':key' => $key);
    $line = orsee_query($query, $pars);
    return $line;
}
Example #10
0
             $continue = false;
         }
     }
 }
 if ($continue) {
     if (!$exptype_id) {
         $new_entry = true;
         $query = "SELECT exptype_id+1 as new_sub FROM " . table('experiment_types') . "\n                        ORDER BY exptype_id DESC LIMIT 1";
         $line = orsee_query($query);
         $exptype_id = $line['new_sub'];
         $lsub['content_type'] = "experiment_type";
         $lsub['content_name'] = $exptype_id;
     } else {
         $new_entry = false;
         $query = "SELECT * from " . table('lang') . "\n                        WHERE content_type='experiment_type'\n                        AND content_name='" . $exptype_id . "'";
         $lsub = orsee_query($query);
     }
     $exptype = $_REQUEST;
     $exptype['exptype_mapping'] = implode(",", $map);
     foreach ($languages as $language) {
         $lsub[$language] = $selfdesc[$language];
     }
     $done = orsee_db_save_array($exptype, "experiment_types", $exptype_id, "exptype_id");
     if ($new_entry) {
         $done = lang__insert_to_lang($lsub);
     } else {
         $done = orsee_db_save_array($lsub, "lang", $lsub['lang_id'], "lang_id");
     }
     log__admin("experimenttype_edit", $exptype['exptype_name']);
     message(lang('changes_saved'));
     redirect("admin/experiment_type_edit.php?exptype_id=" . $exptype_id);
Example #11
0
function participant__get_participant_status($participant_id)
{
    //status_type can be access_to_profile, eligible_for_experiments, is_default_active or is_default_inactive
    $statuses = participant_status__get_statuses();
    $pars = array(':participant_id' => $participant_id);
    $query = "SELECT status_id\n            FROM " . table('participants') . "\n            WHERE participant_id= :participant_id";
    $line = orsee_query($query, $pars);
    return $statuses[$line['status_id']];
}
         $status_id = $line['new_status_id'];
     } else {
         $status_id = 1;
     }
     $status_name_lang['content_type'] = "participant_status_name";
     $status_name_lang['content_name'] = $status_id;
     $status_error_lang['content_type'] = "participant_status_error";
     $status_error_lang['content_name'] = $status_id;
 } else {
     $new = false;
     $pars = array(':status_id' => $status_id);
     $query = "SELECT * from " . table('lang') . " WHERE content_type='participant_status_name' AND content_name= :status_id";
     $status_name_lang = orsee_query($query, $pars);
     if ($not_unconfirmed) {
         $query = "SELECT * from " . table('lang') . " WHERE content_type='participant_status_error' AND content_name= :status_id";
         $status_error_lang = orsee_query($query, $pars);
     }
 }
 foreach ($languages as $language) {
     $status_name_lang[$language] = $status_name[$language];
     if ($not_unconfirmed) {
         $status_error_lang[$language] = $status_error[$language];
     }
 }
 if ($new) {
     $status_name['lang_id'] = lang__insert_to_lang($status_name_lang);
     $status_error['lang_id'] = lang__insert_to_lang($status_error_lang);
 } else {
     $done = orsee_db_save_array($status_name_lang, "lang", $status_name_lang['lang_id'], "lang_id");
     if ($not_unconfirmed) {
         $done = orsee_db_save_array($status_error_lang, "lang", $status_error_lang['lang_id'], "lang_id");
Example #13
0
function check_clearpixel()
{
    $return = false;
    $query = "SELECT * from " . table('objects') . "\n            WHERE item_type='clearpixel' AND item_name='clearpixel'";
    $cp = orsee_query($query);
    if (!isset($cp['item_details'])) {
        $query = "INSERT IGNORE INTO " . table('objects') . "\n                SET item_type='clearpixel', item_name='clearpixel', item_details='" . time() . "'";
        $done = or_query($query);
        $return = true;
    } else {
        if (time() - $cp['item_details'] > 24 * 60 * 60) {
            $query = "UPDATE " . table('objects') . "\n                    SET item_details='" . time() . "'\n                    WHERE item_type='clearpixel' AND item_name='clearpixel'";
            $done = or_query($query);
            $return = true;
        } else {
            $return = false;
        }
    }
    return $return;
}
Example #14
0
     $_REQUEST['password'] = "";
     $_REQUEST['password2'] = "";
 }
 if ($_REQUEST['password'] && !$_REQUEST['password'] == $_REQUEST['password2']) {
     message(lang('you_have_to_give_a_password'));
     $continue = false;
     $_REQUEST['password'] = "";
     $_REQUEST['password2'] = "";
 }
 if ($continue) {
     foreach (array('fname', 'lname', 'adminname') as $k) {
         $_REQUEST[$k] = trim($_REQUEST[$k]);
     }
     $pars = array(':adminname' => $_REQUEST['adminname']);
     $query = "SELECT admin_id FROM " . table('admin') . " \n\t\t\t\t\tWHERE adminname = :adminname";
     $existing_admin = orsee_query($query, $pars);
     if (isset($existing_admin['admin_id']) && $existing_admin['admin_id'] != $admin_id) {
         $continue = false;
         message(lang('error_username_exists'));
     }
 }
 if ($continue) {
     if ($_REQUEST['password']) {
         // no password strength checks when account created by super-admin?
         $_REQUEST['password_crypt'] = unix_crypt($_REQUEST['password']);
         message(lang('password_changed'));
     } else {
         unset($_REQUEST['password']);
     }
     if (!$admin_id) {
         $admin_id = time();
Example #15
0
function query__save_query($json_query, $type, $experiment_id = 0, $properties = array(), $permanent = false)
{
    // type can be participants_search_active, participants_search_all, assign, deassign
    global $expadmin;
    $now = time();
    if ($experiment_id && $permanent) {
        // if this query is supposed to be permanent, then reset current permanent query if any
        $done = query__reset_permanent($experiment_id);
        // for new query
        $properties['is_permanent'] = 1;
        $properties['permanent_start_time'] = time();
        $properties['assigned_count'] = 0;
        $addquery = ", permanent=1";
        $addmessage = lang('activated_as_permanent_query');
    } else {
        $addquery = ", permanent=0";
    }
    $properties_string = property_array_to_db_string($properties);
    $continue = true;
    if ($experiment_id == 0) {
        // check if we already know this query, and if so, just update the record
        $pars = array(':json_query' => $json_query);
        $query = "SELECT * FROM " . table('queries') . "\n                WHERE json_query= :json_query LIMIT 1";
        $line = orsee_query($query, $pars);
        if (isset($line['query_id'])) {
            $pars = array(':query_time' => $now, ':query_id' => $line['query_id']);
            $query = "UPDATE " . table('queries') . "\n                    SET query_time= :query_time\n                    WHERE query_id= :query_id";
            $done = or_query($query, $pars);
            message(lang('query_existed_now_updated'));
            $continue = false;
        }
    }
    // otherwise, save the query
    if ($continue) {
        if (isset($expadmindata['admin_id'])) {
            $admin_id = $expadmindata['admin_id'];
        } else {
            $admin_id = '';
        }
        $pars = array(':query_time' => $now, ':json_query' => $json_query, ':query_type' => $type, ':experiment_id' => $experiment_id, ':properties' => $properties_string, ':admin_id' => $admin_id);
        $query = "INSERT INTO " . table('queries') . "\n                SET query_time=:query_time,\n                json_query=:json_query,\n                query_type=:query_type,\n                experiment_id=:experiment_id,\n                admin_id=:admin_id,\n                properties=:properties " . $addquery;
        $done = or_query($query, $pars);
        message(lang('query_saved'));
        if (isset($addmessage)) {
            message($addmessage);
        }
    }
    return $done;
}
Example #16
0
function sessions__get_experiment_id($session_id)
{
    $pars = array(':session_id' => $session_id);
    $query = "SELECT experiment_id\n      \t\tFROM " . table('sessions') . " \n      \t\tWHERE session_id=:session_id";
    $res = orsee_query($query, $pars);
    if (isset($res['experiment_id'])) {
        $experiment_id = $res['experiment_id'];
    } else {
        $experiment_id = "";
    }
    return $experiment_id;
}
Example #17
0
function expregister__get_participate_at($participant_id, $experiment_id)
{
    $pars = array(':participant_id' => $participant_id, ':experiment_id' => $experiment_id);
    $query = "SELECT * \n      \t\tFROM " . table('participate_at') . "\n      \t\tWHERE experiment_id= :experiment_id \n\t\t\tAND participant_id= :participant_id";
    $result = orsee_query($query, $pars);
    return $result;
}
            message(lang('mail_text_saved'));
        } else {
            message(lang('database_error'));
        }
        log__admin("experiment_customize_session_reminder", "experiment:" . $experiment['experiment_name']);
        if ($save_preview) {
            redirect('admin/experiment_customize_reminder.php?experiment_id=' . $experiment_id . '&show_preview=true');
        } else {
            redirect('admin/experiment_customize_reminder.php?experiment_id=' . $experiment_id);
        }
    }
}
if ($proceed) {
    $pars = array(':experiment_id' => $experiment_id);
    $query = "SELECT * from " . table('lang') . "\n            WHERE content_type='experiment_session_reminder_mail'\n            AND content_name= :experiment_id";
    $experiment_mail = orsee_query($query, $pars);
    $session = experimentmail__preview_fake_session_details($experiment_id);
    if ($show_preview) {
        echo '<TABLE class="or_formtable" style="width: 80%;">';
        echo '<TR><TD colspan=2>
            ' . button_link('experiment_customize_reminder.php?experiment_id=' . urlencode($experiment_id), lang('back_to_mail_page'), 'backward', 'font-size: 8pt;') . '
            </TD></TR>';
        foreach ($inv_langs as $inv_lang) {
            // split in subject and text
            $subject = str_replace(strstr($experiment_mail[$inv_lang], "\n"), "", $experiment_mail[$inv_lang]);
            $body = substr($experiment_mail[$inv_lang], strpos($experiment_mail[$inv_lang], "\n") + 1, strlen($experiment_mail[$inv_lang]));
            $lab = laboratories__get_laboratory_text($session['laboratory_id'], $inv_lang);
            $pform_fields = participant__load_participant_email_fields($inv_lang);
            $experimentmail = experimentmail__preview_fake_participant_details($pform_fields);
            $experimentmail['language'] = $inv_lang;
            $experimentmail = experimentmail__get_session_reminder_details($experimentmail, $experiment, $session, $lab);
}
if ($proceed) {
    if (isset($_REQUEST['reallydelete']) && $_REQUEST['reallydelete']) {
        $reallydelete = true;
    } else {
        $reallydelete = false;
    }
    $allow = check_allow('participationstatus_delete', 'participation_status_edit.php?pstatus_id=' . $pstatus_id);
}
if ($proceed) {
    // load status
    $pars = array(':pstatus_id' => $pstatus_id);
    $query = "SELECT * from " . table('lang') . " WHERE content_type='participation_status_internal_name' AND content_name= :pstatus_id";
    $pstatus_internal_name = orsee_query($query, $pars);
    $query = "SELECT * from " . table('lang') . " WHERE content_type='participation_status_display_name' AND content_name= :pstatus_id";
    $pstatus_display_name = orsee_query($query, $pars);
    // load languages
    $languages = get_languages();
    foreach ($languages as $language) {
        $pstatus['internal_name_' . $language] = $pstatus_internal_name[$language];
        $pstatus['display_name_' . $language] = $pstatus_display_name[$language];
    }
    if ($reallydelete) {
        $participation_statuses = expregister__get_participation_statuses();
        if (!isset($_REQUEST['merge_with']) || !isset($participation_statuses[$_REQUEST['merge_with']])) {
            redirect('admin/participation_status_delete.php?pstatus_id=' . $pstatus_id);
        } else {
            $merge_with = $_REQUEST['merge_with'];
            // transaction?
            $pars = array(':pstatus_id' => $pstatus_id, ':merge_with' => $merge_with);
            $query = "UPDATE " . table('participate_at') . " \n\t\t\t\t\tSET pstatus_id= :merge_with \n\t\t\t\t\tWHERE pstatus_id= :pstatus_id";
Example #20
0
         $done = or_query($query, $pars);
         $imported[] = count($pars) . ' ' . $type;
     }
     $impstring = implode(", ", $imported);
     if ($impstring) {
         message($impstring . ' ' . lang('xxx_language_items_updated') . ' ' . $tlang_name . ' (' . $lang_id . ')');
     }
 } else {
     foreach ($update as $item) {
         $ignored = $ignored + count($item);
     }
 }
 // add new items
 if ($do_upgrade) {
     $query = "SELECT max(lang_id) as max_id FROM " . table('lang');
     $line = orsee_query($query);
     $new_id = $line['max_id'];
     $created = array();
     foreach ($upgrade as $type => $item) {
         $count = 0;
         $upars = array();
         $ipars = array();
         foreach ($item as $name => $value) {
             if ($name == 'lang' || $name == 'lang_name' || $name == 'lang_icon_base64') {
                 continue;
             } else {
                 if (isset($old_lang[$type][$name])) {
                     $upars[] = array(':value' => $value, ':type' => $type, ':name' => $name);
                 } else {
                     $new_id++;
                     $ipars[] = array(':id' => $new_id, ':value' => $value, ':type' => $type, ':name' => $name);
Example #21
0
function experimentmail__preview_fake_session_details($experiment_id)
{
    $pars = array(':experiment_id' => $experiment_id);
    $query = "SELECT * FROM " . table('sessions') . "\n            WHERE experiment_id = :experiment_id\n            ORDER BY if(session_status='live',0,1), session_start DESC\n            LIMIT 1";
    $session = orsee_query($query, $pars);
    if (!isset($session['session_id'])) {
        $session = array();
        $session['session_start'] = ortime__unixtime_to_sesstime();
        $session['session_duration_hour'] = 1;
        $session['session_duration_minute'] = 30;
        $labs = laboratories__get_laboratories();
        $randlab = array_rand($labs);
        $session['laboratory_id'] = $randlab;
    }
    return $session;
}
Example #22
0
function lang__insert_to_lang($item)
{
    $pars = array(':content_type' => $item['content_type']);
    $query = "SELECT max(lang_id) as lcount\n            FROM " . table('lang') . "\n            WHERE content_type= :content_type";
    $line = orsee_query($query, $pars);
    $maxid = $line['lcount'];
    $reorganize = false;
    $newmax = false;
    $newmin = false;
    // if there is no item under this content_type
    if ($maxid == NULL) {
        $newmax = true;
        $reorganize = true;
        $newmin = false;
    } else {
        $newid = $maxid + 1;
        $pars = array(':newid' => $newid);
        $query = "SELECT * FROM " . table('lang') . " WHERE lang_id= :newid";
        $line = orsee_query($query, $pars);
        if (isset($line['lang_id'])) {
            $reorganize = true;
            $newmax = true;
            $newmin = true;
        }
    }
    if ($newmax) {
        $query = "SELECT max(lang_id) as maxid, min(lang_id) as minid FROM " . table('lang');
        $line = orsee_query($query);
        $newid = $line['maxid'] + 1;
        $steps = $line['minid'];
        if ($newmin) {
            $steps = $steps * 10;
        }
    }
    $done1 = orsee_db_save_array($item, "lang", $newid, "lang_id");
    if ($reorganize) {
        $done2 = lang__reorganize_lang_table($steps);
    }
    return $newid;
}
Example #23
0
if ($proceed) {
    if (isset($_REQUEST['email']) && $_REQUEST['email']) {
        $continue = true;
        // captcha
        if ($continue) {
            if ($_REQUEST['captcha'] != $_SESSION['captcha_string']) {
                $continue = false;
                message(lang('error_wrong_captcha'));
                redirect("public/participant_reset_pw.php");
            }
        }
        if ($continue) {
            $status_clause = participant_status__get_pquery_snippet("access_to_profile");
            $pars = array(':email' => $_REQUEST['email']);
            $query = "SELECT * FROM " . table('participants') . " \n\t\t\t\t\tWHERE email= :email\n\t\t\t\t\tAND " . $status_clause;
            $participant = orsee_query($query, $pars);
            if (isset($participant['participant_id'])) {
                // create and save token
                $participant['pwreset_token'] = create_random_token(get_entropy($participant));
                $pars = array(':token' => $participant['pwreset_token'], ':participant_id' => $participant['participant_id'], ':now' => time());
                $query = "UPDATE " . table('participants') . " \n\t\t\t\t\t\tSET pwreset_token = :token,\n\t\t\t\t\t\tpwreset_request_time = :now \n\t\t\t\t\t\tWHERE participant_id= :participant_id";
                $done = or_query($query, $pars);
                // send reset email
                $done = experimentmail__mail_pwreset_link($participant);
                message(lang('password_reset_link_sent_if_email_exists'));
                redirect('public/');
            } else {
                // to not reveal which email addresses exist, just do as if
                message(lang('password_reset_link_sent_if_email_exists'));
                redirect('public/');
            }
Example #24
0
     if ($osid_e == 'y' && $sid_e == 'n') {
         $participant['deletion_time'] = time();
     } elseif ($osid_e == 'n' && $sid_e == 'y') {
         $participant['deletion_time'] = 0;
     }
 }
 $done = orsee_db_save_array($participant, "participants", $participant['participant_id'], "participant_id");
 if ($done) {
     message(lang('changes_saved'));
 }
 if (isset($_REQUEST['register_session']) && $_REQUEST['register_session'] == 'y') {
     $session = orsee_db_load_array("sessions", $_REQUEST['session_id'], "session_id");
     if ($session['session_id']) {
         $pars = array(':participant_id' => $participant['participant_id'], ':experiment_id' => $session['experiment_id']);
         $query = "SELECT * FROM " . table('participate_at') . " \n               \t\t\t\tWHERE participant_id= :participant_id \n                   \t\t\tAND experiment_id= :experiment_id";
         $line = orsee_query($query, $pars);
         if (isset($line['participate_id'])) {
             if ($line['session_id'] > 0) {
                 $osession = orsee_db_load_array("sessions", $line['session_id'], "session_id");
                 message(lang('participant_already_enroled_for_experiment') . ' <A HREF="experiment_participants_show.php?experiment_id=' . $osession['experiment_id'] . '&session_id=' . $osession['session_id'] . '">' . session__build_name($osession) . '</A>.');
             } else {
                 $pars = array(':participant_id' => $participant['participant_id'], ':session_id' => $session['session_id'], ':experiment_id' => $session['experiment_id']);
                 $query = "UPDATE " . table('participate_at') . " \n\t\t\t\t\t\t\t\t\tSET session_id= :session_id, \n\t\t\t\t\t\t\t\t\tpstatus_id=0 \n\t\t\t\t\t\t\t\t\tWHERE participant_id= :participant_id \n\t\t\t\t\t\t\t\t\tAND experiment_id= :experiment_id";
                 $done2 = or_query($query, $pars);
             }
         } else {
             $pars = array(':participant_id' => $participant['participant_id'], ':session_id' => $session['session_id'], ':experiment_id' => $session['experiment_id']);
             $query = "INSERT into " . table('participate_at') . " \n    \t           \t\t\t\tSET participant_id= :participant_id,\n        \t           \t\t\tsession_id= :session_id, \n            \t       \t\t\texperiment_id= :experiment_id,\n                \t   \t\t\tpstatus_id=0";
             $done2 = or_query($query, $pars);
         }
         if (isset($done2) && $done2) {
Example #25
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;
}
Example #26
0
function options__load_object($item_type, $item_name)
{
    $pars = array(':item_type' => $item_type, ':item_name' => $item_name);
    $query = "select * from " . table('objects') . "\n            where item_type= :item_type\n            and item_name= :item_name";
    $object = orsee_query($query, $pars);
    $object['item_details'] = db_string_to_property_array($object['item_details']);
    return $object;
}
}
if ($proceed) {
    if (isset($_REQUEST['reallydelete']) && $_REQUEST['reallydelete']) {
        $reallydelete = true;
    } else {
        $reallydelete = false;
    }
    $allow = check_allow('participantstatus_delete', 'participant_status_edit.php?status_id=' . $status_id);
}
if ($proceed) {
    // load status details
    $pars = array(':status_id' => $status_id);
    $query = "SELECT * from " . table('lang') . " WHERE content_type='participant_status_name' AND content_name= :status_id";
    $status_name = orsee_query($query, $pars);
    $query = "SELECT * from " . table('lang') . " WHERE content_type='participant_status_error' AND content_name= :status_id";
    $status_error = orsee_query($query, $pars);
    if ($status['is_default_active'] == "y" || $status['is_default_inactive'] == "y") {
        message(lang('cannot_delete_participant_status_which_is_default'));
        redirect('admin/participant_status_edit.php?status_id=' . $status_id);
    }
}
if ($proceed) {
    // load languages
    $languages = get_languages();
    foreach ($languages as $language) {
        $status['name_' . $language] = $status_name[$language];
        $status['error_' . $language] = $status_error[$language];
    }
    if ($reallydelete) {
        $participant_statuses = participant_status__get_statuses();
        if (!isset($_REQUEST['merge_with']) || !isset($participant_statuses[$_REQUEST['merge_with']])) {