Completed
Push — master ( a9decc...a21b67 )
by Michael
02:51
created

mail_fnc.php ➔ extcal_SendMail()   B

Complexity

Conditions 5
Paths 16

Size

Total Lines 78
Code Lines 29

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
eloc 29
nc 16
nop 8
dl 0
loc 78
rs 8.4316
c 0
b 0
f 0

How to fix   Long Method    Many Parameters   

Long Method

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:

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 38 and the first side effect is on line 23.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
/*
3
 * You may not change or alter any portion of this comment or credits
4
 * of supporting developers from this source code or any supporting source code
5
 * which is considered copyrighted (c) material of the original comment or credit authors.
6
 *
7
 * This program is distributed in the hope that it will be useful,
8
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
 */
11
12
/**
13
 * @copyright    {@link https://xoops.org/ XOOPS Project}
14
 * @license      {@link http://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2 or later}
15
 * @package      extcal
16
 * @since
17
 * @author       XOOPS Development Team,
18
 *
19
 * L'utilisation de ce formulaire d'adminitration suppose
20
 * que la classe correspondante de la table a été générées avec classGenerator
21
 **/
22
23
require_once __DIR__ . '/../../../class/uploader.php';
24
require_once __DIR__ . '/../../../class/mail/phpmailer/class.phpmailer.php'; // First we require the PHPMailer libary in our script
25
require_once __DIR__ . '/../class/utility.php';
26
require_once __DIR__ . '/constantes.php';
27
require_once __DIR__ . '/../../../class/template.php';
28
29
/********************************************************************
30
 *
31
 *******************************************************************
32
 * @param $mode
33
 * @param $event_id
34
 * @param $member_uid
35
 * @param $subject
36
 * @param $tplMessage
37
 */
38
function sendMail2member($mode, $event_id, $member_uid, $subject, $tplMessage)
0 ignored issues
show
Unused Code introduced by
The parameter $mode is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
39
{
40
    //mode = 0 pas d'entete
41
    //mode = 1 format text
42
    //mode = 2: format html
43
44
    global $xoopsConfig, $xoopsDB;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
45
    // $t = print_r($xoopsConfig, true);
0 ignored issues
show
Unused Code Comprehensibility introduced by
54% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
46
    // echo "<pre>{$t}</pre>";
47
    /*
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
48
    $member_uid = 1;
49
    $event_id = 393;
50
    $message = "Bonne journée à tous";
51
    $newStatus = 1;
52
    $oldStatus = 0;
53
54
    */
55
56
    //l'utilisateur ne pas etre notifié par mail
57
    //if ($mode == 0) exit;
0 ignored issues
show
Unused Code Comprehensibility introduced by
59% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
58
    //-------------------------------------------------------
59
    $tblMember    = $xoopsDB->prefix('extcal_eventmember');
60
    $tblNotMember = $xoopsDB->prefix('extcal_eventnotmember');
61
    $tblUsers     = $xoopsDB->prefix('users');
62
    $tblEvent     = $xoopsDB->prefix('extcal_event');
0 ignored issues
show
Unused Code introduced by
$tblEvent is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
63
64
    //--------------------------------------------------------------
65
    //Recuperation des données event,user et member
66
    //Recuperation des données de l'evennement
67
    $eventHandler = xoops_getModuleHandler(_EXTCAL_CLS_EVENT, _EXTCAL_MODULE);
68
    $obj          = $eventHandler->getEvent($event_id);
69
    $event        = $eventHandler->objectToArray($obj);
70
    $eventHandler->formatEventDate($event, _MD_EXTCAL_FORMAT_DATE);
71
72
    $submiter_uid = $event['event_submitter'];
73
    // ext_echoArray($event,'event');
0 ignored issues
show
Unused Code Comprehensibility introduced by
75% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
74
    //--------------------------------------------------------------
75
    //Recuperation des données du user createur de l'evennement
76
    $sql = <<<__sql__
77
  SELECT if(tu.name='', tu.uname, tu.name) AS name,     tu.uname,   tu.email
78
  FROM {$tblUsers} tu
79
  WHERE tu.uid = {$submiter_uid};
80
__sql__;
81
82
    $rst      = $xoopsDB->query($sql);
83
    $submiter = $xoopsDB->fetchArray($rst);
84
    // echo "{$sql}<br>";
85
    // ext_echoArray($submiter,'submiter');
0 ignored issues
show
Unused Code Comprehensibility introduced by
75% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
86
    //--------------------------------------------------------------
87
    //Recuperation des données du membre inscrit
88
    $sql = <<<__sql__
89
  SELECT if(tu.name='', tu.uname, tu.name) AS name,     tu.uname,   tu.email
90
  FROM {$tblUsers} tu
91
  WHERE tu.uid = {$member_uid};
92
__sql__;
93
94
    $rst    = $xoopsDB->query($sql);
95
    $acteur = $xoopsDB->fetchArray($rst);
96
    //echo "{$sql}<br>";
97
    // ext_echoArray($acteur,'acteur');
0 ignored issues
show
Unused Code Comprehensibility introduced by
75% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
98
    //--------------------------------------------------------------
99
    //Recuperation des données des membres présents
100
    $sql = <<<__sql__
101
SELECT tu.uid, if(tu.name='', tu.uname, tu.name) AS name,   tu.uname,   tu.email,
102
        tm.status
103
FROM {$tblMember} tm,
104
     {$tblUsers}  tu
105
WHERE tm.uid = tu.uid
106
  AND tm.event_id = {$event_id}
107
__sql__;
108
109
    $rst     = $xoopsDB->query($sql);
110
    $members = array();
111 View Code Duplication
    while ($row = $xoopsDB->fetchArray($rst)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
112
        $row['status']        = _MD_EXTCAL_PRESENT;
113
        $members[$row['uid']] = $row;
114
    }
115
116
    //--------------------------------------------------------------
117
    //Recuperation des données des membres absents
118
    $sql = <<<__sql__
119
SELECT tu.uid, if(tu.name='', tu.uname, tu.name) AS name,   tu.uname,   tu.email,
120
        tm.status
121
FROM {$tblNotMember} tm,
122
     {$tblUsers}  tu
123
WHERE tm.uid = tu.uid
124
  AND tm.event_id = {$event_id}
125
__sql__;
126
127
    $rst = $xoopsDB->query($sql);
128 View Code Duplication
    while ($row = $xoopsDB->fetchArray($rst)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
129
        $row['status']        = _MD_EXTCAL_ABSENT;
130
        $members[$row['uid']] = $row;
131
    }
132
133
    // ext_echoArray($members,'members');
0 ignored issues
show
Unused Code Comprehensibility introduced by
75% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
134
    // exit;
135
136
    //--------------------------------------------------------------
137
    //Message et sujet du mail
138
    $action  = ''; //a voir   JJD
139
    $message = sprintf($tplMessage, $acteur['name']);
140
    //$subject .= ' (' . rand(1, 100) . ')';
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
141
    $subject .= ' - ' . $acteur['name'];
142
    //--------------------------------------------------------------
143
    //Chargement du template dans le dossier de langue
144
    //$f = _EXTCAL_PATH_LG . $xoopsConfig['language'] . '\mail_inscription.html';
0 ignored issues
show
Unused Code Comprehensibility introduced by
42% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
145
    //$tpl = new tpl($f);
0 ignored issues
show
Unused Code Comprehensibility introduced by
55% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
146
    $tpl = new XoopsTpl();
147
148
    $tpl->assign('dateAction', date(_MD_EXTCAL_FORMAT_DATE));
149
    $tpl->assign('submiter', $submiter);
150
    $tpl->assign('event', $event);
151
    $tpl->assign('acteur', $acteur);
152
    $tpl->assign('members', $members);
153
    $tpl->assign('action', $action);
154
    $tpl->assign('subject', $subject);
155
    $tpl->assign('message', $message);
156
    $tpl->assign('xoopsConfig', $xoopsConfig);
157
    $tpl->assign('br', '<br>');
158
159
    //--------------------------------------------------------------
160
    $destinataires                     = array();
161
    $destinataires[$submiter['email']] = $submiter['email'];
162
    $destinataires[$acteur['email']]   = $acteur['email'];
163
//    while (list($k, $row) = each($members)) {
0 ignored issues
show
Unused Code Comprehensibility introduced by
62% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
164
    foreach ($members as $k => $row) {
165
        $destinataires[$row['email']] = $row['email'];
166
    }
167
168
    // ext_echoArray($destinataires);
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
169
    // exit;
170
171
    $mail_fromName  = $xoopsConfig['sitename'];
172
    $mail_fromemail = $xoopsConfig['adminmail'];
173
    $mail_subject   = $subject;
174
175
    $bEcho = false;
0 ignored issues
show
Unused Code introduced by
$bEcho is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
176
    $mode  = _EXTCAL_HEADER_HTML;
177
    $sep   = '|';
0 ignored issues
show
Unused Code introduced by
$sep is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
178
179
    $template = 'extcal_mail_member_text.tpl';
180
    if ($mode == _EXTCAL_HEADER_HTML) {
181
        $template = 'extcal_mail_member_html.tpl';
182
    }
183
    $mail_body = $tpl->fetch('db:' . $template);
184
185
    extcal_SendMail($destinataires, $mail_fromName, $mail_fromemail, $mail_subject, $mail_body, $bEcho = false, $mode = 0, $sep = '|');
186
187
    //Prépartion de l'envoi
188
189
    //--------------------------------------------------------------
190
}
191
192
/*****************************************************************
193
 ****************************************************************
194
 * @param        $destinataires
195
 * @param        $mail_fromname
196
 * @param        $mail_fromemail
197
 * @param        $mail_subject
198
 * @param        $mail_body
199
 * @param bool   $bEcho
200
 * @param int    $mode
201
 * @param string $sep
202
 */
203
function extcal_SendMail(
204
    $destinataires,
205
    $mail_fromname,
206
    $mail_fromemail,
207
    $mail_subject,
208
    $mail_body,
209
    $bEcho = false,
210
    $mode = 0,
0 ignored issues
show
Unused Code introduced by
The parameter $mode is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
211
    $sep = '|'
212
) {
213
    global $ModName, $signature, $mail_admin, $xoopsConfig, $xoopsDB, $xoopsModule;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
214
215
    //$bEcho=false;
216
    //echo "<hr>function hermesMail<hr>";
217
218
    // $destinataires = array('[email protected]','[email protected]','[email protected]');
0 ignored issues
show
Unused Code Comprehensibility introduced by
72% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
219
    //$mail_fromname = "test jjd hermes";
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
220
    if ($mail_fromname == '') {
221
        $mail_fromname = $mail_fromemail;
222
    }
223
224
    //$mail_fromemail = "[email protected]";
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
225
    //$mail_subject = "test hemes";
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
226
    //$mail_body = getContentTestMail();
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
227
    //-----------------------------
228
    if (!is_array($destinataires)) {
229
        $destinataires = explode($sep, $destinataires);
230
    }
231
    $header = extcal_getHeader(1, $mail_fromemail);
0 ignored issues
show
Unused Code introduced by
$header is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
232
    //-----------------------------
233
    $myts = MyTextSanitizer::getInstance();
234
    //$xoopsMailer = getMailer();
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
235
    $xoopsMailer = xoops_getMailer();
236
237
    //$xoopsMailer->setToUsers($destinataires[$i]);
0 ignored issues
show
Unused Code Comprehensibility introduced by
90% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
238
239
//    while (list($k, $v) = each($destinataires)) {
0 ignored issues
show
Unused Code Comprehensibility introduced by
62% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
240
    foreach ($destinataires as $k => $v) {
241
        //for ( $i = 0, $iMax = count($destinataires); $i < $iMax; ++$i) {
0 ignored issues
show
Unused Code Comprehensibility introduced by
52% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
242
        //$xoopsMailer->setToUsers($destinataires[$i]);
0 ignored issues
show
Unused Code Comprehensibility introduced by
90% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
243
        $xoopsMailer->setToEmails($v);
244
        //echo "setToUsers : {$destinataires[$i]}<br>";
245
    }
246
247
    $xoopsMailer->multimailer->isHTML(true);
248
    $xoopsMailer->setFromName($myts->oopsStripSlashesGPC($mail_fromname));
249
250
    $xoopsMailer->setFromEmail($myts->oopsStripSlashesGPC($mail_fromemail));
251
252
    $xoopsMailer->setSubject($myts->oopsStripSlashesGPC($mail_subject));
253
    $xoopsMailer->setBody($myts->oopsStripSlashesGPC($mail_body));
254
    //$xoopsMailer->encodeBody($mail_body);
0 ignored issues
show
Unused Code Comprehensibility introduced by
86% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
255
256
    $xoopsMailer->useMail();
257
258
    //function $xoopsMailer->sendMail($email, $subject, $body, $headers)
0 ignored issues
show
Unused Code Comprehensibility introduced by
65% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
259
    $xoopsMailer->send($bEcho);
260
261
    if ($bEcho) {
262
        ExtcalUtility::ext_echo($xoopsMailer->getSuccess());
263
        ExtcalUtility::ext_echo($xoopsMailer->getErrors());
264
    }
265
    /*
0 ignored issues
show
Unused Code Comprehensibility introduced by
40% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
266
267
     echo "<hr>mail_fromname : {$mail_fromname}<br>"
268
          ."mail_fromemail : {$mail_fromemail}<br>"
269
          ."mail_subject : {$mail_subject}<br>"
270
          ."mail_body : {$mail_body}<br><hr>";
271
    */
272
    //---------------------------
273
    /*
0 ignored issues
show
Unused Code Comprehensibility introduced by
55% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
274
275
      $adresse = "[email protected]";
276
      $bolOk = mail($adresse, "test envoi mail", "test envoi envoi mail via php");
277
      $r= (($bolOk) ? " => Succés" : "Echec");
278
      echo "<hr>==> <b>{$r}</b> de l'envoi du mail a: ==> {$adresse}<br>" ;
279
    */
280
}
281
282
/****************************************************************************
283
 *
284
 ***************************************************************************
285
 * @param $mode
286
 * @param $emailSender
287
 *
288
 * @return string
289
 */
290
function extcal_getHeader($mode, $emailSender)
0 ignored issues
show
Coding Style introduced by
extcal_getHeader uses the super-global variable $_SERVER which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
291
{
292
    //mode = 0 pas d'entete
293
    //mode = 1 format text
294
    //mode = 2: format html
295
296
    global $xoopsConfig;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
297
298
    // $t = print_r($xoopsConfig, true);
0 ignored issues
show
Unused Code Comprehensibility introduced by
54% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
299
    // echo "<pre>{$t}</pre>";
300
301
    //------------------------------------------------------
302
    $d = date('d-m-Y h:m:h', time());
0 ignored issues
show
Unused Code introduced by
$d is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
303
    //-----------------------------------------------------------
304
    //defini l'expediteur du mail
305
    if ($emailSender == '') {
306
        if ($xoopsConfig['adminmail'] == '') {
307
            $emailSender = "webmaster@{$_SERVER['SERVER_NAME']}";
308
        } else {
309
            $emailSender = $xoopsConfig['adminmail'];
310
        }
311
    }
312
    //-----------------------------------------------------------
313
    $header   = array();
314
    $header[] = "From: {$emailSender}";
315
    $header[] = "Reply-To: {$emailSender}";
316
    $header[] = 'X-Mailer: PHP/' . PHP_VERSION;
317
318
    if ($mode == _EXTCAL_HEADER_HTML) {
319
        $header[] = 'MIME-Version: 1.0';
320
        $header[] = 'Content-type: text/html; charset=iso-8859-1';
321
    } else {
0 ignored issues
show
Unused Code introduced by
This else statement is empty and can be removed.

This check looks for the else branches of if statements that have no statements or where all statements have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.

These else branches can be removed.

if (rand(1, 6) > 3) {
print "Check failed";
} else {
    //print "Check succeeded";
}

could be turned into

if (rand(1, 6) > 3) {
    print "Check failed";
}

This is much more concise to read.

Loading history...
322
        //bin rien a prori
323
    }
324
    $header[] = '';
325
326
    //$sHeader = implode("\r\n", $header);
0 ignored issues
show
Unused Code Comprehensibility introduced by
59% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
327
    $sHeader = implode("\r\n", $header);
328
329
    return $sHeader;
330
}
331