diff --git a/main/blog/blog_admin.php b/main/blog/blog_admin.php index 42c245b49f..2fda120a8a 100644 --- a/main/blog/blog_admin.php +++ b/main/blog/blog_admin.php @@ -27,7 +27,7 @@ if((!$is_allowed_in_course || !$is_courseMember) && !api_is_allowed_to_edit()) { } if (api_is_allowed_to_edit()) { - require_once(api_get_path(LIBRARY_PATH) . "blog.lib.php"); + 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 @@ -114,7 +114,7 @@ if (api_is_allowed_to_edit()) { if ($_POST) { Display::display_error_message(get_lang('FormHasErrorsPleaseComplete')); } - Blog::display_edit_blog_form(Database::escape_string((int)$_GET['blog_id'])); + Blog::display_edit_blog_form(Database::escape_string((int)$_GET['blog_id'])); } } Blog::display_blog_list(); diff --git a/main/inc/lib/blog.lib.php b/main/inc/lib/blog.lib.php index 598a339169..48f01a74e3 100644 --- a/main/inc/lib/blog.lib.php +++ b/main/inc/lib/blog.lib.php @@ -1214,46 +1214,42 @@ class Blog { } $oFCKeditor->Value = isset($_POST['post_full_text'])?stripslashes($_POST['post_full_text']):''; - echo '
'; + echo '
'; $oFCKeditor->Create(); echo '
'; // attachment - echo '
-
+ echo '
+
-
+
'; // comment - echo '
-
+ echo '
+
-
+ +
'; // submit - echo '
-
-
-
+ echo '
+ +
'; - - echo ''; - } - else - { + } else { api_not_allowed(); } } @@ -2585,40 +2581,20 @@ class Blog { * */ public static function display_new_blog_form () { - echo '
- - ' . get_lang('AddBlog') . ' - -
-
- *' . get_lang('Title') . ' -
-
- -
-
- -
-
- ' . get_lang('Subtitle') . ' -
-
- -
-
- -
-
-
-
- - - -
-
-
-
'; - + + $form = new FormValidator('add_blog', 'post','blog_admin.php?action=add'); + $form->addElement('header', get_lang('AddBlog')); + $form->addElement('text', 'blog_name', get_lang('Title')); + $form->addElement('textarea', 'blog_subtitle', get_lang('Subtitle')); + + $form->addElement('hidden', 'new_blog_submit', 'true'); + $form->addElement('style_submit_button', null, get_lang('SaveProject')); + + $defaults = array(); + $defaults['blog_name'] = Security::remove_XSS($_POST['blog_name']); + $defaults['blog_subtitle'] = Security::remove_XSS($_POST['blog_subtitle']); + $form->setDefaults($defaults); + $form->display(); } /** @@ -2634,46 +2610,25 @@ class Blog { $blog = Database::fetch_array($result); // the form contained errors but we do not want to lose the changes the user already did - if ($_POST) - { + if ($_POST) { $blog['blog_name'] = Security::remove_XSS($_POST['blog_name']); $blog['blog_subtitle'] = Security::remove_XSS($_POST['blog_subtitle']); } - echo '
- - ' . get_lang('EditBlog') . ' - -
-
- *' . get_lang('Title') . ' -
-
- -
-
- -
-
- ' . get_lang('Subtitle') . ' -
-
- -
-
- -
-
-
-
- - - - -
-
-
-
- '; + + $form = new FormValidator('edit_blog', 'post','blog_admin.php?action=edit&blog_id='.Security::remove_XSS($_GET['blog_id'])); + $form->addElement('header', get_lang('EditBlog')); + $form->addElement('text', 'blog_name', get_lang('Title')); + $form->addElement('textarea', 'blog_subtitle', get_lang('Subtitle')); + + $form->addElement('hidden', 'edit_blog_submit', 'true'); + $form->addElement('hidden', 'blog_id', $blog['blog_id']); + $form->addElement('style_submit_button', null, get_lang('Save')); + + $defaults = array(); + $defaults['blog_name'] = $blog['blog_name']; + $defaults['blog_subtitle'] = $blog['blog_subtitle']; + $form->setDefaults($defaults); + $form->display(); } /** diff --git a/main/inc/lib/template.lib.php b/main/inc/lib/template.lib.php index 9cb2b129e9..50a93dd783 100644 --- a/main/inc/lib/template.lib.php +++ b/main/inc/lib/template.lib.php @@ -23,14 +23,16 @@ class Template extends Smarty { var $show_footer; var $help; var $menu_navigation = array(); - var $show_learnpath = false; + var $show_learnpath = false; // This is a learnpath section or not? var $plugin = null; var $course_id = null; + var $user_is_logged_in = false; function __construct($title = '', $show_header = true, $show_footer = true, $show_learnpath = false) { parent::__construct(); - $this->title = $title; - //$this->assign('header', $title); + + //Page title + $this->title = $title; $this->show_learnpath = $show_learnpath; //Smarty 3 configuration @@ -169,8 +171,7 @@ class Template extends Smarty { $this->show_header = $status; $this->assign('show_header', $status); - //Tool bar - + //Toolbar $show_admin_toolbar = api_get_setting('show_admin_toolbar'); $show_toolbar = 0; @@ -193,8 +194,8 @@ class Template extends Smarty { } $this->assign('show_toolbar', $show_toolbar); - //Only if course is available - if (!empty($this->course_id)) { + //Only if course is available + if (!empty($this->course_id) && $this->user_is_logged_in) { if (api_get_setting('show_toolshortcuts') != 'false') { //Course toolbar @@ -227,9 +228,11 @@ class Template extends Smarty { } $user_info['messages_count'] = MessageManager::get_new_messages(); + $this->user_is_logged_in = true; } //Setting the $_u array that could be use in any template $this->assign('_u', $user_info); + $this->user_is_logged_in = false; } private function set_system_parameters() { @@ -240,8 +243,7 @@ class Template extends Smarty { 'web_course' => api_get_path(WEB_COURSE_PATH), 'web_main' => api_get_path(WEB_CODE_PATH), 'web_ajax' => api_get_path(WEB_AJAX_PATH), - 'web_img' => api_get_path(WEB_IMG_PATH), - + 'web_img' => api_get_path(WEB_IMG_PATH) ); $this->assign('_p', $_p); @@ -250,7 +252,7 @@ class Template extends Smarty { 'software_name' => $_configuration['software_name'], 'system_version' => $_configuration['system_version'], 'site_name' => api_get_setting('siteName'), - 'institution' => api_get_setting('Institution'), + 'institution' => api_get_setting('Institution') ); $this->assign('_s', $_s); }