cc-4288. Added owner to query.
This commit is contained in:
parent
2e8ed352b8
commit
d7aad93e4f
|
@ -39,15 +39,17 @@ class Application_Model_Datatables
|
||||||
/*
|
/*
|
||||||
* query used to return data for a paginated/searchable datatable.
|
* query used to return data for a paginated/searchable datatable.
|
||||||
*/
|
*/
|
||||||
public static function findEntries($con, $displayColumns, $fromTable, $data, $dataProp = "aaData")
|
public static function findEntries($con, $displayColumns, $fromTable,
|
||||||
|
$data, $dataProp = "aaData")
|
||||||
{
|
{
|
||||||
$librarySetting = Application_Model_Preference::getCurrentLibraryTableSetting();
|
$librarySetting = Application_Model_Preference::getCurrentLibraryTableSetting();
|
||||||
|
//$displayColumns[] = 'owner';
|
||||||
|
|
||||||
// map that maps original column position to db name
|
// map that maps original column position to db name
|
||||||
$current2dbname = array();
|
$current2dbname = array();
|
||||||
// array of search terms
|
// array of search terms
|
||||||
$orig2searchTerm= array();
|
$orig2searchTerm = array();
|
||||||
foreach ($data as $key=>$d) {
|
foreach ($data as $key => $d) {
|
||||||
if (strstr($key, "mDataProp_")) {
|
if (strstr($key, "mDataProp_")) {
|
||||||
list($dump, $index) = explode("_", $key);
|
list($dump, $index) = explode("_", $key);
|
||||||
$current2dbname[$index] = $d;
|
$current2dbname[$index] = $d;
|
||||||
|
@ -82,6 +84,7 @@ class Application_Model_Datatables
|
||||||
$sql = $selectorCount." FROM ".$fromTable;
|
$sql = $selectorCount." FROM ".$fromTable;
|
||||||
$sqlTotalRows = $sql;
|
$sqlTotalRows = $sql;
|
||||||
|
|
||||||
|
|
||||||
if (isset($searchTerms)) {
|
if (isset($searchTerms)) {
|
||||||
$searchCols = array();
|
$searchCols = array();
|
||||||
for ($i = 0; $i < $data["iColumns"]; $i++) {
|
for ($i = 0; $i < $data["iColumns"]; $i++) {
|
||||||
|
@ -135,8 +138,8 @@ class Application_Model_Datatables
|
||||||
$sql .= " OFFSET ".$data["iDisplayStart"]." LIMIT ".$displayLength;
|
$sql .= " OFFSET ".$data["iDisplayStart"]." LIMIT ".$displayLength;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
$r = $con->query($sqlTotalRows);
|
$r = $con->query($sqlTotalRows);
|
||||||
$totalRows = $r->fetchColumn(0);
|
$totalRows = $r->fetchColumn(0);
|
||||||
|
|
||||||
|
@ -173,12 +176,11 @@ class Application_Model_Datatables
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
Logging::debug($e->getMessage());
|
Logging::debug($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
"sEcho" => intval($data["sEcho"]),
|
"sEcho" => intval($data["sEcho"]),
|
||||||
"iTotalDisplayRecords" => intval($totalDisplayRows),
|
"iTotalDisplayRecords" => intval($totalDisplayRows),
|
||||||
"iTotalRecords" => intval($totalRows),
|
"iTotalRecords" => intval($totalRows),
|
||||||
$dataProp => $results
|
$dataProp => $results
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -635,9 +635,11 @@ class Application_Model_StoredFile
|
||||||
$displayColumns = array("id", "track_title", "artist_name", "album_title", "genre", "length",
|
$displayColumns = array("id", "track_title", "artist_name", "album_title", "genre", "length",
|
||||||
"year", "utime", "mtime", "ftype", "track_number", "mood", "bpm", "composer", "info_url",
|
"year", "utime", "mtime", "ftype", "track_number", "mood", "bpm", "composer", "info_url",
|
||||||
"bit_rate", "sample_rate", "isrc_number", "encoded_by", "label", "copyright", "mime",
|
"bit_rate", "sample_rate", "isrc_number", "encoded_by", "label", "copyright", "mime",
|
||||||
"language", "filepath"
|
"language", "filepath","owner"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//Logging::info($datatables);
|
||||||
|
|
||||||
$plSelect = array();
|
$plSelect = array();
|
||||||
$blSelect = array();
|
$blSelect = array();
|
||||||
$fileSelect = array();
|
$fileSelect = array();
|
||||||
|
@ -647,7 +649,7 @@ class Application_Model_StoredFile
|
||||||
if ($key === "id") {
|
if ($key === "id") {
|
||||||
$plSelect[] = "PL.id AS ".$key;
|
$plSelect[] = "PL.id AS ".$key;
|
||||||
$blSelect[] = "BL.id AS ".$key;
|
$blSelect[] = "BL.id AS ".$key;
|
||||||
$fileSelect[] = $key;
|
$fileSelect[] = "FILES.id AS $key";
|
||||||
$streamSelect[] = "ws.id AS ".$key;
|
$streamSelect[] = "ws.id AS ".$key;
|
||||||
} elseif ($key === "track_title") {
|
} elseif ($key === "track_title") {
|
||||||
$plSelect[] = "name AS ".$key;
|
$plSelect[] = "name AS ".$key;
|
||||||
|
@ -664,6 +666,11 @@ class Application_Model_StoredFile
|
||||||
$blSelect[] = "login AS ".$key;
|
$blSelect[] = "login AS ".$key;
|
||||||
$fileSelect[] = $key;
|
$fileSelect[] = $key;
|
||||||
$streamSelect[] = "login AS ".$key;
|
$streamSelect[] = "login AS ".$key;
|
||||||
|
} elseif ($key === "owner") {
|
||||||
|
$plSelect[] = "login AS ".$key;
|
||||||
|
$blSelect[] = "login AS ".$key;
|
||||||
|
$fileSelect[] = "sub.login AS $key";
|
||||||
|
$streamSelect[] = "login AS ".$key;
|
||||||
}
|
}
|
||||||
//same columns in each table.
|
//same columns in each table.
|
||||||
else if (in_array($key, array("length", "utime", "mtime"))) {
|
else if (in_array($key, array("length", "utime", "mtime"))) {
|
||||||
|
@ -705,7 +712,8 @@ class Application_Model_StoredFile
|
||||||
|
|
||||||
$plTable = "({$plSelect} FROM cc_playlist AS PL LEFT JOIN cc_subjs AS sub ON (sub.id = PL.creator_id))";
|
$plTable = "({$plSelect} FROM cc_playlist AS PL LEFT JOIN cc_subjs AS sub ON (sub.id = PL.creator_id))";
|
||||||
$blTable = "({$blSelect} FROM cc_block AS BL LEFT JOIN cc_subjs AS sub ON (sub.id = BL.creator_id))";
|
$blTable = "({$blSelect} FROM cc_block AS BL LEFT JOIN cc_subjs AS sub ON (sub.id = BL.creator_id))";
|
||||||
$fileTable = "({$fileSelect} FROM cc_files AS FILES WHERE file_exists = 'TRUE')";
|
$fileTable = "({$fileSelect} FROM cc_files AS FILES LEFT JOIN cc_subjs AS sub ON (sub.id = FILES.owner_id) WHERE file_exists = 'TRUE')";
|
||||||
|
//$fileTable = "({$fileSelect} FROM cc_files AS FILES WHERE file_exists = 'TRUE')";
|
||||||
$streamTable = "({$streamSelect} FROM cc_webstream AS ws LEFT JOIN cc_subjs AS sub ON (sub.id = ws.creator_id))";
|
$streamTable = "({$streamSelect} FROM cc_webstream AS ws LEFT JOIN cc_subjs AS sub ON (sub.id = ws.creator_id))";
|
||||||
$unionTable = "({$plTable} UNION {$blTable} UNION {$fileTable} UNION {$streamTable}) AS RESULTS";
|
$unionTable = "({$plTable} UNION {$blTable} UNION {$fileTable} UNION {$streamTable}) AS RESULTS";
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue