ba2c2f352863b4cf6b1da3ea582dac676e898066
3 * functions for bug_report plugin
5 * @copyright © 2004-2007 The SquirrelMail Project Team
6 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
9 * @subpackage bug_report
14 * do not allow to call this file directly
16 if (isset($_SERVER['SCRIPT_FILENAME']) && $_SERVER['SCRIPT_FILENAME'] == __FILE__
) {
17 header("Location: ../../src/login.php");
21 /** Declare plugin configuration vars */
22 global $bug_report_admin_email, $bug_report_allow_users;
24 /** Load default config */
25 if (file_exists(SM_PATH
. 'plugins/bug_report/config_default.php')) {
26 include_once (SM_PATH
. 'plugins/bug_report/config_default.php');
28 // default config was removed.
29 $bug_report_admin_email = '';
30 $bug_report_allow_users = false;
33 /** Load site config */
34 if (file_exists(SM_PATH
. 'config/bug_report_config.php')) {
35 include_once (SM_PATH
. 'config/bug_report_config.php');
36 } elseif (file_exists(SM_PATH
. 'plugins/bug_report/config.php')) {
37 include_once (SM_PATH
. 'plugins/bug_report/config.php');
41 * Checks if user can use bug_report plugin
45 function bug_report_check_user() {
46 global $username, $bug_report_allow_users, $bug_report_admin_email;
48 if (file_exists(SM_PATH
. 'plugins/bug_report/admins')) {
49 $auths = file(SM_PATH
. 'plugins/bug_report/admins');
50 array_walk($auths, 'bug_report_array_trim');
51 $auth = in_array($username, $auths);
52 } else if (file_exists(SM_PATH
. 'config/admins')) {
53 $auths = file(SM_PATH
. 'config/admins');
54 array_walk($auths, 'bug_report_array_trim');
55 $auth = in_array($username, $auths);
56 } else if (($adm_id = fileowner(SM_PATH
. 'config/config.php')) &&
57 function_exists('posix_getpwuid')) {
58 $adm = posix_getpwuid( $adm_id );
59 $auth = ($username == $adm['name']);
64 if (! empty($bug_report_admin_email) && $bug_report_allow_users) {
72 * Removes whitespace from array values
73 * @param string $value array value that has to be trimmed
74 * @param string $key array key
76 * @todo code reuse. create generic sm function.
79 function bug_report_array_trim(&$value,$key) {