function send_email() { $vars = array(); $vars['wt_priority'] = isset($_POST['priority']) ? $_POST['priority'] : 5; $vars['wt_created'] = time(); $subject = isset($_POST['subject']) ? trim($_POST['subject']) : ''; $body = isset($_POST['body']) ? trim($_POST['body']) : ''; $country = isset($_POST['country']) ? $_POST['country'] : 'ALL'; $groups = isset($_POST['groups']) ? $_POST['groups'] : 0; $user_handler =& xoops_getModuleHandler('user', 'subscribers'); $wt_handler =& xoops_getModuleHandler('waiting', 'subscribers'); $error = false; if ($groups == 0 || $groups == 2) { $criteria = null; if ($country != 'ALL') { $criteria = new Criteria('user_country', $country); } $objs = $user_handler->getObjects($criteria); unset($criteria); foreach ($objs as $obj) { $waiting = $wt_handler->create(); $vars['wt_toname'] = $obj->getVar('user_name', 'n'); $vars['wt_toemail'] = $obj->getVar('user_email', 'n'); $vars['wt_subject'] = str_replace("{NAME}", $vars['wt_toname'], $subject); $vars['wt_subject'] = str_replace("{EMAIL}", $vars['wt_toemail'], $vars['wt_subject']); $vars['wt_body'] = str_replace("{NAME}", $vars['wt_toname'], $body); $vars['wt_body'] = str_replace("{EMAIL}", $vars['wt_toemail'], $vars['wt_body']); $waiting->setVars($vars); if (!$wt_handler->insert($waiting)) { $error == true; } unset($waiting); } unset($objs); } if ($groups == 1 || $groups == 2) { include_once XOOPS_ROOT_PATH . '/kernel/user.php'; $member_handler = new XoopsUserHandler($GLOBALS['xoopsDB']); $criteria = new Criteria('level', 0, '>'); $members = $member_handler->getAll($criteria, array('uname', 'email'), false, false); //Using this to not exaust server resources unset($criteria); foreach ($members as $member) { $waiting = $wt_handler->create(); $vars['wt_toname'] = $member['uname']; $vars['wt_toemail'] = $member['email']; $vars['wt_subject'] = str_replace("{NAME}", $vars['wt_toname'], $subject); $vars['wt_subject'] = str_replace("{EMAIL}", $vars['wt_toemail'], $vars['wt_subject']); $vars['wt_body'] = str_replace("{NAME}", $vars['wt_toname'], $body); $vars['wt_body'] = str_replace("{EMAIL}", $vars['wt_toemail'], $vars['wt_body']); $waiting->setVars($vars); if (!$wt_handler->insert($waiting)) { $error == true; } unset($waiting); } unset($members); } if ($error) { redirect_header('admin_send.php', 2, _AM_SUBSCRIBERS_SOME_ERROR); exit; } redirect_header('admin_waiting.php', 2, _AM_SUBSCRIBERS_SUCCESS); exit; }
// @todo this used to accept a second criteria, an array of groups. (@$_POST["groups"]) // perhaps use XoopsMemberHandler getUsersByGroupLink()? $total = $user_handler->getCount($criteria); $validsort = array("uname", "email", "last_login", "user_regdate", "posts"); $sort = !in_array($_POST['user_sort'], $validsort) ? "uname" : $_POST['user_sort']; $order = "ASC"; if (isset($_POST['user_order']) && $_POST['user_order'] == "DESC") { $order = "DESC"; } $criteria->setSort($sort); $criteria->setOrder($order); $criteria->setLimit($limit); $criteria->setStart($start); // @todo this used to accept a second criteria, an array of groups. (@$_POST["groups"]) // perhaps use XoopsMemberHandler getUsersByGroupLink()? $foundusers = $user_handler->getAll($criteria); } echo $js_adduser = '******' . (int) $_REQUEST['multiple'] . '; function addusers() { var sel_str = ""; var num = 0; var mForm = document.forms["' . $name_form . '"]; for (var i=0;i!=mForm.elements.length;i++) { var id=mForm.elements[i]; if ( ( (multiple > 0 && id.type == "checkbox") || (multiple == 0 && id.type == "radio") ) && (id.checked == true) && ( id.name == "' . $name_userid . '" ) ) { var name = mForm.elements[++i]; var len = id.value.length + name.value.length; sel_str += len + ":" + id.value + ":" + name.value;