[ticket/12738] Inject config object into content_visibility class

PHPBB3-12738
This commit is contained in:
Dhruv 2014-06-20 13:25:45 +05:30
parent 517273fa0b
commit 1a79de4214
2 changed files with 13 additions and 5 deletions

View file

@ -79,6 +79,7 @@ services:
class: phpbb\content_visibility
arguments:
- @auth
- @config
- @dbal.conn
- @user
- %core.root_path%

View file

@ -37,6 +37,12 @@ class content_visibility
*/
protected $auth;
/**
* config object
* @var \phpbb\config\config
*/
protected $config;
/**
* phpBB root path
* @var string
@ -62,9 +68,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 +583,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);
}
/**
@ -598,7 +605,7 @@ class content_visibility
$sql_data[$this->users_table] = ((!empty($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);
}
else if ($data['post_visibility'] == ITEM_UNAPPROVED || $data['post_visibility'] == ITEM_REAPPROVE)
{
@ -640,8 +647,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