2 ///////////////////////////////////////////////////////////////////////////
4 // NOTICE OF COPYRIGHT //
6 // Moodle - Modular Object-Oriented Dynamic Learning Environment //
7 // http://moodle.org //
9 // Copyright (C) 1990-onwards Moodle Pty Ltd http://moodle.com //
11 // This program is free software; you can redistribute it and/or modify //
12 // it under the terms of the GNU General Public License as published by //
13 // the Free Software Foundation; either version 2 of the License, or //
14 // (at your option) any later version. //
16 // This program is distributed in the hope that it will be useful, //
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
19 // GNU General Public License for more details: //
21 // http://www.gnu.org/copyleft/gpl.html //
23 ///////////////////////////////////////////////////////////////////////////
25 require_once("../../config.php");
26 require_once("lib.php");
28 $id = required_param('id', PARAM_INT
); // course
30 if (! $course = get_record("course", "id", $id)) {
31 error("Course ID is incorrect");
34 require_course_login($course);
36 $context = get_context_instance(CONTEXT_COURSE
, $course->id
);
38 add_to_log($course->id
, "data", "view all", "index.php?id=$course->id", "");
40 $strweek = get_string('week');
41 $strtopic = get_string('topic');
42 $strname = get_string('name');
43 $strdata = get_string('modulename','data');
46 $navlinks[] = array('name' => $strdata, 'link' => "index.php?id=$course->id", 'type' => 'activity');
47 $navigation = build_navigation($navlinks);
49 print_header_simple($strdata, '', $navigation, '', '', true, "", navmenu($course));
51 if (! $datas = get_all_instances_in_course("data", $course)) {
52 notice("There are no databases", "$CFG->wwwroot/course/view.php?id=$course->id");
56 $strname = get_string('name');
57 $strweek = get_string('week');
58 $strtopic = get_string('topic');
59 $strdescription = get_string("description");
60 $strentries = get_string('entries', 'data');
61 $strnumnotapproved = get_string('numnotapproved', 'data');
63 if ($course->format
== 'weeks') {
64 $table->head
= array ($strweek, $strname, $strdescription, $strentries, $strnumnotapproved);
65 $table->align
= array ('center', 'center', 'center', 'center', 'center');
66 } else if ($course->format
== 'topics') {
67 $table->head
= array ($strtopic, $strname, $strdescription, $strentries, $strnumnotapproved);
68 $table->align
= array ('center', 'center', 'center', 'center', 'center');
70 $table->head
= array ($strname, $strdescription, $strentries, $strnumnotapproved);
71 $table->align
= array ('center', 'center', 'center', 'center');
74 $rss = (!empty($CFG->enablerssfeeds
) && !empty($CFG->data_enablerssfeeds
));
77 require_once($CFG->libdir
."/rsslib.php");
78 array_push($table->head
, 'RSS');
79 array_push($table->align
, 'center');
82 $currentgroup = get_and_set_current_group($course, groupmode($course));
83 if ($currentgroup and has_capability('mod/data:manageentries', $context)) {
84 $group = groups_get_group($currentgroup, false);
85 $groupname = " ($group->name)";
92 foreach ($datas as $data) {
97 if (!$data->visible
) {
98 //Show dimmed if the mod is hidden
99 $link = "<a class=\"dimmed\" href=\"view.php?id=$data->coursemodule\">".format_string($data->name
,true)."</a>";
101 //Show normal if the mod is visible
102 $link = "<a href=\"view.php?id=$data->coursemodule\">".format_string($data->name
,true)."</a>";
105 $numrecords = count_records_sql('SELECT COUNT(r.id) FROM '.$CFG->prefix
.
106 'data_records r WHERE r.dataid ='.$data->id
);
108 if ($data->approval
== 1) {
109 $numunapprovedrecords = count_records_sql('SELECT COUNT(r.id) FROM '.$CFG->prefix
.
110 'data_records r WHERE r.dataid ='.$data->id
.
111 ' AND r.approved <> 1');
113 $numunapprovedrecords = '-';
117 if ($rss && $data->rssarticles
> 0) {
118 $rsslink = rss_get_link($course->id
, $USER->id
, 'data', $data->id
, 'RSS');
121 if ($course->format
== 'weeks' or $course->format
== 'topics') {
122 if ($data->section
!== $currentsection) {
123 if ($data->section
) {
124 $printsection = $data->section
;
126 if ($currentsection !== '') {
127 $table->data
[] = 'hr';
129 $currentsection = $data->section
;
131 $row = array ($printsection, $link, $data->intro
, $numrecords, $numunapprovedrecords);
134 $row = array ($link, $data->intro
, $numrecords, $numunapprovedrecords);
138 array_push($row, $rsslink);
141 $table->data
[] = $row;
146 print_footer($course);