浏览代码

added unread msgs filter to UserMsgs::getMsgs

Piotr Labudda 10 年之前
父节点
当前提交
bdb23f01fd
共有 2 个文件被更改,包括 16 次插入10 次删除
  1. 5 5
      SE/se-lib/Route/TableMsgs.php
  2. 11 5
      SE/se-lib/Route/UserMsgs.php

+ 5 - 5
SE/se-lib/Route/TableMsgs.php

@@ -72,7 +72,7 @@ class Route_TableMsgs extends RouteBase {
 				$arrorsList[] = $e->getMessage();
 			}
 		}
-		$msgsList = $this->_getMsgs('inbox', $tableName, $idRow);
+		$msgsList = $this->getMsgs('inbox', $tableName, $idRow);
 		$totalReadMsgs = 0;
 		$totalUnreadMsgs = 0;
 		foreach ($msgsList as $ind => $msg) {
@@ -82,8 +82,8 @@ class Route_TableMsgs extends RouteBase {
 				$totalUnreadMsgs++;
 			}
 		}
-		$sentMsgsList = $this->_getMsgs('sent', $tableName, $idRow);
-		$removedMsgsList = $this->_getMsgs('removed', $tableName, $idRow);
+		$sentMsgsList = $this->getMsgs('sent', $tableName, $idRow);
+		$removedMsgsList = $this->getMsgs('removed', $tableName, $idRow);
 		?>
 <style type="text/css">
 .tblMsgsListItem { cursor:pointer; }
@@ -261,7 +261,7 @@ function tblMsgsLoadMoreRows(n) {
 		if (!in_array($listType, array('inbox','sent','removed'))) throw new HttpException("Wrong param listType", 404);
 
 		$resultData = new stdClass();
-		$resultData->msgs = $this->_getMsgs($listType, $tableName, $idRow, $lastMsgId);
+		$resultData->msgs = $this->getMsgs($listType, $tableName, $idRow, $lastMsgId);
 		$resultData->keysOrder = array_keys($resultData->msgs);
 		echo json_encode($resultData);
 	}
@@ -346,7 +346,7 @@ function tblMsgsLoadMoreRows(n) {
 <?php
 	}
 
-	public function _getMsgs($filterType, $tableName, $idRow, $lastMsgId = null) {
+	public function getMsgs($filterType, $tableName, $idRow, $lastMsgId = null) {
 		$lastMsgId = (int)$lastMsgId;
 		$msgsRoute = Router::getRoute('Msgs');
 		$msgsList = array();

+ 11 - 5
SE/se-lib/Route/UserMsgs.php

@@ -40,7 +40,7 @@ class Route_UserMsgs extends RouteBase {
 	}
 
 	public function userMsgs($usrLogin) {
-		$msgsList = $this->_getMsgs('inbox', $usrLogin);
+		$msgsList = $this->getMsgs('inbox', $usrLogin);
 		$totalReadMsgs = 0;
 		$totalUnreadMsgs = 0;
 		foreach ($msgsList as $ind => $msg) {
@@ -50,8 +50,8 @@ class Route_UserMsgs extends RouteBase {
 				$totalUnreadMsgs++;
 			}
 		}
-		$sentMsgsList = $this->_getMsgs('sent', $usrLogin);
-		$removedMsgsList = $this->_getMsgs('removed', $usrLogin);
+		$sentMsgsList = $this->getMsgs('sent', $usrLogin);
+		$removedMsgsList = $this->getMsgs('removed', $usrLogin);
 		?>
 <style type="text/css">
 .tblMsgsListItem { cursor:pointer; }
@@ -220,7 +220,7 @@ function tblMsgsLoadMoreRows(n) {
 		if (!in_array($listType, array('inbox','sent','removed'))) throw new HttpException("Wrong param listType", 404);
 
 		$resultData = new stdClass();
-		$resultData->msgs = $this->_getMsgs($listType, $usrLogin, $lastMsgId);
+		$resultData->msgs = $this->getMsgs($listType, $usrLogin, $lastMsgId);
 		$resultData->keysOrder = array_keys($resultData->msgs);
 		echo json_encode($resultData);
 	}
@@ -305,7 +305,7 @@ function tblMsgsLoadMoreRows(n) {
 <?php
 	}
 
-	public function _getMsgs($filterType, $usrLogin, $lastMsgId = null) {
+	public function getMsgs($filterType, $usrLogin, $lastMsgId = null) {
 		$lastMsgId = (int)$lastMsgId;
 		$msgsRoute = Router::getRoute('Msgs');
 		$msgsList = array();
@@ -327,6 +327,12 @@ function tblMsgsLoadMoreRows(n) {
 					and m.`A_STATUS` in('WAITING', 'NORMAL')
 				";
 				break;
+			case 'unread':
+				$sqlWhereAddFilter = "
+					and ({$sqlFilerMsgsForUser})
+					and m.`A_STATUS` in('WAITING')
+				";
+				break;
 			case 'sent':
 				$sqlWhereAddFilter = "
 					and m.`A_RECORD_CREATE_AUTHOR`='{$usrLogin}'