Index: event.php =================================================================== RCS file: /cvsroot/moodle/moodle/calendar/event.php,v retrieving revision 1.112.4.1 diff -u -r1.112.4.1 event.php --- event.php 1 Mar 2012 11:16:38 -0000 1.112.4.1 +++ event.php 22 Mar 2012 16:16:22 -0000 @@ -105,13 +105,14 @@ $formoptions = new stdClass; if ($eventid !== 0) { $title = get_string('editevent', 'calendar'); - $event = calendar_event::load($eventid); + $event = calendar_event::load($eventid); if (!calendar_edit_event_allowed($event)) { print_error('nopermissions'); } $event->action = $action; $event->course = $courseid; $event->timedurationuntil = $event->timestart + $event->timeduration; + $event->timedurationminutes=$event->timeduration/60; $event->count_repeats(); if (!calendar_add_event_allowed($event)) { @@ -142,7 +143,7 @@ } else { $event->timestart = make_timestamp($cal_y, $cal_m, 1, 0, 0, 0); } - } + } $event = new calendar_event($event); if (!calendar_add_event_allowed($event)) { print_error('nopermissions'); @@ -152,10 +153,11 @@ $properties = $event->properties(true); $formoptions->event = $event; $formoptions->hasduration = ($event->timeduration > 0); +$formoptions->showdurationinminutes=($event->timeduration/60)%5>0; $mform = new event_form(null, $formoptions); $mform->set_data($properties); $data = $mform->get_data(); -if ($data) { +if ($data) { if ($data->duration == 1) { $data->timeduration = $data->timedurationuntil- $data->timestart; } else if ($data->duration == 2) { @@ -165,7 +167,7 @@ } $event->update($data); - + $params = array( 'view' => 'day', 'cal_d' => userdate($event->timestart, '%d'), Index: event_form.php =================================================================== RCS file: /cvsroot/moodle/moodle/calendar/event_form.php,v retrieving revision 1.4.6.1 diff -u -r1.4.6.1 event_form.php --- event_form.php 15 Mar 2012 11:56:22 -0000 1.4.6.1 +++ event_form.php 22 Mar 2012 16:13:40 -0000 @@ -48,7 +48,8 @@ $newevent = (empty($this->_customdata->event) || empty($this->_customdata->event->id)); $repeatedevents = (!empty($this->_customdata->event->eventrepeats) && $this->_customdata->event->eventrepeats>0); $hasduration = (!empty($this->_customdata->hasduration) && $this->_customdata->hasduration); - + $showdurationinminutes = (!empty($this->_customdata->showdurationinminutes) && $this->_customdata->showdurationinminutes); + if ($newevent) { $eventtypes = $this->_customdata->eventtypes; $options = array(); @@ -122,9 +123,16 @@ $mform->addElement('text', 'timedurationminutes', null); $mform->setType('timedurationminutes', PARAM_INT); $mform->disabledIf('timedurationminutes','duration','noteq', 2); - - $mform->setDefault('duration', ($hasduration)?1:0); - + + if($hasduration){ + if($showdurationinminutes){ + $mform->setDefault('duration', 2); + }else{ + $mform->setDefault('duration', 1); + } + }else{ + $mform->setDefault('duration', 0); + } if ($newevent) { $mform->addElement('checkbox', 'repeat', get_string('repeatevent', 'calendar'), null, 'repeat');