Example #1
0
 public function getUnreadCount($uid)
 {
     $userData = $this->getUserData($uid);
     $return["unread_notify"] = intval(NotifyMessage::model()->countUnreadByUid($uid));
     $return["unread_atme"] = isset($userData["unread_atme"]) ? intval($userData["unread_atme"]) : 0;
     $return["unread_comment"] = isset($userData["unread_comment"]) ? intval($userData["unread_comment"]) : 0;
     $return["unread_message"] = MessageContent::model()->countUnreadMessage($uid, array(MessageContent::ONE_ON_ONE_CHAT, MessageContent::MULTIPLAYER_CHAT));
     $return["new_folower_count"] = isset($userData["new_folower_count"]) ? intval($userData["new_folower_count"]) : 0;
     $return["unread_total"] = array_sum($return);
     return $return;
 }
Example #2
0
 public function actionShow()
 {
     $message = MessageContent::model()->fetchAllMessageByListId(EnvUtil::getRequest("id"), Ibos::app()->user->uid, intval(EnvUtil::getRequest("sinceid")), intval(EnvUtil::getRequest("maxid")), 10);
     $message["data"] = array_reverse($message["data"]);
     foreach ($message["data"] as $key => $value) {
         $tmpuser = User::model()->fetchByUid($value["fromuid"]);
         $message["data"][$key]["fromrealname"] = $tmpuser["realname"];
         $message["data"][$key]["avatar_small"] = $tmpuser["avatar_small"];
         unset($tmpuser);
     }
     $this->ajaxReturn($message, "JSONP");
 }
Example #3
0
 public function actionPostimg()
 {
     $upload = FileUtil::getUpload($_FILES["pmimage"], "mobile");
     if (!$upload->save()) {
         echo "出错了";
     } else {
         $info = $upload->getAttach();
         $file = FileUtil::getAttachUrl() . "/" . $info["type"] . "/" . $info["attachment"];
         $fileUrl = FileUtil::fileName($file);
         $filePath = FileUtil::getAttachUrl() . "/" . $info["type"] . "/" . $info["attachdir"];
         $filename = "tumb_" . $info["attachname"];
         if (LOCAL) {
             FileUtil::makeDirs($filePath . dirname($filename));
         }
         FileUtil::createFile($filePath . $filename, "");
         Yii::import("ext.ThinkImage.ThinkImage", true);
         $imgObj = new ThinkImage(THINKIMAGE_GD);
         $imgObj->open($fileUrl)->thumb(180, 180, 1)->save($filePath . $filename);
         $content = "<a href='" . $fileUrl . "'><img src='" . $filePath . $filename . "' /></a>";
         $id = intval(isset($_POST["pmid"]) ? $_POST["pmid"] : 0);
         $touid = intval(isset($_POST["pmtouid"]) ? $_POST["touid"] : 0);
         if (!$id && $touid) {
             $data = array("content" => $content, "touid" => $touid, "type" => 1);
             $res = MessageContent::model()->postMessage($data, Yii::app()->user->uid);
             $message = array("listid" => $res, "IsSuccess" => true);
         } else {
             $res = MessageContent::model()->replyMessage($id, $content, Yii::app()->user->uid);
             if ($res) {
                 $message = array("IsSuccess" => true, "data" => Ibos::lang("Private message send success"));
             } else {
                 $message = array("IsSuccess" => false, "data" => Ibos::lang("Private message send fail"));
             }
         }
         $this->ajaxReturn($message, "JSONP");
     }
 }
Example #4
0
 public function actionPost()
 {
     if (EnvUtil::submitCheck("formhash")) {
         $return = array("data" => Ibos::lang("Operation succeed", "message"), "IsSuccess" => true);
         if (empty($_POST["touid"])) {
             $return["data"] = Ibos::lang("Message receiver cannot be empty");
             $return["IsSuccess"] = false;
             $this->ajaxReturn($return);
         }
         if (trim(StringUtil::filterCleanHtml($_POST["content"])) == "") {
             $return["data"] = Ibos::lang("Message content cannot be empty");
             $return["IsSuccess"] = false;
             $this->ajaxReturn($return);
         }
         $_POST["touid"] = implode(",", StringUtil::getUid($_POST["touid"]));
         if (isset($_POST["type"])) {
             !in_array($_POST["type"], array(MessageContent::ONE_ON_ONE_CHAT, MessageContent::MULTIPLAYER_CHAT)) && ($_POST["type"] = null);
         } else {
             $_POST["type"] = null;
         }
         $_POST["content"] = StringUtil::filterDangerTag($_POST["content"]);
         $res = MessageContent::model()->postMessage($_POST, Yii::app()->user->uid);
         if ($res) {
             $this->ajaxReturn($return);
         } else {
             $return["IsSuccess"] = false;
             $return["data"] = MessageContent::model()->getError("message");
             $this->ajaxReturn($return);
         }
     }
 }
 protected function afterSave()
 {
     parent::afterSave();
     $this->id = Yii::app()->db->getLastInsertId();
 }