Pman.Gnumeric.js
[Pman.Core] / RooGetTrait.php
index 8d0aec8..162ebce 100644 (file)
@@ -95,7 +95,7 @@ trait Pman_Core_RooGetTrait {
     function get($tab)
     {
         $this->init();
-        DB_DataObject::debugLevel(1);
+        
         HTML_FlexyFramework::get()->generateDataobjectsCache($this->isDev);
         
         if ( $this->checkDebugPost()) {
@@ -107,7 +107,8 @@ trait Pman_Core_RooGetTrait {
         
         PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array($this, 'onPearError'));
    
-        $tab = array_shift(explode('/', $tab));
+        $explode_tab = explode('/', $tab);
+        $tab = array_shift($explode_tab);
         
         $x = $this->dataObject($tab);
         
@@ -236,7 +237,7 @@ trait Pman_Core_RooGetTrait {
         
         // filter results, and add any data that is needed...
         if (method_exists($x,'postListFilter')) {
-            $ret = $x->postListFilter($ret, $this->getAuthUser(), $_REQUEST);
+            $ret = $x->postListFilter($ret, $this->authUser, $_REQUEST);
         }
         
         
@@ -286,7 +287,7 @@ trait Pman_Core_RooGetTrait {
         $sorted = false;
         if (method_exists($x, 'applySort')) {
             $sorted = $x->applySort(
-                    $this->getAuthUser(),
+                    $this->authUser,
                     $sort,
                     $dir,
                     array_keys($this->cols),
@@ -301,6 +302,7 @@ trait Pman_Core_RooGetTrait {
             
             $cols = $x->table();
             $excols = array_keys($this->cols);
+            //print_R($excols);
             
             if (isset($x->_extra_cols)) {
                 $excols = array_merge($excols, $x->_extra_cols);
@@ -433,7 +435,7 @@ trait Pman_Core_RooGetTrait {
         $cols  = array_keys($data[0]);
      
         $options = &PEAR::getStaticProperty('DB_DataObject','options');
-        $reader = $options["ini_{$x->_database}"] .'.reader';
+        $reader = $options["ini_{$x->databaseNickname()}"] .'.reader';
         if (!file_exists( $reader )) {
             return;
         }
@@ -464,4 +466,39 @@ trait Pman_Core_RooGetTrait {
          
         
     }
+    
+    function multiSort($x)
+    {
+        $ms = json_decode($_REQUEST['_multisort']);
+        if (!isset($ms->order) || !is_array($ms->order)) {
+            return;
+        }
+        $sort_str = array();
+        
+        $cols = $x->table();
+        
+        foreach($ms->order  as $col) {
+            if (!isset($ms->sort->{$col})) {
+                continue; // no direction..
+            }
+            $ms->sort->{$col} = $ms->sort->{$col}  == 'ASC' ? 'ASC' : 'DESC';
+            
+            if (strlen($col) && isset($cols[$col]) ) {
+                $sort_str[] =  $x->tableName() .'.'.$col . ' ' .  $ms->sort->{$col};
+                continue;
+            }
+            
+            if (in_array($col, array_keys($this->cols))) {
+                $sort_str[] = $col. ' ' . $ms->sort->{$col};
+                continue;
+            }
+            if (isset($x->_extra_cols) && in_array($col, $x->_extra_cols)) {
+                $sort_str[] = $col. ' ' . $ms->sort->{$col};
+            }
+        }
+         
+        if ($sort_str) {
+            $x->orderBy(implode(', ', $sort_str ));
+        }
+    }
 }