LoginViewDecider.inc 902 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. class LoginViewDecider {
  3. public function decide() {
  4. $session = new Session();
  5. $logger = new Logger();
  6. $form = new Form();
  7. $userId = $session->getValue("logged_in");
  8. $view = new View();
  9. if($userId){
  10. $user = new User();
  11. $user->populate();
  12. $sql = sprintf("SELECT count(*) as count FROM user_tags WHERE is_seen = 0 AND user_id = '%s'", $user->getId());
  13. $database = new Database();
  14. $result = $database->query($sql);
  15. $newNotificationCount = intval($result[0]['count']);
  16. $logoutViewData = array(
  17. "username" => $user->getDisplayName(),
  18. "userId" => $userId,
  19. "newNotifications" => $newNotificationCount
  20. );
  21. return $view->render("logoutView.inc", $logoutViewData);
  22. }
  23. $errorMessage = $form->getCleanEncodedDefaulted("e", "");
  24. $loginViewData = array("message" => $errorMessage);
  25. return $view->render("loginView.inc", $loginViewData);
  26. }
  27. }