/**
  * Fetch a message string from the database using the supplied code
  *
  * @param int     $code
  * @param array   $message_args (optional)
  * @return string
  */
 public static function fetch_message($code, $message_args = array())
 {
     $proto = new SystemMessage();
     $sysmsg = $proto->getTable()->find($code);
     if (!$sysmsg || !$sysmsg->exists()) {
         throw new Exception("Cannot find {$code} in system_message");
     }
     $msg = vsprintf($sysmsg->smsg_value, $message_args);
     return $msg;
 }
Example #2
0
 public function createSystemMessage()
 {
     $message = new SystemMessage();
     if ($this->from) {
         $message->setFrom($this->from);
     }
     if ($this->returnPath) {
         $message->setReturnPath($this->returnPath);
     }
     return $message;
 }
 public function Decode($buf = '')
 {
     $this->buffer = new CodeEngine($buf);
     $this->Uin = $this->buffer->DecodeInt32();
     $this->MessageID = $this->buffer->DecodeInt32();
     $this->Count = $this->buffer->DecodeInt8();
     $tmp = new SystemMessage();
     if (strlen($this->buffer) > 0) {
         $this->SystemMessage[] = $tmp->Decode($this->buffer);
     }
     return $this;
 }
Example #4
0
 private function check($data)
 {
     $result = $this->checkData($data);
     // вкаждом классе checkData свой
     //echo $result;
     //если все хорошо попадаем суда
     if ($result === true) {
         return true;
     }
     //создаем объект класса SystemMessage()в этом методе потомучто он нужен только сдесь
     //если все плохо
     $sm = new SystemMessage();
     return $sm->message($result);
 }
 public function Decode($buf = '')
 {
     $this->buffer = new CodeEngine($buf);
     $this->RoomID = $this->buffer->DecodeInt32();
     $this->PushTrigger = $this->buffer->DecodeInt8();
     $this->MessageIndex = $this->buffer->DecodeInt8();
     $this->GameID = $this->buffer->DecodeInt16();
     $this->MessageID = $this->buffer->DecodeInt32();
     $this->Count = $this->buffer->DecodeInt8();
     $tmp = new SystemMessage();
     if (strlen($this->buffer) > 0) {
         $this->SystemMessages[] = $tmp->Decode($this->buffer);
     }
     return $this;
 }
Example #6
0
 public static function list_system_messages()
 {
     define(SYSTEM_MESSAGE_ENTRIES_PER_PAGE, 6);
     $system_message_array = SystemMessage::list_entries();
     if (!$_GET['page']) {
         $page = 1;
     } else {
         $page = $_GET['page'];
     }
     $entry_count = count($system_message_array);
     $number_of_pages = ceil($entry_count / SYSTEM_MESSAGE_ENTRIES_PER_PAGE);
     $template = new HTMLTemplate("base/list_system_messages.html");
     if (is_array($system_message_array) and count($system_message_array) >= 1) {
         $template->set_var("no_entry", false);
         $result = array();
         $counter = 0;
         if (count($system_message_array) < $page * SYSTEM_MESSAGE_ENTRIES_PER_PAGE) {
             $max_for = count($system_message_array) % SYSTEM_MESSAGE_ENTRIES_PER_PAGE - 1;
         } else {
             $max_for = SYSTEM_MESSAGE_ENTRIES_PER_PAGE - 1;
         }
         for ($i = 0; $i <= $max_for; $i++) {
             $entry = $page * SYSTEM_MESSAGE_ENTRIES_PER_PAGE + $i - SYSTEM_MESSAGE_ENTRIES_PER_PAGE;
             // Erzeugt Entry-ID
             $value = $system_message_array[$entry];
             $system_message = new SystemMessage($value);
             $user = new User($system_message->get_user_id());
             $datetime_handler = new DatetimeHandler($system_message->get_datetime());
             $content = str_replace("\n", "<br />", $system_message->get_content());
             $content = str_replace("\\", "", $content);
             $result[$counter]['user'] = $user->get_full_name(false);
             $result[$counter]['datetime'] = $datetime_handler->get_date() . " at " . $datetime_handler->get_time();
             $result[$counter]['content'] = $content;
             $counter++;
         }
         $template->set_var("message_array", $result);
     } else {
         $template->set_var("no_entry", true);
     }
     if ($number_of_pages > 1) {
         $template->set_var("page_bar", Common_IO::page_bar($page, $number_of_pages, $_GET));
     } else {
         $template->set_var("page_bar", "");
     }
     $template->output();
 }
Example #7
0
 private static function handle_tenpay($data, $notify = false)
 {
     $orderno = $data['orderno'];
     $update = array();
     $tradedetails = $data['tradedetails'];
     $tradestatus = intval($data['tradestatus']);
     if ($tradestatus == 0) {
         $donate = DonateLog::instance()->findOne(array('conditions' => "orderno=?"), array($orderno));
         if ($donate) {
             if ($donate['status'] == DonateLog::STATUS_PAY_SUCCESS) {
                 // 订单已经处理过
                 return;
             }
             // send message
             $type = SystemMessage::MSG_TYPE_CHANNEL_STAR_PAY;
             $accountid = $donate['accountid'];
             $payaccountid = $donate['payaccountid'];
             if ($accountid != $payaccountid) {
                 $type = SystemMessage::MSG_TYPE_CHANNEL_STAR_PAY_OTHER;
             }
             SystemMessage::instance()->createChannelStarPayMsg($accountid, $payaccountid, $donate['celebrityaccountid'], $type, $donate['id']);
             $update['status'] = DonateLog::STATUS_PAY_SUCCESS;
         } else {
             Log::write("order not exist:  {$orderno}", 'payment');
             return;
             // 不存在该订单
         }
         if ($donate && floatval($data['totalfee']) < floatval($donate['totalfee'])) {
             $update['status'] = DonateLog::STATUS_PAY_AMOUNT_INCORRECT;
         }
     } else {
         $update['status'] = DonateLog::STATUS_FAILED;
     }
     $update['tradestatus'] = $data['tradestatus'];
     $update['outtradeno'] = $data['outtradeno'];
     $update['tradedetails'] = $tradedetails;
     $update['callback_time'] = date('Y-m-d H:i:s');
     DonateLog::instance()->update($update, "orderno=?", array($orderno));
 }
 /**
  * @throws SystemMessageIDMissingException
  */
 public static function edit()
 {
     if ($_GET['id']) {
         $system_message = new SystemMessage($_GET['id']);
         if ($_GET['nextpage'] == 1) {
             $page_1_passed = true;
             if (!$_POST['content']) {
                 $page_1_passed = false;
                 $error = "You must enter a text";
             }
         } else {
             $page_1_passed = false;
             $error = "";
         }
         if ($page_1_passed == false) {
             $template = new HTMLTemplate("base/admin/system_message/edit.html");
             $paramquery = $_GET;
             $paramquery['nextpage'] = "1";
             $params = http_build_query($paramquery, '', '&#38;');
             $template->set_var("params", $params);
             if ($error) {
                 $template->set_var("error", $error);
             } else {
                 $template->set_var("error", "");
             }
             $content = str_replace("\\", "", $system_message->get_content());
             if ($_POST['content']) {
                 $template->set_var("content", $_POST['content']);
             } else {
                 $template->set_var("content", $content);
             }
             $template->output();
         } else {
             $paramquery = $_GET;
             unset($paramquery['nextpage']);
             unset($paramquery['action']);
             $params = http_build_query($paramquery);
             if ($system_message->set_content($_POST['content'])) {
                 Common_IO::step_proceed($params, "Add System Message", "Operation Successful", null);
             } else {
                 Common_IO::step_proceed($params, "Add System Message", "Operation Failed", null);
             }
         }
     } else {
         throw new SystemMessageIDMissingException();
     }
 }