Uploaded image for project: 'phpBB3'
  1. phpBB3
  2. PHPBB3-11113

sending PM to group will also create a new PM to the sender

    XMLWordPrintable

Details

    Description

      When creating a PM and having at least one group as recipient to which you also belong, the sent PM causes the sender himself to get the very same PM as a new one in his inbox. This is a code change from 3.0.10 to 3.0.11 with no relation to any ticket or reason in /includes/functions_privmsgs.php. Version 3.0.10 reads:

      		if (isset($data['address_list']['g']) && sizeof($data['address_list']['g']))
      		{
      			// We need to check the PM status of group members (do they want to receive PM's?)
      			// Only check if not a moderator or admin, since they are allowed to override this user setting
      			$sql_allow_pm = (!$auth->acl_gets('a_', 'm_') && !$auth->acl_getf_global('m_')) ? ' AND u.user_allow_pm = 1' : '';
       
      			$sql = 'SELECT u.user_type, ug.group_id, ug.user_id
      				FROM ' . USERS_TABLE . ' u, ' . USER_GROUP_TABLE . ' ug
      				WHERE ' . $db->sql_in_set('ug.group_id', array_keys($data['address_list']['g'])) . '
      					AND ug.user_pending = 0
      					AND u.user_id = ug.user_id
      					AND u.user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')' .
      					$sql_allow_pm;
      			$result = $db->sql_query($sql);
       
      			while ($row = $db->sql_fetchrow($result))
      			{
      				// Additionally, do not include the sender if he is in the group he wants to send to. ;)
      				if ($row['user_id'] === $user->data['user_id'])
      				{
      					continue;
      				}
       
      				$field = ($data['address_list']['g'][$row['group_id']] == 'to') ? 'to' : 'bcc';
      				$recipients[$row['user_id']] = $field;
      			}
      			$db->sql_freeresult($result);
      		}

      Version 3.0.11 misses the important part:

      		if (isset($data['address_list']['g']) && sizeof($data['address_list']['g']))
      		{
      			// We need to check the PM status of group members (do they want to receive PM's?)
      			// Only check if not a moderator or admin, since they are allowed to override this user setting
      			$sql_allow_pm = (!$auth->acl_gets('a_', 'm_') && !$auth->acl_getf_global('m_')) ? ' AND u.user_allow_pm = 1' : '';
       
      			$sql = 'SELECT u.user_type, ug.group_id, ug.user_id
      				FROM ' . USERS_TABLE . ' u, ' . USER_GROUP_TABLE . ' ug
      				WHERE ' . $db->sql_in_set('ug.group_id', array_keys($data['address_list']['g'])) . '
      					AND ug.user_pending = 0
      					AND u.user_id = ug.user_id
      					AND u.user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')' .
      					$sql_allow_pm;
      			$result = $db->sql_query($sql);
       
      			while ($row = $db->sql_fetchrow($result))
      			{
      				$field = ($data['address_list']['g'][$row['group_id']] == 'to') ? 'to' : 'bcc';
      				$recipients[$row['user_id']] = $field;
      			}
      			$db->sql_freeresult($result);
      		}

      Attachments

        Activity

          People

            CHItA CHItA
            AmigoJack AmigoJack
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: