Commit 5983de1b4d33809c93ab695a11567dce2f193d9f
1 parent
ed8e9a6b
Added document role allocation and email functionality to ktapi. Updated php docblocks on functions.
Committed by: Megan Watson Reviewed by: Kevin Cyster
Showing
3 changed files
with
385 additions
and
103 deletions
ktapi/KTAPIDocument.inc.php
| ... | ... | @@ -2419,6 +2419,16 @@ class KTAPI_Document extends KTAPI_FolderItem |
| 2419 | 2419 | $allowAttachment = $config->get('email/allowAttachment', false); |
| 2420 | 2420 | $allowEmailAddresses = $config->get('email/allowEmailAddresses', false); |
| 2421 | 2421 | |
| 2422 | + // if attachments aren't allowed, set $attachDocument to false | |
| 2423 | + if(!$allowAttachment){ | |
| 2424 | + $attachDocument = false; | |
| 2425 | + } | |
| 2426 | + | |
| 2427 | + // If sending to external email addresses is not allowed - set array of external recipients to empty | |
| 2428 | + if(!$allowEmailAddresses){ | |
| 2429 | + $emailAddrs = array(); | |
| 2430 | + } | |
| 2431 | + | |
| 2422 | 2432 | $emailErrors = array(); |
| 2423 | 2433 | $userEmails = array(); |
| 2424 | 2434 | $listEmails = array(); |
| ... | ... | @@ -2429,11 +2439,11 @@ class KTAPI_Document extends KTAPI_FolderItem |
| 2429 | 2439 | |
| 2430 | 2440 | if ($attachDocument) |
| 2431 | 2441 | { |
| 2432 | - sendManualEmails($aEmailAddresses, $userEmails, $emailErrors); | |
| 2442 | + sendManualEmails($emailAddrs, $userEmails, $emailErrors); | |
| 2433 | 2443 | } |
| 2434 | 2444 | else |
| 2435 | 2445 | { |
| 2436 | - sendExternalEmails($aEmailAddresses, $this->document->getID(), $this->document->getName(), $comment, $emailErrors); | |
| 2446 | + sendExternalEmails($emailAddrs, $this->documentid, $this->get_title(), $comment, $emailErrors); | |
| 2437 | 2447 | } |
| 2438 | 2448 | |
| 2439 | 2449 | if(empty($userEmails)){ |
| ... | ... | @@ -2441,7 +2451,7 @@ class KTAPI_Document extends KTAPI_FolderItem |
| 2441 | 2451 | } |
| 2442 | 2452 | |
| 2443 | 2453 | $listEmails = array_keys($userEmails); |
| 2444 | - sendEmail($listEmails, $this->document->getID(), $this->document->getName(), $comment, (boolean)$fAttachDocument, $aEmailErrors); | |
| 2454 | + sendEmail($listEmails, $this->documentid, $this->get_title(), $comment, (boolean)$attachDocument, $emailErrors); | |
| 2445 | 2455 | |
| 2446 | 2456 | } |
| 2447 | 2457 | } | ... | ... |
ktapi/ktapi.inc.php
| ... | ... | @@ -175,7 +175,7 @@ class KTAPI |
| 175 | 175 | * This returns the current session. |
| 176 | 176 | * |
| 177 | 177 | * @author KnowledgeTree Team |
| 178 | - * @access public | |
| 178 | + * @access protected | |
| 179 | 179 | * @return object $session The KTAPI_Session object |
| 180 | 180 | */ |
| 181 | 181 | public function &get_session() |
| ... | ... | @@ -188,7 +188,7 @@ class KTAPI |
| 188 | 188 | * This returns the session user object or an error object. |
| 189 | 189 | * |
| 190 | 190 | * @author KnowledgeTree Team |
| 191 | - * @access public | |
| 191 | + * @access protected | |
| 192 | 192 | * @return object $user SUCCESS - The User object | FAILURE - an error object |
| 193 | 193 | */ |
| 194 | 194 | public function & get_user() |
| ... | ... | @@ -209,6 +209,14 @@ class KTAPI |
| 209 | 209 | return $user; |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | + /** | |
| 213 | + * Get the available columns for the given view (browse | search) | |
| 214 | + * | |
| 215 | + * @author KnowledgeTree Team | |
| 216 | + * @access public | |
| 217 | + * @param string $view The namespace for the view - ktcore.views.browse | ktcore.views.search | |
| 218 | + * @return unknown | |
| 219 | + */ | |
| 212 | 220 | function get_columns_for_view($view = 'ktcore.views.browse') { |
| 213 | 221 | $ktapi_session = $this->get_session(); |
| 214 | 222 | if (is_null($ktapi_session) || PEAR::isError($ktapi_session)) |
| ... | ... | @@ -225,7 +233,7 @@ class KTAPI |
| 225 | 233 | * This returns a permission object or an error object. |
| 226 | 234 | * |
| 227 | 235 | * @author KnowledgeTree Team |
| 228 | - * @access public | |
| 236 | + * @access protected | |
| 229 | 237 | * @param string $permission The permissions string |
| 230 | 238 | * @return object $permissions SUCCESS - The KTPermission object | FAILURE - an error object |
| 231 | 239 | */ |
| ... | ... | @@ -243,6 +251,7 @@ class KTAPI |
| 243 | 251 | /** |
| 244 | 252 | * Returns an associative array of permission namespaces and their names |
| 245 | 253 | * |
| 254 | + * @author KnowledgeTree Team | |
| 246 | 255 | * @access public |
| 247 | 256 | * @return array |
| 248 | 257 | */ |
| ... | ... | @@ -259,6 +268,7 @@ class KTAPI |
| 259 | 268 | /** |
| 260 | 269 | * Returns folder permissions |
| 261 | 270 | * |
| 271 | + * @author KnowledgeTree Team | |
| 262 | 272 | * @access public |
| 263 | 273 | * @param string |
| 264 | 274 | * @param int |
| ... | ... | @@ -292,6 +302,7 @@ class KTAPI |
| 292 | 302 | /** |
| 293 | 303 | * Add folder permission |
| 294 | 304 | * |
| 305 | + * @author KnowledgeTree Team | |
| 295 | 306 | * @access public |
| 296 | 307 | * @param string |
| 297 | 308 | * @param string |
| ... | ... | @@ -1785,7 +1796,7 @@ class KTAPI |
| 1785 | 1796 | * @author KnowledgeTree Team |
| 1786 | 1797 | * @access public |
| 1787 | 1798 | * @param string $ip The users IP address |
| 1788 | - * @return array Response | |
| 1799 | + * @return array Response 'results' contain the session id | 'message' contains the error message on failure | |
| 1789 | 1800 | */ |
| 1790 | 1801 | function anonymous_login($ip=null) |
| 1791 | 1802 | { |
| ... | ... | @@ -1809,10 +1820,10 @@ class KTAPI |
| 1809 | 1820 | * |
| 1810 | 1821 | * @author KnowledgeTree Team |
| 1811 | 1822 | * @access public |
| 1812 | - * @param string $username | |
| 1813 | - * @param string $password | |
| 1814 | - * @param string $ip | |
| 1815 | - * @return string | |
| 1823 | + * @param string $username The users username | |
| 1824 | + * @param string $password The users password | |
| 1825 | + * @param string $ip Optional. The users IP address | |
| 1826 | + * @return array Response 'results' contain the session id | 'message' contains the error message on failure | |
| 1816 | 1827 | */ |
| 1817 | 1828 | function login($username, $password, $ip=null) |
| 1818 | 1829 | { |
| ... | ... | @@ -1835,7 +1846,7 @@ class KTAPI |
| 1835 | 1846 | * |
| 1836 | 1847 | * @author KnowledgeTree Team |
| 1837 | 1848 | * @access public |
| 1838 | - * @return KTAPI_Error on failure | |
| 1849 | + * @return array Response Empty on success | 'message' contains the error message on failure | |
| 1839 | 1850 | */ |
| 1840 | 1851 | function logout() |
| 1841 | 1852 | { |
| ... | ... | @@ -1852,12 +1863,12 @@ class KTAPI |
| 1852 | 1863 | } |
| 1853 | 1864 | |
| 1854 | 1865 | /** |
| 1855 | - * Returns folder detail given a folder_id. | |
| 1866 | + * Returns the folder details for a given folder id. | |
| 1856 | 1867 | * |
| 1857 | 1868 | * @author KnowledgeTree Team |
| 1858 | 1869 | * @access public |
| 1859 | - * @param int $folder_id | |
| 1860 | - * @return kt_folder_detail. | |
| 1870 | + * @param integer $folder_id The id of the folder | |
| 1871 | + * @return array Response 'results' contains kt_folder_detail | 'message' contains error message on failure | |
| 1861 | 1872 | */ |
| 1862 | 1873 | function get_folder_detail($folder_id) |
| 1863 | 1874 | { |
| ... | ... | @@ -1875,12 +1886,12 @@ class KTAPI |
| 1875 | 1886 | } |
| 1876 | 1887 | |
| 1877 | 1888 | /** |
| 1878 | - * Retrieves all shortcuts linking to a specific document | |
| 1889 | + * Retrieves all shortcuts linking to a specific folder | |
| 1879 | 1890 | * |
| 1880 | 1891 | * @author KnowledgeTree Team |
| 1881 | 1892 | * @access public |
| 1882 | - * @param ing $document_id | |
| 1883 | - * @return kt_document_shortcuts | |
| 1893 | + * @param integer $folder_id The id of the folder | |
| 1894 | + * @return array Response 'results' contains kt_folder_shortcuts | 'message' contains error message on failure | |
| 1884 | 1895 | * |
| 1885 | 1896 | */ |
| 1886 | 1897 | function get_folder_shortcuts($folder_id) |
| ... | ... | @@ -1910,8 +1921,8 @@ class KTAPI |
| 1910 | 1921 | * |
| 1911 | 1922 | * @author KnowledgeTree Team |
| 1912 | 1923 | * @access public |
| 1913 | - * @param string $folder_name | |
| 1914 | - * @return kt_folder_detail. | |
| 1924 | + * @param string $folder_name The name of the folder | |
| 1925 | + * @return array Response 'results' contains kt_folder_detail | 'message' contains error message on failure | |
| 1915 | 1926 | */ |
| 1916 | 1927 | function get_folder_detail_by_name($folder_name) |
| 1917 | 1928 | { |
| ... | ... | @@ -1929,14 +1940,14 @@ class KTAPI |
| 1929 | 1940 | } |
| 1930 | 1941 | |
| 1931 | 1942 | /** |
| 1932 | - * Returns the contents of a folder. | |
| 1943 | + * Returns the contents of a folder - list of contained documents and folders | |
| 1933 | 1944 | * |
| 1934 | 1945 | * @author KnowledgeTree Team |
| 1935 | 1946 | * @access public |
| 1936 | - * @param int $folder_id | |
| 1937 | - * @param int $depth | |
| 1938 | - * @param string $what | |
| 1939 | - * @return kt_folder_contents | |
| 1947 | + * @param integer $folder_id The id of the folder | |
| 1948 | + * @param integer $depth The depth to display - 1 = direct contents, 2 = include contents of the contained folders, etc | |
| 1949 | + * @param string $what Filter on what should be returned, takes a combination of the following: D = documents, F = folders, S = shortcuts | |
| 1950 | + * @return array Response 'results' contains kt_folder_contents | 'message' contains error message on failure | |
| 1940 | 1951 | */ |
| 1941 | 1952 | function get_folder_contents($folder_id, $depth=1, $what='DFS') |
| 1942 | 1953 | { |
| ... | ... | @@ -1963,11 +1974,13 @@ class KTAPI |
| 1963 | 1974 | } |
| 1964 | 1975 | |
| 1965 | 1976 | /** |
| 1966 | - * Creates a new folder. | |
| 1977 | + * Creates a new folder inside the given folder | |
| 1967 | 1978 | * |
| 1968 | - * @param int $folder_id | |
| 1969 | - * @param string $folder_name | |
| 1970 | - * @return kt_folder_detail. | |
| 1979 | + * @author KnowledgeTree Team | |
| 1980 | + * @access public | |
| 1981 | + * @param integer $folder_id The id of the parent folder | |
| 1982 | + * @param string $folder_name The name of the new folder | |
| 1983 | + * @return array Response 'results' contains kt_folder_detail | 'message' contains error message on failure | |
| 1971 | 1984 | */ |
| 1972 | 1985 | function create_folder($folder_id, $folder_name) |
| 1973 | 1986 | { |
| ... | ... | @@ -1988,9 +2001,11 @@ class KTAPI |
| 1988 | 2001 | /** |
| 1989 | 2002 | * Creates a shortcut to an existing folder |
| 1990 | 2003 | * |
| 1991 | - * @param int $target_folder_id Folder to place the shortcut in | |
| 1992 | - * @param int $source_folder_id Folder to create the shortcut to | |
| 1993 | - * @return kt_folder_detail. | |
| 2004 | + * @author KnowledgeTree Team | |
| 2005 | + * @access public | |
| 2006 | + * @param integer $target_folder_id Id of the folder containing the shortcut. | |
| 2007 | + * @param integer $source_folder_id Id of the folder to which the shortcut will point. | |
| 2008 | + * @return array Response 'results' contains kt_shortcut_detail | 'message' contains error message on failure | |
| 1994 | 2009 | */ |
| 1995 | 2010 | function create_folder_shortcut($target_folder_id, $source_folder_id) |
| 1996 | 2011 | { |
| ... | ... | @@ -2027,9 +2042,11 @@ class KTAPI |
| 2027 | 2042 | /** |
| 2028 | 2043 | * Creates a shortcut to an existing document |
| 2029 | 2044 | * |
| 2030 | - * @param int $target_folder_id Folder to place the shortcut in | |
| 2031 | - * @param int $source_document_id Document to create the shortcut to | |
| 2032 | - * @return kt_document_detail. | |
| 2045 | + * @author KnowledgeTree Team | |
| 2046 | + * @access public | |
| 2047 | + * @param integer $target_folder_id Id of the parent folder containing the shortcut | |
| 2048 | + * @param integer $source_document_id Id of the document to which the shortcut will point | |
| 2049 | + * @return array Response 'results' contains kt_document_detail | 'message' contains error message on failure | |
| 2033 | 2050 | */ |
| 2034 | 2051 | function create_document_shortcut($target_folder_id, $source_document_id) |
| 2035 | 2052 | { |
| ... | ... | @@ -2066,9 +2083,11 @@ class KTAPI |
| 2066 | 2083 | /** |
| 2067 | 2084 | * Deletes a folder. |
| 2068 | 2085 | * |
| 2069 | - * @param int $folder_id | |
| 2070 | - * @param string $reason | |
| 2071 | - * @return kt_response. | |
| 2086 | + * @author KnowledgeTree Team | |
| 2087 | + * @access public | |
| 2088 | + * @param integer $folder_id The id of the folder to delete | |
| 2089 | + * @param string $reason The reason for performing the deletion | |
| 2090 | + * @return array Response | 'message' contains error message on failure | |
| 2072 | 2091 | */ |
| 2073 | 2092 | function delete_folder($folder_id, $reason) |
| 2074 | 2093 | { |
| ... | ... | @@ -2095,9 +2114,11 @@ class KTAPI |
| 2095 | 2114 | /** |
| 2096 | 2115 | * Renames a folder. |
| 2097 | 2116 | * |
| 2098 | - * @param int $folder_id | |
| 2099 | - * @param string $newname | |
| 2100 | - * @return kt_response. | |
| 2117 | + * @author KnowledgeTree Team | |
| 2118 | + * @access public | |
| 2119 | + * @param integer $folder_id The id of the folder | |
| 2120 | + * @param string $newname The new name of the folder | |
| 2121 | + * @return array Response | 'message' contains error message on failure | |
| 2101 | 2122 | */ |
| 2102 | 2123 | function rename_folder($folder_id, $newname) |
| 2103 | 2124 | { |
| ... | ... | @@ -2123,10 +2144,12 @@ class KTAPI |
| 2123 | 2144 | /** |
| 2124 | 2145 | * Makes a copy of a folder in another location. |
| 2125 | 2146 | * |
| 2126 | - * @param int $sourceid | |
| 2127 | - * @param int $targetid | |
| 2128 | - * @param string $reason | |
| 2129 | - * @return kt_response | |
| 2147 | + * @author KnowledgeTree Team | |
| 2148 | + * @access public | |
| 2149 | + * @param integer $sourceid The id of the folder to be copied | |
| 2150 | + * @param integer $targetid The id of the folder in which the copy should be placed | |
| 2151 | + * @param string $reason The reason for performing the copy | |
| 2152 | + * @return array Response | 'message' contains error message on failure | |
| 2130 | 2153 | */ |
| 2131 | 2154 | function copy_folder($source_id, $target_id, $reason) |
| 2132 | 2155 | { |
| ... | ... | @@ -2170,10 +2193,12 @@ class KTAPI |
| 2170 | 2193 | /** |
| 2171 | 2194 | * Moves a folder to another location. |
| 2172 | 2195 | * |
| 2173 | - * @param int $sourceid | |
| 2174 | - * @param int $targetid | |
| 2175 | - * @param string $reason | |
| 2176 | - * @return kt_response. | |
| 2196 | + * @author KnowledgeTree Team | |
| 2197 | + * @access public | |
| 2198 | + * @param integer $sourceid The id of the folder to be moved | |
| 2199 | + * @param integer $targetid The id of the folder into which the folder should be moved | |
| 2200 | + * @param string $reason The reason for performing the move | |
| 2201 | + * @return array Response | 'message' contains error message on failure | |
| 2177 | 2202 | */ |
| 2178 | 2203 | function move_folder($source_id, $target_id, $reason) |
| 2179 | 2204 | { |
| ... | ... | @@ -2215,10 +2240,11 @@ class KTAPI |
| 2215 | 2240 | /** |
| 2216 | 2241 | * Returns a list of document types. |
| 2217 | 2242 | * |
| 2218 | - * @param string $session_id | |
| 2219 | - * @return kt_document_types_response. . status_code can be KTWS_ERR_INVALID_SESSION, KTWS_SUCCESS | |
| 2243 | + * @author KnowledgeTree Team | |
| 2244 | + * @access public | |
| 2245 | + * @return array Response 'results' contain kt_document_types_response | 'message' contains error message on failure | |
| 2220 | 2246 | */ |
| 2221 | - public function get_document_types($session_id) | |
| 2247 | + public function get_document_types() | |
| 2222 | 2248 | { |
| 2223 | 2249 | $result = $this->get_documenttypes(); |
| 2224 | 2250 | if (PEAR::isError($result)) |
| ... | ... | @@ -2235,7 +2261,12 @@ class KTAPI |
| 2235 | 2261 | |
| 2236 | 2262 | } |
| 2237 | 2263 | |
| 2238 | - public function get_document_link_types_list($session_id) | |
| 2264 | + /** | |
| 2265 | + * Returns a list of document link types - Attachment, Reference, etc | |
| 2266 | + * | |
| 2267 | + * @return array Response 'results' contain kt_document_link_types_response | 'message' contains error message on failure | |
| 2268 | + */ | |
| 2269 | + public function get_document_link_types_list() | |
| 2239 | 2270 | { |
| 2240 | 2271 | $result = $this->get_document_link_types(); |
| 2241 | 2272 | if (PEAR::isError($result)) |
| ... | ... | @@ -2254,12 +2285,17 @@ class KTAPI |
| 2254 | 2285 | } |
| 2255 | 2286 | |
| 2256 | 2287 | /** |
| 2257 | - * Returns document detail given a document_id. | |
| 2288 | + * Returns document details given a document_id. | |
| 2289 | + * Details can be filtered using a combination of the following: M = metadata, L = links, T = workflow transitions, | |
| 2290 | + * V = version history, H = transaction history | |
| 2258 | 2291 | * |
| 2259 | - * @param int $document_id | |
| 2260 | - * @return kt_document_detail. | |
| 2292 | + * @author KnowledgeTree Team | |
| 2293 | + * @access public | |
| 2294 | + * @param integer $document_id The id of the document | |
| 2295 | + * @param string $detailstr Optional. Filter on the level of detail to return. | |
| 2296 | + * @return array Response 'results' contain kt_document_detail | 'message' contains error message on failure | |
| 2261 | 2297 | */ |
| 2262 | - function get_document_detail($document_id, $detailstr='') | |
| 2298 | + public function get_document_detail($document_id, $detailstr='') | |
| 2263 | 2299 | { |
| 2264 | 2300 | $document = $this->get_document_by_id($document_id); |
| 2265 | 2301 | if (PEAR::isError($document)) |
| ... | ... | @@ -2328,25 +2364,54 @@ class KTAPI |
| 2328 | 2364 | return $response; |
| 2329 | 2365 | } |
| 2330 | 2366 | |
| 2331 | - function get_document_detail_by_filename($folder_id, $filename, $detail='') | |
| 2367 | + /** | |
| 2368 | + * Returns the document details given the filename of the document | |
| 2369 | + * Details can be filtered using a combination of the following: M = metadata, L = links, T = workflow transitions, | |
| 2370 | + * V = version history, H = transaction history | |
| 2371 | + * | |
| 2372 | + * @author KnowledgeTree Team | |
| 2373 | + * @access public | |
| 2374 | + * @param integer $folder_id The id of the folder in which to find the document | |
| 2375 | + * @param string $filename The filename of the document | |
| 2376 | + * @param string $detail Optional. Filter on the level of detail to return. | |
| 2377 | + * @return array Response 'results' contain kt_document_detail | 'message' contains error message on failure | |
| 2378 | + */ | |
| 2379 | + public function get_document_detail_by_filename($folder_id, $filename, $detail='') | |
| 2332 | 2380 | { |
| 2333 | 2381 | return $this->get_document_detail_by_name($folder_id, $filename, 'F', $detail); |
| 2334 | 2382 | } |
| 2335 | 2383 | |
| 2336 | - function get_document_detail_by_title($folder_id, $title, $detail='') | |
| 2384 | + /** | |
| 2385 | + * Returns the document details give the title of the document | |
| 2386 | + * Details can be filtered using a combination of the following: M = metadata, L = links, T = workflow transitions, | |
| 2387 | + * V = version history, H = transaction history | |
| 2388 | + * | |
| 2389 | + * @author KnowledgeTree Team | |
| 2390 | + * @access public | |
| 2391 | + * @param interger $folder_id The id of the folder in which to find the document | |
| 2392 | + * @param string $title The title of the document | |
| 2393 | + * @param string $detail Optional. Filter on the level of detail to return. | |
| 2394 | + * @return array Response 'results' contain kt_document_detail | 'message' contains error message on failure | |
| 2395 | + */ | |
| 2396 | + public function get_document_detail_by_title($folder_id, $title, $detail='') | |
| 2337 | 2397 | { |
| 2338 | 2398 | return $this->get_document_detail_by_name($folder_id, $title, 'T', $detail); |
| 2339 | 2399 | } |
| 2340 | 2400 | |
| 2341 | - | |
| 2342 | 2401 | /** |
| 2343 | 2402 | * Returns document detail given a document name which could include a full path. |
| 2403 | + * Details can be filtered using a combination of the following: M = metadata, L = links, T = workflow transitions, | |
| 2404 | + * V = version history, H = transaction history | |
| 2344 | 2405 | * |
| 2345 | - * @param string $document_name | |
| 2346 | - * @param string @what | |
| 2347 | - * @return kt_document_detail. | |
| 2406 | + * @author KnowledgeTree Team | |
| 2407 | + * @access public | |
| 2408 | + * @param integer $folder_id The id of the folder in which to find the document | |
| 2409 | + * @param string $document_name The name of the document | |
| 2410 | + * @param string @what Optional. Defaults to T. The type of name - F = filename or T = title | |
| 2411 | + * @param string $detail Optional. Filter on the level of detail to return. | |
| 2412 | + * @return array Response 'results' contain kt_document_detail | 'message' contains error message on failure | |
| 2348 | 2413 | */ |
| 2349 | - function get_document_detail_by_name($folder_id, $document_name, $what='T', $detail='') | |
| 2414 | + public function get_document_detail_by_name($folder_id, $document_name, $what='T', $detail='') | |
| 2350 | 2415 | { |
| 2351 | 2416 | $response['status_code'] = 1; |
| 2352 | 2417 | if (empty($document_name)) |
| ... | ... | @@ -2387,13 +2452,117 @@ class KTAPI |
| 2387 | 2452 | } |
| 2388 | 2453 | |
| 2389 | 2454 | /** |
| 2455 | + * Returns the role allocation on the document | |
| 2456 | + * | |
| 2457 | + * @author KnowledgeTree Team | |
| 2458 | + * @access public | |
| 2459 | + * @author KnowledgeTree Team | |
| 2460 | + * @access public | |
| 2461 | + * @param integer $document_id The id of the document | |
| 2462 | + * @return array Response | |
| 2463 | + */ | |
| 2464 | + public function get_role_allocation_for_document($document_id) | |
| 2465 | + { | |
| 2466 | + $document = $this->get_document_by_id($document_id); | |
| 2467 | + if(PEAR::isError($document)){ | |
| 2468 | + $response['status_code'] = 1; | |
| 2469 | + $response['message'] = $document->getMessage(); | |
| 2470 | + return $response; | |
| 2471 | + } | |
| 2472 | + | |
| 2473 | + $allocation = $document->getRoleAllocation(); | |
| 2474 | + | |
| 2475 | + $response['status_code'] = 0; | |
| 2476 | + $response['results'] = $allocation->getMembership(); | |
| 2477 | + return $response; | |
| 2478 | + } | |
| 2479 | + | |
| 2480 | + /** | |
| 2481 | + * Emails a document as an attachment or hyperlink to a list of users, groups or external email addresses. | |
| 2482 | + * In the case of external addresses, if a hyperlink is used then a timed download link (via webservices) is sent allowing the recipient a window period in which to download the document. | |
| 2483 | + * The period is set through the webservices config option webservice/downloadExpiry. Defaults to 30 minutes. | |
| 2484 | + * | |
| 2485 | + * @author KnowledgeTree Team | |
| 2486 | + * @access public | |
| 2487 | + * @param string $document_id The id of the document | |
| 2488 | + * @param array $members The email recipients (users, groups, external) in the format: array('users' => array(1,2), 'groups' => array(3,1), 'external' => array('name@email.com')) | |
| 2489 | + * @param string $comment Content to be appended to the email | |
| 2490 | + * @param bool $attach TRUE if document is an attachment | FALSE if using a hyperlink to the document | |
| 2491 | + * @return array Response | |
| 2492 | + */ | |
| 2493 | + public function email_document($document_id, $members, $content = '', $attach = true) | |
| 2494 | + { | |
| 2495 | + $response['status_code'] = 1; | |
| 2496 | + if(!isset($members['users']) && !isset($members['groups']) && !isset($members['external'])){ | |
| 2497 | + $response['message'] = _kt("No recipients were provided. The list of recipients should be in the format: array('users' => array(1,2), 'groups' => array(3,1), 'external' => array('name@email.com'))."); | |
| 2498 | + return $response; | |
| 2499 | + } | |
| 2500 | + | |
| 2501 | + $document = $this->get_document_by_id($document_id); | |
| 2502 | + if(PEAR::isError($document)){ | |
| 2503 | + $response['message'] = $document->getMessage(); | |
| 2504 | + return $response; | |
| 2505 | + } | |
| 2506 | + | |
| 2507 | + $recipients = array(); | |
| 2508 | + | |
| 2509 | + // Get member objects and add them to the role | |
| 2510 | + // Users | |
| 2511 | + if(isset($members['users'])){ | |
| 2512 | + foreach($members['users'] as $user_id){ | |
| 2513 | + // Get the user object | |
| 2514 | + $member = KTAPI_User::getById($user_id); | |
| 2515 | + | |
| 2516 | + if(PEAR::isError($member)) { | |
| 2517 | + $response['message'] = $member->getMessage(); | |
| 2518 | + return $response; | |
| 2519 | + } | |
| 2520 | + | |
| 2521 | + // Add to recipients list | |
| 2522 | + $recipients[] = $member; | |
| 2523 | + } | |
| 2524 | + } | |
| 2525 | + | |
| 2526 | + // Groups | |
| 2527 | + if(isset($members['groups'])){ | |
| 2528 | + foreach($members['groups'] as $group_id){ | |
| 2529 | + // Get the group object | |
| 2530 | + $member = KTAPI_Group::getById($group_id); | |
| 2531 | + | |
| 2532 | + if(PEAR::isError($member)) { | |
| 2533 | + $response['message'] = $member->getMessage(); | |
| 2534 | + return $response; | |
| 2535 | + } | |
| 2536 | + | |
| 2537 | + // Add to recipients list | |
| 2538 | + $recipients[] = $member; | |
| 2539 | + } | |
| 2540 | + } | |
| 2541 | + | |
| 2542 | + // External recipients | |
| 2543 | + if(isset($members['external'])){ | |
| 2544 | + foreach ($members['external'] as $email_address){ | |
| 2545 | + // Add to recipients list | |
| 2546 | + $recipients[] = $member; | |
| 2547 | + } | |
| 2548 | + } | |
| 2549 | + | |
| 2550 | + $document->email($recipients, $content, $attach); | |
| 2551 | + | |
| 2552 | + $response['status_code'] = 0; | |
| 2553 | + return $response; | |
| 2554 | + } | |
| 2555 | + | |
| 2556 | + /** | |
| 2390 | 2557 | * Retrieves all shortcuts linking to a specific document |
| 2391 | 2558 | * |
| 2559 | + * @author KnowledgeTree Team | |
| 2560 | + * @access public | |
| 2392 | 2561 | * @param ing $document_id |
| 2393 | 2562 | * @return kt_document_shortcuts. |
| 2394 | 2563 | * |
| 2395 | 2564 | */ |
| 2396 | - function get_document_shortcuts($document_id) | |
| 2565 | + public function get_document_shortcuts($document_id) | |
| 2397 | 2566 | { |
| 2398 | 2567 | $document = $this->get_document_by_id($document_id); |
| 2399 | 2568 | if(PEAR::isError($document)){ |
| ... | ... | @@ -2418,6 +2587,8 @@ class KTAPI |
| 2418 | 2587 | /** |
| 2419 | 2588 | * Adds a document to the repository. |
| 2420 | 2589 | * |
| 2590 | + * @author KnowledgeTree Team | |
| 2591 | + * @access public | |
| 2421 | 2592 | * @param int $folder_id |
| 2422 | 2593 | * @param string $title |
| 2423 | 2594 | * @param string $filename |
| ... | ... | @@ -2425,7 +2596,7 @@ class KTAPI |
| 2425 | 2596 | * @param string $tempfilename |
| 2426 | 2597 | * @return kt_document_detail. |
| 2427 | 2598 | */ |
| 2428 | - function add_document($folder_id, $title, $filename, $documenttype, $tempfilename) | |
| 2599 | + public function add_document($folder_id, $title, $filename, $documenttype, $tempfilename) | |
| 2429 | 2600 | { |
| 2430 | 2601 | // we need to add some security to ensure that people don't frig the checkin process to access restricted files. |
| 2431 | 2602 | // possibly should change 'tempfilename' to be a hash or id of some sort if this is troublesome. |
| ... | ... | @@ -2459,7 +2630,7 @@ class KTAPI |
| 2459 | 2630 | return $response; |
| 2460 | 2631 | } |
| 2461 | 2632 | |
| 2462 | - function add_small_document_with_metadata($folder_id, $title, $filename, $documenttype, $base64, $metadata, $sysdata) | |
| 2633 | + public function add_small_document_with_metadata($folder_id, $title, $filename, $documenttype, $base64, $metadata, $sysdata) | |
| 2463 | 2634 | { |
| 2464 | 2635 | $add_result = $this->add_small_document($folder_id, $title, $filename, $documenttype, $base64); |
| 2465 | 2636 | |
| ... | ... | @@ -2490,7 +2661,7 @@ class KTAPI |
| 2490 | 2661 | return $update_result; |
| 2491 | 2662 | } |
| 2492 | 2663 | |
| 2493 | - function add_document_with_metadata($folder_id, $title, $filename, $documenttype, $tempfilename, $metadata, $sysdata) | |
| 2664 | + public function add_document_with_metadata($folder_id, $title, $filename, $documenttype, $tempfilename, $metadata, $sysdata) | |
| 2494 | 2665 | { |
| 2495 | 2666 | $add_result = $this->add_document($folder_id, $title, $filename, $documenttype, $tempfilename); |
| 2496 | 2667 | |
| ... | ... | @@ -2526,11 +2697,13 @@ class KTAPI |
| 2526 | 2697 | /** |
| 2527 | 2698 | * Find documents matching the document oem (integration) no |
| 2528 | 2699 | * |
| 2700 | + * @author KnowledgeTree Team | |
| 2701 | + * @access public | |
| 2529 | 2702 | * @param string $oem_no |
| 2530 | 2703 | * @param string $detail |
| 2531 | 2704 | * @return kt_document_collection_response |
| 2532 | 2705 | */ |
| 2533 | - function get_documents_detail_by_oem_no($oem_no, $detail) | |
| 2706 | + public function get_documents_detail_by_oem_no($oem_no, $detail) | |
| 2534 | 2707 | { |
| 2535 | 2708 | $documents = $this->get_documents_by_oem_no($oem_no); |
| 2536 | 2709 | |
| ... | ... | @@ -2555,6 +2728,8 @@ class KTAPI |
| 2555 | 2728 | /** |
| 2556 | 2729 | * Adds a document to the repository. |
| 2557 | 2730 | * |
| 2731 | + * @author KnowledgeTree Team | |
| 2732 | + * @access public | |
| 2558 | 2733 | * @param int $folder_id |
| 2559 | 2734 | * @param string $title |
| 2560 | 2735 | * @param string $filename |
| ... | ... | @@ -2562,7 +2737,7 @@ class KTAPI |
| 2562 | 2737 | * @param string $base64 |
| 2563 | 2738 | * @return kt_document_detail. |
| 2564 | 2739 | */ |
| 2565 | - function add_small_document($folder_id, $title, $filename, $documenttype, $base64) | |
| 2740 | + public function add_small_document($folder_id, $title, $filename, $documenttype, $base64) | |
| 2566 | 2741 | { |
| 2567 | 2742 | $folder = &$this->get_folder_by_id($folder_id); |
| 2568 | 2743 | if (PEAR::isError($folder)) |
| ... | ... | @@ -2603,6 +2778,8 @@ class KTAPI |
| 2603 | 2778 | /** |
| 2604 | 2779 | * Does a document checkin. |
| 2605 | 2780 | * |
| 2781 | + * @author KnowledgeTree Team | |
| 2782 | + * @access public | |
| 2606 | 2783 | * @param int $folder_id |
| 2607 | 2784 | * @param string $title |
| 2608 | 2785 | * @param string $filename |
| ... | ... | @@ -2610,7 +2787,7 @@ class KTAPI |
| 2610 | 2787 | * @param string $tempfilename |
| 2611 | 2788 | * @return kt_document_detail. status_code can be KTWS_ERR_INVALID_SESSION, KTWS_ERR_INVALID_FOLDER, KTWS_ERR_INVALID_DOCUMENT or KTWS_SUCCESS |
| 2612 | 2789 | */ |
| 2613 | - function checkin_document($document_id, $filename, $reason, $tempfilename, $major_update ) | |
| 2790 | + public function checkin_document($document_id, $filename, $reason, $tempfilename, $major_update ) | |
| 2614 | 2791 | { |
| 2615 | 2792 | // we need to add some security to ensure that people don't frig the checkin process to access restricted files. |
| 2616 | 2793 | // possibly should change 'tempfilename' to be a hash or id of some sort if this is troublesome. |
| ... | ... | @@ -2643,7 +2820,7 @@ class KTAPI |
| 2643 | 2820 | return $this->get_document_detail($document_id); |
| 2644 | 2821 | } |
| 2645 | 2822 | |
| 2646 | - function checkin_small_document_with_metadata($document_id, $filename, $reason, $base64, $major_update, $metadata, $sysdata) | |
| 2823 | + public function checkin_small_document_with_metadata($document_id, $filename, $reason, $base64, $major_update, $metadata, $sysdata) | |
| 2647 | 2824 | { |
| 2648 | 2825 | $add_result = $this->checkin_small_document($document_id, $filename, $reason, $base64, $major_update); |
| 2649 | 2826 | |
| ... | ... | @@ -2672,7 +2849,7 @@ class KTAPI |
| 2672 | 2849 | return $update_result; |
| 2673 | 2850 | } |
| 2674 | 2851 | |
| 2675 | - function checkin_document_with_metadata($document_id, $filename, $reason, $tempfilename, $major_update, $metadata, $sysdata) | |
| 2852 | + public function checkin_document_with_metadata($document_id, $filename, $reason, $tempfilename, $major_update, $metadata, $sysdata) | |
| 2676 | 2853 | { |
| 2677 | 2854 | $add_result = $this->checkin_document($document_id, $filename, $reason, $tempfilename, $major_update); |
| 2678 | 2855 | |
| ... | ... | @@ -2704,6 +2881,8 @@ class KTAPI |
| 2704 | 2881 | /** |
| 2705 | 2882 | * Does a document checkin. |
| 2706 | 2883 | * |
| 2884 | + * @author KnowledgeTree Team | |
| 2885 | + * @access public | |
| 2707 | 2886 | * @param int $document_id |
| 2708 | 2887 | * @param string $filename |
| 2709 | 2888 | * @param string $reason |
| ... | ... | @@ -2711,7 +2890,7 @@ class KTAPI |
| 2711 | 2890 | * @param boolean $major_update |
| 2712 | 2891 | * @return kt_document_detail. |
| 2713 | 2892 | */ |
| 2714 | - function checkin_small_document($document_id, $filename, $reason, $base64, $major_update ) | |
| 2893 | + public function checkin_small_document($document_id, $filename, $reason, $base64, $major_update ) | |
| 2715 | 2894 | { |
| 2716 | 2895 | $upload_manager = new KTUploadManager(); |
| 2717 | 2896 | $tempfilename = $upload_manager->store_base64_file($base64, 'su_'); |
| ... | ... | @@ -2748,11 +2927,13 @@ class KTAPI |
| 2748 | 2927 | /** |
| 2749 | 2928 | * Does a document checkout. |
| 2750 | 2929 | * |
| 2930 | + * @author KnowledgeTree Team | |
| 2931 | + * @access public | |
| 2751 | 2932 | * @param int $document_id |
| 2752 | 2933 | * @param string $reason |
| 2753 | 2934 | * @return kt_document_detail. |
| 2754 | 2935 | */ |
| 2755 | - function checkout_document($document_id, $reason, $download=true) | |
| 2936 | + public function checkout_document($document_id, $reason, $download=true) | |
| 2756 | 2937 | { |
| 2757 | 2938 | $document = &$this->get_document_by_id($document_id); |
| 2758 | 2939 | if (PEAR::isError($document)) |
| ... | ... | @@ -2800,12 +2981,14 @@ class KTAPI |
| 2800 | 2981 | /** |
| 2801 | 2982 | * Does a document checkout. |
| 2802 | 2983 | * |
| 2984 | + * @author KnowledgeTree Team | |
| 2985 | + * @access public | |
| 2803 | 2986 | * @param int $document_id |
| 2804 | 2987 | * @param string $reason |
| 2805 | 2988 | * @param boolean $download |
| 2806 | 2989 | * @return kt_document_detail |
| 2807 | 2990 | */ |
| 2808 | - function checkout_small_document($document_id, $reason, $download) | |
| 2991 | + public function checkout_small_document($document_id, $reason, $download) | |
| 2809 | 2992 | { |
| 2810 | 2993 | $document = &$this->get_document_by_id($document_id); |
| 2811 | 2994 | if (PEAR::isError($document)) |
| ... | ... | @@ -2859,11 +3042,13 @@ class KTAPI |
| 2859 | 3042 | /** |
| 2860 | 3043 | * Undoes a document checkout. |
| 2861 | 3044 | * |
| 3045 | + * @author KnowledgeTree Team | |
| 3046 | + * @access public | |
| 2862 | 3047 | * @param int $document_id |
| 2863 | 3048 | * @param string $reason |
| 2864 | 3049 | * @return kt_document_detail. |
| 2865 | 3050 | */ |
| 2866 | - function undo_document_checkout($document_id, $reason) | |
| 3051 | + public function undo_document_checkout($document_id, $reason) | |
| 2867 | 3052 | { |
| 2868 | 3053 | $document = &$this->get_document_by_id($document_id); |
| 2869 | 3054 | if (PEAR::isError($document)) |
| ... | ... | @@ -2893,10 +3078,12 @@ class KTAPI |
| 2893 | 3078 | /** |
| 2894 | 3079 | * Returns a reference to a file to be downloaded. |
| 2895 | 3080 | * |
| 3081 | + * @author KnowledgeTree Team | |
| 3082 | + * @access public | |
| 2896 | 3083 | * @param int $document_id |
| 2897 | 3084 | * @return kt_response. |
| 2898 | 3085 | */ |
| 2899 | - function download_document($document_id, $version=null) | |
| 3086 | + public function download_document($document_id, $version=null) | |
| 2900 | 3087 | { |
| 2901 | 3088 | $document = &$this->get_document_by_id($document_id); |
| 2902 | 3089 | if (PEAR::isError($document)) |
| ... | ... | @@ -2929,10 +3116,12 @@ class KTAPI |
| 2929 | 3116 | /** |
| 2930 | 3117 | * Returns a reference to a file to be downloaded. |
| 2931 | 3118 | * |
| 3119 | + * @author KnowledgeTree Team | |
| 3120 | + * @access public | |
| 2932 | 3121 | * @param int $document_id |
| 2933 | 3122 | * @return kt_response. |
| 2934 | 3123 | */ |
| 2935 | - function download_small_document($document_id, $version=null) | |
| 3124 | + public function download_small_document($document_id, $version=null) | |
| 2936 | 3125 | { |
| 2937 | 3126 | $document = &$this->get_document_by_id($document_id); |
| 2938 | 3127 | if (PEAR::isError($document)) |
| ... | ... | @@ -2978,11 +3167,13 @@ class KTAPI |
| 2978 | 3167 | /** |
| 2979 | 3168 | * Deletes a document. |
| 2980 | 3169 | * |
| 3170 | + * @author KnowledgeTree Team | |
| 3171 | + * @access public | |
| 2981 | 3172 | * @param int $document_id |
| 2982 | 3173 | * @param string $reason |
| 2983 | 3174 | * @return kt_response |
| 2984 | 3175 | */ |
| 2985 | - function delete_document($document_id, $reason) | |
| 3176 | + public function delete_document($document_id, $reason) | |
| 2986 | 3177 | { |
| 2987 | 3178 | $document = &$this->get_document_by_id($document_id); |
| 2988 | 3179 | if (PEAR::isError($document)) |
| ... | ... | @@ -3008,11 +3199,13 @@ class KTAPI |
| 3008 | 3199 | /** |
| 3009 | 3200 | * Change the document type. |
| 3010 | 3201 | * |
| 3202 | + * @author KnowledgeTree Team | |
| 3203 | + * @access public | |
| 3011 | 3204 | * @param int $document_id |
| 3012 | 3205 | * @param string $documenttype |
| 3013 | 3206 | * @return array |
| 3014 | 3207 | */ |
| 3015 | - function change_document_type($document_id, $documenttype) | |
| 3208 | + public function change_document_type($document_id, $documenttype) | |
| 3016 | 3209 | { |
| 3017 | 3210 | $document = &$this->get_document_by_id($document_id); |
| 3018 | 3211 | if (PEAR::isError($document)) |
| ... | ... | @@ -3037,6 +3230,8 @@ class KTAPI |
| 3037 | 3230 | /** |
| 3038 | 3231 | * Copy a document to another folder. |
| 3039 | 3232 | * |
| 3233 | + * @author KnowledgeTree Team | |
| 3234 | + * @access public | |
| 3040 | 3235 | * @param int $document_id |
| 3041 | 3236 | * @param int $folder_id |
| 3042 | 3237 | * @param string $reason |
| ... | ... | @@ -3044,7 +3239,7 @@ class KTAPI |
| 3044 | 3239 | * @param string $newfilename |
| 3045 | 3240 | * @return array |
| 3046 | 3241 | */ |
| 3047 | - function copy_document($document_id,$folder_id,$reason,$newtitle=null,$newfilename=null) | |
| 3242 | + public function copy_document($document_id,$folder_id,$reason,$newtitle=null,$newfilename=null) | |
| 3048 | 3243 | { |
| 3049 | 3244 | $document = &$this->get_document_by_id($document_id); |
| 3050 | 3245 | if (PEAR::isError($document)) |
| ... | ... | @@ -3078,6 +3273,8 @@ class KTAPI |
| 3078 | 3273 | /** |
| 3079 | 3274 | * Move a folder to another location. |
| 3080 | 3275 | * |
| 3276 | + * @author KnowledgeTree Team | |
| 3277 | + * @access public | |
| 3081 | 3278 | * @param int $document_id |
| 3082 | 3279 | * @param int $folder_id |
| 3083 | 3280 | * @param string $reason |
| ... | ... | @@ -3085,7 +3282,7 @@ class KTAPI |
| 3085 | 3282 | * @param string $newfilename |
| 3086 | 3283 | * @return array |
| 3087 | 3284 | */ |
| 3088 | - function move_document($document_id,$folder_id,$reason,$newtitle=null,$newfilename=null) | |
| 3285 | + public function move_document($document_id,$folder_id,$reason,$newtitle=null,$newfilename=null) | |
| 3089 | 3286 | { |
| 3090 | 3287 | $document = &$this->get_document_by_id($document_id); |
| 3091 | 3288 | if (PEAR::isError($document)) |
| ... | ... | @@ -3125,11 +3322,13 @@ class KTAPI |
| 3125 | 3322 | /** |
| 3126 | 3323 | * Changes the document title. |
| 3127 | 3324 | * |
| 3325 | + * @author KnowledgeTree Team | |
| 3326 | + * @access public | |
| 3128 | 3327 | * @param int $document_id |
| 3129 | 3328 | * @param string $newtitle |
| 3130 | 3329 | * @return arry |
| 3131 | 3330 | */ |
| 3132 | - function rename_document_title($document_id,$newtitle) | |
| 3331 | + public function rename_document_title($document_id,$newtitle) | |
| 3133 | 3332 | { |
| 3134 | 3333 | $document = &$this->get_document_by_id($document_id); |
| 3135 | 3334 | if (PEAR::isError($document)) |
| ... | ... | @@ -3155,11 +3354,13 @@ class KTAPI |
| 3155 | 3354 | /** |
| 3156 | 3355 | * Renames the document filename. |
| 3157 | 3356 | * |
| 3357 | + * @author KnowledgeTree Team | |
| 3358 | + * @access public | |
| 3158 | 3359 | * @param int $document_id |
| 3159 | 3360 | * @param string $newfilename |
| 3160 | 3361 | * @return array |
| 3161 | 3362 | */ |
| 3162 | - function rename_document_filename($document_id,$newfilename) | |
| 3363 | + public function rename_document_filename($document_id,$newfilename) | |
| 3163 | 3364 | { |
| 3164 | 3365 | $document = &$this->get_document_by_id($document_id); |
| 3165 | 3366 | if (PEAR::isError($document)) |
| ... | ... | @@ -3184,12 +3385,14 @@ class KTAPI |
| 3184 | 3385 | /** |
| 3185 | 3386 | * Changes the owner of a document. |
| 3186 | 3387 | * |
| 3388 | + * @author KnowledgeTree Team | |
| 3389 | + * @access public | |
| 3187 | 3390 | * @param int $document_id |
| 3188 | 3391 | * @param string $username |
| 3189 | 3392 | * @param string $reason |
| 3190 | 3393 | * @return array |
| 3191 | 3394 | */ |
| 3192 | - function change_document_owner($document_id, $username, $reason) | |
| 3395 | + public function change_document_owner($document_id, $username, $reason) | |
| 3193 | 3396 | { |
| 3194 | 3397 | $document = &$this->get_document_by_id($document_id); |
| 3195 | 3398 | if (PEAR::isError($document)) |
| ... | ... | @@ -3216,11 +3419,13 @@ class KTAPI |
| 3216 | 3419 | /** |
| 3217 | 3420 | * Start a workflow on a document |
| 3218 | 3421 | * |
| 3422 | + * @author KnowledgeTree Team | |
| 3423 | + * @access public | |
| 3219 | 3424 | * @param int $document_id |
| 3220 | 3425 | * @param string $workflow |
| 3221 | 3426 | * @return array |
| 3222 | 3427 | */ |
| 3223 | - function start_document_workflow($document_id,$workflow) | |
| 3428 | + public function start_document_workflow($document_id,$workflow) | |
| 3224 | 3429 | { |
| 3225 | 3430 | $document = &$this->get_document_by_id($document_id); |
| 3226 | 3431 | if (PEAR::isError($document)) |
| ... | ... | @@ -3245,10 +3450,12 @@ class KTAPI |
| 3245 | 3450 | /** |
| 3246 | 3451 | * Removes the workflow process on a document. |
| 3247 | 3452 | * |
| 3453 | + * @author KnowledgeTree Team | |
| 3454 | + * @access public | |
| 3248 | 3455 | * @param int $document_id |
| 3249 | 3456 | * @return array |
| 3250 | 3457 | */ |
| 3251 | - function delete_document_workflow($document_id) | |
| 3458 | + public function delete_document_workflow($document_id) | |
| 3252 | 3459 | { |
| 3253 | 3460 | $document = &$this->get_document_by_id($document_id); |
| 3254 | 3461 | if (PEAR::isError($document)) |
| ... | ... | @@ -3273,12 +3480,14 @@ class KTAPI |
| 3273 | 3480 | /** |
| 3274 | 3481 | * Starts a transitions on a document with a workflow. |
| 3275 | 3482 | * |
| 3483 | + * @author KnowledgeTree Team | |
| 3484 | + * @access public | |
| 3276 | 3485 | * @param int $document_id |
| 3277 | 3486 | * @param string $transition |
| 3278 | 3487 | * @param string $reason |
| 3279 | 3488 | * @return array |
| 3280 | 3489 | */ |
| 3281 | - function perform_document_workflow_transition($document_id,$transition,$reason) | |
| 3490 | + public function perform_document_workflow_transition($document_id,$transition,$reason) | |
| 3282 | 3491 | { |
| 3283 | 3492 | $document = &$this->get_document_by_id($document_id); |
| 3284 | 3493 | if (PEAR::isError($document)) |
| ... | ... | @@ -3305,10 +3514,12 @@ class KTAPI |
| 3305 | 3514 | /** |
| 3306 | 3515 | * Returns the metadata on a document. |
| 3307 | 3516 | * |
| 3517 | + * @author KnowledgeTree Team | |
| 3518 | + * @access public | |
| 3308 | 3519 | * @param int $document_id |
| 3309 | 3520 | * @return array |
| 3310 | 3521 | */ |
| 3311 | - function get_document_metadata($document_id) | |
| 3522 | + public function get_document_metadata($document_id) | |
| 3312 | 3523 | { |
| 3313 | 3524 | $document = &$this->get_document_by_id($document_id); |
| 3314 | 3525 | if (PEAR::isError($document)) |
| ... | ... | @@ -3350,11 +3561,13 @@ class KTAPI |
| 3350 | 3561 | /** |
| 3351 | 3562 | * Updates document metadata. |
| 3352 | 3563 | * |
| 3564 | + * @author KnowledgeTree Team | |
| 3565 | + * @access public | |
| 3353 | 3566 | * @param int $document_id |
| 3354 | 3567 | * @param array $metadata |
| 3355 | 3568 | * @return array |
| 3356 | 3569 | */ |
| 3357 | - function update_document_metadata($document_id,$metadata, $sysdata=null) | |
| 3570 | + public function update_document_metadata($document_id,$metadata, $sysdata=null) | |
| 3358 | 3571 | { |
| 3359 | 3572 | |
| 3360 | 3573 | $document = &$this->get_document_by_id($document_id); |
| ... | ... | @@ -3389,10 +3602,12 @@ class KTAPI |
| 3389 | 3602 | /** |
| 3390 | 3603 | * Returns a list of available transitions on a give document with a workflow. |
| 3391 | 3604 | * |
| 3605 | + * @author KnowledgeTree Team | |
| 3606 | + * @access public | |
| 3392 | 3607 | * @param int $document_id |
| 3393 | 3608 | * @return array |
| 3394 | 3609 | */ |
| 3395 | - function get_document_workflow_transitions($document_id) | |
| 3610 | + public function get_document_workflow_transitions($document_id) | |
| 3396 | 3611 | { |
| 3397 | 3612 | |
| 3398 | 3613 | $document = &$this->get_document_by_id($document_id); |
| ... | ... | @@ -3419,10 +3634,12 @@ class KTAPI |
| 3419 | 3634 | /** |
| 3420 | 3635 | * Returns the current state that the document is in. |
| 3421 | 3636 | * |
| 3637 | + * @author KnowledgeTree Team | |
| 3638 | + * @access public | |
| 3422 | 3639 | * @param int $document_id |
| 3423 | 3640 | * @return array |
| 3424 | 3641 | */ |
| 3425 | - function get_document_workflow_state($document_id) | |
| 3642 | + public function get_document_workflow_state($document_id) | |
| 3426 | 3643 | { |
| 3427 | 3644 | $document = &$this->get_document_by_id($document_id); |
| 3428 | 3645 | if (PEAR::isError($document)) |
| ... | ... | @@ -3448,10 +3665,12 @@ class KTAPI |
| 3448 | 3665 | /** |
| 3449 | 3666 | * Returns the document transaction history. |
| 3450 | 3667 | * |
| 3668 | + * @author KnowledgeTree Team | |
| 3669 | + * @access public | |
| 3451 | 3670 | * @param int $document_id |
| 3452 | 3671 | * @return array |
| 3453 | 3672 | */ |
| 3454 | - function get_document_transaction_history($document_id) | |
| 3673 | + public function get_document_transaction_history($document_id) | |
| 3455 | 3674 | { |
| 3456 | 3675 | |
| 3457 | 3676 | $document = &$this->get_document_by_id($document_id); |
| ... | ... | @@ -3478,10 +3697,12 @@ class KTAPI |
| 3478 | 3697 | /** |
| 3479 | 3698 | * Returns the folder transaction history. |
| 3480 | 3699 | * |
| 3700 | + * @author KnowledgeTree Team | |
| 3701 | + * @access public | |
| 3481 | 3702 | * @param int $folder_id |
| 3482 | 3703 | * @return array |
| 3483 | 3704 | */ |
| 3484 | - function get_folder_transaction_history($folder_id) | |
| 3705 | + public function get_folder_transaction_history($folder_id) | |
| 3485 | 3706 | { |
| 3486 | 3707 | |
| 3487 | 3708 | $folder = &$this->get_folder_by_id($folder_id); |
| ... | ... | @@ -3508,10 +3729,12 @@ class KTAPI |
| 3508 | 3729 | /** |
| 3509 | 3730 | * Returns the version history. |
| 3510 | 3731 | * |
| 3732 | + * @author KnowledgeTree Team | |
| 3733 | + * @access public | |
| 3511 | 3734 | * @param int $document_id |
| 3512 | 3735 | * @return kt_document_version_history_response |
| 3513 | 3736 | */ |
| 3514 | - function get_document_version_history($document_id) | |
| 3737 | + public function get_document_version_history($document_id) | |
| 3515 | 3738 | { |
| 3516 | 3739 | $document = &$this->get_document_by_id($document_id); |
| 3517 | 3740 | if (PEAR::isError($document)) |
| ... | ... | @@ -3537,13 +3760,15 @@ class KTAPI |
| 3537 | 3760 | /** |
| 3538 | 3761 | * Returns a list of linked documents |
| 3539 | 3762 | * |
| 3763 | + * @author KnowledgeTree Team | |
| 3764 | + * @access public | |
| 3540 | 3765 | * @param string $session_id |
| 3541 | 3766 | * @param int $document_id |
| 3542 | 3767 | * @return array |
| 3543 | 3768 | * |
| 3544 | 3769 | * |
| 3545 | 3770 | */ |
| 3546 | - function get_document_links($document_id) | |
| 3771 | + public function get_document_links($document_id) | |
| 3547 | 3772 | { |
| 3548 | 3773 | $response['status_code'] = 1; |
| 3549 | 3774 | $response['message'] = ''; |
| ... | ... | @@ -3569,11 +3794,13 @@ class KTAPI |
| 3569 | 3794 | /** |
| 3570 | 3795 | * Removes a link between documents |
| 3571 | 3796 | * |
| 3797 | + * @author KnowledgeTree Team | |
| 3798 | + * @access public | |
| 3572 | 3799 | * @param int $parent_document_id |
| 3573 | 3800 | * @param int $child_document_id |
| 3574 | 3801 | * @return kt_response |
| 3575 | 3802 | */ |
| 3576 | - function unlink_documents($parent_document_id, $child_document_id) | |
| 3803 | + public function unlink_documents($parent_document_id, $child_document_id) | |
| 3577 | 3804 | { |
| 3578 | 3805 | $document = &$this->get_document_by_id($parent_document_id); |
| 3579 | 3806 | if (PEAR::isError($document)) |
| ... | ... | @@ -3606,12 +3833,14 @@ class KTAPI |
| 3606 | 3833 | /** |
| 3607 | 3834 | * Creates a link between documents |
| 3608 | 3835 | * |
| 3836 | + * @author KnowledgeTree Team | |
| 3837 | + * @access public | |
| 3609 | 3838 | * @param int $parent_document_id |
| 3610 | 3839 | * @param int $child_document_id |
| 3611 | 3840 | * @param string $type |
| 3612 | 3841 | * @return boolean |
| 3613 | 3842 | */ |
| 3614 | - function link_documents($parent_document_id, $child_document_id, $type) | |
| 3843 | + public function link_documents($parent_document_id, $child_document_id, $type) | |
| 3615 | 3844 | { |
| 3616 | 3845 | |
| 3617 | 3846 | $document = &$this->get_document_by_id($parent_document_id); |
| ... | ... | @@ -3645,9 +3874,11 @@ class KTAPI |
| 3645 | 3874 | /** |
| 3646 | 3875 | * Retrieves the server policies for this server |
| 3647 | 3876 | * |
| 3648 | - * @return array | |
| 3877 | + * @author KnowledgeTree Team | |
| 3878 | + * @access public | |
| 3879 | + * @return array $response The formatted response array | |
| 3649 | 3880 | */ |
| 3650 | - function get_client_policies($client=null) | |
| 3881 | + public function get_client_policies($client=null) | |
| 3651 | 3882 | { |
| 3652 | 3883 | $config = KTConfig::getSingleton(); |
| 3653 | 3884 | |
| ... | ... | @@ -3710,11 +3941,13 @@ class KTAPI |
| 3710 | 3941 | /** |
| 3711 | 3942 | * This is the search interface |
| 3712 | 3943 | * |
| 3944 | + * @author KnowledgeTree Team | |
| 3945 | + * @access public | |
| 3713 | 3946 | * @param string $query |
| 3714 | 3947 | * @param string $options |
| 3715 | - * @return kt_search_response | |
| 3948 | + * @return array $response The formatted response array | |
| 3716 | 3949 | */ |
| 3717 | - function search($query, $options) | |
| 3950 | + public function search($query, $options) | |
| 3718 | 3951 | { |
| 3719 | 3952 | $response['status_code'] = 1; |
| 3720 | 3953 | $response['results'] = array(); | ... | ... |
tests/api/testDocument.php
| ... | ... | @@ -60,6 +60,45 @@ class APIDocumentTestCase extends KTUnitTestCase { |
| 60 | 60 | $this->session->logout(); |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | + /* *** KTAPI functions *** */ | |
| 64 | + | |
| 65 | + function testGetRoleAllocation() | |
| 66 | + { | |
| 67 | + $randomFile = APIDocumentHelper::createRandomFile(); | |
| 68 | + $this->assertTrue(is_file($randomFile)); | |
| 69 | + | |
| 70 | + $document = $this->root->add_document('testtitle', 'testname.txt', 'Default', $randomFile); | |
| 71 | + @unlink($randomFile); | |
| 72 | + $this->assertNotError($document); | |
| 73 | + if(PEAR::isError($document)) return; | |
| 74 | + | |
| 75 | + $response = $this->ktapi->get_role_allocation_for_document($document->get_documentid()); | |
| 76 | + $this->assertEqual($response['status_code'], 0); | |
| 77 | + | |
| 78 | + $document->delete('Testing'); | |
| 79 | + $document->expunge(); | |
| 80 | + } | |
| 81 | + | |
| 82 | + function testEmailDocument() | |
| 83 | + { | |
| 84 | + $randomFile = APIDocumentHelper::createRandomFile(); | |
| 85 | + $this->assertTrue(is_file($randomFile)); | |
| 86 | + | |
| 87 | + $document = $this->root->add_document('testtitle', 'testname.txt', 'Default', $randomFile); | |
| 88 | + @unlink($randomFile); | |
| 89 | + $this->assertNotError($document); | |
| 90 | + if(PEAR::isError($document)) return; | |
| 91 | + | |
| 92 | + $members = array('users' => array(1)); | |
| 93 | + $response = $this->ktapi->email_document($document->get_documentid(), $members, 'Test Email', false); | |
| 94 | + $this->assertEqual($response['status_code'], 0); | |
| 95 | + | |
| 96 | + $document->delete('Testing'); | |
| 97 | + $document->expunge(); | |
| 98 | + } | |
| 99 | + | |
| 100 | + /* *** Class functions *** */ | |
| 101 | + | |
| 63 | 102 | /** |
| 64 | 103 | * Tests the add and delete document functionality |
| 65 | 104 | */ | ... | ... |