Automatic installer.php lang files by installer_builder (20070726)
[moodle-linuxchix.git] / mod / data / index.php
blob1b7057f40130563eeeac6660ed84dc7b38a472c6
1 <?php // $Id$
2 ///////////////////////////////////////////////////////////////////////////
3 // //
4 // NOTICE OF COPYRIGHT //
5 // //
6 // Moodle - Modular Object-Oriented Dynamic Learning Environment //
7 // http://moodle.org //
8 // //
9 // Copyright (C) 1990-onwards Moodle Pty Ltd http://moodle.com //
10 // //
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. //
15 // //
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: //
20 // //
21 // http://www.gnu.org/copyleft/gpl.html //
22 // //
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');
45 $navlinks = array();
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");
55 $timenow = time();
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');
69 } else {
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));
76 if ($rss) {
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)";
86 } else {
87 $groupname = "";
90 $currentsection = "";
92 foreach ($datas as $data) {
94 $printsection = "";
96 //Calculate the href
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>";
100 } else {
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');
112 } else {
113 $numunapprovedrecords = '-';
116 $rsslink = '';
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);
133 } else {
134 $row = array ($link, $data->intro, $numrecords, $numunapprovedrecords);
137 if ($rss) {
138 array_push($row, $rsslink);
141 $table->data[] = $row;
144 echo "<br />";
145 print_table($table);
146 print_footer($course);