public static function deserialize($object) { $returnValue = new stdClass(); if (isset($object->__class__)) { if (!class_exists($object->__class__)) { require_once realpath(dirname(__FILE__)) . DIRECTORY_SEPARATOR . $object->__class__ . '.php'; } $returnValue = new $object->__class__(); } if (is_array($object)) { foreach ($object as $key => $value) { $returnValue->{$key} = JSONSerializer::deserialize($value); } } elseif (is_object($object)) { foreach (get_class_vars($object) as $key) { $returnValue->{$key} = $object->{$key}; } } else { return $object; } return $returnValue; }
* the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * http://www.gnu.org/copyleft/gpl.html * */ require_once 'includes/JSONSerializer.php'; $request = json_decode(JSONSerializer::deserialize(file_get_contents('php://input'))); //print_r($request); if (isset($request->session_id) && $request->session_id != '') { session_id($request->session_id); } $params = array(); if (isset($request->parameters)) { $params = $request->parameters; } require_once 'includes/common.php'; require_once 'includes/SureInvoice.php'; require_once 'includes/SI_Task.php'; require_once 'includes/SI_TaskActivity.php'; log_message("JSON API Called: " . $request->action); log_message(print_r($params, true)); $action_map = array('authenticate' => array('SureInvoice', 'authenticateUser'), 'getCompanies' => array('SI_Company', 'getActiveCompanies'), 'stayAlive' => array('SureInvoice', 'stayAlive'), 'getUserSetting' => array('SureInvoice', 'getUserSetting'), 'saveUserSetting' => array('SureInvoice', 'saveUserSetting'), 'getRecentTime' => array('SureInvoice', 'getRecentTime'), 'getTimerData' => array('SureInvoice', 'getTimerData'), 'pauseTimer' => array('SureInvoice', 'pauseTimer'), 'startTimer' => array('SureInvoice', 'startTimer'), 'addTimer' => array('SureInvoice', 'addTimer'), 'deleteTimer' => array('SureInvoice', 'deleteTimer'), 'getDefaultItemCode' => array('SI_Task', 'getDefaultItemCode'), 'getActivityDetailHTML' => array('SI_TaskActivity', 'getActivityDetailHTML'), 'importGetUsers' => array('SureInvoice', 'importGetUsers'), 'importGetTasks' => array('SureInvoice', 'importGetTasks'), 'importGetItemCodes' => array('SureInvoice', 'importGetItemCodes'));