# OpenIdExtensionSreg.class.php

Go to the documentation of this file.

    00001 <?php
    00002 /***************************************************************************
    00003  *   Copyright (C) 2010 by Alexander V. Solomatin                          *
    00004  *                                                                         *
    00005  *   This program is free software; you can redistribute it and/or modify  *
    00006  *   it under the terms of the GNU Lesser General Public License as        *
    00007  *   published by the Free Software Foundation; either version 3 of the    *
    00008  *   License, or (at your option) any later version.                       *
    00009  *                                                                         *
    00010  ***************************************************************************/
    00011
    00018     final class OpenIdExtensionSreg implements OpenIdExtension
    00019     {
    00020         const NAMESPACE_1_1 = "http://openid.net/extensions/sreg/1.1";
    00021
    00022         const PARAM_NICKNAME        = 'nickname';
    00023         const PARAM_EMAIL           = 'email';
    00024         const PARAM_FULLNAME        = 'fullname';
    00025         const PARAM_DATE_OF_BIRTH   = 'dob';
    00026         const PARAM_GENDER          = 'gender';
    00027         const PARAM_POSTCODE        = 'postcode';
    00028         const PARAM_COUNTRY         = 'country';
    00029         const PARAM_LANGUAGE        = 'language';
    00030         const PARAM_TIMEZONE        = 'timezone';
    00031
    00032         private $params = array();
    00033         private $version = '1.1';
    00034         private $nickname       = null;
    00035         private $email          = null;
    00036         private $fullname       = null;
    00037         private $dob            = null;
    00038         private $gender         = null;
    00039         private $postcode       = null;
    00040         private $country        = null;
    00041         private $language       = null;
    00042         private $timezone       = null;
    00043
    00047         public static function create()
    00048         {
    00049             return new self();
    00050         }
    00051
    00055         public function addParamsToModel(Model $model)
    00056         {
    00057             if ($this->version == '1.1') {
    00058                 $model->set('openid.ns.sreg', self::NAMESPACE_1_1);
    00059             }
    00060
    00061             $model->set('openid.sreg.optional', implode(',', $this->params));
    00062
    00063         }
    00064
    00069         public function parseResponce(HttpRequest $request, array $params)
    00070         {
    00071             foreach ($this->params as $param) {
    00072                 $this->$param = null;
    00073                 if (isset($params['openid.sreg_'.$param])) {
    00074                     $this->$param = $params['openid.sreg_'.$param];
    00075                 }
    00076             }
    00077         }
    00078
    00079         public function getVersion()
    00080         {
    00081             return $this->version;
    00082         }
    00083
    00088         public function addParam($paramName)
    00089         {
    00090             $this->params []= $paramName;
    00091
    00092             return $this;
    00093         }
    00094
    00098         public function dropParams()
    00099         {
    00100             $this->params = array();
    00101
    00102             return $this;
    00103         }
    00104
    00109         public function setVersion($version)
    00110         {
    00111             $this->version = $version;
    00112
    00113             return $this;
    00114         }
    00115
    00116         public function getNickname()
    00117         {
    00118             return $this->nickname;
    00119         }
    00120
    00121         public function getEmail()
    00122         {
    00123             return $this->email;
    00124         }
    00125
    00126         public function getFullname()
    00127         {
    00128             return $this->fullname;
    00129         }
    00130
    00131         public function getDateOfBirth()
    00132         {
    00133             return $this->dob;
    00134         }
    00135
    00136         public function getGender()
    00137         {
    00138             return $this->gender;
    00139         }
    00140
    00141         public function getPostcode()
    00142         {
    00143             return $this->postcode;
    00144         }
    00145
    00146         public function getCountry()
    00147         {
    00148             return $this->country;
    00149         }
    00150
    00151         public function getLanguage()
    00152         {
    00153             return $this->language;
    00154         }
    00155
    00156         public function getTimezone()
    00157         {
    00158             return $this->timezone;
    00159         }
    00160     }
    00161 ?>