mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-05-09 13:06:14 +00:00
add new method __getAttributesData()
This commit is contained in:
parent
239487e198
commit
b068c385e7
|
@ -48,6 +48,22 @@ class RestapiController { /* {{{ */
|
||||||
$this->container = $container;
|
$this->container = $container;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function __getAttributesData($obj) { /* {{{ */
|
||||||
|
$attributes = $obj->getAttributes();
|
||||||
|
$attrvalues = array();
|
||||||
|
if($attributes) {
|
||||||
|
foreach($attributes as $attrdefid=>$attribute) {
|
||||||
|
$attrdef = $attribute->getAttributeDefinition();
|
||||||
|
$attrvalues[] = array(
|
||||||
|
'id'=>$attrdef->getId(),
|
||||||
|
'name'=>$attrdef->getName(),
|
||||||
|
'value'=>$attribute->getValue()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $attrvalues;
|
||||||
|
}
|
||||||
|
|
||||||
protected function __getDocumentData($document) { /* {{{ */
|
protected function __getDocumentData($document) { /* {{{ */
|
||||||
$data = array(
|
$data = array(
|
||||||
'type'=>'document',
|
'type'=>'document',
|
||||||
|
@ -87,19 +103,13 @@ class RestapiController { /* {{{ */
|
||||||
}
|
}
|
||||||
$data['categories'] = $c;
|
$data['categories'] = $c;
|
||||||
}
|
}
|
||||||
$attributes = $document->getAttributes();
|
$attributes = $this->__getAttributesData($document);
|
||||||
if($attributes) {
|
if($attributes) {
|
||||||
$attrvalues = array();
|
$data['attributes'] = $attributes;
|
||||||
foreach($attributes as $attrdefid=>$attribute)
|
|
||||||
$attrvalues[] = array('id'=>(int)$attrdefid, 'value'=>$attribute->getValue());
|
|
||||||
$data['attributes'] = $attrvalues;
|
|
||||||
}
|
}
|
||||||
$attributes = $lc->getAttributes();
|
$attributes = $this->__getAttributesData($lc);
|
||||||
if($attributes) {
|
if($attributes) {
|
||||||
$attrvalues = array();
|
$data['version-attributes'] = $attributes;
|
||||||
foreach($attributes as $attrdefid=>$attribute)
|
|
||||||
$attrvalues[] = array('id'=>(int)$attrdefid, 'value'=>$attribute->getValue());
|
|
||||||
$data['version-attributes'] = $attrvalues;
|
|
||||||
}
|
}
|
||||||
return $data;
|
return $data;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
@ -146,12 +156,9 @@ class RestapiController { /* {{{ */
|
||||||
'comment'=>$folder->getComment(),
|
'comment'=>$folder->getComment(),
|
||||||
'date'=>date('Y-m-d H:i:s', $folder->getDate()),
|
'date'=>date('Y-m-d H:i:s', $folder->getDate()),
|
||||||
);
|
);
|
||||||
$attributes = $folder->getAttributes();
|
$attributes = $this->__getAttributesData($folder);
|
||||||
if($attributes) {
|
if($attributes) {
|
||||||
$attrvalues = array();
|
$data['attributes'] = $attributes;
|
||||||
foreach($attributes as $attrdefid=>$attribute)
|
|
||||||
$attrvalues[] = array('id'=>(int)$attrdefid, 'value'=>$attribute->getValue());
|
|
||||||
$data['attributes'] = $attrvalues;
|
|
||||||
}
|
}
|
||||||
return $data;
|
return $data;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
@ -421,16 +428,8 @@ class RestapiController { /* {{{ */
|
||||||
$folder = $dms->getFolder($args['id']);
|
$folder = $dms->getFolder($args['id']);
|
||||||
if($folder) {
|
if($folder) {
|
||||||
if ($folder->getAccessMode($userobj) >= M_READ) {
|
if ($folder->getAccessMode($userobj) >= M_READ) {
|
||||||
$recs = array();
|
$attributes = $this->__getAttributesData($folder);
|
||||||
$attributes = $folder->getAttributes();
|
return $response->withJson(array('success'=>true, 'message'=>'', 'data'=>$attributes), 200);
|
||||||
foreach($attributes as $attribute) {
|
|
||||||
$recs[] = array(
|
|
||||||
'id'=>(int)$attribute->getId(),
|
|
||||||
'value'=>$attribute->getValue(),
|
|
||||||
'name'=>$attribute->getAttributeDefinition()->getName(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return $response->withJson(array('success'=>true, 'message'=>'', 'data'=>$recs), 200);
|
|
||||||
} else {
|
} else {
|
||||||
return $response->withJson(array('success'=>false, 'message'=>'No access', 'data'=>''), 403);
|
return $response->withJson(array('success'=>false, 'message'=>'No access', 'data'=>''), 403);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user