mirror of
				https://github.com/nerzhul/ocsms.git
				synced 2025-10-31 10:27:42 +00:00 
			
		
		
		
	Avoid problem with duplicates numbers on conversations (spaces and no spaces)
This commit is contained in:
		
							parent
							
								
									714f0c0d9e
								
							
						
					
					
						commit
						a09faa67ad
					
				| @ -124,6 +124,9 @@ class SmsController extends Controller { | |||||||
| 		$phoneNumbers = array(); | 		$phoneNumbers = array(); | ||||||
| 		$msgCount = 0; | 		$msgCount = 0; | ||||||
| 
 | 
 | ||||||
|  | 		// This table will be used to avoid duplicates
 | ||||||
|  | 		$noSpacesPhones = array(); | ||||||
|  | 
 | ||||||
| 		// Contact resolved
 | 		// Contact resolved
 | ||||||
| 		if ($contactName != "" && isset($iContacts[$contactName])) { | 		if ($contactName != "" && isset($iContacts[$contactName])) { | ||||||
| 			$ctPn = count($iContacts[$contactName]); | 			$ctPn = count($iContacts[$contactName]); | ||||||
| @ -138,7 +141,11 @@ class SmsController extends Controller { | |||||||
| 
 | 
 | ||||||
| 				$msgCount += $this->smsMapper->countMessagesForPhoneNumber($this->userId, $fmtPN); | 				$msgCount += $this->smsMapper->countMessagesForPhoneNumber($this->userId, $fmtPN); | ||||||
| 
 | 
 | ||||||
|  | 				$fmtPNNoSpaces = preg_replace("#[ ]#","", $fmtPN); | ||||||
|  | 				if (!in_array($fmtPNNoSpaces, $noSpacesPhones)) { | ||||||
| 					$phoneNumbers[] = $fmtPN; | 					$phoneNumbers[] = $fmtPN; | ||||||
|  | 					$noSpacesPhones[] = $fmtPNNoSpaces; | ||||||
|  | 				} | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 		else { | 		else { | ||||||
| @ -148,7 +155,11 @@ class SmsController extends Controller { | |||||||
| 			$messages = $this->smsMapper->getAllMessagesForPhoneNumber($this->userId, $fmtPN, $lastDate); | 			$messages = $this->smsMapper->getAllMessagesForPhoneNumber($this->userId, $fmtPN, $lastDate); | ||||||
| 			$msgCount = $this->smsMapper->countMessagesForPhoneNumber($this->userId, $fmtPN); | 			$msgCount = $this->smsMapper->countMessagesForPhoneNumber($this->userId, $fmtPN); | ||||||
| 
 | 
 | ||||||
|  | 			$fmtPNNoSpaces = preg_replace("#[ ]#","", $fmtPN); | ||||||
|  | 			if (!in_array($fmtPNNoSpaces, $noSpacesPhones)) { | ||||||
| 				$phoneNumbers[] = $fmtPN; | 				$phoneNumbers[] = $fmtPN; | ||||||
|  | 				$noSpacesPhones[] = $fmtPNNoSpaces; | ||||||
|  | 			} | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		// Order by id (date)
 | 		// Order by id (date)
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user