aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb
diff options
context:
space:
mode:
authorTristan Darricau <github@nicofuma.fr>2014-08-07 16:44:49 +0200
committerTristan Darricau <github@nicofuma.fr>2014-08-07 16:44:49 +0200
commitab8a197e92c491ac37f8ffe2fff1f7c6c42167b6 (patch)
tree550d513947d722a7e294a047175cb1f8f17f012b /phpBB/phpbb
parent778483d070792dc5a6765de2d839110202b16346 (diff)
parent83e5a25c0a03b7b5ee9283201143bf2e6c94758e (diff)
downloadforums-ab8a197e92c491ac37f8ffe2fff1f7c6c42167b6.tar
forums-ab8a197e92c491ac37f8ffe2fff1f7c6c42167b6.tar.gz
forums-ab8a197e92c491ac37f8ffe2fff1f7c6c42167b6.tar.bz2
forums-ab8a197e92c491ac37f8ffe2fff1f7c6c42167b6.tar.xz
forums-ab8a197e92c491ac37f8ffe2fff1f7c6c42167b6.zip
Merge pull request #2623 from dhruvgoel92/ticket/12738
[ticket/12738] Move related code from functions_posting to function * dhruvgoel92/ticket/12738: [ticket/12738] Update constructor docblock [ticket/12738] Add $config to constructor in notification test [ticket/12738] Fix tests with new config object injection [ticket/12738] Inject config object into content_visibility class [ticket/11528] Move related code from functions_posting to function
Diffstat (limited to 'phpBB/phpbb')
-rw-r--r--phpBB/phpbb/content_visibility.php41
1 files changed, 31 insertions, 10 deletions
diff --git a/phpBB/phpbb/content_visibility.php b/phpBB/phpbb/content_visibility.php
index 1f50032f26..da4405d676 100644
--- a/phpBB/phpbb/content_visibility.php
+++ b/phpBB/phpbb/content_visibility.php
@@ -38,6 +38,12 @@ class content_visibility
protected $auth;
/**
+ * config object
+ * @var \phpbb\config\config
+ */
+ protected $config;
+
+ /**
* phpBB root path
* @var string
*/
@@ -53,6 +59,7 @@ class content_visibility
* Constructor
*
* @param \phpbb\auth\auth $auth Auth object
+ * @param \phpbb\config\config $config Config object
* @param \phpbb\db\driver\driver_interface $db Database object
* @param \phpbb\user $user User object
* @param string $phpbb_root_path Root path
@@ -62,9 +69,10 @@ class content_visibility
* @param string $topics_table Topics table name
* @param string $users_table Users table name
*/
- public function __construct(\phpbb\auth\auth $auth, \phpbb\db\driver\driver_interface $db, \phpbb\user $user, $phpbb_root_path, $php_ext, $forums_table, $posts_table, $topics_table, $users_table)
+ public function __construct(\phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\user $user, $phpbb_root_path, $php_ext, $forums_table, $posts_table, $topics_table, $users_table)
{
$this->auth = $auth;
+ $this->config = $config;
$this->db = $db;
$this->user = $user;
$this->phpbb_root_path = $phpbb_root_path;
@@ -576,7 +584,7 @@ class content_visibility
$sql_data[$this->users_table] = (($sql_data[$this->users_table]) ? $sql_data[$this->users_table] . ', ' : '') . 'user_posts = user_posts + 1';
}
- set_config_count('num_posts', 1, true);
+ $this->config->increment('num_posts', 1, false);
}
/**
@@ -588,15 +596,28 @@ class content_visibility
*/
public function remove_post_from_statistic($data, &$sql_data)
{
- $sql_data[$this->topics_table] = ((!empty($sql_data[$this->topics_table])) ? $sql_data[$this->topics_table] . ', ' : '') . 'topic_posts_approved = topic_posts_approved - 1';
- $sql_data[$this->forums_table] = ((!empty($sql_data[$this->forums_table])) ? $sql_data[$this->forums_table] . ', ' : '') . 'forum_posts_approved = forum_posts_approved - 1';
+ if ($data['post_visibility'] == ITEM_APPROVED)
+ {
+ $sql_data[$this->topics_table] = ((!empty($sql_data[$this->topics_table])) ? $sql_data[$this->topics_table] . ', ' : '') . 'topic_posts_approved = topic_posts_approved - 1';
+ $sql_data[$this->forums_table] = ((!empty($sql_data[$this->forums_table])) ? $sql_data[$this->forums_table] . ', ' : '') . 'forum_posts_approved = forum_posts_approved - 1';
- if ($data['post_postcount'])
+ 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';
+ }
+
+ $this->config->increment('num_posts', -1, false);
+ }
+ else if ($data['post_visibility'] == ITEM_UNAPPROVED || $data['post_visibility'] == ITEM_REAPPROVE)
{
- $sql_data[$this->users_table] = ((!empty($sql_data[$this->users_table])) ? $sql_data[$this->users_table] . ', ' : '') . 'user_posts = user_posts - 1';
+ $sql_data[FORUMS_TABLE] = (($sql_data[FORUMS_TABLE]) ? $sql_data[FORUMS_TABLE] . ', ' : '') . 'forum_posts_unapproved = forum_posts_unapproved - 1';
+ $sql_data[TOPICS_TABLE] = (($sql_data[TOPICS_TABLE]) ? $sql_data[TOPICS_TABLE] . ', ' : '') . 'topic_posts_unapproved = topic_posts_unapproved - 1';
+ }
+ else if ($data['post_visibility'] == ITEM_DELETED)
+ {
+ $sql_data[FORUMS_TABLE] = (($sql_data[FORUMS_TABLE]) ? $sql_data[FORUMS_TABLE] . ', ' : '') . 'forum_posts_softdeleted = forum_posts_softdeleted - 1';
+ $sql_data[TOPICS_TABLE] = (($sql_data[TOPICS_TABLE]) ? $sql_data[TOPICS_TABLE] . ', ' : '') . 'topic_posts_softdeleted = topic_posts_softdeleted - 1';
}
-
- set_config_count('num_posts', -1, true);
}
/**
@@ -627,8 +648,8 @@ class content_visibility
$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'];
- set_config_count('num_topics', -1, true);
- set_config_count('num_posts', $topic_row['topic_posts_approved'] * (-1), true);
+ $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