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