From 7dbe916d6d9fe610d7a7f9eff10403c6d12188f8 Mon Sep 17 00:00:00 2001 From: tomash Date: Tue, 28 Nov 2006 19:51:03 +0000 Subject: [PATCH] #1944 + #1869 hubSearch part --- .../modules/htmlUI/var/html/ui_browser.php | 8 +++++-- .../templates/library/hub_actionhandler.tpl | 2 +- .../var/templates/script/contextmenu.js.tpl | 2 +- .../modules/htmlUI/var/ui_hubSearch.class.php | 20 +++++++++++------- .../modules/htmlUI/var/ui_transfers.class.php | 10 ++++++--- .../modules/storageServer/var/Transport.php | 21 +++++++++++++++++-- .../storageServer/var/xmlrpc/XR_LocStor.php | 1 + 7 files changed, 47 insertions(+), 17 deletions(-) diff --git a/campcaster/src/modules/htmlUI/var/html/ui_browser.php b/campcaster/src/modules/htmlUI/var/html/ui_browser.php index 2900241b9..71911665b 100644 --- a/campcaster/src/modules/htmlUI/var/html/ui_browser.php +++ b/campcaster/src/modules/htmlUI/var/html/ui_browser.php @@ -199,7 +199,7 @@ if (isset($_REQUEST['popup']) && is_array($_REQUEST['popup'])){ break; case 'TR.confirmDownloadFromHub': - $uiBrowser->TRANSFERS->downloadFromHub($_REQUEST['id']); + $uiBrowser->TRANSFERS->downloadFromHub($uiBrowser->sessid, $_REQUEST['gunid']); $Smarty->display('popup/TR.confirmTransfer.tpl'); break; @@ -250,7 +250,11 @@ 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'], FALSE)) { + $r = $uiBrowser->HUBSEARCH->getSearchResults($_REQUEST['trtokid'], FALSE); + if ( PEAR::isError($r) && ($r->getCode() != TRERR_NOTFIN) ) { + break; + } + if ($r) { $Smarty->assign('results',true); } else { $Smarty->assign('results',false); diff --git a/campcaster/src/modules/htmlUI/var/templates/library/hub_actionhandler.tpl b/campcaster/src/modules/htmlUI/var/templates/library/hub_actionhandler.tpl index 301f738c2..60bf24104 100644 --- a/campcaster/src/modules/htmlUI/var/templates/library/hub_actionhandler.tpl +++ b/campcaster/src/modules/htmlUI/var/templates/library/hub_actionhandler.tpl @@ -1,4 +1,4 @@ -onClick="return contextmenu('{$i.id}' +onClick="return contextmenu('{$i.gunid}' , 'TR.downloadFromHub' )" diff --git a/campcaster/src/modules/htmlUI/var/templates/script/contextmenu.js.tpl b/campcaster/src/modules/htmlUI/var/templates/script/contextmenu.js.tpl index bb3595ca0..0268e5d67 100644 --- a/campcaster/src/modules/htmlUI/var/templates/script/contextmenu.js.tpl +++ b/campcaster/src/modules/htmlUI/var/templates/script/contextmenu.js.tpl @@ -135,7 +135,7 @@ function contextmenu(param) { break; case "TR.downloadFromHub": - contextmenuHtml = contextmenuHtml + "
  •  ##Transfer from the hub## 
  • "; + contextmenuHtml = contextmenuHtml + "
  •  ##Transfer from the hub## 
  • "; break; case "TR.pause": diff --git a/campcaster/src/modules/htmlUI/var/ui_hubSearch.class.php b/campcaster/src/modules/htmlUI/var/ui_hubSearch.class.php index 6da213b5e..84a0ce5b2 100644 --- a/campcaster/src/modules/htmlUI/var/ui_hubSearch.class.php +++ b/campcaster/src/modules/htmlUI/var/ui_hubSearch.class.php @@ -63,6 +63,16 @@ class uiHubSearch extends uiSearch { //echo 'this->criteria:'; print_r($this->criteria); echo "\n"; $trtokid = $this->Base->gb->globalSearch($this->criteria); + if (PEAR::isError($trtokid)) { + // don't know how to display error message in htmlUi- should be improved: + echo "ERROR: {$trtokid->getMessage()} {$trtokid->getUserInfo()}". + ($trtokid->getCode() ? " ({$trtokid->getCode()})" : "")."\n"; + echo "
    \nBack\n"; + exit; + //$this->Base->_retMsg("ERROR_3: {$trtokid->getMessage()} {$trtokid->getUserInfo()}\n"); + //$this->Base->redirUrl = UI_BROWSER.'?popup[]='; + return $trtokid; + } $this->Base->redirUrl = UI_BROWSER.'?popup[]='.$this->prefix.'.getResults&trtokid='.$trtokid; } // fn newSearch @@ -75,10 +85,8 @@ class uiHubSearch extends uiSearch { } $this->results = array('page' => $this->criteria['offset'] / $this->criteria['limit']); - //print_r($this->criteria); $results = $this->Base->gb->localSearch($this->criteria, $this->Base->sessid); if (PEAR::isError($results)) { - #print_r($results); return FALSE; } foreach ($results['results'] as $rec) { @@ -87,7 +95,6 @@ class uiHubSearch extends uiSearch { } $this->results['cnt'] = $results['cnt']; - //print_r($this->results); $this->pagination($results); return TRUE; @@ -97,14 +104,11 @@ class uiHubSearch extends uiSearch { function getSearchResults($trtokid, $andClose=TRUE) { $this->results = array('page' => $this->criteria['offset']/$this->criteria['limit']); - #sleep(4); $results = $this->Base->gb->getSearchResults($trtokid, $andClose); - // echo"
    RESULTS:
    ";print_r($results);echo "
    "; -/* - if (PEAR::isError($results)) { + if ( PEAR::isError($results) && ($results->getCode() != TRERR_NOTFIN) ) { echo "ERROR: {$results->getMessage()} {$results->getUserInfo()}\n"; + return $results; } -*/ if (!is_array($results) || !count($results)) { return false; } diff --git a/campcaster/src/modules/htmlUI/var/ui_transfers.class.php b/campcaster/src/modules/htmlUI/var/ui_transfers.class.php index feac2ed82..6e2e339f7 100644 --- a/campcaster/src/modules/htmlUI/var/ui_transfers.class.php +++ b/campcaster/src/modules/htmlUI/var/ui_transfers.class.php @@ -160,10 +160,11 @@ class uiTransfers switch ($type) { case 'audioClip': - $this->Base->gb->uploadAudioClip2Hub($gunid); + case 'audioclip': + $r = $this->Base->gb->upload2Hub($gunid); break; case 'playlist': - $this->Base->gb->uploadPlaylist2Hub($gunid); + $this->Base->gb->upload2Hub($gunid); break; default: // TODO: it is not implemented in gb, and this way maybe impossible @@ -173,8 +174,10 @@ class uiTransfers } - function downloadFromHub($id,$type) + function downloadFromHub($sessid, $gunid /*,$type*/) { + $this->Base->gb->downloadFromHub($sessid, $gunid); +/* switch ($type) { case 'audioClip': $this->Base->gb->downloadAudioClipFromHub($id); @@ -187,6 +190,7 @@ class uiTransfers //$this->Base->gb->downloadFileFromHub($gunid); return false; } +*/ } diff --git a/campcaster/src/modules/storageServer/var/Transport.php b/campcaster/src/modules/storageServer/var/Transport.php index 60d5c7e80..95a7433fe 100644 --- a/campcaster/src/modules/storageServer/var/Transport.php +++ b/campcaster/src/modules/storageServer/var/Transport.php @@ -444,6 +444,20 @@ class Transport */ function globalSearch($criteria, $resultMode='php', $pars=array()) { + // testing of hub availability and hub account configuration. + // it makes searchjob not async - should be removed for real async + $r = $this->loginToArchive(); + if (PEAR::isError($r)) { + switch(intval($r->getCode())) { + case 802: + return PEAR::raiseError("Can't login to Hub ({$r->getMessage()})", TRERR_XR_FAIL); + case TRERR_XR_FAIL: + return PEAR::raiseError("Can't connect to Hub ({$r->getMessage()})", TRERR_XR_FAIL); + } + return $r; + } + $this->logoutFromArchive($r); + // ---------- $criteria['resultMode'] = $resultMode; $localfile = tempnam($this->transDir, 'searchjob_'); @chmod($localfile, 0660); @@ -726,7 +740,10 @@ class Transport 'login'=>$this->config['archiveAccountLogin'], 'pass'=>$this->config['archiveAccountPass'] )); - return $res; + if (PEAR::isError($res)) { + return $res; + } + return $res['sessid']; } @@ -908,7 +925,7 @@ class Transport $r2 = $trec->setLock(FALSE); return $r; } - $asessid = $r['sessid']; + $asessid = $r; // method call: if (TR_LOG_LEVEL > 2) { $this->trLog("cronCallMethod: $mname($trtok) >"); diff --git a/campcaster/src/modules/storageServer/var/xmlrpc/XR_LocStor.php b/campcaster/src/modules/storageServer/var/xmlrpc/XR_LocStor.php index b5a5429ea..011a99f22 100644 --- a/campcaster/src/modules/storageServer/var/xmlrpc/XR_LocStor.php +++ b/campcaster/src/modules/storageServer/var/xmlrpc/XR_LocStor.php @@ -3261,6 +3261,7 @@ class XR_LocStor extends LocStor { *
  • 805 - xr_globalSearch: * <message from lower layer>
  • *
  • 848 - invalid session id.
  • + *
  • 874 - invalid hub connection configuration.
  • *
  • 872 - invalid tranport token.
  • * *