Skip to content

Commit

Permalink
Merge pull request #1032 from UniversityRadioYork/mstratford/welcome
Browse files Browse the repository at this point in the history
UI fixes and niceties.
  • Loading branch information
mstratford authored Oct 17, 2022
2 parents afcdb8c + 9e3356f commit 0106699
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 39 deletions.
25 changes: 21 additions & 4 deletions src/Classes/ServiceAPI/MyRadio_Timeslot.php
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,10 @@ public function getTimeslotAfter($filter = [1])
}

/**
* Returns the currently selected timeslot (from the navbar).
*
* @return array Time, id If null, no timeslot is selected/user is logged out.
*/
* Returns the currently selected timeslot (from the navbar).
*
* @return MyRadio_Timeslot|null If null, user has no selected timeslot.
*/
public static function getUserSelectedTimeslot()
{
if (isset($_SESSION['timeslotid'])) {
Expand All @@ -280,6 +280,23 @@ public static function getUserSelectedTimeslot()
return null;
}

/**
* Sets the current user selected timeslot. NOTE: No auth checking here.
*
* @param MyRadioTimeslot|null $timeslot The timeslot (or none) to set the current user timeslot to.
*
* @return MyRadio_Timeslot|null If null, user has no selected timeslot.
*/
public static function setUserSelectedTimeslot($timeslot = null) {
if ($timeslot) {
$_SESSION['timeslotid'] = $timeslot->getID();
$_SESSION['timeslotname'] = CoreUtils::happyTime($timeslot->getStartTime());
} else {
$_SESSION['timeslotid'] = null;
$_SESSION['timeslotname'] = null;
}
}

/**
* Sets a metadata key to the specified value.
*
Expand Down
2 changes: 1 addition & 1 deletion src/Controllers/MyRadio/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
$events = MyRadio_Event::getNext(3);

$twig = CoreUtils::getTemplateObject()->setTemplate('MyRadio/menu.twig')
->addVariable('title', 'Menu')
->addVariable('title', 'Welcome to '.Config::$short_name.', '. $user->getFName(). '!')
->addVariable('menu', $menu)
->addVariable('news_clickthrough', $news_clickthrough)
/*
Expand Down
11 changes: 11 additions & 0 deletions src/Controllers/MyRadio/impersonate.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use \MyRadio\Config;
use \MyRadio\MyRadio\AuthUtils;
use \MyRadio\ServiceAPI\MyRadio_User;
use \MyRadio\ServiceAPI\MyRadio_Timeslot;

if (isset($_REQUEST['memberid'])) {
//Impersonate
Expand All @@ -32,10 +33,20 @@
$_SESSION['name'] = $impersonatee->getName();
$_SESSION['email'] = $impersonatee->getEmail();
$_SESSION['auth_use_locked'] = false;

// Now to reset the timeslot if we should have it once impersonated.
$timeslot = MyRadio_Timeslot::getUserSelectedTimeslot();
if ($timeslot) {
//Can the user access this timeslot?
if (!($timeslot->isCurrentUserAnOwner() || AuthUtils::hasPermission(AUTH_EDITSHOWS))) {
MyRadio_Timeslot::setUserSelectedTimeslot(); // Don't have perms, reset it.
}
}
}
} elseif (isset($_SESSION['myradio-impersonating'])) {
//Unimpersonate
$impersonate = $_SESSION['myradio-impersonating'];
// This will jump back the selected timeslot back too.
$_SESSION = $impersonate;
}

Expand Down
5 changes: 2 additions & 3 deletions src/Controllers/MyRadio/timeslot.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ function setupTimeslot(MyRadio_Timeslot $timeslot)
$message = "You don't have permission to view this show";
require_once 'Controllers/Errors/403.php';
} else {
$_SESSION['timeslotid'] = $timeslot->getID();
$_SESSION['timeslotname'] = CoreUtils::happyTime($timeslot->getStartTime());
MyRadio_Timeslot::setUserSelectedTimeslot($timeslot);
//Handle sign-ins
foreach (($_REQUEST['signin'] ?? []) as $memberid) {
if (!isset($_REQUEST["location"]) || $_REQUEST["location"] == "unselected") {
Expand All @@ -55,7 +54,7 @@ function setupTimeslot(MyRadio_Timeslot $timeslot)
//Submitted Current
setupTimeslot(MyRadio_Timeslot::getCurrentTimeslot());
} elseif (!empty(Config::$contract_uri) && !MyRadio_User::getInstance()->hasSignedContract()) {
$message = "You need to have signed the Presenter's Contract to view this";
$message = "You need to have signed the Presenter's Contract to view this. You'll find it in the main menu.";
require_once 'Controllers/Errors/403.php';
} else {
//Not Submitted
Expand Down
2 changes: 1 addition & 1 deletion src/Menus/menu.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
{
"title": "Audio Logger",
"url": "/loggerng/",
"description": "Download a high-quality log."
"description": "Download a high-quality audio log of your show."
},
{
"title": "List My Shows",
Expand Down
30 changes: 0 additions & 30 deletions src/Templates/NIPSWeb/manage_library.twig

This file was deleted.

0 comments on commit 0106699

Please sign in to comment.