diff --git a/main/blog/blog_admin.php b/main/blog/blog_admin.php index ec2c9f2ab1..ddd2e680b3 100644 --- a/main/blog/blog_admin.php +++ b/main/blog/blog_admin.php @@ -35,78 +35,92 @@ $language_file = "blog"; include('../inc/global.inc.php'); $this_section=SECTION_COURSES; + /* ------------ ACCESS RIGHTS ------------ */ // notice for unauthorized people. api_protect_course_script(true); -require_once(api_get_path(LIBRARY_PATH) . "blog.lib.php"); - -$nameTools = get_lang("blog_management"); - - -// showing the header if we are not in the learning path, if we are in -// the learning path, we do not include the banner so we have to explicitly -// include the stylesheet, which is normally done in the header -if ($_GET['origin'] != 'learnpath') -{ - Display::display_header($nameTools,'Blogs'); -} -else +//------------ ONLY USERS REGISTERED IN THE COURSE---------------------- +if((!$is_allowed_in_course || !$is_courseMember) && !api_is_allowed_to_edit()) { - echo ""; + api_not_allowed(true);//print headers/footers } -/* -============================================================================== - PROCESSING.. -============================================================================== -*/ -if ($_POST['new_blog_submit']) -{ - Blog::create_blog($_POST['blog_name'],$_POST['blog_subtitle']); -} -if ($_POST['edit_blog_submit']) -{ - Blog::edit_blog($_POST['blog_id'],$_POST['blog_name'],$_POST['blog_subtitle']); -} -if ($_GET['action'] == 'visibility') -{ - Blog::change_blog_visibility(mysql_real_escape_string((int)$_GET['blog_id'])); -} -if ($_GET['action'] == 'delete') -{ - Blog::delete_blog(mysql_real_escape_string((int)$_GET['blog_id'])); -} - - -/* -============================================================================== - DISPLAY -============================================================================== -*/ -api_display_tool_title($nameTools); -//api_introductionsection(TOOL_BLOG); - if ($_GET['action'] == 'add') +if (api_is_allowed_to_edit()) +{ + + require_once(api_get_path(LIBRARY_PATH) . "blog.lib.php"); + $nameTools = get_lang("blog_management"); + + + // showing the header if we are not in the learning path, if we are in + // the learning path, we do not include the banner so we have to explicitly + // include the stylesheet, which is normally done in the header + if ($_GET['origin'] != 'learnpath') { - Blog::display_new_blog_form(); + Display::display_header($nameTools,'Blogs'); } - if ($_GET['action'] == 'edit') + else { - Blog::display_edit_blog_form(mysql_real_escape_string((int)$_GET['blog_id'])); + echo ""; + } + /* + ============================================================================== + PROCESSING.. + ============================================================================== + */ + if ($_POST['new_blog_submit']) + { + Blog::create_blog($_POST['blog_name'],$_POST['blog_subtitle']); + } + if ($_POST['edit_blog_submit']) + { + Blog::edit_blog($_POST['blog_id'],$_POST['blog_name'],$_POST['blog_subtitle']); + } + if ($_GET['action'] == 'visibility') + { + Blog::change_blog_visibility(mysql_real_escape_string((int)$_GET['blog_id'])); + } + if ($_GET['action'] == 'delete') + { + Blog::delete_blog(mysql_real_escape_string((int)$_GET['blog_id'])); + } + + + /* + ============================================================================== + DISPLAY + ============================================================================== + */ + api_display_tool_title($nameTools); + //api_introductionsection(TOOL_BLOG); + + + if ($_GET['action'] == 'add') + { + Blog::display_new_blog_form(); + } + if ($_GET['action'] == 'edit') + { + Blog::display_edit_blog_form(mysql_real_escape_string((int)$_GET['blog_id'])); + } + + echo "", + "".get_lang(  ".get_lang('AddBlog').""; + echo ""; + echo "", + "\n", + "\n", + "\n", + "\n"; + Blog::display_blog_list(); + echo "
",get_lang('Title'),"",get_lang('Subtitle'),"",get_lang('Modify'),"
"; + } + else + { + api_not_allowed(true); } - - echo "", - "".get_lang(  ".get_lang('AddBlog').""; - echo ""; - echo "", - "\n", - "\n", - "\n", - "\n"; - Blog::display_blog_list(); - echo "
",get_lang('Title'),"",get_lang('Subtitle'),"",get_lang('Modify'),"
"; - // Display the footer Display::display_footer();