main_api.lib.test_standalone.php 23 KB

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