mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-02-06 15:14:58 +00:00
initial support for getting/setting custom attributes
This commit is contained in:
parent
f139625e4f
commit
7140b12357
|
@ -326,6 +326,7 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server
|
||||||
$info["props"][] = $this->mkprop("getcontentlength", filesize($this->dms->contentDir.'/'.$fspath));
|
$info["props"][] = $this->mkprop("getcontentlength", filesize($this->dms->contentDir.'/'.$fspath));
|
||||||
if($keywords = $obj->getKeywords())
|
if($keywords = $obj->getKeywords())
|
||||||
$info["props"][] = $this->mkprop("SeedDMS:", "keywords", $keywords);
|
$info["props"][] = $this->mkprop("SeedDMS:", "keywords", $keywords);
|
||||||
|
$info["props"][] = $this->mkprop("SeedDMS:", "id", $obj->getID());
|
||||||
$info["props"][] = $this->mkprop("SeedDMS:", "version", $content->getVersion());
|
$info["props"][] = $this->mkprop("SeedDMS:", "version", $content->getVersion());
|
||||||
$status = $content->getStatus();
|
$status = $content->getStatus();
|
||||||
$info["props"][] = $this->mkprop("SeedDMS:", "status", $status['status']);
|
$info["props"][] = $this->mkprop("SeedDMS:", "status", $status['status']);
|
||||||
|
@ -338,17 +339,20 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server
|
||||||
$info["props"][] = $this->mkprop("SeedDMS:", "comment", $comment);
|
$info["props"][] = $this->mkprop("SeedDMS:", "comment", $comment);
|
||||||
$info["props"][] = $this->mkprop("SeedDMS:", "owner", $obj->getOwner()->getLogin());
|
$info["props"][] = $this->mkprop("SeedDMS:", "owner", $obj->getOwner()->getLogin());
|
||||||
|
|
||||||
// get additional properties from database
|
$attributes = $obj->getAttributes();
|
||||||
/*
|
if($attributes) {
|
||||||
$query = "SELECT ns, name, value
|
foreach($attributes as $attribute) {
|
||||||
FROM {$this->db_prefix}properties
|
$attrdef = $attribute->getAttributeDefinition();
|
||||||
WHERE path = '$path'";
|
$valueset = $attrdef->getValueSetAsArray();
|
||||||
$res = mysql_query($query);
|
if($valueset && $attrdef->getMultipleValues()) {
|
||||||
while ($row = mysql_fetch_assoc($res)) {
|
$valuesetstr = $attrdef->getValueSet();
|
||||||
$info["props"][] = $this->mkprop($row["ns"], $row["name"], $row["value"]);
|
$delimiter = substr($valuesetstr, 0, 1);
|
||||||
|
$info["props"][] = $this->mkprop("SeedDMS:", str_replace(' ', '', $attrdef->getName()), $delimiter.implode($delimiter, $attribute->getValueAsArray()));
|
||||||
|
} else
|
||||||
|
$info["props"][] = $this->mkprop("SeedDMS:", str_replace(' ', '', $attrdef->getName()), $attribute->getValue());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
mysql_free_result($res);
|
|
||||||
*/
|
|
||||||
return $info;
|
return $info;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
|
@ -898,16 +902,52 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server
|
||||||
if ($prop["ns"] == "DAV:") {
|
if ($prop["ns"] == "DAV:") {
|
||||||
$options["props"][$key]['status'] = "403 Forbidden";
|
$options["props"][$key]['status'] = "403 Forbidden";
|
||||||
} else {
|
} else {
|
||||||
$this->logger->log('PROPPATCH: set '.$prop["ns"].''.$prop["val"].' to '.$prop["val"], PEAR_LOG_INFO);
|
$this->logger->log('PROPPATCH: set '.$prop["ns"].''.$prop["val"].' to '.$prop["val"], PEAR_LOG_INFO);
|
||||||
if($prop["ns"] == "SeedDMS:") {
|
if($prop["ns"] == "SeedDMS:") {
|
||||||
if (isset($prop["val"]))
|
if (isset($prop["val"]))
|
||||||
$val = $prop["val"];
|
$val = $prop["val"];
|
||||||
else
|
else
|
||||||
$val = '';
|
$val = '';
|
||||||
switch($prop["name"]) {
|
switch($prop["name"]) {
|
||||||
case "comment":
|
case "comment":
|
||||||
$obj->setComment($val);
|
$obj->setComment($val);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
if($attrdef = $this->dms->getAttributeDefinitionByName($prop["name"])) {
|
||||||
|
$valueset = $attrdef->getValueSetAsArray();
|
||||||
|
switch($attrdef->getType()) {
|
||||||
|
case SeedDMS_Core_AttributeDefinition::type_string:
|
||||||
|
if($valueset) {
|
||||||
|
if(in_array($val, $valueset)) {
|
||||||
|
$obj->setAttributeValue($attrdef, $val);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$obj->setAttributeValue($attrdef, $val);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SeedDMS_Core_AttributeDefinition::type_int:
|
||||||
|
if($valueset) {
|
||||||
|
if(in_array($val, $valueset)) {
|
||||||
|
$obj->setAttributeValue($attrdef, (int) $val);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$obj->setAttributeValue($attrdef, (int) $val);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SeedDMS_Core_AttributeDefinition::type_float:
|
||||||
|
if($valueset) {
|
||||||
|
if(in_array($val, $valueset)) {
|
||||||
|
$obj->setAttributeValue($attrdef, (float) $val);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$obj->setAttributeValue($attrdef, (float) $val);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SeedDMS_Core_AttributeDefinition::type_boolean:
|
||||||
|
$obj->setAttributeValue($attrdef, $val == 1 ? true : false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user