%PDF-1.5 %���� ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµùÕ5sLOšuY
Server IP : 49.231.201.246 / Your IP : 216.73.216.149 Web Server : Apache/2.4.18 (Ubuntu) System : Linux 246 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64 User : root ( 0) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : exec,passthru,shell_exec,system,proc_open,popen,pcntl_exec MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /proc/11584/cwd/html/ppaobm/backend/models/ |
Upload File : |
<?php /* * This file is part of the Dektrium project. * * (c) Dektrium project <http://github.com/dektrium/> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace backend\models; use dektrium\user\models\Profile as BaseProfile; use dektrium\user\traits\ModuleTrait; use yii\db\ActiveRecord; /** * This is the model class for table "profile". * * @property integer $user_id * @property string $name * @property string $public_email * @property string $gravatar_email * @property string $gravatar_id * @property string $location * @property string $website * @property string $bio * @property string $timezone * @property User $user * * @author Dmitry Erofeev <dmeroff@gmail.com */ class Profile extends BaseProfile { use ModuleTrait; /** @var \dektrium\user\Module */ protected $module; /** @inheritdoc */ public function init() { $this->module = \Yii::$app->getModule('user'); } /** * Returns avatar url or null if avatar is not set. * @param int $size * @return string|null */ public function getAvatarUrl($size = 200) { return '//gravatar.com/avatar/' . $this->gravatar_id . '?s=' . $size; } /** * @return \yii\db\ActiveQueryInterface */ public function getUser() { return $this->hasOne($this->module->modelMap['User'], ['id' => 'user_id']); } /** * @inheritdoc */ public function rules() { return [ 'bioString' => ['bio', 'string'], 'timeZoneValidation' => ['timezone', 'validateTimeZone'], 'publicEmailPattern' => ['public_email', 'email'], 'gravatarEmailPattern' => ['gravatar_email', 'email'], 'websiteUrl' => ['website', 'url'], 'nameLength' => ['name', 'string', 'max' => 255], 'publicEmailLength' => ['public_email', 'string', 'max' => 255], 'gravatarEmailLength' => ['gravatar_email', 'string', 'max' => 255], 'locationLength' => ['location', 'string', 'max' => 255], 'departmentsLength' => ['departments', 'string', 'max' => 255], 'workLength' => ['work', 'string', 'max' => 255], 'websiteLength' => ['website', 'string', 'max' => 255], ]; } /** * @inheritdoc */ public function attributeLabels() { return [ 'name' => \Yii::t('user', 'Name'), 'public_email' => \Yii::t('user', 'Email (public)'), 'gravatar_email' => \Yii::t('user', 'Gravatar email'), 'location' => \Yii::t('user', 'Location'), 'website' => \Yii::t('user', 'Website'), 'bio' => \Yii::t('user', 'Bio'), 'timezone' => \Yii::t('user', 'Time zone'), 'departments' => 'หน่วยงาน', 'work' => 'งาน', ]; } /** * Validates the timezone attribute. * Adds an error when the specified time zone doesn't exist. * @param string $attribute the attribute being validated * @param array $params values for the placeholders in the error message */ public function validateTimeZone($attribute, $params) { if (!in_array($this->$attribute, timezone_identifiers_list())) { $this->addError($attribute, \Yii::t('user', 'Time zone is not valid')); } } /** * Get the user's time zone. * Defaults to the application timezone if not specified by the user. * @return \DateTimeZone */ public function getTimeZone() { try { return new \DateTimeZone($this->timezone); } catch (\Exception $e) { // Default to application time zone if the user hasn't set their time zone return new \DateTimeZone(\Yii::$app->timeZone); } } /** * Set the user's time zone. * @param \DateTimeZone $timezone the timezone to save to the user's profile */ public function setTimeZone(\DateTimeZone $timeZone) { $this->setAttribute('timezone', $timeZone->getName()); } /** * Converts DateTime to user's local time * @param \DateTime the datetime to convert * @return \DateTime */ public function toLocalTime(\DateTime $dateTime = null) { if ($dateTime === null) { $dateTime = new \DateTime(); } return $dateTime->setTimezone($this->getTimeZone()); } /** * @inheritdoc */ public function beforeSave($insert) { if ($this->isAttributeChanged('gravatar_email')) { $this->setAttribute('gravatar_id', md5(strtolower(trim($this->getAttribute('gravatar_email'))))); } return parent::beforeSave($insert); } /** * @inheritdoc */ public static function tableName() { return '{{%profile}}'; } }