function testCollection()
 {
     $ktapi = new KTAPI();
     $session = $ktapi->start_session('admin', 'admin');
     $this->assertNotError($session);
     $columns = $ktapi->get_columns_for_view();
     $this->assertIsA($columns, 'array');
 }
 function testAdmin()
 {
     $ktapi = new KTAPI();
     $session = $ktapi->start_session('admin', 'admin');
     $this->assertNotError($session);
     $this->assertTrue(is_a($session, 'KTAPI_UserSession'));
     $this->assertTrue($session->is_active());
     $ktapi = new KTAPI();
     $session = $ktapi->get_active_session($session->session);
     $this->assertTrue(is_a($session, 'KTAPI_UserSession'));
     $session->logout();
     $this->assertFalse($session->is_active());
 }
 /**
  * Method to test the document subscriptions for webservices
  *
  */
 public function testSubscriptions_KTAPI()
 {
     $this->ktapi->session_logout();
     $this->session = $this->ktapi->start_session('admin', 'admin');
     $randomFile = APIDocumentHelper::createRandomFile();
     $this->assertTrue(is_file($randomFile));
     $document = $this->root->add_document('testtitle.txt', 'testname.txt', 'Default', $randomFile);
     $this->assertIsA($document, 'KTAPI_Document');
     $this->assertNoErrors();
     @unlink($randomFile);
     $documentid = $document->get_documentid();
     // case no subscription
     $response = $this->ktapi->is_document_subscribed($documentid);
     $this->assertIsA($response, 'array');
     $this->assertEqual($response['results']['subscribed'], 'FALSE');
     $this->assertNoErrors();
     //case add subscription
     $response = $this->ktapi->subscribe_to_document($documentid);
     $this->assertIsA($response, 'array');
     $this->assertEqual($response['results']['action_result'], 'TRUE');
     $this->assertNoErrors();
     //case add DUPLICATE subscription
     $response = $this->ktapi->subscribe_to_document($documentid);
     $this->assertIsA($response, 'array');
     $this->assertEqual($response['results']['action_result'], 'TRUE');
     $this->assertNoErrors();
     // case subscription exists
     $response = $this->ktapi->is_document_subscribed($documentid);
     $this->assertIsA($response, 'array');
     $this->assertEqual($response['results']['subscribed'], 'TRUE');
     $this->assertNoErrors();
     //case delete subscription
     $response = $this->ktapi->unsubscribe_from_document($documentid);
     $this->assertIsA($response, 'array');
     $this->assertEqual($response['results']['action_result'], 'TRUE');
     $this->assertNoErrors();
     //case delete NOT EXISTANT subscription
     $response = $this->ktapi->unsubscribe_from_document($documentid);
     $this->assertIsA($response, 'array');
     $this->assertEqual($response['results']['action_result'], 'TRUE');
     $this->assertNoErrors();
     $document->delete('Test');
     $document->expunge();
 }
 /**
  * Method to test the folder subscriptions for webservices
  *
  */
 public function testSubscriptions_KTAPI()
 {
     $this->ktapi->session_logout();
     $this->session = $this->ktapi->start_session('admin', 'admin');
     $root = $this->ktapi->get_root_folder();
     $folder = $root->add_folder('testXXXXX');
     $this->assertIsA($folder, 'KTAPI_Folder');
     $this->assertNotA($folder, 'PEAR_Error');
     $this->assertNoErrors();
     // case no subscription
     $response = $this->ktapi->is_folder_subscribed($folder->get_folderid());
     $this->assertIsA($response, 'array');
     $this->assertEqual($response['results']['subscribed'], 'FALSE');
     $this->assertNoErrors();
     //case add subscription
     $response = $this->ktapi->subscribe_to_folder($folder->get_folderid());
     $this->assertIsA($response, 'array');
     $this->assertEqual($response['results']['action_result'], 'TRUE');
     $this->assertNoErrors();
     //case add DUPLICATE subscription
     $response = $this->ktapi->subscribe_to_folder($folder->get_folderid());
     $this->assertIsA($response, 'array');
     $this->assertEqual($response['results']['action_result'], 'TRUE');
     $this->assertNoErrors();
     // case subscription exists
     $response = $this->ktapi->is_folder_subscribed($folder->get_folderid());
     $this->assertIsA($response, 'array');
     $this->assertEqual($response['results']['subscribed'], 'TRUE');
     $this->assertNoErrors();
     //case delete subscription
     $response = $this->ktapi->unsubscribe_from_folder($folder->get_folderid());
     $this->assertIsA($response, 'array');
     $this->assertEqual($response['results']['action_result'], 'TRUE');
     $this->assertNoErrors();
     //case delete NOT EXISTANT subscription
     $response = $this->ktapi->unsubscribe_from_folder($folder->get_folderid());
     $this->assertIsA($response, 'array');
     $this->assertEqual($response['results']['action_result'], 'TRUE');
     $this->assertNoErrors();
     $folder->delete('testXXXXX');
 }
Exemple #5
0
                print "Usage: search.php [verbose] user=username pass=password [output=simple|xml|csv] 'search criteria'\n";
                exit;
        }
    }
}
if ($verbose) {
    print _kt('Command line search') . "...\n";
}
if (empty($username)) {
    die(_kt("Please specify a username!"));
}
if (empty($expr)) {
    die(_kt("Please specify search criteria!"));
}
$ktapi = new KTAPI();
$result = $ktapi->start_session($username, $password);
if (PEAR::isError($result)) {
    print _kt("Cannot locate user:"******" {$username}\n";
    exit;
}
try {
    $expr = parseExpression($expr);
    $result = $expr->evaluate();
    switch ($output) {
        case 'simple':
            foreach ($result['docs'] as $item) {
                print 'Document ID: ' . $item->DocumentID . ' Title:' . $item->Title . ' Relevance:' . $item->Rank . "\n";
            }
            break;
        case 'csv':
            print "DocumentId,Title,Relevance\n";
 * admin=admin
 * password=admin
 * maximum=50
 *
 * admin and password is required to expunge documents from the system.
 *
 * maximum is the maximum number of documents that should be expunged from the system in one run.
 *
 */
$start_time = time();
$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);
Exemple #7
0
 /**
  * Creates a new session for the user.
  *
  * @param string $username
  * @param string $password
  * @param string $ip
  * @return kt_response
  */
 public function login()
 {
     if (isset($_REQUEST['type'])) {
         $this->setType($_REQUEST['type']);
     }
     if (isset($_REQUEST['username'])) {
         $this->setUsername($_REQUEST['username']);
     }
     if (isset($_REQUEST['password'])) {
         $this->setPassword($_REQUEST['password']);
     }
     $kt = new KTAPI();
     $session = $kt->start_session($this->username, $this->password, $ip);
     if (PEAR::isError($session)) {
         $this->status_code = 1;
         $this->message = $session->getMessage();
         return $this->login_fail();
     }
     $session = $session->get_session();
     $this->status_code = 0;
     $this->message = "";
     $this->results = $session;
     return $this->login_pass($response);
 }
 /**
  * Creates a new session for the user.
  *
  * @param string $username
  * @param string $password
  * @param string $ip
  * @return kt_response
  */
 function login($username, $password, $ip = null)
 {
     $response = KTWebService::_status(KTWS_ERR_AUTHENTICATION_ERROR);
     $kt = new KTAPI();
     $session = $kt->start_session($username, $password, $ip);
     if (PEAR::isError($session)) {
         $response['message'] = $session->getMessage();
         $this->debug($session->getMessage(), 'login');
         return new SOAP_Value('return', "{urn:{$this->namespace}}kt_response", $response);
     }
     $session = $session->get_session();
     $response['status_code'] = KTWS_SUCCESS;
     $response['message'] = $session;
     $this->debug("login('{$username}','{$password}','{$ip}')", $session);
     return new SOAP_Value('return', "{urn:{$this->namespace}}kt_response", $response);
 }