public function inviteAction() { //redirect user to "Add A Connection" page if already logged in if (Zend_Auth::getInstance()->hasIdentity()) { $this->_helper->_redirector->gotoUrl($this->view->seoUrl('/gapper/add-a-connection')); } //get user ID from registration session $usersNs = new Zend_Session_Namespace("app"); $userId = base64_encode($usersNs->registration_id); //$userId = 106; //if user ID exists in session then proceed for invite if (isset($userId) && $userId != "") { $form = new Application_Form_Invite(); //remove form fields $form->removeElement("name"); $elements = $form->getElements(); $form->clearDecorators(); foreach ($elements as $element) { $element->removeDecorator('label'); } $this->view->form = $form; $this->view->successMsg = ""; if ($this->getRequest()->isPost()) { $params = $this->getRequest()->getPost(); if ($form->isValid($params)) { $errorMsg1 = ""; $errorMsg2 = ""; $siteurl = Zend_Registry::get('siteurl'); //get sender information $userM = new Application_Model_User(); $userRes = $userM->find($usersNs->registration_id); //$userId $params["name"] = ucwords($userRes->getFirstName() . " " . $userRes->getLastName()); $params["email"] = $userRes->getEmail(); $params['invitation_link'] = "{$siteurl}/index/register/sender/{$userId}"; $mail = new Base_Mail(); if (isset($params["inviteEmail"])) { if ($params["contacts"] == "") { $errorMsg1 = "Please add your contacts."; } if ($params["contacts"] != "") { $total_contacts = explode(",", $params['contacts']); $receiver_email = ""; $emailValidateObj = new Zend_Validate_EmailAddress(); $emailError = ""; $contactEmail = array(); for ($i = 0; $i < count($total_contacts); $i++) { $receiver_email = trim($total_contacts[$i]); if ($receiver_email != "" && $emailValidateObj->isValid($receiver_email) == false) { $emailError .= "<br /><b>{$receiver_email}</b> is not a valid email address."; } else { $contactEmail[] = $receiver_email; } } if ($emailError != "") { $errorMsg1 = "Please fix following error(s):" . $emailError; } //set valid emails in new option $params['contactEmail'] = $contactEmail; } $this->view->errorMsg1 = $errorMsg1; //if no errors found then send invitation email if ($errorMsg1 == "") { $comment_url = $siteurl . "/index/register/sender/" . $userId; $invitation_link = "<a href='" . $comment_url . "' target='_blank'>" . $comment_url . "</a>"; $params["invitation_link"] = $invitation_link; $params["message"] = "Join Gap Daemon"; $returnMail = $mail->sendInvitationToEmails($params); //send invitation email to contact entered by user $this->_helper->redirector('thanks', 'index', "default"); } } else { if ($params['total_contacts'] == "") { $errorMsg2 = "Please add your contacts."; } $this->view->errorMsg2 = $errorMsg2; //if no errors found then send invitation email if ($errorMsg2 == "") { $mail->sendInvitation($params); //send invitation email using open inviter $this->_helper->redirector('thanks', 'index', "default"); } } //end else } //end if } //end if post } else { $this->_helper->_redirector->gotoUrl($this->view->seoUrl('/index/register')); } }
public function ___addAConnectionAction() { $userNs = new Zend_Session_Namespace("members"); $where = "user_id='{$userNs->userId}'"; $form = new Application_Form_Invite(); $elements = $form->getElements(); $form->clearDecorators(); foreach ($elements as $element) { $element->removeDecorator('label'); } $this->view->form = $form; $this->view->successMsg = ""; if ($this->getRequest()->isPost()) { $params = $this->getRequest()->getPost(); if ($form->isValid($params)) { $siteurl = Zend_Registry::get('siteurl'); $usersNs = new Zend_Session_Namespace("members"); $userId = base64_encode($usersNs->registration_id); $params['invitation_link'] = "{$siteurl}/index/register/id/{$userNs->userId}"; $mail = new Base_Mail(); $mail->sendInvitation($params); //$this->_helper->redirector('thanks','index',"default"); } } }