Example #1
0
 public function loginAction()
 {
     $this->view->status = "";
     if ($this->_request->isPost() && $this->_request->getPost('openid_action') == 'login' && $this->_request->getPost('openid_identifier', '') !== '' || $this->_request->isPost() && $this->_request->getPost('openid_mode') !== null || !$this->_request->isPost() && $this->_request->getQuery('openid_mode') != null) {
         // Begin If.
         Zend_Loader::loadClass('Zend_Auth_Adapter_OpenId');
         $auth = Zend_Auth::getInstance();
         $result = $auth->authenticate(new Zend_Auth_Adapter_OpenId($this->_request->getPost('openid_identifier')));
         if ($result->isValid()) {
             $user = User::find($result->getIdentity());
             if (!$user) {
                 $user = new User();
                 $user->setUid($result->getIdentity());
                 $this->getEntityManager()->persist($user);
             }
             $user->setLastLogin();
             $this->getEntityManager()->flush();
             $this->_redirect('admin/index');
         } else {
             $auth->clearIdentity();
             foreach ($result->getMessages() as $message) {
                 $this->view->status .= "{$message}<br>\n";
             }
         }
     }
     $this->render();
 }
Example #2
0
 public static function testUpdate()
 {
     $user = new User();
     $user->setId(11);
     // set primary key for update
     $user->setUid('xinerd');
     $user->setPassword('test');
     $user->setAge(26);
     $user = UserDAOImpl::doUpdate($user);
 }
Example #3
0
    protected $_nation;
    public function getUid()
    {
        return $this->_uid;
    }
    public function setUid($uid)
    {
        $this->_uid = $uid;
        return $this;
    }
    public function getNationality()
    {
        return $this->_nation;
    }
    public function setNationality($nation)
    {
        $this->_nation = $nation;
        return $this;
    }
    public function __toString()
    {
        return "User: #{$this->_uid}. " . $this->_nation->getNationalityDeclaration($this->_uid);
    }
}
$user = new User();
$user->setUid(714673)->setNationality(Nationality::getInstance('Italia'));
echo $user, "\n";
// changing a Flyweight means referencing a new instance
// (which may actually already exist in the FlyweightFactory)
$user->setNationality(Nationality::getInstance('Australia'));
echo $user, "\n";