function execute(&$response, &$session, $database = NULL) { if ($response->has_global_status_code()) { $response->add_status($this->cmdid, $session->msgid, 'Put', NULL, NULL, $response->get_global_status_code()); return; } if (!$database) { // No database or source is given. Try getting one by type. switch ($this->meta['type']) { case 'application/vnd.syncml-devinf+xml': case 'application/vnd.syncml-devinf+wbxml': $database = new syncml_database_devinf($session); break; default: $response->add_status($this->cmdid, $session->msgid, 'Put', NULL, NULL, SYNCML_STATUS_UNSUPPORTEDMEDIATYPEORFORMAT); return; } } else { return; } foreach ($this->item as $item) { $result = $database->put_item($item['source']['locuri'], $item['data'], $this->meta['type']); if (!isset($this->noresp) || !$this->noresp) { $response->add_status($this->cmdid, $session->msgid, 'Put', NULL, $item['source']['locuri'], SYNCML_STATUS_OK); } } }
function execute(&$response, &$session, $database = NULL) { if ($response->has_global_status_code()) { $response->add_status($this->cmdid, $session->msgid, 'Get', NULL, NULL, $response->get_global_status_code()); return; } if (!$database) { // No database or source is given. Try getting one by type. switch ($this->meta['type']) { case 'application/vnd.syncml-devinf+xml': case 'application/vnd.syncml-devinf+wbxml': $database = new syncml_database_devinf($session); break; default: $response->add_status($this->cmdid, $session->msgid, 'Get', NULL, NULL, SYNCML_STATUS_UNSUPPORTEDMEDIATYPEORFORMAT); return; } } else { return; } foreach ($this->item as $item) { $result = $database->get_item($item['target']['locuri'], $this->meta['type']); if (is_null($result)) { // Item not found. $response->add_status($this->cmdid, $session->msgid, 'Get', NULL, NULL, SYNCML_STATUS_NOTFOUND, array('trg_uri' => $item['target']['locuri'])); } else { $response->add_status($this->cmdid, $session->msgid, 'Get', NULL, NULL, SYNCML_STATUS_OK); $response->add_result($this->cmdid, $session->msgid, NULL, NULL, 'application/vnd.syncml-devinf+wbxml', array(array('src_uri' => $item['target']['locuri'], 'data' => $result))); } } }