Please upgrade here. These earlier versions are no longer being updated and have security issues.

Prevent new users from posting links

edited September 2013 in Vanilla 2.0 - 2.3

I have found an article which discusses 9 Ways to Eliminate Spam in Your Community Forum
http://vanillaforums.com/blog/news/9-ways-to-eliminate-spam-in-your-community-forum/

And number 8 is:
Only allow members that have proven themselves and have a reputation to be allowed to post links. In Vanilla, it’s possible to prevent members with a low Rank from posting links, editing comments, etc. Ranks are earned by accumulating reputation points or making a certain number of posts.

But I could not find any information on how to achieve that with vanilla forum.

Has any one done that, any one can point me in right direction? :)

Comments

  • it could be done with a plugin through post parsing. You can look at plugins that do post parsing like Filter Star,LaTeX, etc then do the pastern match for links to strip them.

    If you can't do it yourself you will most likely have to pay someone. You have the permission element, and you have the ranking automation.

    grep is your friend.

    UnderDog
  • hgtonighthgtonight ∞ · New Moderator

    That feature is available on the hosted version of Vanilla.

    It is not in the OS version that these forums support.

    That said, @x00 outlined a relatively easy way to do it via a custom plugin.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

    UnderDog
  • Ok I checked the example plugins and I have an idea on how to strip out the links, but is it possible to validate text before saving discussion and do not allow to post discussion at all, if there are links, by displaying error message.

    As in, is it possible inside DiscussionModel_BeforeSaveDiscussion_Handler to tell not to save the discussion with reported error message?

    or any other way to achieve it?

  • Never mind, found out that there is $Sender->Validation->ApplyRule

  • hbfhbf wiki guy? MVP

    Arturs, the best way to share your work is to package it as a plugin and upload it to the addons repository. it's quick and easy and it makes it easier for people to find your work.

    vrijvlinderUnderDog
  • @hbf will do that, once I figure out how to create form to provide settings and save/load configuration ;)

  • hgtonighthgtonight ∞ · New Moderator

    Site wide settings are generally stored in the /conf/config.php file. This is greatly simplified by using a controllers Form object and creating a ConfigurationModel object. For example this function, in a plugin class, will create a function on the Settings controller and process form data:

    public function SettingsController_AnyNameButGenerallyThePluginsName_Create($Sender) { // this function will execute on forum.example.com/settings/anynamebutgenerallythepluginsname
      // Admins only, feel free to change this to something more suitable if necessary
      $Sender->Permission('Garden.Settings.Manage');
    
      // Set data used by the view
      $Sender->SetData('PluginDescription',$this->GetPluginKey('Description'));
    
      $Validation = new Gdn_Validation();
      $ConfigurationModel = new Gdn_ConfigurationModel($Validation);
      $ConfigurationModel->SetField(array( // This sets the defaults for any configurations not found in the /conf/config.php file
        'Plugins.LatestPostList.Pages'  => 'all',
        'Plugins.LatestPostList.Frequency'  => 120,
        'Plugins.LatestPostList.Count'  => 5,
        'Plugins.LatestPostList.Link'   => 'discussions',
        'Plugins.LatestPostList.Effects' => 'none',
      ));
    
      // Set the model on the form.
      $Sender->Form->SetModel($ConfigurationModel);
    
      // If seeing the form for the first time...
      if ($Sender->Form->AuthenticatedPostBack() === FALSE) {
        // This fills in the form data with the loaded configuration data
        $Sender->Form->SetData($ConfigurationModel->Data);
      }
      else {
        // This group validates the data against known rules and throws errors if something isn't right
        $ConfigurationModel->Validation->ApplyRule('Plugins.LatestPostList.Pages', 'Required');
    
        $ConfigurationModel->Validation->ApplyRule('Plugins.LatestPostList.Frequency', 'Required');
        $ConfigurationModel->Validation->ApplyRule('Plugins.LatestPostList.Frequency', 'Integer');
    
        $ConfigurationModel->Validation->ApplyRule('Plugins.LatestPostList.Count', 'Required');
        $ConfigurationModel->Validation->ApplyRule('Plugins.LatestPostList.Count', 'Integer');
    
        $ConfigurationModel->Validation->ApplyRule('Plugins.LatestPostList.Effects', 'Required');
    
        // This calls the save function which will return false if there are form errors
        $Saved = $Sender->Form->Save();
        if ($Saved) {
          // Use a nice inform message to show the user their settings were saved without refreshing the page
          $Sender->InformMessage('<span class="InformSprite Sliders"></span>'.T('Your changes have been saved.'),'HasSprite');
        }
      }
    
      // Render the settings view
      $Sender->Render($this->GetView('settings.php'));
    }
    

    This will render the settings view and save the input. My simplified settings view looks something like this:

    // Write the opening of the form and any errors logged by our validation model
    echo $this->Form->Open();
    echo $this->Form->Errors();
    
    // This is a simple textbox and label
    echo $this->Form->Label(T('List Length'), 'Plugins.LatestPostList.Count');
    echo $this->Form->Textbox('Plugins.LatestPostList.Count');
    
    // This is a dropdown with label
    // The first keys in the array are the values for each option
    // while the values are what is displayed to the user
    echo $this->Form->Label(T('Pages'), 'Plugins.LatestPostList.Pages');
    echo $this->Form->DropDown('Plugins.LatestPostList.Pages', array(
      'both'          => 'Discussions & Announcements',
      'announcements' => 'Just Announcements',
      'discussions'   => 'Just Discussions',
      'all'           => 'Every frontend page'
      ));,
    
    echo $this->Form->Label(T('Link'), 'Plugins.LatestPostList.Link');
    echo $this->Form->Textbox('Plugins.LatestPostList.Link');,
    
    echo $this->Form->Label(T('Frequency'), 'Plugins.LatestPostList.Frequency');
    echo $this->Form->Textbox('Plugins.LatestPostList.Frequency');
    
    echo $this->Form->Label(T('Animation'), 'Plugins.LatestPostList.Effects');
    echo $this->Form->DropDown('Plugins.LatestPostList.Effects', array(
      'none' => 'None',
      '1'    => 'Rolling Hide',
      '2'    => 'Full Fade',
      '3'    => 'Rolling Fade',
      '4'    => 'Rolling Slide',
      '5'    => 'Rolling Width Fade'
      ));
    
    // This closes the form by writing a button with the string passed, in this case a 'Save' button will show up.
    echo $this->Form->Close('Save');
    

    Per user settings are generally stored in the UserMeta db table. The plugin class offers some convenience methods to make storing per user, per plugin settings a breeze. You still want to create a validation class and apply your rules, but rather than calling the $Sender->Form->Save() method, you want to call the $this->SetUserMeta() method. For a full fledged example, check out the signatures plugin source.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

    Adrian
Sign In or Register to comment.