<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/scripts/handlers/handler.php'; require_once $_SERVER['DOCUMENT_ROOT'] . '/scripts/classes/class.Event.php'; $post = GetPOST(); try { $ajaxResult['data'] = $_event->GetMoreListByType($post['user_id'], $post['cur_amount'], $post['event_type']); } catch (Exception $e) { $ajaxResult['result'] = false; $ajaxResult['message'] = $e->getMessage(); } echo json_encode($ajaxResult);
/** * The method for AJAX request handling * * @version 1 * @author Rick de Man <*****@*****.**> * */ public function Ajax() { // User must be signed in if ($this->User['loggedIn'] !== true) { return Ajax::GUESTNOTALLOWED; } // 'Starred' Del/Set if (in_array(GetPOST('AjaxAction'), array('StarredDel', 'StarredSet'))) { // Validating POST DATA $Validate = ValidatePOST(array('ID')); // Look for missing Parameter if ($Validate !== True) { return array(Ajax::PARAMETERNOTFOUND, array('%s' => HtmlHide('POST:' . $Validate))); } // ID must be an array if (!is_array(GetPOST('ID'))) { return Ajax::INVALIDPARAMETERS; } // Query Setup $Query = 'UPDATE `%component_messages_inbox` SET starred = ? WHERE ID = ? AND reciever = ?'; $Comment = 'Loading messages data'; // Prepare the SQL statement $this->SQL->Query_Prepare($Query, $Comment); // Loop each for ID's foreach (GetPOST('ID') as $ID) { $Values = array(GetPOST('AjaxAction') == 'StarredDel' ? 0 : 1, $ID, $this->User['ID']); // Execute the Current Query with Parameters $this->SQL->Query_Execute($Values, false); } // Free the SQL $this->SQL->Query_Next(); return Ajax::SUCCESS; } // 'starred' Toggle if (GetPOST('AjaxAction') == 'StarredToggle') { // Validating POST DATA $Validate = ValidatePOST(array('ID')); // Look for missing Parameter if ($Validate !== True) { return array(Ajax::PARAMETERNOTFOUND, array('%s' => HtmlHide('POST:' . $Validate))); } if (GetPOST('ID') == '') { return Ajax::INVALIDPARAMETERS; } // Query Setup $Query = 'UPDATE `%component_messages_inbox` SET starred = IF( starred = 1, 0, 1) WHERE ID = ? AND reciever = ?'; $Comment = 'Toggle message Starred Flag'; $Values = array(intval(GetPost('ID')), $this->User['ID']); // Prepare the SQL statement $this->SQL->Query_Prepare($Query, $Comment); // Execute the Current Query with Parameters $Result = $this->SQL->Query_Execute($Values, false, true); return Ajax::SUCCESS; } if (GetPOST('AjaxAction') == 'UnreadSet') { // Validating POST DATA $Validate = ValidatePOST(array('ID')); // Look for missing Parameter if ($Validate !== True) { return array(Ajax::PARAMETERNOTFOUND, array('%s' => HtmlHide('POST:' . $Validate))); } if (is_array(GetPOST('ID'))) { // Storage for messages $Messages = array(); // Query Setup $Query = 'SELECT * FROM `%component_messages_inbox` WHERE ID = ? AND unread = 0'; $Comment = 'Loading messages data'; // Prepare the SQL statement $this->SQL->Query_Prepare($Query, $Comment); foreach (GetPOST('ID') as $ID) { $Values = array($ID); // Execute the Current Query with Parameters $Message = $this->SQL->Query_Execute($Values, false); if ($Message['reciever'] == $this->User['ID']) { $Messages[] = $Message['ID']; } } $this->SQL->Query_Next(); // Query Setup $Query = 'UPDATE `%component_messages_inbox` SET unread = ? WHERE ID = ? '; $Comment = 'Loading messages data'; // Prepare the SQL statement $this->SQL->Query_Prepare($Query, $Comment); foreach ($Messages as $ID) { $Values = array(1, $ID); // Execute the Current Query with Parameters $this->SQL->Query_Execute($Values, false); } $this->SQL->Query_Next(); return Ajax::SUCCESS; } } return Ajax::METHODNOTIMPLEMENTED; }
private function Ajax_Component() { // Get Component Name $Component = 'component_' . GetPOST('Component'); // Cheeck if Component exists if (!class_exists($Component)) { $this->Ajax__Result(Ajax::COMPONENTUNKNOWN); } // Load Class $C = new $Component($this->SQL, $this->Template, $this->User); // Load Ajax Results $Status = $C->Ajax(); // Validate Status $this->Ajax__CheckResult($Status); //$this->Ajax__Result( Ajax::NOTIMPLEMENTED ); }