mirror of
				https://github.com/Mibew/i18n.git
				synced 2025-11-01 01:36:57 +03:00 
			
		
		
		
	Add field with close timestamp to the Thread class
This commit is contained in:
		
							parent
							
								
									fb6517dc9f
								
							
						
					
					
						commit
						48ecf35f1a
					
				| @ -214,6 +214,7 @@ class ThreadTest extends PHPUnit_Framework_TestCase { | ||||
| 			'dtmcreated' => time() - 100, | ||||
| 			'dtmmodified' => time() - 90, | ||||
| 			'dtmchatstarted' => 0, | ||||
| 			'dtmclosed' => time(), | ||||
| 
 | ||||
| 			'agentId' => 0, | ||||
| 			'agentName' => '', | ||||
|  | ||||
| @ -50,6 +50,8 @@ $dbtables = array( | ||||
| 		"dtmchatstarted" => "int NOT NULL DEFAULT 0", | ||||
| 		// Unix timestamp of the last thread modification.
 | ||||
| 		"dtmmodified" => "int NOT NULL DEFAULT 0", | ||||
| 		// Unix timestamp of the moment when the thread was closed.
 | ||||
| 		"dtmclosed" => "int NOT NULL DEFAULT 0", | ||||
| 		// ID of the last thread revision.
 | ||||
| 		"lrevision" => "int NOT NULL DEFAULT 0", | ||||
| 		// State of the thread. It is one of Thread::STATE_* constants.
 | ||||
| @ -268,7 +270,7 @@ $dbtables_indexes = array( | ||||
| $memtables = array(); | ||||
| 
 | ||||
| $dbtables_can_update = array( | ||||
| 	"${mysqlprefix}chatthread" => array("agentId", "userTyping", "agentTyping", "messageCount", "nextagent", "shownmessageid", "userid", "userAgent", "groupid", "dtmchatstarted", "invitationstate"), | ||||
| 	"${mysqlprefix}chatthread" => array("agentId", "userTyping", "agentTyping", "messageCount", "nextagent", "shownmessageid", "userid", "userAgent", "groupid", "dtmchatstarted", "dtmclosed", "invitationstate"), | ||||
| 	"${mysqlprefix}chatthreadstatistics" => array("missedthreads", "sentinvitations", "acceptedinvitations", "rejectedinvitations", "ignoredinvitations"), | ||||
| 	"${mysqlprefix}requestbuffer" => array("requestid", "requestkey", "request"), | ||||
| 	"${mysqlprefix}chatmessage" => array("agentId", "plugin", "data"), | ||||
|  | ||||
| @ -109,6 +109,11 @@ if ($act == "silentcreateall") { | ||||
| 			runsql("update ${mysqlprefix}chatthread set dtmchatstarted = dtmcreated", $link); | ||||
| 		} | ||||
| 
 | ||||
| 		if (in_array("${mysqlprefix}chatthread.dtmclosed", $absent_columns)) { | ||||
| 			runsql("ALTER TABLE ${mysqlprefix}chatthread ADD dtmclosed int NOT NULL DEFAULT 0 AFTER dtmmodified", $link); | ||||
| 			runsql("update ${mysqlprefix}chatthread set dtmclosed = dtmmodified", $link); | ||||
| 		} | ||||
| 
 | ||||
| 		if (in_array("${mysqlprefix}chatthread.agentTyping", $absent_columns)) { | ||||
| 			runsql("ALTER TABLE ${mysqlprefix}chatthread ADD agentTyping int DEFAULT 0", $link); | ||||
| 		} | ||||
|  | ||||
| @ -140,6 +140,7 @@ Class Thread { | ||||
| 	 *  - 'messageCount': count of user's messages related to the thread | ||||
| 	 *  - 'created': unix timestamp of the thread creation | ||||
| 	 *  - 'modified': unix timestamp of the thread's last modification | ||||
| 	 *  - 'closed': unix timestamp of the moment when the thread was closed | ||||
| 	 *  - 'chatStarted': unix timestamp of related to thread chat started | ||||
| 	 *  - 'agentId': id of an operator who take part in the chat | ||||
| 	 *  - 'agentName': name of an operator who take part in the chat | ||||
| @ -177,6 +178,7 @@ Class Thread { | ||||
| 		'created' => 'dtmcreated', | ||||
| 		'modified' => 'dtmmodified', | ||||
| 		'chatStarted' => 'dtmchatstarted', | ||||
| 		'closed' => 'dtmclosed', | ||||
| 
 | ||||
| 		'agentId' => 'agentId', | ||||
| 		'agentName' => 'agentName', | ||||
| @ -369,7 +371,7 @@ Class Thread { | ||||
| 		$db = Database::getInstance(); | ||||
| 
 | ||||
| 		$query = "update {chatthread} set lrevision = :next_revision, " . | ||||
| 			"dtmmodified = :now, istate = :state_closed " . | ||||
| 			"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 " . | ||||
| @ -920,6 +922,7 @@ Class Thread { | ||||
| 		// Close thread if it's not already closed
 | ||||
| 		if ($this->state != self::STATE_CLOSED) { | ||||
| 			$this->state = self::STATE_CLOSED; | ||||
| 			$this->closed = time(); | ||||
| 			$this->messageCount = $message_count; | ||||
| 			$this->save(); | ||||
| 		} | ||||
|  | ||||
| @ -606,6 +606,7 @@ class ThreadProcessor extends ClientSideProcessor { | ||||
| 		$thread->userId = $visitor['id']; | ||||
| 		$thread->userAgent = $user_browser; | ||||
| 		$thread->state = Thread::STATE_LEFT; | ||||
| 		$thread->closed = time(); | ||||
| 		$thread->save(); | ||||
| 
 | ||||
| 		// Send some messages
 | ||||
|  | ||||
| @ -202,13 +202,15 @@ function invitation_reject($visitor_id) { | ||||
| 		"UPDATE {chatsitevisitor} v, {chatthread} t SET " . | ||||
| 			"v.threadid = NULL, " . | ||||
| 			"t.invitationstate = :invitation_rejected, " . | ||||
| 			"t.istate = :state_closed " . | ||||
| 			"t.istate = :state_closed, " . | ||||
| 			"t.dtmclosed = :now " . | ||||
| 		"WHERE t.threadid = v.threadid " . | ||||
| 			"AND visitorid = :visitor_id", | ||||
| 		array( | ||||
| 			':invitation_rejected' => Thread::INVITATION_REJECTED, | ||||
| 			':state_closed' => Thread::STATE_CLOSED, | ||||
| 			':visitor_id' => $visitor_id | ||||
| 			':visitor_id' => $visitor_id, | ||||
| 			':now' => time() | ||||
| 		) | ||||
| 	); | ||||
| } | ||||
| @ -239,6 +241,7 @@ function invitation_close_old() { | ||||
| 		"UPDATE {chatsitevisitor} v, {chatthread} t SET " . | ||||
| 			"t.invitationstate = :invitation_ignored, " . | ||||
| 			"t.istate = :state_closed, " . | ||||
| 			"t.dtmclosed = :now, " . | ||||
| 			"v.threadid = NULL " . | ||||
| 		"WHERE t.istate = :state_invited " . | ||||
| 			"AND t.invitationstate = :invitation_wait " . | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user