예제 #1
0
 public function _afterDelete_Delete(\Cake\Event\Event $event)
 {
     $game = $event->subject()->entity;
     $client = new StreamClient('m4rjggbpj7fb', 'bku9w4hvhzt8dpupzq9k4wz8kur3tqmhyg52qze2tnpppqyxzddpgts2jpds4m6z');
     foreach ($game->game_memberships as $gm) {
         if (!empty($gm->member_id)) {
             $feed = $client->feed('user', $gm->member_id);
             $feed->removeActivity('Game:' . $event->subject()->id, true);
         }
     }
 }
예제 #2
0
 public function feed()
 {
     $client = new StreamClient('m4rjggbpj7fb', 'bku9w4hvhzt8dpupzq9k4wz8kur3tqmhyg52qze2tnpppqyxzddpgts2jpds4m6z');
     $current_feed = $client->feed('timeline', $this->Auth->user('id'));
     if (empty($activities = $current_feed->getActivities(0, 30)['results'])) {
         $this->set(['_serialize' => true, 'success' => false]);
         return;
     }
     $users = $this->_generateMemberQuery($activities);
     $users_array = $users->toArray();
     foreach ($activities as $key => $activity) {
         $activity_entity = new FeedItem($activity);
         $first = array_key_exists($activity_entity->first_user_id, $users_array) ? $users_array[$activity_entity->first_user_id] : null;
         $second = array_key_exists($activity_entity->second_user_id, $users_array) ? $users_array[$activity_entity->second_user_id] : null;
         $game = null;
         $activity_entity->update($first, $second, $game);
         $activity_entity->format($this->Auth->user('id'));
         $activities[$key] = $activity_entity;
     }
     $this->set(['_serialize' => true, 'success' => true, 'data' => $activities]);
 }
예제 #3
0
 public function home()
 {
     $this->response->disableCache();
     $loggedUserId = $this->Auth->user('id');
     $isCurrentUser = false;
     if (!Configure::read('Users.Profile.viewOthers') || empty($id)) {
         $id = $loggedUserId;
     }
     try {
         $appContain = (array) Configure::read('Auth.authenticate.' . \Cake\Controller\Component\AuthComponent::ALL . '.contain');
         $socialContain = Configure::read('Users.Social.login') ? ['SocialAccounts'] : [];
         $user = $this->getUsersTable()->get($id, ['contain' => array_merge((array) $appContain, (array) $socialContain)]);
         $this->set('avatarPlaceholder', Configure::read('Users.Avatar.placeholder'));
         if ($user->id === $loggedUserId) {
             $isCurrentUser = true;
         }
     } catch (RecordNotFoundException $ex) {
         $this->Flash->error(__d('Users', 'User was not found'));
         return $this->redirect($this->request->referer());
     } catch (InvalidPrimaryKeyException $ex) {
         $this->Flash->error(__d('Users', 'Not authorized, please login first'));
         return $this->redirect($this->request->referer());
     }
     $this->set(compact('user', 'isCurrentUser'));
     $this->set('_serialize', ['user', 'isCurrentUser']);
     $this->set('pane', $this->request->query('pane') ? $this->request->query('pane') : 'feed');
     $client = new StreamClient('m4rjggbpj7fb', 'bku9w4hvhzt8dpupzq9k4wz8kur3tqmhyg52qze2tnpppqyxzddpgts2jpds4m6z');
     $member_feed = $client->feed('user', $this->Auth->user('id'));
     $readonlyToken = $member_feed->getReadonlyToken();
     $this->set('stream_token', $readonlyToken);
 }