Skip to content

Commit c651f6a

Browse files
author
Kousuke Ebihara
committed
added ability to check acl list when a client GETs member resource
1 parent b805a77 commit c651f6a

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

lib/api/opAPI.class.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,4 +351,16 @@ public function setMemberId($id)
351351
{
352352
$this->member = Doctrine::getTable('Member')->find($id);
353353
}
354+
355+
public function getAcl($model)
356+
{
357+
if (!$this->member)
358+
{
359+
return null;
360+
}
361+
362+
$builderName = 'op'.get_class($model).'AclBuilder';
363+
364+
return call_user_func($builderName.'::buildResource', $model, array($this->member));
365+
}
354366
}

lib/api/opAPIMember.class.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,15 @@ public function feed()
5050

5151
public function entry()
5252
{
53-
return $this->getRouteObject()->fetchOne();
53+
$entry = $this->getRouteObject()->fetchOne();
54+
55+
$acl = $this->getAcl($entry);
56+
if ($acl && !$acl->isAllowed($this->member->id, null, 'view'))
57+
{
58+
return false;
59+
}
60+
61+
return $entry;
5462
}
5563

5664
public function insert(SimpleXMLElement $xml)

0 commit comments

Comments
 (0)