protected function setupTemplate()
 {
     global $cfg;
     parent::setupTemplate();
     $db = Database::getInstance($cfg['DPS']['dsn']);
     $scriptID = pg_escape_string($this->fieldData['scriptID']);
     $auth = Auth::getInstance();
     $userID = $auth->getUserID();
     $date = time();
     if (is_numeric($scriptID)) {
         $script_query = "SELECT bit_or(permissions) \n\t\t\t\tFROM v_tree_script\n\t\t\t\tWHERE id = {$scriptID}\n\t\t\t\t\tAND userid = {$userID}";
         $checkScripts = $db->getOne($script_query);
         if (substr($checkScripts, 0, 1) == "1") {
             if (substr($checkScripts, 1, 1) == "1") {
                 $this->assign('write', 't');
             } else {
                 $this->assign('write', 'f');
             }
             $script_sql = "SELECT * FROM scripts WHERE id = " . $scriptID;
             $script = $db->getRow($script_sql);
             $script['m'] = (int) ($script['length'] / 60);
             $script['s'] = $script['length'] - $script['m'] * 60;
             $script['niceProducer'] = AuthUtil::getUsername($script['creator']);
             $this->assign('script', $script);
         } else {
             $this->assign('error', 'You do not have permission to edit that script.');
         }
     } else {
         $this->assign('error', 'Invalid Show ID supplied');
     }
     $this->assign('Admin', AuthUtil::getDetailedUserrealmAccess(array(1), $userID));
 }
 protected function setupTemplate()
 {
     global $cfg;
     parent::setupTemplate();
     $db = Database::getInstance($cfg['DPS']['dsn']);
     $count_query = "SELECT count(*) FROM requests";
     $requestedNum = $db->getOne($count_query);
     $query = "SELECT * FROM requests ORDER BY date DESC";
     $requestedResult = $db->getAll($query);
     $i = 0;
     foreach ($requestedResult as $key => &$track) {
         $track['number'] = $i;
         $track['rtime'] = date("m/d/y", $track['date']);
         $track['user'] = AuthUtil::getUsername($track['userid']);
         $i++;
     }
     $trackCount = $i;
     $auth = Auth::getInstance();
     $userID = $auth->getUserID();
     $this->assign('CensorTrack', AuthUtil::getDetailedUserrealmAccess(array(3, 21, 30), $userID));
     $this->assign('RequestTrack', 't');
     $this->assign('RemoveRequestTrack', AuthUtil::getDetailedUserrealmAccess(array(3, 21, 29), $userID));
     $this->assign('Admin', AuthUtil::getDetailedUserrealmAccess(array(1), $userID));
     $this->assign('requestedTracks', $requestedResult);
     $this->assign('requestedNum', $requestedNum);
 }
 protected function setupTemplate()
 {
     global $cfg;
     parent::setupTemplate();
     $db = Database::getInstance($cfg['DPS']['dsn']);
     $trackIDs = explode(";", $this->fieldData['trackID']);
     $tracksDetails = array();
     foreach ($trackIDs as $trackID) {
         $sql = "SELECT audio.*, albums.name AS album \n\t\t\tFROM audio, albums \n\t\t\tWHERE audio.music_album = albums.id \n\t\t\t\tAND audio.id = " . pg_escape_string($trackID);
         $trackDetails = $db->getRow($sql);
         $sql = "SELECT DISTINCT artists.name AS name \n\t\t\tFROM artists, audioartists \n\t\t\tWHERE audioartists.audioid = " . pg_escape_string($trackID) . " \n\t\t\t\tAND audioartists.artistid = artists.id";
         $trackDetails['artist'] = $db->getColumn($sql);
         $sql = "SELECT DISTINCT keywords.name AS name \n\t\t\tFROM keywords, audiokeywords \n\t\t\tWHERE audiokeywords.audioid = " . pg_escape_string($trackID) . " \n\t\t\t\tAND audiokeywords.keywordid = keywords.id";
         $trackDetails['keywords'] = $db->getColumn($sql);
         $samples = $trackDetails['length_smpl'];
         $trackDetails['length'] = $tracksLen = round($samples / 44100 / 60) . "mins " . $samples / 44100 % 60 . "secs.";
         $sql = "SELECT * FROM audiocomments \n\t\t\tWHERE audioid = " . pg_escape_string($trackID) . " \n\t\t\tORDER BY creationdate ASC";
         $trackDetails['comments'] = $db->getAll($sql);
         foreach ($trackDetails['comments'] as &$comment) {
             $comment['username'] = AuthUtil::getUsername($comment['userid']);
             $comment['comment'] = str_replace("\n", "<br>", $comment['comment']);
             $comment['ctime'] = substr($comment['creationdate'], 0, 10);
         }
         $tracksDetails[] = $trackDetails;
     }
     $auth = Auth::getInstance();
     $userID = $auth->getUserID();
     $this->assign('RequestTrack', AuthUtil::getDetailedUserrealmAccess(array(3, 21, 29), $userID));
     $this->assign('Access_CommentTrack', AuthUtil::getDetailedUserrealmAccess(array(3, 21, 34), $userID));
     $this->assign('Access_EditTrack', AuthUtil::getDetailedUserrealmAccess(array(3, 21, 27), $userID));
     $this->assign('Admin', AuthUtil::getDetailedUserrealmAccess(array(1), $userID));
     $this->assign('tracksDetails', $tracksDetails);
 }
 protected function setupTemplate()
 {
     global $cfg;
     parent::setupTemplate();
     $db = Database::getInstance($cfg['DPS']['dsn']);
     $auth = Auth::getInstance();
     $userID = $auth->getUserID();
     $loc = 1;
     $sql = "SELECT v_tree_aw_sets.*, aw_sets_users.user_id AS userid\n                from v_tree_aw_sets LEFT OUTER JOIN aw_sets_users\n                ON aw_sets_users.set_id = v_tree_aw_sets.id\n\t\t\tWHERE v_tree_aw_sets.userid = " . $cfg['DPS']['systemUserID'] . " \n\t\t\t\tAND v_tree_aw_sets.permissions & B'" . $cfg['DPS']['fileR'] . "' = '" . $cfg['DPS']['fileR'] . "'";
     // station awsets
     $awsets = $db->getAll($sql);
     $sql = "SELECT val FROM configuration \n\t\t\tWHERE location = {$loc} \n\t\t\t\tAND parameter = 'station_aw_set'";
     $userset = $db->getOne($sql);
     foreach ($awsets as &$awset) {
         if ($userset == $awset['id']) {
             $awset['active'] = 't';
         } else {
             $awset['active'] = 'f';
         }
         $sql = "SELECT BIT_OR(permissions) \n\t\t\t\tFROM v_tree_dir \n\t\t\t\tWHERE v_tree_dir.id = {$awset['parent']}\n\t\t\t\t\tAND v_tree_dir.userid = {$cfg['DPS']['systemUserID']}";
         $awset['parentperm'] = $db->getOne($sql);
         $awset['userid'] = AuthUtil::getUsername($awset['userid']);
     }
     $this->assign('access_playlist', AuthUtil::getDetailedUserrealmAccess(array(3, 21, 33), $userID));
     $this->assign('Admin', AuthUtil::getDetailedUserrealmAccess(array(1), $userID));
     $this->assign('awsets', $awsets);
 }
 protected function setupTemplate()
 {
     global $cfg;
     parent::setupTemplate();
     $db = Database::getInstance($cfg['DPS']['dsn']);
     $trackID = $this->fieldData['trackID'];
     $auth = Auth::getInstance();
     $userID = $auth->getUserID();
     //As there is no general audio view
     $sql = "SELECT count(*) FROM v_tree_jingle \n\t\t\tWHERE id = " . pg_escape_string($trackID) . " \n\t\t\t\tAND userid = " . $userID . " \n\t\t\t\tAND permissions & B'" . $cfg['DPS']['fileW'] . "' = '" . $cfg['DPS']['fileW'] . "'";
     $check = $db->getOne($sql);
     $sql = "SELECT count(*) FROM v_tree_advert \n\t\t\tWHERE id = " . pg_escape_string($trackID) . " \n\t\t\t\tAND userid = " . $userID . " \n\t\t\t\tAND permissions & B'" . $cfg['DPS']['fileW'] . "' = '" . $cfg['DPS']['fileW'] . "'";
     $check = $check + $db->getOne($sql);
     $sql = "SELECT count(*) FROM v_tree_prerec \n\t\t\tWHERE id = " . pg_escape_string($trackID) . " \n\t\t\t\tAND userid = " . $userID . " \n\t\t\t\tAND permissions & B'" . $cfg['DPS']['fileW'] . "' = '" . $cfg['DPS']['fileW'] . "'";
     $check = $check + $db->getOne($sql);
     if ($check < 1) {
         $this->assign('authError', 't');
     } else {
         $sql = "SELECT audio.* FROM audio \n\t\t\t\tWHERE audio.id = " . pg_escape_string($trackID);
         $trackDetails = $db->getRow($sql);
         $sql = "SELECT DISTINCT artists.name AS name, artists.id AS id \n\t\t\t\tFROM artists, audioartists \n\t\t\t\tWHERE audioartists.audioid = " . pg_escape_string($trackID) . " \n\t\t\t\t\tAND audioartists.artistid = artists.id";
         $trackDetails['artist'] = $db->getAll($sql);
         $i = 0;
         foreach ($trackDetails['artist'] as &$artist) {
             $artist['number'] = $i;
             $i++;
         }
         $artistNum = $i;
         $sql = "SELECT DISTINCT keywords.name AS name, keywords.id AS id \n\t\t\t\tFROM keywords, audiokeywords \n\t\t\t\tWHERE audiokeywords.track = " . pg_escape_string($trackID) . " \n\t\t\t\t\tAND audiokeywords.keyword = keywords.id";
         $trackDetails['keywords'] = $db->getAll($sql);
         $i = 0;
         foreach ($trackDetails['keywords'] as &$keyword) {
             $keyword['number'] = $i;
             $i++;
         }
         $keywordNum = $i;
         $samples = $trackDetails['length_smpl'];
         $trackDetails['length'] = $tracksLen = floor($samples / 44100 / 60) . "mins " . $samples / 44100 % 60 . "secs.";
         $sql = "SELECT * from audiocomments \n\t\t\t\tWHERE audioid = " . pg_escape_string($trackID) . "\n\t\t\t\tORDER BY creationdate ASC";
         $trackDetails['comments'] = $db->getAll($sql);
         foreach ($trackDetails['comments'] as &$comment) {
             $comment['username'] = AuthUtil::getUsername($comment['userid']);
             $comment['comment'] = str_replace("\n", "<br>", $comment['comment']);
             $comment['ctime'] = substr($comment['creationdate'], 0, 10);
         }
         $this->assign('trackDetails', $trackDetails);
         $this->assign('keywordNum', $keywordNum);
         $this->assign('artistNum', $artistNum);
         $this->assign('trackID', $trackID);
     }
     $this->assign('access_playlist', AuthUtil::getDetailedUserrealmAccess(array(3, 21, 33), $userID));
     $this->assign('Admin', AuthUtil::getDetailedUserrealmAccess(array(1), $userID));
     $this->assign('studioAccess', AuthUtil::getDetailedUserrealmAccess(array(3, 21, 34), $userID));
 }
 protected function setupTemplate()
 {
     parent::setupTemplate();
     if (isset($this->fieldData['userToEdit'])) {
         $uid = $this->fieldData['userToEdit'];
         $this->assign('id', $uid);
     } else {
         $uid = null;
     }
     $this->assignCustomFields('users', $uid);
     if (isset($this->fieldData['userToEdit'])) {
         $this->assign('treeUser', 'user');
         $this->assign('groupinfo', $this->getGroupInfoForUser($uid));
         $this->assign('username', AuthUtil::getUsername($uid));
     }
     $this->assign('users', AuthUtil::getUserList());
 }
 protected function setupTemplate()
 {
     global $cfg;
     parent::setupTemplate();
     $db = Database::getInstance($cfg['DPS']['dsn']);
     $auth = Auth::getInstance();
     $userID = $auth->getUserID();
     $date = time();
     $show_query = "SELECT DISTINCT showplans.*, v_tree_showplan.permissions \n\t\t\tFROM showplans, v_tree_showplan \n\t\t\tWHERE showplans.id = v_tree_showplan.id AND \n\t\t\t\tv_tree_showplan.userid = {$userID} AND \n\t\t\t\tshowplans.showdate >= " . $date . " AND \n\t\t\t\tv_tree_showplan.permissions & B'" . $cfg['DPS']['fileR'] . "' = '" . $cfg['DPS']['fileR'] . "' \n\t\t\tORDER BY name asc";
     $partShows = $db->getAll($show_query);
     $show_query = "SELECT DISTINCT showplans.*, v_tree_showplan.permissions \n\t\t\tFROM showplans, v_tree_showplan \n\t\t\tWHERE showplans.id = v_tree_showplan.id AND \n\t\t\t\tv_tree_showplan.userid = {$userID} AND \n\t\t\t\tshowplans.showdate < " . $date . " AND \n\t\t\t\tv_tree_showplan.permissions & B'" . $cfg['DPS']['fileR'] . "' = '" . $cfg['DPS']['fileR'] . "' \n\t\t\tORDER BY name asc";
     $doneShows = $db->getAll($show_query);
     foreach ($partShows as &$show) {
         $show['niceAirDate'] = date("d/m/y", $show['showdate']);
         $show['niceAirTime'] = date("H:i", $show['showdate']);
         $show['niceCreateDate'] = date("d/m/y", $show['creationdate']);
         $show['niceCreateTime'] = date("H:i", $show['creationdate']);
         $show['text'] = $show['name'] . " - " . $show['niceAirDate'] . " - " . $show['niceAirTime'] . " (" . AuthUtil::getUsername($show['userid']) . ")";
         $sql = "SELECT BIT_OR(v_tree_dir.permissions) \n\t\t\t\tFROM v_tree_showplan, v_tree_dir \n\t\t\t\tWHERE v_tree_showplan.id = {$show['id']}\n\t\t\t\t\tAND v_tree_showplan.parent = v_tree_dir.id\n\t\t\t\t\tAND v_tree_dir.userid = {$userID}";
         $show['parentperm'] = $db->getOne($sql);
     }
     foreach ($doneShows as &$show) {
         $show['niceAirDate'] = date("d/m/y", $show['showdate']);
         $show['niceAirTime'] = date("H:i", $show['showdate']);
         $show['niceCreateDate'] = date("d/m/y", $show['creationdate']);
         $show['niceCreateTime'] = date("H:i", $show['creationdate']);
         $show['text'] = $show['name'] . " - " . $show['niceAirDate'] . " - " . $show['niceAirTime'] . " (" . AuthUtil::getUsername($show['userid']) . ")";
         $sql = "SELECT BIT_OR(v_tree_dir.permissions) \n\t\t\t\tFROM v_tree_showplan, v_tree_dir \n\t\t\t\tWHERE v_tree_showplan.id = {$show['id']}\n\t\t\t\t\tAND v_tree_showplan.parent = v_tree_dir.id\n\t\t\t\t\tAND v_tree_dir.userid = {$userID}";
         $show['parentperm'] = $db->getOne($sql);
     }
     $pShowCount = count($partShows);
     $dShowCount = count($doneShows);
     $this->assign('Admin', AuthUtil::getDetailedUserrealmAccess(array(1), $userID));
     $this->assign('partShows', $partShows);
     $this->assign('pShowCount', $pShowCount);
     $this->assign('doneShows', $doneShows);
     $this->assign('dShowCount', $dShowCount);
     $this->assign('deleteID', $this->fieldData['deleteID']);
 }
 protected function setupTemplate()
 {
     global $cfg;
     parent::setupTemplate();
     $db = Database::getInstance($cfg['DPS']['dsn']);
     $auth = Auth::getInstance();
     $userID = $auth->getUserID();
     $date = time();
     $script_query = "SELECT scripts.*, v_tree_script.permissions\n\t\t\t\tFROM v_tree_script, scripts\n\t\t\t\tWHERE v_tree_script.userid = {$userID}\n\t\t\t\t\tAND v_tree_script.id = scripts.id\n\t\t\t\t\tAND v_tree_script.permissions & B'{$cfg['DPS']['fileR']}' = '{$cfg['DPS']['fileR']}'\n\t\t\tORDER BY scripts.name asc";
     $scripts = $db->getAll($script_query);
     $scriptCount = count($scripts);
     foreach ($scripts as &$script) {
         $script['niceCreateDate'] = date("d/m/y", $script['creationdate']);
         $script['niceCreateTime'] = date("g a", $script['creationdate']);
         $script['text'] = $script['name'] . " - " . $script['niceCreateDate'] . " - " . $script['niceCreateTime'] . " (" . AuthUtil::getUsername($script['userid']) . ")";
         $sql = "SELECT BIT_OR(v_tree_dir.permissions) \n\t\t\t\tFROM v_tree_script, v_tree_dir \n\t\t\t\tWHERE v_tree_script.id = {$script['id']}\n\t\t\t\t\tAND v_tree_script.parent = v_tree_dir.id\n\t\t\t\t\tAND v_tree_dir.userid = {$userID}";
         $script['parentperm'] = $db->getOne($sql);
     }
     $this->assign('Admin', AuthUtil::getDetailedUserrealmAccess(array(1), $userID));
     $this->assign('scripts', $scripts);
     $this->assign('scriptCount', $scriptCount);
     $this->assign('deleteID', $this->fieldData['deleteID']);
 }
 protected function setupTemplate()
 {
     global $cfg;
     parent::setupTemplate();
     // user awsets
     $db = Database::getInstance($cfg['DPS']['dsn']);
     $auth = Auth::getInstance();
     $userID = $auth->getUserID();
     $loc = 1;
     $sql = "SELECT usersconfigs.val FROM configs, usersconfigs\n\t\t\tWHERE configs.id = usersconfigs.configid\n\t\t\t\tAND configs.name = 'default_aw_set'\n\t\t\t\tAND usersconfigs.userid = " . $userID;
     $userset = $db->getOne($sql);
     $sql = "SELECT val FROM configuration \n\t\t\tWHERE location = {$loc}\n\t\t\t\tAND parameter='station_aw_set'";
     $stationset = $db->getOne($sql);
     if ($stationset != '') {
         $sql = "SELECT aw_sets.id as id, aw_sets.name as name,\n\t\t\t\t\taw_sets.description as desc\n\t\t\t\tFROM aw_sets\n\t\t\t\tWHERE id = {$stationset}";
         $sawset = $db->getRow($sql);
     } else {
         $sawset = "None";
     }
     $sql = "SELECT v_tree_aw_sets.*, aw_sets_users.user_id AS userid\n                FROM v_tree_aw_sets LEFT OUTER JOIN aw_sets_users\n                ON aw_sets_users.set_id = v_tree_aw_sets.id\n\t\t\tWHERE v_tree_aw_sets.userid = {$userID} \n\t\t\t\tAND v_tree_aw_sets.permissions & B'" . $cfg['DPS']['fileR'] . "' = '" . $cfg['DPS']['fileR'] . "'";
     $awsets = $db->getAll($sql);
     foreach ($awsets as &$awset) {
         if ($userset == $awset['id']) {
             $awset['active'] = 't';
         } else {
             $awset['active'] = 'f';
         }
         $sql = "SELECT BIT_OR(permissions) \n\t\t\t\tFROM v_tree_dir \n\t\t\t\tWHERE v_tree_dir.id = {$awset['parent']}\n\t\t\t\t\tAND v_tree_dir.userid = {$userID}";
         $awset['parentperm'] = $db->getOne($sql);
         $awset['userid'] = AuthUtil::getUsername($awset['userid']);
     }
     $this->assign('access_playlist', AuthUtil::getDetailedUserrealmAccess(array(3, 21, 33), $userID));
     $this->assign('Admin', AuthUtil::getDetailedUserrealmAccess(array(1), $userID));
     $this->assign('studioAccess', AuthUtil::getDetailedUserrealmAccess(array(3, 21, 35), $userID));
     $this->assign('awsets', $awsets);
     $this->assign('stationawset', $sawset);
 }
 protected function setupTemplate()
 {
     global $cfg;
     parent::setupTemplate();
     $db = Database::getInstance($cfg['DPS']['dsn']);
     $showID = pg_escape_string($this->fieldData['showID']);
     $auth = Auth::getInstance();
     $userID = $auth->getUserID();
     $date = time();
     if (is_numeric($showID)) {
         $sql = "SELECT count(*) FROM v_tree_showplan\n\t\t\t\tWHERE id = {$showID}\n\t\t\t\t\tAND\tuserid = {$userID}\n\t\t\t\t\tAND permissions & B'" . $cfg['DPS']['fileR'] . "' = '" . $cfg['DPS']['fileR'] . "'";
         if ($db->getOne($sql) > 0) {
             $sql = "SELECT count(*) FROM v_tree_showplan\n\t\t\t\t\tWHERE id = {$showID}\n\t\t\t\t\t\tAND\tuserid = {$userID}\n\t\t\t\t\t\tAND permissions & B'" . $cfg['DPS']['fileW'] . "' = '" . $cfg['DPS']['fileW'] . "'";
             if ($db->getOne($sql) > 0) {
                 $this->assign('write', 't');
             } else {
                 $this->assign('write', 'f');
             }
             $show_sql = "SELECT showplans.*, v_tree_showplan.permissions\n                    FROM showplans, v_tree_showplan\n                    WHERE showplans.id = v_tree_showplan.id\n                        AND v_tree_showplan.userid = {$userID}\n                        AND v_tree_showplan.permissions & B'" . $cfg['DPS']['fileR'] . "' = '" . $cfg['DPS']['fileR'] . "'\n                        AND showplans.id = " . $showID;
             $show = $db->getRow($show_sql);
             $show['niceAirDate'] = date("d/m/y", $show['showdate']);
             $show['niceAirTime'] = date("H:i", $show['showdate']);
             $show['niceCreateDate'] = date("d/m/y", $show['creationdate']);
             $show['niceCreateTime'] = date("H:i", $show['creationdate']);
             $items_sql = "SELECT * FROM showitems \n\t\t\t\t\tWHERE showplanid = " . $showID . " \n\t\t\t\t\tORDER BY position asc";
             $items = $db->getAll($items_sql);
             $time = $show['showdate'];
             foreach ($items as &$item) {
                 $item['time'] = $time;
                 $item['niceTime'] = date("H:i:s", $item['time']);
                 $item['niceLength'] = str_pad((int) ($item['length'] / 60), 2, "0", STR_PAD_LEFT) . ":" . str_pad($item['length'] - (int) ($item['length'] / 60) * 60, 2, "0", STR_PAD_LEFT);
                 $item['niceEndTime'] = date("H:i:s", $item['time'] + $item['length']);
                 $time = $time + $item['length'];
                 if ($item['audioid'] != '') {
                     $sql = "SELECT audio.title AS title, audiotypes.name AS type \n\t\t\t\t\t\t\tFROM audio, audiotypes \n\t\t\t\t\t\t\tWHERE audio.type = audiotypes.id \n\t\t\t\t\t\t\t\tAND audio.id = " . $item['audioid'];
                     $stuff = $db->getRow($sql);
                     $item['audioTitle'] = $stuff['title'];
                     $item['nature'] = $stuff['type'];
                 } else {
                     $item['nature'] = 'unknown';
                 }
                 if ($item['scriptid'] != '') {
                     $sql = "SELECT name FROM scripts \n\t\t\t\t\t\t\tWHERE id = " . $item['scriptid'];
                     $item['scriptName'] = $db->getOne($sql);
                 }
             }
             $time = $time - $show['showdate'];
             $show['niceLength'] = (int) ($time / 60) . "mins " . ($time - (int) ($time / 60) * 60) . "s";
             $show['niceProducer'] = AuthUtil::getUsername($show['userid']);
             if ($show['showdate'] > $date) {
                 $this->assign('done', 'f');
             } else {
                 $this->assign('done', 't');
             }
             $this->assign('show', $show);
             $this->assign('showItems', $items);
             $this->assign('itemCount', count($items));
             $this->assign('endTime', $items[count($items) - 1]['niceEndTime']);
         } else {
             $this->assign('error', 'You do not have permission to edit that show.');
         }
     } else {
         $this->assign('error', 'Invalid Show ID supplied');
     }
     $this->assign('Admin', AuthUtil::getDetailedUserrealmAccess(array(1), $userID));
     $this->assign('deleteID', $this->fieldData['deleteID']);
 }
 protected function setupTemplate()
 {
     global $cfg;
     parent::setupTemplate();
     $db = Database::getInstance($cfg['DPS']['dsn']);
     $showID = pg_escape_string($this->fieldData['showID']);
     $auth = Auth::getInstance();
     $userID = $auth->getUserID();
     $date = time();
     if (is_numeric($showID)) {
         $show_query = "SELECT BIT_OR(v_tree_showplan.permissions) \n\t\t\tFROM v_tree_showplan \n\t\t\tWHERE v_tree_showplan.userid = {$userID} AND \n\t\t\t\tv_tree_showplan.id = {$showID}";
         $checkShows = $db->getOne($show_query);
         if (substr($checkShows, 0, 1) == "1") {
             //READ PERM
             if (substr($checkShows, 1, 1) == "1") {
                 $this->assign('write', 't');
             } else {
                 $this->assign('write', 'f');
             }
             $sql = "SELECT BIT_OR(v_tree_dir.permissions) \n\t\t\t\t\tFROM v_tree_showplan, v_tree_dir \n\t\t\t\t\tWHERE v_tree_showplan.id = {$showID}\n\t\t\t\t\t\tAND v_tree_showplan.parent = v_tree_dir.id\n\t\t\t\t\t\tAND v_tree_dir.userid = {$userID}";
             $checkShows = $db->getOne($show_query);
             if (substr($checkShows, 2, 1) == "1") {
                 $this->assign('perms', 't');
             } else {
                 $this->assign('perms', 'f');
             }
             $show_sql = "SELECT * FROM showplans WHERE id = " . $showID;
             $show = $db->getRow($show_sql);
             $show['D'] = date("j", $show['showdate']);
             $show['M'] = date("n", $show['showdate']);
             $show['Y'] = date("Y", $show['showdate']);
             $show['h'] = date("H", $show['showdate']);
             $show['m'] = date("i", $show['showdate']);
             //$show['niceAirTime'] = date("g a",$show['showdate']);
             //$show['niceCreateDate'] = date("m/d/y",$show['creationdate']);
             //$show['niceCreateTime'] = date("g a",$show['creationdate']);
             $show['niceProducer'] = AuthUtil::getUsername($show['creator']);
             if ($show['showdate'] > $date) {
                 $this->assign('done', 'f');
             } else {
                 $this->assign('done', 't');
             }
             for ($i = 1; $i < 13; $i++) {
                 switch ($i) {
                     default:
                     case 1:
                         $month = "January";
                         break;
                     case 2:
                         $month = "Febuary";
                         break;
                     case 3:
                         $month = "March";
                         break;
                     case 4:
                         $month = "April";
                         break;
                     case 5:
                         $month = "May";
                         break;
                     case 6:
                         $month = "June";
                         break;
                     case 7:
                         $month = "July";
                         break;
                     case 8:
                         $month = "August";
                         break;
                     case 9:
                         $month = "September";
                         break;
                     case 10:
                         $month = "October";
                         break;
                     case 11:
                         $month = "November";
                         break;
                     case 12:
                         $month = "December";
                         break;
                 }
                 if ($i == $show['M']) {
                     $formOpts['month'] = $formOpts['month'] . "<option selected value='{$i}'>{$month}</option>";
                 } else {
                     $formOpts['month'] = $formOpts['month'] . "<option value='{$i}'>{$month}</option>";
                 }
             }
             for ($i = 1; $i < 32; $i++) {
                 if ($i == $show['D']) {
                     $formOpts['date'] = $formOpts['date'] . "<option selected value='{$i}'>{$i}</option>";
                 } else {
                     $formOpts['date'] = $formOpts['date'] . "<option value='{$i}'>{$i}</option>";
                 }
             }
             for ($i = 2006; $i < 2013; $i++) {
                 if ($i == $show['Y']) {
                     $formOpts['year'] = $formOpts['year'] . "<option selected value='{$i}'>{$i}</option>";
                 } else {
                     $formOpts['year'] = $formOpts['year'] . "<option value='{$i}'>{$i}</option>";
                 }
             }
             $this->assign('formOpts', $formOpts);
             $this->assign('show', $show);
         } else {
             $this->assign('error', 'You do not have permission to edit that show.');
         }
     } else {
         $this->assign('error', 'Invalid Show ID supplied');
     }
     $this->assign('Admin', AuthUtil::getDetailedUserrealmAccess(array(1), $userID));
 }