Remove hook call from template; fix all corresponding core plugins.
[squirrelmail.git] / plugins / bug_report / setup.php
1 <?php
2 /**
3 * Bug Report plugin - setup script
4 *
5 * @copyright &copy; 1999-2007 The SquirrelMail Project Team
6 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
7 * @version $Id$
8 * @package plugins
9 * @subpackage bug_report
10 */
11
12 /**
13 * Initialize the bug report plugin
14 * @return void
15 * @access private
16 */
17 function squirrelmail_plugin_init_bug_report() {
18 global $squirrelmail_plugin_hooks;
19
20 $squirrelmail_plugin_hooks['template_construct_page_header.tpl']['bug_report'] = 'bug_report_button';
21 $squirrelmail_plugin_hooks['loading_prefs']['bug_report'] = 'bug_report_load';
22 $squirrelmail_plugin_hooks['optpage_loadhook_display']['bug_report'] = 'bug_report_block';
23 }
24
25
26 /**
27 * Show the button in the main bar
28 * @access private
29 */
30 function bug_report_button() {
31 include_once(SM_PATH.'plugins/bug_report/functions.php');
32 global $bug_report_visible;
33
34 if (! $bug_report_visible || ! bug_report_check_user()) {
35 return;
36 }
37
38 global $oTemplate;
39 $nbsp = $oTemplate->fetch('non_breaking_space.tpl');
40 $output = makeInternalLink('plugins/bug_report/bug_report.php', _("Bug"), '')
41 . $nbsp . $nbsp;
42 return array('menuline' => $output);
43 }
44
45 /**
46 * Loads bug report options
47 * @access private
48 */
49 function bug_report_load() {
50 global $username, $data_dir;
51 global $bug_report_visible;
52
53 $bug_report_visible = (bool) getPref($data_dir, $username, 'bug_report_visible',false);
54 }
55
56 /**
57 * Register bug report option block
58 * @since 1.5.1
59 * @access private
60 */
61 function bug_report_block() {
62 include_once(SM_PATH.'plugins/bug_report/functions.php');
63 if (bug_report_check_user()) {
64 global $optpage_data;
65 $optpage_data['grps']['bug_report'] = _("Bug Reports");
66 $optionValues = array();
67 // FIXME: option needs refresh in SMOPT_REFRESH_RIGHT
68 // (menulink is processed before options are saved/loaded)
69 $optionValues[] = array(
70 'name' => 'bug_report_visible',
71 'caption' => _("Show button in toolbar"),
72 'type' => SMOPT_TYPE_BOOLEAN,
73 'refresh' => SMOPT_REFRESH_ALL,
74 'initial_value' => false
75 );
76 $optpage_data['vals']['bug_report'] = $optionValues;
77 }
78 }