Jump to content

Developer Documentation

Member History

Invision Community 4.2 has introduced the new Member History feature. This feature allows an application to store a log any time an account is altered from within the application, along with arbitrary data outlining what has changed.

Logging a change to an account is as simple as making a called to the \IPS\Member::logHistory() method.

	/**
	 * Log Member Action
	 *
	 * @param	mixed		$app			The application action applies to
	 * @param	string		$type			Log type
	 * @param	mixed		$extra			Any extra data for the type
	 * @param	mixed		$by				The member performing the action. NULL for currently logged in member or FALSE for no member
	 * 
	 * @return	void
	 */
	public function logHistory( $app, $type, $extra=NULL, $by=NULL )
  • $app - This is the application key the log is associated with.
  • $type - This is the log "type" which we will use to identify and parse the log for display later.
  • $extra - This is an array of extra arbitrary data that needs to be stored (display name changes, for example, store both the old and the new username in the form of array( 'old' => 'Old Name', 'new' => 'new Name' );).
  • $by - This is the user performing the change.

Member History Logs are parsed and displayed in the Admin CP (Members > Edit a Member > Member History) by the use of Extensions. Each application can create multiple extensions, however one extensions can also handle multiple log types.

The extension has two methods:

	/**
	 * Parse LogData column
	 *
	 * @param	string		$value		column value
	 * @param	array		$row		entire log row
	 * @return	string
	 */
	public function parseLogData( $value, $row )

	/**
	 * Parse LogType column
	 *
	 * @param	string		$value		column value
	 * @param	array		$row		entire log row
	 * @return	string
	 */
	public function parseLogType( $value, $row )

parseLogData() is used to format the log information so that it displays correctly in the Member History table. $value is the data that was passed through to the $extra parameter of \IPS\Member::logHistory(), and $row is the entire row from the core_member_history table. Note that value will be json_encode()'d so the value will need to be manually passed to json_decode() to get the true value.

parseLogType() is used to show a simple icon on the table, where supported.


  Report Document


×
×
  • Create New...