25 include_once __DIR__ .
'/header.php';
31 $op = Request::getString(
'op',
'list');
35 $xoops->header(
'admin:mailusers/mailusers_send_mail.tpl');
37 $xoops->theme()->addBaseStylesheetAssets(
'modules/system/css/admin.css');
38 $xoops->theme()->addBaseScriptAssets(array(
'@jquery',
'media/xoops/xoops.js',
'modules/system/js/admin.js'));
47 $display_criteria = 1;
53 for (
$i = 0;
$i < $user_count; ++
$i) {
55 $form->addElement($uid_hidden);
60 $form->addElement($users_label);
61 $form->addElement($users_label);
62 $display_criteria = 0;
65 if (!empty($display_criteria)) {
66 $selected_groups = array();
70 $lastlog_min->setValue(
'');
72 $lastlog_max->setValue(
'');
75 $date->addElement($lastlog_min);
76 $date->addElement($lastlog_max);
82 $idle->addElement($idle_more);
83 $idle->addElement($idle_less);
86 $regd_min->setValue(
'');
88 $regd_max->setValue(
'');
98 $inactive_cbox->setExtra(
"onclick='javascript:disableElement(\"mail_lastlog_min\");disableElement(\"mail_lastlog_max\");disableElement(\"mail_idle_more\");disableElement(\"mail_idle_less\");disableElement(\"mail_to_group[]\");'");
102 $criteria_tray->addElement($group_select);
104 $criteria_tray->addElement($date);
106 $criteria_tray->addElement($idle);
108 $criteria_tray->addElement(
$regdate);
110 $criteria_tray->addElement($mailok_cbox);
111 $criteria_tray->addElement($inactive_cbox);
114 $form->addElement($criteria_tray);
117 $fromemail =
$xoops->getConfig(
'from') ?
$xoops->getConfig(
'from') :
$xoops->user->getVar(
"email",
"E");
120 $subject_text =
new Xoops\Form\Text($subject_caption,
"mail_subject", 50, 255);
122 $editor_configs = array();
123 $editor_configs[
"name"] =
"mail_body";
124 $editor_configs[
"value"] =
'';
125 $editor_configs[
"rows"] = 20;
126 $editor_configs[
"cols"] = 100;
127 $editor_configs[
"width"] =
"100%";
128 $editor_configs[
"height"] =
"400px";
129 $editor_configs[
"editor"] =
$xoops->getModuleConfig(
'mailusers_editor');
139 $form->addElement($fname_text);
140 $form->addElement($femail_text);
141 $form->addElement($subject_text);
142 $form->addElement($body_text);
143 $form->addElement($to_checkbox);
144 $form->addElement($op_hidden);
145 $form->addElement($start_hidden);
146 $form->addElement($submit_button);
147 $form->setRequired($subject_text);
148 $form->setRequired($body_text);
155 $mail_send_to = Request::getArray(
'mail_send_to', array(
'mail'));
156 $mail_inactive = Request::getInt(
'mail_inactive', 0);
157 $mail_mailok = Request::getInt(
'mail_mailok', 0);
158 $mail_lastlog_min = Request::getString(
'mail_lastlog_min',
'');
159 $mail_lastlog_max = Request::getString(
'mail_lastlog_max',
'');
160 $mail_idle_more = Request::getInt(
'mail_idle_more', 0);
161 $mail_idle_less = Request::getInt(
'mail_idle_less', 0);
162 $mail_regd_min = Request::getString(
'mail_regd_min',
'');
163 $mail_regd_max = Request::getString(
'mail_regd_max',
'');
164 $mail_to_group = Request::getArray(
'mail_to_group', array());
165 $mail_to_group = array_map(
"intval", $mail_to_group);
166 $mail_start = Request::getInt(
'mail_start', 0);
167 $mail_to_user = Request::getArray(
'mail_to_user', array());
168 $mail_to_user = array_map(
"intval", $mail_to_user);
170 $mail_fromname = Request::getString(
'mail_fromname');
171 $mail_fromemail = Request::getString(
'mail_fromemail');
172 $mail_subject = Request::getString(
'mail_subject');
173 $mail_body = Request::getString(
'mail_body');
176 if (!empty($mail_send_to)) {
180 if ($mail_inactive) {
186 if ($mail_lastlog_min) {
187 $time = strtotime(trim($mail_lastlog_min));
192 if ($mail_lastlog_max) {
193 $time = strtotime(trim($mail_lastlog_max));
198 if ($mail_idle_more) {
199 $time = 60 * 60 * 24 * $mail_idle_more;
200 $time = time() - $time;
205 if ($mail_idle_less) {
206 $time = 60 * 60 * 24 * $mail_idle_less;
207 $time = time() - $time;
213 if ($mail_regd_min) {
214 $time = strtotime(trim($mail_regd_min));
219 if ($mail_regd_max) {
220 $time = strtotime(trim($mail_regd_max));
226 if (!empty(
$criteria) || !empty($mail_to_group)) {
228 $criteria_object->setStart($mail_start);
229 $criteria_object->setLimit(
$limit);
231 list ($field,
$op, $value) = explode(
' ', $c);
234 $criteria_object->add($crit,
'AND');
237 $getusers =
$member_handler->getUsersByGroupLink($mail_to_group, $criteria_object,
true);
238 $count_criteria =
$member_handler->getUserCountByGroupLink($mail_to_group, $criteria_object);
241 if (!in_array($getuser->getVar(
"uid"), $added_id)) {
243 $added_id[] = $getuser->getVar(
"uid");
248 foreach ($mail_to_user as $to_user) {
249 if (!in_array($to_user, $added_id)) {
251 $added_id[] = $to_user;
254 $added_count = count($added);
257 if ($added_count > 0) {
259 $xoopsMailer =
$xoops->getMailer();
260 for (
$i = 0;
$i < $added_count; ++
$i) {
261 $xoopsMailer->setToUsers($added[
$i]);
263 $xoopsMailer->setFromName($mail_fromname);
264 $xoopsMailer->setFromEmail($mail_fromemail);
265 $xoopsMailer->setSubject($mail_subject);
266 $xoopsMailer->setBody($mail_body);
267 if (in_array(
"mail", $mail_send_to)) {
268 $xoopsMailer->useMail();
270 if (in_array(
"pm", $mail_send_to) && !$mail_inactive) {
271 $xoopsMailer->usePM();
273 $xoopsMailer->send(
true);
274 $xoops->tpl()->assign(
'sucess', $xoopsMailer->getSuccess());
275 $xoops->tpl()->assign(
'errors', $xoopsMailer->getErrors());
277 if ($count_criteria >
$limit) {
280 foreach ($mail_to_group as $mailgroup) {
282 $form->addElement($group_hidden);
285 $lastlog_min_hidden =
new Xoops\Form\Hidden(
"mail_lastlog_min",
$myts->htmlSpecialChars($mail_lastlog_min));
286 $lastlog_max_hidden =
new Xoops\Form\Hidden(
"mail_lastlog_max",
$myts->htmlSpecialChars($mail_lastlog_max));
300 $form->addElement($sent_label);
301 $form->addElement($inactive_hidden);
302 $form->addElement($lastlog_min_hidden);
303 $form->addElement($lastlog_max_hidden);
304 $form->addElement($regd_min_hidden);
305 $form->addElement($regd_max_hidden);
306 $form->addElement($idle_more_hidden);
307 $form->addElement($idle_less_hidden);
308 $form->addElement($fname_hidden);
309 $form->addElement($femail_hidden);
310 $form->addElement($subject_hidden);
311 $form->addElement($body_hidden);
312 $form->addElement($op_hidden);
313 $form->addElement($start_hidden);
314 $form->addElement($mail_mailok_hidden);
315 foreach ($mail_send_to as $v) {
316 $form->addElement(
new Xoops\Form\Hidden(
"mail_send_to[]", $v));
318 $form->addElement($submit_button);
const _AM_MAILUSERS_SENDCOMP
const _AM_MAILUSERS_EMAIL
const _AM_MAILUSERS_LASTLOGMIN
if($uname== ''||$pass== '') $member_handler
const _AM_MAILUSERS_IDLELESS
const _AM_MAILUSERS_MAILTAGS3
const _AM_MAILUSERS_REGDMAX
const _AM_MAILUSERS_MAILFMAIL
const _AM_MAILUSERS_SENDTOUSERS
const _AM_MAILUSERS_MAILTAGS1
const _AM_MAILUSERS_GROUPIS
const _AM_MAILUSERS_REGDATE
const _AM_MAILUSERS_REGDMIN
const _AM_MAILUSERS_OPTIONAL
const _AM_MAILUSERS_MAILTAGS4
const _AM_MAILUSERS_SENDTO
const _AM_MAILUSERS_MAILSUBJECT
static getUnameFromId($userid, $usereal=0)
const _AM_MAILUSERS_SENDTOUSERS2
const _AM_MAILUSERS_SENTNUM
const _AM_MAILUSERS_MAILTAGS2
const _AM_MAILUSERS_IDLEMORE
const _AM_MAILUSERS_SENDNEXT
const _AM_MAILUSERS_NOUSERMATCH
const _AM_MAILUSERS_MAILFNAME
const _AM_MAILUSERS_MAILTAGS
const _AM_MAILUSERS_LASTLOGMAX
const _AM_MAILUSERS_INACTIVE
const _AM_MAILUSERS_MAILOK
const _AM_MAILUSERS_MAILBODY