예제 #1
0
/**
* Returns an array of (shared and non-shared) forums belonging to the given course
* @access  public
* @param   integer $course		id of the course
* @return  string array			each row is a forum 
* @see     $db					in include/vitals.inc.php
* @see     is_shared_forum()
* @author  Heidi Hazelton
* @author  Joel Kronenberg
*/
function get_forums($course) {
	global $db;

	if ($course) {
		$sql	= "SELECT F.*, DATE_FORMAT(F.last_post, '%Y-%m-%d %H:%i:%s') AS last_post FROM ".TABLE_PREFIX."forums_courses FC INNER JOIN ".TABLE_PREFIX."forums F USING (forum_id) WHERE FC.course_id=$course GROUP BY FC.forum_id ORDER BY F.title";
	} else {
		$sql	= "SELECT F.*, FC.course_id, DATE_FORMAT(F.last_post, '%Y-%m-%d %H:%i:%s') AS last_post FROM ".TABLE_PREFIX."forums_courses FC INNER JOIN ".TABLE_PREFIX."forums F USING (forum_id) GROUP BY FC.forum_id ORDER BY F.title";
	}

	// 'nonshared' forums are always listed first:
	$forums['nonshared'] = array();
	$forums['shared']    = array();
	$forums['group']     = array();

	$result = mysql_query($sql, $db);
	while ($row = mysql_fetch_assoc($result)) {
		// for each forum, check if it's shared or not:

		if (is_shared_forum($row['forum_id'])) {
			$forums['shared'][] = $row;
		} else {
			$forums['nonshared'][] = $row;
		}
	}
		
	// retrieve the group forums if course is given

	if (!$_SESSION['groups'] || !$course) {
		return $forums;
	}

	// filter out the groups that do not belong to the given course
	foreach ($_SESSION['groups'] as $group) {
		$sql = "SELECT * FROM ".TABLE_PREFIX."groups g, ". TABLE_PREFIX."groups_types gt
		         WHERE g.group_id=".$group."
		           AND g.type_id = gt.type_id
		           AND gt.course_id=".$course;
		$result = mysql_query($sql, $db);
		
		if (mysql_num_rows($result) > 0){
			$groups = $group .',';
		}
	}
	if (isset($groups)) {
		$groups = substr($groups, 0, -1);
		$sql = "SELECT F.*, G.group_id FROM ".TABLE_PREFIX."forums_groups G 
		         INNER JOIN ".TABLE_PREFIX."forums F 
		         USING (forum_id) 
		         WHERE G.group_id IN ($groups) 
		         ORDER BY F.title";
		
		$result = mysql_query($sql, $db);
		while ($row = mysql_fetch_assoc($result)) {
			$row['title'] = get_group_title($row['group_id']);
			$forums['group'][] = $row;
		}
	}
	
	return $forums;	
}
예제 #2
0
/**
* Returns an array of (shared and non-shared) forums belonging to the given course
* @access  public
* @param   integer $course		id of the course
* @return  string array			each row is a forum 
* @see     is_shared_forum()
* @author  Heidi Hazelton
* @author  Joel Kronenberg
*/
function get_forums($course)
{
    if ($course) {
        $sql = "SELECT F.*, DATE_FORMAT(F.last_post, '%%Y-%%m-%%d %%H:%%i:%%s') AS last_post FROM %sforums_courses FC INNER JOIN %sforums F USING (forum_id) WHERE FC.course_id=%d GROUP BY FC.forum_id ORDER BY F.title";
        $rows_forums = queryDB($sql, array(TABLE_PREFIX, TABLE_PREFIX, $course));
    } else {
        $sql = "SELECT F.*, FC.course_id, DATE_FORMAT(F.last_post, '%%Y-%%m-%%d %%H:%%i:%%s') AS last_post FROM %sforums_courses FC INNER JOIN %sforums F USING (forum_id) GROUP BY FC.forum_id ORDER BY F.title";
        $rows_forums = queryDB($sql, array(TABLE_PREFIX, TABLE_PREFIX));
    }
    // 'nonshared' forums are always listed first:
    $forums['nonshared'] = array();
    $forums['shared'] = array();
    $forums['group'] = array();
    foreach ($rows_forums as $row) {
        // for each forum, check if it's shared or not:
        if (is_shared_forum($row['forum_id'])) {
            $forums['shared'][] = $row;
        } else {
            $forums['nonshared'][] = $row;
        }
    }
    // retrieve the group forums if course is given
    if (!$_SESSION['groups'] || !$course) {
        return $forums;
    }
    // filter out the groups that do not belong to the given course
    foreach ($_SESSION['groups'] as $group) {
        $sql = "SELECT * FROM %sgroups g, %sgroups_types gt\n\t\t         WHERE g.group_id=%d\n\t\t           AND g.type_id = gt.type_id\n\t\t           AND gt.course_id=%d";
        $rows_forums = queryDB($sql, array(TABLE_PREFIX, TABLE_PREFIX, $group, $course));
        if ($rows_forums > 0) {
            $groups .= $group . ',';
        }
    }
    if (isset($groups)) {
        $groups = substr($groups, 0, -1);
        $sql = "SELECT F.*, G.group_id FROM %sforums_groups G \n\t\t         INNER JOIN %sforums F \n\t\t         USING (forum_id) \n\t\t         WHERE G.group_id IN (%s) \n\t\t         ORDER BY F.title";
        $rows_gforums = queryDB($sql, array(TABLE_PREFIX, TABLE_PREFIX, $groups));
        foreach ($rows_gforums as $row) {
            $row['title'] = get_group_title($row['group_id']);
            $forums['group'][] = $row;
        }
    }
    return $forums;
}
예제 #3
0
function get_forum_name($fid)
{
    $fid = intval($fid);
    $sql = 'SELECT title FROM %sforums WHERE forum_id=%d';
    $row = queryDB($sql, array(TABLE_PREFIX, $fid), TRUE);
    if (isset($row['title']) && $row['title'] != '') {
        return $row['title'];
    }
    $sql = "SELECT group_id FROM %sforums_groups WHERE forum_id=%d";
    $row = queryDB($sql, array(TABLE_PREFIX, $fid), TRUE);
    if (isset($row['group_id'])) {
        return get_group_title($row['group_id']);
    }
    return FALSE;
}
예제 #4
0
function get_forum_name($fid){
	global $db;

	$fid = intval($fid);

	$sql	= 'SELECT title FROM '.TABLE_PREFIX.'forums WHERE forum_id='.$fid;
	$result	= mysql_query($sql, $db);
	if (($row = mysql_fetch_assoc($result)) && $row['title']) {
		return $row['title'];		
	}

	$sql = "SELECT group_id FROM ".TABLE_PREFIX."forums_groups WHERE forum_id=$fid";
	$result	= mysql_query($sql, $db);
	if ($row = mysql_fetch_assoc($result)) {
		return get_group_title($row['group_id']);
	}

	return FALSE;
}
예제 #5
0
function get_forums($course)
{
    if ($course) {
        $sql = "SELECT F.*, DATE_FORMAT(F.last_post, '%%Y-%%m-%%d %%H:%%i:%%s') AS last_post FROM %sforums_courses FC \n\t\tINNER JOIN %sforums F \n\t\tUSING (forum_id) \n\t\tWHERE FC.course_id=%d \n\t\tGROUP BY FC.forum_id \n\t\tORDER BY F.title";
        $rows_forums = queryDB($sql, array(TABLE_PREFIX, TABLE_PREFIX, $course));
    } else {
        $sql = "SELECT F.*, FC.course_id, DATE_FORMAT(F.last_post, '%%Y-%%m-%%d %%H:%%i:%%s') AS last_post FROM %sforums_courses FC \n\t\tINNER JOIN %sforums F \n\t\tUSING (forum_id) \n\t\tGROUP BY FC.forum_id \n\t\tORDER BY F.title";
        $rows_forums = queryDB($sql, array(TABLE_PREFIX, TABLE_PREFIX));
    }
    // 'nonshared' forums are always listed first:
    $forums['nonshared'] = array();
    $forums['shared'] = array();
    $forums['group'] = array();
    foreach ($rows_forums as $row) {
        // for each forum, check if it's shared or not:
        if (is_shared_forum($row['forum_id'])) {
            $forums['shared'][] = $row;
        } else {
            $forums['nonshared'][] = $row;
        }
    }
    // retrieve the group forums if course is given
    $course_groups = get_course_groups($course);
    if (!$course_groups || !$course) {
        return $forums;
    }
    if (isset($course_groups)) {
        foreach ($course_groups as $groups) {
            $sql = "SELECT F.*, G.group_id FROM %sforums_groups G \n                     INNER JOIN %sforums F \n                     USING (forum_id) \n                     WHERE G.group_id IN (%s) \n                     ORDER BY F.title";
            $rows_gforums = queryDB($sql, array(TABLE_PREFIX, TABLE_PREFIX, $groups['group_id']));
            foreach ($rows_gforums as $row) {
                $row['title'] = get_group_title($row['group_id']);
                $forums['group'][] = $row;
            }
        }
    }
    return $forums;
}
	<?php 
if (isset($data['totaltime'])) {
    $total = convert_case_time($data['totaltime']);
    echo $total[0] . $total[1];
} else {
    echo "0 minutes";
}
?>

	</p>

	<p><label>Group:</label></p>

	<p><?php 
$grp = get_group_title($data['grp'], $dbh);
echo $grp;
?>
 </p>

	<p><label>Date Assigned:</label></p>

	<p><?php 
$date_assigned = extract_date($data['date_assigned']);
echo $date_assigned;
?>
</p>

	<p><label>Last Activity:</label></p>

	<p>