Validator and related things updated, validator ENABLED now.
This commit is contained in:
parent
30a1f1000c
commit
f32ab1daa3
|
@ -23,14 +23,12 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: tomas $
|
Author : $Author: tomas $
|
||||||
Version : $Revision: 1.23 $
|
Version : $Revision: 1.24 $
|
||||||
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 $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
define('DEBUG', FALSE);
|
define('DEBUG', FALSE);
|
||||||
#define('DEBUG', TRUE);
|
#define('DEBUG', TRUE);
|
||||||
define('VALIDATE', FALSE);
|
|
||||||
#define('VALIDATE', TRUE);
|
|
||||||
define('MODIFY_LAST_MATCH', TRUE);
|
define('MODIFY_LAST_MATCH', TRUE);
|
||||||
|
|
||||||
require_once "XML/Util.php";
|
require_once "XML/Util.php";
|
||||||
|
@ -56,6 +54,7 @@ class MetaData{
|
||||||
*/
|
*/
|
||||||
function MetaData(&$gb, $gunid, $resDir)
|
function MetaData(&$gb, $gunid, $resDir)
|
||||||
{
|
{
|
||||||
|
$this->config =& $gb->config;
|
||||||
$this->dbc =& $gb->dbc;
|
$this->dbc =& $gb->dbc;
|
||||||
$this->mdataTable = $gb->mdataTable;
|
$this->mdataTable = $gb->mdataTable;
|
||||||
$this->gunid = $gunid;
|
$this->gunid = $gunid;
|
||||||
|
@ -83,7 +82,8 @@ class MetaData{
|
||||||
if($this->exists) return FALSE;
|
if($this->exists) return FALSE;
|
||||||
$tree =& $this->parse($mdata, $loc);
|
$tree =& $this->parse($mdata, $loc);
|
||||||
if(PEAR::isError($tree)) return $tree;
|
if(PEAR::isError($tree)) return $tree;
|
||||||
$res = $this->validate($tree, $format);
|
$this->format = $format;
|
||||||
|
$res = $this->validate($tree);
|
||||||
if(PEAR::isError($res)) return $res;
|
if(PEAR::isError($res)) return $res;
|
||||||
$res = $this->storeDoc($tree);
|
$res = $this->storeDoc($tree);
|
||||||
if(PEAR::isError($res)) return $res;
|
if(PEAR::isError($res)) return $res;
|
||||||
|
@ -215,6 +215,25 @@ class MetaData{
|
||||||
*/
|
*/
|
||||||
function setMetadataEl($mid, $value=NULL)
|
function setMetadataEl($mid, $value=NULL)
|
||||||
{
|
{
|
||||||
|
$info = $this->dbc->getRow("
|
||||||
|
SELECT parmd.predns as parns, parmd.predicate as parname,
|
||||||
|
md.predxml, md.predns as chns, md.predicate as chname
|
||||||
|
FROM {$this->mdataTable} parmd
|
||||||
|
INNER JOIN {$this->mdataTable} md
|
||||||
|
ON parmd.id=md.subject AND md.subjns='_I'
|
||||||
|
WHERE md.id=$mid
|
||||||
|
");
|
||||||
|
if(PEAR::isError($info)) return $info;
|
||||||
|
if(is_null($info)){
|
||||||
|
return PEAR::raiseError(
|
||||||
|
"MetaData::setMetadataEl: parent container not found"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
extract($info);
|
||||||
|
$parname = ($parns ? "$parns:" : '').$parname;
|
||||||
|
$category = ($chns ? "$chns:" : '').$chname;
|
||||||
|
$r = $this->validateOneValue($parname, $category, $predxml, $value);
|
||||||
|
if(PEAR::isError($r)) return $r;
|
||||||
if(!is_null($value)){
|
if(!is_null($value)){
|
||||||
$sql = "
|
$sql = "
|
||||||
UPDATE {$this->mdataTable}
|
UPDATE {$this->mdataTable}
|
||||||
|
@ -240,17 +259,22 @@ class MetaData{
|
||||||
*/
|
*/
|
||||||
function insertMetadataEl($parid, $category, $value=NULL, $predxml='T')
|
function insertMetadataEl($parid, $category, $value=NULL, $predxml='T')
|
||||||
{
|
{
|
||||||
$cnt = $this->dbc->getOne("
|
$category = strtolower($category);
|
||||||
SELECT count(*) FROM {$this->mdataTable}
|
$parent = $this->dbc->getRow("
|
||||||
|
SELECT predns, predicate, predxml FROM {$this->mdataTable}
|
||||||
WHERE gunid=x'{$this->gunid}'::bigint AND id=$parid
|
WHERE gunid=x'{$this->gunid}'::bigint AND id=$parid
|
||||||
");
|
");
|
||||||
if(PEAR::isError($cnt)) return $cnt;
|
if(PEAR::isError($parent)) return $parent;
|
||||||
if($cnt < 1){
|
if(is_null($parent)){
|
||||||
return PEAR::raiseError(
|
return PEAR::raiseError(
|
||||||
"MetaData::insertMetadataEl: container not found"
|
"MetaData::insertMetadataEl: container not found"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$a = XML_Util::splitQualifiedName(strtolower($category));
|
$parNs = ($parent['predns'] ? "{$parent['predns']}:" : '');
|
||||||
|
$parName = $parNs.$parent['predicate'];
|
||||||
|
$r = $this->validateOneValue($parName, $category, $predxml, $value);
|
||||||
|
if(PEAR::isError($r)) return $r;
|
||||||
|
$a = XML_Util::splitQualifiedName($category);
|
||||||
if(PEAR::isError($a)) return $a;
|
if(PEAR::isError($a)) return $a;
|
||||||
$catNs = $a['namespace'];
|
$catNs = $a['namespace'];
|
||||||
$cat = $a['localPart'];
|
$cat = $a['localPart'];
|
||||||
|
@ -396,6 +420,14 @@ class MetaData{
|
||||||
return $this->fname;
|
return $this->fname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the metadata format to the object instance
|
||||||
|
*/
|
||||||
|
function setFormat($format=NULL)
|
||||||
|
{
|
||||||
|
$this->format = $format;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if there are any file's metadata in database
|
* Check if there are any file's metadata in database
|
||||||
*
|
*
|
||||||
|
@ -458,17 +490,13 @@ class MetaData{
|
||||||
* Validate parsed metadata
|
* Validate parsed metadata
|
||||||
*
|
*
|
||||||
* @param tree array, parsed tree
|
* @param tree array, parsed tree
|
||||||
* @param format string, metadata format for validation
|
|
||||||
* ('audioclip' | 'playlist' | 'webstream' | NULL)
|
|
||||||
* (NULL = no validation)
|
|
||||||
* @return true or PEAR::error
|
* @return true or PEAR::error
|
||||||
*/
|
*/
|
||||||
function validate(&$tree, $format=NULL)
|
function validate(&$tree)
|
||||||
{
|
{
|
||||||
//echo"<pre>";var_dump($tree);exit;
|
if($this->config['validate'] && !is_null($this->format)){
|
||||||
if(VALIDATE && !is_null($format)){
|
|
||||||
require_once"Validator.php";
|
require_once"Validator.php";
|
||||||
$val =& new Validator($format, $this->gunid);
|
$val =& new Validator($this->format, $this->gunid);
|
||||||
if(PEAR::isError($val)) return $val;
|
if(PEAR::isError($val)) return $val;
|
||||||
$res = $val->validate($tree);
|
$res = $val->validate($tree);
|
||||||
if(PEAR::isError($res)) return $res;
|
if(PEAR::isError($res)) return $res;
|
||||||
|
@ -476,6 +504,24 @@ class MetaData{
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate one metadata value (on insert/update)
|
||||||
|
*
|
||||||
|
* @param
|
||||||
|
* @return true or PEAR::error
|
||||||
|
*/
|
||||||
|
function validateOneValue($parName, $category, $predxml, $value)
|
||||||
|
{
|
||||||
|
if($this->config['validate'] && !is_null($this->format)){
|
||||||
|
require_once"Validator.php";
|
||||||
|
$val =& new Validator($this->format, $this->gunid);
|
||||||
|
if(PEAR::isError($val)) return $val;
|
||||||
|
$r = $val->validateOneValue($parName, $category, $predxml, $value);
|
||||||
|
if(PEAR::isError($r)) return $r;
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Insert parsed metadata into database
|
* Insert parsed metadata into database
|
||||||
*
|
*
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: tomas $
|
Author : $Author: tomas $
|
||||||
Version : $Revision: 1.3 $
|
Version : $Revision: 1.4 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/Playlist.php,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/Playlist.php,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -89,15 +89,24 @@ class Playlist extends StoredFile{
|
||||||
*/
|
*/
|
||||||
function getPlInfo()
|
function getPlInfo()
|
||||||
{
|
{
|
||||||
|
$parid = $this->getContainer('playlist');
|
||||||
|
if(PEAR::isError($parid)){ return $parid; }
|
||||||
// get playlist length and record id:
|
// get playlist length and record id:
|
||||||
$r = $this->md->getMetadataEl('dcterms:extent');
|
$r = $this->md->getMetadataEl('playlength', $parid);
|
||||||
if(PEAR::isError($r)){ return $r; }
|
if(PEAR::isError($r)){ return $r; }
|
||||||
if(isset($r[0])){
|
if(isset($r[0])){
|
||||||
$plLen = $r[0]['value'];
|
$plLen = $r[0]['value'];
|
||||||
$plLenMid = $r[0]['mid'];
|
$plLenMid = $r[0]['mid'];
|
||||||
}else{
|
}else{
|
||||||
$plLen = '00:00:00.000000';
|
$r = $this->md->getMetadataEl('dcterms:extent');
|
||||||
$plLenMid = NULL;
|
if(PEAR::isError($r)){ return $r; }
|
||||||
|
if(isset($r[0])){
|
||||||
|
$plLen = $r[0]['value'];
|
||||||
|
$plLenMid = $r[0]['mid'];
|
||||||
|
}else{
|
||||||
|
$plLen = '00:00:00.000000';
|
||||||
|
$plLenMid = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// get main playlist container
|
// get main playlist container
|
||||||
$parid = $this->getContainer('playlist');
|
$parid = $this->getContainer('playlist');
|
||||||
|
@ -277,7 +286,7 @@ class Playlist extends StoredFile{
|
||||||
$offset = $plLen;
|
$offset = $plLen;
|
||||||
$plElInfo = $this->insertPlaylistElement($parid, $offset,
|
$plElInfo = $this->insertPlaylistElement($parid, $offset,
|
||||||
$acGunid, $acLen, $acTit, $fadeIn, $fadeOut);
|
$acGunid, $acLen, $acTit, $fadeIn, $fadeOut);
|
||||||
if(PEAR::isError($plElInfo)){ return $plElnfo; }
|
if(PEAR::isError($plElInfo)){ return $plElInfo; }
|
||||||
extract($plElInfo); // 'plElId', 'plElGunid', 'fadeInId', 'fadeOutId'
|
extract($plElInfo); // 'plElId', 'plElGunid', 'fadeInId', 'fadeOutId'
|
||||||
|
|
||||||
/* commented - maybe useless (C++ part doesn't do it)
|
/* commented - maybe useless (C++ part doesn't do it)
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: tomas $
|
Author : $Author: tomas $
|
||||||
Version : $Revision: 1.23 $
|
Version : $Revision: 1.24 $
|
||||||
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 $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -162,7 +162,7 @@ class StoredFile{
|
||||||
: "gunid=x'$gunid'::bigint"
|
: "gunid=x'$gunid'::bigint"
|
||||||
);
|
);
|
||||||
$row = $gb->dbc->getRow("
|
$row = $gb->dbc->getRow("
|
||||||
SELECT id, to_hex(gunid)as gunid, mime, name
|
SELECT id, to_hex(gunid)as gunid, mime, name, ftype
|
||||||
FROM {$gb->filesTable} WHERE $cond
|
FROM {$gb->filesTable} WHERE $cond
|
||||||
");
|
");
|
||||||
if(PEAR::isError($row)) return $row;
|
if(PEAR::isError($row)) return $row;
|
||||||
|
@ -177,6 +177,7 @@ class StoredFile{
|
||||||
$ac->mime = $row['mime'];
|
$ac->mime = $row['mime'];
|
||||||
$ac->name = $row['name'];
|
$ac->name = $row['name'];
|
||||||
$ac->id = $row['id'];
|
$ac->id = $row['id'];
|
||||||
|
$ac->md->setFormat($row['ftype']);
|
||||||
return $ac;
|
return $ac;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: tomas $
|
Author : $Author: tomas $
|
||||||
Version : $Revision: 1.3 $
|
Version : $Revision: 1.4 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/Validator.php,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/Validator.php,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -38,6 +38,7 @@ define('VAL_FORMAT', 117);
|
||||||
define('VAL_CONTENT', 118);
|
define('VAL_CONTENT', 118);
|
||||||
define('VAL_NOREQA', 119);
|
define('VAL_NOREQA', 119);
|
||||||
define('VAL_ATTRIB', 120);
|
define('VAL_ATTRIB', 120);
|
||||||
|
define('VAL_PREDXML', 121);
|
||||||
|
|
||||||
#require_once "";
|
#require_once "";
|
||||||
|
|
||||||
|
@ -56,11 +57,11 @@ class Validator{
|
||||||
/**
|
/**
|
||||||
* string - format type of validated document
|
* string - format type of validated document
|
||||||
*/
|
*/
|
||||||
var $formatType = NULL;
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
var $format = NULL;
|
var $format = NULL;
|
||||||
|
/**
|
||||||
|
* Preloaded format tree structure
|
||||||
|
*/
|
||||||
|
var $formTree = NULL;
|
||||||
/**
|
/**
|
||||||
* string - gunid of validated file for identification in mass input
|
* string - gunid of validated file for identification in mass input
|
||||||
*/
|
*/
|
||||||
|
@ -68,25 +69,25 @@ class Validator{
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param formatType string - format type of validated document
|
* @param format string - format type of validated document
|
||||||
* @param gunid string - gunid of validated file for identification
|
* @param gunid string - gunid of validated file for identification
|
||||||
* in mass input
|
* in mass input
|
||||||
*/
|
*/
|
||||||
function Validator($formatType, $gunid)
|
function Validator($format, $gunid)
|
||||||
{
|
{
|
||||||
$this->formatType = $formatType;
|
$this->format = $format;
|
||||||
$this->gunid = $gunid;
|
$this->gunid = $gunid;
|
||||||
$formats = array(
|
$formats = array(
|
||||||
'audioclip' => "audioClipFormat",
|
'audioclip' => "audioClipFormat",
|
||||||
'playlist' => "playlistFormat",
|
'playlist' => "playlistFormat",
|
||||||
'webstream' => "webstreamFormat",
|
'webstream' => "webstreamFormat",
|
||||||
);
|
);
|
||||||
if(!isset($formats[$formatType])) return $this->_err(VAL_FORMAT);
|
if(!isset($formats[$format])) return $this->_err(VAL_FORMAT);
|
||||||
$format = $formats[$formatType];
|
$formatName = $formats[$format];
|
||||||
$formatFile = dirname(__FILE__)."/$format.php";
|
$formatFile = dirname(__FILE__)."/$formatName.php";
|
||||||
if(!file_exists($formatFile)) return $this->_err(VAL_FORMAT);
|
if(!file_exists($formatFile)) return $this->_err(VAL_FORMAT);
|
||||||
require $formatFile;
|
require $formatFile;
|
||||||
$this->format = $$format;
|
$this->formTree = $$formatName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -97,30 +98,62 @@ class Validator{
|
||||||
*/
|
*/
|
||||||
function validate(&$data)
|
function validate(&$data)
|
||||||
{
|
{
|
||||||
$r = $this->validateNode($data, $this->format['_root']);
|
$r = $this->validateNode($data, $this->formTree['_root']);
|
||||||
return $r;
|
return $r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate one metadata value (on insert/update)
|
||||||
|
*
|
||||||
|
* @param
|
||||||
|
* @return TRUE or PEAR::error
|
||||||
|
*/
|
||||||
|
function validateOneValue($fname, $category, $predxml, $value)
|
||||||
|
{
|
||||||
|
$formTree =& $this->formTree;
|
||||||
|
switch($predxml){
|
||||||
|
case'T':
|
||||||
|
if(!$this->isChildInFormat($fname, $category))
|
||||||
|
return $this->_err(113, "$category in $fname");
|
||||||
|
break;
|
||||||
|
case'A':
|
||||||
|
if(!$this->isAttrInFormat($fname, $category))
|
||||||
|
return $this->_err(114, "$category in $fname");
|
||||||
|
break;
|
||||||
|
case'N':
|
||||||
|
return TRUE;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return $this->_err(VAL_PREDXML, $predxml);
|
||||||
|
}
|
||||||
|
if(isset($formTree[$category]['regexp'])){
|
||||||
|
// echo "XXX {$formTree[$fname]['regexp']} / ".$node->content."\n";
|
||||||
|
if(!preg_match("|{$formTree[$category]['regexp']}|", $value))
|
||||||
|
return $this->_err(VAL_CONTENT, $category);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validation of one element node from object tree
|
* Validation of one element node from object tree
|
||||||
*
|
*
|
||||||
* @param node object - validated node
|
* @param node object - validated node
|
||||||
* @param fname string - aktual name in format structur
|
* @param fname string - aktual name in format structure
|
||||||
* @return TRUE or PEAR::error
|
* @return TRUE or PEAR::error
|
||||||
*/
|
*/
|
||||||
function validateNode(&$node, $fname)
|
function validateNode(&$node, $fname)
|
||||||
{
|
{
|
||||||
$dname = strtolower(($node->ns? $node->ns.":" : '').$node->name);
|
$dname = strtolower(($node->ns? $node->ns.":" : '').$node->name);
|
||||||
$format =& $this->format;
|
$formTree =& $this->formTree;
|
||||||
if(DEBUG) echo"\nVAL::validateNode: 1 $dname/$fname\n";
|
if(DEBUG) echo"\nVAL::validateNode: 1 $dname/$fname\n";
|
||||||
// check root node name:
|
// check root node name:
|
||||||
if($dname != $fname) return $this->_err(VAL_ROOT, $fname);
|
if($dname != $fname) return $this->_err(VAL_ROOT, $fname);
|
||||||
// check if this element is defined in format:
|
// check if this element is defined in format:
|
||||||
if(!isset($format[$fname])) return $this->_err(VAL_NOTDEF, $fname);
|
if(!isset($formTree[$fname])) return $this->_err(VAL_NOTDEF, $fname);
|
||||||
// check element content
|
// check element content
|
||||||
if(isset($format[$fname]['regexp'])){
|
if(isset($formTree[$fname]['regexp'])){
|
||||||
// echo "XXX {$format[$fname]['regexp']} / ".$node->content."\n";
|
// echo "XXX {$formTree[$fname]['regexp']} / ".$node->content."\n";
|
||||||
if(!preg_match("|{$format[$fname]['regexp']}|", $node->content))
|
if(!preg_match("|{$formTree[$fname]['regexp']}|", $node->content))
|
||||||
return $this->_err(VAL_CONTENT, $fname);
|
return $this->_err(VAL_CONTENT, $fname);
|
||||||
}
|
}
|
||||||
// validate attributes:
|
// validate attributes:
|
||||||
|
@ -141,7 +174,7 @@ class Validator{
|
||||||
*/
|
*/
|
||||||
function validateAttributes(&$node, $fname)
|
function validateAttributes(&$node, $fname)
|
||||||
{
|
{
|
||||||
$format =& $this->format;
|
$formTree =& $this->formTree;
|
||||||
$attrs = array();
|
$attrs = array();
|
||||||
// check if all attrs are permitted here:
|
// check if all attrs are permitted here:
|
||||||
foreach($node->attrs as $i=>$attr){
|
foreach($node->attrs as $i=>$attr){
|
||||||
|
@ -151,15 +184,15 @@ class Validator{
|
||||||
return $this->_err(VAL_UNKNOWNA, $aname);
|
return $this->_err(VAL_UNKNOWNA, $aname);
|
||||||
// check attribute format
|
// check attribute format
|
||||||
// echo "XXA $aname\n";
|
// echo "XXA $aname\n";
|
||||||
if(isset($format[$aname]['regexp'])){
|
if(isset($formTree[$aname]['regexp'])){
|
||||||
// echo "XAR {$format[$fname]['regexp']} / ".$node->content."\n";
|
// echo "XAR {$formTree[$fname]['regexp']} / ".$node->content."\n";
|
||||||
if(!preg_match("|{$format[$aname]['regexp']}|", $attr->val))
|
if(!preg_match("|{$formTree[$aname]['regexp']}|", $attr->val))
|
||||||
return $this->_err(VAL_ATTRIB, $aname);
|
return $this->_err(VAL_ATTRIB, $aname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// check if all required attrs are here:
|
// check if all required attrs are here:
|
||||||
if(isset($format[$fname]['attrs'])){
|
if(isset($formTree[$fname]['attrs'])){
|
||||||
$fattrs =& $format[$fname]['attrs'];
|
$fattrs =& $formTree[$fname]['attrs'];
|
||||||
if(isset($fattrs['required'])){
|
if(isset($fattrs['required'])){
|
||||||
foreach($fattrs['required'] as $i=>$attr){
|
foreach($fattrs['required'] as $i=>$attr){
|
||||||
if(!isset($attrs[$attr]))
|
if(!isset($attrs[$attr]))
|
||||||
|
@ -179,7 +212,7 @@ class Validator{
|
||||||
*/
|
*/
|
||||||
function validateChildren(&$node, $fname)
|
function validateChildren(&$node, $fname)
|
||||||
{
|
{
|
||||||
$format =& $this->format;
|
$formTree =& $this->formTree;
|
||||||
$childs = array();
|
$childs = array();
|
||||||
// check if all children are permitted here:
|
// check if all children are permitted here:
|
||||||
foreach($node->children as $i=>$ch){
|
foreach($node->children as $i=>$ch){
|
||||||
|
@ -193,8 +226,8 @@ class Validator{
|
||||||
$childs[$chname] = TRUE;
|
$childs[$chname] = TRUE;
|
||||||
}
|
}
|
||||||
// check if all required children are here:
|
// check if all required children are here:
|
||||||
if(isset($format[$fname]['childs'])){
|
if(isset($formTree[$fname]['childs'])){
|
||||||
$fchilds =& $format[$fname]['childs'];
|
$fchilds =& $formTree[$fname]['childs'];
|
||||||
if(isset($fchilds['required'])){
|
if(isset($fchilds['required'])){
|
||||||
foreach($fchilds['required'] as $i=>$ch){
|
foreach($fchilds['required'] as $i=>$ch){
|
||||||
if(!isset($childs[$ch])) return $this->_err(VAL_NOREQE, $ch);
|
if(!isset($childs[$ch])) return $this->_err(VAL_NOREQE, $ch);
|
||||||
|
@ -260,10 +293,10 @@ class Validator{
|
||||||
*/
|
*/
|
||||||
function isInFormatAs($fname, $chname, $nType='childs', $reqType='required')
|
function isInFormatAs($fname, $chname, $nType='childs', $reqType='required')
|
||||||
{
|
{
|
||||||
$format =& $this->format;
|
$formTree =& $this->formTree;
|
||||||
$listed = (
|
$listed = (
|
||||||
isset($format[$fname][$nType][$reqType]) ?
|
isset($formTree[$fname][$nType][$reqType]) ?
|
||||||
array_search($chname, $format[$fname][$nType][$reqType]) :
|
array_search($chname, $formTree[$fname][$nType][$reqType]) :
|
||||||
FALSE
|
FALSE
|
||||||
);
|
);
|
||||||
return $listed;
|
return $listed;
|
||||||
|
@ -290,6 +323,7 @@ class Validator{
|
||||||
118=>'Invalid content',
|
118=>'Invalid content',
|
||||||
119=>'Required attribute missing',
|
119=>'Required attribute missing',
|
||||||
120=>'Invalid attribute format',
|
120=>'Invalid attribute format',
|
||||||
|
121=>'Invalid predicate type',
|
||||||
);
|
);
|
||||||
return PEAR::raiseError(
|
return PEAR::raiseError(
|
||||||
"Validator: {$msg[$errno]} #$errno ($par, gunid={$this->gunid})",
|
"Validator: {$msg[$errno]} #$errno ($par, gunid={$this->gunid})",
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: tomas $
|
Author : $Author: tomas $
|
||||||
Version : $Revision: 1.14 $
|
Version : $Revision: 1.15 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/conf.php,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/conf.php,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -40,17 +40,22 @@
|
||||||
* <dt>dsn<dd> datasource setting
|
* <dt>dsn<dd> datasource setting
|
||||||
* <dt>tblNamePrefix <dd>prefix for table names in the database
|
* <dt>tblNamePrefix <dd>prefix for table names in the database
|
||||||
* <dt>authCookieName <dd>secret token cookie name
|
* <dt>authCookieName <dd>secret token cookie name
|
||||||
|
* <dt>StationPrefsGr <dd>name of station preferences group
|
||||||
|
* <dt>AllGr <dd>name of 'all users' group
|
||||||
* <dt>storageDir <dd>main directory for storing binary media files
|
* <dt>storageDir <dd>main directory for storing binary media files
|
||||||
* <dt>bufferDir <dd>directory for temporary files
|
* <dt>bufferDir <dd>directory for temporary files
|
||||||
* <dt>transDir <dd>directory for incomplete transferred files
|
* <dt>transDir <dd>directory for incomplete transferred files
|
||||||
* <dt>accessDir <dd>directory for symlinks to accessed files
|
* <dt>accessDir <dd>directory for symlinks to accessed files
|
||||||
* <dt>isArchive <dd>local/central flag
|
* <dt>isArchive <dd>local/central flag
|
||||||
|
* <dt>validate <dd>enable/disable validator
|
||||||
* <dt>storageUrlPath<dd>path-URL-part of storageServer base dir
|
* <dt>storageUrlPath<dd>path-URL-part of storageServer base dir
|
||||||
* <dt>storageXMLRPC<dd>XMLRPC server script address relative to storageUrlPath
|
* <dt>storageXMLRPC<dd>XMLRPC server script address relative to storageUrlPath
|
||||||
* <dt>storageUrlHost, storageUrlPort<dd>host and port of storageServer
|
* <dt>storageUrlHost, storageUrlPort<dd>host and port of storageServer
|
||||||
* <dt>archiveUrlPath<dd>path-URL-part of archiveServer base dir
|
* <dt>archiveUrlPath<dd>path-URL-part of archiveServer base dir
|
||||||
* <dt>archiveXMLRPC<dd>XMLRPC server script address relative to archiveUrlPath
|
* <dt>archiveXMLRPC<dd>XMLRPC server script address relative to archiveUrlPath
|
||||||
* <dt>archiveUrlHost, archiveUrlPort<dd>host and port of archiveServer
|
* <dt>archiveUrlHost, archiveUrlPort<dd>host and port of archiveServer
|
||||||
|
* <dt>archiveAccountLogin, archiveAccountPass <dd>account info
|
||||||
|
* for login to archive
|
||||||
* </dl>
|
* </dl>
|
||||||
*/
|
*/
|
||||||
$config = array(
|
$config = array(
|
||||||
|
@ -71,6 +76,7 @@ $config = array(
|
||||||
'transDir' => dirname(__FILE__).'/../../storageServer/var/trans',
|
'transDir' => dirname(__FILE__).'/../../storageServer/var/trans',
|
||||||
'accessDir' => dirname(__FILE__).'/../../storageServer/var/access',
|
'accessDir' => dirname(__FILE__).'/../../storageServer/var/access',
|
||||||
'isArchive' => FALSE,
|
'isArchive' => FALSE,
|
||||||
|
'validate' => TRUE,
|
||||||
|
|
||||||
/* ==================================================== URL configuration */
|
/* ==================================================== URL configuration */
|
||||||
'storageUrlPath' => '/livesupportStorageServer',
|
'storageUrlPath' => '/livesupportStorageServer',
|
||||||
|
|
Loading…
Reference in New Issue