Added newmail dropdowns, and preparing for special folders only count mails.
[squirrelmail.git] / functions / plugin.php
CommitLineData
7b086a80 1<?php
2
35586184 3/**
4 * plugin.php
5 *
0606ca1f 6 * Copyright (c) 1999-2002 The SquirrelMail Project Team
35586184 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
35586184 16global $squirrelmail_plugin_hooks;
0a17ec32 17$squirrelmail_plugin_hooks = array();
2d367c68 18
0606ca1f 19/* This function adds a plugin. */
20function use_plugin ($name) {
21 if (file_exists("../plugins/$name/setup.php")) {
22 include_once("../plugins/$name/setup.php");
23 $function = "squirrelmail_plugin_init_$name";
24 if (function_exists($function)) {
25 $function();
2d367c68 26 }
2d367c68 27 }
0606ca1f 28}
2d367c68 29
0606ca1f 30/* This function executes a hook. */
2586d588 31function do_hook ($name,$parm=NULL) {
0606ca1f 32 global $squirrelmail_plugin_hooks;
33 $data = func_get_args();
2586d588 34 $ret = '';
a3439b27 35
0606ca1f 36 if (isset($squirrelmail_plugin_hooks[$name])
37 && is_array($squirrelmail_plugin_hooks[$name])) {
38 foreach ($squirrelmail_plugin_hooks[$name] as $function) {
39 /* Add something to set correct gettext domain for plugin. */
40 if (function_exists($function)) {
2586d588 41 $ret = $function($data,$parm);
dd389be5 42 }
2d367c68 43 }
2d367c68 44 }
7b086a80 45
0606ca1f 46 /* Variable-length argument lists have a slight problem when */
47 /* passing values by reference. Pity. This is a workaround. */
2586d588 48 return $ret;
0606ca1f 49}
7b086a80 50
0606ca1f 51/*************************************/
52/*** MAIN PLUGIN LOADING CODE HERE ***/
53/*************************************/
54
55/* On startup, register all plugins configured for use. */
56if (isset($plugins) && is_array($plugins)) {
57 foreach ($plugins as $name) {
58 use_plugin($name);
2d367c68 59 }
0606ca1f 60}
076c01d7 61
2e994d27 62 /**
63 * This function checks whether the user's USER_AGENT is known to
64 * be broken. If so, returns true and the plugin is invisible to the
65 * offending browser.
66 */
67 function soupNazi(){
68
69 global $HTTP_USER_AGENT, $SQSPELL_SOUP_NAZI;
70
71 require_once('../plugins/squirrelspell/sqspell_config.php');
72
73 $soup_menu = explode( ',', $SQSPELL_SOUP_NAZI );
74 return( in_array( trim( $HTTP_USER_AGENT ), $soup_menu ) );
75 }
76
77?>