Home  ›  Documentation  ›  List of hooks

List of hooks

Throughout esoTalk's code there are plenty of hooks which you can hook onto with your own code. If you don't know what hooks are, how they work, or how to use them, read how to make a plugin.

If there's a place where you need a hook but it isn't on this list, make a request by http://forum.esotalk.com/conversation/new/ starting a new conversation with the tag 'hook request'.

The syntax to hook your own code onto one of these hooks is this:

$controller->addHook("hookName", "yourFunction");

For example, to hook the function addSignatureToPostArray on to the getPost hook in the Conversation controller, the following would be used:

if ($this->esoTalk->action == "conversation") { 
    $this->esoTalk->controller->addHook("getPost", "addSignatureToPostArray"); 
}

Some hooks allow a value to be returned which will may halt any further processing in the context of the hook from occurring. One such example is the validateAddReply hook in the Conversation controller, which will display a message identified by the return value of a hooked function (if applicable.)

esoTalk controller

(Where $this is an instance of the esoTalk controller.)

  • init( &$this ) - esoTalk controller initialization.
  • beforeDatabaseQuery( &$this, &$query ) - before a database query is executed.
  • afterDatabaseQuery( &$this, $query, &$result ) - after a database query is successfully executed.
  • beforeLogin( &$this, &$components ) - before the login query to fetch user data is constructed and executed.
  • afterLogin( &$this, &$data ) - after the user $data is successfully fetched from the database.
  • logout( &$this ) - when the user is logged out.
  • getStatistics( &$this, &$result ) - when forum statistics are fetched in an array of key ⇒ statistic_text.
  • ajax( &$this ) - when an ajax request to this controller is made. Can return something.
  • star( &$this, $conversationId ) - when a conversation is starred/unstarred.
  • changeMemberGroup( &$this, &$group ) - when changing a member's group.
  • ajaxFinish( &$this, &$result ) - before the $result array is outputted as a JSON string.
  • pageStart( &$this ) - situated directly after the <body> tag.
  • pageEnd( &$this ) - situated directly before the </body> tag.
  • head( &$this, &$html ) - when the $html to go inside the <head> tag is generated.
  • message( &$this, &$key, &$disappear, &$arguments ) - when a message is collected to be displayed on the page.
  • fatalError( &$this, &$message ) - when a fatal error occurs.
  • getAvatar( &$this, $memberId, $avatarFormat, $type ) - when the path to a user's avatar is gotten. Can return an avatar path.
  • updateLastAction( &$this, &$action ) - when updating a user's last action in the database.

Conversation controller

(Where $this is an instance of the conversation controller.)

  • initExistingConversation( &$this ) - where all the pre-processing for a conversation that exists (sticky, locked, working out startFrom, etc.) is fired
  • initNewConversation( &$this ) - where all the pre-processing for a conversation that doens't exist is fired.
  • init( &$this ) - conversation controller initialization
  • ajax( &$this ) - when an ajax request to this controller is made. Can return something.
  • beforeGetConversation( &$this, &$components ) - before the query to get the conversation is constructed and executed
  • afterGetConversation( &$this, &$conversation ) - after the query result has been put into an array
  • getNewConversation( &$this, &$conversation ) - when an empty conversation is returned
  • getMembersAllowed( &$this, &$membersAllowed ) - when an array of members allowed is fetched.
  • beforeGetPosts( &$this, &$components ) - before the query to get the posts is constructed and executed
  • getPost( &$this, &$post, $postData ) - after an array of post information ($post) is constructed. $postData is the post data from the database
  • afterGetPosts( &$this, &$posts ) - just before the posts array is returned
  • validateAddReply( &$this, &$content ) - before proceeding with the add reply process. Can return a message identifier to halt the add reply process.
  • beforeAddReply( &$this, &$post ) - before the query to add a reply ($post) is constructed and executed
  • afterAddReply( &$this, $id ) - after a reply is successfully added. $id is the id of the new reply.
  • saveDraft( &$this, &$content ) - before running the query to save a draft with $content.
  • discardDraft( &$this ) - when the user discards their draft.
  • editPost( &this, $postId, &$content ) - before a post is edited. Can return a message identifier to halt the process.
  • getEditControls( &$this, &$controls ) - before an array of formatting controls (bold, italic, etc.) is returned
  • getEditArea( &$this, &$html ) - when the HTML of a textarea and buttons for when a post is being edited is returned.
  • formatForDisplay( &$this, &$post, &$formatters ) - before a post is passed to the Formatter class to be formatted into HTML.
  • formatForEditing( &$this, &$post, &$formatters ) - before a post is passed to the Formatter class to be formatted from HTML back into formatting code.
  • displayPost( &$this, &$post ) - when render-level formatting is performed on a post.
  • validatePost( &$this, &$post ) - when post content is validated. Can return a message identifier to halt the process.
  • deletePost( &$this, $id ) - when a post is deleted.
  • restorePost( &$this, $id ) - when a post is restored.
  • validateStartConversation( &$this, &$conversationData ) - before proceeding with the start conversation process. Can return a message identifier to halt.
  • beforeStartConversation( &$this, &$insertData, $conversationData ) - before the query to start a conversation is constructed from $insertData and executed.
  • afterStartConversation( &$this, $conversationId ) - after a conversation is successfully started. $conversationId is the id of the new conversation.
  • deleteConversation( &$this, &$query ) - when the conversation is deleted.
  • findMemberAllowed( &$this, $name ) - when the member/member group that $name represents is decided. Can return array(memberId, name).
  • afterAddMemberAllowed( &$this, $memberId, $name ) - after $memberId is added as an allowed member in the conversation.
  • afterRemoveMemberAllowed( &$this, $memberId ) - after $memberId is removed as an allowed member in the conversation.
  • getMembersAllowedHTML( &$this, &$html, $membersAllowed ) - when the HTML of the members allowed list is returned.
  • saveTitle( &$this, &$query, $title ) - before the query to save a conversation title is saved.
  • saveTags( &$this, $newTags, $addTags, $delTags ) - when the conversation tags are saved.
  • toggleSticky( &$this, &$query ) - before the query to toggle a conversation's sticky is executed
  • toggleLock( &$this, &$query ) - before the query to toggle a conversation's locked status is executed
  • validateTitle( &$this, &$title ) - when the title is validated. Can return a message identifier to halt the process.
  • afterRenderHeader( &$this ) - after the conversation header (title, tags, members allowed, etc.) is rendered
  • beforeRenderPagination( &$this, &$paginationHtml ) - before the first pagination html is outputted (bottom pagination is duplicated from $paginationHtml)
  • renderReplyArea( &$this ) - situated after the “Post a reply”/“Save draft” buttons.

Feed controller

(Where $this is an instance of the feed controller.)

  • init( &$this ) - before a list of feed items is constructed. Can return something.
  • formatPost( &$this, &$post ) - when post content is formatted before being added to the list of feed items.

Join controller

(Where $this is an instance of the join controller.)

  • init( &$this ) - join controller initialization
  • validate( &$this, &$validationError ) - when the form fields are validated
  • beforeAddMember( &$this, &$insertData ) - before the query to add a member is constructed and executed
  • afterAddMember( &$this, $memberId ) - after the query to add a member is executed successfully
  • ajax( &$this ) - when an ajax request to this controller is made . Can return something.

Profile controller

(Where $this is an instance of the profile controller.)

  • init( &$this ) - profile controller initialization
  • ajax( &$this ) - when an ajax request to this controller is made. Can return something.
  • beforeGetMember( &$this, &$components ) - before the query to get member details is constructed and executed.
  • afterGetMember( &$this, &member ) - after the query result has been put into an array.
  • statistics( &$this ) - when the list of member statistics is outputted.

Search controller

(Where $this is an instance of the search controller.)

  • init( &$this ) - search controller initialization
  • ajax( &$this ) - when an ajax request to this controller is made. Can return something.
  • getConversationIds( &$this, &$components ) - before the query to get a list of conversation IDs is constructed and executed
  • beforeGetResults( &$this, &$components ) - before the query to get the resulting conversations is constructed and executed.
  • afterGetResults( &$this, &$results ) - after the resulting conversations have been fetched and an array constructed.

Settings controller

(Where $this is an instance of the settings class.)

  • init( &$this ) - settings controller initialization
  • ajax( &$this ) - when an ajax request to this controller is made. Can return something.
  • validateForm( &$this, &$validationError ) - when the form fields are validated
  • beforeSave( &$this, &$updateData ) - before the query to save settings is constructed and executed
  • afterSave( &$this ) - after the query to save settings is executed successfully
  • resizeAvatar( &$this, $imageResource, $destination, $type, $resizeWidth, $resizeHeight ) - when an avatar is resized to $resizeWidth by $resizeHeight. Returning true will skip the default resizing process.
esoTalk
  • Documentation home
  • About esoTalk
  • FAQ
  • Installing esoTalk
  • Upgrading esoTalk
  • Customizing your forum
Development
Code documentation
  • Coding standard
  • Folder structure
  • Page execution order
  • Controllers and views
  • Ajax
  • Useful functions
  • List of hooks
Extending esoTalk