/**
  * Set up a new campaign and send a message.
  * 
  * @access public
  */
 public function replyAction()
 {
     $this->_helper->layout->setLayout('nonadmin');
     $id = $this->request->getParam('id');
     $inboxObjload = new Application_Model_Message($this->user);
     $messageObjectload = $inboxObjload->loadinboxmessage($id);
     $this->view->reply_messages = $messageObjectload;
     //echo "<pre>"; print_r($this->view->reply_messages);
     // Defaults
     $success = null;
     $message = null;
     $error = null;
     $recipients = array();
     $sentto = array();
     $date = null;
     $time = null;
     $sendtime = null;
     $timezone = null;
     $status = null;
     // set the default message body values
     $this->defaultValues();
     // When the form is submit
     if ($this->request->isPost()) {
         $this->device_address = $this->request->getParam('device_address');
         $recipients = $this->device_address;
         $this->msg_head = $this->request->getParam('msg_head');
         $this->msg_body = $this->request->getParam('msg_body');
         // Get the sendtime
         $sendtime = date('Y-m-d H:i:s');
         // User's timezone
         $timezone = $this->user->getTimeZone();
         // Only admins can edit the footer
         if ($this->user->isAdmin()) {
             $this->msg_foot = $this->request->getParam('msg_foot');
         }
         // Construct the message
         $msg = $this->msg_head ? "{$this->msg_head}:" : '';
         $msg .= "{$this->msg_body}\n{$this->msg_foot}";
         $msg = trim($msg);
         $sendmessage = new Application_Model_Message($this->user);
         // Verify there was a message set
         if ($msg) {
             //	                       $createuser = $this->user->getId();
             if (!empty($recipients)) {
                 // message Queue it up for delivery
                 //$recipients = 12222222222;
                 //						$status = $sendmessage->queue($msg, $recipients, $sendtime, $timezone,$createuser);
                 $status = $sendmessage->queue($msg, $recipients, $sendtime, $timezone);
                 if ($status) {
                     // Put these recipients into our sentto array to avoid sending duplicates
                     $sentto = array_merge($sentto, $recipients);
                 } else {
                     $error = $sendmessage->getError();
                 }
             } else {
                 $error = 'There are no any phone number.';
             }
             if ($status == 1) {
                 $message = 'Message successfully sent to ' . $recipients;
                 $success = true;
                 // now set the message fields back to default
                 $this->defaultValues();
             } else {
                 $error = $sendmessage->getError();
             }
         } else {
             $error = 'Message content is required';
         }
     }
     //Send the message values back to the view
     $this->view->msg_head = $this->msg_head;
     $this->view->msg_body = $this->msg_body;
     $this->view->msg_foot = $this->msg_foot;
     //Status back to the view
     $this->view->error = $error;
     $this->view->success = $success;
     $this->view->message = $message;
 }