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 (isset($HTTP_SERVER_SERVER['SCRIPT_FILENAME']) && $HTTP_SERVER_SERVER['SCRIPT_FILENAME'] == __FILE__
) ) {
18 header("Location: ../../src/login.php");
22 /** Declare plugin configuration vars */
23 global $bug_report_admin_email, $bug_report_allow_users;
25 /** Load default config */
26 if (file_exists(SM_PATH
. 'plugins/bug_report/config_default.php')) {
27 include_once (SM_PATH
. 'plugins/bug_report/config_default.php');
29 // default config was removed.
30 $bug_report_admin_email = '';
31 $bug_report_allow_users = false;
34 /** Load site config */
35 if (file_exists(SM_PATH
. 'config/bug_report_config.php')) {
36 include_once (SM_PATH
. 'config/bug_report_config.php');
37 } elseif (file_exists(SM_PATH
. 'plugins/bug_report/config.php')) {
38 include_once (SM_PATH
. 'plugins/bug_report/config.php');
42 * Checks if user can use bug_report plugin
46 function bug_report_check_user() {
47 global $username, $bug_report_allow_users, $bug_report_admin_email;
49 if (file_exists(SM_PATH
. 'plugins/bug_report/admins')) {
50 $auths = file(SM_PATH
. 'plugins/bug_report/admins');
51 array_walk($auths, 'bug_report_array_trim');
52 $auth = in_array($username, $auths);
53 } else if (file_exists(SM_PATH
. 'config/admins')) {
54 $auths = file(SM_PATH
. 'config/admins');
55 array_walk($auths, 'bug_report_array_trim');
56 $auth = in_array($username, $auths);
57 } else if (($adm_id = fileowner(SM_PATH
. 'config/config.php')) &&
58 function_exists('posix_getpwuid')) {
59 $adm = posix_getpwuid( $adm_id );
60 $auth = ($username == $adm['name']);
65 if (! empty($bug_report_admin_email) && $bug_report_allow_users) {
73 * Removes whitespace from array values
74 * @param string $value array value that has to be trimmed
75 * @param string $key array key
77 * @todo code reuse. create generic sm function.
80 function bug_report_array_trim(&$value,$key) {