link.php 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Main script for the links tool.
  5. *
  6. * Features:
  7. * - Organize links into categories;
  8. * - favorites/bookmarks-like interface;
  9. * - move links up/down within a category;
  10. * - move categories up/down;
  11. * - expand/collapse all categories (except the main "non"-category);
  12. * - add link to 'root' category => category-less link is always visible.
  13. *
  14. * @author Patrick Cool, main author, completely rewritten
  15. * @author René Haentjens, added CSV file import (October 2004)
  16. * @package chamilo.link
  17. * @todo improve organisation, tables should come from database library, use formvalidator
  18. * @todo Needs serious rewriting here. This doesn't make sense
  19. */
  20. /* INIT SECTION */
  21. // Language files that need to be included
  22. $language_file = array('link', 'admin');
  23. // Including libraries
  24. require_once '../inc/global.inc.php';
  25. $current_course_tool = TOOL_LINK;
  26. require_once api_get_path(LIBRARY_PATH).'link.lib.php';
  27. $this_section = SECTION_COURSES;
  28. api_protect_course_script();
  29. $htmlHeadXtra[] = '<script type="text/javascript">
  30. $(document).ready( function() {
  31. for (i=0;i<$(".actions").length;i++) {
  32. if ($(".actions:eq("+i+")").html()=="<table border=\"0\"></table>" || $(".actions:eq("+i+")").html()=="" || $(".actions:eq("+i+")").html()==null) {
  33. $(".actions:eq("+i+")").hide();
  34. }
  35. }
  36. });
  37. function check_url(id, url) {
  38. var url = "'.api_get_path(WEB_AJAX_PATH).'link.ajax.php?a=check_url&url=" +url;
  39. var loading = " '.addslashes(Display::return_icon('loading1.gif')).'";
  40. $("#url_id_"+id).html(loading);
  41. $("#url_id_"+id).load(url);
  42. }
  43. </script>';
  44. // @todo change the $_REQUEST into $_POST or $_GET
  45. // @todo remove this code
  46. $link_submitted = isset($_POST['submitLink']);
  47. $category_submitted = isset($_POST['submitCategory']);
  48. $urlview = !empty($_GET['urlview']) ? $_GET['urlview'] : '';
  49. $submit_import = !empty($_POST['submitImport']) ? $_POST['submitImport'] : '';
  50. $down = !empty($_GET['down']) ? $_GET['down'] : '';
  51. $up = !empty($_GET['up']) ? $_GET['up'] : '';
  52. $catmove = !empty($_GET['catmove']) ? $_GET['catmove'] : '';
  53. $editlink = !empty($_REQUEST['editlink']) ? $_REQUEST['editlink'] : '';
  54. $id = !empty($_REQUEST['id']) ? $_REQUEST['id'] : '';
  55. $urllink = !empty($_REQUEST['urllink']) ? $_REQUEST['urllink'] : '';
  56. $title = !empty($_REQUEST['title']) ? $_REQUEST['title'] : '';
  57. $description = !empty($_REQUEST['description']) ? $_REQUEST['description'] : '';
  58. $selectcategory = !empty($_REQUEST['selectcategory']) ? $_REQUEST['selectcategory'] : '';
  59. $submit_link = isset($_REQUEST['submitLink']);
  60. $action = !empty($_REQUEST['action']) ? $_REQUEST['action'] : '';
  61. $category_title = !empty($_REQUEST['category_title']) ? $_REQUEST['category_title'] : '';
  62. $submit_category = isset($_POST['submitCategory']);
  63. $target_link = !empty($_REQUEST['target_link']) ? $_REQUEST['target_link'] : '_self';
  64. $nameTools = get_lang('Links');
  65. $course_id = api_get_course_int_id();
  66. // Condition for the session
  67. $session_id = api_get_session_id();
  68. $condition_session = api_get_session_condition($session_id, true, true);
  69. if (isset($_GET['action']) && $_GET['action'] == 'addlink') {
  70. $nameTools = '';
  71. $interbreadcrumb[] = array('url' => 'link.php', 'name' => get_lang('Links'));
  72. $interbreadcrumb[] = array('url' => '#', 'name' => get_lang('AddLink'));
  73. }
  74. if (isset($_GET['action']) && $_GET['action'] == 'addcategory') {
  75. $nameTools = '';
  76. $interbreadcrumb[] = array('url' => 'link.php', 'name' => get_lang('Links'));
  77. $interbreadcrumb[] = array('url' => '#', 'name' => get_lang('AddCategory'));
  78. }
  79. if (isset($_GET['action']) && $_GET['action'] == 'editlink') {
  80. $nameTools = '';
  81. $interbreadcrumb[] = array('url' => 'link.php', 'name' => get_lang('Links'));
  82. $interbreadcrumb[] = array('url' => '#', 'name' => get_lang('EditLink'));
  83. }
  84. // Database Table definitions
  85. $tbl_link = Database::get_course_table(TABLE_LINK);
  86. $tbl_categories = Database::get_course_table(TABLE_LINK_CATEGORY);
  87. // Statistics
  88. event_access_tool(TOOL_LINK);
  89. Display::display_header($nameTools, 'Links');
  90. ?>
  91. <script type="text/javascript">
  92. /* <![CDATA[ */
  93. function MM_popupMsg(msg) { //v1.0
  94. confirm(msg);
  95. }
  96. /* ]]> */
  97. </script>
  98. <?php
  99. /* Action Handling */
  100. $nameTools = get_lang('Links');
  101. if (isset($_GET['action'])) {
  102. $check_token = Security::check_token('request');
  103. if ($check_token) {
  104. switch ($_GET['action']) {
  105. case 'addlink':
  106. if ($link_submitted) {
  107. // Here we add a link
  108. if (!addlinkcategory("link")) {
  109. unset($submit_link);
  110. }
  111. }
  112. break;
  113. case 'addcategory':
  114. if ($category_submitted) {
  115. // Here we add a category
  116. if (!addlinkcategory('category')) {
  117. unset($submit_category);
  118. }
  119. }
  120. break;
  121. case 'importcsv':
  122. if ($_POST['submitImport']) {
  123. import_csvfile();
  124. }
  125. break;
  126. case 'deletelink':
  127. // Here we delete a link
  128. deletelinkcategory($_GET['id'], 'link');
  129. break;
  130. case 'deletecategory':
  131. // Here we delete a category
  132. deletelinkcategory($_GET['id'], 'category');
  133. break;
  134. case 'editlink':
  135. // Here we edit a link
  136. editlinkcategory('link');
  137. break;
  138. case 'editcategory':
  139. // Here we edit a category
  140. editlinkcategory('category');
  141. break;
  142. case 'visible':
  143. // Here we edit a category
  144. change_visibility_link($_GET['id'], $_GET['scope']);
  145. break;
  146. case 'invisible':
  147. // Here we edit a category
  148. change_visibility_link($_GET['id'], $_GET['scope']);
  149. break;
  150. }
  151. Security::clear_token();
  152. }
  153. }
  154. $token = Security::get_token();
  155. /* Introduction section */
  156. Display::display_introduction_section(TOOL_LINK);
  157. if (api_is_allowed_to_edit(null, true) && isset($_GET['action'])) {
  158. echo '<div class="actions">';
  159. if (!empty($_GET['lp_id']) || !empty($_POST['lp_id'])){
  160. if (!empty($_POST['lp_id'])){
  161. $lp_id = Security::remove_XSS($_POST['lp_id']);
  162. } else {
  163. $lp_id = Security::remove_XSS($_GET['lp_id']);
  164. }
  165. echo "<a href=\"../newscorm/lp_controller.php?".api_get_cidreq()."&gradebook=&action=add_item&type=step&lp_id=".$lp_id."#resource_tab-3\">".Display::return_icon('back.png', get_lang("BackTo").' '.get_lang("LearningPaths"),'',ICON_SIZE_MEDIUM)."</a>";
  166. } else {
  167. //echo '<a href="link.php?cidReq='.Security::remove_XSS($_GET['cidReq']).'&amp;urlview='.Security::remove_XSS($_GET['urlview']).'">'.Display::return_icon('back.png', get_lang('BackToLinksOverview'),'',ICON_SIZE_MEDIUM).'</a>';
  168. }
  169. echo '</div>';
  170. // Displaying the correct title and the form for adding a category or link. This is only shown when nothing
  171. // has been submitted yet, hence !isset($submit_link)
  172. if (($_GET['action'] == 'addlink' || $_GET['action'] == 'editlink') &&
  173. empty($_POST['submitLink'])
  174. ) {
  175. $category = 0;
  176. echo '<form class="form-horizontal" method="post" action="'.api_get_self().'?action='.Security::remove_XSS($_GET['action']).'&amp;urlview='.Security::remove_XSS($urlview).'">';
  177. if ($_GET['action'] == 'addlink') {
  178. echo '<legend>'.get_lang('LinkAdd').'</legend>';
  179. } else {
  180. echo '<legend>'.get_lang('LinkMod').'</legend>';
  181. }
  182. echo '<input type="hidden" name="sec_token" value="'.$token.'" />';
  183. $clean_link_id = null;
  184. $onhomepage = null;
  185. $lpId = isset($_GET['lp_id']) ? Security::remove_XSS($_GET['lp_id']) : null;
  186. if ($_GET['action'] == 'editlink') {
  187. $clean_link_id = intval($_GET['id']);
  188. $link_info = get_link_info($_GET['id']);
  189. if ($link_info) {
  190. $urllink = $link_info['url'];
  191. $title = $link_info['title'];
  192. $description = $link_info['description'];
  193. $category = $link_info['category_id'];
  194. $onhomepage = '';
  195. if ($link_info['on_homepage'] != 0) {
  196. $onhomepage = 'checked';
  197. }
  198. $target_link = $link_info['target'];
  199. }
  200. echo '<input type="hidden" name="id" value="'.$clean_link_id.'" />';
  201. } else {
  202. $target_link = "_blank";
  203. }
  204. echo ' <div class="control-group url">
  205. <label class="control-label">
  206. <span class="form_required">*</span> URL
  207. </label>
  208. <div class="controls">
  209. <input type="text" name="urllink" class="span6" value="' . (empty($urllink) ? 'http://' : Security::remove_XSS($urllink)) . '" />
  210. </div>
  211. </div>';
  212. echo ' <div class="control-group title">
  213. <label class="control-label">
  214. '.get_lang('LinkName').'
  215. </label>
  216. <div class="controls">
  217. <input type="text" name="title" class="span6" value="' . Security::remove_XSS($title) . '" />
  218. </div>
  219. </div>';
  220. echo ' <div class="control-group metadata">
  221. <label class="control-label">
  222. '.get_lang('Metadata').'
  223. </label>
  224. <div class="controls">
  225. <a href="../metadata/index.php?eid='.urlencode('Link.'.$clean_link_id).'">'.get_lang('AddMetadata').'</a>
  226. </div>
  227. </div>';
  228. echo ' <div class="control-group description">
  229. <label class="control-label">
  230. '.get_lang('Description').'
  231. </label>
  232. <div class="controls">
  233. <textarea class="span3" cols="50" name="description">' . Security::remove_XSS($description) . '</textarea>
  234. </div>
  235. </div>';
  236. $resultcategories = getLinkCategories($course_id, $session_id);
  237. if (!empty($resultcategories)) {
  238. echo ' <div class="control-group category">
  239. <label class="control-label">
  240. '.get_lang('Category').'
  241. </label>
  242. <div class="controls">';
  243. echo ' <select name="selectcategory">';
  244. echo ' <option value="0">--</option>';
  245. foreach ($resultcategories as $myrow) {
  246. echo ' <option value="'.$myrow['id'].'"';
  247. if ($myrow['id'] == $category) {
  248. echo ' selected';
  249. }
  250. echo '>'.$myrow['category_title'].'</option>';
  251. }
  252. echo ' </select>';
  253. echo ' </div>
  254. </div>';
  255. }
  256. echo ' <div class="control-group onhomepage">
  257. <label class="control-label">
  258. </label>
  259. <div class="controls">
  260. <input class="checkbox" type="checkbox" name="onhomepage" id="onhomepage" value="1"'.$onhomepage.'><label for="onhomepage"> '.get_lang('OnHomepage').'?</label>
  261. </div>
  262. </div>';
  263. echo ' <div class="control-group target" id="div_target">
  264. <label class="control-label">
  265. '.get_lang('LinkTarget').'
  266. </label>
  267. <div class="controls">
  268. <select name="target_link" id="target_link">';
  269. $targets = array('_self'=>get_lang('LinkOpenSelf'),'_blank'=>get_lang('LinkOpenBlank'),'_parent'=>get_lang('LinkOpenParent'),'_top'=>get_lang('LinkOpenTop'));
  270. foreach ($targets as $target_id => $target) {
  271. $selected = '';
  272. if ($target_id == $target_link) {
  273. $selected = ' selected="selected"';
  274. }
  275. echo ' <option value="'.$target_id.'"'.$selected.'>'.$target.'</option> ';
  276. }
  277. echo ' </select>
  278. <span class="help-block">
  279. '.get_lang('AddTargetOfLinkOnHomepage').'
  280. </span>
  281. </div>
  282. </div>';
  283. if (api_get_setting('search_enabled') == 'true') {
  284. require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php';
  285. $specific_fields = get_specific_field_list();
  286. echo ' <div class="control-group index">
  287. <label class="control-label">
  288. '.get_lang('SearchFeatureDoIndexLink').'
  289. </label>
  290. <div class="controls">
  291. <label for="index_document">
  292. <input class="checkbox" type="checkbox" name="index_document" id="index_document" checked="checked">
  293. '.get_lang('Yes').'
  294. </label>
  295. </div>
  296. </div>';
  297. foreach ($specific_fields as $specific_field) {
  298. $default_values = '';
  299. if ($_GET['action'] == 'editlink') {
  300. $filter = array('field_id' => $specific_field['id'], 'ref_id' => intval($_GET['id']), 'tool_id' => '\''. TOOL_LINK .'\'');
  301. $values = get_specific_field_values_list($filter, array('value'));
  302. if (!empty($values)) {
  303. $arr_str_values = array();
  304. foreach ($values as $value) {
  305. $arr_str_values[] = $value['value'];
  306. }
  307. $default_values = implode(', ', $arr_str_values);
  308. }
  309. }
  310. $sf_textbox = '
  311. <div class="control-group">
  312. <label class="control-label">%s</label>
  313. <div class="controls">
  314. <input name="%s" type="text" value="%s"/>
  315. </div>
  316. </div>';
  317. echo sprintf($sf_textbox, $specific_field['name'], $specific_field['code'], $default_values);
  318. }
  319. }
  320. echo '<input type="hidden" name="lp_id" value="' . $lpId. '" />';
  321. echo '<div class="control-group">
  322. <label class="control-label">
  323. </label>
  324. <div class="controls">
  325. <button class="btn save" type="submit" name="submitLink" value="OK">'.get_lang('SaveLink').'</button>
  326. </div>
  327. </div>';
  328. echo '</form>';
  329. } elseif(($_GET['action'] == 'addcategory' || $_GET['action'] == 'editcategory') && !$submit_category) {
  330. echo '<form class="form-horizontal " method="post" action="'.api_get_self().'?action='.Security::remove_XSS($_GET['action']).'&amp;urlview='.Security::remove_XSS($urlview).'">';
  331. if ($_GET['action'] == 'addcategory') {
  332. echo '<legend>'.get_lang('CategoryAdd').'</legend>';
  333. $my_cat_title = get_lang('CategoryAdd');
  334. } else {
  335. echo '<legend>'.get_lang('CategoryMod').'</legend>';
  336. $my_cat_title = get_lang('CategoryMod');
  337. }
  338. echo '<input type="hidden" name="sec_token" value="'.$token.'" />';
  339. if ($_GET['action'] == 'editcategory') {
  340. echo '<input type="hidden" name="id" value="'.$id.'" />';
  341. }
  342. echo ' <div class="control-group category">
  343. <label class="control-label">
  344. <span class="form_required">*</span> '.get_lang('CategoryName').'
  345. </label>
  346. <div class="controls">
  347. <input type="text" name="category_title" size="50" value="'.Security::remove_XSS($category_title).'" />
  348. </div>
  349. </div>';
  350. echo ' <div class="control-group description">
  351. <label class="control-label">
  352. '.get_lang('Description').'
  353. </label>
  354. <div class="controls">
  355. <textarea rows="3" cols="50" name="description">'.Security::remove_XSS($description).'</textarea>
  356. </div>
  357. </div>';
  358. echo ' <div class="control-group">
  359. <label class="control-label">
  360. </label>
  361. <div class="controls">
  362. <button class="btn save" type="submit" name="submitCategory">'.$my_cat_title.' </button>
  363. </div>
  364. </div>';
  365. echo "</form>";
  366. }
  367. }
  368. if (!empty($down)) {
  369. movecatlink($down);
  370. }
  371. if (!empty($up)) {
  372. movecatlink($up);
  373. }
  374. if (empty($_GET['action']) ||
  375. ($_GET['action'] != 'editlink' && $_GET['action'] != 'addcategory' && $_GET['action'] != 'addlink') ||
  376. $link_submitted ||
  377. $category_submitted
  378. ) {
  379. /* Action Links */
  380. echo '<div class="actions">';
  381. if (api_is_allowed_to_edit(null, true)) {
  382. $urlview = Security::remove_XSS($urlview);
  383. echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;action=addlink&amp;category='.(!empty($category) ? $category : '').'&amp;urlview='.$urlview.'">'.
  384. Display::return_icon('new_link.png', get_lang('LinkAdd'),'',ICON_SIZE_MEDIUM).'</a>';
  385. echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;action=addcategory&amp;urlview='.$urlview.'">'.
  386. Display::return_icon('new_folder.png', get_lang('CategoryAdd'),'',ICON_SIZE_MEDIUM).'</a>';
  387. /* "<a href=\"".api_get_self()."?".api_get_cidreq()."&action=importcsv&amp;urlview=".$urlview."\">".get_lang('CsvImport')."</a>\n", // RH*/
  388. }
  389. // Making the show none / show all links. Show none means urlview=0000 (number of zeros depending on the
  390. // number of categories). Show all means urlview=1111 (number of 1 depending on teh number of categories).
  391. $resultcategories = getLinkCategories($course_id, $session_id);
  392. $aantalcategories = count($resultcategories);
  393. if (!empty($resultcategories)) {
  394. echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&urlview=';
  395. for ($j = 1; $j <= $aantalcategories; $j++) {
  396. echo '0';
  397. }
  398. echo '">'.Display::return_icon('view_remove.png', $shownone,'',ICON_SIZE_MEDIUM).'</a>';
  399. echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&urlview=';
  400. for ($j = 1; $j <= $aantalcategories; $j++) {
  401. echo '1';
  402. }
  403. echo '">'.Display::return_icon('view_tree.png', $showall,'',ICON_SIZE_MEDIUM).'</a>';
  404. }
  405. echo '</div>';
  406. // Displaying the links which have no category (thus category = 0 or NULL), if none present this will not be displayed
  407. $sqlLinks = "SELECT * FROM ".$tbl_link." WHERE c_id = $course_id AND category_id=0 OR category_id IS NULL";
  408. $result = Database::query($sqlLinks);
  409. $numberofzerocategory = Database::num_rows($result);
  410. if ($numberofzerocategory !== 0) {
  411. echo '<table class="data_table">';
  412. echo '<tr><th style="font-weight: bold; text-align:left;padding-left: 10px;">'.get_lang('General').'</th></tr>';
  413. echo '</table>';
  414. showlinksofcategory(0);
  415. }
  416. $i = 0;
  417. $catcounter = 1;
  418. $view = '0';
  419. foreach ($resultcategories as $myrow) {
  420. // Validation when belongs to a session
  421. $session_img = api_get_session_image($myrow['session_id'], $_user['status']);
  422. //if (!isset($urlview)) {
  423. if ($urlview == '') {
  424. // No $view set in the url, thus for each category link it should be all zeros except it's own
  425. makedefaultviewcode($i);
  426. } else {
  427. $view = $urlview;
  428. $view[$i] = '1';
  429. }
  430. // If the $urlview has a 1 for this categorie, this means it is expanded and should be desplayed as a
  431. // - instead of a +, the category is no longer clickable and all the links of this category are displayed
  432. $myrow['description'] = text_filter($myrow['description']);
  433. $strVisibility = '';
  434. if ($myrow['visibility'] == '1') {
  435. $strVisibility = '<a href="link.php?' . api_get_cidreq() . '&amp;sec_token='.$token.'&amp;action=invisible&amp;id=' . $myrow['id'] . '&amp;scope=' . TOOL_LINK_CATEGORY . '" title="' . get_lang('Hide') . '">' .
  436. Display :: return_icon('visible.png', get_lang('Hide'), array (), ICON_SIZE_SMALL) . '</a>';
  437. } elseif ($myrow['visibility'] == '0') {
  438. $strVisibility = ' <a href="link.php?' . api_get_cidreq() . '&amp;sec_token='.$token.'&amp;action=visible&amp;id=' . $myrow['id'] . '&amp;scope=' . TOOL_LINK_CATEGORY . '" title="' . get_lang('Show') . '">' .
  439. Display :: return_icon('invisible.png', get_lang('Show'), array (), ICON_SIZE_SMALL) . '</a>';
  440. }
  441. if ($myrow['visibility'] == '1') {
  442. if (isset($urlview[$i]) && $urlview[$i] == '1') {
  443. $newurlview = $urlview;
  444. $newurlview[$i] = '0';
  445. echo '<tr>';
  446. echo '<table class="data_table">';
  447. echo '<tr>';
  448. echo '<th width="81%" style="font-weight: bold; text-align:left;padding-left: 5px;">';
  449. echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;urlview='.Security::remove_XSS($newurlview).'">';
  450. echo '<img src="../img/icons/22/view_remove.png" />&nbsp;&nbsp;'.Security::remove_XSS($myrow['category_title']).'</a><br />&nbsp;&nbsp;&nbsp;'.$myrow['description'];
  451. echo '</th>';
  452. if (api_is_allowed_to_edit(null, true)) {
  453. if ($session_id == $myrow['session_id']) {
  454. echo '<th>';
  455. echo $strVisibility;
  456. showcategoryadmintools($myrow['id']);
  457. echo '</th>';
  458. } else {
  459. echo '<th>'.get_lang('EditionNotAvailableFromSession');
  460. }
  461. }
  462. echo '</tr>';
  463. echo '</table>';
  464. echo showlinksofcategory($myrow['id']);
  465. echo '</tr>';
  466. } else {
  467. echo '<tr>';
  468. echo '<table class="data_table">';
  469. echo '<tr>';
  470. echo '<th width="81%" style="font-weight: bold; text-align:left;padding-left: 5px;">
  471. <a href="'.api_get_self().'?'.api_get_cidreq().'&amp;urlview=';
  472. echo is_array($view) ? implode('', $view) : $view;
  473. echo '"><img src="../img/icons/22/view_tree.png" />&nbsp;&nbsp;'.
  474. Security::remove_XSS($myrow['category_title']).$session_img;
  475. echo'</a><br />&nbsp;&nbsp;&nbsp;';
  476. echo $myrow['description'];
  477. if (api_is_allowed_to_edit(null, true)) {
  478. if ($session_id == $myrow['session_id']) {
  479. echo '<th style="text-align:center;">';
  480. echo $strVisibility;
  481. showcategoryadmintools($myrow['id']);
  482. echo '</th>';
  483. }
  484. }
  485. echo '</th>';
  486. echo '</tr>';
  487. echo '</table>';
  488. echo '</tr>';
  489. }
  490. } else {
  491. // NO VISIBLE
  492. if (api_is_allowed_to_edit(null, true)) {
  493. if (isset($urlview[$i]) && $urlview[$i] == '1') {
  494. $newurlview = $urlview;
  495. $newurlview[$i] = '0';
  496. echo '<tr>';
  497. echo '<table class="data_table">';
  498. echo '<tr>';
  499. echo '<th width="81%" style="font-weight: bold; text-align:left;padding-left: 5px;">';
  500. echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;urlview='.Security::remove_XSS($newurlview).'">';
  501. echo '<img src="../img/icons/22/view_remove_na.png" />&nbsp;&nbsp;'.Security::remove_XSS($myrow['category_title']).'</a><br />&nbsp;&nbsp;&nbsp;'.$myrow['description'];
  502. echo '</th>';
  503. if (api_is_allowed_to_edit(null, true)) {
  504. if ($session_id == $myrow['session_id']) {
  505. echo '<th>'; echo $strVisibility; showcategoryadmintools($myrow['id']); echo '</th>';
  506. } else {
  507. echo '<th>'.get_lang('EditionNotAvailableFromSession');
  508. }
  509. }
  510. echo '</tr>';
  511. echo '</table>';
  512. echo showlinksofcategory($myrow['id']);
  513. echo '</tr>';
  514. } else {
  515. echo '<tr>';
  516. echo '<table class="data_table">';
  517. echo '<tr>';
  518. echo '<th width="81%" style="font-weight: bold; text-align:left;padding-left: 5px;"><a href="'.api_get_self().'?'.api_get_cidreq().'&amp;urlview=';
  519. echo is_array($view) ? implode('', $view) : $view;
  520. echo '"><img src="../img/icons/22/view_tree_na.png" />&nbsp;&nbsp;'.Security::remove_XSS($myrow['category_title']).$session_img;
  521. echo'</a><br />&nbsp;&nbsp;&nbsp;';
  522. echo $myrow['description'];
  523. if (api_is_allowed_to_edit(null, true)) {
  524. if ($session_id == $myrow['session_id']) {
  525. echo '<th style="text-align:center;">';
  526. echo $strVisibility;
  527. showcategoryadmintools($myrow['id']);
  528. echo '</th>';
  529. }
  530. }
  531. echo '</th>';
  532. echo '</tr>';
  533. echo '</table>';
  534. echo '</tr>';
  535. }
  536. }
  537. }
  538. // Displaying the link of the category
  539. $i++;
  540. }
  541. echo '</table>';
  542. }
  543. Display::display_footer();