autoRender = false; // XML-RPC callbacks settings // Use this parameter to map XML-RPC methods to your protected or private controller methods $callbacks = array(); $callbacks['post.view'] = array(&$this, '_postView'); $callbacks['post.add'] = array(&$this, '_postAdd'); $callbacks['post.edit'] = array(&$this, '_postEdit'); $callbacks['post.delete'] = array(&$this, '_postDelete'); // Handle XML-RPC request $this->server = new IXR_Server($callbacks); } function _postView($id = null) { if (!$id) { return new IXR_Error(2, 'Invalid Post'); } return $this->Post->read(null, $id); } function _postAdd($data = array()) { if (!empty($data)) { $this->Post->create(); if ($this->Post->save($data)) { return (int)$this->Post->id; } else { return new IXR_Error(1, 'Post not saved'); } } return false; } function _postEdit($data = array()) { if (empty($data)) { return new IXR_Error(2, 'Invalid Post'); } elseif (!$this->Post->save($data)) { return new IXR_Error(1, 'Post not saved'); } return true; } function _postDelete($id = null) { if (!$id) { return new IXR_Error(2, 'Invalid Post'); } elseif (!$this->Post->del($id)) { return new IXR_Error(3, 'Post not deleted'); } return true; } } ?>