public function executeInviteWebmail($request) { $errors = null; if ($request->isMethod('post')) { $this->wbForm = new InviteWebmailForm(array('provider' => 'yahoo')); $this->wbForm->bind($request->getParameter('invite')); if ($this->wbForm->isValid()) { // fetch contacts $fetchURL = sprintf(sfConfig::get('app_importer_url'), $this->wbForm->getValue('provider')); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $fetchURL); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, 'username='******'username')) . '&password='******'password'))); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $result = curl_exec($ch); $contacts = @unserialize($result); // parse emails $this->contacts = array(); if ($contacts) { foreach ((array) $contacts as $contact) { // validate email try { $val = new sfValidatorEmail(array('required' => true, 'trim' => true)); $email = $val->clean($contact["contacts_email"]); $this->contacts[] = array_merge(InvitePeer::splitName(trim($contact["contacts_name"])), array("email" => $email)); } catch (sfValidatorError $e) { // do nothing } } } if (!count($this->contacts)) { $errors[] = "- No contacts were found, please check your login details"; } } else { // get errors into array if ($this->wbForm["username"]->hasError()) { $errors[] = "- " . $this->wbForm["username"]->getError(); } if ($this->wbForm["password"]->hasError()) { $errors[] = "- " . $this->wbForm["password"]->getError(); } if ($this->wbForm["provider"]->hasError() && !$this->wbForm["username"]->hasError() && !$this->wbForm["password"]->hasError()) { $errors[] = "- " . $this->wbForm["provider"]->getError(); } } } $this->errors = $errors; }