view.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. $language_file = array('exercice', 'work', 'document', 'admin');
  4. require_once '../inc/global.inc.php';
  5. $current_course_tool = TOOL_STUDENTPUBLICATION;
  6. require_once 'work.lib.php';
  7. $id = isset($_GET['id']) ? intval($_GET['id']) : null;
  8. $work = get_work_data_by_id($id);
  9. if (empty($id) || empty($work)) {
  10. api_not_allowed();
  11. }
  12. $interbreadcrumb[] = array ('url' => 'work.php', 'name' => get_lang('StudentPublications'));
  13. $my_folder_data = get_work_data_by_id($work['parent_id']);
  14. $course_info = api_get_course_info();
  15. allowOnlySubscribedUser(api_get_user_id(), $work['parent_id'], $course_info['real_id']);
  16. if (user_is_author($id) || $course_info['show_score'] == 0 && $work['active'] == 1 && $work['accepted'] == 1) {
  17. if (api_is_allowed_to_edit(null, true)) {
  18. $url_dir = 'work_list_all.php?id='.$my_folder_data['id'];
  19. } else {
  20. $url_dir = 'work_list.php?id='.$my_folder_data['id'];
  21. }
  22. $interbreadcrumb[] = array('url' => $url_dir, 'name' => $my_folder_data['title']);
  23. $interbreadcrumb[] = array('url' => '#','name' => $work['title']);
  24. if (
  25. ($course_info['show_score'] == 0 && $work['active'] == 1 && $work['accepted'] == 1) ||
  26. api_is_allowed_to_edit() ||
  27. (user_is_author($id))) {
  28. $tpl = new Template();
  29. $tpl->assign('work', $work);
  30. $template = $tpl->get_template('work/view.tpl');
  31. $content = $tpl->fetch($template);
  32. $tpl->assign('content', $content);
  33. $tpl->display_one_col_template();
  34. } else {
  35. api_not_allowed(true);
  36. }
  37. } else {
  38. api_not_allowed(true);
  39. }