Line 42 | Line 42 |
---|
* @var \phpbb\config\config */ protected $config;
|
* @var \phpbb\config\config */ protected $config;
|
| /** * Event dispatcher object * @var \phpbb\event\dispatcher_interface */ protected $phpbb_dispatcher;
|
/** * phpBB root path
| /** * phpBB root path
|
Line 60 | Line 66 |
---|
* * @param \phpbb\auth\auth $auth Auth object * @param \phpbb\config\config $config Config object
|
* * @param \phpbb\auth\auth $auth Auth object * @param \phpbb\config\config $config Config object
|
| * @param \phpbb\event\dispatcher_interface $phpbb_dispatcher Event dispatcher object
|
* @param \phpbb\db\driver\driver_interface $db Database object * @param \phpbb\user $user User object * @param string $phpbb_root_path Root path
| * @param \phpbb\db\driver\driver_interface $db Database object * @param \phpbb\user $user User object * @param string $phpbb_root_path Root path
|
Line 69 | Line 76 |
---|
* @param string $topics_table Topics table name * @param string $users_table Users table name */
|
* @param string $topics_table Topics table name * @param string $users_table Users table name */
|
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)
| public function __construct(\phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\event\dispatcher_interface $phpbb_dispatcher, \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->auth = $auth; $this->config = $config;
|
| $this->phpbb_dispatcher = $phpbb_dispatcher;
|
$this->db = $db; $this->user = $user; $this->phpbb_root_path = $phpbb_root_path;
| $this->db = $db; $this->user = $user; $this->phpbb_root_path = $phpbb_root_path;
|
Line 135 | Line 143 |
---|
*/ public function get_visibility_sql($mode, $forum_id, $table_alias = '') {
|
*/ public function get_visibility_sql($mode, $forum_id, $table_alias = '') {
|
| $where_sql = '';
$get_visibility_sql_overwrite = false;
/** * Allow changing the result of calling get_visibility_sql * * @event core.phpbb_content_visibility_get_visibility_sql_before * @var string where_sql Extra visibility conditions. It must end with either an SQL "AND" or an "OR" * @var string mode Either "topic" or "post" depending on the query this is being used in * @var array forum_id The forum id in which the search is made. * @var string table_alias Table alias to prefix in SQL queries * @var mixed get_visibility_sql_overwrite If a string, forces the function to return get_forums_visibility_sql_overwrite after executing the event * If false, get_visibility_sql continues normally * It must be either boolean or string * @since 3.1.4-RC1 */ $vars = array( 'where_sql', 'mode', 'forum_id', 'table_alias', 'get_visibility_sql_overwrite', ); extract($this->phpbb_dispatcher->trigger_event('core.phpbb_content_visibility_get_visibility_sql_before', compact($vars)));
if ($get_visibility_sql_overwrite !== false) { return $get_visibility_sql_overwrite; }
|
if ($this->auth->acl_get('m_approve', $forum_id)) {
|
if ($this->auth->acl_get('m_approve', $forum_id)) {
|
return '1 = 1';
| return $where_sql . '1 = 1';
|
}
|
}
|
return $table_alias . $mode . '_visibility = ' . ITEM_APPROVED;
| return $where_sql . $table_alias . $mode . '_visibility = ' . ITEM_APPROVED;
|
}
/**
| }
/**
|
Line 159 | Line 198 |
---|
$where_sql = '(';
$approve_forums = array_intersect($forum_ids, array_keys($this->auth->acl_getf('m_approve', true)));
|
$where_sql = '(';
$approve_forums = array_intersect($forum_ids, array_keys($this->auth->acl_getf('m_approve', true)));
|
| $get_forums_visibility_sql_overwrite = false; /** * Allow changing the result of calling get_forums_visibility_sql * * @event core.phpbb_content_visibility_get_forums_visibility_before * @var string where_sql The action the user tried to execute * @var string mode Either "topic" or "post" depending on the query this is being used in * @var array forum_ids Array of forum ids which the posts/topics are limited to * @var string table_alias Table alias to prefix in SQL queries * @var array approve_forums Array of forums where the user has m_approve permissions * @var mixed get_forums_visibility_sql_overwrite If a string, forces the function to return get_forums_visibility_sql_overwrite after executing the event * If false, get_forums_visibility_sql continues normally * It must be either boolean or string * @since 3.1.3-RC1 */ $vars = array( 'where_sql', 'mode', 'forum_ids', 'table_alias', 'approve_forums', 'get_forums_visibility_sql_overwrite', ); extract($this->phpbb_dispatcher->trigger_event('core.phpbb_content_visibility_get_forums_visibility_before', compact($vars)));
if ($get_forums_visibility_sql_overwrite !== false) { return $get_forums_visibility_sql_overwrite; }
|
if (sizeof($approve_forums)) {
| if (sizeof($approve_forums)) {
|
Line 168 | Line 237 |
---|
if (!sizeof($forum_ids)) { // The user can see all posts/topics in all specified forums
|
if (!sizeof($forum_ids)) { // The user can see all posts/topics in all specified forums
|
return $this->db->sql_in_set($table_alias . 'forum_id', $approve_forums);
| return $where_sql . $this->db->sql_in_set($table_alias . 'forum_id', $approve_forums) . ')';
|
} else {
| } else {
|
Line 179 | Line 248 |
---|
else { // The user is just a normal user
|
else { // The user is just a normal user
|
return $table_alias . $mode . '_visibility = ' . ITEM_APPROVED . ' AND ' . $this->db->sql_in_set($table_alias . 'forum_id', $forum_ids, false, true);
| return $where_sql . $table_alias . $mode . '_visibility = ' . ITEM_APPROVED . ' AND ' . $this->db->sql_in_set($table_alias . 'forum_id', $forum_ids, false, true) . ')';
|
}
$where_sql .= '(' . $table_alias . $mode . '_visibility = ' . ITEM_APPROVED . '
| }
$where_sql .= '(' . $table_alias . $mode . '_visibility = ' . ITEM_APPROVED . '
|
Line 205 | Line 274 |
---|
$where_sqls = array();
$approve_forums = array_diff(array_keys($this->auth->acl_getf('m_approve', true)), $exclude_forum_ids);
|
$where_sqls = array();
$approve_forums = array_diff(array_keys($this->auth->acl_getf('m_approve', true)), $exclude_forum_ids);
|
| $visibility_sql_overwrite = null;
/** * Allow changing the result of calling get_global_visibility_sql * * @event core.phpbb_content_visibility_get_global_visibility_before * @var array where_sqls The action the user tried to execute * @var string mode Either "topic" or "post" depending on the query this is being used in * @var array exclude_forum_ids Array of forum ids the current user doesn't have access to * @var string table_alias Table alias to prefix in SQL queries * @var array approve_forums Array of forums where the user has m_approve permissions * @var string visibility_sql_overwrite Forces the function to return an implosion of where_sqls (joined by "OR") * @since 3.1.3-RC1 */ $vars = array( 'where_sqls', 'mode', 'exclude_forum_ids', 'table_alias', 'approve_forums', 'visibility_sql_overwrite', ); extract($this->phpbb_dispatcher->trigger_event('core.phpbb_content_visibility_get_global_visibility_before', compact($vars)));
if ($visibility_sql_overwrite) { return $visibility_sql_overwrite; }
|
if (sizeof($exclude_forum_ids)) {
| if (sizeof($exclude_forum_ids)) {
|
Line 317 | Line 415 |
---|
if (empty($post_ids)) { return array();
|
if (empty($post_ids)) { return array();
|
| }
if (!function_exists('truncate_string')) { include($this->phpbb_root_path . 'includes/functions_content.' . $this->php_ext);
|
}
$data = array(
| }
$data = array(
|
Line 325 | Line 428 |
---|
'post_delete_time' => ((int) $time) ?: time(), 'post_delete_reason' => truncate_string($reason, 255, 255, false), );
|
'post_delete_time' => ((int) $time) ?: time(), 'post_delete_reason' => truncate_string($reason, 255, 255, false), );
|
| /** * Perform actions right before the query to change post visibility * * @event core.set_post_visibility_before_sql * @var int visibility Element of {ITEM_APPROVED, ITEM_DELETED, ITEM_REAPPROVE} * @var array post_id Array containing all post IDs to be modified. If blank, all posts within the topic are modified. * @var int topic_id Topic of the post IDs to be modified. * @var int forum_id Forum ID that the topic_id resides in. * @var int user_id User ID doing this action. * @var int timestamp Timestamp of this action. * @var string reason Reason specified by the user for this change. * @var bool is_starter Are we changing the topic's starter? * @var bool is_latest Are we changing the topic's latest post? * @var array data The data array for this action. * @since 3.1.10-RC1 */ $vars = array( 'visibility', 'post_id', 'topic_id', 'forum_id', 'user_id', 'timestamp', 'reason', 'is_starter', 'is_latest', 'data', ); extract($this->phpbb_dispatcher->trigger_event('core.set_post_visibility_before_sql', compact($vars)));
|
$sql = 'UPDATE ' . $this->posts_table . ' SET ' . $this->db->sql_build_array('UPDATE', $data) . ' WHERE ' . $this->db->sql_in_set('post_id', $post_ids);
| $sql = 'UPDATE ' . $this->posts_table . ' SET ' . $this->db->sql_build_array('UPDATE', $data) . ' WHERE ' . $this->db->sql_in_set('post_id', $post_ids);
|
Line 482 | Line 613 |
---|
WHERE topic_id = ' . (int) $topic_id; $this->db->sql_query($sql); }
|
WHERE topic_id = ' . (int) $topic_id; $this->db->sql_query($sql); }
|
| /** * Perform actions after all steps to changing post visibility * * @event core.set_post_visibility_after * @var int visibility Element of {ITEM_APPROVED, ITEM_DELETED, ITEM_REAPPROVE} * @var array post_id Array containing all post IDs to be modified. If blank, all posts within the topic are modified. * @var int topic_id Topic of the post IDs to be modified. * @var int forum_id Forum ID that the topic_id resides in. * @var int user_id User ID doing this action. * @var int timestamp Timestamp of this action. * @var string reason Reason specified by the user for this change. * @var bool is_starter Are we changing the topic's starter? * @var bool is_latest Are we changing the topic's latest post? * @var array data The data array for this action. * @since 3.1.10-RC1 */ $vars = array( 'visibility', 'post_id', 'topic_id', 'forum_id', 'user_id', 'timestamp', 'reason', 'is_starter', 'is_latest', 'data', ); extract($this->phpbb_dispatcher->trigger_event('core.set_post_visibility_after', compact($vars)));
|
return $data; }
| return $data; }
|
Line 528 | Line 687 |
---|
// The topic does not exist... return array(); }
|
// The topic does not exist... return array(); }
|
| }
if (!function_exists('truncate_string')) { include($this->phpbb_root_path . 'includes/functions_content.' . $this->php_ext);
|
}
// Note, we do not set a reason for the posts, just for the topic
| }
// Note, we do not set a reason for the posts, just for the topic
|
Line 537 | Line 701 |
---|
'topic_delete_time' => ((int) $time) ?: time(), 'topic_delete_reason' => truncate_string($reason, 255, 255, false), );
|
'topic_delete_time' => ((int) $time) ?: time(), 'topic_delete_reason' => truncate_string($reason, 255, 255, false), );
|
| /** * Perform actions right before the query to change topic visibility * * @event core.set_topic_visibility_before_sql * @var int visibility Element of {ITEM_APPROVED, ITEM_DELETED, ITEM_REAPPROVE} * @var int topic_id Topic of the post IDs to be modified. * @var int forum_id Forum ID that the topic_id resides in. * @var int user_id User ID doing this action. * @var int timestamp Timestamp of this action. * @var string reason Reason specified by the user for this change. * @var bool force_update_all Force an update on all posts within the topic, regardless of their current approval state. * @var array data The data array for this action. * @since 3.1.10-RC1 */ $vars = array( 'visibility', 'topic_id', 'forum_id', 'user_id', 'timestamp', 'reason', 'force_update_all', 'data', ); extract($this->phpbb_dispatcher->trigger_event('core.set_topic_visibility_before_sql', compact($vars)));
|
$sql = 'UPDATE ' . $this->topics_table . ' SET ' . $this->db->sql_build_array('UPDATE', $data) . ' WHERE topic_id = ' . (int) $topic_id;
| $sql = 'UPDATE ' . $this->topics_table . ' SET ' . $this->db->sql_build_array('UPDATE', $data) . ' WHERE topic_id = ' . (int) $topic_id;
|
Line 562 | Line 750 |
---|
{ $this->set_post_visibility($visibility, false, $topic_id, $forum_id, $user_id, $time, '', true, true); }
|
{ $this->set_post_visibility($visibility, false, $topic_id, $forum_id, $user_id, $time, '', true, true); }
|
| /** * Perform actions after all steps to changing topic visibility * * @event core.set_topic_visibility_after * @var int visibility Element of {ITEM_APPROVED, ITEM_DELETED, ITEM_REAPPROVE} * @var int topic_id Topic of the post IDs to be modified. * @var int forum_id Forum ID that the topic_id resides in. * @var int user_id User ID doing this action. * @var int timestamp Timestamp of this action. * @var string reason Reason specified by the user for this change. * @var bool force_update_all Force an update on all posts within the topic, regardless of their current approval state. * @var array data The data array for this action. * @since 3.1.10-RC1 */ $vars = array( 'visibility', 'topic_id', 'forum_id', 'user_id', 'timestamp', 'reason', 'force_update_all', 'data', ); extract($this->phpbb_dispatcher->trigger_event('core.set_topic_visibility_after', compact($vars)));
|
return $data; }
| return $data; }
|