gradebook_edit_link.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. /*
  3. ==============================================================================
  4. Dokeos - elearning and course management software
  5. Copyright (c) 2006 Dokeos S.A.
  6. Copyright (c) 2007 Stijn Konings, Bert Stepp� (Hogeschool Gent)
  7. For a full list of contributors, see "credits.txt".
  8. The full license can be read in "license.txt".
  9. This program is free software; you can redistribute it and/or
  10. modify it under the terms of the GNU General Public License
  11. as published by the Free Software Foundation; either version 2
  12. of the License, or (at your option) any later version.
  13. See the GNU General Public License for more details.
  14. Contact address: Dokeos, 44 rue des palais, B-1030 Brussels, Belgium
  15. Mail: info@dokeos.com
  16. ==============================================================================
  17. */
  18. $language_file = array('gradebook','link');
  19. //$cidReset = true;
  20. require_once ('../inc/global.inc.php');
  21. require_once ('lib/be.inc.php');
  22. require_once ('lib/gradebook_functions.inc.php');
  23. require_once ('lib/fe/linkform.class.php');
  24. require_once ('lib/fe/linkaddeditform.class.php');
  25. api_block_anonymous_users();
  26. block_students();
  27. $course_table = Database::get_main_table(TABLE_MAIN_COURSE);
  28. $tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
  29. //selected name of database
  30. $my_db_name=get_database_name_by_link_id(Security::remove_XSS($_GET['editlink']));
  31. $tbl_forum_thread = Database :: get_course_table(TABLE_FORUM_THREAD,$my_db_name);
  32. $linkarray = LinkFactory :: load(Security::remove_XSS($_GET['editlink']));
  33. $link = $linkarray[0];
  34. $linkcat = isset($_GET['selectcat']) ? Security::remove_XSS($_GET['selectcat']):'';
  35. $linkedit = isset($_GET['editlink']) ? Security::remove_XSS($_GET['editlink']):'';
  36. $form = new LinkAddEditForm(LinkAddEditForm :: TYPE_EDIT,
  37. null,
  38. null,
  39. $link,
  40. 'edit_link_form',
  41. api_get_self() . '?selectcat=' . $linkcat
  42. . '&editlink=' . $linkedit);
  43. if ($form->validate()) {
  44. $values = $form->exportValues();
  45. $link->set_weight($values['weight']);
  46. $link->set_date(strtotime($values['date']));
  47. $link->set_visible(empty ($values['visible']) ? 0 : 1);
  48. $link->save();
  49. $sql_t='UPDATE '.$tbl_forum_thread.' SET thread_weight='.$values['weight'].' WHERE thread_id=(SELECT ref_id FROM '.$tbl_grade_links.' where id='.Security::remove_XSS($_GET['editlink']).' and type=5);';
  50. api_sql_query($sql_t);
  51. header('Location: '.$_SESSION['gradebook_dest'].'?linkedited=&selectcat=' . $link->get_category_id());
  52. exit;
  53. }
  54. $interbreadcrumb[] = array (
  55. 'url' => $_SESSION['gradebook_dest'].'?selectcat='.$linkcat,
  56. 'name' => get_lang('Gradebook'
  57. ));
  58. Display :: display_header(get_lang('EditLink'));
  59. $form->display();
  60. Display :: display_footer();