예제 #1
0
 public function MultiAdd($recpients)
 {
     $i = 0;
     $phoneValidator = new Logic_Validate_NumberMobilePhoneInternational();
     $query = "INSERT INTO ws.adressbook_recipient(phone_number, email_address,ws_adressbook_id) VALUES";
     foreach ($recpients as $recpient) {
         $subquery = '(';
         if (isset($recpient['phone_number']) && !empty($recpient['phone_number'])) {
             if ($phoneValidator->isValid($recpient['phone_number'])) {
                 $subquery .= $recpient['phone_number'] . ',';
             } else {
                 $subquery .= 'NULL,';
             }
         } else {
             $subquery .= 'NULL,';
         }
         if (isset($recpient['email_address']) && !empty($recpient['email_address'])) {
             if (filter_var($recpient['email_address'], FILTER_VALIDATE_EMAIL) != false) {
                 $subquery .= "'" . $recpient['email_address'] . "',";
             } else {
                 $subquery .= 'NULL,';
             }
         } else {
             $subquery .= 'NULL,';
         }
         if ($i == count($recpients) - 1) {
             $subquery .= $recpient['ws_adressbook_id'] . ')';
         } else {
             $subquery .= $recpient['ws_adressbook_id'] . '),';
         }
         $query .= new Zend_Db_Expr($subquery);
         $i++;
     }
     $this->getDefaultAdapter()->query(new Zend_Db_Expr($query));
 }
예제 #2
0
파일: Recipient.php 프로젝트: knatorski/SMS
 /**
  * Normalizuje numer odbiorcy i rzutuje go do integer
  *
  * Usuwa wszystkie znaki poza cyframi, nastepnie wykonuje test, czy numer jest jedenastocyfrowy (2 cyfry nr. kierunkowy + 9 cyfr numer wlasciwy). Zwraca ciag znakow rzutowany do integer.
  *
  * @param string $number
  * @throws Logic_Service_Sms_Exception
  * @return integer
  */
 protected function _normalizeNumber($number)
 {
     if (empty($number)) {
         throw new Logic_WebService_Sms_Exception('Nie podano numeru odbiorcy', 420);
     }
     // usuwam wszystkie znaki, ktore nie sa cyfra
     $filter = new Logic_Filter_NumberMobilePhone();
     $number = $filter->filter($number);
     // testuje poprawnosc numeru
     $validator = new Logic_Validate_NumberMobilePhoneInternational();
     if (!$validator->isValid($number)) {
         throw new Logic_WebService_Sms_Exception('Niepoprawny numer odbiorcy: ' . $number, 421);
     }
     return intval($number);
 }