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(
'/user_aliases_(\d+)/', $fromtype, $reg)) {
186 $tmp = explode(
',', $user->email_aliases);
187 $from = trim($tmp[((
int) $reg[1] - 1)]);
188 } elseif (preg_match(
'/global_aliases_(\d+)/', $fromtype, $reg)) {
190 $from = trim($tmp[((
int) $reg[1] - 1)]);
191 } elseif (preg_match(
'/senderprofile_(\d+)_(\d+)/', $fromtype, $reg)) {
192 $sql =
"SELECT rowid, label, email FROM " . MAIN_DB_PREFIX .
"c_email_senderprofile WHERE rowid = " . (int) $reg[1];
193 $resql = $db->query($sql);
194 $obj = $db->fetch_object($resql);
205 $subject =
GETPOST(
'subject',
'restricthtml');
206 $message =
GETPOST(
'message',
'restricthtml');
208 $sendtobcc =
GETPOST(
'sendtoccc',
'alphawithlgt');
212 $substitutionarray = getCommonSubstitutionArray($langs, 0,
null, $attendees);
217 $urlwithouturlroot = preg_replace(
'/' . preg_quote(DOL_URL_ROOT,
'/') .
'$/i',
'', trim(
$dolibarr_main_url_root));
218 $urlwithroot = $urlwithouturlroot . DOL_URL_ROOT;
219 $url_link = $urlwithroot .
'/public/agenda/agendaexport.php?format=ical' . ($conf->entity > 1 ?
"&entity=" . $conf->entity :
"");
220 $url_link .=
'&exportkey=' . urlencode(
getDolGlobalString(
'MAIN_AGENDA_XCAL_EXPORTKEY',
'...'));
221 $url_link .=
"&project=" . $listofselectedref[$email]->fk_project .
'&module=' . urlencode(
'@eventorganization') .
'&status=' . ConferenceOrBooth::STATUS_CONFIRMED;
222 $html_link =
'<a href="' . $url_link .
'">' . $langs->trans(
'DownloadICSLink') .
'</a>';
224 $substitutionarray[
'__EVENTORGANIZATION_ICS_LINK__'] = $html_link;
225 $substitutionarray[
'__EVENTORGANIZATION_URL_LINK__'] = $url_link;
227 $parameters = array(
'mode' =>
'formemail');
229 if (!empty($listofobjectref)) {
230 $parameters[
'listofobjectref'] = $listofobjectref;
239 if (empty($sendcontext)) {
240 $sendcontext =
'standard';
244 require_once DOL_DOCUMENT_ROOT .
'/core/class/CMailFile.class.php';
245 $mailfile =
new CMailFile($subjectreplaced, $sendto, $from, $messagereplaced, array(), array(), array(), $sendtocc, $sendtobcc, 0, -1,
'',
'',
"attendees_".$attendees->id,
'', $sendcontext);
246 if ($mailfile->error) {
247 $resaction .=
'<div class="error">' . $mailfile->error .
'</div>';
249 $result = $mailfile->sendfile();
251 $resaction .= $langs->trans(
'MailSuccessfulySent', $mailfile->getValidAddress($from, 2), $mailfile->getValidAddress($sendto, 2)) .
'<br>';
254 dol_syslog(
"Try to insert email event into agenda for objid=" . $attendees->id .
" => objectobj=" . get_class($attendees));
256 $actionmsg = $langs->transnoentities(
'MailSentByTo', $from, $sendto);
259 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'Bcc') .
": " . $sendtocc);
261 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'MailTopic') .
": " . $subjectreplaced);
262 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'TextUsedInTheMessageBody') .
":");
267 $objectobj2 = $listofselectedref[$email];
269 $objectobj2->actionmsg = $actionmsg;
270 $objectobj2->actionmsg2 = $actionmsg2;
271 $objectobj2->fk_element = $objectobj2->id;
272 $objectobj2->elementtype = $objectobj2->element;
274 $triggername =
'CONFERENCEORBOOTHATTENDEE_SENTBYMAIL';
276 $result = $objectobj2->call_trigger($triggername, $user);
284 dol_syslog(
"Error in trigger " . $triggername .
' ' . $db->lasterror(), LOG_ERR);
289 $langs->load(
"other");
290 if ($mailfile->error) {
291 $resaction .= $langs->trans(
'ErrorFailedToSendMail', $from, $sendto);
292 $resaction .=
'<br><div class="error">' . $mailfile->error .
'</div>';
294 $resaction .=
'<div class="warning">No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS</div>';
296 $resaction .= $langs->trans(
'ErrorFailedToSendMail', $from, $sendto) .
'<br><div class="error">(unhandled error)</div>';
303 $resaction .= ($resaction ?
'<br>' : $resaction);
304 $resaction .=
'<strong>' . $langs->trans(
"ResultOfMailSending") .
':</strong><br>' .
"\n";
305 $resaction .= $langs->trans(
"NbSelected") .
': ' . count($toselect) .
"\n<br>";
306 $resaction .= $langs->trans(
"NbIgnored") .
': ' . ($nbignored ? $nbignored : 0) .
"\n<br>";
307 $resaction .= $langs->trans(
"NbSent") .
': ' . ($nbsent ? $nbsent : 0) .
"\n<br>";
312 setEventMessages($langs->trans(
"EMailSentForNElements", $nbsent .
'/' . count($toselect)),
null,
'mesgs');
325$parameters[
'toselect'] = $toselect;
326$parameters[
'uploaddir'] = $uploaddir;
327$parameters[
'massaction'] = $massaction;
328$parameters[
'diroutputmassaction'] = isset($diroutputmassaction) ? $diroutputmassaction :
null;
330$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.