コード例 #1
0
 function sendReplyMsg()
 {
     $json['bool'] = 0;
     $json['err'] = "ok";
     $accid = addslashes($_POST['acc_id']);
     $inboxid = addslashes($_POST['inboxid']);
     $isi = addslashes($_POST['isi']);
     // $emai = addslashes($_POST['emai']);
     if ($accid == "") {
         $json['err'] = Lang::t('lang_id_empty');
     }
     if ($inboxid == "") {
         $json['err'] = Lang::t('lang_inbox_id_empty');
     }
     if ($isi == "") {
         $json['err'] = Lang::t('lang_isi_empty');
     }
     if ($json['err'] == "ok") {
         $in = new InboxReply();
         $tgl = date("Y-m-d H:i:s");
         $in->inbox_id = $inboxid;
         $in->inbox_to = $accid;
         $in->inbox_from = Account::getMyID();
         $in->inbox_msg = $isi;
         $in->inbox_createdate = $tgl;
         if ($in->save()) {
             //update inbox
             $inbox = new Inbox();
             $inbox->getByID($inboxid);
             $inbox->inbox_changedate = $tgl;
             $inbox->inbox_anzahlreply++;
             $inbox->load = 1;
             $inbox->addInboxNotif($accid, $inboxid, $inbox->inbox_read);
             //cek read didalamnya
             if ($inbox->inbox_read) {
                 //update Notif
                 $inbox->inbox_read = 0;
             }
             $inbox->inbox_giliran_read = $accid;
             $inbox->save();
             $json['bool'] = 1;
         } else {
             $json['err'] = Lang::t('lang_failed');
         }
     }
     echo json_encode($json);
     exit;
 }
コード例 #2
0
 function sendMsg()
 {
     $json['bool'] = 0;
     $json['err'] = "ok";
     $accid = addslashes($_POST['acc_id']);
     $judul = addslashes($_POST['judul']);
     $isi = addslashes($_POST['isi']);
     $emai = isset($_POST['emai']) ? addslashes($_POST['emai']) : 0;
     $type = isset($_POST['type']) ? addslashes($_POST['type']) : "casual";
     if ($accid == Account::getMyID()) {
         $json['err'] = Lang::t('Receipient ID error');
     }
     if ($accid == "") {
         $json['err'] = Lang::t('Receipient ID empty');
     }
     if ($judul == "") {
         $json['err'] = Lang::t('Message Title empty');
     }
     if ($isi == "") {
         $json['err'] = Lang::t('Message Content empty');
     }
     if ($json['err'] == "ok") {
         $in = new Inbox();
         $tgl = date("Y-m-d H:i:s");
         $in->inbox_from = Account::getMyID();
         $in->inbox_to = $accid;
         $in->inbox_giliran_read = $accid;
         $in->inbox_read = 0;
         $in->inbox_createdate = $tgl;
         $in->inbox_changedate = $tgl;
         $in->inbox_judul = $judul;
         $in->inbox_msg = $isi;
         $in->inbox_type = $type;
         $inboxid = $in->save();
         if ($inboxid) {
             $json['bool'] = $in->addInboxNotif($accid, $inboxid, 1);
             // cek read didalamnya makanya dikasi val 0
             //send mail
             if ($emai) {
                 $lem = new Leapmail();
                 if (!$lem->sendByID($accid, $judul, $isi)) {
                     $json['err'] = Lang::t('Send Email Failed');
                 }
             }
         } else {
             $json['err'] = Lang::t('Saving Failed');
         }
     }
     echo json_encode($json);
 }