copyright update
[squirrelmail.git] / plugins / bug_report / functions.php
1 <?php
2 /**
3 * functions for bug_report plugin
4 *
5 * @copyright &copy; 2004-2006 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 /** @ignore */
13 if (! defined('SM_PATH')) define('SM_PATH','../../');
14
15 /** Declare plugin configuration vars */
16 global $bug_report_admin_email, $bug_report_allow_users;
17
18 /** Load default config */
19 if (file_exists(SM_PATH . 'plugins/bug_report/config_default.php')) {
20 include_once (SM_PATH . 'plugins/bug_report/config_default.php');
21 } else {
22 // default config was removed.
23 $bug_report_admin_email = '';
24 $bug_report_allow_users = false;
25 }
26
27 /** Load site config */
28 if (file_exists(SM_PATH . 'config/bug_report_config.php')) {
29 include_once (SM_PATH . 'config/bug_report_config.php');
30 } elseif (file_exists(SM_PATH . 'plugins/bug_report/config.php')) {
31 include_once (SM_PATH . 'plugins/bug_report/config.php');
32 }
33
34 /**
35 * Checks if user can use bug_report plugin
36 * @return boolean
37 * @since 1.5.1
38 */
39 function bug_report_check_user() {
40 global $username, $bug_report_allow_users, $bug_report_admin_email;
41
42 if (file_exists(SM_PATH . 'plugins/bug_report/admins')) {
43 $auths = file(SM_PATH . 'plugins/bug_report/admins');
44 array_walk($auths, 'bug_report_array_trim');
45 $auth = in_array($username, $auths);
46 } else if (file_exists(SM_PATH . 'config/admins')) {
47 $auths = file(SM_PATH . 'config/admins');
48 array_walk($auths, 'bug_report_array_trim');
49 $auth = in_array($username, $auths);
50 } else if (($adm_id = fileowner(SM_PATH . 'config/config.php')) &&
51 function_exists('posix_getpwuid')) {
52 $adm = posix_getpwuid( $adm_id );
53 $auth = ($username == $adm['name']);
54 } else {
55 $auth = false;
56 }
57
58 if (! empty($bug_report_admin_email) && $bug_report_allow_users) {
59 $auth = true;
60 }
61
62 return ($auth);
63 }
64
65 /**
66 * Removes whitespace from array values
67 * @param string $value array value that has to be trimmed
68 * @param string $key array key
69 * @since 1.5.1
70 * @todo code reuse. create generic sm function.
71 * @access private
72 */
73 function bug_report_array_trim(&$value,$key) {
74 $value=trim($value);
75 }
76
77 ?>