Exemple #1
0
 public function process($data)
 {
     $db = Zend_Registry::get('db');
     $contactMapper = new C3op_Register_ContactMapper($db);
     if ($this->isValid($data) !== true) {
         throw new C3op_Form_ContactEditException('Invalid data!');
     } else {
         $id = $data['id'];
         $contact = $contactMapper->findById($id);
         $contact->SetName($data['name']);
         $contact->SetType($data['type']);
         $contactMapper->update($contact);
         return $id;
     }
 }
Exemple #2
0
 public function process($data)
 {
     if ($this->isValid($data) !== true) {
         throw new C3op_Form_ContactCreateException('Invalid data!');
     } else {
         $db = Zend_Registry::get('db');
         $contactMapper = new C3op_Register_ContactMapper($db);
         $contact = $contactMapper->findById($this->contact->GetValue());
         if ($this->localNumber->GetValue() != "") {
             $phoneNumber = array('area_code' => $this->areaCode->GetValue(), 'local_number' => $this->localNumber->GetValue(), 'label' => $this->label->GetValue());
             $contact->AddPhoneNumber($phoneNumber);
         }
         $contactMapper->update($contact);
         return $contact->GetId();
     }
 }
Exemple #3
0
 public function process($data)
 {
     if ($this->isValid($data) !== true) {
         throw new C3op_Form_ContactCreateException('Invalid data!');
     } else {
         $db = Zend_Registry::get('db');
         $contactMapper = new C3op_Register_ContactMapper($db);
         $contact = $contactMapper->findById($this->contact->GetValue());
         if ($this->localNumber->GetValue() != "") {
             $phoneNumbers = $contact->GetPhoneNumbers();
             if (isset($phoneNumbers[$this->id->GetValue()])) {
                 $phoneNumber = array('area_code' => $this->areaCode->GetValue(), 'local_number' => $this->localNumber->GetValue(), 'label' => $this->label->GetValue());
                 $phoneNumbers[$this->id->GetValue()] = $phoneNumber;
                 $contact->SetPhoneNumbers($phoneNumbers);
                 $contactMapper->update($contact);
                 return $contact->GetId();
             } else {
                 throw new C3op_Form_ContactEditException('Can\'t find this phone id at this contact phone list');
             }
         }
     }
 }