remove old readme
[atutor.git] / docs / mods / _standard / assignment_dropbox / sublinks.php
1 <?php
2
3 if (!defined('AT_INCLUDE_PATH')) { exit; }
4
5 /*****
6 * Free form PHP can appear here to retreive current information
7 * from the module, or a text description of the module where there is
8 * not current information
9 *****/
10
11 global $db;
12
13 $link_limit = 2;                // Number of links to be displayed on "detail view" box
14
15 $groups_list = implode(',',$_SESSION['groups']);
16
17 $sql = '';
18 if (authenticate(AT_PRIV_ASSIGNMENTS, AT_PRIV_RETURN)) { // instructor
19         $file_storage_assignments = array();
20         $sql = "SELECT * FROM ".TABLE_PREFIX."assignments WHERE course_id=$_SESSION[course_id] ORDER BY date_due DESC";
21 } else { // students
22         if ($groups_list <> '') {
23                 $sql = "(SELECT a.title, date_due
24                    FROM ".TABLE_PREFIX."groups_types gt, ".TABLE_PREFIX."groups g, ".TABLE_PREFIX."assignments a
25                   WHERE g.group_id in (".$groups_list.")
26                     AND g.group_id in (SELECT group_id FROM ".TABLE_PREFIX."file_storage_groups)
27                     AND g.type_id = gt.type_id
28                     AND gt.course_id = $_SESSION[course_id]
29                     AND gt.type_id = a.assign_to
30                     AND (a.date_cutoff=0 OR UNIX_TIMESTAMP(a.date_cutoff) > ".time()."))
31                 UNION
32                 ";
33         }
34         $sql .= "(SELECT title, date_due
35                    FROM ".TABLE_PREFIX."assignments 
36                   WHERE assign_to=0 
37                     AND course_id=$_SESSION[course_id] 
38                     AND (date_cutoff=0 OR UNIX_TIMESTAMP(date_cutoff) > ".time()."))
39                 ORDER BY date_due DESC";
40 }
41 $sql .= " LIMIT $link_limit";
42 $result = mysql_query($sql, $db);
43
44 if (mysql_num_rows($result) > 0) {
45         while ($row = mysql_fetch_assoc($result)) {
46                 /****
47                 * SUBLINK_TEXT_LEN, VALIDATE_LENGTH_FOR_DISPLAY are defined in include/lib/constance.lib.inc
48                 * SUBLINK_TEXT_LEN determins the maxium length of the string to be displayed on "detail view" box.
49                 *****/
50                 $title = $row['title'] . ' ('._AT("due_date").': '.$row['date_due'].')';
51                 $list[] = '<a href="'.AT_BASE_HREF.'mods/_standard/assignment_dropbox/index.php">'. 
52                           $title .'</a>';
53 //              $list[] = '<a href="mods/assignment_dropbox/index.php"'.
54 //                        (strlen($row['value']) > SUBLINK_TEXT_LEN ? ' title="'.$row['value'].'"' : '') .'>'. 
55 //                        validate_length($row['value'], SUBLINK_TEXT_LEN, VALIDATE_LENGTH_FOR_DISPLAY) .'</a>';
56         }
57         return $list;   
58 } else {
59         return 0;
60 }
61
62 ?>