// and so the next 86400 seconds worth of logs are printed.
/// Setup for group handling.
-
+
/// If the group mode is separate, and this user does not have editing privileges,
/// then only the user's group can be viewed.
if ($course->groupmode == SEPARATEGROUPS and !has_capability('moodle/course:managegroups', get_context_instance(CONTEXT_COURSE, $course->id))) {
}
$totalcount = 0; // Initialise
-
+
$result = array();
$result['logs'] = get_logs($selector, $order, $limitfrom, $limitnum, $totalcount);
$result['totalcount'] = $totalcount;
return $result;
}
-
-
+
+
function print_log($course, $user=0, $date=0, $order="l.time ASC", $page=0, $perpage=100,
$url="", $modname="", $modid=0, $modaction="", $groupid=0) {
-
+
global $CFG;
-
+
if (!$logs = build_logs_array($course, $user, $date, $order, $page*$perpage, $perpage,
$modname, $modid, $modaction, $groupid)) {
notify("No logs found!");
print_footer($course);
exit;
}
-
+
if ($course->id == SITEID) {
$courses[0] = '';
if ($ccc = get_courses('all', 'c.id ASC', 'c.id,c.shortname,c.visible')) {
}
}
}
-
+
$totalcount = $logs['totalcount'];
$count=0;
$ldcache = array();
}
}
- //Filter log->info
+ //Filter log->info
$log->info = format_string($log->info);
$log->url = strip_tags(urldecode($log->url)); // Some XSS protection
$text = get_string('course')."\t".get_string('time')."\t".get_string('ip_address')."\t".
get_string('fullname')."\t".get_string('action')."\t".get_string('info');
-
+
if (!$logs = build_logs_array($course, $user, $date, $order, '', '',
$modname, $modid, $modaction, $groupid)) {
return false;
}
-
+
if ($course->id == SITEID) {
$courses[0] = '';
if ($ccc = get_courses('all', 'c.id ASC', 'c.id,c.shortname')) {
}
}
}
-
+
$count=0;
$ldcache = array();
$tt = getdate(time());
$filename = 'logs_'.userdate(time(),get_string('backupnameformat'),99,false);
$filename .= '.txt';
- header("Content-Type: application/download\n");
+ header("Content-Type: application/download\n");
header("Content-Disposition: attachment; filename=$filename");
header("Expires: 0");
header("Cache-Control: must-revalidate,post-check=0,pre-check=0");
}
}
- //Filter log->info
+ //Filter log->info
$log->info = format_string($log->info);
$log->url = strip_tags(urldecode($log->url)); // Some XSS protection
function print_log_xls($course, $user, $date, $order='l.time DESC', $modname,
$modid, $modaction, $groupid) {
-
+
global $CFG;
require_once("$CFG->libdir/excellib.class.php");
-
+
if (!$logs = build_logs_array($course, $user, $date, $order, '', '',
$modname, $modid, $modaction, $groupid)) {
return false;
}
-
+
if ($course->id == SITEID) {
$courses[0] = '';
if ($ccc = get_courses('all', 'c.id ASC', 'c.id,c.shortname')) {
}
}
}
-
+
$count=0;
$ldcache = array();
$tt = getdate(time());
$nroPages = ceil(count($logs)/(EXCELROWS-FIRSTUSEDEXCELROW+1));
$filename = 'logs_'.userdate(time(),get_string('backupnameformat'),99,false);
$filename .= '.xls';
-
+
$workbook = new MoodleExcelWorkbook('-');
$workbook->send($filename);
-
+
$worksheet = array();
$headers = array(get_string('course'), get_string('time'), get_string('ip_address'),
get_string('fullname'), get_string('action'), get_string('info'));
-
+
// Creating worksheets
for ($wsnumber = 1; $wsnumber <= $nroPages; $wsnumber++) {
$sheettitle = get_string('excel_sheettitle', 'logs', $wsnumber).$nroPages;
$row = FIRSTUSEDEXCELROW;
}
}
-
+
$myxls->write($row, 0, $courses[$log->course], '');
// Excel counts from 1/1/1900
$excelTime=25569+$log->time/(3600*24);
$myxls->write($row, 3, $fullname, '');
$myxls->write($row, 4, $log->module.' '.$log->action, '');
$myxls->write($row, 5, $log->info, '');
-
+
$row++;
}
function print_log_ooo($course, $user, $date, $order='l.time DESC', $modname,
$modid, $modaction, $groupid) {
-
+
global $CFG;
require_once($CFG->libdir.'/phpdocwriter/lib/include.php');
-
+
if (!$logs = build_logs_array($course, $user, $date, $order, '', '',
$modname, $modid, $modaction, $groupid)) {
return false;
}
-
+
if ($course->id == SITEID) {
$courses[0] = '';
if ($ccc = get_courses('all', 'c.id ASC', 'c.id,c.shortname')) {
}
}
}
-
+
$count=0;
$ldcache = array();
$tt = getdate(time());
$sxw->AddPageDef(array('name'=>'Standard', 'margins'=>'1,1,1,1', 'w'=>'29.7', 'h'=>'21'));
$sxw->Write(get_string('savedat').userdate(time(), $strftimedatetime));
$sxw->Ln(3);
-
+
$headers = array(get_string('course'), get_string('time'), get_string('ip_address'),
get_string('fullname'), get_string('action'), get_string('info'));
-
+
foreach($headers as $key=>$header){
$headers[$key] = eregi_replace ("<br?>", " ",$header);
}
}
}
- // Filter log->info
+ // Filter log->info
$log->info = format_string($log->info);
$log->url = strip_tags(urldecode($log->url)); // Some XSS protection
}
$sxw->Table($headers,$data);
$sxw->Output();
-
+
return true;
}
*/
if ($users) {
echo '<div class="newusers">';
if (! $heading) {
- print_headline(get_string("newusers").':', 3);
+ print_headline(get_string("newusers").':', 3);
$heading = true;
$content = true;
}
echo "<ol class=\"list\">\n";
foreach ($users as $user) {
-
+
$fullname = fullname($user, has_capability('moodle/site:viewfullnames', get_context_instance(CONTEXT_COURSE, $course->id)));
echo '<li class="name"><a href="'.$CFG->wwwroot."/user/view.php?id=$user->id&course=$course->id\">$fullname</a></li>\n";
}
}
} elseif ($ismoving) {
echo "<ul class=\"section\">\n";
- }
+ }
if ($ismoving) {
echo '<li><a title="'.$strmovefull.'"'.
' href="'.$CFG->wwwroot.'/course/mod.php?movetosection='.$section->id.'&sesskey='.$USER->sesskey.'">'.
if (!course_allowed_module($course,$key))
unset($modnames[$key]);
}
-
+
// this is stupid but labels get put into resource, so if resource is hidden and label is not, we're in trouble.
if (course_allowed_module($course,'label') && empty($resourceallowed)) {
$modnames['label'] = get_string('modulename', 'label');
// initialize the arrays if needed
if (!is_array($list)) {
- $list = array();
+ $list = array();
}
if (!is_array($parents)) {
- $parents = array();
+ $parents = array();
}
if ($category) {
$linkcss.' href="'.$CFG->wwwroot.'/course/view.php?id='.$course->id.'">'.
$course->fullname.'</a></b><br />';
- if ($teachers = get_users_by_capability($context, 'moodle/course:update',
- 'u.*, ul.timeaccess as lastaccess, ra.hidden',
+ if ($teachers = get_users_by_capability($context, 'moodle/course:update',
+ 'u.*, ul.timeaccess as lastaccess, ra.hidden',
'r.sortorder ASC', '','','','', false)) {
$canseehidden = has_capability('moodle/role:viewhiddenassigns', $context);
$namesarray = array();
/*
* Delete a course module and any associated data at the course level (events)
- * Until 1.5 this function simply marked a deleted flag ... now it
+ * Until 1.5 this function simply marked a deleted flag ... now it
* deletes it completely.
*
*/
}
/**
- * given a course object with shortname & fullname, this function will
+ * given a course object with shortname & fullname, this function will
* truncate the the number of chars allowed and add ... if it was too long
*/
function course_format_name ($course,$max=100) {
-
+
$str = $course->shortname.': '.$course->fullname;
if (strlen($str) <= $max) {
return $str;
if ($hiddensection) {
$visible = false;
}
-
+
echo '<tr valign="top">';
echo '<td align="right"><b>'.get_string('visible', '').':</b></td>';
echo '<td align="left">';
$choices[0] = get_string('hide');
choose_from_menu($choices, 'visible', $visible, '', '', 0, false, $hiddensection);
echo '</td></tr>';
-}
+}
function update_restricted_mods($course,$mods) {
delete_records("course_allowed_modules","course",$course->id);
/**
* This function will take an int (module id) or a string (module name)
* and return true or false, whether it's allowed in the given course (object)
- * $mod is not allowed to be an object, as the field for the module id is inconsistent
+ * $mod is not allowed to be an object, as the field for the module id is inconsistent
* depending on where in the code it's called from (sometimes $mod->id, sometimes $mod->module)
*/
if (empty($course->restrictmodules)) {
return true;
}
-
+
// i am not sure this capability is correct
if (has_capability('moodle/course:update', get_context_instance(CONTEXT_SYSTEM, SITEID))) {
return true;
/***
*** Efficiently moves many courses around while maintaining
*** sortorder in order.
- ***
+ ***
*** $courseids is an array of course ids
***
**/
global $CFG;
if (!empty($courseids)) {
-
- $courseids = array_reverse($courseids);
+
+ $courseids = array_reverse($courseids);
foreach ($courseids as $courseid) {
-
+
if (! $course = get_record("course", "id", $courseid)) {
notify("Error finding course $courseid");
} else {
if ($sortorder === false) {
// the category is empty
// rather than let the db default to 0
- // set it to > 100 and avoid extra work in fix_coursesortorder()
+ // set it to > 100 and avoid extra work in fix_coursesortorder()
$sortorder = 200;
} else if ($sortorder < 10) {
fix_course_sortorder($categoryid);
$course->teachers = addslashes($course->teachers);
$course->student = addslashes($course->student);
$course->students = addslashes($course->students);
-
+
if (!update_record('course', $course)) {
notify("An error occurred - course not moved!");
}
}
}
fix_course_sortorder();
- }
+ }
return true;
}
}
}
+ //check if we are adding / editing a module that has new forms using formslib
+ if (!empty($add)){
+ $modname=$add;
+ if (file_exists("../mod/$modname/mod_form.php")) {
+ $id = required_param('id',PARAM_INT);
+ $section = required_param('section',PARAM_INT);
+
+ redirect("modedit.php?add=$add&course=$id§ion=$section");
+ }
+ }elseif (!empty($update)){
+ if (!$modname=get_field_sql("SELECT md.name
+ FROM {$CFG->prefix}course_modules cm,
+ {$CFG->prefix}modules md
+ WHERE cm.id = '$update' AND
+ md.id = cm.module")){
+ error('Invalid course module id!');
+ }
+ if (file_exists("../mod/$modname/mod_form.php")) {
+ redirect("modedit.php?update=$update");
+ }
+ }
+ //not adding / editing a module that has new forms using formslib
+ //carry on
- if (!empty($course) and confirm_sesskey()) { // add or update form submitted
+ if (!empty($course) and confirm_sesskey()) { // add, delete or update form submitted
if (empty($mod->coursemodule)) { //add
if (! $course = get_record("course", "id", $mod->course)) {
require_login($course->id); // needed to setup proper $COURSE
$context = get_context_instance(CONTEXT_COURSE, $course->id);
require_capability('moodle/course:manageactivities', $context);
-
+
$mod->course = $course->id;
$mod->modulename = clean_param($mod->modulename, PARAM_SAFEDIR); // For safety
$modlib = "$CFG->dirroot/mod/$mod->modulename/lib.php";
require_login($cm->course); // needed to setup proper $COURSE
$context = get_context_instance(CONTEXT_COURSE, $cm->course);
require_capability('moodle/course:manageactivities', $context);
-
+
if (! $module = get_record("modules", "id", $cm->module)) {
error("This module doesn't exist");
}
$pageheading = get_string("updatinga", "moodle", $fullmodulename);
}
$strnav = "<a href=\"$CFG->wwwroot/mod/$module->name/view.php?id=$cm->id\">".format_string($form->name,true)."</a> ->";
-
+
if ($module->name == 'resource') {
$CFG->pagepath = 'mod/'.$module->name.'/'.$form->type;
} else {
require_login($course->id); // needed to setup proper $COURSE
$context = get_context_instance(CONTEXT_COURSE, $course->id);
require_capability('moodle/course:manageactivities', $context);
-
+
if (! $module = get_record("modules", "id", $cm->module)) {
error("This module doesn't exist");
}
if (! $module = get_record("modules", "name", $add)) {
error("This module type doesn't exist");
}
-
+
$context = get_context_instance(CONTEXT_COURSE, $course->id);
require_capability('moodle/course:manageactivities', $context);
-
+
if (!course_allowed_module($course,$module->id)) {
error("This module has been disabled for this particular course");
}
--- /dev/null
+<?php // $Id$
+
+// adds or updates modules in a course using new formslib
+
+ require("../config.php");
+ require("lib.php");
+
+ require_login();
+
+ $add = optional_param('add', '', PARAM_ALPHA);
+ $update = optional_param('update', 0, PARAM_INT);
+
+ if (!empty($add)){
+ $section = required_param('section', PARAM_INT);
+ $course = required_param('course', PARAM_INT);
+
+ if (! $course = get_record("course", "id", $course)) {
+ error("This course doesn't exist");
+ }
+
+ if (! $module = get_record("modules", "name", $add)) {
+ error("This module type doesn't exist");
+ }
+
+ $context = get_context_instance(CONTEXT_COURSE, $course->id);
+ require_capability('moodle/course:manageactivities', $context);
+
+ if (!course_allowed_module($course, $module->id)) {
+ error("This module has been disabled for this particular course");
+ }
+
+ require_login($course->id); // needed to setup proper $COURSE
+
+ $form->section = $section; // The section number itself
+ $form->course = $course->id;
+ $form->module = $module->id;
+ $form->modulename = $module->name;
+ $form->instance = "";
+ $form->coursemodule = "";
+ $form->add=$add;
+ if (!empty($type)) {
+ $form->type = $type;
+ }
+
+ $sectionname = get_string("name$course->format");
+ $fullmodulename = get_string("modulename", $module->name);
+
+ if ($form->section && $course->format != 'site') {
+ $heading->what = $fullmodulename;
+ $heading->to = "$sectionname $form->section";
+ $pageheading = get_string("addinganewto", "moodle", $heading);
+ } else {
+ $pageheading = get_string("addinganew", "moodle", $fullmodulename);
+ }
+ $strnav = '';
+
+ }elseif (!empty($update)){
+ if (! $cm = get_record("course_modules", "id", $update)) {
+ error("This course module doesn't exist");
+ }
+
+ if (! $course = get_record("course", "id", $cm->course)) {
+ error("This course doesn't exist");
+ }
+
+ require_login($course->id); // needed to setup proper $COURSE
+ $context = get_context_instance(CONTEXT_COURSE, $course->id);
+ require_capability('moodle/course:manageactivities', $context);
+
+ if (! $module = get_record("modules", "id", $cm->module)) {
+ error("This module doesn't exist");
+ }
+
+ if (! $form = get_record($module->name, "id", $cm->instance)) {
+ error("The required instance of this module doesn't exist");
+ }
+
+ if (! $cw = get_record("course_sections", "id", $cm->section)) {
+ error("This course section doesn't exist");
+ }
+
+
+ $form->coursemodule = $cm->id;
+ $form->section = $cm->section; // The section ID
+ $form->course = $course->id;
+ $form->module = $module->id;
+ $form->modulename = $module->name;
+ $form->instance = $cm->instance;
+ $form->update=$update;
+
+ $sectionname = get_string("name$course->format");
+ $fullmodulename = get_string("modulename", $module->name);
+
+ if ($form->section && $course->format != 'site') {
+ $heading->what = $fullmodulename;
+ $heading->in = "$sectionname $cw->section";
+ $pageheading = get_string("updatingain", "moodle", $heading);
+ } else {
+ $pageheading = get_string("updatinga", "moodle", $fullmodulename);
+ }
+ $strnav = "<a href=\"$CFG->wwwroot/mod/$module->name/view.php?id=$cm->id\">".format_string($form->name,true)."</a> ->";
+ }else{
+ error('Invalid operation.');
+ }
+
+ $modmoodleform = "../mod/$module->name/mod_form.php";
+ if (file_exists($modmoodleform)) {
+ require_once($modmoodleform);
+ $mformclassname=$module->name.'_mod_form';
+ $mform=& new $mformclassname('modedit.php');
+
+ }else{
+ error('No formslib form description file found for this activity.');
+ }
+ if ($fromform=$mform->data_submitted()){
+ if (empty($fromform->coursemodule)) { //add
+ if (! $course = get_record("course", "id", $fromform->course)) {
+ error("This course doesn't exist");
+ }
+ $fromform->instance = '';
+ $fromform->coursemodule = '';
+ } else { //update
+ if (! $cm = get_record("course_modules", "id", $fromform->coursemodule)) {
+ error("This course module doesn't exist");
+ }
+
+ if (! $course = get_record("course", "id", $cm->course)) {
+ error("This course doesn't exist");
+ }
+ $fromform->instance = $cm->instance;
+ $fromform->coursemodule = $cm->id;
+ }
+
+ require_login($course->id); // needed to setup proper $COURSE
+ $context = get_context_instance(CONTEXT_COURSE, $course->id);
+ require_capability('moodle/course:manageactivities', $context);
+
+ $fromform->course = $course->id;
+ $fromform->modulename = clean_param($fromform->modulename, PARAM_SAFEDIR); // For safety
+ $modlib = "$CFG->dirroot/mod/$fromform->modulename/lib.php";
+
+ if (file_exists($modlib)) {
+ include_once($modlib);
+ } else {
+ error("This module is missing important code! ($modlib)");
+ }
+ $addinstancefunction = $fromform->modulename."_add_instance";
+ $updateinstancefunction = $fromform->modulename."_update_instance";
+
+ if (!empty($fromform->update)) {
+
+
+ if (isset($fromform->name)) {
+ if (trim($fromform->name) == '') {
+ unset($fromform->name);
+ }
+ }
+
+ $return = $updateinstancefunction($fromform);
+ if (!$return) {
+ error("Could not update the $fromform->modulename", "view.php?id=$course->id");
+ }
+ if (is_string($return)) {
+ error($return, "view.php?id=$course->id");
+ }
+
+ if (isset($fromform->visible)) {
+ set_coursemodule_visible($fromform->coursemodule, $fromform->visible);
+ }
+
+ if (isset($fromform->groupmode)) {
+ set_coursemodule_groupmode($fromform->coursemodule, $fromform->groupmode);
+ }
+
+ if (isset($fromform->redirect)) {
+ $SESSION->returnpage = $fromform->redirecturl;
+ } else {
+ $SESSION->returnpage = "$CFG->wwwroot/mod/$fromform->modulename/view.php?id=$fromform->coursemodule";
+ }
+
+ add_to_log($course->id, "course", "update mod",
+ "../mod/$fromform->modulename/view.php?id=$fromform->coursemodule",
+ "$fromform->modulename $fromform->instance");
+ add_to_log($course->id, $fromform->modulename, "update",
+ "view.php?id=$fromform->coursemodule",
+ "$fromform->instance", $fromform->coursemodule);
+ }elseif (!empty($fromform->add)){
+
+ if (!course_allowed_module($course,$fromform->modulename)) {
+ error("This module ($fromform->modulename) has been disabled for this particular course");
+ }
+
+ if (!isset($fromform->name) || trim($fromform->name) == '') {
+ $fromform->name = get_string("modulename", $fromform->modulename);
+ }
+
+ $return = $addinstancefunction($fromform);
+ if (!$return) {
+ /*if (file_exists($moderr)) {
+ $form = $fromform;
+ include_once($moderr);
+ die;
+ }*/
+ error("Could not add a new instance of $fromform->modulename", "view.php?id=$course->id");
+ }
+ if (is_string($return)) {
+ error($return, "view.php?id=$course->id");
+ }
+
+ if (!isset($fromform->groupmode)) { // to deal with pre-1.5 modules
+ $fromform->groupmode = $course->groupmode; /// Default groupmode the same as course
+ }
+
+ $fromform->instance = $return;
+
+ // course_modules and course_sections each contain a reference
+ // to each other, so we have to update one of them twice.
+
+ if (! $fromform->coursemodule = add_course_module($fromform) ) {
+ error("Could not add a new course module");
+ }
+ if (! $sectionid = add_mod_to_section($fromform) ) {
+ error("Could not add the new course module to that section");
+ }
+
+ if (! set_field("course_modules", "section", $sectionid, "id", $fromform->coursemodule)) {
+ error("Could not update the course module with the correct section");
+ }
+
+ if (!isset($fromform->visible)) { // We get the section's visible field status
+ $fromform->visible = get_field("course_sections","visible","id",$sectionid);
+ }
+ // make sure visibility is set correctly (in particular in calendar)
+ set_coursemodule_visible($fromform->coursemodule, $fromform->visible);
+
+ if (isset($fromform->redirect)) {
+ $SESSION->returnpage = $fromform->redirecturl;
+ } else {
+ $SESSION->returnpage = "$CFG->wwwroot/mod/$fromform->modulename/view.php?id=$fromform->coursemodule";
+ }
+
+ add_to_log($course->id, "course", "add mod",
+ "../mod/$fromform->modulename/view.php?id=$fromform->coursemodule",
+ "$fromform->modulename $fromform->instance");
+ add_to_log($course->id, $fromform->modulename, "add",
+ "view.php?id=$fromform->coursemodule",
+ "$fromform->instance", $fromform->coursemodule);
+ }else{
+ error("Data submitted is invalid.");
+ }
+
+ rebuild_course_cache($course->id);
+
+ if (!empty($SESSION->returnpage)) {
+ $return = $SESSION->returnpage;
+ unset($SESSION->returnpage);
+ redirect($return);
+ } else {
+ redirect("view.php?id=$course->id#section-$sectionreturn");
+ }
+ exit;
+
+ }else{
+ $context = get_context_instance(CONTEXT_COURSE, $course->id);
+ require_capability('moodle/course:manageactivities', $context);
+
+ $streditinga = get_string("editinga", "moodle", $fullmodulename);
+ $strmodulenameplural = get_string("modulenameplural", $module->name);
+
+ print_header_simple($streditinga, '',
+ "<a href=\"$CFG->wwwroot/mod/$module->name/index.php?id=$course->id\">$strmodulenameplural</a> ->
+ $strnav $streditinga", $mform->focus(), "", false);
+
+ if (!empty($cm->id)) {
+ $context = get_context_instance(CONTEXT_MODULE, $cm->id);
+ $currenttab = 'update';
+ include_once($CFG->dirroot.'/'.$CFG->admin.'/roles/tabs.php');
+ }
+ $icon = '<img align="middle" height="16" width="16" src="'.$CFG->modpixpath.'/'.$module->name.'/icon.gif" alt="" style="vertical-align: middle;" /> ';
+
+ print_heading_with_help($pageheading, "mods", $module->name, $icon);
+ $mform->standard_coursemodule_elements_setup($course, isset($cm)?$cm:null, $form->section);
+ $mform->set_defaults($form);
+ $mform->display();
+ print_footer($course);
+ }
+?>
\ No newline at end of file
$string['nonexistentformelements'] = 'Trying to add help buttons to nonexistent form elements : $a';
$string['requiredelement'] = 'Required field.';
$string['general'] = 'General Settings';
-
+$string['modstandardels']='Common Module Settings';
?>
$chat->timemodified = time();
- $chat->chattime = make_timestamp($chat->chatyear, $chat->chatmonth, $chat->chatday,
- $chat->chathour, $chat->chatminute);
-
if ($returnid = insert_record("chat", $chat)) {
$event = NULL;
$chat->timemodified = time();
$chat->id = $chat->instance;
- $chat->chattime = make_timestamp($chat->chatyear, $chat->chatmonth, $chat->chatday,
- $chat->chathour, $chat->chatminute);
if ($returnid = update_record("chat", $chat)) {
- $event = NULL;
+ $event = new object();
if ($event->id = get_field('event', 'id', 'modulename', 'chat', 'instance', $chat->id)) {
$current = 0;
}
if ($chat = get_record('chat', 'id', $chatuser->chatid)) {
-
+
// we find the course module id
$cm = get_coursemodule_from_instance('chat', $chat->id, $course->id);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
-
+
// needs to be fixed
if (!(has_capability('mod/chat:readlog', $context) or instance_is_visible('chat', $chat))) { // Chat hidden to students
continue;
$text = format_text($text, FORMAT_MOODLE, $options, $courseid);
// And now check for special cases
if (substr($text, 0, 5) == 'beep ') {
- /// It's a beep!
+ /// It's a beep!
$beepwho = trim(substr($text, 5));
if ($beepwho == 'all') { // everyone
$outinfo = $message->strtime.': '.get_string('messagebeepsyou', 'chat', fullname($sender));
$outmain = '';
$output->beep = true;
-
+
} else { //something is not caught?
return false;
}
$outinfo = $message->strtime.' '.$sender->firstname;
$outmain = $text;
}
-
+
/// Format the message as a small table
$output->text = strip_tags($outinfo.': '.$outmain);
+++ /dev/null
-<?php // $Id$
- if (!isset($form->name)) {
- $form->name = '';
- }
- if (!isset($form->intro)) {
- $form->intro = '';
- }
- if (!isset($form->keepdays)) {
- $form->keepdays = 30;
- }
- if (!isset($form->studentlogs)) {
- $form->studentlogs = 0;
- }
- if (!isset($form->chattime)) {
- $form->chattime = 0;
- }
- if (!isset($form->schedule)) {
- $form->schedule = 0;
- }
-?>
-<form name="form" method="post" action="mod.php">
-<table cellpadding="5">
-<tr valign="top">
- <td align="right"><b><?php print_string('chatname', 'chat')?>:</b></td>
- <td>
- <input type="text" name="name" size="30" value="<?php p($form->name) ?>" alt="<?php print_string('chatname', 'chat') ?>" />
- </td>
-</tr>
-<tr valign="top">
- <td align="right"><b><?php print_string('chatintro', 'chat')?>:</b><br /><br />
- <?php
- helpbutton('writing', get_string('helpwriting'), 'moodle', true, true);
- echo '<br />';
- helpbutton('questions', get_string('helpquestions'), 'moodle', true, true);
- echo '<br />';
- emoticonhelpbutton('form', 'intro');
- echo '<br />';
- ?>
- </td>
- <td>
- <?php print_textarea($usehtmleditor, 20, 50, 680, 400, 'intro', $form->intro); ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right"><b><?php print_string('chattime', 'chat') ?>:</b></td>
- <td><?php
- print_date_selector('chatday', 'chatmonth', 'chatyear', $form->chattime);
- echo ' - ';
- print_time_selector('chathour', 'chatminute', $form->chattime);
- ?></td>
-</tr>
-<tr valign="top">
- <td align="right"><b><?php print_string('repeattimes', 'chat') ?>:</b></td>
- <td><?php
- unset($options);
- $options[0] = get_string('donotusechattime', 'chat');
- $options[1] = get_string('repeatnone', 'chat');
- $options[2] = get_string('repeatdaily', 'chat');
- $options[3] = get_string('repeatweekly', 'chat');
- choose_from_menu ($options, 'schedule', $form->schedule, '', '', '');
- ?></td>
-</tr>
-<tr valign="top">
- <td align="right"><b><?php print_string('savemessages', 'chat')?>:</b></td>
- <td>
- <?php
- unset($options);
- $options[0] = get_string('neverdeletemessages', 'chat');
- $options[365] = get_string('numdays', '', 365);
- $options[180] = get_string('numdays', '', 180);
- $options[150] = get_string('numdays', '', 150);
- $options[120] = get_string('numdays', '', 120);
- $options[90] = get_string('numdays', '', 90);
- $options[60] = get_string('numdays', '', 60);
- $options[30] = get_string('numdays', '', 30);
- $options[21] = get_string('numdays', '', 21);
- $options[14] = get_string('numdays', '', 14);
- $options[7] = get_string('numdays', '', 7);
- $options[2] = get_string('numdays', '', 2);
-
- choose_from_menu ($options, 'keepdays', $form->keepdays, '', '', '');
- ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right"><b><?php print_string('studentseereports', 'chat')?>:</b></td>
- <td>
- <?php
- unset($options);
- $options[0] = get_string('no');
- $options[1] = get_string('yes');
- choose_from_menu ($options, 'studentlogs', $form->studentlogs, '', '', '');
- ?>
- </td>
-</tr>
-<?php print_standard_coursemodule_settings($form); ?>
-</table>
-<center>
-<input type="hidden" name="course" value="<?php p($form->course) ?>" />
-<input type="hidden" name="sesskey" value="<?php p($form->sesskey) ?>" />
-<input type="hidden" name="coursemodule" value="<?php p($form->coursemodule) ?>" />
-<input type="hidden" name="section" value="<?php p($form->section) ?>" />
-<input type="hidden" name="module" value="<?php p($form->module) ?>" />
-<input type="hidden" name="modulename" value="<?php p($form->modulename) ?>" />
-<input type="hidden" name="instance" value="<?php p($form->instance) ?>" />
-<input type="hidden" name="mode" value="<?php p($form->mode) ?>" />
-<input type="submit" value="<?php print_string('savechanges') ?>" />
-<input type="submit" name="cancel" value="<?php print_string('cancel') ?>" />
-</center>
-</form>
\ No newline at end of file
--- /dev/null
+<?php
+require_once ($CFG->libdir.'/formslib.php');
+class chat_mod_form extends moodleform_mod {
+
+ function definition() {
+
+ global $CFG;
+ $mform =& $this->_form;
+ $renderer =& $mform->defaultRenderer();
+
+//-------------------------------------------------------------------------------
+ $mform->addElement('header', 'general', get_string('general', 'form'));
+
+ $mform->addElement('text', 'name', get_string('chatname', 'chat'));
+ $mform->setType('name', PARAM_TEXT);
+ $mform->addRule('name', null, 'required', null, 'client');
+
+ $mform->addElement('htmleditor', 'intro', get_string('chatintro', 'chat'));
+ $mform->setType('intro', PARAM_RAW);
+ $mform->addRule('intro', get_string('required'), 'required', null, 'client');
+
+ $mform->addElement('date_time_selector', 'chattime', get_string('chattime', 'chat'));
+
+ $options=array();
+ $options[0] = get_string('donotusechattime', 'chat');
+ $options[1] = get_string('repeatnone', 'chat');
+ $options[2] = get_string('repeatdaily', 'chat');
+ $options[3] = get_string('repeatweekly', 'chat');
+ $mform->addElement('select', 'schedule', get_string('repeattimes', 'chat'), $options);
+
+
+ $options=array();
+ $options[0] = get_string('neverdeletemessages', 'chat');
+ $options[365] = get_string('numdays', '', 365);
+ $options[180] = get_string('numdays', '', 180);
+ $options[150] = get_string('numdays', '', 150);
+ $options[120] = get_string('numdays', '', 120);
+ $options[90] = get_string('numdays', '', 90);
+ $options[60] = get_string('numdays', '', 60);
+ $options[30] = get_string('numdays', '', 30);
+ $options[21] = get_string('numdays', '', 21);
+ $options[14] = get_string('numdays', '', 14);
+ $options[7] = get_string('numdays', '', 7);
+ $options[2] = get_string('numdays', '', 2);
+ $mform->addElement('select', 'keepdays', get_string('savemessages', 'chat'), $options);
+
+ $options=array();
+ $options[0] = get_string('no');
+ $options[1] = get_string('yes');
+ $mform->addElement('select', 'studentlogs', get_string('studentseereports', 'chat'), $options);
+
+ $this->standard_coursemodule_elements();
+
+ $buttonarray=array();
+ $buttonarray[] = &MoodleQuickForm::createElement('submit', 'submit', get_string('savechanges'));
+ $buttonarray[] = &MoodleQuickForm::createElement('submit', 'cancel', get_string('cancel'));
+ $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false);
+ $renderer->addStopFieldsetElements('buttonar');
+ }
+
+
+
+}
+?>
\ No newline at end of file