CC-1977: Allow multiple files to be selected and acted upon in the library and playlist
- Fixed issues in "Manage Users" page - Moved some code to more appropriate place
This commit is contained in:
parent
186aa9e898
commit
258521ffbf
|
@ -314,8 +314,13 @@ class Application_Model_StoredFile {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Application_Model_Playlist::DeleteFileFromAllPlaylists($this->getId());
|
// don't delete from the playslist. We might want to put a flag
|
||||||
$this->_file->delete();
|
//Application_Model_Playlist::DeleteFileFromAllPlaylists($this->getId());
|
||||||
|
|
||||||
|
// set file_exists falg to false
|
||||||
|
$this->_file->setDbFileExists(false);
|
||||||
|
$this->_file->save();
|
||||||
|
//$this->_file->delete();
|
||||||
|
|
||||||
if (isset($res)) {
|
if (isset($res)) {
|
||||||
return $res;
|
return $res;
|
||||||
|
@ -430,6 +435,7 @@ class Application_Model_StoredFile {
|
||||||
public function setFilePath($p_filepath)
|
public function setFilePath($p_filepath)
|
||||||
{
|
{
|
||||||
$path_info = Application_Model_MusicDir::splitFilePath($p_filepath);
|
$path_info = Application_Model_MusicDir::splitFilePath($p_filepath);
|
||||||
|
|
||||||
if (is_null($path_info)) {
|
if (is_null($path_info)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -499,7 +505,9 @@ class Application_Model_StoredFile {
|
||||||
$storedFile->_file = $file;
|
$storedFile->_file = $file;
|
||||||
|
|
||||||
if(isset($md['MDATA_KEY_FILEPATH'])) {
|
if(isset($md['MDATA_KEY_FILEPATH'])) {
|
||||||
$res = $storedFile->setFilePath($md['MDATA_KEY_FILEPATH']);
|
// removed "//" in the path. Always use '/' for path separator
|
||||||
|
$filepath = str_replace("//", "/", $md['MDATA_KEY_FILEPATH']);
|
||||||
|
$res = $storedFile->setFilePath($filepath);
|
||||||
if ($res === -1) {
|
if ($res === -1) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -674,12 +682,20 @@ class Application_Model_StoredFile {
|
||||||
$fromTable = " ((".$plSelect."PL.id
|
$fromTable = " ((".$plSelect."PL.id
|
||||||
FROM ".$CC_CONFIG["playListTable"]." AS PL
|
FROM ".$CC_CONFIG["playListTable"]." AS PL
|
||||||
LEFT JOIN ".$CC_CONFIG['playListTimeView']." AS PLT USING(id))
|
LEFT JOIN ".$CC_CONFIG['playListTimeView']." AS PLT USING(id))
|
||||||
|
|
||||||
UNION
|
UNION
|
||||||
|
(".$fileSelect."id FROM ".$CC_CONFIG["filesTable"]." AS FILES WHERE file_exists = 'TRUE')) AS RESULTS";
|
||||||
(".$fileSelect."id FROM ".$CC_CONFIG["filesTable"]." AS FILES)) 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'] = "<input type='checkbox' name='cb_".$row['id']."'>";
|
||||||
|
|
||||||
|
// 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)
|
public static function searchPlaylistsForSchedule($datatables)
|
||||||
|
@ -748,9 +764,6 @@ class Application_Model_StoredFile {
|
||||||
$orderby = join("," , $orderby);
|
$orderby = join("," , $orderby);
|
||||||
// End Order By clause
|
// End Order By clause
|
||||||
|
|
||||||
//ordered by integer as expected by datatables.
|
|
||||||
//$CC_DBC->setFetchMode(DB_FETCHMODE_ORDERED);
|
|
||||||
|
|
||||||
if(isset($where)) {
|
if(isset($where)) {
|
||||||
$where = join(" AND ", $where);
|
$where = join(" AND ", $where);
|
||||||
$sql = $selectorCount." FROM ".$fromTable." WHERE ".$where;
|
$sql = $selectorCount." FROM ".$fromTable." WHERE ".$where;
|
||||||
|
@ -760,26 +773,9 @@ class Application_Model_StoredFile {
|
||||||
else {
|
else {
|
||||||
$sql = $selectorRows." FROM ".$fromTable." ORDER BY ".$orderby." OFFSET ".$data["iDisplayStart"]." LIMIT ".$data["iDisplayLength"];
|
$sql = $selectorRows." FROM ".$fromTable." ORDER BY ".$orderby." OFFSET ".$data["iDisplayStart"]." LIMIT ".$data["iDisplayLength"];
|
||||||
}
|
}
|
||||||
|
|
||||||
$results = $CC_DBC->getAll($sql);
|
$results = $CC_DBC->getAll($sql);
|
||||||
foreach($results as &$row){
|
|
||||||
// add checkbox row
|
|
||||||
$row['checkbox'] = "<input type='checkbox' name='cb_".$row[id]."'>";
|
|
||||||
|
|
||||||
// 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];
|
|
||||||
}
|
|
||||||
//$results['checkbox']
|
|
||||||
//$results = $CC_DBC->getAssoc($sql);
|
|
||||||
Logging::log(print_r($results, true));
|
|
||||||
//echo $results;
|
|
||||||
//echo $sql;
|
|
||||||
|
|
||||||
//put back to default fetch mode.
|
|
||||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
|
||||||
|
|
||||||
if(!isset($totalDisplayRows)) {
|
if(!isset($totalDisplayRows)) {
|
||||||
$totalDisplayRows = $totalRows;
|
$totalDisplayRows = $totalRows;
|
||||||
}
|
}
|
||||||
|
@ -923,24 +919,34 @@ class Application_Model_StoredFile {
|
||||||
return $CC_DBC->GetOne($sql);
|
return $CC_DBC->GetOne($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function listAllFiles($dir_id){
|
/**
|
||||||
|
*
|
||||||
|
* Enter description here ...
|
||||||
|
* @param $dir_id - if this is not provided, it returns all files with full path constructed.
|
||||||
|
* @param $propelObj - if this is true, it returns array of proepl obj
|
||||||
|
*/
|
||||||
|
public static function listAllFiles($dir_id=null, $propelObj=false){
|
||||||
global $CC_DBC;
|
global $CC_DBC;
|
||||||
|
|
||||||
// $sql = "SELECT m.directory || '/' || f.filepath as fp"
|
if($propelObj){
|
||||||
// ." FROM CC_MUSIC_DIRS m"
|
$sql = "SELECT m.directory || f.filepath as fp"
|
||||||
// ." LEFT JOIN CC_FILES f"
|
." FROM CC_MUSIC_DIRS m"
|
||||||
// ." ON m.id = f.directory"
|
." LEFT JOIN CC_FILES f"
|
||||||
// ." WHERE m.id = f.directory"
|
." ON m.id = f.directory WHERE m.id = $dir_id and f.file_exists = 'TRUE'";
|
||||||
// ." AND m.id = $dir_id";
|
}else{
|
||||||
$sql = "SELECT filepath as fp"
|
$sql = "SELECT filepath as fp"
|
||||||
." FROM CC_FILES"
|
." FROM CC_FILES"
|
||||||
." WHERE directory = $dir_id";
|
." WHERE directory = $dir_id and file_exists = 'TRUE'";
|
||||||
|
}
|
||||||
$rows = $CC_DBC->getAll($sql);
|
$rows = $CC_DBC->getAll($sql);
|
||||||
|
|
||||||
$results = array();
|
$results = array();
|
||||||
foreach ($rows as $row){
|
foreach ($rows as $row){
|
||||||
$results[] = $row["fp"];
|
if($propelObj){
|
||||||
|
$results[] = Application_Model_StoredFile::RecallByFilepath($row["fp"]);
|
||||||
|
}else{
|
||||||
|
$results[] = $row["fp"];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
|
@ -983,6 +989,15 @@ class Application_Model_StoredFile {
|
||||||
public function getSoundCloudErrorMsg(){
|
public function getSoundCloudErrorMsg(){
|
||||||
return $this->_file->getDbSoundCloudErrorMsg();
|
return $this->_file->getDbSoundCloudErrorMsg();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setFileExistsFlag($flag){
|
||||||
|
$this->_file->setDbFileExists($flag)
|
||||||
|
->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFileExistsFlag(){
|
||||||
|
return $this->_file->getDbFileExists();
|
||||||
|
}
|
||||||
|
|
||||||
public function uploadToSoundCloud()
|
public function uploadToSoundCloud()
|
||||||
{
|
{
|
||||||
|
|
|
@ -236,8 +236,10 @@ class Application_Model_User {
|
||||||
|
|
||||||
// mark record which is for the current user
|
// mark record which is for the current user
|
||||||
foreach($res['aaData'] as &$record){
|
foreach($res['aaData'] as &$record){
|
||||||
if($record[1] == $username){
|
if($record['login'] == $username){
|
||||||
$record[5] = "self";
|
$record['delete'] = "self";
|
||||||
|
} else {
|
||||||
|
$record['delete'] = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,23 +35,23 @@ function removeUserCallback(row_id, nRow){
|
||||||
}
|
}
|
||||||
|
|
||||||
function rowCallback( nRow, aData, iDisplayIndex ){
|
function rowCallback( nRow, aData, iDisplayIndex ){
|
||||||
$(nRow).click(function(){rowClickCallback(aData[0])});
|
$(nRow).click(function(){rowClickCallback(aData['id'])});
|
||||||
if( aData[5] != "self"){
|
if( aData['delete'] != "self"){
|
||||||
$('td:eq(4)', nRow).append( '<span class="ui-icon ui-icon-closethick"></span>').children('span').click(function(e){e.stopPropagation(); removeUserCallback(aData[0], nRow)});
|
$('td:eq(4)', nRow).append( '<span class="ui-icon ui-icon-closethick"></span>').children('span').click(function(e){e.stopPropagation(); removeUserCallback(aData['id'], nRow)});
|
||||||
}else{
|
}else{
|
||||||
$('td:eq(4)', nRow).empty().append( '<span class="ui-icon ui-icon-closethick"></span>').children('span').click(function(e){e.stopPropagation(); alert("Can't delete yourself!")});
|
$('td:eq(4)', nRow).empty().append( '<span class="ui-icon ui-icon-closethick"></span>').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' );
|
$('td:eq(3)', nRow).html( 'Admin' );
|
||||||
} else if ( aData[4] == "H" )
|
} else if ( aData['type'] == "H" )
|
||||||
{
|
{
|
||||||
$('td:eq(3)', nRow).html( 'DJ' );
|
$('td:eq(3)', nRow).html( 'DJ' );
|
||||||
} else if ( aData[4] == "G" )
|
} else if ( aData['type'] == "G" )
|
||||||
{
|
{
|
||||||
$('td:eq(3)', nRow).html( 'Guest' );
|
$('td:eq(3)', nRow).html( 'Guest' );
|
||||||
} else if ( aData[4] == "P" )
|
} else if ( aData['type'] == "P" )
|
||||||
{
|
{
|
||||||
$('td:eq(3)', nRow).html( 'Program Manager' );
|
$('td:eq(3)', nRow).html( 'Program Manager' );
|
||||||
}
|
}
|
||||||
|
@ -75,12 +75,12 @@ $(document).ready(function() {
|
||||||
},
|
},
|
||||||
"fnRowCallback": rowCallback,
|
"fnRowCallback": rowCallback,
|
||||||
"aoColumns": [
|
"aoColumns": [
|
||||||
/* Id */ { "sName": "id", "bSearchable": false, "bVisible": false },
|
/* Id */ { "sName": "id", "bSearchable": false, "bVisible": false, "mDataProp": "id" },
|
||||||
/* user name */ { "sName": "login" },
|
/* user name */ { "sName": "login", "mDataProp": "login" },
|
||||||
/* first name */ { "sName": "first_name" },
|
/* first name */ { "sName": "first_name", "mDataProp": "first_name" },
|
||||||
/* last name */ { "sName": "last_name" },
|
/* last name */ { "sName": "last_name", "mDataProp": "last_name" },
|
||||||
/* user type */ { "sName": "type", "bSearchable": false },
|
/* user type */ { "sName": "type", "bSearchable": false, "mDataProp": "type" },
|
||||||
/* del button */ { "sName": "null as delete", "bSearchable": false, "bSortable": false}
|
/* del button */ { "sName": "null as delete", "bSearchable": false, "bSortable": false, "mDataProp": "delete"}
|
||||||
],
|
],
|
||||||
"bJQueryUI": true,
|
"bJQueryUI": true,
|
||||||
"bAutoWidth": false,
|
"bAutoWidth": false,
|
||||||
|
|
Loading…
Reference in New Issue