예제 #1
0
 /**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param      PropelPDO $con
  * @return     int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws     PropelException
  * @see        save()
  */
 protected function doSave(PropelPDO $con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their coresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->asfGuardUser !== null) {
             if ($this->asfGuardUser->isModified() || $this->asfGuardUser->isNew()) {
                 $affectedRows += $this->asfGuardUser->save($con);
             }
             $this->setsfGuardUser($this->asfGuardUser);
         }
         // If this object has been modified, then save it to the database.
         if ($this->isModified()) {
             if ($this->isNew()) {
                 $criteria = $this->buildCriteria();
                 $pk = BasePeer::doInsert($criteria, $con);
                 $affectedRows += 1;
                 $this->setNew(false);
             } else {
                 $affectedRows += sfGuardRememberKeyPeer::doUpdate($this, $con);
             }
             $this->resetModified();
             // [HL] After being saved an object is no longer 'modified'
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
 /**
  * executeRegister
  *
  * @access public
  * @return void
  */
 public function executeRegister(sfWebRequest $request)
 {
     $this->form = new sfGuardFormRegister();
     if ($request->isMethod(sfRequest::POST)) {
         $this->form->bind($request->getParameter($this->form->getName()));
         if ($this->form->isValid()) {
             $values = $this->form->getValues();
             $sfGuardUser = new sfGuardUser();
             $sfGuardUser->fromArray($values, BasePeer::TYPE_FIELDNAME);
             if (isset($values['email'])) {
                 $sfGuardUser->setEmail($values['email']);
             }
             $sfGuardUser->setIsActive(false);
             $sfGuardUser->save();
             $messageParams = array('sfGuardUser' => $sfGuardUser, 'password' => $values['password']);
             $body = $this->getComponent($this->getModuleName(), 'send_request_confirm', $messageParams);
             $from = sfConfig::get('app_sf_guard_extra_plugin_mail_from', '*****@*****.**');
             $fromName = sfConfig::get('app_sf_guard_extra_plugin_name_from', 'noreply');
             $to = $sfGuardUser->getEmail();
             $toName = $sfGuardUser->getUsername();
             $subject = sfConfig::get('app_sf_guard_extra_plugin_subject_confirm', 'Confirm Registration');
             $mailer = $this->getMailer();
             $message = $mailer->compose(array($from => $fromName), array($to => $toName), $subject, $body);
             $mailer->send($message);
             $this->getUser()->setFlash('values', $values);
             $this->getUser()->setFlash('sfGuardUser', $sfGuardUser);
             return $this->redirect('@sf_guard_do_register');
         }
     }
 }
예제 #3
0
 /**
  * @see sfValidatorBase
  */
 protected function doClean($values)
 {
     // only validate if username and password are both present
     if (isset($values[$this->getOption('username_field')]) && isset($values[$this->getOption('password_field')])) {
         $username = $values[$this->getOption('username_field')];
         $password = $values[$this->getOption('password_field')];
         // user exists?
         if ($user = sfGuardUserPeer::retrieveByUsername($username)) {
             // password is ok?
             if ($user->getIsActive()) {
                 if (Configuration::get('ldap_enabled', false)) {
                     if (authLDAP::checkPassword($username, $password)) {
                         return array_merge($values, array('user' => $user));
                     }
                 } elseif ($user->checkPassword($password)) {
                     return array_merge($values, array('user' => $user));
                 }
             }
         } elseif (Configuration::get('ldap_enabled', false) && Configuration::get('ldap_create_user', false) && authLDAP::checkPassword($username, $password)) {
             $user = new sfGuardUser();
             $user->setUsername($username);
             $user->save();
             $profile = new Profile();
             $profile->setSfGuardUserId($user->getId());
             $profile->save();
             return array_merge($values, array('user' => $user));
         }
         if ($this->getOption('throw_global_error')) {
             throw new sfValidatorError($this, 'invalid');
         }
         throw new sfValidatorErrorSchema($this, array($this->getOption('username_field') => new sfValidatorError($this, 'invalid')));
     }
     // assume a required error has already been thrown, skip validation
     return $values;
 }
예제 #4
0
 protected function doClean($values)
 {
     $username = isset($values[$this->getOption('username_field')]) ? $values[$this->getOption('username_field')] : '';
     bhLDAP::debug('######## Username: '******'password_field')]) ? $values[$this->getOption('password_field')] : '';
     bhLDAP::debug('######## User exists?');
     $user = Doctrine::getTable('sfGuardUser')->findOneByUsername($username);
     //    bhLDAP::debugDump($user, "user:");
     if (!$user) {
         if (bhLDAP::checkPassword($username, $password)) {
             // pretend the user exists, then check AD password
             bhLDAP::debug('######## User does not exist. Creating dummy user.');
             $user = new sfGuardUser();
             $user->setUsername($username);
             $user->setSalt('unused');
             $user->setPassword('unused');
             $user->setUserProfile(new UserProfile());
             $user->save();
         }
         return array_merge($values, array('user' => $user));
     }
     // password is ok?
     bhLDAP::debug('######## Checking Password...');
     if ($user->checkPassword($password)) {
         bhLDAP::debug('######## Check Password successful...');
         return array_merge($values, array('user' => $user));
     }
     bhLDAP::debug('######## Check Password failed...');
     if ($this->getOption('throw_global_error')) {
         throw new sfValidatorError($this, 'invalid');
     }
     throw new sfValidatorErrorSchema($this, array($this->getOption('username_field') => new sfValidatorError($this, 'invalid')));
 }
예제 #5
0
 public function executeSignin($request)
 {
     $this->form = new sfGuardFormSignin();
     if ($request->isMethod('post')) {
         $data = $request->getParameter('signin');
         $adldap = new adLDAP(array('account_suffix' => '@sch.bme.hu', 'domain_controllers' => array('152.66.208.42'), 'ad_username' => $data['username'], 'ad_password' => $data['password']));
         try {
             $authUser = $adldap->authenticate($data['username'], $data['password']);
             if ($authUser === true) {
                 $userData = $adldap->user_info($data['username']);
                 $user = Doctrine::getTable('sfGuardUser')->findOneBy('username', $data['username']);
                 $save = false;
                 if ($user) {
                     if ($user->Profile->full_name != $userData[0]["displayname"][0] || $user->Profile->email != $userData[0]["mail"][0]) {
                         $save = true;
                     }
                 } else {
                     $user = new sfGuardUser();
                     $save = true;
                 }
                 if ($save) {
                     $user->username = $data['username'];
                     $user->password = $data['password'];
                     $user->Profile->full_name = $userData[0]["displayname"][0];
                     $user->Profile->email = $userData[0]["mail"][0];
                     $user->save();
                 }
             }
         } catch (Exception $e) {
             echo $e;
         }
     }
     parent::executeSignin($request);
 }
예제 #6
0
 private function registerUser($username, $data = NULL)
 {
     try {
         $gingerKey = sfConfig::get('app_portail_ginger_key');
         if ($gingerKey != "abc") {
             $ginger = new \Ginger\Client\GingerClient(sfConfig::get('app_portail_ginger_key'));
             $cotisants = $ginger->getUser($username);
         } else {
             $cotisants = new stdClass();
             $cotisants->mail = $username . "@etu.utc.fr";
             $cotisants->prenom = "Le";
             $cotisants->nom = "Testeur";
             $cotisants->type = "etu";
         }
         if (!$data) {
             $data = new sfGuardUser();
         }
         $data->setUsername($username);
         $data->setEmailAddress($cotisants->mail);
         $data->setFirstName($cotisants->prenom);
         $data->setLastName($cotisants->nom);
         $data->setIsActive(true);
         $data->save();
         $profile = new Profile();
         $profile->setUser($data);
         $profile->setDomain($cotisants->type);
         $profile->save();
         return $data;
     } catch (\Ginger\Client\ApiException $ex) {
         $this->setFlash('error', "Il n'a pas été possible de vous identifier. Merci de contacter simde@assos.utc.fr en précisant votre login et le code d'erreur " . $ex->getCode() . ".");
     }
     return false;
 }
예제 #7
0
 /**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param      PropelPDO $con
  * @return     int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws     PropelException
  * @see        save()
  */
 protected function doSave(PropelPDO $con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their coresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->asfGuardUser !== null) {
             if ($this->asfGuardUser->isModified() || $this->asfGuardUser->isNew()) {
                 $affectedRows += $this->asfGuardUser->save($con);
             }
             $this->setsfGuardUser($this->asfGuardUser);
         }
         if ($this->isNew() || $this->isModified()) {
             // persist changes
             if ($this->isNew()) {
                 $this->doInsert($con);
             } else {
                 $this->doUpdate($con);
             }
             $affectedRows += 1;
             $this->resetModified();
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
 public function populateFromFacebook($doSave = true)
 {
     $fb = $this->getFacebook();
     if (!($sfGuardUser = $this->getGuardUser())) {
         if ($email = $fb->getEmail()) {
             //-- Emails must be uniqe so start there
             $sfGuardUser = Doctrine::getTable('sfGuardUser')->findOneByEmailAddress($email);
         }
         if (!$sfGuardUser && ($fb_uid = $fb->getId())) {
             $sfGuardUser = Doctrine::getTable('sfGuardUser')->findOneByFacebookUid($fb_uid);
         }
         if (!$sfGuardUser) {
             $sfGuardUser = new sfGuardUser();
         }
     }
     //-- If it is in the session but not the guard User, add it to the guard user
     if (!$sfGuardUser->getFacebookAuthCode() && $this->getAttribute('facebook_auth_code')) {
         if (sfConfig::get('sf_logging_enabled')) {
             sfContext::getInstance()->getLogger()->info('--- DEBUG --- FB AUTH CODE in session but not the guard User');
         }
         $sfGuardUser->setFacebookAuthCode($this->getAttribute('facebook_auth_code'));
     }
     $sfGuardUser->populateWithFacebook($fb);
     if ($doSave) {
         $sfGuardUser->save();
         $this->signin($sfGuardUser);
     }
     //-- NOTE:  The $sfGuardUser MAY NOT be saved yet!
     $dispatcher = sfContext::getInstance()->getEventDispatcher();
     $dispatcher->notify(new sfEvent($sfGuardUser, 'm14tFacebook.connect', array()));
     return $sfGuardUser;
 }
 /**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param      PropelPDO $con
  * @return     int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws     PropelException
  * @see        save()
  */
 protected function doSave(PropelPDO $con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their coresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->asfGuardUser !== null) {
             if ($this->asfGuardUser->isModified() || $this->asfGuardUser->isNew()) {
                 $affectedRows += $this->asfGuardUser->save($con);
             }
             $this->setsfGuardUser($this->asfGuardUser);
         }
         // If this object has been modified, then save it to the database.
         if ($this->isModified()) {
             if ($this->isNew()) {
                 $pk = sfGuardRememberKeyPeer::doInsert($this, $con);
                 $affectedRows += 1;
                 // we are assuming that there is only 1 row per doInsert() which
                 // should always be true here (even though technically
                 // BasePeer::doInsert() can insert multiple rows).
                 $this->setNew(false);
             } else {
                 $affectedRows += sfGuardRememberKeyPeer::doUpdate($this, $con);
             }
             $this->resetModified();
             // [HL] After being saved an object is no longer 'modified'
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
예제 #10
0
 /**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     $databaseManager = new sfDatabaseManager($this->configuration);
     $user = new sfGuardUser();
     $user->setUsername($arguments['username']);
     $user->setPassword($arguments['password']);
     $user->save();
     $this->logSection('guard', sprintf('Create user "%s"', $arguments['username']));
 }
 /**
  * Tests saving a sfGuardUserSubredditMembership that identifies a User as
  * "blocked" for a particular Subreddit.  When this occurs, all existing
  * future EpisodeAssignments should be deleted because blocked users cannot
  * participate with the Subreddit.
  */
 public function testSavingBlockedUser()
 {
     // Establish fake Subreddit
     $subreddit = new Subreddit();
     $subreddit->setName(rand(0, 1000));
     $subreddit->setDomain(rand(0, 1000));
     $subreddit->save();
     // Establish User
     $user = new sfGuardUser();
     $user->setEmailAddress(rand(0, 100000));
     $user->setUsername(rand(0, 10000));
     $user->setIsValidated(1);
     $user->save();
     $user_id = $user->getIncremented();
     $this->assertNotEquals(0, $user_id);
     // Establish Episode for Subreddit
     $episode = new Episode();
     $episode->setSubreddit($subreddit);
     $episode->setReleaseDate(date('Y-m-d H:i:s', time() + 34000));
     $episode->save();
     $author_type = AuthorTypeTable::getInstance()->findOneBy('type', 'squid');
     $deadline = new Deadline();
     $deadline->setSubreddit($subreddit);
     $deadline->setAuthorType($author_type);
     $deadline->setSeconds(0);
     $deadline->save();
     $episode_assignment = new EpisodeAssignment();
     $episode_assignment->setSfGuardUser($user);
     $episode_assignment->setEpisode($episode);
     $episode_assignment->setAuthorType($author_type);
     $episode_assignment->save();
     $number_of_episodes = EpisodeAssignmentTable::getInstance()->createQuery()->select('COUNT(EpisodeAssignment.id)')->leftJoin('Episode')->where('subreddit_id = ?', $subreddit->getIncremented())->andWhere('EpisodeAssignment.sf_guard_user_id = ?', $user_id)->andWhere('Episode.release_date > NOW()')->groupBy('EpisodeAssignment.id')->count();
     $this->assertEquals(1, $number_of_episodes);
     // Establish User Membership as Blocked
     $blocked = MembershipTable::getInstance()->findOneBy('type', 'blocked');
     $user_membership = new sfGuardUserSubredditMembership();
     $user_membership->setSubreddit($subreddit);
     $user_membership->setSfGuardUser($user);
     $user_membership->setMembership($blocked);
     // Save Membership
     $user_membership->save();
     // Asert that User has zero Episodes
     $number_of_episodes = EpisodeAssignmentTable::getInstance()->createQuery()->select('COUNT(EpisodeAssignment.id)')->leftJoin('Episode')->where('subreddit_id = ?', $subreddit->getIncremented())->andWhere('EpisodeAssignment.sf_guard_user_id = ?', $user_id)->andWhere('Episode.release_date > NOW()')->groupBy('EpisodeAssignment.id');
     $sql = $number_of_episodes->getSqlQuery();
     $number_of_episodes = $number_of_episodes->count();
     $this->assertTrue(0 == $number_of_episodes, $sql . "\n" . $subreddit->getIncremented() . "\n" . $user_id);
     // Remove User Membership
     $user_membership->delete();
     // Delete User
     $user->delete();
     // Delete Episode
     $episode->delete();
     // Delete Deadline
     $deadline->delete();
     // Delete Subreddit
     $subreddit->delete();
 }
 /**
  * Gets or creates an sfGuardUser record by email
  * 
  * The password and any other information is auto-generated in sfGuardUser
  */
 public function getOrCreateUserByEmail($email)
 {
     $guardUser = $this->findOneByEmailAddress($email);
     if (!$guardUser) {
         $guardUser = new sfGuardUser();
         $guardUser->username = $email;
         $guardUser->save();
     }
     return $guardUser;
 }
예제 #13
0
 public function doSave($con = null)
 {
     $user = new sfGuardUser();
     $user->setUsername($this->getValue('username'));
     $user->setPassword($this->getValue('password'));
     // They must confirm their account first
     $user->setIsActive(false);
     $user->save();
     $this->userId = $user->getId();
     return parent::doSave($con);
 }
 /**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     $configuration = ProjectConfiguration::getApplicationConfiguration($arguments['application'], $options['env'], true);
     $databaseManager = new sfDatabaseManager($configuration);
     $user = new sfGuardUser();
     $user->setUsername($arguments['username']);
     $user->setPassword($arguments['password']);
     $user->setIsActive(true);
     $user->save();
     $this->logSection('guard', sprintf('Create user "%s"', $arguments['username']));
 }
예제 #15
0
 public function executeCreateUser(sfWebRequest $request)
 {
     $data = $request->getPostParameter('data');
     $user = new sfGuardUser();
     $user->username = $data['username'];
     $user->password = $data['password'];
     $user->save();
     $this->setTemplate('showUsers');
     //    $this->settings = Doctrine_Core::getTable('Settings')->findOneById(1);
     //    echo $this->getUser()->getGuardUser()->getUsername();
     //        $this->forward404Unless($this->settings);
 }
예제 #16
0
 public function newPerson($name)
 {
     // Creating sfGuardUser
     $guardUser = new sfGuardUser();
     $guardUser->set('name', $name);
     $guardUser->save();
     // Creating the Person
     $person = new Person();
     $person->set('name', $name);
     $person->set('sf_guard_user_id', $guardUser['id']);
     $person->save();
     return $person;
 }
예제 #17
0
 /**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     $databaseManager = new sfDatabaseManager($this->configuration);
     $user = new sfGuardUser();
     $user->setEmailAddress($arguments['email_address']);
     $user->setUsername($arguments['username']);
     $user->setPassword($arguments['password']);
     $user->setFirstName($arguments['first_name']);
     $user->setLastName($arguments['last_name']);
     $user->setIsActive(true);
     $user->setIsSuperAdmin($options['is-super-admin']);
     $user->save();
     $this->logSection('guard', sprintf('Create user "%s"', $arguments['username']));
 }
예제 #18
0
 public function createUser(array $guard_tab, $ei_user_tab)
 {
     $new_guard = new sfGuardUser();
     $new_guard->setId($guard_tab['id']);
     $new_guard->setUsername($guard_tab['username']);
     $new_guard->setFirstName($guard_tab['first_name']);
     $new_guard->setLastName($guard_tab['last_name']);
     $new_guard->setEmailAddress($guard_tab['email_address']);
     $new_guard->setPassword($guard_tab['password']);
     $new_guard->save();
     /* Création du EiUser */
     EiUserTable::createUser($ei_user_tab, $new_guard->getId());
     return $new_guard;
 }
예제 #19
0
 /**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     $databaseManager = new sfDatabaseManager($this->configuration);
     $user = new sfGuardUser();
     $user->setUsername($arguments['username']);
     $user->setPassword($arguments['password']);
     $user->save();
     $profile = new Profile();
     $profile->setNickname($arguments['nickname']);
     $profile->setEmail($arguments['email']);
     $profile->setSfGuardUserId($user->getId());
     $profile->save();
     $this->logSection('crew', sprintf('Create user "%s"', $arguments['username']));
 }
 public function doSave($con = null)
 {
     if ($this->isNew) {
         $user = new sfGuardUser();
         $user->setUsername($this->getValue('username'));
         $user->setPassword($this->getValue('password'));
         $user->setEmailAddress($this->getValue('email'));
         $user->addGroupByName(sfConfig::get('app_user_default_group'));
         // They must confirm their account first
         $user->setIsActive(false);
         $user->save();
         $this->getObject()->setUserId($user->getId());
     }
     return parent::doSave($con);
 }
예제 #21
0
파일: actions.class.php 프로젝트: EQ4/smint
 public function executeApply()
 {
     $request = $this->getRequest();
     $this->form = new RegisterForm();
     if ($this->getRequest()->getMethod() == sfRequest::POST) {
         $this->form->bind($request->getParameter('register'));
         if ($this->form->isValid()) {
             mysfLog::log($this, "DEBUG: " . print_r($this->form->getValues(), TRUE));
             $this->form_ref =& $this->form;
             $username = $this->form->getValue('email');
             $password = $this->form->getValue('password');
             $sfGuardUser = new sfGuardUser();
             $sfGuardUser->setUsername($username);
             $sfGuardUser->setPassword($password);
             // Not until confirmed
             $sfGuardUser->setIsActive(false);
             $profile = $sfGuardUser->getProfile();
             $sfGuardUser->save();
             // save sfGuardUser before we populate the user profile because we need the user id
             $this->myPopulateProfileSettings($profile, $sfGuardUser);
             $profile->save();
             // Email start
             $opts = array();
             $opts['from_name'] = sfConfig::get('app_mail_fromname', "Spectralmind");
             $opts['from_email'] = sfConfig::get('app_mail_from', "*****@*****.**");
             $opts['parameters'] = array('validate' => $profile->getValidate());
             $opts['body_is_partial'] = true;
             $opts['to_name'] = $profile->getName();
             $opts['to_email'] = $profile->getEmail();
             $opts['subject'] = sfConfig::get('app_mail_subjectconfirmmail', "Confirm your registration");
             //$opts['html'] = "sendValidateNew";
             $opts['text'] = "sendValidateNew";
             /*
             				 // Or to use the Echo Logger
             				 $logger = new Swift_Plugins_Loggers_EchoLogger();
             				 $this->getMailer()->registerPlugin(new Swift_Plugins_LoggerPlugin($logger));
             				 * */
             $numSent = smintMailHelper::mail($opts);
             // not sent? react accordingly
             if ($numSent != 1) {
                 mysfLog::log($this, "ERROR: confirmation email not sent. Return value was {$numSent}");
                 return 'Error';
             }
             mysfLog::log($this, "DEBUG: Confirm link:" . url_for("sfApply/confirm?validate=" . $profile->getValidate(), true));
             return 'After';
         }
     }
 }
예제 #22
0
 /**
  * DOCUMENT ME
  * @return mixed
  */
 public static function getTaskUser()
 {
     $user = Doctrine::getTable('sfGuardUser')->findOneByUsername('ataskuser');
     if (!$user) {
         $user = new sfGuardUser();
         $user->setUsername('ataskuser');
         // Set a good unique password just in case someone cluelessly sets the active flag.
         // This further ensures that no one can ever log in with this account
         $user->setPassword(aGuid::generate());
         // Prevents normal login
         $user->setIsActive(false);
         $user->setIsSuperAdmin(true);
         $user->save();
     }
     return $user;
 }
 /**
  * Create a user for a Facebook account
  *
  * Based on and borrowed heavily from
  * sfFacebookGuardAdapter::createSfGuardUserWithFacebookUidAndCon in
  * sfFacebookConnectPlugin by Fabrice Bernhard
  *
  * @param   int     $facebookUid
  * @param   string  $accessToken
  * @param   int     $accessTokenExpiry
  * @param   array   $facebookUserInfo
  * @return  sfGuardUser
  */
 public static function createUser($facebookUid, $accessToken, $accessTokenExpiry, array $facebookUserInfo)
 {
     $sfGuardUser = new sfGuardUser();
     $sfGuardUser->setUsername(self::generateFacebookUsername($facebookUid));
     $connection = Doctrine::getConnectionByTableName('sfGuardUser');
     try {
         $connection->beginTransaction();
         $sfGuardUser->save();
         $sfGuardUser->getProfile()->setFacebookOnlyAccount(true)->_connectToFacebook($facebookUid, $accessToken, $accessTokenExpiry, $facebookUserInfo, $sfGuardUser);
         $connection->commit();
     } catch (Exception $e) {
         $connection->rollback();
         throw $e;
     }
     return $sfGuardUser;
 }
예제 #24
0
 protected function sync_accounts_maint()
 {
     //query all accounts
     $q = Doctrine_Query::create()->select("*")->from("RidAccounts")->setHydrationMode(Doctrine::HYDRATE_ARRAY);
     $results = $q->execute();
     //check for record in SfGuardUser
     foreach ($results as $r) {
         $this->SfGuardUserSync = Doctrine_Core::getTable('SfGuardUser')->findOneByEmailAddress($r['email']);
         //if missing create
         if ($this->SfGuardUserSync == '') {
             //doctrine, create record in sf_guard_user
             $NewFacebookUser = new sfGuardUser();
             //$NewFacebookUser->id            = $r['id'];
             $NewFacebookUser->email_address = $r['email'];
             $NewFacebookUser->save();
         }
     }
 }
예제 #25
0
 public static function updateOrCreateFbUser($profile)
 {
     $sfGuardUser = Doctrine_Core::getTable('sfGuardUser')->findOneByFacebookId($profile['id']);
     if (!$sfGuardUser) {
         $sfGuardUser = new sfGuardUser();
         $sfGuardUser->setUsername('FB_' . $profile['id']);
         $sfGuardUser->facebook_id = $profile['id'];
         $sfGuardUser->first_name = $profile['first_name'];
         $sfGuardUser->last_name = $profile['last_name'];
         if (array_key_exists('email', $profile)) {
             $sfGuardUser->email_address = $profile['email'];
         } else {
             $sfGuardUser->email_address = $profile['id'] . '@fb.com';
         }
         $sfGuardUser->save();
     }
     return $sfGuardUser;
 }
예제 #26
0
 protected function setUp()
 {
     $conn = Doctrine_Manager::connection('sqlite://memory', 'doctrine');
     Doctrine_Manager::getInstance()->setCurrentConnection('doctrine');
     try {
         Doctrine_Manager::getInstance()->dropDatabases('doctrine');
     } catch (Doctrine_Export_Exception $e) {
         /* database did not exist so ignore.. */
     }
     Doctrine_Manager::getInstance()->createDatabases('doctrine');
     Doctrine_Core::createTablesFromArray(array('sfGuardUser', 'UserLoginHistory'));
     $sfGuardUser = new sfGuardUser();
     $sfGuardUser->username = '******';
     $sfGuardUser->first_name = 'Christian';
     $sfGuardUser->last_name = 'Schaefer';
     $sfGuardUser->email_address = '*****@*****.**';
     $sfGuardUser->save();
 }
예제 #27
0
 /**
  * This is a symfony workaround. As soon as someone logs in check if they are in the DB.
  * If they aren't just insert them so they can authenticate.
  *
  * @param sfWebRequest $request
  */
 public function executeSignin($request)
 {
     if ($request->isMethod("post")) {
         $form = new sfGuardFormSignin();
         $username = $request->getParameter($form->getName() . "[username]");
         $c = new Criteria();
         $c->add(sfGuardUserPeer::USERNAME, $username);
         $res = sfGuardUserPeer::doCount($c);
         // if they dont exist in the db then stick them in so LDAP works
         if ($res == 0) {
             $u = new sfGuardUser();
             $u->setUsername($username);
             $u->save();
             $u->getProfile();
         }
     }
     parent::executeSignin($request);
 }
예제 #28
0
 public function executeApply()
 {
     if ($this->getRequest()->getMethod() == sfRequest::POST) {
         $username = $this->getRequestParameter('username');
         $password = $this->getRequestParameter('password');
         $sfGuardUser = new sfGuardUser();
         $sfGuardUser->setUsername($username);
         $sfGuardUser->setPassword($password);
         // Not until confirmed
         $sfGuardUser->setIsActive(false);
         $profile = $sfGuardUser->getProfile();
         $this->populateProfileSettings($profile);
         $sfGuardUser->save();
         $profile->save();
         $this->setFlash('sfApplyPlugin_id', $sfGuardUser->getId(), false);
         $this->sendEmail('sfApply', 'sendValidate');
         return 'After';
     }
 }
예제 #29
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();
     }
 }