blog_admin.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <?php
  2. /*
  3. ==============================================================================
  4. Dokeos - elearning and course management software
  5. Copyright (c) 2004-2008 Dokeos SPRL
  6. Copyright (c) 2003 Ghent University (UGent)
  7. Copyright (c) 2001 Universite catholique de Louvain (UCL)
  8. Copyright (c) various contributors
  9. For a full list of contributors, see "credits.txt".
  10. The full license can be read in "license.txt".
  11. This program is free software; you can redistribute it and/or
  12. modify it under the terms of the GNU General Public License
  13. as published by the Free Software Foundation; either version 2
  14. of the License, or (at your option) any later version.
  15. See the GNU General Public License for more details.
  16. Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
  17. info@dokeos.com
  18. ==============================================================================
  19. BLOG HOMEPAGE
  20. This file takes care of all blog navigation and displaying.
  21. @package dokeos.blogs
  22. ==============================================================================
  23. */
  24. // name of the language file that needs to be included
  25. $language_file = "blog";
  26. include('../inc/global.inc.php');
  27. $this_section=SECTION_COURSES;
  28. $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT);
  29. /* ------------ ACCESS RIGHTS ------------ */
  30. // notice for unauthorized people.
  31. api_protect_course_script(true);
  32. //------------ ONLY USERS REGISTERED IN THE COURSE----------------------
  33. if((!$is_allowed_in_course || !$is_courseMember) && !api_is_allowed_to_edit())
  34. {
  35. api_not_allowed(true);//print headers/footers
  36. }
  37. if (api_is_allowed_to_edit())
  38. {
  39. require_once(api_get_path(LIBRARY_PATH) . "blog.lib.php");
  40. $nameTools = get_lang("blog_management");
  41. // showing the header if we are not in the learning path, if we are in
  42. // the learning path, we do not include the banner so we have to explicitly
  43. // include the stylesheet, which is normally done in the header
  44. if ($_GET['origin'] != 'learnpath')
  45. {
  46. Display::display_header($nameTools,'Blogs');
  47. }
  48. else
  49. {
  50. echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"".$clarolineRepositoryWeb."css/default.css\"/>";
  51. }
  52. /*
  53. ==============================================================================
  54. PROCESSING..
  55. ==============================================================================
  56. */
  57. if ($_POST['new_blog_submit'])
  58. {
  59. Blog::create_blog($_POST['blog_name'],$_POST['blog_subtitle']);
  60. }
  61. if ($_POST['edit_blog_submit'])
  62. {
  63. Blog::edit_blog($_POST['blog_id'],$_POST['blog_name'],$_POST['blog_subtitle']);
  64. }
  65. if ($_GET['action'] == 'visibility')
  66. {
  67. Blog::change_blog_visibility(mysql_real_escape_string((int)$_GET['blog_id']));
  68. }
  69. if ($_GET['action'] == 'delete')
  70. {
  71. Blog::delete_blog(mysql_real_escape_string((int)$_GET['blog_id']));
  72. }
  73. /*
  74. ==============================================================================
  75. DISPLAY
  76. ==============================================================================
  77. */
  78. api_display_tool_title($nameTools);
  79. //api_introductionsection(TOOL_BLOG);
  80. if ($_GET['action'] == 'add')
  81. {
  82. Blog::display_new_blog_form();
  83. }
  84. if ($_GET['action'] == 'edit')
  85. {
  86. Blog::display_edit_blog_form(mysql_real_escape_string((int)$_GET['blog_id']));
  87. }
  88. echo "<a href='".api_get_self()."?action=add'>",
  89. "<img src='../img/blog_new.gif' border=\"0\" align=\"absmiddle\" alt='".get_lang('NewBlog')."'>&nbsp;&nbsp;".get_lang('AddBlog')."</a>";
  90. echo "<table width=\"100%\" border=\"0\" cellspacing=\"2\" class='data_table'>";
  91. echo "<tr>",
  92. "<th>",get_lang('Title'),"</th>\n",
  93. "<th>",get_lang('Subtitle'),"</th>\n",
  94. "<th>",get_lang('Modify'),"</th>\n",
  95. "</tr>\n";
  96. Blog::display_blog_list();
  97. echo "</table>";
  98. }
  99. else
  100. {
  101. api_not_allowed(true);
  102. }
  103. // Display the footer
  104. Display::display_footer();
  105. ?>