| Conditions | 13 | 
| Paths | 384 | 
| Total Lines | 73 | 
| Code Lines | 35 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 2 | ||
| 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 | $attr_permissions_array[$auth_option] = json_decode($row['attr_auths'], true); | ||
| 58 | } | ||
| 59 | |||
| 60 | 		if (!class_exists('auth_admin')) | ||
| 61 | 		{ | ||
| 62 | include($this->phpbb_root_path . 'includes/acp/auth.' . $this->php_ext); | ||
| 63 | } | ||
| 64 | $auth_admin = new \auth_admin(); | ||
| 65 | |||
| 66 | $hold_ary = array(); | ||
| 67 | |||
| 68 | foreach ($attr_permissions_array as $auth_option => $attr_permissions) | ||
| 69 | 		{ | ||
| 70 | foreach ($attr_permissions as $attr_permission) | ||
| 71 | 			{ | ||
| 72 | foreach ($attr_permission['forums_ids'] as $forum_id) | ||
| 73 | 				{ | ||
| 74 | foreach ($attr_permission['groups_ids'] as $group_id) | ||
| 75 | 					{ | ||
| 76 | if (!isset($hold_ary[$group_id][$forum_id])) | ||
| 77 | 						{ | ||
| 78 | 							$hold_ary = $auth_admin->get_mask('set', false, $group_id, $forum_id, 'f_', 'local', ACL_NO); | ||
| 79 | } | ||
| 80 | |||
| 81 | $hold_ary[$group_id][$forum_id][$auth_option] = ACL_YES; | ||
| 82 | |||
| 83 | 						$auth_admin->acl_set('group', $forum_id, $group_id, $hold_ary[$group_id][$forum_id]); | ||
| 84 | } | ||
| 85 | } | ||
| 86 | } | ||
| 87 | } | ||
| 88 | |||
| 89 | $sql = 'SELECT group_id FROM ' . GROUPS_TABLE . | ||
| 90 | (!$this->config['coppa_enable'] ? " WHERE group_name <> 'REGISTERED_COPPA'" : ''); | ||
| 91 | $result = $this->db->sql_query($sql); | ||
| 92 | |||
| 93 | while ($row = $this->db->sql_fetchrow($result)) | ||
| 94 | 		{ | ||
| 95 | $groups_array[] = $row['group_id']; | ||
| 96 | } | ||
| 97 | |||
| 98 | $sql = 'SELECT forum_id, hide_attr FROM ' . FORUMS_TABLE . ' | ||
| 99 | WHERE hide_attr <> ""'; | ||
| 100 | $result = $this->db->sql_query($sql); | ||
| 101 | |||
| 102 | while ($row = $this->db->sql_fetchrow($result)) | ||
| 103 | 		{ | ||
| 104 | $result_diff = array_diff($groups_array, unserialize($row['hide_attr'])); | ||
| 105 | |||
| 106 | if (sizeof($result_diff)) | ||
| 107 | 			{ | ||
| 108 | foreach ($result_diff as $group_id) | ||
| 109 | 				{ | ||
| 110 | 					$hold_ary = $auth_admin->get_mask('set', false, $group_id, $row['forum_id'], 'm_', 'local', ACL_NO); | ||
| 111 | $hold_ary[$group_id][$row['forum_id']]['m_qte_attr_del'] = ACL_YES; | ||
| 112 | 					$auth_admin->acl_set('group', $row['forum_id'], $group_id, $hold_ary[$group_id][$row['forum_id']]); | ||
| 113 | } | ||
| 114 | } | ||
| 115 | } | ||
| 116 | } | ||
| 117 | |||
| 133 |