예제 #1
0
 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']);
     }
 }
예제 #2
0
 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();
 }
예제 #3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getUserSettingsBlocks()
 {
     return $this->hasMany(UserSettingsBlock::className(), ['block_id' => 'id'])->orderBy(['sort' => 'ASC']);
 }
예제 #4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getUserSettingsBlocks()
 {
     return $this->hasMany(UserSettingsBlock::className(), ['state' => 'name']);
 }
예제 #5
0
 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'));
     }
 }