Cleaned up code.

This commit is contained in:
Rudi Grinberg 2012-09-19 16:34:46 -04:00
parent 4c1d719bf0
commit e5085f0df3
3 changed files with 39 additions and 23 deletions

View file

@ -57,7 +57,9 @@ class Application_Model_Datatables
public static function findEntries($con, $displayColumns, $fromTable, public static function findEntries($con, $displayColumns, $fromTable,
$data, $dataProp = "aaData") $data, $dataProp = "aaData")
{ {
$librarySetting = Application_Model_Preference::getCurrentLibraryTableColumnMap(); //$librarySetting = Application_Model_Preference::getCurrentLibraryTableColumnMap();
$librarySetting =
Application_Model_Preference::getCurrentLibraryTableColumnMap();
//$displayColumns[] = 'owner'; //$displayColumns[] = 'owner';
// map that maps original column position to db name // map that maps original column position to db name
@ -95,9 +97,8 @@ class Application_Model_Datatables
} }
$where = array(); $where = array();
/* Holds the parameters for binding after the /* Holds the parameters for binding after the statement has been
* statement has been prepared prepared */
*/
$params = array(); $params = array();
$advancedWhere = self::buildWhereClauseForAdvancedSearch($dbname2searchTerm); $advancedWhere = self::buildWhereClauseForAdvancedSearch($dbname2searchTerm);

View file

@ -1092,26 +1092,41 @@ class Application_Model_Preference
} }
public static function getCurrentLibraryTableColumnMap()
{
$v = self::getValue("library_datatable", true);
if ( $v === '' ) { public static function getOrderingMap($pref_param)
return function ($x) { return $x; }; {
} else { $v = self::getValue($pref_param, true);
$id = function ($x) { return $x; };
if ($v === '') {
return $id;
}
$ds = unserialize($v); $ds = unserialize($v);
if (!array_key_exists('ColReorder', $ds)) {
return $id;
}
return function ($x) use ($ds) { return function ($x) use ($ds) {
if ( array_key_exists($x, $ds['ColReorder'] ) ) { if (array_key_exists($x, $ds['ColReorder'])) {
return $ds['ColReorder'][$x]; return $ds['ColReorder'][$x];
} else { } else {
/*For now we just have this hack for debugging. We should not
rely on this crappy behaviour in case of failure*/
Logging::info("Pref: $pref_param");
Logging::warn("Index $x does not exist preferences"); Logging::warn("Index $x does not exist preferences");
Logging::warn("Defaulting to identity and printing Logging::warn("Defaulting to identity and printing preferences");
preferences");
Logging::warn($ds); Logging::warn($ds);
return $x; return $x;
} }
} ; };
} }
public static function getCurrentLibraryTableColumnMap()
{
return self::getOrderingMap("library_datatable");
} }
public static function setCurrentLibraryTableSetting($settings) public static function setCurrentLibraryTableSetting($settings)