Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/mod/chat/index.php
Go to the documentation of this file.
00001 <?php
00002 
00003 require_once('../../config.php');
00004 require_once('lib.php');
00005 
00006 $id = required_param('id', PARAM_INT);   // course
00007 
00008 $PAGE->set_url('/mod/chat/index.php', array('id'=>$id));
00009 
00010 if (! $course = $DB->get_record('course', array('id'=>$id))) {
00011     print_error('invalidcourseid');
00012 }
00013 
00014 require_course_login($course);
00015 $PAGE->set_pagelayout('incourse');
00016 
00017 add_to_log($course->id, 'chat', 'view all', "index.php?id=$course->id", '');
00018 
00019 
00021 
00022 $strsectionname = get_string('sectionname', 'format_'.$course->format);
00023 $strchats = get_string('modulenameplural', 'chat');
00024 $strchat  = get_string('modulename', 'chat');
00025 
00026 
00028 $PAGE->navbar->add($strchats);
00029 $PAGE->set_title($strchats);
00030 echo $OUTPUT->header();
00031 
00033 
00034 if (! $chats = get_all_instances_in_course('chat', $course)) {
00035     notice(get_string('thereareno', 'moodle', $strchats), "../../course/view.php?id=$course->id");
00036     die();
00037 }
00038 
00039 $usesections = course_format_uses_sections($course->format);
00040 if ($usesections) {
00041     $sections = get_all_sections($course->id);
00042 }
00043 
00045 
00046 $timenow  = time();
00047 $strname  = get_string('name');
00048 
00049 $table = new html_table();
00050 
00051 if ($usesections) {
00052     $table->head  = array ($strsectionname, $strname);
00053     $table->align = array ('center', 'left');
00054 } else {
00055     $table->head  = array ($strname);
00056     $table->align = array ('left');
00057 }
00058 
00059 $currentsection = '';
00060 foreach ($chats as $chat) {
00061     if (!$chat->visible) {
00062         //Show dimmed if the mod is hidden
00063         $link = "<a class=\"dimmed\" href=\"view.php?id=$chat->coursemodule\">".format_string($chat->name,true)."</a>";
00064     } else {
00065         //Show normal if the mod is visible
00066         $link = "<a href=\"view.php?id=$chat->coursemodule\">".format_string($chat->name,true)."</a>";
00067     }
00068     $printsection = '';
00069     if ($chat->section !== $currentsection) {
00070         if ($chat->section) {
00071             $printsection = get_section_name($course, $sections[$chat->section]);
00072         }
00073         if ($currentsection !== '') {
00074             $table->data[] = 'hr';
00075         }
00076         $currentsection = $chat->section;
00077     }
00078     if ($usesections) {
00079         $table->data[] = array ($printsection, $link);
00080     } else {
00081         $table->data[] = array ($link);
00082     }
00083 }
00084 
00085 echo '<br />';
00086 
00087 echo html_writer::table($table);
00088 
00090 
00091 echo $OUTPUT->footer();
00092 
00093 
 All Data Structures Namespaces Files Functions Variables Enumerations