CC-4112: Smart Playlist: Cannot search Long string
- added length validator - extra fix: Due to lazy loading, aggregated field on playlist was not updated properly.
This commit is contained in:
parent
2e7cf68777
commit
ef64ce2b73
|
@ -271,6 +271,11 @@ class Application_Model_Playlist
|
|||
$row->setDbFadein($info["fadein"]);
|
||||
$row->setDbFadeout($info["fadeout"]);
|
||||
$row->save($this->con);
|
||||
// above save result update on cc_playlist table on length column.
|
||||
// but $this->pl doesn't get updated automatically
|
||||
// so we need to manually grab it again from DB so it has updated values
|
||||
// It is something to do FORMAT_ON_DEMAND( Lazy Loading )
|
||||
$this->pl = CcPlaylistQuery::create()->findPK($this->id);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -929,6 +934,7 @@ class Application_Model_Playlist
|
|||
$playlistType = $data['etc']['sp_type'] == 0 ? 'static':'dynamic';
|
||||
$this->saveType($playlistType);
|
||||
|
||||
// validation start
|
||||
if ($data['etc']['sp_limit_options'] == 'hours') {
|
||||
$multiplier = 60;
|
||||
}
|
||||
|
@ -952,43 +958,47 @@ class Application_Model_Playlist
|
|||
if (count($error) > 0){
|
||||
$errors[] = array("element"=>"sp_limit_value", "msg"=>$error);
|
||||
}
|
||||
|
||||
// format validation
|
||||
|
||||
foreach ($data['criteria'] as $key=>$d){
|
||||
$error = array();
|
||||
$column = CcFilesPeer::getTableMap()->getColumnByPhpName(self::$criteria2PeerMap[$d['sp_criteria_field']]);
|
||||
// check for not selected select box
|
||||
if ($d['sp_criteria_field'] == "0" || $d['sp_criteria_modifier'] == "0"){
|
||||
$error[] = "You must select Criteria and Modifier";
|
||||
} else {
|
||||
// we need to take care 'length' specially since the column type is varchar
|
||||
// validation on type of column
|
||||
if ($d['sp_criteria_field'] == 'length') {
|
||||
if (!preg_match("/(\d{2}):(\d{2}):(\d{2})/", $d['sp_criteria_value'])) {
|
||||
$error[] = "'Length' should be in '00:00:00' format";
|
||||
}
|
||||
} else if (CcFilesPeer::getTableMap()->getColumnByPhpName(self::$criteria2PeerMap[$d['sp_criteria_field']])->getType() == PropelColumnTypes::TIMESTAMP) {
|
||||
} 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 {
|
||||
} else if (!Application_Common_DateHelper::checkDateTimeRangeForSQL($d['sp_criteria_value'])) {
|
||||
// check for if it is in valid range( 1753-01-01 ~ 12/31/9999 )
|
||||
if(!Application_Common_DateHelper::checkDateTimeRangeForSQL($d['sp_criteria_value'])){
|
||||
$error[] = "$d[sp_criteria_value] 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 {
|
||||
} else if (!Application_Common_DateHelper::checkDateTimeRangeForSQL($d['sp_criteria_extra'])) {
|
||||
// check for if it is in valid range( 1753-01-01 ~ 12/31/9999 )
|
||||
if(!Application_Common_DateHelper::checkDateTimeRangeForSQL($d['sp_criteria_extra'])){
|
||||
$error[] = "$d[sp_criteria_extra] is not a valid date/time string";
|
||||
}
|
||||
$error[] = "$d[sp_criteria_extra] is not a valid date/time string";
|
||||
}
|
||||
}
|
||||
} else if (CcFilesPeer::getTableMap()->getColumnByPhpName(self::$criteria2PeerMap[$d['sp_criteria_field']])->getType() == PropelColumnTypes::INTEGER) {
|
||||
} 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";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1105,6 +1115,12 @@ class Application_Model_Playlist
|
|||
|
||||
$spCriteriaModifier = $criteria['modifier'];
|
||||
$spCriteriaValue = $criteria['value'];
|
||||
|
||||
// change date/time to UTC is the column time is timestamp
|
||||
if (CcFilesPeer::getTableMap()->getColumnByPhpName($spCriteriaPhpName)->getType() == PropelColumnTypes::TIMESTAMP) {
|
||||
$spCriteriaValue = Application_Common_DateHelper::ConvertToUtcDateTimeString($spCriteriaValue);
|
||||
}
|
||||
|
||||
if ($spCriteriaModifier == "starts with") {
|
||||
$spCriteriaValue = "$spCriteriaValue%";
|
||||
} else if ($spCriteriaModifier == "ends with") {
|
||||
|
|
|
@ -41,8 +41,8 @@ class CcPlaylistcriteriaTableMap extends TableMap {
|
|||
$this->addPrimaryKey('ID', 'DbId', 'INTEGER', true, null, null);
|
||||
$this->addColumn('CRITERIA', 'DbCriteria', 'VARCHAR', true, 16, null);
|
||||
$this->addColumn('MODIFIER', 'DbModifier', 'VARCHAR', true, 16, null);
|
||||
$this->addColumn('VALUE', 'DbValue', 'VARCHAR', true, 32, null);
|
||||
$this->addColumn('EXTRA', 'DbExtra', 'VARCHAR', false, 32, null);
|
||||
$this->addColumn('VALUE', 'DbValue', 'VARCHAR', true, 512, null);
|
||||
$this->addColumn('EXTRA', 'DbExtra', 'VARCHAR', false, 512, null);
|
||||
$this->addForeignKey('PLAYLIST_ID', 'DbPlaylistId', 'INTEGER', 'cc_playlist', 'ID', true, null, null);
|
||||
// validators
|
||||
} // initialize()
|
||||
|
|
|
@ -255,8 +255,8 @@
|
|||
<column name="id" phpName="DbId" type="INTEGER" primaryKey="true" autoIncrement="true" required="true"/>
|
||||
<column name="criteria" phpName="DbCriteria" type="VARCHAR" size="16" required="true"/>
|
||||
<column name="modifier" phpName="DbModifier" type="VARCHAR" size="16" required="true"/>
|
||||
<column name="value" phpName="DbValue" type="VARCHAR" size="32" required="true"/>
|
||||
<column name="extra" phpName="DbExtra" type="VARCHAR" size="32" required="false"/>
|
||||
<column name="value" phpName="DbValue" type="VARCHAR" size="512" required="true"/>
|
||||
<column name="extra" phpName="DbExtra" type="VARCHAR" size="512" required="false"/>
|
||||
<column name="playlist_id" phpName="DbPlaylistId" type="INTEGER" required="true"/>
|
||||
<foreign-key foreignTable="cc_playlist" name="cc_playlistcontents_playlist_id_fkey" onDelete="CASCADE">
|
||||
<reference local="playlist_id" foreign="id"/>
|
||||
|
|
|
@ -346,8 +346,8 @@ CREATE TABLE "cc_playlistcriteria"
|
|||
"id" serial NOT NULL,
|
||||
"criteria" VARCHAR(16) NOT NULL,
|
||||
"modifier" VARCHAR(16) NOT NULL,
|
||||
"value" VARCHAR(32) NOT NULL,
|
||||
"extra" VARCHAR(32),
|
||||
"value" VARCHAR(512) NOT NULL,
|
||||
"extra" VARCHAR(512),
|
||||
"playlist_id" INTEGER NOT NULL,
|
||||
PRIMARY KEY ("id")
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue