/**
 * Extending the test dates to make them accessible to Calendar Module
 * @param     :    Course id, Member id
 * @return    :    array (test start and end dates) in format that can be used by fullcalendar
 * @author    :    Anurup Raveendran, Herat Gandhi
 */
function tests_extend_date($member_id, $course_id)
{
    $tests = array();
    // get course title
    $sql = "SELECT title  FROM %scourses  WHERE course_id = %d";
    $row = queryDB($sql, array(TABLE_PREFIX, $course_id), TRUE);
    $course_title = $row['title'];
    $sql = "SELECT title,test_id,start_date,end_date FROM %stests WHERE course_id = %d";
    $rows_tests = queryDB($sql, array(TABLE_PREFIX, $course_id));
    if (count($rows_tests) > 0) {
        $index = 0;
        foreach ($rows_tests as $row) {
            if (strpos($row['start_date'] . '', '0000-00-00') === false) {
                $unix_ts = strtotime($row['start_date']);
                $time = date('h:i A', $unix_ts);
                $tests[$index] = array("id" => rand(20000, 25000) . '', "title" => _AT('calendar_test_start') . $row['title'], "start" => $row['start_date'], "end" => $row['start_date'], "allDay" => false, "color" => 'lime', "textColor" => 'black', "editable" => false);
                $unix_ts = strtotime($row['end_date']);
                $time = date('h:i A', $unix_ts);
                $index++;
            }
            if (strpos($row['end_date'] . '', '0000-00-00') === false) {
                $tests[$index] = array("id" => rand(20000, 25000) . '', "title" => _AT('calendar_test_end') . $row['title'], "start" => $row['end_date'], "end" => $row['end_date'], "allDay" => false, "color" => 'purple', "textColor" => 'white', "editable" => false);
                $index++;
            }
        }
    }
    return $tests;
}
Example #2
0
/**
 * Display alternative table cell
 * @param $secondary_result   mysql result of all secondary alternatives
 *        $alternative type   the resource type of the alternative to display. Must be one of the values in resource_types.type_id
 *        $content_id         used to pass into file_manager/index.php
 *        $pid                primary resource id
 *        $td_header_id       the id of the table header cell, to comply with accessibility rule
 * @return html of the table cell "<td>...</td>"
 */
function display_alternative_cell($secondary_resources, $alternative_type, $content_id, $pid, $td_header_id)
{
    global $content_row, $_course_id;
    $found_alternative = false;
    echo '    <td headers="' . $td_header_id . '">' . "\n";
    if (is_array($secondary_resources)) {
        //		mysql_data_seek($secondary_result, 0);  // move the mysql result cursor back to the first row
        foreach ($secondary_resources as $secondary_resource) {
            if ($secondary_resource['type_id'] == $alternative_type) {
                echo '    <div id="' . $pid . '_' . $alternative_type . '">' . "\n";
                echo '      <a href="' . $secondary_resource['secondary_resource'] . '" title="' . _AT('new_window') . '" target="_new">' . get_display_filename($secondary_resource['secondary_resource']) . '</a><br />' . "\n";
                echo '      <a href="#" onclick="trans.utility.poptastic(\'' . TR_BASE_HREF . 'file_manager/index.php?framed=1' . SEP . 'popup=1' . SEP . 'cp=' . $content_row['content_path'] . SEP . '_cid=' . $content_id . SEP . 'pid=' . $pid . SEP . 'a_type=' . $alternative_type . '\');return false;" title="' . _AT('new_window') . '">' . "\n";
                echo '        <img src="' . TR_BASE_HREF . 'images/alter.png" border="0" title="' . _AT('alter') . '" alt="' . _AT('alter') . '" />' . "\n";
                echo '      </a>' . "\n";
                echo '      <a href="#" onclick="removeAlternative(\'' . $content_row['content_path'] . '\', ' . $content_id . ',' . $pid . ',' . $alternative_type . ');return false;">' . "\n";
                echo '        <img src="' . TR_BASE_HREF . 'images/remove.gif" border="0" title="' . _AT('remove') . '" alt="' . _AT('remove') . '" />' . "\n";
                echo '      </a>' . "\n";
                echo '    </div>' . "\n";
                $found_alternative = true;
                break;
            }
        }
    }
    if (!$found_alternative) {
        echo '    <div id="' . $pid . '_' . $alternative_type . '">' . "\n";
        echo '      <input type="button" value="' . _AT('add') . '" title="' . _AT('new_window') . '" onclick="trans.utility.poptastic(\'' . TR_BASE_HREF . 'file_manager/index.php?framed=1' . SEP . 'popup=1' . SEP . 'cp=' . $content_row['content_path'] . SEP . '_cid=' . $content_id . SEP . 'pid=' . $pid . SEP . 'a_type=' . $alternative_type . '\');return false;" />' . "\n";
        echo '    </div>' . "\n";
    }
    echo '    </td>' . "\n";
}
Example #3
0
function print_feedback($feedback, $notes = '')
{
    ?>
	<div class="input-form">
	<table>
	<tr>
	<td><h3><img src="images/feedback.gif" align="top" alt="" class="img" /> <?php 
    echo _AT('TR_FEEDBACK_UPDATE_INSTALLED_SUCCESSFULLY');
    ?>
</h3>
		<?php 
    echo '<ul>';
    foreach ($feedback as $p) {
        echo '<li>' . $p . '</li>';
    }
    echo '</ul>';
    ?>
</td>
	</tr>
	<tr>
		<td>
		<?php 
    echo $notes;
    ?>
		</td>
	</tr>
	</table>
	</div>
<?php 
}
Example #4
0
/**
 * Generate html of each patch row at main patch page
 */
function print_patch_row($patch_row, $row_id, $enable_radiotton)
{
	global $id, $patch_id;   // current selected patch
	global $dependent_patches;

	if ($dependent_patches =="")
		$description = $patch_row["description"];
	else
		$description = $patch_row["description"] . _AT('patch_dependent_patch_not_installed') . "<span style='color: red'>" . $dependent_patches . "</span>";
?>
	<tr <?php if ($enable_radiotton) echo 'onmousedown="document.form[\'m'. $row_id.'\'].checked = true; rowselect(this);" id="r_'. $row_id .'"'; ?>>
		<td><input type="radio" name="id" value="<?php echo $row_id; ?>"<?php if ($enable_radiotton) echo 'id="m'. $row_id.'"'; ?> <?php if (!$enable_radiotton) echo 'disabled="disabled" '; if (strcmp($row_id, $id) == 0 || strcmp($row_id, $patch_id) == 0) echo "checked "?> /></td>
		<td><label <?php if ($enable_radiotton) echo 'for="m'.$row_id.'"'; ?>><?php echo $patch_row["atutor_patch_id"]; ?></label></td>
		<td><?php echo $description; ?></td>
		<td><?php if (!isset($patch_row['status'])) echo _AT("not_installed"); else echo $patch_row["status"]; ?></td>
		<td><?php echo $patch_row["available_to"]; ?></td>
		<td><?php echo $patch_row["author"]; ?></td>
		<td><?php if (isset($patch_row['status'])) echo ($patch_row["installed_date"]=='0000-00-00 00:00:00')?_AT('na'):$patch_row["installed_date"]; ?></td>
		<td>
		<?php 
		if (preg_match('/Installed/', $patch_row["status"]) > 0 && ($patch_row["remove_permission_files"]<> "" || $patch_row["backup_files"]<>"" || $patch_row["patch_files"]<> ""))
			echo '
		  <div class="row buttons">
				<input type="button" align="middle" name="info" value="'._AT('view_message').'" onclick="location.href=\''. $_SERVER['PHP_SELF'] .'?patch_id='.$row_id.'\'" />
			</div>';
		?>
		</td>
	</tr>
<?php
}
 /**
  * Update expire threshold
  * @access  public
  * @param   consumer, expire threshold
  * @return  true, if successful
  *          false and add error into global var $msg, if unsuccessful
  * @author  Cindy Qi Li
  */
 public function updateExpireThreshold($consumer, $expire_threshold)
 {
     global $addslashes, $msg;
     $missing_fields = array();
     /* email check */
     $consumer = $addslashes(trim($consumer));
     /* login name check */
     if ($consumer == '') {
         $missing_fields[] = _AT('consumer');
     }
     if ($missing_fields) {
         $missing_fields = implode(', ', $missing_fields);
         $msg->addError(array('EMPTY_FIELDS', $missing_fields));
     }
     if (!$msg->containsErrors()) {
         /* update db */
         $sql = "UPDATE " . TABLE_PREFIX . "oauth_server_consumers\n\t\t\t           SET expire_threshold = " . $expire_threshold . "\n\t\t\t         WHERE consumer = '" . $consumer . "'";
         if (!$this->execute($sql)) {
             $msg->addError('DB_NOT_UPDATED');
             return false;
         } else {
             return true;
         }
     } else {
         return false;
     }
 }
Example #6
0
function tests_news() {
	global $db, $enrolled_courses, $system_courses;
	$news = array();

	if ($enrolled_courses == ''){
		return $news;
	} 
	$sql = "SELECT T.test_id, T.course_id, T.title, T.start_date as start_date, UNIX_TIMESTAMP(T.start_date) AS sd, UNIX_TIMESTAMP(T.end_date) AS ed 
          FROM ".TABLE_PREFIX."tests T, ".TABLE_PREFIX."tests_questions_assoc Q 
         WHERE Q.test_id=T.test_id 
           AND T.course_id IN $enrolled_courses 
         GROUP BY T.test_id 
         ORDER BY T.start_date DESC";
	$result = mysql_query($sql, $db);
	if($result){
		while($row = mysql_fetch_assoc($result)){
			//show only the visible tests
			if ( ($row['sd'] <= time()) && ($row['ed'] >= time())){
				$news[] = array('time'=>$row['start_date'], 
								'object'=>$row,
								'alt'=>_AT('tests'),
								'course'=>$system_courses[$row['course_id']]['title'],
								'thumb'=>'images/home-tests_sm.png',
								'link'=>'<a href="bounce.php?course='.$row['course_id'].'&p='.urlencode('mods/_standard/tests/test_intro.php?tid='.$row['test_id']).'" '
										.(strlen($row['title']) > SUBLINK_TEXT_LEN ? ' title="'.$row['title'].'"' : '') .'>'
										.validate_length($row['title'], SUBLINK_TEXT_LEN, VALIDATE_LENGTH_FOR_DISPLAY) .'</a> <small>('._AT('start_date').':'.AT_DATE('%F %j, %g:%i',$row['start_date']).')</small>');
			}
		}
	}
	return $news;
}
function fm_path()
{
    global $pathext, $framed, $popup, $cp, $cid, $pid, $a_type, $_course_id;
    echo '<p>' . _AT('current_path') . ' ';
    if (isset($pathext) && $pathext != '') {
        echo '<a href="' . $_SERVER['PHP_SELF'] . '?popup=' . $popup . SEP . 'framed=' . $framed . SEP . 'cp=' . $cp . SEP . '_cid=' . $cid . SEP . 'pid=' . $pid . SEP . 'a_type=' . $a_type . SEP . '_course_id=' . $_course_id . '">' . _AT('home') . '</a> ';
    } else {
        $pathext = '';
        echo _AT('home');
    }
    if ($pathext == '' && isset($_POST['pathext'])) {
        $pathext = urlencode($_POST['pathext']);
    }
    if ($pathext != '') {
        $bits = explode('/', $pathext);
        foreach ($bits as $bit) {
            if ($bit != '') {
                $bit_path .= $bit . '/';
                echo ' / ';
                if ($bit_path == $pathext) {
                    echo $bit;
                } else {
                    echo '<a href="' . $_SERVER['PHP_SELF'] . '?pathext=' . urlencode($bit_path) . SEP . 'popup=' . $popup . SEP . 'framed=' . $framed . SEP . 'cp=' . $_GET['cp'] . SEP . 'pid=' . $_GET['pid'] . SEP . '_cid=' . $cid . SEP . 'a_type=' . $a_type . SEP . '_course_id=' . $_course_id . '">' . $bit . '</a>';
                }
            }
        }
        $bit_path = "";
        $bit = "";
    }
    echo '</p>';
}
Example #8
0
function blogs_news()
{
    global $db, $enrolled_courses, $system_courses;
    $news = array();
    if ($enrolled_courses == '') {
        return $news;
    }
    $sql = "SELECT G.group_id, G.title, G.modules, T.course_id FROM %sgroups G INNER JOIN %sgroups_types  T USING (type_id) WHERE T.course_id IN %s ORDER BY G.title";
    $rows_enrolled = queryDB($sql, array(TABLE_PREFIX, TABLE_PREFIX, $enrolled_courses));
    if (count($rows_enrolled) > 0) {
        foreach ($rows_enrolled as $row) {
            if (strpos($row['modules'], '_standard/blogs') !== FALSE) {
                // check for group membership before showing news.
                $sql = "SELECT member_id FROM %sgroups_members WHERE member_id=%d AND group_id= %d";
                $row_group_member = queryDB($sql, array(TABLE_PREFIX, $_SESSION['member_id'], $row['group_id']), TRUE);
                // check for course instructor, show blog news if so
                $sql = "SELECT member_id from %scourses WHERE member_id =%d";
                $row_instructor = queryDB($sql, array(TABLE_PREFIX, $_SESSION['member_id']));
                if (count($row_group_member) > 0 || count($row_instructor) > 0) {
                    // retrieve the last posted date/time from this blog
                    $sql = "SELECT MAX(date) AS date FROM %sblog_posts WHERE owner_type=%d AND owner_id=%d";
                    $row2 = queryDB($sql, array(TABLE_PREFIX, BLOGS_GROUP, $row['group_id']), TRUE);
                    $last_updated = ' - ' . _AT('last_updated', AT_date(_AT('forum_date_format'), $row2['date'], AT_DATE_MYSQL_DATETIME));
                    $link_title = $row['title'];
                    $news[] = array('time' => $row2['date'], 'object' => $row, 'alt' => _AT('blogs'), 'course' => $system_courses[$row['course_id']]['title'], 'thumb' => 'images/home-blogs_sm.png', 'link' => '<a href="bounce.php?course=' . $row['course_id'] . SEP . 'p=' . urlencode('mods/_standard/blogs/view.php?ot=' . BLOGS_GROUP . SEP . 'oid=' . $row['group_id']) . '"' . (strlen($link_title) > SUBLINK_TEXT_LEN ? ' title="' . AT_print($link_title, 'blog_posts.title') . '"' : '') . '>' . AT_print(validate_length($link_title, SUBLINK_TEXT_LEN, VALIDATE_LENGTH_FOR_DISPLAY), 'blog_posts.title') . '</a>');
                }
            }
        }
    }
    return $news;
}
 /**
  * update an existing oauth server record
  * @access  public
  * @param   server
  *          consumer key
  *          consumer secret
  *          expire threshold
  * @return  true, if successful
  *          false and add error into global var $msg, if unsuccessful
  * @author  Cindy Qi Li
  */
 public function Update($oauth_server, $consumer_key, $consumer_secret, $expire_threshold)
 {
     global $addslashes, $msg;
     $missing_fields = array();
     /* email check */
     $oauth_server = $addslashes(trim($oauth_server));
     $expire_threshold = intval($expire_threshold);
     /* login name check */
     if ($oauth_server == '') {
         $missing_fields[] = _AT('oauth_server');
     }
     if ($missing_fields) {
         $missing_fields = implode(', ', $missing_fields);
         $msg->addError(array('EMPTY_FIELDS', $missing_fields));
     }
     if (!$msg->containsErrors()) {
         $sql = "UPDATE " . TABLE_PREFIX . "oauth_client_servers\n\t\t\t           SET consumer_key = '" . $consumer_key . "',\n\t\t\t               consumer_secret = '" . $consumer_secret . "',\n\t\t\t               expire_threshold = " . $expire_threshold . "\n\t\t\t         WHERE oauth_server = '" . $oauth_server . "'";
         if (!$this->execute($sql)) {
             $msg->addError('DB_NOT_UPDATED');
             return false;
         } else {
             return true;
         }
     } else {
         return false;
     }
 }
Example #10
0
 /**
  * Appends a custom ATutor footer to all outgoing email then sends the email.
  * If mail_queue is enabled then instead of sending the mail out right away, it 
  * places it in the database and waits for the cron to send it using SendQueue().
  * The mail queue does not support reply-to, or attachments, and converts all BCCs
  * to regular To emails.
  * @access  public
  * @return  boolean	whether or not the mail was sent (or queued) successfully.
  * @see     parent::send()
  * @since   ATutor 1.4.1
  * @author  Joel Kronenberg
  */
 function Send()
 {
     global $_config;
     // attach the ATutor footer to the body first:
     $this->Body .= "\n\n" . '----------------------------------------------' . "\n";
     $this->Body .= _AT('sent_via_atutor', AT_BASE_HREF);
     if ($_SESSION['course_id'] > 0) {
         $this->Body .= 'login.php?course=' . $_SESSION['course_id'] . ' | ' . $_SESSION['course_title'];
     }
     $this->Body .= "\n" . _AT('atutor_home') . ': http://atutor.ca';
     // if this email has been queued then don't send it. instead insert it in the db
     // for each bcc or to or cc
     if ($_config['enable_mail_queue'] && !$this->attachment) {
         global $db;
         for ($i = 0; $i < count($this->to); $i++) {
             $this->QueueMail(addslashes($this->to[$i][0]), addslashes($this->to[$i][1]), addslashes($this->From), addslashes($this->FromName), addslashes($this->Subject), addslashes($this->Body));
         }
         for ($i = 0; $i < count($this->cc); $i++) {
             $this->QueueMail(addslashes($this->cc[$i][0]), addslashes($this->cc[$i][1]), addslashes($this->From), addslashes($this->FromName), addslashes($this->Subject), addslashes($this->Body));
         }
         for ($i = 0; $i < count($this->bcc); $i++) {
             $this->QueueMail(addslashes($this->bcc[$i][0]), addslashes($this->bcc[$i][1]), addslashes($this->From), addslashes($this->FromName), addslashes($this->Subject), addslashes($this->Body));
         }
         return true;
     } else {
         return parent::Send();
     }
 }
function print_categories($categories, $cat_id) {
	if ($cat_id == 0) {
		echo '<ul>';
		foreach($categories[0] as $child_cat_id) {
			print_categories($categories, $child_cat_id);
		}
		echo '</ul>';
	} else {
		echo '<li>';
		if ($cat_id == $_REQUEST['cat_id']) {
			echo '<strong>'.$categories[$cat_id]['cat_name'].'</strong>';
		} else if ($cat_id == $_REQUEST['pcat_id']) {
			echo '<a href="'.$_SERVER['PHP_SELF'].'?cat_id='.$cat_id.'"><b>'.$categories[$cat_id]['cat_name'].'</b></a>';
		} else {
			echo '<a href="'.$_SERVER['PHP_SELF'].'?cat_id='.$cat_id.'">'.$categories[$cat_id]['cat_name'].'</a>';
		}
		echo ' <small class="spacer">('.$categories[$cat_id]['num_courses'].' ';
		if ($categories[$cat_id]['num_courses'] == 1) {
			echo _AT('course');
		} else {
			echo _AT('courses');
		}
		
		echo ')</small>';
		if (is_array($categories[$cat_id]['children'])) {
			echo '<ul>';
			foreach($categories[$cat_id]['children'] as $child_cat_id) {
				print_categories($categories, $child_cat_id);
			}
			echo '</ul>';
		}
		echo '</li>';
	}
}
Example #12
0
function forums_news()
{
    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;
    }
    $sql = 'SELECT E.approved, E.last_cid, C.* FROM ' . TABLE_PREFIX . 'course_enrollment E, ' . TABLE_PREFIX . 'courses C WHERE C.course_id in ' . $enrolled_courses . '  AND E.member_id=' . $_SESSION['member_id'] . ' AND E.course_id=C.course_id ORDER BY C.title';
    $rows_en_courses = queryDB($sql, array());
    if (count($rows_en_courses) > 0) {
        foreach ($rows_en_courses as $row) {
            $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 . 'pu=' . 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;
}
Example #13
0
function blogs_news()
{
    global $db, $enrolled_courses, $system_courses;
    $news = array();
    if ($enrolled_courses == '') {
        return $news;
    }
    $sql = "SELECT G.group_id, G.title, G.modules, T.course_id FROM " . TABLE_PREFIX . "groups G INNER JOIN " . TABLE_PREFIX . "groups_types  T USING (type_id) WHERE T.course_id IN {$enrolled_courses} ORDER BY G.title";
    $result = mysql_query($sql, $db);
    if ($result) {
        if (mysql_num_rows($result) > 0) {
            while ($row = mysql_fetch_assoc($result)) {
                if (strpos($row['modules'], '_standard/blogs') !== FALSE) {
                    // retrieve the last posted date/time from this blog
                    $sql = "SELECT MAX(date) AS date FROM " . TABLE_PREFIX . "blog_posts WHERE owner_type=" . BLOGS_GROUP . " AND owner_id={$row['group_id']}";
                    $date_result = mysql_query($sql, $db);
                    $row2 = mysql_fetch_assoc($date_result);
                    $last_updated = ' - ' . _AT('last_updated', AT_date(_AT('forum_date_format'), $row2['date'], AT_DATE_MYSQL_DATETIME));
                    $link_title = $row['title'];
                    $news[] = array('time' => $row2['date'], 'object' => $row, 'alt' => _AT('blogs'), 'course' => $system_courses[$row['course_id']]['title'], 'thumb' => 'images/home-blogs_sm.png', 'link' => '<a href="bounce.php?course=' . $row['course_id'] . SEP . 'p=' . urlencode('mods/_standard/blogs/view.php?ot=' . BLOGS_GROUP . SEP . 'oid=' . $row['group_id']) . '"' . (strlen($link_title) > SUBLINK_TEXT_LEN ? ' title="' . AT_print($link_title, 'blog_posts.title') . '"' : '') . '>' . AT_print(validate_length($link_title, SUBLINK_TEXT_LEN, VALIDATE_LENGTH_FOR_DISPLAY), 'blog_posts.title') . '</a>');
                }
            }
        }
    }
    return $news;
}
Example #14
0
function file_storage_news()
{
    global $enrolled_courses, $system_courses;
    $news = array();
    if ($enrolled_courses == '') {
        return $news;
    }
    // As personal files are listed in any enrolled courses of the student,
    // randomly pick one course for bouce.php
    $end_of_first_course = strpos($enrolled_courses, ",") - 1;
    $any_one_enrolled_course = substr($enrolled_courses, 1, $end_of_first_course ? $end_of_first_course : -1);
    $sql = "(SELECT date, file_id, file_name, owner_id course_id, description \n\t           FROM " . TABLE_PREFIX . "files \n\t          WHERE owner_type = " . WORKSPACE_COURSE . " AND owner_id IN " . $enrolled_courses . ")\n\t        UNION\n\t        (SELECT date, file_id, file_name, " . $any_one_enrolled_course . " course_id, description \n\t           FROM " . TABLE_PREFIX . "files\n\t          WHERE owner_type = " . WORKSPACE_PERSONAL . " AND owner_id = " . $_SESSION['member_id'] . ")\n\t        UNION\n\t        (SELECT f.date, f.file_id, f.file_name, gt.course_id, f.description \n\t           FROM " . TABLE_PREFIX . "files f, " . TABLE_PREFIX . "groups g, " . TABLE_PREFIX . "groups_types gt\n\t          WHERE owner_type = " . WORKSPACE_GROUP . " \n\t            AND f.owner_id = g.group_id \n\t            AND g.type_id = gt.type_id \n\t            AND gt.course_id IN " . $enrolled_courses . "\n\t            AND " . $_SESSION['member_id'] . " in \n\t               (select member_id \n\t                from " . TABLE_PREFIX . "groups_members gm \n\t                where gm.group_id = g.group_id))\n\t         ORDER BY date DESC";
    $rows_files = queryDB($sql, array());
    if (count($rows_files) > 0) {
        foreach ($rows_files as $row) {
            if ($row['description'] != "") {
                $filetext = $row['description'];
            } else {
                $filetext = $row['file_name'];
            }
            $sql = "SELECT course_id, home_links, main_links from %scourses WHERE course_id = %d";
            $row2 = queryDB($sql, array(TABLE_PREFIX, $row['course_id']), TRUE);
            // check if course has file storage enabled
            if (strstr($row2['home_links'], 'file_storage') || strstr($row2['main_links'], 'file_storage')) {
                $news[] = array('time' => $row['date'], 'object' => $row, 'course' => $system_courses[$row['course_id']]['title'], 'alt' => _AT('download'), 'thumb' => 'images/application_get.png', 'link' => '<a href="bounce.php?course=' . $row['course_id'] . SEP . 'p=' . urlencode('mods/_standard/file_storage/index.php?download=1' . SEP . 'files[]=' . $row['file_id']) . '"' . (strlen($filetext) > SUBLINK_TEXT_LEN ? ' title="' . AT_print($filetext, 'input.text') . '"' : '') . '>' . AT_print(validate_length($filetext, SUBLINK_TEXT_LEN, VALIDATE_LENGTH_FOR_DISPLAY), 'input.text') . '</a>');
            }
        }
    }
    return $news;
}
Example #15
0
function photos_create_group($group_id) {
	global $db;
    $group_id = intval($group_id);
    //get group name
    $sql = 'SELECT title FROM ' . TABLE_PREFIX . "groups WHERE group_id=$group_id";
    $result = mysql_query($sql, $db);
    $group_info = mysql_fetch_assoc($result);
    
    $pa = new PhotoAlbum();
    $album_name = $group_info['title'] . '(' . _AT('group') . ')';
    $album_location = _AT('na');
    $album_description = _AT('na');
    $album_type = AT_PA_TYPE_COURSE_ALBUM;
    $album_permission = AT_PA_PRIVATE_ALBUM;

    $album_id = $pa->createAlbum($album_name, $album_location, $album_description, $album_type, $album_permission, $_SESSION['member_id'], 0);
    if ($album_id === false){
        //TODO: sql failure.
        $msg->addError('PA_CREATE_ALBUM_FAILED');
        $result = false;
    } else {
        $sql = 'INSERT INTO '.TABLE_PREFIX."pa_groups (group_id, album_id) VALUES ($group_id, $album_id)";
        $result = mysql_query($sql, $db);
    }
}
/**
 * Extending the assignment dates to make them accessible to Calendar Module
 * @param     :    Course id, Member id
 * @return    :    array (assignment due and cut off dates) in format that can be used by fullcalendar
 * @author    :    Anurup Raveendran, Herat Gandhi
 */
function assignments_extend_date($member_id, $course_id)
{
    //global $db;
    $assignments = array();
    // get course title
    $sql = "SELECT title  FROM %scourses  WHERE course_id = %d";
    $row = queryDB($sql, array(TABLE_PREFIX, $course_id), TRUE);
    $course_title = $row['title'];
    $sql = "SELECT assignment_id,title,date_due,date_cutoff FROM %sassignments WHERE course_id = %d";
    $rows_courses = queryDB($sql, array(TABLE_PREFIX, $course_id));
    $row_count = count($rows_courses);
    if ($row_count > 0) {
        $index = 0;
        foreach ($rows_courses as $row) {
            $assignment_id = $row['assignment_id'];
            $unix_ts = strtotime($row['date_due']);
            $time = date('h:i A', $unix_ts);
            if (strpos($row['date_due'] . '', '0000-00-00') === false) {
                $assignments[$index] = array("id" => rand(5000, 9000) . '', "title" => _AT('calendar_assignment_due') . $row['title'], "start" => $row['date_due'], "end" => $row['date_due'], "allDay" => false, "color" => 'yellow', "textColor" => 'black', "editable" => false);
                $unix_ts = strtotime($row['date_cutoff']);
                $time = date('h:i A', $unix_ts);
                $index++;
            }
            if (strpos($row['date_cutoff'] . '', '0000-00-00') === false) {
                $assignments[$index] = array("id" => rand(5000, 9000) . '', "title" => _AT('calendar_assignment_cut') . $row['title'], "start" => $row['date_cutoff'], "end" => $row['date_cutoff'], "allDay" => false, "color" => 'red', "textColor" => 'white', "editable" => false);
                $index++;
            }
        }
    }
    return $assignments;
}
 /**
  * Appends a custom AContent footer to all outgoing email then sends the email.
  * If mail_queue is enabled then instead of sending the mail out right away, it 
  * places it in the database and waits for the cron to send it using SendQueue().
  * The mail queue does not support reply-to, or attachments, and converts all BCCs
  * to regular To emails.
  * @access  public
  * @return  boolean	whether or not the mail was sent (or queued) successfully.
  * @see     parent::send()
  * @since   AContent 0.1
  * @author  Joel Kronenberg
  */
 function Send()
 {
     global $_config;
     // attach the AContent footer to the body first:
     $this->Body .= "\n\n" . '----------------------------------------------' . "\n";
     $this->Body .= _AT(array('sent_via_transformable', TR_BASE_HREF));
     $this->Body .= "\n" . _AT('home') . ': http://atutor.ca';
     // if this email has been queued then don't send it. instead insert it in the db
     // for each bcc or to or cc
     if ($_config['enable_mail_queue'] && !$this->attachment) {
         require_once TR_INCLUDE_PATH . 'classes/DAO/MailQueueDAO.class.php';
         $mailQueueDAO = new MailQueueDAO();
         for ($i = 0; $i < count($this->to); $i++) {
             $mailQueueDAO->Create(addslashes($this->to[$i][0]), addslashes($this->to[$i][1]), addslashes($this->From), addslashes($this->FromName), addslashes($this->Subject), addslashes($this->Body), addslashes($this->CharSet));
         }
         for ($i = 0; $i < count($this->cc); $i++) {
             $mailQueueDAO->Create(addslashes($this->cc[$i][0]), addslashes($this->cc[$i][1]), addslashes($this->From), addslashes($this->FromName), addslashes($this->Subject), addslashes($this->Body), addslashes($this->CharSet));
         }
         for ($i = 0; $i < count($this->bcc); $i++) {
             $mailQueueDAO->Create(addslashes($this->bcc[$i][0]), addslashes($this->bcc[$i][1]), addslashes($this->From), addslashes($this->FromName), addslashes($this->Subject), addslashes($this->Body), addslashes($this->CharSet));
         }
         return true;
     } else {
         return parent::Send();
     }
 }
Example #18
0
function links_news() {
	global $db, $enrolled_courses, $system_courses;
	$news = array();

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

	$sql = "SELECT * FROM ".TABLE_PREFIX."links L INNER JOIN ".TABLE_PREFIX."links_categories C ON C.cat_id = L.cat_id WHERE owner_id IN $enrolled_courses AND L.Approved=1 ORDER BY SubmitDate DESC";
	$result = mysql_query($sql, $db);
	if($result){
		while($row = mysql_fetch_assoc($result)){
			$news[] = array(
							'time'=>$row['SubmitDate'], 
							'object'=>$row, 
							'alt'=>_AT('links'),
							'course'=>$system_courses[$row['owner_id']]['title'],
							'thumb'=>'images/home-links_sm.png', 
							'link'=>'<a href="bounce.php?course='.$row['owner_id'].'&p='.urlencode('mods/_standard/links/index.php?view='.$row['link_id']).'"'.
									(strlen($row['LinkName']) > SUBLINK_TEXT_LEN ? ' title="'.$row['LinkName'].'"' : '') .'>'. 
									validate_length($row['LinkName'], SUBLINK_TEXT_LEN, VALIDATE_LENGTH_FOR_DISPLAY) .'</a>');
		}
	}
	return $news;
}
function output_tabs($current_tab, $changes) {
	global $_base_path;
	$tabs = get_tabs();
	$num_tabs = count($tabs);
?>
<div class="etabbed-list-container">
	<ul class="etabbed-list" >
	
		
		<?php for ($i=0; $i < $num_tabs; $i++): 
			if ($current_tab == $i):?>
				<li class="prefs_tab_selected">
					<?php if ($changes[$i]): ?>
						<img src="<?php echo $_base_path; ?>images/changes_bullet.gif" alt="<?php echo _AT('usaved_changes_made'); ?>" height="12" width="15" />
					<?php echo '<input type="submit" name="button_'.$i.'" value="'._AT($tabs[$i][0]).'" title="'._AT($tabs[$i][0]).' - alt '.$tabs[$i][2].'" class="prefs_buttontab" accesskey="'.$tabs[$i][2].'" onmouseover="this.style.cursor=\'pointer\';" '.$clickEvent.' />'; ?>
					<?php endif; ?>
					<?php echo _AT($tabs[$i][0]); ?>
				</li>
			
			<?php else: ?>
				<li class="prefs_tab" >
					<?php if ($changes[$i]): ?>
						<img src="<?php echo $_base_path; ?>images/changes_bullet.gif" alt="<?php echo _AT('usaved_changes_made'); ?>" height="12" width="15" />
					<?php endif; ?>

					<?php echo '<input type="submit" name="button_'.$i.'" value="'._AT($tabs[$i][0]).'" title="'._AT($tabs[$i][0]).' - alt '.$tabs[$i][2].'" class="prefs_buttontab" accesskey="'.$tabs[$i][2].'" onmouseover="this.style.cursor=\'pointer\';" '.$clickEvent.' />'; ?>
				</li>
				
			<?php endif; ?>
		<?php endfor; ?>
		
	
	</ul>
</div>	
<?php }
Example #20
0
/**
 * Display alternative table cell
 * @param $rows_secondary_resources   db 2d array of all secondary alternatives
 *        $alternative type   the resource type of the alternative to display. Must be one of the values in resource_types.type_id
 *        $content_id         used to pass into file_manager/index.php
 *        $ps                 used to pass into file_manager/index.php
 * @return html of the table cell "<td>...</td>"
 */
function display_alternative_cell($rows_secondary_resources, $alternative_type, $content_id, $pid, $td_header_id)
{
    global $content_row;
    $found_alternative = false;
    echo '    <td headers="' . $td_header_id . '">' . "\n";
    if (count($rows_secondary_resources) > 0) {
        foreach ($rows_secondary_resources as $secondary_resource) {
            if ($secondary_resource['type_id'] == $alternative_type) {
                echo '    <div id="' . $pid . '_' . $alternative_type . '">' . "\n";
                echo '      <a href="' . $secondary_resource['secondary_resource'] . '" title="' . _AT('new_window') . '" target="_new">' . get_display_filename($secondary_resource['secondary_resource']) . '</a><br />' . "\n";
                echo '      <a href="#" onclick="ATutor.poptastic(\'' . AT_BASE_HREF . 'mods/_core/file_manager/index.php?framed=1' . SEP . 'popup=1' . SEP . 'cp=' . $content_row['content_path'] . SEP . 'cid=' . $content_id . SEP . 'pid=' . $pid . SEP . 'a_type=' . $alternative_type . '\');return false;" title="' . _AT('new_window') . '">' . "\n";
                echo '        <img src="' . AT_BASE_HREF . 'images/home-tests_sm.png" border="0" title="' . _AT('alter') . '" alt="' . _AT('alter') . '" />' . "\n";
                echo '      </a>' . "\n";
                echo '      <a href="#" onclick="removeAlternative(\'' . $content_row['content_path'] . '\', ' . $content_id . ',' . $pid . ',' . $alternative_type . ');return false;">' . "\n";
                echo '        <img src="' . AT_BASE_HREF . 'images/icon_delete.gif" border="0" title="' . _AT('remove') . '" alt="' . _AT('remove') . '" />' . "\n";
                echo '      </a>' . "\n";
                echo '    </div>' . "\n";
                $found_alternative = true;
                break;
            }
        }
    }
    if (!$found_alternative) {
        echo '    <div id="' . $pid . '_' . $alternative_type . '">' . "\n";
        echo '      <input type="button" value="' . _AT('add') . '" title="' . _AT('new_window') . '" onclick="ATutor.poptastic(\'' . AT_BASE_HREF . 'mods/_core/file_manager/index.php?framed=1' . SEP . 'popup=1' . SEP . 'cp=' . $content_row['content_path'] . SEP . 'cid=' . $content_id . SEP . 'pid=' . $pid . SEP . 'a_type=' . $alternative_type . '\');return false;" />' . "\n";
        echo '    </div>' . "\n";
    }
    echo '    </td>' . "\n";
}
Example #21
0
function get_category_name($cat_id)
{
    $sql = "SELECT cat_name FROM %scourse_cats WHERE cat_id=%d";
    $row = queryDB($sql, array(TABLE_PREFIX, $cat_id), TRUE);
    if ($row['cat_name'] == '') {
        $row['cat_name'] = _AT('cats_uncategorized');
    }
    return $row['cat_name'];
}
Example #22
0
function print_entry2($row)
{
    global $page, $system_courses, $forum_info;
    static $counter;
    $counter++;
    $reply_link = '<a href="forum/view.php?fid=' . $row['forum_id'] . SEP . 'pid=';
    if ($row['parent_id'] == 0) {
        $reply_link .= $row['post_id'];
    } else {
        $reply_link .= $row['parent_id'];
    }
    $reply_link .= SEP . 'reply=' . $row['post_id'] . SEP . 'page=' . $page . '#post" >' . _AT('reply') . '</a>';
    ?>

	<li class="<?php 
    if ($counter % 2) {
        echo 'odd';
    } else {
        echo 'even';
    }
    ?>
">
		<a name="<?php 
    echo $row['post_id'];
    ?>
"></a>
		<div class="forum-post-author">
			<label class="title"><?php 
    echo htmlspecialchars(get_display_name($row['member_id']));
    ?>
</label><br />
		</div>

		<div class="forum-post-content">
			
			<div class="date">
                <p><?php 
    echo AT_date(_AT('forum_date_format'), $row['date'], AT_DATE_MYSQL_DATETIME);
    ?>
</p>
            </div>
            <div class="postheader"><h3><?php 
    echo AT_Print($row['subject'], 'forums_threads.subject');
    ?>
</h3></div>
				
			<div class="body">
				<p><?php 
    echo AT_print($row['body'], 'forums_threads.body');
    ?>
</p>
			</div>
		</div>
	</li>
<?php 
}
 /**
  * Update an existing myown_patches record
  * @access  public
  * @param   myownPatchID: myown_patches.myown_patch_id
  *          fieldName: the name of the table field to update
  *          fieldValue: the value to update
  * @return  true if successful
  *          error message array if failed; false if update db failed
  * @author  Cindy Qi Li
  */
 public function UpdateField($myownPatchID, $fieldName, $fieldValue)
 {
     global $addslashes;
     // check if the required fields are filled
     if (($fieldName == 'system_patch_id' || $fieldName == 'applied_version') && $fieldValue == '') {
         return array(_AT('TR_ERROR_EMPTY_FIELD'));
     }
     $sql = "UPDATE " . TABLE_PREFIX . "myown_patches \n\t\t           SET " . $addslashes($fieldName) . "='" . $addslashes($fieldValue) . "'\n\t\t         WHERE myown_patch_id = " . $myownPatchID;
     return $this->execute($sql);
 }
Example #24
0
function calendar_cron()
{
    require 'includes/classes/events.class.php';
    require AT_INCLUDE_PATH . 'classes/phpmailer/atutormailer.class.php';
    //Iterate through each member's preference
    $sql = "SELECT * FROM %scalendar_notification WHERE 1=1";
    $rows_notify = queryDB($sql, array(TABLE_PREFIX));
    $event_obj = new Events();
    foreach ($rows_notify as $row) {
        //Send email only when preference is 1
        if ($row['status'] == 1) {
            $all_events = array();
            $mail = new ATutorMailer();
            //Get personal events
            $personal_events = $event_obj->get_personal_events($row['memberid']);
            foreach ($personal_events as $event) {
                $all_events[] = $event;
            }
            //Get course events
            $sql_q = "SELECT course_id FROM %scourse_enrollment WHERE member_id = %d";
            $rows_enrolled = queryDB($sql_q, array(TABLE_PREFIX, TABLE_PREFIX));
            foreach ($rows_enrolled as $row_q) {
                $course_events = $event_obj->get_atutor_events($row['memberid'], $row_q['course_id']);
                foreach ($course_events as $event) {
                    $all_events[] = $event;
                }
            }
            //Iterate through each event and keep only those events which will start tomorrow
            $email_msg = _AT('calendar_noti_mail_1') . "\n";
            $index = 1;
            foreach ($all_events as $id => $event) {
                if (strtotime(substr($event['start'], 0, 10)) == strtotime('tomorrow')) {
                    $email_msg .= _AT('calendar_noti_mail_2') . " #" . $index . " \n";
                    $email_msg .= _AT('calendar_noti_mail_3') . ": " . substr($event['start'], 0, 10) . " \n";
                    $email_msg .= _AT('calendar_noti_mail_4') . ": " . substr($event['end'], 0, 10) . " \n";
                    $email_msg .= _AT('calendar_noti_mail_5') . ": " . $event['title'] . " \n\n";
                    $index++;
                }
            }
            //Send email using ATutor mailer
            $mail->From = $_config['contact_email'];
            $mail->FromName = $_config['site_name'];
            $mail->AddAddress($_config['contact_email']);
            $mail->Subject = $stripslashes(_AT('calendar_noti_title'));
            $mail->Body = $email_msg;
            $sql_email = "SELECT email FROM %smembers WHERE member_id = %d";
            $row_email = queryDB($sql_email, array(TABLE_PREFIX, $row['memberid']), TRUE);
            $mail->AddBCC($row_email['email']);
            $mail->Send();
            unset($mail);
            //For testing
            // echo "<br/>".$email_msg."<br/>".$row_email['mail'];
        }
    }
}
Example #25
0
function get_category_name($cat_id)
{
    global $db;
    $sql = "SELECT cat_name FROM " . TABLE_PREFIX . "course_cats WHERE cat_id=" . $cat_id;
    $result = mysql_query($sql, $db);
    $row = mysql_fetch_assoc($result);
    if ($row['cat_name'] == '') {
        $row['cat_name'] = _AT('cats_uncategorized');
    }
    return $row['cat_name'];
}
function print_theme_selectbox($theme_list, $selected_theme, $type)
{
    if (!is_array($theme_list) || count($theme_list) == 0) {
        return;
    }
    ?>
	<div class="row">
		<label for="<?php 
    if ($type == DESKTOP_DEVICE) {
        echo "theme";
    } else {
        echo "mobile_theme";
    }
    ?>
"><?php 
    if ($type == DESKTOP_DEVICE) {
        echo _AT('desktop_theme');
    } else {
        echo _AT('mobile_theme');
    }
    ?>
</label><br />
		<select name="<?php 
    if ($type == DESKTOP_DEVICE) {
        echo "theme";
    } else {
        echo "mobile_theme";
    }
    ?>
" id="<?php 
    if ($type == DESKTOP_DEVICE) {
        echo "theme";
    } else {
        echo "mobile_theme";
    }
    ?>
"><?php 
    foreach ($theme_list as $theme_id => $theme) {
        if (!$theme) {
            continue;
        }
        $theme_fldr = get_folder($theme);
        if ($theme_fldr == $selected_theme) {
            echo '<option value="' . $theme_fldr . '" selected="selected">' . $theme . '</option>';
        } else {
            echo '<option value="' . $theme_fldr . '">' . $theme . '</option>';
        }
    }
    ?>
		</select>
	</div>
<?php 
}
Example #27
0
function links_news()
{
    global $enrolled_courses, $system_courses;
    $news = array();
    if ($enrolled_courses == '') {
        return $news;
    }
    $result = queryDB('SELECT * FROM %slinks L INNER JOIN %slinks_categories C ON C.cat_id = L.cat_id WHERE owner_id IN %s AND L.Approved=1 ORDER BY SubmitDate DESC', array(TABLE_PREFIX, TABLE_PREFIX, $enrolled_courses));
    foreach ($result as $row) {
        $news[] = array('time' => $row['SubmitDate'], 'object' => $row, 'alt' => _AT('links'), 'course' => $system_courses[$row['owner_id']]['title'], 'thumb' => 'images/home-links_sm.png', 'link' => '<a href="bounce.php?course=' . $row['owner_id'] . SEP . 'p=' . urlencode('mods/_standard/links/index.php?view=' . $row['link_id']) . '"' . (strlen($row['LinkName']) > SUBLINK_TEXT_LEN ? ' title="' . $row['LinkName'] . '"' : '') . '>' . validate_length($row['LinkName'], SUBLINK_TEXT_LEN, VALIDATE_LENGTH_FOR_DISPLAY) . '</a> <small>');
    }
    return $news;
}
Example #28
0
function reading_list_news()
{
    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 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'] . '"' : '') . '>' . validate_length($row['title'], SUBLINK_TEXT_LEN, VALIDATE_LENGTH_FOR_DISPLAY) . '</a>');
        }
    }
    return $news;
}
Example #29
0
function file_storage_news() {
	global $db, $enrolled_courses, $system_courses;
	$news = array();

	if ($enrolled_courses == '') {
		return $news;
	}
	
	// As personal files are listed in any enrolled courses of the student,
	// randomly pick one course for bouce.php
	$end_of_first_course = strpos($enrolled_courses, ",") - 1;
	$any_one_enrolled_course = substr($enrolled_courses, 1, $end_of_first_course ? $end_of_first_course : -1);
	
	$sql = "(SELECT date, file_id, file_name, owner_id course_id, description 
	           FROM ".TABLE_PREFIX."files 
	          WHERE owner_type = ".WORKSPACE_COURSE." AND owner_id IN ".$enrolled_courses.")
	        UNION
	        (SELECT date, file_id, file_name, ".$any_one_enrolled_course." course_id, description 
	           FROM ".TABLE_PREFIX."files
	          WHERE owner_type = ".WORKSPACE_PERSONAL." AND owner_id = ".$_SESSION['member_id'].")
	        UNION
	        (SELECT f.date, f.file_id, f.file_name, gt.course_id, f.description 
	           FROM ".TABLE_PREFIX."files f, ".TABLE_PREFIX."groups g, ".TABLE_PREFIX."groups_types gt
	          WHERE owner_type = ".WORKSPACE_GROUP." 
	            AND f.owner_id = g.group_id 
	            AND g.type_id = gt.type_id 
	            AND gt.course_id IN ".$enrolled_courses.")
	         ORDER BY date DESC";
	$result = mysql_query($sql, $db);
	
	if($result){
		while($row = mysql_fetch_assoc($result)){
			if($row['description'] !=""){
				$filetext = $row['description'];
			} else {
				$filetext = $row['file_name'];
			}
			$news[] = array('time'=>$row['date'], 
			      'object'=>$row, 
			      'course'=>$system_courses[$row['course_id']]['title'],
			      'alt'=>_AT('download'),
			      'thumb'=>'images/application_get.png', 
			      'link'=>'<a href="bounce.php?course='.$row['course_id'].SEP.'p='.urlencode('mods/_standard/file_storage/index.php?download=1'.SEP.'files[]='. $row['file_id']).'"'.
		          (strlen($filetext) > SUBLINK_TEXT_LEN ? ' title="'.AT_print($filetext, 'input.text').'"' : '') .'>'. 
		          AT_print(validate_length($filetext, SUBLINK_TEXT_LEN, VALIDATE_LENGTH_FOR_DISPLAY), 'input.text') .'</a>');
		}
	}
	return $news;
}
Example #30
0
function reading_list_news()
{
    global $enrolled_courses, $system_courses;
    $news = array();
    if (isset($enrolled_courses)) {
        $sql = "SELECT * FROM %sreading_list R INNER JOIN %sexternal_resources E ON E.resource_id = R.resource_id WHERE R.course_id in %s ORDER BY R.reading_id DESC";
        $rows_resources = queryDB($sql, array(TABLE_PREFIX, TABLE_PREFIX, $enrolled_courses));
        if (count($rows_resources) > 0) {
            foreach ($rows_resources as $row) {
                $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="bounce.php?course=' . $row['course_id'] . SEP . 'p=mods/_standard/reading_list/display_resource.php?id=' . $row['resource_id'] . '"' . (strlen($row['title']) > SUBLINK_TEXT_LEN ? ' title="' . $row['title'] . '"' : '') . '>' . validate_length($row['title'], SUBLINK_TEXT_LEN, VALIDATE_LENGTH_FOR_DISPLAY) . '</a>');
            }
        }
        return $news;
    }
}