diff --git a/backend/config/main.php b/backend/config/main.php index 795e11e..24fa31a 100755 --- a/backend/config/main.php +++ b/backend/config/main.php @@ -61,6 +61,11 @@ return [ 'actions' => ['index'], 'allow' => true, 'roles' => ['@'], + ], + [ + 'actions' => ['images'], + 'allow' => true, + 'roles' => ['@'], ] ], diff --git a/backend/controllers/SiteController.php b/backend/controllers/SiteController.php index 10b5c43..86377ee 100755 --- a/backend/controllers/SiteController.php +++ b/backend/controllers/SiteController.php @@ -1,5 +1,6 @@ all(); + foreach($files as $file_object){ + $file = $file_object->image; + $file_array = explode('/',$file); + if(is_array($file_array) && count($file_array) >3){ + $count = count($file_array); + $file_name = $file_array[$count-2]."_".$file_array[$count-1]; + print_r($file_name); + $save_image = Yii::getAlias('@productsDir') . "/" . $file_name; + copy($file, $save_image); + $file_object->image = $file_name; + $file_object->save(); + } + + } + + + } + public function actionIndex() { $blog = new Blog(); diff --git a/common/models/Customer.php b/common/models/Customer.php index 863ab06..1b225d7 100755 --- a/common/models/Customer.php +++ b/common/models/Customer.php @@ -252,6 +252,16 @@ class Customer extends User implements \yii\web\IdentityInterface $this->password_reset_token = Yii::$app->security->generateRandomString() . '_' . time(); } + public static function findByEmail($email) + { + return static::findOne(['email' => $email, 'status' => self::STATUS_ACTIVE]); + } + + public function getName(){ + return $this->username. ' '.$this->surname; + } + + /** * Removes password reset token */ diff --git a/common/models/LoginForm.php b/common/models/LoginForm.php old mode 100755 new mode 100644 index 92dcf8f..152ca97 --- a/common/models/LoginForm.php +++ b/common/models/LoginForm.php @@ -1,30 +1,29 @@ 'Логин', - 'password'=>'Пароль', - 'rememberMe'=>'Запомнить', - ]; - } - /** * Validates the password. * This method serves as the inline validation for password. @@ -52,7 +42,6 @@ class LoginForm extends Model { if (!$this->hasErrors()) { $user = $this->getUser(); - if (!$user || !$user->validatePassword($this->password)) { $this->addError($attribute, 'Incorrect username or password.'); } @@ -61,12 +50,13 @@ class LoginForm extends Model /** * Logs in a user using the provided username and password. + * * @return boolean whether the user is logged in successfully */ public function login() { if ($this->validate()) { - return Yii::$app->user->login($this->getUser(), $this->rememberMe ? 3600*24*30 : 0); + return Yii::$app->user->login($this->getUser(), $this->rememberMe ? 3600 * 24 * 30 : 0); } else { return false; } @@ -77,12 +67,24 @@ class LoginForm extends Model * * @return User|null */ - public function getUser() + protected function getUser() { - if ($this->_user === false) { - $this->_user = User::findByUsername($this->username); + if ($this->_user === null) { + $this->_user = Customer::findByEmail($this->email); } return $this->_user; } + + + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'rememberMe' => Yii::t('app', 'rememberMe'), + ]; + } } diff --git a/common/modules/product/models/Import.php b/common/modules/product/models/Import.php index e6350ec..2df4d3c 100755 --- a/common/modules/product/models/Import.php +++ b/common/modules/product/models/Import.php @@ -376,8 +376,6 @@ class Import extends Model { { if (! empty ($data[$i])) { - print_r($data); - die(); $mod_arr = explode ('=', $data[$i]); $mod_art = $mod_arr[0]; $variant_filters = explode ('*', $mod_arr[1]); @@ -435,17 +433,17 @@ class Import extends Model { if ($mod_image) { -// $source_image = Yii::getAlias('@uploadDir') . '/product_images/'. urlencode($mod_image); -// if (file_exists($source_image)) { + $source_image = Yii::getAlias('@uploadDir') . '/product_images/'. urlencode($mod_image); + if (file_exists($source_image)) { if (($variantImage = ProductImage::find()->andFilterWhere(['ilike', 'image', $mod_image])->andFilterWhere(['product_variant_id' => $_productVariant->product_variant_id])->one()) === null) { - // copy($source_image, Yii::getAlias('@productsDir') . "/" . $mod_image); + copy($source_image, Yii::getAlias('@productsDir') . "/" . $mod_image); $variantImage = new ProductImage(); $variantImage->product_id = $_product->product_id; $variantImage->product_variant_id = $_productVariant->product_variant_id; $variantImage->image = $mod_image; $variantImage->save(); } - //} + } } } } diff --git a/frontend/assets/AppAsset.php b/frontend/assets/AppAsset.php index 8bd1329..9e19e95 100755 --- a/frontend/assets/AppAsset.php +++ b/frontend/assets/AppAsset.php @@ -30,6 +30,7 @@ class AppAsset extends AssetBundle ]; public $depends = [ 'yii\web\JqueryAsset', + ]; public function init() { diff --git a/frontend/views/layouts/main.php b/frontend/views/layouts/main.php index 1faa43b..b2b9b30 100755 --- a/frontend/views/layouts/main.php +++ b/frontend/views/layouts/main.php @@ -43,37 +43,6 @@ AppAsset::register($this); ga('send', 'pageview'); - - - - - - - - @@ -153,7 +122,13 @@ AppAsset::register($this);
  • Оплата
  • Доставка
  • Контакты
  • -
  • Личный кабинет
  • + user->isGuest) { ?> +
  • Личный кабинет
  • + +
  • user->identity->username , Url::toRoute(['cabinet/index'])); ?>
  • + +
    @@ -549,71 +524,17 @@ AppAsset::register($this); - - - + +render('/modal/registration_window_model_window')?> + +render('/modal/forgot_password_form_model_window') ?>