From e316b65ac84de44d7bd697e1be3703d9b1384adf Mon Sep 17 00:00:00 2001 From: tomash Date: Fri, 24 Nov 2006 02:49:14 +0000 Subject: [PATCH] #1869 fixed hub search in web UI --- .../modules/htmlUI/var/html/ui_browser.php | 2 +- .../modules/htmlUI/var/ui_hubSearch.class.php | 21 +++++++--- .../modules/storageServer/var/GreenBox.php | 6 ++- .../modules/storageServer/var/Transport.php | 42 +++++++++++++------ 4 files changed, 49 insertions(+), 22 deletions(-) diff --git a/campcaster/src/modules/htmlUI/var/html/ui_browser.php b/campcaster/src/modules/htmlUI/var/html/ui_browser.php index 415e886c8..e4cdda941 100644 --- a/campcaster/src/modules/htmlUI/var/html/ui_browser.php +++ b/campcaster/src/modules/htmlUI/var/html/ui_browser.php @@ -248,7 +248,7 @@ if (isset($_REQUEST['popup']) && is_array($_REQUEST['popup'])){ case 'HUBSEARCH.getResults': if (isset($_REQUEST['trtokid']) && $_REQUEST['trtokid']) { $Smarty->assign('trtokid',$_REQUEST['trtokid']); - if ($uiBrowser->HUBSEARCH->getSearchResults($_REQUEST['trtokid'])) { + if ($uiBrowser->HUBSEARCH->getSearchResults($_REQUEST['trtokid'], FALSE)) { $Smarty->assign('results',true); } else { $Smarty->assign('results',false); diff --git a/campcaster/src/modules/htmlUI/var/ui_hubSearch.class.php b/campcaster/src/modules/htmlUI/var/ui_hubSearch.class.php index 909c1712e..6da213b5e 100644 --- a/campcaster/src/modules/htmlUI/var/ui_hubSearch.class.php +++ b/campcaster/src/modules/htmlUI/var/ui_hubSearch.class.php @@ -94,22 +94,31 @@ class uiHubSearch extends uiSearch { } // fn searchDB - function getSearchResults($trtokid) + function getSearchResults($trtokid, $andClose=TRUE) { $this->results = array('page' => $this->criteria['offset']/$this->criteria['limit']); - $results = $this->Base->gb->getSearchResults($trtokid); - //echo"
RESULTS:
";print_r($results);echo "
"; + #sleep(4); + $results = $this->Base->gb->getSearchResults($trtokid, $andClose); + // echo"
RESULTS:
";print_r($results);echo "
"; +/* + if (PEAR::isError($results)) { + echo "ERROR: {$results->getMessage()} {$results->getUserInfo()}\n"; + } +*/ if (!is_array($results) || !count($results)) { return false; } $this->results['cnt'] = $results['cnt']; +/* foreach ($results['results'] as $rec) { // TODO: maybe this getMetaInfo is not correct for the remote results - $this->results['items'][] = $this->Base->getMetaInfo($this->Base->gb->idFromGunid($rec)); + // yes, right :) + // $this->results['items'][] = $this->Base->getMetaInfo($this->Base->gb->idFromGunid($rec)); + $this->results['items'][] = $rec; } +*/ + $this->results['items'] = $results['results']; $this->pagination($results); - //echo 'this->results:'; print_r($this->results); echo "\n"; - //echo 'results:'; print_r($results); echo "\n"; return is_array($results); } // fn getSearchResults diff --git a/campcaster/src/modules/storageServer/var/GreenBox.php b/campcaster/src/modules/storageServer/var/GreenBox.php index 28821f205..4bea101ec 100644 --- a/campcaster/src/modules/storageServer/var/GreenBox.php +++ b/campcaster/src/modules/storageServer/var/GreenBox.php @@ -1695,14 +1695,16 @@ class GreenBox extends BasicStor { * * @param string $trtok * transport token + * @param boolean $andClose + * if TRUE, close transport token * @return array * search result format (see localSearch) */ - public function getSearchResults($trtok) + public function getSearchResults($trtok, $andClose=TRUE) { require_once("Transport.php"); $tr = new Transport($this); - return $tr->getSearchResults($trtok); + return $tr->getSearchResults($trtok, $andClose); } // fn getSearchResults diff --git a/campcaster/src/modules/storageServer/var/Transport.php b/campcaster/src/modules/storageServer/var/Transport.php index c1c24e5a2..60d5c7e80 100644 --- a/campcaster/src/modules/storageServer/var/Transport.php +++ b/campcaster/src/modules/storageServer/var/Transport.php @@ -462,10 +462,12 @@ class Transport * * @param string $trtok * transport token + * @param boolean $andClose + * if TRUE, close transport token * @return array * LS search result format (see localSearch) */ - function getSearchResults($trtok) + function getSearchResults($trtok, $andClose=TRUE) { $trec = TransportRecord::recall($this, $trtok); if (PEAR::isError($trec)) { @@ -481,30 +483,44 @@ class Transport " ({$trec->row['errmsg']})" ); case "closed": +/* + $res = file_get_contents($row['localfile']); + $results = unserialize($res); + return $results; +*/ return PEAR::raiseError( "Transport::getSearchResults:". " closed transport token ($trtok)", TRERR_TOK ); case "finished": if ($row['direction'] == 'down') { - break; // really finished + // really finished + $res = file_get_contents($row['localfile']); + $results = unserialize($res); + if ($andClose) { + $ret = $this->xmlrpcCall('archive.downloadClose', + array( + 'token' => $row['pdtoken'] , + 'trtype' => $row['trtype'] , + )); + if (PEAR::isError($ret)) { + return $ret; + } + @unlink($row['localfile']); + $r = $trec->close(); + if (PEAR::isError($r)) { + return $r; + } + } + return $results; } - // otherwise only request upload finished + // otherwise not really finished - only request upload finished default: return PEAR::raiseError( "Transport::getSearchResults: not finished ($st)", TRERR_NOTFIN ); } - $res = file_get_contents($row['localfile']); - //print_r($res); - $results = unserialize($res); - @unlink($row['localfile']); - $r = $trec->close(); - if (PEAR::isError($r)) { - return $r; - } - return $results; } @@ -1377,7 +1393,7 @@ class Transport break; case "metadata": case "searchjob": - return TRUE; // don't close + return TRUE; // don't close - getSearchResults should close it break; } $ret = $this->xmlrpcCall('archive.downloadClose',