Skip to content

Commit

Permalink
Whitespace changes to comply better with phpBB's code guidelines
Browse files Browse the repository at this point in the history
  • Loading branch information
brunoais committed May 27, 2018
1 parent d872b7a commit 7320106
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 109 deletions.
4 changes: 2 additions & 2 deletions event/language_listener.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ static public function getSubscribedEvents()
public static function insert_at_in_assoc_array($original, $searching_key, $new_thing_key, $new_thing)
{
$rebuild = array();
foreach($original AS $key => $elem)
foreach ($original AS $key => $elem)
{
$rebuild[$key] = $elem;
if($key == $searching_key)
if ($key == $searching_key)
{
$rebuild[$new_thing_key] = $new_thing;
}
Expand Down
60 changes: 30 additions & 30 deletions event/main_listener.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public function __construct(\phpbb\auth\auth $auth, \phpbb\content_visibility $c

public function phpbb_ucp_pm_compose_compose_pm_basic_info_query_before($event)
{
if($event['action'] === 'quotepost')
if ($event['action'] === 'quotepost')
{
$sql = $event['sql'];

Expand All @@ -110,15 +110,15 @@ public function phpbb_ucp_pm_compose_quotepost_query_after($event)
'topic_poster' => $event['topic_poster'],
));

if($permission_result === accesses::NO_READ_OTHER)
if ($permission_result === accesses::NO_READ_OTHER)
{
trigger_error('NOT_AUTHORISED');
}
}

public function phpbb_modify_posting_auth($event)
{
if(in_array($event['mode'], array('reply', 'quote', 'edit', 'delete', 'bump'), true))
if (in_array($event['mode'], array('reply', 'quote', 'edit', 'delete', 'bump'), true))
{

$permission_result = $this->permission_evaluation->permission_evaluate(array(
Expand All @@ -127,7 +127,7 @@ public function phpbb_modify_posting_auth($event)
'post_id' => $event['post_id'],
));

if($permission_result === accesses::NO_READ_OTHER)
if ($permission_result === accesses::NO_READ_OTHER)
{
trigger_error('NOT_AUTHORISED');
}
Expand All @@ -145,7 +145,7 @@ public function phpbb_report_post_auth($event)
'topic_type' => $event['report_data']['topic_type'],
));

if($permission_result === accesses::NO_READ_OTHER)
if ($permission_result === accesses::NO_READ_OTHER)
{
trigger_error('POST_NOT_EXIST');
}
Expand All @@ -157,14 +157,14 @@ public function phpbb_get_logs_main_query_before($event)

$full_access_forum_IDs = array();

if($event['log_type'] == LOG_MOD)
if ($event['log_type'] == LOG_MOD)
{
if ($event['topic_id'])
{
$permission_result = $this->permission_evaluation->permission_evaluate(array(
'topic_id' => $event['topic_id'],
));
if($permission_result === accesses::FULL_READ)
if ($permission_result === accesses::FULL_READ)
{
return;
}
Expand All @@ -173,23 +173,23 @@ public function phpbb_get_logs_main_query_before($event)
{
$forum_ids = $event['forum_id'];
$full_access_forum_IDs = array();
foreach($forum_ids AS $forum_id)
foreach ($forum_ids AS $forum_id)
{
if($this->auth->acl_get('f_read_others_topics_brunoais', $forum_id))
if ($this->auth->acl_get('f_read_others_topics_brunoais', $forum_id))
{
$full_access_forum_IDs[] = $forum_id;
}
}

if(sizeof($full_access_forum_IDs) === sizeof($forum_ids))
if (sizeof($full_access_forum_IDs) === sizeof($forum_ids))
{
// Nothing to filter
return;
}
}
else if (!empty($event['forum_id']))
{
if($this->auth->acl_get('f_read_others_topics_brunoais', $event['forum_id']))
if ($this->auth->acl_get('f_read_others_topics_brunoais', $event['forum_id']))
{
return;
}
Expand All @@ -198,14 +198,14 @@ public function phpbb_get_logs_main_query_before($event)
{
$forum_ids = array_values(array_intersect(get_forum_list('f_read'), get_forum_list('m_')));
$full_access_forum_IDs = array();
foreach($forum_ids AS $forum_id)
foreach ($forum_ids AS $forum_id)
{
if($this->auth->acl_get('f_read_others_topics_brunoais', $forum_id))
if ($this->auth->acl_get('f_read_others_topics_brunoais', $forum_id))
{
$full_access_forum_IDs[] = $forum_id;
}
}
if(sizeof($full_access_forum_IDs) === sizeof($forum_ids))
if (sizeof($full_access_forum_IDs) === sizeof($forum_ids))
{
// Nothing to filter
return;
Expand All @@ -215,7 +215,7 @@ public function phpbb_get_logs_main_query_before($event)
$from_sql = $event['get_logs_sql_ary']['FROM'];
$where_sql = $event['get_logs_sql_ary']['WHERE'];

if(!isset($from_sql[$this->topics_table]))
if (!isset($from_sql[$this->topics_table]))
{
$from_sql[$this->topics_table] = 't';
$where_sql = 't.topic_id = l.topic_id
Expand All @@ -237,9 +237,9 @@ public function phpbb_get_logs_main_query_before($event)
public function phpbb_content_visibility_get_visibility_sql_before($event)
{

if(!$this->auth->acl_get('f_read_others_topics_brunoais', $event['forum_id']))
if (!$this->auth->acl_get('f_read_others_topics_brunoais', $event['forum_id']))
{
if($event['mode'] === 'topic')
if ($event['mode'] === 'topic')
{
$event['where_sql'] .= ' (' . $event['table_alias'] . ' topic_poster = ' . (int) $this->user->data['user_id'] . '
OR topic_type = ' . POST_GLOBAL . '
Expand All @@ -254,20 +254,20 @@ public function phpbb_content_visibility_get_forums_visibility_before($event)
{

// If the event mode is 'post', there's nothing I can do here.
if($event['mode'] === 'topic')
if ($event['mode'] === 'topic')
{
$forum_ids = $event['forum_ids'];
$full_access_forum_IDs = array();

foreach($forum_ids AS $forum_id)
foreach ($forum_ids AS $forum_id)
{
if($this->auth->acl_get('f_read_others_topics_brunoais', $forum_id))
if ($this->auth->acl_get('f_read_others_topics_brunoais', $forum_id))
{
$full_access_forum_IDs[] = $forum_id;
}
}

if(sizeof($full_access_forum_IDs) === sizeof($forum_ids))
if (sizeof($full_access_forum_IDs) === sizeof($forum_ids))
{
// Nothing to filter
return;
Expand All @@ -285,9 +285,9 @@ public function phpbb_display_forums_after($event)

$active_forum_ary = $event['active_forum_ary'];

if(empty($active_forum_ary['exclude_forum_id']))
if (empty($active_forum_ary['exclude_forum_id']))
{
if(empty($active_forum_ary['forum_id']))
if (empty($active_forum_ary['forum_id']))
{
$forum_ids = array();
}
Expand All @@ -302,9 +302,9 @@ public function phpbb_display_forums_after($event)
}

$full_access_forum_IDs = array();
foreach($forum_ids as $forum_id)
foreach ($forum_ids as $forum_id)
{
if($this->auth->acl_get('f_read_others_topics_brunoais', $forum_id))
if ($this->auth->acl_get('f_read_others_topics_brunoais', $forum_id))
{
$full_access_forum_IDs[] = $forum_id;
}
Expand All @@ -318,7 +318,7 @@ public function phpbb_display_forums_after($event)
public function phpbb_viewforum_get_topic_data($event)
{

if(!$event['sort_days'])
if (!$event['sort_days'])
{

$sql = 'SELECT COUNT(topic_id) AS num_topics
Expand All @@ -343,7 +343,7 @@ public function phpbb_viewforum_get_topic_data($event)
public function phpbb_viewforum_get_topic_ids_data($event)
{

if( $event['forum_data']['forum_type'] != FORUM_POST &&
if ( $event['forum_data']['forum_type'] != FORUM_POST &&
strpos($event['sql_where'], 't.forum_id IN') === 0 &&
!empty($this->info_storage['ActiveTopicIds']['restrictedAccess']))
{
Expand All @@ -367,7 +367,7 @@ public function phpbb_display_forums_modify_template_vars($event)
'post_id' => $event['row']['forum_last_post_id'],
));

if($post_access !== accesses::FULL_READ)
if ($post_access !== accesses::FULL_READ)
{
$this->user->add_lang_ext('brunoais/readOthersTopics', 'common');
$forum_row = $event['forum_row'];
Expand All @@ -380,7 +380,7 @@ public function phpbb_display_forums_modify_template_vars($event)
$event['forum_row'] = $forum_row;
}

if(!$this->auth->acl_get('f_read_others_topics_brunoais', $event['row']['forum_id']))
if (!$this->auth->acl_get('f_read_others_topics_brunoais', $event['row']['forum_id']))
{
$forum_row = $event['forum_row'];
$forum_row['TOPICS'] = '-';
Expand All @@ -400,7 +400,7 @@ public function phpbb_viewtopic_before_f_read_check($event)
'topic_type' => $event['topic_data']['topic_type'],
));

if($permission_result === accesses::NO_READ_OTHER)
if ($permission_result === accesses::NO_READ_OTHER)
{
$this->permission_evaluation->access_failed();
}
Expand Down
41 changes: 20 additions & 21 deletions event/mcp_listener.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,14 @@ public function __construct(\phpbb\auth\auth $auth, \phpbb\content_visibility $c

public function phpbb_mcp_global_f_read_auth_after($event)
{
if($event['forum_id'] && $event['topic_id'])
if ($event['forum_id'] && $event['topic_id'])
{
$permission_result = $this->permission_evaluation->permission_evaluate(array(
'forum_id' => $event['forum_id'],
'topic_id' => $event['topic_id'],
));

if($permission_result === accesses::NO_READ_OTHER)
if ($permission_result === accesses::NO_READ_OTHER)
{
trigger_error('NOT_AUTHORISED');
}
Expand All @@ -101,15 +101,15 @@ public function phpbb_mcp_reports_get_reports_query_before($event)

$forum_ids = $event['forum_list'];
$full_access_forum_IDs = array();
foreach($forum_ids AS $forum_id)
foreach ($forum_ids AS $forum_id)
{
if($this->auth->acl_get('f_read_others_topics_brunoais', $forum_id))
if ($this->auth->acl_get('f_read_others_topics_brunoais', $forum_id))
{
$full_access_forum_IDs[] = $forum_id;
}
}

if(sizeof($full_access_forum_IDs) === sizeof($forum_ids))
if (sizeof($full_access_forum_IDs) === sizeof($forum_ids))
{
// Nothing to filter
return;
Expand All @@ -135,14 +135,13 @@ public function phpbb_mcp_sorting_query_before($event)
{

case 'forum_view':

$event['sql'] .= ' AND (' . $this->db->sql_in_set('forum_id', $full_access_forum_IDs, false, true) . '
OR topic_poster = ' . (int) $this->user->data['user_id'] . ' ) ';

break;
}

if($event['where_sql'] === 'WHERE')
if ($event['where_sql'] === 'WHERE')
{
$event['where_sql'] = 'WHERE ';
}
Expand All @@ -154,15 +153,15 @@ public function phpbb_mcp_front_queue_unapproved_total_before($event)

$forum_ids = $event['forum_list'];
$full_access_forum_IDs = array();
foreach($forum_ids AS $forum_id)
foreach ($forum_ids AS $forum_id)
{
if($this->auth->acl_get('f_read_others_topics_brunoais', $forum_id))
if ($this->auth->acl_get('f_read_others_topics_brunoais', $forum_id))
{
$full_access_forum_IDs[] = $forum_id;
}
}

if(sizeof($full_access_forum_IDs) === sizeof($forum_ids))
if (sizeof($full_access_forum_IDs) === sizeof($forum_ids))
{
// Nothing to filter
return;
Expand All @@ -172,7 +171,7 @@ public function phpbb_mcp_front_queue_unapproved_total_before($event)
$from_sql = $event['sql_ary']['FROM'];
$where_sql = $event['sql_ary']['WHERE'];

if(!isset($from_sql[$this->topics_table]))
if (!isset($from_sql[$this->topics_table]))
{
$from_sql[$this->topics_table] = 't';
$where_sql = 't.topic_id = p.topic_id
Expand All @@ -193,19 +192,19 @@ public function phpbb_mcp_front_queue_unapproved_total_before($event)
public function phpbb_mcp_front_view_queue_postid_list_after($event)
{

if($event['total'] > 0)
if ($event['total'] > 0)
{
$forum_ids = $event['forum_list'];
$full_access_forum_IDs = array();
foreach($forum_ids AS $forum_id)
foreach ($forum_ids AS $forum_id)
{
if($this->auth->acl_get('f_read_others_topics_brunoais', $forum_id))
if ($this->auth->acl_get('f_read_others_topics_brunoais', $forum_id))
{
$full_access_forum_IDs[] = $forum_id;
}
}

if(sizeof($full_access_forum_IDs) === sizeof($forum_ids))
if (sizeof($full_access_forum_IDs) === sizeof($forum_ids))
{
// Nothing to filter
return;
Expand Down Expand Up @@ -244,15 +243,15 @@ public function phpbb_mcp_front_reports_count_query_before($event)
{
$forum_ids = $event['forum_list'];
$full_access_forum_IDs = array();
foreach($forum_ids AS $forum_id)
foreach ($forum_ids AS $forum_id)
{
if($this->auth->acl_get('f_read_others_topics_brunoais', $forum_id))
if ($this->auth->acl_get('f_read_others_topics_brunoais', $forum_id))
{
$full_access_forum_IDs[] = $forum_id;
}
}

if(sizeof($full_access_forum_IDs) === sizeof($forum_ids))
if (sizeof($full_access_forum_IDs) === sizeof($forum_ids))
{
// Nothing to filter
return;
Expand All @@ -279,15 +278,15 @@ public function phpbb_mcp_front_reports_listing_query_before($event)

$forum_ids = $event['forum_list'];
$full_access_forum_IDs = array();
foreach($forum_ids AS $forum_id)
foreach ($forum_ids AS $forum_id)
{
if($this->auth->acl_get('f_read_others_topics_brunoais', $forum_id))
if ($this->auth->acl_get('f_read_others_topics_brunoais', $forum_id))
{
$full_access_forum_IDs[] = $forum_id;
}
}

if(sizeof($full_access_forum_IDs) === sizeof($forum_ids))
if (sizeof($full_access_forum_IDs) === sizeof($forum_ids))
{
// Nothing to filter
return;
Expand Down
Loading

0 comments on commit 7320106

Please sign in to comment.