Exemple #1
0
 /**
  * Adds registered user activity.
  * @param string $ip
  * @param string $url
  * @return boolean
  */
 protected static function _addUser($ip, $url)
 {
     $user = new PodiumUser();
     $activity = self::findOne(['user_id' => $user->getId()]);
     if (!$activity) {
         $activity = new Activity();
         $activity->user_id = $user->getId();
     }
     $activity->username = $user->getName();
     $activity->user_role = $user->getRole();
     $activity->user_slug = $user->getSlug();
     $activity->url = $url;
     $activity->ip = $ip;
     $activity->anonymous = $user->getAnonymous();
     return $activity->save();
 }
 /**
  * Replying to the message of given ID.
  * @param integer $id
  * @return string|\yii\web\Response
  */
 public function actionReply($id = null)
 {
     $model = new Message();
     $podiumUser = new PodiumUser();
     $reply = Message::findOne(['id' => $id, 'receiver_id' => $podiumUser->getId()]);
     if ($reply) {
         $model->topic = Message::re() . ' ' . $reply->topic;
         if ($model->load(Yii::$app->request->post())) {
             if ($model->validate()) {
                 if (!$podiumUser->isIgnoredBy($model->receiver_id)) {
                     $model->replyto = $reply->id;
                     if ($model->send()) {
                         $this->success('Message has been sent.');
                         return $this->redirect(['inbox']);
                     }
                 } else {
                     $this->error('Sorry! This member ignores you so you can not send the message.');
                 }
             }
         }
         $model->receiver_id = $reply->sender_id;
         return $this->render('reply', ['model' => $model, 'reply' => $reply]);
     } else {
         $this->error('Sorry! We can not find the message with the given ID.');
         return $this->redirect(['inbox']);
     }
 }