Added support for editedBy field for playlists.
Please reinstall storageServer.
This commit is contained in:
parent
4c78eed9d7
commit
c7f8163eb7
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: tomas $
|
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 $
|
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
|
* Core of LiveSupport file storage module
|
||||||
*
|
*
|
||||||
* @author $Author: tomas $
|
* @author $Author: tomas $
|
||||||
* @version $Revision: 1.40 $
|
* @version $Revision: 1.41 $
|
||||||
* @see Alib
|
* @see Alib
|
||||||
*/
|
*/
|
||||||
class BasicStor extends Alib{
|
class BasicStor extends Alib{
|
||||||
|
@ -301,7 +301,7 @@ class BasicStor extends Alib{
|
||||||
"BasicStor::bsAccess: symlink create failed ($linkFname)",
|
"BasicStor::bsAccess: symlink create failed ($linkFname)",
|
||||||
GBERR_FILEIO);
|
GBERR_FILEIO);
|
||||||
}
|
}
|
||||||
}
|
}else $linkFname=NULL;
|
||||||
$this->dbc->query("BEGIN");
|
$this->dbc->query("BEGIN");
|
||||||
$res = $this->dbc->query("
|
$res = $this->dbc->query("
|
||||||
INSERT INTO {$this->accessTable}
|
INSERT INTO {$this->accessTable}
|
||||||
|
@ -1031,15 +1031,21 @@ class BasicStor extends Alib{
|
||||||
*
|
*
|
||||||
* @param playlistId string, playlist global unique ID
|
* @param playlistId string, playlist global unique ID
|
||||||
* @param val boolean, set/clear of edit flag
|
* @param val boolean, set/clear of edit flag
|
||||||
|
* @param sessid string, session id
|
||||||
* @return boolean, previous state
|
* @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);
|
$ac =& StoredFile::recallByGunid($this, $playlistId);
|
||||||
if($this->dbc->isError($ac)) return $ac;
|
if($this->dbc->isError($ac)) return $ac;
|
||||||
$state = $ac->_getState();
|
$state = $ac->_getState();
|
||||||
if($val){ $ac->setState('edited'); }
|
if($val){ $r = $ac->setState('edited', $userid); }
|
||||||
else{ $ac->setState('ready'); }
|
else{ $r = $ac->setState('ready', 'NULL'); }
|
||||||
|
if($this->dbc->isError($r)) return $r;
|
||||||
return ($state == 'edited');
|
return ($state == 'edited');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1047,13 +1053,14 @@ class BasicStor extends Alib{
|
||||||
* Check if playlist is marked as edited
|
* Check if playlist is marked as edited
|
||||||
*
|
*
|
||||||
* @param playlistId string, playlist global unique ID
|
* @param playlistId string, playlist global unique ID
|
||||||
* @return boolean
|
* @return FALSE | int - id of user editing it
|
||||||
*/
|
*/
|
||||||
function _isEdited($playlistId)
|
function _isEdited($playlistId)
|
||||||
{
|
{
|
||||||
$ac =& StoredFile::recallByGunid($this, $playlistId);
|
$ac =& StoredFile::recallByGunid($this, $playlistId);
|
||||||
if($this->dbc->isError($ac)) return $ac;
|
if($this->dbc->isError($ac)) return $ac;
|
||||||
return $ac->isEdited($playlistId);
|
if(!$ac->isEdited($playlistId)) return FALSE;
|
||||||
|
return $ac->isEditedBy($playlistId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------- redefined "protected" methods */
|
/* ---------------------------------------- redefined "protected" methods */
|
||||||
|
@ -1365,12 +1372,13 @@ class BasicStor extends Alib{
|
||||||
#echo "{$this->filesTable}\n";
|
#echo "{$this->filesTable}\n";
|
||||||
$r = $this->dbc->query("CREATE TABLE {$this->filesTable} (
|
$r = $this->dbc->query("CREATE TABLE {$this->filesTable} (
|
||||||
id int not null,
|
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 ;)
|
name varchar(255) not null default'', -- human file id ;)
|
||||||
mime varchar(255) not null default'', -- mime type
|
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
|
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;
|
if($this->dbc->isError($r)) return $r;
|
||||||
$this->dbc->query("CREATE UNIQUE INDEX {$this->filesTable}_id_idx
|
$this->dbc->query("CREATE UNIQUE INDEX {$this->filesTable}_id_idx
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: tomas $
|
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 $
|
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.41 $
|
* @version $Revision: 1.42 $
|
||||||
* @see BasicStor
|
* @see BasicStor
|
||||||
*/
|
*/
|
||||||
class GreenBox extends BasicStor{
|
class GreenBox extends BasicStor{
|
||||||
|
@ -410,8 +410,8 @@ class GreenBox extends BasicStor{
|
||||||
if(PEAR::isError($hdid)) return $hdid;
|
if(PEAR::isError($hdid)) return $hdid;
|
||||||
if($parid != $hdid && !is_null($parid)){
|
if($parid != $hdid && !is_null($parid)){
|
||||||
$r = $this->bsMoveFile($id, $parid);
|
$r = $this->bsMoveFile($id, $parid);
|
||||||
|
if(PEAR::isError($r)){ return $r; }
|
||||||
}
|
}
|
||||||
if(PEAR::isError($r)){ return $r; }
|
|
||||||
return $id;
|
return $id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -475,7 +475,7 @@ class GreenBox extends BasicStor{
|
||||||
if(PEAR::isError($ac)){ return $ac; }
|
if(PEAR::isError($ac)){ return $ac; }
|
||||||
$r = $ac->md->regenerateXmlFile();
|
$r = $ac->md->regenerateXmlFile();
|
||||||
if(PEAR::isError($r)) return $r;
|
if(PEAR::isError($r)) return $r;
|
||||||
$this->_setEditFlag($gunid, FALSE);
|
$this->_setEditFlag($gunid, FALSE, $sessid);
|
||||||
return $gunid;
|
return $gunid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -490,6 +490,7 @@ class GreenBox extends BasicStor{
|
||||||
function addAudioClipToPlaylist($token, $acId, $sessid)
|
function addAudioClipToPlaylist($token, $acId, $sessid)
|
||||||
{
|
{
|
||||||
$acGunid = $this->_gunidFromId($acId);
|
$acGunid = $this->_gunidFromId($acId);
|
||||||
|
if(PEAR::isError($acGunid)) return $acGunid;
|
||||||
$plGunid = $this->_gunidFromToken($token, 'download');
|
$plGunid = $this->_gunidFromToken($token, 'download');
|
||||||
if(PEAR::isError($plGunid)) return $plGunid;
|
if(PEAR::isError($plGunid)) return $plGunid;
|
||||||
if(is_null($plGunid)){
|
if(is_null($plGunid)){
|
||||||
|
@ -503,9 +504,13 @@ class GreenBox extends BasicStor{
|
||||||
// get playlist length and record id:
|
// get playlist length and record id:
|
||||||
$r = $pl->md->getMetadataEl('dcterms:extent');
|
$r = $pl->md->getMetadataEl('dcterms:extent');
|
||||||
if(PEAR::isError($r)){ return $r; }
|
if(PEAR::isError($r)){ return $r; }
|
||||||
$plLen = $r[0]['value'];
|
if(isset($r[0])){
|
||||||
$plLenMid = $r[0]['mid'];
|
$plLen = $r[0]['value'];
|
||||||
if(is_null($plLen)) $plLen = '00:00:00.000000';
|
$plLenMid = $r[0]['mid'];
|
||||||
|
}else{
|
||||||
|
$plLen = '00:00:00.000000';
|
||||||
|
$plLenMid = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
// get audioClip legth and title
|
// get audioClip legth and title
|
||||||
$ac =& StoredFile::recallByGunid($this, $acGunid);
|
$ac =& StoredFile::recallByGunid($this, $acGunid);
|
||||||
|
@ -680,7 +685,7 @@ class GreenBox extends BasicStor{
|
||||||
if(PEAR::isError($mdata)){ return $mdata; }
|
if(PEAR::isError($mdata)){ return $mdata; }
|
||||||
$res = $ac->replaceMetaData($mdata, 'string');
|
$res = $ac->replaceMetaData($mdata, 'string');
|
||||||
if(PEAR::isError($res)){ return $res; }
|
if(PEAR::isError($res)){ return $res; }
|
||||||
$this->_setEditFlag($gunid, FALSE);
|
$this->_setEditFlag($gunid, FALSE, $sessid);
|
||||||
return $gunid;
|
return $gunid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -750,14 +755,14 @@ class GreenBox extends BasicStor{
|
||||||
*
|
*
|
||||||
* @param id int, local id
|
* @param id int, local id
|
||||||
* @param sessid string, session ID
|
* @param sessid string, session ID
|
||||||
* @return boolean
|
* @return FALSE | int - id of user editing it
|
||||||
*/
|
*/
|
||||||
function playlistIsAvailable($id, $sessid)
|
function playlistIsAvailable($id, $sessid)
|
||||||
{
|
{
|
||||||
$gunid = $this->_gunidFromId($id);
|
$gunid = $this->_gunidFromId($id);
|
||||||
require_once"LocStor.php";
|
require_once"LocStor.php";
|
||||||
$lc =& new LocStor($this->dbc, $this->config);
|
$lc =& new LocStor($this->dbc, $this->config);
|
||||||
return $lc->playlistIsAvailable($sessid, $gunid);
|
return $lc->playlistIsAvailable($sessid, $gunid, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ============================================== methods for preferences */
|
/* ============================================== methods for preferences */
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: tomas $
|
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 $
|
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:
|
// test of gunid format:
|
||||||
if(!$this->_checkGunid($gunid)){
|
if(!$this->_checkGunid($gunid)){
|
||||||
return PEAR::raiseError(
|
return PEAR::raiseError(
|
||||||
"LocStor.php: storeAudioClipOpen: Wrong gunid ($gunid)"
|
"LocStor::storeAudioClipOpen: Wrong gunid ($gunid)"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// test if specified gunid exists:
|
// test if specified gunid exists:
|
||||||
|
@ -68,7 +68,7 @@ class LocStor extends BasicStor{
|
||||||
{ return $res; }
|
{ return $res; }
|
||||||
if($ac->isAccessed()){
|
if($ac->isAccessed()){
|
||||||
return PEAR::raiseError(
|
return PEAR::raiseError(
|
||||||
'LocStor.php: storeAudioClipOpen: is accessed'
|
'LocStor::storeAudioClipOpen: is accessed'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$res = $ac->replace(
|
$res = $ac->replace(
|
||||||
|
@ -82,7 +82,7 @@ class LocStor extends BasicStor{
|
||||||
if(PEAR::isError($parid)) return $parid;
|
if(PEAR::isError($parid)) return $parid;
|
||||||
if(($res = $this->_authorize('write', $parid, $sessid)) !== TRUE)
|
if(($res = $this->_authorize('write', $parid, $sessid)) !== TRUE)
|
||||||
{ return $res; }
|
{ return $res; }
|
||||||
$oid = $this->addObj($tmpFname , 'File', $parid);
|
$oid = $this->addObj($tmpFname , $ftype, $parid);
|
||||||
if(PEAR::isError($oid)) return $oid;
|
if(PEAR::isError($oid)) return $oid;
|
||||||
$ac =& StoredFile::insert(
|
$ac =& StoredFile::insert(
|
||||||
$this, $oid, '', '', $metadata, 'string',
|
$this, $oid, '', '', $metadata, 'string',
|
||||||
|
@ -475,7 +475,7 @@ class LocStor extends BasicStor{
|
||||||
if(PEAR::isError($ex)){ return $ex; }
|
if(PEAR::isError($ex)){ return $ex; }
|
||||||
if($ex){
|
if($ex){
|
||||||
return PEAR::raiseError(
|
return PEAR::raiseError(
|
||||||
'LocStor.php: createPlaylist: already exists'
|
'LocStor::createPlaylist: already exists'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$tmpFname = uniqid('');
|
$tmpFname = uniqid('');
|
||||||
|
@ -483,7 +483,7 @@ class LocStor extends BasicStor{
|
||||||
if(PEAR::isError($parid)) return $parid;
|
if(PEAR::isError($parid)) return $parid;
|
||||||
if(($res = $this->_authorize('write', $parid, $sessid)) !== TRUE)
|
if(($res = $this->_authorize('write', $parid, $sessid)) !== TRUE)
|
||||||
return $res;
|
return $res;
|
||||||
$oid = $this->addObj($tmpFname , 'File', $parid);
|
$oid = $this->addObj($tmpFname , 'playlist', $parid);
|
||||||
if(PEAR::isError($oid)) return $oid;
|
if(PEAR::isError($oid)) return $oid;
|
||||||
$ac =& StoredFile::insert($this, $oid, '', '',
|
$ac =& StoredFile::insert($this, $oid, '', '',
|
||||||
dirname(__FILE__).'/emptyPlaylist.xml',
|
dirname(__FILE__).'/emptyPlaylist.xml',
|
||||||
|
@ -520,12 +520,12 @@ class LocStor extends BasicStor{
|
||||||
if(PEAR::isError($ex)){ return $ex; }
|
if(PEAR::isError($ex)){ return $ex; }
|
||||||
if(!$ex){
|
if(!$ex){
|
||||||
return PEAR::raiseError(
|
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(
|
return PEAR::raiseError(
|
||||||
'LocStor.php: editPlaylist: playlist already edited'
|
'LocStor::editPlaylist: playlist already edited'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$ac =& StoredFile::recallByGunid($this, $playlistId);
|
$ac =& StoredFile::recallByGunid($this, $playlistId);
|
||||||
|
@ -535,7 +535,8 @@ class LocStor extends BasicStor{
|
||||||
return $res;
|
return $res;
|
||||||
$res = $this->bsOpenDownload($id, 'metadata');
|
$res = $this->bsOpenDownload($id, 'metadata');
|
||||||
if(PEAR::isError($res)){ return $res; }
|
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']);
|
unset($res['filename']);
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
@ -556,7 +557,8 @@ class LocStor extends BasicStor{
|
||||||
if(PEAR::isError($ac)){ return $ac; }
|
if(PEAR::isError($ac)){ return $ac; }
|
||||||
$res = $ac->replaceMetaData($newPlaylist, 'string');
|
$res = $ac->replaceMetaData($newPlaylist, 'string');
|
||||||
if(PEAR::isError($res)){ return $res; }
|
if(PEAR::isError($res)){ return $res; }
|
||||||
$this->_setEditFlag($playlistId, FALSE);
|
$r = $this->_setEditFlag($playlistId, FALSE, $sessid);
|
||||||
|
if(PEAR::isError($r)){ return $r; }
|
||||||
return $playlistId;
|
return $playlistId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -573,7 +575,7 @@ class LocStor extends BasicStor{
|
||||||
if(PEAR::isError($ex)){ return $ex; }
|
if(PEAR::isError($ex)){ return $ex; }
|
||||||
if(!$ex){
|
if(!$ex){
|
||||||
return PEAR::raiseError(
|
return PEAR::raiseError(
|
||||||
'LocStor.php: deletePlaylist: playlist not exists'
|
'LocStor::deletePlaylist: playlist not exists'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$ac =& StoredFile::recallByGunid($this, $playlistId);
|
$ac =& StoredFile::recallByGunid($this, $playlistId);
|
||||||
|
@ -599,7 +601,7 @@ class LocStor extends BasicStor{
|
||||||
if(PEAR::isError($ex)){ return $ex; }
|
if(PEAR::isError($ex)){ return $ex; }
|
||||||
if(!$ex){
|
if(!$ex){
|
||||||
return PEAR::raiseError(
|
return PEAR::raiseError(
|
||||||
"LocStor.php: accessPlaylist: playlist not found ($playlistId)",
|
"LocStor::accessPlaylist: playlist not found ($playlistId)",
|
||||||
GBERR_NOTF
|
GBERR_NOTF
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -642,18 +644,22 @@ class LocStor extends BasicStor{
|
||||||
*
|
*
|
||||||
* @param sessid string, session ID
|
* @param sessid string, session ID
|
||||||
* @param playlistId string, playlist global unique ID
|
* @param playlistId string, playlist global unique ID
|
||||||
|
* @param getUid boolean, optional flag for returning editedby uid
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function playlistIsAvailable($sessid, $playlistId)
|
function playlistIsAvailable($sessid, $playlistId, $getUid=FALSE)
|
||||||
{
|
{
|
||||||
$ex = $this->existsPlaylist($sessid, $playlistId);
|
$ex = $this->existsPlaylist($sessid, $playlistId);
|
||||||
if(PEAR::isError($ex)){ return $ex; }
|
if(PEAR::isError($ex)){ return $ex; }
|
||||||
if(!$ex){
|
if(!$ex){
|
||||||
return PEAR::raiseError(
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue