Fixing Chat event type + handling illegal eventtype displaying

Without this fix, chat created events with eventtype set to boolean.
Such value was then used by calendar block to get a string, which
now produces coding_exception.
This commit is contained in:
David Mudrak
2010-04-30 10:53:39 +00:00
parent fc919723ac
commit a48bf07993
4 changed files with 17 additions and 4 deletions
+6 -1
View File
@@ -501,7 +501,12 @@ function calendar_add_event_metadata($event) {
}
$modulename = get_string('modulename', $event->modulename);
$eventtype = get_string($event->eventtype, $event->modulename);
if (get_string_manager()->string_exists($event->eventtype, $event->modulename)) {
// will be used as alt text if the event icon
$eventtype = get_string($event->eventtype, $event->modulename);
} else {
$eventtype = '';
}
$icon = $OUTPUT->pix_url('icon', $event->modulename) . '';
$event->icon = '<img height="16" width="16" src="'.$icon.'" alt="'.$eventtype.'" title="'.$modulename.'" style="vertical-align: middle;" />';
+8
View File
@@ -5968,6 +5968,10 @@ class core_string_manager implements string_manager {
* @return boot true if exists
*/
public function string_exists($identifier, $component) {
$identifier = clean_param($identifier, PARAM_STRINGID);
if (empty($identifier)) {
return false;
}
$lang = current_language();
$string = $this->load_component_strings($component, $lang);
return isset($string[$identifier]);
@@ -6293,6 +6297,10 @@ class install_string_manager implements string_manager {
* @return boot true if exists
*/
public function string_exists($identifier, $component) {
$identifier = clean_param($identifier, PARAM_STRINGID);
if (empty($identifier)) {
return false;
}
// simple old style hack ;)
$str = get_string($identifier, $component);
return (strpos($str, '[[') === false);
+2 -2
View File
@@ -120,7 +120,7 @@ function chat_add_instance($chat) {
$event->userid = 0;
$event->modulename = 'chat';
$event->instance = $returnid;
$event->eventtype = $chat->schedule;
$event->eventtype = 'chattime';
$event->timestart = $chat->chattime;
$event->timeduration = 0;
@@ -499,7 +499,7 @@ function chat_refresh_events($courseid = 0) {
$event->userid = 0;
$event->modulename = 'chat';
$event->instance = $chat->id;
$event->eventtype = $chat->schedule;
$event->eventtype = 'chattime';
$event->timeduration = 0;
$event->visible = $DB->get_field('course_modules', 'visible', array('module'=>$moduleid, 'instance'=>$chat->id));
+1 -1
View File
@@ -33,7 +33,7 @@ class mod_choice_mod_form extends moodleform_mod {
$menuoptions[1] = get_string('enable');
$mform->addElement('header', 'timerestricthdr', get_string('limit', 'choice'));
$mform->addElement('select', 'limitanswers', get_string('limitanswers', 'choice'), $menuoptions);
$mform->setHelpButton('limitanswers', array('limit', get_string('limit', 'choice'), 'choice'));
$mform->addHelpButton('limitanswers', 'choice');
if ($this->_instance){
$repeatno = $DB->count_records('choice_options', array('choiceid'=>$this->_instance));