CC-4157: Playlist Builder -> Smart Playlist -> Wrong warning msg if trying to input 0000-00-00 into Upload criteria
-fixed
This commit is contained in:
parent
f6dffc95c8
commit
97943a6af8
|
@ -320,24 +320,48 @@ class Application_Common_DateHelper
|
|||
public static function checkDateTimeRangeForSQL($p_datetime){
|
||||
$info = explode(' ', $p_datetime);
|
||||
$dateInfo = explode('-', $info[0]);
|
||||
$timeInfo = explode(':', $info[1]);
|
||||
if (isset($info[1])) {
|
||||
$timeInfo = explode(':', $info[1]);
|
||||
}
|
||||
$retVal = array();
|
||||
$retVal["success"] = true;
|
||||
|
||||
$year = $dateInfo[0];
|
||||
$month = $dateInfo[1];
|
||||
$day = $dateInfo[2];
|
||||
// if year is < 1753 or > 9999 it's out of range
|
||||
if ($year < 1753 || !checkdate($month, $day, $year)) {
|
||||
return false;
|
||||
if ($year < 1753) {
|
||||
$retVal['success'] = false;
|
||||
$retVal['errMsg'] = "The year '$year' must be within the range of 1753 - 9999";
|
||||
} else if (!checkdate($month, $day, $year)) {
|
||||
$retVal['success'] = false;
|
||||
$retVal['errMsg'] = "'$year-$month-$day' is not a valid date";
|
||||
} else {
|
||||
// check time
|
||||
$hour = intval($timeInfo[0]);
|
||||
$min = intval($timeInfo[1]);
|
||||
$sec = intval($timeInfo[2]);
|
||||
if ($hour > 23 || $min > 59 || $sec > 59) {
|
||||
return false;
|
||||
if (isset($timeInfo[0]) && $timeInfo[0] != "") {
|
||||
$hour = intval($timeInfo[0]);
|
||||
} else {
|
||||
$hour = -1;
|
||||
}
|
||||
|
||||
if (isset($timeInfo[1]) && $timeInfo[1] != "") {
|
||||
$min = intval($timeInfo[1]);
|
||||
} else {
|
||||
$min = -1;
|
||||
}
|
||||
|
||||
if (isset($timeInfo[2]) && $timeInfo[2] != "") {
|
||||
$sec = intval($timeInfo[2]);
|
||||
} else {
|
||||
$sec = -1;
|
||||
}
|
||||
|
||||
if ( ($hour < 0 || $hour > 23) || ($min < 0 || $min > 59) || ($sec < 0 || $sec > 59) ) {
|
||||
$retVal['success'] = false;
|
||||
$retVal['errMsg'] = "'$timeInfo[0]:$timeInfo[1]:$timeInfo[2]' is not a valid time";
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return $retVal;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -981,17 +981,23 @@ EOT;
|
|||
} else if ($column->getType() == PropelColumnTypes::TIMESTAMP) {
|
||||
if (!preg_match("/(\d{4})-(\d{2})-(\d{2})/", $d['sp_criteria_value'])) {
|
||||
$error[] = "The value should be in timestamp format(eg. 0000-00-00 or 00-00-00 00:00:00";
|
||||
} else if (!Application_Common_DateHelper::checkDateTimeRangeForSQL($d['sp_criteria_value'])) {
|
||||
// check for if it is in valid range( 1753-01-01 ~ 12/31/9999 )
|
||||
$error[] = "$d[sp_criteria_value] is not a valid date/time string";
|
||||
} else {
|
||||
$result = Application_Common_DateHelper::checkDateTimeRangeForSQL($d['sp_criteria_value']);
|
||||
if (!$result["success"]) {
|
||||
// check for if it is in valid range( 1753-01-01 ~ 12/31/9999 )
|
||||
$error[] = $result["errMsg"];
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($d['sp_criteria_extra'])) {
|
||||
if (!preg_match("/(\d{4})-(\d{2})-(\d{2})/", $d['sp_criteria_extra'])) {
|
||||
$error[] = "The value should be in timestamp format(eg. 0000-00-00 or 00-00-00 00:00:00";
|
||||
} else if (!Application_Common_DateHelper::checkDateTimeRangeForSQL($d['sp_criteria_extra'])) {
|
||||
// check for if it is in valid range( 1753-01-01 ~ 12/31/9999 )
|
||||
$error[] = "$d[sp_criteria_extra] is not a valid date/time string";
|
||||
} else {
|
||||
$result = Application_Common_DateHelper::checkDateTimeRangeForSQL($d['sp_criteria_extra']);
|
||||
if (!$result["success"]) {
|
||||
// check for if it is in valid range( 1753-01-01 ~ 12/31/9999 )
|
||||
$error[] = $result["errMsg"];
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if ($column->getType() == PropelColumnTypes::INTEGER) {
|
||||
|
@ -1035,17 +1041,23 @@ EOT;
|
|||
} else if ($column->getType() == PropelColumnTypes::TIMESTAMP) {
|
||||
if (!preg_match("/(\d{4})-(\d{2})-(\d{2})/", $d['sp_criteria_value'])) {
|
||||
$error[] = "The value should be in timestamp format(eg. 0000-00-00 or 00-00-00 00:00:00";
|
||||
} else if (!Application_Common_DateHelper::checkDateTimeRangeForSQL($d['sp_criteria_value'])) {
|
||||
// check for if it is in valid range( 1753-01-01 ~ 12/31/9999 )
|
||||
$error[] = "$d[sp_criteria_value] is not a valid date/time string";
|
||||
} else {
|
||||
$result = Application_Common_DateHelper::checkDateTimeRangeForSQL($d['sp_criteria_value']);
|
||||
if (!$result["success"]) {
|
||||
// check for if it is in valid range( 1753-01-01 ~ 12/31/9999 )
|
||||
$error[] = $result["errMsg"];
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($d['sp_criteria_extra'])) {
|
||||
if (!preg_match("/(\d{4})-(\d{2})-(\d{2})/", $d['sp_criteria_extra'])) {
|
||||
$error[] = "The value should be in timestamp format(eg. 0000-00-00 or 00-00-00 00:00:00";
|
||||
} else if (!Application_Common_DateHelper::checkDateTimeRangeForSQL($d['sp_criteria_extra'])) {
|
||||
// check for if it is in valid range( 1753-01-01 ~ 12/31/9999 )
|
||||
$error[] = "$d[sp_criteria_extra] is not a valid date/time string";
|
||||
} else {
|
||||
$result = Application_Common_DateHelper::checkDateTimeRangeForSQL($d['sp_criteria_extra']);
|
||||
if (!$result["success"]) {
|
||||
// check for if it is in valid range( 1753-01-01 ~ 12/31/9999 )
|
||||
$error[] = $result["errMsg"];
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if ($column->getType() == PropelColumnTypes::INTEGER) {
|
||||
|
|
Loading…
Reference in New Issue