SAAS-940: Provide usability hints to user
Refactored some code
This commit is contained in:
parent
55999a07ec
commit
48547ee347
1 changed files with 31 additions and 18 deletions
|
@ -24,17 +24,9 @@ class Application_Common_UsabilityHints
|
||||||
*/
|
*/
|
||||||
public static function isFutureOrCurrentShowScheduled()
|
public static function isFutureOrCurrentShowScheduled()
|
||||||
{
|
{
|
||||||
$now = new DateTime("now", new DateTimeZone("UTC"));
|
$futureShow = self::getNextFutureShow();
|
||||||
$futureShow = CcShowInstancesQuery::create()
|
$currentShow = self::getCurrentShow();
|
||||||
->filterByDbStarts($now, Criteria::GREATER_THAN)
|
|
||||||
->filterByDbModifiedInstance(false)
|
|
||||||
->findOne();
|
|
||||||
|
|
||||||
$currentShow = CcShowInstancesQuery::create()
|
|
||||||
->filterByDbStarts($now, Criteria::LESS_THAN)
|
|
||||||
->filterByDbEnds($now, Criteria::GREATER_THAN)
|
|
||||||
->filterByDbModifiedInstance(false)
|
|
||||||
->findOne();
|
|
||||||
if (is_null($futureShow) && is_null($currentShow)) {
|
if (is_null($futureShow) && is_null($currentShow)) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
|
@ -50,23 +42,22 @@ class Application_Common_UsabilityHints
|
||||||
*/
|
*/
|
||||||
public static function isCurrentOrNextShowEmpty()
|
public static function isCurrentOrNextShowEmpty()
|
||||||
{
|
{
|
||||||
$schedule = Application_Model_Schedule::GetPlayOrderRange();
|
$futureShow = self::getNextFutureShow();
|
||||||
$shows = $schedule["shows"];
|
$currentShow = self::getCurrentShow();
|
||||||
|
|
||||||
if (empty($shows["current"]) && empty($shows["next"])) {
|
if (is_null($futureShow) && is_null($currentShow)) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
if ($shows["current"]) {
|
if ($currentShow) {
|
||||||
$scheduledTracks = CcScheduleQuery::create()
|
$scheduledTracks = CcScheduleQuery::create()
|
||||||
->filterByDbInstanceId($shows["current"]["instance_id"])
|
->filterByDbInstanceId($currentShow->getDbId())
|
||||||
->find();
|
->find();
|
||||||
if ($scheduledTracks->count() == 0) {
|
if ($scheduledTracks->count() == 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if ($shows["next"]) {
|
} else if ($futureShow) {
|
||||||
$nextShow = $shows["next"][0];
|
|
||||||
$scheduledTracks = CcScheduleQuery::create()
|
$scheduledTracks = CcScheduleQuery::create()
|
||||||
->filterByDbInstanceId($nextShow["instance_id"])
|
->filterByDbInstanceId($futureShow->getDbId())
|
||||||
->find();
|
->find();
|
||||||
if ($scheduledTracks->count() == 0) {
|
if ($scheduledTracks->count() == 0) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -74,4 +65,26 @@ class Application_Common_UsabilityHints
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static function getCurrentShow()
|
||||||
|
{
|
||||||
|
$now = new DateTime("now", new DateTimeZone("UTC"));
|
||||||
|
|
||||||
|
return CcShowInstancesQuery::create()
|
||||||
|
->filterByDbStarts($now, Criteria::LESS_THAN)
|
||||||
|
->filterByDbEnds($now, Criteria::GREATER_THAN)
|
||||||
|
->filterByDbModifiedInstance(false)
|
||||||
|
->findOne();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function getNextFutureShow()
|
||||||
|
{
|
||||||
|
$now = new DateTime("now", new DateTimeZone("UTC"));
|
||||||
|
|
||||||
|
return CcShowInstancesQuery::create()
|
||||||
|
->filterByDbStarts($now, Criteria::GREATER_THAN)
|
||||||
|
->filterByDbModifiedInstance(false)
|
||||||
|
->orderByDbStarts()
|
||||||
|
->findOne();
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue