gradebook_edit_link.php 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. $tbl_work = Database :: get_course_table(TABLE_STUDENT_PUBLICATION,$my_db_name);
  33. $linkarray = LinkFactory :: load(Security::remove_XSS($_GET['editlink']));
  34. $link = $linkarray[0];
  35. $linkcat = isset($_GET['selectcat']) ? Security::remove_XSS($_GET['selectcat']):'';
  36. $linkedit = isset($_GET['editlink']) ? Security::remove_XSS($_GET['editlink']):'';
  37. $form = new LinkAddEditForm(LinkAddEditForm :: TYPE_EDIT,
  38. null,
  39. null,
  40. $link,
  41. 'edit_link_form',
  42. api_get_self() . '?selectcat=' . $linkcat
  43. . '&editlink=' . $linkedit);
  44. if ($form->validate()) {
  45. $values = $form->exportValues();
  46. $link->set_weight($values['weight']);
  47. $link->set_date(strtotime($values['date']));
  48. $link->set_visible(empty ($values['visible']) ? 0 : 1);
  49. $link->save();
  50. //Update weight into forum thread
  51. $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);';
  52. Database::query($sql_t);
  53. //Update weight into student publication(work)
  54. $sql_t='UPDATE '.$tbl_work.' SET weight='.$values['weight'].' WHERE id=(SELECT ref_id FROM '.$tbl_grade_links.' where id='.Security::remove_XSS($_GET['editlink']).' and type=3);';
  55. Database::query($sql_t);
  56. header('Location: '.$_SESSION['gradebook_dest'].'?linkedited=&selectcat=' . $link->get_category_id());
  57. exit;
  58. }
  59. $interbreadcrumb[] = array (
  60. 'url' => $_SESSION['gradebook_dest'].'?selectcat='.$linkcat,
  61. 'name' => get_lang('Gradebook'
  62. ));
  63. Display :: display_header(get_lang('EditLink'));
  64. $form->display();
  65. Display :: display_footer();