/var/www/vhosts/nabawater/vendor/dektrium/yii2-user/models
NameSizeModeActions
query/-0755rm
Account.php62690644editdlrm
LoginForm.php50920644editdlrm
Profile.php48050644editdlrm
RecoveryForm.php36950644editdlrm
RegistrationForm.php37850644editdlrm
ResendForm.php25420644editdlrm
SettingsForm.php64520644editdlrm
Token.php29670644editdlrm
User.php177590644editdlrm
UserSearch.php29660644editdlrm
Edit: /var/www/vhosts/nabawater/vendor/dektrium/yii2-user/models/Profile.php (4805B)
* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace dektrium\user\models; 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 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], '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'), ]; } /** * 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}}'; } }