55if (empty($objectclass) || empty($uploaddir)) {
56 dol_print_error(
null,
'include of actions_massactions.inc.php is done but var $objectclass or $uploaddir was not defined');
61@phan-var-force string $massaction
62@phan-var-force string $objectclass
63@phan-var-force ?string $diroutputmassaction
64@phan-var-force ?string $uploaddir
65@phan-var-force string[] $toselect
66@phan-var-force array<string,mixed> $parameters
72$maxformassaction =
getDolGlobalInt(
'MAIN_LIMIT_FOR_MASS_ACTIONS', 1000);
73if (!empty($massaction) && is_array($toselect) && count($toselect) < 1) {
75 setEventMessages($langs->trans(
"NoRecordSelected"),
null,
"warnings");
77if (!$error && is_array($toselect) && count($toselect) > $maxformassaction) {
78 setEventMessages($langs->trans(
'TooManyRecordForMassAction', (
string) $maxformassaction),
null,
'errors');
82if (!$error && $massaction ==
'confirm_presend_attendees' && !
GETPOST(
'sendmail')) {
83 $massaction =
'presend_attendees';
86if (!$error && $massaction ==
'confirm_presend_attendees') {
90 $langs->load(
"mails");
91 include_once DOL_DOCUMENT_ROOT .
'/core/lib/files.lib.php';
93 $listofobjectid = array();
95 $listofobjectref = array();
96 $oneemailperrecipient = (
GETPOSTINT(
'oneemailperrecipient') ? 1 : 0);
98 $listofselectedid = array();
99 $listofselectedref = array();
100 require_once DOL_DOCUMENT_ROOT .
'/eventorganization/class/conferenceorboothattendee.class.php';
101 $objecttmp =
new $objectclass($db);
102 '@phan-var-force CommonObject $objecttmp';
104 foreach ($toselect as $toselectid) {
105 $result = $objecttmp->fetch($toselectid);
107 $attendee = clone $objecttmp;
108 $attendee->fetch_thirdparty();
109 $listofselectedid[$attendee->email] = $attendee;
110 $listofselectedref[$attendee->email] = $attendee;
113 '@phan-var-force CommonObject $objecttmp';
114 '@phan-var-force array<string,ConferenceOrBoothAttendee> $listofselectedid';
115 '@phan-var-force array<string,ConferenceOrBoothAttendee> $listofselectedref';
118 if (
GETPOST(
'fromtype',
'alpha') ===
'user' && empty($user->email)) {
120 setEventMessages($langs->trans(
"NoSenderEmailDefined"),
null,
'warnings');
121 $massaction =
'presend_attendees';
124 $receiver =
GETPOST(
'receiver',
'alphawithlgt');
125 if (!is_array($receiver)) {
126 if (empty($receiver) || $receiver ==
'-1') {
129 $receiver = array($receiver);
132 if (!trim(
GETPOST(
'sendto',
'alphawithlgt')) && count($receiver) == 0 && count($listofselectedid) == 0) {
134 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Recipient")),
null,
'warnings');
135 $massaction =
'presend_attendees';
138 if (!
GETPOST(
'subject',
'restricthtml')) {
140 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"MailTopic")),
null,
'warnings');
141 $massaction =
'presend_attendees';
144 if (!$error && !empty($listofselectedid)) {
145 $objecttmp->fetch_thirdparty();
146 foreach ($listofselectedid as $email => $attendees) {
153 $sendto = $attendees->thirdparty->name .
'<' . trim($attendees->email) .
'>';
156 $receivercc =
GETPOST(
'receivercc',
'alphawithlgt');
157 if (!is_array($receivercc)) {
158 if ($receivercc ==
'-1') {
159 $receivercc = array();
161 $receivercc = array($receivercc);
165 if (trim(
GETPOST(
'sendtocc',
'alphawithlgt'))) {
166 $tmparray[] = trim(
GETPOST(
'sendtocc',
'alphawithlgt'));
168 $sendtocc = implode(
',', $tmparray);
171 $langs->load(
"commercial");
174 $fromtype =
GETPOST(
'fromtype');
175 if ($fromtype ===
'user') {
176 $email_from = $user->getFullName($langs) .
' <' . $user->email .
'>';
177 } elseif ($fromtype ===
'company') {
179 } elseif (preg_match(
'/global_aliases_(\d+)/', $fromtype, $reg)) {
181 $email_from = trim($tmp[((
int) $reg[1] - 1)]);
182 } elseif (preg_match(
'/senderprofile_(\d+)_(\d+)/', $fromtype, $reg)) {
183 $sql =
"SELECT rowid, label, email FROM " . MAIN_DB_PREFIX .
"c_email_senderprofile WHERE rowid = " . (int) $reg[1];
184 $resql = $db->query($sql);
185 $obj = $db->fetch_object($resql);
195 $replyto = $email_from;
196 $subject =
GETPOST(
'subject',
'restricthtml');
197 $message =
GETPOST(
'message',
'restricthtml');
199 $sendtobcc =
GETPOST(
'sendtoccc',
'alphawithlgt');
203 $substitutionarray = getCommonSubstitutionArray($langs, 0,
null, $attendees);
208 $urlwithouturlroot = preg_replace(
'/' . preg_quote(DOL_URL_ROOT,
'/') .
'$/i',
'', trim(
$dolibarr_main_url_root));
209 $urlwithroot = $urlwithouturlroot . DOL_URL_ROOT;
210 $url_link = $urlwithroot .
'/public/agenda/agendaexport.php?format=ical' . (
$conf->entity > 1 ?
"&entity=" .
$conf->entity :
"");
211 $url_link .=
'&exportkey=' . urlencode(
getDolGlobalString(
'MAIN_AGENDA_XCAL_EXPORTKEY',
'...'));
212 $url_link .=
"&project=" . $listofselectedref[$email]->fk_project .
'&module=' . urlencode(
'@eventorganization') .
'&status=' . ConferenceOrBooth::STATUS_CONFIRMED;
213 $html_link =
'<a href="' . $url_link .
'">' . $langs->trans(
'DownloadICSLink') .
'</a>';
215 $substitutionarray[
'__EVENTORGANIZATION_ICS_LINK__'] = $html_link;
216 $substitutionarray[
'__EVENTORGANIZATION_URL_LINK__'] = $url_link;
218 $parameters = array(
'mode' =>
'formemail');
220 if (!empty($listofobjectref)) {
221 $parameters[
'listofobjectref'] = $listofobjectref;
230 if (empty($sendcontext)) {
231 $sendcontext =
'standard';
235 require_once DOL_DOCUMENT_ROOT .
'/core/class/CMailFile.class.php';
236 $mailfile =
new CMailFile($subjectreplaced, $sendto, $email_from, $messagereplaced, array(), array(), array(), $sendtocc, $sendtobcc, 0, -1,
'',
'',
"attendees_".$attendees->id,
'', $sendcontext);
237 if ($mailfile->error) {
238 $resaction .=
'<div class="error">' . $mailfile->error .
'</div>';
240 $result = $mailfile->sendfile();
242 $resaction .= $langs->trans(
'MailSuccessfulySent', $mailfile->getValidAddress($email_from, 2), $mailfile->getValidAddress($sendto, 2)) .
'<br>';
245 dol_syslog(
"Try to insert email event into agenda for objid=" . $attendees->id .
" => objectobj=" . get_class($attendees));
247 $actionmsg = $langs->transnoentities(
'MailSentByTo', $email_from, $sendto);
250 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'Bcc') .
": " . $sendtocc);
252 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'MailTopic') .
": " . $subjectreplaced);
253 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'TextUsedInTheMessageBody') .
":");
258 $objectobj2 = $listofselectedref[$email];
260 $objectobj2->actionmsg = $actionmsg;
261 $objectobj2->actionmsg2 = $actionmsg2;
262 $objectobj2->fk_element = $objectobj2->id;
263 $objectobj2->elementtype = $objectobj2->element;
265 $triggername =
'CONFERENCEORBOOTHATTENDEE_SENTBYMAIL';
267 $result = $objectobj2->call_trigger($triggername, $user);
274 setEventMessages($db->lasterror(), $objectobj2->errors,
'errors');
275 dol_syslog(
"Error in trigger " . $triggername .
' ' . $db->lasterror(), LOG_ERR);
280 $langs->load(
"other");
281 if ($mailfile->error) {
282 $resaction .= $langs->trans(
'ErrorFailedToSendMail', $email_from, $sendto);
283 $resaction .=
'<br><div class="error">' . $mailfile->error .
'</div>';
285 $resaction .=
'<div class="warning">No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS</div>';
287 $resaction .= $langs->trans(
'ErrorFailedToSendMail', $email_from, $sendto) .
'<br><div class="error">(unhandled error)</div>';
294 $resaction .= ($resaction ?
'<br>' : $resaction);
295 $resaction .=
'<strong>' . $langs->trans(
"ResultOfMailSending") .
':</strong><br>' .
"\n";
296 $resaction .= $langs->trans(
"NbSelected") .
': ' . count($toselect) .
"\n<br>";
297 $resaction .= $langs->trans(
"NbIgnored") .
': ' . ($nbignored ? $nbignored : 0) .
"\n<br>";
298 $resaction .= $langs->trans(
"NbSent") .
': ' . ($nbsent ? $nbsent : 0) .
"\n<br>";
303 setEventMessages($langs->trans(
"EMailSentForNElements", $nbsent .
'/' . count($toselect)),
null,
'mesgs');
304 setEventMessages($resaction,
null,
'mesgs');
307 setEventMessages($resaction,
null,
'warnings');
316$parameters[
'toselect'] = $toselect;
317$parameters[
'uploaddir'] = $uploaddir;
318$parameters[
'massaction'] = $massaction;
319$parameters[
'diroutputmassaction'] = isset($diroutputmassaction) ? $diroutputmassaction :
null;
321$reshook = $hookmanager->executeHooks(
'doMassActions', $parameters,
$object, $action);
323 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
if(! $sortfield) if(! $sortorder) $object
global $dolibarr_main_url_root
Class to send emails (with attachments or not) Usage: $mailfile = new CMailFile($subject,...
Class for ConferenceOrBoothAttendee.
dol_string_nospecial($str, $newstr='_', $badcharstoreplace='', $badcharstoremove='', $keepspaces=0)
Clean a string from all punctuation characters to use it as a ref or login.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
complete_substitutions_array(&$substitutionarray, $outputlangs, $object=null, $parameters=null, $callfunc="completesubstitutionarray")
Complete the $substitutionarray with more entries coming from external module that had set the "subst...
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.