Skip to content
Permalink
Browse files

fixed command dispatching for PR #60

fixed #62 Add Air Name failures
fixed #61 Add Air Name is not preselecting added airname
  • Loading branch information...
RocketMan committed Sep 15, 2019
1 parent 25b4147 commit b29bd7cef46cc624ec52f684a2213a5e5b1837df
Showing with 35 additions and 33 deletions.
  1. +2 −7 config/ui_config.php
  2. +33 −26 ui/Playlists.php
@@ -41,18 +41,13 @@
[ 'a', 'searchReview%', 0, ZK\UI\Reviews::class ],
[ 'a', 'addmgr', 'A-File', ZK\UI\AddManager::class ],
[ 'u', 'newList%', 'New Playlist', ZK\UI\Playlists::class ],
[ 'u', 'addAirname%', '0', ZK\UI\Playlists::class ],
[ 'u', 'addAirnamePost%','0', ZK\UI\Playlists::class ],
[ 'u', 'editList%', '0', ZK\UI\Playlists::class ],
[ 'u', 'deleteList%', '0', ZK\UI\Playlists::class ],
[ 'u', 'restoreList%', '0', ZK\UI\Playlists::class ],
[ 'u', 'editListSel%', 'Edit Playlist', ZK\UI\Playlists::class ],
[ 'u', 'editList%', 'Edit Playlist', ZK\UI\Playlists::class ],
[ 'u', 'showLink', 'Link to Playlist', ZK\UI\Playlists::class ],
[ 'u', 'importExport', 'Import/Export', ZK\UI\Playlists::class ],
[ 'a', 'viewDJ%', 'DJ Zone!', ZK\UI\Playlists::class ],
[ 'a', 'viewDate', 'Playlists by Date', ZK\UI\Playlists::class ],
[ 'u', 'updateDJInfo', 'Update Profile', ZK\UI\Playlists::class ],
[ 'u', 'addTrack', '0', ZK\UI\Playlists::class ],
[ 'u', 'addTrack', 0, ZK\UI\Playlists::class ],
[ 'U', 'changePass', 'Change Password', ZK\UI\ChangePass::class ],
[ 'p', 'deepStorage', 'Deep Storage', ZK\UI\DeepStorage::class ],
[ 'x', 'adminUsers', 'Administer Users', ZK\UI\UserAdmin::class ],
@@ -37,25 +37,30 @@
class Playlists extends MenuItem {
//NOTE: update ui_config.php when changing the actions.
private static $actions = [
[ "newList", "emitEditList" ],
[ "editList", "emitEditList" ],
[ "deleteList", "handleDeleteListPost" ],
[ "restoreList", "handleRestoreListPost" ],
[ "editListPost", "handleListPost" ],
[ "addAirname", "emitNewAirName"],
[ "addAirnamePost", "handleAirnamePost"],
[ "editListSel", "emitEditListPicker" ],
[ "newList", "newOrEditList" ],
[ "newListEditor", "emitEditor" ],
[ "newListPost", "handleListPost" ],
[ "editList", "emitEditListPicker" ],
[ "editListDelete", "handleDeleteListPost" ],
[ "editListDetails", "newOrEditList" ],
[ "editListDetailsPost", "handleListPost" ],
[ "editListEditor", "emitEditor" ],
[ "showLink", "emitShowLink" ],
[ "editListRestore", "handleRestoreListPost" ],
[ "importExport", "emitImportExportList" ],
[ "showLink", "emitShowLink" ],
[ "viewDJ", "emitViewDJ" ],
[ "viewDJReviews", "viewDJReviews" ],
[ "viewDate", "emitViewDate" ],
[ "updateDJInfo", "updateDJInfo" ],
[ "addTrack", "handleAddTrack" ],
];
private static $newOrEditSubactions = [
[ "", "emitEditList" ],
[ "addAirname", "emitNewAirName" ],
[ "addAirnamePost", "handleAirNamePost" ],
];
private $action;
private $subaction;
@@ -334,11 +339,11 @@ private function emitEditListForm($airName, $description, $zkTimeRange, $date, $
</div>
<div>
<label></label>
<a style='font-size:10px' href='?session=<?php echo $this->session->getSessionID();?>&amp;action=addAirname&amp;playlist=<?php echo $playlistId;?>' >Add Air Name</a>
<a style='font-size:10px' href='?session=<?php echo $this->session->getSessionID();?>&amp;action=<?php echo $this->action;?>&amp;subaction=addAirname&amp;playlist=<?php echo $playlistId;?>' >Add Air Name</a>
</div>

<INPUT id='show-date' TYPE=HIDDEN NAME='date' VALUE="">
<INPUT TYPE=HIDDEN NAME=action VALUE="editListPost">
<INPUT TYPE=HIDDEN NAME=action VALUE="<?php echo $this->action; ?>Post">
<INPUT id='playlist-id' TYPE=HIDDEN NAME=playlist VALUE="<?php echo $playlistId;?>">
<INPUT TYPE=HIDDEN NAME=session VALUE="<?php echo $this->session->getSessionID();?>">
</FORM>
@@ -404,7 +409,7 @@ public function emitNewAirName() {
$this->emitNewAirNameForm(null);
}
public function emitNewAirNameForm($errorMsg) {
public function emitNewAirNameForm($errorMessage) {
?>
<DIV CLASS='playlistBanner'>&nbsp; Add Air Name</div>
<?php echo $errorMessage; ?>
@@ -417,9 +422,11 @@ public function emitNewAirNameForm($errorMsg) {
<label></label>
<INPUT TYPE=SUBMIT NAME="newairname" VALUE=" Submit Air Name ">
</div>


<INPUT TYPE=HIDDEN NAME=playlist VALUE="<?php echo $_REQUEST["playlist"];?>">
<INPUT TYPE=HIDDEN NAME=session VALUE="<?php echo $this->session->getSessionID();?>">
<INPUT TYPE=HIDDEN NAME=action VALUE="addAirnamePost">
<INPUT TYPE=HIDDEN NAME=action VALUE="<?php echo $this->action;?>">
<INPUT TYPE=HIDDEN NAME=subaction VALUE="addAirnamePost">
</FORM>
<?php
}
@@ -430,8 +437,8 @@ public function handleAirNamePost() {
$playlistId = trim($_REQUEST["playlist"]);
$success = Engine::api(IDJ::class)->insertAirname($djname, $this->session->getUser());
if($success > 0) {
$airname = Engine::lastInsertId();
$this->emitEditList();
$this->action = $playlistId?"editListDetails":"newList";
$this->emitEditList($djname);
} else {
$errorMessage = "<B><FONT CLASS='error'>'$djname' is invalid or already exists.</FONT></B>";
$this->emitNewAirNameForm($errorMessage);
@@ -491,10 +498,13 @@ private function getDJAirNames($airName) {
return $airNames;
}
public function newOrEditList() {
$this->dispatchAction($this->subaction, self::$newOrEditSubactions);
}
// build the form used to add/modify playlist meta data
public function emitEditList() {
public function emitEditList($airName='') {
$playlistId = $_REQUEST["playlist"];
$airName = '';
$description = '';
$date = '';
$time = '';
@@ -523,7 +533,8 @@ public function emitEditList() {
$description = $sourcePlaylist['description'];
$date = $sourcePlaylist['showdate'];
$time = $sourcePlaylist['showtime'];
$airName = $sourcePlaylist['airname'];
if(!$airName)
$airName = $sourcePlaylist['airname'];
}
$this->emitEditListForm($airName, $description, $time, $date, $playlistId, null);
@@ -568,10 +579,6 @@ private function getDeletedPlaylistCount() {
return Engine::api(IPlaylist::class)->getDeletedPlaylistCount($this->session->getUser());
}
public function emitEditListNew() {
$this->emitEditList(0);
}
public function handleDeleteListPost() {
$playlistId = $_REQUEST["playlist"];
Engine::api(IPlaylist::class)->deletePlaylist($playlistId);
@@ -622,7 +629,7 @@ public function emitEditListPicker() {
<div style='margin-top:4px'>
<input TYPE=SUBMIT VALUE=" Restore ">
</div>
<input TYPE=hidden name=action VALUE="restoreList">
<input TYPE=hidden name=action VALUE="editListRestore">
<input TYPE=hidden name=session VALUE="<?php echo $this->session->getSessionID();?>">
</form>
@@ -636,7 +643,7 @@ public function emitEditListPicker() {
<input id='delete-list' TYPE=BUTTON VALUE="Delete">
</div>
<input TYPE=hidden name=session VALUE="<?php echo $this->session->getSessionID();?>">
<input id='action-type' TYPE=hidden name=action VALUE="editList">
<input id='action-type' TYPE=hidden name=action VALUE="editListDetails">
</form>
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript"><!--
@@ -661,7 +668,7 @@ function setFocus(){}
$("#delete-list").click(function() {
if (confirm("Are your sure?")) {
$("#action-type").val('deleteList');
$("#action-type").val('editListDelete');
$("#active-form").submit();
}
});

0 comments on commit b29bd7c

Please sign in to comment.
You can’t perform that action at this time.