main_api.lib.test_standalone.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537
  1. <?php //$id:$
  2. /**
  3. * A simple set of tests for the main API.
  4. * @author Ivan Tcholakov, 2009.
  5. * For licensing terms, see /dokeos_license.txt
  6. */
  7. class TestMainApi extends UnitTestCase {
  8. function TestMainApi() {
  9. $this->UnitTestCase('Main API tests');
  10. }
  11. public function testApiGetPath() {
  12. $common_paths = array(
  13. WEB_PATH,
  14. SYS_PATH,
  15. REL_PATH,
  16. WEB_SERVER_ROOT_PATH,
  17. SYS_SERVER_ROOT_PATH,
  18. WEB_COURSE_PATH,
  19. SYS_COURSE_PATH,
  20. REL_COURSE_PATH,
  21. REL_CODE_PATH,
  22. WEB_CODE_PATH,
  23. SYS_CODE_PATH,
  24. SYS_LANG_PATH,
  25. WEB_IMG_PATH,
  26. WEB_CSS_PATH,
  27. SYS_PLUGIN_PATH,
  28. WEB_PLUGIN_PATH,
  29. SYS_ARCHIVE_PATH,
  30. WEB_ARCHIVE_PATH,
  31. INCLUDE_PATH,
  32. LIBRARY_PATH,
  33. CONFIGURATION_PATH,
  34. WEB_LIBRARY_PATH
  35. );
  36. $specific_paths = array(
  37. FLASH_PLAYER_AUDIO,
  38. FLASH_PLAYER_VIDEO,
  39. SCRIPT_SWFOBJECT,
  40. SCRIPT_ASCIIMATHML
  41. );
  42. $res = array();
  43. $is_ok = array();
  44. $message = array();
  45. $paths = array();
  46. $message[] = '';
  47. $message[] = '<strong>A test about api_get_path()</strong>';
  48. $message[] = '---------------------------------------------------------------------------------------------------------------';
  49. $message[] = '';
  50. $message[] = '';
  51. $message[] = 'Changed behaviour of the function api_get_path() after Dokeos 1.8.6.1, i.e. as of Dokeos 1.8.6.2.';
  52. $message[] = '---------------------------------------------------------------------------------------------------------------';
  53. $message[] = '';
  54. $message[] = 'Old behaviour (1.8.6.1) api_get_path(INCLUDE_PATH) = '.api_get_path_1_8_6_1(INCLUDE_PATH).'&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;'.'New behaviour (1.8.6.2) api_get_path(INCLUDE_PATH) = '.api_get_path(INCLUDE_PATH);
  55. $message[] = '* Reason for this change: Difference here is due to the fact that the etalonic old function api_get_path() has ben moved in this file ( see api_get_path_1_8_6_1() ). Even for such rare, hypothetical cases, this widely used function should be stable. Now, after installation, the function returns results based on configuration settings only, as it should be.';
  56. $message[] = '';
  57. $message[] = 'Old behaviour (1.8.6.1) api_get_path(WEB_CSS_PATH) = '.api_get_path_1_8_6_1(WEB_CSS_PATH).'&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;'.'New behaviour (1.8.6.2) api_get_path(WEB_CSS_PATH) = '.api_get_path(WEB_CSS_PATH);
  58. $message[] = '* This is a proposed implementation. Retrieving css paths through user\'s configuration options has not been implemented yet.';
  59. $message[] = '';
  60. $message[] = '';
  61. $message[] = 'Reading common purpose paths';
  62. $message[] = '---------------------------------------------------------------------------------------------------------------';
  63. $message[] = '';
  64. foreach ($common_paths as $path) {
  65. $test_case = "api_get_path($path)";
  66. $res[$test_case] = api_get_path($path);
  67. switch ($path) {
  68. case INCLUDE_PATH:
  69. case WEB_CSS_PATH:
  70. $is_ok[$test_case] = is_string($res[$test_case]) && !empty($res[$test_case]);
  71. break;
  72. default:
  73. $is_ok[$test_case] = is_string($res[$test_case]) && !empty($res[$test_case]) && $res[$test_case] == api_get_path_1_8_6_1($path);
  74. }
  75. $message[] = ($is_ok[$test_case] ? '<span style="color: green; font-weight: bold;">Ok</span>' : '<span style="color: red; font-weight: bold;">Failed</span>').' : '.$test_case.' => '.$res[$test_case];
  76. }
  77. $message[] = '';
  78. $message[] = '';
  79. $message[] = 'Reading specific purpose paths';
  80. $message[] = '---------------------------------------------------------------------------------------------------------------';
  81. $message[] = '';
  82. foreach ($specific_paths as $path) {
  83. $test_case = "api_get_path(TO_WEB, $path)";
  84. $test_case = str_replace(array('{', '}'), '', $test_case);
  85. $res[$test_case] = api_get_path(TO_WEB, $path);
  86. $is_ok[$test_case] = is_string($res[$test_case]) && !empty($res[$test_case]);
  87. $message[] = ($is_ok[$test_case] ? '<span style="color: green; font-weight: bold;">Ok</span>' : '<span style="color: red; font-weight: bold;">Failed</span>').' : '.$test_case.' => '.$res[$test_case];
  88. $paths[] = $path;
  89. $test_case = "api_get_path(TO_SYS, $path)";
  90. $test_case = str_replace(array('{', '}'), '', $test_case);
  91. $res[$test_case] = api_get_path(TO_SYS, $path);
  92. $is_ok[$test_case] = is_string($res[$test_case]) && !empty($res[$test_case]);
  93. $message[] = ($is_ok[$test_case] ? '<span style="color: green; font-weight: bold;">Ok</span>' : '<span style="color: red; font-weight: bold;">Failed</span>').' : '.$test_case.' => '.$res[$test_case];
  94. $paths[] = $path;
  95. $test_case = "api_get_path(TO_REL, $path)";
  96. $test_case = str_replace(array('{', '}'), '', $test_case);
  97. $res[$test_case] = api_get_path(TO_REL, $path);
  98. $is_ok[$test_case] = is_string($res[$test_case]) && !empty($res[$test_case]);
  99. $message[] = ($is_ok[$test_case] ? '<span style="color: green; font-weight: bold;">Ok</span>' : '<span style="color: red; font-weight: bold;">Failed</span>').' : '.$test_case.' => '.$res[$test_case];
  100. $paths[] = $path;
  101. }
  102. $message[] = '';
  103. $message[] = '';
  104. $message[] = 'Testing path conversions';
  105. $message[] = '---------------------------------------------------------------------------------------------------------------';
  106. $message[] = '';
  107. $paths = array();
  108. foreach ($common_paths as $path) {
  109. $paths[] = array($path, api_get_path($path));
  110. }
  111. foreach ($specific_paths as $path) {
  112. $paths[] = array($path, api_get_path(TO_WEB, $path));
  113. $paths[] = array($path, api_get_path(TO_SYS, $path));
  114. $paths[] = array($path, api_get_path(TO_REL, $path));
  115. }
  116. foreach ($paths as $path) {
  117. $test_case = 'api_get_path(TO_WEB, '.$path[0].')';
  118. $test_case = str_replace(array('{', '}'), '', $test_case);
  119. $res[$test_case] = api_get_path(TO_WEB, $path[0]);
  120. $test_case_1 = 'api_get_path(TO_WEB, \''.$path[1].'\')';
  121. $res[$test_case_1] = api_get_path(TO_WEB, $path[1]);
  122. $is_ok[$test_case] =
  123. is_string($res[$test_case]) && !empty($res[$test_case])
  124. && is_string($res[$test_case_1]) && !empty($res[$test_case_1])
  125. && $res[$test_case] == $res[$test_case_1];
  126. $message[] = ($is_ok[$test_case] ? '<span style="color: green; font-weight: bold;">Ok</span>' : '<span style="color: red; font-weight: bold;">Failed</span>').' : ';
  127. $message[] = $test_case.' => '.$res[$test_case];
  128. $message[] = $test_case_1.' => '.$res[$test_case_1];
  129. $message[] = '';
  130. $test_case = 'api_get_path(TO_SYS, '.$path[0].')';
  131. $test_case = str_replace(array('{', '}'), '', $test_case);
  132. $res[$test_case] = api_get_path(TO_SYS, $path[0]);
  133. $test_case_1 = 'api_get_path(TO_SYS, \''.$path[1].'\')';
  134. $res[$test_case_1] = api_get_path(TO_SYS, $path[1]);
  135. $is_ok[$test_case] =
  136. is_string($res[$test_case]) && !empty($res[$test_case])
  137. && is_string($res[$test_case_1]) && !empty($res[$test_case_1])
  138. && $res[$test_case] == $res[$test_case_1];
  139. $message[] = ($is_ok[$test_case] ? '<span style="color: green; font-weight: bold;">Ok</span>' : '<span style="color: red; font-weight: bold;">Failed</span>').' : ';
  140. $message[] = $test_case.' => '.$res[$test_case];
  141. $message[] = $test_case_1.' => '.$res[$test_case_1];
  142. $message[] = '';
  143. $test_case = 'api_get_path(TO_REL, '.$path[0].')';
  144. $test_case = str_replace(array('{', '}'), '', $test_case);
  145. $res[$test_case] = api_get_path(TO_REL, $path[0]);
  146. $test_case_1 = 'api_get_path(TO_REL, \''.$path[1].'\')';
  147. $res[$test_case_1] = api_get_path(TO_REL, $path[1]);
  148. $is_ok[$test_case] =
  149. is_string($res[$test_case]) && !empty($res[$test_case])
  150. && is_string($res[$test_case_1]) && !empty($res[$test_case_1])
  151. && $res[$test_case] == $res[$test_case_1];
  152. $message[] = ($is_ok[$test_case] ? '<span style="color: green; font-weight: bold;">Ok</span>' : '<span style="color: red; font-weight: bold;">Failed</span>').' : ';
  153. $message[] = $test_case.' => '.$res[$test_case];
  154. $message[] = $test_case_1.' => '.$res[$test_case_1];
  155. $message[] = '';
  156. }
  157. $message[] = '';
  158. $message[] = 'Random examples, check them visually';
  159. $message[] = '---------------------------------------------------------------------------------------------------------------';
  160. $message[] = '';
  161. $message[] = '$_SERVER[\'REQUEST_URI\'] => '.$_SERVER['REQUEST_URI'];
  162. $message[] = '<strong>Note:</strong> Try some query strings. They should be removed from the results.';
  163. $message[] = 'api_get_path(TO_WEB, $_SERVER[\'REQUEST_URI\']) => '.api_get_path(TO_WEB, $_SERVER['REQUEST_URI']);
  164. $message[] = 'api_get_path(TO_SYS, $_SERVER[\'REQUEST_URI\']) => '.api_get_path(TO_SYS, $_SERVER['REQUEST_URI']);
  165. $message[] = 'api_get_path(TO_REL, $_SERVER[\'REQUEST_URI\']) => '.api_get_path(TO_REL, $_SERVER['REQUEST_URI']);
  166. $message[] = '';
  167. $message[] = '__FILE__ => '.__FILE__;
  168. $message[] = 'api_get_path(TO_WEB, __FILE__) => '.api_get_path(TO_WEB, __FILE__);
  169. $message[] = 'api_get_path(TO_SYS, __FILE__) => '.api_get_path(TO_SYS, __FILE__);
  170. $message[] = 'api_get_path(TO_REL, __FILE__) => '.api_get_path(TO_REL, __FILE__);
  171. $message[] = '';
  172. $message[] = '$_SERVER[\'PHP_SELF\'] => '.$_SERVER['PHP_SELF'];
  173. $message[] = 'api_get_path(TO_WEB, $_SERVER[\'PHP_SELF\']) => '.api_get_path(TO_WEB, $_SERVER['PHP_SELF']);
  174. $message[] = 'api_get_path(TO_SYS, $_SERVER[\'PHP_SELF\']) => '.api_get_path(TO_SYS, $_SERVER['PHP_SELF']);
  175. $message[] = 'api_get_path(TO_REL, $_SERVER[\'PHP_SELF\']) => '.api_get_path(TO_REL, $_SERVER['PHP_SELF']);
  176. $message[] = '';
  177. $message[] = '';
  178. $message[] = '---------------------------------------------------------------------------------------------------------------';
  179. $message[] = 'This test and changes of behaviour of api_get_path() have been done by Ivan Tcholakov, September 22, 2009.';
  180. $message[] = '';
  181. $result = !in_array(false, $is_ok);
  182. $this->assertTrue($result);
  183. //var_dump($res);
  184. foreach ($message as $line) { echo $line.'<br />'; }
  185. // Sample code for showing results in different context.
  186. /*
  187. $common_paths = array(
  188. WEB_PATH,
  189. SYS_PATH,
  190. REL_PATH,
  191. WEB_SERVER_ROOT_PATH,
  192. SYS_SERVER_ROOT_PATH,
  193. WEB_COURSE_PATH,
  194. SYS_COURSE_PATH,
  195. REL_COURSE_PATH,
  196. REL_CODE_PATH,
  197. WEB_CODE_PATH,
  198. SYS_CODE_PATH,
  199. SYS_LANG_PATH,
  200. WEB_IMG_PATH,
  201. WEB_CSS_PATH,
  202. SYS_PLUGIN_PATH,
  203. WEB_PLUGIN_PATH,
  204. SYS_ARCHIVE_PATH,
  205. WEB_ARCHIVE_PATH,
  206. INCLUDE_PATH,
  207. LIBRARY_PATH,
  208. CONFIGURATION_PATH,
  209. WEB_LIBRARY_PATH
  210. );
  211. $specific_paths = array(
  212. FLASH_PLAYER_AUDIO,
  213. FLASH_PLAYER_VIDEO,
  214. SCRIPT_SWFOBJECT,
  215. SCRIPT_ASCIIMATHML
  216. );
  217. $res = array();
  218. $is_ok = array();
  219. $message = array();
  220. $paths = array();
  221. $message[] = '';
  222. $message[] = 'Reading common purpose paths';
  223. $message[] = '---------------------------------------------------------------------------------------------------------------';
  224. $message[] = '';
  225. foreach ($common_paths as $path) {
  226. $test_case = "api_get_path($path)";
  227. $res[$test_case] = api_get_path($path);
  228. $message[] = $test_case.' => '.$res[$test_case];
  229. }
  230. $message[] = '';
  231. $message[] = '';
  232. $message[] = 'Reading specific purpose paths';
  233. $message[] = '---------------------------------------------------------------------------------------------------------------';
  234. $message[] = '';
  235. foreach ($specific_paths as $path) {
  236. $test_case = "api_get_path(TO_WEB, $path)";
  237. $test_case = str_replace(array('{', '}'), '', $test_case);
  238. $res[$test_case] = api_get_path(TO_WEB, $path);
  239. $message[] = $test_case.' => '.$res[$test_case];
  240. $paths[] = $path;
  241. $test_case = "api_get_path(TO_SYS, $path)";
  242. $test_case = str_replace(array('{', '}'), '', $test_case);
  243. $res[$test_case] = api_get_path(TO_SYS, $path);
  244. $message[] = $test_case.' => '.$res[$test_case];
  245. $paths[] = $path;
  246. $test_case = "api_get_path(TO_REL, $path)";
  247. $test_case = str_replace(array('{', '}'), '', $test_case);
  248. $res[$test_case] = api_get_path(TO_REL, $path);
  249. $message[] = $test_case.' => '.$res[$test_case];
  250. $paths[] = $path;
  251. }
  252. foreach ($message as $line) { echo $line.'<br />'; }
  253. */
  254. }
  255. public function testApiIsInternalPath() {
  256. $path1 = api_get_path(WEB_IMG_PATH);
  257. $path2 = 'http://kdflskfsenfnmzsdn/fnefsdsmdsdmsdfsdcmxaddfdafada/index.html';
  258. $path3 = api_get_path(TO_SYS, WEB_IMG_PATH);
  259. $path4 = 'C:\Inetpub\wwwroot\fnefsdsmdsdmsdfsdcmxaddfdafada/index.html';
  260. $path5 = api_get_path(TO_REL, WEB_IMG_PATH);
  261. $path6 = '/fnefsdsmdsdmsdfsdcmxaddfdafada/index.html';
  262. $res1 = api_is_internal_path($path1);
  263. $res2 = api_is_internal_path($path2);
  264. $res3 = api_is_internal_path($path3);
  265. $res4 = api_is_internal_path($path4);
  266. $res5 = api_is_internal_path($path5);
  267. $res6 = api_is_internal_path($path6);
  268. $this->assertTrue(is_bool($res1) && is_bool($res2) && is_bool($res3) && is_bool($res4) && is_bool($res5) && is_bool($res6)
  269. && $res1 && !$res2 && $res3 && !$res4 && $res5 && !$res6);
  270. //var_dump($res1);
  271. //var_dump($res2);
  272. //var_dump($res1);
  273. //var_dump($res2);
  274. //var_dump($res1);
  275. //var_dump($res2);
  276. }
  277. public function testApiAddTrailingSlash() {
  278. $string1 = 'path';
  279. $string2 = 'path/';
  280. $res1 = api_add_trailing_slash($string1);
  281. $res2 = api_add_trailing_slash($string2);
  282. $this->assertTrue(is_string($res1) && is_string($res2) && $res1 == $res2);
  283. //var_dump($res1);
  284. //var_dump($res2);
  285. }
  286. public function testRemoveAddTrailingSlash() {
  287. $string1 = 'path';
  288. $string2 = 'path/';
  289. $res1 = api_remove_trailing_slash($string1);
  290. $res2 = api_remove_trailing_slash($string2);
  291. $this->assertTrue(is_string($res1) && is_string($res2) && $res1 == $res2);
  292. //var_dump($res1);
  293. //var_dump($res2);
  294. }
  295. }
  296. /**
  297. * Returns a full path to a certain Dokeos area, which you specify
  298. * through a parameter.
  299. *
  300. * See $_configuration['course_folder'] in the configuration.php
  301. * to alter the WEB_COURSE_PATH and SYS_COURSE_PATH parameters.
  302. *
  303. * @param one of the following constants:
  304. * WEB_SERVER_ROOT_PATH, SYS_SERVER_ROOT_PATH,
  305. * WEB_PATH, SYS_PATH, REL_PATH, WEB_COURSE_PATH, SYS_COURSE_PATH,
  306. * REL_COURSE_PATH, REL_CODE_PATH, WEB_CODE_PATH, SYS_CODE_PATH,
  307. * SYS_LANG_PATH, WEB_IMG_PATH, GARBAGE_PATH, WEB_PLUGIN_PATH, SYS_PLUGIN_PATH, WEB_ARCHIVE_PATH, SYS_ARCHIVE_PATH,
  308. * INCLUDE_PATH, WEB_LIBRARY_PATH, LIBRARY_PATH, CONFIGURATION_PATH
  309. *
  310. * @example assume that your server root is /var/www/ dokeos is installed in a subfolder dokeos/ and the URL of your campus is http://www.mydokeos.com
  311. * The other configuration paramaters have not been changed.
  312. * The different api_get_paths will give
  313. * WEB_SERVER_ROOT_PATH http://www.mydokeos.com/
  314. * SYS_SERVER_ROOT_PATH /var/www/ - This is the physical folder where the system Dokeos has been placed. It is not always equal to $_SERVER['DOCUMENT_ROOT'].
  315. * WEB_PATH http://www.mydokeos.com/dokeos/
  316. * SYS_PATH /var/www/dokeos/
  317. * REL_PATH dokeos/
  318. * WEB_COURSE_PATH http://www.mydokeos.com/dokeos/courses/
  319. * SYS_COURSE_PATH /var/www/dokeos/courses/
  320. * REL_COURSE_PATH /dokeos/courses/
  321. * REL_CODE_PATH /dokeos/main/
  322. * WEB_CODE_PATH http://www.mydokeos.com/dokeos/main/
  323. * SYS_CODE_PATH /var/www/dokeos/main/
  324. * SYS_LANG_PATH /var/www/dokeos/main/lang/
  325. * WEB_IMG_PATH http://www.mydokeos.com/dokeos/main/img/
  326. * GARBAGE_PATH
  327. * WEB_PLUGIN_PATH http://www.mydokeos.com/dokeos/plugin/
  328. * SYS_PLUGIN_PATH /var/www/dokeos/plugin/
  329. * WEB_ARCHIVE_PATH http://www.mydokeos.com/dokeos/archive/
  330. * SYS_ARCHIVE_PATH /var/www/dokeos/archive/
  331. * INCLUDE_PATH /var/www/dokeos/main/inc/
  332. * WEB_LIBRARY_PATH http://www.mydokeos.com/dokeos/main/inc/lib/
  333. * LIBRARY_PATH /var/www/dokeos/main/inc/lib/
  334. * CONFIGURATION_PATH /var/www/dokeos/main/inc/conf/
  335. */
  336. function api_get_path_1_8_6_1($path_type) {
  337. global $_configuration;
  338. if (!isset($_configuration['access_url']) || $_configuration['access_url']==1 || $_configuration['access_url']=='') {
  339. //by default we call the $_configuration['root_web'] we don't query to the DB
  340. //$url_info= api_get_access_url(1);
  341. //$root_web = $url_info['url'];
  342. if(isset($_configuration['root_web']))
  343. $root_web = $_configuration['root_web'];
  344. } else {
  345. //we look into the DB the function api_get_access_url
  346. //this funcion have a problem because we can't called to the Database:: functions
  347. $url_info= api_get_access_url($_configuration['access_url']);
  348. if ($url_info['active']==1) {
  349. $root_web = $url_info['url'];
  350. } else {
  351. $root_web = $_configuration['root_web'];
  352. }
  353. }
  354. switch ($path_type) {
  355. case WEB_SERVER_ROOT_PATH:
  356. // example: http://www.mydokeos.com/
  357. $result = preg_replace('@'.api_get_path(REL_PATH).'$@', '', api_get_path(WEB_PATH));
  358. if (substr($result, -1) == '/') {
  359. return $result;
  360. } else {
  361. return $result.'/';
  362. }
  363. break;
  364. case SYS_SERVER_ROOT_PATH:
  365. $result = preg_replace('@'.api_get_path(REL_PATH).'$@', '', api_get_path(SYS_PATH));
  366. if (substr($result, -1) == '/') {
  367. return $result;
  368. } else {
  369. return $result.'/';
  370. }
  371. break;
  372. case WEB_PATH :
  373. // example: http://www.mydokeos.com/ or http://www.mydokeos.com/dokeos/ if you're using
  374. // a subdirectory of your document root for Dokeos
  375. if (substr($root_web,-1) == '/') {
  376. return $root_web;
  377. } else {
  378. return $root_web.'/';
  379. }
  380. break;
  381. case SYS_PATH :
  382. // example: /var/www/dokeos/
  383. if (substr($_configuration['root_sys'],-1) == '/') {
  384. return $_configuration['root_sys'];
  385. } else {
  386. return $_configuration['root_sys'].'/';
  387. }
  388. break;
  389. case REL_PATH :
  390. // example: dokeos/
  391. if (substr($_configuration['url_append'], -1) === '/') {
  392. return $_configuration['url_append'];
  393. } else {
  394. return $_configuration['url_append'].'/';
  395. }
  396. break;
  397. case WEB_COURSE_PATH :
  398. // example: http://www.mydokeos.com/courses/
  399. return $root_web.$_configuration['course_folder'];
  400. break;
  401. case SYS_COURSE_PATH :
  402. // example: /var/www/dokeos/courses/
  403. return $_configuration['root_sys'].$_configuration['course_folder'];
  404. break;
  405. case REL_COURSE_PATH :
  406. // example: courses/ or dokeos/courses/
  407. return api_get_path(REL_PATH).$_configuration['course_folder'];
  408. break;
  409. case REL_CODE_PATH :
  410. // example: main/ or dokeos/main/
  411. return api_get_path(REL_PATH).$_configuration['code_append'];
  412. break;
  413. case WEB_CODE_PATH :
  414. // example: http://www.mydokeos.com/main/
  415. //return $GLOBALS['clarolineRepositoryWeb']; // this was changed
  416. return $root_web.$_configuration['code_append'];
  417. break;
  418. case SYS_CODE_PATH :
  419. // example: /var/www/dokeos/main/
  420. return $GLOBALS['clarolineRepositorySys'];
  421. break;
  422. case SYS_LANG_PATH :
  423. // example: /var/www/dokeos/main/lang/
  424. return api_get_path(SYS_CODE_PATH).'lang/';
  425. break;
  426. case WEB_IMG_PATH :
  427. // example: http://www.mydokeos.com/main/img/
  428. return api_get_path(WEB_CODE_PATH).'img/';
  429. break;
  430. case SYS_PLUGIN_PATH :
  431. // example: /var/www/dokeos/plugin/
  432. return api_get_path(SYS_PATH).'plugin/';
  433. break;
  434. case WEB_PLUGIN_PATH :
  435. // example: http://www.mydokeos.com/plugin/
  436. return api_get_path(WEB_PATH).'plugin/';
  437. break;
  438. case GARBAGE_PATH : //now set to be same as archive
  439. case SYS_ARCHIVE_PATH :
  440. // example: /var/www/dokeos/archive/
  441. return api_get_path(SYS_PATH).'archive/';
  442. break;
  443. case WEB_ARCHIVE_PATH :
  444. // example: http://www.mydokeos.com/archive/
  445. return api_get_path(WEB_PATH).'archive/';
  446. break;
  447. case INCLUDE_PATH :
  448. // Generated by main/inc/global.inc.php
  449. // example: /var/www/dokeos/main/inc/
  450. $incpath = realpath(dirname(__FILE__).'/../');
  451. return str_replace('\\', '/', $incpath).'/';
  452. break;
  453. case LIBRARY_PATH :
  454. // example: /var/www/dokeos/main/inc/lib/
  455. return api_get_path(INCLUDE_PATH).'lib/';
  456. break;
  457. case WEB_LIBRARY_PATH :
  458. // example: http://www.mydokeos.com/main/inc/lib/
  459. return api_get_path(WEB_CODE_PATH).'inc/lib/';
  460. break;
  461. case CONFIGURATION_PATH :
  462. // example: /var/www/dokeos/main/inc/conf/
  463. return api_get_path(INCLUDE_PATH).'conf/';
  464. break;
  465. default :
  466. return;
  467. break;
  468. }
  469. }
  470. ?>