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) {
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';
102 $objecttmp =
new $objectclass(
$db);
103 '@phan-var-force CommonObject $objecttmp';
105 foreach ($toselect as $toselectid) {
106 $result = $objecttmp->fetch($toselectid);
108 $attendees = $attendee->fetchAll();
109 if (is_array($attendees) && count($attendees) > 0) {
110 foreach ($attendees as $attmail) {
111 if (!empty($attmail->email)) {
112 $attmail->fetch_thirdparty();
113 $listofselectedid[$attmail->email] = $attmail;
114 $listofselectedref[$attmail->email] = $objecttmp;
120 '@phan-var-force CommonObject $objecttmp';
121 '@phan-var-force array<string,CommonObject> $listofselectedref';
124 if (
GETPOST(
'fromtype',
'alpha') ===
'user' && empty($user->email)) {
127 $massaction =
'presend_attendees';
130 $receiver =
GETPOST(
'receiver',
'alphawithlgt');
131 if (!is_array($receiver)) {
132 if (empty($receiver) || $receiver ==
'-1') {
135 $receiver = array($receiver);
138 if (!trim(
GETPOST(
'sendto',
'alphawithlgt')) && count($receiver) == 0 && count($listofselectedid) == 0) {
140 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Recipient")),
null,
'warnings');
141 $massaction =
'presend_attendees';
144 if (!
GETPOST(
'subject',
'restricthtml')) {
146 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"MailTopic")),
null,
'warnings');
147 $massaction =
'presend_attendees';
150 if (!$error && !empty($listofselectedid)) {
151 $objecttmp->fetch_thirdparty();
152 foreach ($listofselectedid as $email => $attendees) {
159 $sendto = $attendees->thirdparty->name .
'<' . trim($attendees->email) .
'>';
162 $receivercc =
GETPOST(
'receivercc',
'alphawithlgt');
163 if (!is_array($receivercc)) {
164 if ($receivercc ==
'-1') {
165 $receivercc = array();
167 $receivercc = array($receivercc);
171 if (trim(
GETPOST(
'sendtocc',
'alphawithlgt'))) {
172 $tmparray[] = trim(
GETPOST(
'sendtocc',
'alphawithlgt'));
174 $sendtocc = implode(
',', $tmparray);
177 $langs->load(
"commercial");
180 $fromtype =
GETPOST(
'fromtype');
181 if ($fromtype ===
'user') {
182 $from = $user->getFullName($langs) .
' <' . $user->email .
'>';
183 } elseif ($fromtype ===
'company') {
185 } elseif (preg_match(
'/global_aliases_(\d+)/', $fromtype, $reg)) {
187 $from = trim($tmp[((
int) $reg[1] - 1)]);
188 } elseif (preg_match(
'/senderprofile_(\d+)_(\d+)/', $fromtype, $reg)) {
189 $sql =
"SELECT rowid, label, email FROM " . MAIN_DB_PREFIX .
"c_email_senderprofile WHERE rowid = " . (int) $reg[1];
190 $resql =
$db->query($sql);
191 $obj =
$db->fetch_object($resql);
202 $subject =
GETPOST(
'subject',
'restricthtml');
203 $message =
GETPOST(
'message',
'restricthtml');
205 $sendtobcc =
GETPOST(
'sendtoccc',
'alphawithlgt');
209 $substitutionarray = getCommonSubstitutionArray($langs, 0,
null, $attendees);
214 $urlwithouturlroot = preg_replace(
'/' . preg_quote(DOL_URL_ROOT,
'/') .
'$/i',
'', trim(
$dolibarr_main_url_root));
215 $urlwithroot = $urlwithouturlroot . DOL_URL_ROOT;
216 $url_link = $urlwithroot .
'/public/agenda/agendaexport.php?format=ical' . (
$conf->entity > 1 ?
"&entity=" .
$conf->entity :
"");
217 $url_link .=
'&exportkey=' . urlencode(
getDolGlobalString(
'MAIN_AGENDA_XCAL_EXPORTKEY',
'...'));
218 $url_link .=
"&project=" . $listofselectedref[$email]->fk_project .
'&module=' . urlencode(
'@eventorganization') .
'&status=' . ConferenceOrBooth::STATUS_CONFIRMED;
219 $html_link =
'<a href="' . $url_link .
'">' . $langs->trans(
'DownloadICSLink') .
'</a>';
221 $substitutionarray[
'__EVENTORGANIZATION_ICS_LINK__'] = $html_link;
222 $substitutionarray[
'__EVENTORGANIZATION_URL_LINK__'] = $url_link;
224 $parameters = array(
'mode' =>
'formemail');
226 if (!empty($listofobjectref)) {
227 $parameters[
'listofobjectref'] = $listofobjectref;
236 if (empty($sendcontext)) {
237 $sendcontext =
'standard';
241 require_once DOL_DOCUMENT_ROOT .
'/core/class/CMailFile.class.php';
242 $mailfile =
new CMailFile($subjectreplaced, $sendto, $from, $messagereplaced, array(), array(), array(), $sendtocc, $sendtobcc, 0, -1,
'',
'',
"attendees_".$attendees->id,
'', $sendcontext);
243 if ($mailfile->error) {
244 $resaction .=
'<div class="error">' . $mailfile->error .
'</div>';
246 $result = $mailfile->sendfile();
248 $resaction .= $langs->trans(
'MailSuccessfulySent', $mailfile->getValidAddress($from, 2), $mailfile->getValidAddress($sendto, 2)) .
'<br>';
251 dol_syslog(
"Try to insert email event into agenda for objid=" . $attendees->id .
" => objectobj=" . get_class($attendees));
253 $actionmsg = $langs->transnoentities(
'MailSentByTo', $from, $sendto);
256 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'Bcc') .
": " . $sendtocc);
258 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'MailTopic') .
": " . $subjectreplaced);
259 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'TextUsedInTheMessageBody') .
":");
264 $objectobj2 = $listofselectedref[$email];
266 $objectobj2->actionmsg = $actionmsg;
267 $objectobj2->actionmsg2 = $actionmsg2;
268 $objectobj2->fk_element = $objectobj2->id;
269 $objectobj2->elementtype = $objectobj2->element;
271 $triggername =
'CONFERENCEORBOOTHATTENDEE_SENTBYMAIL';
273 $result = $objectobj2->call_trigger($triggername, $user);
281 dol_syslog(
"Error in trigger " . $triggername .
' ' .
$db->lasterror(), LOG_ERR);
286 $langs->load(
"other");
287 if ($mailfile->error) {
288 $resaction .= $langs->trans(
'ErrorFailedToSendMail', $from, $sendto);
289 $resaction .=
'<br><div class="error">' . $mailfile->error .
'</div>';
291 $resaction .=
'<div class="warning">No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS</div>';
293 $resaction .= $langs->trans(
'ErrorFailedToSendMail', $from, $sendto) .
'<br><div class="error">(unhandled error)</div>';
300 $resaction .= ($resaction ?
'<br>' : $resaction);
301 $resaction .=
'<strong>' . $langs->trans(
"ResultOfMailSending") .
':</strong><br>' .
"\n";
302 $resaction .= $langs->trans(
"NbSelected") .
': ' . count($toselect) .
"\n<br>";
303 $resaction .= $langs->trans(
"NbIgnored") .
': ' . ($nbignored ? $nbignored : 0) .
"\n<br>";
304 $resaction .= $langs->trans(
"NbSent") .
': ' . ($nbsent ? $nbsent : 0) .
"\n<br>";
309 setEventMessages($langs->trans(
"EMailSentForNElements", $nbsent .
'/' . count($toselect)),
null,
'mesgs');
322$parameters[
'toselect'] = $toselect;
323$parameters[
'uploaddir'] = $uploaddir;
324$parameters[
'massaction'] = $massaction;
325$parameters[
'diroutputmassaction'] = isset($diroutputmassaction) ? $diroutputmassaction :
null;
327$reshook = $hookmanager->executeHooks(
'doMassActions', $parameters,
$object, $action);
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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.
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...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.