40if (empty($objectclass) || empty($uploaddir)) {
 
   41  dol_print_error(
null, 
'include of actions_massactions.inc.php is done but var $objectclass or $uploaddir was not defined');
 
   46$maxformassaction = (!
getDolGlobalString(
'MAIN_LIMIT_FOR_MASS_ACTIONS') ? 1000 : $conf->global->MAIN_LIMIT_FOR_MASS_ACTIONS);
 
   47if (!empty($massaction) && is_array($toselect) && count($toselect) < 1) {
 
   51if (!$error && is_array($toselect) && count($toselect) > $maxformassaction) {
 
   52  setEventMessages($langs->trans(
'TooManyRecordForMassAction', $maxformassaction), 
null, 
'errors');
 
   56if (!$error && $massaction == 
'confirm_presend_attendees' && !
GETPOST(
'sendmail')) {  
 
   57  $massaction = 
'presend_attendees';
 
   59if (!$error && $massaction == 
'confirm_presend_attendees') {
 
   63  $langs->load(
"mails");
 
   64  include_once DOL_DOCUMENT_ROOT . 
'/core/lib/files.lib.php';
 
   66  $listofobjectid = array();
 
   68  $listofobjectref = array();
 
   69  $oneemailperrecipient = (
GETPOST(
'oneemailperrecipient', 
'int') ? 1 : 0);
 
   72    require_once DOL_DOCUMENT_ROOT . 
'/eventorganization/class/conferenceorboothattendee.class.php';
 
   74    $listofselectedid = array();
 
   75    $listofselectedref = array();
 
   76    $objecttmp = 
new $objectclass($db);
 
   78    foreach ($toselect as $toselectid) {
 
   79      $result = $objecttmp->fetch($toselectid);
 
   81        $attendees = $attendee->fetchAll();
 
   82        if (is_array($attendees) && count($attendees) > 0) {
 
   83          foreach ($attendees as $attmail) {
 
   84            if (!empty($attmail->email)) {
 
   85              $attmail->fetch_thirdparty();
 
   86              $listofselectedid[$attmail->email] = $attmail;
 
   87              $listofselectedref[$attmail->email] = $objecttmp;
 
   96  if (
GETPOST(
'fromtype', 
'alpha') === 
'user' && empty($user->email)) {
 
   99    $massaction = 
'presend_attendees';
 
  102  $receiver = 
GETPOST(
'receiver', 
'alphawithlgt');
 
  103  if (!is_array($receiver)) {
 
  104    if (empty($receiver) || $receiver == 
'-1') {
 
  107      $receiver = array($receiver);
 
  110  if (!trim($_POST[
'sendto']) && count($receiver) == 0 && count($listofselectedid) == 0) {    
 
  112    setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Recipient")), 
null, 
'warnings');
 
  113    $massaction = 
'presend_attendees';
 
  116  if (!
GETPOST(
'subject', 
'restricthtml')) {
 
  118    setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"MailTopic")), 
null, 
'warnings');
 
  119    $massaction = 
'presend_attendees';
 
  123    $objecttmp->fetch_thirdparty();
 
  124    foreach ($listofselectedid as $email => $attendees) {
 
  131      $sendto = $attendees->thirdparty->name . 
'<' . trim($attendees->email) . 
'>';
 
  134      $receivercc = 
GETPOST(
'receivercc', 
'alphawithlgt');
 
  135      if (!is_array($receivercc)) {
 
  136        if ($receivercc == 
'-1') {
 
  137          $receivercc = array();
 
  139          $receivercc = array($receivercc);
 
  143      if (trim($_POST[
'sendtocc'])) {
 
  144        $tmparray[] = trim(
GETPOST(
'sendtocc', 
'alphawithlgt'));
 
  146      $sendtocc = implode(
',', $tmparray);
 
  149      $langs->load(
"commercial");
 
  152      $fromtype = 
GETPOST(
'fromtype');
 
  153      if ($fromtype === 
'user') {
 
  154        $from = $user->getFullName($langs) . 
' <' . $user->email . 
'>';
 
  155      } elseif ($fromtype === 
'company') {
 
  157      } elseif (preg_match(
'/user_aliases_(\d+)/', $fromtype, $reg)) {
 
  158        $tmp = explode(
',', $user->email_aliases);
 
  159        $from = trim($tmp[($reg[1] - 1)]);
 
  160      } elseif (preg_match(
'/global_aliases_(\d+)/', $fromtype, $reg)) {
 
  162        $from = trim($tmp[($reg[1] - 1)]);
 
  163      } elseif (preg_match(
'/senderprofile_(\d+)_(\d+)/', $fromtype, $reg)) {
 
  164        $sql = 
"SELECT rowid, label, email FROM " . MAIN_DB_PREFIX . 
"c_email_senderprofile WHERE rowid = " . (int) $reg[1];
 
  165        $resql = $db->query($sql);
 
  166        $obj = $db->fetch_object($resql);
 
  175      $subject = 
GETPOST(
'subject', 
'restricthtml');
 
  176      $message = 
GETPOST(
'message', 
'restricthtml');
 
  178      $sendtobcc = 
GETPOST(
'sendtoccc', 
'alphawithlgt');
 
  185        $urlwithouturlroot = preg_replace(
'/' . preg_quote(DOL_URL_ROOT, 
'/') . 
'$/i', 
'', trim($dolibarr_main_url_root));
 
  186        $urlwithroot = $urlwithouturlroot . DOL_URL_ROOT;
 
  187        $url_link = $urlwithroot . 
'/public/agenda/agendaexport.php?format=ical' . ($conf->entity > 1 ? 
"&entity=" . $conf->entity : 
"");
 
  188        $url_link .= 
'&exportkey=' . ($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY ? urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY) : 
'...');
 
  189        $url_link .= 
"&project=" . $listofselectedref[$email]->fk_project . 
'&module=' . urlencode(
'@eventorganization') . 
'&status=' . ConferenceOrBooth::STATUS_CONFIRMED;
 
  190        $html_link = 
'<a href="' . $url_link . 
'">' . $langs->trans(
'DownloadICSLink') . 
'</a>';
 
  192      $substitutionarray[
'__EVENTORGANIZATION_ICS_LINK__'] = $html_link;
 
  193      $substitutionarray[
'__EVENTORGANIZATION_URL_LINK__'] = $url_link;
 
  195      $parameters = array(
'mode' => 
'formemail');
 
  197      if (!empty($listofobjectref)) {
 
  198        $parameters[
'listofobjectref'] = $listofobjectref;
 
  207      if (empty($sendcontext)) {
 
  208        $sendcontext = 
'standard';
 
  212      require_once DOL_DOCUMENT_ROOT . 
'/core/class/CMailFile.class.php';
 
  213      $mailfile = 
new CMailFile($subjectreplaced, $sendto, $from, $messagereplaced, array(), array(), array(), $sendtocc, $sendtobcc, $deliveryreceipt, -1, 
'', 
'', 
"attendees_".$attendees->id, 
'', $sendcontext);
 
  214      if ($mailfile->error) {
 
  215        $resaction .= 
'<div class="error">' . $mailfile->error . 
'</div>';
 
  217        $result = $mailfile->sendfile();
 
  219          $resaction .= $langs->trans(
'MailSuccessfulySent', $mailfile->getValidAddress($from, 2), $mailfile->getValidAddress($sendto, 2)) . 
'<br>'; 
 
  222          dol_syslog(
"Try to insert email event into agenda for objid=" . $attendees->id . 
" => objectobj=" . get_class($attendees));
 
  224          $actionmsg = $langs->transnoentities(
'MailSentBy') . 
' ' . $from . 
' ' . $langs->transnoentities(
'To') . 
' ' . $sendto;
 
  227              $actionmsg = 
dol_concatdesc($actionmsg, $langs->transnoentities(
'Bcc') . 
": " . $sendtocc);
 
  229            $actionmsg = 
dol_concatdesc($actionmsg, $langs->transnoentities(
'MailTopic') . 
": " . $subjectreplaced);
 
  230            $actionmsg = 
dol_concatdesc($actionmsg, $langs->transnoentities(
'TextUsedInTheMessageBody') . 
":");
 
  235          $objectobj2 = $listofselectedref[$email];
 
  237          $objectobj2->actionmsg = $actionmsg; 
 
  238          $objectobj2->actionmsg2 = $actionmsg2; 
 
  239          $objectobj2->fk_element = $objectobj2->id;
 
  240          $objectobj2->elementtype = $objectobj2->element;
 
  242          $triggername = 
'CONFERENCEORBOOTHATTENDEE_SENTBYMAIL';
 
  243          if (!empty($triggername)) {
 
  245            $result = $objectobj2->call_trigger($triggername, $user);
 
  253              dol_syslog(
"Error in trigger " . $triggername . 
' ' . $db->lasterror(), LOG_ERR);
 
  259          $langs->load(
"other");
 
  260          if ($mailfile->error) {
 
  261            $resaction .= $langs->trans(
'ErrorFailedToSendMail', $from, $sendto);
 
  262            $resaction .= 
'<br><div class="error">' . $mailfile->error . 
'</div>';
 
  264            $resaction .= 
'<div class="warning">No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS</div>';
 
  266            $resaction .= $langs->trans(
'ErrorFailedToSendMail', $from, $sendto) . 
'<br><div class="error">(unhandled error)</div>';
 
  272  $resaction .= ($resaction ? 
'<br>' : $resaction);
 
  273  $resaction .= 
'<strong>' . $langs->trans(
"ResultOfMailSending") . 
':</strong><br>' . 
"\n";
 
  274  $resaction .= $langs->trans(
"NbSelected") . 
': ' . count($toselect) . 
"\n<br>";
 
  275  $resaction .= $langs->trans(
"NbIgnored") . 
': ' . ($nbignored ? $nbignored : 0) . 
"\n<br>";
 
  276  $resaction .= $langs->trans(
"NbSent") . 
': ' . ($nbsent ? $nbsent : 0) . 
"\n<br>";
 
  281    setEventMessages($langs->trans(
"EMailSentForNElements", $nbsent . 
'/' . count($toselect)), 
null, 
'mesgs');
 
  294$parameters[
'toselect'] = $toselect;
 
  295$parameters[
'uploaddir'] = $uploaddir;
 
  296$parameters[
'massaction'] = $massaction;
 
  297$parameters[
'diroutputmassaction'] = isset($diroutputmassaction) ? $diroutputmassaction : 
null;
 
  299$reshook = $hookmanager->executeHooks(
'doMassActions', $parameters, $object, $action); 
 
Class to send emails (with attachments or not) Usage: $mailfile = new CMailFile($subject,...
 
Class for ConferenceOrBoothAttendee.
 
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
 
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.
 
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
 
getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $object=null, $include=null)
Return array of possible common substitutions.
 
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
 
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.