예제 #1
0
 public function handle()
 {
     // Prepare our reply message
     $message = new Application_Model_Message();
     $bodytext = $this->_getActionKeywordReplyText('help');
     $message->send($bodytext, array($this->_inbound->device_address));
 }
예제 #2
0
 public function linkAction()
 {
     $this->_helper->layout->setLayout('formlayout');
     $formObj = new Application_Model_Form();
     $error = array();
     $success = array();
     $this->request->getParam('url');
     $clubreadyid = 0;
     $urlWithUserId = strrev($this->request->getParam('url'));
     $breakUrlInParts = explode('txet', $urlWithUserId, 2);
     $userid = strrev($breakUrlInParts[0]);
     $formurl = strrev($breakUrlInParts[1]);
     $isClubready = FALSE;
     $user = new Application_Model_User((int) $userid);
     if ($user->additionalinfo == "CR") {
         $clubreadyid = $user->accountstatus;
         $isClubready = TRUE;
     }
     $webformattb = $formObj->webformDetail($userid, addslashes($formurl));
     if (empty($webformattb)) {
         $message['type'] = "error";
         $message['body'] = "Form doesn't exist";
     } else {
         $this->view->webformattb = $webformattb;
     }
     if ($this->request->isPost()) {
         $postdataValue = $this->_request->getParams();
         //echo '<pre>'; print_r($postdataValue);exit;
         //echo "<pre>"; print_r($this->_request->getParams());
         $webform_url_id = $webformattb['0']['webform_url_id'];
         $collectAttributesOnTheBasisOfDropdownAndCheckboxValues = $formObj->collectAttributesOnTheBasisOfDropdownAndCheckboxValues($webform_url_id);
         //          echo "<pre>";  print_r($collectAttributesOnTheBasisOfDropdownAndCheckboxValues);
         //          echo $webform_url_id;
         //          exit;
         $phonenumber = $postdataValue[0];
         $firstname = "";
         $lastname = "";
         $email = "";
         $birthday = "";
         $language = "";
         $attr_folder_ids_array = array();
         if (!empty($collectAttributesOnTheBasisOfDropdownAndCheckboxValues)) {
             foreach ($collectAttributesOnTheBasisOfDropdownAndCheckboxValues as $key => $value) {
                 foreach ($value as $k => $val) {
                     $folderid_attr = $postdataValue[$val];
                     //echo '<pre>'; print_r($folderid_attr);
                     if (is_array($folderid_attr)) {
                         foreach ($folderid_attr as $key => $v) {
                             $folder_id_individual = $v;
                             array_push($attr_folder_ids_array, $folder_id_individual);
                         }
                     } else {
                         $folder_id_individual = $folderid_attr;
                         array_push($attr_folder_ids_array, $folder_id_individual);
                     }
                 }
             }
         }
         $newfolderarray = substr($webformattb['0']['folderid'], 0, 1);
         if ($newfolderarray == ',') {
             $webformattb['0']['folderid'] = substr($webformattb['0']['folderid'], 1);
         }
         $folderidArraySelectedFolder = explode(",", $webformattb['0']['folderid']);
         $folderidArray = array_unique(array_merge($folderidArraySelectedFolder, $attr_folder_ids_array));
         //echo '<pre>'; print_r($folderidArray);
         unset($postdataValue['controller'], $postdataValue['action'], $postdataValue['url'], $postdataValue['module'], $postdataValue['accept']);
         $this->view->postedValues = $postdataValue;
         if ($this->request->getParam('accept') == 1) {
             if (!empty($postdataValue[0])) {
                 $phonenumber = $formObj->cleanPhone($phonenumber);
                 // echo $phonenumber; exit;
                 if (strlen($phonenumber) == 10) {
                     $phonenumber = "1" . $phonenumber;
                     unset($postdataValue['0']);
                     foreach ($postdataValue as $attbid => $attbvalue) {
                         $attbnameArray = $formObj->getAttributeName($attbid);
                         $attbnam = $attbnameArray['0']['attribute'];
                         if ($attbnam == "Email") {
                             $email = addslashes($postdataValue[$attbid]);
                             unset($postdataValue[$attbid]);
                         } elseif ($attbnam == "First Name") {
                             $firstname = addslashes($postdataValue[$attbid]);
                             unset($postdataValue[$attbid]);
                         } elseif ($attbnam == "Last Name") {
                             $lastname = addslashes($postdataValue[$attbid]);
                             unset($postdataValue[$attbid]);
                         } elseif ($attbnam == "Birthday") {
                             $attbvalue = implode("-", $postdataValue[$attbid]);
                             $birthday = $attbvalue;
                             unset($postdataValue[$attbid]);
                         } elseif ($attbnam == "Language") {
                             $language = addslashes($postdataValue[$attbid]);
                             unset($postdataValue[$attbid]);
                         }
                     }
                     $subs_array = array();
                     $a = 0;
                     $attbidArray = array();
                     $status_flag = '';
                     $b_ifnewsubscriber = TRUE;
                     $subscriberintheaccount = FALSE;
                     $tmp_alternate = "";
                     foreach ($folderidArray as $folderid) {
                         if ($formObj->checksubscriber($phonenumber, $folderid) && $formObj->checksubscriber($phonenumber, $folderid) != '') {
                             //update
                             $subscriberid = $formObj->checksubscriber($phonenumber, $folderid);
                             $status_flag = 1;
                             $formObj->updateSubscriberAllDetails($subscriberid, $folderid, $phonenumber, $firstname, $lastname, $email, $birthday, $language, $webform_url_id);
                             $tmp_alternate = "Thank you for checking in with us again, we see you have redeemed this offer already. Please stay tuned for other VIP deals and promotions.";
                             array_push($subs_array, $subscriberid);
                         } else {
                             //insert
                             $info_msg = $webformattb[0]['alertmessage'];
                             $subscriberid = $formObj->addSubscriberAllDetails($folderid, $phonenumber, $firstname, $lastname, $email, $birthday, $language, $webform_url_id);
                             if ($isClubready) {
                                 $dobformat = date('Y-') . $birthday;
                                 $bool = false;
                                 $formObj->postLeadsClubready($firstname, $lastname, $phonenumber, $dobformat, $email, $clubreadyid, $bool);
                             }
                             /* here the new subcriber or opted out gets second info sms */
                             array_push($subs_array, $subscriberid);
                             $tmp_alternate = $webformattb['0']['thankumsg'];
                             $b_ifnewsubscriber = FALSE;
                             if ($formObj->getStatusOfSubscriberFromUserAccount($phonenumber, $userid)) {
                                 $subscriberintheaccount = TRUE;
                             }
                         }
                     }
                     foreach ($postdataValue as $attbid => $attbvalue) {
                         if (is_array($attbvalue)) {
                             $attbvalueins[$a] = implode(",", $attbvalue);
                             $attbvalueins[$a] = addslashes($attbvalueins[$a]);
                             $attbidArray[$a] = $attbid;
                             $a++;
                         } else {
                             $attbvalueins[$a] = addslashes($attbvalue);
                             $attbidArray[$a] = $attbid;
                             $a++;
                         }
                     }
                     $sendtime = date('Y-m-d H:i:s');
                     for ($i = 0; $i < count($subs_array); $i++) {
                         for ($j = 0; $j < $a; $j++) {
                             if ($status_flag == 1) {
                                 //update values
                                 $formObj->updateFormValues($subs_array[$i], $attbidArray[$j], $attbvalueins[$j]);
                             } else {
                                 $formObj->insertFormValues($subs_array[$i], $attbidArray[$j], $attbvalueins[$j]);
                             }
                         }
                     }
                     $success[0] = $webformattb['0']['thankumsg'];
                     // the code
                     $msgObj = new Application_Model_Message();
                     $timezone = null;
                     $source = 202;
                     //queue($body, $recipients, $sendtime = null, $timezone = null, $confirmid = 0, $depth = 0, $createuser = 0, $shortcode=87365)
                     $status = $msgObj->queue($tmp_alternate, $phonenumber, $sendtime, $timezone, 0, $source, $userid);
                     if (!$b_ifnewsubscriber && !$subscriberintheaccount) {
                         $msgObj->queue($info_msg, $phonenumber, $sendtime, $timezone, 0, $source, $userid);
                         if ($webformattb['0']['notifybyemail']) {
                             $confirm = "A new subscriber optin through webform  on {$sendtime}:" . PHP_EOL . "First: " . $firstname . PHP_EOL . 'Last: ' . $lastname . PHP_EOL . "Phone: " . $phonenumber . PHP_EOL . "Email: " . $email;
                             $subject = "Lead notification";
                             $formObj->alertnewlead($webformattb['0']['notifybyemail'], $subject, $confirm);
                         }
                         if ($webformattb['0']['notifybysms']) {
                             if (strlen($webformattb['0']['notifybysms']) < 11) {
                                 $phone = "1" . $webformattb['0']['notifybysms'];
                             } else {
                                 $phone = $webformattb['0']['notifybysms'];
                             }
                             $confirm = "A new lead optin {$sendtime}" . PHP_EOL . "First: " . $firstname . PHP_EOL . 'Last: ' . $lastname . PHP_EOL . "Phone: " . $phonenumber . PHP_EOL . "Email: " . $email;
                             $formObj->alertMessage($phone, $confirm);
                         }
                     }
                 } else {
                     $error[1] = "Please enter 10 digit Phone number.";
                 }
             } else {
                 $error[2] = "Phone number is required.";
             }
         } else {
             $error[3] = "Please accept the terms & conditions";
         }
     }
     $this->view->success = $success;
     $this->view->error = $error;
 }
 public function badnumbersAction()
 {
     if ($this->request->isPost()) {
         $rep = new Application_Model_Report();
         $usrfolders = $this->request->getParam('folders');
         $folders = explode(',', $usrfolders);
         $totalfolders = count($folders);
         $totalsubscribers = array();
         for ($sbr = 0; $sbr < $totalfolders; $sbr++) {
             //                     $folder = new Application_Model_Folder($this->user, $folders[$sbr]);
             $msg = new Application_Model_Message();
             $subscribers = $msg->subscribersByFolderid($folders[$sbr]);
             foreach ($subscribers as $usr_fid => $v) {
                 $totalsubscribers[$v['phonenumber']] = $v['phonenumber'];
             }
         }
         $res = $rep->getBadNumbers($this->user->getId(), $totalsubscribers);
     }
     if ($res) {
         echo $res;
     } else {
         echo "Nothing is selected";
     }
     exit;
 }
예제 #4
0
// Get our config file
$config = new Zend_Config_Ini($apppath . '/application/configs/application.ini');
Zend_Registry::set('config', $config->production);
// Because our models need it this way
// Get the messages model
// Set up our current timestamp
$timestamp = date('Y-m-d H:i:s');
// Log the start of this read
logWrite("####################################");
logWrite("Begin batch send: {$timestamp}");
logWrite("------------------------------------");
// Get the queue and counts
// Log our counts
logWrite("Scheduled campaign");
//logWrite("")
$msg = new Application_Model_Message();
$arr = $msg->scheduledCampaignsSend();
$msg->weeklycampDirectSend($arr);
logWrite("\n---------------------");
logWrite("Scheduled: {$timestamp}");
logWrite("####################################\n");
return 0;
/**
 * Simply writes a log message line to the log file
 * 
 * @param string $msg The message to write
 */
function logWrite($msg)
{
    global $logfile;
    $fh = fopen($logfile, 'a');
 /**
  * Created a sendMessage method that will do everything the post controller would
  * because we have a user who wants to send a message via GET and our API does this
  * via POST. I tried using _forward('post'), but it was doubling up the JSON response
  * body for some reason. So now post and get just call this method to do the same thing.
  * 
  * @access private
  */
 private function sendMessage()
 {
     $valid = true;
     echo $recipients = $this->_requestParam('recipients');
     exit;
     $subjecttext = $this->_requestParam('subject');
     $bodytext = $this->_requestParam('message');
     $sendtime = $this->_requestParam('sendtime');
     $timezone = $this->_requestParam('timezone');
     // Cleanup send time
     if ($sendtime) {
         $tparts = str_split($sendtime, 2);
         $sendtime = $tparts[0] . $tparts[1] . '-' . $tparts[2] . '-' . $tparts[3] . ' ' . $tparts[4] . ':' . $tparts[5] . ':00';
     }
     // Not using this at the moment, so don't want anyone to access it
     //$folder = $this->_request->getParam('id');
     //$loadby = $this->_request->getParam('field');
     $folder = false;
     $loadby = false;
     // Folder is optional (at the moment...)
     if ($folder) {
         $folder = new Application_Model_Folder($this->apiuser, $folder, $loadby);
         if ($folder->isValid()) {
             // Get subscribers in this folder
             $subscribers = $folder->getSubscribers();
             // TODO: Come up with a better way to pull phone #'s out of a folder's subscriber list
             foreach ($subscribers as $subscriber) {
                 $recipients[] = $subscriber['phonenumber'];
             }
         } else {
             $valid = false;
             $this->setError($folder->getError(), 500);
         }
     }
     // Validate and send
     if ($valid) {
         if ($recipients) {
             if ($bodytext) {
                 $message = new Application_Model_Message($this->apiuser);
                 $bodytext = urldecode($bodytext);
                 $subjecttext = urldecode($subjecttext);
                 // Build the message with a subject if there is one.
                 $msg = $subjecttext ? $subjecttext . ': ' . $bodytext : $bodytext;
                 // Queue it up for delivery
                 $return = $message->queue($msg, $recipients, $sendtime, $timezone);
                 if ($return) {
                     $this->setOutputParam('status', true);
                     $this->setOutputParam('message', 'Message successfully sent.');
                 } else {
                     $this->setError($message->getError(), 500);
                 }
             } else {
                 $this->setError('Message is required.', 500);
             }
         } else {
             $this->setError('At least one recipient is required.', 500);
         }
     }
 }
예제 #6
0
 public function deleteMessageAction()
 {
     $id = $this->_getParam('id');
     $usersNs = new Zend_Session_Namespace("members");
     $this->view->config_id = $id;
     $model1 = new Application_Model_Message();
     $model = $model1->find($id);
     if (false === $model) {
         $this->_flashMessenger->addMessage(array('error' => 'Invalid request! Please try again.'));
         $this->_helper->_redirector->gotoUrl($this->view->seoUrl('/admin/log/messages'));
     }
     if ($model->delete("message_id={$id}")) {
         $this->_flashMessenger->addMessage(array('success' => 'Data Deleted succesfully'));
         $this->_helper->_redirector->gotoUrl($this->view->seoUrl('/admin/log/messages'));
     } else {
         $this->_flashMessenger->addMessage(array('error' => 'Failed to Delete the data '));
         $this->_helper->_redirector->gotoUrl($this->view->seoUrl('/admin/log/messages'));
     }
 }
 public function messagesAction()
 {
     $username = $this->_getParam('username');
     $user = $this->getLeftPanel($username);
     //Redirect user if not active, added by Mahipal Adhikari on 3-jan-2011
     $userM = new Application_Model_User();
     if (false === $userM->checkUserActiveStatus($user->getId())) {
         $this->_helper->redirector('index', 'index');
     }
     //diaply username on left panel of user profile page
     $this->view->userObject = $user;
     $userNs = new Zend_Session_Namespace('members');
     $form = new Application_Form_CreateMessages();
     if ($userNs->userId) {
         $form->getElement('toEmail')->setValue($user->getFirstName() . ' ' . $user->getLastName());
         $form->getElement('toId')->setValue($user->getId());
     }
     $this->view->form = $form;
     if ($this->getRequest()->isPost()) {
         $params = $this->getRequest()->getPost();
         if ($form->isValid($params)) {
             $params['status'] = 'inbox';
             //$params['fromId']	=	$userId;
             $params['fromId'] = $userNs->userId;
             $params['parentId'] = 0;
             $messages = new Application_Model_Message($params);
             $savemsg = $messages->save();
             if ($savemsg) {
                 /*------------------------- NOTIFICATION EMAIL ---------------------------*/
                 $userObj = new Application_Model_User();
                 $valTo = $userObj->find($params['toId']);
                 $toFirstName = $valTo->getFirstName();
                 $toLastName = $valTo->getLastName();
                 $option['toName'] = $toFirstName . ' ' . $toLastName;
                 $option['toEmail'] = trim($valTo->getEmail());
                 $option['message'] = $params['body'];
                 $option['messageId'] = $savemsg;
                 $valfrom = $userObj->find($userNs->userId);
                 $option['fromName'] = $valfrom->getFirstName() . ' ' . $valfrom->getLastName();
                 $mail = new Base_Mail();
                 $mail->sendNotificationMail("message_notification", $option);
                 $_SESSION["flash_msg"] = "Message has been sent.";
                 $form->reset();
             } else {
                 $_SESSION["flash_msg"] = "Error occured while sending message, please try again later.";
             }
             //redirect user
             $this->_redirect($this->view->seoUrl('/profile/messages/username/' . $username));
         }
         $this->view->form = $form;
     }
 }
예제 #8
0
 public function sentMessageDetailAction()
 {
     $id = $this->_getParam('id');
     $id = base64_decode($id);
     $modelMessages = new Application_Model_Message();
     $valMessage = $modelMessages->find($id);
     $this->view->body = nl2br(stripslashes($valMessage->getBody()));
     $this->view->subject = $valMessage->getSubject();
     $this->view->addedon = date("dS M Y", $valMessage->getAddedDate());
     $this->_helper->viewRenderer('message-detail');
 }
예제 #9
0
if (!file_exists($logfile)) {
    touch($logfile);
}
// Get the Zend Framework loader setup
require_once 'Zend/Loader/Autoloader.php';
$autoloader = Zend_Loader_Autoloader::getInstance();
// Setup routing of model autoloaders
$loader = new Zend_Loader_Autoloader_Resource(array('basePath' => $apppath . '/application/', 'namespace' => 'Application'));
// Name, path, namepsace
$loader->addResourceType('model', 'models', 'Model');
// Get our config file
$config = new Zend_Config_Ini($apppath . '/application/configs/application.ini');
Zend_Registry::set('config', $config->production);
// Because our models need it this way
// Get the messages model
$message = new Application_Model_Message();
// Set up our current timestamp
$timestamp = date('Y-m-d H:i:s');
// Log the start of this read
logWrite("####################################");
logWrite("Begin batch send: {$timestamp}");
logWrite("------------------------------------");
// Get the queue and counts
$queue = $message->getQueue();
$queueCount = count($queue);
$sendCount = 0;
// Log our counts
logWrite("Message Queue Count: {$queueCount}\nBegin send loop:");
//logWrite("")
if (is_array($queue)) {
    if (!empty($queue)) {
예제 #10
0
$config = new Zend_Config_Ini($apppath . '/application/configs/application.ini');
Zend_Registry::set('config', $config->production);
// Because our models need it this way
// Get the messages model
// Set up our current timestamp
$timestamp = date('Y-m-d H:i:s');
$weekdays = array('Sun' => 'sunday', 'Mon' => 'monday', 'Tue' => 'tuesday', 'Wed' => 'wednesday', 'Thu' => 'thursday', 'Fri' => 'friday', 'Sat' => 'saterday');
// Log the start of this read
logWrite("####################################");
logWrite("Begin batch send: {$timestamp}");
logWrite("------------------------------------");
// Get the queue and counts
// Log our counts
logWrite("Reoccurring");
//logWrite("")
$msg = new Application_Model_Message();
$arr = $msg->selectWeeklyCampaignSend();
$msg->weeklycampToqueue($arr);
$week = $msg->getWeeks(date('Y-m-d'), $weekdays[date('D')]);
$arr = $msg->selectMonthlCampaignSend((int) ($week + 1));
$msg->weeklycampToqueue($arr);
logWrite("\n---------------------");
logWrite("Reoccuring: {$timestamp}");
logWrite("####################################\n");
return 0;
/**
 * Simply writes a log message line to the log file
 * 
 * @param string $msg The message to write
 */
function logWrite($msg)
예제 #11
0
if (!file_exists($logfile)) {
    touch($logfile);
}
// Get the Zend Framework loader setup
require_once 'Zend/Loader/Autoloader.php';
$autoloader = Zend_Loader_Autoloader::getInstance();
// Setup routing of model autoloaders
$loader = new Zend_Loader_Autoloader_Resource(array('basePath' => $apppath . '/application/', 'namespace' => 'Application'));
// Name, path, namepsace
$loader->addResourceType('model', 'models', 'Model');
// Get our config file
$config = new Zend_Config_Ini($apppath . '/application/configs/application.ini');
Zend_Registry::set('config', $config->production);
// Because our models need it this way
// Get the messages model
$message = new Application_Model_Message();
// Set up our current timestamp
$timestamp = date('Y-m-d H:i:s');
// Log the start of this read
logWrite("####################################");
logWrite("Begin batch send: {$timestamp}");
logWrite("------------------------------------");
// Get the queue and counts
$queue = $message->getApiQueue();
$queueCount = count($queue);
$sendCount = 0;
// Log our counts
logWrite("Message Queue Count: {$queueCount}\nBegin send loop:");
//logWrite("")
if (is_array($queue)) {
    if (!empty($queue)) {
예제 #12
0
if (!file_exists($logfile)) {
    touch($logfile);
}
// Get the Zend Framework loader setup
require_once 'Zend/Loader/Autoloader.php';
$autoloader = Zend_Loader_Autoloader::getInstance();
// Setup routing of model autoloaders
$loader = new Zend_Loader_Autoloader_Resource(array('basePath' => $apppath . '/application/', 'namespace' => 'Application'));
// Name, path, namepsace
$loader->addResourceType('model', 'models', 'Model');
// Get our config file
$config = new Zend_Config_Ini($apppath . '/application/configs/application.ini');
Zend_Registry::set('config', $config->production);
// Because our models need it this way
// Get the messages model
$message = new Application_Model_Message();
// Set up our current timestamp
$timestamp = date('Y-m-d H:i:s');
// Log the start of this read
logWrite("####################################");
logWrite("Begin batch send: {$timestamp}");
logWrite("------------------------------------");
// Get the queue and counts
$queue = $message->getQueue();
$queueCount = count($queue);
$sendCount = 0;
// Log our counts
logWrite("Message Queue Count: {$queueCount}\nBegin send loop:");
//logWrite("")
if (is_array($queue)) {
    if (!empty($queue)) {
예제 #13
0
// Get our config file
$config = new Zend_Config_Ini($apppath . '/application/configs/application.ini');
Zend_Registry::set('config', $config->production);
// Because our models need it this way
// Get the messages model
// Set up our current timestamp
$timestamp = date('Y-m-d H:i:s');
// Log the start of this read
logWrite("####################################");
logWrite("Begin batch send: {$timestamp}");
logWrite("------------------------------------");
// Get the queue and counts
// Log our counts
logWrite("Scheduled campaign");
//logWrite("")
$msg = new Application_Model_Message();
// $arr = $msg->scheduledCampaignsSend();
echo date('Y-m-d H:i:s') . '<br>';
// echo '<pre>'; print_r($arr);
//$msg->weeklycampToqueue($arr);
//$msg->weeklycampDirectSend($arr);
$rs = $msg->push_data_to_aggregator();
// $msg->direct_send($rs);
echo '<pre>';
print_r($rs);
logWrite("\n---------------------");
logWrite("Scheduled: {$timestamp}");
logWrite("####################################\n");
return 0;
/**
 * Simply writes a log message line to the log file
예제 #14
0
 private function setModel($row)
 {
     $userTo = $row->findParentRow('Application_Model_DbTable_User', 'To');
     $userFrom = $row->findParentRow('Application_Model_DbTable_User', 'To');
     $model = new Application_Model_Message();
     $model->setId($row->id)->setStatus($row->status)->setRead($row->read)->setToId($row->to_id)->setFromId($row->from_id)->setSubject($row->subject)->setBody($row->body)->setAddedDate($row->addedon)->setUpdateDate($row->updatedon)->setUserTo($userTo)->setUserFrom($userFrom);
     return $model;
 }
예제 #15
0
if (!file_exists($logfile)) {
    touch($logfile);
}
// Get the Zend Framework loader setup
require_once 'Zend/Loader/Autoloader.php';
$autoloader = Zend_Loader_Autoloader::getInstance();
// Setup routing of model autoloaders
$loader = new Zend_Loader_Autoloader_Resource(array('basePath' => $apppath . '/application/', 'namespace' => 'Application'));
// Name, path, namepsace
$loader->addResourceType('model', 'models', 'Model');
// Get our config file
$config = new Zend_Config_Ini($apppath . '/application/configs/application.ini');
Zend_Registry::set('config', $config->production);
// Because our models need it this way
// Get the messages model
$message = new Application_Model_Message();
logWrite("----------------------");
logWrite("BirthdayUpdate Start: {$timestamp}");
$message->selectbd();
logWrite("BirthdayUpdate End: {$timestamp}");
logWrite("\n------------------------------------");
// Set up our current timestamp
$timestamp = date('Y-m-d H:i:s');
// Log the start of this read
logWrite("####################################");
logWrite("Begin batch send: {$timestamp}");
logWrite("------------------------------------");
if ($message->queueBirthDayMessage()) {
    logWrite("Birth day messages are queueing.");
} else {
    logWrite("Birth day messages can not be queued.");
예제 #16
0
 private function setModel($row)
 {
     $model = new Application_Model_Message();
     $model->setMessageId($row->message_id)->setCategoryId($row->category_id)->setSeverityId($row->severity_id)->setTypeId($row->type_id)->setUserMessage($row->user_message)->setSysMessage($row->sys_message)->setRowGuid($row->row_guid)->setCreatedBy($row->created_by)->setUpdatedBy($row->updated_by);
     return $model;
 }
예제 #17
0
//
//logWrite("\n---------------------");
//logWrite("ABC: $timestamp");
//logWrite("####################################\n");
$obj = new Application_Model_Abcdata();
$data = $obj->getPfacnumbers();
$ids = array();
$num = array();
foreach ($data as $k => $v) {
    $ids[$v['id']] = array();
}
//echo '<pre>';print_r($ids);
$msg = "PIZZA FACTORY:Thanks for being a customer. As a reminder u are receiving periodic text message rewards from Pizza Factory. To discontinue reply STOP";
$timezone = "US/Pacific";
$sendtime = date('2013-12-04 10:00:00');
$message = new Application_Model_Message();
foreach ($data as $k => $v) {
    $ids[$v['id']][$v['phonenumber']] = $v['phonenumber'];
}
$cntr = 0;
foreach ($ids as $ik => $iv) {
    $array = array_values($iv);
    if ($cntr > 30) {
        $sendtime = date('2013-12-04 11:00:00');
    }
    if ($cntr > 65) {
        $sendtime = date('2013-12-04 12:30:00');
    }
    $message->queue($msg, $array, $sendtime, $timezone, 0, $ik);
    $cntr++;
}
예제 #18
0
 /**
  * 
  * 
  */
 public function toonefolderAction()
 {
     if ($this->getRequest()->isPost()) {
         $msg = new Application_Model_Message($this->user);
         $folderid = trim($this->request->getParam("folderid"));
         $userid = $this->user->getId();
         $phones = $msg->selectAllsubcribers($userid);
         //            echo '<pre>'; print_r($phones); exit;
         $msg->cleanUpTotalfolder($folderid);
         if (count($phones) != 0) {
             $msg->intoOnefolderAllsubcribers($phones, $folderid);
             echo "Folder is populated";
         }
     }
     exit;
 }
Zend_Registry::set('config', $config->production);
// Because our models need it this way
// Get the messages model
//$message = new Application_Model_Message();
// Set up our current timestamp
$timestamp = date('Y-m-d H:i:s');
// Log the start of this read
logWrite("**********************************");
logWrite("Begin truncate: {$timestamp}");
logWrite("------------------------------------");
$rpt = new Application_Model_Report();
$rpt->saveUserDailyactivity();
// Log our counts
//logWrite("")
/*Memcache server: BDAYCLUB info stores in the memcache memory*/
$msgobj = new Application_Model_Message();
$msgobj->addMemcahceBdclub();
/*end of memcache server use*/
$dataObj = new Application_Model_DataReporting();
$rst = $dataObj->allphonenumbers();
if ($rst) {
    $log = "Rows inserted: {$rst}";
    logWrite($log);
} else {
    logWrite("No data inserted!!");
}
// Set up our current timestamp for closing out
$timestamp = date('Y-m-d H:i:s');
// Log the end of this send
logWrite("\n---------------------");
logWrite("End of inserting: {$timestamp}");
예제 #20
0
 public function weeklycampDirectSend($arr)
 {
     $arc = count($arr);
     $sendmessage = new Application_Model_Message();
     if ($arc != 0) {
         $sendtime = date('Y-m-d H:i:s');
         $cn = 0;
         foreach ($arr as $cind => $cobj) {
             $cn++;
             if ($cobj instanceof stdClass) {
                 // read the object
                 if (!$sendmessage->directcheckScheduled($cobj->campaignid)) {
                     //                        echo $cobj->campaignid;
                     $folders = explode(',', $cobj->folder);
                     $totalfolders = count($folders);
                     $totalsubscribers = array();
                     ini_set('memory_limit', '512M');
                     for ($sbr = 0; $sbr < $totalfolders; $sbr++) {
                         $subscribers = $this->subscribersByFolderid($folders[$sbr]);
                         foreach ($subscribers as $usr_fid => $v) {
                             $totalsubscribers[$v['phonenumber']] = $v['phonenumber'];
                         }
                     }
                     $msg = $cobj->msghead ? "{$cobj->msghead}:" : '';
                     $msg .= "{$cobj->message}\n{$cobj->msgfoot}";
                     $msg = trim($msg);
                     //                    $sendmessage = new Application_Model_Message();
                     if (!empty($totalsubscribers)) {
                         $i_default = 0;
                         // Construct the message
                         $sendmessage->selectedfolders = $cobj->folder;
                         // Set the folderid this message is being sent to
                         $sendmessage->folderid = 1;
                         // Set the user description
                         $sendmessage->description = $cobj->name;
                         // Set a unique identifier for all messages that go out on this campaign
                         $sendmessage->campaignid = $cobj->campaignid;
                         //                     echo $sendtime = date('Y-m-d').' '.$cobj->sendtime;
                         $sendtime = date($cobj->sendtime);
                         //                        $timezone = $cobj->timezone;
                         //                        $userid = $cobj->createuser;
                         $shortcode = $cobj->shortcode;
                         $source = 404;
                         $totalmsg = count($totalsubscribers);
                         $sendmessage->weeklycampaignUpdate($cobj->id, $cobj->createuser, "second", $totalmsg);
                         $regidforcampaign = $this->save_api_outbound($cobj->campaignid, $cobj->createuser);
                         //                        $this->save_api_recipients($regidforcampaign,$totalsubscribers,$source,$cobj->createuser);
                         //                            echo $cobj->createuser; exit;
                         $this->save_api_recipients_collection($msg, $totalsubscribers, $source, $shortcode, $cobj->createuser);
                         //                        $send = $this->direct_send($shortcode,$totalsubscribers,$msg,$regidforcampaign);
                     } else {
                         $this->_writeLog("There are no subscribers in the chosen folder(s)");
                     }
                 }
                 unset($totalsubscribers);
                 //                    unset($cobj);
                 echo date('Y-m-d H:i:s') . ' C# ' . $cn . ' sbcr: ' . $totalmsg . '<br>Failed: ' . $send . '<br>';
                 if ($send == "success") {
                     sleep(20);
                 }
             }
             // end of object
         }
         echo date('Y-m-d H:i:s') . '<br>';
     }
 }
예제 #21
0
 public function handleKeywordActions($replytomessage = null)
 {
     $bReplyToStop = true;
     // LOG IT for testing
     $this->_writeLog("ReplyToMessage is " . print_r($replytomessage, 1));
     // See if this matches a keyword and handle special cases
     $keyword = new Application_Model_Keyword($this->message, true);
     $this->_writeLog("Keyword folderid: {$keyword->folderid}");
     // just hacking this for now
     if (!in_array(strtolower($this->message), array('stop', 'end', 'quit', 'info', 'help', 'cancel', 'stopall'))) {
         // if it didn't load a folderid, it is probably not a valid keyword
         // Now check if there is a replytomessageid and this is a response to
         // a previous outbound
         if (empty($keyword->folderid)) {
             if ($replytomessage) {
                 $this->_writeLog("Originating Keyword ID: {$replytomessage->keywordid}");
                 $keyword = new Application_Model_Keyword($replytomessage->keywordid);
             }
         }
         // If there is a replytomessage, get the create user. This will be for all campaign replies, as well
         // as multi level conversations. If there is no replytomessage we should ALWAYS have a keyword, so
         // get the user that currently owns that keyword and send the reply back as them.
         $creatorid = !empty($replytomessage->createuser) ? $replytomessage->createuser : $keyword->createuser;
     } else {
         $creatorid = 0;
     }
     // Prepare the reply messages if there is one
     $keyword->response = $keyword->replyheader ? "{$keyword->replyheader}:" : '';
     $keyword->response .= "{$keyword->replybody}\n{$keyword->replyfooter}";
     if (trim($keyword->response) === "reply STOP 2 stop") {
         $bReplyToStop = false;
     }
     // 04/13/2013 tmp solution to stop double msg
     // Handle special actions
     $keyword->handleSpecialActions($this);
     // LOG IT for testing
     $this->_writeLog("Keyword ID is {$keyword->id}");
     // If we have an id then this is a keyword
     if ($keyword->id) {
         // LOG IT for testing
         $this->_writeLog("Opted Out Flag is {$keyword->optedOut}");
         // LOG IT for testing
         $this->_writeLog("Message Creator is {$creatorid}");
         $message = new Application_Model_Message(new Application_Model_User((int) $creatorid));
         //            $smsoutbound = new Application_Model_Smsoutbound($message);
         // Set the message keyword and folder id's. These will be used for tracking a conversation as well as handling optouts
         $message->keywordid = $keyword->id;
         $message->folderid = $keyword->folderid;
         // This would only be set from a SpecialAction model
         if (!$this->optedOut) {
             $this->_writeLog("non-optout");
             // Subscribe this sender, but only if they are not already a subscriber
             if (!$keyword->hasSubscriberPhone($this->device_address)) {
                 // Depth for this message is 1 since we are an optin
                 $this->depth = 1;
                 // Sign them up for this keyword
                 $keyword->addSubscriber($this->device_address);
                 /* --------------------- */
                 if ($keyword->notifybysms) {
                     $dt = date('Y-m-d H:i:s');
                     $confirm = "87365:" . $this->device_address . " has opted in to keyword " . $keyword->keyword . " on {$dt}";
                     $this->alertMessage($keyword->notifybysms, $confirm);
                 }
                 if ($keyword->notifybyemail) {
                     $dt = date('Y-m-d H:i:s');
                     $confirm = "87365:" . $this->device_address . " has opted in to keyword " . $keyword->keyword . " on {$dt}";
                     $this->alertnewaccount($keyword->notifybyemail, "Lead notification", $confirm);
                 }
                 /* --------------------- */
                 $this->_writeLog("add subscriber: {$this->device_address}, response: {$keyword->response}");
                 // If there is an autoreply, send it now
                 if ($keyword->response) {
                     if ($bReplyToStop) {
                         // update message exp time
                         if ($keyword->offerexp) {
                             $message->sendNow($this->updateExp($keyword->response, $keyword->offerexp), array($this->device_address), $this->inbound_address);
                         } else {
                             $message->sendNow($keyword->response, array($this->device_address), $this->inbound_address);
                         }
                     }
                 }
             } else {
                 if (!$keyword->usecustomresponse) {
                     // If there is an alternate autoresponder
                     if ($keyword->usealt) {
                         $keyword->response = $keyword->replyheader ? "{$keyword->replyheader}:" : '';
                         $keyword->response .= "{$keyword->replybodyalt}\n{$keyword->replyfooter}";
                     } else {
                         // Otherwise provide a default one.
                         $keyword->response = 'You are already opted in. Thanks for your message.';
                         // TODO: ACTUALLY WE WANT THE 1ST ONE TO KEEP GOING OUT, BUT ALTERNATE RESPONSES
                         // NEED TO BE SET UP FOR ALL EXISTING KEYWORDS 1ST SINCE IT IS A NEW FEATURE
                     }
                 }
                 $this->_writeLog("already opted in: {$keyword->response}");
                 if ($keyword->replybodyalt) {
                     $message->sendNow($keyword->replybodyalt, array($this->device_address), $this->inbound_address);
                 } else {
                     $keyword->replybodyalt = 'You are already opted in. Thanks for your message.';
                     $message->sendNow($keyword->replybodyalt, array($this->device_address), $this->inbound_address);
                 }
             }
         } else {
             /* Taking out for now so stop messages can send their default responses
                Actually, I think this might be unnecessary, because if a custom message is set
                it will override the reponse and be used below...
                if (!$keyword->usecustomresponse) {
                $keyword->response = 'Your message has been received.';
                } */
             $this->_writeLog("OptOut {$keyword->response}");
             if ($bReplyToStop) {
                 $message->sendNow($keyword->response, array($this->device_address), $this->inbound_address);
             }
         }
     }
 }
예제 #22
0
 /**
  *  send campaign
  */
 public function sendCampaignSNFC($msg, $recipients, $sendtime, $timezone, $clubid)
 {
     $i_default = 0;
     $source = 404;
     $shortcode = 88988;
     $message = new Application_Model_Message();
     $message->queue($msg, $recipients, $sendtime, $timezone, $i_default, $source, $clubid, $shortcode);
 }