/** * 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; }
/** * Load a Language String * * @version 1 * @author Rick de Man <*****@*****.**> * * @param string $String * The string 'Section,Key' to be loaded as language string * @return string */ protected function WMS_Lang($String) { // Breakup String Section,Key $Location = explode(',', strtolower($String)); // Array length must be '2' if (count($Location) == 2) { if (isset($this->Lang[$Location[0]][$Location[1]])) { return $this->Lang[$Location[0]][$Location[1]]; } } // Build Debug Info $Trace = debug_backtrace(); // Return Debugger Info if ($this->Debug === True) { return HtmlHide($Trace[0]['file'] . ':' . $Trace[0]['line'] . '-' . __FUNCTION__ . "({$String})" . $String); } // Return provided String return $String; }