?> <?php echo Html::a('', ['/login/facebook'], [' class' => 'oauth-fb', 'title' => 'Войти с помощью аккаунта Facebook', 'rel' => 'external nofollow']); ?> </div> <?php } else { $identity = Yii::$app->getUser()->getIdentity(); ?> <div class="ava"> <?php echo "<span class='hidden-xs'>" . Html::beginTag('a', ['href' => '/me', 'title' => 'Личный кабинет']); $options = ['alt' => 'Аватар', 'title' => 'Аватар', 'class' => 'avatar']; if (isset($identity->photo) && $identity->photo) { echo Html::img(CFF::getThumb($identity->photo), $options); } else { if (isset($identity->gender) && $identity->gender == 2) { echo Html::img('/css/image/f_pic.png', $options); } else { echo Html::img('/css/image/m_pic.png', $options); } } echo "</span>" . Html::endTag('a'); echo '<i class="glyphicon glyphicon-user hidden-lg hidden-md hidden-sm"></i> '; if (isset($identity->first_name)) { echo Html::a($identity->first_name, ['/me'], ['class' => 'enter link', 'title' => 'Личный кабинет']); } echo ' <span class="hidden-xs"></br></span>' . Html::a('Выйти', ['/logout'], ['class' => 'enter link', 'title' => 'Выйти из аккаунта']); ?> </div>
/** * @param $id * @return bool * Удаление файлов для возможных файлов "быстрых" полей */ public function deletePhoto($id) { $option = 'option_' . $id; if (isset($this->{$option}) && $this->{$option}) { if (file_exists(self::FROM_ADM_PATH . $this->{$option})) { unlink(self::FROM_ADM_PATH . $this->{$option}); } $thumb = CFF::getThumb($this->{$option}); if (file_exists(self::FROM_ADM_PATH . $thumb)) { unlink(self::FROM_ADM_PATH . $thumb); } $this->{$option} = null; } return true; }
/** * @return bool */ public function deletePhoto() { if ($this->value) { if (file_exists(Document::FROM_ADM_PATH . $this->value)) { unlink(Document::FROM_ADM_PATH . $this->value); } $thumb = CFF::getThumb($this->value); if (file_exists(Document::FROM_ADM_PATH . $thumb)) { unlink(Document::FROM_ADM_PATH . $thumb); } $this->value = null; } return true; }
<?php use common\helpers\CFF; use yii\helpers\Html; /* @var $this yii\web\View */ /* @var $model common\models\User */ ?> <div class="usercart row"> <div class="col-sm-2"> <?php $options = ['alt' => 'Аватар', 'title' => 'Аватар', 'class' => 'avatar']; if (isset($model->photo) && $model->photo) { echo Html::img(CFF::getThumb($model->photo), $options); } else { if (isset($model->gender) && $model->gender == 2) { echo Html::img('/css/image/f_pic.png', $options); } else { echo Html::img('/css/image/m_pic.png', $options); } } ?> </div> <div class="col-sm-2"> <b>Пол:</b> <?php echo $model->gender ? $model->gender == 1 ? "Мужской" : "Женский" : "<span class='hint'>Не указан</span>"; ?> <br><b>Дата рождения:</b>
/** * @return bool * @throws \yii\db\Exception * Удаление аватара */ public function deletePhoto() { if ($this->photo) { if (file_exists($this->photo)) { unlink($this->photo); } $thumb = CFF::getThumb($this->photo); if (file_exists($thumb)) { unlink($thumb); } if (!$this->isNewRecord) { $db = User::getDb(); $db->createCommand()->update('user', ['photo' => null], ['id' => $this->id])->execute(); } } return true; }