public function actionUpdate($id)
    {
        $model = $this->findModel($id);

        // check permissions
        if (!Yii::$app->user->can('roleContentModerator') // user is not moderator
         &&  Yii::$app->user->can('roleContentAuthor')    // but is author ...
         && !Yii::$app->user->can('updateOwnContent', [   // ... can edit only own article
                'content' => $model,                      //     - if article unvisible - always can
                'canEditVisible'                          //     - but if not visible - see this param
                    => $this->canAuthorEditOwnVisibleArticle,
            ])
        ) {
            if ($this->canAuthorEditOwnVisibleArticle) {
                throw new ForbiddenHttpException(Yii::t($this->tcModule, 'You can update only your own article'));
            } else {
                throw new ForbiddenHttpException(Yii::t($this->tcModule, 'You can update only your own article still unvisible'));
            }
        }

        $post = Yii::$app->request->post();
        $loaded = $model->load($post);

        $attributes = $model->attributes;
        if (!$this->canAuthorEditOwnVisibleArticle) unset($attributes['is_visible']);
        $attributeNames = array_keys($attributes);

        if ($loaded && $model->save(true, $attributeNames)) {
            if ($model->aftersave != $model::AFTERSAVE_LIST) {
                return $this->redirect(['view', 'id' => $model->id]);
            } else {
                $model->orderBy = $model::$defaultOrderBy;
                $model->page = $model->calcPage($model::find()->where(['parent_id' => $model->parent_id]));
                return $this->redirect(['index',
                    'parent' => $model->parent_id,
                    'page'   => $model->page,
                    'id'     => $model->id,
                    'sort'   => $model->orderByToSort(),
                ]);
            }
        } else {
            return $this->render('update', compact('model'));
        }
    }