function testRevisionSave() { $ret = $GLOBALS['db']->query("SELECT COUNT(*) AS rowcount1 FROM document_revisions WHERE document_id = '{$this->doc->id}'"); $row = $GLOBALS['db']->fetchByAssoc($ret); $this->assertEquals($row['rowcount1'], 0, 'We created an empty revision'); $ret = $GLOBALS['db']->query("SELECT document_revision_id FROM documents WHERE id = '{$this->doc->id}'"); $row = $GLOBALS['db']->fetchByAssoc($ret); $this->assertTrue(empty($row['document_revision_id']), 'We linked the document to a fake document_revision'); $ds = new DocumentSoap(); $revision_stuff = array('file' => base64_encode('Pickles has an extravagant beard of pine fur.'), 'filename' => 'a_file_about_pickles.txt', 'id' => $this->doc->id, 'revision' => '1'); $revisionId = $ds->saveFile($revision_stuff); $ret = $GLOBALS['db']->query("SELECT COUNT(*) AS rowcount1 FROM document_revisions WHERE document_id = '{$this->doc->id}'"); $row = $GLOBALS['db']->fetchByAssoc($ret); $this->assertEquals($row['rowcount1'], 1, 'We didn\'t create a revision when we should have'); $ret = $GLOBALS['db']->query("SELECT document_revision_id FROM documents WHERE id = '{$this->doc->id}'"); $row = $GLOBALS['db']->fetchByAssoc($ret); $this->assertEquals($row['document_revision_id'], $revisionId, 'We didn\'t link the newly created document revision to the document'); // Double saving doesn't work because save doesn't reset the new_with_id $newDoc = new Document(); $newDoc->retrieve($this->doc->id); $newDoc->document_revision_id = $revisionId; $newDoc->save(FALSE); $ret = $GLOBALS['db']->query("SELECT COUNT(*) AS rowcount1 FROM document_revisions WHERE document_id = '{$this->doc->id}'"); $row = $GLOBALS['db']->fetchByAssoc($ret); $this->assertEquals($row['rowcount1'], 1, 'We didn\'t create a revision when we should have'); $ret = $GLOBALS['db']->query("SELECT document_revision_id FROM documents WHERE id = '{$this->doc->id}'"); $row = $GLOBALS['db']->fetchByAssoc($ret); $this->assertEquals($row['document_revision_id'], $revisionId, 'We didn\'t link the newly created document revision to the document'); }
/** * sets a new revision for this document * * @param String $session -- Session ID returned by a previous call to login. * @param Array $document_revision -- Array String 'id' -- The ID of the document object * String 'document_name' - The name of the document * String 'revision' - The revision value for this revision * String 'filename' -- The file name of the attachment * String 'file' -- The binary contents of the file. * @return Array - 'id' - String - document revision id * @exception 'SoapFault' -- The SOAP error, if any */ function set_document_revision($session, $document_revision) { $GLOBALS['log']->info('Begin: SugarWebServiceImpl->set_document_revision'); $error = new SoapError(); if (!self::$helperObject->checkSessionAndModuleAccess($session, 'invalid_session', '', '', '', $error)) { $GLOBALS['log']->info('End: SugarWebServiceImpl->set_document_revision'); return; } // if require_once 'modules/Documents/DocumentSoap.php'; $dr = new DocumentSoap(); $GLOBALS['log']->info('End: SugarWebServiceImpl->set_document_revision'); return array('id' => $dr->saveFile($document_revision)); }
/** * Enter description here... * * @param String $session -- Session ID returned by a previous call to login. * @param unknown_type $document_revision * @return unknown */ function set_document_revision($session, $document_revision) { $error = new SoapError(); if (!validate_authenticated($session)) { $error->set_error('invalid_login'); return array('id' => -1, 'error' => $error->get_soap_array()); } require_once 'modules/Documents/DocumentSoap.php'; $dr = new DocumentSoap(); return array('id' => $dr->saveFile($document_revision), 'error' => $error->get_soap_array()); }
/** * sets a new revision for this document * * @param String $session -- Session ID returned by a previous call to login. * @param Array $document_revision -- Array String 'id' -- The ID of the document object * String 'document_name' - The name of the document * String 'revision' - The revision value for this revision * String 'filename' -- The file name of the attachment * String 'file' -- The binary contents of the file. * @return Array - 'id' - document revision id * @exception 'SoapFault' -- The SOAP error, if any */ function new_set_document_revision($session, $document_revision) { $error = new SoapError(); if (!checkSessionAndModuleAccess($session, 'invalid_session', '', '', '', $error)) { return; } // if require_once 'modules/Documents/DocumentSoap.php'; $dr = new DocumentSoap(); return array('id' => $dr->saveFile($document_revision)); }