New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ticket/9837] Display unapproved posts to their authors #5222
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -144,7 +144,13 @@ public function get_count($mode, $data, $forum_id) | |
*/ | ||
public function is_visible($mode, $forum_id, $data) | ||
{ | ||
$is_visible = $this->auth->acl_get('m_approve', $forum_id) || $data[$mode . '_visibility'] == ITEM_APPROVED; | ||
$visibility = $data[$mode . '_visibility']; | ||
$poster_key = ($mode === 'topic') ? 'topic_poster' : 'poster_id'; | ||
$is_visible = $this->auth->acl_get('m_approve', $forum_id) || $visibility == ITEM_APPROVED; | ||
$is_visible = $is_visible || ( | ||
($visibility == ITEM_UNAPPROVED || $visibility == ITEM_REAPPROVE) | ||
&& $this->user->data['user_id'] === $data[$poster_key] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if I'm not mistaken, this is gonna show unapproved anonymous posts to anonymous users, right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As it is now yes. I added it to the TODO list to handle it. I'm really just trying to mock up what changes are needed first so I can have a better idea on what changes would the database tables need to make this a bit more optimized (as of now all users would have a separate query which doesn't seem optimal). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
); | ||
|
||
/** | ||
* Allow changing the result of calling is_visible | ||
|
@@ -216,7 +222,13 @@ public function get_visibility_sql($mode, $forum_id, $table_alias = '') | |
} | ||
else | ||
{ | ||
$where_sql .= $table_alias . $mode . '_visibility = ' . ITEM_APPROVED; | ||
$field_name = ($mode === 'topic') ? 'topic_poster' : 'poster_id'; | ||
$visibility_query = $table_alias . $mode . '_visibility = '; | ||
|
||
$where_sql .= '(' . $visibility_query . ITEM_APPROVED . ')'; | ||
$where_sql .= ' OR ('; | ||
$where_sql .= '(' . $visibility_query . ITEM_UNAPPROVED . ' OR ' . $visibility_query . ITEM_REAPPROVE . ')'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This need a switched off, its not good for large databases. There is no optimization possible. $visibility_query = $table_alias . $mode . '_visibility = ';
$where_sql .= $visibility_query . ITEM_APPROVED;
if ($this->config['show_items_unapproved'])
{
$field_name = ($mode === 'topic') ? 'topic_poster' : 'poster_id';
$where_sql .= ' OR (';
$where_sql .= $db->sql_in_set($visibility_query, array(ITEM_UNAPPROVED, ITEM_REAPPROVE));
$where_sql .= ' AND ' . $table_alias . $field_name . ' = ' . (int) $this->user->data['user_id'] . '
AND ' . $table_alias . $field_name . ' != ' . ANONYMOUS . ')';
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A config switch will be in my next PR, need to decide whther to default on (my preference) or off. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it help sql optimisation if the visibility of unapproved posts to posters had a time limit (only unapproved posts in the last X days)? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Even if it does. I believe it would be quite bad for users to have the post disappear. They could think that it had been deleted.... |
||
$where_sql .= ' AND ' . $table_alias . $field_name . ' = ' . ((int) $this->user->data['user_id']) . ')'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. May you please change this to the query builder to allow extensions to more easily change this query for their own needs? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This query is already using query builder (in the calling function), here we are just building a WHERE clause for query builder. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @v12mike query builder: #4006 Why not use the query builder all the way, including the boolean processing? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is an existing event 'core.phpbb_content_visibility_get_visibility_sql_before' in the middle of building the sql, which I think would get broken if the sql builder was used more extensively here. Can you see how to do it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point. I failed to see it. |
||
} | ||
|
||
return '(' . $where_sql . ')'; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1151,3 +1151,7 @@ input.disabled { | |
background-color: #d41142; | ||
color: #ffffff; | ||
} | ||
|
||
.information { | ||
background-color: #b8d3e0; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to optimize this use
$visibility == ITEM_APPROVED || $this->auth->acl_get('m_approve', $forum_id)