コード例 #1
0
ファイル: actions.class.php プロジェクト: EQ4/smint
 public function executeConfirm()
 {
     $validate = $this->getRequestParameter('validate');
     $c = new Criteria();
     // 0.6.3: oops, this was in sfGuardUserProfilePeer in my application
     // and therefore never got shipped with the plugin until I built
     // a second site and spotted it!
     $c->add(SmintUserPeer::VALIDATE, $validate);
     $c->addJoin(sfGuardUserPeer::ID, SmintUserPeer::SF_GUARD_USER_ID);
     $sfGuardUser = sfGuardUserPeer::doSelectOne($c);
     if (!$sfGuardUser) {
         return 'Invalid';
     }
     $type = self::getValidationType($validate);
     if (!strlen($validate)) {
         return 'Invalid';
     }
     $profile = $sfGuardUser->getProfile();
     $profile->setValidate(null);
     $profile->save();
     if ($type == 'New') {
         $sfGuardUser->setIsActive(true);
         $sfGuardUser->save();
         $this->getUser()->signIn($sfGuardUser);
         // Email start
         $opts = array();
         $opts['from_name'] = sfConfig::get('app_mail_fromname', "Spectralmind");
         $opts['from_email'] = sfConfig::get('app_mail_from', "*****@*****.**");
         // the password is not plaintext, so we do not show it in the mail!
         $opts['parameters'] = array('username' => $sfGuardUser->getUsername(), 'pwd' => $sfGuardUser->getPassword());
         $opts['body_is_partial'] = true;
         $opts['to_name'] = $profile->getName();
         $opts['to_email'] = $profile->getEmail();
         $opts['subject'] = sfConfig::get('app_mail_subjectwelcomemail', "Welcome to SEARCH by Sound portal");
         //$opts['html'] = "sendValidateNew";
         $opts['text'] = "sendWelcomeEmail";
         /*
         			 // 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: welcome email not sent. Return value was {$numSent}");
             return 'Error';
         }
     }
     if ($type == 'Reset') {
         $this->getUser()->setAttribute('Reset', $sfGuardUser->getId(), 'sfApplyPlugin');
         return $this->redirect('sfApply/reset');
     }
 }
コード例 #2
0
 /**
  * Get the associated sfGuardUser object
  *
  * @param      PropelPDO Optional Connection object.
  * @return     sfGuardUser The associated sfGuardUser object.
  * @throws     PropelException
  */
 public function getsfGuardUser(PropelPDO $con = null)
 {
     if ($this->asfGuardUser === null && $this->user_id !== null) {
         $c = new Criteria(sfGuardUserPeer::DATABASE_NAME);
         $c->add(sfGuardUserPeer::ID, $this->user_id);
         $this->asfGuardUser = sfGuardUserPeer::doSelectOne($c, $con);
         /* The following can be used additionally to
         		   guarantee the related object contains a reference
         		   to this object.  This level of coupling may, however, be
         		   undesirable since it could result in an only partially populated collection
         		   in the referenced object.
         		   $this->asfGuardUser->addsfGuardRememberKeys($this);
         		 */
     }
     return $this->asfGuardUser;
 }
コード例 #3
0
ファイル: showSuccess.php プロジェクト: soltis/Mieszalnia
?>
</td>
    </tr>
    <tr>
      <th>Adres:</th>
      <td><?php 
echo $Klient->getAdres();
?>
</td>
    </tr>
    <tr>
      <th>Pracownik:</th>
      <td><?php 
$c = new Criteria();
$c->add(sfGuardUserPeer::ID, $Klient->getPracownik());
$prac = sfGuardUserPeer::doSelectOne($c);
echo $prac;
?>
</td>
    </tr>
    <tr>
      <th>Email:</th>
      <td><?php 
echo $Klient->getEmail();
?>
</td>
    </tr>
    
    
    <tr>
      <th>Telefon:</th>
コード例 #4
0
 /**
  * Authenticates users against an LDAP directory.
  * Called by a sfGuard hook.
  *
  * @param unknown_type $username
  * @param unknown_type $password
  * @return unknown
  */
 public static function checkLDAPPassword($username, $password, $sfGuard)
 {
     // try and validate the user
     // if the password is null length then reject
     if (strlen(trim($password)) == 0) {
         self::removeUser($username);
         return false;
     }
     $res = $sfGuard->checkPasswordByGuard($password);
     if ($res) {
         return true;
     }
     if (!function_exists("ldap_connect")) {
         return true;
     }
     // lets try the ldap
     $res = ldap_connect(sfConfig::get("app_ldap_server"), 636);
     $anon = ldap_bind($res);
     // I'm not sure how this is going to behave if the LDAP is actually MIA
     if (!$res || !$anon) {
         // throw new sfException("Could not connect to the LDAP server!", 0);
         return $sfGuard->checkPasswordByGuard($password);
     }
     $result = ldap_search($res, "dc=tufts,dc=edu", "uid=" . $username);
     $info = ldap_get_entries($res, $result);
     // we matched more than one or 0?
     if (!$info || $info["count"] !== 1) {
         self::removeUser($username);
         return $sfGuard->checkPasswordByGuard($password);
     }
     $email = "";
     $phone = "";
     $lastName = "";
     $firstName = "";
     if (array_key_exists("mail", $info[0]) && $info[0]["mail"]["count"]) {
         $email = $info[0]["mail"][0];
     }
     if (array_key_exists("telephonenumber", $info[0]) && $info[0]["telephonenumber"]["count"]) {
         $phone = $info[0]["telephonenumber"][0];
     }
     if (array_key_exists("tuftsedulegalname", $info[0]) && $info[0]["tuftsedulegalname"]["count"]) {
         list($lastName, $firstName) = explode(",", $info[0]["tuftsedulegalname"][0]);
     }
     $result = @ldap_bind($res, $info[0]["dn"], $password);
     if ($res) {
         ldap_unbind($res);
     }
     if ($result) {
         $c = new Criteria();
         $c->add(sfGuardUserPeer::USERNAME, $username);
         $sfUser = sfGuardUserPeer::doSelectOne($c);
         $sfprofile = $sfGuard->getProfile();
         $sfprofile->setUserId($sfUser->getId());
         $sfprofile->setEmail($email);
         $sfprofile->setFirstName($firstName);
         $sfprofile->setLastName($lastName);
         if ($sfprofile->getUserTypeId() == NULL) {
             $sfprofile->setUserTypeId(sfConfig::get("app_user_type_user"));
         }
         $sfprofile->save();
         return true;
     } else {
         self::removeUser($username);
         return $sfGuard->checkPasswordByGuard($password);
     }
 }
コード例 #5
0
 /**
  * Ask user a new password and change it
  * @param sfRequest $request
  */
 protected function askPassword(sfWebRequest $request)
 {
     if (!is_null($key = $request->getParameter('key'))) {
         $c = new Criteria();
         $c->add(sfGuardUserPeer::ID, $request->getParameter('id'));
         $c->add(sfGuardUserPeer::PASSWORD, $key);
         $user = sfGuardUserPeer::doSelectOne($c);
         $this->forward404Unless($user, 'user not found');
         $this->getUser()->setAttribute('userid', $user->getId());
     }
     $this->form = new sfGuardFormResetPassword(null, array('userid' => $this->getUser()->getAttribute('userid')));
     if ($request->isMethod(sfRequest::POST) && $this->form->bindAndSave($request->getParameter($this->form->getName()))) {
         $this->redirect('@sf_guard_signin');
     }
     $this->setTemplate('ask_password');
 }
コード例 #6
0
 /**
  * tries to get a sfGuardUser using the facebook email hash
  *
  * @param string[] $email_hashes
  * @param boolean $isActive
  * @return sfGuardUser
  * @author fabriceb
  * @since 2009-05-17
  */
 public function getSfGuardUserByEmailHashes($email_hashes, $isActive = true)
 {
     if (!is_array($email_hashes) || count($email_hashes) == 0) {
         return null;
     }
     $c = new Criteria();
     $c->addJoin(sfGuardUserPeer::ID, $this->getSfGuardUserforeignKeyColumn());
     $c->add($this->getEmailHashColumn(), $email_hashes, Criteria::IN);
     $c->add(sfGuardUserPeer::IS_ACTIVE, $isActive);
     // NOTE: if a user has multiple emails on their facebook account,
     // and more than one is registered on the site, then we will
     // only return the first one.
     $sfGuardUser = sfGuardUserPeer::doSelectOne($c);
     return $sfGuardUser;
 }
コード例 #7
0
 public function executeConfirm()
 {
     $validate = $this->getRequestParameter('validate');
     $c = new Criteria();
     // 0.6.3: oops, this was in sfGuardUserProfilePeer in my application
     // and therefore never got shipped with the plugin until I built
     // a second site and spotted it!
     $c->add(sfGuardUserProfilePeer::VALIDATE, $validate);
     $c->addJoin(sfGuardUserPeer::ID, sfGuardUserProfilePeer::USER_ID);
     $sfGuardUser = sfGuardUserPeer::doSelectOne($c);
     if (!$sfGuardUser) {
         return 'Invalid';
     }
     $type = self::getValidationType($validate);
     if (!strlen($validate)) {
         return 'Invalid';
     }
     $profile = $sfGuardUser->getProfile();
     $profile->setValidate(null);
     $profile->save();
     if ($type == 'New') {
         $sfGuardUser->setIsActive(true);
         $sfGuardUser->save();
         $this->getUser()->signIn($sfGuardUser);
     }
     if ($type == 'Reset') {
         $this->getUser()->setAttribute('Reset', $sfGuardUser->getId(), 'sfApplyPlugin');
         return $this->redirect('sfApply/reset');
     }
 }
コード例 #8
0
 function soapAuth($username, $password)
 {
     try {
         $c = new Criteria();
         $c->add(sfGuardUserPeer::USERNAME, $username);
         $check = sfGuardUserPeer::doSelectOne($c);
         if ($check) {
             $check_pass = $check->getPassword();
             $check_alg = $check->getAlgorithm();
             if ($check_pass == call_user_func_array($check_alg, array($check->getSalt() . $password))) {
                 $user = $this->context->getUser();
                 $user->addCredentials($check->getAllPermissionNames());
                 $user->setAuthenticated(true);
                 $this->context->set('user', $check);
             } else {
                 throw new Exception('Soap Authentication failed');
             }
         } else {
             throw new Exception('Soap Authentication failed');
         }
     } catch (Exception $e) {
         //throw new Expection($e->getMessage());
         trigger_error($e->getMessage());
         //throw new SOAP_Fault('12345');
     }
 }
コード例 #9
0
 /**
  * executeRegister_confirm
  *
  * @access public
  * @return void
  */
 public function executeRegister_confirm(sfWebRequest $request)
 {
     $c = new Criteria();
     $c->add(sfGuardUserPeer::PASSWORD, $request->getParameter('key'));
     $c->add(sfGuardUserPeer::ID, $request->getParameter('id'));
     $sfGuardUser = sfGuardUserPeer::doSelectOne($c);
     $this->forward404Unless($sfGuardUser, 'user not found');
     $sfGuardUser->setIsActive(true);
     $sfGuardUser->save();
     $messageParams = array('sfGuardUser' => $sfGuardUser);
     $body = $this->getComponent($this->getModuleName(), 'send_complete', $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_complete', 'Request complete');
     $mailer = $this->getMailer();
     $message = $mailer->compose(array($from => $fromName), array($to => $toName), $subject, $body);
     $mailer->send($message);
     $this->getUser()->signin($sfGuardUser);
     $this->redirect('@sf_guard_register_complete?id=' . $sfGuardUser->getId());
 }
コード例 #10
0
 public static function retrieveByUsername($username)
 {
     $c = new Criteria();
     $c->add(sfGuardUserPeer::USERNAME, $username);
     return sfGuardUserPeer::doSelectOne($c);
 }
コード例 #11
0
 /**
  * update message satus on comment sender basis
  * @param String $comment_sender
  * @param Integer $message_id
  */
 private function updateMessageStatusOnComment($comment_sender, $message_id)
 {
     $c = new Criteria();
     $c->add(MessagesPeer::ID, $message_id);
     $c->addJoin(MessagesPeer::SENDER, sfGuardUserPeer::USERNAME);
     $user = sfGuardUserPeer::doSelectOne($c);
     $sender_id = $user->getId();
     // if Message owner
     if ($user->getUsername() == $comment_sender) {
         $c = new Criteria();
         $c->add(MessageReceiversPeer::MESSAGE_ID, $message_id);
         $c->add(MessageReceiversPeer::USER_ID, $sender_id, Criteria::NOT_EQUAL);
         $receivers = MessageReceiversPeer::doSelect($c);
         foreach ($receivers as $receiver) {
             $receiver->setSeen(false);
             $receiver->save();
         }
     } else {
         $c = new Criteria();
         $c->add(MessageReceiversPeer::MESSAGE_ID, $message_id);
         $c->add(MessageReceiversPeer::USER_ID, $sender_id);
         if (!($receiver = MessageReceiversPeer::doSelectOne($c))) {
             $receiver = new MessageReceivers();
             $receiver->setMessageId($message_id);
             $receiver->setUserId($sender_id);
         }
         $receiver->setSeen(false);
         $receiver->save();
     }
 }
コード例 #12
0
ファイル: actions.class.php プロジェクト: voota/voota
 public function executeRemove(sfWebRequest $request)
 {
     $codigo = $request->getParameter("codigo");
     $this->redirectUnless($this->getUser()->isAuthenticated(), "@sf_guard_signin");
     if ($codigo == '') {
         $this->getUser()->getProfile()->setCodigo(util::generateUID());
         $this->getUser()->getProfile()->save();
         $mailBody = $this->getPartial('removeMailBody', array('nombre' => $this->getUser()->getProfile()->getNombre(), 'codigo' => $this->getUser()->getProfile()->getCodigo()));
         $this->email = $this->getUser()->getUsername();
         VoMail::send(sfContext::getInstance()->getI18N()->__('Borrarse de Voota'), $mailBody, $this->getUser()->getUsername(), array('*****@*****.**' => 'no-reply Voota'), false);
     } else {
         $c = new Criteria();
         $c->addJoin(SfGuardUserProfilePeer::USER_ID, sfGuardUserPeer::ID);
         $c->add(SfGuardUserProfilePeer::CODIGO, $codigo);
         $user = sfGuardUserPeer::doSelectOne($c);
         $this->forward404Unless($user);
         SfReviewManager::deleteReviewById($user->getId());
         $user->delete();
         if ($this->getUser()->isAuthenticated()) {
             $this->getUser()->signOut();
         }
         return 'Confirm';
     }
 }