diff --git a/livesupport/modules/storageServer/var/BasicStor.php b/livesupport/modules/storageServer/var/BasicStor.php index 767c99268..3fa06ac60 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.19 $ + Version : $Revision: 1.20 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/BasicStor.php,v $ ------------------------------------------------------------------------------*/ @@ -50,7 +50,7 @@ require_once "StoredFile.php"; * Core of LiveSupport file storage module * * @author $Author: tomas $ - * @version $Revision: 1.19 $ + * @version $Revision: 1.20 $ * @see Alib */ class BasicStor extends Alib{ @@ -565,7 +565,7 @@ class BasicStor extends Alib{ * @return hash, field 'results' is an array with gunid strings * of files have been found */ - function bsLocalSearch($criteria) + function bsLocalSearch($criteria, $limit, $offset) { $operators = array('and'=>'AND', 'or'=>'OR'); $ops = array('full'=>"='%s'", 'partial'=>"like '%%%s%%'", 'prefix'=>"like '%s%%'", @@ -589,6 +589,7 @@ class BasicStor extends Alib{ $whereArr[] = "$sqlCond"; } $selPart = "SELECT DISTINCT to_hex(f.gunid)as gunid, f.ftype as filetype"; + $limitPart = ($limit != 0 ? " LIMIT $limit" : '' ).($offset != 0 ? " OFFSET $offset" : '' ); $ftypeCond = " AND f.ftype='$filetype'"; if($operator == 'and'){ // operator: and @@ -616,11 +617,12 @@ class BasicStor extends Alib{ "INNER JOIN {$this->filesTable} f ON md.gunid=f.gunid $ftypeCond\n". "WHERE ".join(' OR ', $whereArr); } - $res = $this->dbc->getCol($sql); + $rh = $this->dbc->query($sql); $cnt = $rh->numRows(); $rh->free(); + $res = $this->dbc->getCol($sql.$limitPart); if(!is_array($res)) $res = array(); $res = array_map(array("StoredFile", "_normalizeGunid"), $res); # return array('sql'=>$sql, 'results'=>$res); - return array('results'=>$res); + return array('results'=>$res, 'cnt'=>$cnt); } /* --------------------------------------------------------- info methods */ diff --git a/livesupport/modules/storageServer/var/LocStor.php b/livesupport/modules/storageServer/var/LocStor.php index ae951957f..2641f363b 100644 --- a/livesupport/modules/storageServer/var/LocStor.php +++ b/livesupport/modules/storageServer/var/LocStor.php @@ -23,7 +23,7 @@ Author : $Author: tomas $ - Version : $Revision: 1.21 $ + Version : $Revision: 1.22 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/LocStor.php,v $ ------------------------------------------------------------------------------*/ @@ -273,25 +273,38 @@ class LocStor extends BasicStor{ */ function searchMetadata($sessid, $criteria) { + if(($res = $this->_authorize('read', $this->storId, $sessid)) !== TRUE) + return $res; $filetype = strtolower($criteria['filetype']); + $limit = intval($criteria['limit']); + $offset = intval($criteria['offset']); if($filetype=='all'){ $criteriaAC = $criteria; $criteriaAC['filetype'] = 'audioclip'; $criteriaPL = $criteria; $criteriaPL['filetype'] = 'playlist'; - $resAC = $this->bsLocalSearch($criteriaAC); - $resPL = $this->bsLocalSearch($criteriaPL); + $resAC = $this->bsLocalSearch($criteriaAC, $limit, $offset); + $resPL = $this->bsLocalSearch($criteriaPL, $limit, $offset); return array( 'audioClipResults' => $resAC['results'], - 'playlistResults' => $resPL['results'] + 'audioClipCnt' => $resAC['cnt'], + 'playlistResults' => $resPL['results'], + 'playlistCnt' => $resPL['cnt'], ); } - $srchRes = $this->bsLocalSearch($criteria); - $res = array('audioClipResults'=>NULL, 'playlistResults'=>NULL); + $srchRes = $this->bsLocalSearch($criteria, $limit, $offset); + $res = array( + 'audioClipResults' => array(), + 'audioClipCnt' => 0, + 'playlistResults' => array(), + 'playlistCnt' => 0, + ); switch($filetype){ case"audioclip": $res['audioClipResults'] = $srchRes['results']; + $res['audioClipCnt'] = $srchRes['cnt']; break; case"playlist": $res['playlistResults'] = $srchRes['results']; + $res['playlistCnt'] = $srchRes['cnt']; break; } return $res; diff --git a/livesupport/modules/storageServer/var/xmlrpc/XR_LocStor.php b/livesupport/modules/storageServer/var/xmlrpc/XR_LocStor.php index fa77f8f72..e93047dff 100644 --- a/livesupport/modules/storageServer/var/xmlrpc/XR_LocStor.php +++ b/livesupport/modules/storageServer/var/xmlrpc/XR_LocStor.php @@ -23,7 +23,7 @@ Author : $Author: tomas $ - Version : $Revision: 1.7 $ + Version : $Revision: 1.8 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/xmlrpc/XR_LocStor.php,v $ ------------------------------------------------------------------------------*/ @@ -1120,21 +1120,23 @@ class XR_LocStor extends LocStor{ *
  • sessid : string - session id
  • *
  • criteria : struct, with following fields:
    *