コード例 #1
0
 /**
  * Marks a message as seen for given userId
  *
  * @param int $userId
  */
 public function seen($userId)
 {
     // Update User Message Entry
     $userMessage = ServicesUserMessage::findOne(array('user_id' => $userId, 'message_id' => $this->id));
     if ($userMessage !== null) {
         $userMessage->last_viewed = new \yii\db\Expression('NOW()');
         $userMessage->save();
     }
 }
コード例 #2
0
 /**
  * Returns the Message Model by given Id
  * Also an access check will be performed.
  *
  * If insufficed privileges or not found null will be returned.
  *
  * @param int $id
  */
 private function getMessage($id)
 {
     $message = ServicesMessage::findOne(['id' => $id]);
     if ($message != null) {
         $userMessage = ServicesUserMessage::findOne(['user_id' => Yii::$app->user->id, 'message_id' => $message->id]);
         if ($userMessage != null) {
             return $message;
         }
     }
     return null;
 }