|
@@ -1,10 +1,7 @@
|
|
|
<?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$
|
|
@@ -12,118 +9,69 @@
|
|
|
* @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);
|
|
|
}
|
|
|
+
|
|
|
?>
|