diff --git a/airtime_mvc/application/models/StoredFile.php b/airtime_mvc/application/models/StoredFile.php index ba486fa0e..d371d083f 100644 --- a/airtime_mvc/application/models/StoredFile.php +++ b/airtime_mvc/application/models/StoredFile.php @@ -685,7 +685,17 @@ class Application_Model_StoredFile { UNION (".$fileSelect."id FROM ".$CC_CONFIG["filesTable"]." AS FILES WHERE file_exists = 'TRUE')) AS RESULTS"; - return Application_Model_StoredFile::searchFiles($fromTable, $datatables); + $results = Application_Model_StoredFile::searchFiles($fromTable, $datatables); + foreach($results['aaData'] as &$row){ + // add checkbox row + $row['checkbox'] = ""; + + // a full timestamp is being returned for playlists' year column; + // split it and grab only the year info + $yearSplit = explode('-', $row['year']); + $row['year'] = $yearSplit[0]; + } + return $results; } public static function searchPlaylistsForSchedule($datatables) @@ -765,16 +775,7 @@ class Application_Model_StoredFile { } $results = $CC_DBC->getAll($sql); - foreach($results as &$row){ - // add checkbox row - $row['checkbox'] = ""; - - // a full timestamp is being returned for playlists' year column; - // split it and grab only the year info - $yearSplit = explode('-', $row['year']); - $row['year'] = $yearSplit[0]; - } - + if(!isset($totalDisplayRows)) { $totalDisplayRows = $totalRows; } diff --git a/airtime_mvc/application/models/User.php b/airtime_mvc/application/models/User.php index 81548f013..7e9862d0d 100644 --- a/airtime_mvc/application/models/User.php +++ b/airtime_mvc/application/models/User.php @@ -236,8 +236,10 @@ class Application_Model_User { // mark record which is for the current user foreach($res['aaData'] as &$record){ - if($record[1] == $username){ - $record[5] = "self"; + if($record['login'] == $username){ + $record['delete'] = "self"; + } else { + $record['delete'] = ""; } } diff --git a/airtime_mvc/public/js/airtime/user/user.js b/airtime_mvc/public/js/airtime/user/user.js index 66dd7f975..15e97301d 100644 --- a/airtime_mvc/public/js/airtime/user/user.js +++ b/airtime_mvc/public/js/airtime/user/user.js @@ -35,23 +35,23 @@ function removeUserCallback(row_id, nRow){ } function rowCallback( nRow, aData, iDisplayIndex ){ - $(nRow).click(function(){rowClickCallback(aData[0])}); - if( aData[5] != "self"){ - $('td:eq(4)', nRow).append( '').children('span').click(function(e){e.stopPropagation(); removeUserCallback(aData[0], nRow)}); + $(nRow).click(function(){rowClickCallback(aData['id'])}); + if( aData['delete'] != "self"){ + $('td:eq(4)', nRow).append( '').children('span').click(function(e){e.stopPropagation(); removeUserCallback(aData['id'], nRow)}); }else{ $('td:eq(4)', nRow).empty().append( '').children('span').click(function(e){e.stopPropagation(); alert("Can't delete yourself!")}); } - if ( aData[4] == "A" ) + if ( aData['type'] == "A" ) { $('td:eq(3)', nRow).html( 'Admin' ); - } else if ( aData[4] == "H" ) + } else if ( aData['type'] == "H" ) { $('td:eq(3)', nRow).html( 'DJ' ); - } else if ( aData[4] == "G" ) + } else if ( aData['type'] == "G" ) { $('td:eq(3)', nRow).html( 'Guest' ); - } else if ( aData[4] == "P" ) + } else if ( aData['type'] == "P" ) { $('td:eq(3)', nRow).html( 'Program Manager' ); } @@ -75,12 +75,12 @@ $(document).ready(function() { }, "fnRowCallback": rowCallback, "aoColumns": [ - /* Id */ { "sName": "id", "bSearchable": false, "bVisible": false }, - /* user name */ { "sName": "login" }, - /* first name */ { "sName": "first_name" }, - /* last name */ { "sName": "last_name" }, - /* user type */ { "sName": "type", "bSearchable": false }, - /* del button */ { "sName": "null as delete", "bSearchable": false, "bSortable": false} + /* Id */ { "sName": "id", "bSearchable": false, "bVisible": false, "mDataProp": "id" }, + /* user name */ { "sName": "login", "mDataProp": "login" }, + /* first name */ { "sName": "first_name", "mDataProp": "first_name" }, + /* last name */ { "sName": "last_name", "mDataProp": "last_name" }, + /* user type */ { "sName": "type", "bSearchable": false, "mDataProp": "type" }, + /* del button */ { "sName": "null as delete", "bSearchable": false, "bSortable": false, "mDataProp": "delete"} ], "bJQueryUI": true, "bAutoWidth": false,