Fix old fckeditor calls + fix PHP warnings see BT#8968

1.10.x
Julio Montoya 11 years ago
parent 4e517c5b25
commit 3b56cc764b
  1. 2
      main/admin/add_courses_to_usergroup.php
  2. 2
      main/admin/add_users_to_usergroup.php
  3. 2
      main/admin/course_import.php
  4. 2
      main/admin/dashboard_add_users_to_user.php
  5. 2
      main/admin/session_user_edit.php
  6. 213
      main/blog/blog.php
  7. 16
      main/blog/blog_admin.php
  8. 2
      main/course_description/course_description_form.class.php
  9. 2
      main/course_description/upload_file_form.class.php
  10. 2
      main/glossary/glossary_form.class.php
  11. 2
      main/glossary/upload_file_form.class.php
  12. 359
      main/inc/lib/blog.lib.php
  13. 2
      main/inc/lib/document.lib.php
  14. 2
      main/inc/lib/formvalidator/FormValidator.class.php
  15. 4
      main/link/category_form.class.php
  16. 3
      main/link/link_form.class.php
  17. 2
      main/link/upload_file_form.class.php
  18. 2
      main/notebook/notebook_form.class.php
  19. 2
      main/notebook/upload_file_form.class.php

@ -100,7 +100,7 @@ $filters = array(
); );
$searchForm = new FormValidator('search', 'get', api_get_self().'?id='.$id); $searchForm = new FormValidator('search', 'get', api_get_self().'?id='.$id);
$searchForm->add_header(get_lang('AdvancedSearch')); $searchForm->addHeader(get_lang('AdvancedSearch'));
$renderer =& $searchForm->defaultRenderer(); $renderer =& $searchForm->defaultRenderer();
$searchForm->addElement('hidden', 'id', $id); $searchForm->addElement('hidden', 'id', $id);
foreach ($filters as $param) { foreach ($filters as $param) {

@ -184,7 +184,7 @@ $filters = array(
); );
$searchForm = new FormValidator('search', 'get', api_get_self().'?id='.$id); $searchForm = new FormValidator('search', 'get', api_get_self().'?id='.$id);
$searchForm->add_header(get_lang('AdvancedSearch')); $searchForm->addHeader(get_lang('AdvancedSearch'));
$renderer =& $searchForm->defaultRenderer(); $renderer =& $searchForm->defaultRenderer();
$searchForm->addElement('hidden', 'id', $id); $searchForm->addElement('hidden', 'id', $id);

@ -210,7 +210,7 @@ if (isset($errors) && count($errors) != 0) {
} }
$form = new FormValidator('import', 'post', api_get_self(), null, array('enctype' => 'multipart/form-data')); $form = new FormValidator('import', 'post', api_get_self(), null, array('enctype' => 'multipart/form-data'));
$form->add_header($tool_name); $form->addHeader($tool_name);
$form->addElement('file', 'import_file', get_lang('ImportCSVFileLocation')); $form->addElement('file', 'import_file', get_lang('ImportCSVFileLocation'));
$form->addElement('checkbox', 'add_me_as_teacher', null, get_lang('AddMeAsTeacherInCourses')); $form->addElement('checkbox', 'add_me_as_teacher', null, get_lang('AddMeAsTeacherInCourses'));
$form->addElement('button', 'save', get_lang('Import')); $form->addElement('button', 'save', get_lang('Import'));

@ -259,7 +259,7 @@ $filters = array(
); );
$searchForm = new FormValidator('search', 'get', api_get_self().'?user='.$user_id); $searchForm = new FormValidator('search', 'get', api_get_self().'?user='.$user_id);
$searchForm->add_header(get_lang('AdvancedSearch')); $searchForm->addHeader(get_lang('AdvancedSearch'));
$renderer =& $searchForm->defaultRenderer(); $renderer =& $searchForm->defaultRenderer();
$searchForm->addElement('hidden', 'user', $user_id); $searchForm->addElement('hidden', 'user', $user_id);

@ -33,7 +33,7 @@ $interbreadcrumb[] = array('url' => 'session_list.php','name' => get_lang('Sessi
$interbreadcrumb[] = array('url' => "resume_session.php?id_session=".$sessionId, "name" => get_lang('SessionOverview')); $interbreadcrumb[] = array('url' => "resume_session.php?id_session=".$sessionId, "name" => get_lang('SessionOverview'));
$form = new FormValidator('edit', 'post', api_get_self().'?session_id='.$sessionId.'&user_id='.$userId); $form = new FormValidator('edit', 'post', api_get_self().'?session_id='.$sessionId.'&user_id='.$userId);
$form->add_header(get_lang('EditUserSessionDuration')); $form->addHeader(get_lang('EditUserSessionDuration'));
$data = SessionManager::getUserSession($userId, $sessionId); $data = SessionManager::getUserSession($userId, $sessionId);
$userInfo = api_get_user_info($userId); $userInfo = api_get_user_info($userId);

@ -6,9 +6,6 @@
* @package chamilo.blogs * @package chamilo.blogs
*/ */
/**
* INIT
*/
// name of the language file that needs to be included // name of the language file that needs to be included
$language_file = "blog"; $language_file = "blog";
require_once '../inc/global.inc.php'; require_once '../inc/global.inc.php';
@ -22,18 +19,11 @@ if (empty($blog_id)) {
$this_section = SECTION_COURSES; $this_section = SECTION_COURSES;
$current_course_tool = TOOL_BLOGS; $current_course_tool = TOOL_BLOGS;
/* ACCESS RIGHTS */ /* ACCESS RIGHTS */
// notice for unauthorized people. // notice for unauthorized people.
api_protect_course_script(true); api_protect_course_script(true);
//session
if(isset($_GET['id_session'])) {
$_SESSION['id_session'] = intval($_GET['id_session']);
}
$lib_path = api_get_path(LIBRARY_PATH); $lib_path = api_get_path(LIBRARY_PATH);
$blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT);
$nameTools = get_lang('Blogs'); $nameTools = get_lang('Blogs');
@ -41,95 +31,146 @@ $DaysShort = api_get_week_days_short();
$DaysLong = api_get_week_days_long(); $DaysLong = api_get_week_days_long();
$MonthsLong = api_get_months_long(); $MonthsLong = api_get_months_long();
$current_page = $_GET['action']; $action = isset($_GET['action']) ? $_GET['action'] : null;
/* /*
PROCESSING PROCESSING
*/ */
$safe_post_title = Security::remove_XSS($_POST['post_title']); $safe_post_file_comment = isset($_GET['post_file_comment']) ? Security::remove_XSS($_POST['post_file_comment']) : null;
$safe_post_file_comment = Security::remove_XSS($_POST['post_file_comment']); $safe_comment_text = isset($_GET['comment_text']) ? Security::remove_XSS(stripslashes(api_html_entity_decode($_POST['comment_text'])), COURSEMANAGERLOWSECURITY) : null;
$safe_post_full_text = Security::remove_XSS(stripslashes(api_html_entity_decode($_POST['post_full_text'])), COURSEMANAGERLOWSECURITY); $safe_comment_title = isset($_GET['comment_title']) ? Security::remove_XSS($_POST['comment_title']) : null;
$safe_comment_text = Security::remove_XSS(stripslashes(api_html_entity_decode($_POST['comment_text'])), COURSEMANAGERLOWSECURITY); $safe_task_name = isset($_GET['task_name']) ? Security::remove_XSS($_POST['task_name']) : null;
$safe_comment_title = Security::remove_XSS($_POST['comment_title']); $safe_task_description = isset($_GET['task_description']) ? Security::remove_XSS($_POST['task_description']) : null;
$safe_task_name = Security::remove_XSS($_POST['task_name']);
$safe_task_description = Security::remove_XSS($_POST['task_description']); if (!empty($_POST['new_post_submit'])) {
Blog:: create_post(
if (!empty($_POST['new_post_submit']) AND !empty($_POST['post_title'])) { $_POST['title'],
Blog :: create_post($safe_post_title, $safe_post_full_text, $safe_post_file_comment,$blog_id); $_POST['full_text'],
$_POST['post_file_comment'],
$blog_id
);
$return_message = array('type' => 'confirmation', 'message' => get_lang('BlogAdded')); $return_message = array('type' => 'confirmation', 'message' => get_lang('BlogAdded'));
} }
if (!empty($_POST['edit_post_submit'])) if (!empty($_POST['edit_post_submit'])) {
{ Blog:: edit_post(
$safe_post_title = Security::remove_XSS($_POST['post_title']); $_POST['post_id'],
Blog :: edit_post($_POST['post_id'], $safe_post_title, $safe_post_full_text, $blog_id); $_POST['title'],
$_POST['full_text'],
$blog_id
);
$return_message = array('type' => 'confirmation', 'message' => get_lang('BlogEdited')); $return_message = array('type' => 'confirmation', 'message' => get_lang('BlogEdited'));
} }
if (!empty($_POST['new_comment_submit']))
{ if (!empty($_POST['new_comment_submit'])) {
Blog :: create_comment($safe_comment_title, $safe_comment_text, $safe_post_file_comment,$blog_id, (int)$_GET['post_id'], $_POST['comment_parent_id']); Blog:: create_comment(
$_POST['title'],
$_POST['comment'],
$_POST['post_file_comment'],
$blog_id,
$_GET['post_id'],
$_POST['comment_parent_id']
);
$return_message = array('type' => 'confirmation', 'message' => get_lang('CommentAdded')); $return_message = array('type' => 'confirmation', 'message' => get_lang('CommentAdded'));
} }
if (!empty($_POST['new_task_submit'])) if (!empty($_POST['new_task_submit'])) {
{ Blog:: create_task(
Blog :: create_task($blog_id, $safe_task_name, $safe_task_description, $_POST['chkArticleDelete'], $_POST['chkArticleEdit'], $_POST['chkCommentsDelete'], $_POST['task_color']); $blog_id,
$safe_task_name,
$safe_task_description,
$_POST['chkArticleDelete'],
$_POST['chkArticleEdit'],
$_POST['chkCommentsDelete'],
$_POST['task_color']
);
$return_message = array('type' => 'confirmation', 'message' => get_lang('TaskCreated')); $return_message = array('type' => 'confirmation', 'message' => get_lang('TaskCreated'));
} }
if (isset($_POST['edit_task_submit'])) if (isset($_POST['edit_task_submit'])) {
{ Blog:: edit_task(
Blog :: edit_task($_POST['blog_id'], $_POST['task_id'], $safe_task_name, $safe_task_description, $_POST['chkArticleDelete'], $_POST['chkArticleEdit'],$_POST['chkCommentsDelete'], $_POST['task_color']); $_POST['blog_id'],
$return_message = array('type' => 'confirmation', 'message' => get_lang('TaskEdited')); $_POST['task_id'],
$safe_task_name,
$safe_task_description,
$_POST['chkArticleDelete'],
$_POST['chkArticleEdit'],
$_POST['chkCommentsDelete'],
$_POST['task_color']
);
$return_message = array(
'type' => 'confirmation',
'message' => get_lang('TaskEdited')
);
} }
if (!empty($_POST['assign_task_submit']))
{ if (!empty($_POST['assign_task_submit'])) {
Blog :: assign_task($blog_id, $_POST['task_user_id'], $_POST['task_task_id'], $_POST['task_year']."-".$_POST['task_month']."-".$_POST['task_day']); Blog:: assign_task(
$return_message = array('type' => 'confirmation', 'message' => get_lang('TaskAssigned')); $blog_id,
$_POST['task_user_id'],
$_POST['task_task_id'],
$_POST['task_year'] . "-" . $_POST['task_month'] . "-" . $_POST['task_day']
);
$return_message = array(
'type' => 'confirmation',
'message' => get_lang('TaskAssigned')
);
} }
if (isset($_POST['assign_task_edit_submit'])) if (isset($_POST['assign_task_edit_submit'])) {
{ Blog:: edit_assigned_task(
Blog :: edit_assigned_task($blog_id, $_POST['task_user_id'], $_POST['task_task_id'], $_POST['task_year']."-".$_POST['task_month']."-".$_POST['task_day'], $_POST['old_user_id'], $_POST['old_task_id'], $_POST['old_target_date']); $blog_id,
$return_message = array('type' => 'confirmation', 'message' => get_lang('AssignedTaskEdited')); $_POST['task_user_id'],
$_POST['task_task_id'],
$_POST['task_year'] . "-" . $_POST['task_month'] . "-" . $_POST['task_day'],
$_POST['old_user_id'],
$_POST['old_task_id'],
$_POST['old_target_date']
);
$return_message = array(
'type' => 'confirmation',
'message' => get_lang('AssignedTaskEdited')
);
} }
if (!empty($_POST['new_task_execution_submit'])) if (!empty($_POST['new_task_execution_submit'])) {
{ Blog:: create_comment(
Blog :: create_comment($safe_comment_title, $safe_comment_text, $blog_id, (int)$_GET['post_id'], $_POST['comment_parent_id'], $_POST['task_id']); $safe_comment_title,
$return_message = array('type' => 'confirmation', 'message' => get_lang('CommentCreated')); $safe_comment_text,
$blog_id,
(int)$_GET['post_id'],
$_POST['comment_parent_id'],
$_POST['task_id']
);
$return_message = array(
'type' => 'confirmation',
'message' => get_lang('CommentCreated')
);
} }
if (!empty($_POST['register'])) if (!empty($_POST['register'])) {
{
if (is_array($_POST['user'])) { if (is_array($_POST['user'])) {
foreach ($_POST['user'] as $index => $user_id) foreach ($_POST['user'] as $index => $user_id) {
{
Blog :: set_user_subscribed((int)$_GET['blog_id'], $user_id); Blog :: set_user_subscribed((int)$_GET['blog_id'], $user_id);
} }
} }
} }
if (!empty($_POST['unregister'])) if (!empty($_POST['unregister'])) {
{
if (is_array($_POST['user'])) { if (is_array($_POST['user'])) {
foreach ($_POST['user'] as $index => $user_id) foreach ($_POST['user'] as $index => $user_id) {
{
Blog :: set_user_unsubscribed((int)$_GET['blog_id'], $user_id); Blog :: set_user_unsubscribed((int)$_GET['blog_id'], $user_id);
} }
} }
} }
if (!empty($_GET['register'])) if (!empty($_GET['register'])) {
{
Blog :: set_user_subscribed((int)$_GET['blog_id'], (int)$_GET['user_id']); Blog :: set_user_subscribed((int)$_GET['blog_id'], (int)$_GET['user_id']);
$return_message = array('type' => 'confirmation', 'message' => get_lang('UserRegistered')); $return_message = array('type' => 'confirmation', 'message' => get_lang('UserRegistered'));
$flag = 1; $flag = 1;
} }
if (!empty($_GET['unregister'])) if (!empty($_GET['unregister'])) {
{
Blog :: set_user_unsubscribed((int)$_GET['blog_id'], (int)$_GET['user_id']); Blog :: set_user_unsubscribed((int)$_GET['blog_id'], (int)$_GET['user_id']);
} }
if (isset($_GET['action']) && $_GET['action'] == 'manage_tasks') { if (isset($_GET['action']) && $_GET['action'] == 'manage_tasks') {
if (isset($_GET['do']) && $_GET['do'] == 'delete') if (isset($_GET['do']) && $_GET['do'] == 'delete') {
{
Blog :: delete_task($blog_id, (int)$_GET['task_id']); Blog :: delete_task($blog_id, (int)$_GET['task_id']);
$return_message = array('type' => 'confirmation', 'message' => get_lang('TaskDeleted')); $return_message = array('type' => 'confirmation', 'message' => get_lang('TaskDeleted'));
} }
@ -138,54 +179,40 @@ if (isset($_GET['action']) && $_GET['action'] == 'manage_tasks') {
Blog :: delete_assigned_task($blog_id, intval($_GET['task_id']), intval($_GET['user_id'])); Blog :: delete_assigned_task($blog_id, intval($_GET['task_id']), intval($_GET['user_id']));
$return_message = array('type' => 'confirmation', 'message' => get_lang('TaskAssignmentDeleted')); $return_message = array('type' => 'confirmation', 'message' => get_lang('TaskAssignmentDeleted'));
} }
} }
if (isset($_GET['action']) && $_GET['action'] == 'view_post') { if (isset($_GET['action']) && $_GET['action'] == 'view_post') {
$task_id = (isset ($_GET['task_id']) && is_numeric($_GET['task_id'])) ? $_GET['task_id'] : 0; $task_id = (isset ($_GET['task_id']) && is_numeric($_GET['task_id'])) ? $_GET['task_id'] : 0;
if (isset($_GET['do']) && $_GET['do'] == 'delete_comment') if (isset($_GET['do']) && $_GET['do'] == 'delete_comment') {
{ if (api_is_allowed('BLOG_'.$blog_id, 'article_comments_delete', $task_id)) {
if (api_is_allowed('BLOG_'.$blog_id, 'article_comments_delete', $task_id))
{
Blog :: delete_comment($blog_id, (int)$_GET['post_id'],(int)$_GET['comment_id']); Blog :: delete_comment($blog_id, (int)$_GET['post_id'],(int)$_GET['comment_id']);
$return_message = array('type' => 'confirmation', 'message' => get_lang('CommentDeleted')); $return_message = array('type' => 'confirmation', 'message' => get_lang('CommentDeleted'));
} } else {
else
{
$error = true; $error = true;
$message = get_lang('ActionNotAllowed'); $message = get_lang('ActionNotAllowed');
} }
} }
if (isset($_GET['do']) && $_GET['do'] == 'delete_article') if (isset($_GET['do']) && $_GET['do'] == 'delete_article') {
{ if (api_is_allowed('BLOG_'.$blog_id, 'article_delete', $task_id)) {
if (api_is_allowed('BLOG_'.$blog_id, 'article_delete', $task_id))
{
Blog :: delete_post($blog_id, (int)$_GET['article_id']); Blog :: delete_post($blog_id, (int)$_GET['article_id']);
$current_page = ''; // Article is gone, go to blog home $action = ''; // Article is gone, go to blog home
$return_message = array('type' => 'confirmation', 'message' => get_lang('BlogDeleted')); $return_message = array('type' => 'confirmation', 'message' => get_lang('BlogDeleted'));
} } else {
else
{
$error = true; $error = true;
$message = get_lang('ActionNotAllowed'); $message = get_lang('ActionNotAllowed');
} }
} }
if (isset($_GET['do']) && $_GET['do'] == 'rate') if (isset($_GET['do']) && $_GET['do'] == 'rate') {
{ if (isset($_GET['type']) && $_GET['type'] == 'post') {
if (isset($_GET['type']) && $_GET['type'] == 'post') if (api_is_allowed('BLOG_'.$blog_id, 'article_rate')) {
{
if (api_is_allowed('BLOG_'.$blog_id, 'article_rate'))
{
Blog :: add_rating('post', $blog_id, (int)$_GET['post_id'], (int)$_GET['rating']); Blog :: add_rating('post', $blog_id, (int)$_GET['post_id'], (int)$_GET['rating']);
$return_message = array('type' => 'confirmation', 'message' => get_lang('RatingAdded')); $return_message = array('type' => 'confirmation', 'message' => get_lang('RatingAdded'));
} }
} }
if (isset($_GET['type']) && $_GET['type'] == 'comment') if (isset($_GET['type']) && $_GET['type'] == 'comment') {
{ if (api_is_allowed('BLOG_'.$blog_id, 'article_comments_add')) {
if (api_is_allowed('BLOG_'.$blog_id, 'article_comments_add'))
{
Blog :: add_rating('comment', $blog_id, (int)$_GET['comment_id'], (int)$_GET['rating']); Blog :: add_rating('comment', $blog_id, (int)$_GET['comment_id'], (int)$_GET['rating']);
$return_message = array('type' => 'confirmation', 'message' => get_lang('RatingAdded')); $return_message = array('type' => 'confirmation', 'message' => get_lang('RatingAdded'));
} }
@ -198,7 +225,7 @@ if (isset($_GET['action']) && $_GET['action'] == 'view_post') {
$htmlHeadXtra[] = '<script src="tbl_change.js" type="text/javascript"></script>'; $htmlHeadXtra[] = '<script src="tbl_change.js" type="text/javascript"></script>';
// Set bredcrumb // Set bredcrumb
switch ($current_page) { switch ($action) {
case 'new_post' : case 'new_post' :
$nameTools = get_lang('NewPost'); $nameTools = get_lang('NewPost');
$interbreadcrumb[] = array ('url' => "blog.php?blog_id=$blog_id", "name" => Blog :: get_blog_title($blog_id)); $interbreadcrumb[] = array ('url' => "blog.php?blog_id=$blog_id", "name" => Blog :: get_blog_title($blog_id));
@ -244,7 +271,6 @@ if (!empty($return_message)) {
} }
} }
// actions // actions
echo '<div class=actions>'; echo '<div class=actions>';
?> ?>
@ -258,7 +284,6 @@ echo '</div>';
// Tool introduction // Tool introduction
Display::display_introduction_section(TOOL_BLOGS); Display::display_introduction_section(TOOL_BLOGS);
//Display::display_header($nameTools,'Blogs');
?> ?>
<div class="sectiontitle"><?php echo Blog::get_blog_title($blog_id); ?></div> <div class="sectiontitle"><?php echo Blog::get_blog_title($blog_id); ?></div>
<div class="sectioncomment"><?php echo Blog::get_blog_subtitle($blog_id); ?></div> <div class="sectioncomment"><?php echo Blog::get_blog_subtitle($blog_id); ?></div>
@ -309,7 +334,7 @@ if (isset($error)) {
} }
if (isset($flag) && $flag == '1') { if (isset($flag) && $flag == '1') {
$current_page = "manage_tasks"; $action = "manage_tasks";
Blog :: display_assign_task_form($blog_id); Blog :: display_assign_task_form($blog_id);
} }
@ -338,13 +363,13 @@ if (isset ($_GET['task_id']) && is_numeric($_GET['task_id'])) {
$user_task = true; $user_task = true;
} }
switch ($current_page) { switch ($action) {
case 'new_post' : case 'new_post':
if (api_is_allowed('BLOG_'.$blog_id, 'article_add', $user_task ? $task_id : 0)) { if (api_is_allowed('BLOG_'.$blog_id, 'article_add', $user_task ? $task_id : 0)) {
// we show the form if // we show the form if
// 1. no post data // 1. no post data
// 2. there is post data and the required field is empty // 2. there is post data and the required field is empty
if (!$_POST OR (!empty($_POST) AND empty($_POST['post_title']))) { if (!$_POST OR (!empty($_POST) AND empty($_POST['title']))) {
// if there is post data there is certainly an error in the form // if there is post data there is certainly an error in the form
if ($_POST) { if ($_POST) {
Display::display_error_message(get_lang('FormHasErrorsPleaseComplete')); Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'));

@ -1,5 +1,6 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
/** /**
* BLOG HOMEPAGE * BLOG HOMEPAGE
* This file takes care of all blog navigation and displaying. * This file takes care of all blog navigation and displaying.
@ -52,22 +53,15 @@ if (api_is_allowed_to_edit()) {
Display::return_icon('new_blog.png',get_lang('AddBlog'),'',ICON_SIZE_MEDIUM)."</a>"; Display::return_icon('new_blog.png',get_lang('AddBlog'),'',ICON_SIZE_MEDIUM)."</a>";
echo '</div>'; echo '</div>';
/*
PROCESSING..
*/
$get_blog_name = Security::remove_XSS($_POST['blog_name']);
$get_blog_subtitle = Security::remove_XSS($_POST['blog_subtitle']);
$get_blog_id = Security::remove_XSS($_POST['blog_id']);
if (!empty($_POST['new_blog_submit']) AND !empty($_POST['blog_name'])) { if (!empty($_POST['new_blog_submit']) AND !empty($_POST['blog_name'])) {
if (isset($_POST['blog_name'])) { if (isset($_POST['blog_name'])) {
Blog::create_blog($get_blog_name,$get_blog_subtitle); Blog::create_blog($_POST['blog_name'], $_POST['blog_subtitle']);
Display::display_confirmation_message(get_lang('BlogStored')); Display::display_confirmation_message(get_lang('BlogStored'));
} }
} }
if (!empty($_POST['edit_blog_submit']) AND !empty($_POST['blog_name'])) { if (!empty($_POST['edit_blog_submit']) AND !empty($_POST['blog_name'])) {
if (strlen(trim($_POST['blog_name']))>0) { if (strlen(trim($_POST['blog_name']))>0) {
Blog::edit_blog($get_blog_id,$get_blog_name,$get_blog_subtitle); Blog::edit_blog($_POST['blog_id'], $_POST['blog_name'], $_POST['blog_subtitle']);
Display::display_confirmation_message(get_lang('BlogEdited')); Display::display_confirmation_message(get_lang('BlogEdited'));
} }
} }
@ -94,11 +88,11 @@ if (api_is_allowed_to_edit()) {
/*if ($_POST){ /*if ($_POST){
Display::display_error_message(get_lang('FormHasErrorsPleaseComplete')); Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'));
}*/ }*/
if (strlen($_POST['blog_name'])==0) { /*if (strlen($_POST['blog_name'])==0) {
if (count($_POST)>0) { if (count($_POST)>0) {
Display::display_error_message(get_lang('FormHasErrorsPleaseComplete')); Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'));
} }
} }*/
Blog::display_new_blog_form(); Blog::display_new_blog_form();
} }
} }

@ -70,7 +70,7 @@ class CourseDescriptionForm extends \FormValidator
$defaults['title'] = $description->title; $defaults['title'] = $description->title;
$defaults['content'] = $description->content; $defaults['content'] = $description->content;
$this->add_header($description->get_title()); $this->addHeader($description->get_title());
$this->addHidden('description_type', $description->get_description_type()); $this->addHidden('description_type', $description->get_description_type());
$this->addHidden('c_id', $description->c_id); $this->addHidden('c_id', $description->c_id);
$this->addHidden('id', $description->id); $this->addHidden('id', $description->id);

@ -33,7 +33,7 @@ class UploadFileForm extends \FormValidator
function init() function init()
{ {
$form_name = get_lang('UploadFile'); $form_name = get_lang('UploadFile');
$this->add_header($form_name); $this->addHeader($form_name);
$label = get_lang('File'); $label = get_lang('File');
$this->add_file('file', $label); $this->add_file('file', $label);

@ -74,7 +74,7 @@ class GlossaryForm extends \FormValidator
$this->addHidden(Request::PARAM_SEC_TOKEN, Access::instance()->get_token()); $this->addHidden(Request::PARAM_SEC_TOKEN, Access::instance()->get_token());
$form_name = $glossary->id ? get_lang('TermEdit') : get_lang('TermAddNew'); $form_name = $glossary->id ? get_lang('TermEdit') : get_lang('TermAddNew');
$this->add_header($form_name); $this->addHeader($form_name);
$this->add_textfield('name', get_lang('TermName'), $required = true, array('class' => 'span3')); $this->add_textfield('name', get_lang('TermName'), $required = true, array('class' => 'span3'));
$this->add_html_editor('description', get_lang('TermDefinition'), true, array('ToolbarSet' => 'Glossary', 'Width' => '90%', 'Height' => '300')); $this->add_html_editor('description', get_lang('TermDefinition'), true, array('ToolbarSet' => 'Glossary', 'Width' => '90%', 'Height' => '300'));

@ -42,7 +42,7 @@ class UploadFileForm extends \FormValidator
function init() function init()
{ {
$form_name = get_lang('ImportGlossary'); $form_name = get_lang('ImportGlossary');
$this->add_header($form_name); $this->addHeader($form_name);
$this->addHidden(Request::PARAM_SEC_TOKEN, Access::instance()->get_token()); $this->addHidden(Request::PARAM_SEC_TOKEN, Access::instance()->get_token());
$label = get_lang('ImportCSVFileLocation'); $label = get_lang('ImportCSVFileLocation');

@ -15,7 +15,8 @@
* Class * Class
* @package chamilo.blogs * @package chamilo.blogs
*/ */
class Blog { class Blog
{
/** /**
* Get the title of a blog * Get the title of a blog
* @author Toon Keppens * @author Toon Keppens
@ -227,19 +228,18 @@ class Blog {
* @param String $full_text * @param String $full_text
* @param Integer $blog_id * @param Integer $blog_id
*/ */
public static function create_post ($title, $full_text, $file_comment, $blog_id) { public static function create_post($title, $full_text, $file_comment, $blog_id)
global $_user; {
global $_course; $_user = api_get_user_info();
$_course = api_get_course_info();
$course_id = api_get_course_int_id();
$blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT);
$upload_ok=true; $upload_ok=true;
$has_attachment=false; $has_attachment=false;
$current_date=date('Y-m-d H:i:s',time()); $current_date = api_get_utc_datetime();
$course_id = api_get_course_int_id();
if(!empty($_FILES['user_upload']['name'])) { if (!empty($_FILES['user_upload']['name'])) {
$upload_ok = process_uploaded_file($_FILES['user_upload']); $upload_ok = process_uploaded_file($_FILES['user_upload']);
$has_attachment=true; $has_attachment=true;
} }
@ -270,16 +270,16 @@ class Blog {
Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension')); Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension'));
} else { } else {
$new_file_name = uniqid(''); $new_file_name = uniqid('');
$new_path=$updir.'/'.$new_file_name; $new_path = $updir.'/'.$new_file_name;
$result= @move_uploaded_file($_FILES['user_upload']['tmp_name'], $new_path); $result= @move_uploaded_file($_FILES['user_upload']['tmp_name'], $new_path);
$comment=Database::escape_string($file_comment); $comment = Database::escape_string($file_comment);
// Storing the attachments if any // Storing the attachments if any
if ($result) { if ($result) {
$sql='INSERT INTO '.$blog_table_attachment.'(c_id, filename,comment, path, post_id,size, blog_id,comment_id) '. $sql = 'INSERT INTO '.$blog_table_attachment.'(c_id, filename,comment, path, post_id,size, blog_id,comment_id) '.
"VALUES ($course_id, '".Database::escape_string($file_name)."', '".$comment."', '".Database::escape_string($new_file_name)."' , '".$last_post_id."', '".intval($_FILES['user_upload']['size'])."', '".$blog_id."', '0' )"; "VALUES ($course_id, '".Database::escape_string($file_name)."', '".$comment."', '".Database::escape_string($new_file_name)."' , '".$last_post_id."', '".intval($_FILES['user_upload']['size'])."', '".$blog_id."', '0' )";
$result=Database::query($sql); Database::query($sql);
$message.=' / '.get_lang('AttachmentUpload'); //Display::display_confirmation_message(get_lang('AttachmentUpload'));
} }
} }
} }
@ -346,9 +346,10 @@ class Blog {
* @param Integer $post_id * @param Integer $post_id
* @param Integer $parent_id * @param Integer $parent_id
*/ */
public static function create_comment($title, $full_text, $file_comment,$blog_id, $post_id, $parent_id, $task_id = 'NULL') { public static function create_comment($title, $full_text, $file_comment, $blog_id, $post_id, $parent_id, $task_id = 'NULL')
global $_user; {
global $_course; $_user = api_get_user_info();
$_course = api_get_course_info();
global $blog_table_attachment; global $blog_table_attachment;
$upload_ok = true; $upload_ok = true;
@ -356,7 +357,7 @@ class Blog {
$current_date = date('Y-m-d H:i:s',time()); $current_date = date('Y-m-d H:i:s',time());
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
if(!empty($_FILES['user_upload']['name'])) { if (!empty($_FILES['user_upload']['name'])) {
$upload_ok = process_uploaded_file($_FILES['user_upload']); $upload_ok = process_uploaded_file($_FILES['user_upload']);
$has_attachment=true; $has_attachment=true;
} }
@ -371,10 +372,7 @@ class Blog {
Database::query($sql); Database::query($sql);
// Empty post values, or they are shown on the page again // Empty post values, or they are shown on the page again
$_POST['comment_title'] = ""; $last_id = Database::insert_id();
$_POST['comment_text'] = "";
$last_id=Database::insert_id();
if ($has_attachment) { if ($has_attachment) {
$courseDir = $_course['path'].'/upload/blog'; $courseDir = $_course['path'].'/upload/blog';
@ -382,29 +380,28 @@ class Blog {
$updir = $sys_course_path.$courseDir; $updir = $sys_course_path.$courseDir;
// Try to add an extension to the file if it hasn't one // Try to add an extension to the file if it hasn't one
$new_file_name = add_ext_on_mime(stripslashes($_FILES['user_upload']['name']), $_FILES['user_upload']['type']); $new_file_name = add_ext_on_mime(
stripslashes($_FILES['user_upload']['name']),
$_FILES['user_upload']['type']
);
// user's file name // user's file name
$file_name =$_FILES['user_upload']['name']; $file_name =$_FILES['user_upload']['name'];
if (!filter_extension($new_file_name)) if (!filter_extension($new_file_name)) {
{
Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension')); Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension'));
} } else {
else
{
$new_file_name = uniqid(''); $new_file_name = uniqid('');
$new_path=$updir.'/'.$new_file_name; $new_path=$updir.'/'.$new_file_name;
$result= @move_uploaded_file($_FILES['user_upload']['tmp_name'], $new_path); $result= @move_uploaded_file($_FILES['user_upload']['tmp_name'], $new_path);
$comment=Database::escape_string($file_comment); $comment = Database::escape_string($file_comment);
// Storing the attachments if any // Storing the attachments if any
if ($result) if ($result) {
{
$sql='INSERT INTO '.$blog_table_attachment.'(c_id, filename,comment, path, post_id,size,blog_id,comment_id) '. $sql='INSERT INTO '.$blog_table_attachment.'(c_id, filename,comment, path, post_id,size,blog_id,comment_id) '.
"VALUES ($course_id, '".Database::escape_string($file_name)."', '".$comment."', '".Database::escape_string($new_file_name)."' , '".$post_id."', '".$_FILES['user_upload']['size']."', '".$blog_id."', '".$last_id."' )"; "VALUES ($course_id, '".Database::escape_string($file_name)."', '".$comment."', '".Database::escape_string($new_file_name)."' , '".$post_id."', '".$_FILES['user_upload']['size']."', '".$blog_id."', '".$last_id."' )";
$result=Database::query($sql); Database::query($sql);
$message.=' / '.get_lang('AttachmentUpload'); //$message.=' / '.get_lang('AttachmentUpload');
} }
} }
} }
@ -417,24 +414,25 @@ class Blog {
* @param Integer $blog_id * @param Integer $blog_id
* @param Integer $comment_id * @param Integer $comment_id
*/ */
public static function delete_comment ($blog_id, $post_id, $comment_id) { public static function delete_comment ($blog_id, $post_id, $comment_id)
// Init {
$tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS);
$tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING);
$blog_id = intval($blog_id); $blog_id = intval($blog_id);
$post_id = intval($post_id); $post_id = intval($post_id);
$comment_id = intval($comment_id); $comment_id = intval($comment_id);
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
delete_all_blog_attachment($blog_id,$post_id,$comment_id); delete_all_blog_attachment($blog_id, $post_id, $comment_id);
// Delete ratings on this comment // Delete ratings on this comment
$sql = "DELETE FROM $tbl_blogs_rating WHERE c_id = $course_id AND blog_id = '".(int)$blog_id."' AND item_id = '".(int)$comment_id."' AND rating_type = 'comment'"; $sql = "DELETE FROM $tbl_blogs_rating
WHERE c_id = $course_id AND blog_id = '".$blog_id."' AND item_id = '".$comment_id."' AND rating_type = 'comment'";
Database::query($sql); Database::query($sql);
// select comments that have the selected comment as their parent // select comments that have the selected comment as their parent
$sql = "SELECT comment_id FROM $tbl_blogs_comments WHERE c_id = $course_id AND parent_comment_id = '".(int)$comment_id."'"; $sql = "SELECT comment_id FROM $tbl_blogs_comments
WHERE c_id = $course_id AND parent_comment_id = '".$comment_id."'";
$result = Database::query($sql); $result = Database::query($sql);
// Delete them recursively // Delete them recursively
@ -443,7 +441,8 @@ class Blog {
} }
// Finally, delete the selected comment to // Finally, delete the selected comment to
$sql = "DELETE FROM $tbl_blogs_comments WHERE c_id = $course_id AND comment_id = '".(int)$comment_id."'"; $sql = "DELETE FROM $tbl_blogs_comments
WHERE c_id = $course_id AND comment_id = '".$comment_id."'";
Database::query($sql); Database::query($sql);
} }
@ -455,7 +454,8 @@ class Blog {
* @param String $description * @param String $description
* @param String $color * @param String $color
*/ */
public static function create_task ($blog_id, $title, $description, $articleDelete, $articleEdit, $commentsDelete, $color) { public static function create_task ($blog_id, $title, $description, $articleDelete, $articleEdit, $commentsDelete, $color)
{
// Init // Init
$tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
$tbl_tasks_permissions = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS); $tbl_tasks_permissions = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS);
@ -491,7 +491,7 @@ class Blog {
Database::query($sql); Database::query($sql);
} }
if($commentsDelete == 'on') { if ($commentsDelete == 'on') {
$sql = " $sql = "
INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action ) VALUES ( INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action ) VALUES (
'" . (int)$course_id . "', '" . (int)$course_id . "',
@ -512,14 +512,13 @@ class Blog {
* @param String $description * @param String $description
* @param String $color * @param String $color
*/ */
public static function edit_task($blog_id, $task_id, $title, $description, $articleDelete, $articleEdit, $commentsDelete, $color) { public static function edit_task($blog_id, $task_id, $title, $description, $articleDelete, $articleEdit, $commentsDelete, $color)
// Init {
$tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
$tbl_tasks_permissions = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS); $tbl_tasks_permissions = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS);
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
// Create the task // Create the task
$sql = "UPDATE $tbl_blogs_tasks SET $sql = "UPDATE $tbl_blogs_tasks SET
title = '".Database::escape_string($title)."', title = '".Database::escape_string($title)."',
@ -530,7 +529,8 @@ class Blog {
$tool = 'BLOG_' . $blog_id; $tool = 'BLOG_' . $blog_id;
$sql = "DELETE FROM " . $tbl_tasks_permissions . " WHERE c_id = $course_id AND task_id = '" . (int)$task_id."'"; $sql = "DELETE FROM " . $tbl_tasks_permissions . "
WHERE c_id = $course_id AND task_id = '" . (int)$task_id."'";
Database::query($sql); Database::query($sql);
if ($articleDelete == 'on') { if ($articleDelete == 'on') {
@ -575,7 +575,8 @@ class Blog {
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
// Delete posts // Delete posts
$sql = "DELETE FROM $tbl_blogs_tasks WHERE c_id = $course_id AND blog_id = '".(int)$blog_id."' AND task_id = '".(int)$task_id."'"; $sql = "DELETE FROM $tbl_blogs_tasks
WHERE c_id = $course_id AND blog_id = '".(int)$blog_id."' AND task_id = '".(int)$task_id."'";
Database::query($sql); Database::query($sql);
} }
@ -584,12 +585,14 @@ class Blog {
* @param Integer $blog_id * @param Integer $blog_id
* @param Integer $assignment_id * @param Integer $assignment_id
*/ */
public static function delete_assigned_task ($blog_id, $task_id,$user_id) { public static function delete_assigned_task ($blog_id, $task_id, $user_id)
{
$tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
// Delete posts // Delete posts
$sql = "DELETE FROM $tbl_blogs_tasks_rel_user WHERE c_id = $course_id AND blog_id = '".(int)$blog_id."' AND task_id = '".(int)$task_id."' AND user_id = '".(int)$user_id."'"; $sql = "DELETE FROM $tbl_blogs_tasks_rel_user
WHERE c_id = $course_id AND blog_id = '".(int)$blog_id."' AND task_id = '".(int)$task_id."' AND user_id = '".(int)$user_id."'";
Database::query($sql); Database::query($sql);
} }
@ -628,17 +631,12 @@ class Blog {
echo '<li><a href="blog.php?action=execute_task&amp;blog_id=' . $mytask['blog_id'] . '&amp;task_id='.stripslashes($mytask['task_id']) . '" title="[Blog: '.stripslashes($mytask['blog_name']) . '] ' . get_lang('ExecuteThisTask') . '">'.stripslashes($mytask['title']) . '</a></li>'; echo '<li><a href="blog.php?action=execute_task&amp;blog_id=' . $mytask['blog_id'] . '&amp;task_id='.stripslashes($mytask['task_id']) . '" title="[Blog: '.stripslashes($mytask['blog_name']) . '] ' . get_lang('ExecuteThisTask') . '">'.stripslashes($mytask['title']) . '</a></li>';
} }
echo '<ul>'; echo '<ul>';
} } else {
else
{
echo get_lang('NoTasks'); echo get_lang('NoTasks');
} }
} } else {
else
{
echo get_lang('NoTasks'); echo get_lang('NoTasks');
} }
} }
/** /**
@ -646,14 +644,16 @@ class Blog {
* @author Toon Keppens * @author Toon Keppens
* @param Integer $blog_id * @param Integer $blog_id
*/ */
public static function change_blog_visibility ($blog_id) { public static function change_blog_visibility($blog_id)
{
// Init // Init
$tbl_blogs = Database::get_course_table(TABLE_BLOGS); $tbl_blogs = Database::get_course_table(TABLE_BLOGS);
$tbl_tool = Database::get_course_table(TABLE_TOOL_LIST); $tbl_tool = Database::get_course_table(TABLE_TOOL_LIST);
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
// Get blog properties // Get blog properties
$sql = "SELECT blog_name, visibility FROM $tbl_blogs WHERE c_id = $course_id AND blog_id='".(int)$blog_id."'"; $sql = "SELECT blog_name, visibility FROM $tbl_blogs
WHERE c_id = $course_id AND blog_id='".(int)$blog_id."'";
$result = Database::query($sql); $result = Database::query($sql);
$blog = Database::fetch_array($result); $blog = Database::fetch_array($result);
$visibility = $blog['visibility']; $visibility = $blog['visibility'];
@ -672,11 +672,11 @@ class Blog {
{ {
// Change visibility state, add to course home. // Change visibility state, add to course home.
$sql = "UPDATE $tbl_blogs SET visibility = '1' WHERE c_id = $course_id AND blog_id ='".(int)$blog_id."' LIMIT 1"; $sql = "UPDATE $tbl_blogs SET visibility = '1' WHERE c_id = $course_id AND blog_id ='".(int)$blog_id."' LIMIT 1";
$result = Database::query($sql); Database::query($sql);
$sql = "INSERT INTO $tbl_tool (c_id, name, link, image, visibility, admin, address, added_tool, target ) $sql = "INSERT INTO $tbl_tool (c_id, name, link, image, visibility, admin, address, added_tool, target )
VALUES ($course_id, '".Database::escape_string($title)."', 'blog/blog.php?blog_id=".(int)$blog_id."', 'blog.gif', '1', '0', 'pastillegris.gif', '0', '_self')"; VALUES ($course_id, '".Database::escape_string($title)."', 'blog/blog.php?blog_id=".(int)$blog_id."', 'blog.gif', '1', '0', 'pastillegris.gif', '0', '_self')";
$result = Database::query($sql); Database::query($sql);
} }
} }
@ -720,8 +720,6 @@ class Blog {
$blog_post_date = api_convert_and_format_date($blog_post['date_creation'], null, date_default_timezone_get()); $blog_post_date = api_convert_and_format_date($blog_post['date_creation'], null, date_default_timezone_get());
// Create an introduction text (but keep FULL sentences) // Create an introduction text (but keep FULL sentences)
$introduction_text = "";
$words = 0; $words = 0;
$blog_post_text_cut = cut($blog_post_text, $limit) ; $blog_post_text_cut = cut($blog_post_text, $limit) ;
$words = strlen($blog_post_text); $words = strlen($blog_post_text);
@ -742,8 +740,7 @@ class Blog {
echo '<div class="blogpost_introduction" id="blogpost_introduction_'.$blog_post_id.'">' . $introduction_text.$readMoreLink.'</div>'; echo '<div class="blogpost_introduction" id="blogpost_introduction_'.$blog_post_id.'">' . $introduction_text.$readMoreLink.'</div>';
echo '<div class="blogpost_text" id="blogpost_text_' . $blog_post_id . '" style="display: none">' . $blog_post_text . '</div>'; echo '<div class="blogpost_text" id="blogpost_text_' . $blog_post_id . '" style="display: none">' . $blog_post_text . '</div>';
$file_name_array = get_blog_attachment($blog_id,$blog_post_id,0);
$file_name_array=get_blog_attachment($blog_id,$blog_post_id,0);
if (!empty($file_name_array)) { if (!empty($file_name_array)) {
echo '<br /><br />'; echo '<br /><br />';
@ -1107,24 +1104,26 @@ class Blog {
* *
* @param Integer $blog_id * @param Integer $blog_id
*/ */
public static function display_form_new_post ($blog_id) public static function display_form_new_post($blog_id)
{ {
if (api_is_allowed('BLOG_' . $blog_id, 'article_add')) { if (api_is_allowed('BLOG_' . $blog_id, 'article_add')) {
$form = new FormValidator( $form = new FormValidator(
'add_post', 'add_post',
'post', 'post',
api_get_path(WEB_CODE_PATH)."blog/blog.php?action=new_post&blog_id=" . $blog_id . "&" . api_get_cidreq() api_get_path(WEB_CODE_PATH)."blog/blog.php?action=new_post&blog_id=" . $blog_id . "&" . api_get_cidreq(),
null,
array('enctype' => 'multipart/form-data')
); );
$form->addHidden('post_title_edited', 'false'); $form->addHidden('post_title_edited', 'false');
$form->add_header(get_lang('NewPost')); $form->addHeader(get_lang('NewPost'));
$form->add_textfield('post_title', get_lang('Title')); $form->add_textfield('title', get_lang('Title'));
$config = array(); $config = array();
if (!api_is_allowed_to_edit()) { if (!api_is_allowed_to_edit()) {
$config['ToolbarSet'] = 'ProjectStudent'; $config['ToolbarSet'] = 'ProjectStudent';
} else { } else {
$config['ToolbarSet'] = 'Project'; $config['ToolbarSet'] = 'Project';
} }
$form->add_html_editor('post_full_text', get_lang('Content'), false, false, $config); $form->add_html_editor('full_text', get_lang('Content'), false, false, $config);
$form->add_file('user_upload', get_lang('AddAnAttachment')); $form->add_file('user_upload', get_lang('AddAnAttachment'));
$form->add_textarea('post_file_comment', get_lang('FileComment')); $form->add_textarea('post_file_comment', get_lang('FileComment'));
$form->addHidden('new_post_submit', 'true'); $form->addHidden('new_post_submit', 'true');
@ -1142,16 +1141,16 @@ class Blog {
* *
* @param Integer $blog_id * @param Integer $blog_id
*/ */
public static function display_form_edit_post ($blog_id, $post_id) public static function display_form_edit_post($blog_id, $post_id)
{ {
// Init
$tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
$tbl_users = Database::get_main_table(TABLE_MAIN_USER); $tbl_users = Database::get_main_table(TABLE_MAIN_USER);
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
// Get posts and author // Get posts and author
$sql = "SELECT post.*, user.lastname, user.firstname FROM $tbl_blogs_posts post $sql = "SELECT post.*, user.lastname, user.firstname
FROM $tbl_blogs_posts post
INNER JOIN $tbl_users user ON post.author_id = user.user_id INNER JOIN $tbl_users user ON post.author_id = user.user_id
WHERE WHERE
post.c_id = $course_id AND post.c_id = $course_id AND
@ -1161,48 +1160,30 @@ class Blog {
$result = Database::query($sql); $result = Database::query($sql);
$blog_post = Database::fetch_array($result); $blog_post = Database::fetch_array($result);
// Prepare data // Form
$blog_post_text = stripslashes($blog_post['full_text']);
echo '<form name="edit_post" method="post" action="blog.php?action=edit_post&post_id=' . Security::remove_XSS($_GET['post_id']) . '&blog_id=' . Security::remove_XSS($blog_id) . '&article_id='.Security::remove_XSS($_GET['article_id']).'&task_id='.Security::remove_XSS($_GET['task_id']).'">';
// form title $form = new FormValidator(
echo '<legend>' . get_lang('EditPost') . '</legend>'; 'edit_post',
'post',
// article title api_get_path(WEB_CODE_PATH).'blog/blog.php?action=edit_post&post_id=' . intval($_GET['post_id']) . '&blog_id=' . intval($blog_id) . '&article_id='.intval($_GET['article_id']).'&task_id='.intval($_GET['task_id'])
echo '<div><span class="form_required">*</span>' . get_lang('Title') . ': <input name="post_title" id="post_title" type="text" size="60" value="'.stripslashes($blog_post['title']) . '" /><br /></div>'; );
// article text
//$oFCKeditor = new FCKeditor('post_full_text') ;
$oFCKeditor = new CKeditor();
$oFCKeditor->Width = '100%'; $form->addHeader(get_lang('EditPost'));
$oFCKeditor->Height = '200'; $form->add_textfield('title', get_lang('Title'));
if(!api_is_allowed_to_edit()) { if (!api_is_allowed_to_edit()) {
$oFCKeditor->ToolbarSet = 'Project_Student'; $config['ToolbarSet'] = 'ProjectStudent';
} else { } else {
$oFCKeditor->ToolbarSet = 'Project'; $config['ToolbarSet'] = 'Project';
} }
$oFCKeditor->Value = isset($_POST['post_full_text'])?stripslashes($_POST['post_full_text']):$blog_post_text; $form->add_html_editor('full_text', get_lang('Content'), false, false, $config);
echo '<div class="controls">';
//echo $oFCKeditor->Create();
$oFCKeditor->editor('post_full_text', $oFCKeditor->Value);
echo '</div>';
// submit
echo ' <div class="control-group">
<div class="controls"> $form->addHidden('action', '');
<input type="hidden" name="action" value="" /> $form->addHidden('edit_post_submit', 'true');
<input type="hidden" name="edit_post_submit" value="true" /> $form->addHidden('post_id', intval($_GET['post_id']));
<input type="hidden" name="post_id" value="' . (int)$_GET['post_id'] . '" /> $form->addButton('save', get_lang('Save'));
<button class="save" type="submit" name="Submit">' . get_lang('Save') . '</button> $form->setDefaults($blog_post);
</div> $form->display();
</div>';
echo '</form>';
} }
/** /**
@ -2221,75 +2202,45 @@ class Blog {
* *
* @param Integer $blog_id * @param Integer $blog_id
*/ */
public static function display_new_comment_form ($blog_id, $post_id, $title) { public static function display_new_comment_form($blog_id, $post_id, $title)
echo '<form name="add_post" enctype="multipart/form-data" method="post" action="blog.php?action=view_post&amp;blog_id=' . intval($blog_id) . '&amp;post_id=' . intval($post_id) . '">';
// form title
echo '<legend>';
echo (isset($_GET['task_id']) ? get_lang('ExecuteThisTask') : get_lang('AddNewComment'));
echo '</legend>';
// comment title
echo '<div><span class="form_required">*</span>' . get_lang('Title') . ': <input name="comment_title" id="comment_title" type="text" size="60" value="Re: '.stripslashes($title) . '" /></div><br />';
// comment text
//$oFCKeditor = new FCKeditor('comment_text') ;
$oFCKeditor = new CKeditor();
$oFCKeditor->Width = '100%';
$oFCKeditor->Height = '200';
if(!api_is_allowed_to_edit())
{ {
$oFCKeditor->ToolbarSet = 'Project_Comment_Student'; $form = new FormValidator(
'add_post',
'post',
api_get_path(WEB_CODE_PATH)."blog/blog.php?action=view_post&blog_id=" . intval($blog_id) . "&post_id=".intval($post_id)."&".api_get_cidreq(),
null,
array('enctype' => 'multipart/form-data')
);
$header = get_lang('AddNewComment');
if (isset($_GET['task_id'])) {
$header = get_lang('ExecuteThisTask');
} }
else $form->addHeader($header);
{ $form->add_textfield('title', get_lang('Title'));
$oFCKeditor->ToolbarSet = 'Project_Comment';
$config = array();
if (!api_is_allowed_to_edit()) {
$config['ToolbarSet'] = 'ProjectComment';
} else {
$config['ToolbarSet'] = 'ProjectCommentStudent';
} }
$oFCKeditor->Value = isset($_POST['comment_text'])?stripslashes($_POST['comment_text']):''; $form->add_html_editor('comment', get_lang('Comment'), false, false, $config);
echo '<div class="controls">'; $form->add_file('user_upload', get_lang('AddAnAttachment'));
//echo $oFCKeditor->Create() ;
$oFCKeditor->editor('comment_text');
echo '
</div>';
// attachment $form->add_textarea('post_file_comment', get_lang('FileComment'));
echo ' <div class="control-group">
<label class="control-label">
' . get_lang('AddAnAttachment') . '
</label>
<div class="controls">
<input type="file" name="user_upload"/>
</div>
</div>';
// attachment comment $form->addHidden('action', null);
echo ' <div class="control-group"> $form->addHidden('comment_parent_id', 0);
<label class="control-label">
' . get_lang('FileComment') . '
</label>
<div class="controls">
<textarea name="post_file_comment" cols="34" /></textarea>
</div>
</div>';
// attachment comment if (isset($_GET['task_id'])) {
echo ' <div class="control-group"> $form->addHidden('new_task_execution_submit', 'true');
<div class="controls"> $form->addHidden('task_id', intval($_GET['task_id']));
<input type="hidden" name="action" value="" /> } else {
<input type="hidden" name="comment_parent_id" id="comment_parent_id" value="0" />'; $form->addHidden('new_comment_submit', 'true');
if(isset($_GET['task_id']))
{
echo ' <input type="hidden" name="new_task_execution_submit" value="true" />';
echo ' <input type="hidden" name="task_id" value="' . intval($_GET['task_id']) . '" />';
}
else
{
echo ' <input type="hidden" name="new_comment_submit" value="true" />';
} }
echo ' <button class="save" type="submit" name="Submit">' . get_lang('Save') . '</button> $form->addButton('save', get_lang('Save'));
</div> $form->display();
</div>';
echo '</form>';
} }
@ -2305,7 +2256,8 @@ class Blog {
* *
* @return html code * @return html code
*/ */
public static function display_minimonthcalendar ($month, $year, $blog_id) { public static function display_minimonthcalendar ($month, $year, $blog_id)
{
// Init // Init
global $_user; global $_user;
global $DaysShort; global $DaysShort;
@ -2334,14 +2286,18 @@ class Blog {
//Start the week on monday //Start the week on monday
$startdayofweek = $dayone['wday'] <> 0 ? ($dayone['wday'] - 1) : 6; $startdayofweek = $dayone['wday'] <> 0 ? ($dayone['wday'] - 1) : 6;
$backwardsURL = api_get_self()."?blog_id=" . (int)$_GET['blog_id']."&amp;filter=" . Security::remove_XSS($_GET['filter'])."&amp;month=". ($month == 1 ? 12 : $month -1)."&amp;year=". ($month == 1 ? $year -1 : $year); $blogId = isset($_GET['blog_id']) ? intval($_GET['blog_id']) : null;
$forewardsURL = api_get_self()."?blog_id=" . (int)$_GET['blog_id']."&amp;filter=" . Security::remove_XSS($_GET['filter'])."&amp;month=". ($month == 12 ? 1 : $month +1)."&amp;year=". ($month == 12 ? $year +1 : $year); $filter = isset($_GET['filter']) ? Security::remove_XSS($_GET['filter']) : null;
$backwardsURL = api_get_self()."?blog_id=" . $blogId."&amp;filter=" . $filter."&amp;month=". ($month == 1 ? 12 : $month -1)."&amp;year=". ($month == 1 ? $year -1 : $year);
$forewardsURL = api_get_self()."?blog_id=" . $blogId."&amp;filter=" . $filter."&amp;month=". ($month == 12 ? 1 : $month +1)."&amp;year=". ($month == 12 ? $year +1 : $year);
// Get posts for this month // Get posts for this month
$sql = "SELECT post.*, DAYOFMONTH(date_creation) as post_day, user.lastname, user.firstname FROM $tbl_blogs_posts post $sql = "SELECT post.*, DAYOFMONTH(date_creation) as post_day, user.lastname, user.firstname
FROM $tbl_blogs_posts post
INNER JOIN $tbl_users user INNER JOIN $tbl_users user
ON post.author_id = user.user_id ON post.author_id = user.user_id
WHERE post.c_id = $course_id AND WHERE
post.c_id = $course_id AND
post.blog_id = '".(int)$blog_id."' AND post.blog_id = '".(int)$blog_id."' AND
MONTH(date_creation) = '".(int)$month."' AND MONTH(date_creation) = '".(int)$month."' AND
YEAR(date_creation) = '".(int)$year."' YEAR(date_creation) = '".(int)$year."'
@ -2461,9 +2417,9 @@ class Blog {
* Blog admin | Display the form to add a new blog. * Blog admin | Display the form to add a new blog.
* *
*/ */
public static function display_new_blog_form () { public static function display_new_blog_form()
{
$form = new FormValidator('add_blog', 'post','blog_admin.php?action=add'); $form = new FormValidator('add_blog', 'post', 'blog_admin.php?action=add');
$form->addElement('header', get_lang('AddBlog')); $form->addElement('header', get_lang('AddBlog'));
$form->addElement('text', 'blog_name', get_lang('Title')); $form->addElement('text', 'blog_name', get_lang('Title'));
$form->addElement('textarea', 'blog_subtitle', get_lang('Subtitle')); $form->addElement('textarea', 'blog_subtitle', get_lang('Subtitle'));
@ -2471,9 +2427,10 @@ class Blog {
$form->addElement('hidden', 'new_blog_submit', 'true'); $form->addElement('hidden', 'new_blog_submit', 'true');
$form->addElement('style_submit_button', null, get_lang('SaveProject')); $form->addElement('style_submit_button', null, get_lang('SaveProject'));
$defaults = array(); $defaults = array(
$defaults['blog_name'] = Security::remove_XSS($_POST['blog_name']); 'blog_name' => isset($_POST['blog_name']) ? Security::remove_XSS($_POST['blog_name']) : null,
$defaults['blog_subtitle'] = Security::remove_XSS($_POST['blog_subtitle']); 'blog_subtitle' => isset($_POST['blog_subtitle']) ? Security::remove_XSS($_POST['blog_subtitle']) : null
);
$form->setDefaults($defaults); $form->setDefaults($defaults);
$form->display(); $form->display();
} }
@ -2482,11 +2439,13 @@ class Blog {
* Blog admin | Display the form to edit a blog. * Blog admin | Display the form to edit a blog.
* *
*/ */
public static function display_edit_blog_form ($blog_id) { public static function display_edit_blog_form($blog_id)
{
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
$blog_id= intval($blog_id);
$tbl_blogs = Database::get_course_table(TABLE_BLOGS); $tbl_blogs = Database::get_course_table(TABLE_BLOGS);
$sql = "SELECT blog_id, blog_name, blog_subtitle FROM $tbl_blogs WHERE c_id = $course_id AND blog_id = '".(int)$blog_id."'"; $sql = "SELECT blog_id, blog_name, blog_subtitle FROM $tbl_blogs WHERE c_id = $course_id AND blog_id = '".$blog_id."'";
$result = Database::query($sql); $result = Database::query($sql);
$blog = Database::fetch_array($result); $blog = Database::fetch_array($result);
@ -2496,7 +2455,7 @@ class Blog {
$blog['blog_subtitle'] = Security::remove_XSS($_POST['blog_subtitle']); $blog['blog_subtitle'] = Security::remove_XSS($_POST['blog_subtitle']);
} }
$form = new FormValidator('edit_blog', 'post','blog_admin.php?action=edit&blog_id='.Security::remove_XSS($_GET['blog_id'])); $form = new FormValidator('edit_blog', 'post','blog_admin.php?action=edit&blog_id='.intval($_GET['blog_id']));
$form->addElement('header', get_lang('EditBlog')); $form->addElement('header', get_lang('EditBlog'));
$form->addElement('text', 'blog_name', get_lang('Title')); $form->addElement('text', 'blog_name', get_lang('Title'));
$form->addElement('textarea', 'blog_subtitle', get_lang('Subtitle')); $form->addElement('textarea', 'blog_subtitle', get_lang('Subtitle'));
@ -2527,21 +2486,24 @@ class Blog {
$session_id = api_get_session_id(); $session_id = api_get_session_id();
$condition_session = api_get_session_condition($session_id, false); $condition_session = api_get_session_condition($session_id, false);
$sql = "SELECT blog_name,blog_subtitle,visibility,blog_id FROM $tbl_blogs WHERE c_id = $course_id ORDER BY date_creation DESC"; $sql = "SELECT blog_name, blog_subtitle, visibility, blog_id, session_id
FROM $tbl_blogs WHERE c_id = $course_id
ORDER BY date_creation DESC";
$result = Database::query($sql); $result = Database::query($sql);
$list_info = array();
if (Database::num_rows($result)) { if (Database::num_rows($result)) {
while ($row_project=Database::fetch_row($result)) { while ($row_project=Database::fetch_row($result)) {
$list_info[]=$row_project; $list_info[]=$row_project;
} }
} }
$list_content_blog = array(); $list_content_blog = array();
$list_body_blog = array(); $list_body_blog = array();
$_user = api_get_user_info();
if (is_array($list_info)) { if (is_array($list_info)) {
foreach($list_info as $key => $info_log) { foreach ($list_info as $key => $info_log) {
//validacion when belongs to a session // Validation when belongs to a session
$session_img = api_get_session_image($info_log[4], $_user['status']); $session_img = api_get_session_image($info_log[4], $_user['status']);
$url_start_blog = 'blog.php' ."?". "blog_id=".$info_log[3]. "&amp;".api_get_cidreq(); $url_start_blog = 'blog.php' ."?". "blog_id=".$info_log[3]. "&amp;".api_get_cidreq();
@ -2554,19 +2516,18 @@ class Blog {
$visibility_icon=($info_log[2]==0) ? 'invisible' : 'visible'; $visibility_icon=($info_log[2]==0) ? 'invisible' : 'visible';
$visibility_info=($info_log[2]==0) ? 'Visible' : 'Invisible'; $visibility_info=($info_log[2]==0) ? 'Visible' : 'Invisible';
$my_image.='<a href="' .api_get_self(). '?action=edit&amp;blog_id=' . $info_log[3] . '">'; $my_image = '<a href="' .api_get_self(). '?action=edit&amp;blog_id=' . $info_log[3] . '">';
$my_image.='<img src="../img/edit.gif" border="0" title="' . get_lang('EditBlog') . '" />'; $my_image.= '<img src="../img/edit.gif" border="0" title="' . get_lang('EditBlog') . '" />';
$my_image.="</a>\n"; $my_image.= "</a>\n";
$my_image.='<a href="' .api_get_self(). '?action=delete&amp;blog_id=' . $info_log[3] . '" '; $my_image.= '<a href="' .api_get_self(). '?action=delete&amp;blog_id=' . $info_log[3] . '" ';
$my_image.='onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;" >'; $my_image.= 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;" >';
$my_image.='<img src="../img/delete.gif" border="0" title="' . get_lang('DeleteBlog') . '" />'; $my_image.= '<img src="../img/delete.gif" border="0" title="' . get_lang('DeleteBlog') . '" />';
$my_image.="</a>\n"; $my_image.= "</a>\n";
$my_image.='<a href="' .api_get_self(). '?action=visibility&amp;blog_id=' . $info_log[3] . '">'; $my_image.= '<a href="' .api_get_self(). '?action=visibility&amp;blog_id=' . $info_log[3] . '">';
$my_image.='<img src="../img/' . $visibility_icon . '.gif" border="0" title="' . get_lang($visibility_info) . '" />'; $my_image.= '<img src="../img/' . $visibility_icon . '.gif" border="0" title="' . get_lang($visibility_info) . '" />';
$my_image.="</a>\n"; $my_image.= "</a>\n";
$list_body_blog[]=$my_image; $list_body_blog[]=$my_image;
$my_image='';
$list_content_blog[]=$list_body_blog; $list_content_blog[]=$list_body_blog;
$list_body_blog = array(); $list_body_blog = array();

@ -1446,7 +1446,7 @@ class DocumentManager
} }
/** /**
* Allow to set a specific document as a new template for FCKEditor * Allow to set a specific document as a new template for CKeditor
* for a particular user in a particular course * for a particular user in a particular course
* *
* @param string $title * @param string $title

@ -345,7 +345,7 @@ EOT;
/** /**
* @param string $text * @param string $text
*/ */
public function add_header($text) public function addHeader($text)
{ {
$this->addElement('header', $text); $this->addElement('header', $text);
} }

@ -56,9 +56,7 @@ class CategoryForm extends \FormValidator
$this->addElement('hidden', 'session_id', $category->session_id); $this->addElement('hidden', 'session_id', $category->session_id);
$form_name = $category->id ? get_lang('ModifyCategory') : get_lang('AddCategory'); $form_name = $category->id ? get_lang('ModifyCategory') : get_lang('AddCategory');
$this->add_header($form_name); $this->addHeader($form_name);
$this->add_textfield('category_title', get_lang('Title')); $this->add_textfield('category_title', get_lang('Title'));
$this->addRule('category_title', get_lang('Required'), 'required'); $this->addRule('category_title', get_lang('Required'), 'required');

@ -63,8 +63,7 @@ class LinkForm extends \FormValidator
$this->add_hidden('session_id', $link->session_id); $this->add_hidden('session_id', $link->session_id);
$form_name = $category->id ? get_lang('LinkMod') : get_lang('LinkAdd'); $form_name = $category->id ? get_lang('LinkMod') : get_lang('LinkAdd');
$this->add_header($form_name); $this->addHeader($form_name);
$this->add_textfield('url', get_lang('Url'), $required = true, array('class' => 'span6')); $this->add_textfield('url', get_lang('Url'), $required = true, array('class' => 'span6'));
$this->addRule('url', get_lang('MalformedUrl'), 'regex', '|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i'); $this->addRule('url', get_lang('MalformedUrl'), 'regex', '|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i');

@ -33,7 +33,7 @@ class UploadFileForm extends \FormValidator
function init() function init()
{ {
$form_name = get_lang('UploadFile'); $form_name = get_lang('UploadFile');
$this->add_header($form_name); $this->addHeader($form_name);
$label = get_lang('File'); $label = get_lang('File');
$this->add_file('file', $label); $this->add_file('file', $label);

@ -67,7 +67,7 @@ class NotebookForm extends \FormValidator
$this->add_hidden(Request::PARAM_SEC_TOKEN, Access::instance()->get_token()); $this->add_hidden(Request::PARAM_SEC_TOKEN, Access::instance()->get_token());
$form_name = $notebook->id ? get_lang('ModifyNote') : get_lang('NoteAddNew'); $form_name = $notebook->id ? get_lang('ModifyNote') : get_lang('NoteAddNew');
$this->add_header($form_name); $this->addHeader($form_name);
$this->add_textfield('title', get_lang('NoteTitle'), $required = true, array('class' => 'span3')); $this->add_textfield('title', get_lang('NoteTitle'), $required = true, array('class' => 'span3'));

@ -35,7 +35,7 @@ class UploadFileForm extends \FormValidator
function init() function init()
{ {
$form_name = get_lang('Import'); $form_name = get_lang('Import');
$this->add_header($form_name); $this->addHeader($form_name);
$this->add_hidden(Request::PARAM_SEC_TOKEN, Access::instance()->get_token()); $this->add_hidden(Request::PARAM_SEC_TOKEN, Access::instance()->get_token());
$label = get_lang('File'); $label = get_lang('File');

Loading…
Cancel
Save