Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/mod/data/index.php
Go to the documentation of this file.
00001 <?php
00002 
00003 // This file is part of Moodle - http://moodle.org/
00004 //
00005 // Moodle is free software: you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation, either version 3 of the License, or
00008 // (at your option) any later version.
00009 //
00010 // Moodle is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
00017 
00026 require_once("../../config.php");
00027 require_once("lib.php");
00028 
00029 $id = required_param('id', PARAM_INT);   // course
00030 
00031 $PAGE->set_url('/mod/data/index.php', array('id'=>$id));
00032 
00033 if (!$course = $DB->get_record('course', array('id'=>$id))) {
00034     print_error('invalidcourseid');
00035 }
00036 
00037 require_course_login($course);
00038 $PAGE->set_pagelayout('incourse');
00039 
00040 $context = get_context_instance(CONTEXT_COURSE, $course->id);
00041 
00042 add_to_log($course->id, "data", "view all", "index.php?id=$course->id", "");
00043 
00044 $strsectionname  = get_string('sectionname', 'format_'.$course->format);
00045 $strname = get_string('name');
00046 $strdata = get_string('modulename','data');
00047 $strdataplural  = get_string('modulenameplural','data');
00048 
00049 $PAGE->navbar->add($strdata, new moodle_url('/mod/data/index.php', array('id'=>$course->id)));
00050 $PAGE->set_title($strdata);
00051 $PAGE->set_heading($course->fullname);
00052 echo $OUTPUT->header();
00053 
00054 if (! $datas = get_all_instances_in_course("data", $course)) {
00055     notice(get_string('thereareno', 'moodle',$strdataplural) , "$CFG->wwwroot/course/view.php?id=$course->id");
00056 }
00057 
00058 $usesections = course_format_uses_sections($course->format);
00059 if ($usesections) {
00060     $sections = get_all_sections($course->id);
00061 }
00062 
00063 $timenow  = time();
00064 $strname  = get_string('name');
00065 $strdescription = get_string("description");
00066 $strentries = get_string('entries', 'data');
00067 $strnumnotapproved = get_string('numnotapproved', 'data');
00068 
00069 $table = new html_table();
00070 
00071 if ($usesections) {
00072     $table->head  = array ($strsectionname, $strname, $strdescription, $strentries, $strnumnotapproved);
00073     $table->align = array ('center', 'center', 'center', 'center', 'center');
00074 } else {
00075     $table->head  = array ($strname, $strdescription, $strentries, $strnumnotapproved);
00076     $table->align = array ('center', 'center', 'center', 'center');
00077 }
00078 
00079 $rss = (!empty($CFG->enablerssfeeds) && !empty($CFG->data_enablerssfeeds));
00080 
00081 if ($rss) {
00082     require_once($CFG->libdir."/rsslib.php");
00083     array_push($table->head, 'RSS');
00084     array_push($table->align, 'center');
00085 }
00086 
00087 $options = new stdClass();
00088 $options->noclean = true;
00089 
00090 $currentsection = "";
00091 
00092 foreach ($datas as $data) {
00093 
00094     $printsection = "";
00095 
00096     //Calculate the href
00097     if (!$data->visible) {
00098         //Show dimmed if the mod is hidden
00099         $link = "<a class=\"dimmed\" href=\"view.php?id=$data->coursemodule\">".format_string($data->name,true)."</a>";
00100     } else {
00101         //Show normal if the mod is visible
00102         $link = "<a href=\"view.php?id=$data->coursemodule\">".format_string($data->name,true)."</a>";
00103     }
00104 
00105     // TODO: add group restricted counts here, and limit unapproved to ppl with approve cap only + link to approval page
00106 
00107     $numrecords = $DB->count_records_sql('SELECT COUNT(r.id) FROM {data_records} r WHERE r.dataid =?', array($data->id));
00108 
00109     if ($data->approval == 1) {
00110         $numunapprovedrecords = $DB->count_records_sql('SELECT COUNT(r.id) FROM {data_records} r WHERE r.dataid =? AND r.approved <> 1', array($data->id));
00111     } else {
00112         $numunapprovedrecords = '-';
00113     }
00114 
00115     $rsslink = '';
00116     if ($rss && $data->rssarticles > 0) {
00117         $rsslink = rss_get_link($context->id, $USER->id, 'mod_data', $data->id, 'RSS');
00118     }
00119 
00120     if ($usesections) {
00121         if ($data->section !== $currentsection) {
00122             if ($data->section) {
00123                 $printsection = get_section_name($course, $sections[$data->section]);
00124             }
00125             if ($currentsection !== '') {
00126                 $table->data[] = 'hr';
00127             }
00128             $currentsection = $data->section;
00129         }
00130         $row = array ($printsection, $link, format_text($data->intro, $data->introformat, $options), $numrecords, $numunapprovedrecords);
00131 
00132     } else {
00133         $row = array ($link, format_text($data->intro, $data->introformat, $options), $numrecords, $numunapprovedrecords);
00134     }
00135 
00136     if ($rss) {
00137         array_push($row, $rsslink);
00138     }
00139 
00140     $table->data[] = $row;
00141 }
00142 
00143 echo "<br />";
00144 echo html_writer::tag('div', html_writer::table($table), array('class'=>'no-overflow'));
00145 echo $OUTPUT->footer();
00146 
 All Data Structures Namespaces Files Functions Variables Enumerations