Viewing File core/Error.php of 0.00.0a
|
1: <?php 2: /* ------------------------------------------------------------- 3: This file is part of FreeDESK 4: 5: FreeDESK is (C) Copyright 2012 David Cutting 6: 7: FreeDESK is free software: you can redistribute it and/or modify 8: it under the terms of the GNU General Public License as published by 9: the Free Software Foundation, either version 3 of the License, or 10: (at your option) any later version. 11: 12: FreeDESK is distributed in the hope that it will be useful, 13: but WITHOUT ANY WARRANTY; without even the implied warranty of 14: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15: GNU General Public License for more details. 16: 17: You should have received a copy of the GNU General Public License 18: along with FreeDESK. If not, see www.gnu.org/licenses 19: 20: For more information see www.purplepixie.org/freedesk/ 21: -------------------------------------------------------------- */ 22: 23: /** 24: * Error Codes 25: **/ 26: class ErrorCode 27: { 28: const FailedLogin = 101; 29: const SessionExpired = 102; 30: 31: const UnknownMode = 201; 32: 33: const EntityError = 300; 34: 35: const Forbidden = 403; 36: const ResourceNotFound = 404; 37: 38: const UnknownRequest = 604; 39: } 40: 41: /** 42: * FreeDESK Error 43: **/ 44: class FreeDESK_Error 45: { 46: /** 47: * Code 48: **/ 49: var $Code = 0; 50: /** 51: * Text 52: **/ 53: var $Text = ""; 54: /** 55: * Constructor 56: * @param int $code Error Code (ErrorCode::) 57: * @param string $text Text (optional, default "") 58: **/ 59: function FreeDESK_Error($code, $text="") 60: { 61: $this->Code=$code; 62: $this->Text=$text; 63: } 64: /** 65: * Get Error as XML 66: * @param bool $header Put on XML header (optional, default false) 67: * @return string XML data 68: **/ 69: function XML($header=false) 70: { 71: $xml = new xmlCreate(); 72: $data=array("code"=>$this->Code); 73: $xml->startElement("error",$data); 74: $xml->charElement("code",$this->Code); 75: $xml->charElement("text",$this->Text,0,false,true); 76: $xml->endElement("error"); 77: return $xml->getXML($header); 78: } 79: } 80: ?> 81: