function execute()
 {
     $user_id = (int) Request::post('id');
     $login = ConnectionHelper::userLogin();
     connectionUserContactModel::create()->addUser($login['id'], $user_id);
     connectionUserEventModel::create()->add(array('type' => connectionUserEventModel::TYPE_INVITE_CHAT, 'user' => (int) $user_id, 'from' => (int) $login['id']));
     return 'success';
 }
 public function onTick(&$timer)
 {
     $connected = $this->getConnectionList();
     foreach ($connected as $connection) {
         if (!isset($connection->user_id)) {
             continue;
         }
         if (!isset($connection->date) || (int) strtotime('now') - $connection->date < 1) {
             continue;
         }
         $message = connectionUserEventModel::create()->getUnread($connection->user_id, (int) $connection->last_message, 1);
         if (!$message) {
             continue;
         }
         if ($message['type'] == connectionUserEventModel::TYPE_INVITE_CHAT) {
             $user = connectionUserModel::create()->getInfo($message['from']);
             $this->sendMessage($connection, json_encode(array('action' => 'event', 'data' => array('id' => $message['id'], 'type' => 'bublle', 'title' => 'Приглашение в чат', 'text' => '<a href="/user/' . $user['id'] . '/">' . $user['first_name'] . '</a> приглашает вас в чат для общения.', 'user' => $message['from']))));
         }
         $connection->last_message = $message['id'];
     }
 }
 function execute()
 {
     $id = (int) Request::post('id');
     connectionUserEventModel::create()->setRead($id);
 }