// I have split this is several pieces for clarity.
//if (!api_is_allowed_to_edit() AND (($current_forum_category['visibility']==0 OR $current_forum['visibility']==0) OR ($current_forum_category['locked']<>0 OR $current_forum['locked']<>0 OR $current_thread['locked']<>0)))
if (!api_is_allowed_to_edit() AND (($current_forum_category['visibility']==0 OR $current_forum['visibility']==0)))
if (!api_is_allowed_to_edit(false,true) AND (($current_forum_category['visibility']==0 OR $current_forum['visibility']==0)))
{
forum_not_allowed_here();
}
if (!api_is_allowed_to_edit() AND ($current_forum_category['locked']<>0 OR $current_forum['locked']<>0 OR $current_thread['locked']<>0))
if (!api_is_allowed_to_edit(false,true) AND ($current_forum_category['locked']<>0 OR $current_forum['locked']<>0 OR $current_thread['locked']<>0))
{
forum_not_allowed_here();
}
if (!$_user['user_id'] AND $current_forum['allow_anonymous']==0)
{
forum_not_allowed_here();
forum_not_allowed_here(false,true);
}
if (!api_is_allowed_to_edit() AND $current_forum['allow_edit']==0)
if (!api_is_allowed_to_edit(false,true) AND $current_forum['allow_edit']==0)
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
if ($forum_setting['allow_sticky'] and api_is_allowed_to_edit(false,true) and $current_post['post_parent_id']==0) // the sticky checkbox only appears when it is the first post of a thread
@ -2125,7 +2142,7 @@ function show_edit_post_form($current_post, $current_thread, $current_forum, $fo
$defaults['thread_sticky']=true;
}
}
if ($current_forum['allow_attachments']=='1' OR api_is_allowed_to_edit())
if ($current_forum['allow_attachments']=='1' OR api_is_allowed_to_edit(false,true))
{
if (empty($form_values) AND !$_POST['SubmitPost'])
{
@ -2394,7 +2411,7 @@ function get_post_topics_of_forum($forum_id)
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())
if (api_is_allowed_to_edit(false,true))
{
$sql="SELECT count(*) as number_of_posts
FROM $table_posts posts, $table_threads threads, $table_item_property item_property
@ -2422,7 +2439,7 @@ function get_post_topics_of_forum($forum_id)
$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())
if (api_is_allowed_to_edit(false,true))
{
$sql="SELECT count(*) as number_of_topics
FROM $table_threads threads, $table_item_property item_property
@ -3036,7 +3053,7 @@ function display_forum_search_results($search_term)
3. thread is visible (to do)
4. post is visible
*/
if (!api_is_allowed_to_edit())
if (!api_is_allowed_to_edit(false,true))
{
if ($forum_categories_list[$row['forum_id']['forum_category']]['visibility'] == '1' AND $forum_list[$row['forum_id']]['visibility'] == '1' AND $row['visible'] == '1')
{
@ -3190,7 +3207,7 @@ function get_forums_of_group($group_id)
GROUP BY threads.forum_id";
//-------------- Course Admin -----------------//
if (is_allowed_to_edit())
if (is_allowed_to_edit(false,true))
{
// select all the forum information of all forums (that are not deleted)
$sql="SELECT * FROM ".$table_forums." forum , ".$table_item_property." item_properties
@ -3250,7 +3267,7 @@ function get_forums_of_group($group_id)
// I have split this is several pieces for clarity.
//if (!api_is_allowed_to_edit() AND (($current_forum_category['visibility']==0 OR $current_forum['visibility']==0) OR ($current_forum_category['locked']<>0 OR $current_forum['locked']<>0 OR $current_thread['locked']<>0)))
if (!api_is_allowed_to_edit() AND (($current_forum_category['visibility']==0 OR $current_forum['visibility']==0)))
if (!api_is_allowed_to_edit(false,true) AND (($current_forum_category['visibility']==0 OR $current_forum['visibility']==0)))
{
forum_not_allowed_here();
}
if (!api_is_allowed_to_edit() AND ($current_forum_category['locked']<>0 OR $current_forum['locked']<>0 OR $current_thread['locked']<>0))
if (!api_is_allowed_to_edit(false,true) AND ($current_forum_category['locked']<>0 OR $current_forum['locked']<>0 OR $current_thread['locked']<>0))
// Change visibility of a forum or a forum category
if (($_GET['action']=='invisible' OR $_GET['action']=='visible') AND isset($_GET['content']) AND isset($_GET['id']) AND api_is_allowed_to_edit())
if (($_GET['action']=='invisible' OR $_GET['action']=='visible') AND isset($_GET['content']) AND isset($_GET['id']) AND api_is_allowed_to_edit(false,true))
{
$message=change_visibility($_GET['content'], $_GET['id'],$_GET['action']);// note: this has to be cleaned first
}
// locking and unlocking
if (($_GET['action']=='lock' OR $_GET['action']=='unlock') AND isset($_GET['content']) AND isset($_GET['id']) AND api_is_allowed_to_edit())
if (($_GET['action']=='lock' OR $_GET['action']=='unlock') AND isset($_GET['content']) AND isset($_GET['id']) AND api_is_allowed_to_edit(false,true))
{
$message=change_lock_status($_GET['content'], $_GET['id'],$_GET['action']);// note: this has to be cleaned first
}
// deleting
if ($_GET['action']=='delete' AND isset($_GET['content']) AND isset($_GET['id']) AND api_is_allowed_to_edit())
if ($_GET['action']=='delete' AND isset($_GET['content']) AND isset($_GET['id']) AND api_is_allowed_to_edit(false,true))
{
$message=delete_forum_forumcategory_thread($_GET['content'],$_GET['id']); // note: this has to be cleaned first
}
// moving
if ($_GET['action']=='move' and isset($_GET['thread']) AND api_is_allowed_to_edit())
if ($_GET['action']=='move' and isset($_GET['thread']) AND api_is_allowed_to_edit(false,true))
{
$message=move_thread_form();
}
@ -156,7 +156,7 @@ if ($_GET['action'] == 'notify' AND isset($_GET['content']) AND isset($_GET['id'
*/
// if the user is not a course administrator and the forum is hidden
// then the user is not allowed here.
if (!api_is_allowed_to_edit() AND ($current_forum_category['visibility']==0 OR $current_forum['visibility']==0))
if (!api_is_allowed_to_edit(false,true) AND ($current_forum_category['visibility']==0 OR $current_forum['visibility']==0))
// 2. the course member is here and new threads are allowed
// 3. a visitor is here and new threads AND allowed AND anonymous posts are allowed
if (api_is_allowed_to_edit() OR ($current_forum['allow_new_threads']==1 AND isset($_user['user_id'])) OR ($current_forum['allow_new_threads']==1 AND !isset($_user['user_id']) AND $current_forum['allow_anonymous']==1))
if (api_is_allowed_to_edit(false,true) OR ($current_forum['allow_new_threads']==1 AND isset($_user['user_id'])) OR ($current_forum['allow_new_threads']==1 AND !isset($_user['user_id']) AND $current_forum['allow_anonymous']==1))
{
if ($current_forum['locked'] <> 1 AND $current_forum['locked'] <> 1)
{
@ -247,7 +247,7 @@ if(is_array($threads))
foreach ($threads as $row)
{
// thread who have no replies yet and the only post is invisible should not be displayed to students.
if (api_is_allowed_to_edit() OR !($row['thread_replies']=='0' AND $row['visible']=='0'))
if (api_is_allowed_to_edit(false,true) OR !($row['thread_replies']=='0' AND $row['visible']=='0'))
{
if($counter%2==0)
{
@ -305,7 +305,7 @@ if(is_array($threads))
}
// if the last post is invisible and it is not the teacher who is looking then we have to find the last visible post of the thread
if (($row['visible']=='1' OR api_is_allowed_to_edit()) && $origin!='learnpath')
if (($row['visible']=='1' OR api_is_allowed_to_edit(false,true)) && $origin!='learnpath')
if (api_is_allowed_to_edit() OR ($current_forum['allow_new_threads']==1 AND isset($_user['user_id'])) OR ($current_forum['allow_new_threads']==1 AND !isset($_user['user_id']) AND $current_forum['allow_anonymous']==1))
if (api_is_allowed_to_edit(false,true) OR ($current_forum['allow_new_threads']==1 AND isset($_user['user_id'])) OR ($current_forum['allow_new_threads']==1 AND !isset($_user['user_id']) AND $current_forum['allow_anonymous']==1))
{
if ($current_forum['locked'] <> 1 AND $current_forum['locked'] <> 1)