2 /***********************************************************************/
4 /***********************************************************************/
5 /* Copyright (c) 2002-2010 */
6 /* Inclusive Design Institute */
9 /* This program is free software. You can redistribute it and/or */
10 /* modify it under the terms of the GNU General Public License */
11 /* as published by the Free Software Foundation. */
12 /***********************************************************************/
15 * Get the latest updates of this module
16 * @return list of news, [timestamp]=>
18 function file_storage_news() {
19 global $db, $enrolled_courses, $system_courses;
22 if ($enrolled_courses == '') {
26 // As personal files are listed in any enrolled courses of the student,
27 // randomly pick one course for bouce.php
28 $end_of_first_course = strpos($enrolled_courses, ",") - 1;
29 $any_one_enrolled_course = substr($enrolled_courses, 1, $end_of_first_course ? $end_of_first_course : -1);
31 $sql = "(SELECT date, file_id, file_name, owner_id course_id, description
32 FROM ".TABLE_PREFIX."files
33 WHERE owner_type = ".WORKSPACE_COURSE." AND owner_id IN ".$enrolled_courses.")
35 (SELECT date, file_id, file_name, ".$any_one_enrolled_course." course_id, description
36 FROM ".TABLE_PREFIX."files
37 WHERE owner_type = ".WORKSPACE_PERSONAL." AND owner_id = ".$_SESSION['member_id'].")
39 (SELECT f.date, f.file_id, f.file_name, gt.course_id, f.description
40 FROM ".TABLE_PREFIX."files f, ".TABLE_PREFIX."groups g, ".TABLE_PREFIX."groups_types gt
41 WHERE owner_type = ".WORKSPACE_GROUP."
42 AND f.owner_id = g.group_id
43 AND g.type_id = gt.type_id
44 AND gt.course_id IN ".$enrolled_courses.")
46 $result = mysql_query($sql, $db);
49 while($row = mysql_fetch_assoc($result)){
50 if($row['description'] !=""){
51 $filetext = $row['description'];
53 $filetext = $row['file_name'];
55 $news[] = array('time'=>$row['date'],
57 'course'=>$system_courses[$row['course_id']]['title'],
58 'alt'=>_AT('download'),
59 'thumb'=>'images/application_get.png',
60 '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']).'"'.
61 (strlen($filetext) > SUBLINK_TEXT_LEN ? ' title="'.AT_print($filetext, 'input.text').'"' : '') .'>'.
62 AT_print(validate_length($filetext, SUBLINK_TEXT_LEN, VALIDATE_LENGTH_FOR_DISPLAY), 'input.text') .'</a>');