protected function setupTemplate() { global $cfg; parent::setupTemplate(); $db = Database::getInstance($cfg['DPS']['dsn']); $offset = $this->fieldData['dpsSearchPage']; if ($offset == "") { $offset = 0; } else { $offset--; } $searchValue = trim($this->fieldData['dpsSearchVal']); $searchType = $this->fieldData['dpsSearchType']; $letter = pg_escape_string($this->fieldData['dpsSearchLetter']); if ($searchType == '' && $letter != '') { if ($letter == "*") { $searchType = 'Number'; } else { $searchType = 'Letter'; } } if ($this->fieldData['dpsSortType'] != '') { $sesh = Session::getInstance(); $sortType = $this->fieldData['dpsSortType']; $sesh->setValue("dpsSortType", $sortType); } else { $sesh = Session::getInstance(); if ($sesh->keyExists("dpsSortType")) { $sortType = $sesh->getValue("dpsSortType"); } else { $sortType = "title"; } } if ($searchValue != '') { $searchResult = DPS::searchAudio($searchValue, $searchType, $sortType, $offset, ''); $rNum = DPS::searchPageAudio($searchValue, $searchType, ''); $searchInfo = "Found {$rNum} results matching your query"; } $pages = ceil($rNum / $cfg['DPS']['resultLimit']); //fill the $pageArray array with values from 1 to $pages $pageArray = range(1, $pages); $auth = Auth::getInstance(); $userID = $auth->getUserID(); $this->assign('RequestTrack', AuthUtil::getDetailedUserrealmAccess(array(3, 21, 29), $userID)); $this->assign('CensorTrack', AuthUtil::getDetailedUserrealmAccess(array(3, 21, 30), $userID)); $this->assign('ReportTrack', AuthUtil::getDetailedUserrealmAccess(array(3, 21, 43), $userID)); $this->assign('EditTrack', AuthUtil::getDetailedUserrealmAccess(array(3, 21, 27), $userID)); $this->assign('DeleteTrack', AuthUtil::getDetailedUserrealmAccess(array(2, 21, 32), $userID)); $this->assign('Admin', AuthUtil::getDetailedUserrealmAccess(array(1), $userID)); $this->assign('page', $offset); $this->assign('searchResult', $searchResult); $this->assign('searchInfo', $searchInfo); $this->assign('pages', $pageArray); $this->assign('searchType', $searchType); $this->assign('searchValue', $searchValue); $this->assign('sortType', $sortType); }
protected function setupTemplate() { global $cfg; parent::setupTemplate(); $db = Database::getInstance($cfg['DPS']['dsn']); $offset = $this->fieldData['dpsSearchPage']; if ($offset == "") { $offset = 0; } else { $offset--; } $searchValue = $this->fieldData['dpsSearchVal']; $searchType = $this->fieldData['dpsSearchType']; $letter = pg_escape_string($this->fieldData['dpsSearchLetter']); if ($searchType == '' && $letter != '') { if ($letter == "*") { $searchType = 'Number'; } else { $searchType = 'Letter'; } $searchValue = $letter; } if ($this->fieldData['dpsSortType'] != '') { $sesh = Session::getInstance(); $sortType = $this->fieldData['dpsSortType']; $sesh->setValue("dpsSortType", $sortType); } else { $sesh = Session::getInstance(); if ($sesh->keyExists("dpsSortType")) { $sortType = $sesh->getValue("dpsSortType"); } else { $sortType = "title"; } } if ($searchValue != '') { $searchResult = DPS::searchAudio($searchValue, $searchType, $sortType, $offset, ''); $rNum = DPS::searchPageAudio($searchValue, $searchType, ''); $searchInfo = "Found {$rNum} results matching your query"; } $pages = 1; $pageArray[] = $pages; $rNum = $rNum - $cfg['DPS']['resultLimit']; while ($rNum > $cfg['DPS']['resultLimit']) { $pages++; $pageArray[] = $pages; $rNum = $rNum - $cfg['DPS']['resultLimit']; } //Sue playing now/next $query = "SELECT audio.title AS title, audio.id AS id \n\t\tFROM sustschedule, audio \n\t\tWHERE sustschedule.audioid = audio.id \n\t\tORDER BY sustschedule.id asc \n\t\tOFFSET 1 \n\t\tLIMIT 1"; $sueNextTrack = $db->getRow($query); if ($sueNextTrack != '') { $sql = "SELECT DISTINCT artists.name AS name \n\t\t\tFROM artists, audioartists \n\t\t\tWHERE audioartists.audioid = " . $sueNextTrack['id'] . " \n\t\t\tAND audioartists.artistid = artists.id"; $artists = $db->getAll($sql); foreach ($artists as $artist) { $sueNextTrack['artist'] = $sueNextTrack['artist'] . $artist['name'] . " & "; } $sueNextTrack['artist'] = rtrim($sueNextTrack['artist'], " & "); } $auth = Auth::getInstance(); $userID = $auth->getUserID(); $this->assign('Access_ViewSue', AuthUtil::getDetailedUserrealmAccess(array(26, 20, 3), $userID)); $this->assign('Access_EditSue', AuthUtil::getDetailedUserrealmAccess(array(24, 20, 3), $userID)); $this->assign('Admin', AuthUtil::getDetailedUserrealmAccess(array(1), $userID)); $this->assign('Access_EditTrack', AuthUtil::getDetailedUserrealmAccess(array(27, 21, 3), $userID)); $this->assign('Access_SueStats', AuthUtil::getDetailedUserrealmAccess(array(25, 20, 3), $userID)); $this->assign('Access_Delete', AuthUtil::getDetailedUserrealmAccess(array(32, 21, 3), $userID)); $this->assign('sueNextTrack', $sueNextTrack); $this->assign('page', $offset); $this->assign('searchResult', $searchResult); $this->assign('searchInfo', $searchInfo); $this->assign('pages', $pageArray); $this->assign('searchType', $searchType); $this->assign('searchValue', $searchValue); $this->assign('searchLetter', $letter); $this->assign('sortType', $sortType); }
protected function setupTemplate() { global $cfg; parent::setupTemplate(); $db = Database::getInstance($cfg['DPS']['dsn']); $playlistID = pg_escape_string($this->fieldData['dpsPlaylistID']); if ($playlistID == '' || !is_numeric($playlistID)) { $playlistID = 1; } $offset = $this->fieldData['dpsSearchPage']; if ($offset == "") { $offset = 0; } else { $offset--; } $resultType = $this->fieldData['dpsResultType']; $searchValue = $this->fieldData['dpsSearchVal']; $searchType = $this->fieldData['dpsSearchType']; if ($this->fieldData['dpsSortType'] != '') { $sesh = Session::getInstance(); $sortType = $this->fieldData['dpsSortType']; $sesh->setValue("dpsSortType", $sortType); } else { $sesh = Session::getInstance(); if ($sesh->keyExists("dpsSortType")) { $sortType = $sesh->getValue("dpsSortType"); } else { $sortType = "title"; } } if ($resultType == 'Search') { if ($searchValue != '') { $searchResult = DPS::searchPlaylistAudio($searchValue, $searchType, $sortType, $offset, '', $playlistID); $rNum = DPS::searchPageAudio($searchValue, $searchType, ''); //$searchInfo = "Found $rNum results matching your query"; } } else { if ($resultType == 'View') { $searchResult = DPS::showPlaylist($playlistID, $sortType, $offset); $rNum = DPS::countPlaylist($playlistID); //$searchInfo = "Found $rNum results in the playlist"; } } $pages = ceil($rNum / $cfg['DPS']['resultLimit']); //fill the array $pageArray with values from 1 to $pages (default increment is 1) $pageArray = range(1, $pages); $sql = "SELECT * FROM playlists"; $playlists = $db->getAll($sql); $auth = Auth::getInstance(); $userID = $auth->getUserID(); $sql = "SELECT * FROM playlists WHERE id = " . pg_escape_string($playlistID); $playlist = $db->getRow($sql); $this->assign('Admin', AuthUtil::getDetailedUserrealmAccess(array(1), $userID)); $this->assign('studioAccess', AuthUtil::getDetailedUserrealmAccess(array(3, 21, 33), $userID)); $this->assign('playlists', $playlists); $this->assign('playlist', $playlist); $this->assign('page', $offset); $this->assign('searchResult', $searchResult); $this->assign('searchInfo', $searchInfo); $this->assign('pages', $pageArray); $this->assign('searchType', $searchType); $this->assign('searchValue', $searchValue); $this->assign('sortType', $sortType); $this->assign('resultType', $resultType); }
protected function setupTemplate() { global $cfg; parent::setupTemplate(); $db = Database::getInstance($cfg['DPS']['dsn']); $itemID = pg_escape_string($this->fieldData['itemID']); $auth = Auth::getInstance(); $userID = $auth->getUserID(); $date = time(); if (is_numeric($itemID) && isset($itemID)) { $show_query = "SELECT DISTINCT BIT_OR(v_tree_showplan.permissions) \n\t\t\tFROM showitems, v_tree_showplan \n\t\t\tWHERE showitems.showplanid = v_tree_showplan.id AND \n\t\t\t\tv_tree_showplan.userid = {$userID} AND \n\t\t\t\tshowitems.id = {$itemID}"; $checkShows = $db->getOne($show_query); if (substr($checkShows, 0, 1) == "1") { if (substr($checkShows, 1, 1) == "1") { $this->assign('write', 't'); } else { $this->assign('write', 'f'); } $show_sql = "SELECT showplans.*\n\t\t\t\t\tFROM showplans, showitems\n\t\t\t\t\tWHERE showitems.showplanid = showplans.id\n\t\t\t\t\tAND showitems.id = " . $itemID; $show = $db->getRow($show_sql); $show['niceAirDate'] = date("d/m/y", $show['showdate']); $show['niceAirTime'] = date("g a", $show['showdate']); $show['niceCreateDate'] = date("d/m/y", $show['creationdate']); $show['niceCreateTime'] = date("g a", $show['creationdate']); $items_sql = "SELECT * FROM showitems\n\t\t\t\t\tWHERE showplanid = " . $show['id'] . "\n\t\t\t\t\tORDER BY position ASC"; $items = $db->getAll($items_sql); $time = $show['showdate']; $i = 0; foreach ($items as &$item) { if ($item['id'] == $itemID) { $item['time'] = $time; $item['niceTime'] = date("H:i:s", $item['time']); $item['niceLength'] = (int) ($item['length'] / 60) . ":" . ($item['length'] - (int) ($item['length'] / 60) * 60); if ($item['audio'] != '') { $sql = "SELECT audio.title AS title,\n\t\t\t\t\t\t\t\taudiotypes.name AS type,\n\t\t\t\t\t\t\t\taudio.length_smpl AS len FROM audio, audiotypes\n\t\t\t\t\t\t\t\tWHERE audio.type = audiotypes.id\n\t\t\t\t\t\t\t\tAND audio.id = " . $item['audio']; $stuff = $db->getRow($sql); $item['audioTitle'] = $stuff['title']; $item['nature'] = $stuff['type']; $item['niceAudioLength'] = round($stuff['len'] / 44100 / 60) . ":" . $stuff['len'] / 44100 % 60; } else { $item['nature'] = 'unknown'; } if ($item['script'] != '') { $sql = "SELECT name, length from scripts\n\t\t\t\t\t\t\t\tWHERE id = " . $item['script']; $stuff = $db->getRow($sql); $item['scriptName'] = $stuff['name']; $item['niceScriptLength'] = (int) ($stuff['length'] / 60) . ":" . ($stuff['length'] - (int) ($stuff['length'] / 60) * 60); } break; } $time = $time + $item['length']; $i++; } $offset = $this->fieldData['dpsSearchPage']; if ($offset == "") { $offset = 0; } else { $offset--; } $searchValue = $this->fieldData['dpsSearchVal']; $searchType = $this->fieldData['dpsSearchType']; if ($this->fieldData['dpsSortType'] != '') { $sesh = Session::getInstance(); $sortType = $this->fieldData['dpsSortType']; $sesh->setValue("dpsSortType", $sortType); } else { $sesh = Session::getInstance(); if ($sesh->keyExists("dpsSortType")) { $sortType = $sesh->getValue("dpsSortType"); } else { $sortType = "title"; } } if ($searchValue != '') { $searchResult = DPS::searchAudio($searchValue, $searchType, $sortType, $offset, ''); $rNum = DPS::searchPageAudio($searchValue, $searchType, ''); } $pages = 1; $pageArray[] = $pages; $rNum = $rNum - $cfg['DPS']['resultLimit']; while ($rNum > $cfg['DPS']['resultLimit']) { $pages++; $pageArray[] = $pages; $rNum = $rNum - $cfg['DPS']['resultLimit']; } $this->assign('page', $offset); $this->assign('searchResult', $searchResult); $this->assign('searchInfo', $searchInfo); $this->assign('pages', $pageArray); $this->assign('searchType', $searchType); $this->assign('searchValue', $searchValue); $this->assign('sortType', $sortType); $this->assign('show', $show); $this->assign('item', $items[$i]); } else { $this->assign('error', 'You do not have permission to edit that item.'); } } else { $this->assign('error', 'Invalid Item ID supplied'); } $this->assign('Admin', AuthUtil::getDetailedUserrealmAccess(array(1), $userID)); }