public function actionReset() { $curUser = Yii::$app->user->id; if (UserSettingsBlock::del($curUser)) { UserSettingsBlock::sync($curUser); Yii::$app->getSession()->setFlash('success', Yii::t('app', 'RESET_SETTINGS_SUCCESS')); return $this->redirect(['index']); } }
public function actionUpdate() { $items = Yii::$app->request->post('items'); $state = UserSettingsBlock::sortUpdate(Yii::$app->user->id, $items); if ($state) { $out = ['msg' => Yii::t('app', 'FLASH_SUCCESS_SAVE'), 'type' => 'success']; } else { $out = ['msg' => Yii::t('app', 'FLASH_ERROR_SAVE'), 'type' => 'danger']; } echo json_encode($out); Yii::$app->end(); }
/** * @return \yii\db\ActiveQuery */ public function getUserSettingsBlocks() { return $this->hasMany(UserSettingsBlock::className(), ['block_id' => 'id'])->orderBy(['sort' => 'ASC']); }
/** * @return \yii\db\ActiveQuery */ public function getUserSettingsBlocks() { return $this->hasMany(UserSettingsBlock::className(), ['state' => 'name']); }
protected function findUserBlock($id) { $userId = \Yii::$app->user->id; $Id = (int) str_replace('item', '', $id); if (($model = UserSettingsBlock::find()->where(['user_id' => $userId, 'id' => $Id])->one()) !== null) { return $model; } else { throw new NotFoundHttpException(Yii::t('app', 'PAGE_NOT_FOUND')); } }