function send_newsletter($send_id) { checkPerm('view'); require_once _base_ . '/lib/lib.json.php'; $json = new Services_JSON(); $path = '/appCore/newsletter/'; //access control $nl_sendpercycle = $GLOBALS["framework"]["nl_sendpercycle"]; //-TP// funAdminAccess('OP'); //@set_time_limit(60*15); // 15 minutes! $out =& $GLOBALS['page']; $out->setWorkingZone("content"); $lang =& DoceboLanguage::createInstance('admin_newsletter', 'framework'); $out->add(getTitleArea($lang->def("_NEWSLETTER"), "newsletter")); $out->add("<div class=\"std_block\">\n"); $info = get_send_info($send_id); $sel_groups = $info["sel_groups"]; $sel_lang = $info["sel_lang"]; $tot = $info["tot"]; $sub = $info["sub"]; $msg = $info["msg"]; $msg = str_replace("{site_base_url}", getSiteBaseUrl(), $msg); $fromemail = $info["fromemail"]; $file_array = $json->decode($info['file']); $attach = array(); foreach ($file_array as $file) { $attach[] = '../files' . $path . $file; } $cycle = (int) $_GET["cycle"]; // Items per cycle $ipc = $nl_sendpercycle; if (($cycle + 1) * $ipc < $tot) { $sendcomplete = 0; } else { $sendcomplete = 1; } $limit = $cycle * $ipc . ", " . $ipc; $arr_st = getSendToIdst($send_id, $limit); $acl_manager = Docebo::user()->getAclManager(); if (!empty($sel_lang) && $sel_lang != _ANY_LANG_CODE) { $user_info = $acl_manager->getUsersByLanguage($sel_lang, $arr_st); } else { // Send to all languages $user_info = $acl_manager->getUsers($arr_st); } $send_type = $info["send_type"]; switch ($send_type) { case "email": $tempemail = array(); foreach ($user_info as $info) { // collect recipients email addresses: ------------------------------ $email = $info[ACL_INFO_EMAIL]; if ($email != "") { $tempemail[] = $email; } // ---------------------------------------------- } //send all mails require_once _base_ . '/lib/lib.mailer.php'; $mailer = DoceboMailer::getInstance(); if (count($attach)) { $mailer->SendMail($fromemail, $tempemail, $sub, $msg, $attach, array(MAIL_REPLYTO => $fromemail, MAIL_SENDER_ACLNAME => false)); } else { $mailer->SendMail($fromemail, $tempemail, $sub, $msg, false, array(MAIL_REPLYTO => $fromemail, MAIL_SENDER_ACLNAME => false)); } break; case "sms": // Collect users sms numbers require_once $GLOBALS["where_framework"] . "/lib/lib.field.php"; $acl_man =& Docebo::user()->getACLManager(); $field_man = new FieldList(); $arr_sms_recipients = array(); $send_to_field = Get::sett('sms_cell_num_field'); $users_sms = $field_man->showFieldForUserArr($arr_st, array($send_to_field)); $users_info = $acl_man->getUsers($arr_st); while (list(, $user_dett) = each($users_info)) { // recover media setting $idst_user = $user_dett[ACL_INFO_IDST]; if ($users_sms[$idst_user][$send_to_field] != '') { $arr_sms_recipients[$idst_user] = $users_sms[$idst_user][$send_to_field]; } } require_once $GLOBALS["where_framework"] . "/lib/lib.sms.php"; $sms_manager = new SmsManager(); $sms_manager->sendSms($msg, $arr_sms_recipients); break; } if ($sendcomplete) { require_once _base_ . '/lib/lib.upload.php'; if (count($attach)) { foreach ($attach as $file) { sl_open_fileoperations(); sl_unlink(str_replace('../files', '', $file)); sl_close_fileoperations(); } } $url = "index.php?modname=public_newsletter_admin&op=complete"; Util::jump_to($url); } else { $url = "index.php?modname=public_newsletter_admin&op=pause&ipc=" . $ipc . "&cycle=" . ($cycle + 1) . "&id_send=" . $send_id; Util::jump_to($url); } $out->add("</div><br />\n"); $out->add("<form action=\"index.php?modname=public_newsletter_admin&op=newsletter\" method=\"post\">\n"); $out->add("<div class=\"std_block\">\n" . '<input type="hidden" id="authentic_request_pubr" name="authentic_request" value="' . Util::getSignature() . '" />'); $out->add("<input class=\"button\" type=\"submit\" value=\"" . $lang->def("_BACK") . "\" />\n"); $out->add("</div>\n"); $out->add("</form>\n"); }
function _sendSms($body, &$sms_recipients, &$users_info = false) { // in the future, if we'll have more than one gateway, smsmarket // will became a class that will include all the smsmarket's methods // and we will just load the class and call $obj->sendsms(..) /* switch(Get::sett('sms_gateway')) { case "smsmarket": { $this->_smsmarket_Send(strip_tags($body), $sms_recipients); } break; } */ require_once _adm_ . '/lib/lib.sms.php'; $sms_manager = new SmsManager(); $sms_manager->sendSms(strip_tags($body), $sms_recipients); }