Added sent_subfolders plugin, tweaked config stuff, other stuff.
[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
a3439b27 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;
a3439b27 51 $data = func_get_args();
52
53 if (isset($squirrelmail_plugin_hooks[$name])
54 && is_array($squirrelmail_plugin_hooks[$name])) {
2d367c68 55 foreach ($squirrelmail_plugin_hooks[$name] as $function) {
56 // Add something to set correct gettext domain for plugin
57 if (function_exists($function)) {
a3439b27 58 $function($data);
2d367c68 59 }
dd389be5 60 }
2d367c68 61 }
62
63 // Variable-length argument lists have a slight problem when
64 // passing values by reference. Pity. This is a workaround.
65 return $Data;
66 }
7b086a80 67
2d367c68 68 /* -------------------- MAIN --------------------- */
7b086a80 69
2d367c68 70 // On startup, register all plugins configured for use
71 if (isset($plugins) && is_array($plugins)) {
72 foreach ($plugins as $name) {
73 use_plugin($name);
74 }
75 }
076c01d7 76
35586184 77?>