| Conditions | 18 |
| Paths | 2080 |
| Total Lines | 86 |
| Code Lines | 54 |
| Lines | 0 |
| Ratio | 0 % |
| 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 |
||
| 141 | function email_notification_forum ($t, $email) { |
||
| 142 | static $contexte = array(); |
||
| 143 | |||
| 144 | if(!isset($contexte[$t['id_forum']])){ |
||
| 145 | $url = ''; |
||
| 146 | $id_forum = $t['id_forum']; |
||
| 147 | |||
| 148 | if ($t['statut'] == 'prive') # forum prive |
||
| 149 | { |
||
| 150 | if ($t['id_article']) |
||
| 151 | $url = generer_url_ecrire('articles', 'id_article='.$t['id_article']).'#id'.$id_forum; |
||
| 152 | else if ($t['id_breve']) |
||
| 153 | $url = generer_url_ecrire('breves_voir', 'id_breve='.$t['id_breve']).'#id'.$id_forum; |
||
| 154 | else if ($t['id_syndic']) |
||
| 155 | $url = generer_url_ecrire('sites', 'id_syndic='.$t['id_syndic']).'#id'.$id_forum; |
||
| 156 | } |
||
| 157 | else if ($t['statut'] == 'privrac') # forum general |
||
| 158 | { |
||
| 159 | $url = generer_url_ecrire('forum').'#id'.$id_forum; |
||
| 160 | } |
||
| 161 | else if ($t['statut'] == 'privadm') # forum des admins |
||
| 162 | { |
||
| 163 | $url = generer_url_ecrire('forum_admin').'#id'.$id_forum; |
||
| 164 | } |
||
| 165 | else if ($t['statut'] == 'publie') # forum publie |
||
| 166 | { |
||
| 167 | $url = generer_url_entite($id_forum, 'forum'); |
||
| 168 | } |
||
| 169 | else # forum modere, spam, poubelle direct .... |
||
| 170 | { |
||
| 171 | $url = generer_url_ecrire('controle_forum', "debut_id_forum=".$id_forum); |
||
| 172 | } |
||
| 173 | |||
| 174 | if (!$url) { |
||
| 175 | spip_log("forum $id_forum sans referent",'notifications'); |
||
| 176 | $url = './'; |
||
| 177 | } |
||
| 178 | if ($t['id_article']) { |
||
| 179 | $titre = sql_getfetsel("titre", "spip_articles", "id_article=".sql_quote($t['id_article'])); |
||
| 180 | } |
||
| 181 | if ($t['id_message']) { |
||
| 182 | $titre = sql_getfetsel("titre", "spip_messages", "id_message=".sql_quote($t['id_message'])); |
||
| 183 | } |
||
| 184 | |||
| 185 | $t['titre_source'] = $titre; |
||
| 186 | $t['url'] = $url; |
||
| 187 | |||
| 188 | // detecter les url des liens du forum |
||
| 189 | // pour la moderation (permet de reperer les SPAMS avec des liens caches) |
||
| 190 | $links = array(); |
||
| 191 | foreach ($t as $champ) |
||
| 192 | $links = $links + extraire_balises($champ,'a'); |
||
| 193 | $links = extraire_attribut($links,'href'); |
||
| 194 | $links = implode("\n",$links); |
||
| 195 | $t['liens'] = $links; |
||
| 196 | |||
| 197 | $contexte[$t['id_forum']] = $t; |
||
| 198 | } |
||
| 199 | |||
| 200 | $t = $contexte[$t['id_forum']]; |
||
| 201 | // Rechercher eventuellement la langue du destinataire |
||
| 202 | if (NULL !== ($l = sql_getfetsel('lang', 'spip_auteurs', "email=" . sql_quote($email)))) |
||
| 203 | $l = lang_select($l); |
||
| 204 | |||
| 205 | $parauteur = (strlen($t['auteur']) <= 2) ? '' : |
||
| 206 | (" " ._T('forum_par_auteur', array( |
||
| 207 | 'auteur' => $t['auteur']) |
||
| 208 | ) . |
||
| 209 | ($t['email_auteur'] ? ' <' . $t['email_auteur'] . '>' : '')); |
||
| 210 | |||
| 211 | $titre = textebrut(typo($t['titre_source'])); |
||
| 212 | $forum_poste_par = ($t['id_article'] |
||
| 213 | ? _T('forum_poste_par', array( |
||
| 214 | 'parauteur' => $parauteur, 'titre' => $titre)) |
||
| 215 | : $parauteur . ' (' . $titre . ')'); |
||
| 216 | |||
| 217 | $t['par_auteur'] = $forum_poste_par; |
||
| 218 | |||
| 219 | $envoyer_mail = charger_fonction('envoyer_mail','inc'); // pour nettoyer_titre_email |
||
| 220 | $corps = recuperer_fond("notifications/forum_poste",$t); |
||
| 221 | |||
| 222 | if ($l) |
||
| 223 | lang_select(); |
||
| 224 | |||
| 225 | return $corps; |
||
| 226 | } |
||
| 227 | |||
| 231 |
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.