public function getAllPhoneNumbersForFPN($userId, $phoneNumber, $country) { $query = \OCP\DB::prepare('SELECT sms_address FROM ' . '*PREFIX*ocsms_smsdatas WHERE user_id = ? AND sms_mailbox IN (?,?)'); $result = $query->execute(array($userId, 0, 1)); $phoneList = array(); while ($row = $result->fetchRow()) { $pn = $row["sms_address"]; $fmtPN = PhoneNumberFormatter::format($country, $pn); if (!isset($phoneList[$fmtPN])) { $phoneList[$fmtPN] = array(); } if (!isset($phoneList[$fmtPN][$pn])) { $phoneList[$fmtPN][$pn] = 0; } $phoneList[$fmtPN][$pn] += 1; } $fpn = PhoneNumberFormatter::format($country, $phoneNumber); if (isset($phoneList[$fpn])) { return $phoneList[$fpn]; } else { return array(); } }
/** * @NoAdminRequired * @NoCSRFRequired * @param $contact * @return JSONResponse */ public function deleteConversation($contact) { $contacts = $this->contactCache->getContacts(); $iContacts = $this->contactCache->getInvertedContacts(); $contactName = ""; // Cache country because of loops $configuredCountry = $this->configMapper->getCountry(); $fmtPN = PhoneNumberFormatter::format($configuredCountry, $contact); if (isset($contacts[$fmtPN])) { $contactName = $contacts[$fmtPN]; } // Contact resolved if ($contactName != "" && isset($iContacts[$contactName])) { // forall numbers in iContacts foreach ($iContacts[$contactName] as $cnumber) { $this->smsMapper->removeMessagesForPhoneNumber($this->userId, $cnumber); } } else { $this->smsMapper->removeMessagesForPhoneNumber($this->userId, $contact); } return new JSONResponse(array()); }
private function pushPhoneNumberToCache($rawPhone, $contactName, $country) { $phoneNb = PhoneNumberFormatter::format($country, $rawPhone); $this->contacts[$phoneNb] = $contactName; // Inverted contacts if (!isset($this->contactsInverted[$contactName])) { $this->contactsInverted[$contactName] = array(); } array_push($this->contactsInverted[$contactName], $phoneNb); }