/**
  * Invitation form and processing of invited user details
  */
 public function actionIndex($p)
 {
     if ($this->request->isPost()) {
         $firstName = Fari_Decode::accents($this->request->getPost('first'));
         $lastName = Fari_Decode::accents($this->request->getPost('last'));
         $email = $this->request->getPost('email');
         if (!Fari_Filter::isEmail($email) or empty($firstName)) {
             $this->bag->message = array('status' => 'fail', 'message' => 'Whoops, make sure you enter a full name and proper email address.');
             $this->bag->first = $this->request->getRawPost('first');
             $this->bag->last = $this->request->getRawPost('last');
             $this->bag->email = $this->request->getRawPost('email');
         } else {
             $name = $this->accounts->newInvitation($firstName, $lastName, $email);
             // mail the instructions
             $mail = new Mailer();
             try {
                 $mail->sendInvitation();
             } catch (UserNotFoundException $e) {
                 $this->redirectTo('/error404/');
             }
             $this->flashSuccess = "{$name} is now added to your account. An email with instructions was sent to {$email}";
             $this->redirectTo('/users/');
         }
     }
     $this->bag->tabs = $this->user->inRooms();
     $this->renderAction('new');
 }
/**
 * Transforms all URLs or e-mail addresses within the string into clickable HTML links.
 * @param string $string email or url
 * @param string $ref reference to the link (optional)
 * @param string $type link/email (optional)
 */
function autoLink($string, $ref = NULL, $type = NULL)
{
    // target reference
    if (!isset($ref)) {
        $ref = $string;
    }
    // it's an email
    if ($type == 'email' || Fari_Filter::isEmail($string)) {
        echo "<a href=\"mailto:{$string}\">{$ref}</a>";
        // or a link
    } else {
        // formed URL, just echo as a link
        if (Fari_Filter::isURL($string)) {
            echo '<a href="' . $string . '">' . $ref . '</a>';
        } else {
            // prefix with BASEPATH so we can link internally
            if (substr($string, 0, 1) !== '/') {
                $string = "/{$string}";
            }
            echo '<a href="' . WWW_DIR . $string . '">' . $ref . '</a>';
        }
    }
}
Exemple #3
0
 /**
  * Format email and name string to build an email ready header.
  * @param string $email Email address
  * @param string $name Optional name
  * @return string
  */
 private function formatEmail($email, $name)
 {
     try {
         // check email validity
         if (empty($email) or !Fari_Filter::isEmail($email)) {
             throw new Fari_Exception("\"{$email}\" is not a valid email address.");
         } else {
             $email = "<{$email}>";
             // have we provided the name?
             if (!empty($name)) {
                 // only alphanumeric characters allowed
                 if (!Fari_Filter::isAlpha($name)) {
                     throw new Fari_Exception("\"{$name}\" needs to contain only alphanumeric characters.");
                 } else {
                     // prepend name before the email
                     return '"' . $name . '" ' . $email;
                 }
             } else {
                 // add brackets around the email
                 return $email;
             }
         }
     } catch (Fari_Exception $exception) {
         $exception->fire();
     }
 }