Removed underscores from function names (that indicate private functions) for functions that were actually public. Changed bsGetMetadataValue() to allow an array as an argument to fetch multiple values at once.

This commit is contained in:
paul 2006-11-21 15:43:04 +00:00
parent df75695233
commit 644be7c50c

View file

@ -79,6 +79,7 @@ class BasicStor extends Alib {
public $storId; public $storId;
/** /**
* Constructor * Constructor
* *
@ -921,13 +922,43 @@ class BasicStor extends Alib {
* array of matching records (as hash {id, value, attrs}) * array of matching records (as hash {id, value, attrs})
* @see Metadata::getMetadataValue * @see Metadata::getMetadataValue
*/ */
public function bsGetMetadataValue($id, $category, $lang=NULL, $deflang=NULL) // public function bsGetMetadataValue($id, $category, $lang=NULL, $deflang=NULL)
// {
// $ac = StoredFile::recall($this, $id);
// if ($this->dbc->isError($ac)) {
// return $ac;
// }
// return $ac->md->getMetadataValue($category, $lang, $deflang);
// }
/**
* Get metadata element value
*
* @param int $id
* Virtual file's local id
* @param string|array $category
* metadata element name, or array of metadata element names
* @return string|array
* If a string is passed in for $category, a string is returned,
* if an array is passed, an array is returned.
* @see Metadata::getMetadataValue
*/
public function bsGetMetadataValue($id, $category)
{ {
$ac = StoredFile::recall($this, $id); $ac = StoredFile::recall($this, $id);
if ($this->dbc->isError($ac)) { if ($this->dbc->isError($ac)) {
return $ac; return $ac;
} }
return $ac->md->getMetadataValue($category, $lang, $deflang); if (!is_array($category)) {
return $ac->md->getMetadataValue($category);
} else {
$values = array();
foreach ($category as $tmpCat) {
$values[$tmpCat] = $ac->md->getMetadataValue($tmpCat);
}
return $values;
}
} }
@ -957,13 +988,6 @@ class BasicStor extends Alib {
if ($this->dbc->isError($ac)) { if ($this->dbc->isError($ac)) {
return $ac; return $ac;
} }
/* disabled - html ui change only nonimportant categories
if($ac->isEdited()){
return PEAR::raiseError(
'BasicStor::bsSetMetadataValue: is edited', GBERR_LOCK
);
}
*/
if ($category == 'dcterms:extent') { if ($category == 'dcterms:extent') {
$value = $this->normalizeExtent($value); $value = $this->normalizeExtent($value);
} }
@ -1294,7 +1318,7 @@ class BasicStor extends Alib {
*/ */
public function bsImportPlaylistRaw($parid, $plid, $aPath, $rPath, $ext, &$gunids, $subjid) public function bsImportPlaylistRaw($parid, $plid, $aPath, $rPath, $ext, &$gunids, $subjid)
{ {
$id = $this->_idFromGunid($plid); $id = $this->idFromGunid($plid);
if (!is_null($id)) { if (!is_null($id)) {
return $id; return $id;
} }
@ -1457,7 +1481,7 @@ class BasicStor extends Alib {
if ($v['type'] == 'Folder') { if ($v['type'] == 'Folder') {
break; break;
} }
$gunid = $this->_gunidFromId($v['id']); $gunid = $this->gunidFromId($v['id']);
if ($this->dbc->isError($gunid)) { if ($this->dbc->isError($gunid)) {
return $gunid; return $gunid;
} }
@ -1608,7 +1632,7 @@ class BasicStor extends Alib {
{ {
$type = parent::getObjType($oid); $type = parent::getObjType($oid);
if ($type == 'File') { if ($type == 'File') {
$gunid = $this->_gunidFromId($oid); $gunid = $this->gunidFromId($oid);
if ($this->dbc->isError($gunid)) { if ($this->dbc->isError($gunid)) {
return $gunid; return $gunid;
} }
@ -1766,13 +1790,13 @@ class BasicStor extends Alib {
$acts = array($acts); $acts = array($acts);
} }
$perm = true; $perm = true;
foreach ($acts as $i => $action) { // foreach ($acts as $i => $action) {
$res = $this->checkPerm($userid, $action, $pars[$i]); // $res = $this->checkPerm($userid, $action, $pars[$i]);
if ($this->dbc->isError($res)) { // if ($this->dbc->isError($res)) {
return $res; // return $res;
} // }
$perm = $perm && $res; // $perm = $perm && $res;
} // }
if ($perm) { if ($perm) {
return TRUE; return TRUE;
} }
@ -1827,14 +1851,14 @@ class BasicStor extends Alib {
/** /**
* Get local id from global id * Get local id from global id.
* *
* @param string $gunid * @param string $gunid
* Global id * Global id
* @return int * @return int
* Local id * Local id
*/ */
public function _idFromGunid($gunid) public function idFromGunid($gunid)
{ {
return $this->dbc->getOne( return $this->dbc->getOne(
"SELECT id FROM {$this->filesTable} WHERE gunid=x'$gunid'::bigint" "SELECT id FROM {$this->filesTable} WHERE gunid=x'$gunid'::bigint"
@ -1850,7 +1874,7 @@ class BasicStor extends Alib {
* @return string * @return string
* Global id * Global id
*/ */
public function _gunidFromId($id) public function gunidFromId($id)
{ {
if (!is_numeric($id)) { if (!is_numeric($id)) {
return NULL; return NULL;
@ -1968,7 +1992,7 @@ class BasicStor extends Alib {
* @return FALSE|int * @return FALSE|int
* ID of user editing it * ID of user editing it
*/ */
public function _isEdited($playlistId) public function isEdited($playlistId)
{ {
$ac = StoredFile::recallByGunid($this, $playlistId); $ac = StoredFile::recallByGunid($this, $playlistId);
if ($this->dbc->isError($ac)) { if ($this->dbc->isError($ac)) {
@ -2267,7 +2291,7 @@ class BasicStor extends Alib {
if (PEAR::isError($r)) { if (PEAR::isError($r)) {
return $r; return $r;
} }
#$gunid = $this->_gunidFromId($r); #$gunid = $this->gunidFromId($r);
#$res['results'][] = array('gunid' => $gunid, 'type' => $type); #$res['results'][] = array('gunid' => $gunid, 'type' => $type);
#$res['cnt']++; #$res['cnt']++;
} }