41if (empty($objectclass) || empty($uploaddir)) {
42 dol_print_error(
null,
'include of actions_massactions.inc.php is done but var $objectclass or $uploaddir was not defined');
47@phan-var-force string $massaction
48@phan-var-force string $objectclass
49@phan-var-force ?string $diroutputmassaction
50@phan-var-force ?string $uploaddir
51@phan-var-force string[] $toselect
52@phan-var-force array<string,mixed> $parameters
56$maxformassaction = (!
getDolGlobalString(
'MAIN_LIMIT_FOR_MASS_ACTIONS') ? 1000 : $conf->global->MAIN_LIMIT_FOR_MASS_ACTIONS);
57if (!empty($massaction) && is_array($toselect) && count($toselect) < 1) {
61if (!$error && is_array($toselect) && count($toselect) > $maxformassaction) {
62 setEventMessages($langs->trans(
'TooManyRecordForMassAction', $maxformassaction),
null,
'errors');
66if (!$error && $massaction ==
'confirm_presend_attendees' && !
GETPOST(
'sendmail')) {
67 $massaction =
'presend_attendees';
70if (!$error && $massaction ==
'confirm_presend_attendees') {
74 $langs->load(
"mails");
75 include_once DOL_DOCUMENT_ROOT .
'/core/lib/files.lib.php';
77 $listofobjectid = array();
79 $listofobjectref = array();
80 $oneemailperrecipient = (
GETPOSTINT(
'oneemailperrecipient') ? 1 : 0);
82 $listofselectedid = array();
83 $listofselectedref = array();
85 require_once DOL_DOCUMENT_ROOT .
'/eventorganization/class/conferenceorboothattendee.class.php';
87 $objecttmp =
new $objectclass($db);
88 '@phan-var-force CommonObject $objecttmp';
90 foreach ($toselect as $toselectid) {
91 $result = $objecttmp->fetch($toselectid);
93 $attendees = $attendee->fetchAll();
94 if (is_array($attendees) && count($attendees) > 0) {
95 foreach ($attendees as $attmail) {
96 if (!empty($attmail->email)) {
97 $attmail->fetch_thirdparty();
98 $listofselectedid[$attmail->email] = $attmail;
99 $listofselectedref[$attmail->email] = $objecttmp;
106 '@phan-var-force CommonObject $objecttmp';
107 '@phan-var-force array<string,CommonObject> $listofselectedref';
110 if (
GETPOST(
'fromtype',
'alpha') ===
'user' && empty($user->email)) {
113 $massaction =
'presend_attendees';
116 $receiver =
GETPOST(
'receiver',
'alphawithlgt');
117 if (!is_array($receiver)) {
118 if (empty($receiver) || $receiver ==
'-1') {
121 $receiver = array($receiver);
124 if (!trim(
GETPOST(
'sendto',
'alphawithlgt')) && count($receiver) == 0 && count($listofselectedid) == 0) {
126 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Recipient")),
null,
'warnings');
127 $massaction =
'presend_attendees';
130 if (!
GETPOST(
'subject',
'restricthtml')) {
132 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"MailTopic")),
null,
'warnings');
133 $massaction =
'presend_attendees';
136 if (!$error && !empty($listofselectedid)) {
137 $objecttmp->fetch_thirdparty();
138 foreach ($listofselectedid as $email => $attendees) {
145 $sendto = $attendees->thirdparty->name .
'<' . trim($attendees->email) .
'>';
148 $receivercc =
GETPOST(
'receivercc',
'alphawithlgt');
149 if (!is_array($receivercc)) {
150 if ($receivercc ==
'-1') {
151 $receivercc = array();
153 $receivercc = array($receivercc);
157 if (trim(
GETPOST(
'sendtocc',
'alphawithlgt'))) {
158 $tmparray[] = trim(
GETPOST(
'sendtocc',
'alphawithlgt'));
160 $sendtocc = implode(
',', $tmparray);
163 $langs->load(
"commercial");
166 $fromtype =
GETPOST(
'fromtype');
167 if ($fromtype ===
'user') {
168 $from = $user->getFullName($langs) .
' <' . $user->email .
'>';
169 } elseif ($fromtype ===
'company') {
171 } elseif (preg_match(
'/user_aliases_(\d+)/', $fromtype, $reg)) {
172 $tmp = explode(
',', $user->email_aliases);
173 $from = trim($tmp[((
int) $reg[1] - 1)]);
174 } elseif (preg_match(
'/global_aliases_(\d+)/', $fromtype, $reg)) {
176 $from = trim($tmp[((
int) $reg[1] - 1)]);
177 } elseif (preg_match(
'/senderprofile_(\d+)_(\d+)/', $fromtype, $reg)) {
178 $sql =
"SELECT rowid, label, email FROM " . MAIN_DB_PREFIX .
"c_email_senderprofile WHERE rowid = " . (int) $reg[1];
179 $resql = $db->query($sql);
180 $obj = $db->fetch_object($resql);
189 $subject =
GETPOST(
'subject',
'restricthtml');
190 $message =
GETPOST(
'message',
'restricthtml');
192 $sendtobcc =
GETPOST(
'sendtoccc',
'alphawithlgt');
201 $urlwithouturlroot = preg_replace(
'/' . preg_quote(DOL_URL_ROOT,
'/') .
'$/i',
'', trim($dolibarr_main_url_root));
202 $urlwithroot = $urlwithouturlroot . DOL_URL_ROOT;
203 $url_link = $urlwithroot .
'/public/agenda/agendaexport.php?format=ical' . ($conf->entity > 1 ?
"&entity=" . $conf->entity :
"");
204 $url_link .=
'&exportkey=' . ($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY ? urlencode(
getDolGlobalString(
'MAIN_AGENDA_XCAL_EXPORTKEY')) :
'...');
205 $url_link .=
"&project=" . $listofselectedref[$email]->fk_project .
'&module=' . urlencode(
'@eventorganization') .
'&status=' . ConferenceOrBooth::STATUS_CONFIRMED;
206 $html_link =
'<a href="' . $url_link .
'">' . $langs->trans(
'DownloadICSLink') .
'</a>';
208 $substitutionarray[
'__EVENTORGANIZATION_ICS_LINK__'] = $html_link;
209 $substitutionarray[
'__EVENTORGANIZATION_URL_LINK__'] = $url_link;
211 $parameters = array(
'mode' =>
'formemail');
213 if (!empty($listofobjectref)) {
214 $parameters[
'listofobjectref'] = $listofobjectref;
223 if (empty($sendcontext)) {
224 $sendcontext =
'standard';
228 require_once DOL_DOCUMENT_ROOT .
'/core/class/CMailFile.class.php';
229 $mailfile =
new CMailFile($subjectreplaced, $sendto, $from, $messagereplaced, array(), array(), array(), $sendtocc, $sendtobcc, $deliveryreceipt, -1,
'',
'',
"attendees_".$attendees->id,
'', $sendcontext);
230 if ($mailfile->error) {
231 $resaction .=
'<div class="error">' . $mailfile->error .
'</div>';
233 $result = $mailfile->sendfile();
235 $resaction .= $langs->trans(
'MailSuccessfulySent', $mailfile->getValidAddress($from, 2), $mailfile->getValidAddress($sendto, 2)) .
'<br>';
238 dol_syslog(
"Try to insert email event into agenda for objid=" . $attendees->id .
" => objectobj=" . get_class($attendees));
240 $actionmsg = $langs->transnoentities(
'MailSentByTo', $from, $sendto);
243 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'Bcc') .
": " . $sendtocc);
245 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'MailTopic') .
": " . $subjectreplaced);
246 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'TextUsedInTheMessageBody') .
":");
251 $objectobj2 = $listofselectedref[$email];
253 $objectobj2->actionmsg = $actionmsg;
254 $objectobj2->actionmsg2 = $actionmsg2;
255 $objectobj2->fk_element = $objectobj2->id;
256 $objectobj2->elementtype = $objectobj2->element;
258 $triggername =
'CONFERENCEORBOOTHATTENDEE_SENTBYMAIL';
259 if (!empty($triggername)) {
261 $result = $objectobj2->call_trigger($triggername, $user);
269 dol_syslog(
"Error in trigger " . $triggername .
' ' . $db->lasterror(), LOG_ERR);
275 $langs->load(
"other");
276 if ($mailfile->error) {
277 $resaction .= $langs->trans(
'ErrorFailedToSendMail', $from, $sendto);
278 $resaction .=
'<br><div class="error">' . $mailfile->error .
'</div>';
280 $resaction .=
'<div class="warning">No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS</div>';
282 $resaction .= $langs->trans(
'ErrorFailedToSendMail', $from, $sendto) .
'<br><div class="error">(unhandled error)</div>';
288 $resaction .= ($resaction ?
'<br>' : $resaction);
289 $resaction .=
'<strong>' . $langs->trans(
"ResultOfMailSending") .
':</strong><br>' .
"\n";
290 $resaction .= $langs->trans(
"NbSelected") .
': ' . count($toselect) .
"\n<br>";
291 $resaction .= $langs->trans(
"NbIgnored") .
': ' . ($nbignored ? $nbignored : 0) .
"\n<br>";
292 $resaction .= $langs->trans(
"NbSent") .
': ' . ($nbsent ? $nbsent : 0) .
"\n<br>";
297 setEventMessages($langs->trans(
"EMailSentForNElements", $nbsent .
'/' . count($toselect)),
null,
'mesgs');
310$parameters[
'toselect'] = $toselect;
311$parameters[
'uploaddir'] = $uploaddir;
312$parameters[
'massaction'] = $massaction;
313$parameters[
'diroutputmassaction'] = isset($diroutputmassaction) ? $diroutputmassaction :
null;
315$reshook = $hookmanager->executeHooks(
'doMassActions', $parameters,
$object, $action);
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
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.
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...
getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $object=null, $include=null)
Return array of possible common substitutions.
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.