本文整理汇总了PHP中Foundry::privacy方法的典型用法代码示例。如果您正苦于以下问题:PHP Foundry::privacy方法的具体用法?PHP Foundry::privacy怎么用?PHP Foundry::privacy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Foundry
的用法示例。
在下文中一共展示了Foundry::privacy方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAlbums
/**
* Display the list of photos a user has uploaded
*
* @since 1.0
* @access public
* @param string
* @return
*/
public function getAlbums($user)
{
$params = $this->getUserParams($user->id);
$appParam = $this->app->getParams();
$albums = array();
// Load up albums model
$model = FD::model('Albums');
$sorting = $params->get('ordering', $appParam->get('ordering', 'latest'));
$options = array('order' => 'assigned_date', 'direction' => $sorting == 'latest' ? 'desc' : 'asc');
$options['excludeblocked'] = 1;
// privacy lib
$privacy = Foundry::privacy(Foundry::user()->id);
$results = $model->getAlbums($user->id, SOCIAL_TYPE_USER, $options);
if ($results) {
foreach ($results as $item) {
// we need to check the photo's album privacy to see if user allow to view or not.
if ($privacy->validate('albums.view', $item->id, SOCIAL_TYPE_ALBUM, $item->user_id)) {
$albums[] = $item;
}
}
}
if (empty($albums)) {
return;
}
// If sorting is set to random, then we shuffle the albums
if ($sorting == 'random') {
shuffle($albums);
}
// since we are getting all albums belong to user,
// we do not need to run another query to count the albums.
// just do array count will be fine.
// $total = $model->getTotalAlbums($options);
$total = count($albums);
$limit = $params->get('limit', $appParam->get('limit', 10));
$this->set('total', $total);
$this->set('appParams', $appParam);
$this->set('params', $params);
$this->set('user', $user);
$this->set('albums', $albums);
$this->set('limit', $limit);
$this->set('privacy', $privacy);
return parent::display('widgets/profile/albums');
}
示例2: getOptions
/**
* Return a list of privacy options
*
* @param none
* @return array An array of select options
**/
public function getOptions($type = '', $userId = '')
{
$config = EasyBlogHelper::getConfig();
$file = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_community' . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'core.php';
$options = array();
if ($type != 'category') {
if ($config->get('main_jomsocial_privacy') && JFile::exists($file)) {
$options[] = JHTML::_('select.option', '0', JText::_('COM_EASYBLOG_PRIVACY_JOMSOCIAL_ALL'));
$options[] = JHTML::_('select.option', '20', JText::_('COM_EASYBLOG_PRIVACY_JOMSOCIAL_MEMBERS'));
$options[] = JHTML::_('select.option', '30', JText::_('COM_EASYBLOG_PRIVACY_JOMSOCIAL_FRIENDS'));
$options[] = JHTML::_('select.option', '40', JText::_('COM_EASYBLOG_PRIVACY_JOMSOCIAL_ONLY_ME'));
}
$easysocial = EasyBlogHelper::getHelper('EasySocial');
if ($config->get('integrations_easysocial_privacy') && $easysocial->exists()) {
$my = JFactory::getUser();
$userId = $userId ? $userId : $my->id;
$privacyLib = Foundry::privacy($userId, 'user');
$esOptions = $privacyLib->getOption('0', 'blog', $userId, 'easyblog.blog.view');
if (isset($esOptions->option) && count($esOptions->option) > 0) {
foreach ($esOptions->option as $optionKey => $optionVal) {
$valueInt = $privacyLib->toValue($optionKey);
$options[] = JHTML::_('select.option', $valueInt, JText::_('COM_EASYBLOG_PRIVACY_EASYSOCIAL_' . strtoupper($optionKey)));
}
}
}
}
// Default values
if (empty($options)) {
$options[] = JHTML::_('select.option', '0', JText::_('COM_EASYBLOG_PRIVACY_VIEWABLE_ALL'));
$options[] = JHTML::_('select.option', '1', JText::_('COM_EASYBLOG_PRIVACY_VIEWABLE_MEMBERS'));
if ($type == 'category') {
$options[] = JHTML::_('select.option', '2', JText::_('COM_EASYBLOG_PRIVACY_VIEWABLE_CATEGORY_ACL'));
}
}
return $options;
}
示例3: updateBlogPrivacy
public function updateBlogPrivacy($blog)
{
$privacyLib = Foundry::privacy($blog->created_by, SOCIAL_PRIVACY_TYPE_USER);
$privacyLib->add('easyblog.blog.view', $blog->id, 'blog', $blog->private);
}
示例4: onPrepareStream
/**
* Trigger for onPrepareStream
*
* @since 1.0
* @access public
* @param string
* @return
*/
public function onPrepareStream(SocialStreamItem &$item, $includePrivacy = true)
{
// We only want to process related items
if ($item->context != 'photos') {
return;
}
// If photos has been disabled, there's no point showing any stream
$config = Foundry::config();
// Do not allow user to access photos if it's not enabled
if (!$config->get('photos.enabled') && $item->verb != 'uploadAvatar' && $item->verb != 'updateCover') {
return;
}
// Get current logged in user.
$my = Foundry::user();
// Get user's privacy.
$privacy = Foundry::privacy($my->id);
$element = $item->context;
$uid = $item->contextId;
$useAlbum = count($item->contextIds) > 1 ? true : false;
// Decorate the stream
$item->color = '#F8829C';
$item->fonticon = 'ies-picture';
$item->label = FD::_('APP_USER_PHOTOS_STREAM_TOOLTIP', true);
$item->display = SOCIAL_STREAM_DISPLAY_FULL;
// Load the photo object
$photo = Foundry::table('Photo');
$photoId = $item->contextId;
$photoParams = isset($item->contextParams[$photoId]) ? $item->contextParams[$photoId] : '';
if ($photoParams) {
$obj = FD::json()->decode($photoParams);
if (!$obj) {
$photo->load($photoId);
} else {
// Bind the photo data
$photo->bind($obj);
if (!$photo->id) {
$photo->load($photoId);
}
}
} else {
$photo->load($photoId);
}
// If this is a group, we need to prepare accordingly.
if ($item->cluster_id && $item->cluster_type == SOCIAL_TYPE_GROUP) {
$group = Foundry::group($item->cluster_id);
// If we can't locate the group, skip this.
if (!$group) {
return;
}
// Check if the user can really view this stream
if (!$group->isOpen() && !$group->isMember()) {
return;
}
// Check if the group is private or invite, dont show the sharing button
if (!$group->isOpen()) {
$item->sharing = false;
}
// We need a different label for group items
$item->color = '#303229';
$item->fonticon = 'ies-users';
$item->label = FD::_('APP_USER_PHOTOS_GROUPS_STREAM_TOOLTIP', true);
}
// If this is an event, we need to prepare accordingly.
if ($item->cluster_id && $item->cluster_type == SOCIAL_TYPE_EVENT) {
$event = FD::event($item->cluster_id);
if (empty($event) || empty($event->id)) {
return;
}
if (!$event->isOpen() && !$event->getGuest()->isGuest()) {
return;
}
// Check if the event is private or invite, dont show the sharing button
if (!$event->isOpen()) {
$item->sharing = false;
}
$item->color = '#f06050';
$item->fonticon = 'ies-calendar';
$item->label = FD::_('APP_USER_EVENTS_STREAM_TOOLTIP', true);
}
// Process actions on the stream
$this->processActions($item, $privacy);
$privacyRule = $useAlbum ? 'albums.view' : 'photos.view';
if ($item->verb == 'uploadAvatar' || $item->verb == 'updateCover') {
$privacyRule = 'core.view';
}
if ($includePrivacy) {
if ($privacyRule == 'photos.view') {
// we need to check the photo's album privacy to see if user allow to view or not.
// if( !$privacy->validate( 'albums.view' , $photo->album_id, SOCIAL_TYPE_ALBUM, $item->actor->id ) )
if (!$privacy->validate('photos.view', $photo->id, SOCIAL_TYPE_PHOTO, $item->actor->id)) {
return;
}
//.........这里部分代码省略.........
示例5: bindStreamAccess
public function bindStreamAccess()
{
if (!$this->actor_id) {
// this is a guest.
// let get the privacy id for the keys that passed in.
$keys = $this->_public_rule['key'];
$rules = explode('.', $keys);
$key = array_shift($rules);
$rule = implode('.', $rules);
$currentRule = FD::table('Privacy');
$currentRule->load(array('type' => $key, 'rule' => $rule));
if (!$currentRule->id) {
// lets load the core.view privacy.
$currentRule->load(array('type' => 'core', 'rule' => 'view'));
}
$this->privacy_id = $currentRule->id;
$this->access = 0;
// always default to public
$this->custom_access = '';
} else {
$privacyLib = Foundry::privacy($this->actor_id);
$privacyData = $privacyLib->getData();
$core = $privacyData['core']['view'];
if ($this->_public_rule) {
$keys = $this->_public_rule['key'];
$access = $this->_public_rule['value'];
$custom = isset($this->_public_rule['custom']) ? $this->_public_rule['custom'] : '';
if ($this->actor_type == SOCIAL_STREAM_ACTOR_TYPE_USER) {
// we need to test the user privacy for this rule.
$rules = explode('.', $keys);
$key = array_shift($rules);
$rule = implode('.', $rules);
// if current passed in rule not found, we will use the core.view instead.
$currentRule = $core;
if (isset($privacyData[$key]) && isset($privacyData[$key][$rule])) {
$currentRule = $privacyData[$key][$rule];
}
$this->privacy_id = $currentRule->id;
$this->access = !is_null($access) ? $access : $currentRule->default;
$this->custom_access = '';
if ($this->access == SOCIAL_PRIVACY_CUSTOM) {
$tmp = array();
if ($custom) {
$tmp = $custom;
} else {
if ($currentRule->custom) {
foreach ($currentRule->custom as $cc) {
$tmp[] = $cc->user_id;
}
}
}
if ($tmp) {
$this->custom_access = ',' . implode(',', $tmp) . ',';
}
}
}
} else {
$this->privacy_id = $core->id;
$this->access = !empty($access) ? $access : $core->default;
$this->custom_access = '';
if ($this->access == SOCIAL_PRIVACY_CUSTOM) {
$tmp = array();
if ($custom) {
$tmp = $custom;
} else {
if ($core->custom) {
foreach ($core->custom as $cc) {
$tmp[] = $cc->user_id;
}
}
}
if ($tmp) {
$this->custom_access = ',' . implode(',', $tmp) . ',';
}
}
}
}
}
示例6: updateBlogPrivacy
public function updateBlogPrivacy($blog)
{
if (!$this->exists() || !$this->config->get('integrations_easysocial_privacy')) {
return false;
}
$privacyLib = Foundry::privacy($blog->created_by, SOCIAL_PRIVACY_TYPE_USER);
$privacyLib->add('easyblog.blog.view', $blog->id, 'blog', $blog->access);
}