Пример #1
0
}
// exit if no POST data
if (!register_posted_variables(array('search_terms' => false, 'search_terms_title' => false, 'search_terms_keywords' => false, 'search_terms_instructor' => false, 'search_terms_coursecode' => false, 'search_terms_description' => false), 'any')) {
    $tool_content .= CourseIndexer::getDetailedSearchForm();
    draw($tool_content, 0);
    exit;
}
// search in the index
$idx = new Indexer();
$hits1 = $idx->searchRaw(CourseIndexer::buildQuery($_POST));
// courses with visible 1 or 2
// Additional Access Rights
$anonymous = false;
if (isset($uid) and $uid) {
    $anonymous = true;
    $hits2 = $idx->searchRaw(CourseIndexer::buildQuery($_POST, false));
    // courses with visible 0 or 3
    if ($uid == 0) {
        $hits = array_merge($hits1, $hits2);
        // admin has access to all
    } else {
        $res = Database::get()->queryArray("SELECT course.id \n                           FROM course \n                           JOIN course_user ON course.id = course_user.course_id \n                            AND course_user.user_id = ?d", $uid);
        $subscribed = array();
        foreach ($res as $row) {
            $subscribed[] = $row->id;
        }
        $hits3 = array();
        foreach ($hits2 as $hit2) {
            if (in_array($hit2->pkid, $subscribed)) {
                $hits3[] = $hit2;
            }
Пример #2
0
            'search_terms_instructor' => false,
            'search_terms_coursecode' => false,
            'search_terms_description' => false), 'any')) {
    $tool_content .= CourseIndexer::getDetailedSearchForm();
    draw($tool_content, 0);
    exit();
}

// search in the index
$idx = new Indexer();
$hits1 = $idx->searchRaw(CourseIndexer::buildQuery($_POST));            // courses with visible 1 or 2
// Additional Access Rights
$anonymous = false;
if (isset($uid) and $uid) {
    $anonymous = true;
    $hits2 = $idx->searchRaw(CourseIndexer::buildQuery($_POST, false)); // courses with visible 0 or 3

    if ($uid == 0) {
        $hits = array_merge($hits1, $hits2); // admin has access to all
    } else {        
        $res = Database::get()->queryArray("SELECT course.id 
                           FROM course 
                           JOIN course_user ON course.id = course_user.course_id 
                            AND course_user.user_id = ?d", $uid);
        $subscribed = array();
        foreach ($res as $row) {
            $subscribed[] = $row->id;
        }
        $hits3 = array();
        foreach ($hits2 as $hit2) {
            if (in_array($hit2->pkid, $subscribed)) {