Guest User

Untitled

a guest
Jul 20th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. function listforevent() {
  2. if(!$this->criteriaIDs || !$this->table) {
  3. return false;
  4. }
  5.  
  6. /* Create paging if omit and limit are set. */
  7. if(isset($this->requestData['limit']) && (int)$this->requestData['limit'] > 0) {
  8. $offset = isset($this->requestData['omit']) ? $this->requestData['omit'] : 0;
  9. $limit = $this->requestData['limit'];
  10. $limit_sql = "LIMIT $offset, $limit";
  11. }
  12.  
  13. $eventID = $this->db->makeSafe($this->criteriaIDs);
  14. $userFields = array("emailAddress", "hasImage", "handle");
  15. $queryText = sprintf('
  16. SELECT wp.*, wu."emailAddress", wu."hasImage", wu."handle" FROM %s wp
  17. INNER JOIN wmuser wu ON wu."uniqueID" = wp."userID"
  18. WHERE "eventID" = %s ORDER BY wp."dateTime" %s', $this->table, $eventID,
  19. $limit_sql);
  20. $res = $this->db->query($queryText);
  21. $posts = array();
  22. if($this->db->numRows($res) < 1) {
  23. $this->send404();
  24. exit();
  25. }
  26. if($res) {
  27. while($result = $this->db->resultsArray($res)) {
  28. $result["userInfo"] = array();
  29. $result = $this->db->arrayWithFixedTypes("wmpost", $result);
  30. foreach($result as $key => $value) {
  31. if(in_array($key, $userFields)) {
  32. unset($result[$key]);
  33. $result["userInfo"][$key] = $value;
  34. }
  35. }
  36. $result["userInfo"] = $this->db->arrayWithFixedTypes("wmuser", $result["userInfo"]);
  37. $posts[] = $result;
  38. }
  39. }
  40. print json_encode($posts);
  41. }
Add Comment
Please, Sign In to add comment