Skip to content
Permalink
Browse files

added defaults for when there is no submitted data to datetimeselecto…

…r and small fix for forum\mod_form.php
  • Loading branch information
jamiesensei
jamiesensei committed Nov 23, 2006
1 parent f4bf6a5 commit 02f8f37d5de255ce26dc1f8cbbd7edc3c02e29c0
Showing with 26 additions and 20 deletions.
  1. +15 −13 lib/form/datetimeselector.php
  2. +11 −7 mod/forum/mod_form.php
@@ -157,24 +157,26 @@ function exportValue(&$submitValues, $assoc = false)
$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;
}

// }}}
@@ -148,14 +148,18 @@ function definition_after_data(){
$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);
}


0 comments on commit 02f8f37

Please sign in to comment.
You can’t perform that action at this time.