Differences Between: [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403]
1 <?php 2 3 // This file is part of Moodle - http://moodle.org/ 4 // 5 // Moodle is free software: you can redistribute it and/or modify 6 // it under the terms of the GNU General Public License as published by 7 // the Free Software Foundation, either version 3 of the License, or 8 // (at your option) any later version. 9 // 10 // Moodle is distributed in the hope that it will be useful, 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 // GNU General Public License for more details. 14 // 15 // You should have received a copy of the GNU General Public License 16 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 17 18 /** 19 * This file is part of the Database module for Moodle 20 * 21 * @copyright 1990 Martin Dougiamas http://dougiamas.com 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 * @package mod_data 24 */ 25 26 require_once("../../config.php"); 27 require_once ("lib.php"); 28 29 $id = required_param('id', PARAM_INT); // course 30 31 $PAGE->set_url('/mod/data/index.php', array('id'=>$id)); 32 33 if (!$course = $DB->get_record('course', array('id'=>$id))) { 34 print_error('invalidcourseid'); 35 } 36 37 require_course_login($course); 38 $PAGE->set_pagelayout('incourse'); 39 40 $context = context_course::instance($course->id); 41 42 $params = array( 43 'context' => context_course::instance($course->id) 44 ); 45 $event = \mod_data\event\course_module_instance_list_viewed::create($params); 46 $event->add_record_snapshot('course', $course); 47 $event->trigger(); 48 49 $strname = get_string('name'); 50 $strdata = get_string('modulename','data'); 51 $strdataplural = get_string('modulenameplural','data'); 52 53 $PAGE->navbar->add($strdata, new moodle_url('/mod/data/index.php', array('id'=>$course->id))); 54 $PAGE->set_title($strdata); 55 $PAGE->set_heading($course->fullname); 56 echo $OUTPUT->header(); 57 echo $OUTPUT->heading($strdataplural, 2); 58 59 if (! $datas = get_all_instances_in_course("data", $course)) { 60 notice(get_string('thereareno', 'moodle',$strdataplural) , "$CFG->wwwroot/course/view.php?id=$course->id"); 61 } 62 63 $usesections = course_format_uses_sections($course->format); 64 65 $timenow = time(); 66 $strname = get_string('name'); 67 $strdescription = get_string("description"); 68 $strentries = get_string('entries', 'data'); 69 $strnumnotapproved = get_string('numnotapproved', 'data'); 70 71 $table = new html_table(); 72 73 if ($usesections) { 74 $strsectionname = get_string('sectionname', 'format_'.$course->format); 75 $table->head = array ($strsectionname, $strname, $strdescription, $strentries, $strnumnotapproved); 76 $table->align = array ('center', 'center', 'center', 'center', 'center'); 77 } else { 78 $table->head = array ($strname, $strdescription, $strentries, $strnumnotapproved); 79 $table->align = array ('center', 'center', 'center', 'center'); 80 } 81 82 $rss = (!empty($CFG->enablerssfeeds) && !empty($CFG->data_enablerssfeeds)); 83 84 if ($rss) { 85 require_once($CFG->libdir."/rsslib.php"); 86 array_push($table->head, 'RSS'); 87 array_push($table->align, 'center'); 88 } 89 90 $currentsection = ""; 91 92 foreach ($datas as $data) { 93 94 $printsection = ""; 95 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>"; 103 } 104 105 // TODO: add group restricted counts here, and limit unapproved to ppl with approve cap only + link to approval page 106 107 $numrecords = $DB->count_records_sql('SELECT COUNT(r.id) FROM {data_records} r WHERE r.dataid =?', array($data->id)); 108 109 if ($data->approval == 1) { 110 $numunapprovedrecords = $DB->count_records_sql('SELECT COUNT(r.id) FROM {data_records} r WHERE r.dataid =? AND r.approved <> 1', array($data->id)); 111 } else { 112 $numunapprovedrecords = '-'; 113 } 114 115 $rsslink = ''; 116 if ($rss && $data->rssarticles > 0) { 117 $rsslink = rss_get_link($context->id, $USER->id, 'mod_data', $data->id, 'RSS'); 118 } 119 120 if ($usesections) { 121 if ($data->section !== $currentsection) { 122 if ($data->section) { 123 $printsection = get_section_name($course, $data->section); 124 } 125 if ($currentsection !== '') { 126 $table->data[] = 'hr'; 127 } 128 $currentsection = $data->section; 129 } 130 $row = array($printsection, $link, format_module_intro('data', $data, $data->coursemodule), 131 $numrecords, $numunapprovedrecords); 132 133 } else { 134 $row = array($link, format_module_intro('data', $data, $data->coursemodule), 135 $numrecords, $numunapprovedrecords); 136 } 137 138 if ($rss) { 139 array_push($row, $rsslink); 140 } 141 142 $table->data[] = $row; 143 } 144 145 echo "<br />"; 146 echo html_writer::tag('div', html_writer::table($table), array('class'=>'no-overflow')); 147 echo $OUTPUT->footer(); 148
title
Description
Body
title
Description
Body
title
Description
Body
title
Body