TUTOSMain Page | About | Help | FAQ | Special pages | Log in
The Free Knowledgebase
Printable version | Disclaimers | Privacy policy

Hook function

From TUTOS

While running TUTOS will call customizable hook functions at various points in time. You can use and run whatever php allows here. The functions will be called with the object as the one and only arguement.

Contents

Types of hooks

Currently TUTOS knows about these types of hooks.

presave

Run before saving.

postsave

Run after saving.

postdel

Run after an object is deleted. A good place to inform external objects about the deletion.

check

Called when submitting data to the database. A good chance to bounce back when unsatisfied with users input.

afterread

Called after reading in data from the database.

postinit

Run after initializing an object. Here is a good place to preset data. This hooks are stored in the $tutos['postinit-hooks'][OBJECTTYPENAME] array.

Example

Preset all projectnames with PLEASE USE OFFICIAL PROJECTNUMBER and always set a version number.

To do so add the following lines in config.php

function hook1($obj) {
	$obj->name = 'PLEASE USE OFFICIAL PROJECTNUMBER';
}
$tutos['postinit-hooks']['product'][] = 'hook1';

function hook2($obj) {
	$msg = '';
	if ($obj->version == '') {
		$obj->version = '1';
		$msg = 'automated version correction';
	}
	return $msg;
}
$tutos['presave-hooks']['product'][] = 'hook2';

Notice

This feature started with version after 1.5.20090629 and is still under development (i.e. not all objects and situations are supported)

Retrieved from "http://wiki.tutos.org/index.php/Hook_function"

This page has been accessed 475 times. This page was last modified on 23 October 2009, at 14:20.
Content is available under GNU Free Documentation License 1.2.


Find

Browse
Main Page
Recent changes
Random page
Help
sitesupport
Edit
View source
Editing help
This page
Discuss this page
New section
Printable version
Context
Page history
What links here
Related changes
My pages
Log in / create account
Special pages
New pages
File list
Statistics
More...