Ejemplo n.º 1
0
 /**
  * @Route ("/admin/user/{id}/edit")
  * @Secure ({"ADMIN"})
  * @HttpMethod ({"GET"})
  *
  * @param array $params         
  * @param ViewModel $model          
  * @throws Exception
  * @return string
  */
 public function adminUserEdit(array $params, ViewModel $model)
 {
     $model->title = 'User';
     FilterParams::required($params, 'id');
     $user = UserService::instance()->getUserById($params['id']);
     if (empty($user)) {
         throw new Exception('User was not found');
     }
     $userService = UserService::instance();
     $userFeaturesService = UserFeaturesService::instance();
     $apiAuthenticationService = ApiAuthenticationService::instance();
     $chatlogService = ChatlogService::instance();
     $subscriptionsService = SubscriptionsService::instance();
     $user['roles'] = $userService->getUserRolesByUserId($user['userId']);
     $user['features'] = $userFeaturesService->getUserFeatures($user['userId']);
     $user['ips'] = $userService->getIPByUserId($user['userId']);
     $model->user = $user;
     $model->smurfs = $userService->findSameIPUsers($user['userId']);
     $model->features = $userFeaturesService->getDetailedFeatures();
     $ban = $userService->getUserActiveBan($user['userId']);
     $banContext = array();
     if (!empty($ban)) {
         $banContext = $chatlogService->getChatLogBanContext($user['userId'], Date::getDateTime($ban['starttimestamp']), 18);
     }
     $model->banContext = $banContext;
     $model->ban = $ban;
     $model->authSessions = $apiAuthenticationService->getAuthSessionsByUserId($user['userId']);
     $model->address = $userService->getAddressByUserId($user['userId']);
     $model->subscriptions = $subscriptionsService->getUserSubscriptions($user['userId']);
     if (Session::get('modelSuccess')) {
         $model->success = Session::get('modelSuccess');
         Session::set('modelSuccess');
     }
     return 'admin/user';
 }
Ejemplo n.º 2
0
 /**
  * @Route ("/chat/history")
  *
  * @param array $params            
  * @param ViewModel $model            
  */
 public function history(array $params, ViewModel $model)
 {
     $chatLogService = ChatlogService::instance();
     $chatlog = $chatLogService->getChatLog(Config::$a['chat']['backlog']);
     $broadcasts = $chatLogService->getBroadcasts(Date::getDateTime(strtotime('5 minutes ago')));
     $b = '';
     $lines = array();
     $suppress = array();
     foreach ($chatlog as &$line) {
         if ($line['event'] == 'MUTE' or $line['event'] == 'BAN') {
             $suppress[$line['target']] = true;
         }
         if (isset($suppress[$line['username']])) {
             continue;
         }
         if (!empty($line['features'])) {
             $line['features'] = explode(',', $line['features']);
         } else {
             $line['features'] = array();
         }
         if ($line['subscriber'] == 1) {
             $line['features'][] = UserFeature::SUBSCRIBER;
             if ($line['istwitchsubscriber']) {
                 $line['features'][] = UserFeature::SUBSCRIBERT0;
             }
             if ($line['subscriptionTier'] == 2) {
                 $line['features'][] = UserFeature::SUBSCRIBERT2;
             }
             if ($line['subscriptionTier'] == 3) {
                 $line['features'][] = UserFeature::SUBSCRIBERT3;
             }
             if ($line['subscriptionTier'] == 4) {
                 $line['features'][] = UserFeature::SUBSCRIBERT4;
             }
         }
         unset($line['istwitchsubscriber']);
         // do not leak the abstraction
         $lines[] = $line;
     }
     $b .= 'var backlog = ' . json_encode($lines) . ';' . PHP_EOL;
     $b .= 'var broadcasts = ' . json_encode($broadcasts) . ';' . PHP_EOL;
     $response = new Response(Http::STATUS_OK, $b);
     $response->addHeader(Http::HEADER_CONTENTTYPE, MimeType::JAVASCRIPT);
     return $response;
 }
Ejemplo n.º 3
0
 /**
  * @Route ("/admin/dashboard")
  * @Route ("/admin")
  * @Secure ({"ADMIN"})
  * @HttpMethod ({"GET","POST"})
  *
  * @param ViewModel $model
  * @return string
  */
 public function dashboard(ViewModel $model)
 {
     $chatLogService = ChatlogService::instance();
     $model->broadcasts = $chatLogService->getLastBroadcasts(10);
     return 'admin/dashboard';
 }