Ejemplo n.º 1
0
 public function executeSignUp($request)
 {
     $this->form = new SignUpForm();
     if ($request->isMethod('get')) {
         return;
     }
     $this->form->bind($request->getParameter('form'));
     if (!$this->form->isValid()) {
         return;
     }
     $sfGuardUser = new sfGuardUser();
     $sfGuardUser->setUsername($this->form->getValue('username'));
     $sfGuardUser->setPassword($this->form->getValue('password'));
     $sfGuardUser->setIsActive(false);
     $sfGuardUser->save();
     $sfGuardUserProfile = new sfGuardUserProfile();
     $sfGuardUserProfile->setSfGuardUser($sfGuardUser);
     $sfGuardUserProfile->setEmail($this->form->getValue('email'));
     $sfGuardUserProfile->setFirstName($this->form->getValue('first_name'));
     $sfGuardUserProfile->setLastName($this->form->getValue('last_name'));
     $sfGuardUserProfile->setGender($this->form->getValue('gender'));
     $sfGuardUserProfile->setBirthday($this->form->getValue('birthday'));
     $sfGuardUserProfile->setWebpage($this->form->getValue('webpage'));
     $sfGuardUserProfile->save();
     try {
         $connection = new Swift_Connection_SMTP('mail.sis-nav.com', 25);
         $connection->setUsername('*****@*****.**');
         $connection->setPassword('gahve123');
         $mailer = new Swift($connection);
         $message = new Swift_Message('Account Confirmation');
         $mailContext = array('email' => $sfGuardUserProfile->getEmail(), 'full_name' => $sfGuardUserProfile->getFullName(), 'activation_key' => $sfGuardUserProfile->getActivationKey());
         $message->attach(new Swift_Message_Part($this->getPartial('mail/signUpHtmlBody', $mailContext), 'text/html'));
         $message->attach(new Swift_Message_Part($this->getPartial('mail/signUpTextBody', $mailContext), 'text/plain'));
         $mailer->send($message, $sfGuardUserProfile->getEmail(), '*****@*****.**');
         $mailer->disconnect();
     } catch (Exception $e) {
         $mailer->disconnect();
     }
     $this->getUser()->setFlash('info', 'A confirmation email has been sent to your email address.');
     $this->forward('site', 'message');
 }
 /**
  * Serialize the form into the database.
  **/
 public function save($con = null)
 {
     if (!is_null($this->getValue("photographer_id"))) {
         $p = $this->getObject();
     } else {
         $sfUser = new sfGuardUser();
         $sfUser->setUsername($this->getValue("email"));
         $sfUser->setPassword($this->getValue("password"));
         $sfUser->save();
         if (strpos($this->getValue("name"), " ") !== false) {
             list($firstName, $lastName) = explode(" ", $this->getValue("name"));
         } else {
             $firstName = "";
             $lastName = "";
         }
         $sfProfile = new sfGuardUserProfile();
         $sfProfile->setUserTypeId(sfConfig::get("app_user_type_photographer"));
         $sfProfile->setUserId($sfUser->getId());
         $sfProfile->setEmail($this->getValue("email"));
         $sfProfile->setFirstName($firstName);
         $sfProfile->setLastName($lastName);
         $sfProfile->save();
         $p = new Photographer();
         $p->setUserId($sfProfile->getId());
     }
     $p->setName($this->getValue("name"));
     $p->setEmail($this->getValue("email"));
     $p->setPhone($this->getValue("phone"));
     $p->setAffiliation($this->getValue("affiliation"));
     $p->setWebsite($this->getValue("website"));
     $p->setDescription($this->getValue("description"));
     $p->setBillingAddress($this->getValue("billing_info"));
     $p->save();
     if ($this->getValue("reset_password")) {
         $user = $p->getsfGuardUserProfile()->getsfGuardUser();
         $user->setPassword($this->getValue("password"));
         $user->save();
     }
 }
Ejemplo n.º 3
0
 public function transformPhotographers()
 {
     $this->photogKeys = array();
     $dom = DOMDocument::load("tuftsph_jm2db.xml");
     $photogs = $dom->getElementsByTagName("photogs");
     $total = $photogs->length;
     $count = 1;
     echo "Converting Photographers \n";
     foreach ($photogs as $pr) {
         echo $count . "/" . $total . "\n";
         $count += 1;
         $childNodes = $pr->childNodes;
         $i = array();
         foreach ($childNodes as $child) {
             $i[$child->nodeName] = $child->textContent;
         }
         list($firstName, $lastName) = explode(" ", $i["name"]);
         if (strlen($i["email"]) == 0 || is_null($i["email"])) {
             $i["email"] = "NO_EMAIL_" . $count . "@TUFTS.EDU";
         }
         $user = new sfGuardUser();
         $user->setUsername($i["email"]);
         $user->setPassword("");
         $user->setAlgorithm("sha1");
         $user->save();
         $profile = new sfGuardUserProfile();
         $profile->setUserId($user->getId());
         $profile->setUserTypeId(sfConfig::get("app_user_type_photographer"));
         $profile->setEmail($i["email"]);
         $profile->setFirstName($firstName);
         $profile->setLastName($lastName);
         $profile->save();
         $ph = new Photographer();
         $ph->setUserId($profile->getId());
         $ph->setName($i["name"]);
         $ph->setPhone($i["phone"]);
         $ph->setEmail($i["email"]);
         $ph->setAffiliation($i["affiliation"]);
         $ph->save();
         $this->photogKeys[$i["photog_id"]] = $ph->getId();
     }
 }