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:
Frédéric FRANCE
2025-09-12 15:12:55 +02:00
committed by GitHub
parent 8b57bb2e41
commit 1bbbd96690
3 changed files with 43 additions and 101 deletions

View File

@@ -10836,66 +10836,6 @@ parameters:
count: 2
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\.$#'
identifier: if.alwaysTrue

View File

@@ -946,26 +946,26 @@ class CMailFile
}
$keyforsmtpserver = 'MAIN_MAIL_SMTP_SERVER';
$keyforsmtpport = 'MAIN_MAIL_SMTP_PORT';
$keyforsmtpid = 'MAIN_MAIL_SMTPS_ID';
$keyforsmtppw = 'MAIN_MAIL_SMTPS_PW';
$keyforsmtpport = 'MAIN_MAIL_SMTP_PORT';
$keyforsmtpid = 'MAIN_MAIL_SMTPS_ID';
$keyforsmtppw = 'MAIN_MAIL_SMTPS_PW';
$keyforsmtpauthtype = 'MAIN_MAIL_SMTPS_AUTH_TYPE';
$keyforsmtpoauthservice = 'MAIN_MAIL_SMTPS_OAUTH_SERVICE';
$keyfortls = 'MAIN_MAIL_EMAIL_TLS';
$keyforstarttls = 'MAIN_MAIL_EMAIL_STARTTLS';
$keyfortls = 'MAIN_MAIL_EMAIL_TLS';
$keyforstarttls = 'MAIN_MAIL_EMAIL_STARTTLS';
$keyforsslseflsigned = 'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED';
if (!empty($this->sendcontext)) {
$smtpContextKey = strtoupper($this->sendcontext);
$smtpContextSendMode = getDolGlobalString('MAIN_MAIL_SENDMODE_'.$smtpContextKey);
if (!empty($smtpContextSendMode) && $smtpContextSendMode != 'default') {
$keyforsmtpserver = 'MAIN_MAIL_SMTP_SERVER_'.$smtpContextKey;
$keyforsmtpport = 'MAIN_MAIL_SMTP_PORT_'.$smtpContextKey;
$keyforsmtpid = 'MAIN_MAIL_SMTPS_ID_'.$smtpContextKey;
$keyforsmtppw = 'MAIN_MAIL_SMTPS_PW_'.$smtpContextKey;
$keyforsmtpport = 'MAIN_MAIL_SMTP_PORT_'.$smtpContextKey;
$keyforsmtpid = 'MAIN_MAIL_SMTPS_ID_'.$smtpContextKey;
$keyforsmtppw = 'MAIN_MAIL_SMTPS_PW_'.$smtpContextKey;
$keyforsmtpauthtype = 'MAIN_MAIL_SMTPS_AUTH_TYPE_'.$smtpContextKey;
$keyforsmtpoauthservice = 'MAIN_MAIL_SMTPS_OAUTH_SERVICE_'.$smtpContextKey;
$keyfortls = 'MAIN_MAIL_EMAIL_TLS_'.$smtpContextKey;
$keyforstarttls = 'MAIN_MAIL_EMAIL_STARTTLS_'.$smtpContextKey;
$keyfortls = 'MAIN_MAIL_EMAIL_TLS_'.$smtpContextKey;
$keyforstarttls = 'MAIN_MAIL_EMAIL_STARTTLS_'.$smtpContextKey;
$keyforsslseflsigned = 'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_'.$smtpContextKey;
}
}

View File

@@ -37,8 +37,11 @@
// $diroutputmassaction may be defined
/**
* @var Conf $conf
* @var CommonObject $object
* @var DoliDB $db
* @var HookManager $hookmanager
* @var Translate $langs
* @var User $user
*
* @var string $massaction
* @var string $objectclass
@@ -66,13 +69,13 @@ if (empty($objectclass) || empty($uploaddir)) {
$error = 0;
// 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) {
$error++;
setEventMessages($langs->trans("NoRecordSelected"), null, "warnings");
}
if (!$error && is_array($toselect) && count($toselect) > $maxformassaction) {
setEventMessages($langs->trans('TooManyRecordForMassAction', $maxformassaction), null, 'errors');
setEventMessages($langs->trans('TooManyRecordForMassAction', (string) $maxformassaction), null, 'errors');
$error++;
}
@@ -94,23 +97,21 @@ if (!$error && $massaction == 'confirm_presend_attendees') {
$listofselectedid = array();
$listofselectedref = array();
if (!$error) {
require_once DOL_DOCUMENT_ROOT . '/eventorganization/class/conferenceorboothattendee.class.php';
$attendee = new ConferenceOrBoothAttendee($db);
$objecttmp = new $objectclass($db);
'@phan-var-force CommonObject $objecttmp';
require_once DOL_DOCUMENT_ROOT . '/eventorganization/class/conferenceorboothattendee.class.php';
$attendee = new ConferenceOrBoothAttendee($db);
$objecttmp = new $objectclass($db);
'@phan-var-force CommonObject $objecttmp';
foreach ($toselect as $toselectid) {
$result = $objecttmp->fetch($toselectid);
if ($result > 0) {
$attendees = $attendee->fetchAll();
if (is_array($attendees) && count($attendees) > 0) {
foreach ($attendees as $attmail) {
if (!empty($attmail->email)) {
$attmail->fetch_thirdparty();
$listofselectedid[$attmail->email] = $attmail;
$listofselectedref[$attmail->email] = $objecttmp;
}
foreach ($toselect as $toselectid) {
$result = $objecttmp->fetch($toselectid);
if ($result > 0) {
$attendees = $attendee->fetchAll();
if (is_array($attendees) && count($attendees) > 0) {
foreach ($attendees as $attmail) {
if (!empty($attmail->email)) {
$attmail->fetch_thirdparty();
$listofselectedid[$attmail->email] = $attmail;
$listofselectedref[$attmail->email] = $objecttmp;
}
}
}
@@ -193,6 +194,8 @@ if (!$error && $massaction == 'confirm_presend_attendees') {
$obj = $db->fetch_object($resql);
if ($obj) {
$from = dol_string_nospecial($obj->label, ' ', array(",")) . ' <' . $obj->email . '>';
} else {
$from = '';
}
} else {
$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)
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) {
$resaction .= '<div class="error">' . $mailfile->error . '</div>';
} else {
@@ -269,24 +272,22 @@ if (!$error && $massaction == 'confirm_presend_attendees') {
$objectobj2->elementtype = $objectobj2->element;
$triggername = 'CONFERENCEORBOOTHATTENDEE_SENTBYMAIL';
if (!empty($triggername)) {
// Call trigger
$result = $objectobj2->call_trigger($triggername, $user);
if ($result < 0) {
$error++;
}
// End call triggers
// Call trigger
$result = $objectobj2->call_trigger($triggername, $user);
if ($result < 0) {
$error++;
}
// End call triggers
if ($error) {
setEventMessages($db->lasterror(), $objectobj2->errors, 'errors');
dol_syslog("Error in trigger " . $triggername . ' ' . $db->lasterror(), LOG_ERR);
}
if ($error) {
setEventMessages($db->lasterror(), $objectobj2->errors, 'errors');
dol_syslog("Error in trigger " . $triggername . ' ' . $db->lasterror(), LOG_ERR);
}
$nbsent++; // Nb of object sent
} else {
$langs->load("other");
if ($mailfile->error) {
if ($mailfile->error) { // @phpstan-ignore-line
$resaction .= $langs->trans('ErrorFailedToSendMail', $from, $sendto);
$resaction .= '<br><div class="error">' . $mailfile->error . '</div>';
} elseif (getDolGlobalString('MAIN_DISABLE_ALL_MAILS')) {
@@ -294,6 +295,7 @@ if (!$error && $massaction == 'confirm_presend_attendees') {
} else {
$resaction .= $langs->trans('ErrorFailedToSendMail', $from, $sendto) . '<br><div class="error">(unhandled error)</div>';
}
$nbignored++;
}
}
} // foreach ($listofselectedid as $email => $attendees)