MDL-50892 mod: allow activity to have name '0'

This commit is contained in:
Marina Glancy 2015-08-12 11:48:43 +08:00
parent 36750a2872
commit 355e943c4b
8 changed files with 8 additions and 8 deletions

View file

@ -212,7 +212,7 @@ if (!empty($activities)) {
echo $OUTPUT->spacer(array('height'=>30, 'br'=>true)); // should be done with CSS instead echo $OUTPUT->spacer(array('height'=>30, 'br'=>true)); // should be done with CSS instead
} }
echo $OUTPUT->box_start(); echo $OUTPUT->box_start();
if (!empty($activity->name)) { if (strval($activity->name) !== '') {
echo html_writer::tag('h2', $activity->name); echo html_writer::tag('h2', $activity->name);
} }
$inbox = true; $inbox = true;

View file

@ -173,7 +173,7 @@ switch($requestmethod) {
$module->name = clean_param($title, PARAM_CLEANHTML); $module->name = clean_param($title, PARAM_CLEANHTML);
} }
if (!empty($module->name)) { if (strval($module->name) !== '') {
$DB->update_record($cm->modname, $module); $DB->update_record($cm->modname, $module);
$cm->name = $module->name; $cm->name = $module->name;
\core\event\course_module_updated::create_from_cm($cm, $modcontext)->trigger(); \core\event\course_module_updated::create_from_cm($cm, $modcontext)->trigger();

View file

@ -185,7 +185,7 @@ class grading_manager {
} else if ($this->get_context()->contextlevel >= CONTEXT_COURSE) { } else if ($this->get_context()->contextlevel >= CONTEXT_COURSE) {
list($context, $course, $cm) = get_context_info_array($this->get_context()->id); list($context, $course, $cm) = get_context_info_array($this->get_context()->id);
if (!empty($cm->name)) { if (strval($cm->name) !== '') {
$title = $cm->name; $title = $cm->name;
} else { } else {
debugging('Gradable areas are currently supported at the course module level only', DEBUG_DEVELOPER); debugging('Gradable areas are currently supported at the course module level only', DEBUG_DEVELOPER);

View file

@ -104,7 +104,7 @@ class calendar_event_created extends base {
if (!isset($this->other['repeatid'])) { if (!isset($this->other['repeatid'])) {
throw new \coding_exception('The \'repeatid\' value must be set in other.'); throw new \coding_exception('The \'repeatid\' value must be set in other.');
} }
if (empty($this->other['name'])) { if (!isset($this->other['name'])) {
throw new \coding_exception('The \'name\' value must be set in other.'); throw new \coding_exception('The \'name\' value must be set in other.');
} }
if (!isset($this->other['timestart'])) { if (!isset($this->other['timestart'])) {

View file

@ -85,7 +85,7 @@ class calendar_event_deleted extends base {
if (!isset($this->other['repeatid'])) { if (!isset($this->other['repeatid'])) {
throw new \coding_exception('The \'repeatid\' value must be set in other.'); throw new \coding_exception('The \'repeatid\' value must be set in other.');
} }
if (empty($this->other['name'])) { if (!isset($this->other['name'])) {
throw new \coding_exception('The \'name\' value must be set in other.'); throw new \coding_exception('The \'name\' value must be set in other.');
} }
if (!isset($this->other['timestart'])) { if (!isset($this->other['timestart'])) {

View file

@ -103,7 +103,7 @@ class calendar_event_updated extends base {
if (!isset($this->other['repeatid'])) { if (!isset($this->other['repeatid'])) {
throw new \coding_exception('The \'repeatid\' value must be set in other.'); throw new \coding_exception('The \'repeatid\' value must be set in other.');
} }
if (empty($this->other['name'])) { if (!isset($this->other['name'])) {
throw new \coding_exception('The \'name\' value must be set in other.'); throw new \coding_exception('The \'name\' value must be set in other.');
} }
if (!isset($this->other['timestart'])) { if (!isset($this->other['timestart'])) {

View file

@ -1290,7 +1290,7 @@ class grade_item extends grade_object {
* @return string name * @return string name
*/ */
public function get_name($fulltotal=false) { public function get_name($fulltotal=false) {
if (!empty($this->itemname)) { if (strval($this->itemname) !== '') {
// MDL-10557 // MDL-10557
return format_string($this->itemname); return format_string($this->itemname);

View file

@ -492,7 +492,7 @@ class course_modinfo {
// Loop through each piece of module data, constructing it // Loop through each piece of module data, constructing it
static $modexists = array(); static $modexists = array();
foreach ($coursemodinfo->modinfo as $mod) { foreach ($coursemodinfo->modinfo as $mod) {
if (empty($mod->name)) { if (strval($mod->name) === '') {
// something is wrong here // something is wrong here
continue; continue;
} }