diff --git a/livesupport/modules/storageServer/var/BasicStor.php b/livesupport/modules/storageServer/var/BasicStor.php
index 1dbfe03c7..50172e7f9 100644
--- a/livesupport/modules/storageServer/var/BasicStor.php
+++ b/livesupport/modules/storageServer/var/BasicStor.php
@@ -23,7 +23,7 @@
Author : $Author: tomas $
- Version : $Revision: 1.33 $
+ Version : $Revision: 1.34 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/BasicStor.php,v $
------------------------------------------------------------------------------*/
@@ -52,7 +52,7 @@ require_once "Transport.php";
* Core of LiveSupport file storage module
*
* @author $Author: tomas $
- * @version $Revision: 1.33 $
+ * @version $Revision: 1.34 $
* @see Alib
*/
class BasicStor extends Alib{
@@ -665,6 +665,8 @@ class BasicStor extends Alib{
* (may be empty or ommited only with less then 2 items in
* "conditions" field)
*
+ *
orderby : string - metadata category for sorting (optional)
+ * desc : boolean - flag for descending order (optional)
* conditions - array of hashes with structure:
*
* - cat - string, metadata category name
diff --git a/livesupport/modules/storageServer/var/DataEngine.php b/livesupport/modules/storageServer/var/DataEngine.php
index e169335d1..fdadd3623 100644
--- a/livesupport/modules/storageServer/var/DataEngine.php
+++ b/livesupport/modules/storageServer/var/DataEngine.php
@@ -23,7 +23,7 @@
Author : $Author: tomas $
- Version : $Revision: 1.5 $
+ Version : $Revision: 1.6 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/DataEngine.php,v $
------------------------------------------------------------------------------*/
@@ -44,6 +44,8 @@ require_once "XML/Util.php";
* (may be empty or ommited only with less then 2 items in
* "conditions" field)
*
+ * orderby : string - metadata category for sorting (optional)
+ * desc : boolean - flag for descending order (optional)
* conditions - array of hashes with structure:
*
* - cat - string, metadata category name
@@ -273,10 +275,19 @@ class DataEngine{
{
$filetype = $this->filetypes[strtolower($criteria['filetype'])];
$operator = strtolower($criteria['operator']);
+ $desc = $criteria['desc'];
$whereArr = $this->_makeWhereArr($criteria['conditions']);
+ $orderbyQn = strtolower($criteria['orderby']);
+ $obSplitQn = XML_Util::splitQualifiedName($orderbyQn);
+ $obNs = $obSplitQn['namespace'];
+ $orderby = $obSplitQn['localPart'];
$browse = !is_null($brFld);
if(!$browse){
- $fldsPart = "DISTINCT to_hex(f.gunid)as gunid";
+ if(!$orderby){
+ $fldsPart = "DISTINCT to_hex(f.gunid)as gunid";
+ }else{
+ $fldsPart = "DISTINCT f.gunid";
+ }
}else{
$fldsPart = "DISTINCT br.object";
}
@@ -291,7 +302,16 @@ class DataEngine{
$sql = $this->_makeOrSql(
$fldsPart, $whereArr, $fileCond, $browse, $brFldNs, $brFld);
}
- // echo "\n---\n$sql\n---\n";
+ if(!$browse && $orderby){
+ $sql =
+ "SELECT to_hex(sq2.gunid)as gunid, m.object\n".
+ "FROM (\n$sql\n)sq2\n".
+ "LEFT JOIN ls_mdata m\n".
+ " ON m.gunid = sq2.gunid AND m.predicate='$orderby' AND m.objns='_L'".
+ (!is_null($obNs)? " AND m.predns='$obNs'":'')."\n".
+ "ORDER BY m.object".($desc? ' DESC':'')."\n";
+ }
+ echo "\n---\n$sql\n---\n";
$cnt = $this->_getNumRows($sql);
if(PEAR::isError($cnt)) return $cnt;
$res = $this->dbc->getCol($sql.$limitPart);
diff --git a/livesupport/modules/storageServer/var/GreenBox.php b/livesupport/modules/storageServer/var/GreenBox.php
index fca900df7..9d6406587 100644
--- a/livesupport/modules/storageServer/var/GreenBox.php
+++ b/livesupport/modules/storageServer/var/GreenBox.php
@@ -23,7 +23,7 @@
Author : $Author: tomas $
- Version : $Revision: 1.40 $
+ Version : $Revision: 1.41 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/GreenBox.php,v $
------------------------------------------------------------------------------*/
@@ -35,7 +35,7 @@ require_once "BasicStor.php";
* LiveSupport file storage module
*
* @author $Author: tomas $
- * @version $Revision: 1.40 $
+ * @version $Revision: 1.41 $
* @see BasicStor
*/
class GreenBox extends BasicStor{
@@ -344,6 +344,8 @@ class GreenBox extends BasicStor{
*
* limit : int - limit for result arrays (0 means unlimited)
* offset : int - starting point (0 means without offset)
+ * orderby : string - metadata category for sorting (optional)
+ * desc : boolean - flag for descending order (optional)
* conditions - array of hashes with structure:
*
* - cat - string, metadata category name