Пример #1
0
 /**
  * test grabbing a volunteer by Email Activation
  */
 public function testGetVolunteerByVolEmailActivation()
 {
     // count the number of rows and save it for later
     $numRows = $this->getConnection()->getRowCount("volunteer");
     // create a new Volunteer and insert to into mySQL
     $volunteer = new Volunteer(null, $this->organization->getOrgId(), $this->VALID_EMAIL, $this->VALID_EMAIL_ACTIVATION, $this->VALID_FIRST_NAME, $this->VALID_HASH, $this->VALID_VOL_IS_ADMIN, $this->VALID_LAST_NAME, $this->VALID_PHONE, $this->VALID_SALT);
     $volunteer->insert($this->getPDO());
     // grab the data from mySQL and enforce the fields match our expectations
     $pdoVolunteer = Volunteer::getVolunteerByVolEmailActivation($this->getPDO(), $volunteer->getVolEmailActivation());
     $this->assertSame($numRows + 1, $this->getConnection()->getRowCount("volunteer"));
     $this->assertSame($pdoVolunteer->getOrgId(), $this->organization->getOrgId());
     $this->assertSame($pdoVolunteer->getVolEmail(), $this->VALID_EMAIL);
     $this->assertSame($pdoVolunteer->getVolEmailActivation(), $this->VALID_EMAIL_ACTIVATION);
     $this->assertSame($pdoVolunteer->getVolFirstName(), $this->VALID_FIRST_NAME);
     $this->assertSame($pdoVolunteer->getVolHash(), $this->VALID_HASH);
     $this->assertSame($pdoVolunteer->getVolIsAdmin(), $this->VALID_VOL_IS_ADMIN);
     $this->assertSame($pdoVolunteer->getVolLastName(), $this->VALID_LAST_NAME);
     $this->assertSame($pdoVolunteer->getVolPhone(), $this->VALID_PHONE);
     $this->assertSame($pdoVolunteer->getVolSalt(), $this->VALID_SALT);
 }
Пример #2
0
                // attach the subject line to the message
                $swiftMessage->setSubject("Please confirm your Bread Basket account");
                /**
                 * attach the actual message to the message
                 * here, we set two versions of the message: the HTML formatted message and a special filter_var()ed
                 * version of the message that generates a plain text version of the HTML content
                 * notice one tactic used is to display the entire $confirmLink to plain text; this lets users
                 * who aren't viewing HTML content in Emails still access your links
                 **/
                // building the activation link that can travel to another server and still work. This is the link that will be clicked to confirm the account.
                $basePath = $_SERVER["SCRIPT_NAME"];
                for ($i = 0; $i < 3; $i++) {
                    $lastSlash = strrpos($basePath, "/");
                    $basePath = substr($basePath, 0, $lastSlash);
                }
                $urlglue = $basePath . "/controllers/email-confirmation?emailActivation=" . $volunteer->getVolEmailActivation();
                $confirmLink = "https://" . $_SERVER["SERVER_NAME"] . $urlglue;
                $message = <<<EOF
<h1>You've been registered for the Bread Basket program!</h1>
<p>Visit the following URL to set a new password and complete the registration process: </p>
<a href="{$confirmLink}">{$confirmLink}</a></p>
EOF;
                $swiftMessage->setBody($message, "text/html");
                $swiftMessage->addPart(html_entity_decode(filter_var($message, FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES)), "text/plain");
                /**
                 * send the Email via SMTP; the SMTP server here is configured to relay everything upstream via CNM
                 * this default may or may not be available on all web hosts; consult their documentation/support for details
                 * SwiftMailer supports many different transport methods; SMTP was chosen because it's the most compatible and has the best error handling
                 * @see http://swiftmailer.org/docs/sending.html Sending Messages - Documentation - SwitftMailer
                 **/
                $smtp = Swift_SmtpTransport::newInstance("localhost", 25);