-
Bug
-
Resolution: Fixed
-
None
-
3.0.x
-
None
-
PHP Environment:
Database:
Private messaging export as CSV function is very broken in the way it handles recipients (to and bcc).
This is the code in question:
$value['bcc'] = '';
|
if (is_array($value['to']))
|
{
|
foreach ($value['to'] as $key => $values)
|
{
|
if (!empty($values['bcc']) && is_array($values['bcc']))
|
{
|
$value['bcc'] = implode(',', $values['bcc']);
|
}
|
$value['to'] = implode(',', $values['to']);
|
}
|
}
|
While running foreach() over $value['to'] it reassigns $value['to'] as string; not good. Because of this group names never show up in the export, it also assumes a message had recipients in the to field this is not always the case. I wrote a little fix to solve the problem:
Index: includes/ucp/ucp_pm_viewfolder.php
|
===================================================================
|
RCS file: /cvsroot/phpbb/phpBB2/includes/ucp/ucp_pm_viewfolder.php,v
|
retrieving revision 1.33
|
diff -C2 -w -r1.33 ucp_pm_viewfolder.php
|
*** includes/ucp/ucp_pm_viewfolder.php 22 May 2006 05:42:49 -0000 1.33
|
--- includes/ucp/ucp_pm_viewfolder.php 22 May 2006 12:42:47 -0000
|
***************
|
*** 304,319 ****
|
foreach ($data as $value)
|
{
|
|
|
! $value['bcc'] = '';
|
! if (is_array($value['to']))
|
! {
|
! foreach ($value['to'] as $key => $values)
|
{
|
! if (!empty($values['bcc']) && is_array($values['bcc']))
|
{
|
! $value['bcc'] = implode(',', $values['bcc']);
|
! }
|
! $value['to'] = implode(',', $values['to']);
|
}
|
}
|
|
|
--- 304,320 ----
|
foreach ($data as $value)
|
{
|
+ $recipients = $value['to'];
|
+ $value['to'] = $value['bcc'] = '';
|
|
|
! if (is_array($recipients))
|
{
|
! foreach ($recipients as $key => $values)
|
{
|
! $value['bcc'] .= (isset($values['bcc']) && is_array($values['bcc'])) ? ',' . implode(',', $values['bcc']) : '';
|
! $value['to'] .= (isset($values['to']) && is_array($values['to'])) ? ',' . implode(',', $values['to']) : '';
|
}
|
+ // Remove the commas which will appear before the first entry.
|
+ $value['to'] = substr($value['to'], 1);
|
+ $value['bcc'] = substr($value['bcc'], 1);
|
}
|
With this new code the CSV yields:
heheyeyd,Chris,22 May 2006 12:31,"Anonymous,Chris,GLOBAL_MODERATORS",dfdsfgfdg,"REGISTERED,ADMINISTRATORS,BOTS" Blah Blah,Chris,22 May 2006 12:20,,Blah Blah Blah,Chris
Rather than:
[phpBB Debug] PHP Notice: in file /includes/ucp/ucp_pm_viewfolder.php on line 316: Undefined index: to
[phpBB Debug] PHP Notice: in file /includes/ucp/ucp_pm_viewfolder.php on line 316: implode() [function.implode]: Bad arguments.
[phpBB Debug] PHP Notice: in file /includes/ucp/ucp_pm_viewfolder.php on line 371: Cannot modify header information - headers already sent by (output started at ./includes/functions.php:2126)
[phpBB Debug] PHP Notice: in file /includes/ucp/ucp_pm_viewfolder.php on line 372: Cannot modify header information - headers already sent by (output started at ./includes/functions.php:2126)
[phpBB Debug] PHP Notice: in file /includes/ucp/ucp_pm_viewfolder.php on line 373: Cannot modify header information - headers already sent by (output started at ./includes/functions.php:2126)
heheyeyd,Chris,22 May 2006 12:31,GLOBAL_MODERATORS,dfdsfgfdg,"REGISTERED,ADMINISTRATORS,BOTS" Blah Blah,Chris,22 May 2006 12:20,,Blah Blah Blah,Chris
Also; should I be able to PM the anonymous user?

