DocumentBrowser.php
3.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php
require_once ("../../config/dmsDefaults.php");
require_once ("$default->fileSystemRoot/lib/documentmanagement/DocumentBrowser.inc");
/**
* $Id$
*
* Unit Tests for lib/documentmanagement/DocumentBrowser.inc
* includes tests for:
* browseByFolder($folderID)
* browseByCategory($category)
* browseByDocumentType($documentTypeID)
*
* Licensed under the GNU GPL. For full terms see the file COPYING.
*
* @version $Revision$
* @author Michael Joseph <michael@jamwarehouse.com>, Jam Warehouse (Pty) Ltd, South Africa
* @package tests.documentmanagement
*/
// -------------------------------
// page start
// -------------------------------
if (checkSession()) {
echo "<pre>";
$db = new DocumentBrowser();
// default browse- should resolve to root folder
echo "default browse- starts at this users root folder<br>";
$artifacts = $db->browseByFolder();
if (!is_null($_SESSION["errorMessage"])) {
echo "error: " . $_SESSION["errorMessage"] . "<br>";
$_SESSION["errorMessage"] = NULL;
}
print_r($artifacts);
// now supply a folderid
$folderID = 3;
echo "browse- starting at folder (folderID=$folderID)<br>";
$artifacts = $db->browseByFolder($folderID);
if (!is_null($_SESSION["errorMessage"])) {
echo "error: " . $_SESSION["errorMessage"] . "<br>";
$_SESSION["errorMessage"] = NULL;
}
print_r($artifacts);
// browse by category
echo "category browse- return a list of categories:<br>";
$results = $db->browseByCategory();
if (!is_null($_SESSION["errorMessage"])) {
echo "error: " . $_SESSION["errorMessage"] . "<br>";
$_SESSION["errorMessage"] = NULL;
}
print_r($results);
// pick the first category
$category = $results["categories"][0];
echo "browsing by category = $category<br>";
$artifacts = $db->browseByCategory($category);
if (!is_null($_SESSION["errorMessage"])) {
echo "error: " . $_SESSION["errorMessage"] . "<br>";
$_SESSION["errorMessage"] = NULL;
}
print_r($artifacts);
// document type browsing
echo "document type browse- get list of doc types<br>";
$results = $db->browseByDocumentType();
if (!is_null($_SESSION["errorMessage"])) {
echo "error: " . $_SESSION["errorMessage"] . "<br>";
$_SESSION["errorMessage"] = NULL;
}
print_r($results);
// pick the first document type id
srand ((float) microtime() * 10000000);
$documentTypeID = $results["documentTypes"][0]["id"];
$documentTypeName = $results["documentTypes"][0]["name"];
echo "browsing by document type = $documentTypeID; name=$documentTypeName<br>";
$artifacts = $db->browseByDocumentType($documentTypeID);
if (!is_null($_SESSION["errorMessage"])) {
echo "error: " . $_SESSION["errorMessage"] . "<br>";
$_SESSION["errorMessage"] = NULL;
}
print_r($artifacts);
echo "</pre>";
} else {
// FIXME: redirect to no permission page
print "you do not have access to view this page! please go away, and come back when you do.<br>";
echo generateLink("logout") . "logout</a>";
}
?>