public function deleteAction()
 {
     if ($this->getRequest()->isPost()) {
         $id = (int) $this->getRequest()->getParam('id');
         $model = new Default_Model_AddressBook();
         $model->delete($id);
     }
     return $this->_helper->redirector('index', 'addressbook');
 }
 public function fetchAll()
 {
     $resultSet = $this->getDbTable()->fetchAll();
     $entries = array();
     foreach ($resultSet as $row) {
         $entry = new Default_Model_AddressBook();
         $entry->setId($row->id)->setName($row->name)->setMapper($this);
         $entries[] = $entry;
     }
     return $entries;
 }
 public function init()
 {
     $this->setMethod('get');
     $this->addElement('text', 'name', array('label' => 'Name', 'class' => 'text', 'decorators' => array('ViewHelper', 'Label', array(array('data' => 'htmlTag', 'tag' => 'div')))));
     $addressBook = new Default_Model_AddressBook();
     $addressBooks = $addressBook->getNames();
     $this->addElement('select', 'addressbook', array('multiOptions' => $addressBooks, 'label' => false, 'decorators' => array('ViewHelper', array(array('data' => 'htmlTag', 'tag' => 'div')))));
     $this->getElement('addressbook')->addMultiOption('0', 'All');
     $this->addElement('submit', 'submit-button', array('ignore' => true, 'label' => 'View', 'class' => 'submit', 'decorators' => array('ViewHelper', array(array('data' => 'htmlTag', 'tag' => 'div')))));
     $this->setName('address_book_form');
     $this->setDecorators(array('FormElements', 'Form'));
 }
Example #4
0
 public function init()
 {
     $this->setMethod('post');
     $this->addElement('text', 'firstName', array('label' => 'First Name', 'required' => true, 'class' => 'title text', 'filters' => array('StringTrim')));
     $this->addElement('text', 'lastName', array('label' => 'Last Name', 'required' => true, 'class' => 'title text', 'filters' => array('StringTrim')));
     $this->addElement('text', 'address1', array('label' => 'Address 1', 'required' => false, 'class' => 'text', 'filters' => array('StringTrim')));
     $this->addElement('text', 'address2', array('label' => 'Address 2', 'required' => false, 'class' => 'text', 'filters' => array('StringTrim')));
     $this->addElement('text', 'town', array('label' => 'Town/City', 'required' => false, 'class' => 'text', 'filters' => array('StringTrim')));
     $this->addElement('text', 'county', array('label' => 'County', 'required' => false, 'class' => 'text', 'filters' => array('StringTrim')));
     $this->addElement('text', 'country', array('label' => 'Country', 'required' => false, 'class' => 'text', 'filters' => array('StringTrim')));
     $this->addElement('text', 'postCode', array('label' => 'Post Code', 'required' => false, 'class' => 'text', 'filters' => array('StringTrim')));
     $this->addElement('text', 'homeTel', array('label' => 'Home Telephone', 'required' => false, 'class' => 'text', 'filters' => array('StringTrim')));
     $this->addElement('text', 'workTel', array('label' => 'Work Telephone', 'required' => false, 'class' => 'text', 'filters' => array('StringTrim')));
     $this->addElement('text', 'mobileTel', array('label' => 'Mobile Telephone', 'required' => false, 'class' => 'text', 'filters' => array('StringTrim')));
     $this->addElement('text', 'fax', array('label' => 'Fax', 'required' => false, 'class' => 'text', 'filters' => array('StringTrim')));
     // Add an email element
     $this->addElement('text', 'email', array('label' => 'Email Address', 'required' => false, 'class' => 'text', 'filters' => array('StringTrim')));
     $addressBook = new Default_Model_AddressBook();
     $addressBooks = $addressBook->getNames();
     $this->addElement('select', 'addressBookId', array('multiOptions' => $addressBooks, 'required' => true, 'label' => 'Address Book'));
     // Add the submit button
     $this->addElement('submit', 'submit', array('ignore' => true, 'label' => 'Add Contact'));
 }
Example #5
0
 /**
  * Search for contact
  * @param string Name of contact to search for
  * @param int ID of address book to search in
  * @return array Array of Default_Model_Contact
  */
 public function search($name = null, $addressBook = null)
 {
     if (isset($addressBook) && !empty($addressBook)) {
         if (isset($name) && !empty($name)) {
             // search for name and address book
             return $this->getMapper()->findByName($name, $addressBook);
         } else {
             // search for address book
             $model = new Default_Model_AddressBook();
             return $model->getContacts($addressBook);
         }
     } else {
         if (isset($name) && !empty($name)) {
             // search for name
             return $this->getMapper()->findByName($name);
         } else {
             // search for all contacts
             return $this->fetchAll();
         }
     }
 }