CC-4005: Tag files with Last Played date and number of times played

- done for files and webstreams
This commit is contained in:
James 2012-09-10 18:01:36 -04:00
parent dfb1ffed79
commit ba37bb4327
11 changed files with 219 additions and 35 deletions

View file

@ -73,6 +73,12 @@ abstract class BaseCcWebstream extends BaseObject implements Persistent
*/
protected $utime;
/**
* The value for the lptime field.
* @var string
*/
protected $lptime;
/**
* The value for the mime field.
* @var string
@ -245,6 +251,39 @@ abstract class BaseCcWebstream extends BaseObject implements Persistent
}
}
/**
* Get the [optionally formatted] temporal [lptime] column value.
*
*
* @param string $format The date/time format string (either date()-style or strftime()-style).
* If format is NULL, then the raw DateTime object will be returned.
* @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
* @throws PropelException - if unable to parse/validate the date/time value.
*/
public function getDbLPtime($format = 'Y-m-d H:i:s')
{
if ($this->lptime === null) {
return null;
}
try {
$dt = new DateTime($this->lptime);
} catch (Exception $x) {
throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->lptime, true), $x);
}
if ($format === null) {
// Because propel.useDateTimeClass is TRUE, we return a DateTime object.
return $dt;
} elseif (strpos($format, '%') !== false) {
return strftime($format, $dt->format('U'));
} else {
return $dt->format($format);
}
}
/**
* Get the [mime] column value.
*
@ -473,6 +512,55 @@ abstract class BaseCcWebstream extends BaseObject implements Persistent
return $this;
} // setDbUtime()
/**
* Sets the value of [lptime] column to a normalized version of the date/time value specified.
*
* @param mixed $v string, integer (timestamp), or DateTime value. Empty string will
* be treated as NULL for temporal objects.
* @return CcWebstream The current object (for fluent API support)
*/
public function setDbLPtime($v)
{
// we treat '' as NULL for temporal objects because DateTime('') == DateTime('now')
// -- which is unexpected, to say the least.
if ($v === null || $v === '') {
$dt = null;
} elseif ($v instanceof DateTime) {
$dt = $v;
} else {
// some string/numeric value passed; we normalize that so that we can
// validate it.
try {
if (is_numeric($v)) { // if it's a unix timestamp
$dt = new DateTime('@'.$v, new DateTimeZone('UTC'));
// We have to explicitly specify and then change the time zone because of a
// DateTime bug: http://bugs.php.net/bug.php?id=43003
$dt->setTimeZone(new DateTimeZone(date_default_timezone_get()));
} else {
$dt = new DateTime($v);
}
} catch (Exception $x) {
throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x);
}
}
if ( $this->lptime !== null || $dt !== null ) {
// (nested ifs are a little easier to read in this case)
$currNorm = ($this->lptime !== null && $tmpDt = new DateTime($this->lptime)) ? $tmpDt->format('Y-m-d\\TH:i:sO') : null;
$newNorm = ($dt !== null) ? $dt->format('Y-m-d\\TH:i:sO') : null;
if ( ($currNorm !== $newNorm) // normalized values don't match
)
{
$this->lptime = ($dt ? $dt->format('Y-m-d\\TH:i:sO') : null);
$this->modifiedColumns[] = CcWebstreamPeer::LPTIME;
}
} // if either are not null
return $this;
} // setDbLPtime()
/**
* Set the value of [mime] column.
*
@ -537,7 +625,8 @@ abstract class BaseCcWebstream extends BaseObject implements Persistent
$this->creator_id = ($row[$startcol + 5] !== null) ? (int) $row[$startcol + 5] : null;
$this->mtime = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null;
$this->utime = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null;
$this->mime = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null;
$this->lptime = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null;
$this->mime = ($row[$startcol + 9] !== null) ? (string) $row[$startcol + 9] : null;
$this->resetModified();
$this->setNew(false);
@ -546,7 +635,7 @@ abstract class BaseCcWebstream extends BaseObject implements Persistent
$this->ensureConsistency();
}
return $startcol + 9; // 9 = CcWebstreamPeer::NUM_COLUMNS - CcWebstreamPeer::NUM_LAZY_LOAD_COLUMNS).
return $startcol + 10; // 10 = CcWebstreamPeer::NUM_COLUMNS - CcWebstreamPeer::NUM_LAZY_LOAD_COLUMNS).
} catch (Exception $e) {
throw new PropelException("Error populating CcWebstream object", $e);
@ -888,6 +977,9 @@ abstract class BaseCcWebstream extends BaseObject implements Persistent
return $this->getDbUtime();
break;
case 8:
return $this->getDbLPtime();
break;
case 9:
return $this->getDbMime();
break;
default:
@ -921,7 +1013,8 @@ abstract class BaseCcWebstream extends BaseObject implements Persistent
$keys[5] => $this->getDbCreatorId(),
$keys[6] => $this->getDbMtime(),
$keys[7] => $this->getDbUtime(),
$keys[8] => $this->getDbMime(),
$keys[8] => $this->getDbLPtime(),
$keys[9] => $this->getDbMime(),
);
return $result;
}
@ -978,6 +1071,9 @@ abstract class BaseCcWebstream extends BaseObject implements Persistent
$this->setDbUtime($value);
break;
case 8:
$this->setDbLPtime($value);
break;
case 9:
$this->setDbMime($value);
break;
} // switch()
@ -1012,7 +1108,8 @@ abstract class BaseCcWebstream extends BaseObject implements Persistent
if (array_key_exists($keys[5], $arr)) $this->setDbCreatorId($arr[$keys[5]]);
if (array_key_exists($keys[6], $arr)) $this->setDbMtime($arr[$keys[6]]);
if (array_key_exists($keys[7], $arr)) $this->setDbUtime($arr[$keys[7]]);
if (array_key_exists($keys[8], $arr)) $this->setDbMime($arr[$keys[8]]);
if (array_key_exists($keys[8], $arr)) $this->setDbLPtime($arr[$keys[8]]);
if (array_key_exists($keys[9], $arr)) $this->setDbMime($arr[$keys[9]]);
}
/**
@ -1032,6 +1129,7 @@ abstract class BaseCcWebstream extends BaseObject implements Persistent
if ($this->isColumnModified(CcWebstreamPeer::CREATOR_ID)) $criteria->add(CcWebstreamPeer::CREATOR_ID, $this->creator_id);
if ($this->isColumnModified(CcWebstreamPeer::MTIME)) $criteria->add(CcWebstreamPeer::MTIME, $this->mtime);
if ($this->isColumnModified(CcWebstreamPeer::UTIME)) $criteria->add(CcWebstreamPeer::UTIME, $this->utime);
if ($this->isColumnModified(CcWebstreamPeer::LPTIME)) $criteria->add(CcWebstreamPeer::LPTIME, $this->lptime);
if ($this->isColumnModified(CcWebstreamPeer::MIME)) $criteria->add(CcWebstreamPeer::MIME, $this->mime);
return $criteria;
@ -1101,6 +1199,7 @@ abstract class BaseCcWebstream extends BaseObject implements Persistent
$copyObj->setDbCreatorId($this->creator_id);
$copyObj->setDbMtime($this->mtime);
$copyObj->setDbUtime($this->utime);
$copyObj->setDbLPtime($this->lptime);
$copyObj->setDbMime($this->mime);
if ($deepCopy) {
@ -1331,6 +1430,7 @@ abstract class BaseCcWebstream extends BaseObject implements Persistent
$this->creator_id = null;
$this->mtime = null;
$this->utime = null;
$this->lptime = null;
$this->mime = null;
$this->alreadyInSave = false;
$this->alreadyInValidation = false;