Skip to content

Commit

Permalink
Issue-4953: Fixed the issue that "Things Current" displays some activ…
Browse files Browse the repository at this point in the history
…ities from the courses that the login user is not enrolled in.
  • Loading branch information
cindyli committed Feb 14, 2012
1 parent 60194fe commit c558a59
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 56 deletions.
86 changes: 43 additions & 43 deletions mods/_standard/forums/module_news.php
Original file line number Diff line number Diff line change
@@ -1,56 +1,56 @@
<?php
/***********************************************************************/
/* ATutor */
/***********************************************************************/
/* Copyright (c) 2002-2010 */
/* Inclusive Design Institute */
/* http://atutor.ca */
/* */
/* This program is free software. You can redistribute it and/or */
/* modify it under the terms of the GNU General Public License */
/* as published by the Free Software Foundation. */
/***********************************************************************/
/****************************************************************************/
/* ATutor */
/****************************************************************************/
/* Copyright (c) 2002-2010 */
/* Inclusive Design Institute */
/* http://atutor.ca */
/* */
/* This program is free software. You can redistribute it and/or */
/* modify it under the terms of the GNU General Public License */
/* as published by the Free Software Foundation. */
/****************************************************************************/
// $Id$
/*
* Get the latest updates of this module
* @return list of news, [timestamp]=>
*/
function forums_news() {
require_once(AT_INCLUDE_PATH.'../mods/_standard/forums/lib/forums.inc.php');
global $db, $enrolled_courses, $system_courses;
$news = array();
require_once(AT_INCLUDE_PATH.'../mods/_standard/forums/lib/forums.inc.php');
global $db, $enrolled_courses, $system_courses;
$news = array();

if ($enrolled_courses == ''){
return $news;
}
if ($enrolled_courses == ''){
return $news;
}

$sql = 'SELECT E.approved, E.last_cid, C.* FROM '.TABLE_PREFIX.'course_enrollment E, '.TABLE_PREFIX.'courses C WHERE E.member_id=1 AND E.course_id=C.course_id ORDER BY C.title';
$result = mysql_query($sql, $db);
if ($result) {
while($row = mysql_fetch_assoc($result)){
$all_forums = get_forums($row['course_id']);
if (is_array($all_forums)){
foreach($all_forums as $forums){
if (is_array($forums)){
$sql = 'SELECT E.approved, E.last_cid, C.* FROM '.TABLE_PREFIX.'course_enrollment E, '.TABLE_PREFIX.'courses C WHERE C.courses in '. $enrolled_courses . ' AND E.member_id=1 AND E.course_id=C.course_id ORDER BY C.title';
$result = mysql_query($sql, $db);
if ($result) {
while($row = mysql_fetch_assoc($result)){
$all_forums = get_forums($row['course_id']);
if (is_array($all_forums)){
foreach($all_forums as $forums){
if (is_array($forums)){

foreach ($forums as $forum_obj){
$forum_obj['course_id'] = $row['course_id'];
$link_title = $forum_obj['title'];
$news[] = array('time'=>$forum_obj['last_post'],
'object'=>$forum_obj,
'alt'=>_AT('forum'),
'thumb'=>'images/pin.png',
'course'=>$system_courses[$row['course_id']]['title'],
'link'=>'<a href="bounce.php?course='.$row['course_id'].SEP.'p='.urlencode('mods/_standard/forums/forum/index.php?fid='.$forum_obj['forum_id']).'"'.
(strlen($link_title) > SUBLINK_TEXT_LEN ? ' title="'.AT_print($link_title, 'forums.title').'"' : '') .'>'.
AT_print(validate_length($link_title, SUBLINK_TEXT_LEN, VALIDATE_LENGTH_FOR_DISPLAY), 'forums.title') .'</a>');
}
}
}
}
}
}
return $news;
foreach ($forums as $forum_obj){
$forum_obj['course_id'] = $row['course_id'];
$link_title = $forum_obj['title'];
$news[] = array('time'=>$forum_obj['last_post'],
'object'=>$forum_obj,
'alt'=>_AT('forum'),
'thumb'=>'images/pin.png',
'course'=>$system_courses[$row['course_id']]['title'],
'link'=>'<a href="bounce.php?course='.$row['course_id'].SEP.'p='.urlencode('mods/_standard/forums/forum/index.php?fid='.$forum_obj['forum_id']).'"'.
(strlen($link_title) > SUBLINK_TEXT_LEN ? ' title="'.AT_print($link_title, 'forums.title').'"' : '') .'>'.
AT_print(validate_length($link_title, SUBLINK_TEXT_LEN, VALIDATE_LENGTH_FOR_DISPLAY), 'forums.title') .'</a>');
}
}
}
}
}
}
return $news;
}

?>
28 changes: 15 additions & 13 deletions mods/_standard/reading_list/module_news.php
Original file line number Diff line number Diff line change
@@ -1,31 +1,33 @@
<?php
/***********************************************************************/
/* ATutor */
/***********************************************************************/
/* Copyright (c) 2002-2010 */
/* Inclusive Design Institute */
/* http://atutor.ca */
/* */
/* This program is free software. You can redistribute it and/or */
/* modify it under the terms of the GNU General Public License */
/* as published by the Free Software Foundation. */
/***********************************************************************/
/****************************************************************************/
/* ATutor */
/****************************************************************************/
/* Copyright (c) 2002-2010 */
/* Inclusive Design Institute */
/* http://atutor.ca */
/* */
/* This program is free software. You can redistribute it and/or */
/* modify it under the terms of the GNU General Public License */
/* as published by the Free Software Foundation. */
/****************************************************************************/
// $Id$
/*
* Get the latest updates of this module
* @return list of news, [timestamp]=>
*/
function reading_list_news() {
global $db;
global $db, $enrolled_courses, $system_courses;
$news = array();

$sql = "SELECT * FROM ".TABLE_PREFIX."reading_list R INNER JOIN ".TABLE_PREFIX."external_resources E ON E.resource_id = R.resource_id WHERE R.course_id=$_SESSION[course_id] ORDER BY R.reading_id DESC";
$sql = "SELECT * FROM ".TABLE_PREFIX."reading_list R INNER JOIN ".TABLE_PREFIX."external_resources E ON E.resource_id = R.resource_id WHERE R.course_id in ".$enrolled_courses." ORDER BY R.reading_id DESC";
$result = mysql_query($sql, $db);

if (mysql_num_rows($result) > 0) {
while ($row = mysql_fetch_assoc($result)) {
$news[] = array('time'=>$row['date_end'],
'object'=>$row,
'alt'=>_AT('reading_list'),
'course'=>$system_courses[$row['course_id']]['title'],
'thumb'=>'images/home-reading_list_sm.png',
'link'=>'<a href="'.url_rewrite('mods/_standard/reading_list/display_resource.php?id=' . $row['resource_id'],
AT_PRETTY_URL_IS_HEADER).'"'.(strlen($row['title']) > SUBLINK_TEXT_LEN ? ' title="'.$row['title'].'"' : '') .'>'.
Expand Down

0 comments on commit c558a59

Please sign in to comment.