Strings update
[squirrelmail.git] / functions / plugin.php
CommitLineData
7b086a80 1<?php
2
35586184 3/**
4 * plugin.php
5 *
6 * Copyright (c) 1999-2001 The SquirrelMail Development Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
8 *
9 * This file provides the framework for a plugin architecture.
10 *
11 * Documentation on how to write plugins might show up some time.
12 *
13 * $Id$
14 */
15
16/*****************************************************************/
17/*** THIS FILE NEEDS TO HAVE ITS FORMATTING FIXED!!! ***/
18/*** PLEASE DO SO AND REMOVE THIS COMMENT SECTION. ***/
19/*** + Base level indent should begin at left margin, as ***/
0a17ec32 20/*** the first line of the function definition below. ***/
35586184 21/*** + All identation should consist of four space blocks ***/
22/*** + Tab characters are evil. ***/
23/*** + all comments should use "slash-star ... star-slash" ***/
24/*** style -- no pound characters, no slash-slash style ***/
25/*** + FLOW CONTROL STATEMENTS (if, while, etc) SHOULD ***/
26/*** ALWAYS USE { AND } CHARACTERS!!! ***/
27/*** + Please use ' instead of ", when possible. Note " ***/
28/*** should always be used in _( ) function calls. ***/
29/*** Thank you for your help making the SM code more readable. ***/
30/*****************************************************************/
31
32global $squirrelmail_plugin_hooks;
0a17ec32 33$squirrelmail_plugin_hooks = array();
2d367c68 34
35 // This function adds a plugin
36 function use_plugin ($name) {
37
38 if (file_exists('../plugins/'.$name.'/setup.php')) {
39 include_once('../plugins/'.$name.'/setup.php');
40 $function = 'squirrelmail_plugin_init_'.$name;
dd389be5 41 if (function_exists($function)) {
2d367c68 42 $function();
43 }
44 }
45
46 }
47
48 // This function executes a hook
49 function do_hook ($name) {
50 global $squirrelmail_plugin_hooks;
51 $Data = func_get_args();
52 if (isset($squirrelmail_plugin_hooks[$name]) &&
53 is_array($squirrelmail_plugin_hooks[$name])) {
54 foreach ($squirrelmail_plugin_hooks[$name] as $function) {
55 // Add something to set correct gettext domain for plugin
56 if (function_exists($function)) {
57 $function($Data);
58 }
dd389be5 59 }
2d367c68 60 }
61
62 // Variable-length argument lists have a slight problem when
63 // passing values by reference. Pity. This is a workaround.
64 return $Data;
65 }
7b086a80 66
2d367c68 67 /* -------------------- MAIN --------------------- */
7b086a80 68
2d367c68 69 // On startup, register all plugins configured for use
70 if (isset($plugins) && is_array($plugins)) {
71 foreach ($plugins as $name) {
72 use_plugin($name);
73 }
74 }
076c01d7 75
35586184 76?>