Fixing dependence upon hard-coded password by modifying playlist build to not require authentication
This commit is contained in:
parent
0ac58165a3
commit
934cad44b5
|
@ -18,53 +18,26 @@ class AutoPlaylistManager {
|
||||||
return empty($lastPolled) || (microtime(true) > $lastPolled + self::$_AUTOPLAYLIST_POLL_INTERVAL_SECONDS);
|
return empty($lastPolled) || (microtime(true) > $lastPolled + self::$_AUTOPLAYLIST_POLL_INTERVAL_SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* This function is copied from the TestUser class and is used to instantiate a user so that
|
|
||||||
* the Scheduler model can be utilized by buildAutoPlaylist.
|
|
||||||
* Not sure if this is the best strategy but it works.
|
|
||||||
*/
|
|
||||||
public static function loginUser()
|
|
||||||
{
|
|
||||||
$authAdapter = Application_Model_Auth::getAuthAdapter();
|
|
||||||
|
|
||||||
//pass to the adapter the submitted username and password
|
|
||||||
$authAdapter->setIdentity('admin')
|
|
||||||
->setCredential('admin');
|
|
||||||
|
|
||||||
$auth = Zend_Auth::getInstance();
|
|
||||||
$result = $auth->authenticate($authAdapter);
|
|
||||||
if ($result->isValid()) {
|
|
||||||
//all info about this user from the login table omit only the password
|
|
||||||
$userInfo = $authAdapter->getResultRowObject(null, 'password');
|
|
||||||
|
|
||||||
//the default storage is a session with namespace Zend_Auth
|
|
||||||
$authStorage = $auth->getStorage();
|
|
||||||
$authStorage->write($userInfo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find all shows with autoplaylists who have yet to have their playlists built and added to the schedule
|
* Find all shows with autoplaylists who have yet to have their playlists built and added to the schedule
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static function buildAutoPlaylist() {
|
public static function buildAutoPlaylist() {
|
||||||
// Starting a session so that the User can be created
|
// Starting a session
|
||||||
Zend_Session::start();
|
Zend_Session::start();
|
||||||
static::loginUser();
|
Logging::info("Checking to run Auto Playlist");
|
||||||
Logging::info("Checking to run Auto Playlist");
|
$autoPlaylists = static::_upcomingAutoPlaylistShows();
|
||||||
$autoPlaylists = static::_upcomingAutoPlaylistShows();
|
foreach ($autoPlaylists as $autoplaylist) {
|
||||||
foreach ($autoPlaylists as $autoplaylist) {
|
|
||||||
// creates a ShowInstance object to build the playlist in from the ShowInstancesQuery Object
|
// creates a ShowInstance object to build the playlist in from the ShowInstancesQuery Object
|
||||||
$si = new Application_Model_ShowInstance($autoplaylist->getDbId());
|
$si = new Application_Model_ShowInstance($autoplaylist->getDbId());
|
||||||
$playlistid = $si->GetAutoPlaylistId();
|
$playlistid = $si->GetAutoPlaylistId();
|
||||||
Logging::info("Scheduling $playlistid");
|
Logging::info("Scheduling $playlistid");
|
||||||
// call the addPlaylist to show function and don't check for user permission to avoid call to non-existant user object
|
// call the addPlaylist to show function and don't check for user permission to avoid call to non-existant user object
|
||||||
$si->addPlaylistToShow($playlistid, false);
|
$si->addPlaylistToShow($playlistid, false);
|
||||||
$si->setAutoPlaylistBuilt(true);
|
$si->setAutoPlaylistBuilt(true);
|
||||||
|
|
||||||
}
|
}
|
||||||
Application_Model_Preference::setAutoPlaylistPollLock(microtime(true));
|
Application_Model_Preference::setAutoPlaylistPollLock(microtime(true));
|
||||||
Zend_Session::stop();
|
Zend_Session::stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -76,7 +76,7 @@ class Application_Model_Scheduler
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* make sure any incoming requests for scheduling are ligit.
|
* make sure any incoming requests for scheduling are legit.
|
||||||
*
|
*
|
||||||
* @param array $items, an array containing pks of cc_schedule items.
|
* @param array $items, an array containing pks of cc_schedule items.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -230,6 +230,7 @@ SQL;
|
||||||
$id = $this->_showInstance->getDbId();
|
$id = $this->_showInstance->getDbId();
|
||||||
|
|
||||||
$scheduler = new Application_Model_Scheduler();
|
$scheduler = new Application_Model_Scheduler();
|
||||||
|
$scheduler->setCheckUserPermissions($checkUserPerm);
|
||||||
$scheduler->scheduleAfter(
|
$scheduler->scheduleAfter(
|
||||||
array(array("id" => 0, "instance" => $id, "timestamp" => $ts)),
|
array(array("id" => 0, "instance" => $id, "timestamp" => $ts)),
|
||||||
array(array("id" => $pl_id, "type" => "playlist"))
|
array(array("id" => $pl_id, "type" => "playlist"))
|
||||||
|
|
Loading…
Reference in New Issue