CC-1665: Scheduled stream rebroadcasting and recording
-Make playlist builder show creator name instead of creator id
This commit is contained in:
parent
b23b9a0cbd
commit
f901e13a84
8 changed files with 59 additions and 47 deletions
|
@ -34,7 +34,6 @@ class WebstreamController extends Zend_Controller_Action
|
|||
{
|
||||
$request = $this->getRequest();
|
||||
|
||||
|
||||
$id = $request->getParam("id");
|
||||
if (is_null($id)) {
|
||||
throw new Exception("Missing parameter 'id'");
|
||||
|
@ -48,10 +47,35 @@ class WebstreamController extends Zend_Controller_Action
|
|||
{
|
||||
$request = $this->getRequest();
|
||||
|
||||
|
||||
$user = Application_Model_User::getCurrentUser();
|
||||
$hasPermission = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER, UTYPE_HOST));
|
||||
$id = $request->getParam("id");
|
||||
|
||||
if ($id == -1) {
|
||||
$webstream = new CcWebstream();
|
||||
} else {
|
||||
$webstream = CcWebstreamQuery::create()->findPK($id);
|
||||
}
|
||||
|
||||
if ($id != -1) {
|
||||
//we are updating a playlist. Ensure that if the user is a host/dj, that he has the correct permission.
|
||||
$user = Application_Model_User::getCurrentUser();
|
||||
if ($webstream->getDbCreatorId() != $user->getId()) {
|
||||
header("Status: 401 Not Authorized");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$hasPermission) {
|
||||
header("Status: 401 Not Authorized");
|
||||
return;
|
||||
}
|
||||
|
||||
$analysis = Application_Model_Webstream::analyzeFormData($request);
|
||||
|
||||
if (Application_Model_Webstream::isValid($analysis)) {
|
||||
Application_Model_Webstream::save($request);
|
||||
Application_Model_Webstream::save($request, $webstream);
|
||||
$this->view->statusMessage = "<div class='success'>Webstream saved.</div>";
|
||||
} else {
|
||||
$this->view->statusMessage = "<div class='errors'>Invalid form values.</div>";
|
||||
|
|
|
@ -606,7 +606,7 @@ class Application_Model_StoredFile
|
|||
$plSelect[] = "PL.id AS ".$key;
|
||||
$blSelect[] = "BL.id AS ".$key;
|
||||
$fileSelect[] = $key;
|
||||
$streamSelect[] = $key;
|
||||
$streamSelect[] = "ws.id AS ".$key;
|
||||
} elseif ($key === "track_title") {
|
||||
$plSelect[] = "name AS ".$key;
|
||||
$blSelect[] = "name AS ".$key;
|
||||
|
@ -621,7 +621,7 @@ class Application_Model_StoredFile
|
|||
$plSelect[] = "login AS ".$key;
|
||||
$blSelect[] = "login AS ".$key;
|
||||
$fileSelect[] = $key;
|
||||
$streamSelect[] = "creator_id AS ".$key;
|
||||
$streamSelect[] = "login AS ".$key;
|
||||
}
|
||||
//same columns in each table.
|
||||
else if (in_array($key, array("length", "utime", "mtime"))) {
|
||||
|
@ -659,7 +659,7 @@ class Application_Model_StoredFile
|
|||
$plTable = "({$plSelect} FROM cc_playlist AS PL LEFT JOIN cc_subjs AS sub ON (sub.id = PL.creator_id))";
|
||||
$blTable = "({$blSelect} FROM cc_block AS BL LEFT JOIN cc_subjs AS sub ON (sub.id = BL.creator_id))";
|
||||
$fileTable = "({$fileSelect} FROM cc_files AS FILES WHERE file_exists = 'TRUE')";
|
||||
$streamTable = "({$streamSelect} FROM cc_webstream AS WEBSTREAM)";
|
||||
$streamTable = "({$streamSelect} FROM cc_webstream AS ws LEFT JOIN cc_subjs AS sub ON (sub.id = ws.creator_id))";
|
||||
$unionTable = "({$plTable} UNION {$blTable} UNION {$fileTable} UNION {$streamTable}) AS RESULTS";
|
||||
|
||||
//choose which table we need to select data from.
|
||||
|
|
|
@ -14,7 +14,7 @@ class Application_Model_Webstream{
|
|||
$this->webstream->setDbName("Untitled Webstream");
|
||||
$this->webstream->setDbDescription("");
|
||||
$this->webstream->setDbUrl("http://");
|
||||
$this->webstream->setDbLength("00h 00m");
|
||||
$this->webstream->setDbLength("00:00:00");
|
||||
$this->webstream->setDbName("Untitled Webstream");
|
||||
} else {
|
||||
$this->id = $id;
|
||||
|
@ -44,7 +44,7 @@ class Application_Model_Webstream{
|
|||
if (count($arr) == 3) {
|
||||
list($hours, $min, $sec) = $arr;
|
||||
$di = new DateInterval("PT{$hours}H{$min}M{$sec}S");
|
||||
return $di->format("%Hh %im");
|
||||
return $di->format("%Hh %Im");
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
@ -100,20 +100,6 @@ class Application_Model_Webstream{
|
|||
return $leftOvers;
|
||||
|
||||
}
|
||||
/*
|
||||
Array
|
||||
(
|
||||
[controller] => Webstream
|
||||
[action] => save
|
||||
[module] => default
|
||||
[format] => json
|
||||
[description] => desc
|
||||
[url] => http://
|
||||
[length] => 00h 20m
|
||||
[name] => Default
|
||||
)
|
||||
*/
|
||||
|
||||
|
||||
public static function analyzeFormData($request)
|
||||
{
|
||||
|
@ -173,7 +159,7 @@ Array
|
|||
return true;
|
||||
}
|
||||
|
||||
public static function save($request)
|
||||
public static function save($request, $webstream)
|
||||
{
|
||||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
||||
|
||||
|
@ -191,13 +177,6 @@ Array
|
|||
throw new Exception("Invalid date format: $length");
|
||||
}
|
||||
|
||||
$id = $request->getParam("id");
|
||||
|
||||
if (is_null($id)) {
|
||||
$webstream = new CcWebstream();
|
||||
} else {
|
||||
$webstream = CcWebstreamQuery::create()->findPK($id);
|
||||
}
|
||||
|
||||
$webstream->setDbName($request->getParam("name"));
|
||||
$webstream->setDbDescription($request->getParam("description"));
|
||||
|
|
|
@ -43,7 +43,7 @@ class CcWebstreamTableMap extends TableMap {
|
|||
$this->addColumn('DESCRIPTION', 'DbDescription', 'VARCHAR', true, 255, null);
|
||||
$this->addColumn('URL', 'DbUrl', 'VARCHAR', true, 255, null);
|
||||
$this->addColumn('LENGTH', 'DbLength', 'VARCHAR', true, null, '00:00:00');
|
||||
$this->addColumn('CREATOR_ID', 'DbCreatorId', 'VARCHAR', true, 255, null);
|
||||
$this->addColumn('CREATOR_ID', 'DbCreatorId', 'INTEGER', true, null, null);
|
||||
$this->addColumn('MTIME', 'DbMtime', 'TIMESTAMP', true, 6, null);
|
||||
$this->addColumn('UTIME', 'DbUtime', 'TIMESTAMP', true, 6, null);
|
||||
// validators
|
||||
|
|
|
@ -57,7 +57,7 @@ abstract class BaseCcWebstream extends BaseObject implements Persistent
|
|||
|
||||
/**
|
||||
* The value for the creator_id field.
|
||||
* @var string
|
||||
* @var int
|
||||
*/
|
||||
protected $creator_id;
|
||||
|
||||
|
@ -166,7 +166,7 @@ abstract class BaseCcWebstream extends BaseObject implements Persistent
|
|||
/**
|
||||
* Get the [creator_id] column value.
|
||||
*
|
||||
* @return string
|
||||
* @return int
|
||||
*/
|
||||
public function getDbCreatorId()
|
||||
{
|
||||
|
@ -342,13 +342,13 @@ abstract class BaseCcWebstream extends BaseObject implements Persistent
|
|||
/**
|
||||
* Set the value of [creator_id] column.
|
||||
*
|
||||
* @param string $v new value
|
||||
* @param int $v new value
|
||||
* @return CcWebstream The current object (for fluent API support)
|
||||
*/
|
||||
public function setDbCreatorId($v)
|
||||
{
|
||||
if ($v !== null) {
|
||||
$v = (string) $v;
|
||||
$v = (int) $v;
|
||||
}
|
||||
|
||||
if ($this->creator_id !== $v) {
|
||||
|
@ -498,7 +498,7 @@ abstract class BaseCcWebstream extends BaseObject implements Persistent
|
|||
$this->description = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
|
||||
$this->url = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
|
||||
$this->length = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
|
||||
$this->creator_id = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
|
||||
$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->resetModified();
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
* @method CcWebstream findOneByDbDescription(string $description) Return the first CcWebstream filtered by the description column
|
||||
* @method CcWebstream findOneByDbUrl(string $url) Return the first CcWebstream filtered by the url column
|
||||
* @method CcWebstream findOneByDbLength(string $length) Return the first CcWebstream filtered by the length column
|
||||
* @method CcWebstream findOneByDbCreatorId(string $creator_id) Return the first CcWebstream filtered by the creator_id column
|
||||
* @method CcWebstream findOneByDbCreatorId(int $creator_id) Return the first CcWebstream filtered by the creator_id column
|
||||
* @method CcWebstream findOneByDbMtime(string $mtime) Return the first CcWebstream filtered by the mtime column
|
||||
* @method CcWebstream findOneByDbUtime(string $utime) Return the first CcWebstream filtered by the utime column
|
||||
*
|
||||
|
@ -49,7 +49,7 @@
|
|||
* @method array findByDbDescription(string $description) Return CcWebstream objects filtered by the description column
|
||||
* @method array findByDbUrl(string $url) Return CcWebstream objects filtered by the url column
|
||||
* @method array findByDbLength(string $length) Return CcWebstream objects filtered by the length column
|
||||
* @method array findByDbCreatorId(string $creator_id) Return CcWebstream objects filtered by the creator_id column
|
||||
* @method array findByDbCreatorId(int $creator_id) Return CcWebstream objects filtered by the creator_id column
|
||||
* @method array findByDbMtime(string $mtime) Return CcWebstream objects filtered by the mtime column
|
||||
* @method array findByDbUtime(string $utime) Return CcWebstream objects filtered by the utime column
|
||||
*
|
||||
|
@ -269,20 +269,29 @@ abstract class BaseCcWebstreamQuery extends ModelCriteria
|
|||
/**
|
||||
* Filter the query on the creator_id column
|
||||
*
|
||||
* @param string $dbCreatorId The value to use as filter.
|
||||
* Accepts wildcards (* and % trigger a LIKE)
|
||||
* @param int|array $dbCreatorId The value to use as filter.
|
||||
* Accepts an associative array('min' => $minValue, 'max' => $maxValue)
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return CcWebstreamQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByDbCreatorId($dbCreatorId = null, $comparison = null)
|
||||
{
|
||||
if (null === $comparison) {
|
||||
if (is_array($dbCreatorId)) {
|
||||
$useMinMax = false;
|
||||
if (isset($dbCreatorId['min'])) {
|
||||
$this->addUsingAlias(CcWebstreamPeer::CREATOR_ID, $dbCreatorId['min'], Criteria::GREATER_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if (isset($dbCreatorId['max'])) {
|
||||
$this->addUsingAlias(CcWebstreamPeer::CREATOR_ID, $dbCreatorId['max'], Criteria::LESS_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if ($useMinMax) {
|
||||
return $this;
|
||||
}
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
} elseif (preg_match('/[\%\*]/', $dbCreatorId)) {
|
||||
$dbCreatorId = str_replace('*', '%', $dbCreatorId);
|
||||
$comparison = Criteria::LIKE;
|
||||
}
|
||||
}
|
||||
return $this->addUsingAlias(CcWebstreamPeer::CREATOR_ID, $dbCreatorId, $comparison);
|
||||
|
|
|
@ -419,7 +419,7 @@
|
|||
<column name="description" phpName="DbDescription" type="VARCHAR" size="255" required="true" />
|
||||
<column name="url" phpName="DbUrl" type="VARCHAR" size="255" required="true" />
|
||||
<column name="length" phpName="DbLength" type="VARCHAR" sqlType="interval" required="true" defaultValue="00:00:00"/>
|
||||
<column name="creator_id" phpName="DbCreatorId" type="VARCHAR" size="255" required="true" />
|
||||
<column name="creator_id" phpName="DbCreatorId" type="INTEGER" required="true" />
|
||||
<column name="mtime" phpName="DbMtime" type="TIMESTAMP" size="6" required="true" />
|
||||
<column name="utime" phpName="DbUtime" type="TIMESTAMP" size="6" required="true" />
|
||||
</table>
|
||||
|
|
|
@ -635,7 +635,7 @@ CREATE TABLE "cc_webstream"
|
|||
"description" VARCHAR(255) NOT NULL,
|
||||
"url" VARCHAR(255) NOT NULL,
|
||||
"length" interval default '00:00:00' NOT NULL,
|
||||
"creator_id" VARCHAR(255) NOT NULL,
|
||||
"creator_id" INTEGER NOT NULL,
|
||||
"mtime" TIMESTAMP(6) NOT NULL,
|
||||
"utime" TIMESTAMP(6) NOT NULL,
|
||||
PRIMARY KEY ("id")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue