public function actionRecompose($id) { $message = Message::findOne(['id' => $id]); $model = new MessageCreateForm(); $model->cacheDraftsMessage($message); $model->create_at = date('Y-m-d h:i'); $model->sender_id = \Yii::$app->user->getId(); $model->status = 0; if ($model->load(\Yii::$app->request->post())) { $model->addMessage(); Message::deleteAll(['id' => $id]); $this->redirect(Url::to(['/message/show-outbox'])); } return $this->render('compose', ['model' => $model]); }
public function actionDeleteUser() { $selection = (array) Yii::$app->request->post('selection'); foreach ($selection as $id) { if ($id != Yii::$app->params['adminId']) { User::deleteAll(['id' => $id]); Post::deleteAll(['user_id' => $id]); PostNotification::deleteAll(['action_id' => $id]); PostNotification::deleteAll(['receiver_id' => $id]); Comment::deleteAll(['user_id' => $id]); Like::deleteAll(['user_id' => $id]); Message::deleteAll(['sender_id' => $id]); Message::deleteAll(['receiver_id' => $id]); Relationship::deleteAll(['user_id_1' => $id]); Relationship::deleteAll(['user_id_2' => $id]); RelationshipNotification::deleteAll(['action_id' => $id]); RelationshipNotification::deleteAll(['receive_id' => $id]); Schedule::deleteAll(['own_id' => $id]); ScheduleNotification::deleteAll(['action_id' => $id]); ScheduleNotification::deleteAll(['receiver_id' => $id]); } } return $this->render('user-manage'); }