mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-17 23:11:29 +01:00
clean code (#35317)
* clean code * clean code * clean code * clean code * clean code * clean code * clean code * clean code * clean code * clean code
This commit is contained in:
@@ -10836,66 +10836,6 @@ parameters:
|
|||||||
count: 2
|
count: 2
|
||||||
path: ../../../htdocs/eventorganization/conferenceorboothattendee_list.php
|
path: ../../../htdocs/eventorganization/conferenceorboothattendee_list.php
|
||||||
|
|
||||||
-
|
|
||||||
message: '#^If condition is always false\.$#'
|
|
||||||
identifier: if.alwaysFalse
|
|
||||||
count: 1
|
|
||||||
path: ../../../htdocs/eventorganization/core/actions_massactions_mail.inc.php
|
|
||||||
|
|
||||||
-
|
|
||||||
message: '#^Negated boolean expression is always true\.$#'
|
|
||||||
identifier: booleanNot.alwaysTrue
|
|
||||||
count: 1
|
|
||||||
path: ../../../htdocs/eventorganization/core/actions_massactions_mail.inc.php
|
|
||||||
|
|
||||||
-
|
|
||||||
message: '#^Ternary operator condition is always false\.$#'
|
|
||||||
identifier: ternary.alwaysFalse
|
|
||||||
count: 1
|
|
||||||
path: ../../../htdocs/eventorganization/core/actions_massactions_mail.inc.php
|
|
||||||
|
|
||||||
-
|
|
||||||
message: '#^Variable \$action might not be defined\.$#'
|
|
||||||
identifier: variable.undefined
|
|
||||||
count: 1
|
|
||||||
path: ../../../htdocs/eventorganization/core/actions_massactions_mail.inc.php
|
|
||||||
|
|
||||||
-
|
|
||||||
message: '#^Variable \$deliveryreceipt might not be defined\.$#'
|
|
||||||
identifier: variable.undefined
|
|
||||||
count: 1
|
|
||||||
path: ../../../htdocs/eventorganization/core/actions_massactions_mail.inc.php
|
|
||||||
|
|
||||||
-
|
|
||||||
message: '#^Variable \$from might not be defined\.$#'
|
|
||||||
identifier: variable.undefined
|
|
||||||
count: 6
|
|
||||||
path: ../../../htdocs/eventorganization/core/actions_massactions_mail.inc.php
|
|
||||||
|
|
||||||
-
|
|
||||||
message: '#^Variable \$hookmanager might not be defined\.$#'
|
|
||||||
identifier: variable.undefined
|
|
||||||
count: 3
|
|
||||||
path: ../../../htdocs/eventorganization/core/actions_massactions_mail.inc.php
|
|
||||||
|
|
||||||
-
|
|
||||||
message: '#^Variable \$object might not be defined\.$#'
|
|
||||||
identifier: variable.undefined
|
|
||||||
count: 1
|
|
||||||
path: ../../../htdocs/eventorganization/core/actions_massactions_mail.inc.php
|
|
||||||
|
|
||||||
-
|
|
||||||
message: '#^Variable \$triggername in empty\(\) always exists and is not falsy\.$#'
|
|
||||||
identifier: empty.variable
|
|
||||||
count: 1
|
|
||||||
path: ../../../htdocs/eventorganization/core/actions_massactions_mail.inc.php
|
|
||||||
|
|
||||||
-
|
|
||||||
message: '#^Variable \$user might not be defined\.$#'
|
|
||||||
identifier: variable.undefined
|
|
||||||
count: 4
|
|
||||||
path: ../../../htdocs/eventorganization/core/actions_massactions_mail.inc.php
|
|
||||||
|
|
||||||
-
|
-
|
||||||
message: '#^If condition is always true\.$#'
|
message: '#^If condition is always true\.$#'
|
||||||
identifier: if.alwaysTrue
|
identifier: if.alwaysTrue
|
||||||
|
|||||||
@@ -946,26 +946,26 @@ class CMailFile
|
|||||||
}
|
}
|
||||||
|
|
||||||
$keyforsmtpserver = 'MAIN_MAIL_SMTP_SERVER';
|
$keyforsmtpserver = 'MAIN_MAIL_SMTP_SERVER';
|
||||||
$keyforsmtpport = 'MAIN_MAIL_SMTP_PORT';
|
$keyforsmtpport = 'MAIN_MAIL_SMTP_PORT';
|
||||||
$keyforsmtpid = 'MAIN_MAIL_SMTPS_ID';
|
$keyforsmtpid = 'MAIN_MAIL_SMTPS_ID';
|
||||||
$keyforsmtppw = 'MAIN_MAIL_SMTPS_PW';
|
$keyforsmtppw = 'MAIN_MAIL_SMTPS_PW';
|
||||||
$keyforsmtpauthtype = 'MAIN_MAIL_SMTPS_AUTH_TYPE';
|
$keyforsmtpauthtype = 'MAIN_MAIL_SMTPS_AUTH_TYPE';
|
||||||
$keyforsmtpoauthservice = 'MAIN_MAIL_SMTPS_OAUTH_SERVICE';
|
$keyforsmtpoauthservice = 'MAIN_MAIL_SMTPS_OAUTH_SERVICE';
|
||||||
$keyfortls = 'MAIN_MAIL_EMAIL_TLS';
|
$keyfortls = 'MAIN_MAIL_EMAIL_TLS';
|
||||||
$keyforstarttls = 'MAIN_MAIL_EMAIL_STARTTLS';
|
$keyforstarttls = 'MAIN_MAIL_EMAIL_STARTTLS';
|
||||||
$keyforsslseflsigned = 'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED';
|
$keyforsslseflsigned = 'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED';
|
||||||
if (!empty($this->sendcontext)) {
|
if (!empty($this->sendcontext)) {
|
||||||
$smtpContextKey = strtoupper($this->sendcontext);
|
$smtpContextKey = strtoupper($this->sendcontext);
|
||||||
$smtpContextSendMode = getDolGlobalString('MAIN_MAIL_SENDMODE_'.$smtpContextKey);
|
$smtpContextSendMode = getDolGlobalString('MAIN_MAIL_SENDMODE_'.$smtpContextKey);
|
||||||
if (!empty($smtpContextSendMode) && $smtpContextSendMode != 'default') {
|
if (!empty($smtpContextSendMode) && $smtpContextSendMode != 'default') {
|
||||||
$keyforsmtpserver = 'MAIN_MAIL_SMTP_SERVER_'.$smtpContextKey;
|
$keyforsmtpserver = 'MAIN_MAIL_SMTP_SERVER_'.$smtpContextKey;
|
||||||
$keyforsmtpport = 'MAIN_MAIL_SMTP_PORT_'.$smtpContextKey;
|
$keyforsmtpport = 'MAIN_MAIL_SMTP_PORT_'.$smtpContextKey;
|
||||||
$keyforsmtpid = 'MAIN_MAIL_SMTPS_ID_'.$smtpContextKey;
|
$keyforsmtpid = 'MAIN_MAIL_SMTPS_ID_'.$smtpContextKey;
|
||||||
$keyforsmtppw = 'MAIN_MAIL_SMTPS_PW_'.$smtpContextKey;
|
$keyforsmtppw = 'MAIN_MAIL_SMTPS_PW_'.$smtpContextKey;
|
||||||
$keyforsmtpauthtype = 'MAIN_MAIL_SMTPS_AUTH_TYPE_'.$smtpContextKey;
|
$keyforsmtpauthtype = 'MAIN_MAIL_SMTPS_AUTH_TYPE_'.$smtpContextKey;
|
||||||
$keyforsmtpoauthservice = 'MAIN_MAIL_SMTPS_OAUTH_SERVICE_'.$smtpContextKey;
|
$keyforsmtpoauthservice = 'MAIN_MAIL_SMTPS_OAUTH_SERVICE_'.$smtpContextKey;
|
||||||
$keyfortls = 'MAIN_MAIL_EMAIL_TLS_'.$smtpContextKey;
|
$keyfortls = 'MAIN_MAIL_EMAIL_TLS_'.$smtpContextKey;
|
||||||
$keyforstarttls = 'MAIN_MAIL_EMAIL_STARTTLS_'.$smtpContextKey;
|
$keyforstarttls = 'MAIN_MAIL_EMAIL_STARTTLS_'.$smtpContextKey;
|
||||||
$keyforsslseflsigned = 'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_'.$smtpContextKey;
|
$keyforsslseflsigned = 'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_'.$smtpContextKey;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,8 +37,11 @@
|
|||||||
// $diroutputmassaction may be defined
|
// $diroutputmassaction may be defined
|
||||||
/**
|
/**
|
||||||
* @var Conf $conf
|
* @var Conf $conf
|
||||||
|
* @var CommonObject $object
|
||||||
* @var DoliDB $db
|
* @var DoliDB $db
|
||||||
|
* @var HookManager $hookmanager
|
||||||
* @var Translate $langs
|
* @var Translate $langs
|
||||||
|
* @var User $user
|
||||||
*
|
*
|
||||||
* @var string $massaction
|
* @var string $massaction
|
||||||
* @var string $objectclass
|
* @var string $objectclass
|
||||||
@@ -66,13 +69,13 @@ if (empty($objectclass) || empty($uploaddir)) {
|
|||||||
$error = 0;
|
$error = 0;
|
||||||
|
|
||||||
// Mass actions. Controls on number of lines checked.
|
// Mass actions. Controls on number of lines checked.
|
||||||
$maxformassaction = (!getDolGlobalString('MAIN_LIMIT_FOR_MASS_ACTIONS') ? 1000 : $conf->global->MAIN_LIMIT_FOR_MASS_ACTIONS);
|
$maxformassaction = getDolGlobalInt('MAIN_LIMIT_FOR_MASS_ACTIONS', 1000);
|
||||||
if (!empty($massaction) && is_array($toselect) && count($toselect) < 1) {
|
if (!empty($massaction) && is_array($toselect) && count($toselect) < 1) {
|
||||||
$error++;
|
$error++;
|
||||||
setEventMessages($langs->trans("NoRecordSelected"), null, "warnings");
|
setEventMessages($langs->trans("NoRecordSelected"), null, "warnings");
|
||||||
}
|
}
|
||||||
if (!$error && is_array($toselect) && count($toselect) > $maxformassaction) {
|
if (!$error && is_array($toselect) && count($toselect) > $maxformassaction) {
|
||||||
setEventMessages($langs->trans('TooManyRecordForMassAction', $maxformassaction), null, 'errors');
|
setEventMessages($langs->trans('TooManyRecordForMassAction', (string) $maxformassaction), null, 'errors');
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,23 +97,21 @@ if (!$error && $massaction == 'confirm_presend_attendees') {
|
|||||||
|
|
||||||
$listofselectedid = array();
|
$listofselectedid = array();
|
||||||
$listofselectedref = array();
|
$listofselectedref = array();
|
||||||
if (!$error) {
|
require_once DOL_DOCUMENT_ROOT . '/eventorganization/class/conferenceorboothattendee.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT . '/eventorganization/class/conferenceorboothattendee.class.php';
|
$attendee = new ConferenceOrBoothAttendee($db);
|
||||||
$attendee = new ConferenceOrBoothAttendee($db);
|
$objecttmp = new $objectclass($db);
|
||||||
$objecttmp = new $objectclass($db);
|
'@phan-var-force CommonObject $objecttmp';
|
||||||
'@phan-var-force CommonObject $objecttmp';
|
|
||||||
|
|
||||||
foreach ($toselect as $toselectid) {
|
foreach ($toselect as $toselectid) {
|
||||||
$result = $objecttmp->fetch($toselectid);
|
$result = $objecttmp->fetch($toselectid);
|
||||||
if ($result > 0) {
|
if ($result > 0) {
|
||||||
$attendees = $attendee->fetchAll();
|
$attendees = $attendee->fetchAll();
|
||||||
if (is_array($attendees) && count($attendees) > 0) {
|
if (is_array($attendees) && count($attendees) > 0) {
|
||||||
foreach ($attendees as $attmail) {
|
foreach ($attendees as $attmail) {
|
||||||
if (!empty($attmail->email)) {
|
if (!empty($attmail->email)) {
|
||||||
$attmail->fetch_thirdparty();
|
$attmail->fetch_thirdparty();
|
||||||
$listofselectedid[$attmail->email] = $attmail;
|
$listofselectedid[$attmail->email] = $attmail;
|
||||||
$listofselectedref[$attmail->email] = $objecttmp;
|
$listofselectedref[$attmail->email] = $objecttmp;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -193,6 +194,8 @@ if (!$error && $massaction == 'confirm_presend_attendees') {
|
|||||||
$obj = $db->fetch_object($resql);
|
$obj = $db->fetch_object($resql);
|
||||||
if ($obj) {
|
if ($obj) {
|
||||||
$from = dol_string_nospecial($obj->label, ' ', array(",")) . ' <' . $obj->email . '>';
|
$from = dol_string_nospecial($obj->label, ' ', array(",")) . ' <' . $obj->email . '>';
|
||||||
|
} else {
|
||||||
|
$from = '';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$from = dol_string_nospecial(GETPOST('fromname'), ' ', array(",")) . ' <' . GETPOST('frommail') . '>';
|
$from = dol_string_nospecial(GETPOST('fromname'), ' ', array(",")) . ' <' . GETPOST('frommail') . '>';
|
||||||
@@ -239,7 +242,7 @@ if (!$error && $massaction == 'confirm_presend_attendees') {
|
|||||||
|
|
||||||
// Send mail (substitutionarray must be done just before this)
|
// Send mail (substitutionarray must be done just before this)
|
||||||
require_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php';
|
require_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php';
|
||||||
$mailfile = new CMailFile($subjectreplaced, $sendto, $from, $messagereplaced, array(), array(), array(), $sendtocc, $sendtobcc, (int) $deliveryreceipt, -1, '', '', "attendees_".$attendees->id, '', $sendcontext);
|
$mailfile = new CMailFile($subjectreplaced, $sendto, $from, $messagereplaced, array(), array(), array(), $sendtocc, $sendtobcc, 0, -1, '', '', "attendees_".$attendees->id, '', $sendcontext);
|
||||||
if ($mailfile->error) {
|
if ($mailfile->error) {
|
||||||
$resaction .= '<div class="error">' . $mailfile->error . '</div>';
|
$resaction .= '<div class="error">' . $mailfile->error . '</div>';
|
||||||
} else {
|
} else {
|
||||||
@@ -269,24 +272,22 @@ if (!$error && $massaction == 'confirm_presend_attendees') {
|
|||||||
$objectobj2->elementtype = $objectobj2->element;
|
$objectobj2->elementtype = $objectobj2->element;
|
||||||
|
|
||||||
$triggername = 'CONFERENCEORBOOTHATTENDEE_SENTBYMAIL';
|
$triggername = 'CONFERENCEORBOOTHATTENDEE_SENTBYMAIL';
|
||||||
if (!empty($triggername)) {
|
// Call trigger
|
||||||
// Call trigger
|
$result = $objectobj2->call_trigger($triggername, $user);
|
||||||
$result = $objectobj2->call_trigger($triggername, $user);
|
if ($result < 0) {
|
||||||
if ($result < 0) {
|
$error++;
|
||||||
$error++;
|
}
|
||||||
}
|
// End call triggers
|
||||||
// End call triggers
|
|
||||||
|
|
||||||
if ($error) {
|
if ($error) {
|
||||||
setEventMessages($db->lasterror(), $objectobj2->errors, 'errors');
|
setEventMessages($db->lasterror(), $objectobj2->errors, 'errors');
|
||||||
dol_syslog("Error in trigger " . $triggername . ' ' . $db->lasterror(), LOG_ERR);
|
dol_syslog("Error in trigger " . $triggername . ' ' . $db->lasterror(), LOG_ERR);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$nbsent++; // Nb of object sent
|
$nbsent++; // Nb of object sent
|
||||||
} else {
|
} else {
|
||||||
$langs->load("other");
|
$langs->load("other");
|
||||||
if ($mailfile->error) {
|
if ($mailfile->error) { // @phpstan-ignore-line
|
||||||
$resaction .= $langs->trans('ErrorFailedToSendMail', $from, $sendto);
|
$resaction .= $langs->trans('ErrorFailedToSendMail', $from, $sendto);
|
||||||
$resaction .= '<br><div class="error">' . $mailfile->error . '</div>';
|
$resaction .= '<br><div class="error">' . $mailfile->error . '</div>';
|
||||||
} elseif (getDolGlobalString('MAIN_DISABLE_ALL_MAILS')) {
|
} elseif (getDolGlobalString('MAIN_DISABLE_ALL_MAILS')) {
|
||||||
@@ -294,6 +295,7 @@ if (!$error && $massaction == 'confirm_presend_attendees') {
|
|||||||
} else {
|
} else {
|
||||||
$resaction .= $langs->trans('ErrorFailedToSendMail', $from, $sendto) . '<br><div class="error">(unhandled error)</div>';
|
$resaction .= $langs->trans('ErrorFailedToSendMail', $from, $sendto) . '<br><div class="error">(unhandled error)</div>';
|
||||||
}
|
}
|
||||||
|
$nbignored++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // foreach ($listofselectedid as $email => $attendees)
|
} // foreach ($listofselectedid as $email => $attendees)
|
||||||
|
|||||||
Reference in New Issue
Block a user