Public content by author

Is there anyway to show the public content of an author in a block?

currently, Posts by Author block shows all posts by an author and shows 'Access denied. This is private content' for posts which is not published publicly. I want to prevent this private content from showing up. therefore, I want to change the Posts by Author method parameters to add something like 'privacy'=>'public'. This is the current service call:

array (

  'module' => 'bx_posts',

  'method' => 'browse_author',

  'params' => 

  array (

    0 => '{profile_id}',

    1 => 

    array (

      'per_page' => 'bx_posts_per_page_profile',

      'empty_message' => false,

    ),

  ),

  • 502
  • More
Replies (14)
    • LeonidS can you help with this please!

      • Hello Scholar !

        Sorry, but there is no ready method to show only the public posts from the author. It will require to write a new one.

        • Hello Scholar !

          Sorry, but there is no ready method to show only the public posts from the author. It will require to write a new one.

          Hi LeonidS. I've tracked the browse_author method and it passes arguments to the function

          _updateCurrentForAuthor (). here is the code for it:

              protected function _updateCurrentForAuthor($sMode, $aParams, &$oProfileAuthor)    {        $CNF = &$this->oModule->_oConfig->CNF;
          $oProfileAuthor = BxDolProfile::getInstance((int)$aParams['author']); if (!$oProfileAuthor) return false;
          $iProfileAuthor = $oProfileAuthor->id(); if (bx_get_logged_profile_id() == $iProfileAuthor || $this->oModule->_isModerator()) { // for real owner and for moderators show anonymous posts $this->aCurrent['restriction']['author']['operator'] = 'in'; $this->aCurrent['restriction']['author']['value'] = array($iProfileAuthor, -$iProfileAuthor); } else { $this->aCurrent['restriction']['author']['value'] = $iProfileAuthor; }
          if(!empty($aParams['except'])) $this->aCurrent['restriction']['except']['value'] = is_array($aParams['except']) ? $aParams['except'] : array($aParams['except']);
          if(!empty($aParams['per_page'])) $this->aCurrent['paginate']['perPage'] = is_numeric($aParams['per_page']) ? (int)$aParams['per_page'] : (int)getParam($aParams['per_page']);
          $this->sBrowseUrl = 'page.php?i=' . $CNF['URI_AUTHOR_ENTRIES'] . '&profile_id={profile_id}'; $this->aCurrent['title'] = _t($CNF['T']['txt_all_entries_by_author']); $this->aCurrent['rss']['link'] = 'modules/?r=' . $this->oModule->_oConfig->getUri() . '/rss/' . $sMode . '/' . $iProfileAuthor;
          return true; }

          where can I add a statement to exclude non-public posts?

            • If you're OK tomodify this code then you may add the following line:

              $this->aCurrent['restriction'] ['public'] => array('value' => BX_DOL_PG_ALL, 'field' => 'allow_view_to', 'operator' => '=');

              after this one:

              if(!empty($aParams['per_page'])) $this->aCurrent['paginate']['perPage']

              • If you're OK tomodify this code then you may add the following line:

                $this->aCurrent['restriction'] ['public'] => array('value' => BX_DOL_PG_ALL, 'field' => 'allow_view_to', 'operator' => '=');

                after this one:

                if(!empty($aParams['per_page'])) $this->aCurrent['paginate']['perPage'] 

                that worked great, but I had to put it in the else statement to allow owners to view their non-public posts.

                • LeonidS Now, I want to do the same with the keyword search results. They are all based on BxDolSearch class. It sounds that this method setProcessPrivateContent is responsible for privacy settings. how can I change it to only show public/allowed content instead of showing 'Access denied. This is private content ' message. how can I add your great code snippet to BxDolSearch ?

                  • I've just added ability to set custom condition in browse service - https://github.com/unaio/una/issues/3166

                    So after next UNA update you will be able to use the following service block:

                    array (
                      'module' => 'bx_posts',
                      'method' => 'browse_with_condition',
                      'params' => 
                      array (
                        0 => 
                        array (
                          'mode' => 'author',
                          'params' => 
                          array (
                            'author' => 10,
                            'condition' => 
                            array (
                              'restriction' => 
                              array (
                                'public' => 
                                array (
                                  'field' => 'allow_view_to',
                                  'operator' => '=',
                                  'value' => 3,
                                ),
                              ),
                            ),
                          ),
                        ),
                      ),
                    )
                    • Alex T⚜️ that's great for blocks, what about keyword search results? any chance to modify the setProcessPrivateContent so that it hides private content, instead of showing it with 'Access Denied' message?

                      •  what about keyword search results? any chance to modify the setProcessPrivateContent so that it hides private content, instead of showing it with 'Access Denied' message?

                        Such functionality isn't available for keyword search, we'll consider it for next major update - https://github.com/unaio/una/issues/3180

                        • Does this mean that there will be no more privacy errors?

                          • Hello Genesis !

                            Please specify which errors do you mean?

                            • Hi Leonids. I think Genesis means this error message: 'Access denied. This is private content' since private content won't show in the 'Posts by Author' block anymore.

                              • The part which Alex T⚜️ mentioned relates to other functionality than Genesis means.

                                Login or Join to comment.