Added support for editedBy field for playlists.

Please reinstall storageServer.
This commit is contained in:
tomas 2005-02-24 21:38:59 +00:00
parent 4c78eed9d7
commit c7f8163eb7
3 changed files with 56 additions and 37 deletions

View File

@ -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/BasicStor.php,v $
------------------------------------------------------------------------------*/
@ -52,7 +52,7 @@ require_once "Transport.php";
* Core of LiveSupport file storage module
*
* @author $Author: tomas $
* @version $Revision: 1.40 $
* @version $Revision: 1.41 $
* @see Alib
*/
class BasicStor extends Alib{
@ -301,7 +301,7 @@ class BasicStor extends Alib{
"BasicStor::bsAccess: symlink create failed ($linkFname)",
GBERR_FILEIO);
}
}
}else $linkFname=NULL;
$this->dbc->query("BEGIN");
$res = $this->dbc->query("
INSERT INTO {$this->accessTable}
@ -1031,15 +1031,21 @@ class BasicStor extends Alib{
*
* @param playlistId string, playlist global unique ID
* @param val boolean, set/clear of edit flag
* @param sessid string, session id
* @return boolean, previous state
*/
function _setEditFlag($playlistId, $val=TRUE)
function _setEditFlag($playlistId, $val=TRUE, $sessid='')
{
if($sessid !== ''){
$userid = $this->getSessUserId($sessid);
if($this->dbc->isError($userid)) return $userid;
}else $userid=NULL;
$ac =& StoredFile::recallByGunid($this, $playlistId);
if($this->dbc->isError($ac)) return $ac;
$state = $ac->_getState();
if($val){ $ac->setState('edited'); }
else{ $ac->setState('ready'); }
if($val){ $r = $ac->setState('edited', $userid); }
else{ $r = $ac->setState('ready', 'NULL'); }
if($this->dbc->isError($r)) return $r;
return ($state == 'edited');
}
@ -1047,13 +1053,14 @@ class BasicStor extends Alib{
* Check if playlist is marked as edited
*
* @param playlistId string, playlist global unique ID
* @return boolean
* @return FALSE | int - id of user editing it
*/
function _isEdited($playlistId)
{
$ac =& StoredFile::recallByGunid($this, $playlistId);
if($this->dbc->isError($ac)) return $ac;
return $ac->isEdited($playlistId);
if(!$ac->isEdited($playlistId)) return FALSE;
return $ac->isEditedBy($playlistId);
}
/* ---------------------------------------- redefined "protected" methods */
@ -1365,12 +1372,13 @@ class BasicStor extends Alib{
#echo "{$this->filesTable}\n";
$r = $this->dbc->query("CREATE TABLE {$this->filesTable} (
id int not null,
gunid bigint not null, -- global unique ID
gunid bigint not null, -- global unique ID
name varchar(255) not null default'', -- human file id ;)
mime varchar(255) not null default'', -- mime type
ftype varchar(128) not null default'', -- file type
ftype varchar(128) not null default'', -- file type
state varchar(128) not null default'empty', -- file state
currentlyAccessing int not null default 0 -- access counter
currentlyAccessing int not null default 0, -- access counter
editedBy int REFERENCES {$this->subjTable} -- who edits it
)");
if($this->dbc->isError($r)) return $r;
$this->dbc->query("CREATE UNIQUE INDEX {$this->filesTable}_id_idx

View File

@ -23,7 +23,7 @@
Author : $Author: tomas $
Version : $Revision: 1.41 $
Version : $Revision: 1.42 $
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.41 $
* @version $Revision: 1.42 $
* @see BasicStor
*/
class GreenBox extends BasicStor{
@ -410,8 +410,8 @@ class GreenBox extends BasicStor{
if(PEAR::isError($hdid)) return $hdid;
if($parid != $hdid && !is_null($parid)){
$r = $this->bsMoveFile($id, $parid);
if(PEAR::isError($r)){ return $r; }
}
if(PEAR::isError($r)){ return $r; }
return $id;
}
@ -475,7 +475,7 @@ class GreenBox extends BasicStor{
if(PEAR::isError($ac)){ return $ac; }
$r = $ac->md->regenerateXmlFile();
if(PEAR::isError($r)) return $r;
$this->_setEditFlag($gunid, FALSE);
$this->_setEditFlag($gunid, FALSE, $sessid);
return $gunid;
}
@ -490,6 +490,7 @@ class GreenBox extends BasicStor{
function addAudioClipToPlaylist($token, $acId, $sessid)
{
$acGunid = $this->_gunidFromId($acId);
if(PEAR::isError($acGunid)) return $acGunid;
$plGunid = $this->_gunidFromToken($token, 'download');
if(PEAR::isError($plGunid)) return $plGunid;
if(is_null($plGunid)){
@ -503,9 +504,13 @@ class GreenBox extends BasicStor{
// get playlist length and record id:
$r = $pl->md->getMetadataEl('dcterms:extent');
if(PEAR::isError($r)){ return $r; }
$plLen = $r[0]['value'];
$plLenMid = $r[0]['mid'];
if(is_null($plLen)) $plLen = '00:00:00.000000';
if(isset($r[0])){
$plLen = $r[0]['value'];
$plLenMid = $r[0]['mid'];
}else{
$plLen = '00:00:00.000000';
$plLenMid = NULL;
}
// get audioClip legth and title
$ac =& StoredFile::recallByGunid($this, $acGunid);
@ -680,7 +685,7 @@ class GreenBox extends BasicStor{
if(PEAR::isError($mdata)){ return $mdata; }
$res = $ac->replaceMetaData($mdata, 'string');
if(PEAR::isError($res)){ return $res; }
$this->_setEditFlag($gunid, FALSE);
$this->_setEditFlag($gunid, FALSE, $sessid);
return $gunid;
}
@ -750,14 +755,14 @@ class GreenBox extends BasicStor{
*
* @param id int, local id
* @param sessid string, session ID
* @return boolean
* @return FALSE | int - id of user editing it
*/
function playlistIsAvailable($id, $sessid)
{
$gunid = $this->_gunidFromId($id);
require_once"LocStor.php";
$lc =& new LocStor($this->dbc, $this->config);
return $lc->playlistIsAvailable($sessid, $gunid);
return $lc->playlistIsAvailable($sessid, $gunid, TRUE);
}
/* ============================================== methods for preferences */

View File

@ -23,7 +23,7 @@
Author : $Author: tomas $
Version : $Revision: 1.35 $
Version : $Revision: 1.36 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/LocStor.php,v $
------------------------------------------------------------------------------*/
@ -56,7 +56,7 @@ class LocStor extends BasicStor{
// test of gunid format:
if(!$this->_checkGunid($gunid)){
return PEAR::raiseError(
"LocStor.php: storeAudioClipOpen: Wrong gunid ($gunid)"
"LocStor::storeAudioClipOpen: Wrong gunid ($gunid)"
);
}
// test if specified gunid exists:
@ -68,7 +68,7 @@ class LocStor extends BasicStor{
{ return $res; }
if($ac->isAccessed()){
return PEAR::raiseError(
'LocStor.php: storeAudioClipOpen: is accessed'
'LocStor::storeAudioClipOpen: is accessed'
);
}
$res = $ac->replace(
@ -82,7 +82,7 @@ class LocStor extends BasicStor{
if(PEAR::isError($parid)) return $parid;
if(($res = $this->_authorize('write', $parid, $sessid)) !== TRUE)
{ return $res; }
$oid = $this->addObj($tmpFname , 'File', $parid);
$oid = $this->addObj($tmpFname , $ftype, $parid);
if(PEAR::isError($oid)) return $oid;
$ac =& StoredFile::insert(
$this, $oid, '', '', $metadata, 'string',
@ -475,7 +475,7 @@ class LocStor extends BasicStor{
if(PEAR::isError($ex)){ return $ex; }
if($ex){
return PEAR::raiseError(
'LocStor.php: createPlaylist: already exists'
'LocStor::createPlaylist: already exists'
);
}
$tmpFname = uniqid('');
@ -483,7 +483,7 @@ class LocStor extends BasicStor{
if(PEAR::isError($parid)) return $parid;
if(($res = $this->_authorize('write', $parid, $sessid)) !== TRUE)
return $res;
$oid = $this->addObj($tmpFname , 'File', $parid);
$oid = $this->addObj($tmpFname , 'playlist', $parid);
if(PEAR::isError($oid)) return $oid;
$ac =& StoredFile::insert($this, $oid, '', '',
dirname(__FILE__).'/emptyPlaylist.xml',
@ -520,12 +520,12 @@ class LocStor extends BasicStor{
if(PEAR::isError($ex)){ return $ex; }
if(!$ex){
return PEAR::raiseError(
'LocStor.php: editPlaylist: playlist not exists'
'LocStor::editPlaylist: playlist not exists'
);
}
if($this->_isEdited($playlistId)){
if($this->_isEdited($playlistId) !== FALSE){
return PEAR::raiseError(
'LocStor.php: editPlaylist: playlist already edited'
'LocStor::editPlaylist: playlist already edited'
);
}
$ac =& StoredFile::recallByGunid($this, $playlistId);
@ -535,7 +535,8 @@ class LocStor extends BasicStor{
return $res;
$res = $this->bsOpenDownload($id, 'metadata');
if(PEAR::isError($res)){ return $res; }
$this->_setEditFlag($playlistId, TRUE);
$r = $this->_setEditFlag($playlistId, TRUE, $sessid);
if(PEAR::isError($r)){ return $r; }
unset($res['filename']);
return $res;
}
@ -556,7 +557,8 @@ class LocStor extends BasicStor{
if(PEAR::isError($ac)){ return $ac; }
$res = $ac->replaceMetaData($newPlaylist, 'string');
if(PEAR::isError($res)){ return $res; }
$this->_setEditFlag($playlistId, FALSE);
$r = $this->_setEditFlag($playlistId, FALSE, $sessid);
if(PEAR::isError($r)){ return $r; }
return $playlistId;
}
@ -573,7 +575,7 @@ class LocStor extends BasicStor{
if(PEAR::isError($ex)){ return $ex; }
if(!$ex){
return PEAR::raiseError(
'LocStor.php: deletePlaylist: playlist not exists'
'LocStor::deletePlaylist: playlist not exists'
);
}
$ac =& StoredFile::recallByGunid($this, $playlistId);
@ -599,7 +601,7 @@ class LocStor extends BasicStor{
if(PEAR::isError($ex)){ return $ex; }
if(!$ex){
return PEAR::raiseError(
"LocStor.php: accessPlaylist: playlist not found ($playlistId)",
"LocStor::accessPlaylist: playlist not found ($playlistId)",
GBERR_NOTF
);
}
@ -642,18 +644,22 @@ class LocStor extends BasicStor{
*
* @param sessid string, session ID
* @param playlistId string, playlist global unique ID
* @param getUid boolean, optional flag for returning editedby uid
* @return boolean
*/
function playlistIsAvailable($sessid, $playlistId)
function playlistIsAvailable($sessid, $playlistId, $getUid=FALSE)
{
$ex = $this->existsPlaylist($sessid, $playlistId);
if(PEAR::isError($ex)){ return $ex; }
if(!$ex){
return PEAR::raiseError(
'LocStor.php: playlistIsAvailable: playlist not exists'
'LocStor::playlistIsAvailable: playlist not exists'
);
}
return !$this->_isEdited($playlistId);
$ie = $this->_isEdited($playlistId);
if($ie === FALSE) return TRUE;
if($getUid) return $ie;
return FALSE;
}
}