added defaults for when there is no submitted data to datetimeselector and small fix for forum\mod_form.php
This commit is contained in:
@@ -157,24 +157,26 @@ class MoodleQuickForm_date_time_selector extends MoodleQuickForm_group{
|
||||
$valuearray = array();
|
||||
foreach ($this->_elements as $element){
|
||||
$thisexport = $element->exportValue($submitValues[$this->getName()], true);
|
||||
if ($thisexport!=null){
|
||||
if ($thisexport!==null){
|
||||
$valuearray += $thisexport;
|
||||
}
|
||||
}
|
||||
if (count($valuearray)){
|
||||
$value[$this->getName()]=make_timestamp($valuearray['year'],
|
||||
$valuearray['month'],
|
||||
$valuearray['day'],
|
||||
$valuearray['hour'],
|
||||
$valuearray['minute'],
|
||||
0,
|
||||
$this->_options['timezone'],
|
||||
$this->_options['applydst']);
|
||||
|
||||
return $value;
|
||||
} else {
|
||||
if (count($valuearray)==0){
|
||||
return null;
|
||||
}
|
||||
|
||||
$valuearray=$valuearray + array('year'=>1970, 'month'=>1, 'day'=>1, 'hour'=>0, 'minute'=>0);
|
||||
$value[$this->getName()]=make_timestamp(
|
||||
$valuearray['year'],
|
||||
$valuearray['month'],
|
||||
$valuearray['day'],
|
||||
$valuearray['hour'],
|
||||
$valuearray['minute'],
|
||||
0,
|
||||
$this->_options['timezone'],
|
||||
$this->_options['applydst']);
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
// }}}
|
||||
|
||||
+11
-7
@@ -148,14 +148,18 @@ class forum_mod_form extends moodleform_mod {
|
||||
$type->freeze();
|
||||
$type->setPersistantFreeze(true);
|
||||
}
|
||||
$assesstimestartvalue=is_array($mform->getElementValue('assesstimestart'));
|
||||
$assesstimefinishvalue=is_array($mform->getElementValue('assesstimefinish'));
|
||||
$ratingtime=&$mform->getElement('ratingtime');
|
||||
if ($assesstimestartvalue && $assesstimefinishvalue){
|
||||
$ratingtime->setValue(true);
|
||||
} else {
|
||||
$ratingtime->setValue(false);
|
||||
|
||||
}
|
||||
function set_defaults($default_values, $slashed=false){
|
||||
if (is_object($default_values)) {
|
||||
$default_values = (array)$default_values;
|
||||
}
|
||||
if (isset($default_values['assessed'])){
|
||||
$default_values['ratingtime']=($default_values['assessed']
|
||||
&& $default_values['assesstimestart']
|
||||
&& $default_values['assesstimefinish'] )?1:0;
|
||||
}
|
||||
parent::set_defaults($default_values, $slashed);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user