| Conditions | 11 |
| Paths | 192 |
| Total Lines | 61 |
| Code Lines | 31 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 44 | public function convert_permissions() |
||
| 45 | { |
||
| 46 | $attr_permissions_array = $groups_array = array(); |
||
| 47 | |||
| 48 | $migrator_tool_permission = $this->container->get('migrator.tool.permission'); |
||
| 49 | |||
| 50 | $sql = 'SELECT * FROM ' . $this->table_prefix . 'topics_attr'; |
||
| 51 | $result = $this->db->sql_query($sql); |
||
| 52 | |||
| 53 | while ($row = $this->db->sql_fetchrow($result)) |
||
| 54 | { |
||
| 55 | $auth_option = 'f_qte_attr_'.$row['attr_id']; |
||
| 56 | $migrator_tool_permission->add($auth_option, false); |
||
| 57 | |||
| 58 | $attr_permissions_array[$auth_option] = json_decode($row['attr_auths'], true); |
||
| 59 | } |
||
| 60 | |||
| 61 | if (!class_exists('auth_admin')) |
||
| 62 | { |
||
| 63 | include($this->phpbb_root_path . 'includes/acp/auth.' . $this->php_ext); |
||
| 64 | } |
||
| 65 | $auth_admin = new \auth_admin(); |
||
| 66 | |||
| 67 | foreach ($attr_permissions_array as $auth_option => $attr_permissions) |
||
| 68 | { |
||
| 69 | foreach ($attr_permissions as $attr_permission) |
||
| 70 | { |
||
| 71 | if (sizeof($attr_permission['forums_ids']) && sizeof($attr_permission['groups_ids'])) |
||
| 72 | { |
||
| 73 | $auth_option_arry = array(); |
||
| 74 | $auth_option_arry[$auth_option] = ACL_YES; |
||
| 75 | $auth_admin->acl_set('group', $attr_permission['forums_ids'], $attr_permission['groups_ids'], $auth_option_arry); |
||
| 76 | } |
||
| 77 | } |
||
| 78 | } |
||
| 79 | |||
| 80 | $sql = 'SELECT group_id FROM ' . GROUPS_TABLE . |
||
| 81 | (!$this->config['coppa_enable'] ? " WHERE group_name <> 'REGISTERED_COPPA'" : ''); |
||
| 82 | $result = $this->db->sql_query($sql); |
||
| 83 | |||
| 84 | while ($row = $this->db->sql_fetchrow($result)) |
||
| 85 | { |
||
| 86 | $groups_array[] = $row['group_id']; |
||
| 87 | } |
||
| 88 | |||
| 89 | $sql = 'SELECT forum_id, hide_attr FROM ' . FORUMS_TABLE . ' |
||
| 90 | WHERE hide_attr <> ""'; |
||
| 91 | $result = $this->db->sql_query($sql); |
||
| 92 | |||
| 93 | while ($row = $this->db->sql_fetchrow($result)) |
||
| 94 | { |
||
| 95 | $result_diff = array_diff($groups_array, unserialize($row['hide_attr'])); |
||
| 96 | |||
| 97 | if (sizeof($result_diff)) |
||
| 98 | { |
||
| 99 | $auth_option_arry = array(); |
||
| 100 | $auth_option_arry['m_qte_attr_del'] = ACL_YES; |
||
| 101 | $auth_admin->acl_set('group', $row['forum_id'], $result_diff, $auth_option_arry); |
||
| 102 | } |
||
| 103 | } |
||
| 104 | } |
||
| 105 | |||
| 121 |