Class Likes
Class Likes
Copyright: 2020 Simple Machines and individual contributors
License: BSD
Author: Simple Machines https://www.simplemachines.org
Located at Sources/Likes.php
			 public 
			
			
			
		 | 
		|
			 public 
			
			
			
		 | 
		|
			 public 
			mixed
			
			
		 | 
		|
			 protected 
			
			
			
		 | 
		|
			 protected 
			
			
			
		 | 
		|
			 protected 
			
			
			
		 | 
		|
			 protected 
			
			
			
		 | 
		|
			 protected 
			
			
			
		 | 
		|
			 public 
			
			
			
		 | 
		|
			 public 
			
			
			
		 | 
		|
			 protected 
			
			
			
		 | 
		|
			 protected 
			
			
			
		 | 
		
			protected  
			boolean
		 | 
		
				$_js
			 Know if a request comes from an ajax call or not, depends on $_GET['js'] been set.  | 
		
			 
				#
				 
		false
			 | 
	
			protected  
			string
		 | 
		
				$_error
			 If filled, its value will contain a string matching a key on a language var $txt[$this->_error]  | 
		
			 
				#
				 
		false
			 | 
	
			protected  
			string
		 | 
		
				$_type
			 The unique type to like, needs to be unique and it needs to be no longer than 6 characters, only numbers and letters are allowed.  | 
		
			 
				#
				 
		''
			 | 
	
			protected  
			string
		 | 
		
				$_extra
			 A generic string used if you need to pass any extra info. It gets set via $_GET['extra'].  | 
		
			 
				#
				 
		false
			 | 
	
			protected  
			integer
		 | 
		
				$_content
			 a valid ID to identify your like content.  | 
		
			 
				#
				 
		0
			 | 
	
			protected  
			integer
		 | 
		
				$_numLikes
			 The number of times your content has been liked.  | 
		
			 
				#
				 
		0
			 | 
	
			protected  
			boolean
		 | 
		
				$_alreadyLiked
			 If the current user has already liked this content.  | 
		
			 
				#
				 
		false
			 | 
	
			protected  
			array
		 | 
		
				$_validLikes
			 $_validLikes mostly used for external integration, needs to be filled as an array with the following keys: => 'can_like' boolean|string whether or not the current user can actually like your content. for can_like: Return a boolean true if the user can, otherwise return a string, the string will be used as key in a regular $txt language error var. The code assumes you already loaded your language file. If no value is returned or the $txt var isn't set, the code will use a generic error message. => 'redirect' string To add support for non JS users, It is highly encouraged to set a valid URL to redirect the user to, if you don't provide any, the code will redirect the user to the main page. The code only performs a light check to see if the redirect is valid so be extra careful while building it. => 'type' string 6 letters or numbers. The unique identifier for your content, the code doesn't check for duplicate entries, if there are 2 or more exact hook calls, the code will take the first registered one so make sure you provide a unique identifier. Must match with what you sent in $_GET['ltype']. => 'flush_cache' boolean this is optional, it tells the code to reset your like content's cache entry after a new entry has been inserted. => 'callback' callable optional, useful if you don't want to issue a separate hook for updating your data, it is called immediately after the data was inserted or deleted and before the actual hook. Uses call_helper(); so the same format for your function/method can be applied here. => 'json' boolean optional defaults to false, if true the Like class will return a json object as response instead of HTML.  | 
		
			 
				#
				 
		array(
    'can_like' => false,
    'redirect' => '',
    'type' => '',
    'flush_cache' => '',
    'callback' => false,
    'json' => false,
)
			 | 
	
			protected  
			array
		 | 
		
				$_user
			 The current user info ($user_info).  | 
		|
			protected  
			integer
		 | 
		
				$_idTopic
			 The topic ID, used for liking messages.  | 
		
			 
				#
				 
		0
			 | 
	
			protected  
			boolean
		 | 
		
				$_setResponse
			 to know if response(); will be executed as normal. If this is set to false it indicates the method already solved its own way to send back a response.  | 
		
			 
				#
				 
		true
			 |