Example #1
0
 public function getTagsByPhotoId($photoId, $type = null)
 {
     $tagList = $this->tagDao->findByPhotoIdOrCopyPhotoId($photoId, $type);
     $photoOwnerId = UTAGS_CLASS_PhotoBridge::getInstance()->getPhotoOwnerId($photoId);
     $userId = OW::getUser()->getId();
     $userTags = array();
     foreach ($tagList as $tag) {
         $userTags[$tag->userId] = isset($userTags[$tag->userId]) ? $userTags[$tag->userId] : array();
         $userTags[$tag->userId][] = $tag;
     }
     $actions = @OW::getEventManager()->call("privacy_check_permission_for_user_list", array("action" => UTAGS_CLASS_PrivacyBridge::ACTION_VIEW_TAGS, "ownerIdList" => array_keys($userTags), "viewerId" => OW::getUser()->getId()));
     $out = array();
     $globalPermited = OW::getUser()->isAuthorized("utags", "view_tags");
     $moderatorPermited = OW::getUser()->isAuthorized("utags");
     foreach ($tagList as $tag) {
         $permited = false;
         /*@var $tag UTAGS_BOL_Tag */
         if ($moderatorPermited) {
             $permited = true;
         } else {
             if ($tag->userId == $userId || $photoOwnerId == $userId || $tag->entityType == self::ENTITY_TYPE_USER && $tag->entityId == $userId) {
                 $permited = true;
             } else {
                 if (!$actions[$tag->userId]["blocked"]) {
                     $permited = true;
                 } else {
                     $permited = $globalPermited;
                 }
             }
         }
         if ($permited) {
             $out[] = $tag;
         }
     }
     return $out;
 }