Installation
============
-Go back to the main directory, run configure and add the plugin.
-
+You must configure plugin before you enable it in your SquirrelMail
+installation. Plugin's configuration is stored in
+config/bug_report_config.php or plugins/bug_report/config.php files.
+Configuration options can be found in plugins/bug_report/config_default.php
+file.
+
+If both configuration files are present, plugin uses the one in
+config/ directory.
+
+By default plugin is visible only to users listed in
+plugins/bug_report/admins or config/admins file or only to user
+that owns main SquirrelMail configuration file. Other users can use
+bug_report plugin, if you set administrator's email in plugin's
+configuration and set $bug_report_allow_users option to true.
+
+Once plugin is configured, go back to the main directory, run configure
+and enable the plugin.
Credits
=======
<?php
-
/**
* bug_report.php
*
* a button to show the bug report mail message in order to actually
* send it.
*
- * This is a standard SquirrelMail 1.2 API for plugins.
- *
* @copyright © 1999-2005 The SquirrelMail Project Team
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version $Id$
* @ignore
*/
define('SM_PATH','../../');
-
+/** load system functions */
require_once(SM_PATH . 'include/validate.php');
+/** load form functions */
+include_once(SM_PATH . 'functions/forms.php');
+/** load error_box() function */
+include_once(SM_PATH . 'functions/display_messages.php');
+/** load plugin functions */
+include_once(SM_PATH . 'plugins/bug_report/functions.php');
+
+displayPageHeader($color, 'None');
-/** is bug_report plugin disabled */
-if (! is_plugin_enabled('bug_report')) {
+/** is bug_report plugin disabled or called by wrong user */
+if (! is_plugin_enabled('bug_report') || ! bug_report_check_user()) {
error_box(_("Plugin is disabled."),$color);
echo "\n</body></html>\n";
exit();
}
-// loading form functions
-include_once(SM_PATH . 'functions/forms.php');
-
-displayPageHeader($color, 'None');
-
+/** get system specs */
include_once(SM_PATH . 'plugins/bug_report/system_specs.php');
-include_once(SM_PATH . 'plugins/bug_report/functions.php');
global $body;
-$body_top = "I subscribe to the squirrelmail-users mailing list.\n" .
+$body_top = "I am subscribed to the this mailing list.\n" .
+ " (applies when you are sending email to SquirrelMail mailing list)\n".
" [ ] True - No need to CC me when replying\n" .
" [ ] False - Please CC me when replying\n" .
"\n" .
<table align="center" border="0">
<tr>
<td>
- <?php echo _("This bug involves"); ?>: <select name="send_to">
+ <?php echo _("This bug involves:")
+ .' <select name="send_to">';
+ if (! empty($bug_report_admin_email)) {
+ // if admin's email is set - add 'report to admin' option and make it default one
+ echo '<option value="' . htmlspecialchars($bug_report_admin_email) .'" selected="selected">'
+ ._("my email account") .'</option>';
+ }
+ ?>
<option value="squirrelmail-users@lists.sourceforge.net"><?php
echo _("the general program"); ?></option>
<option value="squirrelmail-plugins@lists.sourceforge.net"><?php
</table>
</form>
<br />
-<?php
-// special forms that allow searching for bugs in mailing list and bugtracker
-echo html_tag('table',
- html_tag('tr',
- html_tag('th', _("Search Mailing List Archives"), 'center', $color[0])
- ) .
- html_tag('tr',
- html_tag('td', add_gmane_form())
- ) .
- html_tag('tr',
- html_tag('td', ' <br />')
- ) .
- html_tag('tr',
- html_tag('th', _("Search SourceForge Bugtracker"), 'center', $color[0])
- ) .
- html_tag('tr',
- html_tag('td', add_sf_bug_form())
- ), 'center', '', 'width="95%"');
-?>
</body>
</html>
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * Bug Report plugin - default configuration file
+ *
+ * This file contains default Bug Report plugin configuration options.
+ * Plugin's site configuration should be stored in config/bug_report_config.php
+ * or plugins/bug_report/config.php file.
+ *
+ * @copyright © 2005 The SquirrelMail Project Team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
+ * @version $Id$
+ * @package plugins
+ * @subpackage bug_report
+ */
+
+/**
+ * Admin email
+ * @global string $bug_report_admin_email
+ */
+$bug_report_admin_email = '';
+
+/**
+ * Controls availability of bug_report plugin to end users.
+ * If option is set to false, only interface admins can use
+ * bug_report plugin. If option is set to true and admin email
+ * is set, bug_report plugin can be used by other interface
+ * users. Information about setting administrative users can be
+ * found in plugins/bug_report/README
+ * @global boolean $bug_report_allow_users
+ */
+$bug_report_allow_users = false;
+?>
\ No newline at end of file
<?php
-
/**
* functions for bug_report plugin
*
- * functions/forms.php and functions/html.php have to be loaded before including this file.
- *
* @copyright © 2004-2005 The SquirrelMail Project Team
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version $Id$
* @subpackage bug_report
*/
-/**
- * Creates gmane search form
- *
- * Requires html v.4.0 compatible browser
- * @return string html formated form
- */
-function add_gmane_form() {
- // Start form (need target="_blank" element)
- $ret=addForm('http://search.gmane.org/search.php','get','mform');
+/** @ignore */
+if (! defined('SM_PATH')) define('SM_PATH','../../');
- // Add visible options
- $ret.=html_tag('table',
- html_tag('tr',
- html_tag('td',_("Search for words:"),'right') .
- html_tag('td',addInput('query','',50),'left')
- ) .
- html_tag('tr',
- html_tag('td',_("Written by:") . '<br />' .
- '<small>' . _("Email addresses only") . '</small>','right') .
- html_tag('td',addInput('email','',40),'left')
- ) .
- html_tag('tr',
- html_tag('td',_("Mailing list:"),'right') .
- html_tag('td',addSelect('group',array('gmane.mail.squirrelmail.user'
- => _("SquirrelMail users list"),
- 'gmane.mail.squirrelmail.plugins'
- => _("SquirrelMail plugins list"),
- 'gmane.mail.squirrelmail.devel'
- => _("SquirrelMail developers list"),
- 'gmane.mail.squirrelmail.internationalization'
- => _("SquirrelMail internationalization list"))
- ,'gmane.mail.squirrelmail.user',true),'left')
- ) .
- html_tag('tr',
- html_tag('td',_("Sort by:"),'right') .
- html_tag('td',addSelect('sort',array('date' => _("Date"),
- 'relevance' => _("Relevance"))
- ,'date',true),'left')
- ) .
- html_tag('tr',
- html_tag('td',
- '<button type="submit" name="submit" value="submit">' . _("Search Archives") . "</button>\n" .
- '<button type="reset" name="reset" value="reset">' . _("Reset Form") . "</button>\n"
- ,'center','','colspan="2"')
- ),
- 'center');
+/** Declare plugin configuration vars */
+global $bug_report_admin_email, $bug_report_allow_users;
- // Close form
- $ret.="</form>\n";
+/** Load default config */
+if (file_exists(SM_PATH . 'plugins/bug_report/config_default.php')) {
+ include_once (SM_PATH . 'plugins/bug_report/config_default.php');
+} else {
+ // default config was removed.
+ $bug_report_admin_email = '';
+ $bug_report_allow_users = false;
+}
- // Return form
- return $ret;
+/** Load site config */
+if (file_exists(SM_PATH . 'config/bug_report_config.php')) {
+ include_once (SM_PATH . 'config/bug_report_config.php');
+} elseif (file_exists(SM_PATH . 'plugins/bug_report/config.php')) {
+ include_once (SM_PATH . 'plugins/bug_report/config.php');
}
/**
- * Creates SquirrelMail SF bugtracker search form
- *
- * Requires html v.4.0 compatible browser
- * @return string html formated form
+ * Checks if user can use bug_report plugin
+ * @return boolean
+ * @since 1.5.1
*/
-function add_sf_bug_form() {
- // Start form
- $ret=addForm('http://sourceforge.net/tracker/index.php','post');
+function bug_report_check_user() {
+ global $username, $bug_report_allow_users, $bug_report_admin_email;
- // Add hidden options (some input fields are hidden from end user)
- $ret.=addHidden('group_id','311') .
- addHidden('atid','100311') .
- addHidden('set','custom') .
- addHidden('_assigned_to','0') .
- addHidden('_status','100') .
- addHidden('_category','100') .
- addHidden('_group','100') .
- addHidden('by_submitter','');
+ if (file_exists(SM_PATH . 'plugins/bug_report/admins')) {
+ $auths = file(SM_PATH . 'plugins/bug_report/admins');
+ array_walk($auths, 'bug_report_array_trim');
+ $auth = in_array($username, $auths);
+ } else if (file_exists(SM_PATH . 'config/admins')) {
+ $auths = file(SM_PATH . 'config/admins');
+ array_walk($auths, 'bug_report_array_trim');
+ $auth = in_array($username, $auths);
+ } else if (($adm_id = fileowner(SM_PATH . 'config/config.php')) &&
+ function_exists('posix_getpwuid')) {
+ $adm = posix_getpwuid( $adm_id );
+ $auth = ($username == $adm['name']);
+ } else {
+ $auth = false;
+ }
- // Add visible input fields and buttons
- $ret.=html_tag('table',
- html_tag('tr',
- html_tag('td',_("Summary keyword:"),'right') .
- html_tag('td',addInput('summary_keyword','',20,80),'left')
- ) .
- html_tag('tr',
- html_tag('td',_("Sort By:"),'right') .
- html_tag('td',
- addSelect('order',array('artifact_id' => _("ID"),
- 'priority' => _("Priority"),
- 'summary' => _("Summary"),
- 'open_date' => _("Open Date"),
- 'close_date' => _("Close Date"),
- 'submitted_by' => _("Submitter"),
- 'assigned_to' => _("Assignee")),
- 'artifact_id',true),'left')
- ) .
- html_tag('tr',
- html_tag('td',_("Order:"),'right') .
- html_tag('td',
- addSelect('sort',array('ASC'=>_("Ascending"),
- 'DESC'=>_("Descending")),
- 'DESC',true),
- 'left')
- ) .
- html_tag('tr',
- html_tag('td',
- '<button type="submit" name="submit" value="submit">' . _("Search Bugtracker") . "</button>\n" .
- '<button type="reset" name="reset" value="reset">' . _("Reset Form") . "</button>\n"
- ,'center','','colspan="2"')
- )
- ,'center');
+ if (! empty($bug_report_admin_email) && $bug_report_allow_users) {
+ $auth = true;
+ }
- // Close form
- $ret.="</form>\n";
+ return ($auth);
+}
- // Return form
- return $ret;
+/**
+ * Removes whitespace from array values
+ * @param string $value array value that has to be trimmed
+ * @param string $key array key
+ * @since 1.5.1
+ * @todo code reuse. create generic sm function.
+ * @access private
+ */
+function bug_report_array_trim(&$value,$key) {
+ $value=trim($value);
}
+
?>
\ No newline at end of file
<?php
-
/**
- * setup.php
- *
- * This is a standard SquirrelMail 1.2 API for plugins.
+ * Bug Report plugin - setup script
*
* @copyright © 1999-2005 The SquirrelMail Project Team
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @access private
*/
function bug_report_button() {
+ include_once(SM_PATH.'plugins/bug_report/functions.php');
global $bug_report_visible;
- if (! $bug_report_visible) {
+ if (! $bug_report_visible || ! bug_report_check_user()) {
return;
}
* @access private
*/
function bug_report_block() {
- global $optpage_data;
- $optpage_data['grps']['bug_report'] = _("Bug Reports");
- $optionValues = array();
- // FIXME: option needs refresh in SMOPT_REFRESH_RIGHT
- // (menulink is processed before options are saved/loaded)
- $optionValues[] = array(
- 'name' => 'bug_report_visible',
- 'caption' => _("Show button in toolbar"),
- 'type' => SMOPT_TYPE_BOOLEAN,
- 'refresh' => SMOPT_REFRESH_ALL,
- 'initial_value' => false
- );
- $optpage_data['vals']['bug_report'] = $optionValues;
+ include_once(SM_PATH.'plugins/bug_report/functions.php');
+ if (bug_report_check_user()) {
+ global $optpage_data;
+ $optpage_data['grps']['bug_report'] = _("Bug Reports");
+ $optionValues = array();
+ // FIXME: option needs refresh in SMOPT_REFRESH_RIGHT
+ // (menulink is processed before options are saved/loaded)
+ $optionValues[] = array(
+ 'name' => 'bug_report_visible',
+ 'caption' => _("Show button in toolbar"),
+ 'type' => SMOPT_TYPE_BOOLEAN,
+ 'refresh' => SMOPT_REFRESH_ALL,
+ 'initial_value' => false
+ );
+ $optpage_data['vals']['bug_report'] = $optionValues;
+ }
}
?>
\ No newline at end of file
<?php
-
/**
- * This shows system specification details.
- *
- * This is a standard SquirrelMail 1.2 API for plugins.
+ * This script shows system specification details.
*
* @copyright © 1999-2005 The SquirrelMail Project Team
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @ignore
*/
define('SM_PATH','../../');
+/** load system functions */
include_once(SM_PATH . 'include/validate.php');
+/** load error_box() function */
+include_once(SM_PATH . 'functions/display_messages.php');
+/** load plugin functions */
+include_once(SM_PATH.'plugins/bug_report/functions.php');
-/** is bug_report plugin disabled */
-if (! is_plugin_enabled('bug_report')) {
+/** is bug_report plugin disabled or called by wrong user */
+if (! is_plugin_enabled('bug_report') || ! bug_report_check_user()) {
error_box(_("Plugin is disabled."),$color);
echo "\n</body></html>\n";
exit();
<?php
-
/**
- * This gathers system specification details for use with bug reporting
+ * This script gathers system specification details for use with bug reporting
* and anyone else who needs it.
*
- * This is a standard SquirrelMail 1.2 API for plugins.
- *
* @copyright © 1999-2005 The SquirrelMail Project Team
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version $Id$