Kaynağa Gözat

TableMsgs add msg to group

Piotr Labudda 10 yıl önce
ebeveyn
işleme
855f6acf28
1 değiştirilmiş dosya ile 11 ekleme ve 10 silme
  1. 11 10
      SE/se-lib/Route/TableMsgs.php

+ 11 - 10
SE/se-lib/Route/TableMsgs.php

@@ -350,13 +350,16 @@ function tblMsgsLoadMoreRows(n) {
 		if (empty($tableName)) throw new Exception("No table name!");
 		if (empty($tableName)) throw new Exception("No table name!");
 		$sqlWhereAddFilter = "";
 		$sqlWhereAddFilter = "";
 		$usrLogin = User::getLogin();
 		$usrLogin = User::getLogin();
+		$userGroupIds = User::getGroupsIds();
+		$sqlFilerMsgsForUser = "
+			m.`userTargetType` in('everyone')
+			or (m.`userTargetType`='user' and m.`userTargetName`='{$usrLogin}')
+			or (m.`userTargetType`='group' and m.`userTargetName` in(" . implode(",", $userGroupIds) . "))
+		";
 		switch ($filterType) {
 		switch ($filterType) {
 			case 'inbox':
 			case 'inbox':
 				$sqlWhereAddFilter = "
 				$sqlWhereAddFilter = "
-					and (m.`userTargetType` in('everyone')
-						or (m.`userTargetType`='user' and m.`userTargetName`='{$usrLogin}')
-						-- TODO: use group id
-					)
+					and ({$sqlFilerMsgsForUser})
 					and m.`A_STATUS` not in('DELETED')
 					and m.`A_STATUS` not in('DELETED')
 				";
 				";
 				break;
 				break;
@@ -369,11 +372,8 @@ function tblMsgsLoadMoreRows(n) {
 			case 'removed':
 			case 'removed':
 				$sqlWhereAddFilter = "
 				$sqlWhereAddFilter = "
 					and (m.`A_RECORD_CREATE_AUTHOR`='{$usrLogin}'
 					and (m.`A_RECORD_CREATE_AUTHOR`='{$usrLogin}'
-						or (m.`userTargetType` in('everyone')
-						or (m.`userTargetType`='user' and m.`userTargetName`='{$usrLogin}')
-						-- TODO: use group id
+						or ({$sqlFilerMsgsForUser})
 					)
 					)
-				)
 					and m.`A_STATUS` in('DELETED')
 					and m.`A_STATUS` in('DELETED')
 				";
 				";
 				break;
 				break;
@@ -394,6 +394,7 @@ function tblMsgsLoadMoreRows(n) {
 			order by m.`ID` DESC
 			order by m.`ID` DESC
 			limit {$sqlLimit}
 			limit {$sqlLimit}
 		";
 		";
+		//DBG::_('DBG_MSGS', '>1', "sql", $sql, __CLASS__, __FUNCTION__, __LINE__);
 		$db = DB::getDB();
 		$db = DB::getDB();
 		$res = $db->query($sql);
 		$res = $db->query($sql);
 		while ($r = $db->fetch($res)) {
 		while ($r = $db->fetch($res)) {
@@ -458,7 +459,7 @@ function tblMsgsLoadMoreRows(n) {
 		$listTo = array();
 		$listTo = array();
 		$listTo['everyone'] = 'Wszyscy';
 		$listTo['everyone'] = 'Wszyscy';
 		$listTo['user'] = 'Użytkownik';
 		$listTo['user'] = 'Użytkownik';
-		//$listTo['group'] = 'Grupa';
+		$listTo['group'] = 'Grupa';
 		$toType = (array_key_exists($toType, $listTo))? $toType : 'everyone';
 		$toType = (array_key_exists($toType, $listTo))? $toType : 'everyone';
 		$typeSpecialGroupId = TypespecialVariable::getInstance(-1, '__ZASOB');
 		$typeSpecialGroupId = TypespecialVariable::getInstance(-1, '__ZASOB');
 		$typeSpecialUserLogin = TypespecialVariable::getInstance(-1, '__USER_LOGIN');
 		$typeSpecialUserLogin = TypespecialVariable::getInstance(-1, '__USER_LOGIN');
@@ -748,7 +749,7 @@ function tblMsgsLoadMoreRows(n) {
 		?>
 		?>
 <div class="container">
 <div class="container">
 	<div class="alert alert-success">
 	<div class="alert alert-success">
-		Wiadomość została usunięta - <a href="index.php?_route=TableMsgs&_task=tableRow&idTable=<?php echo $idTable; ?>&idRow=<?php echo $idRow; ?>">wróć</a>
+		Wiadomość została usunięta <a class="btn btn-xs btn-default" href="index.php?_route=TableMsgs&_task=tableRow&idTable=<?php echo $idTable; ?>&idRow=<?php echo $idRow; ?>">wróć</a>
 	</div>
 	</div>
 </div>
 </div>
 <?php
 <?php