diff options
Diffstat (limited to 'phpBB')
-rw-r--r-- | phpBB/composer.json | 2 | ||||
-rw-r--r-- | phpBB/composer.lock | 185 | ||||
-rw-r--r-- | phpBB/includes/functions_posting.php | 13 | ||||
-rw-r--r-- | phpBB/phpbb/content_visibility.php | 69 | ||||
-rw-r--r-- | phpBB/phpbb/notification/type/approve_post.php | 9 | ||||
-rw-r--r-- | phpBB/phpbb/notification/type/approve_topic.php | 9 | ||||
-rw-r--r-- | phpBB/phpbb/notification/type/base.php | 33 | ||||
-rw-r--r-- | phpBB/phpbb/notification/type/bookmark.php | 12 | ||||
-rw-r--r-- | phpBB/phpbb/notification/type/post.php | 14 | ||||
-rw-r--r-- | phpBB/phpbb/notification/type/quote.php | 17 | ||||
-rw-r--r-- | phpBB/phpbb/notification/type/topic.php | 14 |
11 files changed, 75 insertions, 302 deletions
diff --git a/phpBB/composer.json b/phpBB/composer.json index 0ab30b0837..e74dd120f0 100644 --- a/phpBB/composer.json +++ b/phpBB/composer.json @@ -37,8 +37,6 @@ "twig/twig": "1.13.*" }, "require-dev": { - "behat/mink": "1.4.*", - "behat/mink-goutte-driver": "1.0.*", "fabpot/goutte": "1.0.*", "phpunit/dbunit": "1.3.*", "phpunit/phpunit": "4.1.*", diff --git a/phpBB/composer.lock b/phpBB/composer.lock index 3860a98b31..671daa70e1 100644 --- a/phpBB/composer.lock +++ b/phpBB/composer.lock @@ -3,7 +3,7 @@ "This file locks the dependencies of your project to a known state", "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file" ], - "hash": "6bc742a2b9feb426db9987d27085f915", + "hash": "27d5da149e0b5d76b76f43210306b666", "packages": [ { "name": "lusitanian/oauth", @@ -255,12 +255,14 @@ ], "authors": [ { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" }, { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" } ], "description": "Symfony Debug Component", @@ -719,167 +721,6 @@ ], "packages-dev": [ { - "name": "behat/mink", - "version": "v1.4.3", - "source": { - "type": "git", - "url": "https://github.com/Behat/Mink.git", - "reference": "0817070a6e2ec9f475fad9bfb81a962c462eb934" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/Behat/Mink/zipball/0817070a6e2ec9f475fad9bfb81a962c462eb934", - "reference": "0817070a6e2ec9f475fad9bfb81a962c462eb934", - "shasum": "" - }, - "require": { - "php": ">=5.3.1", - "symfony/css-selector": ">=2.0,<2.4-dev" - }, - "suggest": { - "behat/mink-browserkit-driver": "extremely fast headless driver for Symfony\\Kernel-based apps (Sf2, Silex)", - "behat/mink-goutte-driver": "fast headless driver for any app without JS emulation", - "behat/mink-selenium2-driver": "slow, but JS-enabled driver for any app (requires Selenium2)", - "behat/mink-zombie-driver": "fast and JS-enabled headless driver for any app (requires node.js)" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-develop": "1.4.x-dev" - } - }, - "autoload": { - "psr-0": { - "Behat\\Mink": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Konstantin Kudryashov", - "email": "ever.zet@gmail.com", - "homepage": "http://everzet.com" - } - ], - "description": "Web acceptance testing framework for PHP 5.3", - "homepage": "http://mink.behat.org/", - "keywords": [ - "browser", - "testing", - "web" - ], - "time": "2013-03-02 15:53:18" - }, - { - "name": "behat/mink-browserkit-driver", - "version": "v1.0.5", - "source": { - "type": "git", - "url": "https://github.com/Behat/MinkBrowserKitDriver.git", - "reference": "f2771b5fc4dbc233859addf37a7d150852f78418" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/Behat/MinkBrowserKitDriver/zipball/f2771b5fc4dbc233859addf37a7d150852f78418", - "reference": "f2771b5fc4dbc233859addf37a7d150852f78418", - "shasum": "" - }, - "require": { - "behat/mink": "~1.4.3", - "php": ">=5.3.1", - "symfony/browser-kit": "~2.0", - "symfony/dom-crawler": "~2.0" - }, - "require-dev": { - "silex/silex": "@dev" - }, - "type": "mink-driver", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-0": { - "Behat\\Mink\\Driver": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Konstantin Kudryashov", - "email": "ever.zet@gmail.com", - "homepage": "http://everzet.com" - } - ], - "description": "Symfony2 BrowserKit driver for Mink framework", - "homepage": "http://mink.behat.org/", - "keywords": [ - "Mink", - "Symfony2", - "browser", - "testing" - ], - "time": "2013-04-13 12:17:15" - }, - { - "name": "behat/mink-goutte-driver", - "version": "v1.0.9", - "source": { - "type": "git", - "url": "https://github.com/Behat/MinkGoutteDriver.git", - "reference": "fa1b073b48761464feb0b05e6825da44b20118d8" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/Behat/MinkGoutteDriver/zipball/fa1b073b48761464feb0b05e6825da44b20118d8", - "reference": "fa1b073b48761464feb0b05e6825da44b20118d8", - "shasum": "" - }, - "require": { - "behat/mink-browserkit-driver": ">=1.0.5,<1.2.0", - "fabpot/goutte": "~1.0.1", - "php": ">=5.3.1" - }, - "type": "mink-driver", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-0": { - "Behat\\Mink\\Driver": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Konstantin Kudryashov", - "email": "ever.zet@gmail.com", - "homepage": "http://everzet.com" - } - ], - "description": "Goutte driver for Mink framework", - "homepage": "http://mink.behat.org/", - "keywords": [ - "browser", - "goutte", - "headless", - "testing" - ], - "time": "2013-07-03 18:43:54" - }, - { "name": "fabpot/goutte", "version": "v1.0.3", "source": { @@ -2428,11 +2269,17 @@ "time": "2014-05-17 21:49:26" } ], - "aliases": [], + "aliases": [ + + ], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": [ + + ], "platform": { "php": ">=5.3.3" }, - "platform-dev": [] + "platform-dev": [ + + ] } diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index fb09bc7057..624ce187b9 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -1324,18 +1324,7 @@ function delete_post($forum_id, $topic_id, $post_id, &$data, $is_soft = false, $ { delete_topics('topic_id', array($topic_id), false); - if ($data['topic_visibility'] == ITEM_APPROVED) - { - $sql_data[FORUMS_TABLE] .= 'forum_posts_approved = forum_posts_approved - 1, forum_topics_approved = forum_topics_approved - 1'; - } - else if ($data['topic_visibility'] == ITEM_UNAPPROVED || $data['post_visibility'] == ITEM_REAPPROVE) - { - $sql_data[FORUMS_TABLE] .= 'forum_posts_unapproved = forum_posts_unapproved - 1, forum_topics_unapproved = forum_topics_unapproved - 1'; - } - else if ($data['topic_visibility'] == ITEM_DELETED) - { - $sql_data[FORUMS_TABLE] .= 'forum_posts_softdeleted = forum_posts_softdeleted - 1, forum_topics_softdeleted = forum_topics_softdeleted - 1'; - } + $phpbb_content_visibility->remove_topic_from_statistic($data, $sql_data); $update_sql = update_post_information('forum', $forum_id, true); if (sizeof($update_sql)) diff --git a/phpBB/phpbb/content_visibility.php b/phpBB/phpbb/content_visibility.php index da4405d676..8bd537586e 100644 --- a/phpBB/phpbb/content_visibility.php +++ b/phpBB/phpbb/content_visibility.php @@ -570,7 +570,7 @@ class content_visibility * Add post to topic and forum statistics * * @param $data array Contains information from the topics table about given topic - * @param $sql_data array Populated with the SQL changes, may be empty at call time + * @param &$sql_data array Populated with the SQL changes, may be empty at call time * @return null */ public function add_post_to_statistic($data, &$sql_data) @@ -591,7 +591,7 @@ class content_visibility * Remove post from topic and forum statistics * * @param $data array Contains information from the topics table about given topic - * @param $sql_data array Populated with the SQL changes, may be empty at call time + * @param &$sql_data array Populated with the SQL changes, may be empty at call time * @return null */ public function remove_post_from_statistic($data, &$sql_data) @@ -623,64 +623,29 @@ class content_visibility /** * Remove topic from forum statistics * - * @param $topic_id int The topic to act on - * @param $forum_id int Forum where the topic is found - * @param $topic_row array Contains information from the topic, may be empty at call time - * @param $sql_data array Populated with the SQL changes, may be empty at call time + * @param $data array Post and topic data + * @param &$sql_data array Populated with the SQL changes, may be empty at call time * @return null */ - public function remove_topic_from_statistic($topic_id, $forum_id, &$topic_row, &$sql_data) + public function remove_topic_from_statistic($data, &$sql_data) { - // Do we need to grab some topic informations? - if (!sizeof($topic_row)) + if ($data['topic_visibility'] == ITEM_APPROVED) { - $sql = 'SELECT topic_type, topic_posts_approved, topic_posts_unapproved, topic_posts_softdeleted, topic_visibility - FROM ' . $this->topics_table . ' - WHERE topic_id = ' . (int) $topic_id; - $result = $this->db->sql_query($sql); - $topic_row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - } - - // If this is an edited topic or the first post the topic gets completely disapproved later on... - $sql_data[$this->forums_table] = (($sql_data[$this->forums_table]) ? $sql_data[$this->forums_table] . ', ' : '') . 'forum_topics_approved = forum_topics_approved - 1'; - $sql_data[$this->forums_table] .= ', forum_posts_approved = forum_posts_approved - ' . $topic_row['topic_posts_approved']; - $sql_data[$this->forums_table] .= ', forum_posts_unapproved = forum_posts_unapproved - ' . $topic_row['topic_posts_unapproved']; - $sql_data[$this->forums_table] .= ', forum_posts_softdeleted = forum_posts_softdeleted - ' . $topic_row['topic_posts_softdeleted']; + $sql_data[FORUMS_TABLE] .= 'forum_posts_approved = forum_posts_approved - 1, forum_topics_approved = forum_topics_approved - 1'; - $this->config->increment('num_topics', -1, false); - $this->config->increment('num_posts', $topic_row['topic_posts_approved'] * (-1), false); - - // Get user post count information - $sql = 'SELECT poster_id, COUNT(post_id) AS num_posts - FROM ' . $this->posts_table . ' - WHERE topic_id = ' . (int) $topic_id . ' - AND post_postcount = 1 - AND post_visibility = ' . ITEM_APPROVED . ' - GROUP BY poster_id'; - $result = $this->db->sql_query($sql); - - $postcounts = array(); - while ($row = $this->db->sql_fetchrow($result)) + if ($data['post_postcount']) + { + $sql_data[$this->users_table] = ((!empty($sql_data[$this->users_table])) ? $sql_data[$this->users_table] . ', ' : '') . 'user_posts = user_posts - 1'; + } + } + else if ($data['topic_visibility'] == ITEM_UNAPPROVED || $data['post_visibility'] == ITEM_REAPPROVE) { - $postcounts[(int) $row['num_posts']][] = (int) $row['poster_id']; + $sql_data[FORUMS_TABLE] .= 'forum_posts_unapproved = forum_posts_unapproved - 1, forum_topics_unapproved = forum_topics_unapproved - 1'; } - $this->db->sql_freeresult($result); - - // Decrement users post count - foreach ($postcounts as $num_posts => $poster_ids) + else if ($data['topic_visibility'] == ITEM_DELETED) { - $sql = 'UPDATE ' . $this->users_table . ' - SET user_posts = 0 - WHERE user_posts < ' . $num_posts . ' - AND ' . $this->db->sql_in_set('user_id', $poster_ids); - $this->db->sql_query($sql); - - $sql = 'UPDATE ' . $this->users_table . ' - SET user_posts = user_posts - ' . $num_posts . ' - WHERE user_posts >= ' . $num_posts . ' - AND ' . $this->db->sql_in_set('user_id', $poster_ids); - $this->db->sql_query($sql); + $sql_data[FORUMS_TABLE] .= 'forum_posts_softdeleted = forum_posts_softdeleted - 1, forum_topics_softdeleted = forum_topics_softdeleted - 1'; } + } } diff --git a/phpBB/phpbb/notification/type/approve_post.php b/phpBB/phpbb/notification/type/approve_post.php index 0aad19d6bf..22c9076adc 100644 --- a/phpBB/phpbb/notification/type/approve_post.php +++ b/phpBB/phpbb/notification/type/approve_post.php @@ -81,14 +81,7 @@ class approve_post extends \phpbb\notification\type\post $users = array(); $users[$post['poster_id']] = array(''); - $auth_read = $this->auth->acl_get_list(array_keys($users), 'f_read', $post['forum_id']); - - if (empty($auth_read)) - { - return array(); - } - - return $this->check_user_notification_options($auth_read[$post['forum_id']]['f_read'], array_merge($options, array( + return $this->get_authorised_recipients(array_keys($users), $post['forum_id'], array_merge($options, array( 'item_type' => self::$notification_option['id'], ))); } diff --git a/phpBB/phpbb/notification/type/approve_topic.php b/phpBB/phpbb/notification/type/approve_topic.php index e649f3920e..77e53a0064 100644 --- a/phpBB/phpbb/notification/type/approve_topic.php +++ b/phpBB/phpbb/notification/type/approve_topic.php @@ -81,14 +81,7 @@ class approve_topic extends \phpbb\notification\type\topic $users = array(); $users[$post['poster_id']] = array(''); - $auth_read = $this->auth->acl_get_list(array_keys($users), 'f_read', $post['forum_id']); - - if (empty($auth_read)) - { - return array(); - } - - return $this->check_user_notification_options($auth_read[$post['forum_id']]['f_read'], array_merge($options, array( + return $this->get_authorised_recipients(array_keys($users), $post['forum_id'], array_merge($options, array( 'item_type' => self::$notification_option['id'], ))); } diff --git a/phpBB/phpbb/notification/type/base.php b/phpBB/phpbb/notification/type/base.php index a11ad76db9..4ead06071e 100644 --- a/phpBB/phpbb/notification/type/base.php +++ b/phpBB/phpbb/notification/type/base.php @@ -533,4 +533,37 @@ abstract class base implements \phpbb\notification\type\type_interface WHERE ' . $where; $this->db->sql_query($sql); } + + /** + * Get a list of users that are authorised to receive notifications + * + * @param array $users Array of users that have subscribed to a notification + * @param int $forum_id Forum ID of the forum + * @param array $options Array of notification options + * @param bool $sort Whether the users array should be sorted. Default: false + * @return array Array of users that are authorised recipients + */ + protected function get_authorised_recipients($users, $forum_id, $options, $sort = false) + { + if (empty($users)) + { + return array(); + } + + $users = array_unique($users); + + if ($sort) + { + sort($users); + } + + $auth_read = $this->auth->acl_get_list($users, 'f_read', $forum_id); + + if (empty($auth_read)) + { + return array(); + } + + return $this->check_user_notification_options($auth_read[$forum_id]['f_read'], $options); + } } diff --git a/phpBB/phpbb/notification/type/bookmark.php b/phpBB/phpbb/notification/type/bookmark.php index c83288cfb8..21180b3b53 100644 --- a/phpBB/phpbb/notification/type/bookmark.php +++ b/phpBB/phpbb/notification/type/bookmark.php @@ -83,21 +83,13 @@ class bookmark extends \phpbb\notification\type\post } $this->db->sql_freeresult($result); - if (empty($users)) - { - return array(); - } - sort($users); + $notify_users = $this->get_authorised_recipients($users, $post['forum_id'], $options, true); - $auth_read = $this->auth->acl_get_list($users, 'f_read', $post['forum_id']); - - if (empty($auth_read)) + if (empty($notify_users)) { return array(); } - $notify_users = $this->check_user_notification_options($auth_read[$post['forum_id']]['f_read'], $options); - // Try to find the users who already have been notified about replies and have not read the topic since and just update their notifications $update_notifications = array(); $sql = 'SELECT n.* diff --git a/phpBB/phpbb/notification/type/post.php b/phpBB/phpbb/notification/type/post.php index 357176ec35..1eba4a6a88 100644 --- a/phpBB/phpbb/notification/type/post.php +++ b/phpBB/phpbb/notification/type/post.php @@ -123,23 +123,13 @@ class post extends \phpbb\notification\type\base } $this->db->sql_freeresult($result); - if (empty($users)) - { - return array(); - } + $notify_users = $this->get_authorised_recipients($users, $post['forum_id'], $options, true); - $users = array_unique($users); - sort($users); - - $auth_read = $this->auth->acl_get_list($users, 'f_read', $post['forum_id']); - - if (empty($auth_read)) + if (empty($notify_users)) { return array(); } - $notify_users = $this->check_user_notification_options($auth_read[$post['forum_id']]['f_read'], $options); - // Try to find the users who already have been notified about replies and have not read the topic since and just update their notifications $update_notifications = array(); $sql = 'SELECT n.* diff --git a/phpBB/phpbb/notification/type/quote.php b/phpBB/phpbb/notification/type/quote.php index 6e672e6fbd..5c3c822ec2 100644 --- a/phpBB/phpbb/notification/type/quote.php +++ b/phpBB/phpbb/notification/type/quote.php @@ -102,22 +102,7 @@ class quote extends \phpbb\notification\type\post } $this->db->sql_freeresult($result); - if (empty($users)) - { - return array(); - } - sort($users); - - $auth_read = $this->auth->acl_get_list($users, 'f_read', $post['forum_id']); - - if (empty($auth_read)) - { - return array(); - } - - $notify_users = $this->check_user_notification_options($auth_read[$post['forum_id']]['f_read'], $options); - - return $notify_users; + return $this->get_authorised_recipients($users, $post['forum_id'], $options, true); } /** diff --git a/phpBB/phpbb/notification/type/topic.php b/phpBB/phpbb/notification/type/topic.php index 289e45bedb..af199fb765 100644 --- a/phpBB/phpbb/notification/type/topic.php +++ b/phpBB/phpbb/notification/type/topic.php @@ -111,19 +111,7 @@ class topic extends \phpbb\notification\type\base } $this->db->sql_freeresult($result); - if (empty($users)) - { - return array(); - } - - $auth_read = $this->auth->acl_get_list($users, 'f_read', $topic['forum_id']); - - if (empty($auth_read)) - { - return array(); - } - - return $this->check_user_notification_options($auth_read[$topic['forum_id']]['f_read'], $options); + return $this->get_authorised_recipients($users, $topic['forum_id'], $options); } /** |