fixed copy, move, delete problems in html ui
This commit is contained in:
parent
798b48c6b3
commit
0bb6923efd
6 changed files with 51 additions and 32 deletions
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: tomas $
|
Author : $Author: tomas $
|
||||||
Version : $Revision: 1.16 $
|
Version : $Revision: 1.17 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/BasicStor.php,v $
|
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
|
* Core of LiveSupport file storage module
|
||||||
*
|
*
|
||||||
* @author $Author: tomas $
|
* @author $Author: tomas $
|
||||||
* @version $Revision: 1.16 $
|
* @version $Revision: 1.17 $
|
||||||
* @see Alib
|
* @see Alib
|
||||||
*/
|
*/
|
||||||
class BasicStor extends Alib{
|
class BasicStor extends Alib{
|
||||||
|
@ -184,6 +184,8 @@ class BasicStor extends Alib{
|
||||||
return PEAR::raiseError(
|
return PEAR::raiseError(
|
||||||
"BasicStor::moveFile: destination is not folder ($did)", GBERR_WRTYPE
|
"BasicStor::moveFile: destination is not folder ($did)", GBERR_WRTYPE
|
||||||
);
|
);
|
||||||
|
$parid = $this->getParent($id);
|
||||||
|
if($parid == $did) return TRUE;
|
||||||
$this->_relocateSubtree($id, $did);
|
$this->_relocateSubtree($id, $did);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,7 +213,6 @@ class BasicStor extends Alib{
|
||||||
*/
|
*/
|
||||||
function bsDeleteFile($id)
|
function bsDeleteFile($id)
|
||||||
{
|
{
|
||||||
$parid = $this->getParent($id);
|
|
||||||
$res = $this->removeObj($id);
|
$res = $this->removeObj($id);
|
||||||
if(PEAR::isError($res)) return $res;
|
if(PEAR::isError($res)) return $res;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -747,7 +748,7 @@ class BasicStor extends Alib{
|
||||||
";
|
";
|
||||||
$this->test_dump = $this->dumpTree($this->storId);
|
$this->test_dump = $this->dumpTree($this->storId);
|
||||||
if($this->test_dump==$this->test_correct)
|
if($this->test_dump==$this->test_correct)
|
||||||
{ $this->test_log.="storageServer: OK\n"; return true; }
|
{ $this->test_log.="# BasicStor::test: OK\n"; return true; }
|
||||||
else PEAR::raiseError('BasicStor::test:', 1, PEAR_ERROR_DIE, '%s'.
|
else PEAR::raiseError('BasicStor::test:', 1, PEAR_ERROR_DIE, '%s'.
|
||||||
"<pre>\ncorrect:\n.{$this->test_correct}.\n".
|
"<pre>\ncorrect:\n.{$this->test_correct}.\n".
|
||||||
"dump:\n.{$this->test_dump}.\n</pre>\n");
|
"dump:\n.{$this->test_dump}.\n</pre>\n");
|
||||||
|
@ -874,7 +875,7 @@ class BasicStor extends Alib{
|
||||||
$this->dbc->dropSequence("{$this->mdataTable}_id_seq");
|
$this->dbc->dropSequence("{$this->mdataTable}_id_seq");
|
||||||
$this->dbc->query("DROP TABLE {$this->filesTable}");
|
$this->dbc->query("DROP TABLE {$this->filesTable}");
|
||||||
$this->dbc->query("DROP TABLE {$this->accessTable}");
|
$this->dbc->query("DROP TABLE {$this->accessTable}");
|
||||||
$d = dir($this->storageDir);
|
$d = @dir($this->storageDir);
|
||||||
while (is_object($d) && (false !== ($entry = $d->read()))){
|
while (is_object($d) && (false !== ($entry = $d->read()))){
|
||||||
if(filetype("{$this->storageDir}/$entry")=='dir' &&
|
if(filetype("{$this->storageDir}/$entry")=='dir' &&
|
||||||
$entry!='CVS' && strlen($entry)==3)
|
$entry!='CVS' && strlen($entry)==3)
|
||||||
|
@ -894,7 +895,7 @@ class BasicStor extends Alib{
|
||||||
while (false !== ($entry = $d->read())) if(substr($entry,0,1)!='.')
|
while (false !== ($entry = $d->read())) if(substr($entry,0,1)!='.')
|
||||||
{ unlink("{$this->bufferDir}/$entry"); }
|
{ unlink("{$this->bufferDir}/$entry"); }
|
||||||
$d->close();
|
$d->close();
|
||||||
rmdir($this->bufferDir);
|
@rmdir($this->bufferDir);
|
||||||
}
|
}
|
||||||
parent::uninstall();
|
parent::uninstall();
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: tomas $
|
Author : $Author: tomas $
|
||||||
Version : $Revision: 1.20 $
|
Version : $Revision: 1.21 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/GreenBox.php,v $
|
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
|
* LiveSupport file storage module
|
||||||
*
|
*
|
||||||
* @author $Author: tomas $
|
* @author $Author: tomas $
|
||||||
* @version $Revision: 1.20 $
|
* @version $Revision: 1.21 $
|
||||||
* @see BasicStor
|
* @see BasicStor
|
||||||
*/
|
*/
|
||||||
class GreenBox extends BasicStor{
|
class GreenBox extends BasicStor{
|
||||||
|
@ -395,8 +395,9 @@ class GreenBox extends BasicStor{
|
||||||
{
|
{
|
||||||
$type = $this->getObjName($oid, 'type');
|
$type = $this->getObjName($oid, 'type');
|
||||||
if($type == 'File'){
|
if($type == 'File'){
|
||||||
$type =
|
$ftype =
|
||||||
StoredFile::_getType($this->_gunidFromId($oid));
|
StoredFile::_getType($this->_gunidFromId($oid));
|
||||||
|
if(!is_null($ftype)) $type=$ftype;
|
||||||
}
|
}
|
||||||
return $type;
|
return $type;
|
||||||
}
|
}
|
||||||
|
@ -411,6 +412,7 @@ class GreenBox extends BasicStor{
|
||||||
*/
|
*/
|
||||||
function copyObj($id, $newParid, $after=NULL)
|
function copyObj($id, $newParid, $after=NULL)
|
||||||
{
|
{
|
||||||
|
$parid = $this->getParent($id);
|
||||||
$nid = parent::copyObj($id, $newParid, $after);
|
$nid = parent::copyObj($id, $newParid, $after);
|
||||||
if(PEAR::isError($nid)) return $nid;
|
if(PEAR::isError($nid)) return $nid;
|
||||||
switch($this->getObjType($id)){
|
switch($this->getObjType($id)){
|
||||||
|
@ -447,7 +449,7 @@ class GreenBox extends BasicStor{
|
||||||
*/
|
*/
|
||||||
function removeObj($id)
|
function removeObj($id)
|
||||||
{
|
{
|
||||||
switch($this->getObjType($id)){
|
switch($ot = $this->getObjType($id)){
|
||||||
case"audioclip":
|
case"audioclip":
|
||||||
case"playlist":
|
case"playlist":
|
||||||
case"File":
|
case"File":
|
||||||
|
@ -455,15 +457,21 @@ class GreenBox extends BasicStor{
|
||||||
if(!PEAR::isError($ac)){
|
if(!PEAR::isError($ac)){
|
||||||
$ac->delete();
|
$ac->delete();
|
||||||
}
|
}
|
||||||
parent::removeObj($id);
|
$r = parent::removeObj($id);
|
||||||
|
if(PEAR::isError($r)) return $r;
|
||||||
break;
|
break;
|
||||||
case"Folder":
|
case"Folder":
|
||||||
parent::removeObj($id);
|
$r = parent::removeObj($id);
|
||||||
|
if(PEAR::isError($r)) return $r;
|
||||||
break;
|
break;
|
||||||
case"Replica":
|
case"Replica":
|
||||||
parent::removeObj($id);
|
$r = parent::removeObj($id);
|
||||||
|
if(PEAR::isError($r)) return $r;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
return PEAR::raiseError(
|
||||||
|
"GreenBox::removeObj: unknown obj type ($ot)"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,8 @@
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: maroy $
|
Author : $Author: tomas $
|
||||||
Version : $Revision: 1.11 $
|
Version : $Revision: 1.12 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/MetaData.php,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/MetaData.php,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -128,8 +128,10 @@ class MetaData{
|
||||||
*/
|
*/
|
||||||
function replace($mdata, $loc='file')
|
function replace($mdata, $loc='file')
|
||||||
{
|
{
|
||||||
if($this->exists) $res = $this->delete();
|
if($this->exists){
|
||||||
if(PEAR::isError($res)) return $res;
|
$res = $this->delete();
|
||||||
|
if(PEAR::isError($res)) return $res;
|
||||||
|
}
|
||||||
return $this->insert($mdata, $loc);
|
return $this->insert($mdata, $loc);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: tomas $
|
Author : $Author: tomas $
|
||||||
Version : $Revision: 1.13 $
|
Version : $Revision: 1.14 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/StoredFile.php,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/StoredFile.php,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -71,7 +71,7 @@ class StoredFile{
|
||||||
|
|
||||||
/* ========= 'factory' methods - should be called to construct StoredFile */
|
/* ========= 'factory' methods - should be called to construct StoredFile */
|
||||||
/**
|
/**
|
||||||
* Create instace of StoreFile object and insert new file
|
* Create instace of StoredFile object and insert new file
|
||||||
*
|
*
|
||||||
* @param gb reference to GreenBox object
|
* @param gb reference to GreenBox object
|
||||||
* @param oid int, local object id in the tree
|
* @param oid int, local object id in the tree
|
||||||
|
@ -227,7 +227,7 @@ class StoredFile{
|
||||||
'', '', NULL, $src->_getType()
|
'', '', NULL, $src->_getType()
|
||||||
);
|
);
|
||||||
if(PEAR::isError($ac)) return $ac;
|
if(PEAR::isError($ac)) return $ac;
|
||||||
$ac->md->replace($src->md->getMetaData());
|
$ac->md->replace($src->md->getMetaData(), 'string');
|
||||||
return $ac;
|
return $ac;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -593,10 +593,11 @@ class StoredFile{
|
||||||
function _getType($gunid=NULL)
|
function _getType($gunid=NULL)
|
||||||
{
|
{
|
||||||
if(is_null($gunid)) $gunid = $this->gunid;
|
if(is_null($gunid)) $gunid = $this->gunid;
|
||||||
return $this->dbc->getOne("
|
$ftype = $this->dbc->getOne("
|
||||||
SELECT ftype FROM {$this->filesTable}
|
SELECT ftype FROM {$this->filesTable}
|
||||||
WHERE gunid=x'$gunid'::bigint
|
WHERE gunid=x'$gunid'::bigint
|
||||||
");
|
");
|
||||||
|
return $ftype;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -98,18 +98,18 @@ $tpldata['showMenu']=true;
|
||||||
'</form>';
|
'</form>';
|
||||||
}
|
}
|
||||||
function fmove(id, relPath){
|
function fmove(id, relPath){
|
||||||
var newPath=prompt('Destination folder (relative path):', relPath);
|
var newPath=prompt('Destination folder (relative path, e.g. "..", "folderName", "../folderName):', relPath);
|
||||||
if(newPath==null) return;
|
if(newPath==null || newPath=='') return;
|
||||||
location.href='gbHttp.php?id='+id+'&act=move&newPath='+newPath;
|
location.href='gbHttp.php?id='+id+'&act=move&newPath='+newPath;
|
||||||
}
|
}
|
||||||
function fcopy(id, relPath){
|
function fcopy(id, relPath){
|
||||||
var newPath=prompt('Destination folder (relative path):', relPath);
|
var newPath=prompt('Destination folder (relative path, e.g. "..", "folderName", "../folderName):', relPath);
|
||||||
if(newPath==null) return;
|
if(newPath==null || newPath=='') return;
|
||||||
location.href='gbHttp.php?id='+id+'&act=copy&newPath='+newPath;
|
location.href='gbHttp.php?id='+id+'&act=copy&newPath='+newPath;
|
||||||
}
|
}
|
||||||
function freplicate(name, id){
|
function freplicate(name, id){
|
||||||
var np=prompt('Destination folder (relative path):', id);
|
var np=prompt('Destination folder (relative path, e.g. "..", "folderName", "../folderName):', id);
|
||||||
if(np==null) return;
|
if(np==null || np=='') return;
|
||||||
location.href='gbHttp.php?id='+id+'&act=repl&newparid='+np;
|
location.href='gbHttp.php?id='+id+'&act=repl&newparid='+np;
|
||||||
}
|
}
|
||||||
function newFolder(){
|
function newFolder(){
|
||||||
|
@ -168,8 +168,8 @@ $tpldata['showMenu']=true;
|
||||||
</td><td>
|
</td><td>
|
||||||
<?php $a=array('Folder'=>'D', 'File'=>'F', 'Replica'=>'R', 'audioclip'=>'A', 'playlist'=>'P'); echo$a[$o['type']]?>
|
<?php $a=array('Folder'=>'D', 'File'=>'F', 'Replica'=>'R', 'audioclip'=>'A', 'playlist'=>'P'); echo$a[$o['type']]?>
|
||||||
<a href="javascript:frename('<?php echo$o['name']?>', '<?php echo$o['id']?>')" class="button">rename</a>
|
<a href="javascript:frename('<?php echo$o['name']?>', '<?php echo$o['id']?>')" class="button">rename</a>
|
||||||
<a href="javascript:fmove('<?php echo$o['id']?>', '.')" class="button">move</a>
|
<a href="javascript:fmove('<?php echo$o['id']?>', '')" class="button">move</a>
|
||||||
<a href="javascript:fcopy('<?php echo$o['id']?>', '.')" class="button">copy</a>
|
<a href="javascript:fcopy('<?php echo$o['id']?>', '')" class="button">copy</a>
|
||||||
<?php /*?>
|
<?php /*?>
|
||||||
<a href="javascript:freplicate('<?php echo$o['name']?>', '<?php echo$o['id']?>')" class="button">replicate</a>
|
<a href="javascript:freplicate('<?php echo$o['name']?>', '<?php echo$o['id']?>')" class="button">replicate</a>
|
||||||
<?php */?>
|
<?php */?>
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: tomas $
|
Author : $Author: tomas $
|
||||||
Version : $Revision: 1.10 $
|
Version : $Revision: 1.11 $
|
||||||
Location : $ $
|
Location : $ $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -33,7 +33,7 @@ require_once"gbHtml_h.php";
|
||||||
* storageServer WWW-form interface
|
* storageServer WWW-form interface
|
||||||
*
|
*
|
||||||
* @author $Author: tomas $
|
* @author $Author: tomas $
|
||||||
* @version $Revision: 1.10 $
|
* @version $Revision: 1.11 $
|
||||||
* @see Alib
|
* @see Alib
|
||||||
* @see GreenBox
|
* @see GreenBox
|
||||||
*/
|
*/
|
||||||
|
@ -163,13 +163,19 @@ switch($_REQUEST['act']){
|
||||||
case"move":
|
case"move":
|
||||||
$newPath = urlencode($_REQUEST['newPath']);
|
$newPath = urlencode($_REQUEST['newPath']);
|
||||||
$did = $gb->getObjIdFromRelPath($id, $newPath);
|
$did = $gb->getObjIdFromRelPath($id, $newPath);
|
||||||
|
if(PEAR::isError($did)){
|
||||||
|
$_SESSION['alertMsg'] = $did->getMessage();
|
||||||
|
$redirUrl = BROWSER."?id=$parid";
|
||||||
|
break;
|
||||||
|
}
|
||||||
$parid = $gb->getParent($id);
|
$parid = $gb->getParent($id);
|
||||||
$r = $gb->moveFile($id, $did, $sessid);
|
$r = $gb->moveFile($id, $did, $sessid);
|
||||||
if(PEAR::isError($r)){
|
if(PEAR::isError($r)){
|
||||||
$_SESSION['alertMsg'] = $r->getMessage();
|
$_SESSION['alertMsg'] = $r->getMessage();
|
||||||
$redirUrl = BROWSER."?id=$parid";
|
$redirUrl = BROWSER."?id=$parid";
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else $redirUrl = BROWSER."?id=$did";
|
$redirUrl = BROWSER."?id=$did";
|
||||||
break;
|
break;
|
||||||
/**
|
/**
|
||||||
* copy
|
* copy
|
||||||
|
@ -187,6 +193,7 @@ switch($_REQUEST['act']){
|
||||||
$r = $gb->copyFile($id, $did, $sessid);
|
$r = $gb->copyFile($id, $did, $sessid);
|
||||||
if(PEAR::isError($r)){
|
if(PEAR::isError($r)){
|
||||||
$_SESSION['alertMsg'] = $r->getMessage();
|
$_SESSION['alertMsg'] = $r->getMessage();
|
||||||
|
#$_SESSION['alertMsg'] = $r->getMessage()." ".$r->getUserInfo();
|
||||||
$redirUrl = BROWSER."?id=$parid";
|
$redirUrl = BROWSER."?id=$parid";
|
||||||
}
|
}
|
||||||
else $redirUrl = BROWSER."?id=$did";
|
else $redirUrl = BROWSER."?id=$did";
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue