Changeset 702 for trunk/forum/includes/ucp/ucp_pm_viewfolder.php
- Timestamp:
- Mar 31, 2010, 6:32:40 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/forum/includes/ucp/ucp_pm_viewfolder.php
r400 r702 3 3 * 4 4 * @package ucp 5 * @version $Id : ucp_pm_viewfolder.php 8795 2008-08-29 11:50:01Z Kellanved$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 66 66 $mark_options = array('mark_important', 'delete_marked'); 67 67 68 // Minimise edits 69 if (!$auth->acl_get('u_pm_delete') && $key = array_search('delete_marked', $mark_options)) 70 { 71 unset($mark_options[$key]); 72 } 73 68 74 $s_mark_options = ''; 69 75 foreach ($mark_options as $mark_option) … … 116 122 if ($folder_id == PRIVMSGS_OUTBOX || $folder_id == PRIVMSGS_SENTBOX) 117 123 { 118 $recipient_list = $address = array(); 119 120 foreach ($folder_info['rowset'] as $message_id => $row) 121 { 122 $address[$message_id] = rebuild_header(array('to' => $row['to_address'], 'bcc' => $row['bcc_address'])); 123 $_save = array('u', 'g'); 124 foreach ($_save as $save) 125 { 126 if (isset($address[$message_id][$save]) && sizeof($address[$message_id][$save])) 127 { 128 foreach (array_keys($address[$message_id][$save]) as $ug_id) 129 { 130 $recipient_list[$save][$ug_id] = array('name' => $user->lang['NA'], 'colour' => ''); 131 } 132 } 133 } 134 } 135 136 $_types = array('u', 'g'); 137 foreach ($_types as $ug_type) 138 { 139 if (!empty($recipient_list[$ug_type])) 140 { 141 if ($ug_type == 'u') 142 { 143 $sql = 'SELECT user_id as id, username as name, user_colour as colour 144 FROM ' . USERS_TABLE . ' 145 WHERE '; 146 } 147 else 148 { 149 $sql = 'SELECT group_id as id, group_name as name, group_colour as colour, group_type 150 FROM ' . GROUPS_TABLE . ' 151 WHERE '; 152 } 153 $sql .= $db->sql_in_set(($ug_type == 'u') ? 'user_id' : 'group_id', array_map('intval', array_keys($recipient_list[$ug_type]))); 154 155 $result = $db->sql_query($sql); 156 157 while ($row = $db->sql_fetchrow($result)) 158 { 159 if ($ug_type == 'g') 160 { 161 $row['name'] = ($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['name']] : $row['name']; 162 } 163 164 $recipient_list[$ug_type][$row['id']] = array('name' => $row['name'], 'colour' => $row['colour']); 165 } 166 $db->sql_freeresult($result); 167 } 168 } 169 170 foreach ($address as $message_id => $adr_ary) 171 { 172 foreach ($adr_ary as $type => $id_ary) 173 { 174 foreach ($id_ary as $ug_id => $_id) 175 { 176 if ($type == 'u') 177 { 178 $address_list[$message_id][] = get_username_string('full', $ug_id, $recipient_list[$type][$ug_id]['name'], $recipient_list[$type][$ug_id]['colour']); 179 } 180 else 181 { 182 $user_colour = ($recipient_list[$type][$ug_id]['colour']) ? ' style="font-weight: bold; color:#' . $recipient_list[$type][$ug_id]['colour'] . '"' : ''; 183 $link = '<a href="' . append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&g=' . $ug_id) . '"' . $user_colour . '>'; 184 $address_list[$message_id][] = $link . $recipient_list[$type][$ug_id]['name'] . (($link) ? '</a>' : ''); 185 } 186 } 187 } 188 } 189 unset($recipient_list, $address); 124 $address_list = get_recipient_strings($folder_info['rowset']); 190 125 } 191 192 $data = array();193 126 194 127 foreach ($folder_info['pm_list'] as $message_id) … … 268 201 { 269 202 // Build Recipient List if in outbox/sentbox 270 $address = array(); 203 204 $address_temp = $address = $data = array(); 205 271 206 if ($folder_id == PRIVMSGS_OUTBOX || $folder_id == PRIVMSGS_SENTBOX) 272 207 { 273 208 foreach ($folder_info['rowset'] as $message_id => $row) 274 209 { 275 $address[$message_id] = rebuild_header(array('to' => $row['to_address'], 'bcc' => $row['bcc_address'])); 210 $address_temp[$message_id] = rebuild_header(array('to' => $row['to_address'], 'bcc' => $row['bcc_address'])); 211 $address[$message_id] = array(); 276 212 } 277 213 } … … 297 233 foreach ($_types as $ug_type) 298 234 { 299 if (isset($address [$message_id][$ug_type]) && sizeof($address[$message_id][$ug_type]))235 if (isset($address_temp[$message_id][$ug_type]) && sizeof($address_temp[$message_id][$ug_type])) 300 236 { 237 if (!isset($address[$message_id][$ug_type])) 238 { 239 $address[$message_id][$ug_type] = array(); 240 } 301 241 if ($ug_type == 'u') 302 242 { … … 311 251 WHERE '; 312 252 } 313 $sql .= $db->sql_in_set(($ug_type == 'u') ? 'user_id' : 'group_id', array_map('intval', array_keys($address [$message_id][$ug_type])));253 $sql .= $db->sql_in_set(($ug_type == 'u') ? 'user_id' : 'group_id', array_map('intval', array_keys($address_temp[$message_id][$ug_type]))); 314 254 315 255 $result = $db->sql_query($sql); … … 317 257 while ($info_row = $db->sql_fetchrow($result)) 318 258 { 319 $address[$message_id][$ug_type][$address [$message_id][$ug_type][$info_row['id']]][] = $info_row['name'];320 unset($address [$message_id][$ug_type][$info_row['id']]);259 $address[$message_id][$ug_type][$address_temp[$message_id][$ug_type][$info_row['id']]][] = $info_row['name']; 260 unset($address_temp[$message_id][$ug_type][$info_row['id']]); 321 261 } 322 262 $db->sql_freeresult($result); … … 324 264 } 325 265 266 // There is the chance that all recipients of the message got deleted. To avoid creating 267 // exports without recipients, we add a bogus "undisclosed recipient". 268 if (!(isset($address[$message_id]['g']) && sizeof($address[$message_id]['g'])) && 269 !(isset($address[$message_id]['u']) && sizeof($address[$message_id]['u']))) 270 { 271 $address[$message_id]['u'] = array(); 272 $address[$message_id]['u']['to'] = array(); 273 $address[$message_id]['u']['to'][] = $user->lang['UNDISCLOSED_RECIPIENT']; 274 } 275 326 276 decode_message($message_row['message_text'], $message_row['bbcode_uid']); 327 277 328 278 $data[] = array( 329 279 'subject' => censor_text($row['message_subject']), 330 280 'sender' => $row['username'], 331 'date' => $user->format_date($row['message_time']), 281 // ISO 8601 date. For PHP4 we are able to hardcode the timezone because $user->format_date() does not set it. 282 'date' => $user->format_date($row['message_time'], (PHP_VERSION >= 5) ? 'c' : "Y-m-d\TH:i:s+00:00", true), 332 283 'to' => ($folder_id == PRIVMSGS_OUTBOX || $folder_id == PRIVMSGS_SENTBOX) ? $address[$message_id] : '', 333 284 'message' => $message_row['message_text'] … … 457 408 { 458 409 $sort_by_text = array('t' => $user->lang['POST_TIME'], 's' => $user->lang['SUBJECT']); 459 $sort_by_sql = array('t' => 'p.m sg_id', 's' => 'p.message_subject');410 $sort_by_sql = array('t' => 'p.message_time', 's' => array('p.message_subject', 'p.message_time')); 460 411 } 461 412 else 462 413 { 463 414 $sort_by_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 's' => $user->lang['SUBJECT']); 464 $sort_by_sql = array('a' => 'u.username_clean', 't' => 'p.msg_id', 's' => 'p.message_subject');415 $sort_by_sql = array('a' => array('u.username_clean', 'p.message_time'), 't' => 'p.message_time', 's' => array('p.message_subject', 'p.message_time')); 465 416 } 466 417 … … 503 454 'TOTAL_MESSAGES' => (($pm_count == 1) ? $user->lang['VIEW_PM_MESSAGE'] : sprintf($user->lang['VIEW_PM_MESSAGES'], $pm_count)), 504 455 505 'POST_IMG' => (!$auth->acl_get('u_sendpm')) ? $user->img('button_topic_locked', 'P M_LOCKED') : $user->img('button_pm_new', 'POST_PM'),506 507 ' L_NO_MESSAGES' => (!$auth->acl_get('u_sendpm')) ? $user->lang['POST_PM_LOCKED'] : $user->lang['NO_MESSAGES'],456 'POST_IMG' => (!$auth->acl_get('u_sendpm')) ? $user->img('button_topic_locked', 'POST_PM_LOCKED') : $user->img('button_pm_new', 'POST_NEW_PM'), 457 458 'S_NO_AUTH_SEND_MESSAGE' => !$auth->acl_get('u_sendpm'), 508 459 509 460 'S_SELECT_SORT_DIR' => $s_sort_dir, … … 512 463 'S_TOPIC_ICONS' => ($config['enable_pm_icons']) ? true : false, 513 464 514 'U_POST_NEW_TOPIC' => ($auth->acl_get('u_sendpm')) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=compose') : '', 465 'U_POST_NEW_TOPIC' => ($auth->acl_get('u_sendpm')) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=compose') : '', 515 466 'S_PM_ACTION' => append_sid("{$phpbb_root_path}ucp.$phpEx", "i=pm&mode=view&action=view_folder&f=$folder_id" . (($start !== 0) ? "&start=$start" : '')), 516 467 )); … … 532 483 533 484 // Select the sort order 534 $ sql_sort_order = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'ASC' : 'DESC');485 $direction = ($sort_dir == 'd') ? 'ASC' : 'DESC'; 535 486 $sql_start = max(0, $pm_count - $sql_limit - $start); 536 487 } … … 538 489 { 539 490 // Select the sort order 540 $ sql_sort_order = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC');491 $direction = ($sort_dir == 'd') ? 'DESC' : 'ASC'; 541 492 $sql_start = $start; 493 } 494 495 // Sql sort order 496 if (is_array($sort_by_sql[$sort_key])) 497 { 498 $sql_sort_order = implode(' ' . $direction . ', ', $sort_by_sql[$sort_key]) . ' ' . $direction; 499 } 500 else 501 { 502 $sql_sort_order = $sort_by_sql[$sort_key] . ' ' . $direction; 542 503 } 543 504
Note:
See TracChangeset
for help on using the changeset viewer.