public function add() { if ($_SERVER['REQUEST_METHOD'] == 'POST') { $contact = new ContactEntity(); $contact->setName($_POST['name']); $contact->setEmail($_POST['email']); $contact->setPhone($_POST['phone']); $contact->setMessage($_POST['message']); $contact->setDate($_POST['date']); $contacts_collection = new ContactCollection(); $contacts_collection->save($contact); header('Location: index.php?frontcontroller=contacts'); } $this->loadView('website/contacts'); }
/** * @param int $pageNumber * @param string $condition * @param int $groupId * @param string $sortField * @param bool $sortOrder * @return ContactCollection */ function &SearchContactsAndGroups($pageNumber, $condition, $groupId, $sortField, $sortOrder, $lookForType) { $contacts = null; if ($this->_dbConnection->Execute($this->_commandCreator->SearchContactsAndGroups($pageNumber, $condition, $groupId, $sortField, $sortOrder, $this->Account, $lookForType))) { $contacts = new ContactCollection(); $k = 0; while (false !== ($row = $this->_dbConnection->GetNextRecord())) { if ($lookForType == 1 && $k > SUGGESTCONTACTS) { $this->_dbConnection->FreeResult(); break; } $contact = new Contact(); $contact->Id = $row->id; $contact->IsGroup = $row->is_group; $contact->Name = $row->name; $contact->Email = $row->email; $contact->Frequency = $row->frequency; $contact->UseFriendlyName = (bool) $row->usefriendlyname; $contacts->Add($contact); unset($contact); $k++; } } return $contacts; }
/** * @param int $groupId * @return ContactCollection */ public function GetContactsOfGroup($groupId) { $contacts = null; if ($this->_connect()) { if ($this->_search('(&(objectClass=' . self::OBJECT_CLASS_CONTACT . ')(memberofpabgroup=' . $groupId . '))')) { $contacts = new ContactCollection(); $return = ldap_get_entries($this->_link, $this->_search); $this->_checkBoolReturn($return); if ($return) { $k = 0; while (isset($return[$k])) { $row = $return[$k]; if (is_array($row) && isset($row['un'][0])) { $contact = new Contact(); $contact->Id = $row['un'][0]; $contact->Name = isset($row['cn'][0]) ? $row['cn'][0] : ''; $contact->Email = isset($row['mail'][0]) ? $row['mail'][0] : ''; $contact->UseFriendlyName = true; $contacts->Add($contact); unset($contact); } $k++; } } } } return $contacts; }
public function delete() { $contacts_collection = new ContactCollection(); $contacts_collection->delete($_GET['id']); header('Location: index.php?controller=contacts'); }