Exemplo n.º 1
0
 /**
  * @Route ("/admin/chat")
  * @Secure ({"ADMIN"})
  * @HttpMethod ({"GET"})
  *
  * @param ViewModel $model
  * @throws Exception
  * @return string
  */
 public function adminChat(ViewModel $model)
 {
     $model->title = 'Chat';
     if (Session::get('modelSuccess')) {
         $model->success = Session::get('modelSuccess');
         Session::set('modelSuccess');
     }
     if (Session::get('modelError')) {
         $model->error = Session::get('modelError');
         Session::set('modelError');
     }
     return 'admin/chat';
 }
Exemplo n.º 2
0
 /**
  * @Route ("/register")
  * @HttpMethod ({"GET"})
  *
  * Handle the confirmation request
  *
  * @param array $params         
  * @throws Exception
  */
 public function register(array $params, ViewModel $model)
 {
     $authCreds = $this->getSessionAuthenticationCredentials($params);
     $email = $authCreds->getEmail();
     $username = $authCreds->getUsername();
     if (!empty($username) && empty($email)) {
         $email = $username . '@destiny.gg';
     }
     $model->title = 'Register';
     $model->username = $username;
     $model->email = $email;
     $model->follow = isset($params['follow']) ? $params['follow'] : '';
     $model->authProvider = $authCreds->getAuthProvider();
     $model->code = $authCreds->getAuthCode();
     $model->rememberme = Session::get('rememberme');
     return 'register';
 }
Exemplo n.º 3
0
 /**
  * @Route ("/admin/user/{id}/subscription/{subscriptionId}/edit")
  * @Secure ({"ADMIN"})
  * @HttpMethod ({"GET"})
  *
  * @param array $params         
  * @param ViewModel $model          
  * @throws Exception
  * @return string
  */
 public function subscriptionEdit(array $params, ViewModel $model)
 {
     FilterParams::required($params, 'id');
     FilterParams::required($params, 'subscriptionId');
     $subscriptionsService = SubscriptionsService::instance();
     $userService = UserService::instance();
     $ordersService = OrdersService::instance();
     $subscription = array();
     $payments = array();
     $order = array();
     if (!empty($params['subscriptionId'])) {
         $subscription = $subscriptionsService->getSubscriptionById($params['subscriptionId']);
         $order = $ordersService->getOrderById($subscription['orderId']);
         $payments = $ordersService->getPaymentsByOrderId($subscription['orderId']);
     }
     if (Session::get('modelSuccess')) {
         $model->success = Session::get('modelSuccess');
         Session::set('modelSuccess');
     }
     $model->user = $userService->getUserById($params['id']);
     $model->subscriptions = Config::$a['commerce']['subscriptions'];
     $model->subscription = $subscription;
     $model->order = $order;
     $model->payments = $payments;
     $model->title = 'Subsription';
     return "admin/subscription";
 }
Exemplo n.º 4
0
 /**
  * @Route ("/profile/authentication")
  * @Secure ({"USER"})
  *
  * @param ViewModel $model
  * @return string
  */
 public function profileAuthentication(ViewModel $model)
 {
     $userService = UserService::instance();
     $userId = Session::getCredentials()->getUserId();
     $model->title = 'Authentication';
     $model->user = $userService->getUserById($userId);
     // Build a list of profile types for UI purposes
     $authProfiles = $userService->getAuthProfilesByUserId($userId);
     $authProfileTypes = array();
     if (!empty($authProfiles)) {
         foreach ($authProfiles as $profile) {
             $authProfileTypes[] = $profile['authProvider'];
         }
         $model->authProfiles = $authProfiles;
     }
     $model->authProfileTypes = $authProfileTypes;
     if (Session::get('modelSuccess')) {
         $model->success = Session::get('modelSuccess');
         Session::set('modelSuccess');
     }
     if (Session::get('modelError')) {
         $model->error = Session::get('modelError');
         Session::set('modelError');
     }
     $model->authTokens = ApiAuthenticationService::instance()->getAuthTokensByUserId($userId);
     $model->title = 'Authentication';
     return 'profile/authentication';
 }
Exemplo n.º 5
0
 /**
  * Check if the user has been flagged for update
  *
  * @param int $userId
  * @return last update time | false
  */
 private function isUserFlaggedForUpdate($userId)
 {
     $cache = Application::instance()->getCacheDriver();
     $lastUpdated = $cache->fetch(sprintf('refreshusersession-%s', $userId));
     return $lastUpdated && $lastUpdated != Session::get('lastUpdated') ? $lastUpdated : false;
 }
Exemplo n.º 6
0
 /**
  * @Route ("/profile")
  * @HttpMethod ({"GET"})
  * @Secure ({"USER"})
  *
  * @param array $params         
  * @param ViewModel $model          
  * @return string
  */
 public function profile(array $params, ViewModel $model)
 {
     $userService = UserService::instance();
     $orderService = OrdersService::instance();
     $subscriptionsService = SubscriptionsService::instance();
     $userId = Session::getCredentials()->getUserId();
     $subscription = $subscriptionsService->getUserActiveSubscription($userId);
     if (empty($subscription)) {
         $subscription = $subscriptionsService->getUserPendingSubscription($userId);
     }
     $paymentProfile = null;
     $subscriptionType = null;
     if (!empty($subscription) && !empty($subscription['subscriptionType'])) {
         $subscriptionType = $subscriptionsService->getSubscriptionType($subscription['subscriptionType']);
         $paymentProfile = $this->getPaymentProfile($subscription);
     }
     $address = $userService->getAddressByUserId($userId);
     if (empty($address)) {
         $address = array();
         $address['fullName'] = '';
         $address['line1'] = '';
         $address['line2'] = '';
         $address['city'] = '';
         $address['region'] = '';
         $address['zip'] = '';
         $address['country'] = '';
     }
     if (Session::get('modelSuccess')) {
         $model->success = Session::get('modelSuccess');
         Session::set('modelSuccess');
     }
     if (Session::get('modelError')) {
         $model->error = Session::get('modelError');
         Session::set('modelError');
     }
     $model->title = 'Profile';
     $model->user = $userService->getUserById($userId);
     $model->subscription = $subscription;
     $model->subscriptionType = $subscriptionType;
     $gifts = $subscriptionsService->getActiveSubscriptionsByGifterId($userId);
     for ($i = 0; $i < count($gifts); $i++) {
         $gifts[$i]['type'] = $subscriptionsService->getSubscriptionType($gifts[$i]['subscriptionType']);
     }
     $model->gifts = $gifts;
     $model->paymentProfile = $paymentProfile;
     $model->address = $address;
     $model->title = 'Account';
     return 'profile';
 }