Beispiel #1
0
function sendAppPush($device_type, $device_tokens, $notification_type, $message)
{
    $ci =& get_instance();
    $ci->load->helper('file');
    $pushtitle = $ci->config->item('PUSHTITLE');
    $notification = $ci->config->item('NOTIFICATION');
    if ($device_type == 1 && $notification['android']['enable']) {
        // android
        $push = new Push($notification['android']['appkey'], $notification['android']['appMasterSecret']);
        ob_start();
        // 打开缓冲区
        $push->sendAndroidUnicast($device_tokens, PUSHTICKER, $pushtitle[$notification_type], $message);
        $info_return = ob_get_clean();
        $device_typename = 'Android';
    } elseif ($device_type == 2 && $notification['ios']['enable']) {
        // ios
        $push = new Push($notification['ios']['appkey'], $notification['ios']['appMasterSecret']);
        ob_start();
        // 打开缓冲区
        $push->sendIOSUnicast($device_tokens, $message);
        $info_return = ob_get_clean();
        $device_typename = 'IOS';
    } else {
        // windows...
        $device_typename = 'unknow';
        $info_return = '';
    }
    // PUSHLOG
    write_file(APPPATH . "/logs/push/" . date('Ymd') . "_push.log", date('Y-m-d H:i:s', time()) . PHP_EOL . 'platform:' . $device_typename . PHP_EOL . 'device_tokens:' . $device_tokens . PHP_EOL . 'message:' . $message . PHP_EOL . 'retun:' . $info_return . PHP_EOL, 'a');
}
Beispiel #2
0
 public function send($device_tokens, $msg_title = '你收到一个新消息', $msg_property = [])
 {
     $payload = json_encode($msg_property);
     $message = new \xmpush\Builder();
     $message->title('明源微助手');
     // 通知栏的title
     $message->description($msg_title);
     // 通知栏的descption
     $message->passThrough(0);
     // 这是一条通知栏消息,如果需要透传,把这个参数设置成1,同时去掉title和descption两个参数
     $message->payload($payload);
     // 携带的数据,点击后将会通过客户端的receiver中的onReceiveMessage方法传入。
     $message->extra(\xmpush\Builder::notifyForeground, 1);
     // 应用在前台是否展示通知,如果不希望应用在前台时候弹出通知,则设置这个参数为0
     $message->notifyId(rand(0, 4));
     // 通知类型。最多支持0-4 5个取值范围,同样的类型的通知会互相覆盖,不同类型可以在通知栏并存
     $message->build();
     if (count($device_tokens) == 1 && $device_tokens[0] == 'all') {
         $ret = $this->sender->broadcastAll($message);
     } else {
         $ret = $this->sender->sendToIds($message, $device_tokens);
     }
     if ($ret->getErrorCode() == \xmpush\ErrorCode::Success) {
         return Push::ret($ret->getErrorCode(), $ret->getRaw()['info']);
     } else {
         return Push::ret($ret->getErrorCode(), $ret->getRaw()['reason']);
     }
 }
Beispiel #3
0
 public function test()
 {
     $device = $this->getDevice();
     $pushToken = PushToken::find((int) $device->id);
     if ($pushToken) {
         Push::send($pushToken->platform, $pushToken->token, 'This is test message');
         return $this->respondNoContent();
     } else {
         return $this->respondWithError('Device isn\'t bound');
     }
 }
Beispiel #4
0
 public function providerRejects($id)
 {
     if ($this->isClosed()) {
         return false;
     }
     $key = array_search($id, $this->providers);
     if ($key !== false) {
         unset($this->providers[$key]);
         if (!$this->save()) {
             return false;
         }
         if (count($this->providers) == 0) {
             $user = User::findById((string) $this->user);
             Push::send('Não foram encontradas pessoas disponíveis.', [$user->registrationId]);
         }
         return true;
     }
     return false;
 }
 public function post_confirm()
 {
     //valido que exixtan los datos resividos
     $this->servicio_id = !empty(Input::get('service_id')) ? Input::get('service_id') : 0;
     $this->conductor_id = !empty(Input::get('driver_id')) ? Input::get('service_id') : 0;
     //confirmo que los datos resividos sean correctos
     if ($this->servicio_id != 0 && $this->conductor_id != 0) {
         //relizo una busqueda con los datos recibiros de conductor y servicio
         $this->servicio = Service::find($this->servicio_id);
         $this->conductor = Driver::find($this->conductor_id);
         //confirmo de que el sercicio exista
         if ($this->Validar($this->servicio)) {
             //confirmo de que el conductor esiste y el estado del sercio es 1
             if (empty($this->servicio->driver_id) && $this->servicio->status_id == "1") {
                 //realiso la actualizacion del servicio y valido la respuesta
                 if ($this->update('Service')) {
                     //realiso la actualizacion del conductor y valido la respuesta
                     if ($this->update('Driver')) {
                         //conturuyo el mensaje de validacion
                         $mensaje = "tu servicio ha sido confirmado!";
                         $push = Push::make();
                         //valido que el servicio exixte
                         if ($this->validar($this->servicio->uuid)) {
                             //valido que tipo de  servicio fue resivido
                             if ($this->servicio->user->type == "1") {
                                 //guardo el mensaje en el servicio resivido
                                 $result = $push->ios($this->servicio->uuid, $mensaje, 1, 'honk.wav', 'Open', array('serviceId' => $this->servicio->id));
                             } else {
                                 $result = $push->android2($this->servicio->uuid, $mensaje, 1, 'default', 'Open', array('serviceId' => $this->servicio->id));
                             }
                             //si todo para bn retorno error = false
                             return Response::json(array("error" => false));
                         }
                     }
                 }
             }
         }
     }
     //si curre un error retorno error =tue
     return Response::json(array("error" => true));
 }
Beispiel #6
0
 public function sendMsg($recipient, $message, $signature)
 {
     // urlencode data
     $recipient = utf8_encode($recipient);
     $message = utf8_encode($message);
     $signature = utf8_encode($signature);
     $posturl = "{$this->serverapi}{$recipient}/";
     $ch = curl_init($posturl);
     curl_setopt($ch, CURLOPT_POST, 1);
     curl_setopt($ch, CURLOPT_POSTFIELDS, "_encoding=UTF-8&message={$message}&signature={$signature}");
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     $bodyresult = curl_exec($ch);
     if (curl_errno($ch)) {
         // echo "Problem with connection to pushme\n";
         return 1;
     }
     curl_close($ch);
     if (Push::checkResult($bodyresult) == 0) {
         // echo "Message was sent successfully.\n";
         return 0;
     } else {
         return 1;
     }
 }
Beispiel #7
0
 /**
  * 教师提交补课信息
  * @param $user_id
  * @param $departmentId
  * @param $courseId
  * @param $classroomId
  * @param $extraTime
  * @param $studentJson
  * @param $extraReason
  * @return array|bool
  */
 public function postExtraLesson($user_id, $departmentId, $courseId, $classroomId, $extraTime, $studentJson, $extraReason)
 {
     $data = array();
     $nowTime = date('Y-m-d H:i:s');
     try {
         $con_user = Yii::app()->cnhutong;
         // 补课表添加数据
         $result1 = $con_user->createCommand()->insert('com_extra', array('member_id' => $user_id, 'extra_time' => $extraTime, 'department_id' => $departmentId, 'course_id' => $courseId, 'classroom_id' => $classroomId, 'create_time' => $nowTime, 'update_time' => $nowTime, 'flag' => 1, 'status' => 1, 'type' => 2, 'reason' => $extraReason));
         // 获取补课表id
         $extraId = Yii::app()->cnhutong->getLastInsertID();
         $studentNameArr = array();
         // 补课详情表添加数据
         foreach ($studentJson as $row) {
             $result2 = $con_user->createCommand()->insert('com_extra_detail', array('extra_id' => $extraId, 'member_id' => $row['studentId'], 'status' => 0, 'create_time' => $nowTime, 'update_time' => $nowTime, 'create_user_id' => 0, 'update_user_id' => 0));
             if (Common::model()->getNameById($row['studentId'])) {
                 $studentNameArr[] = Common::model()->getNameById($row['studentId']);
             }
         }
         // 推送相关补课消息给相应老师
         // 申请人名称
         $userName = Common::model()->getNameById($user_id);
         // 学员名称
         $studentNames = implode(' ', $studentNameArr);
         // 加课时间 $extraTime
         // 课程
         $courseName = Common::model()->getCourseById($courseId);
         // 校区
         $departmentName = Common::model()->getDepartmentById($departmentId);
         // 老师
         $teacherName = Common::model()->getNameById($user_id);
         // 教室
         $classroomName = Common::model()->getClassroomById($classroomId);
         // 理由 备注 $extraReason
         $msg_content = " 申请人: {$userName} &8424 学员: {$studentNames} &8424 时间: {$extraTime} &8424 课程: {$courseName} &8424 老师: {$teacherName} &8424 教室: {$departmentName}/{$classroomName} &8424 备注: {$extraReason} ";
         $msg_title = '老师补课申请';
         $alert_content = $teacherName . " 提交了 " . $extraTime . " 的补课申请";
         // 添加老师补课消息
         Notice::model()->insertNotice($user_id, $user_id, 1, null, $extraId, 3, $msg_title, $msg_content, $nowTime, 1, 0);
         $push = Push::model()->pushMsg(11, $user_id, '3', $msg_title, $alert_content);
         if ($push) {
             return true;
         } else {
             return false;
         }
     } catch (Exception $e) {
         error_log($e);
         return false;
     }
 }
Beispiel #8
0
    $db->query(sprintf('SET NAMES utf8 COLLATE %s', $settings->collate));
}
mb_internal_encoding('utf8');
// initialize Haanga
require include_dir . 'Haanga.php';
Haanga::configure(array('template_dir' => 'templates/', 'cache_dir' => 'templates/compiled/', 'compiler' => array('global' => array('settings', 'session'), 'strip_whitespace' => true, 'allow_exec' => false, 'autoescape' => false)));
// initialize the html engine
require classes_dir . 'html.php';
$html = new HTML();
// initiailze session
require classes_dir . 'session.php';
$session = new Session();
$session->init();
// initialize push engine
require classes_dir . 'push.php';
$push = new Push();
$push->init();
// configure gettext's locale
putenv('LC_ALL=' . $settings->locale);
setlocale(LC_ALL, $settings->locale);
bindtextdomain('messages', './locale');
textdomain('messages');
// redir to /login if not in ^/login already
if (!is_bot() && ($settings->privacy_level == 2 && $session->level == 'anonymous' && !preg_match(sprintf('/^%s(login|api|userlogin|_)/', preg_quote($settings->base_url, '/')), $_SERVER['REQUEST_URI']))) {
    $html->do_sysmsg(_('Log in'), _('You must log in to read any quote.'), 403);
}
/* make privacy_level_for_bots effective */
if (is_bot() && $settings->privacy_level_for_bots == 2 && !preg_match(sprintf('/^%s(rss|robots\\.txt)/', preg_quote($settings->base_url, '/')), $_SERVER['REQUEST_URI'])) {
    header('HTTP/1.1 403 Forbidden');
    die('403 Forbidden');
    /* so what */
Beispiel #9
0
 /**
  * 提交任务签到接口:
  * 教师在App中提交学员课时签到信息
  * @param $user_id
  * @param $lessonJson
  * @return bool|int
  */
 public function postSign($user_id, $lessonJson)
 {
     $nowTime = date('Y-m-d H:m:i');
     try {
         $con_task = Yii::app()->cnhutong;
         $table_name = 'ht_lesson_student';
         // 按照课时ID进行签到,ht_lesson_student: status_id = 1(老师签到),step = 0 正常, step = 1 补课, step = 2 缺勤, step = 6 请假
         foreach ($lessonJson as $row) {
             // 需要对$lessonJson里面的数值做判断 if... step = 0 增加一条消息记录,jPush推送学员用户; step = 2|6 增加一条补课机会记录
             $result = $con_task->createCommand()->update($table_name, array('status_id' => 1, 'step' => $row['step']), 'id = :id', array(':id' => $row['lessonStudentId']));
             if ($row['step'] == 2 || $row['step'] == 6) {
                 // 判断 step = 2|6 添加补课机会记录
                 self::insertExtraChance($row['lessonStudentId'], $row['step']);
             } elseif ($row['step'] == 0) {
                 // step = 0 增加一条消息记录,jPush推送学员用户发送销课通知
                 $acceptIdArr = self::getAcceptIdByLessonStudentId($row['lessonStudentId']);
                 // $acceptArr = array(); 则表示为该学员未绑定任何user_id 只记录消息,不推送
                 if ($acceptIdArr && $acceptIdArr[0]['user_id']) {
                     foreach ($acceptIdArr as $acceptId) {
                         $lessonDetail = Common::model()->getLessonDetailById($row['lessonStudentId']);
                         // 推送相关补课消息给相应老师
                         // 学员名称
                         $studentName = $lessonDetail['studentName'];
                         // 时间
                         $dateTime = $lessonDetail['date'] . ' ' . $lessonDetail['time'];
                         // 课程
                         $courseName = $lessonDetail['course'];
                         // 课时
                         $lesson_cnt_charged = $lessonDetail['lesson_cnt_charged'];
                         // 校区
                         $departmentName = $lessonDetail['department'];
                         // 老师
                         $teacherName = Common::model()->getNameById($user_id);
                         // 教室
                         $classroomName = $lessonDetail['classroom'];
                         // 学员
                         $studentId = $lessonDetail['studentId'];
                         // 理由 备注 $extraReason
                         $msg_content = " 学员: {$studentName} &8424 时间: {$dateTime} &8424 课程: {$courseName} &8424 课时: {$lesson_cnt_charged} &8424 老师: {$teacherName} &8424 教室: {$departmentName}/{$classroomName} ";
                         $msg_title = '销课通知';
                         $alert_content = $studentName . " 完成了 " . $courseName;
                         $push = Push::model()->pushMsg(10, $acceptId['user_id'], '1', $msg_title, $alert_content);
                         //                            if ($push) {
                         //                                return true;
                         //                            } else {
                         //                                return false;
                         //                            }
                     }
                     // 添加老师销课消息
                     Notice::model()->insertNotice($user_id, $studentId, 1, null, null, 1, $msg_title, $msg_content, $nowTime, 1, 0);
                 } else {
                     // 记录消息,不推送
                     $lessonDetail = Common::model()->getLessonDetailById($row['lessonStudentId']);
                     // 推送相关补课消息给相应老师
                     // 学员名称
                     $studentName = $lessonDetail['studentName'];
                     // 时间
                     $dateTime = $lessonDetail['date'] . ' ' . $lessonDetail['time'];
                     // 课程
                     $courseName = $lessonDetail['course'];
                     // 课时
                     $lesson_cnt_charged = $lessonDetail['lesson_cnt_charged'];
                     // 校区
                     $departmentName = $lessonDetail['department'];
                     // 老师
                     $teacherName = Common::model()->getNameById($user_id);
                     // 教室
                     $classroomName = $lessonDetail['classroom'];
                     // 学员
                     $studentId = $lessonDetail['studentId'];
                     // 理由 备注 $extraReason
                     $msg_content = " 学员: {$studentName} &8424 时间: {$dateTime} &8424 课程: {$courseName} &8424 课时: {$lesson_cnt_charged} &8424 老师: {$teacherName} &8424 教室: {$departmentName}/{$classroomName} ";
                     $msg_title = '销课通知';
                     // 添加老师销课消息
                     Notice::model()->insertNotice($user_id, $studentId, 1, null, null, 1, $msg_title, $msg_content, $nowTime, 1, 0);
                 }
             } else {
                 return false;
             }
             //                return true;        // 不加会返回null
         }
     } catch (Exception $e) {
         error_log($e);
         return false;
     }
 }
Beispiel #10
0
     // Now do something!
     if ($parseObj->validateInboundMessage()) {
         // And do more stuff!
         $parseObj->postNewPushOnParse();
     }
     // Exit from switch
     break;
     // The confirmation URL is linked from an email, so it'll be a GET request.
 // The confirmation URL is linked from an email, so it'll be a GET request.
 case 'GET':
     // Include the Push class, only if we need it.
     require "Push.php";
     // Check to see if the PushID is set. If not, throw an error.
     if (isset($_GET['pushId'])) {
         $pushId = $_GET['pushId'];
         $pushObj = new Push($pushId);
         // Check to see if we were able to get a good Push notification from Parse, if not, throw a nice error.
         if ($pushObj->getPushDetails() == "200" && $pushObj->validatePush()) {
             // Send the push notification to Parse API and set the Push to "sent". If both 200, show success.
             if ($pushObj->sendPushNotification() == "200" && $pushObj->setPushAsSent() == "200") {
                 echo '<html><head><meta http-equiv="content-type" content="text/html; harset=UTF-8"/><title>Push Confirmation</title></head><style>body{ font-family:"Lucida Grande", Tahoma, Arial, Verdana, sans-serif; background: #F8F8F8; font-size: 12px; } div{ background-color: white; width: 400px; padding: 30px; border: 3px solid #7e7e7e; color: #757575; margin: 0 auto; display: block; margin-top: 100px; } h2 { color: #000000; margin: 0px; margin-bottom: 10px; } </style> <body><div class="message"><h2>Push Notification Status</h2> Your push notification of "' . $pushObj->returnPushMessage() . '" has been succcessfuly sent. </div> </body></html>';
             }
         } else {
             echo '<html><head><meta http-equiv="content-type" content="text/html; harset=UTF-8"/><title>Push Confirmation</title></head><style>body{ font-family:"Lucida Grande", Tahoma, Arial, Verdana, sans-serif; background: #F8F8F8; font-size: 12px; } div{ background-color: white; width: 400px; padding: 30px; border: 3px solid #7e7e7e; color: #757575; margin: 0 auto; display: block; margin-top: 100px; } h2 { color: #000000; margin: 0px; margin-bottom: 10px; } </style><body><div class="message"><h2>Push Notification Status</h2> Sorry, this link has expired.</div><br></body></html>';
         }
     } else {
         echo '<html><head><meta http-equiv="content-type" content="text/html; harset=UTF-8"/><title>Push Confirmation</title></head><style>body{ font-family:"Lucida Grande", Tahoma, Arial, Verdana, sans-serif; background: #F8F8F8; font-size: 12px; } div{ background-color: white; width: 400px; padding: 30px; border: 3px solid #7e7e7e; color: #757575; margin: 0 auto; display: block; margin-top: 100px; } h2 { color: #000000; margin: 0px; margin-bottom: 10px; } </style><body><div class="message"><h2>Error</h2> Sorry, something did not go right.</div><br></body></html>';
     }
     break;
     // Default error, in the event the script is called via other HTTP method.
 // Default error, in the event the script is called via other HTTP method.
Beispiel #11
0
 /**
  * Emits a push message to this user.
  * @param string $endpoint The endpoint to push to.
  * @param object $data The data to push. Optional.
  */
 public function emit($endpoint, $data = null)
 {
     Push::getPushServer($this)->emit($this->getUserId(), $endpoint, $data);
 }
define('EURO_MILHOES_ENDPOINT', 'https://nunofcguerreiro.com/api-euromillions-json');
define('PUSH_MESSAGE', 'Abra a aplicação para conferir qual o seu prémio!');
require_once '../inc/config.inc.php';
require_once BASE_PATH . 'inc/database.inc.php';
require_once BASE_PATH . 'inc/push.inc.php';
$lastUpdateDate = '1970-01-01';
$lastDraw = @$db_conn->query("SELECT * FROM `draws` ORDER BY `id` DESC LIMIT 1")->fetchAll()[0];
if ($lastDraw) {
    $lastUpdateDate = $lastDraw['date'];
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, EURO_MILHOES_ENDPOINT);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$content = curl_exec($ch);
curl_close($ch);
$content = json_decode($content, true);
$obj = $content['drawns'][0];
$lastDrawDate = $obj['date'];
$dt1 = new DateTime($lastUpdateDate);
$dt2 = new DateTime($lastDrawDate);
if ($dt2 > $dt1) {
    $arr = array('numbers' => array_map('intval', explode(' ', $obj['numbers'])), 'stars' => array_map('intval', explode(' ', $obj['stars'])));
    $db_conn->query("INSERT INTO `draws` (`draw`, `date`) VALUES (%s, %s)", json_encode($arr), $obj['date']);
    echo 'Updated';
    $iOS = new iOSPush(PUSH_MESSAGE);
    $iOS->setDevices(Push::getTokens(DEVICE_TYPE_IOS));
    $iOS->send();
    $android = new AndroidPush(PUSH_MESSAGE);
    $android->setDevices(Push::getTokens(DEVICE_TYPE_ANDROID));
    $android->send();
}
Beispiel #13
0
 public function send()
 {
     $this->data['new']['chats'] = array_values(array_unique($this->data['new']['chats']));
     $this->data['new']['posts'] = array_values(array_unique($this->data['new']['posts']));
     $this->data['new']['comments'] = array_values(array_unique($this->data['new']['comments']));
     $this->data['new']['carChats'] = array_values(array_unique($this->data['new']['carChats']));
     $this->data['new']['emergencies'] = array_values(array_unique($this->data['new']['emergencies']));
     if (isset($this->data['posts'])) {
         $posts = array();
         foreach ($this->data['posts'] as $post) {
             if (isset($post['comments'])) {
                 $comments = array();
                 foreach ($post['comments'] as $comment) {
                     $comments[] = $comment;
                 }
                 $post['comments'] = $comments;
             }
             $posts[] = $post;
         }
         $this->data['posts'] = $posts;
     }
     if (isset($this->data['comments'])) {
         $comments = array();
         foreach ($this->data['commented'] as $comment) {
             $comments[] = $comment;
         }
         $this->data['comments'] = $comments;
     }
     $this->redis->set($this->token, json_encode(array('new' => $this->data['new'])));
     $json = json_encode($this->data);
     $this->redis->publish($this->token, $json);
     $device = Device::where('auth_token', $this->token)->first();
     $pushToken = PushToken::find((int) $device->id);
     if ($pushToken) {
         Push::send($pushToken->platform, $pushToken->token, $json);
     }
     return $this;
 }
Beispiel #14
0
<?php

////////////////////////////////////////////////////////////
//
// PushMe PHP example code v0.1
// Example PHP code to send messages via pushme.to service.
//
// Patryk 'jamzed' Kuzmicz || 2010.01.24
// patryk.kuzmicz@gmail.com
//
////////////////////////////////////////////////////////////
include 'pushmeClass.php';
$msg = new Push();
$sender = "sender";
$recipient = "recipient";
$message = "Message text ;-)";
echo $msg->sendMsg($recipient, $message, $sender) ? "Error!\n" : "Sent!\n";
Beispiel #15
0
<?php

require_once 'bootstrap.php';
$push = new Push($config);
$push->execute();
echo $push->_log_messages;
Beispiel #16
0
 /**
  * 发送通知
  * @notificationContent Strng 通知内容
  * @param Strng $msgTitle 
  * @param Strng $msgContent 
  * @param Array $customMessageParams = array("receiver_type" => 1,     *
  *                                          "receiver_value" => "",
  *                                          "sendno" => 1,
  *                                          "send_description" => "",
  *                                          "override_msg_id" => "")
  * @param Array $extras
  *  
  * @return MessageResult $msgResult   错误信息对象
  */
 public function sendCustomMessage($msgTitle, $msgContent, $customMessageParams, $extras)
 {
     //初始化返回对象
     $msgResult = new MessageResult();
     //验证参数
     $validate = new ValidateParams($this->initparams);
     if (!$validate->validateCustomMessage($msgTitle, $msgContent, $customMessageParams, $extras, $msgResult)) {
         return $msgResult;
     }
     //设置对象参数
     $customMessageParams["msgTitle"] = $msgTitle;
     $customMessageParams["msgContent"] = $msgContent;
     if ($this->initparams['platform'] == 'android') {
         $customMessageParams["mes_type"] = 2;
     } else {
         $customMessageParams["mes_type"] = 1;
     }
     $sendVO = new SendVO($this->initparams, $customMessageParams, $extras);
     //发送通知
     $pushClient = new Push();
     $pushClient->pushMsg($sendVO, $msgResult);
     return $msgResult;
 }
Beispiel #17
0
 public function __construct($androidAuthKey, $iosApnsCert)
 {
     self::$androidAuthKey = $androidAuthKey;
     self::$iosApnsCert = $iosApnsCert;
 }
Beispiel #18
0
 /**
  * handle incoming events
  *
  */
 public static function event($params)
 {
     // send a push notification
     Push::send($params['subject'] . ' ' . $params['message'] . ' ' . $params['file'], $params['link']);
 }
Beispiel #19
0
 /**
  * 提交课时请假信息
  * @param $memberId
  * @param $courseId
  * @param $lessonStudentId
  * @param $dateTime
  * @param $reason
  * @return bool
  */
 public function lessonStudentLeave($memberId, $courseId, $lessonStudentId, $dateTime, $reason)
 {
     $nowTime = date('Y-m-d H:i:s');
     try {
         $con_user = Yii::app()->cnhutong;
         $table_name = 'com_leave';
         // 请假表记录请假详情
         $data = $con_user->createCommand()->insert($table_name, array('member_id' => $memberId, 'course_id' => $courseId, 'lesson_student_id' => $lessonStudentId, 'leave_time' => $dateTime, 'create_time' => $nowTime, 'update_time' => $nowTime, 'flag' => 2, 'status' => 1, 'reason' => $reason));
         $leaveId = Yii::app()->cnhutong->getLastInsertID();
         // 学员请假直接修改课表课时状态
         $dataLeave = $con_user->createCommand()->update('ht_lesson_student', array('step' => 6), 'id = :lessonStudentId', array(':lessonStudentId' => $lessonStudentId));
         // 根据课时id获得学员id (ht_lesson_student),再根据学员id获得绑定的user_id(com_user_member)
         $lessonDetail = Common::model()->getLessonDetailById($lessonStudentId);
         // 推送相关请假消息给相应老师
         // 学员名称
         $studentName = $lessonDetail['studentName'];
         // 时间
         $dateTime = $lessonDetail['date'] . ' ' . $lessonDetail['time'];
         // 课程
         $courseName = $lessonDetail['course'];
         // 课时
         $lesson_cnt_charged = $lessonDetail['lesson_cnt_charged'];
         // 校区
         $departmentName = $lessonDetail['department'];
         // 老师
         $teacherId = $lessonDetail['teacherId'];
         // 教室
         $classroomName = $lessonDetail['classroom'];
         // 理由 备注 $extraReason
         $msg_content = " 学员: {$studentName} &8424 时间: {$dateTime} &8424 课程: {$courseName} &8424 课时: {$lesson_cnt_charged} &8424 教室: {$departmentName}/{$classroomName} &8424 备注: {$reason} ";
         $msg_title = '学员请假通知';
         $alert_content = $dateTime . " 的 " . $courseName . " 有一位学员请假";
         // 添加学员请假消息
         // 教师
         Notice::model()->insertNotice($memberId, $teacherId, 2, $leaveId, null, 2, $msg_title, $msg_content, $nowTime, 1, 0);
         // 学生
         Notice::model()->insertNotice($memberId, $memberId, 2, $leaveId, null, 2, $msg_title, $msg_content, $nowTime, 1, 0);
         $push = Push::model()->pushMsg(11, $teacherId, '2', $msg_title, $alert_content);
         //            if ($push) {
         //                return true;
         //            } else {
         //                return false;
         //            }
     } catch (Exception $e) {
         error_log($e);
         return false;
     }
 }