Ignore:
Timestamp:
Mar 31, 2010, 6:32:40 PM (14 years ago)
Author:
george
Message:
  • Upraveno: Aktualizace fóra.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/forum/includes/functions_privmsgs.php

    r400 r702  
    33*
    44* @package phpBB3
    5 * @version $Id: functions_privmsgs.php 8993 2008-10-10 17:38:17Z toonarmy $
     5* @version $Id$
    66* @copyright (c) 2005 phpBB Group
    77* @license http://opensource.org/licenses/gpl-license.php GNU Public License
     
    895895                case 'delete_marked':
    896896
     897                        global $auth;
     898
     899                        if (!$auth->acl_get('u_pm_delete'))
     900                        {
     901                                trigger_error('NO_AUTH_DELETE_MESSAGE');
     902                        }
     903
    897904                        if (confirm_box(true))
    898905                        {
     
    11461153                        $sql = 'SELECT user_id, username, user_colour
    11471154                                FROM ' . USERS_TABLE . '
    1148                                 WHERE ' . $db->sql_in_set('user_id', $u) . '
    1149                                         AND user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')';
     1155                                WHERE ' . $db->sql_in_set('user_id', $u);
    11501156                        $result = $db->sql_query($sql);
    11511157
     
    13511357                                        AND ug.user_pending = 0
    13521358                                        AND u.user_id = ug.user_id
    1353                                         AND u.user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')' . 
     1359                                        AND u.user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')' .
    13541360                                        $sql_allow_pm;
    13551361                        $result = $db->sql_query($sql);
     
    13571363                        while ($row = $db->sql_fetchrow($result))
    13581364                        {
     1365                                // Additionally, do not include the sender if he is in the group he wants to send to. ;)
     1366                                if ($row['user_id'] === $user->data['user_id'])
     1367                                {
     1368                                        continue;
     1369                                }
     1370
    13591371                                $field = ($data['address_list']['g'][$row['group_id']] == 'to') ? 'to' : 'bcc';
    13601372                                $recipients[$row['user_id']] = $field;
     
    14061418                                'bbcode_uid'            => $data['bbcode_uid'],
    14071419                                'to_address'            => implode(':', $to),
    1408                                 'bcc_address'           => implode(':', $bcc)
     1420                                'bcc_address'           => implode(':', $bcc),
     1421                                'message_reported'      => 0,
    14091422                        );
    14101423                break;
     
    15461559                        {
    15471560                                // insert attachment into db
    1548                                 if (!@file_exists($phpbb_root_path . $config['upload_path'] . '/' . basename($orphan_rows[$attach_row['attach_id']]['physical_filename'])))
     1561                                if (!@file_exists($phpbb_root_path . $config['upload_path'] . '/' . utf8_basename($orphan_rows[$attach_row['attach_id']]['physical_filename'])))
    15491562                                {
    15501563                                        continue;
     
    15721585                if ($space_taken && $files_added)
    15731586                {
    1574                         set_config('upload_dir_size', $config['upload_dir_size'] + $space_taken, true);
    1575                         set_config('num_files', $config['num_files'] + $files_added, true);
     1587                        set_config_count('upload_dir_size', $space_taken, true);
     1588                        set_config_count('num_files', $files_added, true);
    15761589                }
    15771590        }
     
    16921705        global $db, $user, $config, $template, $phpbb_root_path, $phpEx, $auth, $bbcode;
    16931706
     1707        // Select all receipts and the author from the pm we currently view, to only display their pm-history
     1708        $sql = 'SELECT author_id, user_id
     1709                FROM ' . PRIVMSGS_TO_TABLE . "
     1710                WHERE msg_id = $msg_id
     1711                        AND folder_id <> " . PRIVMSGS_HOLD_BOX;
     1712        $result = $db->sql_query($sql);
     1713
     1714        $recipients = array();
     1715        while ($row = $db->sql_fetchrow($result))
     1716        {
     1717                $recipients[] = (int) $row['user_id'];
     1718                $recipients[] = (int) $row['author_id'];
     1719        }
     1720        $db->sql_freeresult($result);
     1721        $recipients = array_unique($recipients);
     1722
    16941723        // Get History Messages (could be newer)
    16951724        $sql = 'SELECT t.*, p.*, u.*
     
    16971726                WHERE t.msg_id = p.msg_id
    16981727                        AND p.author_id = u.user_id
    1699                         AND t.folder_id NOT IN (' . PRIVMSGS_NO_BOX . ', ' . PRIVMSGS_HOLD_BOX . ")
     1728                        AND t.folder_id NOT IN (' . PRIVMSGS_NO_BOX . ', ' . PRIVMSGS_HOLD_BOX . ')
     1729                        AND ' . $db->sql_in_set('t.author_id', $recipients, false, true) . "
    17001730                        AND t.user_id = $user_id";
     1731
     1732        // We no longer need those.
     1733        unset($recipients);
    17011734
    17021735        if (!$message_row['root_level'])
     
    17641797        $next_history_pm = $previous_history_pm = $prev_id = 0;
    17651798
    1766         foreach ($rowset as $id => $row)
    1767         {
     1799        // Re-order rowset to be able to get the next/prev message rows...
     1800        $rowset = array_values($rowset);
     1801
     1802        for ($i = 0, $size = sizeof($rowset); $i < $size; $i++)
     1803        {
     1804                $row = &$rowset[$i];
     1805                $id = (int) $row['msg_id'];
     1806
    17681807                $author_id      = $row['author_id'];
    17691808                $folder_id      = (int) $row['folder_id'];
     
    17761815                $decoded_message = false;
    17771816
    1778                 if ($in_post_mode && $auth->acl_get('u_sendpm') && $author_id != ANONYMOUS && $author_id != $user->data['user_id'])
     1817                if ($in_post_mode && $auth->acl_get('u_sendpm') && $author_id != ANONYMOUS)
    17791818                {
    17801819                        $decoded_message = $message;
     
    17961835                if ($id == $msg_id)
    17971836                {
    1798                         $next_history_pm = next($rowset);
    1799                         $next_history_pm = (sizeof($next_history_pm)) ? (int) $next_history_pm['msg_id'] : 0;
     1837                        $next_history_pm = (isset($rowset[$i + 1])) ? (int) $rowset[$i + 1]['msg_id'] : 0;
    18001838                        $previous_history_pm = $prev_id;
    18011839                }
     
    18201858                        'MSG_ID'                        => $row['msg_id'],
    18211859                        'U_VIEW_MESSAGE'        => "$url&amp;f=$folder_id&amp;p=" . $row['msg_id'],
    1822                         'U_QUOTE'                       => (!$in_post_mode && $auth->acl_get('u_sendpm') && $author_id != ANONYMOUS && $author_id != $user->data['user_id']) ? "$url&amp;mode=compose&amp;action=quote&amp;f=" . $folder_id . "&amp;p=" . $row['msg_id'] : '',
     1860                        'U_QUOTE'                       => (!$in_post_mode && $auth->acl_get('u_sendpm') && $author_id != ANONYMOUS) ? "$url&amp;mode=compose&amp;action=quote&amp;f=" . $folder_id . "&amp;p=" . $row['msg_id'] : '',
    18231861                        'U_POST_REPLY_PM'       => ($author_id != $user->data['user_id'] && $author_id != ANONYMOUS && $auth->acl_get('u_sendpm')) ? "$url&amp;mode=compose&amp;action=reply&amp;f=$folder_id&amp;p=" . $row['msg_id'] : '')
    18241862                );
    1825                 unset($rowset[$id]);
     1863                unset($rowset[$i]);
    18261864                $prev_id = $id;
    18271865        }
     
    18591897}
    18601898
     1899/**
     1900* Generates an array of coloured recipient names from a list of PMs - (groups & users)
     1901*
     1902* @param        array   $pm_by_id       An array of rows from PRIVMSGS_TABLE, keys are the msg_ids.
     1903*
     1904* @return       array                           2D Array: array(msg_id => array('username or group string', ...), ...)
     1905*                                                               Usernames are generated with {@link get_username_string get_username_string}
     1906*                                                               Groups are coloured and have a link to the membership page
     1907*/
     1908function get_recipient_strings($pm_by_id)
     1909{
     1910        global $db, $phpbb_root_path, $phpEx, $user;
     1911
     1912        $address_list = $recipient_list = $address = array();
     1913
     1914        $_types = array('u', 'g');
     1915
     1916        foreach ($pm_by_id as $message_id => $row)
     1917        {
     1918                $address[$message_id] = rebuild_header(array('to' => $row['to_address'], 'bcc' => $row['bcc_address']));
     1919
     1920                foreach ($_types as $ug_type)
     1921                {
     1922                        if (isset($address[$message_id][$ug_type]) && sizeof($address[$message_id][$ug_type]))
     1923                        {
     1924                                foreach ($address[$message_id][$ug_type] as $ug_id => $in_to)
     1925                                {
     1926                                        $recipient_list[$ug_type][$ug_id] = array('name' => $user->lang['NA'], 'colour' => '');
     1927                                }
     1928                        }
     1929                }
     1930        }
     1931
     1932        foreach ($_types as $ug_type)
     1933        {
     1934                if (!empty($recipient_list[$ug_type]))
     1935                {
     1936                        if ($ug_type == 'u')
     1937                        {
     1938                                $sql = 'SELECT user_id as id, username as name, user_colour as colour
     1939                                        FROM ' . USERS_TABLE . '
     1940                                        WHERE ';
     1941                        }
     1942                        else
     1943                        {
     1944                                $sql = 'SELECT group_id as id, group_name as name, group_colour as colour, group_type
     1945                                        FROM ' . GROUPS_TABLE . '
     1946                                        WHERE ';
     1947                        }
     1948                        $sql .= $db->sql_in_set(($ug_type == 'u') ? 'user_id' : 'group_id', array_map('intval', array_keys($recipient_list[$ug_type])));
     1949
     1950                        $result = $db->sql_query($sql);
     1951
     1952                        while ($row = $db->sql_fetchrow($result))
     1953                        {
     1954                                if ($ug_type == 'g')
     1955                                {
     1956                                        $row['name'] = ($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['name']] : $row['name'];
     1957                                }
     1958
     1959                                $recipient_list[$ug_type][$row['id']] = array('name' => $row['name'], 'colour' => $row['colour']);
     1960                        }
     1961                        $db->sql_freeresult($result);
     1962                }
     1963        }
     1964
     1965        foreach ($address as $message_id => $adr_ary)
     1966        {
     1967                foreach ($adr_ary as $type => $id_ary)
     1968                {
     1969                        foreach ($id_ary as $ug_id => $_id)
     1970                        {
     1971                                if ($type == 'u')
     1972                                {
     1973                                        $address_list[$message_id][] = get_username_string('full', $ug_id, $recipient_list[$type][$ug_id]['name'], $recipient_list[$type][$ug_id]['colour']);
     1974                                }
     1975                                else
     1976                                {
     1977                                        $user_colour = ($recipient_list[$type][$ug_id]['colour']) ? ' style="font-weight: bold; color:#' . $recipient_list[$type][$ug_id]['colour'] . '"' : '';
     1978                                        $link = '<a href="' . append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&amp;g=' . $ug_id) . '"' . $user_colour . '>';
     1979                                        $address_list[$message_id][] = $link . $recipient_list[$type][$ug_id]['name'] . (($link) ? '</a>' : '');
     1980                                }
     1981                        }
     1982                }
     1983        }
     1984
     1985        return $address_list;
     1986}
     1987
    18611988?>
Note: See TracChangeset for help on using the changeset viewer.