Conditions | 13 |
Paths | 45 |
Total Lines | 90 |
Lines | 44 |
Ratio | 48.89 % |
Changes | 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 |
||
48 | public function checksecurity() |
||
49 | { |
||
50 | global $secure, $smarty; |
||
51 | |||
52 | // CommunityUser has no database row, and we really don't want CommunityUser to have oauth credentials... |
||
53 | if (!User::getCurrent()->isCommunityUser()) { |
||
54 | if (User::getCurrent()->getStoredOnWikiName() == "##OAUTH##" |
||
55 | && User::getCurrent()->getOAuthAccessToken() == null |
||
56 | ) { |
||
57 | reattachOAuthAccount(User::getCurrent()); |
||
58 | } |
||
59 | |||
60 | if (User::getCurrent()->isOAuthLinked()) { |
||
61 | try { |
||
62 | // test retrieval of the identity |
||
63 | User::getCurrent()->getOAuthIdentity(); |
||
64 | } |
||
65 | catch (TransactionException $ex) { |
||
66 | User::getCurrent()->setOAuthAccessToken(null); |
||
67 | User::getCurrent()->setOAuthAccessSecret(null); |
||
68 | User::getCurrent()->save(); |
||
69 | |||
70 | reattachOAuthAccount(User::getCurrent()); |
||
71 | } |
||
72 | } |
||
73 | else { |
||
74 | global $enforceOAuth; |
||
75 | |||
76 | if ($enforceOAuth) { |
||
77 | reattachOAuthAccount(User::getCurrent()); |
||
78 | } |
||
79 | } |
||
80 | } |
||
81 | |||
82 | if (User::getCurrent()->isNew()) { |
||
83 | BootstrapSkin::displayAlertBox("I'm sorry, but, your account has not been approved by a site administrator yet. Please stand by.", "alert-error", "New account", true, false); |
||
84 | BootstrapSkin::displayInternalFooter(); |
||
85 | die(); |
||
86 | } |
||
87 | elseif (User::getCurrent()->isSuspended()) { |
||
88 | $database = gGetDb(); |
||
89 | $suspendstatement = $database->prepare(<<<SQL |
||
90 | SELECT comment |
||
91 | FROM log |
||
92 | WHERE action = 'Suspended' AND objectid = :userid and objecttype = 'User' |
||
93 | ORDER BY timestamp DESC |
||
94 | LIMIT 1; |
||
95 | SQL |
||
96 | ); |
||
97 | |||
98 | $suspendstatement->bindValue(":userid", User::getCurrent()->getId()); |
||
99 | $suspendstatement->execute(); |
||
100 | |||
101 | $suspendreason = $suspendstatement->fetchColumn(); |
||
102 | $suspendstatement->closeCursor(); |
||
103 | |||
104 | $smarty->assign("suspendreason", $suspendreason); |
||
105 | $smarty->display("login/suspended.tpl"); |
||
106 | BootstrapSkin::displayInternalFooter(); |
||
107 | die(); |
||
108 | } |
||
109 | elseif (User::getCurrent()->isDeclined()) { |
||
110 | $database = gGetDb(); |
||
111 | $suspendstatement = $database->prepare(<<<SQL |
||
112 | SELECT comment |
||
113 | FROM log |
||
114 | WHERE action = 'Declined' AND objectid = :userid and objecttype = 'User' |
||
115 | ORDER BY timestamp DESC |
||
116 | LIMIT 1; |
||
117 | SQL |
||
118 | ); |
||
119 | |||
120 | $suspendstatement->bindValue(":userid", User::getCurrent()->getId()); |
||
121 | $suspendstatement->execute(); |
||
122 | |||
123 | $suspendreason = $suspendstatement->fetchColumn(); |
||
124 | $suspendstatement->closeCursor(); |
||
125 | |||
126 | $smarty->assign("suspendreason", $suspendreason); |
||
127 | $smarty->display("login/declined.tpl"); |
||
128 | BootstrapSkin::displayInternalFooter(); |
||
129 | die(); |
||
130 | } |
||
131 | elseif ((!User::getCurrent()->isCommunityUser()) && (User::getCurrent()->isUser() || User::getCurrent()->isAdmin())) { |
||
132 | $secure = 1; |
||
133 | } |
||
134 | else { |
||
135 | //die("Not logged in!"); |
||
136 | } |
||
137 | } |
||
138 | } |
||
139 |