| 198 |
$output = '<div class="message-flat">'; |
$output = '<div class="message-flat">'; |
| 199 |
$output .= theme('mail_archive_message_replyto', $message->reply_to); |
$output .= theme('mail_archive_message_replyto', $message->reply_to); |
| 200 |
$output .= theme('mail_archive_message_raw_link', $message); |
$output .= theme('mail_archive_message_raw_link', $message); |
| 201 |
|
$output .= ' '; |
| 202 |
|
$output .= theme('mail_archive_message_delete_link', $message); |
| 203 |
$output .= theme('mail_archive_message_header', $message); |
$output .= theme('mail_archive_message_header', $message); |
| 204 |
$output .= theme('mail_archive_message_body', $message); |
$output .= theme('mail_archive_message_body', $message); |
| 205 |
$output .= '</div>'; |
$output .= '</div>'; |
| 211 |
$output .= '<div style="margin-left: '. ($depth * 15) .'px;">'; |
$output .= '<div style="margin-left: '. ($depth * 15) .'px;">'; |
| 212 |
$output .= '<div class="message-thread">'; |
$output .= '<div class="message-thread">'; |
| 213 |
$output .= theme('mail_archive_message_raw_link', $message); |
$output .= theme('mail_archive_message_raw_link', $message); |
| 214 |
|
$output .= ' '; |
| 215 |
|
$output .= theme('mail_archive_message_delete_link', $message); |
| 216 |
$output .= theme('mail_archive_message_header', $message); |
$output .= theme('mail_archive_message_header', $message); |
| 217 |
$output .= theme('mail_archive_message_body', $message); |
$output .= theme('mail_archive_message_body', $message); |
| 218 |
$output .= '</div>'; |
$output .= '</div>'; |
| 253 |
return $output; |
return $output; |
| 254 |
} |
} |
| 255 |
|
|
| 256 |
|
function theme_mail_archive_message_delete_link($message) { |
| 257 |
|
$output .= '<span class="message-delete-link">'; |
| 258 |
|
$output .= l(t('delete message'), url("mailarchive/$message->lid/message/$message->mid/delete")); |
| 259 |
|
$output .= '</span>'; |
| 260 |
|
return $output; |
| 261 |
|
} |
| 262 |
|
|
| 263 |
function theme_mail_archive_display($categories, $subscriptions, $parents, $tid, $subscriptions_per_page) { |
function theme_mail_archive_display($categories, $subscriptions, $parents, $tid, $subscriptions_per_page) { |
| 264 |
global $user; |
global $user; |
| 265 |
|
|
| 465 |
$items[] = array('path' => "mailarchive/$lid/message/$mid/raw", |
$items[] = array('path' => "mailarchive/$lid/message/$mid/raw", |
| 466 |
'callback' => 'mail_archive_overview', |
'callback' => 'mail_archive_overview', |
| 467 |
'access' => user_access('access mail archive'), |
'access' => user_access('access mail archive'), |
| 468 |
'type' => MENU_SUGGESTED_ITEM, |
'type' => MENU_SUGGESTED_ITEM); |
| 469 |
'weight' => 2); |
$items[] = array('path' => "mailarchive/$lid/message/$mid/delete", |
| 470 |
|
'callback' => 'mail_archive_overview', |
| 471 |
|
'access' => user_access('access mail archive'), |
| 472 |
|
'type' => MENU_SUGGESTED_ITEM); |
| 473 |
|
|
| 474 |
if ($style == 'flat') { |
if ($style == 'flat') { |
| 475 |
if ($previous = mail_archive_message_flat_previous($lid, $mid)) { |
if ($previous = mail_archive_message_flat_previous($lid, $mid)) { |
| 526 |
$items[] = array('path' => "mailarchive/$lid/search/$mid/$style", |
$items[] = array('path' => "mailarchive/$lid/search/$mid/$style", |
| 527 |
'callback' => 'mail_archive_overview', |
'callback' => 'mail_archive_overview', |
| 528 |
'access' => user_access('access mail archive'), |
'access' => user_access('access mail archive'), |
| 529 |
'type' => MENU_SUGGESTED_ITEM, |
'type' => MENU_SUGGESTED_ITEM); |
|
'weight' => 2); |
|
| 530 |
} |
} |
| 531 |
else if ($op == 'overview') { |
else if ($op == 'overview') { |
| 532 |
$items[] = array('path' => "mailarchive/$lid/overview/flat", |
$items[] = array('path' => "mailarchive/$lid/overview/flat", |
| 904 |
case 'raw': |
case 'raw': |
| 905 |
mail_archive_display_message_raw($lid, $id); |
mail_archive_display_message_raw($lid, $id); |
| 906 |
break; |
break; |
| 907 |
|
case 'delete': |
| 908 |
|
$output = mail_archive_message_delete($lid, $id); |
| 909 |
|
break; |
| 910 |
case 'thread': |
case 'thread': |
| 911 |
$output = "<div class=\"message\">\n"; |
$output = "<div class=\"message\">\n"; |
| 912 |
|
|
| 1070 |
exit (0); |
exit (0); |
| 1071 |
} |
} |
| 1072 |
|
|
| 1073 |
|
function mail_archive_message_delete($lid, $mid) { |
| 1074 |
|
$edit = $_POST['edit']; |
| 1075 |
|
if ($edit['delete']) { |
| 1076 |
|
$message = mail_archive_load_message($lid, $mid); |
| 1077 |
|
|
| 1078 |
|
// delete all references to message from address index |
| 1079 |
|
db_query('DELETE FROM {mail_archive_address_index} WHERE mid = %d', $mid); |
| 1080 |
|
|
| 1081 |
|
if ($edit['delete_attachments'] && $message->attachments) { |
| 1082 |
|
$result = db_query('SELECT filename FROM {mail_archive_attachments_index} WHERE mid = %d', $mid); |
| 1083 |
|
// delete attachments from filesystem |
| 1084 |
|
while ($attachment = db_fetch_object($result)) { |
| 1085 |
|
mail_archive_delete_file(file_create_path($message->path .'/'. $attachment->filename)); |
| 1086 |
|
} |
| 1087 |
|
} |
| 1088 |
|
|
| 1089 |
|
/* delete from attachment index even if we didn't delete the attachment |
| 1090 |
|
** from the filesystem -- there's no point in leaving it in the attachment |
| 1091 |
|
** index at this point. |
| 1092 |
|
*/ |
| 1093 |
|
db_query('DELETE FROM {mail_archive_attachments_index} WHERE mid = %d', $mid); |
| 1094 |
|
// delete all message parts from filesystem |
| 1095 |
|
$files = file_scan_directory(file_create_path($message->path), "$mid"); |
| 1096 |
|
foreach ($files as $file) { |
| 1097 |
|
mail_archive_delete_file($file->filename); |
| 1098 |
|
} |
| 1099 |
|
|
| 1100 |
|
/* attempt to remove message directory (this will fail if we didn't delete |
| 1101 |
|
** the attachments). |
| 1102 |
|
*/ |
| 1103 |
|
mail_archive_delete_directory(file_create_path($message->path)); |
| 1104 |
|
|
| 1105 |
|
// delete message from message index |
| 1106 |
|
db_query('DELETE FROM {mail_archive_message_index} WHERE lid = %d AND mid = %d', $lid, $mid); |
| 1107 |
|
drupal_set_message(t('Message deleted from database.')); |
| 1108 |
|
|
| 1109 |
|
// update subscription message count |
| 1110 |
|
db_query('UPDATE {mail_archive_subscriptions} SET messages = messages - 1 WHERE lid = %d', $lid); |
| 1111 |
|
|
| 1112 |
|
// go back to list overview |
| 1113 |
|
drupal_goto("mailarchive/$lid/overview/thread"); |
| 1114 |
|
} |
| 1115 |
|
else { |
| 1116 |
|
$message = mail_archive_load_message($lid, $mid); |
| 1117 |
|
$output = t('Are you sure you want to permanently delete the message "%subject" by "%author"?', array('%subject' => $message->subject_short, '%author' => $message->mailfrom_short)); |
| 1118 |
|
$output .= form_checkbox(t('Delete attachments'), 'delete_attachments', 1, 1, t('Leave this checked to delete all attachments associated with this message, if any. If you do not delete the attachments now, you will not be able to delete them later from this interface. You will only be able to delete them manually.')); |
| 1119 |
|
//TODO: |
| 1120 |
|
//$output .= form_checkbox(t('Delete followup messages and their children'), 'delete_followups', 1, 0, t('If checked, all replies to this message will recursively be deleted.')); |
| 1121 |
|
$output = theme('box', t('Confirm'), $output); |
| 1122 |
|
$output .= form_submit('Delete message'); |
| 1123 |
|
$output .= form_hidden('delete', 1); |
| 1124 |
|
} |
| 1125 |
|
|
| 1126 |
|
return form($output); |
| 1127 |
|
} |
| 1128 |
|
|
| 1129 |
|
function mail_archive_message_delete($lid, $mid) { |
| 1130 |
|
echo "<pre>\n"; |
| 1131 |
|
$message = db_fetch_object(db_query('SELECT mid, lid, path, attachments FROM {mail_archive_message_index} WHERE lid = %d AND mid = %d', $lid, $mid)); |
| 1132 |
|
|
| 1133 |
|
if (user_access('administer mail archive')) { |
| 1134 |
|
if ($output = mail_archive_retrieve_message($message->path, $mid .'.0')) { |
| 1135 |
|
echo htmlspecialchars($output); |
| 1136 |
|
} |
| 1137 |
|
else { |
| 1138 |
|
echo "\n". t('[this message has no headers]') ."\n"; |
| 1139 |
|
} |
| 1140 |
|
} |
| 1141 |
|
|
| 1142 |
|
// display body of message |
| 1143 |
|
if ($output = mail_archive_retrieve_message($message->path, $mid .'.1')) { |
| 1144 |
|
echo htmlspecialchars($output); |
| 1145 |
|
} |
| 1146 |
|
else { |
| 1147 |
|
echo "\n". t('[this message has no body]') ."\n"; |
| 1148 |
|
} |
| 1149 |
|
|
| 1150 |
|
if ($message->attachments) { |
| 1151 |
|
$attachments = mail_archive_get_attachments($mid); |
| 1152 |
|
for ($i = 0; $i < $message->attachments; $i++) { |
| 1153 |
|
$part = $i + 2; |
| 1154 |
|
if ($attachments[$part]->type == 0) { // text |
| 1155 |
|
echo "\n\n--Multipart\n"; |
| 1156 |
|
$subtype = $attachments[$part]->subtype; |
| 1157 |
|
echo t("Content-Type: %type\n", array('%type' => "TEXT/$subtype")); |
| 1158 |
|
$filename = $attachments[$part]->filename; |
| 1159 |
|
echo t(" filename=\"%name\"\n\n", array('%name' => "$filename")); |
| 1160 |
|
if ($output = mail_archive_retrieve_message($message->path, "$mid.". $part)) { |
| 1161 |
|
echo htmlspecialchars($output); |
| 1162 |
|
} |
| 1163 |
|
else { |
| 1164 |
|
echo "\n". t('[failed to load attachment]') ."\n"; |
| 1165 |
|
} |
| 1166 |
|
} |
| 1167 |
|
} |
| 1168 |
|
} |
| 1169 |
|
|
| 1170 |
|
// don't return, we simply displayed it to the screen. |
| 1171 |
|
echo "</pre>\n"; |
| 1172 |
|
} |
| 1173 |
|
|
| 1174 |
function mail_archive_get_attachments($mid) { |
function mail_archive_get_attachments($mid) { |
| 1175 |
$result = db_query('SELECT mid, created, filename, bytes, type, subtype, encoding, part FROM {mail_archive_attachments_index WHERE mid = %d', $mid); |
$result = db_query('SELECT mid, created, filename, bytes, type, subtype, encoding, part FROM {mail_archive_attachments_index WHERE mid = %d', $mid); |
| 1176 |
while ($attachment = db_fetch_object($result)) { |
while ($attachment = db_fetch_object($result)) { |
| 1783 |
} |
} |
| 1784 |
return rtrim($subject); |
return rtrim($subject); |
| 1785 |
} |
} |
| 1786 |
|
|
| 1787 |
|
function mail_archive_delete_file($file) { |
| 1788 |
|
if (file_delete($file)) { |
| 1789 |
|
drupal_set_message(t('Deleted file "%file".<br />', array('%file' => $file))); |
| 1790 |
|
} |
| 1791 |
|
else { |
| 1792 |
|
drupal_set_message(t('Failed to delete file "%file".<br />', array('%file' => $file)), 'error'); |
| 1793 |
|
} |
| 1794 |
|
} |
| 1795 |
|
|
| 1796 |
|
function mail_archive_delete_directory($path) { |
| 1797 |
|
if (@rmdir($path)) { |
| 1798 |
|
drupal_set_message(t('Deleted directory "%path".<br />', array('%path' => $path))); |
| 1799 |
|
} |
| 1800 |
|
else { |
| 1801 |
|
drupal_set_message(t('Failed to delete directory "%path". Check permissions, and be sure the directory is empty.<br />', array('%path' => $path)), 'error'); |
| 1802 |
|
} |
| 1803 |
|
} |