View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0004286 | Plugin - EmailReporting | General | public | 2004-08-06 09:51 | 2016-07-21 15:17 |
Reporter | indy | Assigned To | SL-Gundam | ||
Priority | normal | Severity | feature | Reproducibility | N/A |
Status | closed | Resolution | fixed | ||
Summary | 0004286: Solution for reporting via E-Mail | ||||
Description | Maybe somebody is interested in, I have written a script for receiving bug reports through a POP3 E-Mail account. | ||||
Tags | admin, email | ||||
Attached Files | mantis-working.patch (23,038 bytes)
diff -rNu mantis.orig/README.bug_report_mail mantis/README.bug_report_mail --- mantis.orig/README.bug_report_mail Thu Jan 1 01:00:00 1970 +++ mantis/README.bug_report_mail Mon Aug 9 23:26:21 2004 @@ -0,0 +1,54 @@ +The current version of bug_report_mail only support plain text e-mails +and POP3 Mailaccounts with PEAR's Net_POP3 packge. + +bug_report_mail is able to recognize if mail is a reply to an already opened +bug and adds the content as a bugnote. + +If you are alway running Mantis you have to alter you projects table +with the sql/bug_report_mail.sql script. +If not, you can create the database tables in the way described in +the doc/INSTALL file. + +This patch changes the following files: + core/user_api.php + manage_proj_edit_page.php + config_inc.php.sample +These files are new: + core/mail_api.php + sql/bug_report_mail.php + bug_report_mail.php + manage_proj_mail_delete.php + manage_proj_mail_update.php + +After installing this patch, you can add a POP3 server's hostname +and authentication data for each of your projects with the +project edit form. + +There are two ways to receive mail with bug_report_mail: +The secure way is to use a standard reporting user: +You have to create a reporter account, for example 'Mail'. +The name for this reporter account you have to write in your config_inc.php file: + $g_mail_reporter = "Mail"; +and then, bug_report_mail must be informed to behave like this: + $g_mail_use_reporter = ON; + +The other way is to signup new user accounts automatically. +For using this, you have to change this + $g_mail_auto_signup = OFF; +from OFF to ON. +Now, bug_report_mail will look for an user named like the mail's sender +or an user which mail adress is identical. +If no user is found, then a new account will be created. +The new user's name will be the mail address. + +This could be used for attacks, but there is no other way in the moment. + +After this, bug_report_mail can be used via cron like this: + +*/5 * * * * lynx --dump http://mantis.homepage.com/bug_report_mail.php + +This line uses lynx to fetch bug reports from via POP3 every 5 minutes. + +This addon is distributed under the same condition as Mantis itself. + +Gerrit Beine, August 2004 diff -rNu mantis.orig/bug_report_mail.php mantis/bug_report_mail.php --- mantis.orig/bug_report_mail.php Thu Jan 1 01:00:00 1970 +++ mantis/bug_report_mail.php Mon Aug 9 23:24:27 2004 @@ -0,0 +1,37 @@ +<?php + # Mantis - a php based bugtracking system + # Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org + # Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net + # This program is distributed under the terms and conditions of the GPL + # See the README and LICENSE files for details + # Copyright (C) 2004 Gerrit Beine - gerrit.beine@pitcom.de + # Copyright (C) 2004 pitcom GmbH, Plauen, Germany + + # -------------------------------------------------------- + # $Id$ + # -------------------------------------------------------- +?> +<?php + # This page receives an E-Mail via POP3 and generates an Report + header("Content-type: text/plain"); +?> +<?php + require_once( 'core.php' ); + + $t_core_path = config_get( 'core_path' ); + + require_once( $t_core_path.'string_api.php' ); + require_once( $t_core_path.'bug_api.php' ); + require_once( $t_core_path.'mail_api.php' ); +?> +<?php + $t_projects = mail_project_get_all_rows(); + foreach ($t_projects as $t_project) { + $t_mails = mail_get_all_mails($t_project); + foreach ($t_mails as $t_mail) + { + mail_add_bug($t_mail, $t_project); + } + } +?> + diff -rNu mantis.orig/config_inc.php mantis/config_inc.php --- mantis.orig/config_inc.php Thu Jan 1 01:00:00 1970 +++ mantis/config_inc.php Mon Aug 9 22:27:31 2004 @@ -0,0 +1,78 @@ +<?php + # Mantis - a php based bugtracking system + # Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org + # Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net + # This program is distributed under the terms and conditions of the GPL + # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id: config_inc.php.sample,v 1.12 2004/02/08 13:16:57 vboctor Exp $ + # -------------------------------------------------------- + + # This sample file contains the essential files that you MUST + # configure to your specific settings. You may override settings + # from config_defaults_inc.php by assigning new values in this file + + # Rename this file to config_inc.php after configuration. + + ########################################################################### + # CONFIGURATION VARIABLES + ########################################################################### + + # In general the value OFF means the feature is disabled and ON means the + # feature is enabled. Any other cases will have an explanation. + + # Look in http://www.mantisbt.org/manual or config_defaults_inc.php for more + # detailed comments. + + # --- database variables --------- + + # set these values to match your setup + $g_hostname = "localhost"; + $g_port = 3306; # 3306 is default + $g_db_username = "root"; + $g_db_password = "root"; + $g_database_name = "mantis"; + + # --- email variables ------------- + $g_administrator_email = 'administrator@example.com'; + $g_webmaster_email = 'webmaster@example.com'; + + # the "From: " field in emails + $g_from_email = 'noreply@example.com'; + + # the "To: " address all emails are sent. This can be a mailing list or archive address. + # Actual users are emailed via the bcc: fields + $g_to_email = 'nobody@example.com'; + + # the return address for bounced mail + $g_return_path_email = 'admin@example.com'; + + # --- login method ---------------- + # CRYPT or PLAIN or MD5 or LDAP or BASIC_AUTH + $g_login_method = MD5; + + # --- email vars ------------------ + # set to OFF to disable email check + # These should be OFF for Windows installations + $g_validate_email = OFF; + $g_check_mx_record = OFF; + + # --- file upload settings -------- + # This is the master setting to disable *all* file uploading functionality + # + # The default value is ON but you must make sure file uploading is enabled + # in PHP as well. You may need to add "file_uploads = TRUE" to your php.ini. + $g_allow_file_upload = ON; + + # --- mail reporting settings ----- + # This tells Mantis to report all the Mail with only one account + $g_mail_use_reporter = OFF; + + # The account's name for mail reporting + $g_mail_reporter = 'Mail'; + + # Signup new users automatically (possible security risk!) + # Default is OFF, only works if mail_use_reporter is OFF + $g_mail_auto_signup = ON; +?> diff -rNu mantis.orig/config_inc.php.sample mantis/config_inc.php.sample --- mantis.orig/config_inc.php.sample Sun Feb 8 14:16:56 2004 +++ mantis/config_inc.php.sample Mon Aug 9 18:32:00 2004 @@ -64,4 +64,15 @@ # The default value is ON but you must make sure file uploading is enabled # in PHP as well. You may need to add "file_uploads = TRUE" to your php.ini. $g_allow_file_upload = ON; + + # --- mail reporting settings ----- + # This tells Mantis to report all the Mail with only one account + $g_mail_use_reporter = ON; + + # The account's name for mail reporting + $g_mail_reporter = 'Mail'; + + # Signup new users automatically (possible security risk!) + # Default is OFF, only works if mail_use_reporter is OFF + $g_mail_auto_signup = OFF; ?> diff -rNu mantis.orig/core/mail_api.php mantis/core/mail_api.php --- mantis.orig/core/mail_api.php Thu Jan 1 01:00:00 1970 +++ mantis/core/mail_api.php Mon Aug 9 23:22:29 2004 @@ -0,0 +1,212 @@ +<?php + # Mantis - a php based bugtracking system + # Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net + # This program is distributed under the terms and conditions of the GPL + # See the README and LICENSE files for details + # Copyright (C) 2004 Gerrit Beine - gerrit.beine@pitcom.de + # Copyright (C) 2004 pitcom GmbH, Plauen, Germany + + # -------------------------------------------------------- + # $Id$ + # -------------------------------------------------------- + + $t_core_dir = dirname( __FILE__ ).DIRECTORY_SEPARATOR; + + require_once( $t_core_dir . 'bug_api.php' ); + require_once( $t_core_dir . 'bugnote_api.php' ); + require_once( $t_core_dir . 'user_api.php' ); + require_once( $t_core_dir . 'project_api.php' ); +?> +<?php + # This page receives an E-Mail via POP3 and generates an Report +?> +<?php + require_once( 'Net/POP3.php' ); + + # -------------------- + # Update the mail account data + function mail_update( $p_project_id, $p_pop3_host, $p_pop3_user, $p_pop3_pass ) { + $c_project_id = db_prepare_int( $p_project_id ); + $c_pop3_host = db_prepare_string( $p_pop3_host ); + $c_pop3_user = db_prepare_string( $p_pop3_user ); + $c_pop3_pass = db_prepare_string( $p_pop3_pass ); + + $t_project_table = config_get( 'mantis_project_table' ); + + $query = "UPDATE $t_project_table + SET pop3_host='$c_pop3_host', + pop3_user='$c_pop3_user', + pop3_pass='$c_pop3_pass' + WHERE id='$c_project_id'"; + db_query( $query ); + return true; + } + + # -------------------- + # Removes the mail account data + function mail_delete( $p_project_id ) { + $c_project_id = db_prepare_int( $p_project_id ); + + $t_project_table = config_get( 'mantis_project_table' ); + + $query = "UPDATE $t_project_table + SET pop3_host=NULL, + pop3_user=NULL, + pop3_pass=NULL + WHERE id='$c_project_id'"; + db_query( $query ); + return true; + } + + #=================================== + # Data Access + #=================================== + + # -------------------- + # Return all versions for the specified project + function mail_get_account_data( $p_project_id ) { + $c_project_id = db_prepare_int( $p_project_id ); + + $t_project_table = config_get( 'mantis_project_table' ); + + $query = "SELECT pop3_host, pop3_user, pop3_pass + FROM $t_project_table + WHERE id='$c_project_id'"; + $result = db_query( $query ); + + return db_fetch_array( $result ); + } + + # -------------------- + # return all projects with valid data for mail access + # return an empty array if there are no such projects + function mail_project_get_all_rows() { + $m_projects = array(); + $t_projects = project_get_all_rows(); + foreach ($t_projects as $t_project) { + if ($t_project['pop3_host']) { + array_push($m_projects, $t_project); + } + } + return $m_projects; + } + + # -------------------- + # return all mails for a project + # return an empty array if there are no new mails + function mail_get_all_mails($p_project) { + $t_mails = array(); + $pop3 = &new Net_POP3(); + $t_pop3_host = $p_project['pop3_host']; + $t_pop3_user = $p_project['pop3_user']; + $t_pop3_password = $p_project['pop3_pass']; + $pop3->connect($t_pop3_host, 110); + $pop3->login($t_pop3_user, $t_pop3_password); + for ($i = 1; $i <= $pop3->numMsg(); $i++) { + $mail = $pop3->getParsedHeaders($i); + $mail['X-Mantis-Body'] = $pop3->getBody($i); + $mail['X-Mantis-Complete'] = $pop3->getMsg($i); + array_push($t_mails, $mail); + $pop3->deleteMsg($i); + } + $pop3->disconnect(); + return $t_mails; + } + + # -------------------- + # return the a valid username from an email address + function mail_user_name_from_address ($p_mailaddress) { + $t_mailaddress = $p_mailaddress; + if (preg_match("/<(.*?)>/", $p_mailaddress, $matches)) { + $t_mailaddress = $matches[1]; + } + return preg_replace("/[@\.-]/",'_',$t_mailaddress); + } + + # -------------------- + # return true if there is a valid mantis bug referernce in subject + function mail_is_a_bugnote ($p_subject) { + return preg_match("/\[([A-Za-z0-9-_\.]*\s[0-9]{7})\]/", $p_subject); + } + + # -------------------- + # return the bug's id from the subject + function mail_get_bug_id_from_subject ($p_subject) { + preg_match("/\[([A-Za-z0-9-_\.]*\s([0-9]{7}?))\]/", $p_subject, $matches); + return $matches[2]; + } + # -------------------- + # return the user id for the mail reporting user + # return false if no username can be found + function mail_get_user ($p_mail) { + $t_mail_use_reporter = config_get( 'mail_use_reporter' ); + $t_mail_auto_signup = config_get( 'mail_auto_signup' ); + if ($t_mail_use_reporter) { + $t_mail_reporter = config_get( 'mail_reporter' ); + $t_reporter_id = user_get_id_by_name($t_mail_reporter); + } + else { + $t_user_name = mail_user_name_from_address($p_mail['From']); + $t_reporter_id = user_get_id_by_name($t_user_name); + if (!$t_reporter_id) { // try to get the user's id searching for mail address + $t_reporter_id = user_get_id_by_mail($p_mail['From']); + } + if (!$t_reporter_id && $t_mail_auto_signup) { // try to signup the user + user_signup($t_user_name, $p_mail['From']); + $t_reporter_id = user_get_id_by_name($t_user_name); + } + } + return $t_reporter_id; + } + + # -------------------- + # Adds a bug reported via email + # Todo: If there is already a bug, add it as a bug note + function mail_add_bug($p_mail, $p_project) { + $f_build = gpc_get_string( 'build', '' ); + $f_platform = gpc_get_string( 'platform', '' ); + $f_os = gpc_get_string( 'os', '' ); + $f_os_build = gpc_get_string( 'os_build', '' ); + $f_product_version = gpc_get_string( 'product_version', '' ); + $f_profile_id = gpc_get_int( 'profile_id', 0 ); + $f_handler_id = gpc_get_int( 'handler_id', 0 ); + $f_view_state = gpc_get_int( 'view_state', 0 ); + + $f_category = gpc_get_string( 'category', '' ); + $f_priority = gpc_get_int( 'priority', NORMAL ); + $f_steps_to_reproduce = gpc_get_string( 'steps_to_reproduce', '' ); + + $f_reproducibility = 10; + $f_severity = 50; + $f_summary = $p_mail['Subject']; + $f_description = $p_mail['X-Mantis-Body']; + $f_additional_info = $p_mail['X-Mantis-Complete']; + $f_project_id = $p_project['id']; + $t_reporter_id = mail_get_user($p_mail); + + if (mail_is_a_bugnote($p_mail['Subject'])) + { + # Add a bug note + $t_bug_id = mail_get_bug_id_from_subject($p_mail['Subject']); + bugnote_add ( $t_bug_id, $p_mail['X-Mantis-Body'] ); + email_bugnote_add ( $t_bug_id ); + } + else + { + # Create the bug + $t_bug_id = bug_create( $f_project_id, + $t_reporter_id, $f_handler_id, + $f_priority, + $f_severity, $f_reproducibility, + $f_category, + $f_os, $f_os_build, + $f_platform, $f_product_version, + $f_build, + $f_profile_id, $f_summary, $f_view_state, + $f_description, $f_steps_to_reproduce, $f_additional_info ); + email_new_bug( $t_bug_id ); + } + + } + +?> diff -rNu mantis.orig/core/user_api.php mantis/core/user_api.php --- mantis.orig/core/user_api.php Sun Jan 11 08:16:10 2004 +++ mantis/core/user_api.php Sun Aug 8 20:08:38 2004 @@ -413,6 +413,26 @@ } # -------------------- + # get a user id from an mail address + # return false if the mail address does not exist + function user_get_id_by_mail( $p_mailadress ) { + $c_mailadress = db_prepare_string( $p_mailadress ); + + $t_user_table = config_get( 'mantis_user_table' ); + + $query = "SELECT id + FROM $t_user_table + WHERE email='$c_mailadress'"; + $result = db_query( $query ); + + if ( 0 == db_num_rows( $result ) ) { + return false; + } else { + return db_result( $result ); + } + } + + # -------------------- # return all data associated with a particular user name # return false if the username does not exist function user_get_row_by_name( $p_username ) { diff -rNu mantis.orig/manage_proj_edit_page.php mantis/manage_proj_edit_page.php --- mantis.orig/manage_proj_edit_page.php Sun Jan 11 08:16:06 2004 +++ mantis/manage_proj_edit_page.php Mon Aug 9 21:37:44 2004 @@ -18,6 +18,7 @@ require_once( $t_core_path . 'version_api.php' ); require_once( $t_core_path . 'custom_field_api.php' ); require_once( $t_core_path . 'icon_api.php' ); + require_once( $t_core_path . 'mail_api.php' ); ?> <?php $f_project_id = gpc_get_int( 'project_id' ); @@ -25,6 +26,7 @@ access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id ); $row = project_get_row( $f_project_id ); + $mail = mail_get_account_data( $f_project_id ); ?> <?php html_page_top1() ?> <?php html_page_top2() ?> @@ -524,6 +526,57 @@ } # end for ?> </table> +</div> + +<!-- MAIL ACCOUNT RESET --> +<br /> +<div align="center"> + <form method="post" action="manage_proj_mail_update.php"> + <input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" /> + <table class="width75" cellspacing="1"> + <tr> + <td class="form-title" colspan="4"> + <?php echo 'Mail Account Settings' ?> + </td> + </tr> + <tr class="row-1"> + <td class="category" width="25%"> + <?php echo "POP3 Host"?> + </td> + <td width="75%"> + <input type="text" name="pop3_host" size="64" maxlength="255" value="<?php echo string_attribute( $mail['pop3_host'] ) ?>" /> + </td> + </tr> + <tr class="row-1"> + <td class="category" width="25%"> + <?php echo "POP3 User"?> + </td> + <td width="75%"> + <input type="text" name="pop3_user" size="64" maxlength="255" value="<?php echo string_attribute( $mail['pop3_user'] ) ?>" /> + </td> + </tr> + <tr class="row-1"> + <td class="category" width="25%"> + <?php echo "POP3 Password"?> + </td> + <td width="75%"> + <input type="text" name="pop3_pass" size="64" maxlength="255" value="<?php echo string_attribute( $mail['pop3_pass'] ) ?>" /> + </td> + </tr> + <tr> + <td colspan="2"> + <input type="submit" value="<?php echo 'Set Mail Account Data' ?>" /> + </td> + </tr> + </table> + </form> +</div> +<!-- MAIL ACCOUNT RESET --> +<div class="border-center"> + <form method="post" action="manage_proj_mail_delete.php"> + <input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" /> + <input type="submit" value="<?php echo 'Delete Mail Account Data' ?>" /> + </form> </div> <?php html_page_bottom1( __FILE__ ) ?> diff -rNu mantis.orig/manage_proj_mail_delete.php mantis/manage_proj_mail_delete.php --- mantis.orig/manage_proj_mail_delete.php Thu Jan 1 01:00:00 1970 +++ mantis/manage_proj_mail_delete.php Mon Aug 9 21:25:02 2004 @@ -0,0 +1,45 @@ +<?php + # Mantis - a php based bugtracking system + # Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org + # Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net + # This program is distributed under the terms and conditions of the GPL + # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id$ + # -------------------------------------------------------- +?> +<?php + require_once( 'core.php' ); + + $t_core_path = config_get( 'core_path' ); + + require_once( $t_core_path.'mail_api.php' ); +?> +<?php + $f_project_id = gpc_get_int( 'project_id' ); + + access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id ); + + mail_delete( $f_project_id ); + + $t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $f_project_id; +?> +<?php + html_page_top1(); + + html_meta_redirect( $t_redirect_url ); + + html_page_top2(); +?> + +<br /> +<div align="center"> +<?php + echo lang_get( 'operation_successful' ) . '<br />'; + + print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) ); +?> +</div> + +<?php html_page_bottom1( __FILE__ ) ?> diff -rNu mantis.orig/manage_proj_mail_update.php mantis/manage_proj_mail_update.php --- mantis.orig/manage_proj_mail_update.php Thu Jan 1 01:00:00 1970 +++ mantis/manage_proj_mail_update.php Mon Aug 9 21:35:44 2004 @@ -0,0 +1,60 @@ +<?php + # Mantis - a php based bugtracking system + # Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org + # Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net + # This program is distributed under the terms and conditions of the GPL + # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id$ + # -------------------------------------------------------- +?> +<?php + require_once( 'core.php' ); + + $t_core_path = config_get( 'core_path' ); + + require_once( $t_core_path.'mail_api.php' ); +?> +<?php + $f_project_id = gpc_get_int( 'project_id' ); + $f_pop3_host = gpc_get_string( 'pop3_host' ); + $f_pop3_user = gpc_get_string( 'pop3_user' ); + $f_pop3_pass = gpc_get_string( 'pop3_pass' ); + + access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id ); + + if ( is_blank( $f_pop3_host ) ) { + trigger_error( ERROR_EMPTY_FIELD, ERROR ); + } + else { + if ( is_blank( $f_pop3_user ) ) { + trigger_error( ERROR_EMPTY_FIELD, ERROR ); + } + if ( is_blank( $f_pop3_pass ) ) { + trigger_error( ERROR_EMPTY_FIELD, ERROR ); + } + } + + mail_update( $f_project_id, $f_pop3_host, $f_pop3_user, $f_pop3_pass ); + + $t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $f_project_id; +?> +<?php + html_page_top1(); + + html_meta_redirect( $t_redirect_url ); + + html_page_top2(); +?> + +<br /> +<div align="center"> +<?php + echo lang_get( 'operation_successful' ) . '<br />'; + + print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) ); +?> +</div> + +<?php html_page_bottom1( __FILE__ ) ?> diff -rNu mantis.orig/sql/bug_report_mail.sql mantis/sql/bug_report_mail.sql --- mantis.orig/sql/bug_report_mail.sql Thu Jan 1 01:00:00 1970 +++ mantis/sql/bug_report_mail.sql Fri Aug 6 15:14:24 2004 @@ -0,0 +1,5 @@ + +ALTER TABLE `mantis_project_table` +ADD `pop3_host` VARCHAR( 255 ) DEFAULT NULL , +ADD `pop3_user` VARCHAR( 255 ) DEFAULT NULL , +ADD `pop3_pass` VARCHAR( 255 ) DEFAULT NULL ; diff -rNu mantis.orig/sql/db_generate.sql mantis/sql/db_generate.sql --- mantis.orig/sql/db_generate.sql Fri Feb 6 20:44:24 2004 +++ mantis/sql/db_generate.sql Mon Aug 9 18:16:44 2004 @@ -306,6 +306,9 @@ access_min int(2) NOT NULL default '10', file_path varchar(250) NOT NULL default '', description text NOT NULL, + pop3_host varchar(255) default NULL, + pop3_user varchar(255) default NULL, + pop3_pass varchar(255) default NULL, PRIMARY KEY (id), UNIQUE KEY name (name), KEY id (id) mantis-0.19.0.patch (42,781 bytes)
diff -Nru mantis-0.19.0.orig/bug_report_mail.php mantis-0.19.0/bug_report_mail.php --- mantis-0.19.0.orig/bug_report_mail.php Thu Jan 1 01:00:00 1970 +++ mantis-0.19.0/bug_report_mail.php Wed Sep 15 17:29:41 2004 @@ -0,0 +1,33 @@ +<?php + # Mantis - a php based bugtracking system + # Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net + # Copyright (C) 2004 Gerrit Beine - gerrit.beine@pitcom.de + # This program is distributed under the terms and conditions of the GPL + # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id$ + # -------------------------------------------------------- + + # This page receives an E-Mail via POP3 and generates an Report + header("Content-type: text/plain"); + + require_once( 'core.php' ); + + $t_core_path = config_get( 'core_path' ); + + require_once( $t_core_path . 'string_api.php' ); + require_once( $t_core_path . 'bug_api.php' ); + require_once( $t_core_path . 'mail_api.php' ); + + $t_projects = mail_project_get_all_rows(); + + foreach ($t_projects as $t_project) { + $t_mails = mail_get_all_mails($t_project); + foreach ($t_mails as $t_mail) + { + mail_add_bug($t_mail, $t_project); + } + } +?> + diff -Nru mantis-0.19.0.orig/config_defaults_inc.php mantis-0.19.0/config_defaults_inc.php --- mantis-0.19.0.orig/config_defaults_inc.php Sun Sep 12 14:12:30 2004 +++ mantis-0.19.0/config_defaults_inc.php Wed Sep 15 17:27:55 2004 @@ -1335,4 +1335,20 @@ # Enable support for bug relationships where a bug can be a related, dependent on, or duplicate of another. # See relationship_api.php for more details. $g_enable_relationship = ON; + + ###################### + # Mail Reporting + ###################### + + # --- mail reporting settings ----- + # This tells Mantis to report all the Mail with only one account + $g_mail_use_reporter = ON; + + # The account's name for mail reporting + # Also used for fallback if a user is not found in database + $g_mail_reporter = 'Mail'; + + # Signup new users automatically (possible security risk!) + # Default is OFF, ignored if mail_use_reporter is ON + $g_mail_auto_signup = OFF; ?> diff -Nru mantis-0.19.0.orig/config_inc.php mantis-0.19.0/config_inc.php --- mantis-0.19.0.orig/config_inc.php Sun Sep 12 16:03:14 2004 +++ mantis-0.19.0/config_inc.php Wed Sep 15 17:28:04 2004 @@ -49,4 +49,17 @@ # The default value is ON but you must make sure file uploading is enabled # in PHP as well. You may need to add "file_uploads = TRUE" to your php.ini. $g_allow_file_upload = ON; + + # --- mail reporting settings ----- + # This tells Mantis to report all the Mail with only one account + $g_mail_use_reporter = OFF; + + # The account's name for mail reporting + # Also used for fallback if a user is not found in database + $g_mail_reporter = 'Mail'; + + # Signup new users automatically (possible security risk!) + # Default is OFF, ignored if mail_use_reporter is ON + $g_mail_auto_signup = ON; + ?> diff -Nru mantis-0.19.0.orig/core/mail_api.php mantis-0.19.0/core/mail_api.php --- mantis-0.19.0.orig/core/mail_api.php Thu Jan 1 01:00:00 1970 +++ mantis-0.19.0/core/mail_api.php Wed Sep 15 17:20:27 2004 @@ -0,0 +1,222 @@ +<?php + # Mantis - a php based bugtracking system + # Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net + # Copyright (C) 2004 Gerrit Beine - gerrit.beine@pitcom.de + # This program is distributed under the terms and conditions of the GPL + # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id$ + # -------------------------------------------------------- + + $t_core_dir = dirname( __FILE__ ).DIRECTORY_SEPARATOR; + + require_once( $t_core_dir . 'bug_api.php' ); + require_once( $t_core_dir . 'bugnote_api.php' ); + require_once( $t_core_dir . 'user_api.php' ); + require_once( $t_core_dir . 'project_api.php' ); + + # This page receives an E-Mail via POP3 and generates an Report + + require_once( 'Net/POP3.php' ); + + # -------------------- + # Update the mail account data + function mail_update( $p_project_id, $p_pop3_host, $p_pop3_user, $p_pop3_pass ) { + $v_project_id = db_prepare_int( $p_project_id ); + $v_pop3_host = db_prepare_string( $p_pop3_host ); + $v_pop3_user = db_prepare_string( $p_pop3_user ); + $v_pop3_pass = db_prepare_string( $p_pop3_pass ); + + $t_project_table = config_get( 'mantis_project_table' ); + + $query = "UPDATE $t_project_table + SET pop3_host='$v_pop3_host', + pop3_user='$v_pop3_user', + pop3_pass='$v_pop3_pass' + WHERE id='$v_project_id'"; + db_query( $query ); + return true; + } + + # -------------------- + # Removes the mail account data + function mail_delete( $p_project_id ) { + $v_project_id = db_prepare_int( $p_project_id ); + + $t_project_table = config_get( 'mantis_project_table' ); + + $query = "UPDATE $t_project_table + SET pop3_host=NULL, + pop3_user=NULL, + pop3_pass=NULL + WHERE id='$v_project_id'"; + + db_query( $query ); + + return true; + } + + # -------------------- + # Return all versions for the specified project + function mail_get_account_data( $p_project_id ) { + $v_project_id = db_prepare_int( $p_project_id ); + + $t_project_table = config_get( 'mantis_project_table' ); + + $query = "SELECT pop3_host, pop3_user, pop3_pass + FROM $t_project_table + WHERE id='$v_project_id'"; + + $result = db_query( $query ); + + return db_fetch_array( $result ); + } + + # -------------------- + # return all projects with valid data for mail access + # return an empty array if there are no such projects + function mail_project_get_all_rows() { + $v_projects = array(); + $t_projects = project_get_all_rows(); + + foreach ($t_projects as $t_project) { + if ($t_project['pop3_host']) { + array_push($v_projects, $t_project); + } + } + + return $v_projects; + } + + # -------------------- + # return all mails for a project + # return an empty array if there are no new mails + function mail_get_all_mails( $p_project ) { + $v_mails = array(); + $t_pop3 = &new Net_POP3(); + $t_pop3_host = $p_project['pop3_host']; + $t_pop3_user = $p_project['pop3_user']; + $t_pop3_password = $p_project['pop3_pass']; + + $t_pop3->connect($t_pop3_host, 110); + $t_pop3->login($t_pop3_user, $t_pop3_password); + + for ($i = 1; $i <= $t_pop3->numMsg(); $i++) { + $t_mail = $t_pop3->getParsedHeaders($i); + $t_mail['X-Mantis-Body'] = $t_pop3->getBody($i); + $t_mail['X-Mantis-Complete'] = $t_pop3->getMsg($i); + array_push($v_mails, $t_mail); + #$t_pop3->deleteMsg($i); + } + + $t_pop3->disconnect(); + return $v_mails; + } + + # -------------------- + # return the mailadress from the mail's 'From' + function mail_parse_address ( $p_mailaddress ) { + if (preg_match("/<(.*?)>/", $p_mailaddress, $matches)) { + $c_mailaddress = $matches[1]; + } + + return $c_mailaddress; + } + + # -------------------- + # return the a valid username from an email address + function mail_user_name_from_address ( $p_mailaddress ) { + + return preg_replace("/[@\.-]/", '_', $p_mailaddress); + } + + # -------------------- + # return true if there is a valid mantis bug referernce in subject + function mail_is_a_bugnote ($p_mail_subject) { + return preg_match("/\[([A-Za-z0-9-_\.]*\s[0-9]{7})\]/", $p_mail_subject); + } + + # -------------------- + # return the bug's id from the subject + function mail_get_bug_id_from_subject ( $p_mail_subject) { + preg_match("/\[([A-Za-z0-9-_\.]*\s([0-9]{7}?))\]/", $p_mail_subject, $v_matches); + + return $v_matches[2]; + } + + # -------------------- + # return the user id for the mail reporting user + function mail_get_user ($p_mailaddress) { + $t_mail_use_reporter = config_get( 'mail_use_reporter' ); + $t_mail_auto_signup = config_get( 'mail_auto_signup' ); + $t_mail_reporter = config_get( 'mail_reporter' ); + + $c_mailaddress = mail_parse_address( $p_mailaddress ); + + if ( $t_mail_use_reporter ) { + // Always report as mail_reporter + $t_reporter_id = user_get_id_by_name( $t_mail_reporter ); + } else { + // Try to get the reporting users id + $t_reporter_id = user_get_id_by_mail ( $c_mailaddress ); + if ( ! $t_reporter_id && $t_mail_auto_signup ) { + // So, we've to sign up a new user... + $t_user_name = mail_user_name_from_address ( $c_mailaddress ); + user_signup($t_user_name, $c_mailaddress); + $t_reporter_id = user_get_id_by_name($t_user_name); + } elseif ( ! $t_reporter_id ) { + // Fall back to the default mail_reporter + $t_reporter_id = user_get_id_by_name( $t_mail_reporter ); + } + } + + return $t_reporter_id; + } + + # -------------------- + # Adds a bug which is reported via email + # Taken from bug_report.php and + function mail_add_bug( $p_mail, $p_project ) { + $t_bug_data = new BugData; + $t_bug_data->build = gpc_get_string( 'build', '' ); + $t_bug_data->platform = gpc_get_string( 'platform', '' ); + $t_bug_data->os = gpc_get_string( 'os', '' ); + $t_bug_data->os_build = gpc_get_string( 'os_build', '' ); + $t_bug_data->version = gpc_get_string( 'product_version', '' ); + $t_bug_data->profile_id = gpc_get_int( 'profile_id', 0 ); + $t_bug_data->handler_id = gpc_get_int( 'handler_id', 0 ); + $t_bug_data->view_state = gpc_get_int( 'view_state', config_get( 'default_bug_view_status' ) ); + + $t_bug_data->category = gpc_get_string( 'category', '' ); + $t_bug_data->reproducibility = 10; + $t_bug_data->severity = 50; + $t_bug_data->priority = gpc_get_int( 'priority', NORMAL ); + $t_bug_data->summary = $p_mail['Subject']; + $t_bug_data->description = $p_mail['X-Mantis-Body']; + $t_bug_data->steps_to_reproduce = gpc_get_string( 'steps_to_reproduce', '' ); + $t_bug_data->additional_information = $p_mail['X-Mantis-Complete']; + + $t_bug_data->project_id = $p_project['id']; + + $t_bug_data->reporter_id = mail_get_user( $p_mail['From'] ); + + if (mail_is_a_bugnote($p_mail['Subject'])) + { + # Add a bug note + $t_bug_id = mail_get_bug_id_from_subject( $p_mail['Subject'] ); + if ( ! bug_is_readonly( $t_bug_id ) ) { + bugnote_add ( $t_bug_id, $p_mail['X-Mantis-Body'] ); + email_bugnote_add ( $t_bug_id ); + } + } + else + { + # Create the bug + #$t_bug_id = bug_create( $t_bug_data ); + #email_new_bug( $t_bug_id ); + } + + } + +?> diff -Nru mantis-0.19.0.orig/core/user_api.php mantis-0.19.0/core/user_api.php --- mantis-0.19.0.orig/core/user_api.php Mon Aug 23 16:13:34 2004 +++ mantis-0.19.0/core/user_api.php Wed Sep 15 17:20:36 2004 @@ -478,6 +478,27 @@ } # -------------------- + # get a user id from an mail address + # return false if the mail address does not exist + function user_get_id_by_mail( $p_mailaddress ) { + + $c_mailaddress = db_prepare_string( $p_mailaddress ); + + $t_user_table = config_get( 'mantis_user_table' ); + + $query = "SELECT id + FROM $t_user_table + WHERE email='$c_mailaddress'"; + $result = db_query( $query ); + + if ( 0 == db_num_rows( $result ) ) { + return false; + } else { + return db_result( $result ); + } + } + + # -------------------- # return all data associated with a particular user name # return false if the username does not exist function user_get_row_by_name( $p_username ) { diff -Nru mantis-0.19.0.orig/doc/README.bug_report_mail mantis-0.19.0/doc/README.bug_report_mail --- mantis-0.19.0.orig/doc/README.bug_report_mail Thu Jan 1 01:00:00 1970 +++ mantis-0.19.0/doc/README.bug_report_mail Wed Sep 15 17:32:01 2004 @@ -0,0 +1,53 @@ +The current version of bug_report_mail only support plain text e-mails +and POP3 Mailaccounts with PEAR's Net_POP3 packge. + +bug_report_mail is able to recognize if mail is a reply to an already opened +bug and adds the content as a bugnote. + +If you are alway running Mantis you have to alter your projects table +with the sql/bug_report_mail.sql script. +If not, you can create the database tables in the way described in +the doc/INSTALL file. + +This patch changes the following files: + core/user_api.php + manage_proj_edit_page.php + config_default_inc.php +These files are new: + core/mail_api.php + sql/bug_report_mail.sql + bug_report_mail.php + manage_proj_mail_delete.php + manage_proj_mail_update.php + +After installing this patch, you can add a POP3 server's hostname +and authentication data for each of your projects with the project edit form. + +There are two ways to receive mail with bug_report_mail: +The secure (and default) way is to use a standard reporting user: +You have to create a reporter account, for example 'Mail'. +The name for this reporter account you have to write in your config_inc.php file: + $g_mail_reporter = "Mail"; +and then, bug_report_mail must be informed to behave like this: + $g_mail_use_reporter = ON; + +The other way is to signup new user accounts automatically. +For using this, you have to change this + $g_mail_auto_signup = OFF; +from OFF to ON. +Now, bug_report_mail will look for an user named like the mail's sender +or an user which mail adress is identical. +If no user is found, then a new account will be created. +The new user's name will be the mail address. + +This could be used for attacks, but there is no other way in the moment. + +After this, bug_report_mail can be used via cron like this: + +*/5 * * * * lynx --dump http://mantis.homepage.com/bug_report_mail.php + +This line uses lynx to fetch bug reports from via POP3 every 5 minutes. + +This addon is distributed under the same condition as Mantis itself. + +Gerrit Beine, August 2004 diff -Nru mantis-0.19.0.orig/doc/README.bug_report_mail~ mantis-0.19.0/doc/README.bug_report_mail~ --- mantis-0.19.0.orig/doc/README.bug_report_mail~ Thu Jan 1 01:00:00 1970 +++ mantis-0.19.0/doc/README.bug_report_mail~ Mon Aug 9 23:26:21 2004 @@ -0,0 +1,54 @@ +The current version of bug_report_mail only support plain text e-mails +and POP3 Mailaccounts with PEAR's Net_POP3 packge. + +bug_report_mail is able to recognize if mail is a reply to an already opened +bug and adds the content as a bugnote. + +If you are alway running Mantis you have to alter you projects table +with the sql/bug_report_mail.sql script. +If not, you can create the database tables in the way described in +the doc/INSTALL file. + +This patch changes the following files: + core/user_api.php + manage_proj_edit_page.php + config_inc.php.sample +These files are new: + core/mail_api.php + sql/bug_report_mail.php + bug_report_mail.php + manage_proj_mail_delete.php + manage_proj_mail_update.php + +After installing this patch, you can add a POP3 server's hostname +and authentication data for each of your projects with the +project edit form. + +There are two ways to receive mail with bug_report_mail: +The secure way is to use a standard reporting user: +You have to create a reporter account, for example 'Mail'. +The name for this reporter account you have to write in your config_inc.php file: + $g_mail_reporter = "Mail"; +and then, bug_report_mail must be informed to behave like this: + $g_mail_use_reporter = ON; + +The other way is to signup new user accounts automatically. +For using this, you have to change this + $g_mail_auto_signup = OFF; +from OFF to ON. +Now, bug_report_mail will look for an user named like the mail's sender +or an user which mail adress is identical. +If no user is found, then a new account will be created. +The new user's name will be the mail address. + +This could be used for attacks, but there is no other way in the moment. + +After this, bug_report_mail can be used via cron like this: + +*/5 * * * * lynx --dump http://mantis.homepage.com/bug_report_mail.php + +This line uses lynx to fetch bug reports from via POP3 every 5 minutes. + +This addon is distributed under the same condition as Mantis itself. + +Gerrit Beine, August 2004 diff -Nru mantis-0.19.0.orig/manage_proj_edit_page.php mantis-0.19.0/manage_proj_edit_page.php --- mantis-0.19.0.orig/manage_proj_edit_page.php Thu Jul 15 00:16:34 2004 +++ mantis-0.19.0/manage_proj_edit_page.php Wed Sep 15 17:30:05 2004 @@ -18,6 +18,7 @@ require_once( $t_core_path . 'version_api.php' ); require_once( $t_core_path . 'custom_field_api.php' ); require_once( $t_core_path . 'icon_api.php' ); + require_once( $t_core_path . 'mail_api.php' ); ?> <?php $f_project_id = gpc_get_int( 'project_id' ); @@ -25,6 +26,8 @@ access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id ); $row = project_get_row( $f_project_id ); + $mail = mail_get_account_data( $f_project_id ); + ?> <?php html_page_top1() ?> <?php html_page_top2() ?> @@ -534,4 +537,55 @@ </table> </div> + +<!-- MAIL ACCOUNT CHANGE --> +<br /> +<div align="center"> + <form method="post" action="manage_proj_mail_update.php"> + <input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" /> + <table class="width75" cellspacing="1"> + <tr> + <td class="form-title" colspan="4"> + <?php echo 'Mail Account Settings' ?> + </td> + </tr> + <tr class="row-1"> + <td class="category" width="25%"> + <?php echo "POP3 Host"?> + </td> + <td width="75%"> + <input type="text" name="pop3_host" size="64" maxlength="255" value="<?php echo string_attribute( $mail['pop3_host'] ) ?>" /> + </td> + </tr> + <tr class="row-1"> + <td class="category" width="25%"> + <?php echo "POP3 User"?> + </td> + <td width="75%"> + <input type="text" name="pop3_user" size="64" maxlength="255" value="<?php echo string_attribute( $mail['pop3_user'] ) ?>" /> + </td> + </tr> + <tr class="row-1"> + <td class="category" width="25%"> + <?php echo "POP3 Password"?> + </td> + <td width="75%"> + <input type="text" name="pop3_pass" size="64" maxlength="255" value="<?php echo string_attribute( $mail['pop3_pass'] ) ?>" /> + </td> + </tr> + <tr> + <td colspan="2"> + <input type="submit" value="<?php echo 'Set Mail Account Data' ?>" /> + </td> + </tr> + </table> + </form> +</div> +<!-- MAIL ACCOUNT RESET --> +<div class="border-center"> + <form method="post" action="manage_proj_mail_delete.php"> + <input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" /> + <input type="submit" value="<?php echo 'Delete Mail Account Data' ?>" /> + </form> +</div> <?php html_page_bottom1( __FILE__ ) ?> diff -Nru mantis-0.19.0.orig/manage_proj_edit_page.php~ mantis-0.19.0/manage_proj_edit_page.php~ --- mantis-0.19.0.orig/manage_proj_edit_page.php~ Thu Jan 1 01:00:00 1970 +++ mantis-0.19.0/manage_proj_edit_page.php~ Wed Sep 15 16:40:53 2004 @@ -0,0 +1,591 @@ +<?php + # Mantis - a php based bugtracking system + # Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org + # Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net + # This program is distributed under the terms and conditions of the GPL + # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id: manage_proj_edit_page.php,v 1.79 2004/07/14 22:16:34 vboctor Exp $ + # -------------------------------------------------------- +?> +<?php + require_once( 'core.php' ); + + $t_core_path = config_get( 'core_path' ); + + require_once( $t_core_path . 'category_api.php' ); + require_once( $t_core_path . 'version_api.php' ); + require_once( $t_core_path . 'custom_field_api.php' ); + require_once( $t_core_path . 'icon_api.php' ); + require_once( $t_core_path.'mail_api.php' ); +?> +<?php + $f_project_id = gpc_get_int( 'project_id' ); + + access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id ); + + $row = project_get_row( $f_project_id ); + $mail = mail_get_account_data( $f_project_id ); + +?> +<?php html_page_top1() ?> +<?php html_page_top2() ?> + +<?php print_manage_menu( 'manage_proj_edit_page.php' ) ?> + +<br /> + + +<!-- PROJECT PROPERTIES --> +<div align="center"> +<form method="post" action="manage_proj_update.php"> +<table class="width75" cellspacing="1"> + +<!-- Title --> +<tr> + <td class="form-title" colspan="2"> + <input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" /> + <?php echo lang_get( 'edit_project_title' ) ?> + </td> +</tr> + +<!-- Name --> +<tr <?php echo helper_alternate_class() ?>> + <td class="category" width="25%"> + <?php echo lang_get( 'project_name' ) ?> + </td> + <td width="75%"> + <input type="text" name="name" size="50" maxlength="128" value="<?php echo string_attribute( $row['name'] ) ?>" /> + </td> +</tr> + +<!-- Status --> +<tr <?php echo helper_alternate_class() ?>> + <td class="category"> + <?php echo lang_get( 'status' ) ?> + </td> + <td> + <select name="status"> + <?php print_enum_string_option_list( 'project_status', $row['status'] ) ?> + </select> + </td> +</tr> + +<!-- Enabled --> +<tr <?php echo helper_alternate_class() ?>> + <td class="category"> + <?php echo lang_get( 'enabled' ) ?> + </td> + <td> + <input type="checkbox" name="enabled" <?php check_checked( $row['enabled'], ON ); ?> /> + </td> +</tr> + +<!-- View Status (public/private) --> +<tr <?php echo helper_alternate_class() ?>> + <td class="category"> + <?php echo lang_get( 'view_status' ) ?> + </td> + <td> + <select name="view_state"> + <?php print_enum_string_option_list( 'view_state', $row['view_state']) ?> + </select> + </td> +</tr> + +<!-- File upload path (if uploading is enabled) --> +<?php if ( file_is_uploading_enabled() ) { ?> +<tr <?php echo helper_alternate_class() ?>> + <td class="category"> + <?php echo lang_get( 'upload_file_path' ) ?> + </td> + <td> + <input type="text" name="file_path" size="50" maxlength="250" value="<?php echo string_attribute( $row['file_path'] ) ?>" /> + </td> +</tr> +<?php } ?> + +<!-- Description --> +<tr <?php echo helper_alternate_class() ?>> + <td class="category"> + <?php echo lang_get( 'description' ) ?> + </td> + <td> + <textarea name="description" cols="60" rows="5" wrap="virtual"><?php echo string_textarea( $row['description'] ) ?></textarea> + </td> +</tr> + +<!-- Submit Button --> +<tr> + <td> </td> + <td> + <input type="submit" class="button" value="<?php echo lang_get( 'update_project_button' ) ?>" /> + </td> +</tr> +</table> +</form> +</div> + +<br /> + +<!-- PROJECT DELETE --> +<?php +# You must have global permissions to delete projects +if ( access_has_global_level ( config_get( 'delete_project_threshold' ) ) ) { ?> +<div class="border-center"> + <form method="post" action="manage_proj_delete.php"> + <input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" /> + <input type="submit" class="button" value="<?php echo lang_get( 'delete_project_button' ) ?>" /> + </form> +</div> +<?php } ?> + +<br /> + +<?php + # reset the class counter + helper_alternate_class( 0 ); +?> + +<!-- PROJECT CATEGORIES --> +<div align="center"> +<table class="width75" cellspacing="1"> + +<!-- Title --> +<tr> + <td class="form-title" colspan="3"> + <?php echo lang_get( 'categories' ) ?> + </td> +</tr> +<?php + $t_categories = category_get_all_rows( $f_project_id ); + + if ( count( $t_categories ) > 0 ) { +?> + <tr class="row-category"> + <td> + <?php echo lang_get( 'category' ) ?> + </td> + <td> + <?php echo lang_get( 'assign_to' ) ?> + </td> + <td class="center"> + <?php echo lang_get( 'actions' ) ?> + </td> + </tr> +<?php + } + + foreach ( $t_categories as $t_category ) { + $t_name = $t_category['category']; + + if ( NO_USER != $t_category['user_id'] && user_exists( $t_category['user_id'] )) { + $t_user_name = user_get_name( $t_category['user_id'] ); + } else { + $t_user_name = ''; + } +?> +<!-- Repeated Info Row --> + <tr <?php echo helper_alternate_class() ?>> + <td> + <?php echo string_display( $t_name ) ?> + </td> + <td> + <?php echo $t_user_name ?> + </td> + <td class="center"> + <?php + $t_name = urlencode( $t_name ); + + print_bracket_link( 'manage_proj_cat_edit_page.php?project_id=' . $f_project_id . '&category=' . $t_name, lang_get( 'edit_link' ) ); + echo ' '; + print_bracket_link( 'manage_proj_cat_delete.php?project_id=' . $f_project_id . '&category=' . $t_name, lang_get( 'delete_link' ) ); + ?> + </td> + </tr> +<?php + } # end for loop +?> + +<!-- Add Category Form --> +<tr> + <td class="left" colspan="3"> + <form method="post" action="manage_proj_cat_add.php"> + <input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" /> + <input type="text" name="category" size="32" maxlength="64" /> + <input type="submit" class="button" value="<?php echo lang_get( 'add_category_button' ) ?>" /> + </form> + </td> +</tr> + +<!-- Copy Categories Form --> +<tr> + <td class="left" colspan="3"> + <form method="post" action="manage_proj_cat_copy.php"> + <input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" /> + <select name="other_project_id"> + <?php print_project_option_list( null, false ) ?> + </select> + <input type="submit" name="copy_from" class="button" value="<?php echo lang_get( 'copy_categories_from' ) ?>" /> + <input type="submit" name="copy_to" class="button" value="<?php echo lang_get( 'copy_categories_to' ) ?>" /> + </form> + </td> +</tr> +</table> + +<br /> + +<?php + # reset the class counter + helper_alternate_class( 0 ); +?> + +<!-- PROJECT VERSIONS --> +<table class="width75" cellspacing="1"> + +<!-- Title --> +<tr> + <td class="form-title" colspan="3"> + <?php echo lang_get( 'versions' ) ?> + </td> +</tr> +<?php + $t_versions = version_get_all_rows( $f_project_id ); + + if ( count( $t_versions ) > 0 ) { +?> + <tr class="row-category"> + <td> + <?php echo lang_get( 'version' ) ?> + </td> + <td class="center"> + <?php echo lang_get( 'timestamp' ) ?> + </td> + <td class="center"> + <?php echo lang_get( 'actions' ) ?> + </td> + </tr> +<?php + } + + foreach ( $t_versions as $t_version ) { + $t_name = $t_version['version']; + $t_date_order = $t_version['date_order']; + $t_date_formatted = string_format_complete_date( $t_version['date_order'] ); +?> +<!-- Repeated Info Rows --> + <tr <?php echo helper_alternate_class() ?>> + <td> + <?php echo string_display( $t_name ) ?> + </td> + <td class="center"> + <?php echo $t_date_formatted ?> + </td> + <td class="center"> + <?php + $t_version_id = version_get_id( $t_name, $f_project_id ); + + print_bracket_link( 'manage_proj_ver_edit_page.php?version_id=' . $t_version_id, lang_get( 'edit_link' ) ); + echo ' '; + print_bracket_link( 'manage_proj_ver_delete.php?version_id=' . $t_version_id, lang_get( 'delete_link' ) ); + ?> + </td> + </tr> +<?php + } # end for loop +?> + +<!-- Version Add Form --> +<tr> + <td class="left" colspan="3"> + <form method="post" action="manage_proj_ver_add.php"> + <input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" /> + <input type="text" name="version" size="32" maxlength="64" /> + <input type="submit" class="button" value="<?php echo lang_get( 'add_version_button' ) ?>" /> + </form> + </td> +</tr> +</table> +</div> + + +<?php + # reset the class counter + helper_alternate_class( 0 ); +?> + +<!-- PROJECT CUSTOM FIELD --> +<?php +# You need either global permissions or project-specific permissions to link +# custom fields +if ( access_has_project_level( config_get( 'custom_field_link_threshold' ), $f_project_id ) && + ( count( custom_field_get_ids() ) > 0 ) ) { +?> + <br /> + <div align="center"> + <table class="width75" cellspacing="1"> + <tr> + <td class="form-title" colspan="3"> + <?php echo lang_get( 'custom_fields_setup' ) ?> + </td> + </tr> + <?php + $t_custom_fields = custom_field_get_linked_ids( $f_project_id ); + + if ( count( $t_custom_fields ) > 0 ) { + ?> + <tr class="row-category"> + <td width="50%"> + <?php echo lang_get( 'custom_field' ) ?> + </td> + <td width="25%"> + <?php echo lang_get( 'custom_field_sequence' ) ?> + </td> + <td class="center" width="25%"> + <?php echo lang_get( 'actions' ); ?> + </td> + </tr> + <?php + } + + foreach( $t_custom_fields as $t_field_id ) { + $t_desc = custom_field_get_definition( $t_field_id ); + ?> + <tr <?php echo helper_alternate_class() ?>> + <td> + <?php echo $t_desc['name'] ?> + </td> + <td> +<form method="post" action="manage_proj_custom_field_update.php"> + <input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" /> + <input type="hidden" name="field_id" value="<?php echo $t_field_id ?>" /> + <input type="text" name="sequence" value="<?php echo custom_field_get_sequence( $t_field_id, $f_project_id ) ?>" size="2" /> + <input type="submit" class="button" value="<?php echo lang_get( 'update' ) ?>" /> +</form> + </td> + <td class="center"> + <?php + # You need global permissions to edit custom field defs + print_bracket_link( "manage_proj_custom_field_remove.php?field_id=$t_field_id&project_id=$f_project_id", lang_get( 'remove_link' ) ); + ?> + </td> + </tr> + <?php + } # end for loop + ?> + <tr> + <td class="left" colspan="3"> + <form method="post" action="manage_proj_custom_field_add_existing.php"> + <input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" /> + <select name="field_id"> + <?php + $t_custom_fields = custom_field_get_ids(); + + foreach( $t_custom_fields as $t_field_id ) + { + if( !custom_field_is_linked( $t_field_id, $f_project_id ) ) { + $t_desc = custom_field_get_definition( $t_field_id ); + echo "<option value=\"$t_field_id\">" . string_attribute( $t_desc['name'] ) . '</option>' ; + } + } + ?> + </select> + <input type="submit" class="button" value="<?php echo lang_get( 'add_existing_custom_field' ) ?>" /> + </form> + </td> + </tr> + </table> + </div> +<?php +} +?> + + +<!-- PROJECT VIEW STATUS --> +<br /> +<div align="center"> + <table class="width75" cellspacing="1"> + <tr> + <td class="center"> + <?php + if ( VS_PUBLIC == project_get_field( $f_project_id, 'view_state' ) ) { + echo lang_get( 'public_project_msg' ); + } else { + echo lang_get( 'private_project_msg' ); + } + ?> + </td> + </tr> + </table> +</div> + + +<!-- USER MANAGEMENT (ADD) --> +<?php +# We want to allow people with global permissions and people with high enough +# permissions on the project we are editing +if ( access_has_project_level( config_get( 'project_user_threshold' ), $f_project_id ) ) { +?> +<br /> +<div align="center"> + <form method="post" action="manage_proj_user_add.php"> + <input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" /> + <table class="width75" cellspacing="1"> + <tr> + <td class="form-title" colspan="5"> + <?php echo lang_get( 'add_user_title' ) ?> + </td> + </tr> + <tr class="row-1" valign="top"> + <td class="category"> + <?php echo lang_get( 'username' ) ?> + </td> + <td class="category"> + <?php echo lang_get( 'access_level' ) ?> + </td> + <td class="category"> </td> + </tr> + <tr class="row-1" valign="top"> + <td> + <select name="user_id[]" multiple="multiple" size="10"> + <?php print_project_user_list_option_list( $f_project_id ) ?> + </select> + </td> + <td> + <select name="access_level"> + <?php # No administrator choice ?> + <?php print_project_access_levels_option_list( config_get( 'default_new_account_access_level' ) ) ?> + </select> + </td> + <td> + <input type="submit" class="button" value="<?php echo lang_get( 'add_user_button' ) ?>" /> + </td> + </tr> + </table> + </form> +</div> +<?php +} +?> + + +<!-- LIST OF USERS --> +<br /> +<div align="center"> + <table class="width75" cellspacing="1"> + <tr> + <td class="form-title" colspan="4"> + <?php echo lang_get( 'manage_accounts_title' ) ?> + </td> + </tr> + <tr class="row-category"> + <td> + <?php echo lang_get( 'username' ) ?> + </td> + <td> + <?php echo lang_get( 'email' ) ?> + </td> + <td> + <?php echo lang_get( 'access_level' ) ?> + </td> + <td class="center"> + <?php echo lang_get( 'actions' ) ?> + </td> + </tr> +<?php + $t_users = project_get_all_user_rows( $f_project_id ); + + # reset the class counter + helper_alternate_class( 0 ); + + foreach ( $t_users as $t_user ) { +?> + <tr <?php echo helper_alternate_class() ?>> + <td> + <?php + echo $t_user['username']; + if ( isset( $t_user['realname'] ) && $t_user['realname'] > "" ) { + echo " (" . $t_user['realname'] . ")"; + } + ?> + </td> + <td> + <?php + $t_email = user_get_email( $t_user['id'] ); + print_email_link( $t_email, $t_email ); + ?> + </td> + <td> + <?php echo get_enum_element( 'access_levels', $t_user['access_level'] ) ?> + </td> + <td class="center"> + <?php + # You need global or project-specific permissions to remove users + # from this project + if ( access_has_project_level( config_get( 'project_user_threshold' ), $f_project_id ) ) { + if ( project_includes_user( $f_project_id, $t_user['id'] ) ) { + print_bracket_link( 'manage_proj_user_remove.php?project_id=' . $f_project_id . '&user_id=' . $t_user['id'], lang_get( 'remove_link' ) ); + } + } + ?> + </td> + </tr> +<?php + } # end for +?> + </table> +</div> + + +<!-- MAIL ACCOUNT CHANGE --> +<br /> +<div align="center"> + <form method="post" action="manage_proj_mail_update.php"> + <input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" /> + <table class="width75" cellspacing="1"> + <tr> + <td class="form-title" colspan="4"> + <?php echo 'Mail Account Settings' ?> + </td> + </tr> + <tr class="row-1"> + <td class="category" width="25%"> + <?php echo "POP3 Host"?> + </td> + <td width="75%"> + <input type="text" name="pop3_host" size="64" maxlength="255" value="<?php echo string_attribute( $mail['pop3_host'] ) ?>" /> + </td> + </tr> + <tr class="row-1"> + <td class="category" width="25%"> + <?php echo "POP3 User"?> + </td> + <td width="75%"> + <input type="text" name="pop3_user" size="64" maxlength="255" value="<?php echo string_attribute( $mail['pop3_user'] ) ?>" /> + </td> + </tr> + <tr class="row-1"> + <td class="category" width="25%"> + <?php echo "POP3 Password"?> + </td> + <td width="75%"> + <input type="text" name="pop3_pass" size="64" maxlength="255" value="<?php echo string_attribute( $mail['pop3_pass'] ) ?>" /> + </td> + </tr> + <tr> + <td colspan="2"> + <input type="submit" value="<?php echo 'Set Mail Account Data' ?>" /> + </td> + </tr> + </table> + </form> +</div> +<!-- MAIL ACCOUNT RESET --> +<div class="border-center"> + <form method="post" action="manage_proj_mail_delete.php"> + <input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" /> + <input type="submit" value="<?php echo 'Delete Mail Account Data' ?>" /> + </form> +</div> +<?php html_page_bottom1( __FILE__ ) ?> diff -Nru mantis-0.19.0.orig/manage_proj_mail_delete.php mantis-0.19.0/manage_proj_mail_delete.php --- mantis-0.19.0.orig/manage_proj_mail_delete.php Thu Jan 1 01:00:00 1970 +++ mantis-0.19.0/manage_proj_mail_delete.php Wed Sep 15 17:29:59 2004 @@ -0,0 +1,42 @@ +<?php + # Mantis - a php based bugtracking system + # Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org + # Copyright (C) 2004 Gerrit Beine - gerrit.beine@pitcom.de + # This program is distributed under the terms and conditions of the GPL + # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id$ + # -------------------------------------------------------- + + require_once( 'core.php' ); + + $t_core_path = config_get( 'core_path' ); + + require_once( $t_core_path . 'mail_api.php' ); + + $f_project_id = gpc_get_int( 'project_id' ); + + access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id ); + + mail_delete( $f_project_id ); + + $t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $f_project_id; + + html_page_top1(); + + html_meta_redirect( $t_redirect_url ); + + html_page_top2(); +?> + +<br /> +<div align="center"> +<?php + echo lang_get( 'operation_successful' ) . '<br />'; + + print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) ); +?> +</div> + +<?php html_page_bottom1( __FILE__ ) ?> diff -Nru mantis-0.19.0.orig/manage_proj_mail_delete.php~ mantis-0.19.0/manage_proj_mail_delete.php~ --- mantis-0.19.0.orig/manage_proj_mail_delete.php~ Thu Jan 1 01:00:00 1970 +++ mantis-0.19.0/manage_proj_mail_delete.php~ Wed Sep 15 16:35:39 2004 @@ -0,0 +1,42 @@ +<?php + # Mantis - a php based bugtracking system + # Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org + # Copyright (C) 2004 Gerrit Beine - gerrit.beine@pitcom.de + # This program is distributed under the terms and conditions of the GPL + # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id$ + # -------------------------------------------------------- + + require_once( 'core.php' ); + + $t_core_path = config_get( 'core_path' ); + + require_once( $t_core_path.'mail_api.php' ); + + $f_project_id = gpc_get_int( 'project_id' ); + + access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id ); + + mail_delete( $f_project_id ); + + $t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $f_project_id; + + html_page_top1(); + + html_meta_redirect( $t_redirect_url ); + + html_page_top2(); +?> + +<br /> +<div align="center"> +<?php + echo lang_get( 'operation_successful' ) . '<br />'; + + print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) ); +?> +</div> + +<?php html_page_bottom1( __FILE__ ) ?> diff -Nru mantis-0.19.0.orig/manage_proj_mail_update.php mantis-0.19.0/manage_proj_mail_update.php --- mantis-0.19.0.orig/manage_proj_mail_update.php Thu Jan 1 01:00:00 1970 +++ mantis-0.19.0/manage_proj_mail_update.php Wed Sep 15 17:29:54 2004 @@ -0,0 +1,58 @@ +<?php + # Mantis - a php based bugtracking system + # Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net + # Copyright (C) 2004 Gerrit Beine - gerrit.beine@pitcom.de + # This program is distributed under the terms and conditions of the GPL + # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id$ + # -------------------------------------------------------- + + require_once( 'core.php' ); + + $t_core_path = config_get( 'core_path' ); + + require_once( $t_core_path . 'mail_api.php' ); + + $f_project_id = gpc_get_int( 'project_id' ); + $f_pop3_host = gpc_get_string( 'pop3_host' ); + $f_pop3_user = gpc_get_string( 'pop3_user' ); + $f_pop3_pass = gpc_get_string( 'pop3_pass' ); + + echo $f_project_id; + access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id ); + + if ( is_blank( $f_pop3_host ) ) { + trigger_error( ERROR_EMPTY_FIELD, ERROR ); + } + else { + if ( is_blank( $f_pop3_user ) ) { + trigger_error( ERROR_EMPTY_FIELD, ERROR ); + } + if ( is_blank( $f_pop3_pass ) ) { + trigger_error( ERROR_EMPTY_FIELD, ERROR ); + } + } + + mail_update( $f_project_id, $f_pop3_host, $f_pop3_user, $f_pop3_pass ); + + $t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $f_project_id; + + html_page_top1(); + + html_meta_redirect( $t_redirect_url ); + + html_page_top2(); +?> + +<br /> +<div align="center"> +<?php + echo lang_get( 'operation_successful' ) . '<br />'; + + print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) ); +?> +</div> + +<?php html_page_bottom1( __FILE__ ) ?> diff -Nru mantis-0.19.0.orig/manage_proj_mail_update.php~ mantis-0.19.0/manage_proj_mail_update.php~ --- mantis-0.19.0.orig/manage_proj_mail_update.php~ Thu Jan 1 01:00:00 1970 +++ mantis-0.19.0/manage_proj_mail_update.php~ Wed Sep 15 16:37:50 2004 @@ -0,0 +1,58 @@ +<?php + # Mantis - a php based bugtracking system + # Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net + # Copyright (C) 2004 Gerrit Beine - gerrit.beine@pitcom.de + # This program is distributed under the terms and conditions of the GPL + # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id$ + # -------------------------------------------------------- + + require_once( 'core.php' ); + + $t_core_path = config_get( 'core_path' ); + + require_once( $t_core_path.'mail_api.php' ); + + $f_project_id = gpc_get_int( 'project_id' ); + $f_pop3_host = gpc_get_string( 'pop3_host' ); + $f_pop3_user = gpc_get_string( 'pop3_user' ); + $f_pop3_pass = gpc_get_string( 'pop3_pass' ); + + echo $f_project_id; + access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id ); + + if ( is_blank( $f_pop3_host ) ) { + trigger_error( ERROR_EMPTY_FIELD, ERROR ); + } + else { + if ( is_blank( $f_pop3_user ) ) { + trigger_error( ERROR_EMPTY_FIELD, ERROR ); + } + if ( is_blank( $f_pop3_pass ) ) { + trigger_error( ERROR_EMPTY_FIELD, ERROR ); + } + } + + mail_update( $f_project_id, $f_pop3_host, $f_pop3_user, $f_pop3_pass ); + + $t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $f_project_id; + + html_page_top1(); + + html_meta_redirect( $t_redirect_url ); + + html_page_top2(); +?> + +<br /> +<div align="center"> +<?php + echo lang_get( 'operation_successful' ) . '<br />'; + + print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) ); +?> +</div> + +<?php html_page_bottom1( __FILE__ ) ?> diff -Nru mantis-0.19.0.orig/sql/bug_report_mail.sql mantis-0.19.0/sql/bug_report_mail.sql --- mantis-0.19.0.orig/sql/bug_report_mail.sql Thu Jan 1 01:00:00 1970 +++ mantis-0.19.0/sql/bug_report_mail.sql Wed Sep 15 17:24:06 2004 @@ -0,0 +1,4 @@ +ALTER TABLE `mantis_project_table` +ADD `pop3_host` VARCHAR( 255 ) DEFAULT NULL , +ADD `pop3_user` VARCHAR( 255 ) DEFAULT NULL , +ADD `pop3_pass` VARCHAR( 255 ) DEFAULT NULL ; diff -Nru mantis-0.19.0.orig/sql/db_generate.sql mantis-0.19.0/sql/db_generate.sql --- mantis-0.19.0.orig/sql/db_generate.sql Sun Sep 12 14:19:24 2004 +++ mantis-0.19.0/sql/db_generate.sql Wed Sep 15 17:24:02 2004 @@ -377,6 +377,9 @@ access_min int(2) NOT NULL default '10', file_path varchar(250) NOT NULL default '', description text NOT NULL, + pop3_host varchar( 255 ) default NULL , + pop3_user varchar( 255 ) default NULL , + pop3_pass varchar( 255 ) default NULL , PRIMARY KEY (id), UNIQUE KEY name (name), KEY id (id) mantis-0.19.0.patch (34,447 bytes)
diff -Nru mantis-0.19.0.orig/bug_report_mail.php mantis-0.19.0/bug_report_mail.php --- mantis-0.19.0.orig/bug_report_mail.php Thu Jan 1 01:00:00 1970 +++ mantis-0.19.0/bug_report_mail.php Wed Sep 15 18:59:59 2004 @@ -0,0 +1,33 @@ +<?php + # Mantis - a php based bugtracking system + # Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net + # Copyright (C) 2004 Gerrit Beine - gerrit.beine@pitcom.de + # This program is distributed under the terms and conditions of the GPL + # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id$ + # -------------------------------------------------------- + + # This page receives an E-Mail via POP3 and generates an Report + header("Content-type: text/plain"); + + require_once( 'core.php' ); + + $t_core_path = config_get( 'core_path' ); + + require_once( $t_core_path . 'string_api.php' ); + require_once( $t_core_path . 'bug_api.php' ); + require_once( $t_core_path . 'mail_api.php' ); + + $t_mailaccounts = mail_get_accounts(); + + foreach ($t_mailaccounts as $t_mailaccount) { + $t_mails = mail_get_all_mails($t_mailaccount); + foreach ($t_mails as $t_mail) + { + mail_add_bug($t_mail, $t_mailaccount); + } + } +?> + diff -Nru mantis-0.19.0.orig/config_defaults_inc.php mantis-0.19.0/config_defaults_inc.php --- mantis-0.19.0.orig/config_defaults_inc.php Sun Sep 12 14:12:30 2004 +++ mantis-0.19.0/config_defaults_inc.php Wed Sep 15 17:27:55 2004 @@ -1335,4 +1335,20 @@ # Enable support for bug relationships where a bug can be a related, dependent on, or duplicate of another. # See relationship_api.php for more details. $g_enable_relationship = ON; + + ###################### + # Mail Reporting + ###################### + + # --- mail reporting settings ----- + # This tells Mantis to report all the Mail with only one account + $g_mail_use_reporter = ON; + + # The account's name for mail reporting + # Also used for fallback if a user is not found in database + $g_mail_reporter = 'Mail'; + + # Signup new users automatically (possible security risk!) + # Default is OFF, ignored if mail_use_reporter is ON + $g_mail_auto_signup = OFF; ?> diff -Nru mantis-0.19.0.orig/config_inc.php mantis-0.19.0/config_inc.php --- mantis-0.19.0.orig/config_inc.php Sun Sep 12 16:03:14 2004 +++ mantis-0.19.0/config_inc.php Wed Sep 15 17:28:04 2004 @@ -49,4 +49,17 @@ # The default value is ON but you must make sure file uploading is enabled # in PHP as well. You may need to add "file_uploads = TRUE" to your php.ini. $g_allow_file_upload = ON; + + # --- mail reporting settings ----- + # This tells Mantis to report all the Mail with only one account + $g_mail_use_reporter = OFF; + + # The account's name for mail reporting + # Also used for fallback if a user is not found in database + $g_mail_reporter = 'Mail'; + + # Signup new users automatically (possible security risk!) + # Default is OFF, ignored if mail_use_reporter is ON + $g_mail_auto_signup = ON; + ?> diff -Nru mantis-0.19.0.orig/core/category_api.php mantis-0.19.0/core/category_api.php --- mantis-0.19.0.orig/core/category_api.php Thu Apr 8 20:04:52 2004 +++ mantis-0.19.0/core/category_api.php Wed Sep 15 18:52:45 2004 @@ -206,7 +206,7 @@ $t_project_category_table = config_get( 'mantis_project_category_table' ); - $query = "SELECT category, user_id + $query = "SELECT category, user_id, pop3_host, pop3_user, pop3_pass FROM $t_project_category_table WHERE project_id='$c_project_id' ORDER BY category"; diff -Nru mantis-0.19.0.orig/core/mail_api.php mantis-0.19.0/core/mail_api.php --- mantis-0.19.0.orig/core/mail_api.php Thu Jan 1 01:00:00 1970 +++ mantis-0.19.0/core/mail_api.php Wed Sep 15 19:00:09 2004 @@ -0,0 +1,341 @@ +<?php + # Mantis - a php based bugtracking system + # Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net + # Copyright (C) 2004 Gerrit Beine - gerrit.beine@pitcom.de + # This program is distributed under the terms and conditions of the GPL + # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id$ + # -------------------------------------------------------- + + $t_core_dir = dirname( __FILE__ ).DIRECTORY_SEPARATOR; + + require_once( $t_core_dir . 'bug_api.php' ); + require_once( $t_core_dir . 'bugnote_api.php' ); + require_once( $t_core_dir . 'user_api.php' ); + require_once( $t_core_dir . 'project_api.php' ); + + # This page receives an E-Mail via POP3 and generates an Report + + require_once( 'Net/POP3.php' ); + + # -------------------- + # Return mail account data for the specified project + function mail_get_account_data( $p_project_id ) { + $v_project_id = db_prepare_int( $p_project_id ); + + $t_project_table = config_get( 'mantis_project_table' ); + + $query = "SELECT pop3_host, pop3_user, pop3_pass, pop3_categories + FROM $t_project_table + WHERE id='$v_project_id'"; + + $result = db_query( $query ); + + return db_fetch_array( $result ); + } + + # -------------------- + # Update the mail account data + function mail_update( $p_project_id, $p_pop3_host, $p_pop3_user, $p_pop3_pass ) { + $v_project_id = db_prepare_int( $p_project_id ); + $v_pop3_host = db_prepare_string( $p_pop3_host ); + $v_pop3_user = db_prepare_string( $p_pop3_user ); + $v_pop3_pass = db_prepare_string( $p_pop3_pass ); + + $t_project_table = config_get( 'mantis_project_table' ); + + $query = "UPDATE $t_project_table + SET pop3_host='$v_pop3_host', + pop3_user='$v_pop3_user', + pop3_pass='$v_pop3_pass' + WHERE id='$v_project_id'"; + db_query( $query ); + return true; + } + + # -------------------- + # Removes the mail account data + function mail_delete( $p_project_id ) { + $v_project_id = db_prepare_int( $p_project_id ); + + $t_project_table = config_get( 'mantis_project_table' ); + + $query = "UPDATE $t_project_table + SET pop3_host=NULL, + pop3_user=NULL, + pop3_pass=NULL + WHERE id='$v_project_id'"; + + db_query( $query ); + + return true; + } + + # -------------------- + # Activate the Mail per Category feature for a project + function mail_categories( $p_project_id , $p_active ) { + $v_project_id = db_prepare_int( $p_project_id ); + + if ($p_active == 'On') { + $v_active = 1; + } else { + $v_active = 0; + } + + $t_project_table = config_get( 'mantis_project_table' ); + + $query = "UPDATE $t_project_table + SET pop3_categories='$v_active' + WHERE id='$v_project_id'"; + + db_query( $query ); + + return true; + } + + # -------------------- + # Return mail account data for the specified project and category + function mail_category_get_account_data( $p_project_id, $p_category ) { + $c_project_id = db_prepare_int( $p_project_id ); + $c_category = db_prepare_string( $p_category ); + + $t_project_category_table = config_get( 'mantis_project_category_table' ); + + $query = "SELECT pop3_host, pop3_user, pop3_pass + FROM $t_project_category_table + WHERE project_id='$c_project_id' AND category='$c_category'"; + + $result = db_query( $query ); + + return db_fetch_array( $result ); + } + + # -------------------- + # Update the mail account data for a category + function mail_category_update( $p_project_id, $p_category, $p_pop3_host, $p_pop3_user, $p_pop3_pass ) { + $c_project_id = db_prepare_int( $p_project_id ); + $c_category = db_prepare_string( $p_category ); + $c_pop3_host = db_prepare_string( $p_pop3_host ); + $c_pop3_user = db_prepare_string( $p_pop3_user ); + $c_pop3_pass = db_prepare_string( $p_pop3_pass ); + + $t_project_category_table = config_get( 'mantis_project_category_table' ); + + $query = "UPDATE $t_project_category_table + SET pop3_host='$c_pop3_host', + pop3_user='$c_pop3_user', + pop3_pass='$c_pop3_pass' + WHERE project_id='$c_project_id' AND category='$c_category'"; + db_query( $query ); + return true; + } + + # -------------------- + # Removes the mail account data for a category + function mail_category_delete( $p_project_id, $p_category ) { + $c_project_id = db_prepare_int( $p_project_id ); + $c_category = db_prepare_string( $p_category ); + + $t_project_table = config_get( 'mantis_project_table' ); + + $t_project_category_table = config_get( 'mantis_project_category_table' ); + + $query = "UPDATE $t_project_category_table + SET pop3_host=NULL, + pop3_user=NULL, + pop3_pass=NULL + WHERE project_id='$c_project_id' AND category='$c_category'"; + + db_query( $query ); + return true; + } + + # -------------------- + # return all mailaccounts + # return an empty array if there are no + function mail_get_accounts() { + $v_accounts = array(); + $t_projects = mail_project_get_all_rows(); + + foreach ($t_projects as $t_project) { + if ($t_project['pop3_categories']) { + $v_categories = mail_categories_get_all_rows( $t_project['pop3_categories'] ); + $v_accounts = array_merge($v_accounts, $v_categories); + } else { + array_push($v_accounts, $t_project); + } + } + + return $v_accounts; + } + + # -------------------- + # return all projects with valid data for mail access + # return an empty array if there are no such projects + function mail_project_get_all_rows() { + $v_projects = array(); + $t_projects = project_get_all_rows(); + + foreach ($t_projects as $t_project) { + if ($t_project['pop3_host'] || $t_project['pop3_categories']) { + array_push($v_projects, $t_project); + } + } + + return $v_projects; + } + + # -------------------- + # return all projects with valid data for mail access + # return an empty array if there are no such projects + function mail_categories_get_all_rows( $p_project_id ) { + $v_categories = array(); + $t_categories = category_get_all_rows( $p_project_id ); + + foreach ($t_categories as $t_category) { + if ($t_category['pop3_host']) { + $t_category['id'] = $p_project_id; + array_push($v_categories, $t_category); + } + } + + return $v_categories; + } + + # -------------------- + # return all mails for an account + # return an empty array if there are no new mails + function mail_get_all_mails( $p_account ) { + $v_mails = array(); + $t_pop3 = &new Net_POP3(); + $t_pop3_host = $p_account['pop3_host']; + $t_pop3_user = $p_account['pop3_user']; + $t_pop3_password = $p_account['pop3_pass']; + + $t_pop3->connect($t_pop3_host, 110); + $t_pop3->login($t_pop3_user, $t_pop3_password); + + for ($i = 1; $i <= $t_pop3->numMsg(); $i++) { + $t_mail = $t_pop3->getParsedHeaders($i); + $t_mail['X-Mantis-Body'] = $t_pop3->getBody($i); + $t_mail['X-Mantis-Complete'] = $t_pop3->getMsg($i); + array_push($v_mails, $t_mail); + $t_pop3->deleteMsg($i); + } + + $t_pop3->disconnect(); + return $v_mails; + } + + # -------------------- + # return the mailadress from the mail's 'From' + function mail_parse_address ( $p_mailaddress ) { + if (preg_match("/<(.*?)>/", $p_mailaddress, $matches)) { + $c_mailaddress = $matches[1]; + } + + return $c_mailaddress; + } + + # -------------------- + # return the a valid username from an email address + function mail_user_name_from_address ( $p_mailaddress ) { + + return preg_replace("/[@\.-]/", '_', $p_mailaddress); + } + + # -------------------- + # return true if there is a valid mantis bug referernce in subject + function mail_is_a_bugnote ($p_mail_subject) { + return preg_match("/\[([A-Za-z0-9-_\.]*\s[0-9]{7})\]/", $p_mail_subject); + } + + # -------------------- + # return the bug's id from the subject + function mail_get_bug_id_from_subject ( $p_mail_subject) { + preg_match("/\[([A-Za-z0-9-_\.]*\s([0-9]{7}?))\]/", $p_mail_subject, $v_matches); + + return $v_matches[2]; + } + + # -------------------- + # return the user id for the mail reporting user + function mail_get_user ($p_mailaddress) { + $t_mail_use_reporter = config_get( 'mail_use_reporter' ); + $t_mail_auto_signup = config_get( 'mail_auto_signup' ); + $t_mail_reporter = config_get( 'mail_reporter' ); + + $c_mailaddress = mail_parse_address( $p_mailaddress ); + + if ( $t_mail_use_reporter ) { + // Always report as mail_reporter + $t_reporter_id = user_get_id_by_name( $t_mail_reporter ); + } else { + // Try to get the reporting users id + $t_reporter_id = user_get_id_by_mail ( $c_mailaddress ); + if ( ! $t_reporter_id && $t_mail_auto_signup ) { + // So, we've to sign up a new user... + $t_user_name = mail_user_name_from_address ( $c_mailaddress ); + user_signup($t_user_name, $c_mailaddress); + $t_reporter_id = user_get_id_by_name($t_user_name); + } elseif ( ! $t_reporter_id ) { + // Fall back to the default mail_reporter + $t_reporter_id = user_get_id_by_name( $t_mail_reporter ); + } + } + + return $t_reporter_id; + } + + # -------------------- + # Adds a bug which is reported via email + # Taken from bug_report.php and + function mail_add_bug( $p_mail, $p_account ) { + $t_bug_data = new BugData; + $t_bug_data->build = gpc_get_string( 'build', '' ); + $t_bug_data->platform = gpc_get_string( 'platform', '' ); + $t_bug_data->os = gpc_get_string( 'os', '' ); + $t_bug_data->os_build = gpc_get_string( 'os_build', '' ); + $t_bug_data->version = gpc_get_string( 'product_version', '' ); + $t_bug_data->profile_id = gpc_get_int( 'profile_id', 0 ); + $t_bug_data->handler_id = gpc_get_int( 'handler_id', 0 ); + $t_bug_data->view_state = gpc_get_int( 'view_state', config_get( 'default_bug_view_status' ) ); + + if ( $p_account['category']) { + $t_bug_data->category = gpc_get_string( 'category', $p_account['category'] ); + } else { + $t_bug_data->category = gpc_get_string( 'category', '' ); + } + $t_bug_data->reproducibility = 10; + $t_bug_data->severity = 50; + $t_bug_data->priority = gpc_get_int( 'priority', NORMAL ); + $t_bug_data->summary = $p_mail['Subject']; + $t_bug_data->description = $p_mail['X-Mantis-Body']; + $t_bug_data->steps_to_reproduce = gpc_get_string( 'steps_to_reproduce', '' ); + $t_bug_data->additional_information = $p_mail['X-Mantis-Complete']; + + $t_bug_data->project_id = $p_account['id']; + + $t_bug_data->reporter_id = mail_get_user( $p_mail['From'] ); + + if (mail_is_a_bugnote($p_mail['Subject'])) + { + # Add a bug note + $t_bug_id = mail_get_bug_id_from_subject( $p_mail['Subject'] ); + if ( ! bug_is_readonly( $t_bug_id ) ) { + bugnote_add ( $t_bug_id, $p_mail['X-Mantis-Body'] ); + email_bugnote_add ( $t_bug_id ); + } + } + else + { + # Create the bug + $t_bug_id = bug_create( $t_bug_data ); + email_new_bug( $t_bug_id ); + } + + } + +?> diff -Nru mantis-0.19.0.orig/core/user_api.php mantis-0.19.0/core/user_api.php --- mantis-0.19.0.orig/core/user_api.php Mon Aug 23 16:13:34 2004 +++ mantis-0.19.0/core/user_api.php Wed Sep 15 17:20:36 2004 @@ -478,6 +478,27 @@ } # -------------------- + # get a user id from an mail address + # return false if the mail address does not exist + function user_get_id_by_mail( $p_mailaddress ) { + + $c_mailaddress = db_prepare_string( $p_mailaddress ); + + $t_user_table = config_get( 'mantis_user_table' ); + + $query = "SELECT id + FROM $t_user_table + WHERE email='$c_mailaddress'"; + $result = db_query( $query ); + + if ( 0 == db_num_rows( $result ) ) { + return false; + } else { + return db_result( $result ); + } + } + + # -------------------- # return all data associated with a particular user name # return false if the username does not exist function user_get_row_by_name( $p_username ) { diff -Nru mantis-0.19.0.orig/doc/README.bug_report_mail mantis-0.19.0/doc/README.bug_report_mail --- mantis-0.19.0.orig/doc/README.bug_report_mail Thu Jan 1 01:00:00 1970 +++ mantis-0.19.0/doc/README.bug_report_mail Wed Sep 15 19:01:55 2004 @@ -0,0 +1,58 @@ +The current version of bug_report_mail only support plain text e-mails +and POP3 Mailaccounts with PEAR's Net_POP3 packge. + +bug_report_mail is able to recognize if mail is a reply to an already opened +bug and adds the content as a bugnote. + +If you are alway running Mantis you have to alter your projects table +with the sql/bug_report_mail.sql script. +If not, you can create the database tables in the way described in +the doc/INSTALL file. + +This patch changes the following files: + core/category_api.php + core/user_api.php + config_defaults_inc.php + manage_proj_cat_edit_page.php + manage_proj_edit_page.php +These files are new: + core/mail_api.php + sql/bug_report_mail.sql + bug_report_mail.php + manage_proj_cat_mail_delete.php + manage_proj_cat_mail_update.php + manage_proj_mail_categories.php + manage_proj_mail_delete.php + manage_proj_mail_update.php + +After installing this patch, you can add a POP3 server's hostname +and authentication data for each of your projects with the project edit form. + +There are two ways to receive mail with bug_report_mail: +The secure (and default) way is to use a standard reporting user: +You have to create a reporter account, for example 'Mail'. +The name for this reporter account you have to write in your config_inc.php file: + $g_mail_reporter = "Mail"; +and then, bug_report_mail must be informed to behave like this: + $g_mail_use_reporter = ON; + +The other way is to signup new user accounts automatically. +For using this, you have to change this + $g_mail_auto_signup = OFF; +from OFF to ON. +Now, bug_report_mail will look for an user named like the mail's sender +or an user which mail adress is identical. +If no user is found, then a new account will be created. +The new user's name will be the mail address. + +This could be used for attacks, but there is no other way in the moment. + +After this, bug_report_mail can be used via cron like this: + +*/5 * * * * lynx --dump http://mantis.homepage.com/bug_report_mail.php + +This line uses lynx to fetch bug reports from via POP3 every 5 minutes. + +This addon is distributed under the same condition as Mantis itself. + +Gerrit Beine, August 2004 diff -Nru mantis-0.19.0.orig/manage_proj_cat_edit_page.php mantis-0.19.0/manage_proj_cat_edit_page.php --- mantis-0.19.0.orig/manage_proj_cat_edit_page.php Mon Apr 12 23:04:34 2004 +++ mantis-0.19.0/manage_proj_cat_edit_page.php Wed Sep 15 18:26:32 2004 @@ -15,6 +15,7 @@ $t_core_path = config_get( 'core_path' ); require_once( $t_core_path.'category_api.php' ); + require_once( $t_core_path.'mail_api.php' ); ?> <?php $f_project_id = gpc_get_int( 'project_id' ); @@ -24,6 +25,12 @@ $t_row = category_get_row( $f_project_id, $f_category ); $t_assigned_to = $t_row['user_id']; + $t_mail = mail_get_account_data( $f_project_id ); + if ( $t_mail['pop3_categories'] ) { + $t_category_mail = mail_category_get_account_data( $f_project_id, $f_category ); + print_r($t_category_mail); + } + ?> <?php html_page_top1() ?> <?php html_page_top2() ?> @@ -83,5 +90,60 @@ <input type="submit" class="button" value="<?php echo lang_get( 'delete_category_button' ) ?>" /> </form> </div> + +<?php if ( $t_mail['pop3_categories'] ) { ?> +<!-- MAIL ACCOUNT CHANGE --> +<br /> +<div align="center"> + <form method="post" action="manage_proj_cat_mail_update.php"> + <input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" /> + <input type="hidden" name="category" value="<?php echo string_attribute( $f_category ) ?>" /> + <table class="width75" cellspacing="1"> + <tr> + <td class="form-title" colspan="4"> + <?php echo 'Category Mail Account Settings' ?> + </td> + </tr> + <tr class="row-1"> + <td class="category" width="25%"> + <?php echo "POP3 Host"?> + </td> + <td width="75%"> + <input type="text" name="pop3_host" size="64" maxlength="255" value="<?php echo string_attribute( $t_category_mail['pop3_host'] ) ?>" /> + </td> + </tr> + <tr class="row-1"> + <td class="category" width="25%"> + <?php echo "POP3 User"?> + </td> + <td width="75%"> + <input type="text" name="pop3_user" size="64" maxlength="255" value="<?php echo string_attribute( $t_category_mail['pop3_user'] ) ?>" /> + </td> + </tr> + <tr class="row-1"> + <td class="category" width="25%"> + <?php echo "POP3 Password"?> + </td> + <td width="75%"> + <input type="text" name="pop3_pass" size="64" maxlength="255" value="<?php echo string_attribute( $t_category_mail['pop3_pass'] ) ?>" /> + </td> + </tr> + <tr> + <td colspan="2"> + <input type="submit" value="<?php echo 'Set Mail Account Data' ?>" /> + </td> + </tr> + </table> + </form> +</div> +<!-- MAIL ACCOUNT RESET --> +<div class="border-center"> + <form method="post" action="manage_proj_cat_mail_delete.php"> + <input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" /> + <input type="hidden" name="category" value="<?php echo string_attribute( $f_category ) ?>" /> + <input type="submit" value="<?php echo 'Delete Mail Account Data' ?>" /> + </form> +</div> +<?php } ?> <?php html_page_bottom1( __FILE__ ) ?> diff -Nru mantis-0.19.0.orig/manage_proj_cat_mail_delete.php mantis-0.19.0/manage_proj_cat_mail_delete.php --- mantis-0.19.0.orig/manage_proj_cat_mail_delete.php Thu Jan 1 01:00:00 1970 +++ mantis-0.19.0/manage_proj_cat_mail_delete.php Wed Sep 15 18:26:08 2004 @@ -0,0 +1,43 @@ +<?php + # Mantis - a php based bugtracking system + # Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net + # Copyright (C) 2004 Gerrit Beine - gerrit.beine@pitcom.de + # This program is distributed under the terms and conditions of the GPL + # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id$ + # -------------------------------------------------------- + + require_once( 'core.php' ); + + $t_core_path = config_get( 'core_path' ); + + require_once( $t_core_path . 'mail_api.php' ); + + $f_project_id = gpc_get_int( 'project_id' ); + $f_category = gpc_get_string( 'category' ); + + access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id ); + + mail_category_delete( $f_project_id, $f_category ); + + $t_redirect_url = 'manage_proj_cat_edit_page.php?project_id=' . $f_project_id . '&category=' . $f_category; + + html_page_top1(); + + html_meta_redirect( $t_redirect_url ); + + html_page_top2(); +?> + +<br /> +<div align="center"> +<?php + echo lang_get( 'operation_successful' ) . '<br />'; + + print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) ); +?> +</div> + +<?php html_page_bottom1( __FILE__ ) ?> diff -Nru mantis-0.19.0.orig/manage_proj_cat_mail_update.php mantis-0.19.0/manage_proj_cat_mail_update.php --- mantis-0.19.0.orig/manage_proj_cat_mail_update.php Thu Jan 1 01:00:00 1970 +++ mantis-0.19.0/manage_proj_cat_mail_update.php Wed Sep 15 18:14:39 2004 @@ -0,0 +1,58 @@ +<?php + # Mantis - a php based bugtracking system + # Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net + # Copyright (C) 2004 Gerrit Beine - gerrit.beine@pitcom.de + # This program is distributed under the terms and conditions of the GPL + # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id$ + # -------------------------------------------------------- + + require_once( 'core.php' ); + + $t_core_path = config_get( 'core_path' ); + + require_once( $t_core_path . 'mail_api.php' ); + + $f_project_id = gpc_get_int( 'project_id' ); + $f_pop3_host = gpc_get_string( 'pop3_host' ); + $f_pop3_user = gpc_get_string( 'pop3_user' ); + $f_pop3_pass = gpc_get_string( 'pop3_pass' ); + $f_category = gpc_get_string( 'category' ); + + access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id ); + + if ( is_blank( $f_pop3_host ) ) { + trigger_error( ERROR_EMPTY_FIELD, ERROR ); + } + else { + if ( is_blank( $f_pop3_user ) ) { + trigger_error( ERROR_EMPTY_FIELD, ERROR ); + } + if ( is_blank( $f_pop3_pass ) ) { + trigger_error( ERROR_EMPTY_FIELD, ERROR ); + } + } + + mail_category_update( $f_project_id, $f_category, $f_pop3_host, $f_pop3_user, $f_pop3_pass ); + + $t_redirect_url = 'manage_proj_cat_edit_page.php?project_id=' . $f_project_id . '&category=' . $f_category; + + html_page_top1(); + + html_meta_redirect( $t_redirect_url ); + + html_page_top2(); +?> + +<br /> +<div align="center"> +<?php + echo lang_get( 'operation_successful' ) . '<br />'; + + print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) ); +?> +</div> + +<?php html_page_bottom1( __FILE__ ) ?> diff -Nru mantis-0.19.0.orig/manage_proj_edit_page.php mantis-0.19.0/manage_proj_edit_page.php --- mantis-0.19.0.orig/manage_proj_edit_page.php Thu Jul 15 00:16:34 2004 +++ mantis-0.19.0/manage_proj_edit_page.php Wed Sep 15 18:27:49 2004 @@ -18,6 +18,7 @@ require_once( $t_core_path . 'version_api.php' ); require_once( $t_core_path . 'custom_field_api.php' ); require_once( $t_core_path . 'icon_api.php' ); + require_once( $t_core_path . 'mail_api.php' ); ?> <?php $f_project_id = gpc_get_int( 'project_id' ); @@ -25,6 +26,8 @@ access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id ); $row = project_get_row( $f_project_id ); + $mail = mail_get_account_data( $f_project_id ); + ?> <?php html_page_top1() ?> <?php html_page_top2() ?> @@ -534,4 +537,74 @@ </table> </div> +<?php if ( ! $mail['pop3_categories'] ) { ?> +<!-- MAIL ACCOUNT CHANGE --> +<br /> +<div align="center"> + <form method="post" action="manage_proj_mail_update.php"> + <input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" /> + <table class="width75" cellspacing="1"> + <tr> + <td class="form-title" colspan="4"> + <?php echo 'Mail Account Settings' ?> + </td> + </tr> + <tr class="row-1"> + <td class="category" width="25%"> + <?php echo "POP3 Host"?> + </td> + <td width="75%"> + <input type="text" name="pop3_host" size="64" maxlength="255" value="<?php echo string_attribute( $mail['pop3_host'] ) ?>" /> + </td> + </tr> + <tr class="row-1"> + <td class="category" width="25%"> + <?php echo "POP3 User"?> + </td> + <td width="75%"> + <input type="text" name="pop3_user" size="64" maxlength="255" value="<?php echo string_attribute( $mail['pop3_user'] ) ?>" /> + </td> + </tr> + <tr class="row-1"> + <td class="category" width="25%"> + <?php echo "POP3 Password"?> + </td> + <td width="75%"> + <input type="text" name="pop3_pass" size="64" maxlength="255" value="<?php echo string_attribute( $mail['pop3_pass'] ) ?>" /> + </td> + </tr> + <tr> + <td colspan="2"> + <input type="submit" value="<?php echo 'Set Mail Account Data' ?>" /> + </td> + </tr> + </table> + </form> +</div> +<!-- MAIL ACCOUNT RESET --> +<div class="border-center"> + <form method="post" action="manage_proj_mail_delete.php"> + <input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" /> + <input type="submit" value="<?php echo 'Delete Mail Account Data' ?>" /> + </form> +</div> +<br /> +<!-- MAIL ACCOUNT CATEGORIES --> +<div class="border-center"> + <form method="post" action="manage_proj_mail_categories.php"> + <input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" /> + <input type="hidden" name="categories" value="On" /> + <input type="submit" value="<?php echo 'Activate Mail Account per Category' ?>" /> + </form> +</div> +<?php } else { ?> +<!-- MAIL ACCOUNT CATEGORIES --> +<div class="border-center"> + <form method="post" action="manage_proj_mail_categories.php"> + <input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" /> + <input type="hidden" name="categories" value="Off" /> + <input type="submit" value="<?php echo 'Deactivate Mail Account per Category' ?>" /> + </form> +</div> +<?php } ?> <?php html_page_bottom1( __FILE__ ) ?> diff -Nru mantis-0.19.0.orig/manage_proj_mail_categories.php mantis-0.19.0/manage_proj_mail_categories.php --- mantis-0.19.0.orig/manage_proj_mail_categories.php Thu Jan 1 01:00:00 1970 +++ mantis-0.19.0/manage_proj_mail_categories.php Wed Sep 15 18:03:32 2004 @@ -0,0 +1,43 @@ +<?php + # Mantis - a php based bugtracking system + # Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net + # Copyright (C) 2004 Gerrit Beine - gerrit.beine@pitcom.de + # This program is distributed under the terms and conditions of the GPL + # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id$ + # -------------------------------------------------------- + + require_once( 'core.php' ); + + $t_core_path = config_get( 'core_path' ); + + require_once( $t_core_path . 'mail_api.php' ); + + $f_project_id = gpc_get_int( 'project_id' ); + $f_activate = gpc_get_string( 'categories' ); + + access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id ); + + mail_categories( $f_project_id, $f_activate ); + + $t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $f_project_id; + + html_page_top1(); + + html_meta_redirect( $t_redirect_url ); + + html_page_top2(); +?> + +<br /> +<div align="center"> +<?php + echo lang_get( 'operation_successful' ) . '<br />'; + + print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) ); +?> +</div> + +<?php html_page_bottom1( __FILE__ ) ?> diff -Nru mantis-0.19.0.orig/manage_proj_mail_delete.php mantis-0.19.0/manage_proj_mail_delete.php --- mantis-0.19.0.orig/manage_proj_mail_delete.php Thu Jan 1 01:00:00 1970 +++ mantis-0.19.0/manage_proj_mail_delete.php Wed Sep 15 17:50:34 2004 @@ -0,0 +1,42 @@ +<?php + # Mantis - a php based bugtracking system + # Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net + # Copyright (C) 2004 Gerrit Beine - gerrit.beine@pitcom.de + # This program is distributed under the terms and conditions of the GPL + # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id$ + # -------------------------------------------------------- + + require_once( 'core.php' ); + + $t_core_path = config_get( 'core_path' ); + + require_once( $t_core_path . 'mail_api.php' ); + + $f_project_id = gpc_get_int( 'project_id' ); + + access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id ); + + mail_delete( $f_project_id ); + + $t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $f_project_id; + + html_page_top1(); + + html_meta_redirect( $t_redirect_url ); + + html_page_top2(); +?> + +<br /> +<div align="center"> +<?php + echo lang_get( 'operation_successful' ) . '<br />'; + + print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) ); +?> +</div> + +<?php html_page_bottom1( __FILE__ ) ?> diff -Nru mantis-0.19.0.orig/manage_proj_mail_update.php mantis-0.19.0/manage_proj_mail_update.php --- mantis-0.19.0.orig/manage_proj_mail_update.php Thu Jan 1 01:00:00 1970 +++ mantis-0.19.0/manage_proj_mail_update.php Wed Sep 15 17:50:31 2004 @@ -0,0 +1,58 @@ +<?php + # Mantis - a php based bugtracking system + # Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net + # Copyright (C) 2004 Gerrit Beine - gerrit.beine@pitcom.de + # This program is distributed under the terms and conditions of the GPL + # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id$ + # -------------------------------------------------------- + + require_once( 'core.php' ); + + $t_core_path = config_get( 'core_path' ); + + require_once( $t_core_path . 'mail_api.php' ); + + $f_project_id = gpc_get_int( 'project_id' ); + $f_pop3_host = gpc_get_string( 'pop3_host' ); + $f_pop3_user = gpc_get_string( 'pop3_user' ); + $f_pop3_pass = gpc_get_string( 'pop3_pass' ); + + echo $f_project_id; + access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id ); + + if ( is_blank( $f_pop3_host ) ) { + trigger_error( ERROR_EMPTY_FIELD, ERROR ); + } + else { + if ( is_blank( $f_pop3_user ) ) { + trigger_error( ERROR_EMPTY_FIELD, ERROR ); + } + if ( is_blank( $f_pop3_pass ) ) { + trigger_error( ERROR_EMPTY_FIELD, ERROR ); + } + } + + mail_update( $f_project_id, $f_pop3_host, $f_pop3_user, $f_pop3_pass ); + + $t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $f_project_id; + + html_page_top1(); + + html_meta_redirect( $t_redirect_url ); + + html_page_top2(); +?> + +<br /> +<div align="center"> +<?php + echo lang_get( 'operation_successful' ) . '<br />'; + + print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) ); +?> +</div> + +<?php html_page_bottom1( __FILE__ ) ?> diff -Nru mantis-0.19.0.orig/sql/bug_report_mail.sql mantis-0.19.0/sql/bug_report_mail.sql --- mantis-0.19.0.orig/sql/bug_report_mail.sql Thu Jan 1 01:00:00 1970 +++ mantis-0.19.0/sql/bug_report_mail.sql Wed Sep 15 18:13:15 2004 @@ -0,0 +1,12 @@ +ALTER TABLE `mantis_project_table` +ADD `pop3_host` VARCHAR( 255 ) DEFAULT NULL , +ADD `pop3_user` VARCHAR( 255 ) DEFAULT NULL , +ADD `pop3_pass` VARCHAR( 255 ) DEFAULT NULL , +ADD `pop3_categories` ENUM( '0', '1' ) DEFAULT '0' NOT NULL ; + +ALTER TABLE `mantis_project_category_table` +ADD `pop3_host` VARCHAR( 255 ) DEFAULT NULL , +ADD `pop3_user` VARCHAR( 255 ) DEFAULT NULL , +ADD `pop3_pass` VARCHAR( 255 ) DEFAULT NULL ; + + diff -Nru mantis-0.19.0.orig/sql/db_generate.sql mantis-0.19.0/sql/db_generate.sql --- mantis-0.19.0.orig/sql/db_generate.sql Sun Sep 12 14:19:24 2004 +++ mantis-0.19.0/sql/db_generate.sql Wed Sep 15 18:30:43 2004 @@ -328,6 +328,10 @@ project_id int(7) unsigned NOT NULL default '0', category varchar(64) NOT NULL default '', user_id int(7) unsigned NOT NULL default '0', + pop3_host varchar( 255 ) default NULL , + pop3_user varchar( 255 ) default NULL , + pop3_pass varchar( 255 ) default NULL , + pop3_pass varchar( 255 ) default NULL , PRIMARY KEY (project_id,category) ) TYPE=MyISAM; @@ -377,6 +381,11 @@ access_min int(2) NOT NULL default '10', file_path varchar(250) NOT NULL default '', description text NOT NULL, + pop3_host varchar( 255 ) default NULL , + pop3_user varchar( 255 ) default NULL , + pop3_pass varchar( 255 ) default NULL , + pop3_pass varchar( 255 ) default NULL , + pop3_categories enum( '0','1' ) NOT NULL default '0', PRIMARY KEY (id), UNIQUE KEY name (name), KEY id (id) mantis-0.19.1.patch (29,263 bytes)
diff -Nur mantis-0.19.1.orig/bug_report_mail.php mantis-0.19.1/bug_report_mail.php --- mantis-0.19.1.orig/bug_report_mail.php Thu Jan 1 01:00:00 1970 +++ mantis-0.19.1/bug_report_mail.php Wed Sep 15 18:59:59 2004 @@ -0,0 +1,33 @@ +<?php + # Mantis - a php based bugtracking system + # Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net + # Copyright (C) 2004 Gerrit Beine - gerrit.beine@pitcom.de + # This program is distributed under the terms and conditions of the GPL + # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id$ + # -------------------------------------------------------- + + # This page receives an E-Mail via POP3 and generates an Report + header("Content-type: text/plain"); + + require_once( 'core.php' ); + + $t_core_path = config_get( 'core_path' ); + + require_once( $t_core_path . 'string_api.php' ); + require_once( $t_core_path . 'bug_api.php' ); + require_once( $t_core_path . 'mail_api.php' ); + + $t_mailaccounts = mail_get_accounts(); + + foreach ($t_mailaccounts as $t_mailaccount) { + $t_mails = mail_get_all_mails($t_mailaccount); + foreach ($t_mails as $t_mail) + { + mail_add_bug($t_mail, $t_mailaccount); + } + } +?> + diff -Nur mantis-0.19.1.orig/config_defaults_inc.php mantis-0.19.1/config_defaults_inc.php --- mantis-0.19.1.orig/config_defaults_inc.php Sat Nov 6 12:54:14 2004 +++ mantis-0.19.1/config_defaults_inc.php Sat Nov 6 19:59:13 2004 @@ -1470,4 +1470,20 @@ # NOTE: These are meaningless under Windows! Just ignore them! $g_dot_tool = '/usr/bin/dot'; $g_neato_tool = '/usr/bin/neato'; + + ###################### + # Mail Reporting + ###################### + + # --- mail reporting settings ----- + # This tells Mantis to report all the Mail with only one account + $g_mail_use_reporter = ON; + + # The account's name for mail reporting + # Also used for fallback if a user is not found in database + $g_mail_reporter = 'Mail'; + + # Signup new users automatically (possible security risk!) + # Default is OFF, ignored if mail_use_reporter is ON + $g_mail_auto_signup = OFF; ?> diff -Nur mantis-0.19.1.orig/core/category_api.php mantis-0.19.1/core/category_api.php --- mantis-0.19.1.orig/core/category_api.php Thu Apr 8 21:04:52 2004 +++ mantis-0.19.1/core/category_api.php Sat Nov 6 19:41:45 2004 @@ -206,7 +206,7 @@ $t_project_category_table = config_get( 'mantis_project_category_table' ); - $query = "SELECT category, user_id + $query = "SELECT category, user_id, pop3_host, pop3_user, pop3_pass FROM $t_project_category_table WHERE project_id='$c_project_id' ORDER BY category"; diff -Nur mantis-0.19.1.orig/core/mail_api.php mantis-0.19.1/core/mail_api.php --- mantis-0.19.1.orig/core/mail_api.php Thu Jan 1 01:00:00 1970 +++ mantis-0.19.1/core/mail_api.php Sat Nov 6 18:27:31 2004 @@ -0,0 +1,341 @@ +<?php + # Mantis - a php based bugtracking system + # Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net + # Copyright (C) 2004 Gerrit Beine - gerrit.beine@pitcom.de + # This program is distributed under the terms and conditions of the GPL + # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id$ + # -------------------------------------------------------- + + $t_core_dir = dirname( __FILE__ ).DIRECTORY_SEPARATOR; + + require_once( $t_core_dir . 'bug_api.php' ); + require_once( $t_core_dir . 'bugnote_api.php' ); + require_once( $t_core_dir . 'user_api.php' ); + require_once( $t_core_dir . 'project_api.php' ); + + # This page receives an E-Mail via POP3 and generates an Report + + require_once( 'Net/POP3.php' ); + + # -------------------- + # Return mail account data for the specified project + function mail_get_account_data( $p_project_id ) { + $v_project_id = db_prepare_int( $p_project_id ); + + $t_project_table = config_get( 'mantis_project_table' ); + + $query = "SELECT pop3_host, pop3_user, pop3_pass, pop3_categories + FROM $t_project_table + WHERE id='$v_project_id'"; + + $result = db_query( $query ); + + return db_fetch_array( $result ); + } + + # -------------------- + # Update the mail account data + function mail_update( $p_project_id, $p_pop3_host, $p_pop3_user, $p_pop3_pass ) { + $v_project_id = db_prepare_int( $p_project_id ); + $v_pop3_host = db_prepare_string( $p_pop3_host ); + $v_pop3_user = db_prepare_string( $p_pop3_user ); + $v_pop3_pass = db_prepare_string( $p_pop3_pass ); + + $t_project_table = config_get( 'mantis_project_table' ); + + $query = "UPDATE $t_project_table + SET pop3_host='$v_pop3_host', + pop3_user='$v_pop3_user', + pop3_pass='$v_pop3_pass' + WHERE id='$v_project_id'"; + db_query( $query ); + return true; + } + + # -------------------- + # Removes the mail account data + function mail_delete( $p_project_id ) { + $v_project_id = db_prepare_int( $p_project_id ); + + $t_project_table = config_get( 'mantis_project_table' ); + + $query = "UPDATE $t_project_table + SET pop3_host=NULL, + pop3_user=NULL, + pop3_pass=NULL + WHERE id='$v_project_id'"; + + db_query( $query ); + + return true; + } + + # -------------------- + # Activate the Mail per Category feature for a project + function mail_categories( $p_project_id , $p_active ) { + $v_project_id = db_prepare_int( $p_project_id ); + + if ($p_active == 'On') { + $v_active = 1; + } else { + $v_active = 0; + } + + $t_project_table = config_get( 'mantis_project_table' ); + + $query = "UPDATE $t_project_table + SET pop3_categories='$v_active' + WHERE id='$v_project_id'"; + + db_query( $query ); + + return true; + } + + # -------------------- + # Return mail account data for the specified project and category + function mail_category_get_account_data( $p_project_id, $p_category ) { + $c_project_id = db_prepare_int( $p_project_id ); + $c_category = db_prepare_string( $p_category ); + + $t_project_category_table = config_get( 'mantis_project_category_table' ); + + $query = "SELECT pop3_host, pop3_user, pop3_pass + FROM $t_project_category_table + WHERE project_id='$c_project_id' AND category='$c_category'"; + + $result = db_query( $query ); + + return db_fetch_array( $result ); + } + + # -------------------- + # Update the mail account data for a category + function mail_category_update( $p_project_id, $p_category, $p_pop3_host, $p_pop3_user, $p_pop3_pass ) { + $c_project_id = db_prepare_int( $p_project_id ); + $c_category = db_prepare_string( $p_category ); + $c_pop3_host = db_prepare_string( $p_pop3_host ); + $c_pop3_user = db_prepare_string( $p_pop3_user ); + $c_pop3_pass = db_prepare_string( $p_pop3_pass ); + + $t_project_category_table = config_get( 'mantis_project_category_table' ); + + $query = "UPDATE $t_project_category_table + SET pop3_host='$c_pop3_host', + pop3_user='$c_pop3_user', + pop3_pass='$c_pop3_pass' + WHERE project_id='$c_project_id' AND category='$c_category'"; + db_query( $query ); + return true; + } + + # -------------------- + # Removes the mail account data for a category + function mail_category_delete( $p_project_id, $p_category ) { + $c_project_id = db_prepare_int( $p_project_id ); + $c_category = db_prepare_string( $p_category ); + + $t_project_table = config_get( 'mantis_project_table' ); + + $t_project_category_table = config_get( 'mantis_project_category_table' ); + + $query = "UPDATE $t_project_category_table + SET pop3_host=NULL, + pop3_user=NULL, + pop3_pass=NULL + WHERE project_id='$c_project_id' AND category='$c_category'"; + + db_query( $query ); + return true; + } + + # -------------------- + # return all mailaccounts + # return an empty array if there are no + function mail_get_accounts() { + $v_accounts = array(); + $t_projects = mail_project_get_all_rows(); + + foreach ($t_projects as $t_project) { + if ($t_project['pop3_categories']) { + $v_categories = mail_categories_get_all_rows( $t_project['id'] ); + $v_accounts = array_merge($v_accounts, $v_categories); + } else { + array_push($v_accounts, $t_project); + } + } + + return $v_accounts; + } + + # -------------------- + # return all projects with valid data for mail access + # return an empty array if there are no such projects + function mail_project_get_all_rows() { + $v_projects = array(); + $t_projects = project_get_all_rows(); + + foreach ($t_projects as $t_project) { + if ($t_project['pop3_host'] || $t_project['pop3_categories']) { + array_push($v_projects, $t_project); + } + } + + return $v_projects; + } + + # -------------------- + # return all projects with valid data for mail access + # return an empty array if there are no such projects + function mail_categories_get_all_rows( $p_project_id ) { + $v_categories = array(); + $t_categories = category_get_all_rows( $p_project_id ); + + foreach ($t_categories as $t_category) { + if ($t_category['pop3_host']) { + $t_category['id'] = $p_project_id; + array_push($v_categories, $t_category); + } + } + + return $v_categories; + } + + # -------------------- + # return all mails for an account + # return an empty array if there are no new mails + function mail_get_all_mails( $p_account ) { + $v_mails = array(); + $t_pop3 = &new Net_POP3(); + $t_pop3_host = $p_account['pop3_host']; + $t_pop3_user = $p_account['pop3_user']; + $t_pop3_password = $p_account['pop3_pass']; + + $t_pop3->connect($t_pop3_host, 110); + $t_pop3->login($t_pop3_user, $t_pop3_password); + + for ($i = 1; $i <= $t_pop3->numMsg(); $i++) { + $t_mail = $t_pop3->getParsedHeaders($i); + $t_mail['X-Mantis-Body'] = $t_pop3->getBody($i); + $t_mail['X-Mantis-Complete'] = $t_pop3->getMsg($i); + array_push($v_mails, $t_mail); + $t_pop3->deleteMsg($i); + } + + $t_pop3->disconnect(); + return $v_mails; + } + + # -------------------- + # return the mailadress from the mail's 'From' + function mail_parse_address ( $p_mailaddress ) { + if (preg_match("/<(.*?)>/", $p_mailaddress, $matches)) { + $c_mailaddress = $matches[1]; + } + + return $c_mailaddress; + } + + # -------------------- + # return the a valid username from an email address + function mail_user_name_from_address ( $p_mailaddress ) { + + return preg_replace("/[@\.-]/", '_', $p_mailaddress); + } + + # -------------------- + # return true if there is a valid mantis bug referernce in subject + function mail_is_a_bugnote ($p_mail_subject) { + return preg_match("/\[([A-Za-z0-9-_\.]*\s[0-9]{7})\]/", $p_mail_subject); + } + + # -------------------- + # return the bug's id from the subject + function mail_get_bug_id_from_subject ( $p_mail_subject) { + preg_match("/\[([A-Za-z0-9-_\.]*\s([0-9]{7}?))\]/", $p_mail_subject, $v_matches); + + return $v_matches[2]; + } + + # -------------------- + # return the user id for the mail reporting user + function mail_get_user ($p_mailaddress) { + $t_mail_use_reporter = config_get( 'mail_use_reporter' ); + $t_mail_auto_signup = config_get( 'mail_auto_signup' ); + $t_mail_reporter = config_get( 'mail_reporter' ); + + $c_mailaddress = mail_parse_address( $p_mailaddress ); + + if ( $t_mail_use_reporter ) { + // Always report as mail_reporter + $t_reporter_id = user_get_id_by_name( $t_mail_reporter ); + } else { + // Try to get the reporting users id + $t_reporter_id = user_get_id_by_mail ( $c_mailaddress ); + if ( ! $t_reporter_id && $t_mail_auto_signup ) { + // So, we've to sign up a new user... + $t_user_name = mail_user_name_from_address ( $c_mailaddress ); + user_signup($t_user_name, $c_mailaddress); + $t_reporter_id = user_get_id_by_name($t_user_name); + } elseif ( ! $t_reporter_id ) { + // Fall back to the default mail_reporter + $t_reporter_id = user_get_id_by_name( $t_mail_reporter ); + } + } + + return $t_reporter_id; + } + + # -------------------- + # Adds a bug which is reported via email + # Taken from bug_report.php and + function mail_add_bug( $p_mail, $p_account ) { + $t_bug_data = new BugData; + $t_bug_data->build = gpc_get_string( 'build', '' ); + $t_bug_data->platform = gpc_get_string( 'platform', '' ); + $t_bug_data->os = gpc_get_string( 'os', '' ); + $t_bug_data->os_build = gpc_get_string( 'os_build', '' ); + $t_bug_data->version = gpc_get_string( 'product_version', '' ); + $t_bug_data->profile_id = gpc_get_int( 'profile_id', 0 ); + $t_bug_data->handler_id = gpc_get_int( 'handler_id', 0 ); + $t_bug_data->view_state = gpc_get_int( 'view_state', config_get( 'default_bug_view_status' ) ); + + if ( $p_account['category']) { + $t_bug_data->category = gpc_get_string( 'category', $p_account['category'] ); + } else { + $t_bug_data->category = gpc_get_string( 'category', '' ); + } + $t_bug_data->reproducibility = 10; + $t_bug_data->severity = 50; + $t_bug_data->priority = gpc_get_int( 'priority', NORMAL ); + $t_bug_data->summary = $p_mail['Subject']; + $t_bug_data->description = $p_mail['X-Mantis-Body']; + $t_bug_data->steps_to_reproduce = gpc_get_string( 'steps_to_reproduce', '' ); + $t_bug_data->additional_information = $p_mail['X-Mantis-Complete']; + + $t_bug_data->project_id = $p_account['id']; + + $t_bug_data->reporter_id = mail_get_user( $p_mail['From'] ); + + if (mail_is_a_bugnote($p_mail['Subject'])) + { + # Add a bug note + $t_bug_id = mail_get_bug_id_from_subject( $p_mail['Subject'] ); + if ( ! bug_is_readonly( $t_bug_id ) ) { + bugnote_add ( $t_bug_id, $p_mail['X-Mantis-Body'] ); + email_bugnote_add ( $t_bug_id ); + } + } + else + { + # Create the bug + $t_bug_id = bug_create( $t_bug_data ); + email_new_bug( $t_bug_id ); + } + + } + +?> diff -Nur mantis-0.19.1.orig/core/user_api.php mantis-0.19.1/core/user_api.php --- mantis-0.19.1.orig/core/user_api.php Mon Aug 23 17:13:34 2004 +++ mantis-0.19.1/core/user_api.php Sat Nov 6 19:43:10 2004 @@ -477,6 +477,27 @@ } } + # get a user id from an mail address + # return false if the mail address does not exist + function user_get_id_by_mail( $p_mailaddress ) { + + $c_mailaddress = db_prepare_string( $p_mailaddress ); + + $t_user_table = config_get( 'mantis_user_table' ); + + $query = "SELECT id + FROM $t_user_table + WHERE email='$c_mailaddress'"; + $result = db_query( $query ); + + if ( 0 == db_num_rows( $result ) ) { + return false; + } else { + return db_result( $result ); + } + } + + # -------------------- # -------------------- # return all data associated with a particular user name # return false if the username does not exist diff -Nur mantis-0.19.1.orig/manage_proj_cat_edit_page.php mantis-0.19.1/manage_proj_cat_edit_page.php --- mantis-0.19.1.orig/manage_proj_cat_edit_page.php Tue Apr 13 00:04:34 2004 +++ mantis-0.19.1/manage_proj_cat_edit_page.php Sat Nov 6 19:55:07 2004 @@ -15,6 +15,7 @@ $t_core_path = config_get( 'core_path' ); require_once( $t_core_path.'category_api.php' ); + require_once( $t_core_path.'mail_api.php' ); ?> <?php $f_project_id = gpc_get_int( 'project_id' ); @@ -24,6 +25,10 @@ $t_row = category_get_row( $f_project_id, $f_category ); $t_assigned_to = $t_row['user_id']; + $t_mail = mail_get_account_data( $f_project_id ); + if ( $t_mail['pop3_categories'] ) { + $t_category_mail = mail_category_get_account_data( $f_project_id, $f_category ); + } ?> <?php html_page_top1() ?> <?php html_page_top2() ?> @@ -83,5 +88,60 @@ <input type="submit" class="button" value="<?php echo lang_get( 'delete_category_button' ) ?>" /> </form> </div> + +<?php if ( $t_mail['pop3_categories'] ) { ?> +<!-- MAIL ACCOUNT CHANGE --> +<br /> +<div align="center"> + <form method="post" action="manage_proj_cat_mail_update.php"> + <input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" /> + <input type="hidden" name="category" value="<?php echo string_attribute( $f_category ) ?>" /> + <table class="width75" cellspacing="1"> + <tr> + <td class="form-title" colspan="4"> + <?php echo 'Category Mail Account Settings' ?> + </td> + </tr> + <tr class="row-1"> + <td class="category" width="25%"> + <?php echo "POP3 Host"?> + </td> + <td width="75%"> + <input type="text" name="pop3_host" size="64" maxlength="255" value="<?php echo string_attribute( $t_category_mail['pop3_host'] ) ?>" /> + </td> + </tr> + <tr class="row-1"> + <td class="category" width="25%"> + <?php echo "POP3 User"?> + </td> + <td width="75%"> + <input type="text" name="pop3_user" size="64" maxlength="255" value="<?php echo string_attribute( $t_category_mail['pop3_user'] ) ?>" /> + </td> + </tr> + <tr class="row-1"> + <td class="category" width="25%"> + <?php echo "POP3 Password"?> + </td> + <td width="75%"> + <input type="text" name="pop3_pass" size="64" maxlength="255" value="<?php echo string_attribute( $t_category_mail['pop3_pass'] ) ?>" /> + </td> + </tr> + <tr> + <td colspan="2"> + <input type="submit" value="<?php echo 'Set Mail Account Data' ?>" /> + </td> + </tr> + </table> + </form> +</div> +<!-- MAIL ACCOUNT RESET --> +<div class="border-center"> + <form method="post" action="manage_proj_cat_mail_delete.php"> + <input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" /> + <input type="hidden" name="category" value="<?php echo string_attribute( $f_category ) ?>" /> + <input type="submit" value="<?php echo 'Delete Mail Account Data' ?>" /> + </form> +</div> +<?php } ?> <?php html_page_bottom1( __FILE__ ) ?> diff -Nur mantis-0.19.1.orig/manage_proj_cat_mail_delete.php mantis-0.19.1/manage_proj_cat_mail_delete.php --- mantis-0.19.1.orig/manage_proj_cat_mail_delete.php Thu Jan 1 01:00:00 1970 +++ mantis-0.19.1/manage_proj_cat_mail_delete.php Wed Sep 15 18:26:08 2004 @@ -0,0 +1,43 @@ +<?php + # Mantis - a php based bugtracking system + # Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net + # Copyright (C) 2004 Gerrit Beine - gerrit.beine@pitcom.de + # This program is distributed under the terms and conditions of the GPL + # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id$ + # -------------------------------------------------------- + + require_once( 'core.php' ); + + $t_core_path = config_get( 'core_path' ); + + require_once( $t_core_path . 'mail_api.php' ); + + $f_project_id = gpc_get_int( 'project_id' ); + $f_category = gpc_get_string( 'category' ); + + access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id ); + + mail_category_delete( $f_project_id, $f_category ); + + $t_redirect_url = 'manage_proj_cat_edit_page.php?project_id=' . $f_project_id . '&category=' . $f_category; + + html_page_top1(); + + html_meta_redirect( $t_redirect_url ); + + html_page_top2(); +?> + +<br /> +<div align="center"> +<?php + echo lang_get( 'operation_successful' ) . '<br />'; + + print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) ); +?> +</div> + +<?php html_page_bottom1( __FILE__ ) ?> diff -Nur mantis-0.19.1.orig/manage_proj_cat_mail_update.php mantis-0.19.1/manage_proj_cat_mail_update.php --- mantis-0.19.1.orig/manage_proj_cat_mail_update.php Thu Jan 1 01:00:00 1970 +++ mantis-0.19.1/manage_proj_cat_mail_update.php Wed Sep 15 18:14:39 2004 @@ -0,0 +1,58 @@ +<?php + # Mantis - a php based bugtracking system + # Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net + # Copyright (C) 2004 Gerrit Beine - gerrit.beine@pitcom.de + # This program is distributed under the terms and conditions of the GPL + # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id$ + # -------------------------------------------------------- + + require_once( 'core.php' ); + + $t_core_path = config_get( 'core_path' ); + + require_once( $t_core_path . 'mail_api.php' ); + + $f_project_id = gpc_get_int( 'project_id' ); + $f_pop3_host = gpc_get_string( 'pop3_host' ); + $f_pop3_user = gpc_get_string( 'pop3_user' ); + $f_pop3_pass = gpc_get_string( 'pop3_pass' ); + $f_category = gpc_get_string( 'category' ); + + access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id ); + + if ( is_blank( $f_pop3_host ) ) { + trigger_error( ERROR_EMPTY_FIELD, ERROR ); + } + else { + if ( is_blank( $f_pop3_user ) ) { + trigger_error( ERROR_EMPTY_FIELD, ERROR ); + } + if ( is_blank( $f_pop3_pass ) ) { + trigger_error( ERROR_EMPTY_FIELD, ERROR ); + } + } + + mail_category_update( $f_project_id, $f_category, $f_pop3_host, $f_pop3_user, $f_pop3_pass ); + + $t_redirect_url = 'manage_proj_cat_edit_page.php?project_id=' . $f_project_id . '&category=' . $f_category; + + html_page_top1(); + + html_meta_redirect( $t_redirect_url ); + + html_page_top2(); +?> + +<br /> +<div align="center"> +<?php + echo lang_get( 'operation_successful' ) . '<br />'; + + print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) ); +?> +</div> + +<?php html_page_bottom1( __FILE__ ) ?> diff -Nur mantis-0.19.1.orig/manage_proj_edit_page.php mantis-0.19.1/manage_proj_edit_page.php --- mantis-0.19.1.orig/manage_proj_edit_page.php Wed Sep 22 13:15:32 2004 +++ mantis-0.19.1/manage_proj_edit_page.php Sat Nov 6 19:54:10 2004 @@ -18,6 +18,7 @@ require_once( $t_core_path . 'version_api.php' ); require_once( $t_core_path . 'custom_field_api.php' ); require_once( $t_core_path . 'icon_api.php' ); + require_once( $t_core_path . 'mail_api.php' ); ?> <?php $f_project_id = gpc_get_int( 'project_id' ); @@ -25,6 +26,7 @@ access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id ); $row = project_get_row( $f_project_id ); + $mail = mail_get_account_data( $f_project_id ); ?> <?php html_page_top1() ?> <?php html_page_top2() ?> @@ -551,4 +553,74 @@ </table> </div> +<?php if ( ! $mail['pop3_categories'] ) { ?> +<!-- MAIL ACCOUNT CHANGE --> +<br /> +<div align="center"> + <form method="post" action="manage_proj_mail_update.php"> + <input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" /> + <table class="width75" cellspacing="1"> + <tr> + <td class="form-title" colspan="4"> + <?php echo 'Mail Account Settings' ?> + </td> + </tr> + <tr class="row-1"> + <td class="category" width="25%"> + <?php echo "POP3 Host"?> + </td> + <td width="75%"> + <input type="text" name="pop3_host" size="64" maxlength="255" value="<?php echo string_attribute( $mail['pop3_host'] ) ?>" /> + </td> + </tr> + <tr class="row-1"> + <td class="category" width="25%"> + <?php echo "POP3 User"?> + </td> + <td width="75%"> + <input type="text" name="pop3_user" size="64" maxlength="255" value="<?php echo string_attribute( $mail['pop3_user'] ) ?>" /> + </td> + </tr> + <tr class="row-1"> + <td class="category" width="25%"> + <?php echo "POP3 Password"?> + </td> + <td width="75%"> + <input type="text" name="pop3_pass" size="64" maxlength="255" value="<?php echo string_attribute( $mail['pop3_pass'] ) ?>" /> + </td> + </tr> + <tr> + <td colspan="2"> + <input type="submit" value="<?php echo 'Set Mail Account Data' ?>" /> + </td> + </tr> + </table> + </form> +</div> +<!-- MAIL ACCOUNT RESET --> +<div class="border-center"> + <form method="post" action="manage_proj_mail_delete.php"> + <input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" /> + <input type="submit" value="<?php echo 'Delete Mail Account Data' ?>" /> + </form> +</div> +<br /> +<!-- MAIL ACCOUNT CATEGORIES --> +<div class="border-center"> + <form method="post" action="manage_proj_mail_categories.php"> + <input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" /> + <input type="hidden" name="categories" value="On" /> + <input type="submit" value="<?php echo 'Activate Mail Account per Category' ?>" /> + </form> +</div> +<?php } else { ?> +<!-- MAIL ACCOUNT CATEGORIES --> +<div class="border-center"> + <form method="post" action="manage_proj_mail_categories.php"> + <input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" /> + <input type="hidden" name="categories" value="Off" /> + <input type="submit" value="<?php echo 'Deactivate Mail Account per Category' ?>" /> + </form> +</div> +<?php } ?> <?php html_page_bottom1( __FILE__ ) ?> diff -Nur mantis-0.19.1.orig/manage_proj_mail_categories.php mantis-0.19.1/manage_proj_mail_categories.php --- mantis-0.19.1.orig/manage_proj_mail_categories.php Thu Jan 1 01:00:00 1970 +++ mantis-0.19.1/manage_proj_mail_categories.php Wed Sep 15 18:03:32 2004 @@ -0,0 +1,43 @@ +<?php + # Mantis - a php based bugtracking system + # Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net + # Copyright (C) 2004 Gerrit Beine - gerrit.beine@pitcom.de + # This program is distributed under the terms and conditions of the GPL + # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id$ + # -------------------------------------------------------- + + require_once( 'core.php' ); + + $t_core_path = config_get( 'core_path' ); + + require_once( $t_core_path . 'mail_api.php' ); + + $f_project_id = gpc_get_int( 'project_id' ); + $f_activate = gpc_get_string( 'categories' ); + + access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id ); + + mail_categories( $f_project_id, $f_activate ); + + $t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $f_project_id; + + html_page_top1(); + + html_meta_redirect( $t_redirect_url ); + + html_page_top2(); +?> + +<br /> +<div align="center"> +<?php + echo lang_get( 'operation_successful' ) . '<br />'; + + print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) ); +?> +</div> + +<?php html_page_bottom1( __FILE__ ) ?> diff -Nur mantis-0.19.1.orig/manage_proj_mail_delete.php mantis-0.19.1/manage_proj_mail_delete.php --- mantis-0.19.1.orig/manage_proj_mail_delete.php Thu Jan 1 01:00:00 1970 +++ mantis-0.19.1/manage_proj_mail_delete.php Wed Sep 15 17:50:34 2004 @@ -0,0 +1,42 @@ +<?php + # Mantis - a php based bugtracking system + # Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net + # Copyright (C) 2004 Gerrit Beine - gerrit.beine@pitcom.de + # This program is distributed under the terms and conditions of the GPL + # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id$ + # -------------------------------------------------------- + + require_once( 'core.php' ); + + $t_core_path = config_get( 'core_path' ); + + require_once( $t_core_path . 'mail_api.php' ); + + $f_project_id = gpc_get_int( 'project_id' ); + + access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id ); + + mail_delete( $f_project_id ); + + $t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $f_project_id; + + html_page_top1(); + + html_meta_redirect( $t_redirect_url ); + + html_page_top2(); +?> + +<br /> +<div align="center"> +<?php + echo lang_get( 'operation_successful' ) . '<br />'; + + print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) ); +?> +</div> + +<?php html_page_bottom1( __FILE__ ) ?> diff -Nur mantis-0.19.1.orig/manage_proj_mail_update.php mantis-0.19.1/manage_proj_mail_update.php --- mantis-0.19.1.orig/manage_proj_mail_update.php Thu Jan 1 01:00:00 1970 +++ mantis-0.19.1/manage_proj_mail_update.php Wed Sep 15 17:50:31 2004 @@ -0,0 +1,58 @@ +<?php + # Mantis - a php based bugtracking system + # Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net + # Copyright (C) 2004 Gerrit Beine - gerrit.beine@pitcom.de + # This program is distributed under the terms and conditions of the GPL + # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id$ + # -------------------------------------------------------- + + require_once( 'core.php' ); + + $t_core_path = config_get( 'core_path' ); + + require_once( $t_core_path . 'mail_api.php' ); + + $f_project_id = gpc_get_int( 'project_id' ); + $f_pop3_host = gpc_get_string( 'pop3_host' ); + $f_pop3_user = gpc_get_string( 'pop3_user' ); + $f_pop3_pass = gpc_get_string( 'pop3_pass' ); + + echo $f_project_id; + access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id ); + + if ( is_blank( $f_pop3_host ) ) { + trigger_error( ERROR_EMPTY_FIELD, ERROR ); + } + else { + if ( is_blank( $f_pop3_user ) ) { + trigger_error( ERROR_EMPTY_FIELD, ERROR ); + } + if ( is_blank( $f_pop3_pass ) ) { + trigger_error( ERROR_EMPTY_FIELD, ERROR ); + } + } + + mail_update( $f_project_id, $f_pop3_host, $f_pop3_user, $f_pop3_pass ); + + $t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $f_project_id; + + html_page_top1(); + + html_meta_redirect( $t_redirect_url ); + + html_page_top2(); +?> + +<br /> +<div align="center"> +<?php + echo lang_get( 'operation_successful' ) . '<br />'; + + print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) ); +?> +</div> + +<?php html_page_bottom1( __FILE__ ) ?> mantis-0.19.1-mime.patch (38,514 bytes)
diff -Nur mantis-0.19.1.orig/bug_report_mail.php mantis-0.19.1/bug_report_mail.php --- mantis-0.19.1.orig/bug_report_mail.php Thu Jan 1 01:00:00 1970 +++ mantis-0.19.1/bug_report_mail.php Sun Nov 21 18:19:31 2004 @@ -0,0 +1,33 @@ +<?php + # Mantis - a php based bugtracking system + # Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net + # Copyright (C) 2004 Gerrit Beine - gerrit.beine@pitcom.de + # This program is distributed under the terms and conditions of the GPL + # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id$ + # -------------------------------------------------------- + + # This page receives an E-Mail via POP3 and generates an Report + header("Content-type: text/plain"); + require_once( 'core.php' ); + + $t_core_path = config_get( 'core_path' ); + + require_once( $t_core_path . 'string_api.php' ); + require_once( $t_core_path . 'bug_api.php' ); + require_once( $t_core_path . 'mail_api.php' ); + + $t_mailaccounts = mail_get_accounts(); + + foreach ($t_mailaccounts as $t_mailaccount) { + $t_mails = mail_get_all_mails($t_mailaccount); + foreach ($t_mails as $t_mail) + { + $GLOBALS['g_cache_current_user_id'] = mail_get_user( $t_mail['From'] ); + mail_add_bug($t_mail, $t_mailaccount); + } + } +?> + diff -Nur mantis-0.19.1.orig/config_defaults_inc.php mantis-0.19.1/config_defaults_inc.php --- mantis-0.19.1.orig/config_defaults_inc.php Sat Nov 6 12:54:14 2004 +++ mantis-0.19.1/config_defaults_inc.php Sat Nov 6 19:59:13 2004 @@ -1470,4 +1470,20 @@ # NOTE: These are meaningless under Windows! Just ignore them! $g_dot_tool = '/usr/bin/dot'; $g_neato_tool = '/usr/bin/neato'; + + ###################### + # Mail Reporting + ###################### + + # --- mail reporting settings ----- + # This tells Mantis to report all the Mail with only one account + $g_mail_use_reporter = ON; + + # The account's name for mail reporting + # Also used for fallback if a user is not found in database + $g_mail_reporter = 'Mail'; + + # Signup new users automatically (possible security risk!) + # Default is OFF, ignored if mail_use_reporter is ON + $g_mail_auto_signup = OFF; ?> diff -Nur mantis-0.19.1.orig/config_inc.php mantis-0.19.1/config_inc.php --- mantis-0.19.1.orig/config_inc.php Thu Jan 1 01:00:00 1970 +++ mantis-0.19.1/config_inc.php Sun Sep 12 15:23:34 2004 @@ -0,0 +1,52 @@ +<?php + # Mantis - a php based bugtracking system + # Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org + # Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net + # This program is distributed under the terms and conditions of the GPL + # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id: config_inc.php.sample,v 1.14 2004/09/12 12:23:35 vboctor Exp $ + # -------------------------------------------------------- + + # This sample file contains the essential files that you MUST + # configure to your specific settings. You may override settings + # from config_defaults_inc.php by assigning new values in this file + + # Rename this file to config_inc.php after configuration. + + ########################################################################### + # CONFIGURATION VARIABLES + ########################################################################### + + # In general the value OFF means the feature is disabled and ON means the + # feature is enabled. Any other cases will have an explanation. + + # Look in http://www.mantisbt.org/manual or config_defaults_inc.php for more + # detailed comments. + + # --- database variables --------- + + # set these values to match your setup + $g_hostname = "localhost"; + $g_db_username = "root"; + $g_db_password = ""; + $g_database_name = "bugtracker"; + + # --- email variables ------------- + $g_administrator_email = 'administrator@example.com'; + $g_webmaster_email = 'webmaster@example.com'; + + # the "From: " field in emails + $g_from_email = 'noreply@example.com'; + + # the return address for bounced mail + $g_return_path_email = 'admin@example.com'; + + # --- file upload settings -------- + # This is the master setting to disable *all* file uploading functionality + # + # The default value is ON but you must make sure file uploading is enabled + # in PHP as well. You may need to add "file_uploads = TRUE" to your php.ini. + $g_allow_file_upload = ON; +?> \ No newline at end of file diff -Nur mantis-0.19.1.orig/core/category_api.php mantis-0.19.1/core/category_api.php --- mantis-0.19.1.orig/core/category_api.php Thu Apr 8 21:04:52 2004 +++ mantis-0.19.1/core/category_api.php Sat Nov 6 19:41:45 2004 @@ -206,7 +206,7 @@ $t_project_category_table = config_get( 'mantis_project_category_table' ); - $query = "SELECT category, user_id + $query = "SELECT category, user_id, pop3_host, pop3_user, pop3_pass FROM $t_project_category_table WHERE project_id='$c_project_id' ORDER BY category"; diff -Nur mantis-0.19.1.orig/core/mail_api.php mantis-0.19.1/core/mail_api.php --- mantis-0.19.1.orig/core/mail_api.php Thu Jan 1 01:00:00 1970 +++ mantis-0.19.1/core/mail_api.php Sun Nov 21 18:39:10 2004 @@ -0,0 +1,409 @@ +<?php + # Mantis - a php based bugtracking system + # Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net + # Copyright (C) 2004 Gerrit Beine - gerrit.beine@pitcom.de + # This program is distributed under the terms and conditions of the GPL + # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id$ + # -------------------------------------------------------- + + $t_core_dir = dirname( __FILE__ ).DIRECTORY_SEPARATOR; + + require_once( $t_core_dir . 'bug_api.php' ); + require_once( $t_core_dir . 'bugnote_api.php' ); + require_once( $t_core_dir . 'user_api.php' ); + require_once( $t_core_dir . 'project_api.php' ); + require_once( $t_core_dir . 'file_api.php' ); + + # This page receives an E-Mail via POP3 and generates an Report + + require_once( 'Net/POP3.php' ); + require_once( 'Mail/mimeDecode.php' ); + + # -------------------- + # Return mail account data for the specified project + function mail_get_account_data( $p_project_id ) { + $v_project_id = db_prepare_int( $p_project_id ); + + $t_project_table = config_get( 'mantis_project_table' ); + + $query = "SELECT pop3_host, pop3_user, pop3_pass, pop3_categories + FROM $t_project_table + WHERE id='$v_project_id'"; + + $result = db_query( $query ); + + return db_fetch_array( $result ); + } + + # -------------------- + # Update the mail account data + function mail_update( $p_project_id, $p_pop3_host, $p_pop3_user, $p_pop3_pass ) { + $v_project_id = db_prepare_int( $p_project_id ); + $v_pop3_host = db_prepare_string( $p_pop3_host ); + $v_pop3_user = db_prepare_string( $p_pop3_user ); + $v_pop3_pass = db_prepare_string( $p_pop3_pass ); + + $t_project_table = config_get( 'mantis_project_table' ); + + $query = "UPDATE $t_project_table + SET pop3_host='$v_pop3_host', + pop3_user='$v_pop3_user', + pop3_pass='$v_pop3_pass' + WHERE id='$v_project_id'"; + db_query( $query ); + return true; + } + + # -------------------- + # Removes the mail account data + function mail_delete( $p_project_id ) { + $v_project_id = db_prepare_int( $p_project_id ); + + $t_project_table = config_get( 'mantis_project_table' ); + + $query = "UPDATE $t_project_table + SET pop3_host=NULL, + pop3_user=NULL, + pop3_pass=NULL + WHERE id='$v_project_id'"; + + db_query( $query ); + + return true; + } + + # -------------------- + # Activate the Mail per Category feature for a project + function mail_categories( $p_project_id , $p_active ) { + $v_project_id = db_prepare_int( $p_project_id ); + + if ($p_active == 'On') { + $v_active = 1; + } else { + $v_active = 0; + } + + $t_project_table = config_get( 'mantis_project_table' ); + + $query = "UPDATE $t_project_table + SET pop3_categories='$v_active' + WHERE id='$v_project_id'"; + + db_query( $query ); + + return true; + } + + # -------------------- + # Return mail account data for the specified project and category + function mail_category_get_account_data( $p_project_id, $p_category ) { + $c_project_id = db_prepare_int( $p_project_id ); + $c_category = db_prepare_string( $p_category ); + + $t_project_category_table = config_get( 'mantis_project_category_table' ); + + $query = "SELECT pop3_host, pop3_user, pop3_pass + FROM $t_project_category_table + WHERE project_id='$c_project_id' AND category='$c_category'"; + + $result = db_query( $query ); + + return db_fetch_array( $result ); + } + + # -------------------- + # Update the mail account data for a category + function mail_category_update( $p_project_id, $p_category, $p_pop3_host, $p_pop3_user, $p_pop3_pass ) { + $c_project_id = db_prepare_int( $p_project_id ); + $c_category = db_prepare_string( $p_category ); + $c_pop3_host = db_prepare_string( $p_pop3_host ); + $c_pop3_user = db_prepare_string( $p_pop3_user ); + $c_pop3_pass = db_prepare_string( $p_pop3_pass ); + + $t_project_category_table = config_get( 'mantis_project_category_table' ); + + $query = "UPDATE $t_project_category_table + SET pop3_host='$c_pop3_host', + pop3_user='$c_pop3_user', + pop3_pass='$c_pop3_pass' + WHERE project_id='$c_project_id' AND category='$c_category'"; + db_query( $query ); + return true; + } + + # -------------------- + # Removes the mail account data for a category + function mail_category_delete( $p_project_id, $p_category ) { + $c_project_id = db_prepare_int( $p_project_id ); + $c_category = db_prepare_string( $p_category ); + + $t_project_table = config_get( 'mantis_project_table' ); + + $t_project_category_table = config_get( 'mantis_project_category_table' ); + + $query = "UPDATE $t_project_category_table + SET pop3_host=NULL, + pop3_user=NULL, + pop3_pass=NULL + WHERE project_id='$c_project_id' AND category='$c_category'"; + + db_query( $query ); + return true; + } + + # -------------------- + # return all mailaccounts + # return an empty array if there are no + function mail_get_accounts() { + $v_accounts = array(); + $t_projects = mail_project_get_all_rows(); + + foreach ($t_projects as $t_project) { + if ($t_project['pop3_categories']) { + $v_categories = mail_categories_get_all_rows( $t_project['id'] ); + $v_accounts = array_merge($v_accounts, $v_categories); + } else { + array_push($v_accounts, $t_project); + } + } + + return $v_accounts; + } + + # -------------------- + # return all projects with valid data for mail access + # return an empty array if there are no such projects + function mail_project_get_all_rows() { + $v_projects = array(); + $t_projects = project_get_all_rows(); + + foreach ($t_projects as $t_project) { + if ($t_project['pop3_host'] || $t_project['pop3_categories']) { + array_push($v_projects, $t_project); + } + } + + return $v_projects; + } + + # -------------------- + # return all projects with valid data for mail access + # return an empty array if there are no such projects + function mail_categories_get_all_rows( $p_project_id ) { + $v_categories = array(); + $t_categories = category_get_all_rows( $p_project_id ); + + foreach ($t_categories as $t_category) { + if ($t_category['pop3_host']) { + $t_category['id'] = $p_project_id; + array_push($v_categories, $t_category); + } + } + + return $v_categories; + } + + # -------------------- + # return all mails for an account + # return an empty array if there are no new mails + function mail_get_all_mails( $p_account ) { + $v_mails = array(); + $t_pop3 = &new Net_POP3(); + $t_pop3_host = $p_account['pop3_host']; + $t_pop3_user = $p_account['pop3_user']; + $t_pop3_password = $p_account['pop3_pass']; + $t_pop3->connect($t_pop3_host, 110); + $t_pop3->login($t_pop3_user, $t_pop3_password); + + for ($i = 1; $i <= $t_pop3->numMsg(); $i++) { + $t_mail = mail_parse_content( $t_pop3->getMsg($i) ); + array_push($v_mails, $t_mail); +# $t_pop3->deleteMsg($i); + } + + $t_pop3->disconnect(); + return $v_mails; + } + + # -------------------- + # return the mail parsed for Mantis + function mail_parse_content ( $p_mail ) { + $t_mail = array (); + $t_decoder = new Mail_mimeDecode($p_mail); + $t_params['include_bodies'] = true; + $t_params['decode_bodies'] = true; + $t_params['decode_headers'] = true; + $t_structure = $t_decoder->decode($t_params); + $t_mail['To'] = $t_structure->headers['to']; + $t_mail['From'] = $t_structure->headers['from']; + $t_mail['Subject'] = $t_structure->headers['subject']; + if (is_array($t_structure->parts)) + { + $t_parts = mail_parse_parts( $t_structure->parts ); + } + else + { + $t_parts = array ( mail_parse_part( $t_structure ) ); + } + if ($t_parts[0]['Content-Type'] == 'text/plain') { + $t_body = array_shift($t_parts); + } + else + { + $t_body['Body'] = "It seems, there is no text... :-o"; + } + $t_mail['X-Mantis-Parts'] = $t_parts; + $t_mail['X-Mantis-Body'] = $t_body['Body']; + $t_mail['X-Mantis-Complete'] = $p_mail; + + return $t_mail; + } + + # -------------------- + # return the mail parsed for Mantis + function mail_parse_parts ( $p_parts ) { + $t_parts = array (); + foreach ( $p_parts as $t_part ) { + array_push($t_parts, mail_parse_part( $t_part )); + } + + return $t_parts; + } + + # -------------------- + # return the mail parsed for Mantis + function mail_parse_part ( $p_part ) { + $t_part = array (); + $t_part['Content-Type'] = $p_part->ctype_primary."/".$p_part->ctype_secondary; + $t_part['Name'] = $p_part->ctype_parameters['name']; + $t_part['Body'] = $p_part->body; + + return $t_part; + } + + # -------------------- + # return the mailadress from the mail's 'From' + function mail_parse_address ( $p_mailaddress ) { + if (preg_match("/<(.*?)>/", $p_mailaddress, $matches)) { + $c_mailaddress = $matches[1]; + } + + return $c_mailaddress; + } + + # -------------------- + # return the a valid username from an email address + function mail_user_name_from_address ( $p_mailaddress ) { + return preg_replace("/[@\.-]/", '_', $p_mailaddress); + } + + # -------------------- + # return true if there is a valid mantis bug referernce in subject + function mail_is_a_bugnote ($p_mail_subject) { + return preg_match("/\[([A-Za-z0-9-_\.]*\s[0-9]{7})\]/", $p_mail_subject); + } + + # -------------------- + # return the bug's id from the subject + function mail_get_bug_id_from_subject ( $p_mail_subject) { + preg_match("/\[([A-Za-z0-9-_\.]*\s([0-9]{7}?))\]/", $p_mail_subject, $v_matches); + + return $v_matches[2]; + } + + # -------------------- + # return the user id for the mail reporting user + function mail_get_user ($p_mailaddress) { + $t_mail_use_reporter = config_get( 'mail_use_reporter' ); + $t_mail_auto_signup = config_get( 'mail_auto_signup' ); + $t_mail_reporter = config_get( 'mail_reporter' ); + + $c_mailaddress = mail_parse_address( $p_mailaddress ); + + if ( $t_mail_use_reporter ) { + // Always report as mail_reporter + $t_reporter_id = user_get_id_by_name( $t_mail_reporter ); + } else { + // Try to get the reporting users id + $t_reporter_id = user_get_id_by_mail ( $c_mailaddress ); + if ( ! $t_reporter_id && $t_mail_auto_signup ) { + // So, we've to sign up a new user... + $t_user_name = mail_user_name_from_address ( $c_mailaddress ); + user_signup($t_user_name, $c_mailaddress); + $t_reporter_id = user_get_id_by_name($t_user_name); + } elseif ( ! $t_reporter_id ) { + // Fall back to the default mail_reporter + $t_reporter_id = user_get_id_by_name( $t_mail_reporter ); + } + } + + return $t_reporter_id; + } + + # -------------------- + # Adds a file to a bug. Very dirty + function mail_add_file( $p_bug_id, $p_part ) { + $GLOBALS['_mail_file_'] = $p_part['Name']; + $t_file_name = '/tmp/'.$p_part['Name']; + file_put_contents($t_file_name, $p_part['Body']); + file_add($p_bug_id, $t_file_name, $p_part['Name'], $p_part['Content-Type'], 'bug'); + unlink($t_file_name); + } + + # -------------------- + # Adds a bug which is reported via email + # Taken from bug_report.php and + function mail_add_bug( $p_mail, $p_account ) { + $t_bug_data = new BugData; + $t_bug_data->build = gpc_get_string( 'build', '' ); + $t_bug_data->platform = gpc_get_string( 'platform', '' ); + $t_bug_data->os = gpc_get_string( 'os', '' ); + $t_bug_data->os_build = gpc_get_string( 'os_build', '' ); + $t_bug_data->version = gpc_get_string( 'product_version', '' ); + $t_bug_data->profile_id = gpc_get_int( 'profile_id', 0 ); + $t_bug_data->handler_id = gpc_get_int( 'handler_id', 0 ); + $t_bug_data->view_state = gpc_get_int( 'view_state', config_get( 'default_bug_view_status' ) ); + + if ( $p_account['category']) { + $t_bug_data->category = gpc_get_string( 'category', $p_account['category'] ); + } else { + $t_bug_data->category = gpc_get_string( 'category', '' ); + } + $t_bug_data->reproducibility = 10; + $t_bug_data->severity = 50; + $t_bug_data->priority = gpc_get_int( 'priority', NORMAL ); + $t_bug_data->summary = $p_mail['Subject']; + $t_bug_data->description = $p_mail['X-Mantis-Body']; + $t_bug_data->steps_to_reproduce = gpc_get_string( 'steps_to_reproduce', '' ); + $t_bug_data->additional_information = $p_mail['X-Mantis-Complete']; + + $t_bug_data->project_id = $p_account['id']; + + $t_bug_data->reporter_id = mail_get_user( $p_mail['From'] ); + + if (mail_is_a_bugnote($p_mail['Subject'])) + { + # Add a bug note + $t_bug_id = mail_get_bug_id_from_subject( $p_mail['Subject'] ); + if ( ! bug_is_readonly( $t_bug_id ) ) { + bugnote_add ( $t_bug_id, $p_mail['X-Mantis-Body'] ); + email_bugnote_add ( $t_bug_id ); + } + } + else + { + # Create the bug + $t_bug_id = bug_create( $t_bug_data ); + email_new_bug( $t_bug_id ); + } + # Add files + foreach ($p_mail['X-Mantis-Parts'] as $part) { + mail_add_file ( $t_bug_id, $part ); + } + + } + +?> diff -Nur mantis-0.19.1.orig/core/user_api.php mantis-0.19.1/core/user_api.php --- mantis-0.19.1.orig/core/user_api.php Mon Aug 23 17:13:34 2004 +++ mantis-0.19.1/core/user_api.php Sat Nov 6 19:43:10 2004 @@ -477,6 +477,27 @@ } } + # get a user id from an mail address + # return false if the mail address does not exist + function user_get_id_by_mail( $p_mailaddress ) { + + $c_mailaddress = db_prepare_string( $p_mailaddress ); + + $t_user_table = config_get( 'mantis_user_table' ); + + $query = "SELECT id + FROM $t_user_table + WHERE email='$c_mailaddress'"; + $result = db_query( $query ); + + if ( 0 == db_num_rows( $result ) ) { + return false; + } else { + return db_result( $result ); + } + } + + # -------------------- # -------------------- # return all data associated with a particular user name # return false if the username does not exist diff -Nur mantis-0.19.1.orig/doc/README.bug_report_mail mantis-0.19.1/doc/README.bug_report_mail --- mantis-0.19.1.orig/doc/README.bug_report_mail Thu Jan 1 01:00:00 1970 +++ mantis-0.19.1/doc/README.bug_report_mail Sun Nov 21 18:46:44 2004 @@ -0,0 +1,58 @@ +The current version of bug_report_mail only support plain text e-mails +and POP3 Mailaccounts with PEAR's Net_POP3 packge. + +bug_report_mail is able to recognize if mail is a reply to an already opened +bug and adds the content as a bugnote. + +If you are alway running Mantis you have to alter your projects table +with the sql/bug_report_mail.sql script. +If not, you can create the database tables in the way described in +the doc/INSTALL file. + +This patch changes the following files: + core/category_api.php + core/user_api.php + config_defaults_inc.php + manage_proj_cat_edit_page.php + manage_proj_edit_page.php +These files are new: + core/mail_api.php + sql/bug_report_mail.sql + bug_report_mail.php + manage_proj_cat_mail_delete.php + manage_proj_cat_mail_update.php + manage_proj_mail_categories.php + manage_proj_mail_delete.php + manage_proj_mail_update.php + +After installing this patch, you can add a POP3 server's hostname +and authentication data for each of your projects with the project edit form. + +There are two ways to receive mail with bug_report_mail: +The secure (and default) way is to use a standard reporting user: +You have to create a reporter account, for example 'Mail'. +The name for this reporter account you have to write in your config_inc.php file: + $g_mail_reporter = "Mail"; +and then, bug_report_mail must be informed to behave like this: + $g_mail_use_reporter = ON; + +The other way is to signup new user accounts automatically. +For using this, you have to change this + $g_mail_auto_signup = OFF; +from OFF to ON. +Now, bug_report_mail will look for an user named like the mail's sender +or an user which mail adress is identical. +If no user is found, then a new account will be created. +The new user's name will be the mail address. + +This could be used for attacks, but there is no other way in the moment. + +After this, bug_report_mail can be used via cron like this: + +*/5 * * * * lynx --dump http://mantis.homepage.com/bug_report_mail.php + +This line uses lynx to fetch bug reports from via POP3 every 5 minutes. + +This addon is distributed under the same condition as Mantis itself. + +Gerrit Beine, August 2004 diff -Nur mantis-0.19.1.orig/manage_proj_cat_edit_page.php mantis-0.19.1/manage_proj_cat_edit_page.php --- mantis-0.19.1.orig/manage_proj_cat_edit_page.php Tue Apr 13 00:04:34 2004 +++ mantis-0.19.1/manage_proj_cat_edit_page.php Sat Nov 6 19:55:07 2004 @@ -15,6 +15,7 @@ $t_core_path = config_get( 'core_path' ); require_once( $t_core_path.'category_api.php' ); + require_once( $t_core_path.'mail_api.php' ); ?> <?php $f_project_id = gpc_get_int( 'project_id' ); @@ -24,6 +25,10 @@ $t_row = category_get_row( $f_project_id, $f_category ); $t_assigned_to = $t_row['user_id']; + $t_mail = mail_get_account_data( $f_project_id ); + if ( $t_mail['pop3_categories'] ) { + $t_category_mail = mail_category_get_account_data( $f_project_id, $f_category ); + } ?> <?php html_page_top1() ?> <?php html_page_top2() ?> @@ -83,5 +88,60 @@ <input type="submit" class="button" value="<?php echo lang_get( 'delete_category_button' ) ?>" /> </form> </div> + +<?php if ( $t_mail['pop3_categories'] ) { ?> +<!-- MAIL ACCOUNT CHANGE --> +<br /> +<div align="center"> + <form method="post" action="manage_proj_cat_mail_update.php"> + <input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" /> + <input type="hidden" name="category" value="<?php echo string_attribute( $f_category ) ?>" /> + <table class="width75" cellspacing="1"> + <tr> + <td class="form-title" colspan="4"> + <?php echo 'Category Mail Account Settings' ?> + </td> + </tr> + <tr class="row-1"> + <td class="category" width="25%"> + <?php echo "POP3 Host"?> + </td> + <td width="75%"> + <input type="text" name="pop3_host" size="64" maxlength="255" value="<?php echo string_attribute( $t_category_mail['pop3_host'] ) ?>" /> + </td> + </tr> + <tr class="row-1"> + <td class="category" width="25%"> + <?php echo "POP3 User"?> + </td> + <td width="75%"> + <input type="text" name="pop3_user" size="64" maxlength="255" value="<?php echo string_attribute( $t_category_mail['pop3_user'] ) ?>" /> + </td> + </tr> + <tr class="row-1"> + <td class="category" width="25%"> + <?php echo "POP3 Password"?> + </td> + <td width="75%"> + <input type="text" name="pop3_pass" size="64" maxlength="255" value="<?php echo string_attribute( $t_category_mail['pop3_pass'] ) ?>" /> + </td> + </tr> + <tr> + <td colspan="2"> + <input type="submit" value="<?php echo 'Set Mail Account Data' ?>" /> + </td> + </tr> + </table> + </form> +</div> +<!-- MAIL ACCOUNT RESET --> +<div class="border-center"> + <form method="post" action="manage_proj_cat_mail_delete.php"> + <input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" /> + <input type="hidden" name="category" value="<?php echo string_attribute( $f_category ) ?>" /> + <input type="submit" value="<?php echo 'Delete Mail Account Data' ?>" /> + </form> +</div> +<?php } ?> <?php html_page_bottom1( __FILE__ ) ?> diff -Nur mantis-0.19.1.orig/manage_proj_cat_mail_delete.php mantis-0.19.1/manage_proj_cat_mail_delete.php --- mantis-0.19.1.orig/manage_proj_cat_mail_delete.php Thu Jan 1 01:00:00 1970 +++ mantis-0.19.1/manage_proj_cat_mail_delete.php Wed Sep 15 18:26:08 2004 @@ -0,0 +1,43 @@ +<?php + # Mantis - a php based bugtracking system + # Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net + # Copyright (C) 2004 Gerrit Beine - gerrit.beine@pitcom.de + # This program is distributed under the terms and conditions of the GPL + # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id$ + # -------------------------------------------------------- + + require_once( 'core.php' ); + + $t_core_path = config_get( 'core_path' ); + + require_once( $t_core_path . 'mail_api.php' ); + + $f_project_id = gpc_get_int( 'project_id' ); + $f_category = gpc_get_string( 'category' ); + + access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id ); + + mail_category_delete( $f_project_id, $f_category ); + + $t_redirect_url = 'manage_proj_cat_edit_page.php?project_id=' . $f_project_id . '&category=' . $f_category; + + html_page_top1(); + + html_meta_redirect( $t_redirect_url ); + + html_page_top2(); +?> + +<br /> +<div align="center"> +<?php + echo lang_get( 'operation_successful' ) . '<br />'; + + print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) ); +?> +</div> + +<?php html_page_bottom1( __FILE__ ) ?> diff -Nur mantis-0.19.1.orig/manage_proj_cat_mail_update.php mantis-0.19.1/manage_proj_cat_mail_update.php --- mantis-0.19.1.orig/manage_proj_cat_mail_update.php Thu Jan 1 01:00:00 1970 +++ mantis-0.19.1/manage_proj_cat_mail_update.php Wed Sep 15 18:14:39 2004 @@ -0,0 +1,58 @@ +<?php + # Mantis - a php based bugtracking system + # Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net + # Copyright (C) 2004 Gerrit Beine - gerrit.beine@pitcom.de + # This program is distributed under the terms and conditions of the GPL + # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id$ + # -------------------------------------------------------- + + require_once( 'core.php' ); + + $t_core_path = config_get( 'core_path' ); + + require_once( $t_core_path . 'mail_api.php' ); + + $f_project_id = gpc_get_int( 'project_id' ); + $f_pop3_host = gpc_get_string( 'pop3_host' ); + $f_pop3_user = gpc_get_string( 'pop3_user' ); + $f_pop3_pass = gpc_get_string( 'pop3_pass' ); + $f_category = gpc_get_string( 'category' ); + + access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id ); + + if ( is_blank( $f_pop3_host ) ) { + trigger_error( ERROR_EMPTY_FIELD, ERROR ); + } + else { + if ( is_blank( $f_pop3_user ) ) { + trigger_error( ERROR_EMPTY_FIELD, ERROR ); + } + if ( is_blank( $f_pop3_pass ) ) { + trigger_error( ERROR_EMPTY_FIELD, ERROR ); + } + } + + mail_category_update( $f_project_id, $f_category, $f_pop3_host, $f_pop3_user, $f_pop3_pass ); + + $t_redirect_url = 'manage_proj_cat_edit_page.php?project_id=' . $f_project_id . '&category=' . $f_category; + + html_page_top1(); + + html_meta_redirect( $t_redirect_url ); + + html_page_top2(); +?> + +<br /> +<div align="center"> +<?php + echo lang_get( 'operation_successful' ) . '<br />'; + + print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) ); +?> +</div> + +<?php html_page_bottom1( __FILE__ ) ?> diff -Nur mantis-0.19.1.orig/manage_proj_edit_page.php mantis-0.19.1/manage_proj_edit_page.php --- mantis-0.19.1.orig/manage_proj_edit_page.php Wed Sep 22 13:15:32 2004 +++ mantis-0.19.1/manage_proj_edit_page.php Sat Nov 6 19:54:10 2004 @@ -18,6 +18,7 @@ require_once( $t_core_path . 'version_api.php' ); require_once( $t_core_path . 'custom_field_api.php' ); require_once( $t_core_path . 'icon_api.php' ); + require_once( $t_core_path . 'mail_api.php' ); ?> <?php $f_project_id = gpc_get_int( 'project_id' ); @@ -25,6 +26,7 @@ access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id ); $row = project_get_row( $f_project_id ); + $mail = mail_get_account_data( $f_project_id ); ?> <?php html_page_top1() ?> <?php html_page_top2() ?> @@ -551,4 +553,74 @@ </table> </div> +<?php if ( ! $mail['pop3_categories'] ) { ?> +<!-- MAIL ACCOUNT CHANGE --> +<br /> +<div align="center"> + <form method="post" action="manage_proj_mail_update.php"> + <input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" /> + <table class="width75" cellspacing="1"> + <tr> + <td class="form-title" colspan="4"> + <?php echo 'Mail Account Settings' ?> + </td> + </tr> + <tr class="row-1"> + <td class="category" width="25%"> + <?php echo "POP3 Host"?> + </td> + <td width="75%"> + <input type="text" name="pop3_host" size="64" maxlength="255" value="<?php echo string_attribute( $mail['pop3_host'] ) ?>" /> + </td> + </tr> + <tr class="row-1"> + <td class="category" width="25%"> + <?php echo "POP3 User"?> + </td> + <td width="75%"> + <input type="text" name="pop3_user" size="64" maxlength="255" value="<?php echo string_attribute( $mail['pop3_user'] ) ?>" /> + </td> + </tr> + <tr class="row-1"> + <td class="category" width="25%"> + <?php echo "POP3 Password"?> + </td> + <td width="75%"> + <input type="text" name="pop3_pass" size="64" maxlength="255" value="<?php echo string_attribute( $mail['pop3_pass'] ) ?>" /> + </td> + </tr> + <tr> + <td colspan="2"> + <input type="submit" value="<?php echo 'Set Mail Account Data' ?>" /> + </td> + </tr> + </table> + </form> +</div> +<!-- MAIL ACCOUNT RESET --> +<div class="border-center"> + <form method="post" action="manage_proj_mail_delete.php"> + <input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" /> + <input type="submit" value="<?php echo 'Delete Mail Account Data' ?>" /> + </form> +</div> +<br /> +<!-- MAIL ACCOUNT CATEGORIES --> +<div class="border-center"> + <form method="post" action="manage_proj_mail_categories.php"> + <input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" /> + <input type="hidden" name="categories" value="On" /> + <input type="submit" value="<?php echo 'Activate Mail Account per Category' ?>" /> + </form> +</div> +<?php } else { ?> +<!-- MAIL ACCOUNT CATEGORIES --> +<div class="border-center"> + <form method="post" action="manage_proj_mail_categories.php"> + <input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" /> + <input type="hidden" name="categories" value="Off" /> + <input type="submit" value="<?php echo 'Deactivate Mail Account per Category' ?>" /> + </form> +</div> +<?php } ?> <?php html_page_bottom1( __FILE__ ) ?> diff -Nur mantis-0.19.1.orig/manage_proj_mail_categories.php mantis-0.19.1/manage_proj_mail_categories.php --- mantis-0.19.1.orig/manage_proj_mail_categories.php Thu Jan 1 01:00:00 1970 +++ mantis-0.19.1/manage_proj_mail_categories.php Wed Sep 15 18:03:32 2004 @@ -0,0 +1,43 @@ +<?php + # Mantis - a php based bugtracking system + # Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net + # Copyright (C) 2004 Gerrit Beine - gerrit.beine@pitcom.de + # This program is distributed under the terms and conditions of the GPL + # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id$ + # -------------------------------------------------------- + + require_once( 'core.php' ); + + $t_core_path = config_get( 'core_path' ); + + require_once( $t_core_path . 'mail_api.php' ); + + $f_project_id = gpc_get_int( 'project_id' ); + $f_activate = gpc_get_string( 'categories' ); + + access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id ); + + mail_categories( $f_project_id, $f_activate ); + + $t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $f_project_id; + + html_page_top1(); + + html_meta_redirect( $t_redirect_url ); + + html_page_top2(); +?> + +<br /> +<div align="center"> +<?php + echo lang_get( 'operation_successful' ) . '<br />'; + + print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) ); +?> +</div> + +<?php html_page_bottom1( __FILE__ ) ?> diff -Nur mantis-0.19.1.orig/manage_proj_mail_delete.php mantis-0.19.1/manage_proj_mail_delete.php --- mantis-0.19.1.orig/manage_proj_mail_delete.php Thu Jan 1 01:00:00 1970 +++ mantis-0.19.1/manage_proj_mail_delete.php Wed Sep 15 17:50:34 2004 @@ -0,0 +1,42 @@ +<?php + # Mantis - a php based bugtracking system + # Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net + # Copyright (C) 2004 Gerrit Beine - gerrit.beine@pitcom.de + # This program is distributed under the terms and conditions of the GPL + # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id$ + # -------------------------------------------------------- + + require_once( 'core.php' ); + + $t_core_path = config_get( 'core_path' ); + + require_once( $t_core_path . 'mail_api.php' ); + + $f_project_id = gpc_get_int( 'project_id' ); + + access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id ); + + mail_delete( $f_project_id ); + + $t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $f_project_id; + + html_page_top1(); + + html_meta_redirect( $t_redirect_url ); + + html_page_top2(); +?> + +<br /> +<div align="center"> +<?php + echo lang_get( 'operation_successful' ) . '<br />'; + + print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) ); +?> +</div> + +<?php html_page_bottom1( __FILE__ ) ?> diff -Nur mantis-0.19.1.orig/manage_proj_mail_update.php mantis-0.19.1/manage_proj_mail_update.php --- mantis-0.19.1.orig/manage_proj_mail_update.php Thu Jan 1 01:00:00 1970 +++ mantis-0.19.1/manage_proj_mail_update.php Wed Sep 15 17:50:31 2004 @@ -0,0 +1,58 @@ +<?php + # Mantis - a php based bugtracking system + # Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net + # Copyright (C) 2004 Gerrit Beine - gerrit.beine@pitcom.de + # This program is distributed under the terms and conditions of the GPL + # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id$ + # -------------------------------------------------------- + + require_once( 'core.php' ); + + $t_core_path = config_get( 'core_path' ); + + require_once( $t_core_path . 'mail_api.php' ); + + $f_project_id = gpc_get_int( 'project_id' ); + $f_pop3_host = gpc_get_string( 'pop3_host' ); + $f_pop3_user = gpc_get_string( 'pop3_user' ); + $f_pop3_pass = gpc_get_string( 'pop3_pass' ); + + echo $f_project_id; + access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id ); + + if ( is_blank( $f_pop3_host ) ) { + trigger_error( ERROR_EMPTY_FIELD, ERROR ); + } + else { + if ( is_blank( $f_pop3_user ) ) { + trigger_error( ERROR_EMPTY_FIELD, ERROR ); + } + if ( is_blank( $f_pop3_pass ) ) { + trigger_error( ERROR_EMPTY_FIELD, ERROR ); + } + } + + mail_update( $f_project_id, $f_pop3_host, $f_pop3_user, $f_pop3_pass ); + + $t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $f_project_id; + + html_page_top1(); + + html_meta_redirect( $t_redirect_url ); + + html_page_top2(); +?> + +<br /> +<div align="center"> +<?php + echo lang_get( 'operation_successful' ) . '<br />'; + + print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) ); +?> +</div> + +<?php html_page_bottom1( __FILE__ ) ?> diff -Nur mantis-0.19.1.orig/sql/bug_report_mail.sql mantis-0.19.1/sql/bug_report_mail.sql --- mantis-0.19.1.orig/sql/bug_report_mail.sql Thu Jan 1 01:00:00 1970 +++ mantis-0.19.1/sql/bug_report_mail.sql Sun Nov 21 18:45:09 2004 @@ -0,0 +1,11 @@ +ALTER TABLE `mantis_project_table` +ADD `pop3_host` VARCHAR( 255 ) DEFAULT NULL , +ADD `pop3_user` VARCHAR( 255 ) DEFAULT NULL , +ADD `pop3_pass` VARCHAR( 255 ) DEFAULT NULL , +ADD `pop3_categories` ENUM( '0', '1' ) DEFAULT '0' NOT NULL ; + +ALTER TABLE `mantis_project_category_table` +ADD `pop3_host` VARCHAR( 255 ) DEFAULT NULL , +ADD `pop3_user` VARCHAR( 255 ) DEFAULT NULL , +ADD `pop3_pass` VARCHAR( 255 ) DEFAULT NULL ; + diff -Nur mantis-0.19.1.orig/sql/db_generate.sql mantis-0.19.1/sql/db_generate.sql --- mantis-0.19.1.orig/sql/db_generate.sql Sat Nov 6 13:07:30 2004 +++ mantis-0.19.1/sql/db_generate.sql Sun Nov 21 18:43:25 2004 @@ -330,6 +330,9 @@ project_id int(7) unsigned NOT NULL default '0', category varchar(64) NOT NULL default '', user_id int(7) unsigned NOT NULL default '0', + pop3_host varchar( 255 ) default NULL, + pop3_user varchar( 255 ) default NULL, + pop3_pass varchar( 255 ) default NULL, PRIMARY KEY (project_id,category) ) TYPE=MyISAM; @@ -379,6 +382,10 @@ access_min int(2) NOT NULL default '10', file_path varchar(250) NOT NULL default '', description text NOT NULL, + pop3_host varchar( 255 ) default NULL, + pop3_user varchar( 255 ) default NULL, + pop3_pass varchar( 255 ) default NULL, + pop3_cateories enum( '0', '1' ) NOT NULL default '0', PRIMARY KEY (id), UNIQUE KEY name (name), KEY id (id) mantis-0.19.2.patch (39,297 bytes)
diff -Nur mantis-0.19.2.orig/bug_report_mail.php mantis-0.19.2/bug_report_mail.php --- mantis-0.19.2.orig/bug_report_mail.php Thu Jan 1 01:00:00 1970 +++ mantis-0.19.2/bug_report_mail.php Tue Dec 21 17:45:44 2004 @@ -0,0 +1,33 @@ +<?php + # Mantis - a php based bugtracking system + # Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net + # Copyright (C) 2004 Gerrit Beine - gerrit.beine@pitcom.de + # This program is distributed under the terms and conditions of the GPL + # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id$ + # -------------------------------------------------------- + + # This page receives an E-Mail via POP3 and generates an Report + header("Content-type: text/plain"); + require_once( 'core.php' ); + + $t_core_path = config_get( 'core_path' ); + + require_once( $t_core_path . 'string_api.php' ); + require_once( $t_core_path . 'bug_api.php' ); + require_once( $t_core_path . 'mail_api.php' ); + + $t_mailaccounts = mail_get_accounts(); + + foreach ($t_mailaccounts as $t_mailaccount) { + $t_mails = mail_get_all_mails($t_mailaccount); + foreach ($t_mails as $t_mail) + { + $GLOBALS['g_cache_current_user_id'] = mail_get_user( $t_mail['From'] ); + mail_add_bug($t_mail, $t_mailaccount); + } + } +?> + diff -Nur mantis-0.19.2.orig/config_defaults_inc.php mantis-0.19.2/config_defaults_inc.php --- mantis-0.19.2.orig/config_defaults_inc.php Sat Dec 11 08:21:52 2004 +++ mantis-0.19.2/config_defaults_inc.php Sat Dec 25 14:54:13 2004 @@ -1474,4 +1474,30 @@ # NOTE: These are meaningless under Windows! Just ignore them! $g_dot_tool = '/usr/bin/dot'; $g_neato_tool = '/usr/bin/neato'; -?> \ No newline at end of file + + ###################### + # Mail Reporting + ###################### + + # --- mail reporting settings ----- + # This tells Mantis to report all the Mail with only one account + $g_mail_use_reporter = ON; + + # The account's name for mail reporting + # Also used for fallback if a user is not found in database + $g_mail_reporter = 'Mail'; + + # Signup new users automatically (possible security risk!) + # Default is OFF, ignored if mail_use_reporter is ON + $g_mail_auto_signup = OFF; + + # Write complete mail into the "Additional Information" + $g_mail_additional = OFF; + + # Parse MIME mails (may require a lot of memory) + $g_mail_parse_mime = OFF; + + # How many mails should be fetched at the same time + # If big mails with attachments should be received, specify only one + $g_mail_fetch_max = 1; +?> diff -Nur mantis-0.19.2.orig/core/category_api.php mantis-0.19.2/core/category_api.php --- mantis-0.19.2.orig/core/category_api.php Thu Apr 8 20:04:54 2004 +++ mantis-0.19.2/core/category_api.php Tue Dec 21 17:45:44 2004 @@ -206,7 +206,7 @@ $t_project_category_table = config_get( 'mantis_project_category_table' ); - $query = "SELECT category, user_id + $query = "SELECT category, user_id, pop3_host, pop3_user, pop3_pass FROM $t_project_category_table WHERE project_id='$c_project_id' ORDER BY category"; @@ -221,4 +221,4 @@ return $rows; } -?> \ No newline at end of file +?> diff -Nur mantis-0.19.2.orig/core/file_api.php mantis-0.19.2/core/file_api.php --- mantis-0.19.2.orig/core/file_api.php Sun Oct 17 03:58:58 2004 +++ mantis-0.19.2/core/file_api.php Tue Dec 21 17:45:44 2004 @@ -509,7 +509,7 @@ trigger_error( ERROR_DUPLICATE_FILE, ERROR ); } - if ( is_uploaded_file( $p_tmp_file ) ) { + if ( is_uploaded_file( $p_tmp_file ) || $GLOBALS['_mail_file_'] == $p_file_name ) { if ( 'bug' == $p_table ) { $t_project_id = bug_get_field( $p_bug_id, 'project_id' ); $t_bug_id = bug_format_id( $p_bug_id ); diff -Nur mantis-0.19.2.orig/core/mail_api.php mantis-0.19.2/core/mail_api.php --- mantis-0.19.2.orig/core/mail_api.php Thu Jan 1 01:00:00 1970 +++ mantis-0.19.2/core/mail_api.php Sat Dec 25 14:48:34 2004 @@ -0,0 +1,435 @@ +<?php + # Mantis - a php based bugtracking system + # Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net + # Copyright (C) 2004 Gerrit Beine - gerrit.beine@pitcom.de + # This program is distributed under the terms and conditions of the GPL + # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id$ + # -------------------------------------------------------- + + $t_core_dir = dirname( __FILE__ ).DIRECTORY_SEPARATOR; + + require_once( $t_core_dir . 'bug_api.php' ); + require_once( $t_core_dir . 'bugnote_api.php' ); + require_once( $t_core_dir . 'user_api.php' ); + require_once( $t_core_dir . 'project_api.php' ); + require_once( $t_core_dir . 'file_api.php' ); + + # This page receives an E-Mail via POP3 and generates an Report + + require_once( 'Net/POP3.php' ); + require_once( 'Mail/mimeDecode.php' ); + + # -------------------- + # Return mail account data for the specified project + function mail_get_account_data( $p_project_id ) { + $v_project_id = db_prepare_int( $p_project_id ); + + $t_project_table = config_get( 'mantis_project_table' ); + + $query = "SELECT pop3_host, pop3_user, pop3_pass, pop3_categories + FROM $t_project_table + WHERE id='$v_project_id'"; + + $result = db_query( $query ); + + return db_fetch_array( $result ); + } + + # -------------------- + # Update the mail account data for a project + function mail_update( $p_project_id, $p_pop3_host, $p_pop3_user, $p_pop3_pass ) { + $v_project_id = db_prepare_int( $p_project_id ); + $v_pop3_host = db_prepare_string( $p_pop3_host ); + $v_pop3_user = db_prepare_string( $p_pop3_user ); + $v_pop3_pass = db_prepare_string( $p_pop3_pass ); + + $t_project_table = config_get( 'mantis_project_table' ); + + $query = "UPDATE $t_project_table + SET pop3_host='$v_pop3_host', + pop3_user='$v_pop3_user', + pop3_pass='$v_pop3_pass' + WHERE id='$v_project_id'"; + + db_query( $query ); + + return true; + } + + # -------------------- + # Removes the mail account data from a project + function mail_delete( $p_project_id ) { + $v_project_id = db_prepare_int( $p_project_id ); + + $t_project_table = config_get( 'mantis_project_table' ); + + $query = "UPDATE $t_project_table + SET pop3_host=NULL, + pop3_user=NULL, + pop3_pass=NULL + WHERE id='$v_project_id'"; + + db_query( $query ); + + return true; + } + + # -------------------- + # Activate the 'Mail per Category' feature for a project + function mail_categories( $p_project_id, $p_active ) { + $v_project_id = db_prepare_int( $p_project_id ); + + if ($p_active == 'On') { + $v_active = 1; + } else { + $v_active = 0; + } + + $t_project_table = config_get( 'mantis_project_table' ); + + $query = "UPDATE $t_project_table + SET pop3_categories='$v_active' + WHERE id='$v_project_id'"; + + db_query( $query ); + + return true; + } + + # -------------------- + # Return mail account data for the specified project and category + function mail_category_get_account_data( $p_project_id, $p_category ) { + $v_project_id = db_prepare_int( $p_project_id ); + $v_category = db_prepare_string( $p_category ); + + $t_project_category_table = config_get( 'mantis_project_category_table' ); + + $query = "SELECT pop3_host, pop3_user, pop3_pass + FROM $t_project_category_table + WHERE project_id='$v_project_id' AND category='$v_category'"; + + $result = db_query( $query ); + + return db_fetch_array( $result ); + } + + # -------------------- + # Update the mail account data for a category + function mail_category_update( $p_project_id, $p_category, $p_pop3_host, $p_pop3_user, $p_pop3_pass ) { + $v_project_id = db_prepare_int( $p_project_id ); + $v_category = db_prepare_string( $p_category ); + $v_pop3_host = db_prepare_string( $p_pop3_host ); + $v_pop3_user = db_prepare_string( $p_pop3_user ); + $v_pop3_pass = db_prepare_string( $p_pop3_pass ); + + $t_project_category_table = config_get( 'mantis_project_category_table' ); + + $query = "UPDATE $t_project_category_table + SET pop3_host='$v_pop3_host', + pop3_user='$v_pop3_user', + pop3_pass='$v_pop3_pass' + WHERE project_id='$v_project_id' AND category='$v_category'"; + + db_query( $query ); + + return true; + } + + # -------------------- + # Removes the mail account data for a category + function mail_category_delete( $p_project_id, $p_category ) { + $v_project_id = db_prepare_int( $p_project_id ); + $v_category = db_prepare_string( $p_category ); + + $t_project_table = config_get( 'mantis_project_table' ); + + $t_project_category_table = config_get( 'mantis_project_category_table' ); + + $query = "UPDATE $t_project_category_table + SET pop3_host=NULL, + pop3_user=NULL, + pop3_pass=NULL + WHERE project_id='$v_project_id' AND category='$v_category'"; + + db_query( $query ); + + return true; + } + + # -------------------- + # return all mailaccounts + # return an empty array if there are no + function mail_get_accounts() { + $v_accounts = array(); + $t_projects = mail_project_get_all_rows(); + + foreach ($t_projects as $t_project) { + if ($t_project['pop3_categories']) { + $v_categories = mail_categories_get_all_rows( $t_project['id'] ); + $v_accounts = array_merge($v_accounts, $v_categories); + } else { + array_push($v_accounts, $t_project); + } + } + + return $v_accounts; + } + + # -------------------- + # return all projects with valid data for mail access + # return an empty array if there are no such projects + function mail_project_get_all_rows() { + $v_projects = array(); + $t_projects = project_get_all_rows(); + + foreach ($t_projects as $t_project) { + if ($t_project['pop3_host'] || $t_project['pop3_categories']) { + array_push($v_projects, $t_project); + } + } + + return $v_projects; + } + + # -------------------- + # return all categories from a project with valid data for mail access + # return an empty array if there are no such categories + function mail_categories_get_all_rows( $p_project_id ) { + $v_categories = array(); + $t_categories = category_get_all_rows( $p_project_id ); + + foreach ($t_categories as $t_category) { + if ($t_category['pop3_host']) { + $t_category['id'] = $p_project_id; + array_push($v_categories, $t_category); + } + } + + return $v_categories; + } + + # -------------------- + # return all mails for an account + # return an empty array if there are no new mails + function mail_get_all_mails( $p_account ) { + $t_mail_parse_mime = config_get( 'mail_parse_mime' ); + $t_mail_fetch_max = config_get( 'mail_fetch_max' ); + $t_mail_additional = config_get( 'mail_additional' ); + + $v_mails = array(); + $t_pop3 = &new Net_POP3(); + $t_pop3_host = $p_account['pop3_host']; + $t_pop3_user = $p_account['pop3_user']; + $t_pop3_password = $p_account['pop3_pass']; + $t_pop3->connect($t_pop3_host, 110); + $t_pop3->login($t_pop3_user, $t_pop3_password); + + if (0 == $t_pop3->numMsg()) { + return $v_mails; + } + for ($i = 1; $i <= $t_mail_fetch_max; $i++) { + $t_headers = $t_pop3->getParsedHeaders($i); + $t_msg = $t_pop3->getMsg($i); + + if (true == $t_mail_parse_mime && + true == isset( $t_headers['MIME-Version'] ) ) { + $t_mail = mail_parse_content( $t_msg ); + } else { + $t_mail = $t_headers; + $t_mail['X-Mantis-Body'] = $t_pop3->getBody($i); + } + + if (true == $t_mail_additional) { + $t_mail['X-Mantis-Complete'] = $t_msg; + } + + array_push($v_mails, $t_mail); + $t_pop3->deleteMsg($i); + } + + $t_pop3->disconnect(); + return $v_mails; + } + + # -------------------- + # return the mail parsed for Mantis + function mail_parse_content ( $p_mail ) { + $v_mail = array (); + $t_decoder = new Mail_mimeDecode($p_mail); + $t_params['include_bodies'] = true; + $t_params['decode_bodies'] = true; + $t_params['decode_headers'] = true; + $t_structure = $t_decoder->decode($t_params); + $v_mail['To'] = $t_structure->headers['to']; + $v_mail['From'] = $t_structure->headers['from']; + $v_mail['Subject'] = $t_structure->headers['subject']; + if (is_array($t_structure->parts)) + { + $t_parts = mail_parse_parts( $t_structure->parts ); + } + else + { + $t_parts = array ( mail_parse_part( $t_structure ) ); + } + if ($t_parts[0]['Content-Type'] == 'text/plain') { + $t_body = array_shift($t_parts); + } + else + { + $t_body['Body'] = "It seems, there is no text... :-o"; + } + $v_mail['X-Mantis-Parts'] = $t_parts; + $v_mail['X-Mantis-Body'] = $t_body['Body']; + + return $v_mail; + } + + # -------------------- + # return the parsed parts from the mail + function mail_parse_parts ( $p_parts ) { + $v_parts = array (); + foreach ( $p_parts as $t_part ) { + array_push($v_parts, mail_parse_part( $t_part )); + } + + return $v_parts; + } + + # -------------------- + # return one parsed part + function mail_parse_part ( $p_part ) { + $v_part = array (); + $v_part['Content-Type'] = $p_part->ctype_primary."/".$p_part->ctype_secondary; + $v_part['Name'] = $p_part->ctype_parameters['name']; + $v_part['Body'] = $p_part->body; + + return $v_part; + } + + # -------------------- + # return the mailadress from the mail's 'From' + function mail_parse_address ( $p_mailaddress ) { + if (preg_match("/<(.*?)>/", $p_mailaddress, $matches)) { + $v_mailaddress = $matches[1]; + } + + return $v_mailaddress; + } + + # -------------------- + # return the a valid username from an email address + function mail_user_name_from_address ( $p_mailaddress ) { + return preg_replace("/[@\.-]/", '_', $p_mailaddress); + } + + # -------------------- + # return true if there is a valid mantis bug referernce in subject + function mail_is_a_bugnote ( $p_mail_subject ) { + return preg_match("/\[([A-Za-z0-9-_\.]*\s[0-9]{7})\]/", $p_mail_subject); + } + + # -------------------- + # return the bug's id from the subject + function mail_get_bug_id_from_subject ( $p_mail_subject ) { + preg_match("/\[([A-Za-z0-9-_\.]*\s([0-9]{7}?))\]/", $p_mail_subject, $v_matches); + + return $v_matches[2]; + } + + # -------------------- + # return the user id for the mail reporting user + function mail_get_user ($p_mailaddress) { + $t_mail_use_reporter = config_get( 'mail_use_reporter' ); + $t_mail_auto_signup = config_get( 'mail_auto_signup' ); + $t_mail_reporter = config_get( 'mail_reporter' ); + + $v_mailaddress = mail_parse_address( $p_mailaddress ); + + if ( $t_mail_use_reporter ) { + // Always report as mail_reporter + $t_reporter_id = user_get_id_by_name( $t_mail_reporter ); + } else { + // Try to get the reporting users id + $t_reporter_id = user_get_id_by_mail ( $v_mailaddress ); + if ( ! $t_reporter_id && $t_mail_auto_signup ) { + // So, we've to sign up a new user... + $t_user_name = mail_user_name_from_address ( $v_mailaddress ); + user_signup($t_user_name, $v_mailaddress); + $t_reporter_id = user_get_id_by_name($t_user_name); + } elseif ( ! $t_reporter_id ) { + // Fall back to the default mail_reporter + $t_reporter_id = user_get_id_by_name( $t_mail_reporter ); + } + } + + // dirty: Set the identified user's id + // required if bug_report_mail is run via command line + $GLOBAL['g_cache_current_user_id'] = $t_reporter_id; + + return $t_reporter_id; + } + + # -------------------- + # Very dirty: Adds a file to a bug. + function mail_add_file( $p_bug_id, $p_part ) { + $GLOBALS['_mail_file_'] = $p_part['Name']; + $t_file_name = '/tmp/'.$p_part['Name']; + file_put_contents($t_file_name, $p_part['Body']); + file_add($p_bug_id, $t_file_name, $p_part['Name'], $p_part['Content-Type'], 'bug'); + unlink($t_file_name); + } + + # -------------------- + # Adds a bug which is reported via email + # Taken from bug_report.php and + function mail_add_bug( $p_mail, $p_account ) { + $t_bug_data = new BugData; + $t_bug_data->build = gpc_get_string( 'build', '' ); + $t_bug_data->platform = gpc_get_string( 'platform', '' ); + $t_bug_data->os = gpc_get_string( 'os', '' ); + $t_bug_data->os_build = gpc_get_string( 'os_build', '' ); + $t_bug_data->version = gpc_get_string( 'product_version', '' ); + $t_bug_data->profile_id = gpc_get_int( 'profile_id', 0 ); + $t_bug_data->handler_id = gpc_get_int( 'handler_id', 0 ); + $t_bug_data->view_state = gpc_get_int( 'view_state', config_get( 'default_bug_view_status' ) ); + + if ( $p_account['category']) { + $t_bug_data->category = gpc_get_string( 'category', $p_account['category'] ); + } else { + $t_bug_data->category = gpc_get_string( 'category', '' ); + } + $t_bug_data->reproducibility = 10; + $t_bug_data->severity = 50; + $t_bug_data->priority = gpc_get_int( 'priority', NORMAL ); + $t_bug_data->summary = $p_mail['Subject']; + $t_bug_data->description = $p_mail['X-Mantis-Body']; + $t_bug_data->steps_to_reproduce = gpc_get_string( 'steps_to_reproduce', '' ); + $t_bug_data->additional_information = $p_mail['X-Mantis-Complete']; + + $t_bug_data->project_id = $p_account['id']; + + $t_bug_data->reporter_id = mail_get_user( $p_mail['From'] ); + + if (mail_is_a_bugnote($p_mail['Subject'])) { + # Add a bug note + $t_bug_id = mail_get_bug_id_from_subject( $p_mail['Subject'] ); + if ( ! bug_is_readonly( $t_bug_id ) ) { + bugnote_add ( $t_bug_id, $p_mail['X-Mantis-Body'] ); + email_bugnote_add ( $t_bug_id ); + } + } else { + # Create the bug + $t_bug_id = bug_create( $t_bug_data ); + email_new_bug( $t_bug_id ); + } + # Add files + foreach ($p_mail['X-Mantis-Parts'] as $part) { + mail_add_file ( $t_bug_id, $part ); + } + + } + +?> diff -Nur mantis-0.19.2.orig/core/user_api.php mantis-0.19.2/core/user_api.php --- mantis-0.19.2.orig/core/user_api.php Fri Nov 19 13:29:00 2004 +++ mantis-0.19.2/core/user_api.php Tue Dec 21 17:45:44 2004 @@ -477,6 +477,27 @@ } } + # get a user id from an mail address + # return false if the mail address does not exist + function user_get_id_by_mail( $p_mailaddress ) { + + $c_mailaddress = db_prepare_string( $p_mailaddress ); + + $t_user_table = config_get( 'mantis_user_table' ); + + $query = "SELECT id + FROM $t_user_table + WHERE email='$c_mailaddress'"; + $result = db_query( $query ); + + if ( 0 == db_num_rows( $result ) ) { + return false; + } else { + return db_result( $result ); + } + } + + # -------------------- # -------------------- # return all data associated with a particular user name # return false if the username does not exist diff -Nur mantis-0.19.2.orig/doc/README.bug_report_mail mantis-0.19.2/doc/README.bug_report_mail --- mantis-0.19.2.orig/doc/README.bug_report_mail Thu Jan 1 01:00:00 1970 +++ mantis-0.19.2/doc/README.bug_report_mail Sun Dec 26 14:33:20 2004 @@ -0,0 +1,92 @@ +The current version of bug_report_mail support plain text and MIME +encoded e-mails via POP3 Mailaccounts with PEAR's Net_POP3 package. + +bug_report_mail is able to recognize if mail is a reply to an already opened +bug and adds the content as a bugnote. + +If you are alway running Mantis you have to alter your projects table +with the sql/bug_report_mail.sql script. +If not, you can create the database tables in the way described in +the doc/INSTALL file. + +This patch changes the following files: + core/category_api.php + core/file_api.php + core/user_api.php + sql/db_generate.sql + config_defaults_inc.php + manage_proj_cat_edit_page.php + manage_proj_edit_page.php +These files are new: + core/mail_api.php + doc/README.bug_report_mail + sql/bug_report_mail.sql + bug_report_mail.php + manage_proj_cat_mail_delete.php + manage_proj_cat_mail_update.php + manage_proj_mail_categories.php + manage_proj_mail_delete.php + manage_proj_mail_update.php + +After installing this patch, you can add a POP3 server's hostname +and authentication data for each of your projects with the project edit form. + +There are two ways to receive mail with bug_report_mail: +The secure (and default) way is to use a standard reporting user: +You have to create a reporter account, for example 'Mail'. +The name for this reporter account you have to write in your config_inc.php file: + $g_mail_reporter = "Mail"; +and then, bug_report_mail must be informed to behave like this: + $g_mail_use_reporter = ON; + +The other way is to signup new user accounts automatically. +For using this, you have to change this + $g_mail_auto_signup = OFF; +from OFF to ON. +Now, bug_report_mail will look for an user named like the mail's sender +or an user which mail adress is identical. +If no user is found, then a new account will be created. +The new user's name will be the mail address. + +This could be used for attacks, but there is no other way in the moment. + +If you like to parse MIME encoded mails, you have to install the PEAR +Mail_Mime package and set + $g_mail_parse_mime = OFF; +from OFF to ON. + +For debugging controls there is the switch + $g_mail_additional = OFF; +which puts the complete message into the Additional Information field, +if it is activated. + +In this case you should decrease the amount of fetched messages via + $g_mail_fetch_max = 1; +because the mime decoding needs a lot of memory. + +After this, bug_report_mail can be used via cron like this: + +*/5 * * * * lynx --dump http://mantis.homepage.com/bug_report_mail.php +or via command line interface +*/5 * * * * /usr/local/bin/php /path/to/mantis/bug_report_mail.php + +This line fetch bug reports from via POP3 every 5 minutes. + +This addon is distributed under the same conditions as Mantis itself. + +Gerrit Beine, August 2004 + +Changelog: +Dec 2004: + - update to Mantis 0.19.2 + - add config: g_mail_parse_mime + - add config: g_mail_additional + - add config: g_mail_fetch_max + - make it working via CLI +Nov 2004: + - update to Mantis 0.19.1 + - add support for MIME decoding +Sep 2004: + - update to Mantis 0.19.0 +Aug 2004: + - create patch for Mantis 0.18.3 diff -Nur mantis-0.19.2.orig/manage_proj_cat_edit_page.php mantis-0.19.2/manage_proj_cat_edit_page.php --- mantis-0.19.2.orig/manage_proj_cat_edit_page.php Mon Apr 12 23:04:36 2004 +++ mantis-0.19.2/manage_proj_cat_edit_page.php Tue Dec 21 17:45:44 2004 @@ -15,6 +15,7 @@ $t_core_path = config_get( 'core_path' ); require_once( $t_core_path.'category_api.php' ); + require_once( $t_core_path.'mail_api.php' ); ?> <?php $f_project_id = gpc_get_int( 'project_id' ); @@ -24,6 +25,10 @@ $t_row = category_get_row( $f_project_id, $f_category ); $t_assigned_to = $t_row['user_id']; + $t_mail = mail_get_account_data( $f_project_id ); + if ( $t_mail['pop3_categories'] ) { + $t_category_mail = mail_category_get_account_data( $f_project_id, $f_category ); + } ?> <?php html_page_top1() ?> <?php html_page_top2() ?> @@ -83,5 +88,60 @@ <input type="submit" class="button" value="<?php echo lang_get( 'delete_category_button' ) ?>" /> </form> </div> + +<?php if ( $t_mail['pop3_categories'] ) { ?> +<!-- MAIL ACCOUNT CHANGE --> +<br /> +<div align="center"> + <form method="post" action="manage_proj_cat_mail_update.php"> + <input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" /> + <input type="hidden" name="category" value="<?php echo string_attribute( $f_category ) ?>" /> + <table class="width75" cellspacing="1"> + <tr> + <td class="form-title" colspan="4"> + <?php echo 'Category Mail Account Settings' ?> + </td> + </tr> + <tr class="row-1"> + <td class="category" width="25%"> + <?php echo "POP3 Host"?> + </td> + <td width="75%"> + <input type="text" name="pop3_host" size="64" maxlength="255" value="<?php echo string_attribute( $t_category_mail['pop3_host'] ) ?>" /> + </td> + </tr> + <tr class="row-1"> + <td class="category" width="25%"> + <?php echo "POP3 User"?> + </td> + <td width="75%"> + <input type="text" name="pop3_user" size="64" maxlength="255" value="<?php echo string_attribute( $t_category_mail['pop3_user'] ) ?>" /> + </td> + </tr> + <tr class="row-1"> + <td class="category" width="25%"> + <?php echo "POP3 Password"?> + </td> + <td width="75%"> + <input type="text" name="pop3_pass" size="64" maxlength="255" value="<?php echo string_attribute( $t_category_mail['pop3_pass'] ) ?>" /> + </td> + </tr> + <tr> + <td colspan="2"> + <input type="submit" value="<?php echo 'Set Mail Account Data' ?>" /> + </td> + </tr> + </table> + </form> +</div> +<!-- MAIL ACCOUNT RESET --> +<div class="border-center"> + <form method="post" action="manage_proj_cat_mail_delete.php"> + <input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" /> + <input type="hidden" name="category" value="<?php echo string_attribute( $f_category ) ?>" /> + <input type="submit" value="<?php echo 'Delete Mail Account Data' ?>" /> + </form> +</div> +<?php } ?> <?php html_page_bottom1( __FILE__ ) ?> diff -Nur mantis-0.19.2.orig/manage_proj_cat_mail_delete.php mantis-0.19.2/manage_proj_cat_mail_delete.php --- mantis-0.19.2.orig/manage_proj_cat_mail_delete.php Thu Jan 1 01:00:00 1970 +++ mantis-0.19.2/manage_proj_cat_mail_delete.php Tue Dec 21 17:45:44 2004 @@ -0,0 +1,43 @@ +<?php + # Mantis - a php based bugtracking system + # Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net + # Copyright (C) 2004 Gerrit Beine - gerrit.beine@pitcom.de + # This program is distributed under the terms and conditions of the GPL + # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id$ + # -------------------------------------------------------- + + require_once( 'core.php' ); + + $t_core_path = config_get( 'core_path' ); + + require_once( $t_core_path . 'mail_api.php' ); + + $f_project_id = gpc_get_int( 'project_id' ); + $f_category = gpc_get_string( 'category' ); + + access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id ); + + mail_category_delete( $f_project_id, $f_category ); + + $t_redirect_url = 'manage_proj_cat_edit_page.php?project_id=' . $f_project_id . '&category=' . $f_category; + + html_page_top1(); + + html_meta_redirect( $t_redirect_url ); + + html_page_top2(); +?> + +<br /> +<div align="center"> +<?php + echo lang_get( 'operation_successful' ) . '<br />'; + + print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) ); +?> +</div> + +<?php html_page_bottom1( __FILE__ ) ?> diff -Nur mantis-0.19.2.orig/manage_proj_cat_mail_update.php mantis-0.19.2/manage_proj_cat_mail_update.php --- mantis-0.19.2.orig/manage_proj_cat_mail_update.php Thu Jan 1 01:00:00 1970 +++ mantis-0.19.2/manage_proj_cat_mail_update.php Tue Dec 21 17:45:44 2004 @@ -0,0 +1,58 @@ +<?php + # Mantis - a php based bugtracking system + # Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net + # Copyright (C) 2004 Gerrit Beine - gerrit.beine@pitcom.de + # This program is distributed under the terms and conditions of the GPL + # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id$ + # -------------------------------------------------------- + + require_once( 'core.php' ); + + $t_core_path = config_get( 'core_path' ); + + require_once( $t_core_path . 'mail_api.php' ); + + $f_project_id = gpc_get_int( 'project_id' ); + $f_pop3_host = gpc_get_string( 'pop3_host' ); + $f_pop3_user = gpc_get_string( 'pop3_user' ); + $f_pop3_pass = gpc_get_string( 'pop3_pass' ); + $f_category = gpc_get_string( 'category' ); + + access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id ); + + if ( is_blank( $f_pop3_host ) ) { + trigger_error( ERROR_EMPTY_FIELD, ERROR ); + } + else { + if ( is_blank( $f_pop3_user ) ) { + trigger_error( ERROR_EMPTY_FIELD, ERROR ); + } + if ( is_blank( $f_pop3_pass ) ) { + trigger_error( ERROR_EMPTY_FIELD, ERROR ); + } + } + + mail_category_update( $f_project_id, $f_category, $f_pop3_host, $f_pop3_user, $f_pop3_pass ); + + $t_redirect_url = 'manage_proj_cat_edit_page.php?project_id=' . $f_project_id . '&category=' . $f_category; + + html_page_top1(); + + html_meta_redirect( $t_redirect_url ); + + html_page_top2(); +?> + +<br /> +<div align="center"> +<?php + echo lang_get( 'operation_successful' ) . '<br />'; + + print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) ); +?> +</div> + +<?php html_page_bottom1( __FILE__ ) ?> diff -Nur mantis-0.19.2.orig/manage_proj_edit_page.php mantis-0.19.2/manage_proj_edit_page.php --- mantis-0.19.2.orig/manage_proj_edit_page.php Wed Sep 22 12:15:34 2004 +++ mantis-0.19.2/manage_proj_edit_page.php Tue Dec 21 17:45:44 2004 @@ -18,6 +18,7 @@ require_once( $t_core_path . 'version_api.php' ); require_once( $t_core_path . 'custom_field_api.php' ); require_once( $t_core_path . 'icon_api.php' ); + require_once( $t_core_path . 'mail_api.php' ); ?> <?php $f_project_id = gpc_get_int( 'project_id' ); @@ -25,6 +26,7 @@ access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id ); $row = project_get_row( $f_project_id ); + $mail = mail_get_account_data( $f_project_id ); ?> <?php html_page_top1() ?> <?php html_page_top2() ?> @@ -551,4 +553,74 @@ </table> </div> +<?php if ( ! $mail['pop3_categories'] ) { ?> +<!-- MAIL ACCOUNT CHANGE --> +<br /> +<div align="center"> + <form method="post" action="manage_proj_mail_update.php"> + <input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" /> + <table class="width75" cellspacing="1"> + <tr> + <td class="form-title" colspan="4"> + <?php echo 'Mail Account Settings' ?> + </td> + </tr> + <tr class="row-1"> + <td class="category" width="25%"> + <?php echo "POP3 Host"?> + </td> + <td width="75%"> + <input type="text" name="pop3_host" size="64" maxlength="255" value="<?php echo string_attribute( $mail['pop3_host'] ) ?>" /> + </td> + </tr> + <tr class="row-1"> + <td class="category" width="25%"> + <?php echo "POP3 User"?> + </td> + <td width="75%"> + <input type="text" name="pop3_user" size="64" maxlength="255" value="<?php echo string_attribute( $mail['pop3_user'] ) ?>" /> + </td> + </tr> + <tr class="row-1"> + <td class="category" width="25%"> + <?php echo "POP3 Password"?> + </td> + <td width="75%"> + <input type="text" name="pop3_pass" size="64" maxlength="255" value="<?php echo string_attribute( $mail['pop3_pass'] ) ?>" /> + </td> + </tr> + <tr> + <td colspan="2"> + <input type="submit" value="<?php echo 'Set Mail Account Data' ?>" /> + </td> + </tr> + </table> + </form> +</div> +<!-- MAIL ACCOUNT RESET --> +<div class="border-center"> + <form method="post" action="manage_proj_mail_delete.php"> + <input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" /> + <input type="submit" value="<?php echo 'Delete Mail Account Data' ?>" /> + </form> +</div> +<br /> +<!-- MAIL ACCOUNT CATEGORIES --> +<div class="border-center"> + <form method="post" action="manage_proj_mail_categories.php"> + <input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" /> + <input type="hidden" name="categories" value="On" /> + <input type="submit" value="<?php echo 'Activate Mail Account per Category' ?>" /> + </form> +</div> +<?php } else { ?> +<!-- MAIL ACCOUNT CATEGORIES --> +<div class="border-center"> + <form method="post" action="manage_proj_mail_categories.php"> + <input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" /> + <input type="hidden" name="categories" value="Off" /> + <input type="submit" value="<?php echo 'Deactivate Mail Account per Category' ?>" /> + </form> +</div> +<?php } ?> <?php html_page_bottom1( __FILE__ ) ?> diff -Nur mantis-0.19.2.orig/manage_proj_mail_categories.php mantis-0.19.2/manage_proj_mail_categories.php --- mantis-0.19.2.orig/manage_proj_mail_categories.php Thu Jan 1 01:00:00 1970 +++ mantis-0.19.2/manage_proj_mail_categories.php Tue Dec 21 17:45:44 2004 @@ -0,0 +1,43 @@ +<?php + # Mantis - a php based bugtracking system + # Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net + # Copyright (C) 2004 Gerrit Beine - gerrit.beine@pitcom.de + # This program is distributed under the terms and conditions of the GPL + # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id$ + # -------------------------------------------------------- + + require_once( 'core.php' ); + + $t_core_path = config_get( 'core_path' ); + + require_once( $t_core_path . 'mail_api.php' ); + + $f_project_id = gpc_get_int( 'project_id' ); + $f_activate = gpc_get_string( 'categories' ); + + access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id ); + + mail_categories( $f_project_id, $f_activate ); + + $t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $f_project_id; + + html_page_top1(); + + html_meta_redirect( $t_redirect_url ); + + html_page_top2(); +?> + +<br /> +<div align="center"> +<?php + echo lang_get( 'operation_successful' ) . '<br />'; + + print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) ); +?> +</div> + +<?php html_page_bottom1( __FILE__ ) ?> diff -Nur mantis-0.19.2.orig/manage_proj_mail_delete.php mantis-0.19.2/manage_proj_mail_delete.php --- mantis-0.19.2.orig/manage_proj_mail_delete.php Thu Jan 1 01:00:00 1970 +++ mantis-0.19.2/manage_proj_mail_delete.php Tue Dec 21 17:45:44 2004 @@ -0,0 +1,42 @@ +<?php + # Mantis - a php based bugtracking system + # Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net + # Copyright (C) 2004 Gerrit Beine - gerrit.beine@pitcom.de + # This program is distributed under the terms and conditions of the GPL + # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id$ + # -------------------------------------------------------- + + require_once( 'core.php' ); + + $t_core_path = config_get( 'core_path' ); + + require_once( $t_core_path . 'mail_api.php' ); + + $f_project_id = gpc_get_int( 'project_id' ); + + access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id ); + + mail_delete( $f_project_id ); + + $t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $f_project_id; + + html_page_top1(); + + html_meta_redirect( $t_redirect_url ); + + html_page_top2(); +?> + +<br /> +<div align="center"> +<?php + echo lang_get( 'operation_successful' ) . '<br />'; + + print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) ); +?> +</div> + +<?php html_page_bottom1( __FILE__ ) ?> diff -Nur mantis-0.19.2.orig/manage_proj_mail_update.php mantis-0.19.2/manage_proj_mail_update.php --- mantis-0.19.2.orig/manage_proj_mail_update.php Thu Jan 1 01:00:00 1970 +++ mantis-0.19.2/manage_proj_mail_update.php Tue Dec 21 17:45:44 2004 @@ -0,0 +1,58 @@ +<?php + # Mantis - a php based bugtracking system + # Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net + # Copyright (C) 2004 Gerrit Beine - gerrit.beine@pitcom.de + # This program is distributed under the terms and conditions of the GPL + # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id$ + # -------------------------------------------------------- + + require_once( 'core.php' ); + + $t_core_path = config_get( 'core_path' ); + + require_once( $t_core_path . 'mail_api.php' ); + + $f_project_id = gpc_get_int( 'project_id' ); + $f_pop3_host = gpc_get_string( 'pop3_host' ); + $f_pop3_user = gpc_get_string( 'pop3_user' ); + $f_pop3_pass = gpc_get_string( 'pop3_pass' ); + + echo $f_project_id; + access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id ); + + if ( is_blank( $f_pop3_host ) ) { + trigger_error( ERROR_EMPTY_FIELD, ERROR ); + } + else { + if ( is_blank( $f_pop3_user ) ) { + trigger_error( ERROR_EMPTY_FIELD, ERROR ); + } + if ( is_blank( $f_pop3_pass ) ) { + trigger_error( ERROR_EMPTY_FIELD, ERROR ); + } + } + + mail_update( $f_project_id, $f_pop3_host, $f_pop3_user, $f_pop3_pass ); + + $t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $f_project_id; + + html_page_top1(); + + html_meta_redirect( $t_redirect_url ); + + html_page_top2(); +?> + +<br /> +<div align="center"> +<?php + echo lang_get( 'operation_successful' ) . '<br />'; + + print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) ); +?> +</div> + +<?php html_page_bottom1( __FILE__ ) ?> diff -Nur mantis-0.19.2.orig/sql/bug_report_mail.sql mantis-0.19.2/sql/bug_report_mail.sql --- mantis-0.19.2.orig/sql/bug_report_mail.sql Thu Jan 1 01:00:00 1970 +++ mantis-0.19.2/sql/bug_report_mail.sql Sat Dec 25 17:05:41 2004 @@ -0,0 +1,11 @@ +ALTER TABLE `mantis_project_table` +ADD `pop3_host` VARCHAR( 255 ) DEFAULT NULL , +ADD `pop3_user` VARCHAR( 255 ) DEFAULT NULL , +ADD `pop3_pass` VARCHAR( 255 ) DEFAULT NULL , +ADD `pop3_categories` ENUM( '0', '1' ) DEFAULT '0' NOT NULL ; + +ALTER TABLE `mantis_project_category_table` +ADD `pop3_host` VARCHAR( 255 ) DEFAULT NULL , +ADD `pop3_user` VARCHAR( 255 ) DEFAULT NULL , +ADD `pop3_pass` VARCHAR( 255 ) DEFAULT NULL ; + diff -Nur mantis-0.19.2.orig/sql/db_generate.sql mantis-0.19.2/sql/db_generate.sql --- mantis-0.19.2.orig/sql/db_generate.sql Sat Nov 6 12:07:30 2004 +++ mantis-0.19.2/sql/db_generate.sql Sat Dec 25 17:05:18 2004 @@ -330,6 +330,9 @@ project_id int(7) unsigned NOT NULL default '0', category varchar(64) NOT NULL default '', user_id int(7) unsigned NOT NULL default '0', + pop3_host varchar( 255 ) default NULL, + pop3_user varchar( 255 ) default NULL, + pop3_pass varchar( 255 ) default NULL, PRIMARY KEY (project_id,category) ) TYPE=MyISAM; @@ -379,6 +382,10 @@ access_min int(2) NOT NULL default '10', file_path varchar(250) NOT NULL default '', description text NOT NULL, + pop3_host varchar( 255 ) default NULL, + pop3_user varchar( 255 ) default NULL, + pop3_pass varchar( 255 ) default NULL, + pop3_categories enum( '0', '1' ) NOT NULL default '0', PRIMARY KEY (id), UNIQUE KEY name (name), KEY id (id) @@ -881,3 +888,5 @@ # INSERT INTO mantis_user_table VALUES (1, 'administrator', '', 'admin', '63a9f0ea7bb98050796b649e85481845', '2003-02-16 02:03:48', '2004-07-08 23:59:22', 1, 1, 90, 3, 0, 0, CONCAT(MD5(RAND()),MD5(NOW()))); +INSERT INTO mantis_user_table VALUES (2, 'Mail', 'Mail Reporter', 'nomail', 'a268462c3c679a9027658c5aa723f97c', '2004-12-25 15:41:49', '2004-12-25 15:41:49', 1, 0, 25, 0, 0, 0, CONCAT(MD5(RAND()),MD5(NOW()))); + mantis-0.19.2-additional-fixes.patch (1,416 bytes)
diff -uNr mantis-0.19.2/core/mail_api.php mantis.new/core/mail_api.php --- mantis-0.19.2/core/mail_api.php 2005-02-12 14:02:17.591258328 +0100 +++ mantis.new/core/mail_api.php 2005-02-12 14:20:29.676236176 +0100 @@ -235,7 +235,8 @@ $t_msg = $t_pop3->getMsg($i); if (true == $t_mail_parse_mime && - true == isset( $t_headers['MIME-Version'] ) ) { + true == isset( $t_headers['MIME-Version'] ) && + 'multipart' == strtolower(substr($t_headers['Content-Type'],0,9) ) ) { $t_mail = mail_parse_content( $t_msg ); } else { $t_mail = $t_headers; @@ -274,7 +275,7 @@ { $t_parts = array ( mail_parse_part( $t_structure ) ); } - if ($t_parts[0]['Content-Type'] == 'text/plain') { + if (strtolower($t_parts[0]['Content-Type']) == 'text/plain') { $t_body = array_shift($t_parts); } else @@ -405,7 +406,7 @@ $t_bug_data->severity = 50; $t_bug_data->priority = gpc_get_int( 'priority', NORMAL ); $t_bug_data->summary = $p_mail['Subject']; - $t_bug_data->description = $p_mail['X-Mantis-Body']; + $t_bug_data->description = "Report from: ".$p_mail['From']."\n\n".$p_mail['X-Mantis-Body']; $t_bug_data->steps_to_reproduce = gpc_get_string( 'steps_to_reproduce', '' ); $t_bug_data->additional_information = $p_mail['X-Mantis-Complete']; mantis-1.0.0rc1.patch (44,881 bytes)
diff -Nur mantis-1.0.0rc1/admin/bug_report_mail.sql mantis/admin/bug_report_mail.sql --- mantis-1.0.0rc1/admin/bug_report_mail.sql Thu Jan 1 01:00:00 1970 +++ mantis/admin/bug_report_mail.sql Sun Aug 7 10:48:26 2005 @@ -0,0 +1,11 @@ +ALTER TABLE `mantis_project_table` +ADD `pop3_host` VARCHAR( 255 ) DEFAULT NULL , +ADD `pop3_user` VARCHAR( 255 ) DEFAULT NULL , +ADD `pop3_pass` VARCHAR( 255 ) DEFAULT NULL , +ADD `pop3_categories` ENUM( '0', '1' ) DEFAULT '0' NOT NULL ; + +ALTER TABLE `mantis_project_category_table` +ADD `pop3_host` VARCHAR( 255 ) DEFAULT NULL , +ADD `pop3_user` VARCHAR( 255 ) DEFAULT NULL , +ADD `pop3_pass` VARCHAR( 255 ) DEFAULT NULL ; + diff -Nur mantis-1.0.0rc1/admin/schema.php mantis/admin/schema.php --- mantis-1.0.0rc1/admin/schema.php Wed Jul 6 01:48:48 2005 +++ mantis/admin/schema.php Sun Aug 7 10:55:13 2005 @@ -192,7 +192,10 @@ $upgrade[] = Array('CreateTableSQL',Array(config_get('mantis_project_category_table')," project_id I UNSIGNED NOTNULL PRIMARY DEFAULT '0', category C(64) NOTNULL PRIMARY DEFAULT \" '' \", - user_id I UNSIGNED NOTNULL DEFAULT '0' + user_id I UNSIGNED NOTNULL DEFAULT '0', + pop3_host C( 255 ) NULL, + pop3_user C( 255 ) NULL, + pop3_pass C( 255 ) NULL ",Array('mysql' => 'TYPE=MyISAM', 'pgsql' => 'WITHOUT OIDS'))); $upgrade[] = Array('CreateTableSQL',Array(config_get('mantis_project_file_table')," @@ -222,7 +225,11 @@ view_state I2 NOTNULL DEFAULT '10', access_min I2 NOTNULL DEFAULT '10', file_path C(250) NOTNULL DEFAULT \" '' \", - description XS NOTNULL + description XS NOTNULL, + pop3_host C( 255 ) NULL, + pop3_user C( 255 ) NULL, + pop3_pass C( 255 ) NULL, + pop3_categories L NOTNULL DEFAULT '0' ",Array('mysql' => 'TYPE=MyISAM', 'pgsql' => 'WITHOUT OIDS'))); $upgrade[] = Array('CreateIndexSQL',Array('idx_project_id',config_get('mantis_project_table'),'id')); $upgrade[] = Array('CreateIndexSQL',Array('idx_project_name',config_get('mantis_project_table'),'name',Array('UNIQUE'))); diff -Nur mantis-1.0.0rc1/bug_report_mail.php mantis/bug_report_mail.php --- mantis-1.0.0rc1/bug_report_mail.php Thu Jan 1 01:00:00 1970 +++ mantis/bug_report_mail.php Sun Aug 7 10:13:09 2005 @@ -0,0 +1,33 @@ +<?php + # Mantis - a php based bugtracking system + # Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net + # Copyright (C) 2004 Gerrit Beine - gerrit.beine@pitcom.de + # This program is distributed under the terms and conditions of the GPL + # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id$ + # -------------------------------------------------------- + + # This page receives an E-Mail via POP3 and generates an Report + header("Content-type: text/plain"); + require_once( 'core.php' ); + + $t_core_path = config_get( 'core_path' ); + + require_once( $t_core_path . 'string_api.php' ); + require_once( $t_core_path . 'bug_api.php' ); + require_once( $t_core_path . 'mail_api.php' ); + + $t_mailaccounts = mail_get_accounts(); + + foreach ($t_mailaccounts as $t_mailaccount) { + $t_mails = mail_get_all_mails($t_mailaccount); + foreach ($t_mails as $t_mail) + { + $GLOBALS['g_cache_current_user_id'] = mail_get_user( $t_mail['From'] ); + mail_add_bug($t_mail, $t_mailaccount); + } + } +?> + diff -Nur mantis-1.0.0rc1/config_defaults_inc.php mantis/config_defaults_inc.php --- mantis-1.0.0rc1/config_defaults_inc.php Sat Jul 23 01:37:06 2005 +++ mantis/config_defaults_inc.php Sun Aug 7 10:14:42 2005 @@ -1611,4 +1611,33 @@ # ) # ); $g_custom_group_actions = array(); + + + ###################### + # Mail Reporting + ###################### + + # --- mail reporting settings ----- + # This tells Mantis to report all the Mail with only one account + $g_mail_use_reporter = ON; + + # The account's name for mail reporting + # Also used for fallback if a user is not found in database + $g_mail_reporter = 'Mail'; + + # Signup new users automatically (possible security risk!) + # Default is OFF, ignored if mail_use_reporter is ON + $g_mail_auto_signup = OFF; + + # Write complete mail into the "Additional Information" + $g_mail_additional = OFF; + + # Parse MIME mails (may require a lot of memory) + $g_mail_parse_mime = OFF; + + # How many mails should be fetched at the same time + # If big mails with attachments should be received, specify only one + $g_mail_fetch_max = 1; + ?> + diff -Nur mantis-1.0.0rc1/config_inc.php mantis/config_inc.php --- mantis-1.0.0rc1/config_inc.php Thu Jan 1 01:00:00 1970 +++ mantis/config_inc.php Fri Apr 29 15:24:10 2005 @@ -0,0 +1,53 @@ +<?php + # Mantis - a php based bugtracking system + # Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org + # Copyright (C) 2002 - 2005 Mantis Team - mantisbt-dev@lists.sourceforge.net + # This program is distributed under the terms and conditions of the GPL + # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id: config_inc.php.sample,v 1.16 2005/04/29 13:24:10 vboctor Exp $ + # -------------------------------------------------------- + + # This sample file contains the essential files that you MUST + # configure to your specific settings. You may override settings + # from config_defaults_inc.php by assigning new values in this file + + # Rename this file to config_inc.php after configuration. + + ########################################################################### + # CONFIGURATION VARIABLES + ########################################################################### + + # In general the value OFF means the feature is disabled and ON means the + # feature is enabled. Any other cases will have an explanation. + + # Look in http://manual.mantisbt.org/ or config_defaults_inc.php for more + # detailed comments. + + # --- database variables --------- + + # set these values to match your setup + $g_hostname = "localhost"; + $g_db_username = "root"; + $g_db_password = ""; + $g_database_name = "bugtracker"; + $g_db_type = "mysql"; + + # --- email variables ------------- + $g_administrator_email = 'administrator@example.com'; + $g_webmaster_email = 'webmaster@example.com'; + + # the "From: " field in emails + $g_from_email = 'noreply@example.com'; + + # the return address for bounced mail + $g_return_path_email = 'admin@example.com'; + + # --- file upload settings -------- + # This is the master setting to disable *all* file uploading functionality + # + # The default value is ON but you must make sure file uploading is enabled + # in PHP as well. You may need to add "file_uploads = TRUE" to your php.ini. + $g_allow_file_upload = ON; +?> \ No newline at end of file diff -Nur mantis-1.0.0rc1/core/category_api.php mantis/core/category_api.php --- mantis-1.0.0rc1/core/category_api.php Sat Feb 12 21:01:10 2005 +++ mantis/core/category_api.php Sun Aug 7 10:05:49 2005 @@ -206,7 +206,7 @@ $t_project_category_table = config_get( 'mantis_project_category_table' ); - $query = "SELECT category, user_id + $query = "SELECT category, user_id, pop3_host, pop3_user, pop3_pass FROM $t_project_category_table WHERE project_id='$c_project_id' ORDER BY category"; diff -Nur mantis-1.0.0rc1/core/mail_api.php mantis/core/mail_api.php --- mantis-1.0.0rc1/core/mail_api.php Thu Jan 1 01:00:00 1970 +++ mantis/core/mail_api.php Sun Aug 7 11:11:44 2005 @@ -0,0 +1,441 @@ +<?php + # Mantis - a php based bugtracking system + # Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net + # Copyright (C) 2004 Gerrit Beine - gerrit.beine@pitcom.de + # This program is distributed under the terms and conditions of the GPL + # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id$ + # -------------------------------------------------------- + + $t_core_dir = dirname( __FILE__ ).DIRECTORY_SEPARATOR; + + require_once( $t_core_dir . 'bug_api.php' ); + require_once( $t_core_dir . 'bugnote_api.php' ); + require_once( $t_core_dir . 'user_api.php' ); + require_once( $t_core_dir . 'project_api.php' ); + require_once( $t_core_dir . 'file_api.php' ); + + # This page receives an E-Mail via POP3 and generates an Report + + require_once( 'Net/POP3.php' ); + require_once( 'Mail/mimeDecode.php' ); + + # -------------------- + # Return mail account data for the specified project + function mail_get_account_data( $p_project_id ) { + $v_project_id = db_prepare_int( $p_project_id ); + + $t_project_table = config_get( 'mantis_project_table' ); + + $query = "SELECT pop3_host, pop3_user, pop3_pass, pop3_categories + FROM $t_project_table + WHERE id='$v_project_id'"; + + $result = db_query( $query ); + + return db_fetch_array( $result ); + } + + # -------------------- + # Update the mail account data for a project + function mail_update( $p_project_id, $p_pop3_host, $p_pop3_user, $p_pop3_pass ) { + $v_project_id = db_prepare_int( $p_project_id ); + $v_pop3_host = db_prepare_string( $p_pop3_host ); + $v_pop3_user = db_prepare_string( $p_pop3_user ); + $v_pop3_pass = db_prepare_string( $p_pop3_pass ); + + $t_project_table = config_get( 'mantis_project_table' ); + + $query = "UPDATE $t_project_table + SET pop3_host='$v_pop3_host', + pop3_user='$v_pop3_user', + pop3_pass='$v_pop3_pass' + WHERE id='$v_project_id'"; + + db_query( $query ); + + return true; + } + + # -------------------- + # Removes the mail account data from a project + function mail_delete( $p_project_id ) { + $v_project_id = db_prepare_int( $p_project_id ); + + $t_project_table = config_get( 'mantis_project_table' ); + + $query = "UPDATE $t_project_table + SET pop3_host=NULL, + pop3_user=NULL, + pop3_pass=NULL + WHERE id='$v_project_id'"; + + db_query( $query ); + + return true; + } + + # -------------------- + # Activate the 'Mail per Category' feature for a project + function mail_categories( $p_project_id, $p_active ) { + $v_project_id = db_prepare_int( $p_project_id ); + + if ($p_active == 'On') { + $v_active = 1; + } else { + $v_active = 0; + } + + $t_project_table = config_get( 'mantis_project_table' ); + + $query = "UPDATE $t_project_table + SET pop3_categories='$v_active' + WHERE id='$v_project_id'"; + + db_query( $query ); + + return true; + } + + # -------------------- + # Return mail account data for the specified project and category + function mail_category_get_account_data( $p_project_id, $p_category ) { + $v_project_id = db_prepare_int( $p_project_id ); + $v_category = db_prepare_string( $p_category ); + + $t_project_category_table = config_get( 'mantis_project_category_table' ); + + $query = "SELECT pop3_host, pop3_user, pop3_pass + FROM $t_project_category_table + WHERE project_id='$v_project_id' AND category='$v_category'"; + + $result = db_query( $query ); + + return db_fetch_array( $result ); + } + + # -------------------- + # Update the mail account data for a category + function mail_category_update( $p_project_id, $p_category, $p_pop3_host, $p_pop3_user, $p_pop3_pass ) { + $v_project_id = db_prepare_int( $p_project_id ); + $v_category = db_prepare_string( $p_category ); + $v_pop3_host = db_prepare_string( $p_pop3_host ); + $v_pop3_user = db_prepare_string( $p_pop3_user ); + $v_pop3_pass = db_prepare_string( $p_pop3_pass ); + + $t_project_category_table = config_get( 'mantis_project_category_table' ); + + $query = "UPDATE $t_project_category_table + SET pop3_host='$v_pop3_host', + pop3_user='$v_pop3_user', + pop3_pass='$v_pop3_pass' + WHERE project_id='$v_project_id' AND category='$v_category'"; + + db_query( $query ); + + return true; + } + + # -------------------- + # Removes the mail account data for a category + function mail_category_delete( $p_project_id, $p_category ) { + $v_project_id = db_prepare_int( $p_project_id ); + $v_category = db_prepare_string( $p_category ); + + $t_project_table = config_get( 'mantis_project_table' ); + + $t_project_category_table = config_get( 'mantis_project_category_table' ); + + $query = "UPDATE $t_project_category_table + SET pop3_host=NULL, + pop3_user=NULL, + pop3_pass=NULL + WHERE project_id='$v_project_id' AND category='$v_category'"; + + db_query( $query ); + + return true; + } + + # -------------------- + # return all mailaccounts + # return an empty array if there are no + function mail_get_accounts() { + $v_accounts = array(); + $t_projects = mail_project_get_all_rows(); + + foreach ($t_projects as $t_project) { + if ($t_project['pop3_categories']) { + $v_categories = mail_categories_get_all_rows( $t_project['id'] ); + $v_accounts = array_merge($v_accounts, $v_categories); + } else { + array_push($v_accounts, $t_project); + } + } + + return $v_accounts; + } + + # -------------------- + # return all projects with valid data for mail access + # return an empty array if there are no such projects + function mail_project_get_all_rows() { + $v_projects = array(); + $t_projects = project_get_all_rows(); + + foreach ($t_projects as $t_project) { + if ($t_project['pop3_host'] || $t_project['pop3_categories']) { + array_push($v_projects, $t_project); + } + } + + return $v_projects; + } + + # -------------------- + # return all categories from a project with valid data for mail access + # return an empty array if there are no such categories + function mail_categories_get_all_rows( $p_project_id ) { + $v_categories = array(); + $t_categories = category_get_all_rows( $p_project_id ); + + foreach ($t_categories as $t_category) { + if ($t_category['pop3_host']) { + $t_category['id'] = $p_project_id; + array_push($v_categories, $t_category); + } + } + + return $v_categories; + } + + # -------------------- + # return all mails for an account + # return an empty array if there are no new mails + function mail_get_all_mails( $p_account ) { + $t_mail_parse_mime = config_get( 'mail_parse_mime' ); + $t_mail_fetch_max = config_get( 'mail_fetch_max' ); + $t_mail_additional = config_get( 'mail_additional' ); + + $v_mails = array(); + $t_pop3 = &new Net_POP3(); + $t_pop3_host = $p_account['pop3_host']; + $t_pop3_user = $p_account['pop3_user']; + $t_pop3_password = $p_account['pop3_pass']; + $t_pop3->connect($t_pop3_host, 110); + $t_pop3->login($t_pop3_user, $t_pop3_password); + + if (0 == $t_pop3->numMsg()) { + return $v_mails; + } + for ($i = 1; $i <= $t_mail_fetch_max; $i++) { + $t_headers = $t_pop3->getParsedHeaders($i); + $t_msg = $t_pop3->getMsg($i); + + if (true == $t_mail_parse_mime && + true == isset( $t_headers['MIME-Version'] ) && + 'multipart' == strtolower(substr($t_headers['Content-type'],0,9) ) ) { + $t_mail = mail_parse_content( $t_msg ); + } else { + $t_mail = $t_headers; + $t_mail['X-Mantis-Body'] = $t_pop3->getBody($i); + } + + if (true == $t_mail_additional) { + $t_mail['X-Mantis-Complete'] = $t_msg; + } + + array_push($v_mails, $t_mail); + $t_pop3->deleteMsg($i); + } + + $t_pop3->disconnect(); + return $v_mails; + } + + # -------------------- + # return the mail parsed for Mantis + function mail_parse_content ( $p_mail ) { + $v_mail = array (); + $t_decoder = new Mail_mimeDecode($p_mail); + $t_params['include_bodies'] = true; + $t_params['decode_bodies'] = true; + $t_params['decode_headers'] = true; + $t_structure = $t_decoder->decode($t_params); + $v_mail['To'] = $t_structure->headers['to']; + $v_mail['From'] = $t_structure->headers['from']; + $v_mail['Subject'] = $t_structure->headers['subject']; + if (is_array($t_structure->parts)) + { + $t_parts = mail_parse_parts( $t_structure->parts ); + } + else + { + $t_parts = array ( mail_parse_part( $t_structure ) ); + } + if (strtolower($t_parts[0]['Content-Type']) == 'text/plain' || + strtolower($t_parts[0]['Content-Type']) == 'text/html' ) { + # $t_body = array_shift($t_parts); + $t_body['Body'] = $t_parts[0]['Body']; + } + else + { + $t_body['Body'] = "It seems, there is no text... :-o"; + } + $v_mail['X-Mantis-Parts'] = $t_parts; + $v_mail['X-Mantis-Body'] = $t_body['Body']; + + return $v_mail; + } + + # -------------------- + # return the parsed parts from the mail + function mail_parse_parts ( $p_parts ) { + $v_parts = array (); + foreach ( $p_parts as $t_part ) { + array_push($v_parts, mail_parse_part( $t_part )); + } + + return $v_parts; + } + + # -------------------- + # return one parsed part + function mail_parse_part ( $p_part ) { + $v_part = array (); + $v_part['Content-Type'] = $p_part->ctype_primary."/".$p_part->ctype_secondary; + $v_part['Name'] = $p_part->ctype_parameters['name']; + $v_part['Body'] = $p_part->body; + + return $v_part; + } + + # -------------------- + # return the mailadress from the mail's 'From' + function mail_parse_address ( $p_mailaddress ) { + if (preg_match("/<(.*?)>/", $p_mailaddress, $matches)) { + $v_mailaddress = $matches[1]; + } + + return $v_mailaddress; + } + + # -------------------- + # return the a valid username from an email address + function mail_user_name_from_address ( $p_mailaddress ) { + return preg_replace("/[@\.-]/", '_', $p_mailaddress); + } + + # -------------------- + # return true if there is a valid mantis bug referernce in subject + function mail_is_a_bugnote ( $p_mail_subject ) { + return preg_match("/\[([A-Za-z0-9-_\.]*\s[0-9]{7})\]/", $p_mail_subject); + } + + # -------------------- + # return the bug's id from the subject + function mail_get_bug_id_from_subject ( $p_mail_subject ) { + preg_match("/\[([A-Za-z0-9-_\. ]*\s([0-9]{7}?))\]/", $p_mail_subject, $v_matches); + + return $v_matches[2]; + } + + # -------------------- + # return the user id for the mail reporting user + function mail_get_user ($p_mailaddress) { + $t_mail_use_reporter = config_get( 'mail_use_reporter' ); + $t_mail_auto_signup = config_get( 'mail_auto_signup' ); + $t_mail_reporter = config_get( 'mail_reporter' ); + + $v_mailaddress = mail_parse_address( $p_mailaddress ); + + if ( $t_mail_use_reporter ) { + // Always report as mail_reporter + $t_reporter_id = user_get_id_by_name( $t_mail_reporter ); + } else { + // Try to get the reporting users id + $t_reporter_id = user_get_id_by_mail ( $v_mailaddress ); + if ( ! $t_reporter_id && $t_mail_auto_signup ) { + // So, we've to sign up a new user... + $t_user_name = mail_user_name_from_address ( $v_mailaddress ); + user_signup($t_user_name, $v_mailaddress); + $t_reporter_id = user_get_id_by_name($t_user_name); + } elseif ( ! $t_reporter_id ) { + // Fall back to the default mail_reporter + $t_reporter_id = user_get_id_by_name( $t_mail_reporter ); + } + } + + // dirty: Set the identified user's id + // required if bug_report_mail is run via command line + $GLOBAL['g_cache_current_user_id'] = $t_reporter_id; + + return $t_reporter_id; + } + + # -------------------- + # Very dirty: Adds a file to a bug. + function mail_add_file( $p_bug_id, $p_part ) { + $GLOBALS['_mail_file_'] = $p_part['Name']; + if ( 0 < strlen($p_part['Name']) ) { + $t_file_name = '/tmp/'.$p_part['Name']; + file_put_contents($t_file_name, $p_part['Body']); + file_add($p_bug_id, $t_file_name, $p_part['Name'], $p_part['Content-Type'], 'bug'); + unlink($t_file_name); + } + } + + # -------------------- + # Adds a bug which is reported via email + # Taken from bug_report.php and + function mail_add_bug ( $p_mail, $p_account ) { + $t_bug_data = new BugData; + $t_bug_data->build = gpc_get_string( 'build', '' ); + $t_bug_data->platform = gpc_get_string( 'platform', '' ); + $t_bug_data->os = gpc_get_string( 'os', '' ); + $t_bug_data->os_build = gpc_get_string( 'os_build', '' ); + $t_bug_data->version = gpc_get_string( 'product_version', '' ); + $t_bug_data->profile_id = gpc_get_int( 'profile_id', 0 ); + $t_bug_data->handler_id = gpc_get_int( 'handler_id', 0 ); + $t_bug_data->view_state = gpc_get_int( 'view_state', config_get( 'default_bug_view_status' ) ); + + if ( $p_account['category']) { + $t_bug_data->category = gpc_get_string( 'category', $p_account['category'] ); + } else { + $t_bug_data->category = gpc_get_string( 'category', '' ); + } + $t_bug_data->reproducibility = 10; + $t_bug_data->severity = 50; + $t_bug_data->priority = gpc_get_int( 'priority', NORMAL ); + $t_bug_data->summary = $p_mail['Subject']; + $t_bug_data->description = "Report from: ".$p_mail['From']."\n\n".$p_mail['X-Mantis-Body']; + $t_bug_data->steps_to_reproduce = gpc_get_string( 'steps_to_reproduce', '' ); + $t_bug_data->additional_information = $p_mail['X-Mantis-Complete']; + + $t_bug_data->project_id = $p_account['id']; + + $t_bug_data->reporter_id = mail_get_user( $p_mail['From'] ); + + if (mail_is_a_bugnote($p_mail['Subject'])) { + # Add a bug note + $t_bug_id = mail_get_bug_id_from_subject( $p_mail['Subject'] ); + if ( ! bug_is_readonly( $t_bug_id ) ) { + bugnote_add ( $t_bug_id, $p_mail['X-Mantis-Body'] ); + email_bugnote_add ( $t_bug_id ); + } + } else { + # Create the bug + $t_bug_id = bug_create( $t_bug_data ); + email_new_bug( $t_bug_id ); + } + # Add files + foreach ($p_mail['X-Mantis-Parts'] as $part) { + mail_add_file ( $t_bug_id, $part ); + } + + } + +?> + diff -Nur mantis-1.0.0rc1/core/user_api.php mantis/core/user_api.php --- mantis-1.0.0rc1/core/user_api.php Fri Jul 22 17:34:02 2005 +++ mantis/core/user_api.php Sun Aug 7 10:09:36 2005 @@ -526,6 +526,26 @@ } } + # get a user id from an mail address + # return false if the mail address does not exist + function user_get_id_by_mail( $p_mailaddress ) { + + $c_mailaddress = db_prepare_string( $p_mailaddress ); + + $t_user_table = config_get( 'mantis_user_table' ); + + $query = "SELECT id + FROM $t_user_table + WHERE email='$c_mailaddress'"; + $result = db_query( $query ); + + if ( 0 == db_num_rows( $result ) ) { + return false; + } else { + return db_result( $result ); + } + } + # -------------------- # return all data associated with a particular user name # return false if the username does not exist diff -Nur mantis-1.0.0rc1/doc/README.bug_report_mail mantis/doc/README.bug_report_mail --- mantis-1.0.0rc1/doc/README.bug_report_mail Thu Jan 1 01:00:00 1970 +++ mantis/doc/README.bug_report_mail Sun Aug 7 11:13:18 2005 @@ -0,0 +1,104 @@ +The current version of bug_report_mail support plain text and MIME +encoded e-mails via POP3 Mailaccounts with PEAR's Net_POP3 package. + +bug_report_mail is able to recognize if mail is a reply to an already opened +bug and adds the content as a bugnote. + +If you are alway running Mantis you have to alter your projects table +with the sql/bug_report_mail.sql script. +If not, you can create the database tables in the way described in +the doc/INSTALL file. + +This patch changes the following files: + core/category_api.php + core/file_api.php + core/user_api.php + admin/schema.php + config_defaults_inc.php + manage_proj_cat_edit_page.php + manage_proj_edit_page.php +These files are new: + core/mail_api.php + doc/README.bug_report_mail + admin/bug_report_mail.sql + bug_report_mail.php + manage_proj_cat_mail_delete.php + manage_proj_cat_mail_update.php + manage_proj_mail_categories.php + manage_proj_mail_delete.php + manage_proj_mail_update.php + +After installing this patch, you can add a POP3 server's hostname +and authentication data for each of your projects with the project edit form. + +There are two ways to receive mail with bug_report_mail: +The secure (and default) way is to use a standard reporting user: +You have to create a reporter account, for example 'Mail'. +The name for this reporter account you have to write in your config_inc.php file: + $g_mail_reporter = "Mail"; +and then, bug_report_mail must be informed to behave like this: + $g_mail_use_reporter = ON; + +The other way is to signup new user accounts automatically. +For using this, you have to change this + $g_mail_auto_signup = OFF; +from OFF to ON. +Now, bug_report_mail will look for an user named like the mail's sender +or an user which mail adress is identical. +If no user is found, then a new account will be created. +The new user's name will be the mail address. + +This could be used for attacks, but there is no other way in the moment. + +If you like to parse MIME encoded mails, you have to install the PEAR +Mail_Mime package and set + $g_mail_parse_mime = OFF; +from OFF to ON. + +For debugging controls there is the switch + $g_mail_additional = OFF; +which puts the complete message into the Additional Information field, +if it is activated. + +In this case you should decrease the amount of fetched messages via + $g_mail_fetch_max = 1; +because the mime decoding needs a lot of memory. + +After this, bug_report_mail can be used via cron like this: + +*/5 * * * * lynx --dump http://mantis.homepage.com/bug_report_mail.php +or via command line interface +*/5 * * * * /usr/local/bin/php /path/to/mantis/bug_report_mail.php + +This line fetch bug reports from via POP3 every 5 minutes. + +This addon is distributed under the same conditions as Mantis itself. + +Gerrit Beine, August 2004 + +Changelog: +Aug 2005: + - update to Mantis 1.0.0rc1 + - include the additional patches submitted by + - gernot (Fixed MIME handling and save the mail's sender) + mail_get_all_mails in core/mail_api.php + mail_parse_content in core/mail_api.php + mail_add_bug in core/mail_api.php + - stevenc (Fixed MIME handling) + mail_parse_content in core/mail_api.php + - rainman (Fixed empty files bug and regex for finding a bug id) + mail_add_file in core/mail_api.php + mail_get_bug_id_from_subject in core/mail_api.php +Dec 2004: + - update to Mantis 0.19.2 + - add config: g_mail_parse_mime + - add config: g_mail_additional + - add config: g_mail_fetch_max + - make it working via CLI +Nov 2004: + - update to Mantis 0.19.1 + - add support for MIME decoding +Sep 2004: + - update to Mantis 0.19.0 +Aug 2004: + - create patch for Mantis 0.18.3 diff -Nur mantis-1.0.0rc1/doc/README.bug_report_mail~ mantis/doc/README.bug_report_mail~ --- mantis-1.0.0rc1/doc/README.bug_report_mail~ Thu Jan 1 01:00:00 1970 +++ mantis/doc/README.bug_report_mail~ Sun Aug 7 10:20:58 2005 @@ -0,0 +1,98 @@ +The current version of bug_report_mail support plain text and MIME +encoded e-mails via POP3 Mailaccounts with PEAR's Net_POP3 package. + +bug_report_mail is able to recognize if mail is a reply to an already opened +bug and adds the content as a bugnote. + +If you are alway running Mantis you have to alter your projects table +with the sql/bug_report_mail.sql script. +If not, you can create the database tables in the way described in +the doc/INSTALL file. + +This patch changes the following files: + core/category_api.php + core/file_api.php + core/user_api.php + sql/db_generate.sql + config_defaults_inc.php + manage_proj_cat_edit_page.php + manage_proj_edit_page.php +These files are new: + core/mail_api.php + doc/README.bug_report_mail + sql/bug_report_mail.sql + bug_report_mail.php + manage_proj_cat_mail_delete.php + manage_proj_cat_mail_update.php + manage_proj_mail_categories.php + manage_proj_mail_delete.php + manage_proj_mail_update.php + +After installing this patch, you can add a POP3 server's hostname +and authentication data for each of your projects with the project edit form. + +There are two ways to receive mail with bug_report_mail: +The secure (and default) way is to use a standard reporting user: +You have to create a reporter account, for example 'Mail'. +The name for this reporter account you have to write in your config_inc.php file: + $g_mail_reporter = "Mail"; +and then, bug_report_mail must be informed to behave like this: + $g_mail_use_reporter = ON; + +The other way is to signup new user accounts automatically. +For using this, you have to change this + $g_mail_auto_signup = OFF; +from OFF to ON. +Now, bug_report_mail will look for an user named like the mail's sender +or an user which mail adress is identical. +If no user is found, then a new account will be created. +The new user's name will be the mail address. + +This could be used for attacks, but there is no other way in the moment. + +If you like to parse MIME encoded mails, you have to install the PEAR +Mail_Mime package and set + $g_mail_parse_mime = OFF; +from OFF to ON. + +For debugging controls there is the switch + $g_mail_additional = OFF; +which puts the complete message into the Additional Information field, +if it is activated. + +In this case you should decrease the amount of fetched messages via + $g_mail_fetch_max = 1; +because the mime decoding needs a lot of memory. + +After this, bug_report_mail can be used via cron like this: + +*/5 * * * * lynx --dump http://mantis.homepage.com/bug_report_mail.php +or via command line interface +*/5 * * * * /usr/local/bin/php /path/to/mantis/bug_report_mail.php + +This line fetch bug reports from via POP3 every 5 minutes. + +This addon is distributed under the same conditions as Mantis itself. + +Gerrit Beine, August 2004 + +Changelog: +Aug 2005: + - update to Mantis 1.0.0rc1 + - include the additional patches submitted by + - gernot + - stevenc + - rainman +Dec 2004: + - update to Mantis 0.19.2 + - add config: g_mail_parse_mime + - add config: g_mail_additional + - add config: g_mail_fetch_max + - make it working via CLI +Nov 2004: + - update to Mantis 0.19.1 + - add support for MIME decoding +Sep 2004: + - update to Mantis 0.19.0 +Aug 2004: + - create patch for Mantis 0.18.3 diff -Nur mantis-1.0.0rc1/manage_proj_cat_edit_page.php mantis/manage_proj_cat_edit_page.php --- mantis-1.0.0rc1/manage_proj_cat_edit_page.php Sat Feb 12 21:01:06 2005 +++ mantis/manage_proj_cat_edit_page.php Sun Aug 7 10:23:56 2005 @@ -15,6 +15,7 @@ $t_core_path = config_get( 'core_path' ); require_once( $t_core_path.'category_api.php' ); + require_once( $t_core_path.'mail_api.php' ); ?> <?php $f_project_id = gpc_get_int( 'project_id' ); @@ -24,6 +25,10 @@ $t_row = category_get_row( $f_project_id, $f_category ); $t_assigned_to = $t_row['user_id']; + $t_mail = mail_get_account_data( $f_project_id ); + if ( $t_mail['pop3_categories'] ) { + $t_category_mail = mail_category_get_account_data( $f_project_id, $f_category ); + } ?> <?php html_page_top1() ?> <?php html_page_top2() ?> @@ -84,4 +89,59 @@ </form> </div> +<?php if ( $t_mail['pop3_categories'] ) { ?> +<!-- MAIL ACCOUNT CHANGE --> +<br /> +<div align="center"> + <form method="post" action="manage_proj_cat_mail_update.php"> + <input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" /> + <input type="hidden" name="category" value="<?php echo string_attribute( $f_category ) ?>" /> + <table class="width75" cellspacing="1"> + <tr> + <td class="form-title" colspan="4"> + <?php echo 'Category Mail Account Settings' ?> + </td> + </tr> + <tr class="row-1"> + <td class="category" width="25%"> + <?php echo "POP3 Host"?> + </td> + <td width="75%"> + <input type="text" name="pop3_host" size="64" maxlength="255" value="<?php echo string_attribute( $t_category_mail['pop3_host'] ) ?>" /> + </td> + </tr> + <tr class="row-1"> + <td class="category" width="25%"> + <?php echo "POP3 User"?> + </td> + <td width="75%"> + <input type="text" name="pop3_user" size="64" maxlength="255" value="<?php echo string_attribute( $t_category_mail['pop3_user'] ) ?>" /> + </td> + </tr> + <tr class="row-1"> + <td class="category" width="25%"> + <?php echo "POP3 Password"?> + </td> + <td width="75%"> + <input type="text" name="pop3_pass" size="64" maxlength="255" value="<?php echo string_attribute( $t_category_mail['pop3_pass'] ) ?>" /> + </td> + </tr> + <tr> + <td colspan="2"> + <input type="submit" value="<?php echo 'Set Mail Account Data' ?>" /> + </td> + </tr> + </table> + </form> +</div> +<!-- MAIL ACCOUNT RESET --> +<div class="border-center"> + <form method="post" action="manage_proj_cat_mail_delete.php"> + <input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" /> + <input type="hidden" name="category" value="<?php echo string_attribute( $f_category ) ?>" /> + <input type="submit" value="<?php echo 'Delete Mail Account Data' ?>" /> + </form> +</div> +<?php } ?> + <?php html_page_bottom1( __FILE__ ) ?> diff -Nur mantis-1.0.0rc1/manage_proj_cat_mail_delete.php mantis/manage_proj_cat_mail_delete.php --- mantis-1.0.0rc1/manage_proj_cat_mail_delete.php Thu Jan 1 01:00:00 1970 +++ mantis/manage_proj_cat_mail_delete.php Sun Aug 7 10:24:56 2005 @@ -0,0 +1,44 @@ +<?php + # Mantis - a php based bugtracking system + # Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net + # Copyright (C) 2004 Gerrit Beine - gerrit.beine@pitcom.de + # This program is distributed under the terms and conditions of the GPL + # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id$ + # -------------------------------------------------------- + + require_once( 'core.php' ); + + $t_core_path = config_get( 'core_path' ); + + require_once( $t_core_path . 'mail_api.php' ); + + $f_project_id = gpc_get_int( 'project_id' ); + $f_category = gpc_get_string( 'category' ); + + access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id ); + + mail_category_delete( $f_project_id, $f_category ); + + $t_redirect_url = 'manage_proj_cat_edit_page.php?project_id=' . $f_project_id . '&category=' . $f_category; + + html_page_top1(); + + html_meta_redirect( $t_redirect_url ); + + html_page_top2(); +?> + +<br /> +<div align="center"> +<?php + echo lang_get( 'operation_successful' ) . '<br />'; + + print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) ); +?> +</div> + +<?php html_page_bottom1( __FILE__ ) ?> + diff -Nur mantis-1.0.0rc1/manage_proj_cat_mail_update.php mantis/manage_proj_cat_mail_update.php --- mantis-1.0.0rc1/manage_proj_cat_mail_update.php Thu Jan 1 01:00:00 1970 +++ mantis/manage_proj_cat_mail_update.php Sun Aug 7 10:25:59 2005 @@ -0,0 +1,59 @@ +<?php + # Mantis - a php based bugtracking system + # Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net + # Copyright (C) 2004 Gerrit Beine - gerrit.beine@pitcom.de + # This program is distributed under the terms and conditions of the GPL + # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id$ + # -------------------------------------------------------- + + require_once( 'core.php' ); + + $t_core_path = config_get( 'core_path' ); + + require_once( $t_core_path . 'mail_api.php' ); + + $f_project_id = gpc_get_int( 'project_id' ); + $f_pop3_host = gpc_get_string( 'pop3_host' ); + $f_pop3_user = gpc_get_string( 'pop3_user' ); + $f_pop3_pass = gpc_get_string( 'pop3_pass' ); + $f_category = gpc_get_string( 'category' ); + + access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id ); + + if ( is_blank( $f_pop3_host ) ) { + trigger_error( ERROR_EMPTY_FIELD, ERROR ); + } + else { + if ( is_blank( $f_pop3_user ) ) { + trigger_error( ERROR_EMPTY_FIELD, ERROR ); + } + if ( is_blank( $f_pop3_pass ) ) { + trigger_error( ERROR_EMPTY_FIELD, ERROR ); + } + } + + mail_category_update( $f_project_id, $f_category, $f_pop3_host, $f_pop3_user, $f_pop3_pass ); + + $t_redirect_url = 'manage_proj_cat_edit_page.php?project_id=' . $f_project_id . '&category=' . $f_category; + + html_page_top1(); + + html_meta_redirect( $t_redirect_url ); + + html_page_top2(); +?> + +<br /> +<div align="center"> +<?php + echo lang_get( 'operation_successful' ) . '<br />'; + + print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) ); +?> +</div> + +<?php html_page_bottom1( __FILE__ ) ?> + diff -Nur mantis-1.0.0rc1/manage_proj_edit_page.php mantis/manage_proj_edit_page.php --- mantis-1.0.0rc1/manage_proj_edit_page.php Tue Jul 19 15:42:48 2005 +++ mantis/manage_proj_edit_page.php Sun Aug 7 10:41:35 2005 @@ -18,6 +18,7 @@ require_once( $t_core_path . 'version_api.php' ); require_once( $t_core_path . 'custom_field_api.php' ); require_once( $t_core_path . 'icon_api.php' ); + require_once( $t_core_path . 'mail_api.php' ); ?> <?php $f_project_id = gpc_get_int( 'project_id' ); @@ -25,6 +26,7 @@ access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id ); $row = project_get_row( $f_project_id ); + $mail = mail_get_account_data( $f_project_id ); ?> <?php html_page_top1() ?> <?php html_page_top2() ?> @@ -690,4 +692,76 @@ </table> </div> +<?php if ( ! $mail['pop3_categories'] ) { ?> +<!-- MAIL ACCOUNT CHANGE --> +<br /> +<div align="center"> + <form method="post" action="manage_proj_mail_update.php"> + <input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" /> + <table class="width75" cellspacing="1"> + <tr> + <td class="form-title" colspan="4"> + <?php echo 'Mail Account Settings' ?> + </td> + </tr> + <tr class="row-1"> + <td class="category" width="25%"> + <?php echo "POP3 Host"?> + </td> + <td width="75%"> + <input type="text" name="pop3_host" size="64" maxlength="255" value="<?php echo string_attribute( $mail['pop3_host'] ) ?>" /> + </td> + </tr> + <tr class="row-1"> + <td class="category" width="25%"> + <?php echo "POP3 User"?> + </td> + <td width="75%"> + <input type="text" name="pop3_user" size="64" maxlength="255" value="<?php echo string_attribute( $mail['pop3_user'] ) ?>" /> + </td> + </tr> + <tr class="row-1"> + <td class="category" width="25%"> + <?php echo "POP3 Password"?> + </td> + <td width="75%"> + <input type="text" name="pop3_pass" size="64" maxlength="255" value="<?php echo string_attribute( $mail['pop3_pass'] ) ?>" /> + </td> + </tr> + <tr> + <td colspan="2"> + <input type="submit" value="<?php echo 'Set Mail Account Data' ?>" /> + </td> + </tr> + </table> + </form> +</div> +<!-- MAIL ACCOUNT RESET --> +<div class="border-center"> + <form method="post" action="manage_proj_mail_delete.php"> + <input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" /> + <input type="submit" value="<?php echo 'Delete Mail Account Data' ?>" /> + </form> +</div> +<br /> +<!-- MAIL ACCOUNT CATEGORIES --> +<div class="border-center"> + <form method="post" action="manage_proj_mail_categories.php"> + <input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" /> + <input type="hidden" name="categories" value="On" /> + <input type="submit" value="<?php echo 'Activate Mail Account per Category' ?>" /> + </form> +</div> +<?php } else { ?> +<!-- MAIL ACCOUNT CATEGORIES --> +<div class="border-center"> + <form method="post" action="manage_proj_mail_categories.php"> + <input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" /> + <input type="hidden" name="categories" value="Off" /> + <input type="submit" value="<?php echo 'Deactivate Mail Account per Category' ?>" /> + </form> +</div> +<?php } ?> + <?php html_page_bottom1( __FILE__ ) ?> + diff -Nur mantis-1.0.0rc1/manage_proj_mail_categories.php mantis/manage_proj_mail_categories.php --- mantis-1.0.0rc1/manage_proj_mail_categories.php Thu Jan 1 01:00:00 1970 +++ mantis/manage_proj_mail_categories.php Sun Aug 7 10:30:02 2005 @@ -0,0 +1,43 @@ +<?php + # Mantis - a php based bugtracking system + # Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net + # Copyright (C) 2004 Gerrit Beine - gerrit.beine@pitcom.de + # This program is distributed under the terms and conditions of the GPL + # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id$ + # -------------------------------------------------------- + + require_once( 'core.php' ); + + $t_core_path = config_get( 'core_path' ); + + require_once( $t_core_path . 'mail_api.php' ); + + $f_project_id = gpc_get_int( 'project_id' ); + $f_activate = gpc_get_string( 'categories' ); + + access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id ); + + mail_categories( $f_project_id, $f_activate ); + + $t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $f_project_id; + + html_page_top1(); + + html_meta_redirect( $t_redirect_url ); + + html_page_top2(); +?> + +<br /> +<div align="center"> +<?php + echo lang_get( 'operation_successful' ) . '<br />'; + print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) ); +?> +</div> + +<?php html_page_bottom1( __FILE__ ) ?> + diff -Nur mantis-1.0.0rc1/manage_proj_mail_delete.php mantis/manage_proj_mail_delete.php --- mantis-1.0.0rc1/manage_proj_mail_delete.php Thu Jan 1 01:00:00 1970 +++ mantis/manage_proj_mail_delete.php Sun Aug 7 10:31:01 2005 @@ -0,0 +1,43 @@ +<?php + # Mantis - a php based bugtracking system + # Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net + # Copyright (C) 2004 Gerrit Beine - gerrit.beine@pitcom.de + # This program is distributed under the terms and conditions of the GPL + # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id$ + # -------------------------------------------------------- + + require_once( 'core.php' ); + + $t_core_path = config_get( 'core_path' ); + + require_once( $t_core_path . 'mail_api.php' ); + + $f_project_id = gpc_get_int( 'project_id' ); + + access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id ); + + mail_delete( $f_project_id ); + + $t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $f_project_id; + + html_page_top1(); + + html_meta_redirect( $t_redirect_url ); + + html_page_top2(); +?> + +<br /> +<div align="center"> +<?php + echo lang_get( 'operation_successful' ) . '<br />'; + + print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) ); +?> +</div> + +<?php html_page_bottom1( __FILE__ ) ?> + diff -Nur mantis-1.0.0rc1/manage_proj_mail_update.php mantis/manage_proj_mail_update.php --- mantis-1.0.0rc1/manage_proj_mail_update.php Thu Jan 1 01:00:00 1970 +++ mantis/manage_proj_mail_update.php Sun Aug 7 10:32:15 2005 @@ -0,0 +1,59 @@ +<?php + # Mantis - a php based bugtracking system + # Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net + # Copyright (C) 2004 Gerrit Beine - gerrit.beine@pitcom.de + # This program is distributed under the terms and conditions of the GPL + # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id$ + # -------------------------------------------------------- + + require_once( 'core.php' ); + + $t_core_path = config_get( 'core_path' ); + + require_once( $t_core_path . 'mail_api.php' ); + + $f_project_id = gpc_get_int( 'project_id' ); + $f_pop3_host = gpc_get_string( 'pop3_host' ); + $f_pop3_user = gpc_get_string( 'pop3_user' ); + $f_pop3_pass = gpc_get_string( 'pop3_pass' ); + + echo $f_project_id; + access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id ); + + if ( is_blank( $f_pop3_host ) ) { + trigger_error( ERROR_EMPTY_FIELD, ERROR ); + } + else { + if ( is_blank( $f_pop3_user ) ) { + trigger_error( ERROR_EMPTY_FIELD, ERROR ); + } + if ( is_blank( $f_pop3_pass ) ) { + trigger_error( ERROR_EMPTY_FIELD, ERROR ); + } + } + + mail_update( $f_project_id, $f_pop3_host, $f_pop3_user, $f_pop3_pass ); + + $t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $f_project_id; + + html_page_top1(); + + html_meta_redirect( $t_redirect_url ); + + html_page_top2(); +?> + +<br /> +<div align="center"> +<?php + echo lang_get( 'operation_successful' ) . '<br />'; + + print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) ); +?> +</div> + +<?php html_page_bottom1( __FILE__ ) ?> + mantis-1.0.0rc2.patch (41,283 bytes)
diff -Nur mantis-1.0.0rc2.orig/admin/schema.php mantis-1.0.0rc2/admin/schema.php --- mantis-1.0.0rc2.orig/admin/schema.php Wed Aug 3 16:20:34 2005 +++ mantis-1.0.0rc2/admin/schema.php Mon Oct 31 11:15:02 2005 @@ -192,7 +192,10 @@ $upgrade[] = Array('CreateTableSQL',Array(config_get('mantis_project_category_table')," project_id I UNSIGNED NOTNULL PRIMARY DEFAULT '0', category C(64) NOTNULL PRIMARY DEFAULT \" '' \", - user_id I UNSIGNED NOTNULL DEFAULT '0' + user_id I UNSIGNED NOTNULL DEFAULT '0', + pop3_host C(250) NULL, + pop3_user C(250) NULL, + pop3_pass C(250) NULL ",Array('mysql' => 'TYPE=MyISAM', 'pgsql' => 'WITHOUT OIDS'))); $upgrade[] = Array('CreateTableSQL',Array(config_get('mantis_project_file_table')," @@ -222,7 +225,11 @@ view_state I2 NOTNULL DEFAULT '10', access_min I2 NOTNULL DEFAULT '10', file_path C(250) NOTNULL DEFAULT \" '' \", - description XS NOTNULL + description XS NOTNULL, + pop3_host C(250) NULL, + pop3_user C(250) NULL, + pop3_pass C(250) NULL, + pop3_categories L NOTNULL DEFAULT '0' ",Array('mysql' => 'TYPE=MyISAM', 'pgsql' => 'WITHOUT OIDS'))); $upgrade[] = Array('CreateIndexSQL',Array('idx_project_id',config_get('mantis_project_table'),'id')); $upgrade[] = Array('CreateIndexSQL',Array('idx_project_name',config_get('mantis_project_table'),'name',Array('UNIQUE'))); @@ -340,5 +347,9 @@ $upgrade[] = Array('InsertData', Array( config_get('mantis_user_table'), "(username, realname, email, password, date_created, last_visit, enabled, protected, access_level, login_count, lost_password_request_count, failed_login_count, cookie_string) VALUES ('administrator', '', 'root@localhost', '63a9f0ea7bb98050796b649e85481845', " . db_now() . ", " . db_now() . ", 1, 0, 90, 3, 0, 0, '" . + md5( mt_rand( 0, mt_getrandmax() ) + mt_rand( 0, mt_getrandmax() ) ) . md5( time() ) . "')" ) ); +$upgrade[] = Array('InsertData', Array( config_get('mantis_user_table'), + "(username, realname, email, password, date_created, last_visit, enabled, protected, access_level, login_count, lost_password_request_count, failed_login_count, cookie_string) VALUES + ('mail', 'Mail Reporter', 'root@nomail@localhost', 'a268462c3c679a9027658c5aa723f97c', " . db_now() . ", " . db_now() . ", 1, 0, 25, 0, 0, 0, '" . md5( mt_rand( 0, mt_getrandmax() ) + mt_rand( 0, mt_getrandmax() ) ) . md5( time() ) . "')" ) ); ?> diff -Nur mantis-1.0.0rc2.orig/bug_report_mail.php mantis-1.0.0rc2/bug_report_mail.php --- mantis-1.0.0rc2.orig/bug_report_mail.php Thu Jan 1 01:00:00 1970 +++ mantis-1.0.0rc2/bug_report_mail.php Mon Oct 31 11:15:02 2005 @@ -0,0 +1,39 @@ +<?php + # Mantis - a php based bugtracking system + # Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net + # Copyright (C) 2004 Gerrit Beine - gerrit.beine@pitcom.de + # This program is distributed under the terms and conditions of the GPL + # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id$ + # -------------------------------------------------------- + + # This page receives an E-Mail via POP3 and generates an Report + header("Content-type: text/plain"); + require_once( 'core.php' ); + + $t_core_path = config_get( 'core_path' ); + + require_once( $t_core_path . 'string_api.php' ); + require_once( $t_core_path . 'bug_api.php' ); + require_once( $t_core_path . 'mail_api.php' ); + + $t_mailaccounts = mail_get_accounts(); + + foreach ($t_mailaccounts as $t_mailaccount) { + if ( config_get( 'mail_debug' ) ) { + print_r($t_mailaccounts); + } + $t_mails = mail_get_all_mails($t_mailaccount); + foreach ($t_mails as $t_mail) + { + if ( config_get( 'mail_debug' ) ) { + print_r($t_mail); + } + $GLOBALS['g_cache_current_user_id'] = mail_get_user( $t_mail['From'] ); + mail_add_bug($t_mail, $t_mailaccount); + } + } +?> + diff -Nur mantis-1.0.0rc2.orig/config_defaults_inc.php mantis-1.0.0rc2/config_defaults_inc.php --- mantis-1.0.0rc2.orig/config_defaults_inc.php Sun Sep 11 13:24:08 2005 +++ mantis-1.0.0rc2/config_defaults_inc.php Mon Oct 31 11:15:02 2005 @@ -1617,4 +1617,37 @@ # ) # ); $g_custom_group_actions = array(); + + ###################### + # Mail Reporting + ###################### + + # --- mail reporting settings ----- + # This tells Mantis to report all the Mail with only one account + $g_mail_use_reporter = ON; + + # The account's name for mail reporting + # Also used for fallback if a user is not found in database + $g_mail_reporter = 'Mail'; + + # Signup new users automatically (possible security risk!) + # Default is OFF, ignored if mail_use_reporter is ON + $g_mail_auto_signup = OFF; + + # Write complete mail into the "Additional Information" + $g_mail_additional = OFF; + + # Write sender of the message into the bug report + $g_mail_save_from = OFF; + + # Parse MIME mails (may require a lot of memory) + $g_mail_parse_mime = OFF; + + # How many mails should be fetched at the same time + # If big mails with attachments should be received, specify only one + $g_mail_fetch_max = 1; + + # Signup new users automatically (possible security risk!) + # Default is OFF, ignored if mail_use_reporter is ON + $g_mail_debug = OFF; ?> diff -Nur mantis-1.0.0rc2.orig/core/category_api.php mantis-1.0.0rc2/core/category_api.php --- mantis-1.0.0rc2.orig/core/category_api.php Sat Feb 12 21:01:10 2005 +++ mantis-1.0.0rc2/core/category_api.php Mon Oct 31 11:15:22 2005 @@ -186,7 +186,7 @@ $t_project_category_table = config_get( 'mantis_project_category_table' ); - $query = "SELECT category, user_id + $query = "SELECT category, user_id, pop3_host, pop3_user, pop3_pass FROM $t_project_category_table WHERE project_id='$c_project_id' AND category='$c_category'"; @@ -206,7 +206,7 @@ $t_project_category_table = config_get( 'mantis_project_category_table' ); - $query = "SELECT category, user_id + $query = "SELECT category, user_id, pop3_host, pop3_user, pop3_pass FROM $t_project_category_table WHERE project_id='$c_project_id' ORDER BY category"; diff -Nur mantis-1.0.0rc2.orig/core/mail_api.php mantis-1.0.0rc2/core/mail_api.php --- mantis-1.0.0rc2.orig/core/mail_api.php Thu Jan 1 01:00:00 1970 +++ mantis-1.0.0rc2/core/mail_api.php Mon Oct 31 11:15:02 2005 @@ -0,0 +1,443 @@ +<?php + # Mantis - a php based bugtracking system + # Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net + # Copyright (C) 2004 Gerrit Beine - gerrit.beine@pitcom.de + # This program is distributed under the terms and conditions of the GPL + # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id$ + # -------------------------------------------------------- + + $t_core_dir = dirname( __FILE__ ).DIRECTORY_SEPARATOR; + + require_once( $t_core_dir . 'bug_api.php' ); + require_once( $t_core_dir . 'bugnote_api.php' ); + require_once( $t_core_dir . 'user_api.php' ); + require_once( $t_core_dir . 'project_api.php' ); + require_once( $t_core_dir . 'file_api.php' ); + + # This page receives an E-Mail via POP3 and generates an Report + + require_once( 'Net/POP3.php' ); + require_once( 'Mail/mimeDecode.php' ); + + # -------------------- + # Return mail account data for the specified project + function mail_get_account_data( $p_project_id ) { + $v_project_id = db_prepare_int( $p_project_id ); + + $t_project_table = config_get( 'mantis_project_table' ); + + $query = "SELECT pop3_host, pop3_user, pop3_pass, pop3_categories + FROM $t_project_table + WHERE id='$v_project_id'"; + + $result = db_query( $query ); + + return db_fetch_array( $result ); + } + + # -------------------- + # Update the mail account data for a project + function mail_update( $p_project_id, $p_pop3_host, $p_pop3_user, $p_pop3_pass ) { + $v_project_id = db_prepare_int( $p_project_id ); + $v_pop3_host = db_prepare_string( $p_pop3_host ); + $v_pop3_user = db_prepare_string( $p_pop3_user ); + $v_pop3_pass = db_prepare_string( $p_pop3_pass ); + + $t_project_table = config_get( 'mantis_project_table' ); + + $query = "UPDATE $t_project_table + SET pop3_host='$v_pop3_host', + pop3_user='$v_pop3_user', + pop3_pass='$v_pop3_pass' + WHERE id='$v_project_id'"; + + db_query( $query ); + + return true; + } + + # -------------------- + # Removes the mail account data from a project + function mail_delete( $p_project_id ) { + $v_project_id = db_prepare_int( $p_project_id ); + + $t_project_table = config_get( 'mantis_project_table' ); + + $query = "UPDATE $t_project_table + SET pop3_host=NULL, + pop3_user=NULL, + pop3_pass=NULL + WHERE id='$v_project_id'"; + + db_query( $query ); + + return true; + } + + # -------------------- + # Activate the 'Mail per Category' feature for a project + function mail_categories( $p_project_id, $p_active ) { + $v_project_id = db_prepare_int( $p_project_id ); + + if ($p_active == 'On') { + $v_active = 1; + } else { + $v_active = 0; + } + + $t_project_table = config_get( 'mantis_project_table' ); + + $query = "UPDATE $t_project_table + SET pop3_categories='$v_active' + WHERE id='$v_project_id'"; + + db_query( $query ); + + return true; + } + + # -------------------- + # Return mail account data for the specified project and category + function mail_category_get_account_data( $p_project_id, $p_category ) { + $v_project_id = db_prepare_int( $p_project_id ); + $v_category = db_prepare_string( $p_category ); + + $t_project_category_table = config_get( 'mantis_project_category_table' ); + + $query = "SELECT pop3_host, pop3_user, pop3_pass + FROM $t_project_category_table + WHERE project_id='$v_project_id' AND category='$v_category'"; + + $result = db_query( $query ); + + return db_fetch_array( $result ); + } + + # -------------------- + # Update the mail account data for a category + function mail_category_update( $p_project_id, $p_category, $p_pop3_host, $p_pop3_user, $p_pop3_pass ) { + $v_project_id = db_prepare_int( $p_project_id ); + $v_category = db_prepare_string( $p_category ); + $v_pop3_host = db_prepare_string( $p_pop3_host ); + $v_pop3_user = db_prepare_string( $p_pop3_user ); + $v_pop3_pass = db_prepare_string( $p_pop3_pass ); + + $t_project_category_table = config_get( 'mantis_project_category_table' ); + + $query = "UPDATE $t_project_category_table + SET pop3_host='$v_pop3_host', + pop3_user='$v_pop3_user', + pop3_pass='$v_pop3_pass' + WHERE project_id='$v_project_id' AND category='$v_category'"; + + db_query( $query ); + + return true; + } + + # -------------------- + # Removes the mail account data for a category + function mail_category_delete( $p_project_id, $p_category ) { + $v_project_id = db_prepare_int( $p_project_id ); + $v_category = db_prepare_string( $p_category ); + + $t_project_table = config_get( 'mantis_project_table' ); + + $t_project_category_table = config_get( 'mantis_project_category_table' ); + + $query = "UPDATE $t_project_category_table + SET pop3_host=NULL, + pop3_user=NULL, + pop3_pass=NULL + WHERE project_id='$v_project_id' AND category='$v_category'"; + + db_query( $query ); + + return true; + } + + # -------------------- + # return all mailaccounts + # return an empty array if there are no + function mail_get_accounts() { + $v_accounts = array(); + $t_projects = mail_project_get_all_rows(); + + foreach ($t_projects as $t_project) { + if ($t_project['pop3_categories']) { + $v_categories = mail_categories_get_all_rows( $t_project['id'] ); + $v_accounts = array_merge($v_accounts, $v_categories); + } else { + array_push($v_accounts, $t_project); + } + } + + return $v_accounts; + } + + # -------------------- + # return all projects with valid data for mail access + # return an empty array if there are no such projects + function mail_project_get_all_rows() { + $v_projects = array(); + $t_projects = project_get_all_rows(); + + foreach ($t_projects as $t_project) { + if ($t_project['pop3_host'] || $t_project['pop3_categories']) { + array_push($v_projects, $t_project); + } + } + + return $v_projects; + } + + # -------------------- + # return all categories from a project with valid data for mail access + # return an empty array if there are no such categories + function mail_categories_get_all_rows( $p_project_id ) { + $v_categories = array(); + $t_categories = category_get_all_rows( $p_project_id ); + + foreach ($t_categories as $t_category) { + if ($t_category['pop3_host']) { + $t_category['id'] = $p_project_id; + array_push($v_categories, $t_category); + } + } + + return $v_categories; + } + + # -------------------- + # return all mails for an account + # return an empty array if there are no new mails + function mail_get_all_mails( $p_account ) { + $t_mail_parse_mime = config_get( 'mail_parse_mime' ); + $t_mail_fetch_max = config_get( 'mail_fetch_max' ); + $t_mail_additional = config_get( 'mail_additional' ); + + $v_mails = array(); + $t_pop3 = &new Net_POP3(); + $t_pop3_host = $p_account['pop3_host']; + $t_pop3_user = $p_account['pop3_user']; + $t_pop3_password = $p_account['pop3_pass']; + $t_pop3->connect($t_pop3_host, 110); + $t_pop3->login($t_pop3_user, $t_pop3_password); + + if ( 0 == $t_pop3->numMsg() ) { + return $v_mails; + } + for ($i = 1; $i <= $t_mail_fetch_max; $i++) { + $t_headers = $t_pop3->getParsedHeaders($i); + $t_msg = $t_pop3->getMsg($i); + if (true == $t_mail_parse_mime && + true == isset( $t_headers['MIME-Version'] ) && + 'multipart' == strtolower ( substr( $t_headers['Content-Type'], 0, 9 ) ) ) { + $t_mail = mail_parse_content( $t_msg ); + } else { + $t_mail = $t_headers; + $t_mail['X-Mantis-Body'] = $t_pop3->getBody($i); + } + + if (true == $t_mail_additional) { + $t_mail['X-Mantis-Complete'] = $t_msg; + } + + array_push($v_mails, $t_mail); + $t_pop3->deleteMsg($i); + } + + $t_pop3->disconnect(); + return $v_mails; + } + + # -------------------- + # return the mail parsed for Mantis + function mail_parse_content ( $p_mail ) { + $v_mail = array (); + $t_decoder = new Mail_mimeDecode($p_mail); + $t_params['include_bodies'] = true; + $t_params['decode_bodies'] = true; + $t_params['decode_headers'] = true; + $t_structure = $t_decoder->decode($t_params); + $v_mail['To'] = $t_structure->headers['to']; + $v_mail['From'] = $t_structure->headers['from']; + $v_mail['Subject'] = $t_structure->headers['subject']; + if (is_array($t_structure->parts)) { + $t_parts = mail_parse_parts( $t_structure->parts ); + } else { + $t_parts = array ( mail_parse_part( $t_structure ) ); + } + if (strtolower($t_parts[0]['Content-Type']) == 'text/plain' || + strtolower($t_parts[0]['Content-Type']) == 'text/html' ) { + $t_body['Body'] = $t_parts[0]['Body']; + } else { + $t_body['Body'] = "It seems, there is no text... :-o"; + } + $v_mail['X-Mantis-Parts'] = $t_parts; + $v_mail['X-Mantis-Body'] = $t_body['Body']; + + return $v_mail; + } + + # -------------------- + # return the parsed parts from the mail + function mail_parse_parts ( $p_parts ) { + $v_parts = array (); + foreach ( $p_parts as $t_part ) { + array_push($v_parts, mail_parse_part( $t_part )); + } + + return $v_parts; + } + + # -------------------- + # return one parsed part + function mail_parse_part ( $p_part ) { + $v_part = array (); + $v_part['Content-Type'] = $p_part->ctype_primary."/".$p_part->ctype_secondary; + $v_part['Name'] = $p_part->ctype_parameters['name']; + $v_part['Body'] = $p_part->body; + + return $v_part; + } + + # -------------------- + # return the mailadress from the mail's 'From' + function mail_parse_address ( $p_mailaddress ) { + if (preg_match("/<(.*?)>/", $p_mailaddress, $matches)) { + $v_mailaddress = $matches[1]; + } + + return $v_mailaddress; + } + + # -------------------- + # return the a valid username from an email address + function mail_user_name_from_address ( $p_mailaddress ) { + return preg_replace("/[@\.-]/", '_', $p_mailaddress); + } + + # -------------------- + # return true if there is a valid mantis bug referernce in subject + function mail_is_a_bugnote ( $p_mail_subject ) { + return preg_match("/\[([A-Za-z0-9-_\. ]*\s[0-9]{7})\]/", $p_mail_subject); + } + + # -------------------- + # return the bug's id from the subject + function mail_get_bug_id_from_subject ( $p_mail_subject ) { + preg_match("/\[([A-Za-z0-9-_\. ]*\s([0-9]{7}?))\]/", $p_mail_subject, $v_matches); + + return $v_matches[2]; + } + + # -------------------- + # return the user id for the mail reporting user + function mail_get_user ($p_mailaddress) { + $t_mail_use_reporter = config_get( 'mail_use_reporter' ); + $t_mail_auto_signup = config_get( 'mail_auto_signup' ); + $t_mail_reporter = config_get( 'mail_reporter' ); + + $v_mailaddress = mail_parse_address( $p_mailaddress ); + + if ( $t_mail_use_reporter ) { + // Always report as mail_reporter + $t_reporter_id = user_get_id_by_name( $t_mail_reporter ); + } else { + // Try to get the reporting users id + $t_reporter_id = user_get_id_by_mail ( $v_mailaddress ); + if ( ! $t_reporter_id && $t_mail_auto_signup ) { + // So, we've to sign up a new user... + $t_user_name = mail_user_name_from_address ( $v_mailaddress ); + user_signup($t_user_name, $v_mailaddress); + $t_reporter_id = user_get_id_by_name($t_user_name); + } elseif ( ! $t_reporter_id ) { + // Fall back to the default mail_reporter + $t_reporter_id = user_get_id_by_name( $t_mail_reporter ); + } + } + + // dirty: Set the identified user's id + // required if bug_report_mail is run via command line + $GLOBAL['g_cache_current_user_id'] = $t_reporter_id; + + return $t_reporter_id; + } + + # -------------------- + # Very dirty: Adds a file to a bug. + function mail_add_file( $p_bug_id, $p_part ) { + $GLOBALS['_mail_file_'] = $p_part['Name']; + if ( 0 < strlen($p_part['Name']) ) { + $t_file_name = '/tmp/'.$p_part['Name']; + file_put_contents($t_file_name, $p_part['Body']); + file_add($p_bug_id, $t_file_name, $p_part['Name'], $p_part['Content-Type'], 'bug'); + unlink($t_file_name); + } + } + + # -------------------- + # Adds a bug which is reported via email + # Taken from bug_report.php and + function mail_add_bug ( $p_mail, $p_account ) { + $t_mail_save_from = config_get( 'mail_save_from' ); + + $t_bug_data = new BugData; + $t_bug_data->build = gpc_get_string( 'build', '' ); + $t_bug_data->platform = gpc_get_string( 'platform', '' ); + $t_bug_data->os = gpc_get_string( 'os', '' ); + $t_bug_data->os_build = gpc_get_string( 'os_build', '' ); + $t_bug_data->version = gpc_get_string( 'product_version', '' ); + $t_bug_data->profile_id = gpc_get_int( 'profile_id', 0 ); + $t_bug_data->handler_id = gpc_get_int( 'handler_id', 0 ); + $t_bug_data->view_state = gpc_get_int( 'view_state', config_get( 'default_bug_view_status' ) ); + + if ( $p_account['category']) { + $t_bug_data->category = gpc_get_string( 'category', $p_account['category'] ); + } else { + $t_bug_data->category = gpc_get_string( 'category', '' ); + } + $t_bug_data->reproducibility = 10; + $t_bug_data->severity = 50; + $t_bug_data->priority = gpc_get_int( 'priority', NORMAL ); + $t_bug_data->summary = $p_mail['Subject']; + if ( $t_mail_save_from ) { + $t_bug_data->description = "Report from: ".$p_mail['From']."\n\n".$p_mail['X-Mantis-Body']; + } + else { + $t_bug_data->description = $p_mail['X-Mantis-Body']; + } + $t_bug_data->steps_to_reproduce = gpc_get_string( 'steps_to_reproduce', '' ); + $t_bug_data->additional_information = $p_mail['X-Mantis-Complete']; + + $t_bug_data->project_id = $p_account['id']; + + $t_bug_data->reporter_id = mail_get_user( $p_mail['From'] ); + + if ( mail_is_a_bugnote( $p_mail['Subject'] ) ) { + # Add a bug note + $t_bug_id = mail_get_bug_id_from_subject( $p_mail['Subject'] ); + if ( ! bug_is_readonly( $t_bug_id ) ) { + bugnote_add ( $t_bug_id, $p_mail['X-Mantis-Body'] ); + email_bugnote_add ( $t_bug_id ); + } + } else { + # Create the bug + $t_bug_id = bug_create( $t_bug_data ); + email_new_bug( $t_bug_id ); + } + # Add files + if ( null != $p_mail['X-Mantis-Parts'] ) { + foreach ($p_mail['X-Mantis-Parts'] as $part) { + mail_add_file ( $t_bug_id, $part ); + } + } + + } + +?> + diff -Nur mantis-1.0.0rc2.orig/core/user_api.php mantis-1.0.0rc2/core/user_api.php --- mantis-1.0.0rc2.orig/core/user_api.php Fri Jul 22 17:34:02 2005 +++ mantis-1.0.0rc2/core/user_api.php Mon Oct 31 11:15:02 2005 @@ -526,6 +526,24 @@ } } + # get a user id from an mail address + # return false if the mail address does not exist + function user_get_id_by_mail( $p_mailaddress ) { + $c_mailaddress = db_prepare_string( $p_mailaddress ); + $t_user_table = config_get( 'mantis_user_table' ); + + $query = "SELECT id + FROM $t_user_table + WHERE email='$c_mailaddress'"; + $result = db_query( $query ); + + if ( 0 == db_num_rows( $result ) ) { + return false; + } else { + return db_result( $result ); + } + } + # -------------------- # return all data associated with a particular user name # return false if the username does not exist diff -Nur mantis-1.0.0rc2.orig/doc/README.bug_report_mail mantis-1.0.0rc2/doc/README.bug_report_mail --- mantis-1.0.0rc2.orig/doc/README.bug_report_mail Thu Jan 1 01:00:00 1970 +++ mantis-1.0.0rc2/doc/README.bug_report_mail Mon Oct 31 11:17:22 2005 @@ -0,0 +1,113 @@ +The current version of bug_report_mail support plain text and MIME +encoded e-mails via POP3 Mailaccounts with PEAR's Net_POP3 package. + +bug_report_mail is able to recognize if mail is a reply to an already opened +bug and adds the content as a bugnote. + +If you are alway running Mantis you have to alter your projects table +with the sql/bug_report_mail.sql script. +If not, you can create the database tables in the way described in +the doc/INSTALL file. + +This patch changes the following files: + core/category_api.php + core/user_api.php + admin/schema.php + config_defaults_inc.php + manage_proj_cat_edit_page.php + manage_proj_edit_page.php +These files are new: + core/mail_api.php + doc/README.bug_report_mail + doc/bug_report_mail.sql + bug_report_mail.php + manage_proj_cat_mail_delete.php + manage_proj_cat_mail_update.php + manage_proj_mail_categories.php + manage_proj_mail_delete.php + manage_proj_mail_update.php + +After installing this patch, you can add a POP3 server's hostname +and authentication data for each of your projects with the project edit form. + +There are two ways to receive mail with bug_report_mail: +The secure (and default) way is to use a standard reporting user: +You have to create a reporter account, for example 'Mail'. +The name for this reporter account you have to write in your config_inc.php file: + $g_mail_reporter = "Mail"; +and then, bug_report_mail must be informed to behave like this: + $g_mail_use_reporter = ON; + +The other way is to signup new user accounts automatically. +For using this, you have to change this + $g_mail_auto_signup = OFF; +from OFF to ON. +Now, bug_report_mail will look for an user named like the mail's sender +or an user which mail adress is identical. +If no user is found, then a new account will be created. +The new user's name will be the mail address. + +This could be used for attacks, but there is no other way in the moment. + +If you like to parse MIME encoded mails, you have to install the PEAR +Mail_Mime package and set + $g_mail_parse_mime = OFF; +from OFF to ON. + +For debugging controls there is the switch + $g_mail_additional = OFF; +which puts the complete message into the Additional Information field, +if it is activated. + +In this case you should decrease the amount of fetched messages via + $g_mail_fetch_max = 1; +because the mime decoding needs a lot of memory. + +If you'd like to use the Mail Reporter but don't save the whole message for +making the sender's address available, set + $g_mail_save_from = OFF; +to ON. + +After this, bug_report_mail can be used via cron like this: + +*/5 * * * * lynx --dump http://mantis.homepage.com/bug_report_mail.php +or via command line interface +*/5 * * * * /usr/local/bin/php /path/to/mantis/bug_report_mail.php + +This line fetch bug reports from via POP3 every 5 minutes. + +This addon is distributed under the same conditions as Mantis itself. + +Gerrit Beine, August 2004 + +Changelog: +Sep 2005: + - update to Mantis 1.0.0rc2 + - fixed a bug in getting all categories for a project + category_get_all_rows in core/category_api.php +Aug 2005: + - update to Mantis 1.0.0rc1 + - include the additional patches submitted by + - gernot (Fixed MIME handling and save the mail's sender) + mail_get_all_mails in core/mail_api.php + mail_parse_content in core/mail_api.php + mail_add_bug in core/mail_api.php + - stevenc (Fixed MIME handling) + mail_parse_content in core/mail_api.php + - rainman (Fixed empty files bug and regex for finding a bug id) + mail_add_file in core/mail_api.php + mail_get_bug_id_from_subject in core/mail_api.php +Dec 2004: + - update to Mantis 0.19.2 + - add config: g_mail_parse_mime + - add config: g_mail_additional + - add config: g_mail_fetch_max + - make it working via CLI +Nov 2004: + - update to Mantis 0.19.1 + - add support for MIME decoding +Sep 2004: + - update to Mantis 0.19.0 +Aug 2004: + - create patch for Mantis 0.18.3 + diff -Nur mantis-1.0.0rc2.orig/doc/bug_report_mail.sql mantis-1.0.0rc2/doc/bug_report_mail.sql --- mantis-1.0.0rc2.orig/doc/bug_report_mail.sql Thu Jan 1 01:00:00 1970 +++ mantis-1.0.0rc2/doc/bug_report_mail.sql Mon Oct 31 11:15:02 2005 @@ -0,0 +1,12 @@ +ALTER TABLE `mantis_project_table` +ADD `pop3_host` VARCHAR( 255 ) DEFAULT NULL , +ADD `pop3_user` VARCHAR( 255 ) DEFAULT NULL , +ADD `pop3_pass` VARCHAR( 255 ) DEFAULT NULL , +ADD `pop3_categories` ENUM( '0', '1' ) DEFAULT '0' NOT NULL ; + +ALTER TABLE `mantis_project_category_table` +ADD `pop3_host` VARCHAR( 255 ) DEFAULT NULL , +ADD `pop3_user` VARCHAR( 255 ) DEFAULT NULL , +ADD `pop3_pass` VARCHAR( 255 ) DEFAULT NULL ; + +INSERT INTO mantis_user_table (username, realname, email, password, date_created, last_visit, enabled, protected, access_level, login_count, lost_password_request_count, failed_login_count, cookie_string) VALUES ('Mail', 'Mail Reporter', 'nomail', 'a268462c3c679a9027658c5aa723f97c', '2004-12-25 15:41:49', '2004-12-25 15:41:49', 1, 0, 25, 0, 0, 0, CONCAT(MD5(RAND()),MD5(NOW()))); diff -Nur mantis-1.0.0rc2.orig/manage_proj_cat_edit_page.php mantis-1.0.0rc2/manage_proj_cat_edit_page.php --- mantis-1.0.0rc2.orig/manage_proj_cat_edit_page.php Sat Feb 12 21:01:06 2005 +++ mantis-1.0.0rc2/manage_proj_cat_edit_page.php Mon Oct 31 11:15:02 2005 @@ -15,6 +15,7 @@ $t_core_path = config_get( 'core_path' ); require_once( $t_core_path.'category_api.php' ); + require_once( $t_core_path.'mail_api.php' ); ?> <?php $f_project_id = gpc_get_int( 'project_id' ); @@ -24,6 +25,10 @@ $t_row = category_get_row( $f_project_id, $f_category ); $t_assigned_to = $t_row['user_id']; + $t_mail = mail_get_account_data( $f_project_id ); + if ( $t_mail['pop3_categories'] ) { + $t_category_mail = mail_category_get_account_data( $f_project_id, $f_category ); + } ?> <?php html_page_top1() ?> <?php html_page_top2() ?> @@ -84,4 +89,59 @@ </form> </div> +<?php if ( $t_mail['pop3_categories'] ) { ?> +<!-- MAIL ACCOUNT CHANGE --> +<br /> +<div align="center"> + <form method="post" action="manage_proj_cat_mail_update.php"> + <input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" /> + <input type="hidden" name="category" value="<?php echo string_attribute( $f_category ) ?>" /> + <table class="width75" cellspacing="1"> + <tr> + <td class="form-title" colspan="4"> + <?php echo 'Category Mail Account Settings' ?> + </td> + </tr> + <tr class="row-1"> + <td class="category" width="25%"> + <?php echo "POP3 Host"?> + </td> + <td width="75%"> + <input type="text" name="pop3_host" size="64" maxlength="255" value="<?php echo string_attribute( $t_category_mail['pop3_host'] ) ?>" /> + </td> + </tr> + <tr class="row-1"> + <td class="category" width="25%"> + <?php echo "POP3 User"?> + </td> + <td width="75%"> + <input type="text" name="pop3_user" size="64" maxlength="255" value="<?php echo string_attribute( $t_category_mail['pop3_user'] ) ?>" /> + </td> + </tr> + <tr class="row-1"> + <td class="category" width="25%"> + <?php echo "POP3 Password"?> + </td> + <td width="75%"> + <input type="text" name="pop3_pass" size="64" maxlength="255" value="<?php echo string_attribute( $t_category_mail['pop3_pass'] ) ?>" /> + </td> + </tr> + <tr> + <td colspan="2"> + <input type="submit" value="<?php echo 'Set Mail Account Data' ?>" /> + </td> + </tr> + </table> + </form> +</div> +<!-- MAIL ACCOUNT RESET --> +<div class="border-center"> + <form method="post" action="manage_proj_cat_mail_delete.php"> + <input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" /> + <input type="hidden" name="category" value="<?php echo string_attribute( $f_category ) ?>" /> + <input type="submit" value="<?php echo 'Delete Mail Account Data' ?>" /> + </form> +</div> +<?php } ?> + <?php html_page_bottom1( __FILE__ ) ?> diff -Nur mantis-1.0.0rc2.orig/manage_proj_cat_mail_delete.php mantis-1.0.0rc2/manage_proj_cat_mail_delete.php --- mantis-1.0.0rc2.orig/manage_proj_cat_mail_delete.php Thu Jan 1 01:00:00 1970 +++ mantis-1.0.0rc2/manage_proj_cat_mail_delete.php Mon Oct 31 11:15:02 2005 @@ -0,0 +1,44 @@ +<?php + # Mantis - a php based bugtracking system + # Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net + # Copyright (C) 2004 Gerrit Beine - gerrit.beine@pitcom.de + # This program is distributed under the terms and conditions of the GPL + # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id$ + # -------------------------------------------------------- + + require_once( 'core.php' ); + + $t_core_path = config_get( 'core_path' ); + + require_once( $t_core_path . 'mail_api.php' ); + + $f_project_id = gpc_get_int( 'project_id' ); + $f_category = gpc_get_string( 'category' ); + + access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id ); + + mail_category_delete( $f_project_id, $f_category ); + + $t_redirect_url = 'manage_proj_cat_edit_page.php?project_id=' . $f_project_id . '&category=' . $f_category; + + html_page_top1(); + + html_meta_redirect( $t_redirect_url ); + + html_page_top2(); +?> + +<br /> +<div align="center"> +<?php + echo lang_get( 'operation_successful' ) . '<br />'; + + print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) ); +?> +</div> + +<?php html_page_bottom1( __FILE__ ) ?> + diff -Nur mantis-1.0.0rc2.orig/manage_proj_cat_mail_update.php mantis-1.0.0rc2/manage_proj_cat_mail_update.php --- mantis-1.0.0rc2.orig/manage_proj_cat_mail_update.php Thu Jan 1 01:00:00 1970 +++ mantis-1.0.0rc2/manage_proj_cat_mail_update.php Mon Oct 31 11:15:02 2005 @@ -0,0 +1,59 @@ +<?php + # Mantis - a php based bugtracking system + # Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net + # Copyright (C) 2004 Gerrit Beine - gerrit.beine@pitcom.de + # This program is distributed under the terms and conditions of the GPL + # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id$ + # -------------------------------------------------------- + + require_once( 'core.php' ); + + $t_core_path = config_get( 'core_path' ); + + require_once( $t_core_path . 'mail_api.php' ); + + $f_project_id = gpc_get_int( 'project_id' ); + $f_pop3_host = gpc_get_string( 'pop3_host' ); + $f_pop3_user = gpc_get_string( 'pop3_user' ); + $f_pop3_pass = gpc_get_string( 'pop3_pass' ); + $f_category = gpc_get_string( 'category' ); + + access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id ); + + if ( is_blank( $f_pop3_host ) ) { + trigger_error( ERROR_EMPTY_FIELD, ERROR ); + } + else { + if ( is_blank( $f_pop3_user ) ) { + trigger_error( ERROR_EMPTY_FIELD, ERROR ); + } + if ( is_blank( $f_pop3_pass ) ) { + trigger_error( ERROR_EMPTY_FIELD, ERROR ); + } + } + + mail_category_update( $f_project_id, $f_category, $f_pop3_host, $f_pop3_user, $f_pop3_pass ); + + $t_redirect_url = 'manage_proj_cat_edit_page.php?project_id=' . $f_project_id . '&category=' . $f_category; + + html_page_top1(); + + html_meta_redirect( $t_redirect_url ); + + html_page_top2(); +?> + +<br /> +<div align="center"> +<?php + echo lang_get( 'operation_successful' ) . '<br />'; + + print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) ); +?> +</div> + +<?php html_page_bottom1( __FILE__ ) ?> + diff -Nur mantis-1.0.0rc2.orig/manage_proj_edit_page.php mantis-1.0.0rc2/manage_proj_edit_page.php --- mantis-1.0.0rc2.orig/manage_proj_edit_page.php Tue Jul 26 14:41:02 2005 +++ mantis-1.0.0rc2/manage_proj_edit_page.php Mon Oct 31 11:15:02 2005 @@ -18,6 +18,7 @@ require_once( $t_core_path . 'version_api.php' ); require_once( $t_core_path . 'custom_field_api.php' ); require_once( $t_core_path . 'icon_api.php' ); + require_once( $t_core_path . 'mail_api.php' ); ?> <?php $f_project_id = gpc_get_int( 'project_id' ); @@ -25,6 +26,7 @@ access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id ); $row = project_get_row( $f_project_id ); + $mail = mail_get_account_data( $f_project_id ); ?> <?php html_page_top1() ?> <?php html_page_top2() ?> @@ -689,5 +691,76 @@ </tr> </table> </div> + +<?php if ( ! $mail['pop3_categories'] ) { ?> +<!-- MAIL ACCOUNT CHANGE --> +<br /> +<div align="center"> + <form method="post" action="manage_proj_mail_update.php"> + <input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" /> + <table class="width75" cellspacing="1"> + <tr> + <td class="form-title" colspan="4"> + <?php echo 'Mail Account Settings' ?> + </td> + </tr> + <tr class="row-1"> + <td class="category" width="25%"> + <?php echo "POP3 Host"?> + </td> + <td width="75%"> + <input type="text" name="pop3_host" size="64" maxlength="255" value="<?php echo string_attribute( $mail['pop3_host'] ) ?>" /> + </td> + </tr> + <tr class="row-1"> + <td class="category" width="25%"> + <?php echo "POP3 User"?> + </td> + <td width="75%"> + <input type="text" name="pop3_user" size="64" maxlength="255" value="<?php echo string_attribute( $mail['pop3_user'] ) ?>" /> + </td> + </tr> + <tr class="row-1"> + <td class="category" width="25%"> + <?php echo "POP3 Password"?> + </td> + <td width="75%"> + <input type="text" name="pop3_pass" size="64" maxlength="255" value="<?php echo string_attribute( $mail['pop3_pass'] ) ?>" /> + </td> + </tr> + <tr> + <td colspan="2"> + <input type="submit" value="<?php echo 'Set Mail Account Data' ?>" /> + </td> + </tr> + </table> + </form> +</div> +<!-- MAIL ACCOUNT RESET --> +<div class="border-center"> + <form method="post" action="manage_proj_mail_delete.php"> + <input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" /> + <input type="submit" value="<?php echo 'Delete Mail Account Data' ?>" /> + </form> +</div> +<br /> +<!-- MAIL ACCOUNT CATEGORIES --> +<div class="border-center"> + <form method="post" action="manage_proj_mail_categories.php"> + <input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" /> + <input type="hidden" name="categories" value="On" /> + <input type="submit" value="<?php echo 'Activate Mail Account per Category' ?>" /> + </form> +</div> +<?php } else { ?> +<!-- MAIL ACCOUNT CATEGORIES --> +<div class="border-center"> + <form method="post" action="manage_proj_mail_categories.php"> + <input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" /> + <input type="hidden" name="categories" value="Off" /> + <input type="submit" value="<?php echo 'Deactivate Mail Account per Category' ?>" /> + </form> +</div> +<?php } ?> <?php html_page_bottom1( __FILE__ ) ?> diff -Nur mantis-1.0.0rc2.orig/manage_proj_mail_categories.php mantis-1.0.0rc2/manage_proj_mail_categories.php --- mantis-1.0.0rc2.orig/manage_proj_mail_categories.php Thu Jan 1 01:00:00 1970 +++ mantis-1.0.0rc2/manage_proj_mail_categories.php Mon Oct 31 11:15:02 2005 @@ -0,0 +1,43 @@ +<?php + # Mantis - a php based bugtracking system + # Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net + # Copyright (C) 2004 Gerrit Beine - gerrit.beine@pitcom.de + # This program is distributed under the terms and conditions of the GPL + # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id$ + # -------------------------------------------------------- + + require_once( 'core.php' ); + + $t_core_path = config_get( 'core_path' ); + + require_once( $t_core_path . 'mail_api.php' ); + + $f_project_id = gpc_get_int( 'project_id' ); + $f_activate = gpc_get_string( 'categories' ); + + access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id ); + + mail_categories( $f_project_id, $f_activate ); + + $t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $f_project_id; + + html_page_top1(); + + html_meta_redirect( $t_redirect_url ); + + html_page_top2(); +?> + +<br /> +<div align="center"> +<?php + echo lang_get( 'operation_successful' ) . '<br />'; + print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) ); +?> +</div> + +<?php html_page_bottom1( __FILE__ ) ?> + diff -Nur mantis-1.0.0rc2.orig/manage_proj_mail_delete.php mantis-1.0.0rc2/manage_proj_mail_delete.php --- mantis-1.0.0rc2.orig/manage_proj_mail_delete.php Thu Jan 1 01:00:00 1970 +++ mantis-1.0.0rc2/manage_proj_mail_delete.php Mon Oct 31 11:15:02 2005 @@ -0,0 +1,43 @@ +<?php + # Mantis - a php based bugtracking system + # Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net + # Copyright (C) 2004 Gerrit Beine - gerrit.beine@pitcom.de + # This program is distributed under the terms and conditions of the GPL + # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id$ + # -------------------------------------------------------- + + require_once( 'core.php' ); + + $t_core_path = config_get( 'core_path' ); + + require_once( $t_core_path . 'mail_api.php' ); + + $f_project_id = gpc_get_int( 'project_id' ); + + access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id ); + + mail_delete( $f_project_id ); + + $t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $f_project_id; + + html_page_top1(); + + html_meta_redirect( $t_redirect_url ); + + html_page_top2(); +?> + +<br /> +<div align="center"> +<?php + echo lang_get( 'operation_successful' ) . '<br />'; + + print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) ); +?> +</div> + +<?php html_page_bottom1( __FILE__ ) ?> + diff -Nur mantis-1.0.0rc2.orig/manage_proj_mail_update.php mantis-1.0.0rc2/manage_proj_mail_update.php --- mantis-1.0.0rc2.orig/manage_proj_mail_update.php Thu Jan 1 01:00:00 1970 +++ mantis-1.0.0rc2/manage_proj_mail_update.php Mon Oct 31 11:15:02 2005 @@ -0,0 +1,58 @@ +<?php + # Mantis - a php based bugtracking system + # Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net + # Copyright (C) 2004 Gerrit Beine - gerrit.beine@pitcom.de + # This program is distributed under the terms and conditions of the GPL + # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id$ + # -------------------------------------------------------- + + require_once( 'core.php' ); + + $t_core_path = config_get( 'core_path' ); + + require_once( $t_core_path . 'mail_api.php' ); + + $f_project_id = gpc_get_int( 'project_id' ); + $f_pop3_host = gpc_get_string( 'pop3_host' ); + $f_pop3_user = gpc_get_string( 'pop3_user' ); + $f_pop3_pass = gpc_get_string( 'pop3_pass' ); + + access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id ); + + if ( is_blank( $f_pop3_host ) ) { + trigger_error( ERROR_EMPTY_FIELD, ERROR ); + } + else { + if ( is_blank( $f_pop3_user ) ) { + trigger_error( ERROR_EMPTY_FIELD, ERROR ); + } + if ( is_blank( $f_pop3_pass ) ) { + trigger_error( ERROR_EMPTY_FIELD, ERROR ); + } + } + + mail_update( $f_project_id, $f_pop3_host, $f_pop3_user, $f_pop3_pass ); + + $t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $f_project_id; + + html_page_top1(); + + html_meta_redirect( $t_redirect_url ); + + html_page_top2(); +?> + +<br /> +<div align="center"> +<?php + echo lang_get( 'operation_successful' ) . '<br />'; + + print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) ); +?> +</div> + +<?php html_page_bottom1( __FILE__ ) ?> + mantis-0.19.3.patch (40,912 bytes)
diff -Nur mantis-0.19.3.orig/bug_report_mail.php mantis-0.19.3/bug_report_mail.php --- mantis-0.19.3.orig/bug_report_mail.php Thu Jan 1 01:00:00 1970 +++ mantis-0.19.3/bug_report_mail.php Mon Oct 31 11:22:28 2005 @@ -0,0 +1,39 @@ +<?php + # Mantis - a php based bugtracking system + # Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net + # Copyright (C) 2004 Gerrit Beine - gerrit.beine@pitcom.de + # This program is distributed under the terms and conditions of the GPL + # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id$ + # -------------------------------------------------------- + + # This page receives an E-Mail via POP3 and generates an Report + header("Content-type: text/plain"); + require_once( 'core.php' ); + + $t_core_path = config_get( 'core_path' ); + + require_once( $t_core_path . 'string_api.php' ); + require_once( $t_core_path . 'bug_api.php' ); + require_once( $t_core_path . 'mail_api.php' ); + + $t_mailaccounts = mail_get_accounts(); + + foreach ($t_mailaccounts as $t_mailaccount) { + if ( config_get( 'mail_debug' ) ) { + print_r($t_mailaccounts); + } + $t_mails = mail_get_all_mails($t_mailaccount); + foreach ($t_mails as $t_mail) + { + if ( config_get( 'mail_debug' ) ) { + print_r($t_mail); + } + $GLOBALS['g_cache_current_user_id'] = mail_get_user( $t_mail['From'] ); + mail_add_bug($t_mail, $t_mailaccount); + } + } +?> + diff -Nur mantis-0.19.3.orig/config_defaults_inc.php mantis-0.19.3/config_defaults_inc.php --- mantis-0.19.3.orig/config_defaults_inc.php Tue Oct 11 14:00:54 2005 +++ mantis-0.19.3/config_defaults_inc.php Mon Oct 31 11:22:28 2005 @@ -1474,4 +1474,37 @@ # NOTE: These are meaningless under Windows! Just ignore them! $g_dot_tool = '/usr/bin/dot'; $g_neato_tool = '/usr/bin/neato'; -?> \ No newline at end of file + + ###################### + # Mail Reporting + ###################### + + # --- mail reporting settings ----- + # This tells Mantis to report all the Mail with only one account + $g_mail_use_reporter = ON; + + # The account's name for mail reporting + # Also used for fallback if a user is not found in database + $g_mail_reporter = 'Mail'; + + # Signup new users automatically (possible security risk!) + # Default is OFF, ignored if mail_use_reporter is ON + $g_mail_auto_signup = OFF; + + # Write complete mail into the "Additional Information" + $g_mail_additional = OFF; + + # Write sender of the message into the bug report + $g_mail_save_from = OFF; + + # Parse MIME mails (may require a lot of memory) + $g_mail_parse_mime = OFF; + + # How many mails should be fetched at the same time + # If big mails with attachments should be received, specify only one + $g_mail_fetch_max = 1; + + # Signup new users automatically (possible security risk!) + # Default is OFF, ignored if mail_use_reporter is ON + $g_mail_debug = OFF; +?> diff -Nur mantis-0.19.3.orig/core/category_api.php mantis-0.19.3/core/category_api.php --- mantis-0.19.3.orig/core/category_api.php Thu Apr 8 20:04:52 2004 +++ mantis-0.19.3/core/category_api.php Mon Oct 31 11:22:49 2005 @@ -186,7 +186,7 @@ $t_project_category_table = config_get( 'mantis_project_category_table' ); - $query = "SELECT category, user_id + $query = "SELECT category, user_id, pop3_host, pop3_user, pop3_pass FROM $t_project_category_table WHERE project_id='$c_project_id' AND category='$c_category'"; @@ -206,7 +206,7 @@ $t_project_category_table = config_get( 'mantis_project_category_table' ); - $query = "SELECT category, user_id + $query = "SELECT category, user_id, pop3_host, pop3_user, pop3_pass FROM $t_project_category_table WHERE project_id='$c_project_id' ORDER BY category"; @@ -221,4 +221,4 @@ return $rows; } -?> \ No newline at end of file +?> diff -Nur mantis-0.19.3.orig/core/file_api.php mantis-0.19.3/core/file_api.php --- mantis-0.19.3.orig/core/file_api.php Sun Oct 17 03:58:56 2004 +++ mantis-0.19.3/core/file_api.php Mon Oct 31 11:22:28 2005 @@ -509,7 +509,7 @@ trigger_error( ERROR_DUPLICATE_FILE, ERROR ); } - if ( is_uploaded_file( $p_tmp_file ) ) { + if ( is_uploaded_file( $p_tmp_file ) || $GLOBALS['_mail_file_'] == $p_file_name ) { if ( 'bug' == $p_table ) { $t_project_id = bug_get_field( $p_bug_id, 'project_id' ); $t_bug_id = bug_format_id( $p_bug_id ); diff -Nur mantis-0.19.3.orig/core/mail_api.php mantis-0.19.3/core/mail_api.php --- mantis-0.19.3.orig/core/mail_api.php Thu Jan 1 01:00:00 1970 +++ mantis-0.19.3/core/mail_api.php Mon Oct 31 11:22:28 2005 @@ -0,0 +1,443 @@ +<?php + # Mantis - a php based bugtracking system + # Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net + # Copyright (C) 2004 Gerrit Beine - gerrit.beine@pitcom.de + # This program is distributed under the terms and conditions of the GPL + # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id$ + # -------------------------------------------------------- + + $t_core_dir = dirname( __FILE__ ).DIRECTORY_SEPARATOR; + + require_once( $t_core_dir . 'bug_api.php' ); + require_once( $t_core_dir . 'bugnote_api.php' ); + require_once( $t_core_dir . 'user_api.php' ); + require_once( $t_core_dir . 'project_api.php' ); + require_once( $t_core_dir . 'file_api.php' ); + + # This page receives an E-Mail via POP3 and generates an Report + + require_once( 'Net/POP3.php' ); + require_once( 'Mail/mimeDecode.php' ); + + # -------------------- + # Return mail account data for the specified project + function mail_get_account_data( $p_project_id ) { + $v_project_id = db_prepare_int( $p_project_id ); + + $t_project_table = config_get( 'mantis_project_table' ); + + $query = "SELECT pop3_host, pop3_user, pop3_pass, pop3_categories + FROM $t_project_table + WHERE id='$v_project_id'"; + + $result = db_query( $query ); + + return db_fetch_array( $result ); + } + + # -------------------- + # Update the mail account data for a project + function mail_update( $p_project_id, $p_pop3_host, $p_pop3_user, $p_pop3_pass ) { + $v_project_id = db_prepare_int( $p_project_id ); + $v_pop3_host = db_prepare_string( $p_pop3_host ); + $v_pop3_user = db_prepare_string( $p_pop3_user ); + $v_pop3_pass = db_prepare_string( $p_pop3_pass ); + + $t_project_table = config_get( 'mantis_project_table' ); + + $query = "UPDATE $t_project_table + SET pop3_host='$v_pop3_host', + pop3_user='$v_pop3_user', + pop3_pass='$v_pop3_pass' + WHERE id='$v_project_id'"; + + db_query( $query ); + + return true; + } + + # -------------------- + # Removes the mail account data from a project + function mail_delete( $p_project_id ) { + $v_project_id = db_prepare_int( $p_project_id ); + + $t_project_table = config_get( 'mantis_project_table' ); + + $query = "UPDATE $t_project_table + SET pop3_host=NULL, + pop3_user=NULL, + pop3_pass=NULL + WHERE id='$v_project_id'"; + + db_query( $query ); + + return true; + } + + # -------------------- + # Activate the 'Mail per Category' feature for a project + function mail_categories( $p_project_id, $p_active ) { + $v_project_id = db_prepare_int( $p_project_id ); + + if ($p_active == 'On') { + $v_active = 1; + } else { + $v_active = 0; + } + + $t_project_table = config_get( 'mantis_project_table' ); + + $query = "UPDATE $t_project_table + SET pop3_categories='$v_active' + WHERE id='$v_project_id'"; + + db_query( $query ); + + return true; + } + + # -------------------- + # Return mail account data for the specified project and category + function mail_category_get_account_data( $p_project_id, $p_category ) { + $v_project_id = db_prepare_int( $p_project_id ); + $v_category = db_prepare_string( $p_category ); + + $t_project_category_table = config_get( 'mantis_project_category_table' ); + + $query = "SELECT pop3_host, pop3_user, pop3_pass + FROM $t_project_category_table + WHERE project_id='$v_project_id' AND category='$v_category'"; + + $result = db_query( $query ); + + return db_fetch_array( $result ); + } + + # -------------------- + # Update the mail account data for a category + function mail_category_update( $p_project_id, $p_category, $p_pop3_host, $p_pop3_user, $p_pop3_pass ) { + $v_project_id = db_prepare_int( $p_project_id ); + $v_category = db_prepare_string( $p_category ); + $v_pop3_host = db_prepare_string( $p_pop3_host ); + $v_pop3_user = db_prepare_string( $p_pop3_user ); + $v_pop3_pass = db_prepare_string( $p_pop3_pass ); + + $t_project_category_table = config_get( 'mantis_project_category_table' ); + + $query = "UPDATE $t_project_category_table + SET pop3_host='$v_pop3_host', + pop3_user='$v_pop3_user', + pop3_pass='$v_pop3_pass' + WHERE project_id='$v_project_id' AND category='$v_category'"; + + db_query( $query ); + + return true; + } + + # -------------------- + # Removes the mail account data for a category + function mail_category_delete( $p_project_id, $p_category ) { + $v_project_id = db_prepare_int( $p_project_id ); + $v_category = db_prepare_string( $p_category ); + + $t_project_table = config_get( 'mantis_project_table' ); + + $t_project_category_table = config_get( 'mantis_project_category_table' ); + + $query = "UPDATE $t_project_category_table + SET pop3_host=NULL, + pop3_user=NULL, + pop3_pass=NULL + WHERE project_id='$v_project_id' AND category='$v_category'"; + + db_query( $query ); + + return true; + } + + # -------------------- + # return all mailaccounts + # return an empty array if there are no + function mail_get_accounts() { + $v_accounts = array(); + $t_projects = mail_project_get_all_rows(); + + foreach ($t_projects as $t_project) { + if ($t_project['pop3_categories']) { + $v_categories = mail_categories_get_all_rows( $t_project['id'] ); + $v_accounts = array_merge($v_accounts, $v_categories); + } else { + array_push($v_accounts, $t_project); + } + } + + return $v_accounts; + } + + # -------------------- + # return all projects with valid data for mail access + # return an empty array if there are no such projects + function mail_project_get_all_rows() { + $v_projects = array(); + $t_projects = project_get_all_rows(); + + foreach ($t_projects as $t_project) { + if ($t_project['pop3_host'] || $t_project['pop3_categories']) { + array_push($v_projects, $t_project); + } + } + + return $v_projects; + } + + # -------------------- + # return all categories from a project with valid data for mail access + # return an empty array if there are no such categories + function mail_categories_get_all_rows( $p_project_id ) { + $v_categories = array(); + $t_categories = category_get_all_rows( $p_project_id ); + + foreach ($t_categories as $t_category) { + if ($t_category['pop3_host']) { + $t_category['id'] = $p_project_id; + array_push($v_categories, $t_category); + } + } + + return $v_categories; + } + + # -------------------- + # return all mails for an account + # return an empty array if there are no new mails + function mail_get_all_mails( $p_account ) { + $t_mail_parse_mime = config_get( 'mail_parse_mime' ); + $t_mail_fetch_max = config_get( 'mail_fetch_max' ); + $t_mail_additional = config_get( 'mail_additional' ); + + $v_mails = array(); + $t_pop3 = &new Net_POP3(); + $t_pop3_host = $p_account['pop3_host']; + $t_pop3_user = $p_account['pop3_user']; + $t_pop3_password = $p_account['pop3_pass']; + $t_pop3->connect($t_pop3_host, 110); + $t_pop3->login($t_pop3_user, $t_pop3_password); + + if ( 0 == $t_pop3->numMsg() ) { + return $v_mails; + } + for ($i = 1; $i <= $t_mail_fetch_max; $i++) { + $t_headers = $t_pop3->getParsedHeaders($i); + $t_msg = $t_pop3->getMsg($i); + if (true == $t_mail_parse_mime && + true == isset( $t_headers['MIME-Version'] ) && + 'multipart' == strtolower ( substr( $t_headers['Content-Type'], 0, 9 ) ) ) { + $t_mail = mail_parse_content( $t_msg ); + } else { + $t_mail = $t_headers; + $t_mail['X-Mantis-Body'] = $t_pop3->getBody($i); + } + + if (true == $t_mail_additional) { + $t_mail['X-Mantis-Complete'] = $t_msg; + } + + array_push($v_mails, $t_mail); + $t_pop3->deleteMsg($i); + } + + $t_pop3->disconnect(); + return $v_mails; + } + + # -------------------- + # return the mail parsed for Mantis + function mail_parse_content ( $p_mail ) { + $v_mail = array (); + $t_decoder = new Mail_mimeDecode($p_mail); + $t_params['include_bodies'] = true; + $t_params['decode_bodies'] = true; + $t_params['decode_headers'] = true; + $t_structure = $t_decoder->decode($t_params); + $v_mail['To'] = $t_structure->headers['to']; + $v_mail['From'] = $t_structure->headers['from']; + $v_mail['Subject'] = $t_structure->headers['subject']; + if (is_array($t_structure->parts)) { + $t_parts = mail_parse_parts( $t_structure->parts ); + } else { + $t_parts = array ( mail_parse_part( $t_structure ) ); + } + if (strtolower($t_parts[0]['Content-Type']) == 'text/plain' || + strtolower($t_parts[0]['Content-Type']) == 'text/html' ) { + $t_body['Body'] = $t_parts[0]['Body']; + } else { + $t_body['Body'] = "It seems, there is no text... :-o"; + } + $v_mail['X-Mantis-Parts'] = $t_parts; + $v_mail['X-Mantis-Body'] = $t_body['Body']; + + return $v_mail; + } + + # -------------------- + # return the parsed parts from the mail + function mail_parse_parts ( $p_parts ) { + $v_parts = array (); + foreach ( $p_parts as $t_part ) { + array_push($v_parts, mail_parse_part( $t_part )); + } + + return $v_parts; + } + + # -------------------- + # return one parsed part + function mail_parse_part ( $p_part ) { + $v_part = array (); + $v_part['Content-Type'] = $p_part->ctype_primary."/".$p_part->ctype_secondary; + $v_part['Name'] = $p_part->ctype_parameters['name']; + $v_part['Body'] = $p_part->body; + + return $v_part; + } + + # -------------------- + # return the mailadress from the mail's 'From' + function mail_parse_address ( $p_mailaddress ) { + if (preg_match("/<(.*?)>/", $p_mailaddress, $matches)) { + $v_mailaddress = $matches[1]; + } + + return $v_mailaddress; + } + + # -------------------- + # return the a valid username from an email address + function mail_user_name_from_address ( $p_mailaddress ) { + return preg_replace("/[@\.-]/", '_', $p_mailaddress); + } + + # -------------------- + # return true if there is a valid mantis bug referernce in subject + function mail_is_a_bugnote ( $p_mail_subject ) { + return preg_match("/\[([A-Za-z0-9-_\. ]*\s[0-9]{7})\]/", $p_mail_subject); + } + + # -------------------- + # return the bug's id from the subject + function mail_get_bug_id_from_subject ( $p_mail_subject ) { + preg_match("/\[([A-Za-z0-9-_\. ]*\s([0-9]{7}?))\]/", $p_mail_subject, $v_matches); + + return $v_matches[2]; + } + + # -------------------- + # return the user id for the mail reporting user + function mail_get_user ($p_mailaddress) { + $t_mail_use_reporter = config_get( 'mail_use_reporter' ); + $t_mail_auto_signup = config_get( 'mail_auto_signup' ); + $t_mail_reporter = config_get( 'mail_reporter' ); + + $v_mailaddress = mail_parse_address( $p_mailaddress ); + + if ( $t_mail_use_reporter ) { + // Always report as mail_reporter + $t_reporter_id = user_get_id_by_name( $t_mail_reporter ); + } else { + // Try to get the reporting users id + $t_reporter_id = user_get_id_by_mail ( $v_mailaddress ); + if ( ! $t_reporter_id && $t_mail_auto_signup ) { + // So, we've to sign up a new user... + $t_user_name = mail_user_name_from_address ( $v_mailaddress ); + user_signup($t_user_name, $v_mailaddress); + $t_reporter_id = user_get_id_by_name($t_user_name); + } elseif ( ! $t_reporter_id ) { + // Fall back to the default mail_reporter + $t_reporter_id = user_get_id_by_name( $t_mail_reporter ); + } + } + + // dirty: Set the identified user's id + // required if bug_report_mail is run via command line + $GLOBAL['g_cache_current_user_id'] = $t_reporter_id; + + return $t_reporter_id; + } + + # -------------------- + # Very dirty: Adds a file to a bug. + function mail_add_file( $p_bug_id, $p_part ) { + $GLOBALS['_mail_file_'] = $p_part['Name']; + if ( 0 < strlen($p_part['Name']) ) { + $t_file_name = '/tmp/'.$p_part['Name']; + file_put_contents($t_file_name, $p_part['Body']); + file_add($p_bug_id, $t_file_name, $p_part['Name'], $p_part['Content-Type'], 'bug'); + unlink($t_file_name); + } + } + + # -------------------- + # Adds a bug which is reported via email + # Taken from bug_report.php and + function mail_add_bug ( $p_mail, $p_account ) { + $t_mail_save_from = config_get( 'mail_save_from' ); + + $t_bug_data = new BugData; + $t_bug_data->build = gpc_get_string( 'build', '' ); + $t_bug_data->platform = gpc_get_string( 'platform', '' ); + $t_bug_data->os = gpc_get_string( 'os', '' ); + $t_bug_data->os_build = gpc_get_string( 'os_build', '' ); + $t_bug_data->version = gpc_get_string( 'product_version', '' ); + $t_bug_data->profile_id = gpc_get_int( 'profile_id', 0 ); + $t_bug_data->handler_id = gpc_get_int( 'handler_id', 0 ); + $t_bug_data->view_state = gpc_get_int( 'view_state', config_get( 'default_bug_view_status' ) ); + + if ( $p_account['category']) { + $t_bug_data->category = gpc_get_string( 'category', $p_account['category'] ); + } else { + $t_bug_data->category = gpc_get_string( 'category', '' ); + } + $t_bug_data->reproducibility = 10; + $t_bug_data->severity = 50; + $t_bug_data->priority = gpc_get_int( 'priority', NORMAL ); + $t_bug_data->summary = $p_mail['Subject']; + if ( $t_mail_save_from ) { + $t_bug_data->description = "Report from: ".$p_mail['From']."\n\n".$p_mail['X-Mantis-Body']; + } + else { + $t_bug_data->description = $p_mail['X-Mantis-Body']; + } + $t_bug_data->steps_to_reproduce = gpc_get_string( 'steps_to_reproduce', '' ); + $t_bug_data->additional_information = $p_mail['X-Mantis-Complete']; + + $t_bug_data->project_id = $p_account['id']; + + $t_bug_data->reporter_id = mail_get_user( $p_mail['From'] ); + + if ( mail_is_a_bugnote( $p_mail['Subject'] ) ) { + # Add a bug note + $t_bug_id = mail_get_bug_id_from_subject( $p_mail['Subject'] ); + if ( ! bug_is_readonly( $t_bug_id ) ) { + bugnote_add ( $t_bug_id, $p_mail['X-Mantis-Body'] ); + email_bugnote_add ( $t_bug_id ); + } + } else { + # Create the bug + $t_bug_id = bug_create( $t_bug_data ); + email_new_bug( $t_bug_id ); + } + # Add files + if ( null != $p_mail['X-Mantis-Parts'] ) { + foreach ($p_mail['X-Mantis-Parts'] as $part) { + mail_add_file ( $t_bug_id, $part ); + } + } + + } + +?> + diff -Nur mantis-0.19.3.orig/core/user_api.php mantis-0.19.3/core/user_api.php --- mantis-0.19.3.orig/core/user_api.php Fri Nov 19 13:29:00 2004 +++ mantis-0.19.3/core/user_api.php Mon Oct 31 11:22:28 2005 @@ -477,6 +477,24 @@ } } + # get a user id from an mail address + # return false if the mail address does not exist + function user_get_id_by_mail( $p_mailaddress ) { + $c_mailaddress = db_prepare_string( $p_mailaddress ); + $t_user_table = config_get( 'mantis_user_table' ); + + $query = "SELECT id + FROM $t_user_table + WHERE email='$c_mailaddress'"; + $result = db_query( $query ); + + if ( 0 == db_num_rows( $result ) ) { + return false; + } else { + return db_result( $result ); + } + } + # -------------------- # return all data associated with a particular user name # return false if the username does not exist diff -Nur mantis-0.19.3.orig/doc/README.bug_report_mail mantis-0.19.3/doc/README.bug_report_mail --- mantis-0.19.3.orig/doc/README.bug_report_mail Thu Jan 1 01:00:00 1970 +++ mantis-0.19.3/doc/README.bug_report_mail Mon Oct 31 11:23:39 2005 @@ -0,0 +1,116 @@ +The current version of bug_report_mail support plain text and MIME +encoded e-mails via POP3 Mailaccounts with PEAR's Net_POP3 package. + +bug_report_mail is able to recognize if mail is a reply to an already opened +bug and adds the content as a bugnote. + +If you are alway running Mantis you have to alter your projects table +with the sql/bug_report_mail.sql script. +If not, you can create the database tables in the way described in +the doc/INSTALL file. + +This patch changes the following files: + core/category_api.php + core/file_api.php + core/user_api.php + sql/db_generate.sql + config_defaults_inc.php + manage_proj_cat_edit_page.php + manage_proj_edit_page.php +These files are new: + core/mail_api.php + doc/README.bug_report_mail + sql/bug_report_mail.sql + bug_report_mail.php + manage_proj_cat_mail_delete.php + manage_proj_cat_mail_update.php + manage_proj_mail_categories.php + manage_proj_mail_delete.php + manage_proj_mail_update.php + +After installing this patch, you can add a POP3 server's hostname +and authentication data for each of your projects with the project edit form. + +There are two ways to receive mail with bug_report_mail: +The secure (and default) way is to use a standard reporting user: +You have to create a reporter account, for example 'Mail'. +The name for this reporter account you have to write in your config_inc.php file: + $g_mail_reporter = "Mail"; +and then, bug_report_mail must be informed to behave like this: + $g_mail_use_reporter = ON; + +The other way is to signup new user accounts automatically. +For using this, you have to change this + $g_mail_auto_signup = OFF; +from OFF to ON. +Now, bug_report_mail will look for an user named like the mail's sender +or an user which mail adress is identical. +If no user is found, then a new account will be created. +The new user's name will be the mail address. + +This could be used for attacks, but there is no other way in the moment. + +If you like to parse MIME encoded mails, you have to install the PEAR +Mail_Mime package and set + $g_mail_parse_mime = OFF; +from OFF to ON. + +For debugging controls there is the switch + $g_mail_additional = OFF; +which puts the complete message into the Additional Information field, +if it is activated. + +In this case you should decrease the amount of fetched messages via + $g_mail_fetch_max = 1; +because the mime decoding needs a lot of memory. + +If you'd like to use the Mail Reporter but don't save the whole message for +making the sender's address available, set + $g_mail_save_from = OFF; +to ON. + +After this, bug_report_mail can be used via cron like this: + +*/5 * * * * lynx --dump http://mantis.homepage.com/bug_report_mail.php +or via command line interface +*/5 * * * * /usr/local/bin/php /path/to/mantis/bug_report_mail.php + +This line fetch bug reports from via POP3 every 5 minutes. + +This addon is distributed under the same conditions as Mantis itself. + +Gerrit Beine, August 2004 + +Changelog: +Oct 2005 + - update to Mantis 0.19.3 +Sep 2005: + - update to Mantis 1.0.0rc2 + - fixed a bug in getting all categories for a project + category_get_all_rows in core/category_api.php +Aug 2005: + - update to Mantis 1.0.0rc1 + - include the additional patches submitted by + - gernot (Fixed MIME handling and save the mail's sender) + mail_get_all_mails in core/mail_api.php + mail_parse_content in core/mail_api.php + mail_add_bug in core/mail_api.php + - stevenc (Fixed MIME handling) + mail_parse_content in core/mail_api.php + - rainman (Fixed empty files bug and regex for finding a bug id) + mail_add_file in core/mail_api.php + mail_get_bug_id_from_subject in core/mail_api.php +Dec 2004: + - update to Mantis 0.19.2 + - add config: g_mail_parse_mime + - add config: g_mail_additional + - add config: g_mail_fetch_max + - make it working via CLI +Nov 2004: + - update to Mantis 0.19.1 + - add support for MIME decoding +Sep 2004: + - update to Mantis 0.19.0 +Aug 2004: + - create patch for Mantis 0.18.3 + diff -Nur mantis-0.19.3.orig/manage_proj_cat_edit_page.php mantis-0.19.3/manage_proj_cat_edit_page.php --- mantis-0.19.3.orig/manage_proj_cat_edit_page.php Mon Apr 12 23:04:34 2004 +++ mantis-0.19.3/manage_proj_cat_edit_page.php Mon Oct 31 11:22:28 2005 @@ -15,6 +15,7 @@ $t_core_path = config_get( 'core_path' ); require_once( $t_core_path.'category_api.php' ); + require_once( $t_core_path.'mail_api.php' ); ?> <?php $f_project_id = gpc_get_int( 'project_id' ); @@ -24,6 +25,10 @@ $t_row = category_get_row( $f_project_id, $f_category ); $t_assigned_to = $t_row['user_id']; + $t_mail = mail_get_account_data( $f_project_id ); + if ( $t_mail['pop3_categories'] ) { + $t_category_mail = mail_category_get_account_data( $f_project_id, $f_category ); + } ?> <?php html_page_top1() ?> <?php html_page_top2() ?> @@ -84,4 +89,59 @@ </form> </div> +<?php if ( $t_mail['pop3_categories'] ) { ?> +<!-- MAIL ACCOUNT CHANGE --> +<br /> +<div align="center"> + <form method="post" action="manage_proj_cat_mail_update.php"> + <input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" /> + <input type="hidden" name="category" value="<?php echo string_attribute( $f_category ) ?>" /> + <table class="width75" cellspacing="1"> + <tr> + <td class="form-title" colspan="4"> + <?php echo 'Category Mail Account Settings' ?> + </td> + </tr> + <tr class="row-1"> + <td class="category" width="25%"> + <?php echo "POP3 Host"?> + </td> + <td width="75%"> + <input type="text" name="pop3_host" size="64" maxlength="255" value="<?php echo string_attribute( $t_category_mail['pop3_host'] ) ?>" /> + </td> + </tr> + <tr class="row-1"> + <td class="category" width="25%"> + <?php echo "POP3 User"?> + </td> + <td width="75%"> + <input type="text" name="pop3_user" size="64" maxlength="255" value="<?php echo string_attribute( $t_category_mail['pop3_user'] ) ?>" /> + </td> + </tr> + <tr class="row-1"> + <td class="category" width="25%"> + <?php echo "POP3 Password"?> + </td> + <td width="75%"> + <input type="text" name="pop3_pass" size="64" maxlength="255" value="<?php echo string_attribute( $t_category_mail['pop3_pass'] ) ?>" /> + </td> + </tr> + <tr> + <td colspan="2"> + <input type="submit" value="<?php echo 'Set Mail Account Data' ?>" /> + </td> + </tr> + </table> + </form> +</div> +<!-- MAIL ACCOUNT RESET --> +<div class="border-center"> + <form method="post" action="manage_proj_cat_mail_delete.php"> + <input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" /> + <input type="hidden" name="category" value="<?php echo string_attribute( $f_category ) ?>" /> + <input type="submit" value="<?php echo 'Delete Mail Account Data' ?>" /> + </form> +</div> +<?php } ?> + <?php html_page_bottom1( __FILE__ ) ?> diff -Nur mantis-0.19.3.orig/manage_proj_cat_mail_delete.php mantis-0.19.3/manage_proj_cat_mail_delete.php --- mantis-0.19.3.orig/manage_proj_cat_mail_delete.php Thu Jan 1 01:00:00 1970 +++ mantis-0.19.3/manage_proj_cat_mail_delete.php Mon Oct 31 11:22:28 2005 @@ -0,0 +1,44 @@ +<?php + # Mantis - a php based bugtracking system + # Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net + # Copyright (C) 2004 Gerrit Beine - gerrit.beine@pitcom.de + # This program is distributed under the terms and conditions of the GPL + # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id$ + # -------------------------------------------------------- + + require_once( 'core.php' ); + + $t_core_path = config_get( 'core_path' ); + + require_once( $t_core_path . 'mail_api.php' ); + + $f_project_id = gpc_get_int( 'project_id' ); + $f_category = gpc_get_string( 'category' ); + + access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id ); + + mail_category_delete( $f_project_id, $f_category ); + + $t_redirect_url = 'manage_proj_cat_edit_page.php?project_id=' . $f_project_id . '&category=' . $f_category; + + html_page_top1(); + + html_meta_redirect( $t_redirect_url ); + + html_page_top2(); +?> + +<br /> +<div align="center"> +<?php + echo lang_get( 'operation_successful' ) . '<br />'; + + print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) ); +?> +</div> + +<?php html_page_bottom1( __FILE__ ) ?> + diff -Nur mantis-0.19.3.orig/manage_proj_cat_mail_update.php mantis-0.19.3/manage_proj_cat_mail_update.php --- mantis-0.19.3.orig/manage_proj_cat_mail_update.php Thu Jan 1 01:00:00 1970 +++ mantis-0.19.3/manage_proj_cat_mail_update.php Mon Oct 31 11:22:28 2005 @@ -0,0 +1,59 @@ +<?php + # Mantis - a php based bugtracking system + # Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net + # Copyright (C) 2004 Gerrit Beine - gerrit.beine@pitcom.de + # This program is distributed under the terms and conditions of the GPL + # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id$ + # -------------------------------------------------------- + + require_once( 'core.php' ); + + $t_core_path = config_get( 'core_path' ); + + require_once( $t_core_path . 'mail_api.php' ); + + $f_project_id = gpc_get_int( 'project_id' ); + $f_pop3_host = gpc_get_string( 'pop3_host' ); + $f_pop3_user = gpc_get_string( 'pop3_user' ); + $f_pop3_pass = gpc_get_string( 'pop3_pass' ); + $f_category = gpc_get_string( 'category' ); + + access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id ); + + if ( is_blank( $f_pop3_host ) ) { + trigger_error( ERROR_EMPTY_FIELD, ERROR ); + } + else { + if ( is_blank( $f_pop3_user ) ) { + trigger_error( ERROR_EMPTY_FIELD, ERROR ); + } + if ( is_blank( $f_pop3_pass ) ) { + trigger_error( ERROR_EMPTY_FIELD, ERROR ); + } + } + + mail_category_update( $f_project_id, $f_category, $f_pop3_host, $f_pop3_user, $f_pop3_pass ); + + $t_redirect_url = 'manage_proj_cat_edit_page.php?project_id=' . $f_project_id . '&category=' . $f_category; + + html_page_top1(); + + html_meta_redirect( $t_redirect_url ); + + html_page_top2(); +?> + +<br /> +<div align="center"> +<?php + echo lang_get( 'operation_successful' ) . '<br />'; + + print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) ); +?> +</div> + +<?php html_page_bottom1( __FILE__ ) ?> + diff -Nur mantis-0.19.3.orig/manage_proj_edit_page.php mantis-0.19.3/manage_proj_edit_page.php --- mantis-0.19.3.orig/manage_proj_edit_page.php Wed Sep 22 12:15:32 2004 +++ mantis-0.19.3/manage_proj_edit_page.php Mon Oct 31 11:22:28 2005 @@ -18,6 +18,7 @@ require_once( $t_core_path . 'version_api.php' ); require_once( $t_core_path . 'custom_field_api.php' ); require_once( $t_core_path . 'icon_api.php' ); + require_once( $t_core_path . 'mail_api.php' ); ?> <?php $f_project_id = gpc_get_int( 'project_id' ); @@ -25,6 +26,7 @@ access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id ); $row = project_get_row( $f_project_id ); + $mail = mail_get_account_data( $f_project_id ); ?> <?php html_page_top1() ?> <?php html_page_top2() ?> @@ -550,5 +552,77 @@ </tr> </table> </div> + +<?php if ( ! $mail['pop3_categories'] ) { ?> +<!-- MAIL ACCOUNT CHANGE --> +<br /> +<div align="center"> + <form method="post" action="manage_proj_mail_update.php"> + <input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" /> + <table class="width75" cellspacing="1"> + <tr> + <td class="form-title" colspan="4"> + <?php echo 'Mail Account Settings' ?> + </td> + </tr> + <tr class="row-1"> + <td class="category" width="25%"> + <?php echo "POP3 Host"?> + </td> + <td width="75%"> + <input type="text" name="pop3_host" size="64" maxlength="255" value="<?php echo string_attribute( $mail['pop3_host'] ) ?>" /> + </td> + </tr> + <tr class="row-1"> + <td class="category" width="25%"> + <?php echo "POP3 User"?> + </td> + <td width="75%"> + <input type="text" name="pop3_user" size="64" maxlength="255" value="<?php echo string_attribute( $mail['pop3_user'] ) ?>" /> + </td> + </tr> + <tr class="row-1"> + <td class="category" width="25%"> + <?php echo "POP3 Password"?> + </td> + <td width="75%"> + <input type="text" name="pop3_pass" size="64" maxlength="255" value="<?php echo string_attribute( $mail['pop3_pass'] ) ?>" /> + </td> + </tr> + <tr> + <td colspan="2"> + <input type="submit" value="<?php echo 'Set Mail Account Data' ?>" /> + </td> + </tr> + </table> + </form> +</div> +<!-- MAIL ACCOUNT RESET --> +<div class="border-center"> + <form method="post" action="manage_proj_mail_delete.php"> + <input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" /> + <input type="submit" value="<?php echo 'Delete Mail Account Data' ?>" /> + </form> +</div> +<br /> +<!-- MAIL ACCOUNT CATEGORIES --> +<div class="border-center"> + <form method="post" action="manage_proj_mail_categories.php"> + <input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" /> + <input type="hidden" name="categories" value="On" /> + <input type="submit" value="<?php echo 'Activate Mail Account per Category' ?>" /> + </form> +</div> +<?php } else { ?> +<!-- MAIL ACCOUNT CATEGORIES --> +<div class="border-center"> + <form method="post" action="manage_proj_mail_categories.php"> + <input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" /> + <input type="hidden" name="categories" value="Off" /> + <input type="submit" value="<?php echo 'Deactivate Mail Account per Category' ?>" /> + </form> +</div> +<?php } ?> + <?php html_page_bottom1( __FILE__ ) ?> diff -Nur mantis-0.19.3.orig/manage_proj_mail_categories.php mantis-0.19.3/manage_proj_mail_categories.php --- mantis-0.19.3.orig/manage_proj_mail_categories.php Thu Jan 1 01:00:00 1970 +++ mantis-0.19.3/manage_proj_mail_categories.php Mon Oct 31 11:22:28 2005 @@ -0,0 +1,43 @@ +<?php + # Mantis - a php based bugtracking system + # Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net + # Copyright (C) 2004 Gerrit Beine - gerrit.beine@pitcom.de + # This program is distributed under the terms and conditions of the GPL + # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id$ + # -------------------------------------------------------- + + require_once( 'core.php' ); + + $t_core_path = config_get( 'core_path' ); + + require_once( $t_core_path . 'mail_api.php' ); + + $f_project_id = gpc_get_int( 'project_id' ); + $f_activate = gpc_get_string( 'categories' ); + + access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id ); + + mail_categories( $f_project_id, $f_activate ); + + $t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $f_project_id; + + html_page_top1(); + + html_meta_redirect( $t_redirect_url ); + + html_page_top2(); +?> + +<br /> +<div align="center"> +<?php + echo lang_get( 'operation_successful' ) . '<br />'; + print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) ); +?> +</div> + +<?php html_page_bottom1( __FILE__ ) ?> + diff -Nur mantis-0.19.3.orig/manage_proj_mail_delete.php mantis-0.19.3/manage_proj_mail_delete.php --- mantis-0.19.3.orig/manage_proj_mail_delete.php Thu Jan 1 01:00:00 1970 +++ mantis-0.19.3/manage_proj_mail_delete.php Mon Oct 31 11:22:28 2005 @@ -0,0 +1,43 @@ +<?php + # Mantis - a php based bugtracking system + # Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net + # Copyright (C) 2004 Gerrit Beine - gerrit.beine@pitcom.de + # This program is distributed under the terms and conditions of the GPL + # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id$ + # -------------------------------------------------------- + + require_once( 'core.php' ); + + $t_core_path = config_get( 'core_path' ); + + require_once( $t_core_path . 'mail_api.php' ); + + $f_project_id = gpc_get_int( 'project_id' ); + + access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id ); + + mail_delete( $f_project_id ); + + $t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $f_project_id; + + html_page_top1(); + + html_meta_redirect( $t_redirect_url ); + + html_page_top2(); +?> + +<br /> +<div align="center"> +<?php + echo lang_get( 'operation_successful' ) . '<br />'; + + print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) ); +?> +</div> + +<?php html_page_bottom1( __FILE__ ) ?> + diff -Nur mantis-0.19.3.orig/manage_proj_mail_update.php mantis-0.19.3/manage_proj_mail_update.php --- mantis-0.19.3.orig/manage_proj_mail_update.php Thu Jan 1 01:00:00 1970 +++ mantis-0.19.3/manage_proj_mail_update.php Mon Oct 31 11:22:28 2005 @@ -0,0 +1,58 @@ +<?php + # Mantis - a php based bugtracking system + # Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net + # Copyright (C) 2004 Gerrit Beine - gerrit.beine@pitcom.de + # This program is distributed under the terms and conditions of the GPL + # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id$ + # -------------------------------------------------------- + + require_once( 'core.php' ); + + $t_core_path = config_get( 'core_path' ); + + require_once( $t_core_path . 'mail_api.php' ); + + $f_project_id = gpc_get_int( 'project_id' ); + $f_pop3_host = gpc_get_string( 'pop3_host' ); + $f_pop3_user = gpc_get_string( 'pop3_user' ); + $f_pop3_pass = gpc_get_string( 'pop3_pass' ); + + access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id ); + + if ( is_blank( $f_pop3_host ) ) { + trigger_error( ERROR_EMPTY_FIELD, ERROR ); + } + else { + if ( is_blank( $f_pop3_user ) ) { + trigger_error( ERROR_EMPTY_FIELD, ERROR ); + } + if ( is_blank( $f_pop3_pass ) ) { + trigger_error( ERROR_EMPTY_FIELD, ERROR ); + } + } + + mail_update( $f_project_id, $f_pop3_host, $f_pop3_user, $f_pop3_pass ); + + $t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $f_project_id; + + html_page_top1(); + + html_meta_redirect( $t_redirect_url ); + + html_page_top2(); +?> + +<br /> +<div align="center"> +<?php + echo lang_get( 'operation_successful' ) . '<br />'; + + print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) ); +?> +</div> + +<?php html_page_bottom1( __FILE__ ) ?> + diff -Nur mantis-0.19.3.orig/sql/bug_report_mail.sql mantis-0.19.3/sql/bug_report_mail.sql --- mantis-0.19.3.orig/sql/bug_report_mail.sql Thu Jan 1 01:00:00 1970 +++ mantis-0.19.3/sql/bug_report_mail.sql Mon Oct 31 11:22:28 2005 @@ -0,0 +1,12 @@ +ALTER TABLE `mantis_project_table` +ADD `pop3_host` VARCHAR( 255 ) DEFAULT NULL , +ADD `pop3_user` VARCHAR( 255 ) DEFAULT NULL , +ADD `pop3_pass` VARCHAR( 255 ) DEFAULT NULL , +ADD `pop3_categories` ENUM( '0', '1' ) DEFAULT '0' NOT NULL ; + +ALTER TABLE `mantis_project_category_table` +ADD `pop3_host` VARCHAR( 255 ) DEFAULT NULL , +ADD `pop3_user` VARCHAR( 255 ) DEFAULT NULL , +ADD `pop3_pass` VARCHAR( 255 ) DEFAULT NULL ; + +INSERT INTO mantis_user_table (username, realname, email, password, date_created, last_visit, enabled, protected, access_level, login_count, lost_password_in_progress_count, failed_login_count, cookie_string) VALUES ('Mail', 'Mail Reporter', 'nomail', 'a268462c3c679a9027658c5aa723f97c', '2004-12-25 15:41:49', '2004-12-25 15:41:49', 1, 0, 25, 0, 0, 0, CONCAT(MD5(RAND()),MD5(NOW()))); diff -Nur mantis-0.19.3.orig/sql/db_generate.sql mantis-0.19.3/sql/db_generate.sql --- mantis-0.19.3.orig/sql/db_generate.sql Sat Nov 6 12:07:30 2004 +++ mantis-0.19.3/sql/db_generate.sql Mon Oct 31 11:22:28 2005 @@ -330,6 +330,9 @@ project_id int(7) unsigned NOT NULL default '0', category varchar(64) NOT NULL default '', user_id int(7) unsigned NOT NULL default '0', + pop3_host varchar( 255 ) default NULL, + pop3_user varchar( 255 ) default NULL, + pop3_pass varchar( 255 ) default NULL, PRIMARY KEY (project_id,category) ) TYPE=MyISAM; @@ -379,6 +382,10 @@ access_min int(2) NOT NULL default '10', file_path varchar(250) NOT NULL default '', description text NOT NULL, + pop3_host varchar( 255 ) default NULL, + pop3_user varchar( 255 ) default NULL, + pop3_pass varchar( 255 ) default NULL, + pop3_categories enum( '0', '1' ) NOT NULL default '0', PRIMARY KEY (id), UNIQUE KEY name (name), KEY id (id) @@ -881,3 +888,5 @@ # INSERT INTO mantis_user_table VALUES (1, 'administrator', '', 'admin', '63a9f0ea7bb98050796b649e85481845', '2003-02-16 02:03:48', '2004-07-08 23:59:22', 1, 1, 90, 3, 0, 0, CONCAT(MD5(RAND()),MD5(NOW()))); +INSERT INTO mantis_user_table VALUES (2, 'Mail', 'Mail Reporter', 'nomail', 'a268462c3c679a9027658c5aa723f97c', '2004-12-25 15:41:49', '2004-12-25 15:41:49', 1, 0, 25, 0, 0, 0, CONCAT(MD5(RAND()),MD5(NOW()))); + mantis-1.0.0rc3.patch (41,385 bytes)
diff -Nur mantis-1.0.0rc3.orig/admin/schema.php mantis-1.0.0rc3/admin/schema.php --- mantis-1.0.0rc3.orig/admin/schema.php Wed Aug 3 16:20:34 2005 +++ mantis-1.0.0rc3/admin/schema.php Mon Oct 31 11:18:41 2005 @@ -192,7 +192,10 @@ $upgrade[] = Array('CreateTableSQL',Array(config_get('mantis_project_category_table')," project_id I UNSIGNED NOTNULL PRIMARY DEFAULT '0', category C(64) NOTNULL PRIMARY DEFAULT \" '' \", - user_id I UNSIGNED NOTNULL DEFAULT '0' + user_id I UNSIGNED NOTNULL DEFAULT '0', + pop3_host C(250) NULL, + pop3_user C(250) NULL, + pop3_pass C(250) NULL ",Array('mysql' => 'TYPE=MyISAM', 'pgsql' => 'WITHOUT OIDS'))); $upgrade[] = Array('CreateTableSQL',Array(config_get('mantis_project_file_table')," @@ -222,7 +225,11 @@ view_state I2 NOTNULL DEFAULT '10', access_min I2 NOTNULL DEFAULT '10', file_path C(250) NOTNULL DEFAULT \" '' \", - description XS NOTNULL + description XS NOTNULL, + pop3_host C(250) NULL, + pop3_user C(250) NULL, + pop3_pass C(250) NULL, + pop3_categories L NOTNULL DEFAULT '0' ",Array('mysql' => 'TYPE=MyISAM', 'pgsql' => 'WITHOUT OIDS'))); $upgrade[] = Array('CreateIndexSQL',Array('idx_project_id',config_get('mantis_project_table'),'id')); $upgrade[] = Array('CreateIndexSQL',Array('idx_project_name',config_get('mantis_project_table'),'name',Array('UNIQUE'))); @@ -340,5 +347,9 @@ $upgrade[] = Array('InsertData', Array( config_get('mantis_user_table'), "(username, realname, email, password, date_created, last_visit, enabled, protected, access_level, login_count, lost_password_request_count, failed_login_count, cookie_string) VALUES ('administrator', '', 'root@localhost', '63a9f0ea7bb98050796b649e85481845', " . db_now() . ", " . db_now() . ", 1, 0, 90, 3, 0, 0, '" . + md5( mt_rand( 0, mt_getrandmax() ) + mt_rand( 0, mt_getrandmax() ) ) . md5( time() ) . "')" ) ); +$upgrade[] = Array('InsertData', Array( config_get('mantis_user_table'), + "(username, realname, email, password, date_created, last_visit, enabled, protected, access_level, login_count, lost_password_request_count, failed_login_count, cookie_string) VALUES + ('mail', 'Mail Reporter', 'root@nomail@localhost', 'a268462c3c679a9027658c5aa723f97c', " . db_now() . ", " . db_now() . ", 1, 0, 25, 0, 0, 0, '" . md5( mt_rand( 0, mt_getrandmax() ) + mt_rand( 0, mt_getrandmax() ) ) . md5( time() ) . "')" ) ); ?> diff -Nur mantis-1.0.0rc3.orig/bug_report_mail.php mantis-1.0.0rc3/bug_report_mail.php --- mantis-1.0.0rc3.orig/bug_report_mail.php Thu Jan 1 01:00:00 1970 +++ mantis-1.0.0rc3/bug_report_mail.php Mon Oct 31 11:18:41 2005 @@ -0,0 +1,40 @@ +<?php +error_reporting(E_ALL); + # Mantis - a php based bugtracking system + # Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net + # Copyright (C) 2004 Gerrit Beine - gerrit.beine@pitcom.de + # This program is distributed under the terms and conditions of the GPL + # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id$ + # -------------------------------------------------------- + + # This page receives an E-Mail via POP3 and generates an Report + header("Content-type: text/plain"); + require_once( 'core.php' ); + + $t_core_path = config_get( 'core_path' ); + + require_once( $t_core_path . 'string_api.php' ); + require_once( $t_core_path . 'bug_api.php' ); + require_once( $t_core_path . 'mail_api.php' ); + + $t_mailaccounts = mail_get_accounts(); + + foreach ($t_mailaccounts as $t_mailaccount) { + if ( config_get( 'mail_debug' ) ) { + print_r($t_mailaccounts); + } + $t_mails = mail_get_all_mails($t_mailaccount); + foreach ($t_mails as $t_mail) + { + if ( config_get( 'mail_debug' ) ) { + print_r($t_mail); + } + $GLOBALS['g_cache_current_user_id'] = mail_get_user( $t_mail['From'] ); + mail_add_bug($t_mail, $t_mailaccount); + } + } +?> + diff -Nur mantis-1.0.0rc3.orig/config_defaults_inc.php mantis-1.0.0rc3/config_defaults_inc.php --- mantis-1.0.0rc3.orig/config_defaults_inc.php Sat Oct 29 01:36:32 2005 +++ mantis-1.0.0rc3/config_defaults_inc.php Mon Oct 31 11:18:41 2005 @@ -1617,4 +1617,37 @@ # ) # ); $g_custom_group_actions = array(); + + ###################### + # Mail Reporting + ###################### + + # --- mail reporting settings ----- + # This tells Mantis to report all the Mail with only one account + $g_mail_use_reporter = ON; + + # The account's name for mail reporting + # Also used for fallback if a user is not found in database + $g_mail_reporter = 'Mail'; + + # Signup new users automatically (possible security risk!) + # Default is OFF, ignored if mail_use_reporter is ON + $g_mail_auto_signup = OFF; + + # Write complete mail into the "Additional Information" + $g_mail_additional = OFF; + + # Write sender of the message into the bug report + $g_mail_save_from = OFF; + + # Parse MIME mails (may require a lot of memory) + $g_mail_parse_mime = OFF; + + # How many mails should be fetched at the same time + # If big mails with attachments should be received, specify only one + $g_mail_fetch_max = 1; + + # Signup new users automatically (possible security risk!) + # Default is OFF, ignored if mail_use_reporter is ON + $g_mail_debug = OFF; ?> diff -Nur mantis-1.0.0rc3.orig/core/category_api.php mantis-1.0.0rc3/core/category_api.php --- mantis-1.0.0rc3.orig/core/category_api.php Sat Feb 12 21:01:10 2005 +++ mantis-1.0.0rc3/core/category_api.php Mon Oct 31 11:18:41 2005 @@ -186,7 +186,7 @@ $t_project_category_table = config_get( 'mantis_project_category_table' ); - $query = "SELECT category, user_id + $query = "SELECT category, user_id, pop3_host, pop3_user, pop3_pass FROM $t_project_category_table WHERE project_id='$c_project_id' AND category='$c_category'"; @@ -206,7 +206,7 @@ $t_project_category_table = config_get( 'mantis_project_category_table' ); - $query = "SELECT category, user_id + $query = "SELECT category, user_id, pop3_host, pop3_user, pop3_pass FROM $t_project_category_table WHERE project_id='$c_project_id' ORDER BY category"; diff -Nur mantis-1.0.0rc3.orig/core/mail_api.php mantis-1.0.0rc3/core/mail_api.php --- mantis-1.0.0rc3.orig/core/mail_api.php Thu Jan 1 01:00:00 1970 +++ mantis-1.0.0rc3/core/mail_api.php Mon Oct 31 11:18:41 2005 @@ -0,0 +1,443 @@ +<?php + # Mantis - a php based bugtracking system + # Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net + # Copyright (C) 2004 Gerrit Beine - gerrit.beine@pitcom.de + # This program is distributed under the terms and conditions of the GPL + # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id$ + # -------------------------------------------------------- + + $t_core_dir = dirname( __FILE__ ).DIRECTORY_SEPARATOR; + + require_once( $t_core_dir . 'bug_api.php' ); + require_once( $t_core_dir . 'bugnote_api.php' ); + require_once( $t_core_dir . 'user_api.php' ); + require_once( $t_core_dir . 'project_api.php' ); + require_once( $t_core_dir . 'file_api.php' ); + + # This page receives an E-Mail via POP3 and generates an Report + + require_once( 'Net/POP3.php' ); + require_once( 'Mail/mimeDecode.php' ); + + # -------------------- + # Return mail account data for the specified project + function mail_get_account_data( $p_project_id ) { + $v_project_id = db_prepare_int( $p_project_id ); + + $t_project_table = config_get( 'mantis_project_table' ); + + $query = "SELECT pop3_host, pop3_user, pop3_pass, pop3_categories + FROM $t_project_table + WHERE id='$v_project_id'"; + + $result = db_query( $query ); + + return db_fetch_array( $result ); + } + + # -------------------- + # Update the mail account data for a project + function mail_update( $p_project_id, $p_pop3_host, $p_pop3_user, $p_pop3_pass ) { + $v_project_id = db_prepare_int( $p_project_id ); + $v_pop3_host = db_prepare_string( $p_pop3_host ); + $v_pop3_user = db_prepare_string( $p_pop3_user ); + $v_pop3_pass = db_prepare_string( $p_pop3_pass ); + + $t_project_table = config_get( 'mantis_project_table' ); + + $query = "UPDATE $t_project_table + SET pop3_host='$v_pop3_host', + pop3_user='$v_pop3_user', + pop3_pass='$v_pop3_pass' + WHERE id='$v_project_id'"; + + db_query( $query ); + + return true; + } + + # -------------------- + # Removes the mail account data from a project + function mail_delete( $p_project_id ) { + $v_project_id = db_prepare_int( $p_project_id ); + + $t_project_table = config_get( 'mantis_project_table' ); + + $query = "UPDATE $t_project_table + SET pop3_host=NULL, + pop3_user=NULL, + pop3_pass=NULL + WHERE id='$v_project_id'"; + + db_query( $query ); + + return true; + } + + # -------------------- + # Activate the 'Mail per Category' feature for a project + function mail_categories( $p_project_id, $p_active ) { + $v_project_id = db_prepare_int( $p_project_id ); + + if ($p_active == 'On') { + $v_active = 1; + } else { + $v_active = 0; + } + + $t_project_table = config_get( 'mantis_project_table' ); + + $query = "UPDATE $t_project_table + SET pop3_categories='$v_active' + WHERE id='$v_project_id'"; + + db_query( $query ); + + return true; + } + + # -------------------- + # Return mail account data for the specified project and category + function mail_category_get_account_data( $p_project_id, $p_category ) { + $v_project_id = db_prepare_int( $p_project_id ); + $v_category = db_prepare_string( $p_category ); + + $t_project_category_table = config_get( 'mantis_project_category_table' ); + + $query = "SELECT pop3_host, pop3_user, pop3_pass + FROM $t_project_category_table + WHERE project_id='$v_project_id' AND category='$v_category'"; + + $result = db_query( $query ); + + return db_fetch_array( $result ); + } + + # -------------------- + # Update the mail account data for a category + function mail_category_update( $p_project_id, $p_category, $p_pop3_host, $p_pop3_user, $p_pop3_pass ) { + $v_project_id = db_prepare_int( $p_project_id ); + $v_category = db_prepare_string( $p_category ); + $v_pop3_host = db_prepare_string( $p_pop3_host ); + $v_pop3_user = db_prepare_string( $p_pop3_user ); + $v_pop3_pass = db_prepare_string( $p_pop3_pass ); + + $t_project_category_table = config_get( 'mantis_project_category_table' ); + + $query = "UPDATE $t_project_category_table + SET pop3_host='$v_pop3_host', + pop3_user='$v_pop3_user', + pop3_pass='$v_pop3_pass' + WHERE project_id='$v_project_id' AND category='$v_category'"; + + db_query( $query ); + + return true; + } + + # -------------------- + # Removes the mail account data for a category + function mail_category_delete( $p_project_id, $p_category ) { + $v_project_id = db_prepare_int( $p_project_id ); + $v_category = db_prepare_string( $p_category ); + + $t_project_table = config_get( 'mantis_project_table' ); + + $t_project_category_table = config_get( 'mantis_project_category_table' ); + + $query = "UPDATE $t_project_category_table + SET pop3_host=NULL, + pop3_user=NULL, + pop3_pass=NULL + WHERE project_id='$v_project_id' AND category='$v_category'"; + + db_query( $query ); + + return true; + } + + # -------------------- + # return all mailaccounts + # return an empty array if there are no + function mail_get_accounts() { + $v_accounts = array(); + $t_projects = mail_project_get_all_rows(); + + foreach ($t_projects as $t_project) { + if ($t_project['pop3_categories']) { echo 1; + $v_categories = mail_categories_get_all_rows( $t_project['id'] ); + $v_accounts = array_merge($v_accounts, $v_categories); + } else { + array_push($v_accounts, $t_project); + } + } + + return $v_accounts; + } + + # -------------------- + # return all projects with valid data for mail access + # return an empty array if there are no such projects + function mail_project_get_all_rows() { + $v_projects = array(); + $t_projects = project_get_all_rows(); + + foreach ($t_projects as $t_project) { + if ($t_project['pop3_host'] || $t_project['pop3_categories']) { + array_push($v_projects, $t_project); + } + } + + return $v_projects; + } + + # -------------------- + # return all categories from a project with valid data for mail access + # return an empty array if there are no such categories + function mail_categories_get_all_rows( $p_project_id ) { + $v_categories = array(); + $t_categories = category_get_all_rows( $p_project_id ); + + foreach ($t_categories as $t_category) { + if ($t_category['pop3_host']) { + $t_category['id'] = $p_project_id; + array_push($v_categories, $t_category); + } + } + + return $v_categories; + } + + # -------------------- + # return all mails for an account + # return an empty array if there are no new mails + function mail_get_all_mails( $p_account ) { + $t_mail_parse_mime = config_get( 'mail_parse_mime' ); + $t_mail_fetch_max = config_get( 'mail_fetch_max' ); + $t_mail_additional = config_get( 'mail_additional' ); + + $v_mails = array(); + $t_pop3 = &new Net_POP3(); + $t_pop3_host = $p_account['pop3_host']; + $t_pop3_user = $p_account['pop3_user']; + $t_pop3_password = $p_account['pop3_pass']; + $t_pop3->connect($t_pop3_host, 110); + $t_pop3->login($t_pop3_user, $t_pop3_password); + + if ( 0 == $t_pop3->numMsg() ) { + return $v_mails; + } + for ($i = 1; $i <= $t_mail_fetch_max; $i++) { + $t_headers = $t_pop3->getParsedHeaders($i); + $t_msg = $t_pop3->getMsg($i); + if (true == $t_mail_parse_mime && + true == isset( $t_headers['MIME-Version'] ) && + 'multipart' == strtolower ( substr( $t_headers['Content-Type'], 0, 9 ) ) ) { + $t_mail = mail_parse_content( $t_msg ); + } else { + $t_mail = $t_headers; + $t_mail['X-Mantis-Body'] = $t_pop3->getBody($i); + } + + if (true == $t_mail_additional) { + $t_mail['X-Mantis-Complete'] = $t_msg; + } + + array_push($v_mails, $t_mail); + #$t_pop3->deleteMsg($i); + } + + $t_pop3->disconnect(); + return $v_mails; + } + + # -------------------- + # return the mail parsed for Mantis + function mail_parse_content ( $p_mail ) { + $v_mail = array (); + $t_decoder = new Mail_mimeDecode($p_mail); + $t_params['include_bodies'] = true; + $t_params['decode_bodies'] = true; + $t_params['decode_headers'] = true; + $t_structure = $t_decoder->decode($t_params); + $v_mail['To'] = $t_structure->headers['to']; + $v_mail['From'] = $t_structure->headers['from']; + $v_mail['Subject'] = $t_structure->headers['subject']; + if (is_array($t_structure->parts)) { + $t_parts = mail_parse_parts( $t_structure->parts ); + } else { + $t_parts = array ( mail_parse_part( $t_structure ) ); + } + if (strtolower($t_parts[0]['Content-Type']) == 'text/plain' || + strtolower($t_parts[0]['Content-Type']) == 'text/html' ) { + $t_body['Body'] = $t_parts[0]['Body']; + } else { + $t_body['Body'] = "It seems, there is no text... :-o"; + } + $v_mail['X-Mantis-Parts'] = $t_parts; + $v_mail['X-Mantis-Body'] = $t_body['Body']; + + return $v_mail; + } + + # -------------------- + # return the parsed parts from the mail + function mail_parse_parts ( $p_parts ) { + $v_parts = array (); + foreach ( $p_parts as $t_part ) { + array_push($v_parts, mail_parse_part( $t_part )); + } + + return $v_parts; + } + + # -------------------- + # return one parsed part + function mail_parse_part ( $p_part ) { + $v_part = array (); + $v_part['Content-Type'] = $p_part->ctype_primary."/".$p_part->ctype_secondary; + $v_part['Name'] = $p_part->ctype_parameters['name']; + $v_part['Body'] = $p_part->body; + + return $v_part; + } + + # -------------------- + # return the mailadress from the mail's 'From' + function mail_parse_address ( $p_mailaddress ) { + if (preg_match("/<(.*?)>/", $p_mailaddress, $matches)) { + $v_mailaddress = $matches[1]; + } + + return $v_mailaddress; + } + + # -------------------- + # return the a valid username from an email address + function mail_user_name_from_address ( $p_mailaddress ) { + return preg_replace("/[@\.-]/", '_', $p_mailaddress); + } + + # -------------------- + # return true if there is a valid mantis bug referernce in subject + function mail_is_a_bugnote ( $p_mail_subject ) { + return preg_match("/\[([A-Za-z0-9-_\. ]*\s[0-9]{7})\]/", $p_mail_subject); + } + + # -------------------- + # return the bug's id from the subject + function mail_get_bug_id_from_subject ( $p_mail_subject ) { + preg_match("/\[([A-Za-z0-9-_\. ]*\s([0-9]{7}?))\]/", $p_mail_subject, $v_matches); + + return $v_matches[2]; + } + + # -------------------- + # return the user id for the mail reporting user + function mail_get_user ($p_mailaddress) { + $t_mail_use_reporter = config_get( 'mail_use_reporter' ); + $t_mail_auto_signup = config_get( 'mail_auto_signup' ); + $t_mail_reporter = config_get( 'mail_reporter' ); + + $v_mailaddress = mail_parse_address( $p_mailaddress ); + + if ( $t_mail_use_reporter ) { + // Always report as mail_reporter + $t_reporter_id = user_get_id_by_name( $t_mail_reporter ); + } else { + // Try to get the reporting users id + $t_reporter_id = user_get_id_by_mail ( $v_mailaddress ); + if ( ! $t_reporter_id && $t_mail_auto_signup ) { + // So, we've to sign up a new user... + $t_user_name = mail_user_name_from_address ( $v_mailaddress ); + user_signup($t_user_name, $v_mailaddress); + $t_reporter_id = user_get_id_by_name($t_user_name); + } elseif ( ! $t_reporter_id ) { + // Fall back to the default mail_reporter + $t_reporter_id = user_get_id_by_name( $t_mail_reporter ); + } + } + + // dirty: Set the identified user's id + // required if bug_report_mail is run via command line + $GLOBAL['g_cache_current_user_id'] = $t_reporter_id; + + return $t_reporter_id; + } + + # -------------------- + # Very dirty: Adds a file to a bug. + function mail_add_file( $p_bug_id, $p_part ) { + $GLOBALS['_mail_file_'] = $p_part['Name']; + if ( 0 < strlen($p_part['Name']) ) { + $t_file_name = '/tmp/'.$p_part['Name']; + file_put_contents($t_file_name, $p_part['Body']); + file_add($p_bug_id, $t_file_name, $p_part['Name'], $p_part['Content-Type'], 'bug'); + unlink($t_file_name); + } + } + + # -------------------- + # Adds a bug which is reported via email + # Taken from bug_report.php and + function mail_add_bug ( $p_mail, $p_account ) { + $t_mail_save_from = config_get( 'mail_save_from' ); + + $t_bug_data = new BugData; + $t_bug_data->build = gpc_get_string( 'build', '' ); + $t_bug_data->platform = gpc_get_string( 'platform', '' ); + $t_bug_data->os = gpc_get_string( 'os', '' ); + $t_bug_data->os_build = gpc_get_string( 'os_build', '' ); + $t_bug_data->version = gpc_get_string( 'product_version', '' ); + $t_bug_data->profile_id = gpc_get_int( 'profile_id', 0 ); + $t_bug_data->handler_id = gpc_get_int( 'handler_id', 0 ); + $t_bug_data->view_state = gpc_get_int( 'view_state', config_get( 'default_bug_view_status' ) ); + + if ( $p_account['category']) { + $t_bug_data->category = gpc_get_string( 'category', $p_account['category'] ); + } else { + $t_bug_data->category = gpc_get_string( 'category', '' ); + } + $t_bug_data->reproducibility = 10; + $t_bug_data->severity = 50; + $t_bug_data->priority = gpc_get_int( 'priority', NORMAL ); + $t_bug_data->summary = $p_mail['Subject']; + if ( $t_mail_save_from ) { + $t_bug_data->description = "Report from: ".$p_mail['From']."\n\n".$p_mail['X-Mantis-Body']; + } + else { + $t_bug_data->description = $p_mail['X-Mantis-Body']; + } + $t_bug_data->steps_to_reproduce = gpc_get_string( 'steps_to_reproduce', '' ); + $t_bug_data->additional_information = $p_mail['X-Mantis-Complete']; + + $t_bug_data->project_id = $p_account['id']; + + $t_bug_data->reporter_id = mail_get_user( $p_mail['From'] ); + + if ( mail_is_a_bugnote( $p_mail['Subject'] ) ) { + # Add a bug note + $t_bug_id = mail_get_bug_id_from_subject( $p_mail['Subject'] ); + if ( ! bug_is_readonly( $t_bug_id ) ) { + bugnote_add ( $t_bug_id, $p_mail['X-Mantis-Body'] ); + email_bugnote_add ( $t_bug_id ); + } + } else { + # Create the bug + $t_bug_id = bug_create( $t_bug_data ); + email_new_bug( $t_bug_id ); + } + # Add files + if ( null != $p_mail['X-Mantis-Parts'] ) { + foreach ($p_mail['X-Mantis-Parts'] as $part) { + mail_add_file ( $t_bug_id, $part ); + } + } + + } + +?> + diff -Nur mantis-1.0.0rc3.orig/core/user_api.php mantis-1.0.0rc3/core/user_api.php --- mantis-1.0.0rc3.orig/core/user_api.php Fri Jul 22 17:34:02 2005 +++ mantis-1.0.0rc3/core/user_api.php Mon Oct 31 11:18:41 2005 @@ -526,6 +526,24 @@ } } + # get a user id from an mail address + # return false if the mail address does not exist + function user_get_id_by_mail( $p_mailaddress ) { + $c_mailaddress = db_prepare_string( $p_mailaddress ); + $t_user_table = config_get( 'mantis_user_table' ); + + $query = "SELECT id + FROM $t_user_table + WHERE email='$c_mailaddress'"; + $result = db_query( $query ); + + if ( 0 == db_num_rows( $result ) ) { + return false; + } else { + return db_result( $result ); + } + } + # -------------------- # return all data associated with a particular user name # return false if the username does not exist diff -Nur mantis-1.0.0rc3.orig/doc/README.bug_report_mail mantis-1.0.0rc3/doc/README.bug_report_mail --- mantis-1.0.0rc3.orig/doc/README.bug_report_mail Thu Jan 1 01:00:00 1970 +++ mantis-1.0.0rc3/doc/README.bug_report_mail Mon Oct 31 11:19:12 2005 @@ -0,0 +1,116 @@ +The current version of bug_report_mail support plain text and MIME +encoded e-mails via POP3 Mailaccounts with PEAR's Net_POP3 package. + +bug_report_mail is able to recognize if mail is a reply to an already opened +bug and adds the content as a bugnote. + +If you are alway running Mantis you have to alter your projects table +with the sql/bug_report_mail.sql script. +If not, you can create the database tables in the way described in +the doc/INSTALL file. + +This patch changes the following files: + core/category_api.php + core/user_api.php + admin/schema.php + config_defaults_inc.php + manage_proj_cat_edit_page.php + manage_proj_edit_page.php +These files are new: + core/mail_api.php + doc/README.bug_report_mail + doc/bug_report_mail.sql + bug_report_mail.php + manage_proj_cat_mail_delete.php + manage_proj_cat_mail_update.php + manage_proj_mail_categories.php + manage_proj_mail_delete.php + manage_proj_mail_update.php + +After installing this patch, you can add a POP3 server's hostname +and authentication data for each of your projects with the project edit form. + +There are two ways to receive mail with bug_report_mail: +The secure (and default) way is to use a standard reporting user: +You have to create a reporter account, for example 'Mail'. +The name for this reporter account you have to write in your config_inc.php file: + $g_mail_reporter = "Mail"; +and then, bug_report_mail must be informed to behave like this: + $g_mail_use_reporter = ON; + +The other way is to signup new user accounts automatically. +For using this, you have to change this + $g_mail_auto_signup = OFF; +from OFF to ON. +Now, bug_report_mail will look for an user named like the mail's sender +or an user which mail adress is identical. +If no user is found, then a new account will be created. +The new user's name will be the mail address. + +This could be used for attacks, but there is no other way in the moment. + +If you like to parse MIME encoded mails, you have to install the PEAR +Mail_Mime package and set + $g_mail_parse_mime = OFF; +from OFF to ON. + +For debugging controls there is the switch + $g_mail_additional = OFF; +which puts the complete message into the Additional Information field, +if it is activated. + +In this case you should decrease the amount of fetched messages via + $g_mail_fetch_max = 1; +because the mime decoding needs a lot of memory. + +If you'd like to use the Mail Reporter but don't save the whole message for +making the sender's address available, set + $g_mail_save_from = OFF; +to ON. + +After this, bug_report_mail can be used via cron like this: + +*/5 * * * * lynx --dump http://mantis.homepage.com/bug_report_mail.php +or via command line interface +*/5 * * * * /usr/local/bin/php /path/to/mantis/bug_report_mail.php + +This line fetch bug reports from via POP3 every 5 minutes. + +This addon is distributed under the same conditions as Mantis itself. + +Gerrit Beine, August 2004 + +Changelog: +Oct 2005 + - update to Mantis 1.0.0rc3 + - update to Mantis 0.19.3 +Sep 2005: + - update to Mantis 1.0.0rc2 + - fixed a bug in getting all categories for a project + category_get_all_rows in core/category_api.php +Aug 2005: + - update to Mantis 1.0.0rc1 + - include the additional patches submitted by + - gernot (Fixed MIME handling and save the mail's sender) + mail_get_all_mails in core/mail_api.php + mail_parse_content in core/mail_api.php + mail_add_bug in core/mail_api.php + - stevenc (Fixed MIME handling) + mail_parse_content in core/mail_api.php + - rainman (Fixed empty files bug and regex for finding a bug id) + mail_add_file in core/mail_api.php + mail_get_bug_id_from_subject in core/mail_api.php +Dec 2004: + - update to Mantis 0.19.2 + - add config: g_mail_parse_mime + - add config: g_mail_additional + - add config: g_mail_fetch_max + - make it working via CLI +Nov 2004: + - update to Mantis 0.19.1 + - add support for MIME decoding +Sep 2004: + - update to Mantis 0.19.0 +Aug 2004: + - create patch for Mantis 0.18.3 + diff -Nur mantis-1.0.0rc3.orig/doc/bug_report_mail.sql mantis-1.0.0rc3/doc/bug_report_mail.sql --- mantis-1.0.0rc3.orig/doc/bug_report_mail.sql Thu Jan 1 01:00:00 1970 +++ mantis-1.0.0rc3/doc/bug_report_mail.sql Mon Oct 31 11:18:41 2005 @@ -0,0 +1,12 @@ +ALTER TABLE `mantis_project_table` +ADD `pop3_host` VARCHAR( 255 ) DEFAULT NULL , +ADD `pop3_user` VARCHAR( 255 ) DEFAULT NULL , +ADD `pop3_pass` VARCHAR( 255 ) DEFAULT NULL , +ADD `pop3_categories` ENUM( '0', '1' ) DEFAULT '0' NOT NULL ; + +ALTER TABLE `mantis_project_category_table` +ADD `pop3_host` VARCHAR( 255 ) DEFAULT NULL , +ADD `pop3_user` VARCHAR( 255 ) DEFAULT NULL , +ADD `pop3_pass` VARCHAR( 255 ) DEFAULT NULL ; + +INSERT INTO mantis_user_table (username, realname, email, password, date_created, last_visit, enabled, protected, access_level, login_count, lost_password_request_count, failed_login_count, cookie_string) VALUES ('Mail', 'Mail Reporter', 'nomail', 'a268462c3c679a9027658c5aa723f97c', '2004-12-25 15:41:49', '2004-12-25 15:41:49', 1, 0, 25, 0, 0, 0, CONCAT(MD5(RAND()),MD5(NOW()))); diff -Nur mantis-1.0.0rc3.orig/manage_proj_cat_edit_page.php mantis-1.0.0rc3/manage_proj_cat_edit_page.php --- mantis-1.0.0rc3.orig/manage_proj_cat_edit_page.php Sat Feb 12 21:01:06 2005 +++ mantis-1.0.0rc3/manage_proj_cat_edit_page.php Mon Oct 31 11:18:41 2005 @@ -15,6 +15,7 @@ $t_core_path = config_get( 'core_path' ); require_once( $t_core_path.'category_api.php' ); + require_once( $t_core_path.'mail_api.php' ); ?> <?php $f_project_id = gpc_get_int( 'project_id' ); @@ -24,6 +25,10 @@ $t_row = category_get_row( $f_project_id, $f_category ); $t_assigned_to = $t_row['user_id']; + $t_mail = mail_get_account_data( $f_project_id ); + if ( $t_mail['pop3_categories'] ) { + $t_category_mail = mail_category_get_account_data( $f_project_id, $f_category ); + } ?> <?php html_page_top1() ?> <?php html_page_top2() ?> @@ -84,4 +89,59 @@ </form> </div> +<?php if ( $t_mail['pop3_categories'] ) { ?> +<!-- MAIL ACCOUNT CHANGE --> +<br /> +<div align="center"> + <form method="post" action="manage_proj_cat_mail_update.php"> + <input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" /> + <input type="hidden" name="category" value="<?php echo string_attribute( $f_category ) ?>" /> + <table class="width75" cellspacing="1"> + <tr> + <td class="form-title" colspan="4"> + <?php echo 'Category Mail Account Settings' ?> + </td> + </tr> + <tr class="row-1"> + <td class="category" width="25%"> + <?php echo "POP3 Host"?> + </td> + <td width="75%"> + <input type="text" name="pop3_host" size="64" maxlength="255" value="<?php echo string_attribute( $t_category_mail['pop3_host'] ) ?>" /> + </td> + </tr> + <tr class="row-1"> + <td class="category" width="25%"> + <?php echo "POP3 User"?> + </td> + <td width="75%"> + <input type="text" name="pop3_user" size="64" maxlength="255" value="<?php echo string_attribute( $t_category_mail['pop3_user'] ) ?>" /> + </td> + </tr> + <tr class="row-1"> + <td class="category" width="25%"> + <?php echo "POP3 Password"?> + </td> + <td width="75%"> + <input type="text" name="pop3_pass" size="64" maxlength="255" value="<?php echo string_attribute( $t_category_mail['pop3_pass'] ) ?>" /> + </td> + </tr> + <tr> + <td colspan="2"> + <input type="submit" value="<?php echo 'Set Mail Account Data' ?>" /> + </td> + </tr> + </table> + </form> +</div> +<!-- MAIL ACCOUNT RESET --> +<div class="border-center"> + <form method="post" action="manage_proj_cat_mail_delete.php"> + <input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" /> + <input type="hidden" name="category" value="<?php echo string_attribute( $f_category ) ?>" /> + <input type="submit" value="<?php echo 'Delete Mail Account Data' ?>" /> + </form> +</div> +<?php } ?> + <?php html_page_bottom1( __FILE__ ) ?> diff -Nur mantis-1.0.0rc3.orig/manage_proj_cat_mail_delete.php mantis-1.0.0rc3/manage_proj_cat_mail_delete.php --- mantis-1.0.0rc3.orig/manage_proj_cat_mail_delete.php Thu Jan 1 01:00:00 1970 +++ mantis-1.0.0rc3/manage_proj_cat_mail_delete.php Mon Oct 31 11:18:41 2005 @@ -0,0 +1,44 @@ +<?php + # Mantis - a php based bugtracking system + # Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net + # Copyright (C) 2004 Gerrit Beine - gerrit.beine@pitcom.de + # This program is distributed under the terms and conditions of the GPL + # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id$ + # -------------------------------------------------------- + + require_once( 'core.php' ); + + $t_core_path = config_get( 'core_path' ); + + require_once( $t_core_path . 'mail_api.php' ); + + $f_project_id = gpc_get_int( 'project_id' ); + $f_category = gpc_get_string( 'category' ); + + access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id ); + + mail_category_delete( $f_project_id, $f_category ); + + $t_redirect_url = 'manage_proj_cat_edit_page.php?project_id=' . $f_project_id . '&category=' . $f_category; + + html_page_top1(); + + html_meta_redirect( $t_redirect_url ); + + html_page_top2(); +?> + +<br /> +<div align="center"> +<?php + echo lang_get( 'operation_successful' ) . '<br />'; + + print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) ); +?> +</div> + +<?php html_page_bottom1( __FILE__ ) ?> + diff -Nur mantis-1.0.0rc3.orig/manage_proj_cat_mail_update.php mantis-1.0.0rc3/manage_proj_cat_mail_update.php --- mantis-1.0.0rc3.orig/manage_proj_cat_mail_update.php Thu Jan 1 01:00:00 1970 +++ mantis-1.0.0rc3/manage_proj_cat_mail_update.php Mon Oct 31 11:18:41 2005 @@ -0,0 +1,59 @@ +<?php + # Mantis - a php based bugtracking system + # Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net + # Copyright (C) 2004 Gerrit Beine - gerrit.beine@pitcom.de + # This program is distributed under the terms and conditions of the GPL + # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id$ + # -------------------------------------------------------- + + require_once( 'core.php' ); + + $t_core_path = config_get( 'core_path' ); + + require_once( $t_core_path . 'mail_api.php' ); + + $f_project_id = gpc_get_int( 'project_id' ); + $f_pop3_host = gpc_get_string( 'pop3_host' ); + $f_pop3_user = gpc_get_string( 'pop3_user' ); + $f_pop3_pass = gpc_get_string( 'pop3_pass' ); + $f_category = gpc_get_string( 'category' ); + + access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id ); + + if ( is_blank( $f_pop3_host ) ) { + trigger_error( ERROR_EMPTY_FIELD, ERROR ); + } + else { + if ( is_blank( $f_pop3_user ) ) { + trigger_error( ERROR_EMPTY_FIELD, ERROR ); + } + if ( is_blank( $f_pop3_pass ) ) { + trigger_error( ERROR_EMPTY_FIELD, ERROR ); + } + } + + mail_category_update( $f_project_id, $f_category, $f_pop3_host, $f_pop3_user, $f_pop3_pass ); + + $t_redirect_url = 'manage_proj_cat_edit_page.php?project_id=' . $f_project_id . '&category=' . $f_category; + + html_page_top1(); + + html_meta_redirect( $t_redirect_url ); + + html_page_top2(); +?> + +<br /> +<div align="center"> +<?php + echo lang_get( 'operation_successful' ) . '<br />'; + + print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) ); +?> +</div> + +<?php html_page_bottom1( __FILE__ ) ?> + diff -Nur mantis-1.0.0rc3.orig/manage_proj_edit_page.php mantis-1.0.0rc3/manage_proj_edit_page.php --- mantis-1.0.0rc3.orig/manage_proj_edit_page.php Tue Jul 26 14:41:02 2005 +++ mantis-1.0.0rc3/manage_proj_edit_page.php Mon Oct 31 11:18:41 2005 @@ -18,6 +18,7 @@ require_once( $t_core_path . 'version_api.php' ); require_once( $t_core_path . 'custom_field_api.php' ); require_once( $t_core_path . 'icon_api.php' ); + require_once( $t_core_path . 'mail_api.php' ); ?> <?php $f_project_id = gpc_get_int( 'project_id' ); @@ -25,6 +26,7 @@ access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id ); $row = project_get_row( $f_project_id ); + $mail = mail_get_account_data( $f_project_id ); ?> <?php html_page_top1() ?> <?php html_page_top2() ?> @@ -689,5 +691,76 @@ </tr> </table> </div> + +<?php if ( ! $mail['pop3_categories'] ) { ?> +<!-- MAIL ACCOUNT CHANGE --> +<br /> +<div align="center"> + <form method="post" action="manage_proj_mail_update.php"> + <input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" /> + <table class="width75" cellspacing="1"> + <tr> + <td class="form-title" colspan="4"> + <?php echo 'Mail Account Settings' ?> + </td> + </tr> + <tr class="row-1"> + <td class="category" width="25%"> + <?php echo "POP3 Host"?> + </td> + <td width="75%"> + <input type="text" name="pop3_host" size="64" maxlength="255" value="<?php echo string_attribute( $mail['pop3_host'] ) ?>" /> + </td> + </tr> + <tr class="row-1"> + <td class="category" width="25%"> + <?php echo "POP3 User"?> + </td> + <td width="75%"> + <input type="text" name="pop3_user" size="64" maxlength="255" value="<?php echo string_attribute( $mail['pop3_user'] ) ?>" /> + </td> + </tr> + <tr class="row-1"> + <td class="category" width="25%"> + <?php echo "POP3 Password"?> + </td> + <td width="75%"> + <input type="text" name="pop3_pass" size="64" maxlength="255" value="<?php echo string_attribute( $mail['pop3_pass'] ) ?>" /> + </td> + </tr> + <tr> + <td colspan="2"> + <input type="submit" value="<?php echo 'Set Mail Account Data' ?>" /> + </td> + </tr> + </table> + </form> +</div> +<!-- MAIL ACCOUNT RESET --> +<div class="border-center"> + <form method="post" action="manage_proj_mail_delete.php"> + <input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" /> + <input type="submit" value="<?php echo 'Delete Mail Account Data' ?>" /> + </form> +</div> +<br /> +<!-- MAIL ACCOUNT CATEGORIES --> +<div class="border-center"> + <form method="post" action="manage_proj_mail_categories.php"> + <input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" /> + <input type="hidden" name="categories" value="On" /> + <input type="submit" value="<?php echo 'Activate Mail Account per Category' ?>" /> + </form> +</div> +<?php } else { ?> +<!-- MAIL ACCOUNT CATEGORIES --> +<div class="border-center"> + <form method="post" action="manage_proj_mail_categories.php"> + <input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" /> + <input type="hidden" name="categories" value="Off" /> + <input type="submit" value="<?php echo 'Deactivate Mail Account per Category' ?>" /> + </form> +</div> +<?php } ?> <?php html_page_bottom1( __FILE__ ) ?> diff -Nur mantis-1.0.0rc3.orig/manage_proj_mail_categories.php mantis-1.0.0rc3/manage_proj_mail_categories.php --- mantis-1.0.0rc3.orig/manage_proj_mail_categories.php Thu Jan 1 01:00:00 1970 +++ mantis-1.0.0rc3/manage_proj_mail_categories.php Mon Oct 31 11:18:41 2005 @@ -0,0 +1,43 @@ +<?php + # Mantis - a php based bugtracking system + # Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net + # Copyright (C) 2004 Gerrit Beine - gerrit.beine@pitcom.de + # This program is distributed under the terms and conditions of the GPL + # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id$ + # -------------------------------------------------------- + + require_once( 'core.php' ); + + $t_core_path = config_get( 'core_path' ); + + require_once( $t_core_path . 'mail_api.php' ); + + $f_project_id = gpc_get_int( 'project_id' ); + $f_activate = gpc_get_string( 'categories' ); + + access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id ); + + mail_categories( $f_project_id, $f_activate ); + + $t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $f_project_id; + + html_page_top1(); + + html_meta_redirect( $t_redirect_url ); + + html_page_top2(); +?> + +<br /> +<div align="center"> +<?php + echo lang_get( 'operation_successful' ) . '<br />'; + print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) ); +?> +</div> + +<?php html_page_bottom1( __FILE__ ) ?> + diff -Nur mantis-1.0.0rc3.orig/manage_proj_mail_delete.php mantis-1.0.0rc3/manage_proj_mail_delete.php --- mantis-1.0.0rc3.orig/manage_proj_mail_delete.php Thu Jan 1 01:00:00 1970 +++ mantis-1.0.0rc3/manage_proj_mail_delete.php Mon Oct 31 11:18:41 2005 @@ -0,0 +1,43 @@ +<?php + # Mantis - a php based bugtracking system + # Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net + # Copyright (C) 2004 Gerrit Beine - gerrit.beine@pitcom.de + # This program is distributed under the terms and conditions of the GPL + # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id$ + # -------------------------------------------------------- + + require_once( 'core.php' ); + + $t_core_path = config_get( 'core_path' ); + + require_once( $t_core_path . 'mail_api.php' ); + + $f_project_id = gpc_get_int( 'project_id' ); + + access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id ); + + mail_delete( $f_project_id ); + + $t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $f_project_id; + + html_page_top1(); + + html_meta_redirect( $t_redirect_url ); + + html_page_top2(); +?> + +<br /> +<div align="center"> +<?php + echo lang_get( 'operation_successful' ) . '<br />'; + + print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) ); +?> +</div> + +<?php html_page_bottom1( __FILE__ ) ?> + diff -Nur mantis-1.0.0rc3.orig/manage_proj_mail_update.php mantis-1.0.0rc3/manage_proj_mail_update.php --- mantis-1.0.0rc3.orig/manage_proj_mail_update.php Thu Jan 1 01:00:00 1970 +++ mantis-1.0.0rc3/manage_proj_mail_update.php Mon Oct 31 11:18:41 2005 @@ -0,0 +1,58 @@ +<?php + # Mantis - a php based bugtracking system + # Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net + # Copyright (C) 2004 Gerrit Beine - gerrit.beine@pitcom.de + # This program is distributed under the terms and conditions of the GPL + # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id$ + # -------------------------------------------------------- + + require_once( 'core.php' ); + + $t_core_path = config_get( 'core_path' ); + + require_once( $t_core_path . 'mail_api.php' ); + + $f_project_id = gpc_get_int( 'project_id' ); + $f_pop3_host = gpc_get_string( 'pop3_host' ); + $f_pop3_user = gpc_get_string( 'pop3_user' ); + $f_pop3_pass = gpc_get_string( 'pop3_pass' ); + + access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id ); + + if ( is_blank( $f_pop3_host ) ) { + trigger_error( ERROR_EMPTY_FIELD, ERROR ); + } + else { + if ( is_blank( $f_pop3_user ) ) { + trigger_error( ERROR_EMPTY_FIELD, ERROR ); + } + if ( is_blank( $f_pop3_pass ) ) { + trigger_error( ERROR_EMPTY_FIELD, ERROR ); + } + } + + mail_update( $f_project_id, $f_pop3_host, $f_pop3_user, $f_pop3_pass ); + + $t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $f_project_id; + + html_page_top1(); + + html_meta_redirect( $t_redirect_url ); + + html_page_top2(); +?> + +<br /> +<div align="center"> +<?php + echo lang_get( 'operation_successful' ) . '<br />'; + + print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) ); +?> +</div> + +<?php html_page_bottom1( __FILE__ ) ?> + Parser.php (5,175 bytes)
<?php require_once( 'Mail/mimeDecode.php' ); class Mail_Parser { private $_parse_html = false; private $_parse_mime = false; private $_htmlparser = "/usr/bin/w3m -T text/html -dump"; private $_htmltmpdir = "/tmp"; private $_file; private $_content; private $_from; private $_subject; private $_transferencoding; private $_body; private $_parts = array ( ); private $_ctype = array ( ); function __construct( $options = array() ) { $this->_parse_mime = $options['parse_mime']; $this->_parse_html = $options['parse_html']; $this->_htmlparser = $options['htmlparser']; $this->_htmltmpdir = $options['htmltmpdir']; } public function setInputString ( $content ) { $this->_content = $content; } public function setInputFile( $file ) { $this->_file = $file; $this->_content = file_get_contents( $this->_file ); } public function parse() { $decoder = new Mail_mimeDecode( $this->_content ); $params['include_bodies'] = true; $params['decode_bodies'] = true; $params['decode_headers'] = true; $structure = $decoder->decode( $params ); $this->parseStructure( $structure ); unset( $this->_content ); } public function from() { return $this->_from; } public function subject() { return $this->_subject; } public function priority() { return $this->_priority; } public function body() { return $this->_body; } public function parts() { return $this->_parts; } private function parseStructure( $structure ) { $this->setFrom( $structure->headers['from'] ); $this->setSubject( $structure->headers['subject'] ); $this->setContentType( $structure->ctype_primary, $structure->ctype_secondary ); if ( isset( $structure->headers['x-priority'] ) ) { $this->setPriority( $structure->headers['x-priority'] ); } if ( isset( $structure->headers['content-transfer-encoding'] ) ) { $this->setTransferEncoding( $structure->headers['content-transfer-encoding'] ); } if ( isset( $structure->body ) ) { $this->setBody( $structure->body ); } if ( $this->_parse_mime && isset( $structure->parts ) ) { $this->setParts( $structure->parts ); } } private function setFrom( $from ) { $this->_from = quoted_printable_decode( $from ); } private function setSubject( $subject ) { $this->_subject = quoted_printable_decode( $subject ); } private function setPriority( $priority ) { $this->_priority = $priority; } private function setTransferEncoding( $transferencoding ) { $this->_transferencoding = $transferencoding; } private function setContentType( $primary, $secondary ) { $this->_ctype['primary'] = $primary; $this->_ctype['secondary'] = $secondary; } private function setBody( $body ) { if ( 0 == strlen( $body ) || 0 != strlen( $this->_body ) ) { return; } if ( 'text' == $this->_ctype['primary'] && 'plain' == $this->_ctype['secondary'] ) { switch ( $this->_transferencoding ) { case 'base64': case '8bit': case 'quoted-printable': $this->_body = quoted_printable_decode( $body ); break; default: $this->_body = $body; break; } } elseif ( $this->_parse_html && 'text' == $this->_ctype['primary'] && 'html' == $this->_ctype['secondary'] ) { $file = $this->_htmltmpdir . "/" . md5 ( $body ); file_put_contents( $file, $body ); // (brody): // unix/piped: $this->_body = shell_exec("cat " . $file . " | " . $this->_htmlparser); // windows and parameter: $this->_body = shell_exec($this->_htmlparser . " " . $file); unlink($file); } } private function setParts( &$parts) { $i = 0; if ( 'multipart' == $parts[$i]->ctype_primary ) { $this->setParts( $parts[$i]->parts ); $i++; } // FIX(brody): use parts of type (text/plain,html) as body , if not classified as attachment (disposition) if ( 'text' == $parts[$i]->ctype_primary && in_array( $parts[$i]->ctype_secondary, array( 'plain', 'html' ) ) && (! isset ($parts[$i]->disposition)) ) { $this->setContentType( $parts[$i]->ctype_primary, $parts[$i]->ctype_secondary ); $this->setTransferEncoding( $parts[$i]->headers['content-transfer-encoding'] ); $this->setBody( $parts[$i]->body ); $i++; } if ( isset( $parts[$i] ) && 'text' == $parts[$i]->ctype_primary && 'html' == $parts[$i]->ctype_secondary ) { $i++; } for ( $i; $i < count( $parts ); $i++ ) { $this->addPart( $parts[$i] ); } } private function addPart( &$part ) { $p['ctype'] = $part->ctype_primary . "/" . $part->ctype_secondary; if ( isset( $part->ctype_parameters['name'] ) ) { $p['name'] = $part->ctype_parameters['name']; } $p['body'] = $part->body; $this->_parts[] = $p; } } ?> Parser.php.patch (801 bytes)
128c128 < $ this ->_body = shell_exec( " cat " . $file . " | " . $this->_htmlparser) ; --- > / / ( brody ) : 128a129,131 > // unix/piped: $this->_body = shell_exec("cat " . $file . " | " . $this->_htmlparser); > // windows and parameter: > $this->_body = shell_exec($this->_htmlparser . " " . $file); 133c136 < private function setParts( &$parts ) { $i = 0; --- > private function setParts( &$parts) { $i = 0; 137a141 > // FIX(brody): use parts of type (text/plain,html) as body , if not classified as attachment (disposition) 139c143 < in_array( $parts[$i]->ctype_secondary, array( 'plain', 'html' ) ) ) { --- > in_array( $parts[$i]->ctype_secondary, array( 'plain', 'html' ) ) && (! isset ($parts[$i]->disposition)) ) { mail_api.php.patch (2,517 bytes)
220a221 > $t_mail_debug = config_get( 'mail_debug' ); 221a223,224 > // get stamp of (prev) last processed mail > $t_mail_last_processed = config_get( 'pop3_last_mail_ds',null ,null ,$p_account['id']); 251a255 > if ( null == $t_mail_last_processed || $t_mail['Datestamp'] > $t_mail_last_processed ) { 253a258,263 > $t_mail_last_processed = $t_mail['Datestamp']; > } else { > if ( $t_mail_debug ) { > echo "\nMail skipped - to old against last checked mail!\n"; > } > } 261a272,273 > // save stamp of last processed mail > config_set( 'pop3_last_mail_ds', $t_mail_last_processed , null, $p_account['id']); 287a300,301 > $t_mail['Datestamp'] = strtotime($t_mp->date()); > 302c316 < if ( true == $t_mail_use_bug_priority ) { --- > / / FIXED( wb ) 302a317 > if ( $t_mail_use_bug_priority ) { 308,309c323,324 < if ( true == $t_mail_additional ) { < $ t_mail [ ' X-Mantis-Complete'] = $t_msg; --- > / / FIXED( wb ) > if ( $ t_mail_additional ) { 309a325 > $t_mail['X-Mantis-Complete'] = $p_mail; 383c401 < function mail_add_file( $p_bug_id, $p_part, $number ) { --- > function mail_add_file( $p_bug_id, $p_part, $number = 0 ) { 384a403,405 > $t_attachment_directory = config_get( 'mail_tmp_directory' ); > > if ( is_dir($t_attachment_directory) && is_writeable($t_attachment_directory) ) { 386c407 < $t_file_name = ' /tmp/'.$p_part['name']; --- > $t_file_name = $t_attachment_directory . ' /'.$p_part['name']; 388c409 < file_add($ p_bug_id, $t_file_name, $number . " -".$p_part['name'], $p_part['ctype'], 'bug') ; --- > if($ number > 0 ) { 388a410,413 > file_add($p_bug_id, $t_file_name, $number."_".$p_part['name'], $p_part['ctype'], 'bug'); > } else { > file_add($p_bug_id, $t_file_name, $p_part['name'], $p_part['ctype'], 'bug'); > } 391a417 > } 395c421 < $t_mail_directory = config_get( 'mail_directory' ); --- > $t_mail_directory = config_get( 'mail_tmp_directory' ); 443a470,473 > # FIX(wb) Wo made (optionally) the note (From) > if ( $t_mail_save_from ) { > bugnote_add ( $t_bug_id, "(<b>".$p_mail['From']."</b>):\n".$p_mail['X-Mantis-Body'] ); > } else { 444a475 > } 456c487 < # Add files --- > # Add files, number removed 458c489 < $number = 1; --- > # $number = 1; 460c491 < mail_add_file ( $t_bug_id, $part, $number ); --- > mail_add_file ( $t_bug_id, $part ); 1202890957da93014a9e1d86b8b0fc26e66b637721 (12,353 bytes)
Received: from dapozzom01 ([10.221.4.105]) by servpro.lispa.it (Lotus Domino Release 7.0.2FP2) with ESMTP id 2008021309202397-6980 ; Wed, 13 Feb 2008 09:20:23 +0100 From: "Marco Da Pozzo" <marco.dapozzo@lombardia-servizi.it> To: "mantisLoto" <mantis.Loto@lombardia-servizi.it> Subject: oggetto Date: Wed, 13 Feb 2008 09:22:25 +0100 MIME-Version: 1.0 X-Mailer: Microsoft Office Outlook, Build 11.0.5510 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 Thread-Index: AchuGY7No6xm4wacSNy1ptxAWPileA== X-MIMETrack: Itemize by SMTP Server on SERVPRO/Lombardia Informatica/IT(Release 7.0.2FP2|May 14, 2007) at 13/02/2008 09:20:24, Serialize by Router on SERVPRO/Lombardia Informatica/IT(Release 7.0.2FP2|May 14, 2007) at 13/02/2008 09:20:25, Serialize complete at 13/02/2008 09:20:25, Itemize by Router on SERVPRO/Lombardia Informatica/IT(Release 7.0.2FP2|May 14, 2007) at 13/02/2008 09:20:25, Serialize by POP3 Server on SERVPRO/Lombardia Informatica/IT(Release 7.0.2FP2|May 14, 2007) at 13/02/2008 09:20:36, Serialize complete at 13/02/2008 09:20:36 Message-ID: <OFA1C24376.35B8287E-ONC12573EE.002DD070@lispa.it> Content-Type: multipart/mixed; boundary="----=_NextPart_000_00BE_01C86E21.F267BC80" ------=_NextPart_000_00BE_01C86E21.F267BC80 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="US-ASCII" Corpo mail Corpo mail Corpo mail Corpo mailCorpo mail Corpo mailCorpo mail Corpo mailCorpo mail Corpo mailCorpo mail Corpo mailCorpo mail Corpo mailCorpo mail Corpo mailCorpo mail Corpo mail ------=_NextPart_000_00BE_01C86E21.F267BC80 Content-Type: application/octet-stream; name="README.bug_report_mail" Content-Disposition: attachment; filename="README.bug_report_mail" Content-Transfer-Encoding: base64 VGhlIGN1cnJlbnQgdmVyc2lvbiBvZiBidWdfcmVwb3J0X21haWwgc3VwcG9ydCBwbGFpbiB0ZXh0 IGFuZCBNSU1FDQplbmNvZGVkIGUtbWFpbHMgdmlhIFBPUDMgTWFpbGFjY291bnRzIHdpdGggUEVB UidzIE5ldF9QT1AzIHBhY2thZ2UuDQoNCmJ1Z19yZXBvcnRfbWFpbCBpcyBhYmxlIHRvIHJlY29n bml6ZSBpZiBtYWlsIGlzIGEgcmVwbHkgdG8gYW4gYWxyZWFkeSBvcGVuZWQNCmJ1ZyBhbmQgYWRk cyB0aGUgY29udGVudCBhcyBhIGJ1Z25vdGUuDQoNCklmIHlvdSBhcmUgYWx3YXkgcnVubmluZyBN YW50aXMgeW91IGhhdmUgdG8gYWx0ZXIgeW91ciBwcm9qZWN0cyB0YWJsZQ0Kd2l0aCB0aGUgc3Fs L2J1Z19yZXBvcnRfbWFpbC5zcWwgc2NyaXB0Lg0KSWYgbm90LCB5b3UgY2FuIGNyZWF0ZSB0aGUg ZGF0YWJhc2UgdGFibGVzIGluIHRoZSB3YXkgZGVzY3JpYmVkIGluDQp0aGUgZG9jL0lOU1RBTEwg ZmlsZS4NCg0KVGhpcyBwYXRjaCBjaGFuZ2VzIHRoZSBmb2xsb3dpbmcgZmlsZXM6DQogICAgY29y ZS9jYXRlZ29yeV9hcGkucGhwDQogICAgY29yZS9maWxlX2FwaS5waHANCiAgICBjb3JlL3VzZXJf YXBpLnBocA0KICAgIGFkbWluL3NjaGVtYS5waHANCiAgICBjb25maWdfZGVmYXVsdHNfaW5jLnBo cA0KICAgIG1hbmFnZV9wcm9qX2NhdF9lZGl0X3BhZ2UucGhwDQogICAgbWFuYWdlX3Byb2pfZWRp dF9wYWdlLnBocA0KVGhlc2UgZmlsZXMgYXJlIG5ldzoNCiAgICBNYWlsL21pbWUucGhwDQogICAg TWFpbC9taW1lRGVjb2RlLnBocA0KICAgIE1haWwvbWltZVBhcnQucGhwDQogICAgTWFpbC9QYXJz ZXIucGhwDQogICAgTmV0L1BPUDMucGhwDQogICAgTmV0L1NvY2tldC5waHANCiAgICBjb3JlL21h aWxfYXBpLnBocA0KICAgIGRvYy9SRUFETUUuYnVnX3JlcG9ydF9tYWlsDQogICAgZG9jL2J1Z19y ZXBvcnRfbWFpbC5zcWwNCiAgICBQRUFSLnBocA0KICAgIGJ1Z19yZXBvcnRfbWFpbC5waHANCiAg ICBtYW5hZ2VfcHJval9jYXRfbWFpbF9kZWxldGUucGhwDQogICAgbWFuYWdlX3Byb2pfY2F0X21h aWxfdXBkYXRlLnBocA0KICAgIG1hbmFnZV9wcm9qX21haWxfY2F0ZWdvcmllcy5waHANCiAgICBt YW5hZ2VfcHJval9tYWlsX2RlbGV0ZS5waHANCiAgICBtYW5hZ2VfcHJval9tYWlsX3VwZGF0ZS5w aHANCg0KQWZ0ZXIgaW5zdGFsbGluZyB0aGlzIHBhdGNoLCB5b3UgY2FuIGFkZCBhIFBPUDMgc2Vy dmVyJ3MgaG9zdG5hbWUNCmFuZCBhdXRoZW50aWNhdGlvbiBkYXRhIGZvciBlYWNoIG9mIHlvdXIg cHJvamVjdHMgd2l0aCB0aGUgcHJvamVjdCBlZGl0IGZvcm0uDQoNClRoZXJlIGFyZSB0d28gd2F5 cyB0byByZWNlaXZlIG1haWwgd2l0aCBidWdfcmVwb3J0X21haWw6DQpUaGUgc2VjdXJlIChhbmQg ZGVmYXVsdCkgd2F5IGlzIHRvIHVzZSBhIHN0YW5kYXJkIHJlcG9ydGluZyB1c2VyOg0KWW91IGhh dmUgdG8gY3JlYXRlIGEgcmVwb3J0ZXIgYWNjb3VudCwgZm9yIGV4YW1wbGUgJ01haWwnLg0KVGhl IG5hbWUgZm9yIHRoaXMgcmVwb3J0ZXIgYWNjb3VudCB5b3UgaGF2ZSB0byB3cml0ZSBpbiB5b3Vy IGNvbmZpZ19pbmMucGhwIGZpbGU6DQoJJGdfbWFpbF9yZXBvcnRlciA9ICJNYWlsIjsNCmFuZCB0 aGVuLCBidWdfcmVwb3J0X21haWwgbXVzdCBiZSBpbmZvcm1lZCB0byBiZWhhdmUgbGlrZSB0aGlz Og0KCSRnX21haWxfdXNlX3JlcG9ydGVyID0gT047DQoNClRoZSBvdGhlciB3YXkgaXMgdG8gc2ln bnVwIG5ldyB1c2VyIGFjY291bnRzIGF1dG9tYXRpY2FsbHkuDQpGb3IgdXNpbmcgdGhpcywgeW91 IGhhdmUgdG8gY2hhbmdlIHRoaXMNCgkkZ19tYWlsX2F1dG9fc2lnbnVwICAgICA9IE9GRjsNCmZy b20gT0ZGIHRvIE9OLg0KTm93LCBidWdfcmVwb3J0X21haWwgd2lsbCBsb29rIGZvciBhbiB1c2Vy IG5hbWVkIGxpa2UgdGhlIG1haWwncyBzZW5kZXINCm9yIGFuIHVzZXIgd2hpY2ggbWFpbCBhZHJl c3MgaXMgaWRlbnRpY2FsLg0KSWYgbm8gdXNlciBpcyBmb3VuZCwgdGhlbiBhIG5ldyBhY2NvdW50 IHdpbGwgYmUgY3JlYXRlZC4NClRoZSBuZXcgdXNlcidzIG5hbWUgd2lsbCBiZSB0aGUgbWFpbCBh ZGRyZXNzLg0KDQpUaGlzIGNvdWxkIGJlIHVzZWQgZm9yIGF0dGFja3MsIGJ1dCB0aGVyZSBpcyBu byBvdGhlciB3YXkgaW4gdGhlIG1vbWVudC4NCg0KSWYgeW91IGxpa2UgdG8gcGFyc2UgTUlNRSBl bmNvZGVkIG1haWxzLCB5b3UgaGF2ZSB0byBpbnN0YWxsIHRoZSBQRUFSDQpNYWlsX01pbWUgcGFj a2FnZSBhbmQgc2V0DQoJJGdfbWFpbF9wYXJzZV9taW1lCT0gT0ZGOw0KZnJvbSBPRkYgdG8gT04u DQoNCkZvciBwYXJzaW5nIEhUTUwgbWFpbHMsIHNldCANCgkkZ19tYWlsX3BhcnNlX2h0bWwJPSBP TjsNCmFuZCBzZXQgDQoJJGdfbWFpbF9odG1sX3BhcnNlcg0KdG8gYSB2YWxpZCB0b29sIGZvciBk dW1waW5nIEhUTUwgY29udGVudHMgKCIvdXNyL2Jpbi93M20gLVQgdGV4dC9odG1sIC1kdW1wIikN CkFsc28sIA0KCSRnX21haWxfdG1wX2RpcmVjdG9yeQ0KaGFzIHRvIGJlIGEgdmFsaWQgZGlyZWN0 b3J5IHRvIGhhbmRsZSB3cml0ZSB0aGUgdGVtcG9yYXJ5IEhUTUwgZmlsZXMuDQoNCkZvciBkZWJ1 Z2dpbmcgY29udHJvbHMgdGhlcmUgaXMgdGhlIHN3aXRjaA0KCSRnX21haWxfYWRkaXRpb25hbAk9 IE9GRjsNCndoaWNoIHB1dHMgdGhlIGNvbXBsZXRlIG1lc3NhZ2UgaW50byB0aGUgQWRkaXRpb25h bCBJbmZvcm1hdGlvbiBmaWVsZCwNCmlmIGl0IGlzIGFjdGl2YXRlZC4NCg0KSWYgeW91IGxpa2Ug dG8gc2VlIHdoYXQgYnVnX3JlcG9ydF9tYWlsLnBocCBpcyBkb2luZywgc2V0DQoJJGdfbWFpbF9k ZWJ1ZyA9IE9OOw0KDQpJZiAkZ19tYWlsX2RpcmVjdG9yeSBpcyBhIHZhbGlkIGRpcmVjdG9yeSBh bmQgYWxzbyB3cml0ZWFibGUsDQp0aGUgY29tcGxldGUgbWFpbHMgd2lsbCBiZSBzYXZlZCB0byB0 aGlzIGRpcmVjdG9yeS4NCg0KSW4gdGhpcyBjYXNlIHlvdSBzaG91bGQgZGVjcmVhc2UgdGhlIGFt b3VudCBvZiBmZXRjaGVkIG1lc3NhZ2VzIHZpYQ0KCSRnX21haWxfZmV0Y2hfbWF4CT0gMTsNCmJl Y2F1c2UgdGhlIG1pbWUgZGVjb2RpbmcgbmVlZHMgYSBsb3Qgb2YgbWVtb3J5Lg0KDQpJZiB5b3Un ZCBsaWtlIHRvIHVzZSB0aGUgTWFpbCBSZXBvcnRlciBidXQgZG9uJ3Qgc2F2ZSB0aGUgd2hvbGUg bWVzc2FnZSBmb3INCm1ha2luZyB0aGUgc2VuZGVyJ3MgYWRkcmVzcyBhdmFpbGFibGUsIHNldA0K CSRnX21haWxfc2F2ZV9mcm9tCT0gT0ZGOw0KdG8gT04uDQoNCklmIHlvdSBkb24ndCB3YW50IGJ1 Z19yZXBvcnRfbWFpbC5waHAgdG8gZGVsZXRlIHRoZSBtYWlscyBmcm9tIHlvdXIgUE9QMw0Kc2Vy dmVyIHNldA0KCSRnX21haWxfZGVsZXRlID0gT0ZGOw0KVXNlIHRoaXMgY2FyZWZ1bGx5IQ0KDQpX aXRoIA0KCSRnX21haWxfYXV0aF9tZXRob2QNCnlvdSBtYXkgc2V0IHRoZSBBVVRIIG1ldGhvZCBm b3IgeW91ciBQT1AzIHNlcnZlci4gRGVmYXVsdCBpcyAnVVNFUicsDQpidXQgJ0RJR0VTVC1NRDUn LCdDUkFNLU1ENScsJ0xPR0lOJywnUExBSU4nLCdBUE9QJyBhcmUgYWxzbyBwb3NzaWJsZQ0KDQpG b3IgdXNpbmcgdGhlIHByaW9yaXR5IG9mIHRoZSBtYWlscyBmb3IgdGhlIGJ1ZyBwcmlvcml0eSwg c2V0DQoJJGdfbWFpbF91c2VfYnVnX3ByaW9yaXR5ID0gT047DQpUaGUNCgkkZ19tYWlsX2J1Z19w cmlvcml0eV9kZWZhdWx0ID0gTk9STUFMOw0KaXMgdGhlIGRlZmF1bHQgdmFsdWUgZm9yIHRoZSBw cmlvcml0eSBvZiBuZXcgYnVnIGVudHJpZXMuDQoNCkRlZmF1bHQgYnVnIGNhdGVnb3J5IGZvciBt YWlsIHJlcG9ydGVkIGJ1Z3MgKERlZmF1bHRzIHRvICJkZWZhdWx0X2J1Z19jYXRlZ29yeSIpDQpC ZWNhdXNlIGluIE1hbnRpcyAxLjEuMGEzIGEgY2F0ZWdvcnkgaXMgcmVxdWlyZWQsIHdlIG5lZWQg YSBkZWZhdWx0IGNhdGVnb3J5IGZvciBpc3N1ZXMgcmVwb3J0ZWQgYnkgZW1haWwuDQpNYWtlIHN1 cmUgdGhlIGNhdGVnb3J5IGV4aXN0cyBhbmQgaXQgaGFzIGJlZW4gY29uZmlndXJlZCBjb3JyZWN0 bHkNCgkkZ19tYWlsX2RlZmF1bHRfYnVnX2NhdGVnb3J5ID0gJyVkZWZhdWx0X2J1Z19jYXRlZ29y eSUnOw0KDQpBZnRlciB0aGlzLCBidWdfcmVwb3J0X21haWwgY2FuIGJlIHVzZWQgdmlhIGNyb24g bGlrZSB0aGlzOg0KDQoqLzUgKiAgICogICAqICAgKiBseW54IC0tZHVtcCBodHRwOi8vbWFudGlz LmhvbWVwYWdlLmNvbS9idWdfcmVwb3J0X21haWwucGhwDQpvciB2aWEgY29tbWFuZCBsaW5lIGlu dGVyZmFjZQ0KKi81ICogICAqICAgKiAgICogL3Vzci9sb2NhbC9iaW4vcGhwIC9wYXRoL3RvL21h bnRpcy9idWdfcmVwb3J0X21haWwucGhwDQoNClRoaXMgbGluZSBmZXRjaCBidWcgcmVwb3J0cyBm cm9tIHZpYSBQT1AzIGV2ZXJ5IDUgbWludXRlcy4gDQoNClRoaXMgYWRkb24gaXMgZGlzdHJpYnV0 ZWQgdW5kZXIgdGhlIHNhbWUgY29uZGl0aW9ucyBhcyBNYW50aXMgaXRzZWxmLg0KDQpHZXJyaXQg QmVpbmUsIEF1Z3VzdCAyMDA0DQoNCkNoYW5nZWxvZzoNCkp1biAyMDA3DQoJLSB1cGRhdGUgdG8g TWFudGlzIDEuMS4wYTMNCgktIFN1cHBvcnQgZm9yIFBIUCA0ICggfjEzODA1ICkNCgktIEZpeGVk IGEgYnVnIHdpdGggcHJvY2Vzc2luZyBwcmlvcml0eSdzIG9mIGVtYWlscyAocHJpb3JpdHkgY2xh c3MgdmFyaWFibGUgZGlkbid0IGV4aXN0IGluIE1haWwvUGFyc2VyLnBocCkNCgktIFVwZGF0ZXMg dG8gdGhlIGxhdGVzdCBQRUFSIHBhY2thZ2VzDQoJLSBwcmludF9yIGNoYW5nZWQgdG8gdmFyX2R1 bXAncyAoV29ya3MgYmV0dGVyIGlmIHlvdSBoYXZlIHhkZWJ1ZyBleHRlbnNpb24gaW5zdGFsbGVk KQ0KCS0gTmV3IGNvbmZpZyBzZXR0aW5nIGNhbGxlZDoNCgkJIyBEZWZhdWx0IGJ1ZyBjYXRlZ29y eSBmb3IgbWFpbCByZXBvcnRlZCBidWdzIChEZWZhdWx0cyB0byAiZGVmYXVsdF9idWdfY2F0ZWdv cnkiKQ0KCQkjIEJlY2F1c2UgaW4gTWFudGlzIDEuMS4wYTMgYSBjYXRlZ29yeSBpcyByZXF1aXJl ZCwgd2UgbmVlZCBhIGRlZmF1bHQgY2F0ZWdvcnkgZm9yIGlzc3VlcyByZXBvcnRlZCBieSBlbWFp bC4NCgkJIyBNYWtlIHN1cmUgdGhlIGNhdGVnb3J5IGV4aXN0cyBhbmQgaXQgaGFzIGJlZW4gY29u ZmlndXJlZCBjb3JyZWN0bHkNCgkJJGdfbWFpbF9kZWZhdWx0X2J1Z19jYXRlZ29yeSA9ICclZGVm YXVsdF9idWdfY2F0ZWdvcnklJzsNCgktIEZpeGVkIGEgbWlzc2luZyB2YXJpYWJsZSBpbiB0aGUg ZnVuY3Rpb246ICJtYWlsX3Byb2Nlc3NfYWxsX21haWxzIg0KCQkkdF9tYWlsX2RlYnVnIHdhcyBu b3Qgc2V0IGFuZCB3b3VsZCBjYXVzZSBub3RpY2UgbGV2ZWwgZXJyb3JzIGFuZCBkZWJ1ZyBtb2Rl IGluIHRoaXMgZnVuY3Rpb24gd291bGRuJ3Qgd29yayAoIH4xMzg1NCApDQoJLSBFbWFpbHMgYXJl IG5vdyBub3QgYWxsd2F5cyBzYXZlZCB0byBkaXNrICggfjEzODU0ICkNCgktIE1hZGUgc3VyZSAk dF9tYWlsWydYLU1hbnRpcy1Db21wbGV0ZSddIHdvdWxkIGFsbHdheXMgYmUgcG9wdWxhdGVkICgg d2l0aCBudWxsIHZhbHVlIGlmIHRoZSBjb25maWcgIm1haWxfYWRkaXRpb25hbCIgd2FzIGRpc2Fi bGVkICkNCgktIEFkZGluZyBhdHRhY2htZW50cyB0byBidWcgaXRlbXMgbm93IGFsc28gd29ya3Mg b24gV2luZG93cyBzeXN0ZW1zIChSZW1vdmVkIGhhcmRjb2RlZCBkaXJlY3RvcnkgcGFydCAiL3Rt cC8iKS4NCgktIFRoZSBzdWJqZWN0IG9mIGFuIGVtYWlsIGlzIG5vdyBhbHNvIHRyaW1tZWQgYmVm b3JlIHN0b3JpbmcgaXQgaW4gJHRfYnVnX2RhdGEtPnN1bW1hcnkuIExpa2UgaXQgaXMgaW4gYnVn X3JlcG9ydC5waHANCgktIEZpeGVkIHByb2JsZW0gd2l0aCBkdXBsaWNhdGUgYXR0YWNobWVudHMg KCB+MTQyNTUgYW5kIH4xNDI1NiApDQpBdWcgMjAwNg0KCS0gdXBkYXRlIHRvIE1hbnRpcyAxLjAu NQ0KCS0gbWFpbCBwYXJzaW5nIGNvbXBsZXRlbHkgcmV3cml0dGVuDQoJLSBpbmNsdWRlIGFkZGl0 aW9uYWwgcGF0Y2hlcyBzdWJtaXR0ZWQgYnkNCgkJLSBjYXMgKGhhbmRsaW5nIG9mIGF0dGFjaG1l bnRzIGFuZCBlbXB0eSBmaWVsZHMpDQoJCSAgbWFpbF9hZGRfZmlsZSBpbiBjb3JlL21haWwuYXBp DQoJCSAgbWFpbF9hZGRfYnVnIGluIGNvcmUvbWFpbC5hcGkNCk1heSAyMDA2DQoJLSB1cGRhdGUg dG8gTWFudGlzIDEuMC4zDQoJLSBhZGRlZCBzdXBwb3J0IGZvciBIVE1MIG1haWwNCgktIGFkZGVk IHN1cHBvcnQgZm9yIGVuY29kZWQgbWFpbCBib2RpZXMgYW5kIHN1YmplY3RzDQoJLSBjaGFuZ2Vk IGhhbmRsaW5nIG9mIG1haWwNCgktIHRoZSBnbG9iYWwgbWFpbF9kZWJ1ZyBjb25maWd1cmF0aW9u IG9wdGlvbiBpcyBub3cgc2V0IE9GRiBieSBkZWZhdWx0DQoJLSBpbmNsdWRlIHRoZSBhZGRpdGlv bmFsIHBhdGNoZXMgc3VibWl0dGVkIGJ5DQoJCS0gRUJZIChzdXBwb3J0IGZvciBwcmlvcml0aWVz IGFuZCBmaWxlIHVwbG9hZHMpDQoJCSAgZmlsZV9hZGQgaW4gY29yZS9maWxlX2FwaS5waHANCgkJ ICBtYWlsX3BhcnNlX2NvbnRlbnQgaW4gY29yZS9tYWlsX2FwaS5waHANCgkJICBjb25maWdfZGVm YXVsdHNfaW5jLnBocA0KRGVjIDIwMDUNCgktIHVwZGF0ZSB0byBNYW50aXMgMS4wLjByYzQNCgkt IHVwZGF0ZSB0byBNYW50aXMgMC4xOS40DQpPY3QgMjAwNQ0KCS0gdXBkYXRlIHRvIE1hbnRpcyAx LjAuMHJjMw0KCS0gdXBkYXRlIHRvIE1hbnRpcyAwLjE5LjMNClNlcCAyMDA1Og0KCS0gdXBkYXRl IHRvIE1hbnRpcyAxLjAuMHJjMg0KCS0gZml4ZWQgYSBidWcgaW4gZ2V0dGluZyBhbGwgY2F0ZWdv cmllcyBmb3IgYSBwcm9qZWN0DQoJCWNhdGVnb3J5X2dldF9hbGxfcm93cyBpbiBjb3JlL2NhdGVn b3J5X2FwaS5waHANCkF1ZyAyMDA1Og0KCS0gdXBkYXRlIHRvIE1hbnRpcyAxLjAuMHJjMQ0KCS0g aW5jbHVkZSB0aGUgYWRkaXRpb25hbCBwYXRjaGVzIHN1Ym1pdHRlZCBieSAgICAgIA0KCQktIGdl cm5vdCAoRml4ZWQgTUlNRSBoYW5kbGluZyBhbmQgc2F2ZSB0aGUgbWFpbCdzIHNlbmRlcikNCgkJ ICBtYWlsX2dldF9hbGxfbWFpbHMgaW4gY29yZS9tYWlsX2FwaS5waHANCgkJICBtYWlsX3BhcnNl X2NvbnRlbnQgaW4gY29yZS9tYWlsX2FwaS5waHANCgkJICBtYWlsX2FkZF9idWcgaW4gY29yZS9t YWlsX2FwaS5waHANCgkJLSBzdGV2ZW5jIChGaXhlZCBNSU1FIGhhbmRsaW5nKQ0KCQkgIG1haWxf cGFyc2VfY29udGVudCBpbiBjb3JlL21haWxfYXBpLnBocA0KCQktIHJhaW5tYW4gKEZpeGVkIGVt cHR5IGZpbGVzIGJ1ZyBhbmQgcmVnZXggZm9yIGZpbmRpbmcgYSBidWcgaWQpDQoJCSAgbWFpbF9h ZGRfZmlsZSBpbiBjb3JlL21haWxfYXBpLnBocA0KCQkgIG1haWxfZ2V0X2J1Z19pZF9mcm9tX3N1 YmplY3QgaW4gY29yZS9tYWlsX2FwaS5waHANCkRlYyAyMDA0Og0KCS0gdXBkYXRlIHRvIE1hbnRp cyAwLjE5LjINCgktIGFkZCBjb25maWc6IGdfbWFpbF9wYXJzZV9taW1lDQoJLSBhZGQgY29uZmln OiBnX21haWxfYWRkaXRpb25hbA0KCS0gYWRkIGNvbmZpZzogZ19tYWlsX2ZldGNoX21heA0KCS0g bWFrZSBpdCB3b3JraW5nIHZpYSBDTEkNCk5vdiAyMDA0Og0KCS0gdXBkYXRlIHRvIE1hbnRpcyAw LjE5LjENCgktIGFkZCBzdXBwb3J0IGZvciBNSU1FIGRlY29kaW5nDQpTZXAgMjAwNDoNCgktIHVw ZGF0ZSB0byBNYW50aXMgMC4xOS4wDQpBdWcgMjAwNDoNCgktIGNyZWF0ZSBwYXRjaCBmb3IgTWFu dGlzIDAuMTguMw0KDQo= ------=_NextPart_000_00BE_01C86E21.F267BC80-- recmail.patch (3,954 bytes)
diff -ur Recmail-orig/pages/recmail_add.php Recmail/pages/recmail_add.php --- Recmail-orig/pages/recmail_add.php 2009-02-10 16:58:06.000000000 +0530 +++ Recmail/pages/recmail_add.php 2009-02-10 16:59:40.000000000 +0530 @@ -1,6 +1,6 @@ <?php $t_plugin_path = config_get( 'plugin_path' ); -require_once( $t_plugin_path . 'Recmail\api\mail_api.php' ); +require_once( $t_plugin_path . 'Recmail/api/mail_api.php' ); # Update mailbox $f_mailbox_name = gpc_get_string( 'mailbox_name' ); $f_pop3_host = gpc_get_string( 'mail_pop3_host' ); @@ -29,4 +29,4 @@ echo '</div>'; html_page_bottom1(); } -?> \ No newline at end of file +?> diff -ur Recmail-orig/pages/recmail_delete.php Recmail/pages/recmail_delete.php --- Recmail-orig/pages/recmail_delete.php 2009-02-10 16:58:06.000000000 +0530 +++ Recmail/pages/recmail_delete.php 2009-02-10 17:00:20.000000000 +0530 @@ -1,8 +1,8 @@ <?php $t_plugin_path = config_get( 'plugin_path' ); -require_once( $t_plugin_path . 'Recmail\api\mail_api.php' ); +require_once( $t_plugin_path . 'Recmail/api/mail_api.php' ); $f_box_id = gpc_get_int( 'mailbox_id' ); $query = "delete from $g_mantis_recmail_table where mailbox_id=$f_box_id limit 1 "; $result = db_query( $query ); print_successful_redirect( plugin_page( 'setpop',TRUE ) ); -?> \ No newline at end of file +?> diff -ur Recmail-orig/pages/recmail_edit_page.php Recmail/pages/recmail_edit_page.php --- Recmail-orig/pages/recmail_edit_page.php 2009-02-10 16:58:06.000000000 +0530 +++ Recmail/pages/recmail_edit_page.php 2009-02-10 16:59:00.000000000 +0530 @@ -18,7 +18,7 @@ html_page_top2(); $t_plugin_path = config_get( 'plugin_path' ); -require_once( $t_plugin_path . 'Recmail\api\mail_api.php' ); +require_once( $t_plugin_path . 'Recmail/api/mail_api.php' ); print_manage_menu(); diff -ur Recmail-orig/pages/recmail_update.php Recmail/pages/recmail_update.php --- Recmail-orig/pages/recmail_update.php 2009-02-10 16:58:06.000000000 +0530 +++ Recmail/pages/recmail_update.php 2009-02-10 16:58:34.000000000 +0530 @@ -1,6 +1,6 @@ <?php $t_plugin_path = config_get( 'plugin_path' ); -require_once( $t_plugin_path . 'Recmail\api\mail_api.php' ); +require_once( $t_plugin_path . 'Recmail/api/mail_api.php' ); # Update mailbox $f_mailbox_name = gpc_get_string( 'mailbox_name' ); $f_pop3_host = gpc_get_string( 'pop3_host' ); @@ -10,4 +10,4 @@ $query = "update $g_mantis_recmail_table set mailbox_name='$f_mailbox_name', pop3_host='$f_pop3_host', pop3_user='$f_pop3_user', pop3_pass='$f_pop3_pass' where mailbox_id=$f_box_id"; $results = mysql_query( $query ); print_successful_redirect( plugin_page( 'setpop',TRUE ) ); -?> \ No newline at end of file +?> diff -ur Recmail-orig/pages/recmail_verify.php Recmail/pages/recmail_verify.php --- Recmail-orig/pages/recmail_verify.php 2009-02-10 16:58:06.000000000 +0530 +++ Recmail/pages/recmail_verify.php 2009-02-10 17:00:47.000000000 +0530 @@ -1,6 +1,6 @@ <?php $t_plugin_path = config_get( 'plugin_path' ); -require_once( $t_plugin_path . 'Recmail\api\mail_api.php' ); +require_once( $t_plugin_path . 'Recmail/api/mail_api.php' ); $f_mailbox_id = gpc_get_int( 'mailbox_id' ); @@ -44,4 +44,4 @@ } else{ print_successful_redirect( plugin_page( 'setpop',TRUE ) ); } -?> \ No newline at end of file +?> diff -ur Recmail-orig/pages/setpop.php Recmail/pages/setpop.php --- Recmail-orig/pages/setpop.php 2009-02-10 16:58:06.000000000 +0530 +++ Recmail/pages/setpop.php 2009-02-10 17:00:02.000000000 +0530 @@ -5,7 +5,7 @@ html_page_top2(); $t_plugin_path = config_get( 'plugin_path' ); -require_once( $t_plugin_path . 'Recmail\api\mail_api.php' ); +require_once( $t_plugin_path . 'Recmail/api/mail_api.php' ); print_manage_menu(); ?> @@ -147,4 +147,4 @@ </div> <?php # Edit/Delete ext_db Form END ?> -<?php html_page_bottom1( __FILE__ ) ?> \ No newline at end of file +<?php html_page_bottom1( __FILE__ ) ?> recmail_reply_attach.patch (1,725 bytes)
diff -ubr Recmail/api/mail_api.php Recmail.new/api/mail_api.php --- Recmail/api/mail_api.php 2009-01-21 20:34:52.000000000 -0500 +++ Recmail.new/api/mail_api.php 2009-02-18 21:32:22.000000000 -0500 @@ -162,12 +162,15 @@ # -------------------- # return true if there is a valid mantis bug referernce in subject function mail_is_a_bugnote ( $p_mail_subject ) { - if ( preg_match("/\[([A-Za-z0-9-_\. ]*\s[0-9]{1,7})\]/", $p_mail_subject) && bug_exists( $t_bug_id )){ - $t_bug_id = mail_get_bug_id_from_subject( $p_mail['Subject'] ); + if (preg_match("/\[([A-Za-z0-9-_\. ]*\s([0-9]{1,7}))\]/", $p_mail_subject, $v_matches)) { + $t_bug_title = $v_matches[1]; + $t_bug_id = $v_matches[2]; + if (bug_exists( $t_bug_id )) { + return true; + //$t_bug_id = mail_get_bug_id_from_subject( $p_mail_['Subject'] ); } - else{ - return false; } + return false; } # -------------------- @@ -223,7 +226,8 @@ # Handle the file upload $GLOBALS['_mail_file_'] = $p_part['name']; if ( 0 < strlen($p_part['name']) ) { - $t_file_name = ini_get( 'upload_tmp_dir' ) . '/' . $p_part['name']; + #$t_file_name = ini_get( 'upload_tmp_dir' ) . '/' . $p_part['name']; + $t_file_name = plugin_config_get( 'mail_tmp_directory' ) . '/' . $p_part['name']; $t_method = config_get( 'file_upload_method' ); file_put_contents($t_file_name, $p_part['body']); mail_file_add($p_bug_id, realpath( $t_file_name ), $number."-".$p_part['name'], $p_part['ctype'], 'bug'); @@ -298,10 +302,7 @@ } } else { # Create the bug - - $t_bug_id = bug_create( $t_bug_data ); - email_new_bug( $t_bug_id ); } reject-mail.patch (6,313 bytes)
diff -rb Recmail095a/Recmail.php Recmail.new/Recmail.php 24c24 < 'mail_auto_signup' => OFF, --- > 'mail_unknown_address' => 'fallback', 36a37 > 'mail_rejection_notice' => lang_get( 'mail_rejection_notice_default' ), diff -rb Recmail095a/Recmail_api.php Recmail.new/Recmail_api.php 68c68,77 < mail_add_bug( $t_mail, $proj,$cat ); --- > > $t_reporter_id = mail_get_user( $t_mail['From'] ); > if ($t_reporter_id == 0) { > // Reject the unknown sender > mail_reject_unknown( $t_mail ); > } else { > // Proceed normally > mail_add_bug( $t_mail, $proj, $cat, $t_reporter_id ); > } > 179c188,190 < $t_mail_auto_signup = plugin_config_get( 'mail_auto_signup' ); --- > $t_mail_auto_signup = (plugin_config_get( 'mail_unknown_address' ) == 'signup'); > $t_mail_auto_fallback = (plugin_config_get( 'mail_unknown_address' ) == 'fallback'); > $t_mail_auto_reject = (plugin_config_get( 'mail_unknown_address' ) == 'reject'); 199a211,215 > } elseif ( ! $t_reporter_id && $t_mail_auto_reject ) { > // Reject the unknown mail > echo "Rejected unknown sender: $v_mailaddress<br />"; > return 0; > 243c259,265 < function mail_add_bug ( &$p_mail,$proj ,$cat ) { --- > function mail_add_bug ( &$p_mail,$proj, $cat, $reporter_id = -1 ) { > if ($reporter_id == -1) { > $t_bug_data->reporter_id = mail_get_user( $p_mail['From'] ); > } else { > $t_bug_data->reporter_id = $reporter_id; > } > 280,281d301 < $t_bug_data->reporter_id = mail_get_user( $p_mail['From'] ); < 287c307,308 < email_bugnote_add ( $t_bug_id ); --- > //// bugnote_add() already sent the email > //email_bugnote_add ( $t_bug_id ); 442a464,476 > > > # Send a rejection notice to the unrecognized sender. > function mail_reject_unknown( $p_mail ) { > $t_recipient = mail_parse_address($p_mail['From']); > $t_subject = 're: '.$p_mail['Subject']; > $t_message = plugin_config_get( 'mail_rejection_notice' ); > $t_message = str_replace('#address#', $t_recipient, $t_message); > > email_store( $t_recipient, $t_subject, $t_message ); > } > > diff -rb Recmail095a/lang/strings_english.txt Recmail.new/lang/strings_english.txt 7a8 > $s_mail_unknown_address = 'How to handle mail from unknown addresses (see Doc)'; 8a10,11 > $s_mail_auto_fallback = 'Use default reporting account'; > $s_mail_auto_reject = 'Reject'; 41a45,46 > $s_mail_rejection_notice = 'Mail Rejection Notice'; > $s_mail_rejection_notice_default= 'Our Mantis bug tracking system has received an email from your address. Normally the system would automatically add a new bug report using the email, but we are sorry that we do not recognize your email address of #address#. It is necessary that you use the same address that is in your Mantis user account. You may log in to our Mantis website and update your email address there, so that the system can properly accept emails from you in the future. Thank you.'; \ No newline at end of file diff -rb Recmail095a/pages/bug_report_mail.php Recmail.new/pages/bug_report_mail.php 17c17 < header("Content-type: text/plain"); --- > //header("Content-type: text/plain"); 23a24,26 > > plugin_push_current( 'Recmail' ); > diff -rb Recmail095a/pages/checkuser.php Recmail.new/pages/checkuser.php 13c13 < $mail .="@recmail.com"; --- > $mail .="@example.com"; diff -rb Recmail095a/pages/config.php Recmail.new/pages/config.php 59,63c59 < <?php echo lang_get( 'mail_auto_signup' ) ?> < </td> < <td class="center" width="20%"> < <label><input type="radio" name="mail_auto_signup" value="1" <?php echo ( ON == plugin_config_get( 'mail_auto_signup' ) ) ? 'checked="checked" ' : ''?>/> < <?php echo lang_get( 'mail_format_enabled' ) ?></label> --- > <?php echo lang_get( 'mail_unknown_address' ) ?> 64a61 > 66,67c63,88 < <label><input type="radio" name="mail_auto_signup" value="0" <?php echo ( OFF == plugin_config_get( 'mail_auto_signup' ) ) ? 'checked="checked" ' : ''?>/> < <?php echo lang_get( 'mail_format_disabled' ) ?></label> --- > <?php > if (!$t_mail_auto_signup_default = plugin_config_get('mail_unknown_address')) { > if (ON == plugin_config_get( 'mail_auto_signup' )) { > $t_mail_auto_signup_default = 'signup'; > } else { > $t_mail_auto_signup_default = 'fallback'; > } > } > $t_options = array( > 'signup' => lang_get( 'mail_auto_signup' ), > 'fallback' => lang_get( 'mail_auto_fallback' ), > 'reject' => lang_get( 'mail_auto_reject' ), > ); > ?> > <label><select name="mail_unknown_address"> > <?php > foreach ($t_options as $t_key => $t_val) { > echo '<option value="'.$t_key.'"'; > if ($t_key == $t_mail_auto_signup_default) { > echo ' selected'; > } > echo '>'.$t_val.'</option>'; > } > ?> > </select></label> > 68a90 > <td></td> 287c309,318 < --- > <tr <?php echo helper_alternate_class() ?>> > <td class="category" width="60%"> > <?php echo lang_get( 'mail_rejection_notice' ) ?> > </td> > <td class="center" colspan="2"> > <textarea name="mail_rejection_notice" rows="10" cols="60"><?php > echo str_replace('"', '"', plugin_config_get( 'mail_rejection_notice' )); > ?></textarea> > </td> > </tr> diff -rb Recmail095a/pages/config_edit.php Recmail.new/pages/config_edit.php 7c7 < $f_mail_auto_signup = gpc_get_int('mail_auto_signup', OFF); --- > $f_mail_unknown_address = gpc_get_string('mail_unknown_address', 'fallback'); 19a20 > $f_mail_rejection_notice = gpc_get_string('mail_rejection_notice', lang_get('mail_rejection_notice_default')); 28c29,30 < plugin_config_set('mail_auto_signup' , $f_mail_auto_signup); --- > //plugin_config_set('mail_auto_signup' , $f_mail_auto_signup); > plugin_config_set('mail_unknown_address' , $f_mail_unknown_address); 40a43 > plugin_config_set('mail_rejection_notice' , $f_mail_rejection_notice); Only in Recmail.new/pages: error_log diff -rb Recmail095a/pages/setpop.php Recmail.new/pages/setpop.php 76c76 < <input type="text" name="mail_pop3_host" size="30" maxlength="30" /> --- > <input type="text" name="mail_pop3_host" size="30" maxlength="50" /> obones_feature_branch.patch (21,367 bytes)
From 316d2b9ed4390660d1a9a59da213a3c17840f3a9 Mon Sep 17 00:00:00 2001 From: unknown <o.sannier@.siege.ldlc.com> Date: Wed, 24 Mar 2010 10:18:53 +0100 Subject: [PATCH 1/4] Add the "category by subject" management --- core/mail_api.php | 10 +++ lang/strings_english.txt | 1 + pages/maintainmailbox.php | 34 +++++++++++ pages/maintainmailbox_edit.php | 127 ++++++++++++++++++++++++---------------- 4 files changed, 122 insertions(+), 50 deletions(-) diff --git a/core/mail_api.php b/core/mail_api.php index cc76985..c36f8f8 100644 --- a/core/mail_api.php +++ b/core/mail_api.php @@ -724,6 +724,16 @@ $t_bug_data->view_state = gpc_get_int( 'view_state', config_get( 'default_bug_view_status' ) ); $t_bug_data->category_id = gpc_get_int( 'category_id', $p_mailbox[ 'mailbox_global_category' ] ); + + foreach ($p_mailbox[ 'mailbox_keyword_categories' ] as $expression_pair) + { + if (preg_match($expression_pair[ 'expression' ], $p_mail[ 'Subject' ]) == 1) + { + $t_bug_data->category_id = $expression_pair[ 'category' ]; + } + } + + $t_bug_data->reproducibility = config_get( 'default_bug_reproducibility', 10 ); $t_bug_data->severity = config_get( 'default_bug_severity', 50 ); $t_bug_data->priority = $p_mail[ 'Priority' ]; diff --git a/lang/strings_english.txt b/lang/strings_english.txt index f6a2809..7e60b90 100644 --- a/lang/strings_english.txt +++ b/lang/strings_english.txt @@ -61,6 +61,7 @@ $s_plugin_EmailReporting_mailbox_basefolder = 'Mailbox basefolder (IMAP)'; $s_plugin_EmailReporting_mailbox_createfolderstructure = 'Create project subfolder structure (IMAP)'; $s_plugin_EmailReporting_mailbox_project = 'Select a project (N/A if above is set to "yes")'; $s_plugin_EmailReporting_mailbox_global_category = 'Select a global category'; +$s_plugin_EmailReporting_mailbox_keyword_categories = 'Indicate your regular expression / category pairs (see <a href="http://www.php.net/manual/en/function.preg-match.php">preg_match</a> for details)'; $s_plugin_EmailReporting_unknown_setting = 'Unknown setting encountered. Setting ignored'; $s_plugin_EmailReporting_missing_reporter = 'Please select a user account'; diff --git a/pages/maintainmailbox.php b/pages/maintainmailbox.php index 1b7ce01..076ce38 100644 --- a/pages/maintainmailbox.php +++ b/pages/maintainmailbox.php @@ -84,6 +84,11 @@ $t_config_array = array( 'type' => 'dropdown_global_categories', 'value' => '', ), + array( + 'name' => 'mailbox_keyword_categories', + 'type' => 'list_keywords_categories', + 'value' => '', + ) ); foreach( $t_config_array AS $t_config ) @@ -233,6 +238,35 @@ foreach( $t_config_array AS $t_config ) </tr> <?php break; + + case 'list_keywords_categories': +?> +<tr <?php echo helper_alternate_class( )?>> + <td class="category" width="60%"> + <?php echo plugin_lang_get( $t_config[ 'name' ] )?> + </td> + <td class="center" width="40%" colspan="2"> + <?php + if (is_array($t_config[ 'value' ])) + { + $i = 0; + foreach ($t_config[ 'value' ] as $expression_pair) + { + echo "<label><input type=\"text\" size=\"25\" maxlength=\"50\" name=\"".$t_config[ 'name' ]."_expression_".$i."\" value=\"". $expression_pair[ 'expression' ]."\"/></label>"; + echo "<label><select name=\"".$t_config[ 'name' ]."_category_".$i."\"> "; + print_category_option_list( $expression_pair[ 'category' ], ALL_PROJECTS ); + echo "</select></label>\n"; + ++$i; + } + } + ?> + + <label><input type="text" size="25" maxlength="50" name="<?php echo $t_config[ 'name' ] ?>_expression_new" value=""/></label><label><select name="<?php echo $t_config[ 'name' ] ?>_category_new"> <?php print_category_option_list('', ALL_PROJECTS ) ?></select></label> + </td> +</tr> +<?php + break; + default: echo '<tr><td colspan="3">' . plugin_lang_get( 'unknown_setting' ) . '</td></tr>'; } } diff --git a/pages/maintainmailbox_edit.php b/pages/maintainmailbox_edit.php index 9f57174..94fa9f3 100644 --- a/pages/maintainmailbox_edit.php +++ b/pages/maintainmailbox_edit.php @@ -9,81 +9,108 @@ $t_mailboxes = plugin_config_get( 'mailboxes' ); if ( $f_mailbox_action === 'add' || ( ( $f_mailbox_action === 'edit' || $f_mailbox_action === 'test' ) && $f_select_mailbox >= 0 ) ) { - $t_mailbox = array( - 'mailbox_description' => gpc_get_string( 'mailbox_description' ), - 'mailbox_type' => gpc_get_string( 'mailbox_type', 'POP3' ), - 'mailbox_hostname' => gpc_get_string( 'mailbox_hostname' ), - 'mailbox_encryption' => gpc_get_string( 'mailbox_encryption', 'None' ), - 'mailbox_username' => gpc_get_string( 'mailbox_username' ), - 'mailbox_password' => base64_encode( gpc_get_string( 'mailbox_password' ) ), - 'mailbox_auth_method' => gpc_get_string( 'mailbox_auth_method', 'USER' ), - 'mailbox_basefolder' => trim( str_replace( '\\', '/', gpc_get_string( 'mailbox_basefolder', '' ) ), '/ ' ), - 'mailbox_createfolderstructure' => gpc_get_bool( 'mailbox_createfolderstructure', OFF ), - 'mailbox_project' => gpc_get_int( 'mailbox_project' ), - 'mailbox_global_category' => gpc_get_int( 'mailbox_global_category' ), - ); + $t_mailbox = array( + 'mailbox_description' => gpc_get_string( 'mailbox_description' ), + 'mailbox_type' => gpc_get_string( 'mailbox_type', 'POP3' ), + 'mailbox_hostname' => gpc_get_string( 'mailbox_hostname' ), + 'mailbox_encryption' => gpc_get_string( 'mailbox_encryption', 'None' ), + 'mailbox_username' => gpc_get_string( 'mailbox_username' ), + 'mailbox_password' => base64_encode( gpc_get_string( 'mailbox_password' ) ), + 'mailbox_auth_method' => gpc_get_string( 'mailbox_auth_method', 'USER' ), + 'mailbox_basefolder' => trim( str_replace( '\\', '/', gpc_get_string( 'mailbox_basefolder', '' ) ), '/ ' ), + 'mailbox_createfolderstructure' => gpc_get_bool( 'mailbox_createfolderstructure', OFF ), + 'mailbox_project' => gpc_get_int( 'mailbox_project' ), + 'mailbox_global_category' => gpc_get_int( 'mailbox_global_category' ), + 'mailbox_keyword_categories' => array(), + ); + + // Add existing pairs, only if they are filled in + $i = 0; + while (gpc_get_string('mailbox_keyword_categories_expression_'.$i, null) != null) + { + $expression = gpc_get_string('mailbox_keyword_categories_expression_'.$i); + if (!empty($expression)) + { + array_push($t_mailbox['mailbox_keyword_categories'], array('expression' => $expression, + 'category' => gpc_get_int('mailbox_keyword_categories_category_'.$i) + ) + ); + } + + ++$i; + } + + // Add a new pair, if filled in + $expression = gpc_get_string('mailbox_keyword_categories_expression_new'); + if (!empty($expression)) + { + array_push($t_mailbox['mailbox_keyword_categories'], array('expression' => $expression, + 'category' => gpc_get_int('mailbox_keyword_categories_category_new') + ) + ); + } } if ( $f_mailbox_action === 'add' ) { - array_push( $t_mailboxes, $t_mailbox ); + array_push( $t_mailboxes, $t_mailbox ); } elseif ( $f_mailbox_action === 'edit' && $f_select_mailbox >= 0 ) { - $t_mailboxes[ $f_select_mailbox ] = $t_mailbox; + $t_mailboxes[ $f_select_mailbox ] = $t_mailbox; } elseif ( $f_mailbox_action === 'delete' && $f_select_mailbox >= 0 ) { - unset( $t_mailboxes[ $f_select_mailbox ] ); + unset( $t_mailboxes[ $f_select_mailbox ] ); } elseif ( $f_mailbox_action === 'test' && $f_select_mailbox >= 0 ) { - # Verify mailbox - from Recmail by Cas Nuy - require_once( 'mail_api.php' ); + # Verify mailbox - from Recmail by Cas Nuy + require_once( 'mail_api.php' ); - $t_result = mail_process_all_mails( $t_mailbox, true ); + $t_result = mail_process_all_mails( $t_mailbox, true ); - if ( ( is_array( $t_result ) && $t_result[ 'ERROR_TYPE' ] === 'NON-PEAR-ERROR' ) || PEAR::isError( $t_result ) ) - { - $t_no_redirect = true; + if ( ( is_array( $t_result ) && $t_result[ 'ERROR_TYPE' ] === 'NON-PEAR-ERROR' ) || PEAR::isError( $t_result ) ) + { + $t_no_redirect = true; - html_page_top1(); - html_page_top2(); + html_page_top1(); + html_page_top2(); ?> <br /><div class="center"> - <?php echo plugin_lang_get( 'test_failure' ); ?> - <br><br> - <?php echo plugin_lang_get( 'mailbox_description' ) . ': ' . $t_mailbox[ 'mailbox_description' ]; ?> - <br> - <?php echo plugin_lang_get( 'mailbox_type' ) . ': ' . $t_mailbox[ 'mailbox_type' ]; ?> - <br> - <?php echo plugin_lang_get( 'mailbox_hostname' ) . ': ' . $t_mailbox[ 'mailbox_hostname' ]; ?> - <br> - <?php echo plugin_lang_get( 'mailbox_encryption' ) . ': ' . $t_mailbox[ 'mailbox_encryption' ]; ?> - <br> - <?php echo plugin_lang_get( 'mailbox_username' ) . ': ' . $t_mailbox[ 'mailbox_username' ]; ?> - <br> - <?php echo plugin_lang_get( 'mailbox_password' ) . ': ******'; ?> - <br> - <?php echo plugin_lang_get( 'mailbox_auth_method' ) . ': ' . $t_mailbox[ 'mailbox_auth_method' ]; ?> - <br> - <?php echo plugin_lang_get( 'mailbox_basefolder' ) . ': ' . $t_mailbox[ 'mailbox_basefolder' ]; ?> - <br><br> - <?php echo ( ( is_array( $t_result ) && $t_result[ 'ERROR_TYPE' ] === 'NON-PEAR-ERROR' ) ? $t_result[ 'ERROR_MESSAGE' ] : $t_result->toString() ); ?> - <br><br> - <?php print_bracket_link( plugin_page( 'maintainmailbox', TRUE ), lang_get( 'proceed' ) ); ?> + <?php echo plugin_lang_get( 'test_failure' ); ?> + <br><br> + <?php echo plugin_lang_get( 'mailbox_description' ) . ': ' . $t_mailbox[ 'mailbox_description' ]; ?> + <br> + <?php echo plugin_lang_get( 'mailbox_type' ) . ': ' . $t_mailbox[ 'mailbox_type' ]; ?> + <br> + <?php echo plugin_lang_get( 'mailbox_hostname' ) . ': ' . $t_mailbox[ 'mailbox_hostname' ]; ?> + <br> + <?php echo plugin_lang_get( 'mailbox_encryption' ) . ': ' . $t_mailbox[ 'mailbox_encryption' ]; ?> + <br> + <?php echo plugin_lang_get( 'mailbox_username' ) . ': ' . $t_mailbox[ 'mailbox_username' ]; ?> + <br> + <?php echo plugin_lang_get( 'mailbox_password' ) . ': ******'; ?> + <br> + <?php echo plugin_lang_get( 'mailbox_auth_method' ) . ': ' . $t_mailbox[ 'mailbox_auth_method' ]; ?> + <br> + <?php echo plugin_lang_get( 'mailbox_basefolder' ) . ': ' . $t_mailbox[ 'mailbox_basefolder' ]; ?> + <br><br> + <?php echo ( ( is_array( $t_result ) && $t_result[ 'ERROR_TYPE' ] === 'NON-PEAR-ERROR' ) ? $t_result[ 'ERROR_MESSAGE' ] : $t_result->toString() ); ?> + <br><br> + <?php print_bracket_link( plugin_page( 'maintainmailbox', TRUE ), lang_get( 'proceed' ) ); ?> </div> <?php - html_page_bottom1(); - } + html_page_bottom1(); + } } if( plugin_config_get( 'mailboxes' ) != $t_mailboxes && ( $f_mailbox_action === 'add' || ( ( $f_mailbox_action === 'edit' || $f_mailbox_action === 'delete' ) && $f_select_mailbox >= 0 ) ) ) { - plugin_config_set( 'mailboxes', $t_mailboxes ); + plugin_config_set( 'mailboxes', $t_mailboxes ); } if ( !isset( $t_no_redirect ) ) { - print_successful_redirect( plugin_page( 'maintainmailbox', true ) ); -} + print_successful_redirect( plugin_page( 'maintainmailbox', true ) ); +} \ No newline at end of file -- 1.7.0.2.msysgit.0 From 4d401197225df12e5b64131c0a9b7bd5121de6d1 Mon Sep 17 00:00:00 2001 From: unknown <o.sannier@.siege.ldlc.com> Date: Mon, 29 Mar 2010 10:59:44 +0200 Subject: [PATCH 2/4] Better Regex for accented characters in project names --- core/mail_api.php | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/mail_api.php b/core/mail_api.php index c36f8f8..e29fcc0 100644 --- a/core/mail_api.php +++ b/core/mail_api.php @@ -454,7 +454,7 @@ # -------------------- # return true if there is a valid mantis bug refererence in subject or return false if not found function mail_is_a_bugnote ( $p_mail_subject ) { - if ( preg_match( "/\[([A-Za-z0-9-_\. ]*\s[0-9]{1,7})\]/", $p_mail_subject ) ){ + if ( preg_match( "/\[([[:alnum:]\p{L}-_\. ]*\s[0-9]{1,7})\]/iu", $p_mail_subject ) ){ $t_bug_id = mail_get_bug_id_from_subject( $p_mail_subject ); if ( bug_exists( $t_bug_id ) && !bug_is_readonly( $t_bug_id ) ){ return true; @@ -467,7 +467,7 @@ # -------------------- # return the bug's id from the subject function mail_get_bug_id_from_subject ( $p_mail_subject ) { - preg_match( "/\[([A-Za-z0-9-_\. ]*\s([0-9]{1,7}?))\]/", $p_mail_subject, $v_matches ); + preg_match( "/\[([[:alnum:]\p{L}-_\. ]*\s([0-9]{1,7}?))\]/iu", $p_mail_subject, $v_matches ); return $v_matches[ 2 ]; } -- 1.7.0.2.msysgit.0 From 3cc04e323a8a692d357d2a4bab4c776f7c0f79dc Mon Sep 17 00:00:00 2001 From: unknown <o.sannier@.siege.ldlc.com> Date: Tue, 6 Apr 2010 12:05:23 +0200 Subject: [PATCH 3/4] Can now use the email as the username (optionally stripping the domain name) and use the previous username as the realname. --- EmailReporting.php | 9 ++++++++- core/mail_api.php | 37 ++++++++++++++++++++++++++++++++----- lang/strings_english.txt | 2 ++ pages/config.php | 8 ++++++++ pages/config_edit.php | 10 ++++++++++ 5 files changed, 60 insertions(+), 6 deletions(-) diff --git a/EmailReporting.php b/EmailReporting.php index 604bd61..3c2bb5e 100644 --- a/EmailReporting.php +++ b/EmailReporting.php @@ -10,7 +10,7 @@ class EmailReportingPlugin extends MantisPlugin { $this->description = plugin_lang_get( 'description' ); $this->page = 'config'; - $this->version = '0.7.9'; + $this->version = '0.7.9-DEV'; $this->requires = array( 'MantisCore' => '1.2', ); @@ -50,6 +50,13 @@ class EmailReportingPlugin extends MantisPlugin { # Default is OFF, if mail_use_reporter is OFF and this is OFF then it will # fallback to the mail_reporter account above 'mail_auto_signup' => OFF, + + # Use the email as a username if auto signing up + 'mail_use_email_as_username' => OFF, + + # Strip the domain name (the part after the @) when using the email as a + # username and auto signing up + 'mail_strip_domain_from_username' => OFF, # How many mails should be fetched at the same time # If big mails with attachments should be received, specify only one diff --git a/core/mail_api.php b/core/mail_api.php index e29fcc0..3c7202a 100644 --- a/core/mail_api.php +++ b/core/mail_api.php @@ -286,7 +286,8 @@ if ( $t_mail_delete ) { - $p_mailbox_connection->deleteMsg( $p_i ); + if (!$p_mailbox_connection->deleteMsg( $p_i )) + echo 'deleteMsg failed'; } } @@ -423,17 +424,33 @@ { $v_mailaddress = array( 'username' => trim( $matches[ 1 ], '"\' ' ), + 'realname' => '', 'email' => trim( $matches[ 2 ] ), ); + + $t_mail_use_email_as_username = plugin_config_get( 'mail_use_email_as_username' ); + $t_mail_strip_domain_from_username = plugin_config_get( 'mail_strip_domain_from_username' ); + + if ($t_mail_use_email_as_username) + { + $v_mailaddress['realname'] = $v_mailaddress['username']; + $email = $v_mailaddress['email']; + + if ($t_mail_strip_domain_from_username) + $v_mailaddress['username'] = substr($email, 0, strpos($email, '@')); + else + $v_mailaddress['username'] = $email; + } } else { $v_mailaddress = array( - 'name' => '', + 'username' => '', + 'realname' => '', 'email' => $p_mailaddress, ); } - + return $v_mailaddress; } @@ -502,11 +519,15 @@ if ( user_is_name_valid( $t_reporter ) && user_is_name_unique( $t_reporter ) ) { - # notify the selected group a new user has signed-up + # notify the selected group a new user has signed-up and set realname if( user_signup( $t_reporter, $v_mailaddress[ 'email' ] ) ) { - email_notify_new_account( $t_reporter, $v_mailaddress[ 'email' ] ); + if (ON == config_get('enable_email_notification')) + email_notify_new_account( $t_reporter, $v_mailaddress[ 'email' ] ); + $t_reporter_id = user_get_id_by_name ( $t_reporter ); + if ($v_mailaddress['realname'] != '') + user_set_realname($t_reporter_id, $v_mailaddress['realname']); } } @@ -698,6 +719,7 @@ $t_resolved = config_get( 'bug_resolved_status_threshold' ); $t_status = bug_get_field( $t_bug_id, 'status' ); + config_set('email_receive_own', ON); if ( $t_resolved <= $t_status ) { # Reopen issue and add a bug note @@ -708,6 +730,8 @@ # Add a bug note bugnote_add( $t_bug_id, $t_description ); } + global $g_email_receive_own; + config_set('email_receive_own', $g_email_receive_own); } else { @@ -763,7 +787,10 @@ # Create the bug $t_bug_id = $t_bug_data->create(); + config_set('email_receive_own', ON); email_new_bug( $t_bug_id ); + global $g_email_receive_own; + config_set('email_receive_own', $g_email_receive_own); } # Add files diff --git a/lang/strings_english.txt b/lang/strings_english.txt index 7e60b90..2bfc623 100644 --- a/lang/strings_english.txt +++ b/lang/strings_english.txt @@ -25,6 +25,8 @@ $s_plugin_EmailReporting_mail_check_timer = 'How often should the mailboxes be c $s_plugin_EmailReporting_mail_use_reporter = 'Use one account for issues created by email'; $s_plugin_EmailReporting_mail_reporter = 'The account name for issues created by email'; $s_plugin_EmailReporting_mail_auto_signup = 'Signup new users automatically (possible security risk!, see documentation)'; +$s_plugin_EmailReporting_mail_use_email_as_username = 'Use email as username'; +$s_plugin_EmailReporting_mail_strip_domain_from_username = 'Strip domain name from username'; $s_plugin_EmailReporting_mail_fetch_max = 'How many emails per mailbox should be fetched every time this script is executed (see documentation)'; $s_plugin_EmailReporting_mail_add_complete_email = 'Add the complete email into the attachments'; $s_plugin_EmailReporting_mail_save_from = 'Write the sender of the message into the issue report'; diff --git a/pages/config.php b/pages/config.php index defac6d..b5fbe17 100644 --- a/pages/config.php +++ b/pages/config.php @@ -68,6 +68,14 @@ $t_config_array = array( 'type' => 'boolean', ), array( + 'name' => 'mail_use_email_as_username', + 'type' => 'boolean', + ), + array( + 'name' => 'mail_strip_domain_from_username', + 'type' => 'boolean', + ), + array( 'name' => 'mail_fetch_max', 'type' => 'integer', ), diff --git a/pages/config_edit.php b/pages/config_edit.php index b68e6a5..ceefe70 100644 --- a/pages/config_edit.php +++ b/pages/config_edit.php @@ -9,6 +9,8 @@ $f_mail_check_timer = gpc_get_int( 'mail_check_timer', 300 ); $f_mail_use_reporter = gpc_get_bool( 'mail_use_reporter', ON ); $f_mail_reporter = gpc_get_string( 'mail_reporter', 'Mail' ); $f_mail_auto_signup = gpc_get_bool( 'mail_auto_signup', OFF ); +$f_mail_use_email_as_username = gpc_get_bool('mail_use_email_as_username', OFF); +$f_mail_strip_domain_from_username = gpc_get_bool('mail_strip_domain_from_username', OFF); $f_mail_fetch_max = gpc_get_int( 'mail_fetch_max', 1 ); $f_mail_add_complete_email = gpc_get_bool( 'mail_add_complete_email', OFF ); $f_mail_save_from = gpc_get_bool( 'mail_save_from', OFF ); @@ -73,6 +75,14 @@ if( plugin_config_get( 'mail_auto_signup' ) != $f_mail_auto_signup ) { plugin_config_set( 'mail_auto_signup', $f_mail_auto_signup ); } +if( plugin_config_get( 'mail_use_email_as_username', false ) != $f_mail_use_email_as_username ) { + plugin_config_set( 'mail_use_email_as_username', $f_mail_use_email_as_username ); +} + +if( plugin_config_get( 'mail_strip_domain_from_username', false ) != $f_mail_strip_domain_from_username ) { + plugin_config_set( 'mail_strip_domain_from_username', $f_mail_strip_domain_from_username ); +} + if( plugin_config_get( 'mail_fetch_max' ) != $f_mail_fetch_max ) { plugin_config_set( 'mail_fetch_max', $f_mail_fetch_max ); } -- 1.7.0.2.msysgit.0 From 68bd57285282e4800e5b56b05fd7c2b93e597692 Mon Sep 17 00:00:00 2001 From: unknown <o.sannier@.siege.ldlc.com> Date: Tue, 6 Apr 2010 14:24:08 +0200 Subject: [PATCH 4/4] Disable the signup email, it never finishes and prevents the rest of the code to work --- core/mail_api.php | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/mail_api.php b/core/mail_api.php index 3c7202a..407cca9 100644 --- a/core/mail_api.php +++ b/core/mail_api.php @@ -522,8 +522,8 @@ # notify the selected group a new user has signed-up and set realname if( user_signup( $t_reporter, $v_mailaddress[ 'email' ] ) ) { - if (ON == config_get('enable_email_notification')) - email_notify_new_account( $t_reporter, $v_mailaddress[ 'email' ] ); +// if (ON == config_get('enable_email_notification')) +// email_notify_new_account( $t_reporter, $v_mailaddress[ 'email' ] ); $t_reporter_id = user_get_id_by_name ( $t_reporter ); if ($v_mailaddress['realname'] != '') -- 1.7.0.2.msysgit.0 events.patch (5,650 bytes)
Index: core/config_api.php =================================================================== --- core/config_api.php (revision 994) +++ core/config_api.php (working copy) @@ -164,7 +164,14 @@ ?> <tr <?php echo helper_alternate_class( )?>> <td class="category" width="60%"> - <?php echo plugin_lang_get( $p_name )?> + <?php + $plugin_name = event_signal('EVENT_ERP_GET_EXTRA_FIELD_NAME', $p_name); + if ($plugin_name != null) + echo $plugin_name; + else + echo plugin_lang_get( $p_name ); + + ?> </td> <?php switch ( $p_type ) @@ -439,7 +446,19 @@ <?php break; - default: echo '<tr><td colspan="3">' . plugin_lang_get( 'unknown_setting' ) . $p_name . ' -> level 1</td></tr>'; + default: + $plugin_name = event_signal('EVENT_ERP_GET_EXTRA_FIELD_NAME', $p_name); + if ($plugin_name != null) + { + echo '<tr '.helper_alternate_class( ).'>'; + echo '<td class="category" width="60%">'.$plugin_name.'</td>'; + echo event_signal('EVENT_ERP_OUTPUT_EXTRA_FIELD_TYPE', array($p_name, $p_type, $t_value)); + echo '</tr>'; + } + else + { + echo '<tr><td colspan="3">' . plugin_lang_get( 'unknown_setting' ) . $p_name . ' -> level 1</td></tr>'; + } } } Index: core/mail_api.php =================================================================== --- core/mail_api.php (revision 994) +++ core/mail_api.php (working copy) @@ -592,6 +592,8 @@ $t_status = bug_get_field( $t_bug_id, 'status' ); + $t_description = event_signal( 'EVENT_ERP_PROCESS_BUGNOTE_DATA', $t_description, array($p_email, $this->_mailbox) ); + if ( $this->_bug_resolved_status_threshold <= $t_status ) { # Reopen issue and add a bug note @@ -662,6 +664,7 @@ # Allow plugins to pre-process bug data $t_bug_data = event_signal( 'EVENT_REPORT_BUG_DATA', $t_bug_data ); + $t_bug_data = event_signal( 'EVENT_ERP_PROCESS_BUG_DATA', $t_bug_data, array($p_email, $this->_mailbox) ); # Create the bug $t_bug_id = $t_bug_data->create(); Index: EmailReporting.php =================================================================== --- EmailReporting.php (revision 995) +++ EmailReporting.php (working copy) @@ -215,6 +215,46 @@ } } + function events() { + return array( + # Allow other plugins to process bugdata before the bug is added + # Parameters are BugData, Email details array, Mailbox data + # Result is BugData + 'EVENT_ERP_PROCESS_BUG_DATA' => EVENT_TYPE_CHAIN, + + # Allow other plugins to process bugnote data before the bug is added + # Parameters are bugnote text, Email details array, Mailbox data + # Result is bugnote text + 'EVENT_ERP_PROCESS_BUGNOTE_DATA' => EVENT_TYPE_CHAIN, + + # Allow other plugins to add configuration elements in the form displayed + # by manage_mailbox.php in the mailbox_settings_issue section + # Parameters are extra fields from other plugins and mailbox data (value of $t_mailbox) + # Result is an array of key/value pairs used as the first two parameters + # in a call to ERP_output_config_options + 'EVENT_ERP_GET_EXTRA_MAILBOX_SETTINGS_ISSUE_FIELDS' => EVENT_TYPE_CHAIN, + + # Allow other plugins to add elements in the mailbox data that is saved in the config + # Parameters are extra data from other plugins and Mailbox data from manage_mailbox_edit.php + # Result is Mailbox data + 'EVENT_ERP_GET_EXTRA_MAILBOX_DATA' => EVENT_TYPE_CHAIN, + + # Allow other plugins to give the name for an extra field added via the + # EVENT_ERP_GET_EXTRA_MAILBOX_SETTINGS_ISSUE_FIELDS event + # Parameter is the name of the extra field + # Result is the displayable string as returned by plugin_lang_get + 'EVENT_ERP_GET_EXTRA_FIELD_NAME' => EVENT_TYPE_FIRST, + + # Allow other plugins to output the input HTML elements for a specific type + # as given for an extra field added via the + # EVENT_ERP_GET_EXTRA_MAILBOX_SETTINGS_ISSUE_FIELDS event + # Parameters are the name, the type and the value of the extra field + # Result is the HTML code that will be displayed on the right part of the table + # and must include the <td></td> tags + 'EVENT_ERP_OUTPUT_EXTRA_FIELD_TYPE' => EVENT_TYPE_FIRST, + ); + } + /** * EmailReporting plugin hooks. */ Index: pages/manage_mailbox.php =================================================================== --- pages/manage_mailbox.php (revision 994) +++ pages/manage_mailbox.php (working copy) @@ -73,6 +73,14 @@ ERP_output_config_option( 'mailbox_project_id', 'dropdown_projects', -3, $t_mailbox ); ERP_output_config_option( 'mailbox_global_category_id', 'dropdown_global_categories', -3, $t_mailbox ); +$extra_fields = event_signal('EVENT_ERP_GET_EXTRA_MAILBOX_SETTINGS_ISSUE_FIELDS', null, $t_mailbox); + +if (is_array($extra_fields)) +{ + foreach ($extra_fields as $field_id => $field_type_id) + ERP_output_config_option( $field_id, $field_type_id, -3, $t_mailbox ); +} + ERP_output_config_option( $f_mailbox_action . '_mailbox', 'submit' ); ?> Index: pages/manage_mailbox_edit.php =================================================================== --- pages/manage_mailbox_edit.php (revision 994) +++ pages/manage_mailbox_edit.php (working copy) @@ -31,6 +31,11 @@ $t_mailbox += $t_mailbox_imap; } + + $t_extra_data = event_signal('EVENT_ERP_GET_EXTRA_MAILBOX_DATA', null, array($t_mailbox)); + + if (is_array($t_extra_data)) + $t_mailbox = array_merge($t_mailbox, $t_extra_data); } if ( $f_mailbox_action === 'add' || $f_mailbox_action === 'copy' ) directory_trim.diff (1,400 bytes)
Index: manage_config_edit.php =================================================================== --- manage_config_edit.php (revision 1000) +++ manage_config_edit.php (revision 1001) @@ -9,7 +9,7 @@ 'mail_add_complete_email' => gpc_get_bool( 'mail_add_complete_email' ), 'mail_auto_signup' => gpc_get_bool( 'mail_auto_signup' ), 'mail_debug' => gpc_get_bool( 'mail_debug' ), - 'mail_debug_directory' => trim( str_replace( '\\', '/', gpc_get_string( 'mail_debug_directory' ) ), '/ ' ), + 'mail_debug_directory' => rtrim(trim( str_replace( '\\', '/', gpc_get_string( 'mail_debug_directory' ) )), '/' ), 'mail_delete' => gpc_get_bool( 'mail_delete' ), 'mail_email_receive_own' => gpc_get_string( 'mail_email_receive_own' ), 'mail_encoding' => gpc_get_string( 'mail_encoding' ), @@ -26,7 +26,7 @@ 'mail_reporter_id' => gpc_get_int( 'mail_reporter_id' ), 'mail_save_from' => gpc_get_bool( 'mail_save_from' ), 'mail_secured_script' => gpc_get_bool( 'mail_secured_script' ), - 'mail_tmp_directory' => trim( str_replace( '\\', '/', gpc_get_string( 'mail_tmp_directory' ) ), '/ ' ), + 'mail_tmp_directory' => rtrim(trim( str_replace( '\\', '/', gpc_get_string( 'mail_tmp_directory' ) )), '/'), 'mail_use_bug_priority' => gpc_get_bool( 'mail_use_bug_priority' ), 'mail_use_reporter' => gpc_get_bool( 'mail_use_reporter' ), ); file_upload.patch (8,952 bytes)
Index: core/custom_file_api.php =================================================================== --- core/custom_file_api.php (revision 994) +++ core/custom_file_api.php (working copy) @@ -1,123 +0,0 @@ -<?php -/** - * Add a file to the system using the configured storage method - * - * @param integer $p_bug_id the bug id - * @param array $p_file the uploaded file info, as retrieved from gpc_get_file() - * - * almost the same as its counterpart in the file_api.php from MantisBT version 1.2.0, but with small adjustments to the disk upload part - */ -function ERP_custom_file_add( $p_bug_id, $p_file, $p_table = 'bug', $p_title = '', $p_desc = '', $p_user_id = null ) { - - file_ensure_uploaded( $p_file ); - $t_file_name = $p_file['name']; - $t_tmp_file = $p_file['tmp_name']; - - if( !file_type_check( $t_file_name ) ) { - trigger_error( ERROR_FILE_NOT_ALLOWED, ERROR ); - } - - if( !file_is_name_unique( $t_file_name, $p_bug_id ) ) { - trigger_error( ERROR_DUPLICATE_FILE, ERROR ); - } - - if( 'bug' == $p_table ) { - $t_project_id = bug_get_field( $p_bug_id, 'project_id' ); - $t_bug_id = bug_format_id( $p_bug_id ); - } else { - $t_project_id = helper_get_current_project(); - $t_bug_id = 0; - } - - if( $p_user_id === null ) { - $c_user_id = auth_get_current_user_id(); - } else { - $c_user_id = (int)$p_user_id; - } - - # prepare variables for insertion - $c_bug_id = db_prepare_int( $p_bug_id ); - $c_project_id = db_prepare_int( $t_project_id ); - $c_file_type = db_prepare_string( $p_file['type'] ); - $c_title = db_prepare_string( $p_title ); - $c_desc = db_prepare_string( $p_desc ); - - if( $t_project_id == ALL_PROJECTS ) { - $t_file_path = config_get( 'absolute_path_default_upload_folder' ); - } else { - $t_file_path = project_get_field( $t_project_id, 'file_path' ); - if( $t_file_path == '' ) { - $t_file_path = config_get( 'absolute_path_default_upload_folder' ); - } - } - $c_file_path = db_prepare_string( $t_file_path ); - $c_new_file_name = db_prepare_string( $t_file_name ); - - $t_file_hash = ( 'bug' == $p_table ) ? $t_bug_id : config_get( 'document_files_prefix' ) . '-' . $t_project_id; - $t_unique_name = file_generate_unique_name( $t_file_hash . '-' . $t_file_name, $t_file_path ); - $t_disk_file_name = $t_file_path . $t_unique_name; - $c_unique_name = db_prepare_string( $t_unique_name ); - - $t_file_size = filesize( $t_tmp_file ); - if( 0 == $t_file_size ) { - trigger_error( ERROR_FILE_NO_UPLOAD_FAILURE, ERROR ); - } - $t_max_file_size = (int) min( ini_get_number( 'upload_max_filesize' ), ini_get_number( 'post_max_size' ), config_get( 'max_file_size' ) ); - if( $t_file_size > $t_max_file_size ) { - trigger_error( ERROR_FILE_TOO_BIG, ERROR ); - } - $c_file_size = db_prepare_int( $t_file_size ); - - $t_method = config_get( 'file_upload_method' ); - - switch( $t_method ) { - case FTP: - case DISK: - file_ensure_valid_upload_path( $t_file_path ); - - if( !file_exists( $t_disk_file_name ) ) { - if( FTP == $t_method ) { - $conn_id = file_ftp_connect(); - file_ftp_put( $conn_id, $t_disk_file_name, $t_tmp_file ); - file_ftp_disconnect( $conn_id ); - } - - // move_uploaded_file replaced with rename function. Needed since files added through the EmailReporting method are not seen as such - if( !rename( $t_tmp_file, $t_disk_file_name ) ) { - // Corrected trigger error message name, FILE_MOVE_FAILED should have been ERROR_FILE_MOVE_FAILED - trigger_error( ERROR_FILE_MOVE_FAILED, ERROR ); - } - - chmod( $t_disk_file_name, config_get( 'attachments_file_permissions' ) ); - - $c_content = "''"; - } else { - trigger_error( ERROR_FILE_DUPLICATE, ERROR ); - } - break; - case DATABASE: - $c_content = db_prepare_binary_string( fread( fopen( $t_tmp_file, 'rb' ), $t_file_size ) ); - break; - default: - trigger_error( ERROR_GENERIC, ERROR ); - } - - $t_file_table = db_get_table( 'mantis_' . $p_table . '_file_table' ); - $c_id = ( 'bug' == $p_table ) ? $c_bug_id : $c_project_id; - - $query = "INSERT INTO $t_file_table - (" . $p_table . "_id, title, description, diskfile, filename, folder, filesize, file_type, date_added, content, user_id) - VALUES - ($c_id, '$c_title', '$c_desc', '$c_unique_name', '$c_new_file_name', '$c_file_path', $c_file_size, '$c_file_type', '" . db_now() . "', $c_content, $c_user_id)"; - db_query( $query ); - - if( 'bug' == $p_table ) { - - # updated the last_updated date - $result = bug_update_date( $p_bug_id ); - - # log new bug - history_log_event_special( $p_bug_id, FILE_ADDED, $t_file_name ); - } -} -?> Index: core/mail_api.php =================================================================== --- core/mail_api.php (revision 998) +++ core/mail_api.php (working copy) @@ -13,8 +13,6 @@ require_once( 'user_api.php' ); require_once( 'file_api.php' ); - require_once( plugin_config_get( 'path_erp', NULL, TRUE ) . 'core/custom_file_api.php' ); - require_once( 'Net/POP3.php' ); require_once( plugin_config_get( 'path_erp', NULL, TRUE ) . 'core/Net/IMAP_1.0.3.php' ); @@ -735,7 +733,7 @@ foreach ( $p_email[ 'X-Mantis-Parts' ] as $part ) { - $t_file_rejected = $this->add_file( $t_bug_id, $part ); + $t_file_rejected = $this->add_file( $t_bug_id, $p_email[ 'Reporter_id' ], $part ); if ( $t_file_rejected !== TRUE ) { @@ -765,7 +763,7 @@ # -------------------- # Very dirty: Adds a file to a bug. # returns true on success and the filename with reason on error - private function add_file( $p_bug_id, &$p_part ) + private function add_file( $p_bug_id, $p_user_id, &$p_part ) { # Handle the file upload $t_part_name = ( ( isset( $p_part[ 'name' ] ) ) ? trim( $p_part[ 'name' ] ) : NULL ); @@ -794,17 +792,34 @@ $this->_file_number++; } - $t_file_name = $this->_mail_tmp_directory . '/' . md5( microtime() ); + $t_file_name = $this->_mail_tmp_directory . '/' . $this->_file_number . '-' . $t_part_name; file_put_contents( $t_file_name, $p_part[ 'body' ] ); - ERP_custom_file_add( $p_bug_id, array( - 'tmp_name' => realpath( $t_file_name ), - 'name' => $this->_file_number . '-' . $t_part_name, - 'type' => $p_part[ 'ctype' ], - 'error' => NULL - ), 'bug' ); - + $ch = curl_init(); + + $data = array('bug_id' => $p_bug_id, + 'user_id' => $p_user_id, + 'file' => '@'.$t_file_name); // .';type='.$p_part[ 'ctype' ]); // the type part does not work under all versions of PHP (5.2.6 KO, 5.2.13 OK) + + $url = config_get_global( 'path' ).plugin_page('file_add.php', true); + echo $url."\n"; + echo "\n\n"; + print_r($data); + echo "\n\n"; + + curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_POST, 1); + curl_setopt($ch, CURLOPT_POSTFIELDS, $data); + + if(curl_exec($ch) === false) + { + echo 'Curl error: ' . curl_error($ch) ."<br />\n"; + } + + // Close handle + curl_close($ch); + if ( is_file( $t_file_name ) ) { unlink( $t_file_name ); Index: pages/file_add.php =================================================================== --- pages/file_add.php (revision 0) +++ pages/file_add.php (revision 0) @@ -0,0 +1,49 @@ +<?php + +require_once('file_api.php'); + +$t_address = $_SERVER['REMOTE_ADDR']; +$t_valid = false; + +helper_begin_long_process(); + +# Always allow the same machine to import +if ( '127.0.0.1' == $t_address || '127.0.1.1' == $t_address + || 'localhost' == $t_address || '::1' == $t_address + || $_SERVER['SERVER_ADDR'] == $t_address || $_SERVER['SERVER_NAME'] == $t_address ) { + $t_valid = true; +} + +# Not validated by this point gets the boot! +if ( !$t_valid ) { + die( plugin_lang_get( 'invalid_file_add_url' ) ); +} + + +$f_bug_id = gpc_get_int( 'bug_id', -1 ); +$f_user_id = gpc_get_int( 'user_id', null ); +$f_file = gpc_get_file( 'file', -1 ); + +echo "Bug id : $f_bug_id<br />\n"; +echo "User id: $f_user_id<<br />\n"; +echo "File info:<br />\n"; +print_r($f_file); +echo "<br />\n"; + +if ( $f_bug_id == -1 && $f_file == -1 ) { + # _POST/_FILES does not seem to get populated if you exceed size limit so check if bug_id is -1 + trigger_error( ERROR_FILE_TOO_BIG, ERROR ); +} + +# Must set global current user id because file_add and other functions it calls +# make calls to auth_get_current_user_id() and we obviously have no user logged +# in when run via the cron job +global $g_cache_current_user_id; +$g_cache_current_user_id = $f_user_id; + +echo "Adding file<br />\n"; +file_add( $f_bug_id, $f_file, 'bug'); +echo "All done<br />\n"; + + +?> \ No newline at end of file file_number.patch (1,389 bytes)
Index: core/mail_api.php =================================================================== --- core/mail_api.php (revision 1002) +++ core/mail_api.php (working copy) @@ -35,8 +35,6 @@ 'IMAP' => array( 'normal' => 143, 'encrypted' => 993 ), ); - private $_file_number = 1; - private $_validated_email_list = array(); private $_mail_add_bug_reports; @@ -729,8 +727,6 @@ { $t_rejected_files = NULL; - $this->_file_number = 1; - foreach ( $p_email[ 'X-Mantis-Parts' ] as $part ) { $t_file_rejected = $this->add_file( $t_bug_id, $p_email[ 'Reporter_id' ], $part ); @@ -787,12 +783,14 @@ } else { - while ( !file_is_name_unique( $this->_file_number . '-' . $t_part_name, $p_bug_id ) ) + $file_number = 0; + + while ( !file_is_name_unique( $t_file_name = (($file_number > 0)? preg_replace('/(\..+)$/', '-'.$file_number.'$1' , $t_part_name) : $t_part_name), $p_bug_id ) ) { - $this->_file_number++; + $file_number++; } - $t_file_name = $this->_mail_tmp_directory . '/' . $this->_file_number . '-' . $t_part_name; + $t_file_name = $this->_mail_tmp_directory . '/' . $t_file_name; file_put_contents( $t_file_name, $p_part[ 'body' ] ); @@ -824,8 +822,6 @@ { unlink( $t_file_name ); } - - $this->_file_number++; } return( TRUE ); multi_string_reply_marker.patch (1,291 bytes)
Index: core/config_api.php =================================================================== --- core/config_api.php (revision 1002) +++ core/config_api.php (working copy) @@ -146,6 +146,7 @@ break; case 'array': + case 'multi_string': case 'boolean': case 'directory_string': case 'integer': @@ -184,6 +185,14 @@ <?php break; + case 'multi_string': +?> + <td class="center" width="40%" colspan="2"> + <textarea cols="40" rows="6" name="<?php echo $p_name ?>"><?php echo $t_value; ?></textarea> + </td> +<?php + break; + case 'boolean': ?> <td class="center" width="20%"> Index: pages/manage_config.php =================================================================== --- pages/manage_config.php (revision 1002) +++ pages/manage_config.php (working copy) @@ -76,7 +76,7 @@ ERP_output_config_option( 'mail_nosubject', 'string', -2 ); ERP_output_config_option( 'mail_nodescription', 'string', -2 ); ERP_output_config_option( 'mail_removed_reply_text', 'string', -2 ); -ERP_output_config_option( 'mail_remove_replies_after', 'string', -2 ); +ERP_output_config_option( 'mail_remove_replies_after', 'multi_string', -2 ); ERP_output_config_option( NULL, 'empty' ); ERP_output_config_option( 'debug_options', 'header' ); reply_identification.patch (1,783 bytes)
Index: core/mail_api.php =================================================================== --- core/mail_api.php (revision 1007) +++ core/mail_api.php (working copy) @@ -1054,12 +1054,15 @@ # Removes replies from mails private function identify_replies( $p_description ) { + $t_description = $p_description; + if ( $this->_mail_remove_replies ) { - $t_first_occurence = stripos( $p_description, $this->_mail_remove_replies_after ); + $t_first_occurence = stripos( $t_description, $this->_mail_remove_replies_after ); + if ( $t_first_occurence !== FALSE ) { - $t_description = substr( $p_description, 0, $t_first_occurence ) . $this->_mail_removed_reply_text; + $t_description = substr( $t_description, 0, $t_first_occurence ) . $this->_mail_removed_reply_text; } } @@ -1069,19 +1072,14 @@ # the version delivered with this package seems to be working OK though but just to be sure $t_email_separator1 = substr( $this->_email_separator1, 0, -1 ); - $t_first_occurence = strpos( $p_description, $t_email_separator1 ); - if ( $t_first_occurence !== FALSE && substr_count( $p_description, $t_email_separator1, $t_first_occurence ) >= 5 ) + $t_first_occurence = strpos( $t_description, $t_email_separator1 ); + if ( $t_first_occurence !== FALSE && substr_count( $t_description, $t_email_separator1, $t_first_occurence ) >= 5 ) { - $t_description = substr( $p_description, 0, $t_first_occurence ) . $this->_mail_removed_reply_text; + $t_description = substr( $t_description, 0, $t_first_occurence ) . $this->_mail_removed_reply_text; } } - if ( isset( $t_description ) ) - { - return( $t_description ); - } - - return( $p_description ); + return $t_description; } # -------------------- note_and_new_issue_add_subject_cc_date.patch (11,736 bytes)
diff -Naur original/EmailReporting/core/Mail/Parser.php new/EmailReporting/core/Mail/Parser.php --- original/EmailReporting/core/Mail/Parser.php 2011-09-15 10:04:38.000000000 +0200 +++ new/EmailReporting/core/Mail/Parser.php 2011-09-15 10:36:47.000000000 +0200 @@ -14,6 +14,8 @@ private $_from; private $_subject; + private $_cc; + private $_date; private $_charset = 'auto'; private $_priority; private $_transferencoding; @@ -100,6 +102,8 @@ { $this->_from = $this->process_encoding( $this->_from ); $this->_subject = $this->process_encoding( $this->_subject ); + $this->_cc = $this->process_encoding( $this->_cc ); + $this->_date = $this->process_encoding( $this->_date ); $this->_body = $this->process_encoding( $this->_body ); } } @@ -114,6 +118,16 @@ return( $this->_subject ); } + public function cc() + { + return( $this->_cc ); + } + + public function mail_date() + { + return( $this->_date ); + } + public function priority() { return( $this->_priority ); @@ -133,6 +147,17 @@ { $this->setFrom( $structure->headers['from'] ); $this->setSubject( $structure->headers['subject'] ); + + if( isset( $structure->headers['cc'] ) ) + { + $this->setCC( $structure->headers['cc'] ); + } + + if( isset( $structure->headers['date'] ) ) + { + $this->setDate( $structure->headers['date'] ); + } + $this->setContentType( $structure->ctype_primary, $structure->ctype_secondary ); if ( isset( $structure->ctype_parameters[ 'charset' ] ) ) @@ -171,6 +196,16 @@ $this->_subject = $subject; } + private function setCC( $cc ) + { + $this->_cc = $cc; + } + + private function setDate( $date ) + { + $this->_date = $date; + } + private function setCharset( $charset ) { if ( extension_loaded( 'mbstring' ) && $this->_charset === 'auto' ) diff -Naur original/EmailReporting/core/mail_api.php new/EmailReporting/core/mail_api.php --- original/EmailReporting/core/mail_api.php 2011-09-15 10:04:38.000000000 +0200 +++ new/EmailReporting/core/mail_api.php 2011-09-15 10:36:47.000000000 +0200 @@ -58,6 +58,9 @@ private $_mail_removed_reply_text; private $_mail_reporter_id; private $_mail_save_from; + private $_mail_save_note_subject; + private $_mail_save_cc; + private $_mail_save_date; private $_mail_tmp_directory; private $_mail_use_bug_priority; private $_mail_use_reporter; @@ -109,6 +112,9 @@ $this->_mail_removed_reply_text = plugin_config_get( 'mail_removed_reply_text' ); $this->_mail_reporter_id = plugin_config_get( 'mail_reporter_id' ); $this->_mail_save_from = plugin_config_get( 'mail_save_from' ); + $this->_mail_save_note_subject = plugin_config_get( 'mail_save_note_subject'); + $this->_mail_save_cc = plugin_config_get( 'mail_save_cc' ); + $this->_mail_save_date = plugin_config_get( 'mail_save_date' ); $this->_mail_tmp_directory = plugin_config_get( 'mail_tmp_directory' ); $this->_mail_use_bug_priority = plugin_config_get( 'mail_use_bug_priority' ); $this->_mail_use_reporter = plugin_config_get( 'mail_use_reporter' ); @@ -447,15 +453,14 @@ $t_mp->parse(); - $t_email[ 'From' ] = $t_mp->from(); - $t_email[ 'From_parsed' ] = $this->parse_address( $t_email[ 'From' ] ); - $t_email[ 'Reporter_id' ] = $this->get_user( $t_email[ 'From_parsed' ] ); - - $t_email[ 'Subject' ] = trim( $t_mp->subject() ); - - $t_email[ 'X-Mantis-Body' ] = trim( $t_mp->body() ); - - $t_email[ 'X-Mantis-Parts' ] = $t_mp->parts(); + $t_email[ 'From' ] = $t_mp->from(); + $t_email[ 'From_parsed' ] = $this->parse_address( $t_email[ 'From' ] ); + $t_email[ 'Reporter_id' ] = $this->get_user( $t_email[ 'From_parsed' ] ); + $t_email[ 'Subject' ] = trim( $t_mp->subject() ); + $t_email[ 'CC' ] = trim( $t_mp->cc() ); + $t_email[ 'Date' ] = trim( $t_mp->mail_date() ); + $t_email[ 'X-Mantis-Body' ] = trim( $t_mp->body() ); + $t_email[ 'X-Mantis-Parts' ] = $t_mp->parts(); if ( $this->_mail_use_bug_priority ) { @@ -602,8 +607,12 @@ $t_description = $p_email[ 'X-Mantis-Body' ]; $t_description = $this->identify_replies( $t_description ); - $t_description = $this->apply_mail_save_from( $p_email[ 'From' ], $t_description ); + $t_description = $this->apply_mail_subject( $p_email[ 'Subject' ], $t_description ); + $t_description = $this->apply_mail_save_date( $p_email[ 'Date' ], $t_description ); + $t_description = $this->apply_mail_save_cc( $p_email[ 'CC' ], $t_description ); + $t_description = $this->apply_mail_save_from( $p_email[ 'From' ], $t_description ); + # Event integration # Core mantis event already exists within bignote_add function $t_bugnote_text = event_signal( 'EVENT_ERP_BUGNOTE_DATA', $t_description, $t_bug_id ); @@ -650,7 +659,13 @@ $t_bug_data->status = $this->_bug_submit_status; $t_bug_data->summary = $p_email[ 'Subject' ]; - $t_bug_data->description = $this->apply_mail_save_from( $p_email[ 'From' ], $p_email[ 'X-Mantis-Body' ] ); + $t_description = $p_email[ 'X-Mantis-Body' ]; + $t_description = $this->apply_mail_subject( $p_email[ 'Subject' ], $t_description ); + $t_description = $this->apply_mail_save_date( $p_email[ 'Date' ], $t_description ); + $t_description = $this->apply_mail_save_cc( $p_email[ 'CC' ], $t_description ); + $t_description = $this->apply_mail_save_from( $p_email[ 'From' ], $t_description ); + + $t_bug_data->description = $t_description; $t_bug_data->steps_to_reproduce = $this->_default_bug_steps_to_reproduce; $t_bug_data->additional_information = $this->_default_bug_additional_info; @@ -1018,6 +1033,7 @@ private function mail_is_a_bugnote( $p_mail_subject ) { $t_bug_id = $this->get_bug_id_from_subject( $p_mail_subject ); + print("recognized t_bug_id=[".$t_bug_id."], subject=[".$p_mail_subject."]"); if ( $t_bug_id !== FALSE ) { @@ -1034,7 +1050,7 @@ # return the bug's id from the subject private function get_bug_id_from_subject( $p_mail_subject ) { - preg_match( "/\[.*?\s([0-9]{1,7}?)\]/u", $p_mail_subject, $v_matches ); + preg_match( "/.*\[.*?(0*[0-9]{1,7}?)\s*\]/u", $p_mail_subject, $v_matches ); if ( isset( $v_matches[ 1 ] ) ) { @@ -1119,12 +1135,49 @@ { if ( $this->_mail_save_from ) { - return( 'Email from: ' . $p_from . "\n\n" . $p_description ); + return( 'From: ' . $p_from . "\n" . $p_description ); + } + + return( $p_description ); + } + + # -------------------- + # Add the save subject text if enabled + private function apply_mail_subject( $p_subject, $p_description ) + { + if ( $this->_mail_save_note_subject ) + { + return( 'Subject: ' . $p_subject . "\n\n\n" . $p_description ); + } + + return( $p_description ); + } + + # -------------------- + # Add the save cc text if enabled + private function apply_mail_save_cc( $p_cc, $p_description ) + { + if ( $this->_mail_save_cc ) + { + return( 'CC: ' . $p_cc . "\n" . $p_description ); } return( $p_description ); } + + # -------------------- + # Add the save date text if enabled + private function apply_mail_save_date( $p_date, $p_description ) + { + if ( $this->_mail_save_date ) + { + return( 'Date: ' . $p_date . "\n" . $p_description ); + } + + return( $p_description ); + } + # -------------------- # Show memory usage in debug mode private function show_memory_usage( $p_location ) diff -Naur original/EmailReporting/EmailReporting.php new/EmailReporting/EmailReporting.php --- original/EmailReporting/EmailReporting.php 2011-09-15 10:04:37.000000000 +0200 +++ new/EmailReporting/EmailReporting.php 2011-09-15 10:36:47.000000000 +0200 @@ -48,6 +48,9 @@ # Is this plugin allowed to process and add bugnotes to existing issues 'mail_add_bugnotes' => ON, + # Add email subject to a note or new bug report + 'mail_save_note_subject' => OFF, + # Add complete email into the attachments 'mail_add_complete_email' => OFF, @@ -133,6 +136,12 @@ # Write sender of the message into the bug report 'mail_save_from' => ON, + # Write CC into the bug report + 'mail_save_cc' => OFF, + + # Write Date into the bug report + 'mail_save_date' => OFF, + # Do you want to secure the EmailReporting script so that it cannot be run # via a webserver? 'mail_secured_script' => ON, @@ -474,5 +483,10 @@ plugin_config_set( 'mail_mantisbt_url_fix', $t_path ); } } + if ( $t_config_version <= 10 ) + { + plugin_config_set( 'mail_save_note_subject', ON ); + plugin_config_set( 'config_version', 11 ); + } } } diff -Naur original/EmailReporting/lang/strings_english.txt new/EmailReporting/lang/strings_english.txt --- original/EmailReporting/lang/strings_english.txt 2011-09-15 10:04:38.000000000 +0200 +++ new/EmailReporting/lang/strings_english.txt 2011-09-15 10:36:47.000000000 +0200 @@ -51,7 +51,10 @@ $s_plugin_EmailReporting_mail_remove_replies_after = 'Use this text to identify the start of a reply'; $s_plugin_EmailReporting_mail_removed_reply_text = 'Use this text if replies have been removed from the email'; $s_plugin_EmailReporting_mail_reporter_id = 'The default / fallback reporter user for issues created by email'; -$s_plugin_EmailReporting_mail_save_from = 'Write the sender of the email into the issue report'; +$s_plugin_EmailReporting_mail_save_from = 'Write the sender of the email into the issue/bugnote'; +$s_plugin_EmailReporting_mail_save_cc = 'Write the CC of the email into the issue/bugnote'; +$s_plugin_EmailReporting_mail_save_date = 'Write the Date of the email into the issue/bugnote'; +$s_plugin_EmailReporting_mail_save_note_subject = 'Write the email subject into the issue/bugnote'; $s_plugin_EmailReporting_mail_secured_script = 'Block this script from running via a webserver (recommended = "Yes")'; $s_plugin_EmailReporting_mail_tmp_directory = 'Directory for saving temporary email content'; $s_plugin_EmailReporting_mail_use_bug_priority = 'Look for priority header field'; diff -Naur original/EmailReporting/pages/manage_config_edit.php new/EmailReporting/pages/manage_config_edit.php --- original/EmailReporting/pages/manage_config_edit.php 2011-09-15 10:04:37.000000000 +0200 +++ new/EmailReporting/pages/manage_config_edit.php 2011-09-15 10:36:47.000000000 +0200 @@ -26,6 +26,9 @@ 'mail_removed_reply_text' => gpc_get_string( 'mail_removed_reply_text' ), 'mail_reporter_id' => gpc_get_int( 'mail_reporter_id' ), 'mail_save_from' => gpc_get_bool( 'mail_save_from' ), + 'mail_save_cc' => gpc_get_bool( 'mail_save_cc' ), + 'mail_save_date' => gpc_get_bool( 'mail_save_date' ), + 'mail_save_note_subject' => gpc_get_bool( 'mail_save_note_subject'), 'mail_secured_script' => gpc_get_bool( 'mail_secured_script' ), 'mail_tmp_directory' => ERP_prepare_directory_string( gpc_get_string( 'mail_tmp_directory' ) ), 'mail_use_bug_priority' => gpc_get_bool( 'mail_use_bug_priority' ), diff -Naur original/EmailReporting/pages/manage_config.php new/EmailReporting/pages/manage_config.php --- original/EmailReporting/pages/manage_config.php 2011-09-15 10:04:37.000000000 +0200 +++ new/EmailReporting/pages/manage_config.php 2011-09-15 10:36:47.000000000 +0200 @@ -65,6 +65,9 @@ ERP_output_config_option( 'mail_remove_replies', 'boolean', -2 ); ERP_output_config_option( 'mail_email_receive_own', 'boolean', -2 ); ERP_output_config_option( 'mail_save_from', 'boolean', -2 ); +ERP_output_config_option( 'mail_save_cc', 'boolean', -2 ); +ERP_output_config_option( 'mail_save_date', 'boolean', -2 ); +ERP_output_config_option( 'mail_save_note_subject', 'boolean', -2 ); ERP_output_config_option( NULL, 'empty' ); ERP_output_config_option( 'priority_feature_options', 'header' ); note_and_new_issue_add_subject_cc_date_to.patch (12,919 bytes)
diff -Nuar original/EmailReporting/core/Mail/Parser.php new/EmailReporting/core/Mail/Parser.php --- original/EmailReporting/core/Mail/Parser.php 2010-10-19 18:48:26.000000000 +0200 +++ new/EmailReporting/core/Mail/Parser.php 2011-09-15 11:43:00.000000000 +0200 @@ -13,7 +13,10 @@ private $_content; private $_from; + private $_to; private $_subject; + private $_cc; + private $_date; private $_charset = 'auto'; private $_priority; private $_transferencoding; @@ -99,7 +102,10 @@ if ( extension_loaded( 'mbstring' ) ) { $this->_from = $this->process_encoding( $this->_from ); + $this->_to = $this->process_encoding( $this->_to ); $this->_subject = $this->process_encoding( $this->_subject ); + $this->_cc = $this->process_encoding( $this->_cc ); + $this->_date = $this->process_encoding( $this->_date ); $this->_body = $this->process_encoding( $this->_body ); } } @@ -114,6 +120,21 @@ return( $this->_subject ); } + public function cc() + { + return( $this->_cc ); + } + + public function mail_to() + { + return( $this->_to ); + } + + public function mail_date() + { + return( $this->_date ); + } + public function priority() { return( $this->_priority ); @@ -133,6 +154,22 @@ { $this->setFrom( $structure->headers['from'] ); $this->setSubject( $structure->headers['subject'] ); + + if( isset( $structure->headers['cc'] ) ) + { + $this->setCC( $structure->headers['cc'] ); + } + + if( isset( $structure->headers['date'] ) ) + { + $this->setDate( $structure->headers['date'] ); + } + + if( isset( $structure->headers['to'] ) ) + { + $this->setTo( $structure->headers['to'] ); + } + $this->setContentType( $structure->ctype_primary, $structure->ctype_secondary ); if ( isset( $structure->ctype_parameters[ 'charset' ] ) ) @@ -171,6 +208,21 @@ $this->_subject = $subject; } + private function setCC( $cc ) + { + $this->_cc = $cc; + } + + private function setDate( $date ) + { + $this->_date = $date; + } + + private function setTo( $to ) + { + $this->_to = $to; + } + private function setCharset( $charset ) { if ( extension_loaded( 'mbstring' ) && $this->_charset === 'auto' ) diff -Nuar original/EmailReporting/core/mail_api.php new/EmailReporting/core/mail_api.php --- original/EmailReporting/core/mail_api.php 2010-11-06 23:23:16.000000000 +0100 +++ new/EmailReporting/core/mail_api.php 2011-09-15 12:00:34.000000000 +0200 @@ -58,6 +58,10 @@ private $_mail_removed_reply_text; private $_mail_reporter_id; private $_mail_save_from; + private $_mail_save_to; + private $_mail_save_note_subject; + private $_mail_save_cc; + private $_mail_save_date; private $_mail_tmp_directory; private $_mail_use_bug_priority; private $_mail_use_reporter; @@ -109,6 +113,10 @@ $this->_mail_removed_reply_text = plugin_config_get( 'mail_removed_reply_text' ); $this->_mail_reporter_id = plugin_config_get( 'mail_reporter_id' ); $this->_mail_save_from = plugin_config_get( 'mail_save_from' ); + $this->_mail_save_to = plugin_config_get( 'mail_save_to' ); + $this->_mail_save_note_subject = plugin_config_get( 'mail_save_note_subject'); + $this->_mail_save_cc = plugin_config_get( 'mail_save_cc' ); + $this->_mail_save_date = plugin_config_get( 'mail_save_date' ); $this->_mail_tmp_directory = plugin_config_get( 'mail_tmp_directory' ); $this->_mail_use_bug_priority = plugin_config_get( 'mail_use_bug_priority' ); $this->_mail_use_reporter = plugin_config_get( 'mail_use_reporter' ); @@ -447,15 +455,15 @@ $t_mp->parse(); - $t_email[ 'From' ] = $t_mp->from(); - $t_email[ 'From_parsed' ] = $this->parse_address( $t_email[ 'From' ] ); - $t_email[ 'Reporter_id' ] = $this->get_user( $t_email[ 'From_parsed' ] ); - - $t_email[ 'Subject' ] = trim( $t_mp->subject() ); - - $t_email[ 'X-Mantis-Body' ] = trim( $t_mp->body() ); - - $t_email[ 'X-Mantis-Parts' ] = $t_mp->parts(); + $t_email[ 'From' ] = $t_mp->from(); + $t_email[ 'From_parsed' ] = $this->parse_address( $t_email[ 'From' ] ); + $t_email[ 'Reporter_id' ] = $this->get_user( $t_email[ 'From_parsed' ] ); + $t_email[ 'Subject' ] = trim( $t_mp->subject() ); + $t_email[ 'CC' ] = trim( $t_mp->cc() ); + $t_email[ 'Date' ] = trim( $t_mp->mail_date() ); + $t_email[ 'To' ] = trim( $t_mp->mail_to() ); + $t_email[ 'X-Mantis-Body' ] = trim( $t_mp->body() ); + $t_email[ 'X-Mantis-Parts' ] = $t_mp->parts(); if ( $this->_mail_use_bug_priority ) { @@ -602,8 +610,16 @@ $t_description = $p_email[ 'X-Mantis-Body' ]; $t_description = $this->identify_replies( $t_description ); - $t_description = $this->apply_mail_save_from( $p_email[ 'From' ], $t_description ); + $t_description = $this->apply_mail_subject( $p_email[ 'Subject' ], $t_description ); + $t_description = $this->apply_mail_save_date( $p_email[ 'Date' ], $t_description ); + if( array_key_exists( $p_email[ 'CC' ] ) && !empty( $p_email[ 'CC' ] ) ) + { + $t_description = $this->apply_mail_save_cc( $p_email[ 'CC' ], $t_description ); + } + $t_description = $this->apply_mail_save_to( $p_email[ 'To' ], $t_description ); + $t_description = $this->apply_mail_save_from( $p_email[ 'From' ], $t_description ); + # Event integration # Core mantis event already exists within bignote_add function $t_bugnote_text = event_signal( 'EVENT_ERP_BUGNOTE_DATA', $t_description, $t_bug_id ); @@ -650,7 +666,19 @@ $t_bug_data->status = $this->_bug_submit_status; $t_bug_data->summary = $p_email[ 'Subject' ]; - $t_bug_data->description = $this->apply_mail_save_from( $p_email[ 'From' ], $p_email[ 'X-Mantis-Body' ] ); + $t_description = $p_email[ 'X-Mantis-Body' ]; + $t_description = $this->apply_mail_subject( $p_email[ 'Subject' ], $t_description ); + $t_description = $this->apply_mail_save_date( $p_email[ 'Date' ], $t_description ); + + if( array_key_exists( $p_email[ 'CC' ] ) && !empty( $p_email[ 'CC' ] ) ) + { + $t_description = $this->apply_mail_save_cc( $p_email[ 'CC' ], $t_description ); + } + + $t_description = $this->apply_mail_save_to( $p_email[ 'To' ], $t_description ); + $t_description = $this->apply_mail_save_from( $p_email[ 'From' ], $t_description ); + + $t_bug_data->description = $t_description; $t_bug_data->steps_to_reproduce = $this->_default_bug_steps_to_reproduce; $t_bug_data->additional_information = $this->_default_bug_additional_info; @@ -1034,7 +1062,7 @@ # return the bug's id from the subject private function get_bug_id_from_subject( $p_mail_subject ) { - preg_match( "/\[.*?\s([0-9]{1,7}?)\]/u", $p_mail_subject, $v_matches ); + preg_match( "/.*\[.*?(0*[0-9]{1,7}?)\s*\]/u", $p_mail_subject, $v_matches ); if ( isset( $v_matches[ 1 ] ) ) { @@ -1119,13 +1147,62 @@ { if ( $this->_mail_save_from ) { - return( 'Email from: ' . $p_from . "\n\n" . $p_description ); + return( 'From: ' . $p_from . "\n" . $p_description ); + } + + return( $p_description ); + } + + # -------------------- + # Add the save to text if enabled + private function apply_mail_save_to( $p_to, $p_description ) + { + if ( $this->_mail_save_to ) + { + return( 'To: ' . $p_to . "\n" . $p_description ); + } + + return( $p_description ); + } + + # -------------------- + # Add the save subject text if enabled + private function apply_mail_subject( $p_subject, $p_description ) + { + if ( $this->_mail_save_note_subject ) + { + return( 'Subject: ' . $p_subject . "\n\n\n" . $p_description ); } return( $p_description ); } # -------------------- + # Add the save cc text if enabled + private function apply_mail_save_cc( $p_cc, $p_description ) + { + if ( $this->_mail_save_cc ) + { + return( 'CC: ' . $p_cc . "\n" . $p_description ); + } + + return( $p_description ); + } + + + # -------------------- + # Add the save date text if enabled + private function apply_mail_save_date( $p_date, $p_description ) + { + if ( $this->_mail_save_date ) + { + return( 'Date: ' . $p_date . "\n" . $p_description ); + } + + return( $p_description ); + } + + # -------------------- # Show memory usage in debug mode private function show_memory_usage( $p_location ) { diff -Nuar original/EmailReporting/EmailReporting.php new/EmailReporting/EmailReporting.php --- original/EmailReporting/EmailReporting.php 2010-11-11 23:31:02.000000000 +0100 +++ new/EmailReporting/EmailReporting.php 2011-09-15 11:43:00.000000000 +0200 @@ -48,6 +48,9 @@ # Is this plugin allowed to process and add bugnotes to existing issues 'mail_add_bugnotes' => ON, + # Add email subject to a note or new bug report + 'mail_save_note_subject' => OFF, + # Add complete email into the attachments 'mail_add_complete_email' => OFF, @@ -133,6 +136,15 @@ # Write sender of the message into the bug report 'mail_save_from' => ON, + # Write recipient (To) of the message into the bug report + 'mail_save_to' => OFF, + + # Write CC into the bug report + 'mail_save_cc' => OFF, + + # Write Date into the bug report + 'mail_save_date' => OFF, + # Do you want to secure the EmailReporting script so that it cannot be run # via a webserver? 'mail_secured_script' => ON, @@ -474,5 +486,10 @@ plugin_config_set( 'mail_mantisbt_url_fix', $t_path ); } } + if ( $t_config_version <= 10 ) + { + plugin_config_set( 'mail_save_note_subject', ON ); + plugin_config_set( 'config_version', 11 ); + } } } diff -Nuar original/EmailReporting/lang/strings_english.txt new/EmailReporting/lang/strings_english.txt --- original/EmailReporting/lang/strings_english.txt 2010-10-19 18:44:46.000000000 +0200 +++ new/EmailReporting/lang/strings_english.txt 2011-09-15 11:43:00.000000000 +0200 @@ -51,7 +51,11 @@ $s_plugin_EmailReporting_mail_remove_replies_after = 'Use this text to identify the start of a reply'; $s_plugin_EmailReporting_mail_removed_reply_text = 'Use this text if replies have been removed from the email'; $s_plugin_EmailReporting_mail_reporter_id = 'The default / fallback reporter user for issues created by email'; -$s_plugin_EmailReporting_mail_save_from = 'Write the sender of the email into the issue report'; +$s_plugin_EmailReporting_mail_save_from = 'Write the sender of the email into the issue/bugnote'; +$s_plugin_EmailReporting_mail_save_to = 'Write the recipient (To) of the email into the issue/bugnote'; +$s_plugin_EmailReporting_mail_save_cc = 'Write the CC of the email into the issue/bugnote'; +$s_plugin_EmailReporting_mail_save_date = 'Write the Date of the email into the issue/bugnote'; +$s_plugin_EmailReporting_mail_save_note_subject = 'Write the email subject into the issue/bugnote'; $s_plugin_EmailReporting_mail_secured_script = 'Block this script from running via a webserver (recommended = "Yes")'; $s_plugin_EmailReporting_mail_tmp_directory = 'Directory for saving temporary email content'; $s_plugin_EmailReporting_mail_use_bug_priority = 'Look for priority header field'; diff -Nuar original/EmailReporting/pages/manage_config_edit.php new/EmailReporting/pages/manage_config_edit.php --- original/EmailReporting/pages/manage_config_edit.php 2010-10-07 15:08:38.000000000 +0200 +++ new/EmailReporting/pages/manage_config_edit.php 2011-09-15 11:43:00.000000000 +0200 @@ -26,6 +26,10 @@ 'mail_removed_reply_text' => gpc_get_string( 'mail_removed_reply_text' ), 'mail_reporter_id' => gpc_get_int( 'mail_reporter_id' ), 'mail_save_from' => gpc_get_bool( 'mail_save_from' ), + 'mail_save_to' => gpc_get_bool( 'mail_save_to' ), + 'mail_save_cc' => gpc_get_bool( 'mail_save_cc' ), + 'mail_save_date' => gpc_get_bool( 'mail_save_date' ), + 'mail_save_note_subject' => gpc_get_bool( 'mail_save_note_subject'), 'mail_secured_script' => gpc_get_bool( 'mail_secured_script' ), 'mail_tmp_directory' => ERP_prepare_directory_string( gpc_get_string( 'mail_tmp_directory' ) ), 'mail_use_bug_priority' => gpc_get_bool( 'mail_use_bug_priority' ), diff -Nuar original/EmailReporting/pages/manage_config.php new/EmailReporting/pages/manage_config.php --- original/EmailReporting/pages/manage_config.php 2010-10-07 15:08:26.000000000 +0200 +++ new/EmailReporting/pages/manage_config.php 2011-09-15 11:43:00.000000000 +0200 @@ -65,6 +65,10 @@ ERP_output_config_option( 'mail_remove_replies', 'boolean', -2 ); ERP_output_config_option( 'mail_email_receive_own', 'boolean', -2 ); ERP_output_config_option( 'mail_save_from', 'boolean', -2 ); +ERP_output_config_option( 'mail_save_to', 'boolean', -2 ); +ERP_output_config_option( 'mail_save_cc', 'boolean', -2 ); +ERP_output_config_option( 'mail_save_date', 'boolean', -2 ); +ERP_output_config_option( 'mail_save_note_subject', 'boolean', -2 ); ERP_output_config_option( NULL, 'empty' ); ERP_output_config_option( 'priority_feature_options', 'header' ); | ||||
related to | 0006658 | closed | ryandesign | mantisbt | Replying to a mantis ticket should add it as a note to that issue |
has duplicate | 0001568 | closed | grangeway | mantisbt | Abillity to send mail to mantis adding bugs and bugnotes |
has duplicate | 0003320 | closed | grangeway | mantisbt | Email ability |
has duplicate | 0005233 | closed | thraxisp | mantisbt | Submission of issues by email |
has duplicate | 0005710 | closed | thraxisp | mantisbt | E-Mail-Import in mantis |
has duplicate | 0008339 | closed | vboctor | mantisbt | email reporting |
has duplicate | 0009964 | closed | jreese | mantisbt | report a bug via email |
has duplicate | 0010010 | closed | thraxisp | mantisbt | E-mail implementation to mantis as a new bug |
has duplicate | 0010550 | closed | siebrand | mantisbt | Report issue via email |
has duplicate | 0011831 | closed | atrol | mantisbt | Tickets can be created via email? |
has duplicate | 0013049 | closed | atrol | mantisbt | Report a new Bug via Email |
related to | 0006619 | closed | grangeway | mantisbt | Report by email concept |
related to | 0008984 | closed | SL-Gundam | Plugin - EmailReporting | Adding notes to existing bug via email |
related to | 0007086 | closed | SL-Gundam | Plugin - EmailReporting | Mantis email via IMAP + folders |
related to | 0010146 | closed | dregad | mantisbt | Send/Receive mail from issue |
I've put a test version to the request ;) Have fun. |
|
I haven't tried it, but it looks good. I guess we can include this (at least until we have a more flexible e-mail interface). I would appreciate it however if you provide a patch for the project admin interface. A few other concerns:
|
|
You can use it. It's an ugly hack this time. ;) A feedback to the user was not needed here, but of course, it's possible. And... edited on: 08-07-04 04:20 |
|
OK, looking forward to see what you come up with! |
|
I took a look to Bug 0001568 an it seems to be possible for me. Today I've introduced a new function for finding a user via its mailadress and one to create a new user account out of the box by a mail report. |
|
I'm not going to type 'OK, keep it up!' every time you post a status update, but I am reading them :-) Consider it implicit. |
|
The new patch adds the following functions to bug_report_mail:
todo: look into subject of mails for adding bug notes |
|
The mantis-working patch creates user accounts in the right way and is able to recognize mails as replies to an already opened bug. I think, this should be a ready-to-work solution this time :) The patch is against Mantis 0.18.3 |
|
Looks and sounds good. However, we're currently working on getting 0.19.0 out first. Could you wait until it's out and send in a patch against that (or even better, use 'cvs diff' with an up to date 0.19.0 CVS tree)? |
|
No problem ;) I'll wait for it. |
|
Hi, this looks really nice and I´m looking for a solution to report issues vie email. |
|
Yes, I know this. An other possibilily is to put the mail's content into a script doing a http post request. Both are solutions, I tried. But on my mantis host, I have a lot of But if you're interested in, I can integrate my older solution doing a http post request into this patch. Edit: I take a look, it's only a little change :) bearbeitet am: 08-12-04 16:54 |
|
Puh... The next thing, i will integrate is the possibility to have more than one mailaccount for every project. Some people asked me to add support for mail accounts per category. Have fun... Indy |
|
This is fantastic stuff! Keep it up. May I put up an idea: if you create a user account from the email (if one was not found), would you then delete the new account when the issue is closed? (as an option) Again - great work. |
|
|
|
This seems to be related to an old issue 3320: Email ability |
|
On having a bug with no reporter... I agree it is not the best idea - even if it is closed, it would be good to know who reported the issue for future reference. Will give this more thought. |
|
I'm sorry, the first patch i added today is not really good. The newer will work. Sorry. |
|
why isn't this bug marked as related to the bug 3320? |
|
Any chance we can get a version that works on stdin? This would be awesome for people using software like qmail where it makes more sense to pipe input directly from a .qmail file (this also puts a smaller load on the server in that it's only done when mail is actually received). Using the CLI-interface, PHP files can be invoked/executed from the command-line like any other type of script. So no need to go via the webserver. |
|
Yes, of course it's possible. |
|
The newest patch is able to handle MIME-Mails in a correct way. It works on my system, please test :) -- By the way... I have no idea this time to handle mails via stdin in a correct way. Ouhps: please remove the comment from line 224 in mail_api.php ;) |
|
Update to Mantis 0.19.2. I've added new configuration options, see README.bug_report_mail for details. |
|
Could someone please just include a download wich can be copied to/over the 0.19.2 version. |
|
A complete Mantis 0.19.2 including this patch can be downloaded here: |
|
Looks really nice. I'm currently in the process of installing a new Mantis with this patch applied and testing it. However, I found some small problems when the mails are sent via PINE:
Please see my patch mantis-0.19.2-additional-fixes.patch and include it to your patch if you like it. The patch has to be applied after mantis-0.19.2.patch. |
|
BTW, indy: I think you should change the status of this bug away from "feedback", otherwise it might be overlooked as Mantis developers think you still haven't answered their questions... |
|
Another remark (hopefully the last for today, sorry :( ): I additionally needed to patch Mail_Mime 1.2.1 according to http://pear.php.net/bugs/bug.php?id=1132 so that it will also decode mails with encoding "BASE64" instead of "base64". |
|
gernot: I do not have any privileges to change the state for this report. |
|
Additional remark: if you call bug_report_mail.php from the command line via "php", the host and path settings of your server will not be found. This leads to an incorrect message sent upon user registration (www.example.com instead of your server name, wrong path). So if you want to use this script via "Php" command line, you have to manually set $t_host and $t_path (at least, I didn't try it yet). |
|
I get a 404 here? I would REALLY like to test this out as I use a live bug-tracking system for a database-driven website that controls not only content to a site, but a organization's own reporting and membership system. Thanks in advance! |
|
I've put the patches and the modified version of Mantis back into the download-area. |
|
Thanks! |
|
Will this patch also become available for the new 1.x.x version of Mantis? |
|
Of course, but in the moment, I've not enough time to do this. |
|
I found a bug which prevented the body of an mime email to be added in the description field of a new bug report. file: core/mail.api.php if (strtolower($t_parts[0]['Content-Type']) == 'text/plain' || |
|
Fatal error: main(): Failed opening required 'Net/POP3.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/virtual/sfmc/public_html/admin/bugs/core/mail_api.php on line 22 I get this error from the cron.. I have this on a virtual host (hosting partner)... It's not permissions as the file is chmod' 655.. |
|
I've got a problem (maybe my stupidity). |
|
@jbrouhard: You need the Net_POP3 package from PEAR. @rainman: What's your POP3 server? |
|
The POP3 server is an Exchange server with POP3 access. I turned the debugging on in Net_POP3 and I've been diving through the code. I found a missing Auth_SASL package (which appeared to be optional, but I installed it anyway), but so far I still have a problem. I think I'm close. I'll post a followup if I get it working. I expect I'm missing another package. |
|
This is the exact server version I am running: It appears that I have an authorization problem. Here is the error I am getting: USER NOT supported authentication method!. This server supports these methods: NTLM, but I support DIGEST-MD5,CRAM-MD5,APOP,PLAIN,LOGIN,USER |
|
rainman: you might be able to changhe the settings on the Exchange server to allow for PLAIN login, or even APOP login. NTLM is Exchange's hook to the Active Directory. We run Exchange 5.5 where I work, so I can't really check this out. |
|
OK. The problem appears to be between the exchange POP3 server and Pear::Net_POP3 negotiating the authenitication method. If I hard code the auth method to 'USER' it logs in OK. I will attempt to take it up with the Net_POP3 folks. |
|
Found a minor problem with the attachment functionality: My POP3 server (MS Exchange (ARGH!)) was sending the message in multiple parts that ended up causing the mail_add_file function to try to save a file with no name. I think that this is because the user was sending the mail formatted in HTML, so the message was considered an attachment, but there was no name. There's probably a better way to fix this, but here's what I did to fix it: In file mail_api.php |
|
The Server admin got the Net_POP3 pear package installed, and now i'm getting: Fatal error: main(): Failed opening required 'Mail/mimeDecode.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/virtual/sfmc/public_html/admin/bugs/core/mail_api.php on line 23 I'm guessing mimeDecode is missing ? |
|
I think this package is missing: http://pear.php.net/package/Mail_Mime |
|
I found that the function to add a bugnote was not working because my project name in Mantis had a space in it. The bug id in the brackets looked something like this [Project Name 0000341]. To fix this I added a space into the regex in the mail_is_a_bugnote function and the mail_get_bug_id_from_subject function in mail_api.php. Old regex example: return pregmatch("/[([A-Za-z0-9-.]\s[0-9]{7})]/", $p_mail_subject); I think maybe I goofed when creating a project with a space in the name, but this fixes the problem. |
|
Thanks a lot for the bugfixes and patches. |
|
Heyho, the first patch for Mantis 1.0.0rc1 is submitted. Feel free to test! |
|
Now, the file adding seems to work! A complete version of Mantis 1.0.0rc1 including all required packages is available for download. |
|
I tried to download the solution from "http://arme-und-beine.de/download/mantis-1.0.0rc1.zip" but the file downloaded is corrupted |
|
I've load the file up again. There's also a bzip2 archive in the directory, try this one, if the ZIP archive fails again. (I hate ZIP gah) |
|
OK!!. |
|
Having an install issue... pulled down the above mentioned mantis-1.0rc1 bzip with the patches rolled in, went to the admin dir, tried to upgrade the DB and got the following error.. Parse error: parse error, expecting `')'' in /var/www/html/newmantis/admin/schema.php on line 349 line 349 is:
?> I also get the same error with the login page |
|
Fixed my issue, not sure if this is somthing that needs to be looked at... the problem was as follows - note I had to change the 'id' as I am upgrading an existing mantis and already had a user with id=2 --- mantis-1.0.0rc1/admin/schema.php 2005-08-24 09:58:20.000000000 -0400 -$upgrade[] = Array('InsertData', Array( config_get('mantis_user_table'),
Basically I needed to add the $upgrade[] ... line to the seccond 'mail' user addition code. |
|
When I run the bug_report_mail.php I get the following error: APPLICATION WARNING #100: Configuration option 'mail_debug' not found. APPLICATION WARNING #100: Configuration option 'mail_debug' not found. However I am still getting the tickets created in my test project under the catagory which they are supose to. What config file is the mail_debug variable suposed to be set in? and what is the recomended value for this option. |
|
RFE: Is it possible for this to support pop3s as well? out mail server doesn't use pop3 for security reasons. I am working around it right now but my solution is a bit of a kludge. |
|
RFE: The install doesn't take into consideration that you may be upgrading an existing DB. When it tries to create the mail user it does so with and ID of two... this wont work if you have existing users in your db. The program sould do a "select max(id) from mantis_user_table;" and then incriment that value by 1, assigning max(id)+1 to the id field for the creation of the mail user. |
|
RFE: E-mail Ticket addition kacks if there is no subject in the e-mail... If the e-mail sent to the box which mantis checks for e-mail tickets contains no subject it will not insert the ticket to the project with a "No Summary" error: APPLICATION ERROR #11 A necessary field 'Summary' was empty. Please recheck your inputs. To make matters worse the e-mail ticket is also del'ed which can lead to a situation where you can get accused of not responding to an issue, because as far as the user is concern their e-mail was delivered even though the bug_report_mail.php/mantis thew the isssue on the floor The mail_api.php should be changed to look and see if the Subject string is empty and write in a default subject so that when it's handed off to mantis it will properly insert the bug to your project. |
|
Right now this works great for submittion via e-mail however it's practical application is limited due to the fact that all future tracking after the inital e-mail is limited to mantis-only conversation. Is it planned to have this grow to the point where the origional submitter will be e-mailed on each ticket update? as well as an inital tracking ticket which they can reply to, which will automatically update the mantis bug? Without the ability to carry on a conversation regarding the bug over e-mail the usefullness of the submittion via e-mail is limited. |
|
@drtns: POP3S is possible if it's supported by the Net_POP3 package. The answer for submitters is already possible, if you enable creating of a new account for email reporters. Your patch will be integrated ASAP, thanks! |
|
In my case I received too the APPLICATION WARNING 100: Configuration option 'mail_debug' not found with no issue created |
|
Can anybody provide a list of features needed or bugs to be resolved until this feature can be integrated into a mantis-version? |
|
Of course: bugs:
features:
|
|
Hi guys, Thanks to all |
|
Hi all, If a 1.0.0rc2 patch is made can instructions be included on how to apply it to an already configured system? (I've already deleted the admin directory as directed so the schema.php will fail). Thanks, Al. |
|
I'll make a patch for 1.0.0rc2 this weekend and include a mail sample and an installation howto! |
|
Will there be a patch for RC 1.0.0rc2? Or will the patch for rc1 work as well? Keep up the good work! |
|
I'm sorry - until now I was not able to take enough time for making a new patch set for Mantis 0.19.3 and 1.0.0rc2. Maybe, the current patches will work, but there are still some bugs. |
|
Are there any plans to integrate this feature in Mantis in an official release? |
|
Jo... I'm ready. For Windows users I'll put ZIP-archives including the patch and necessary stuff on http://arme-und-beine.de/download @moppel: |
|
The code looks really nice and clean, I think we can integrate this after we put out 1.0 (we want to finally get that out first). A few notes:
Really impressive work! |
|
|
|
Hi. I've used Mantis 1.0.0rc2 patch. If I send mail with subject, mail body and attachment I get "It seems, there is no text... :-o" in bug description field. My settings are: |
|
This could be a bug. Maybe, please send me you testmail to gerrit.beine@gmx.de. I'll take a look. |
|
poll mail cron info. If someone need a win32 cron running as a service(i try it with XP Pro), i use a ".cmd" batchfile with "c:...\php c:...\bug_report_mail.php" It works great with a freeware from http://www.kalab.com/freeware/cron/cron.htm greetz & great work indy |
|
nice work, you have done so far. I hope this will improve our work substantially, unfortunately: investigating it a little further: in mantis-1.0.3rc3tar.gz schema.php had ^M (control-M) at the end of every line, so patch couldn't find the lines.... removing them, solved the issue. |
|
Hi all, I've made a quick and dirty patch for Mantis 0.19.4 and 1.0.0rc4. It's available here: http://arme-und-beine.de/projekte_mantis.html Until now, I haven't found enough time to test it, but I hope it's working. So long... |
|
It's all working!!!!! |
|
I've the following two problems |
|
regarding bugnote id 11929 ad 2) Only load one message: How many mails should be fetched at the same time
See also doc/README.bug_report_mail |
|
In my configuration the parameter is set to 20 |
|
Maybe, this could be to large. |
|
i've posted conceptual issue 0006619. |
|
I have to problems with this patch: |
|
FYI: I'm using an older release with my own bug fixes (see notes above) but I found a situation where when one of the reporter email addresses was invalid, the reply from the postmaster was added as a note, which caused another email to go out to the reporter, which caused another reply from the postmaster ... Well, you get the picture. I fixed it by checking the from address and ignoring emails from the postmaster, however there's probably a smarter way to fix it. |
|
Can i use 1.0.0rc3 patch for Mantis 1.0.0 relase? |
|
I'm using the patch with 1.0.0 and works fine. |
|
Hy guys, I am very interested in this feature of Mantis but I don't have the possiblities to test this patch at the moment. My question is: How does the E-Mails look like?? Is it difficult to write them, that the system can work with them? Is it a very robust system, or is it possible that a single character can crash the whole system?? C YA - []Nekro |
|
I just installed this patch to 1.0.1 and it is great! A few little glitches I have noticed: -Email are not removed from the mailbox. Easily solved as indicated by jaapandre |
|
Hi there, I'm working on the next "release". I'll submit it after the 5th of march (after the chemnitzer linux days) So long... Gerrit |
|
Would there be an easy way to: -Keep the emails on the mail server but avoid creating new issues each time they are fetched without deleting the emails? I would like to keep a trace in my mailbox. What I do for now is a rule on the mail server to copy email to a second mailbox from which mantis will fetch emails and deletes them afterward. |
|
Hi, How can I apply the patch to my mantis system?? Which programm do I need?? I am using a WindowsXP OS... C YA - Nekro |
|
Take a look to this site: http://arme-und-beine.de/projekte_mantis.html I offer some patched archives of Mantis for download. |
|
I cannot get the email attachment to be added to my issues. I have the Mail_MIME package installed... and I can attach file to other issues for the same project manually just fine. Any idea what else I could check? EDIT: Ok, I isolated the problem to this line that fails in file_api.php: move_uploaded_file( $p_tmp_file, $t_disk_file_name ) I checked both src and dest file names and they are Ok... plus I see the uploaded file created properly in my /tmp/ directory. It does not seem to be linked to privileges and I have safe mode OFF. I am using DISK upload. EDIT 2: Was this tested under Linux with DISK storage? From what I read, the move_uploaded_file function will only work if the file being moved was actually uploaded. When you save the file you got from the POP3 server to the /tmp/ directory it does not look like it qualifies for that function and it refuses to move it to my project's upload folder. I finally got it to work like this: file_api.php: mail_api.php: |
|
What about setting the priority in Mantis based on if the email is sent with low / normal / high priority? Using a set of variables to configure to what the email priority should translate into Mantis priority... EDIT: Made a quick & dirty patch to enable this, seems to work OK: config_inc.php: mail_api.php - mail_parse_content mail_api.php - mail_add_bug |
|
Indy, you indicated that you had a new release in the work for better Outlook support... will this be released for 1.0.x or will it be only ready for the 1.1 release that will incorporate the email reporting feature? I am having numerous problems with Outlook emails which make email submission unreliable in my environment. I am eagerly waiting for any improvements! |
|
Hi, I'm sorry. On May, 2nd the thesis period will be over, then I'll offer new patches with some new features and fixes, especially for mails sent with Outlook. So long... |
|
Hi, I'm back ;-) Now, a patch for Mantis 1.0.3 is available. I've also added the patches by EBY with some minor changes. In this version, the processing of mails changed: bug_report_mail no longer fetches all mails into an array. Feel free to test and report bugs, if there are any. So long... Indy |
|
Can someone clariy for me what this patch will do? I've installed it and can get incoming emails to be added as new issues. But, what I really want to accomplish is allowing users to reply to emails that mantis sends out on existing issues and have their reply added as a note to the issue. Can this patch do that? My testing is just with simple text emails. |
|
How exactly would i set this up on a Windows server with exchange running in the background? My linux knowledge leaves much to be desired. My mantis installation is currently running 100% with no issues but it is a business requirement that can accept incoming emails for tickets. I've been through the entire note list so far and not much has been cleared up. |
|
^^^ignore that, i got it working \o/ ^^^ Sort of, anyway. I've added the following to my config_inc.php The MIME parsing is functioning correctly but the auto signup is not. I've snt mails from various accounts but it always reports the user as the mail reporter. I've since deleted the mail reporter user and now the tickets have no reporter whatsoever. Any help there pls. Also, i've noticed that the version number have a conflict. I've loaded a test version of mantis 1.0.3 and the latest mail patch but the version number displaying at the bottom of the screen reports Mantis 1.0.0rc4. Any help would be appreciated! |
|
Just got around to try to install your latest patch... could there be an error with the patch file, I highlighted in bold what I think should not be there, i.e. replace with 'mantis_project_table'. BTW, I am applying the patch to a clean 1.0.3 install. $upgrade[] = Array('CreateTableSQL',Array(config_get('mantis_projectfiletable'),"
Update: I found other issues in the patch file for the following files, could you have done your diff on a 'non default 1.0.3' build? I patched files manually and all seems fine now. File to patch: mantis-1.0.3/admin/schema.php |
|
okay then, i was just being stupid... Got my mails working. It sends and receives emails without attachments briliantly. Problem now comes in when i send a message with an attachment(doesn't matter if it is the first issue or any of the subsequent responses). The issue will be created and the subject is placed in the summary field but in the description it states "It seems, there is no text... :-o" The file does not get attached to the issue either. |
|
how would i go about setting the following? I need to exclude all email addresses (except internal) from receiving the signup notification. I also need to exclude certain email addresses from receiving any mails whatsoever. These will be messages that come from other systems relating to downtime, program errors, etc. Any help would be appreciated! |
|
Is indy still around? I need to install the 1.0.3 patch but i need the windows version... I checked his site and there is nothing available. The last patch is mantis-1.0.0rc4.zip... I have a feeling that this patch will resolve my issues. |
|
Yes, he is ;-) I'll create a patched version of Mantis 1.0.3 this evening and post the URL here. |
|
Thanks indy, any news on that URL? |
|
using Mantis 1.0.1 I noticed that although mail_fetch_max was set to 1, multiple emails were imported and not all correct. I changed this: into this : Most likely there is a better way, if so please let us know. |
|
Heyho, patched versions of Mantis 1.0.3 are available now: So long... |
|
Thanks for the patched release. Strange error though. If i install a new version then the db is setup perfectly. If i update an existing installation then the db changes are not applied. I cannot access the manage projects section as i get the following error: APPLICATION ERROR 0000401 I've checked the db and true enough the mentioned fields do not exist. They do exist on a new installation though. This is causing a bit of a problem as i cannot upgrade my current live release to the latest version. Any ideas? |
|
Please take a look to doc/README.bug_report_mail Quote: If you are alway running Mantis you have to alter your projects table So long... Indy |
|
Yeah, sorry about that. The typo had me a bit confused... I think alway should actually be already. Different problem now though... I've enabled auto_signup to create a user for each incoming ticket. It imports the first mail from a user perfectly but if i submit a 2nd email it will not import the data. I enabled debugging and ran bug_report_mail.php in IE. The following displays: Array ( [0] => Array ( [0] => 27 [id] => 27 [1] => Mail Requests [name] => Mail Requests [2] => 10 [status] => 10 [3] => 1 [enabled] => 1 [4] => 10 [view_state] => 10 [5] => 10 [access_min] => 10 [6] => [file_path] => [7] => This is for incoming mails (rfs@domain.com) [description] => This is for incoming mails (rfs@domain.com) [8] => mail.domain.com [pop3_host] => mail.domain.com [9] => DOMAIN\RFS [pop3_user] => DOMAIN\RFS [10] => Password [pop3_pass] => Password [11] => 0 [pop3_categories] => 0 ) ) Array ( [Received] => from TESTSVR ([10.1.0.200]) by server.domain.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2650.21) id PGMJG0QS; Wed, 19 Jul 2006 11:34:03 +0200 [Message-ID] => 291B76E98794D511878C0010B5EC4BEE02A86E07@mail.domain.com [From] => TEST System [To] => user@domain.com [Subject] => TEST New company registration [Date] => Wed, 19 Jul 2006 11:22:30 +0200 [MIME-Version] => 1.0 [Content-Type] => text/plain; charset="iso-8859-1" [X-Mantis-Body] => New client Registration Company: edwed Contact Person: sds Telephone: 21 21 Ben3 [Priority] => 30 ) Below that i get: APPLICATION ERROR 0000801 Weird indeed. This used to work perfectly before i applied the latest version. Help please! |
|
We receive from time to time mails without subject and the import script stumbles over this. where the original code was : Before i forget, adjustment has to be made in mail_api.php. Finally want to confirm the issue and fix reported by EBY (0012226) when using DISK as storage solution. Cas |
|
I'll integrate this new patch and fix the errors on weekend. So long... |
|
Not too sure if you've done the integration yet but if not would it possible to integrate directly with version 1.0.4. which was released over the weekend? |
|
Hi bmcool, I'll do this. So long... |
|
i downloaded the copy from indy's link on 7/16/2006, but when I try to click the link for managing my specific project (manage_proj_edit_page.php?project_id=1), I get the following error: SYSTEM WARNING: main(PEAR.php): failed to open stream: No such file or directory It looks like all necessary pear packages are in it, except for this file. Do I need to download this file from another package off pear.php.net? Thanks. |
|
You may use the PEAR.php from http://pear.php.net/package/PEAR |
|
I also can confirm BMCCOOL's comment (0013114) that when wants the user to be added if it does not exist, the latest patch acts strangely. It indeeds generates a "User not found" error. Cas |
|
I also can confirm BMCCOOL's comment (0013114) that when one wants the user to be added if it does not exist, the latest patch acts strangely. It indeeds generates a "User not found" error. Cas |
|
I have spotted another issue (and created the solution for it). function mail_add_bug Add filesif ( null != $p_mail['X-Mantis-Parts'] ) { then the mail_add_file routine should be like this --------------------Very dirty: Adds a file to a bug.function mail_add_file( $p_bug_id, $p_part,$p_filenr ) { Hopefully this helps others too. Cas |
|
Thanks to cas, I've added your patch. |
|
Heyho, I've updated the patch for Mantis 1.0.5. See: http://gerritbeine.de/download/mantis/ The mail parsing is a complete rewrite, now it should support all combinations of embedded HTML and text and also different encodings. So long... |
|
Hi, I've recently upgraded to 1.0.5 but get the following error when i run bug_report_mail.php [pear_error: message="Generic login error" code=1 mode=return level=notice prefix="" info=""] This is just the portion of the error that i think is causing the error. I've never seen it before and google doesn't know much either... Any ideas? |
|
Indy, i have found 2 little issues. One of the nice things of this add-on is that when a second mail arrives with the same topic, it adds it as a note to the original. If you find time to look at this, could you also strip the "RE:" that outlooks adds to the subject when replying such that also those messages can be added as a note ? |
|
A lot of attachments were lost after the crash of mantisbt.org. Indy, can you please attach the latest code. I will patch this Mantis installation to show the broken attachments. |
|
Hi there, the latest version of the mail import patch is available again. It is still unchanged, I'll fix the noticed issues when I'm back from Kyrgyzstan in the middle of October. |
|
Wow, indy! What are you doing there in Kirgyzstan? Are you Russian? |
|
No, I'm German. ;-) |
|
That's cool, anyway |
|
Hey everyone, just wanted to let you know the good news that Indy has joined the Mantis development team and we will work together in getting this feature into Mantis codebase. The first step will be to write the requirements of the feature in the Wiki. The aim of this excercise will be to indentify any necessary changes that are required before including this in the offical codebase. Once this is done it shouldn't be a lot of work to implement the changes and get this stuff in. http://wiki.mantisbugtracker.com/doku.php/mantisbt:requirements I would like to take this chance to thank Indy for his work so far and looking forward to work closely with him once he gets back from his business trip. |
|
I'm just testing this nice feature under Windows. I had some difficulties with attachments because of the hard-coded '/tmp' in the mail_add_file-function.
} |
|
Indy, i notice different behavior if i run the bug_report_mail.php script through a commandline. Amongst other things, retrieving the reporter id seems to fail. If i run the script through the browser all works fine. |
|
This is a fantastic feature I'm really hoping to use, but I've hit an error. When I go to Manage/Manage Projects/'specific project' (manage_proj_edit_page.php) I get the following error: Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /mantis/Mail/Parser.php on line 7 I made a complete new install using the 1.0.5 package from Indy's site: http://gerritbeine.de/download/mantis/mantis-1.0.5.tar.bz2 All the files and db tables apear to be in place, and the rest of Mantis functions fine. Any ideas? |
|
Hi! I need some help! At here we use utf-8 for mail encoding. This is not too nice in mantis when I report a bug by mail. |
|
vJack, I had the same problem. The cause is the Parser.php. The php scripts in this file are wrote to support only PHP version 5.x. So when I tried to make it work on my PHP 4.x hosting, it resulted in similar errors. Somehow the code should be refactored to support both versions PHP 4.x and 5.x, I guess. |
|
wrt my post (0013367) Anybody have any ideas how i can get past the "generic login error" when i run bug_report_mail.php? |
|
hi everyone I'm trying to get this nifty feature working in windows. so far I'm not getting any errors but I'm unsure of a couple things. Is the 'mail' user that needs to be set up the address that we would be sending e-mails to to report a bug via e-mail? and also is opening bug_report_mail.php from the web browser the proper way to retrieve the e-mails for entry into reporting the bug? |
|
The Mail\Parser.php uses the new format specifiers which are not supported by PHP 4.x. Hence, this will not work on the PHP servers running on most of the Mantis installations out there and won't be compliant with Mantis current minimum requirements. I got it passing the syntax check, but haven't tested it, by removing the following:
It would be great if we can use an older version of this module which supports 4.x. In the worst case, we should avoid including these files if the installed version of PHP is 4.x. |
|
The Mail_Parser class is written by me. Sorry, I have no more PHP 4.x installations running... ;-) |
|
what syntax must e-mails follow to be parsed properly for reporting issues? |
|
Is my understanding of this correct? After installation of the patch you go to manage project accounts and add a user/email address and set up a reporter account? and set it up for the current category of the project? upon running bug_report_mail no errors get generated and nothing changes in the database even when I try to get it to be more verbose. Is there something glaringly obvious that I'm missing? any assistance would be appreciated. |
|
Small issue with your debug mode... emails are always saved to file to my temporary folder even if debug is off. Looks like you do not check if the debug mode is ON or OFF in the mail_save_message_to_file function, despite the fact that you retrieve the config param value. I moved the call to the mail_save_message_to_file function in mail_process_all_mails like this: ... function mail_process_all_mails( &$p_account ) { ... if ( $t_mail_debug ) { #mail_save_message_to_file( $t_msg ); ... |
|
Does anyone have a patch for this feature based on 1.1.0a2? |
|
Sorry, there is no newer patch at the moment. I'm sorry. When I'm back in Germany, the development of my patch will continue. |
|
Is there a reason this has not been committed to the development tree to officially supported, instead of having to patch every release? |
|
Victor gave me already CVS access, but I was not able to commit the patch into the offical Mantis sourcecode. I was very busy the last months. |
|
Where I can findout all the modules updated for 1.1.0a1 |
|
I would just like a quick confirm, that the 1.0.5 patch works for 1.0.6?? |
|
Same question: I would just like a quick confirm, that the 1.0.5 patch works for 1.0.6?? |
|
A small problem I noticed and for which I am trying to find a solution: If you forward the same email to Mantis twice (or different emails with same attachments names and order) to add a bug note to an existing bug... then on the second email, the system will add the new bug note but when it tries to add the attachment it will fail and result in a "duplicate file" error. Although this mod adds a prefix (1-, 2-, 3-, etc.) to each attachment in the same email, it will have problems when subsequent emails for the same bug have the same attachments names and in the same order. As a result, the email is parsed into the existing bug note, the attachments dont make it and the email is left in the mailbox after the error is triggered. This means that on the next email fetch, the email is still parsed and bug note added again and failure on attachment (duplicate file name in database) will again leave the email in the mailbox... repeating over and over... with email notification going out non stop each time the email is parsed again. You get the picture. I am trying to find a solution for this: deleting the email prior to this attachment parsing is a quick fix but not intuitive to users as their attachments are just dropped. Ideally, a way to number attachments globally would work... if at the time where the system starts numbering attachments for a new email, it 1st fetched the max attachment prefix number for the current bug. More work. |
|
I made a quick and dirty fix for the problem I just reported: I do not use the attachment numbering code found in mail_api.php, I could take out the numbering completely but decided to just comment out where it added when passed to the file_add code: #EBY 20070327 - bug with prefix file_add($p_bug_id, $t_file_name, $number."-".$p_part['name'], $p_part['ctype'], 'bug');
Instead when it comes time to check for the unicity of the new attachment file name in the database, I replaced the check as follows: #EBY 20070327 - fix duplicate attachment issue if ( !file_is_name_unique( $p_file_name, $p_bug_id ) ) {trigger_error( ERROR_DUPLICATE_FILE, ERROR );}This works great and if I forward more copies of the same file in different emails they all get added with a different unique prefix. Not a very elegant solution (dont like that kind of loop) but it does the job for now! |
|
Regarding the 1.0.5 patch for Email on release 1.0.6... I got mine to work although I did have some problems that required minor edits. I don't think the problems I encountered were related to the patch being made for 1.0.5 but rather just small bugs that caused minor issues on my specific setup. |
|
Hi everybody, it's a very nice stuff !! I've developped the following evolutions on the mail reporter functionnality:
you will find a complete 1.0.6 distribution on <a href="http://boulayj.free.fr/Open%20Source/mantis1.0.6%20+%20mail%20reporter.zip">my blog</a> |
|
The zip file seems to be corrupted |
|
Will there be a version for the 1.1* ???? |
|
Yes it will, when I find enough time to work on it again. |
|
Maybe somebody else can do the integration if you dont have the time... (I can look at it if you like...) |
|
I would love the email format to be compatible with the bugzilla format: http://www.bugzilla.org/docs/3.0/html/api/email_in.html Some thought has gone in to the Bugzilla format, I think it would be a good idea to learn from their experience. Plus compatability makes it easier for people to switch to Mantis. |
|
I was in need of this feature for Mantis 1.1.0a3. This is the result. It's based on mantis-1.0.5.patch.gz Changelog:
|
|
I forgot to terminate a line in mail_api.php. ( "Mantis-1.1.0a3-changed_files_only.zip" ) My apologies for that. I added the package again with the correction in it ( "Mantis-1.1.0a3-changed_files_only-v2.zip" ) Can somebody remove "Mantis-1.1.0a3-changed_files_only.zip". I can't do it myself. |
|
How to apply a patch? Step by step instructions for for reporting via E-Mail patch? I'm running mantis-1.1.0a3 on a shared host. 1) I don't know how to apply the patch :=( HELP! 2) After paching, files in ""Mantis-1.1.0a3-changed_files_only-v2.zip" should be copied 3) I assume that i have to configure an e-mail forwarder for "reporter@domain.com" like this: Correct me if I'm wrong. |
|
How to apply a patch??? I'm running mantis-1.1.0a3 on a shared host. 1) I don't know how to apply the patch :=( HELP! 2) After paching, files in ""Mantis-1.1.0a3-changed_files_only-v2.zip" 3) I assume that i have to configure an e-mail forwarder for "reporter@domain.com" like this: Correct me if I'm wrong. |
|
I discovered one last small problem that could occur. So thats fixed in Mantis-1.1.0a3-changed_files_only-v3.zip Because this was the second problem which required patching i tested all the changes. I couldn't find anymore problems. |
|
@reszel In the /docs/ directory you'll find 2 files called: After the script has been succesfully installed you can log into the admin account. Go to "Manage projects" page. Click on a project. At the bottom of the page you'll find a form to activate email retrieval for that project. Hope this helps |
|
Hi Indy, I have a couple of things that I think could improve this even more: Keep up the great work! |
|
Why isn't this in CVS branch?? |
|
Why isn't this in CVS branch?? |
|
See note 0013961 davide73italy ;) |
|
i still dont get how do i activate the reporting by mail... |
|
If a email Report via Email with attachments recieved. Line 466 in mail_api.php while( !file_is_name_unique( $number . '-' . $p_file_name, $p_bug_id ) ) { it have to be: while( !file_is_name_unique( $number . '-' . $part['name'], $t_bug_id ) ) { |
|
If a email Report via Email with attachments recieved. Line 466 in mail_api.php while( !file_is_name_unique( $number . '-' . $p_file_name, $p_bug_id ) ) { it have to be: while( !file_is_name_unique( $number . '-' . $part['name'], $t_bug_id ) ) { |
|
can someone please help me..i have been waiting for many days now i still dont get how do i activate the reporting by mail... |
|
Hi DaVinci, In the POP3 settings fields, you must type the POP3 connexion parameters. POP3 Host : your mail server Once your pop mail server is configured, you can also configure some parameters in the configuration file In order to execute the automatic reporter, you have to go on page I hope this will help you ... |
|
thanxx for the reply.. error:<db_username> [pear_error: message="-ERR authorization failed" code=-1 mode=return level=notice prefix="" info=""] error:helpdesk@mydomain.com [pear_error: message="Generic login error" code=1 mode=return level=notice prefix="" info=""] |
|
im am the administrator an yet i get the error above |
|
It seems that your connection parameters are wrong !! Try to enter the user account only : "helpdesk", without the complete email adress. It should work ! Could you also give me the version of the mail reporter extension you use ? |
|
im using: and i appereciate ur help but i do not understand what do u mean http://your_mantis_server/bug_report_mail.php This is what i want to do: http://www.mantisbt.org/forums/viewtopic.php?t=3429&highlight= |
|
Thank you for great patch! :-) it makes issue and notes for existed issues by email. But it don't create notifications to email reporter via email even with "creating new accounts" option enabled. I'm using mantis 1.0.5 with mantis-1.0.5.patch.gz |
|
Ummm... First of all, thanks to all for that huge and great work. Second, I have configured this patch ok and I can report issues via web OK including spanish caracters like ñ, á,é,à .. etc... But using mail reporter plug-in I can report issues via email IF NOT contain these spanish caracters... if contain it i get this error: How can solve it????????????????Please. APPLICATION ERROR 0000401 Many thanks in advance. |
|
After a lot of work making it work for 1.0.8, i finally have it working. Thanks for such a great patch, but i would love to see this new feature in the upcoming 1.1.0 version! |
|
Please add the following line to the file mimeDecode.php to prevent adding of e-mail certificates (to verify that the mail is from me) as an attachment to a bug. This line needs to be added around line 292 in the function _decode in the above mentioned file. |
|
Found another small issue. If an email is retrieved with an attachment but no body text, the bug/issue is created but the attachment is not added. |
|
eagle00789, |
|
I've played with this for a while and would love to see this accepted into the Mantis sourcecode. Very useful patch, this... |
|
Please add this one to the project! |
|
Please add this one to the project! |
|
I've been abroad for a while, but now I'm back. So long... Gerrit |
|
Hi Gerrit, I ask, because I'm on the way to integrate this great patch into my prod version 1.0.7 (which also works for 1.0.8) |
|
Hi all, thanks in advance |
|
Have a small update on the mail_api.php. --------------------return true if there is a valid mantis bug referernce in subjectfunction mail_is_a_bugnote ( $p_mail_subject ) { Perhaps this can be included in the next version. Cas |
|
hi, Thanks in advance. |
|
jboulay in note(0014370) you have a bat file to run the mail call function. I have a test instance of Mantis on Windows XP and I changed the paths in the batch file to match my setup and it works. I've a production version on Windows 2000 server and I can't get the batch file to work. I'm stuck. Do you know what I need to change to have it work on Windows 2000 server? Thank You |
|
Any news about this patch and its availability for 1.1.0? |
|
I tried to integrate this patch to mantis-1.1.0 and got the following error: APPLICATION ERROR #18 Page redirection error, ensure that there are no spaces outside the PHP block (<?php ?>) in configinc.php or custom*.php files. Please use the "Back" button in your web browser to return to the previous page. There you can correct whatever problems were identified in this error or select another action. You can also click an option from the menu bar to go directly to a new section. I have checked the config files and the custom files and it doesn't have any spaces outside php block. Any solution for the above problem? |
|
I have managed to setup the plugin in mantis-1.1.0. The issues was with config_defaults_inc.php and I used the new config_defaults_inc.php and added the additional config parameters for mail_report. However I am unable to create bug from email. I am using a secure POP3 server and have hacked core/mail_api.php to modify the POP3 port to 995. Is there any way out to fix the issue with secure POP3 server? |
|
I have downloaded and installed 1.1.1, is this issue built in to this new version or do I still need to download and apply this patch? |
|
scubie, A longer time ago it was moved from 1.1.0 to 1.2.0, unfortunately. |
|
Thanks brody - still learning to use the system, important lesson learned! |
|
libregeek, In addition to changing the port to 995, add ssl:// before the mail server. E.g., ssl://pop.gmail.com Once I did that, I was able to connect to a secure POP3 server and retrieve the mails. DaVinci, This may also have been the cause of your "Generic login error" error message. |
|
Just a couple notes:
Thanks for the work you've been putting into this, Indy. It's an important feature! |
|
Strangeways, My working copy is on V1.0.7; if you or anyone else is interested, I'd post the fixed file to this thread |
|
Hi Brody, Thanks for the information! I would be interested in seeing the changes you have made to parser.php. My working copy is V1.1.0, but I'm trying to put together a package of changed files for V1.1.1. Perhaps I could incorporate the bug fix into that and then post the new package here. |
|
Strangeways, I hope that its enough to only attach the mentioned file "parser.php". May changes are commented with (brody). If you have questions, contact me... |
|
Thanks Brody! This was very helpful. I ended up including both html parser commands and put an operating system check to run the correct version. I also ended up rewriting the setParts function and made sure to check for the disposition attribute on each part. I've put together an UNOFFICIAL package for V1.1.1 and attached it to this issue. The changes are listed below:
As stated above, this package is unofficial. It also needs testing. Indy, feel free to include any of these changes in an official packaging. Something else I'd like to do at some point is add a checkbox next to the POP3 Host field to indicate a secure POP3 server. This would automatically add ssl:// to the beginning of the mail server string, and also change the port from 110 to 995. |
|
Just uploaded a new package: Mantis-1.1.1-changed_files_only-unofficial-v1.tgz There was a bug in the setParts function that was causing the content to appear to be duplicated when there was no attachment. My apologies. I've fixed it to only concatenate the content when it is in sub-parts. The previous package can be deleted. |
|
Strangeways, Although I did not take a look into your changes, but your assumption isn't that correct, I think. I got all parts as attachment including that meant as body. Using a debug session I first found out that setParts() got called recursivly to get sub parts and uses all parts in its last loop. Second the "disposition" test came to check between text body part(s) and text attachment. All attachments (with disposition set) should be handled as attachments (addParts) Regarding the htmlparser - my version is a java class around jericho-html.jar, which also could be used under linux. Because the html parser could be configured inside the configuration (I'm right?) it would make more sense to support a "flying file" parameter, which tells, where the file should be included. Thus you'd get in either case as shell_exec ($html_parser) and inside configuration |
|
Great, it works. Thanks! I think I found something though. If I configure Mantis to pick up 5 messages at a time, it doen't seem to call the "QUIT" command. Without the "QUIT" command, our GroupWise server doesn't delete messages, although I see Mantis send the "DELE" command. If I make $g_mail_fetch_max 1, everything works just fine and messages are picked up, processed and deleted from the mailserver. |
|
Just wanted to provide another patch here - but that failed without an error message. This patch circumvents the problem (i have currently), if one can't delete mails on a pop3 account for some reasons. Thus you would set "g_mail_delete" to OFF. Side effect: On every call of the php script you duplicate your issues. I extended the mail_api.php to check, if an e-mail of an account (of a project) is newer than the last checked mail and only add newer mails. Last saving the datestamp of the last added mail, so only then again newer mails are filled in. |
|
Second try - it did :-) see last attached file (mail_api.php.patch-v2) |
|
I cannot get the email attachment to be added to my issue and for the description always “No description found” |
|
I attached the debug file |
|
Thanks for the debugfile - this file is a Mime-Mail (in my opinion), thus you need to switch at least $g_mail_parse_mime to ON. Besides that, there is a typo in your configuration I guess: |
|
hi, i added a few lines of code to set the category and severity from the email message when reporting a new bug. --- mail_api.php-orig 2008-02-14 15:07:51.863103100 +0100 +
|
|
I run it with $g_mail_fetch_max set to 1 and a cronjob that fetches mail every minute. Should work fine as long as there aren't any e-mail bursts. |
|
Hmm, found something else. This one is nasty... If I report anything via e-mail, the URL Mantis puts in the confirmation e-mail is screwed up. My URL is rewritten to http://www.example.com./view.php?id=xxx (yup, mind the period before the slash). I know the example.com domain is mentioned in the default config, but in my config it's gone. I searched through the program files, but couldn't find anything suspicious. Ok, I'm not a programmer... If I do something with an issue in Mantis itself, everything's fine. But as soon as I interact with Mantis through e-mail, the URL gets whacked. |
|
One advice on the added POP3 ability, which works on my system. Therein the database is changed and a new user is added to the user base. The user per default has nomail@localhost as user, but of not acknowlegable default email settings, set additional a preference record with all e-mail traffic for that user is switched off. Furthermore it might be useful, to protect that user against deleting and changing |
|
@Woefdram,0004286:0017046: You right, this seems to be a bug, maybe a not initialized variable, my disturbed URL is more crashed compared to another manually added issue, which says (e.g.): by Mail Reporter, the URL is I guess, that has to do with the fact, that the Mail Reporter is run directly with php.exe, while the other is run through the webserver |
|
Using the Mantis-1.1.1-changed_files_only-unofficial-v1.tgz I'm having a problem with the description not being added. I have the mail patch running in mantis 1.0.6 and have the config file with Parse MIME = ON and the description is included. But on the 1.1.1 version with the Parse MIME = ON get the error no description found. I can look at the file from the debug and it has the description. I'm running on Windows 2000 Server. |
|
To fix the URL in the email just add the path to your Mantis installation in the config_inc.php file or added it in the Configuration section in Mantis. Works for me :-) |
|
@Loki: What did you configure there - Would you tell us? I instead changed config_defaults.inc, made some translations (i.e. de, en) to circumvent this problem with a correct message in the e-mail. I'll attach adequate patches including those for the above mentioned languages |
|
Hi. In the config_inc.php or in the configuration Mantis version 1.1.1 |
|
Using the Mantis-1.1.1-changed_files_only-unofficial-v1.tgz I'm having a problem with the description not being added. The Description is included if the email format is Plain text. Parse MIME = ON I've turn on: This setting I don't understand for WINDOWS 2000 Server. How would I set this the example is not for Windows HTML Parser Command
Any help would be Great! |
|
@Loki: The by default mentioned HTTP-Parser is a plain linux tool and the execution command is also unix like. I needed to change several lines in the mantis software to integrate such an html-parser on windows. Please take a look at my note 0004286:0016968 and strangeways' notes below. The unofficial patch should prepare to use a html-parser also under windows, as strangeways wrote. |
|
@Loki: Thanks for the tip. I put my Mantis URL in $g_path and now the links Mantis generates are correct. |
|
@Woefdram: Welcome. @brody: I read the notes and from what is said in them the 1.1.1 should only need these 2 config settings: This is how they are set but I still get 'no description found' in the description in Mantis. If this setting htmlparser\parse.bat ${f} needs to be added I'm not sure where it goes. Thanks |
|
Loki, i>@strangeway</b: Because I think there are a lot of users, who are running mantis on windows, might it be interesting to generally and as an option to the plain linux variant integrate my solution into the next release bundle? I think, that Java will be available on most OSes including Linux and Windows. |
|
@brody: Thanks for the clarification on why the html is not working. I have Mantis 1.0.6 using the mail import and it imports the description when the email is in HTML. So I'm confused as to why that works on the same server that I have the test version 1.1.1 on? I'm going to hold off upgrading the production code from 1.0.6 to 1.1.x until I've tested a html parser (jericho-html). |
|
Loki, that is indeed interesting - I'm using V1.0.7 with pop3-email extension on Windows, but not V1.1.1; maybe strangeways could help around V1.1.1 and its differing behaviour concerning the html parser on Windows. The original pop3-email extension is from V1.0.5, but there was no html-parser inside (except the configuration for unix OSes). What is your e-mail backend? Some of them deliver html emails in both html and text. The parser (of 1.1.1) has been changed by strangeways with parts of my code as written in that note below. I tested it thoroughly on my environment. If you would send me such an email, which works on V1.0.6 and not on V1.1.1, I could take a look on it. I've again read your 0004286:0017210 and maybe found a hint to your problem. You wrote about two settings and what they are in your configuration, if I'm right. While the first one seems to be correct (its a switch), the second one is no switch, but the commandline to call and this one I've set to "htmlparser\parse.bat". Please take in mind that my setting assume a slightly other kind of calling mechanism as with unix, but strangeway should have adapted it in V1.1.1 |
|
b>@Indy</b: Thanks again for providing the pop3 patch. A question: Do you have an idea, why umlauts are destroyed on reading (or saving the mail) as new issue or note? e.g. "ü" get converted to ü |
|
I have successfully installed the email_reporting patch for mantis-1.1.1. The mails sent to a POP3 account is successfully registered in the mantis system. But the reporter doesn't get any confirmation mail or the bug_id. How can I send back the issue_id to the sender, so that the user will get the issue_id and use it as a referencein future. Is there any patch available? If not can I work on this feature? |
|
hi all, we are using at the moment mantis 1.0.8 with the mail report function on a Linux Server and it's running perfect. In the future we want to use mantis 1.1.1 with the mail report function on a Windows 2003 Server. Now I'm testing it and I've got many Problems with the mail report function. I know that we must change something in the parser.php file and that we need a htmlparser for windows. @brody: you wrote in note#16968 |
|
I had some problems with my provider (save mode is set, so HTML parser cannot be launched). So I changed the function setBody in Mail/Parser.php:
The change causes an include of the mailbody in the incidents description field when parsing of HTML mails is rturned off ($g_mail_parse_html = OFF;). It uses striptags() to remove HTML tags from the body. If you like, include it. |
|
@libregeek's 0004286:0017342: I guess that the Mail Reporter adds new issues to your issue list. If the user gets not registered automatically on sending a new issue (as in my case), he must register at the site and switch its settings to be notified on new issues, but that are all issues. If you register new users ($g_mail_user_reporter = OFF), it might be additional implementation effort to get the user notified about his own issue, because mantis' e-mail notification on new issues does by default only notify developers and above, if they want to be notified about it(personal settings). Additionally you can influence this maybe through settings in the configuration. Take a look at $g_notify_flags |
|
@jojow's 0004286:0017345: The parse.bat is only a wrapper around "my" htmlparser, the jericho-html parser, I use. If you need it, I'll could put it here, but I think your parser might be wrapped through another call as mine. |
|
I've tested the "strip_tags" - function. With only this function I get an error 401 and the INSERT into the database won't work.
|
|
that's funny: |
|
@jojow: I found a small PHP package which possibly fits the needs: http://php-html.sourceforge.net/html2text.php But I did not try it. By the way: I allways get a strange error message when adding comments with the "Add Note" Form on your installation: Fatal error: Allowed memory size of 16777216 bytes exhausted (tried to allocate 199508 bytes) in /home/mantisbt/public_html/bugs/core/database_api.php on line 171 Does not belong here but fyi... |
|
@brody: Thanks for your clarification. In my case the implementation is like the following - I don't create a new user when somebody sent a bug(via email) to mantis. Instead, it uses a common account(like mailUser) for all users to report the bug to mantis. I am wondering how difficult it will be to add some email-ids to a issue so that they will be notified about the bug status and notes. |
|
I managed to get German umlauts working by changing Mail/Parser.php: in setBody() I added a new line at the end: <code> Windows: parser command with parameter
</code> In setSubject I also added htmlentities(): <code> This works for me with plain text and html mails. |
|
Hi, Here at the City of Amsterdam (www.amsterdam.nl) we've been using this GREAT addition to mantis for about 6 months now. We'd like to update to Mantis 1.2. But as you know this e-mail reporting function does not work in that version of Mantis. Are there any plans to for an update for this function to work with Mantis 1.2? Perhaps as a plugin even? Thanks for your reply! |
|
Hi, I'm working on integrating this into our system. I've hit a problem with net_pop3, which isn't quite decoding mime e-mails properly. Sometimes a mail sent with text and html bodies will contain both: this appears as the body repeated twice, with the first copy containing no newlines (I presume the whole thing is being sent to the html processor) - this is most noticeable from outlook and yahoo! mail though it does not happen every time. Also, if you send a mail from gmail with an attachment, the body is sent as an inline text part, and is not picked up at all. My experience with this is that it can be reproduced every time, simply send a gmail with an attachment and "No Description found" is inserted. Anybody else having these problems? I don't want to have to go in and change net_pop3, and since it's been nearly 3 years since the last release I don't hold out much hope for a bug-fix. I'm going to look at piping it out to a different program/script.... |
|
@rjosulli: the decoding of mime mails is not done by net_pop3, but by the Mail-package, especially Mail_mimeDecode and Mail_Parser. I remember that I've to fix several issues there (we use MS Exchange/Outlook, too) to get it working. But in the meantime its working in most of cases. |
|
We also use this feature heavily and I am surprised it is not in the latest versio (1.2.0). |
|
I'm using Mantis 1.1.1 on Linux with following settings and all tims that a new mail is sent a ticket is created with in the body the plain text and html text. |
|
@dapozzom:
IF you switch first setting of, html is not handled any more. |
|
My incoming mail is generated with HTML/Plain text setting on the client, so if I will put the $g_mail_parse_html =OFF the description will contain " No description found", setting to ON the description will contain the HTML body and the "translated" one. So the bug description contains twice the same information. |
|
I am confused with all this history. Can someone give me a basic outline of how to get this thing running on 1.0.8 and Windows 2003? What files should I download, will I need that html parser, etc? Thanks! |
|
I seem to have a problem with very long URLs which get truncated if received by mail. And this is how it shows up after importing: Any suggestions someone? |
|
@dapozzom 0004286:0018024, you wrote: My incoming mail is generated with HTML/Plain text setting on the client, so if I will put the $g_mail_parse_html =OFF the description will contain " No description found", setting to ON the description will contain the HTML body and the "translated" one. So the bug description contains twice the same information. If you have a clean "plain text" part in your mail, you should get it also, if you switch html parsing to OFF. If you get "no description found", did you maybe switch "mime parsing" to OFF. It seems to me that something with your mails is not ok for the parsing process either in mime, which normal correctly differ between text and html parts in general inside mime based mails. I've both "mime parsing" and "html parsing" on, which works |
|
@cas 0004286:0018044: Take a look into the datbase table to decide, if the line breaks (you see) come from the parsing process or from the bugtracker userinterface. If in the database (bug text table) a URL in the description column is not broken by <cr> or <lf>, the gui breakes an disforms the URLs |
|
Brody, all long entries direct through the gui are fine, only when parsed at mail receipt wh have this behaviour. |
|
Found another little issue and prepared fix for it. |
|
Found another little issue and prepared fix for it. |
|
Uploaded a new package with changes files for version 1.1.2 Jun 2008
Hope this package is usefull for some of you |
|
Sorry for this but there was small typo which caused problems with processing attachments. Here is the fixed package: Mantis-1.1.2-changed_files_only-unofficial_v2.zip Jul 2008
|
|
Hi, For me the following version works fine:
... and mails with attachments are not analyzed right: "No description found" |
|
Hello, Is: The latest version of this? Paul |
|
Hi, Just wanted to make a suggestion for a future release. If possible can the passwords not be stored in plain text. Thanks, -Jack |
|
Is this still be developed or has this been abandoned? Its been awhile since I've seen any updates are there are a few features not working right. I'm having issues with replies to emails not being added as bug notes and the mail parser seems to fail on characters with accent marks on them. Thanks, -Jack |
|
Hi, I have the same problem with french accents, is there a way to get around this issue ? Thanks. Laurent |
|
Hello, how does this work if you are using Active Directory? Our UserIDs are not email addresses, they are our network logins. Can this check AD, and create an account using a network login, and fill in the email address as per AD? Seems like everything I read above is related to an internet facing installation. Thanks |
|
Suggestion for future release: Per project one specific reporter. Now you have to choose between one reporter ( 'Mail' ) or all kind of different reporters. Suppose you have within one organization, which reports by email, one contactperson. You want that to be the reporter. This give them feedback on the issue created ( Issue ID ). I do not want all different reporters in the system. ( Otherwise I would have make accounts for them. Later on you could also update the reporter field in the issue ). |
|
I am having te same problem with recognizing emails as bugnotes ( already existing issues ). See 0004286:0018506. However for me that is not the solution. How is this suppose to work. What do you put in the subject of the email, just the issue ID ( with or without the leading zero's ) or something else. |
|
I'm having problems with emails containing attachments. It will not attach them to a isuue, and log file shows: SYSTEM WARNING: file_put_contents(/image001.jpg) However normal uploads by Mantis are working correctly. What could be the problem? However in my php.ini upload_tmp_dir was not set so it tried to write into the rootdir '/', which was not allowed. |
|
i can not get it to work on 1.2.0a2 i couldnt even get it to work on 1.1.3 or 1.1.4 |
|
Hello DaVinci. Did not test it on 1.2.0a2, but works on 1.1.4. What is your problem exactly? |
|
TomR, In 1.1.4 and 1.1.3 the e-mails that Mantis collects are empty: no description, no attachemnts no nothing |
|
TomR, In 1.1.4 and 1.1.3 the e-mails that Mantis collects are empty: no description, no attachemnts no nothing |
|
i've a suggestion:
|
|
Reg. your last mentioned problem of examining the same mail twice, I added a check, if the mail is to old and has been checked before... Reg. empty mails, what product is the mailserver you use?! I guess, a M$ Exchange... |
|
@brody i've tried to access the mails from LotusNotes but it didnt work :( |
|
@DaVinci |
|
@brody |
|
This would make for a great plugin; I don't think it'll be making it's way into Mantis core anytime for 1.2.x, so removing the target. |
|
@all the people above when a reporter sends a mail his e-mail address is imported in header: Report from: John Doe john.doe@domain.com John Doe is always a user in Mantis and i want his name to be imported into Reported by filed instead of Reporter [reporter@somedomain.com] which is the name of the e-mail address everyone sends e-mail to. I hope you understands the question. |
|
@JReese: When will this come - as plugin? This important feature for a lot of users is displaced many many times... @DaVinci: Think, that I understand you. The patches for the feature to process e-mails can put that name into the reporter's field. But therefore a reporter entry (a new user) must be generated every time. Therefor two switches exists: $g_mail_use_reporter and $g_mail_reporter. If first is set to "OFF" every issue is saved under its reporter. The "Reported from:" is controlled by $g_mail_save_from switch. Seems to be a misconfiguration in your case. |
|
@brody: |
|
@DaVinci: Yes (for the first) - as documented in the settings file ... read:" --- mail reporting settings -----
and the second part also documented in the config file: Write sender of the message into the bug report [IF set to ON!] |
|
b>@indy</b: thanks again for providing the email-pop3 addon. I'm using the (self-extended) mantis-1.0.5.patch.gz addapted to V1.0.7 and have a problem with the original Parser.php, which mangles some mails by second time applying a decoding of "quoted printable". The first apply comes from the origin Mime_Decode class (if configured to decode mime mails directly) and the again decoding of the decoded text comes from the Parser.php class function setBody(), which decodes a plain text again and calls a html parser for html part of mails. Any idea? Is correct to generally make setBody() to only set the body and do no further decoding? |
|
@brody what am i doing wrong? |
|
It seems that attached *.txt files are not attached to the issue. Can anybody explain me the reason for that? |
|
@brody |
|
@brody i couldnt get it to work with LotusNotes |
|
@DaVinci at 07:53: I guess you mean W2K (I don't know W3K) :-) @DaVinci at 07:57: If LotusNotes is capable of being contacted by POP3 and you or your application gets the rights to do so. We use (sorrily) Exchange Server and I found a lot of problems, because Microsoft has its own standards regarding POP3 and IMAP. I've no experience regarding contacting Lotus Notes. |
|
@TomR's note 0004286:0020180: It might be forbidden in this installation. Some of the admins should/could tell you, the reason. I'm only reporter here... |
|
@brody |
|
Hi Really very nice, it is great work Actually it's working fine for bug report email.I got following issues kindly help me very urgent. 1.when user reply via email, the whole content(exist notes also) stored in bug notes but i want only reply messags only stored on bug notes. 2.if user attach the file means the bug notes displayed "No description found" but file is not attached to bug notes. |
|
@TomR 0004286:0020234: I found same problem in context to Exchange Server, which sometimes handled *.txt attachements not as attachement or slightly different to normal attachment. If you use Exchange Server as your e-mail backend that might be the reason for that mishaviour. A general fix is difficult; I fixed Parser.php for that, after digging deep into Exchange's Mail Handling. In general I had to fix/correct a lot of things. BTW: THe mentioned patch seems to be in indys upload of package 1.1.1
|
|
@Brody, Thnx for your reply, however no Exchange whatsover. Just POP3 on Linux server. I used Mantis-1.1.2-changed files only-unofficial V2.zip and that seemd to work, except voor *.txt uploads. |
|
POP3 is a "client side" protocol. I connect to Exchange by POP3, but that does not matter the format of the messages. Maybe your mail server on linux does also have special behaviour. I do not know, I found some misbehaviour on Exchange and patched my installation adequately. If you need to get this fixed on your installation, you'll have to debug it. For that I use the eclipse PDT Plugin (org.eclipse.php) in combination with the free available zend debugger plugin and for the non mail functions a local installation on my laptop. Good luck! |
|
Hi thanks for your reply brody 2.when user reply via email with file attachment, the file is not displayed in notes section and also notes are displayed "No description found" instead of display original reply messages. if any extra configuration need currently i used following configuration in config_inc.php file
kindly help me very urgent can i change any configuration please advise me I need how can i set "bug report email" functionality in our external projects.that is i using testing project in this project i need integrate the bug report email functionality kindly give yours valuable suggestion. |
|