Loading...
 
Event functionality developer documentation Type of page »  Developers documentation

Events

Events

Events can be triggered in Tiki during execution of functions. A general usage is to trigger events in service controllers.
Events call a callback function
Events can be chained
Activities are triggered event instances that are configured to be recorded. Event instances are not automatically recorded (except for some basic events), you need to set up an activity rule if you want this to happen. Activities can be displayed in activity streams.
Events are not log entries.
Tiki events are defined in the source code, so if you want to setup a new event, you need to modify the definition file.

Definitions

lib/setup/events.php


An event is definded as below:

event namea unique name for the event. Example: tiki.comment.update.
priorityAllows events to be forced to execute after others. For example, normal priorities may alter data, but indexing should not happen until all data has been modified. Default priority is 0. Priorities are numeric, false indicates that the event executes at all levels. This is used for chaining and happens transparently when using bind() with an event as the callback.
callback the name of the callback function to be executed.
arguments arguments to be passed to the callback function


When defining events it is important to bind and chain them (see function bind and bindPriority in the Library)
function bind binds an event at normal priority and handles event chaining.
function bindPriority binds the event at a specific priority
Binding can:

  • point to another event
  • defer to a library with a function within that library
  • call a service controller function
  • be delegated to another library/controller

$events = TikiLib::events();
$defer = function ($lib, $function ) {
	return Tiki_Event_Lib::defer($lib, $function);
};

//single binding to another event
$events->bind('tiki.comment.post', 'tiki.comment.save');

//multiple binding by deferring to a library and a function within that library
$events->bind('tiki.trackeritem.save', $defer('trk', 'update_tracker_summary'));
$events->bind('tiki.trackeritem.save', $defer('trk', 'invalidate_item_cache'));

// binding using a service controller
$events->bind('tiki.trackeritem.create', ['Services_MustRead_Controller', 'handleItemCreation']);

//delegated binding
TikiLib::lib('goalevent')->bindEvents($events);

Library

lib/core/Tiki/Event/Manager.php

How to use

In a service controller call the trigger function and supply the necessary inputs

TikiLib::events()->trigger('tiki.comment.update', array(
					'type' => $comment['objectType'],
					'object' => $comment['object'],
					'title' => $title,
					'comment' => $threadId,
					'user' => $GLOBALS['user'],
					'content' => $data,
					'index_handled' => true,
				));
Contributors to this page: gezza .
Page last modified on Monday 24 August, 2015 20:46:58 CEST by gezza.

Search Wishes (subject only)

Keywords

The following is a list of keywords that should serve as hubs for navigation within the Tiki development and should correspond to documentation keywords.

Each feature in Tiki has a wiki page which regroups all the bugs, requests for enhancements, etc. It is somewhat a form of wiki-based project management. You can also express your interest in a feature by adding it to your profile. You can also try out the Dynamic filter.

Accessibility (WAI & 508)
Accounting 7.x
Administration
Ajax 2.x
Articles & Submissions
Backlinks
Banner
Batch 6.x
BigBlueButton audio/video/chat/screensharing (5.x)
Blog
Bookmark
Browser Compatibility
Calendar
Category
Chat
Comment
Communication Center
Consistency
Contacts Address book
Contact us
Content template
Contribution 2.x
Cookie
Copyright
Credits 6.x
Custom Home (and Group Home Page)
Database MySQL - MyISAM
Database MySQL - InnoDB
Date and Time
Debugger Console
Directory (of hyperlinks)
Documentation link from Tiki to doc.tiki.org (Help System)
Docs 8.x
DogFood
Draw 7.x
Dynamic Content
Preferences
Dynamic Variable
External Authentication
FAQ
Featured links
Feeds (RSS)
File Gallery
Forum
Friendship Network (Community)
Group
Help
Hotword
HTML Page
i18n (Multilingual, l10n, Babelfish)
Image Gallery
Import-Export
Install
Integrator
Interoperability
Inter-User Messages
InterTiki
jQuery
Kaltura video management
Karma
Live Support
Logs (system & action)
Lost edit protection
Mail-in
Map
Menu
Meta Tag
Missing features
Visual Mapping 3.x
Mobile Tiki and Voice Tiki
Mods
Modules
MultiTiki
MyTiki
Newsletter
Notepad
OS independence (Non-Linux, Windows/IIS, Mac, BSD)
Organic Groups (Self-managed Teams)
Payment 5.x
Performance Speed / Load / Compression / Cache
Permission
Poll
Profiles
Quiz
Rating
Report
Score
Search engine optimization (SEO)
Search
Security
Semantic links 3.x
Share
Shopping Cart 5.x
Shoutbox
Site Identity
Slideshow
Smarty Template
Social Networking
Spam protection (Anti-bot CATPCHA)
Spellcheck
Spreadsheet
Staging and Approval
Stats
Survey
Syntax Highlighter (Codemirror)
Tablesorter
Tags 2.x
Task
Tell a Friend, alert + Social Bookmarking
Terms and Conditions
Theme
TikiTests 2.x
Timesheet
Token Access
Toolbar (Quicktags)
Trackers
TRIM
User Administration
User Files
User Menu
Watch
WebHelp
Webmail and Groupmail
WebServices 3.x
Wiki 3D
Wiki History, page rename, etc
Wiki plugins extends basic syntax
Wiki syntax text area, parser, etc
Wiki structure (book and table of content)
Workspace and perspectives 4.x
WYSIWTSN 4.x
WYSIWYCA
WYSIWYG 2.x
XMLRPC




Useful Tools