Developer Question: Visibility

@LeonidS my friend, I am hoping you may know the answer to this.

Is there anyway I can restrict Visibility.

Example. Say I do not want Polls to have Group visibility, so when adding a new poll under Visibility, my groups do not show up.

Is there a way in studio? Database? Custom class overrides?

How can I accomplish this?

Thank you UNA!

  • 3948
  • More
Replies (8)
    • Does the settings in Settings >> General >> "Hide post to context for modules in Privacy field" do what you need?

    • That would exclude all content into that comtext. If I select Groups, then posting videos, etc would not show on the form for video, etc.

      I'm looking for a more fine grain way of removing some but not all.

      I have no issue recoding, just need pointed in the direction where these checks are done, where the select box is populated at.

    • I have some forms on my site that I hide categories in this way. I use the following Javascript to hide specific options, including the "friends," "me only," etc.

        <script language="javascript">
      
      
      const aVars = ['GROUPS'];
      aVars.forEach(reduce_vars);
      function reduce_vars (sItem)
      {
      $(".sys-privacy-group").children().remove('optgroup[label=' + sItem + ']');
      }  
          
          
        $(".sys-privacy-group option[value=2]").remove();
        
        $(".sys-privacy-group option[value=3]").remove();
          
        $(".sys-privacy-group option[value=5]").remove();
          
        $(".sys-privacy-group option[value=6]").remove();
          
        $(".sys-privacy-group option[value=7]").remove();
          
        $(".sys-privacy-group option[value=8]").remove();
        
        $(".sys-privacy-group option[value=9]").remove();
        
        $(".sys-privacy-group option[value=c]").remove();
        
        $(".sys-privacy-group option[value=s]").remove();
      
      
      </script>
      

      That kind of what you are looking for?

    • I will look into that, I don't like using client side unless I absolutely have to, plus, it would change per person, etc. I will do some digging, I'd like to find the code in the core, and add what I need.

      @Corey Dozier again, thank you for the suggestions.

    • Hello @Wise !

      Yes, the solution by @Corey Dozier is in the right direction (thnx, mate!) - the JS variant is the simplest solution to get rid off the unnecessary variant(s) in the VIsiblity field.

    • Hello. If it's OK for you to write some custom code and make some changes in DB:

      INSERT INTO `sys_objects_privacy` (`object`, `module`, `action`, `title`, `default_group`, `table`, `table_field_id`, `table_field_author`, `override_class_name`, `override_class_file`) VALUES ('bx_polls_allow_view_to', 'bx_polls', 'view', '_bx_polls_form_entry_input_allow_view_to', '3', 'bx_polls_entries', 'id', 'author', '', '');

      It's privacy object for "Visible to" field in polls. You may use custom class/file here `override_class_name`, `override_class_file`. For now, you may even put the class in the polls/classes/ folder and it won't be overwritten untill UNA decides to do the same in core.

      Then you need to overwrite 'addSpaces' method in your class.

      public function addSpaces($aValues, $iOwnerId, $aParams)

      It's used to add contexts in the list. Something similar you may find in Timeline BxTimelinePrivacy class.

      Good luck!

    • @Anton L thank you! I will look through the database and code, just needed the direction.

    • You are welcome!🙏

    Login or Join to comment.