$sql="UPDATE ".$table_categories." SET cat_title='".$clean_cat_title."', cat_comment='".Database::escape_string($values['forum_category_comment'])."' WHERE cat_id='".Database::escape_string($values['forum_category_id'])."'";
* This function deletes a forum or a forum category
* This function currently does not delete the forums inside the category, nor the threads and replies inside these forums.
* For the moment this is the easiest method and it has the advantage that it allows to recover fora that were acidently deleted
* when the forum category got deleted.
*
* @param $content = what we are deleting (a forum or a forum category)
* @param $id The id of the forum category that has to be deleted.
*
* @todo write the code for the cascading deletion of the forums inside a forum category and also the threads and replies inside these forums
* @todo config setting for recovery or not (see also the documents tool: real delete or not).
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @version february 2006, dokeos 1.8
*/
function delete_forum_forumcategory_thread($content, $id)
{
global $_course;
if ($content=='forumcategory')
{
$tool_constant=TOOL_FORUM_CATEGORY;
$return_message=get_lang('ForumCategoryDeleted');
}
if ($content=='forum')
{
$tool_constant=TOOL_FORUM;
$return_message=get_lang('ForumDeleted');
}
if ($content=='thread')
{
$tool_constant=TOOL_FORUM_THREAD;
$return_message=get_lang('ThreadDeleted');
}
api_item_property_update($_course,$tool_constant,$id,"delete",api_get_user_id()); // note: check if this returns a true and if so => return $return_message, if not => return false;
//delete_attachment($post_id);
return $return_message;
}
/**
* This function deletes a forum post. This separate function is needed because forum posts do not appear in the item_property table (yet)
* and because deleting a post also has consequence on the posts that have this post as parent_id (they are also deleted).
* an alternative would be to store the posts also in item_property and mark this post as deleted (visibility = 2).
* We also have to decrease the number of replies in the thread table
*
* @param $post_id the id of the post that will be deleted
*
* @todo write recursive function that deletes all the posts that have this message as parent
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @version february 2006, dokeos 1.8
*/
function delete_post($post_id)
{
global $table_posts;
global $table_threads;
$sql="DELETE FROM $table_posts WHERE post_id='".Database::escape_string($post_id)."'"; // note: this has to be a recursive function that deletes all of the posts in this block.
* This function takes care of the display of the up and down icon
*
* @param $content what is it that we want to make (in)visible: forum category, forum, thread, post
* @param $id is the id of the item we want to display the icons for
* @param $list is an array of all the items. All items in this list should have an up and down icon except for the first (no up icon) and the last (no down icon)
* The key of this $list array is the id of the item.
*
* @return
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @version february 2006, dokeos 1.8
*/
function display_up_down_icon($content, $id, $list)
api_item_property_update($_course,$constants[$content],$id,$target_visibility,api_get_user_id()); // note: check if this returns true or false => returnmessage depends on it.
if ($target_visibility=='visible')
{
handle_mail_cue($content, $id);
}
return get_lang('VisibilityChanged');
}
/**
* This function changes the lock status in the database
*
* @param $content what is it that we want to (un)lock: forum category, forum, thread, post
* @param $id the id of the content we want to (un)lock
* @param $action do we lock (=>locked value in db = 1) or unlock (=> locked value in db = 0)
* @return string, language variable
*
* @todo move to itemmanager
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @version february 2006, dokeos 1.8
*/
function change_lock_status($content, $id, $action)
{
global $table_categories;
global $table_forums;
global $table_threads;
global $table_posts;
// Determine the relevant table
if ($content=='forumcategory')
{
$table=$table_categories;
$id_field='cat_id';
}
elseif ($content=='forum')
{
$table=$table_forums;
$id_field='forum_id';
}
elseif ($content=='thread')
{
$table=$table_threads;
$id_field='thread_id';
}
else
{
return get_lang('Error');
}
// Determine what we are doing => defines the value for the database and the return message
if ($action=='lock')
{
$db_locked=1;
$return_message=get_lang('Locked');
}
elseif ($action=='unlock')
{
$db_locked=0;
$return_message=get_lang('Unlocked');
}
else
{
return get_lang('Error');
}
// Doing the change in the database
$sql="UPDATE $table SET locked='".Database::escape_string($db_locked)."' WHERE $id_field='".Database::escape_string($id)."'";
if (api_sql_query($sql))
{
return $return_message;
}
else
{
return get_lang('Error');
}
}
/**
* This function moves a forum or a forum category up or down
*
* @param $content what is it that we want to make (in)visible: forum category, forum, thread, post
* @param $direction do we want to move it up or down.
* @param $id the id of the content we want to make invisible
* @todo consider removing the table_item_property calls here but this can prevent unwanted side effects when a forum does not have an entry in
* the item_property table but does have one in the forum table.
* @return
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @version february 2006, dokeos 1.8
*/
function move_up_down($content, $direction, $id)
{
global $table_categories;
global $table_forums;
global $table_item_property;
// Determine which field holds the sort order
if ($content=='forumcategory')
{
$table=$table_categories;
$sort_column='cat_order';
$id_column='cat_id';
$sort_column='cat_order';
}
elseif ($content=='forum')
{
$table=$table_forums;
$sort_column='forum_order';
$id_column='forum_id';
$sort_column='forum_order';
// we also need the forum_category of this forum
$sql="SELECT forum_category FROM $table_forums WHERE forum_id=".Database::escape_string($id);
$result=api_sql_query($sql);
$row=mysql_fetch_array($result);
$forum_category=$row['forum_category'];
}
else
{
return get_lang('Error');
}
// determine if need to sort ascending or descending
AND item_properties.tool='".TOOL_FORUM_CATEGORY."'
ORDER BY forum_categories.cat_order $sort_direction";
}
if ($content=='forum')
{
$sql="SELECT * FROM".$table." WHERE forum_category='".Database::escape_string($forum_category)."' ORDER BY forum_order $sort_direction";
}
// echo $sql.'<br/>';
// finding the items that need to be switched
$result=api_sql_query($sql);
$found=false;
while ($row=mysql_fetch_array($result))
{
//echo $row[$id_column].'-';
if ($found==true)
{
$next_id=$row[$id_column];
$next_sort=$row[$sort_column];
$found=false;
}
if($id==$row[$id_column])
{
$this_id=$id;
$this_sort=$row[$sort_column];
$found=true;
}
}
// Committing the switch
// we do an extra check if we do not have illegal values. If your remove this if statment you will
// be able to mess with the sorting by refreshing the page over and over again.
if ($this_sort<>'' AND $next_sort<>'' AND $next_id<>'' AND $this_id<>'')
{
$sql_update1="UPDATE $table SET $sort_column='".Database::escape_string($this_sort)."' WHERE $id_column='".Database::escape_string($next_id)."'";
$sql_update2="UPDATE $table SET $sort_column='".Database::escape_string($next_sort)."' WHERE $id_column='".Database::escape_string($this_id)."'";
api_sql_query($sql_update1);
api_sql_query($sql_update2);
}
return get_lang(ucfirst($content).'Moved');
}
/**
* This function returns a piece of html code that make the links grey (=invisible for the student)
*
* @param boolean 0/1: 0 = invisible, 1 = visible
* @return string
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @version february 2006, dokeos 1.8
*/
function class_visible_invisible($current_visibility_status)
{
if ($current_visibility_status=='0')
{
return "class='invisible'";
}
}
/**
* Retrieve all the information off the forum categories (or one specific) for the current course.
* The categories are sorted according to their sorting order (cat_order
*
* @param $id default ''. When an id is passed we only find the information about that specific forum category. If no id is passed we get all the forum categories.
* @return an array containing all the information about all the forum categories
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* This functions gets all the last post information of a certain forum
*
* @param $forum_id the id of the forum we want to know the last post information of.
* @param $show_invisibles
* @return array containing all the information about the last post (last_post_id, last_poster_id, last_post_date, last_poster_name, last_poster_lastname, last_poster_firstname)
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @version february 2006, dokeos 1.8
*/
function get_last_post_information($forum_id, $show_invisibles=false)
{
global $table_forums;
global $table_threads;
global $table_posts;
global $table_item_property;
global $table_users;
$sql="SELECT post.post_id, post.forum_id, post.poster_id, post.poster_name, post.post_date, users.lastname, users.firstname, post.visible, thread_properties.visibility AS thread_visibility, forum_properties.visibility AS forum_visibility
FROM $table_posts post, $table_users users, $table_item_property thread_properties, $table_item_property forum_properties
WHERE post.forum_id=".Database::escape_string($forum_id)."
AND post.poster_id=users.user_id
AND post.thread_id=thread_properties.ref
AND thread_properties.tool='".TOOL_FORUM_THREAD."'
last_poster_users.firstname as last_poster_firstname , last_poster_users.lastname as last_poster_lastname, last_poster_users.user_id as last_poster_user_id, thread.locked as locked
FROM $table_threads thread
INNER JOIN $table_item_property item_properties
ON thread.thread_id=item_properties.ref
AND item_properties.visibility='1'
AND item_properties.tool='".TOOL_FORUM_THREAD."'
LEFT JOIN $table_users users
ON thread.thread_poster_id=users.user_id
LEFT JOIN $table_posts post
ON thread.thread_last_post = post.post_id
LEFT JOIN $table_users last_poster_users
ON post.poster_id= last_poster_users.user_id
WHERE thread.forum_id='".Database::escape_string($forum_id)."'
ORDER BY thread.thread_sticky DESC, thread.thread_date DESC";
if (is_allowed_to_edit())
{
// important note: it might seem a little bit awkward that we have 'thread.locked as locked' in the sql statement
// because we also have thread.* in it. This is because thread has a field locked and post also has the same field
// since we are merging these we would have the post.locked value but in fact we want the thread.locked value
// This is why it is added to the end of the field selection
last_poster_users.firstname as last_poster_firstname , last_poster_users.lastname as last_poster_lastname, last_poster_users.user_id as last_poster_user_id, thread.locked as locked
FROM $table_threads thread
INNER JOIN $table_item_property item_properties
ON thread.thread_id=item_properties.ref
AND item_properties.visibility<>2
AND item_properties.tool='".TOOL_FORUM_THREAD."'
LEFT JOIN $table_users users
ON thread.thread_poster_id=users.user_id
LEFT JOIN $table_posts post
ON thread.thread_last_post = post.post_id
LEFT JOIN $table_users last_poster_users
ON post.poster_id= last_poster_users.user_id
WHERE thread.forum_id='".Database::escape_string($forum_id)."'
ORDER BY thread.thread_sticky DESC, thread.thread_date DESC";
}
$result=api_sql_query($sql);
while ($row=mysql_fetch_assoc($result))
{
$thread_list[]=$row;
}
return $thread_list;
}
/**
* Retrieve all posts of a given thread
*
* @return an array containing all the information about the posts of a given thread
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @version february 2006, dokeos 1.8
*/
function get_posts($thread_id)
{
global $table_posts;
global $table_users;
// note: change these SQL so that only the relevant fields of the user table are used
if (api_is_allowed_to_edit())
{
$sql = "SELECT * FROM $table_posts posts
LEFT JOIN $table_users users
ON posts.poster_id=users.user_id
WHERE posts.thread_id='".Database::escape_string($thread_id)."'
ORDER BY posts.post_id ASC";
}
else
{
// students can only se the posts that are approved (posts.visible='1')
$sql = "SELECT * FROM $table_posts posts
LEFT JOIN $table_users users
ON posts.poster_id=users.user_id
WHERE posts.thread_id='".Database::escape_string($thread_id)."'
AND posts.visible='1'
ORDER BY posts.post_id ASC";
}
$result=api_sql_query($sql, __FILE__, __LINE__);
while ($row=mysql_fetch_array($result))
{
$post_list[]=$row;
}
return $post_list;
}
/**
* This function return the html syntax for the image
*
* @param $image_url The url of the image (absolute or relative)
* @param $alt The alt text (when the images cannot be displayed). http://www.w3.org/TR/html4/struct/objects.html#adef-alt
* @param $title The title of the image. Most browsers display this as 'tool tip'. http://www.w3.org/TR/html4/struct/global.html#adef-title
*
* @todo this is the same as the Display::xxx function, so it can be removed => all calls have to be changed also
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* This function retrieves all the information of a post
*
* @param $forum_id integer that indicates the forum
* @return array returns
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @version february 2006, dokeos 1.8
*/
function get_post_information($post_id)
{
global $table_posts;
global $table_users;
$sql="SELECT * FROM ".$table_posts."posts, ".$table_users." users WHERE posts.poster_id=users.user_id AND posts.post_id='".Database::escape_string($post_id)."'";
$result=api_sql_query($sql);
$row=mysql_fetch_array($result);
return $row;
}
/**
* This function retrieves all the information of a thread
*
* @param $forum_id integer that indicates the forum
* @return array returns
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @version february 2006, dokeos 1.8
*/
function get_thread_information($thread_id)
{
global $table_threads;
global $table_item_property;
$sql="SELECT * FROM ".$table_threads." threads, ".$table_item_property." item_properties
WHERE item_properties.tool='".TOOL_FORUM_THREAD."'
AND item_properties.ref='".Database::escape_string($thread_id)."'
AND threads.thread_id='".Database::escape_string($thread_id)."'";
$result=api_sql_query($sql);
$row=mysql_fetch_array($result);
return $row;
}
/**
* This function retrieves all the information of a given forum_id
*
* @param $forum_id integer that indicates the forum
* @return array returns
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @version february 2006, dokeos 1.8
*
* @deprecated this functionality is now moved to get_forums($forum_id)
*/
function get_forum_information($forum_id)
{
global $table_forums;
global $table_item_property;
$sql="SELECT * FROM ".$table_forums." forums, ".$table_item_property." item_properties
WHERE item_properties.tool='".TOOL_FORUM."'
AND item_properties.ref='".Database::escape_string($forum_id)."'
AND forums.forum_id='".Database::escape_string($forum_id)."'";
$result=api_sql_query($sql);
$row=mysql_fetch_array($result);
$row['approval_direct_post'] = 0; // we can't anymore change this option, so it should always be activated
return $row;
}
/**
* This function retrieves all the information of a given forumcategory id
*
* @param $forum_id integer that indicates the forum
* @return array returns
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @version february 2006, dokeos 1.8
*/
function get_forumcategory_information($cat_id)
{
global $table_categories;
global $table_item_property;
$sql="SELECT * FROM ".$table_categories." forumcategories, ".$table_item_property." item_properties
WHERE item_properties.tool='".TOOL_FORUM_CATEGORY."'
AND item_properties.ref='".Database::escape_string($cat_id)."'
AND forumcategories.cat_id='".Database::escape_string($cat_id)."'";
$result=api_sql_query($sql);
$row=mysql_fetch_array($result);
return $row;
}
/**
* This function counts the number of forums inside a given category
*
* @param $cat_id the id of the forum category
* @todo an additional parameter that takes the visibility into account. For instance $countinvisible=0 would return the number
* of visible forums, $countinvisible=1 would return the number of visible and invisible forums
* @return int the number of forums inside the given category
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @version february 2006, dokeos 1.8
*/
function count_number_of_forums_in_category($cat_id)
{
global $table_forums;
$sql="SELECT count(*) AS number_of_forums FROM ".$table_forums." WHERE forum_category='".Database::escape_string($cat_id)."'";
$result=api_sql_query($sql);
$row=mysql_fetch_array($result);
return $row['number_of_forums'];
}
/**
* This function stores a new thread. This is done through an entry in the forum_thread table AND
* in the forum_post table because. The threads are also stored in the item_property table. (forum posts are not (yet))
*
* @param
* @return
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
// now have to update the thread table to fill the thread_last_post field (so that we know when the thread has been updated for the last time)
$sql="UPDATE $table_threads SET thread_last_post='".Database::escape_string($last_post_id)."' WHERE thread_id='".Database::escape_string($last_thread_id)."'";
$result=api_sql_query($sql, __LINE__, __FILE__);
$message=get_lang('NewThreadStored').'<br/>';
if ($current_forum['approval_direct_post']=='1' AND !api_is_allowed_to_edit())
* This function displays the form that is used to add a post. This can be a new thread or a reply.
* @param $action is the parameter that determines if we are
* 1. newthread: adding a new thread (both empty) => No I-frame
* 2. replythread: Replying to a thread ($action = replythread) => I-frame with the complete thread (if enabled)
* 3. replymessage: Replying to a message ($action =replymessage) => I-frame with the complete thread (if enabled) (I first thought to put and I-frame with the message only)
* 4. quote: Quoting a message ($action= quotemessage) => I-frame with the complete thread (if enabled). The message will be in the reply. (I first thought not to put an I-frame here)
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @version february 2006, dokeos 1.8
*/
function show_add_post_form($action='', $id='', $form_values='')
{
global $forum_setting;
global $current_forum;
global $_user;
global $origin;
// initiate the object
$form = new FormValidator('thread', 'post', api_get_self().'?forum='.Security::remove_XSS($_GET['forum']).'&thread='.Security::remove_XSS($_GET['thread']).'&post='.Security::remove_XSS($_GET['post']).'&action='.Security::remove_XSS($_GET['action']).'&origin='.$origin);
if ($forum_setting['allow_sticky'] and api_is_allowed_to_edit() and $current_post['post_parent_id']==0) // the sticky checkbox only appears when it is the first post of a thread
* The thread view counter gets increased every time someone looks at the thread
*
* @param
* @return
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @version february 2006, dokeos 1.8
*/
function increase_thread_view($thread_id)
{
global $table_threads;
$sql="UPDATE $table_threads SET thread_views=thread_views+1 WHERE thread_id='".Database::escape_string($thread_id)."'"; // this needs to be cleaned first
$result=api_sql_query($sql, __LINE__, __FILE__);
}
/**
* The relies counter gets increased every time somebody replies to the thread
*
* @param
* @return
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @version february 2006, dokeos 1.8
*/
function update_thread($thread_id, $last_post_id,$post_date)
{
global $table_threads;
$sql="UPDATE $table_threads SET thread_replies=thread_replies+1,
* This function is used to find all the information about what's new in the forum tool
*
* @param
* @return
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @version february 2006, dokeos 1.8
*/
function get_whats_new()
{
global $_user;
global $_course;
global $table_posts;
// note this has later to be replaced by the tool constant. But temporarily bb_forum is used since this is the only thing that is in the tracking currently.
$sql="SELECT * FROM ".$tracking_last_tool_access." WHERE access_user_id='".Database::escape_string($_user['user_id'])."' AND access_cours_code='".Database::escape_string($_course['sysCode'])."' AND access_tool='".Database::escape_string($tool)."'";
$sql="SELECT * FROM".$table_posts."WHERE post_date>'".Database::escape_string($_SESSION['last_forum_access'])."'"; // note: check the performance of this query.
* With this function we find the number of posts and topics in a given forum.
*
* @param
* @return
*
* @todo consider to call this function only once and let it return an array where the key is the forum id and the value is an array with number_of_topics and number of post
* as key of this array and the value as a value. This could reduce the number of queries needed (especially when there are more forums)
* @todo consider merging both in one query.
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @version february 2006, dokeos 1.8
*
* @deprecated the counting mechanism is now inside the function get_forums
*/
function get_post_topics_of_forum($forum_id)
{
global $table_posts;
global $table_threads;
global $table_item_property;
$sql="SELECT count(*) as number_of_posts FROM $table_posts WHERE forum_id='".$forum_id."'";
if (api_is_allowed_to_edit())
{
$sql="SELECT count(*) as number_of_posts
FROM $table_posts posts, $table_threads threads, $table_item_property item_property
WHERE posts.forum_id='".Database::escape_string($forum_id)."'
AND posts.thread_id=threads.thread_id
AND item_property.ref=threads.thread_id
AND item_property.visibility<>2
AND item_property.tool='".TOOL_FORUM_THREAD."'
";
}
else
{
$sql="SELECT count(*) as number_of_posts
FROM $table_posts posts, $table_threads threads, $table_item_property item_property
WHERE posts.forum_id='".Database::escape_string($forum_id)."'
AND posts.thread_id=threads.thread_id
AND item_property.ref=threads.thread_id
AND item_property.visibility=1
AND posts.visible=1
AND item_property.tool='".TOOL_FORUM_THREAD."'
";
}
$result=api_sql_query($sql);
$row=mysql_fetch_array($result);
$number_of_posts=$row['number_of_posts'];
// we could loop through the result array and count the number of different group_ids but I have chosen to use a second sql statement
if (api_is_allowed_to_edit())
{
$sql="SELECT count(*) as number_of_topics
FROM $table_threads threads, $table_item_property item_property
WHERE threads.forum_id='".Database::escape_string($forum_id)."'
AND item_property.ref=threads.thread_id
AND item_property.visibility<>2
AND item_property.tool='".TOOL_FORUM_THREAD."'
";
}
else
{
$sql="SELECT count(*) as number_of_topics
FROM $table_threads threads, $table_item_property item_property
WHERE threads.forum_id='".Database::escape_string($forum_id)."'
AND item_property.ref=threads.thread_id
AND item_property.visibility=1
AND item_property.tool='".TOOL_FORUM_THREAD."'
";
}
$result=api_sql_query($sql);
$row=mysql_fetch_array($result);
$number_of_topics=$row['number_of_topics'];
if ($number_of_topics=='')
{
$number_of_topics=0; // due to the nature of the group by this can result in an empty string.
if($current_thread['visibility']=='1' AND $current_forum['visibility']=='1' AND $current_forum_category['visibility']=='1' AND $current_forum['approval_direct_post']!='1')
{
$send_mails=true;
}
else
{
$send_mails=false;
}
// the forum category, the forum, the thread and the reply are visible to the user
$sql_delete_mailcue="DELETE FROM $table_mailcue WHERE post_id='".Database::escape_string($id)."' AND thread_id='".Database::escape_string($post_info['thread_id'])."'";
$sql="UPDATE $table_posts SET thread_id='".Database::escape_string($new_thread_id)."', post_parent_id='0' WHERE post_id='".Database::escape_string($values['post_id'])."'";
$result=api_sql_query($sql, __LINE__, __FILE__);
//echo $sql.'<br/>';
// resetting the parent_id of the thread to 0 for all those who had this moved post as parent
$sql="UPDATE $table_posts SET post_parent_id='0' WHERE post_parent_id='".Database::escape_string($values['post_id'])."'";
$result=api_sql_query($sql, __LINE__, __FILE__);
//echo $sql.'<br/>';
// updating updating the number of threads in the forum
$sql="UPDATE $table_forums SET forum_threads=forum_threads+1 WHERE forum_id='".Database::escape_string($current_post['forum_id'])."'";
$result=api_sql_query($sql, __LINE__, __FILE__);
//echo $sql.'<br/>';
// resetting the last post of the old thread and decreasing the number of replies and the thread
$sql="SELECT * FROM $table_posts WHERE thread_id='".Database::escape_string($current_post['thread_id'])."' ORDER BY post_id DESC";
//echo $sql.'<br/>';
$result=api_sql_query($sql, __LINE__, __FILE__);
$row=mysql_fetch_array($result);
//my_print_r($row);
$sql="UPDATE $table_threads SET thread_last_post='".$row['post_id']."', thread_replies=thread_replies-1 WHERE thread_id='".Database::escape_string($current_post['thread_id'])."'";
$result=api_sql_query($sql, __LINE__, __FILE__);
//echo $sql.'<br/>';
}
else
{
// moving to the chosen thread
$sql="UPDATE $table_posts SET thread_id='".Database::escape_string($_POST['thread'])."', post_parent_id='0' WHERE post_id='".Database::escape_string($values['post_id'])."'";
$result=api_sql_query($sql, __LINE__, __FILE__);
// resetting the parent_id of the thread to 0 for all those who had this moved post as parent
$sql="UPDATE $table_posts SET post_parent_id='0' WHERE post_parent_id='".Database::escape_string($values['post_id'])."'";
$result=api_sql_query($sql, __LINE__, __FILE__);
}
return get_lang('ThreadMoved');
}
/**
*
* @param
* @return
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @version february 2006, dokeos 1.8
*/
function store_move_thread($values)
{
global $table_posts;
global $table_threads;
global $table_forums;
global $_course;
// change the thread table: setting the forum_id to the new forum
$sql="UPDATE $table_threads SET forum_id='".Database::escape_string($_POST['forum'])."' WHERE thread_id='".Database::escape_string($_POST['thread_id'])."'";
$result=api_sql_query($sql, __LINE__, __FILE__);
// changing all the posts of the thread: setting the forum_id to the new forum
$sql="UPDATE $table_posts SET forum_id='".Database::escape_string($_POST['forum'])."' WHERE thread_id='".Database::escape_string($_POST['thread_id'])."'";
$result=api_sql_query($sql, __LINE__, __FILE__);
return get_lang('ThreadMoved');
}
/**
* Prepares a string or an array of strings for display by stripping slashes
* @param mixed String or array of strings
* @return mixed String or array of strings
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
if ($forum_categories_list[$row['forum_id']['forum_category']]['visibility'] == '1' AND $forum_list[$row['forum_id']]['visibility'] == '1' AND $row['visible'] == '1')