1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. This forum is for release discussion only. Discussions that do not relate specifically to the resource release should be discussed in another, more appropriate forum.
    Dismiss Notice
  3. This forum has been archived. New threads and replies may not be made. All add-ons/resources that are active should be migrated to the Resource Manager. See this thread for more information.

Enforce No Shouting For One Group

Discussion in 'Code Modifications [Archive]' started by Jake Bunce, Aug 23, 2011.

  1. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    (in response to this thread)

    First enable this option:

    Admin CP -> Home -> Options -> Threads, Discussions and Conversations -> Automatically Adjust Case of Discussion Titles

    Now we can edit the code to apply this restriction to a specific group only. Edit this file:

    library/XenForo/DataWriter/Discussion.php

    Add the red code. Change the blue part to specify the user_group_id that cannot shout:

    Code:
    	/**
    	 * Verifies that the discussion title is valid
    	 *
    	 * @param string
    	 *
    	 * @return boolean
    	 */
    	public function _verifyTitle(&$title)
    	{
    		/* ONLY ENFORCE NO SHOUTING FOR ONE GROUP */
    		$visitor = XenForo_Visitor::getInstance();
    		$noShout = $visitor->isMemberOf(11, true);
    		if (!$noShout)
    		{
    			return true;
    		}
    		/* ONLY ENFORCE NO SHOUTING FOR ONE GROUP */
    
    		// TODO: send these to callbacks to allow hookability?
    
    		switch ($this->getOption(self::OPTION_ADJUST_TITLE_CASE))
    		{
    			case 'ucfirst': // sentence case
    				$title = utf8_ucfirst(utf8_strtolower($title));
    				break;
    
    			case 'ucwords': // title case
    				$title = utf8_ucwords(utf8_strtolower($title));
    				break;
    		}
    
    		return true;
    	}
    
     
    Jeremy and Dean like this.
  2. Dean

    Dean Well-Known Member

    OUTSTANDING!!!! (that was an attempt at humor)

    Thank you very much Jake :)

    edit: that works great! I will slowly add people in that group as needed. That way the well behaved people will not have their titles changed.
     
    Jeremy likes this.
  3. ineedhelp

    ineedhelp Well-Known Member

    Can I see a before and after effect of this please?

    IF SOMEONE TYPES LIKE THIS OR COPY AND PASTES TEXT TYPED IN ALL CAPS - WILL IT AUTOMATICALLY LOWER CASE IT?

    And keep the First letter Capital ?

    Is this code compatible with 1.1.0 ?

    Also - I would like this feature throughout the site, not just for a particular group.
     
  4. Dean

    Dean Well-Known Member

    It simply enforces this criteria for thread titles, or not, based on user group:
    admincp -> options -> options -> Threads, Discussions and Conversations -> Automatically Adjust Case of Discussion Titles
     
  5. ineedhelp

    ineedhelp Well-Known Member

    What's the point of this mod? You can already do this within xenforo.... Only The First Title Letter Is Capital
     
  6. Dean

    Dean Well-Known Member

    99% of my members don't abuse the caps lock for titles, 1% do abuse it. So 99% of my members are exempt from the "Automatically Adjust Case of Discussion Titles".

    Because we have several terms unique to us that needs to have 2 or 3 consecutive capital letters to make it look correct...
     
  7. ineedhelp

    ineedhelp Well-Known Member

    Ok now i understand ur needs.

    :)
     
    Dean likes this.

Share This Page