mirror of
				https://github.com/Mibew/i18n.git
				synced 2025-10-31 01:15:49 +03:00 
			
		
		
		
	Fix bug with old threads closing
This commit is contained in:
		
							parent
							
								
									ab8a889464
								
							
						
					
					
						commit
						a899cc2dff
					
				| @ -370,14 +370,43 @@ Class Thread { | ||||
| 
 | ||||
| 		$db = Database::getInstance(); | ||||
| 
 | ||||
| 		$query = "update {chatthread} set lrevision = :next_revision, " . | ||||
| 			"dtmmodified = :now, dtmclosed = :now, istate = :state_closed " . | ||||
| 			"where istate <> :state_closed and istate <> :state_left " . | ||||
| 			"and ((lastpingagent <> 0 and lastpinguser <> 0 and " . | ||||
| 			"(ABS(:now - lastpinguser) > :thread_lifetime and " . | ||||
| 			"ABS(:now - lastpingagent) > :thread_lifetime)) or " . | ||||
| 			"(lastpingagent = 0 and lastpinguser <> 0 and " . | ||||
| 			"ABS(:now - lastpinguser) > :thread_lifetime))"; | ||||
| 		$query = "UPDATE {chatthread} SET " . | ||||
| 				"lrevision = :next_revision, " . | ||||
| 				"dtmmodified = :now, " . | ||||
| 				"dtmclosed = :now, " . | ||||
| 				"istate = :state_closed " . | ||||
| 			"WHERE istate <> :state_closed " . | ||||
| 				"AND istate <> :state_left " . | ||||
| 				// Check created timestamp
 | ||||
| 				"AND ABS(:now - dtmcreated) > :thread_lifetime " . | ||||
| 				// Check pings
 | ||||
| 				"AND ( " . | ||||
| 					"( " . | ||||
| 						// Both user and operator have no connection problems.
 | ||||
| 						// Check all pings.
 | ||||
| 						"lastpingagent <> 0 " . | ||||
| 						"AND lastpinguser <> 0 " . | ||||
| 						"AND ABS(:now - lastpinguser) > :thread_lifetime " . | ||||
| 						"AND ABS(:now - lastpingagent) > :thread_lifetime " . | ||||
| 					") OR ( " . | ||||
| 						// Only operator have connection problems.
 | ||||
| 						// Check user's ping.
 | ||||
| 						"lastpingagent = 0 " . | ||||
| 						"AND lastpinguser <> 0 " . | ||||
| 						"AND ABS(:now - lastpinguser) > :thread_lifetime " . | ||||
| 					") OR ( " . | ||||
| 						// Only user have connection problems.
 | ||||
| 						// Check operator's ping.
 | ||||
| 						"lastpinguser = 0 " . | ||||
| 						"AND lastpingagent <> 0 " . | ||||
| 						"AND ABS(:now - lastpingagent) > :thread_lifetime " . | ||||
| 					") OR ( " . | ||||
| 						// Both user and operator have connection problems.
 | ||||
| 						// Just close thread.
 | ||||
| 						"lastpinguser = 0 " . | ||||
| 						"AND lastpingagent = 0 " . | ||||
| 					") " . | ||||
| 				")"; | ||||
| 
 | ||||
| 		$db->query( | ||||
| 			$query, | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user