Пример #1
0
if (!defined('AT_INCLUDE_PATH')) {
    exit;
}
global $db;
global $_base_path;
global $savant;
//Number of posts to display
$post_limit = 5;
ob_start();
// global $_course_id is set when a guest accessing a public course.
// This is to solve the issue that the google indexing fails as the session vars are lost.
global $_course_id;
if (isset($_SESSION['course_id'])) {
    $_course_id = $_SESSION['course_id'];
}
$forum_list = get_group_concat('forums_courses', 'forum_id', "course_id={$_course_id}");
if ($forum_list != 0) {
    $sql = "SELECT subject, post_id, forum_id, member_id FROM " . TABLE_PREFIX . "forums_threads WHERE parent_id=0 AND forum_id IN ({$forum_list}) ORDER BY last_comment DESC LIMIT {$post_limit}";
    $result = mysql_query($sql, $db);
    if (mysql_num_rows($result) > 0) {
        while ($row = mysql_fetch_assoc($result)) {
            echo '&#176; <a href="' . $_base_path . url_rewrite('forum/view.php?fid=' . $row['forum_id'] . htmlentities(SEP) . 'pid=' . $row['post_id']) . '" title="' . $row['subject'] . ': ' . htmlspecialchars(get_display_name($row['member_id'])) . '">' . AT_print(validate_length($row['subject'], 20, VALIDATE_LENGTH_FOR_DISPLAY), 'forums_threads.subject') . '</a><br />';
        }
    } else {
        echo '<strong>' . _AT('none_found') . '</strong>';
    }
} else {
    echo '<strong>' . _AT('none_found') . '</strong>';
}
$savant->assign('dropdown_contents', ob_get_contents());
ob_end_clean();
Пример #2
0
    foreach ($search as $term) {
        $term = trim($term);
        $term = str_replace(array('%', '_'), array('\\%', '\\_'), $term);
        if ($term) {
            $term = '%' . $term . '%';
            $sql .= "((M.first_name LIKE '{$term}') OR (M.second_name LIKE '{$term}') OR (M.last_name LIKE '{$term}') OR (M.email LIKE '{$term}') OR (M.login LIKE '{$term}')) {$predicate}";
        }
    }
    $sql = '(' . substr($sql, 0, -strlen($predicate)) . ')';
    $search = $sql;
} else {
    $search = '1';
}
$instructor_id = $system_courses[$course_id]['member_id'];
// retrieve all the members of this course (used later to get all those who aren't in this course)
$course_enrollment = get_group_concat('course_enrollment', 'member_id', "course_id={$course_id} AND member_id<>{$instructor_id}");
$course_enrollment .= ',' . $instructor_id;
$tab_counts = array();
$tab_sql_counts = array();
$tab_sql_counts[0] = "SELECT COUNT(*) AS cnt FROM " . TABLE_PREFIX . "course_enrollment CE INNER JOIN " . TABLE_PREFIX . "members M USING (member_id) WHERE CE.course_id={$course_id} \n\t\t\t\t\t\tAND CE.approved='y' AND M.member_id<>{$instructor_id} AND CE.privileges=0 AND {$search}";
$tab_sql_counts[1] = "SELECT COUNT(*) AS cnt FROM " . TABLE_PREFIX . "course_enrollment CE INNER JOIN " . TABLE_PREFIX . "members M USING (member_id) WHERE CE.course_id={$course_id} \n\t\t\t\t\t\tAND CE.approved='y' AND CE.privileges>0 AND {$search}";
$tab_sql_counts[2] = "SELECT COUNT(*) AS cnt FROM " . TABLE_PREFIX . "course_enrollment CE INNER JOIN " . TABLE_PREFIX . "members M USING (member_id) WHERE CE.course_id={$course_id} \n\t\t\t\t\t\tAND approved='a' AND {$search}";
$tab_sql_counts[3] = "SELECT COUNT(*) AS cnt FROM " . TABLE_PREFIX . "course_enrollment CE INNER JOIN " . TABLE_PREFIX . "members M USING (member_id) WHERE CE.course_id={$course_id}\n\t\t\t\t\t\tAND approved='n' AND {$search}";
$tab_sql_counts[4] = "SELECT COUNT(*) AS cnt FROM " . TABLE_PREFIX . "members M WHERE M.status>1 AND M.member_id NOT IN ({$course_enrollment}) AND {$search}";
foreach ($tab_sql_counts as $tab => $sql) {
    if ($tab == 3 && $system_courses[$course_id]['access'] != 'private') {
        $tab_counts[$tab] = 0;
    } else {
        $result = mysql_query($sql);
        $row = mysql_fetch_assoc($result);
        $tab_counts[$tab] = $row['cnt'];
Пример #3
0
		$term = trim($term);
		$term = str_replace(array('%','_'), array('\%', '\_'), $term);
		if ($term) {
			$term = '%'.$term.'%';
			$sql .= "((M.first_name LIKE '$term') OR (M.second_name LIKE '$term') OR (M.last_name LIKE '$term') OR (M.email LIKE '$term') OR (M.login LIKE '$term')) $predicate";
		}
	}
	$sql = '('.substr($sql, 0, -strlen($predicate)).')';
	$search = $sql;
} else {
	$search = '1';
}

$instructor_id = $system_courses[$course_id]['member_id'];
// retrieve all the members of this course (used later to get all those who aren't in this course)
$course_enrollment = get_group_concat('course_enrollment', 'member_id', "course_id=$course_id AND member_id<>$instructor_id");
$course_enrollment .= ','.$instructor_id;

$tab_counts     = array();
$tab_sql_counts = array();
$tab_sql_counts[0] = "SELECT COUNT(*) AS cnt FROM ".TABLE_PREFIX."course_enrollment CE INNER JOIN ".TABLE_PREFIX."members M USING (member_id) WHERE CE.course_id=$course_id 
						AND CE.approved='y' AND M.member_id<>$instructor_id AND CE.privileges=0 AND $search";
$tab_sql_counts[1] = "SELECT COUNT(*) AS cnt FROM ".TABLE_PREFIX."course_enrollment CE INNER JOIN ".TABLE_PREFIX."members M USING (member_id) WHERE CE.course_id=$course_id 
						AND CE.approved='y' AND CE.privileges>0 AND $search";
$tab_sql_counts[2] = "SELECT COUNT(*) AS cnt FROM ".TABLE_PREFIX."course_enrollment CE INNER JOIN ".TABLE_PREFIX."members M USING (member_id) WHERE CE.course_id=$course_id 
						AND approved='a' AND $search";
$tab_sql_counts[3] = "SELECT COUNT(*) AS cnt FROM ".TABLE_PREFIX."course_enrollment CE INNER JOIN ".TABLE_PREFIX."members M USING (member_id) WHERE CE.course_id=$course_id
						AND approved='n' AND $search";
$tab_sql_counts[4] = "SELECT COUNT(*) AS cnt FROM ".TABLE_PREFIX."members M WHERE M.status>1 AND M.member_id NOT IN ($course_enrollment) AND $search";

foreach ($tab_sql_counts as $tab => $sql) {