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'); }
<?php use yii\helpers\Html; /* @var $this \yii\web\View */ /* @var $content string */ $model = \common\models\User::findOne(['id' => Yii::$app->user->getId()]); $postCount = \common\models\Post::find()->where(['user_id' => $model['id']])->count(); $friendCount = \common\models\Relationship::find()->where(['user_id_1' => $model['id'], 'status' => 1])->count() + \common\models\Relationship::find()->where(['user_id_2' => $model['id'], 'status' => 1])->count(); $listNewRelNotify = \common\models\RelationshipNotification::find()->where(['receive_id' => Yii::$app->user->getId()])->orderBy('status')->limit(20)->asArray()->all(); $newRelNotifyCount = \common\models\RelationshipNotification::find()->where(['receive_id' => Yii::$app->user->getId(), 'status' => 0])->count(); $listNewMsgNotify = \common\models\Message::find()->where(['receiver_id' => Yii::$app->user->getId()])->orderBy('is_notified')->limit(20)->asArray()->all(); $newMsgNotifyCount = \common\models\Message::find()->where(['receiver_id' => Yii::$app->user->getId(), 'is_notified' => 0])->count(); ?> <header class="main-header"> <?php echo Html::a('<span class="logo-mini">APP</span><span class="logo-lg">' . Yii::$app->name . '</span>', Yii::$app->homeUrl, ['class' => 'logo']); ?> <nav class="navbar navbar-static-top" role="navigation"> <a href="#" class="sidebar-toggle" data-toggle="offcanvas" role="button"> <span class="sr-only">Toggle navigation</span> </a> <div class="navbar-custom-menu"> <ul class="nav navbar-nav"> <!-- Messages: style can be found in dropdown.less-->
public function actionMakeOldRelationshipNotification() { RelationshipNotification::updateAll(['status' => 1], 'status=0 AND receive_id=' . \Yii::$app->user->getId()); }
public function actionAcceptFriendRequestAsFamily() { if (isset($_POST['user_id_1']) && isset($_POST['user_id_2']) && isset($_POST['update_at'])) { // Notification $notify = new RelationshipNotification(); $notify['action_id'] = $_POST['user_id_1']; $notify['receive_id'] = $_POST['user_id_2']; $user_id_1 = $_POST['user_id_1']; $user_id_2 = $_POST['user_id_2']; $user_id_action = $user_id_1; if ($user_id_1 > $user_id_2) { $tg = $user_id_1; $user_id_1 = $user_id_2; $user_id_2 = $tg; } $rel = Relationship::findOne(['user_id_1' => $user_id_1, 'user_id_2' => $user_id_2, 'status' => 0]); $rel['status'] = 1; $rel['update_at'] = $_POST['update_at']; $rel['user_id_action'] = $user_id_action; if ($user_id_action == $user_id_1) { $rel['with_user_1_is'] = 2; } else { $rel['with_user_2_is'] = 2; } $rel->save(); $notify['type'] = 2; $notify['status'] = 0; $notify['create_at'] = $_POST['update_at']; $notify->save(); echo 'YES'; } else { echo 'NO'; } }