function getAcl($object) { global $members; switch (get_class($object)) { case 'Community': return opCommunityTopicAclBuilder::buildCollection($object, $members); case 'CommunityTopic': return opCommunityTopicAclBuilder::buildResource($object, $members); } }
/** * preExecute */ public function preExecute() { if ($this->getRoute() instanceof sfDoctrineRoute) { $object = $this->getRoute()->getObject(); if ($object instanceof Community) { $this->community = $object; $this->acl = opCommunityTopicAclBuilder::buildCollection($this->community, array($this->getUser()->getMember())); } elseif ($object instanceof CommunityTopic) { $this->communityTopic = $object; $this->community = $this->communityTopic->getCommunity(); $this->acl = opCommunityTopicAclBuilder::buildResource($this->communityTopic, array($this->getUser()->getMember())); } } }
<?php $acl = opCommunityTopicAclBuilder::buildResource($communityTopic, array($sf_user->getMember())); op_mobile_page_title($community->getName(), $communityTopic->getName()); ?> <?php echo op_within_page_link(); echo op_format_date($communityTopic->getCreatedAt(), 'MM/dd HH:mm'); if ($communityTopic->getMemberId() === $sf_user->getMemberId()) { } ?> <br> <?php if ($communityTopic->getMember() && $communityTopic->getMember()->getName()) { echo link_to($communityTopic->getMember()->getName(), 'member/profile?id=' . $communityTopic->getMember()->getId()); } if ($communityTopic->isEditable($sf_user->getMemberId())) { ?> [<?php echo link_to(__('Edit'), '@communityTopic_edit?id=' . $communityTopic->getId()); ?> ] <?php } ?> <br> <?php echo nl2br($communityTopic->getBody()); ?> <br>
protected function isAllowed(opDoctrineRecord $object, Member $member, $action) { if ($object instanceof Community) { $acl = opCommunityTopicAclBuilder::buildCollection($object, array($this->member)); } elseif ($object instanceof CommunityTopic || $object instanceof CommunityEvent) { $acl = opCommunityTopicAclBuilder::buildResource($object, array($this->member)); } return $acl->isAllowed($this->member->getId(), null, $action); }
protected function getResourceAcl($communityTopic, $member) { return opCommunityTopicAclBuilder::buildResource($communityTopic, array($member)); }