public function checkPhotoAccess($albumid = null, $photoid = null) { $mainframe = JFactory::getApplication(); $jinput = $mainframe->input; $config = CFactory::getConfig(); $userId = $jinput->get('userid'); $groupId = $jinput->get('groupid'); $my = CFactory::getUser(); if ($userId) { $creator = CFactory::getuser($userId); $creatorId = $creator->id; } if ($albumid) { $album = JTable::getInstance('Album', 'CTable'); $album->load($albumid); $creatorId = $album->creator; } if ($photoid) { $photo = JTable::getINstance('Photo', 'CTable'); $photo->load($photoid); $creatorId = $photo->creator; } // check privacy $allowed = true; // default privacy levels if (isset($creatorId) && !$groupId) { if (isset($album) && $album->permission <= 10) { return true; } else { if (!CPrivacy::isAccessAllowed($my->id, $creatorId, 'privacyPhotoView', 'privacyPhotoView')) { $allowed = false; } } } elseif (isset($groupId) && $groupId) { $group = JTable::getInstance('Group', 'CTable'); $group->load($group); if ($group->approvals == 1 && !$group->isMember($my->id) && !COwnerHelper::isCommunityAdmin()) { $allowed = false; } else { $allowed = true; } } if (!$allowed) { echo "<div class=\"cEmpty cAlert\">" . JText::_('COM_COMMUNITY_PRIVACY_ERROR_MSG') . "</div>"; return; } if (!$config->get('enablephotos')) { $mainframe->enqueueMessage(JText::_('COM_COMMUNITY_PHOTOS_DISABLED'), ''); return false; } return true; }