diff --git a/main/inc/lib/blog.lib.php b/main/inc/lib/blog.lib.php
index 0368a7998f..779f1e935d 100644
--- a/main/inc/lib/blog.lib.php
+++ b/main/inc/lib/blog.lib.php
@@ -44,7 +44,6 @@ class Blog
}
}
-
/**
* Get the description of a blog
* @author Toon Keppens
@@ -105,17 +104,14 @@ class Blog
*/
public static function create_blog($title, $subtitle)
{
- global $_user;
-
$course_id = api_get_course_int_id();
$current_date = date('Y-m-d H:i:s', time());
$session_id = api_get_session_id();
- // Tabel definitions
+ // Table definitions
$tbl_blogs = Database::get_course_table(TABLE_BLOGS);
$tbl_tool = Database::get_course_table(TABLE_TOOL_LIST);
$tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
- $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
//verified if exist blog
$sql = 'SELECT COUNT(*) as count FROM '.$tbl_blogs.' WHERE c_id = '.$course_id.' AND blog_name="'.Database::escape_string(
@@ -148,20 +144,16 @@ class Blog
$sql = "INSERT INTO $tbl_blogs_posts (c_id, title, full_text, date_creation, blog_id, author_id )
VALUES ($course_id, '".get_lang("Welcome")."', '".get_lang(
'FirstPostText'
- )."','".$current_date."', '".Database::escape_string((int)$this_blog_id)."', '".Database::escape_string(
- (int)$_user['user_id']
- )."');";
+ )."','".$current_date."', '".Database::escape_string((int)$this_blog_id)."', '".api_get_user_id()."');";
Database::query($sql);
// Put it on course homepage
$sql = "INSERT INTO $tbl_tool (c_id, name, link, image, visibility, admin, address, added_tool, session_id)
- VALUES ($course_id, '".Database::escape_string(
- $title
- )."','blog/blog.php?blog_id=".(int)$this_blog_id."','blog.gif','1','0','pastillegris.gif',0,'$session_id')";
+ VALUES ($course_id, '".Database::escape_string($title)."','blog/blog.php?blog_id=".(int)$this_blog_id."','blog.gif','1','0','pastillegris.gif',0,'$session_id')";
Database::query($sql);
// Subscribe the teacher to this blog
- Blog::set_user_subscribed((int)$this_blog_id, (int)$_user['user_id']);
+ Blog::set_user_subscribed($this_blog_id, api_get_user_id());
}
}
@@ -174,7 +166,6 @@ class Blog
*/
public static function edit_blog($blog_id, $title, $subtitle)
{
- global $_user;
// Table definitions
$tbl_blogs = Database::get_course_table(TABLE_BLOGS);
@@ -267,72 +258,68 @@ class Blog
* Creates a new post in a given blog
* @author Toon Keppens
* @param String $title
- * @param String $full_text
+ * @param String $text
* @param Integer $blog_id
*/
- public static function create_post($title, $full_text, $file_comment, $blog_id)
+ public static function create_post($title, $text, $file_comment, $blog_id)
{
- global $_user;
$_course = api_get_course_info();
-
+ // Table Definitions
$blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT);
+ $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
+
$upload_ok = true;
$has_attachment = false;
$current_date = date('Y-m-d H:i:s', time());
-
$course_id = api_get_course_int_id();
+ // Create the post
+ $sql = "INSERT INTO $tbl_blogs_posts (c_id, title, full_text, date_creation, blog_id, author_id)
+ VALUES ($course_id, '".Database::escape_string($title)."', '".Database::escape_string($text)."','".$current_date."', '".(int)$blog_id."', '".api_get_user_id()."');";
+ Database::query($sql);
+ $last_post_id = Database::insert_id();
- if (!empty($_FILES['user_upload']['name'])) {
- $upload_ok = FileManager::process_uploaded_file($_FILES['user_upload']);
- $has_attachment = true;
- }
-
- if ($upload_ok) {
- // Table Definitions
- $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
-
- // Create the post
- $sql = "INSERT INTO $tbl_blogs_posts (c_id, title, full_text, date_creation, blog_id, author_id )
- VALUES ($course_id, '".Database::escape_string($title)."', '".Database::escape_string(
- $full_text
- )."','".$current_date."', '".(int)$blog_id."', '".(int)$_user['user_id']."');";
+ if ($last_post_id) {
+ if (!empty($_FILES['user_upload']['name'])) {
+ $upload_ok = FileManager::process_uploaded_file($_FILES['user_upload']);
+ $has_attachment = true;
+ }
- Database::query($sql);
- $last_post_id = Database::insert_id();
+ if ($upload_ok) {
- if ($has_attachment) {
- $courseDir = $_course['path'].'/upload/blog';
- $sys_course_path = api_get_path(SYS_COURSE_PATH);
- $updir = $sys_course_path.$courseDir;
+ if ($has_attachment) {
+ $courseDir = $_course['path'].'/upload/blog';
+ $sys_course_path = api_get_path(SYS_COURSE_PATH);
+ $updir = $sys_course_path.$courseDir;
- // Try to add an extension to the file if it hasn't one
- $new_file_name = FileManager::add_ext_on_mime(
- stripslashes($_FILES['user_upload']['name']),
- $_FILES['user_upload']['type']
- );
+ // Try to add an extension to the file if it hasn't one
+ $new_file_name = FileManager::add_ext_on_mime(
+ stripslashes($_FILES['user_upload']['name']),
+ $_FILES['user_upload']['type']
+ );
- // user's file name
- $file_name = $_FILES['user_upload']['name'];
+ // user's file name
+ $file_name = $_FILES['user_upload']['name'];
- if (!FileManager::filter_extension($new_file_name)) {
- Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension'));
- } else {
- $new_file_name = uniqid('');
- $new_path = $updir.'/'.$new_file_name;
- $result = @move_uploaded_file($_FILES['user_upload']['tmp_name'], $new_path);
- $comment = Database::escape_string($file_comment);
-
- // Storing the attachments if any
- if ($result) {
- $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)."', '".Database::escape_string(
- $comment
- )."', '".Database::escape_string($new_file_name)."' , '".$last_post_id."', '".intval(
- $_FILES['user_upload']['size']
- )."', '".$blog_id."', '0' )";
- $result = Database::query($sql);
- $message .= ' / '.get_lang('AttachmentUpload');
+ if (!FileManager::filter_extension($new_file_name)) {
+ Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension'));
+ } else {
+ $new_file_name = uniqid('');
+ $new_path = $updir.'/'.$new_file_name;
+ $result = move_uploaded_file($_FILES['user_upload']['tmp_name'], $new_path);
+ $comment = Database::escape_string($file_comment);
+
+ // Storing the attachments if any
+ if ($result) {
+ $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)."', '".Database::escape_string(
+ $comment
+ )."', '".Database::escape_string($new_file_name)."' , '".$last_post_id."', '".intval(
+ $_FILES['user_upload']['size']
+ )."', '".$blog_id."', '0' )";
+ Database::query($sql);
+ $message .= ' / '.get_lang('AttachmentUpload');
+ }
}
}
}
@@ -349,16 +336,16 @@ class Blog
* @param String $full_text
* @param Integer $blog_id
*/
- public static function edit_post($post_id, $title, $full_text, $blog_id)
+ public static function edit_post($post_id, $title, $text, $blog_id)
{
// Init
$tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
$course_id = api_get_course_int_id();
// Create the post
- $sql = "UPDATE $tbl_blogs_posts SET title = '".Database::escape_string(
- $title
- )."', full_text = '".Database::escape_string($full_text)."'
+ $sql = "UPDATE $tbl_blogs_posts SET
+ title = '".Database::escape_string($title)."',
+ full_text = '".Database::escape_string($text)."'
WHERE c_id = $course_id AND post_id ='".(int)$post_id."' AND blog_id ='".(int)$blog_id."' LIMIT 1 ;";
Database::query($sql);
}
@@ -412,8 +399,8 @@ class Blog
$parent_id,
$task_id = 'NULL'
) {
- global $_user;
$_course = api_get_course_info();
+ $userId = api_get_user_id();
global $blog_table_attachment;
$upload_ok = true;
@@ -434,7 +421,7 @@ class Blog
$sql = "INSERT INTO $tbl_blogs_comments (c_id, title, comment, author_id, date_creation, blog_id, post_id, parent_comment_id, task_id )
VALUES ($course_id, '".Database::escape_string($title)."', '".Database::escape_string(
$full_text
- )."', '".(int)$_user['user_id']."','".$current_date."', '".(int)$blog_id."', '".(int)$post_id."', '".(int)$parent_id."', '".(int)$task_id."')";
+ )."', '".$userId."','".$current_date."', '".(int)$blog_id."', '".(int)$post_id."', '".(int)$parent_id."', '".(int)$task_id."')";
Database::query($sql);
// Empty post values, or they are shown on the page again
@@ -543,9 +530,7 @@ class Blog
// Create the task
$sql = "INSERT INTO $tbl_blogs_tasks (c_id, blog_id, title, description, color, system_task )
- VALUES ($course_id , '".(int)$blog_id."', '".Database::escape_string(
- $title
- )."', '".Database::escape_string($description)."', '".Database::escape_string($color)."', '0');";
+ VALUES ($course_id, '".(int)$blog_id."', '".Database::escape_string($title)."', '".Database::escape_string($description)."', '".Database::escape_string($color)."', '0');";
Database::query($sql);
$task_id = Database::insert_id();
@@ -692,7 +677,7 @@ class Blog
*/
public static function get_personal_task_list()
{
- global $_user;
+ $userId = api_get_user_id();
// Init
$tbl_blogs = Database::get_course_table(TABLE_BLOGS);
@@ -701,7 +686,7 @@ class Blog
$course_id = api_get_course_int_id();
- if ($_user['user_id']) {
+ if ($userId) {
$sql = "SELECT task_rel_user.*, task.title, blog.blog_name FROM $tbl_blogs_tasks_rel_user task_rel_user
INNER JOIN $tbl_blogs_tasks task ON task_rel_user.task_id = task.task_id
INNER JOIN $tbl_blogs blog ON task_rel_user.blog_id = blog.blog_id
@@ -710,7 +695,7 @@ class Blog
task.c_id = $course_id AND
blog.c_id = $course_id AND
task_rel_user.c_id = $course_id AND
- task_rel_user.user_id = ".(int)$_user['user_id']."
+ task_rel_user.user_id = ".$userId."
ORDER BY target_date ASC";
$result = Database::query($sql);
@@ -788,7 +773,6 @@ class Blog
$tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
$tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS);
$tbl_users = Database::get_main_table(TABLE_MAIN_USER);
- global $dateFormatLong;
$course_id = api_get_course_int_id();
@@ -1044,7 +1028,7 @@ class Blog
*/
public static function add_rating($type, $blog_id, $item_id, $rating)
{
- global $_user;
+ $userId = api_get_user_id();
// Init
$tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING);
@@ -1056,20 +1040,16 @@ class Blog
blog_id = '".(int)$blog_id."'
AND item_id = '".(int)$item_id."'
AND rating_type = '".Database::escape_string($type)."'
- AND user_id = '".(int)$_user['user_id']."'";
+ AND user_id = '".$userId."'";
$result = Database::query($sql);
- if (Database::num_rows($result) == 0) // Add rating
- {
+ // Add rating
+ if (Database::num_rows($result) == 0) {
$sql = "INSERT INTO $tbl_blogs_rating (c_id, blog_id, rating_type, item_id, user_id, rating )
- VALUES ($course_id, '".(int)$blog_id."', '".Database::escape_string(
- $type
- )."', '".(int)$item_id."', '".(int)$_user['user_id']."', '".Database::escape_string($rating)."')";
- $result = Database::query($sql);
-
+ VALUES ($course_id, '".(int)$blog_id."', '".Database::escape_string($type)."', '".(int)$item_id."', '".$userId."', '".Database::escape_string($rating)."')";
+ Database::query($sql);
return true;
- } else // Return
- {
+ } else {
return false;
}
}
@@ -1089,9 +1069,13 @@ class Blog
$course_id = api_get_course_int_id();
// Calculate rating
- $sql = "SELECT AVG(rating) as rating FROM $tbl_blogs_rating WHERE c_id = $course_id AND blog_id = '".(int)$blog_id."' AND item_id = '".(int)$item_id."' AND rating_type = '".Database::escape_string(
- $type
- )."' ";
+ $sql = "SELECT AVG(rating) as rating
+ FROM $tbl_blogs_rating
+ WHERE
+ c_id = $course_id AND
+ blog_id = '".(int)$blog_id."' AND
+ item_id = '".(int)$item_id."' AND
+ rating_type = '".Database::escape_string($type)."'";
$result = Database::query($sql);
$result = Database::fetch_array($result);
@@ -1110,7 +1094,7 @@ class Blog
*/
public static function display_rating_form($type, $blog_id, $post_id, $comment_id = null)
{
- global $_user;
+ $userId = api_get_user_id();
$tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING);
$course_id = api_get_course_int_id();
@@ -1121,35 +1105,30 @@ class Blog
blog_id = '".(int)$blog_id."'
AND item_id = '".(int)$post_id."'
AND rating_type = '".Database::escape_string($type)."'
- AND user_id = '".(int)$_user['user_id']."'";
+ AND user_id = '".$userId."'";
$result = Database::query($sql);
-
- if (Database::num_rows($result) == 0) // Add rating
- {
- return ' - '.get_lang(
- 'RateThis'
- ).':
';
- } else // Return
- {
+ // Add rating
+ if (Database::num_rows($result) == 0) {
+ return ' - '.get_lang('RateThis').': ';
+ } else {
+ // Return
return '';
}
}
+
if ($type = 'comment') {
// Check if the user has already rated this comment
$sql = "SELECT rating_id FROM $tbl_blogs_rating
WHERE c_id = $course_id AND blog_id = '".(int)$blog_id."'
AND item_id = '".(int)$comment_id."'
AND rating_type = '".Database::escape_string($type)."'
- AND user_id = '".(int)$_user['user_id']."'";
+ AND user_id = '".$userId."'";
$result = Database::query($sql);
-
- if (Database::num_rows($result) == 0) // Add rating
- {
- return ' - '.get_lang(
- 'RateThis'
- ).': ';
- } else // Return
- {
+ // Add rating
+ if (Database::num_rows($result) == 0) {
+ return ' - '.get_lang('RateThis').': ';
+ } else {
+ // Return
return '';
}
}
@@ -1162,6 +1141,7 @@ class Blog
* @param Integer $current_level
* @param Integer $blog_id
* @param Integer $post_id
+ * @param int $task_id
*/
public static function get_threaded_comments($current = 0, $current_level = 0, $blog_id, $post_id, $task_id = 0)
{
@@ -1271,146 +1251,42 @@ class Blog
public static function display_form_new_post($blog_id)
{
if (api_is_allowed('BLOG_'.$blog_id, 'article_add')) {
- echo '';
-
-
- echo '';
+ $form = new FormValidator('add_post', 'post', $url, null, array('enctype' => 'multipart/form-data'));
+ $form->addElement('header', get_lang('NewPost'));
+ $form->addElement('hidden', 'post_title_edited', 'false');
+ $form->addElement('hidden', 'new_post_submit', 'true');
+
+ self::setForm($form);
+ $form->display();
} else {
api_not_allowed();
}
}
+ /**
+ * @param FormValidator $form
+ * @return mixed
+ */
+ public static function setForm($form)
+ {
+ $form->addElement('hidden', 'action', '');
+
+ $form->addElement('text', 'post_title', get_lang('Title'));
+ $form->addRule('post_title', get_lang('ThisFieldIsRequired'), 'required');
+
+ $form->addElement('html_editor', 'post_full_text', get_lang('Content'));
+
+ $form->addElement('file', 'user_upload', get_lang('AddAnAttachment'));
+
+ $form->addElement('text', 'post_file_comment', get_lang('FileComment'));
+ $form->addElement('button', 'submit', get_lang('Save'));
+ return $form;
+
+ }
+
/**
* Displays the form to edit a post
* @author Toon Keppens
@@ -1438,52 +1314,22 @@ class Blog
// Prepare data
$blog_post_text = stripslashes($blog_post['full_text']);
+ $text = isset($_POST['post_full_text']) ? stripslashes($_POST['post_full_text']) : $blog_post_text;
- echo '';
+ $defaults = array(
+ 'post_title' => $blog_post['title'],
+ 'post_full_text' => $text,
+ );
+ $form->setDefaults($defaults);
+ self::setForm($form);
+ $form->display();
}
/**
@@ -2332,13 +2178,13 @@ class Blog
// Subscribe the user
$sql = "INSERT INTO $tbl_blogs_rel_user (c_id, blog_id, user_id ) VALUES ($course_id, '".(int)$blog_id."', '".(int)$user_id."');";
- $result = Database::query($sql);
+ Database::query($sql);
// Give this user basic rights
$sql = "INSERT INTO $tbl_user_permissions (c_id, user_id,tool,action) VALUES ($course_id, '".(int)$user_id."','BLOG_".(int)$blog_id."','article_add')";
- $result = Database::query($sql);
+ Database::query($sql);
$sql = "INSERT INTO $tbl_user_permissions (c_id, user_id,tool,action) VALUES ($course_id, '".(int)$user_id."','BLOG_".(int)$blog_id."','article_comments_add')";
- $result = Database::query($sql);
+ Database::query($sql);
}
/**
@@ -2418,6 +2264,8 @@ class Blog
$student_list = CourseManager :: get_student_list_from_course_code(api_get_course_int_id(), false, $session_id);
$user_data = array();
+ $selectAll = isset($_GET['selectall']) ? $_GET['selectall'] : null;
+
// Add users that are not in this blog to the list.
foreach ($student_list as $key => $user) {
if (isset($user['id_user'])) {
@@ -2426,7 +2274,7 @@ class Blog
if (!in_array($user['user_id'], $blog_member_ids)) {
$a_infosUser = UserManager :: get_user_info_by_id($user['user_id']);
$row = array();
- $row[] = '';
+ $row[] = '';
$username = api_htmlentities(sprintf(get_lang('LoginX'), $a_infosUser["username"]), ENT_QUOTES);
if ($is_western_name_order) {
$row[] = $a_infosUser["firstname"];
@@ -2482,7 +2330,8 @@ class Blog
*/
public static function display_form_user_unsubscribe($blog_id)
{
- global $_user;
+ $userId = api_get_user_id();
+
$is_western_name_order = api_is_western_name_order();
// Init
@@ -2553,7 +2402,7 @@ class Blog
$row[] = $task;
//Link to register users
- if ($myrow["user_id"] != $_user['user_id']) {
+ if ($myrow["user_id"] != $userId) {
$row[] = "".get_lang(
'UnRegister'
@@ -2611,75 +2460,35 @@ class Blog
*/
public static function display_new_comment_form($blog_id, $post_id, $title)
{
- echo '';
+ $form->addElement('button', 'submit', get_lang('Save'));
+ $form->display();
}
-
/**
* show the calender of the given month
* @author Patrick Cool
@@ -2694,14 +2503,16 @@ class Blog
*/
public static function display_minimonthcalendar($month, $year, $blog_id)
{
- // Init
- global $_user;
global $DaysShort;
global $MonthsLong;
+ $userId = api_get_user_id();
+
$posts = array();
$tasks = array();
+ $filter = isset($_GET['filter']) ? Security::remove_XSS($_GET['filter']) : null;
+
$tbl_users = Database::get_main_table(TABLE_MAIN_USER);
$tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
$tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
@@ -2723,12 +2534,8 @@ class Blog
//Start the week on monday
$startdayofweek = $dayone['wday'] <> 0 ? ($dayone['wday'] - 1) : 6;
- $backwardsURL = api_get_self()."?blog_id=".(int)$_GET['blog_id']."&filter=".Security::remove_XSS(
- $_GET['filter']
- )."&month=".($month == 1 ? 12 : $month - 1)."&year=".($month == 1 ? $year - 1 : $year);
- $forewardsURL = api_get_self()."?blog_id=".(int)$_GET['blog_id']."&filter=".Security::remove_XSS(
- $_GET['filter']
- )."&month=".($month == 12 ? 1 : $month + 1)."&year=".($month == 12 ? $year + 1 : $year);
+ $backwardsURL = api_get_self()."?blog_id=".(int)$_GET['blog_id']."&filter=".$filter."&month=".($month == 1 ? 12 : $month - 1)."&year=".($month == 1 ? $year - 1 : $year);
+ $forewardsURL = api_get_self()."?blog_id=".(int)$_GET['blog_id']."&filter=".$filter."&month=".($month == 12 ? 1 : $month + 1)."&year=".($month == 12 ? $year + 1 : $year);
// Get posts for this month
$sql = "SELECT post.*, DAYOFMONTH(date_creation) as post_day, user.lastname, user.firstname FROM $tbl_blogs_posts post
@@ -2752,7 +2559,7 @@ class Blog
}
// Get tasks for this month
- if ($_user['user_id']) {
+ if ($userId) {
$sql = " SELECT task_rel_user.*, DAYOFMONTH(target_date) as task_day, task.title, blog.blog_name
FROM $tbl_blogs_tasks_rel_user task_rel_user
INNER JOIN $tbl_blogs_tasks task ON task_rel_user.task_id = task.task_id
@@ -2761,7 +2568,7 @@ class Blog
task_rel_user.c_id = $course_id AND
task.c_id = $course_id AND
blog.c_id = $course_id AND
- task_rel_user.user_id = '".(int)$_user['user_id']."'
+ task_rel_user.user_id = '".$userId."'
AND MONTH(target_date) = '".(int)$month."'
AND YEAR(target_date) = '".(int)$year."'
ORDER BY target_date ASC";
@@ -2809,7 +2616,7 @@ class Blog
$bgcolor = $ii < 5 ? $class = "class=\"days_week\"" : $class = "class=\"days_weekend\"";
$dayheader = "$curday";
- if (($curday == $today[mday]) && ($year == $today[year]) && ($month == $today[mon])) {
+ if (($curday == $today['mday']) && ($year == $today['year']) && ($month == $today['mon'])) {
$dayheader = "$curday";
$class = "class=\"days_today\"";
}
@@ -2920,7 +2727,8 @@ class Blog
*/
public static function display_blog_list()
{
- global $charset, $_user;
+ global $charset;
+ $userInfo = api_get_user_info();
$course_id = api_get_course_int_id();
// Init
$counter = 0;
@@ -2931,7 +2739,8 @@ class Blog
$session_id = api_get_session_id();
$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
+ FROM $tbl_blogs WHERE c_id = $course_id ORDER BY date_creation DESC";
$result = Database::query($sql);
if (Database::num_rows($result)) {
while ($row_project = Database::fetch_row($result)) {
@@ -2939,14 +2748,13 @@ class Blog
}
}
-
$list_content_blog = array();
$list_body_blog = array();
if (is_array($list_info)) {
foreach ($list_info as $key => $info_log) {
- //validacion when belongs to a session
- $session_img = api_get_session_image($info_log[4], $_user['status']);
+ // Validation when belongs to a session
+ $session_img = api_get_session_image($info_log[4], $userInfo['status']);
$url_start_blog = 'blog.php'."?"."blog_id=".$info_log[3]."&".api_get_cidreq();
$title = $info_log[0];
@@ -3172,8 +2980,5 @@ function get_blog_comment_from_user($course_code, $user_id)
$return_data .= '
';
}
}
-
return $return_data;
}
-
-?>
diff --git a/main/inc/lib/career.lib.php b/main/inc/lib/career.lib.php
index 65e226535b..e3ef301aff 100644
--- a/main/inc/lib/career.lib.php
+++ b/main/inc/lib/career.lib.php
@@ -9,114 +9,108 @@
* Code
*/
require_once 'promotion.lib.php';
-require_once 'fckeditor/fckeditor.php';
-
-define ('CAREER_STATUS_ACTIVE', 1);
-define ('CAREER_STATUS_INACTIVE',0);
/**
* @package chamilo.library
*/
-class Career extends Model {
-
- var $table;
- var $columns = array('id', 'name','description','status','created_at','updated_at');
-
- public function __construct() {
+class Career extends Model
+{
+ const CAREER_STATUS_ACTIVE = 1;
+ const CAREER_STATUS_INACTIVE = 0;
+ public $table;
+ public $columns = array('id', 'name','description','status','created_at','updated_at');
+
+ public function __construct()
+ {
$this->table = Database::get_main_table(TABLE_CAREER);
- }
-
+ }
+
/**
* Get the count of elements
*/
- public function get_count() {
+ public function get_count()
+ {
$row = Database::select('count(*) as count', $this->table, array(),'first');
return $row['count'];
}
-
+
public function get_all($where_conditions = array()) {
return Database::select('*',$this->table, array('where'=>$where_conditions,'order' =>'name ASC'));
}
-
+
/**
* Update all promotion status by career
* @param int career id
* @param int status (1 or 0)
*/
public function update_all_promotion_status_by_career_id($career_id, $status) {
- $promotion = new Promotion();
+ $promotion = new Promotion();
$promotion_list = $promotion->get_all_promotions_by_career_id($career_id);
if (!empty($promotion_list)) {
- foreach($promotion_list as $item) {
+ foreach($promotion_list as $item) {
$params['id'] = $item['id'];
- $params['status'] = $status;
- $promotion->update($params);
- $promotion->update_all_sessions_status_by_promotion_id($params['id'], $status);
+ $params['status'] = $status;
+ $promotion->update($params);
+ $promotion->update_all_sessions_status_by_promotion_id($params['id'], $status);
}
}
}
-
+
/**
* Displays the title + grid
*/
- public function display() {
+ public function display()
+ {
// action links
echo '';
- echo Display::grid_html('careers');
+ echo ''.Display::return_icon('back.png',get_lang('Back'),'','32').'';
+ echo ''.Display::return_icon('new_career.png',get_lang('Add'),'','32').'';
+ echo '';
+ echo Display::grid_html('careers');
}
-
- public function get_status_list() {
- return array(CAREER_STATUS_ACTIVE => get_lang('Unarchived'), CAREER_STATUS_INACTIVE => get_lang('Archived'));
+
+ public function get_status_list()
+ {
+ return array(self::CAREER_STATUS_ACTIVE => get_lang('Unarchived'), self::CAREER_STATUS_INACTIVE => get_lang('Archived'));
}
-
+
/**
* Returns a Form validator Obj
- * @todo the form should be auto generated
* @param string url
* @param string action add, edit
- * @return obj form validator obj
+ * @return obj form validator obj
*/
- public function return_form($url, $action) {
-
- $oFCKeditor = new FCKeditor('description') ;
- $oFCKeditor->ToolbarSet = 'careers';
- $oFCKeditor->Width = '100%';
- $oFCKeditor->Height = '200';
- $oFCKeditor->Value = '';
- $oFCKeditor->CreateHtml();
-
+ public function return_form($url, $action)
+ {
$form = new FormValidator('career', 'post', $url);
- // Settting the form elements
- $header = get_lang('Add');
+ // Setting the form elements
+ $header = get_lang('Add');
if ($action == 'edit') {
$header = get_lang('Modify');
}
-
+
$form->addElement('header', $header);
$id = isset($_GET['id']) ? intval($_GET['id']) : '';
$form->addElement('hidden', 'id', $id);
-
+
$form->addElement('text', 'name', get_lang('Name'), array('size' => '70'));
- $form->add_html_editor('description', get_lang('Description'), false, false, array('ToolbarSet' => 'careers','Width' => '100%', 'Height' => '250'));
- $status_list = $this->get_status_list();
+ $form->add_html_editor('description', get_lang('Description'), false, false, array('ToolbarSet' => 'careers','Width' => '100%', 'Height' => '250'));
+ $status_list = $this->get_status_list();
$form->addElement('select', 'status', get_lang('Status'), $status_list);
if ($action == 'edit') {
$form->addElement('text', 'created_at', get_lang('CreatedAt'));
$form->freeze('created_at');
}
-
+
if ($action == 'edit') {
$form->addElement('style_submit_button', 'submit', get_lang('Modify'), 'class="save"');
} else {
$form->addElement('style_submit_button', 'submit', get_lang('Add'), 'class="save"');
}
-
+
// Setting the defaults
$defaults = $this->get($id);
-
+
if (!empty($defaults['created_at'])) {
$defaults['created_at'] = api_convert_and_format_date($defaults['created_at']);
}
@@ -124,12 +118,12 @@ class Career extends Model {
$defaults['updated_at'] = api_convert_and_format_date($defaults['updated_at']);
}
$form->setDefaults($defaults);
-
+
// Setting the rules
$form->addRule('name', get_lang('ThisFieldIsRequired'), 'required');
- return $form;
+ return $form;
}
-
+
/**
* Copies the career to a new one
* @param integer Career ID
@@ -161,7 +155,7 @@ class Career extends Model {
if ($copy_promotions) {
//Now also copy each session of the promotion as a new session and register it inside the promotion
$promotion = new Promotion();
- $promo_list = $promotion->get_all_promotions_by_career_id($id);
+ $promo_list = $promotion->get_all_promotions_by_career_id($id);
if (!empty($promo_list)) {
foreach($promo_list as $item) {
$pid = $promotion->copy($item['id'], $cid);
@@ -169,8 +163,8 @@ class Career extends Model {
}
}
return $cid;
- }
-
+ }
+
public function get_status($career_id) {
$TBL_CAREER = Database::get_main_table(TABLE_CAREER);
$career_id = intval($career_id);
@@ -182,10 +176,10 @@ class Career extends Model {
} else {
return false;
}
-
+
}
-
-
+
+
public function save($params, $show_query = false) {
$id = parent::save($params, $show_query);
if (!empty($id)) {
@@ -193,9 +187,9 @@ class Career extends Model {
}
return $id;
}
-
+
public function delete($id) {
parent::delete($id);
event_system(LOG_CAREER_DELETE, LOG_CAREER_ID, $id, api_get_utc_datetime(), api_get_user_id());
- }
+ }
}
\ No newline at end of file
diff --git a/main/inc/lib/fck_course_document.inc.php b/main/inc/lib/fck_course_document.inc.php
deleted file mode 100644
index 0910cab6e9..0000000000
--- a/main/inc/lib/fck_course_document.inc.php
+++ /dev/null
@@ -1,260 +0,0 @@
-
-function confirmation (name)
-{
- if (confirm(\" ". api_utf8_encode(get_lang('AreYouSureToDelete')) ." \"+ name + \" ?\"))
- {return true;}
- else
- {return false;}
-}
-";
-
-/* Variables
- - some need defining before inclusion of libraries */
-
-$sType = isset($sType) ? $sType : '';
-
-if ($sType=="MP3") $sType="audio";
-
-// Resource type
-$sType = strtolower($sType);
-
-// Choosing the repository to be used.
-if (api_is_in_course()) {
- if (!api_is_in_group()) {
- // 1. We are inside a course and not in a group.
- if (api_is_allowed_to_edit()) {
- // 1.1. Teacher
- $base_work_dir = api_get_path(SYS_COURSE_PATH).api_get_course_path().'/document/';
- $http_www = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/';
- } else {
- // 1.2. Student
- $base_work_dir = api_get_path(SYS_COURSE_PATH).api_get_course_path().'/document/shared_folder/'.api_get_user_id().'/';
- $http_www = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/shared_folder/'.api_get_user_id().'/';
- }
- } else {
- // 2. Inside a course and inside a group.
- $base_work_dir = api_get_path(SYS_COURSE_PATH).api_get_course_path().'/document'.$group_properties['directory'].'/';
- $http_www = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document'.$group_properties['directory'].'/';
- }
-} else {
- if (api_is_platform_admin() && $_SESSION['this_section'] == 'platform_admin') {
- // 3. Platform administration activities.
- $base_work_dir = api_get_path(SYS_DATA_PATH).'default_platform_document/';
- $http_www = api_get_path(WEB_PUBLIC_PATH).'data/default_platform_document/';
- } else {
- // 4. The user is outside courses.
- $my_path = UserManager::get_user_picture_path_by_id(api_get_user_id(),'system');
- $base_work_dir = $my_path['dir'].'my_files/';
- $my_path = UserManager::get_user_picture_path_by_id(api_get_user_id(),'web');
- $http_www = $my_path['dir'].'my_files/';
- }
-}
-
-// Set the upload path according to the resource type.
-if ($sType == 'audio') {
- check_and_create_resource_directory($base_work_dir, '/audio', get_lang('Audio'));
- $base_work_dir = $base_work_dir.'audio/';
- $http_www = $http_www.'audio/';
- $path = "/audio/";
-} elseif ($sType == 'flash') {
- check_and_create_resource_directory($base_work_dir, '/flash', get_lang('Flash'));
- $base_work_dir = $base_work_dir.'flash/';
- $http_www = $http_www.'flash/';
- $path = "/flash/";
-} elseif ($sType == 'images') {
- check_and_create_resource_directory($base_work_dir, '/images', get_lang('Images'));
- $base_work_dir = $base_work_dir.'images/';
- $http_www = $http_www.'images/';
- $path = "/images/";
-} elseif ($sType == 'video') {
- check_and_create_resource_directory($base_work_dir, '/video', get_lang('Video'));
- $base_work_dir = $base_work_dir.'video/';
- $http_www = $http_www.'video/';
- $path = "/video/";
-} elseif ($sType == 'video/flv') {
- check_and_create_resource_directory($base_work_dir, '/video', get_lang('Video'));
- check_and_create_resource_directory($base_work_dir, '/video/flv', 'flv');
- $base_work_dir = $base_work_dir.'video/flv/';
- $http_www = $http_www.'video/flv/';
- $path = "/video/flv/";
-}
-
-$course_dir = $_course['path'].'/document/'.$sType;
-$sys_course_path = api_get_path(SYS_COURSE_PATH);
-
-$dbl_click_id = 0; // used to avoid double-click
-$is_allowed_to_edit = api_is_allowed_to_edit();
-
-$req_gid = '';
-
-/* Constants and variables */
-
-$course_quota = DocumentManager::get_course_quota();
-
-/* MAIN SECTION */
-
-/* Header */
-
-$tool_name = get_lang('Doc'); // Title of the page (should come from the language file)
-
-?>
-
-
-'')
-{
-?>
-
-
- $path) {
- DocumentManager::delete_document($_course, $path, $base_work_dir);
- }
- Display::display_normal_message(api_utf8_encode(get_lang('DocDeleted')));
- break;
- }
- }
-}
-
-/* GET ALL DOCUMENT DATA FOR CURDIRPATH */
-
-$docs_and_folders = getlist ($base_work_dir.'/');
-
-if ($docs_and_folders) {
- //create a sortable table with our data
- $sortable_data = array();
- while (list ($key, $id) = each($docs_and_folders)) {
- // Skip directories.
- if ($id['filetype'] != 'file') {
- continue;
- }
-
- $row = array ();
-
- //if the item is invisible, wrap it in a span with class invisible
- $invisibility_span_open = ($id['visibility'] == 0) ? '' : '';
- $invisibility_span_close = ($id['visibility'] == 0) ? '' : '';
- //size (or total size of a directory)
- $size = $id['filetype'] == 'folder' ? FileManager::get_total_folder_size($id['path'], $is_allowed_to_edit) : $id[size];
- //get the title or the basename depending on what we're using
- if ($id['title'] != '') {
- $document_name = $id['title'];
- } else {
- $document_name = basename($id['path']);
- }
- // icons with hyperlinks
- $row[]= ''.build_document_icon_tag($id['filetype'],$id['path']).'';
- //document title with hyperlink
- $row[] = ''.$id['title'].'';
- //comments => display comment under the document name
- //$row[] = $invisibility_span_open.nl2br(htmlspecialchars($id['comment'])).$invisibility_span_close;
- $display_size = Text::format_file_size($size);
- $row[] = ''.$size.''.$invisibility_span_open.$display_size.$invisibility_span_close;
- //last edit date
- $display_date = date('d.m.Y', (strtotime($id['lastedit_date'])));
- $row[] = ''.$id['lastedit_date'].''.$invisibility_span_open.$display_date.$invisibility_span_close;
-
- $sortable_data[] = $row;
- }
-} else {
- $sortable_data = array();
- //$table_footer=''.get_lang('NoDocsInFolder').'
';
-}
-
-$table = new SortableTableFromArray($sortable_data, 4, 10);
-$query_vars['curdirpath'] = $curdirpath;
-if (isset($_SESSION['_gid'])) {
- $query_vars['gidReq'] = $_SESSION['_gid'];
-}
-$table->set_additional_parameters($query_vars);
-$column = 0;
-/*
-if ($is_allowed_to_edit AND count($docs_and_folders) > 1) {
- $table->set_header($column++, '', false);
-}
-*/
-
-$table->set_header($column++, api_htmlentities(get_lang('Type'), ENT_QUOTES));
-$table->set_header($column++, api_htmlentities(get_lang('Title'), ENT_QUOTES));
-
-//$column_header[] = array(get_lang('Comment'),true); => display comment under the document name
-$table->set_header($column++, api_htmlentities(get_lang('Size'), ENT_QUOTES));
-$table->set_header($column++, api_htmlentities(get_lang('Date'), ENT_QUOTES));
-
-echo api_utf8_encode($table->get_table_html());
-echo api_utf8_encode($table_footer);
-
-// Functions
-?>
-
\ No newline at end of file
diff --git a/main/inc/lib/formvalidator/Element/html_editor.php b/main/inc/lib/formvalidator/Element/html_editor.php
index badae68109..a8ee9b081b 100644
--- a/main/inc/lib/formvalidator/Element/html_editor.php
+++ b/main/inc/lib/formvalidator/Element/html_editor.php
@@ -84,7 +84,7 @@ class HTML_QuickForm_html_editor extends HTML_QuickForm_textarea
}
/**
- * Build this element using FCKeditor
+ * Build this element using an editor
*/
public function buildEditor()
{
diff --git a/main/inc/lib/promotion.lib.php b/main/inc/lib/promotion.lib.php
index 9c6fbc6ac8..67d6a6149f 100644
--- a/main/inc/lib/promotion.lib.php
+++ b/main/inc/lib/promotion.lib.php
@@ -10,31 +10,33 @@
*/
require_once 'career.lib.php';
-require_once 'fckeditor/fckeditor.php';
define ('PROMOTION_STATUS_ACTIVE', 1);
-define ('PROMOTION_STATUS_INACTIVE',0);
+define ('PROMOTION_STATUS_INACTIVE', 0);
/**
* @package chamilo.library
*/
-class Promotion extends Model {
-
- var $table;
- var $columns = array('id','name','description','career_id','status','created_at','updated_at');
-
- public function __construct() {
+class Promotion extends Model
+{
+
+ public $table;
+ public $columns = array('id', 'name', 'description', 'career_id', 'status', 'created_at', 'updated_at');
+
+ public function __construct()
+ {
$this->table = Database::get_main_table(TABLE_PROMOTION);
}
-
+
/**
* Get the count of elements
*/
- public function get_count() {
+ public function get_count()
+ {
$row = Database::select('count(*) as count', $this->table, array(),'first');
return $row['count'];
}
-
-
+
+
/**
* Copies the promotion to a new one
* @param integer Promotion ID
@@ -43,78 +45,79 @@ class Promotion extends Model {
* @return integer New promotion ID on success, false on failure
*/
public function copy($id, $career_id = null, $copy_sessions = false) {
- $pid = false;
- $promotion = $this->get($id);
- if (!empty($promotion)) {
- $new = array();
- foreach ($promotion as $key => $val) {
- switch ($key) {
- case 'id':
- case 'updated_at':
- break;
- case 'name':
- $val .= ' '.get_lang('CopyLabelSuffix');
- $new[$key] = $val;
- break;
- case 'created_at':
- $val = api_get_utc_datetime();
- $new[$key] = $val;
- break;
- case 'career_id':
- if (!empty($career_id)) {
- $val = (int)$career_id;
- }
- $new[$key] = $val;
- default:
- $new[$key] = $val;
- break;
- }
- }
-
- if ($copy_sessions) {
- /**
- * When copying a session we do:
- * 1. Copy a new session from the source
- * 2. Copy all courses from the session (no user data, no user list)
- * 3. Create the promotion
- */
- $session_list = SessionManager::get_all_sessions_by_promotion($id);
-
- if (!empty($session_list)) {
- $pid = $this->save($new);
- if (!empty($pid)) {
+ $pid = false;
+ $promotion = $this->get($id);
+ if (!empty($promotion)) {
+ $new = array();
+ foreach ($promotion as $key => $val) {
+ switch ($key) {
+ case 'id':
+ case 'updated_at':
+ break;
+ case 'name':
+ $val .= ' '.get_lang('CopyLabelSuffix');
+ $new[$key] = $val;
+ break;
+ case 'created_at':
+ $val = api_get_utc_datetime();
+ $new[$key] = $val;
+ break;
+ case 'career_id':
+ if (!empty($career_id)) {
+ $val = (int)$career_id;
+ }
+ $new[$key] = $val;
+ default:
+ $new[$key] = $val;
+ break;
+ }
+ }
+
+ if ($copy_sessions) {
+ /**
+ * When copying a session we do:
+ * 1. Copy a new session from the source
+ * 2. Copy all courses from the session (no user data, no user list)
+ * 3. Create the promotion
+ */
+ $session_list = SessionManager::get_all_sessions_by_promotion($id);
+
+ if (!empty($session_list)) {
+ $pid = $this->save($new);
+ if (!empty($pid)) {
$new_session_list = array();
-
- foreach($session_list as $item) {
- $sid = SessionManager::copy_session($item['id'], true, false, false, true);
+
+ foreach ($session_list as $item) {
+ $sid = SessionManager::copy_session($item['id'], true, false, false, true);
$new_session_list[] = $sid;
- }
-
+ }
+
if (!empty($new_session_list)) {
SessionManager::suscribe_sessions_to_promotion($pid, $new_session_list);
}
- }
- }
- } else {
- $pid = $this->save($new);
- }
+ }
+ }
+ } else {
+ $pid = $this->save($new);
+ }
}
return $pid;
}
-
+
/**
* Gets all promotions by career id
* @param int career id
* @return array results
*/
- public function get_all_promotions_by_career_id($career_id, $order = false) {
+ public function get_all_promotions_by_career_id($career_id, $order = false)
+ {
return Database::select('*', $this->table, array('where'=>array('career_id = ?'=>$career_id),'order' =>$order));
}
-
+
public function get_status_list() {
return array(PROMOTION_STATUS_ACTIVE => get_lang('Active'), PROMOTION_STATUS_INACTIVE => get_lang('Inactive'));
- }
-
+ }
+
/**
* Displays the title + grid
* @return string html code
@@ -123,76 +126,66 @@ class Promotion extends Model {
// action links
echo '';
echo '
'.Display::return_icon('back.png',get_lang('Back'),'','32').'';
- echo '
'.Display::return_icon('new_promotion.png',get_lang('Add'),'','32').'';
+ echo '
'.Display::return_icon('new_promotion.png',get_lang('Add'),'','32').'';
echo '
'.Display::return_icon('new_session.png',get_lang('AddSession'),'','32').'';
echo '
';
- echo Display::grid_html('promotions');
+ echo Display::grid_html('promotions');
}
-
+
/**
* Update all session status by promotion
* @param int promotion id
* @param int status (1, 0)
*/
public function update_all_sessions_status_by_promotion_id($promotion_id, $status) {
- $session_list = SessionManager::get_all_sessions_by_promotion($promotion_id);
+ $session_list = SessionManager::get_all_sessions_by_promotion($promotion_id);
if (!empty($session_list)) {
foreach($session_list as $item) {
- SessionManager::set_session_status($item['id'], $status);
+ SessionManager::set_session_status($item['id'], $status);
}
}
}
-
-
+
/**
* Returns a Form validator Obj
- * @todo the form should be auto generated
* @param string url
* @param string header name
- * @return obj form validator obj
+ * @return obj form validator obj
*/
-
+
function return_form($url, $action = 'add') {
-
- $oFCKeditor = new FCKeditor('description') ;
- $oFCKeditor->ToolbarSet = 'careers';
- $oFCKeditor->Width = '100%';
- $oFCKeditor->Height = '200';
- $oFCKeditor->Value = '';
- $oFCKeditor->CreateHtml();
-
$form = new FormValidator('promotion', 'post', $url);
- // Settting the form elements
+ // Setting the form elements
$header = get_lang('Add');
if ($action == 'edit') {
$header = get_lang('Modify');
}
$id = isset($_GET['id']) ? intval($_GET['id']) : '';
-
+
$form->addElement('header', '', $header);
$form->addElement('hidden', 'id', $id);
- $form->addElement('text', 'name', get_lang('Name'), array('size' => '70','id' => 'name'));
- $form->add_html_editor('description', get_lang('Description'), false, false, array('ToolbarSet' => 'careers','Width' => '100%', 'Height' => '250'));
+ $form->addElement('text', 'name', get_lang('Name'), array('size' => '70','id' => 'name'));
+ $form->add_html_editor('description', get_lang('Description'), false, false, array('ToolbarSet' => 'careers','Width' => '100%', 'Height' => '250'));
$career = new Career();
$careers = $career->get_all();
- $career_list = array();
- foreach($careers as $item) {
+ $career_list = array();
+ foreach($careers as $item) {
$career_list[$item['id']] = $item['name'];
}
$form->addElement('select', 'career_id', get_lang('Career'), $career_list);
-
- $status_list = $this->get_status_list();
+
+ $status_list = $this->get_status_list();
$form->addElement('select', 'status', get_lang('Status'), $status_list);
if ($action == 'edit') {
$form->addElement('text', 'created_at', get_lang('CreatedAt'));
$form->freeze('created_at');
- }
+ }
if ($action == 'edit') {
$form->addElement('style_submit_button', 'submit', get_lang('Modify'), 'class="save"');
} else {
$form->addElement('style_submit_button', 'submit', get_lang('Add'), 'class="save"');
}
-
+
// Setting the defaults
$defaults = $this->get($id);
if (!empty($defaults['created_at'])) {
@@ -200,32 +193,32 @@ class Promotion extends Model {
}
if (!empty($defaults['updated_at'])) {
$defaults['updated_at'] = api_convert_and_format_date($defaults['updated_at']);
- }
+ }
$form->setDefaults($defaults);
-
+
// Setting the rules
$form->addRule('name', get_lang('ThisFieldIsRequired'), 'required');
-
+
return $form;
}
-
+
public function save($params, $show_query = false) {
$id = parent::save($params, $show_query);
if (!empty($id)) {
event_system(LOG_PROMOTION_CREATE, LOG_PROMOTION_ID, $id, api_get_utc_datetime(), api_get_user_id());
}
- return $id;
+ return $id;
}
-
- public function delete($id)
+
+ public function delete($id)
{
if (parent::delete($id)) {
SessionManager::clear_session_ref_promotion($id);
- event_system(LOG_PROMOTION_DELETE, LOG_PROMOTION_ID, $id, api_get_utc_datetime(), api_get_user_id());
+ event_system(LOG_PROMOTION_DELETE, LOG_PROMOTION_ID, $id, api_get_utc_datetime(), api_get_user_id());
} else {
return false;
- }
+ }
}
-
-
+
+
}
diff --git a/main/newscorm/lp_controller.php b/main/newscorm/lp_controller.php
index abf4dfd9a1..4ef86c4c64 100644
--- a/main/newscorm/lp_controller.php
+++ b/main/newscorm/lp_controller.php
@@ -96,7 +96,6 @@ $session_id = api_get_session_id();
api_protect_course_script(true);
-require_once api_get_path(LIBRARY_PATH).'fckeditor/fckeditor.php';
$lpfound = false;
$myrefresh = 0;
diff --git a/main/social/message_for_group_form.inc.php b/main/social/message_for_group_form.inc.php
index 20def448dc..1da65c94e4 100644
--- a/main/social/message_for_group_form.inc.php
+++ b/main/social/message_for_group_form.inc.php
@@ -8,24 +8,24 @@
* Initialization
*/
$language_file = array('registration','messages','userInfo','admin');
-$cidReset=true;
+$cidReset = true;
require_once '../inc/global.inc.php';
+$app['template.show_footer'] = false;
+$app['template.show_header'] = false;
+$app['default_layout'] = 'default/layout/blank.tpl';
+
api_block_anonymous_users();
if (api_get_setting('allow_social_tool') !='true') {
api_not_allowed();
}
-require_once api_get_path(LIBRARY_PATH).'fckeditor/fckeditor.php';
-
$tok = Security::get_token();
if (isset($_REQUEST['user_friend'])) {
$info_user_friend=array();
$info_path_friend=array();
$userfriend_id = intval($_REQUEST['user_friend']);
- // panel=1 send message
- // panel=2 send invitation
$panel = Security::remove_XSS($_REQUEST['view_panel']);
$info_user_friend = api_get_user_info($userfriend_id);
$info_path_friend = UserManager::get_user_picture_path_by_id($userfriend_id,'web',false,true);
@@ -35,7 +35,7 @@ $group_id = isset($_GET['group_id']) ? intval($_GET['group_id']) : null;
$message_id = isset($_GET['message_id']) ? intval($_GET['message_id']) : null;
$actions = array('add_message_group', 'edit_message_group', 'reply_message_group');
-$allowed_action = (isset($_GET['action']) && in_array($_GET['action'],$actions))?Security::remove_XSS($_GET['action']):'';
+$allowed_action = isset($_GET['action']) && in_array($_GET['action'],$actions) ? Security::remove_XSS($_GET['action']):'';
$to_group = '';
$subject = '';
@@ -49,17 +49,17 @@ if (!empty($group_id) && $allowed_action) {
api_not_allowed(true);
}
- $to_group = $group_info['name'];
- if (!empty($message_id)) {
- $message_info = MessageManager::get_message_by_id($message_id);
- if ($allowed_action == 'reply_message_group') {
- $subject = get_lang('Reply').': '.api_xml_http_response_encode($message_info['title']);
- //$message = api_xml_http_response_encode($message_info['content']);
- } else {
- $subject = api_xml_http_response_encode($message_info['title']);
- $message = api_xml_http_response_encode($message_info['content']);
- }
- }
+ $to_group = $group_info['name'];
+ if (!empty($message_id)) {
+ $message_info = MessageManager::get_message_by_id($message_id);
+ if ($allowed_action == 'reply_message_group') {
+ $subject = get_lang('Reply').': '.api_xml_http_response_encode($message_info['title']);
+ //$message = api_xml_http_response_encode($message_info['content']);
+ } else {
+ $subject = api_xml_http_response_encode($message_info['title']);
+ $message = api_xml_http_response_encode($message_info['content']);
+ }
+ }
}
$page_item = !empty($_GET['topics_page_nr']) ? intval($_GET['topics_page_nr']):1;
@@ -67,67 +67,38 @@ $param_item_page = isset($_GET['items_page_nr']) && isset($_GET['topic_id']) ? (
if (isset($_GET['topic_id'])) {
$param_item_page .= '&topic_id='.intval($_GET['topic_id']);
}
-$page_topic = isset($_GET['topics_page_nr']) ? intval($_GET['topics_page_nr']):1;
-
-$anchor_topic = isset($_GET['anchor_topic']) ? Security::remove_XSS($_GET['anchor_topic']): null;
-?>
-
-
\ No newline at end of file
+$page_topic = isset($_GET['topics_page_nr']) ? intval($_GET['topics_page_nr']) : 1;
+$anchor_topic = isset($_GET['anchor_topic']) ? Security::remove_XSS($_GET['anchor_topic']) : null;
+
+$url = api_get_path(WEB_PUBLIC_PATH).'main/social/group_topics.php?id='.$group_id.'&anchor_topic='.$anchor_topic.'&topics_page_nr='.$page_topic.$param_item_page;
+
+$form = new FormValidator('form', 'post', $url, null, array('enctype' => 'multipart/form-data'));
+$form->addElement('hidden', 'action', $allowed_action);
+$form->addElement('hidden', 'group_id', $group_id);
+$form->addElement('hidden', 'parent_id', $message_id);
+$form->addElement('hidden', 'message_id', $message_id);
+$form->addElement('hidden', 'token', $tok);
+
+if (api_get_setting('allow_message_tool')=='true') {
+ // Normal message
+ $user_info = api_get_user_info($userfriend_id);
+ $height = 180;
+ if ($allowed_action == 'add_message_group') {
+ $form->addElement('text', 'title', get_lang('Title'));
+ $height = 140;
+ }
+
+ $form->addElement('html_editor', 'content');
+
+ $form->addElement('label', null, get_lang('AttachmentFiles'));
+ $form->addElement('label', null, '
+
'.get_lang('AddOneMoreFile').''
+ );
+
+ $form->addElement('html', '
');
+ $form->addElement('file', 'attach_1', sprintf(get_lang('MaximunFileSizeX'), Text::format_file_size(api_get_setting('message_max_upload_filesize'))));
+ $form->addElement('html', '
');
+ $form->addElement('button', 'submit', get_lang('SendMessage'));
+
+ $form->display();
+}