/** * Send a notification message to the user * * @param string $template_dir Template directory * @param string $template Template name * @param string $subject Subject line for notification message * @param array $tags Array of substitutions for template variables * * @return bool true if success, false if error **/ public function notifyUser($template_dir, $template, $subject, $tags) { global $icmsConfigMailer; // Check the user's notification preference. $member_handler = icms::handler('icms_member'); $user =& $member_handler->getUser($this->getVar('not_uid')); if (!is_object($user)) { return true; } $method = $user->getVar('notify_method'); $xoopsMailer = new icms_messaging_Handler(); include_once ICMS_ROOT_PATH . '/include/notification_constants.php'; switch ($method) { case XOOPS_NOTIFICATION_METHOD_PM: $xoopsMailer->usePM(); $xoopsMailer->setFromUser($member_handler->getUser($icmsConfigMailer['fromuid'])); foreach ($tags as $k => $v) { $xoopsMailer->assign($k, $v); } break; case XOOPS_NOTIFICATION_METHOD_EMAIL: $xoopsMailer->useMail(); foreach ($tags as $k => $v) { $xoopsMailer->assign($k, preg_replace("/&/i", '&', $v)); } break; default: return true; // report error in user's profile?? break; } // Set up the mailer $xoopsMailer->setTemplateDir($template_dir); $xoopsMailer->setTemplate($template); $xoopsMailer->setToUsers($user); //global $icmsConfig; //$xoopsMailer->setFromEmail($icmsConfig['adminmail']); //$xoopsMailer->setFromName($icmsConfig['sitename']); $xoopsMailer->setSubject($subject); $success = $xoopsMailer->send(); // If send-once-then-delete, delete notification // If send-once-then-wait, disable notification include_once ICMS_ROOT_PATH . '/include/notification_constants.php'; $notification_handler = icms::handler('icms_data_notification'); if ($this->getVar('not_mode') == XOOPS_NOTIFICATION_MODE_SENDONCETHENDELETE) { $notification_handler->delete($this); return $success; } if ($this->getVar('not_mode') == XOOPS_NOTIFICATION_MODE_SENDONCETHENWAIT) { $this->setVar('not_mode', XOOPS_NOTIFICATION_MODE_WAITFORLOGIN); $notification_handler->insert($this); } return $success; }
echo '<div class="CPbigTitle" style="background-image: url('. ICMS_MODULES_URL . '/system/admin/mailusers/images/mailusers_big.png)">' . _MD_AM_MLUS . '</div><br />'; if ($added_count > 0) { $xoopsMailer = new icms_messaging_Handler(); for ($i = 0; $i < $added_count; $i++) { $xoopsMailer->setToUsers($added[$i]); } $xoopsMailer->setFromName(icms_core_DataFilter::stripSlashesGPC($_POST['mail_fromname'])); $xoopsMailer->setFromEmail(icms_core_DataFilter::stripSlashesGPC($_POST['mail_fromemail'])); $xoopsMailer->setSubject(icms_core_DataFilter::stripSlashesGPC($_POST['mail_subject'])); $xoopsMailer->setBody(icms_core_DataFilter::stripSlashesGPC($_POST['mail_body'])); if (in_array("mail", $_POST['mail_send_to'])) { $xoopsMailer->useMail(); } if (in_array("pm", $_POST['mail_send_to']) && empty($_POST['mail_inactive'])) { $xoopsMailer->usePM(); } $xoopsMailer->send(TRUE); echo $xoopsMailer->getSuccess(); echo $xoopsMailer->getErrors(); if ($count_criteria > $limit) { $form = new icms_form_Theme(_AM_SENDMTOUSERS, "mailusers", "admin.php?fct=mailusers", 'post', TRUE); if (!empty($_POST['mail_to_group'])) { foreach ($_POST['mail_to_group'] as $mailgroup) { $group_hidden = new icms_form_elements_Hidden("mail_to_group[]", $mailgroup); $form->addElement($group_hidden); } } $inactive_hidden = new icms_form_elements_Hidden("mail_inactive", @$_POST['mail_inactive']);