aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid M <davidmj@users.sourceforge.net>2006-02-21 19:49:35 +0000
committerDavid M <davidmj@users.sourceforge.net>2006-02-21 19:49:35 +0000
commitd6c8a4a1ae4343bb98de07d643ec2247a7ba2d6a (patch)
tree59bce7353c903249e6c7678139fba9638db978a3
parentcddf792dea0195783c20094023272c5713faf2b3 (diff)
downloadforums-d6c8a4a1ae4343bb98de07d643ec2247a7ba2d6a.tar
forums-d6c8a4a1ae4343bb98de07d643ec2247a7ba2d6a.tar.gz
forums-d6c8a4a1ae4343bb98de07d643ec2247a7ba2d6a.tar.bz2
forums-d6c8a4a1ae4343bb98de07d643ec2247a7ba2d6a.tar.xz
forums-d6c8a4a1ae4343bb98de07d643ec2247a7ba2d6a.zip
- You can now export an entire folder as either CSV or XML :D
git-svn-id: file:///svn/phpbb/trunk@5567 89ea8834-ac86-4346-8a33-228a782c2dd0
-rw-r--r--phpBB/includes/acp/acp_language.php2
-rw-r--r--phpBB/includes/ucp/ucp_pm_viewfolder.php173
-rw-r--r--phpBB/language/en/common.php2
-rw-r--r--phpBB/language/en/ucp.php2
-rw-r--r--phpBB/styles/subSilver/template/ucp_pm_viewfolder.html28
5 files changed, 162 insertions, 45 deletions
diff --git a/phpBB/includes/acp/acp_language.php b/phpBB/includes/acp/acp_language.php
index a5d12425c6..4bb5958501 100644
--- a/phpBB/includes/acp/acp_language.php
+++ b/phpBB/includes/acp/acp_language.php
@@ -57,8 +57,6 @@ class acp_language
$this->tpl_name = 'acp_language';
$this->page_title = 'ACP_LANGUAGE_PACKS';
- $this->u_action = "{$phpbb_admin_path}index.$phpEx$SID&amp;i=$id&amp;mode=$mode";
-
if ($action == 'upload_data' && request_var('test_connection', ''))
{
$test_connection = false;
diff --git a/phpBB/includes/ucp/ucp_pm_viewfolder.php b/phpBB/includes/ucp/ucp_pm_viewfolder.php
index 6922f62d41..be131a8130 100644
--- a/phpBB/includes/ucp/ucp_pm_viewfolder.php
+++ b/phpBB/includes/ucp/ucp_pm_viewfolder.php
@@ -121,56 +121,75 @@ function view_folder($id, $mode, $folder_id, $folder, $type)
$url = "{$phpbb_root_path}ucp.$phpEx$SID";
+ $data = array();
+
foreach ($folder_info['pm_list'] as $message_id)
{
$row = &$folder_info['rowset'][$message_id];
- $folder_img = ($row['unread']) ? 'folder_new' : 'folder';
- $folder_alt = ($row['unread']) ? 'NEW_MESSAGES' : 'NO_NEW_MESSAGES';
+ if (isset($_REQUEST['submit_export']))
+ {
+ $sql = 'SELECT p.message_text
+ FROM ' . PRIVMSGS_TO_TABLE . ' t, ' . PRIVMSGS_TABLE . ' p, ' . USERS_TABLE . ' u
+ WHERE t.user_id = ' . $user->data['user_id'] . "
+ AND p.author_id = u.user_id
+ AND t.folder_id = $folder_id
+ AND t.msg_id = p.msg_id
+ AND p.msg_id = $message_id";
+ $result = $db->sql_query_limit($sql, 1);
+ $message_row = $db->sql_fetchrow($result);
+ $db->sql_freeresult($result);
+
+ $data[] = array('subject' => censor_text($row['message_subject']), 'from' => $row['username'], 'date' => $user->format_date($row['message_time']), 'to' => ($folder_id == PRIVMSGS_OUTBOX || $folder_id == PRIVMSGS_SENTBOX) ? implode(', ', $address_list[$message_id]) : '', 'message' => $message_row['message_text']);
+ }
+ else
+ {
+ $folder_img = ($row['unread']) ? 'folder_new' : 'folder';
+ $folder_alt = ($row['unread']) ? 'NEW_MESSAGES' : 'NO_NEW_MESSAGES';
- // Generate all URIs ...
- $message_author = "<a href=\"{$phpbb_root_path}memberlist.$phpEx$SID&amp;mode=viewprofile&amp;u=" . $row['author_id'] . '">' . $row['username'] . '</a>';
- $view_message_url = "$url&amp;i=$id&amp;mode=view&amp;f=$folder_id&amp;p=$message_id";
- $remove_message_url = "$url&amp;i=compose&amp;action=delete&amp;p=$message_id";
+ // Generate all URIs ...
+ $message_author = "<a href=\"{$phpbb_root_path}memberlist.$phpEx$SID&amp;mode=viewprofile&amp;u=" . $row['author_id'] . '">' . $row['username'] . '</a>';
+ $view_message_url = "$url&amp;i=$id&amp;mode=view&amp;f=$folder_id&amp;p=$message_id";
+ $remove_message_url = "$url&amp;i=compose&amp;action=delete&amp;p=$message_id";
- $row_indicator = '';
- foreach ($color_rows as $var)
- {
- if (($var != 'friend' && $var != 'foe' && $row[$var])
- ||
- (($var == 'friend' || $var == 'foe') && isset(${$var}[$row['author_id']]) && ${$var}[$row['author_id']]))
+ $row_indicator = '';
+ foreach ($color_rows as $var)
{
- $row_indicator = $var;
- break;
+ if (($var != 'friend' && $var != 'foe' && $row[$var])
+ ||
+ (($var == 'friend' || $var == 'foe') && isset(${$var}[$row['author_id']]) && ${$var}[$row['author_id']]))
+ {
+ $row_indicator = $var;
+ break;
+ }
}
- }
-
- // Send vars to template
- $template->assign_block_vars('messagerow', array(
- 'PM_CLASS' => ($row_indicator) ? 'pm_' . $row_indicator . '_colour' : '',
-
- 'FOLDER_ID' => $folder_id,
- 'MESSAGE_ID' => $message_id,
- 'MESSAGE_AUTHOR' => $message_author,
- 'SENT_TIME' => $user->format_date($row['message_time']),
- 'SUBJECT' => censor_text($row['message_subject']),
- 'FOLDER' => (isset($folder[$row['folder_id']])) ? $folder[$row['folder_id']]['folder_name'] : '',
- 'U_FOLDER' => (isset($folder[$row['folder_id']])) ? "$url&amp;folder=" . $row['folder_id'] : '',
- 'PM_ICON_IMG' => (!empty($icons[$row['icon_id']])) ? '<img src="' . $config['icons_path'] . '/' . $icons[$row['icon_id']]['img'] . '" width="' . $icons[$row['icon_id']]['width'] . '" height="' . $icons[$row['icon_id']]['height'] . '" alt="" title="" />' : '',
- 'FOLDER_IMG' => $user->img($folder_img, $folder_alt),
- 'PM_IMG' => ($row_indicator) ? $user->img('pm_' . $row_indicator, '') : '',
- 'ATTACH_ICON_IMG' => ($auth->acl_get('u_download') && $row['message_attachment'] && $config['allow_pm_attach'] && $config['auth_download_pm']) ? $user->img('icon_attach', $user->lang['TOTAL_ATTACHMENTS']) : '',
-
- 'S_PM_REPORTED' => (!empty($row['message_reported']) && $auth->acl_get('m_')) ? true : false,
- 'S_PM_DELETED' => ($row['deleted']) ? true : false,
-
- 'U_VIEW_PM' => ($row['deleted']) ? '' : $view_message_url,
- 'U_REMOVE_PM' => ($row['deleted']) ? $remove_message_url : '',
- 'RECIPIENTS' => ($folder_id == PRIVMSGS_OUTBOX || $folder_id == PRIVMSGS_SENTBOX) ? implode(', ', $address_list[$message_id]) : '',
- 'U_MCP_REPORT' => "{$phpbb_root_path}mcp.$phpEx?sid={$user->session_id}&amp;i=reports&amp;pm=$message_id")
-// 'U_MCP_QUEUE' => "mcp.$phpEx?sid={$user->session_id}&amp;i=mod_queue&amp;t=$topic_id")
- );
+ // Send vars to template
+ $template->assign_block_vars('messagerow', array(
+ 'PM_CLASS' => ($row_indicator) ? 'pm_' . $row_indicator . '_colour' : '',
+
+ 'FOLDER_ID' => $folder_id,
+ 'MESSAGE_ID' => $message_id,
+ 'MESSAGE_AUTHOR' => $message_author,
+ 'SENT_TIME' => $user->format_date($row['message_time']),
+ 'SUBJECT' => censor_text($row['message_subject']),
+ 'FOLDER' => (isset($folder[$row['folder_id']])) ? $folder[$row['folder_id']]['folder_name'] : '',
+ 'U_FOLDER' => (isset($folder[$row['folder_id']])) ? "$url&amp;folder=" . $row['folder_id'] : '',
+ 'PM_ICON_IMG' => (!empty($icons[$row['icon_id']])) ? '<img src="' . $config['icons_path'] . '/' . $icons[$row['icon_id']]['img'] . '" width="' . $icons[$row['icon_id']]['width'] . '" height="' . $icons[$row['icon_id']]['height'] . '" alt="" title="" />' : '',
+ 'FOLDER_IMG' => $user->img($folder_img, $folder_alt),
+ 'PM_IMG' => ($row_indicator) ? $user->img('pm_' . $row_indicator, '') : '',
+ 'ATTACH_ICON_IMG' => ($auth->acl_get('u_download') && $row['message_attachment'] && $config['allow_pm_attach'] && $config['auth_download_pm']) ? $user->img('icon_attach', $user->lang['TOTAL_ATTACHMENTS']) : '',
+
+ 'S_PM_REPORTED' => (!empty($row['message_reported']) && $auth->acl_get('m_')) ? true : false,
+ 'S_PM_DELETED' => ($row['deleted']) ? true : false,
+
+ 'U_VIEW_PM' => ($row['deleted']) ? '' : $view_message_url,
+ 'U_REMOVE_PM' => ($row['deleted']) ? $remove_message_url : '',
+ 'RECIPIENTS' => ($folder_id == PRIVMSGS_OUTBOX || $folder_id == PRIVMSGS_SENTBOX) ? implode(', ', $address_list[$message_id]) : '',
+ 'U_MCP_REPORT' => "{$phpbb_root_path}mcp.$phpEx?sid={$user->session_id}&amp;i=reports&amp;pm=$message_id")
+ // 'U_MCP_QUEUE' => "mcp.$phpEx?sid={$user->session_id}&amp;i=mod_queue&amp;t=$topic_id")
+ );
+ }
}
unset($folder_info['rowset']);
@@ -179,6 +198,78 @@ function view_folder($id, $mode, $folder_id, $folder, $type)
'S_SHOW_COLOUR_LEGEND' => true)
);
}
+
+ $type = request_var('export_option', '');
+
+ // Ask the user what he wants
+ if (isset($_REQUEST['submit_export']))
+ {
+ if (!isset($_REQUEST['delimiter']) && $type == 'CSV')
+ {
+ $template->assign_var('PROMPT', true);
+ }
+ else
+ {
+ switch ($type)
+ {
+ case 'CSV':
+ case 'CSV_EXCEL':
+ $mimetype = 'text/csv';
+ $filetype = 'csv';
+ if ($type == 'csv_excel')
+ {
+ $enclosure = '"';
+ $delimiter = ',';
+ $newline = "\r\n";
+ }
+ else
+ {
+ $enclosure = request_var('enclosure', '"');
+ $delimiter = request_var('delimiter', ',');
+ $newline = "\n";
+ }
+ $string = '';
+ foreach ($data as $value)
+ {
+ foreach ($value as $text)
+ {
+ $cell = str_replace($enclosure, $enclosure . $enclosure, $text);
+
+ if (strpos($cell, $enclosure) !== false || strpos($cell, $delimiter) !== FALSE || strpos($cell, $newline) !== FALSE)
+ {
+ $string .= $enclosure . $text . $enclosure . $delimiter;
+ }
+ else
+ {
+ $string .= $cell . $delimiter;
+ }
+ }
+ $string = substr($string, 0, -1) . $newline;
+ }
+ break;
+ case 'XML':
+ $mimetype = 'text/xml';
+ $filetype = 'xml';
+ $string = '<?xml version="1.0"?>' . "\n";
+ $string .= "<messages>\n";
+ foreach ($data as $value)
+ {
+ $string .= "\t<privmsg>\n";
+ foreach ($value as $tag => $text)
+ {
+ $string .= "\t\t<$tag>$text</$tag>\n";
+ }
+ $string .= "\t</privmsg>\n";
+ }
+ $string .= '</messages>';
+ }
+ header('Pragma: no-cache');
+ header("Content-Type: $mimetype; name=\"data.$filetype\"");
+ header("Content-disposition: attachment; filename=data.$filetype");
+ echo $string;
+ exit;
+ }
+ }
}
/**
diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php
index eb01d21921..05684243a0 100644
--- a/phpBB/language/en/common.php
+++ b/phpBB/language/en/common.php
@@ -104,6 +104,7 @@ $lang = array_merge($lang, array(
'DELETE_COOKIES' => 'Delete all board cookies',
'DELETE_MARKED' => 'Delete Marked',
'DELETE_POST' => 'Delete Post',
+ 'DELIMITER' => 'Delimiter',
'DESCENDING' => 'Descending',
'DISABLED' => 'Disabled',
'DISPLAY' => 'Display',
@@ -121,6 +122,7 @@ $lang = array_merge($lang, array(
'EMAIL_ADDRESS' => 'Email address',
'EMPTY_SUBJECT' => 'You must specify a subject when posting a new topic.',
'ENABLED' => 'Enabled',
+ 'ENCLOSURE' => 'Enclosure',
'ERR_CONNECTING_SERVER' => 'Error connecting to the server',
'EXTENSION' => 'Extension',
'EXTENSION_DISABLED_AFTER_POSTING' => 'The extension <b>%s</b> has been deactivated and can no longer be displayed',
diff --git a/phpBB/language/en/ucp.php b/phpBB/language/en/ucp.php
index 022c7ca68c..235ade1d58 100644
--- a/phpBB/language/en/ucp.php
+++ b/phpBB/language/en/ucp.php
@@ -137,8 +137,10 @@ $lang = array_merge($lang, array(
'EMPTY_DRAFT_TITLE' => 'You must enter a draft title',
'EXPORT_AS_XML' => 'Export as XML',
'EXPORT_AS_CSV' => 'Export as CSV',
+ 'EXPORT_AS_CSV_EXCEL' => 'Export as CSV (Excel)',
'EXPORT_AS_TXT' => 'Export as TXT',
'EXPORT_AS_MSG' => 'Export as MSG',
+ 'EXPORT_FOLDER' => 'Export Folder',
'FIELD_REQUIRED' => 'The field "%s" must be completed.',
'FIELD_TOO_SHORT' => 'The field "%1$s" is too short, a minimum of %2$d characters is required.',
diff --git a/phpBB/styles/subSilver/template/ucp_pm_viewfolder.html b/phpBB/styles/subSilver/template/ucp_pm_viewfolder.html
index 7227377f99..e9839d3f84 100644
--- a/phpBB/styles/subSilver/template/ucp_pm_viewfolder.html
+++ b/phpBB/styles/subSilver/template/ucp_pm_viewfolder.html
@@ -3,8 +3,9 @@
<!-- $Id$ -->
<div id="pagecontent">
-
+<!-- IF not PROMPT -->
<!-- INCLUDE ucp_pm_message_header.html -->
+<!-- ENDIF -->
<div style="padding: 2px;"></div>
<!-- IF S_PM_ICONS and S_UNREAD -->
@@ -16,7 +17,24 @@
<!-- ENDIF -->
<form name="viewfolder" method="post" action="{S_PM_ACTION}" style="margin:0px">
-
+<!-- IF PROMPT -->
+<table class="tablebg" width="100%" cellspacing="1" cellpadding="0" border="0">
+ <tr>
+ <th colspan="2" valign="middle">{L_OPTIONS}</th>
+ </tr>
+ <tr>
+ <td class="row1" width="35%">{L_DELIMITER}: </td>
+ <td class="row2"><input class="post" type="text" name="delimiter" value="," /></td>
+ </tr>
+ <tr>
+ <td class="row1" width="35%">{L_ENCLOSURE}: </td>
+ <td class="row2"><input class="post" type="text" name="enclosure" value="&#034;" /></td>
+ </tr>
+ <tr>
+ <td class="cat" colspan="2" align="center"><input type="hidden" name="export_option" value="CSV" /><input class="btnmain" type="submit" name="submit_export" value="{L_EXPORT_FOLDER}" />&nbsp;&nbsp;<input class="btnlite" type="reset" value="Reset" name="reset" /></td>
+ </tr>
+</table>
+<!-- ELSE -->
<table class="tablebg" width="100%" cellspacing="1" cellpadding="0" border="0">
<!-- IF NUM_NOT_MOVED -->
<tr>
@@ -84,6 +102,12 @@
<div style="padding: 2px;"></div>
<!-- INCLUDE ucp_pm_message_footer.html -->
+<!-- IF .messagerow -->
+ <div style="float:left"><br /><select name="export_option"><option value="CSV">{L_EXPORT_AS_CSV}</option><option value="CSV_EXCEL">{L_EXPORT_AS_CSV_EXCEL}</option><option value="XML">{L_EXPORT_AS_XML}</option></select>&nbsp;<input class="btnlite" type="submit" name="submit_export" value="{L_EXPORT_FOLDER}" /></div>
+<!-- ENDIF -->
+
+<!-- ENDIF -->
+</form>
<br clear="all" />
</div>