Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function listforevent() {
- if(!$this->criteriaIDs || !$this->table) {
- return false;
- }
- /* Create paging if omit and limit are set. */
- if(isset($this->requestData['limit']) && (int)$this->requestData['limit'] > 0) {
- $offset = isset($this->requestData['omit']) ? $this->requestData['omit'] : 0;
- $limit = $this->requestData['limit'];
- $limit_sql = "LIMIT $offset, $limit";
- }
- $eventID = $this->db->makeSafe($this->criteriaIDs);
- $userFields = array("emailAddress", "hasImage", "handle");
- $queryText = sprintf('
- SELECT wp.*, wu."emailAddress", wu."hasImage", wu."handle" FROM %s wp
- INNER JOIN wmuser wu ON wu."uniqueID" = wp."userID"
- WHERE "eventID" = %s ORDER BY wp."dateTime" %s', $this->table, $eventID,
- $limit_sql);
- $res = $this->db->query($queryText);
- $posts = array();
- if($this->db->numRows($res) < 1) {
- $this->send404();
- exit();
- }
- if($res) {
- while($result = $this->db->resultsArray($res)) {
- $result["userInfo"] = array();
- $result = $this->db->arrayWithFixedTypes("wmpost", $result);
- foreach($result as $key => $value) {
- if(in_array($key, $userFields)) {
- unset($result[$key]);
- $result["userInfo"][$key] = $value;
- }
- }
- $result["userInfo"] = $this->db->arrayWithFixedTypes("wmuser", $result["userInfo"]);
- $posts[] = $result;
- }
- }
- print json_encode($posts);
- }
Add Comment
Please, Sign In to add comment