コード例 #1
0
 /**
  * Testing the bulk actions - checkout and cancel check out
  */
 public function testApiBulkImmute()
 {
     // Create folder and documents
     $doc1 = $this->createDocument('Test Doc One', 'testdoc1.txt');
     $doc2 = $this->createDocument('Test Doc Two', 'testdoc2.txt');
     $folder1 = $this->root->add_folder("New test folder");
     $this->assertNotError($newFolder);
     if (PEAR::isError($newFolder)) {
         return;
     }
     $doc4 = $this->createDocument('Test Doc Four', 'testdoc4.txt', $folder1);
     $doc1_id = $doc1->get_documentid();
     $doc2_id = $doc2->get_documentid();
     $aItems = array();
     $aItems['documents'][] = $doc1_id;
     $aItems['documents'][] = $doc2_id;
     $aItems['folders'][] = $folder1->get_folderid();
     // Call bulk action - checkout
     $response = $this->ktapi->performBulkAction('immute', $aItems);
     $this->assertEqual($response['status_code'], 0);
     $this->assertTrue(empty($response['results']));
     // update document object
     $doc1 = $this->ktapi->get_document_by_id($doc1_id);
     $this->assertTrue($doc1->isImmutable());
     // remove immutability for deletion
     $doc1->unimmute();
     $doc2->unimmute();
     $doc4->unimmute();
     // delete items
     $response = $this->ktapi->performBulkAction('delete', $aItems, 'Testing API');
     $this->assertEqual($response['status_code'], 0);
 }
コード例 #2
0
ファイル: testDocument.php プロジェクト: 5haman/knowledgetree
 /**
  * Tests the checkout, checkin, cancel checkout and is_checked_out document functionality
  */
 function testCheckinCheckout()
 {
     $randomFile = APIDocumentHelper::createRandomFile();
     $this->assertTrue(is_file($randomFile));
     $document = $this->root->add_document('testtitle369', 'testname369.txt', 'Default', $randomFile);
     $this->assertNotError($document);
     if (PEAR::isError($document)) {
         return;
     }
     $this->assertTrue($document instanceof KTAPI_Document);
     @unlink($randomFile);
     $documentid = $document->get_documentid();
     // document should be checked in
     $document = $this->ktapi->get_document_by_id($documentid);
     $this->assertFalse($document->is_checked_out());
     $document->checkout('Testing document checkout');
     // document should now be checked out
     $document = $this->ktapi->get_document_by_id($documentid);
     $this->assertTrue($document->is_checked_out());
     $document->undo_checkout('Testing document cancel checkout');
     // document should be checked in
     $document = $this->ktapi->get_document_by_id($documentid);
     $this->assertFalse($document->is_checked_out());
     $document->checkout('Testing document checkout');
     // document should now be checked out
     $document = $this->ktapi->get_document_by_id($documentid);
     $this->assertTrue($document->is_checked_out());
     // create another random file
     $randomFile = APIDocumentHelper::createRandomFile('updating the previous content');
     $this->assertTrue(is_file($randomFile));
     $document->checkin('testname369.txt', 'Updating test checkin document', $randomFile);
     @unlink($randomFile);
     // document should be checked in
     $document = $this->ktapi->get_document_by_id($documentid);
     $this->assertFalse($document->is_checked_out());
     $document->delete('Testing document checkin');
     $document->expunge();
 }
コード例 #3
0
ファイル: expungeall.php プロジェクト: sfsergey/knowledgetree
$config = KTConfig::getSingleton();
$user = $config->get('autoexpunge/admin', 'admin');
$password = $config->get('autoexpunge/password', 'admin');
$maximum = $config->get('autoexpunge/maximum', 50);
$ktapi = new KTAPI();
$session = $ktapi->start_session($user, $password);
if (PEAR::isError($session)) {
    $default->log->debug('Expunge_all task: Can\'t create session: ' . $session->getMessage());
    return;
}
$sql = sprintf("SELECT id FROM documents WHERE status_id=%d LIMIT %d", DELETED, $maximum);
$rows = DBUtil::getResultArray($sql);
$count = count($rows);
if ($count == 0) {
    $default->log->debug('Expunge_all task: Nothing to do.');
    $session->logout();
    return;
}
foreach ($rows as $row) {
    $id = $row['id'];
    $document = $ktapi->get_document_by_id($id);
    $title = $document->get_title();
    $default->log->info('Expunge_all task: Document to expunge, ID: ' . $id . ' Name: ' . $title);
    $result = $document->expunge();
    if (PEAR::isError($result)) {
        $default->log->error('Expunge_all task: document can\'t be expunged: ' . $result->getMessage());
    }
}
$end_time = time();
$diff = $end_time - $start_time;
$session->logout();