Ejemplo n.º 1
0
 /**
  * set object Values
  *
  * @param array $values : the POST result values
  * @param string $prefixname : the prefix used for post names
  * @return boolean true on success, false on failure
  * @access public
  */
 function setValues($values, $prefixName)
 {
     global $cms_language;
     $params = $this->getParamsValues();
     $date = new CMS_date();
     $date->setFormat($cms_language->getDateFormat());
     if (isset($values[$prefixName . $this->_field->getID() . '_0'])) {
         if (!$date->setLocalizedDate($values[$prefixName . $this->_field->getID() . '_0'], !$this->_field->getValue('required'))) {
             return false;
         }
         if ($params['withHMS'] && isset($values[$prefixName . $this->_field->getID() . '_1']) && $values[$prefixName . $this->_field->getID() . '_1']) {
             $hms = explode(':', $values[$prefixName . $this->_field->getID() . '_1']);
             if (sizeof($hms) != 3) {
                 return false;
             }
             if (!$date->setHour($hms[0])) {
                 return false;
             }
             if (!$date->setMinute($hms[1])) {
                 return false;
             }
             if (!$date->setSecond($hms[2])) {
                 return false;
             }
         }
     }
     if ($params['creationDate']) {
         $date->setFromDBValue($this->_subfieldValues[0]->getValue());
     }
     if ($date->isNull() && ($params['setNow'] || $params['creationDate']) || $params['updateDate']) {
         $date->setNow();
         if ($params['moveDate']) {
             $date->moveDate($params['moveDate']);
         }
     }
     if (!$this->_subfieldValues[0]->setValue($date->getDBValue())) {
         return false;
     }
     return true;
 }