CC-84: Smart Playlists

-fixed undefined offset apache warnings
This commit is contained in:
denise 2012-08-01 14:07:38 -04:00
parent 8f063367cc
commit 0f681d7c25
1 changed files with 68 additions and 62 deletions

View File

@ -965,59 +965,61 @@ EOT;
} }
}// foreach }// foreach
$modKeys = array_keys($data['modrow']); if (isset($data['modrow'])) {
for ($i = 0; $i < count($modKeys); $i++) { $modKeys = array_keys($data['modrow']);
foreach ($data['modrow'][$modKeys[$i]] as $key=>$d){ for ($i = 0; $i < count($modKeys); $i++) {
$error = array(); foreach ($data['modrow'][$modKeys[$i]] as $key=>$d){
// check for not selected select box $error = array();
if ($d['sp_criteria_field'] == "0" || $d['sp_criteria_modifier'] == "0"){ // check for not selected select box
$error[] = "You must select Criteria and Modifier"; if ($d['sp_criteria_field'] == "0" || $d['sp_criteria_modifier'] == "0"){
} else { $error[] = "You must select Criteria and Modifier";
$column = CcFilesPeer::getTableMap()->getColumnByPhpName(self::$criteria2PeerMap[$d['sp_criteria_field']]); } else {
// validation on type of column $column = CcFilesPeer::getTableMap()->getColumnByPhpName(self::$criteria2PeerMap[$d['sp_criteria_field']]);
if ($d['sp_criteria_field'] == 'length') { // validation on type of column
if (!preg_match("/(\d{2}):(\d{2}):(\d{2})/", $d['sp_criteria_value'])) { if ($d['sp_criteria_field'] == 'length') {
$error[] = "'Length' should be in '00:00:00' format"; if (!preg_match("/(\d{2}):(\d{2}):(\d{2})/", $d['sp_criteria_value'])) {
} $error[] = "'Length' should be in '00:00:00' format";
} else if ($column->getType() == PropelColumnTypes::TIMESTAMP) { }
if (!preg_match("/(\d{4})-(\d{2})-(\d{2})/", $d['sp_criteria_value'])) { } else if ($column->getType() == PropelColumnTypes::TIMESTAMP) {
$error[] = "The value should be in timestamp format(eg. 0000-00-00 or 00-00-00 00:00:00"; if (!preg_match("/(\d{4})-(\d{2})-(\d{2})/", $d['sp_criteria_value'])) {
} 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";
}
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"; $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'])) { } else if (!Application_Common_DateHelper::checkDateTimeRangeForSQL($d['sp_criteria_value'])) {
// check for if it is in valid range( 1753-01-01 ~ 12/31/9999 ) // 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"; $error[] = "$d[sp_criteria_value] is not a valid date/time string";
}
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 if ($column->getType() == PropelColumnTypes::INTEGER) {
if (!is_numeric($d['sp_criteria_value'])) {
$error[] = "The value has to be numeric";
}
// length check
if (intval($d['sp_criteria_value']) >= pow(2,31)) {
$error[] = "The value should be less then 2147483648";
}
} else if ($column->getType() == PropelColumnTypes::VARCHAR) {
if (strlen($d['sp_criteria_value']) > $column->getSize()) {
$error[] = "The value should be less ".$column->getSize()." characters";
} }
} }
} else if ($column->getType() == PropelColumnTypes::INTEGER) {
if (!is_numeric($d['sp_criteria_value'])) {
$error[] = "The value has to be numeric";
}
// length check
if (intval($d['sp_criteria_value']) >= pow(2,31)) {
$error[] = "The value should be less then 2147483648";
}
} else if ($column->getType() == PropelColumnTypes::VARCHAR) {
if (strlen($d['sp_criteria_value']) > $column->getSize()) {
$error[] = "The value should be less ".$column->getSize()." characters";
}
} }
}
if ($d['sp_criteria_value'] == "") {
if ($d['sp_criteria_value'] == "") { $error[] = "Value cannot be empty";
$error[] = "Value cannot be empty"; }
} if(count($error) > 0){
if(count($error) > 0){ $errors[] = array("element"=>"sp_criteria_field_".$modKeys[$i]."_".$key, "msg"=>$error);
$errors[] = array("element"=>"sp_criteria_field_".$modKeys[$i]."_".$key, "msg"=>$error); }
} }//end mod foreach
}//end mod foreach }//for loop
}//for loop }//if
$result = count($errors) > 0 ? 1 :0; $result = count($errors) > 0 ? 1 :0;
$files["count"] = 0; $files["count"] = 0;
@ -1060,19 +1062,21 @@ EOT;
} }
//insert modifier rows //insert modifier rows
$modKeys = array_keys($p_criteriaData['modrow']); if (isset($p_criteriaData['modrow'])) {
for ($i = 0; $i < count($modKeys); $i++) { $modKeys = array_keys($p_criteriaData['modrow']);
foreach( $p_criteriaData['modrow'][$modKeys[$i]] as $d){ for ($i = 0; $i < count($modKeys); $i++) {
$qry = new CcBlockcriteria(); foreach( $p_criteriaData['modrow'][$modKeys[$i]] as $d){
$qry->setDbCriteria($d['sp_criteria_field']) $qry = new CcBlockcriteria();
->setDbModifier($d['sp_criteria_modifier']) $qry->setDbCriteria($d['sp_criteria_field'])
->setDbValue($d['sp_criteria_value']) ->setDbModifier($d['sp_criteria_modifier'])
->setDbBlockId($this->id); ->setDbValue($d['sp_criteria_value'])
->setDbBlockId($this->id);
if (isset($d['sp_criteria_extra'])) {
$qry->setDbExtra($d['sp_criteria_extra']); if (isset($d['sp_criteria_extra'])) {
$qry->setDbExtra($d['sp_criteria_extra']);
}
$qry->save();
} }
$qry->save();
} }
} }
@ -1264,8 +1268,10 @@ EOT;
*/ */
$tempName = $ele['name']; $tempName = $ele['name'];
preg_match('/^\D*(?=\d)/', $tempName, $r); preg_match('/^\D*(?=\d)/', $tempName, $r);
$critIndexPos = strlen($r[0]); if (isset($r[0])) {
$critIndex = $tempName[$critIndexPos]; $critIndexPos = strlen($r[0]);
$critIndex = $tempName[$critIndexPos];
}
$fieldName = substr($ele['name'], 0, $index); $fieldName = substr($ele['name'], 0, $index);