diff --git a/main/wiki/index.php b/main/wiki/index.php
index dddacc0c2f..febcff1546 100644
--- a/main/wiki/index.php
+++ b/main/wiki/index.php
@@ -240,17 +240,83 @@ if ($_GET['view'])
$result=api_sql_query($sql,__LINE__,__FILE__);
$last_row=Database::fetch_array($result);
- if ($_GET['view']<$last_row['id'])
- {
- $message= '('.$current_row['version'].' / '.$last_row['version'].') '.get_lang('NoAreSeeingTheLastVersion').'
'.get_lang("ConvertToLastVersion").': '.get_lang("Restore").'';
-
- Display::display_warning_message($message,false);
- }
- if ($_GET['action']=='restorepage')
- {
- Display::display_confirmation_message(restore_wikipage($current_row['reflink'], $current_row['title'], $current_row['content'], $current_row['group_id'], $current_row['assignment'], $current_row['comment'], $current_row['progress'], $last_row['version'], $current_row['linksto']).': '.$last_row['title'].'',false);
-
- }
+ if ($_GET['view']<$last_row['id'])
+ {
+ $message= '('.$current_row['version'].' / '.$last_row['version'].') '.get_lang('NoAreSeeingTheLastVersion').'
'.get_lang("ConvertToLastVersion").': '.get_lang("Restore").'';
+
+ Display::display_warning_message($message,false);
+ }
+
+ ///restore page
+ if ($_GET['action']=='restorepage')
+ {
+ //Only teachers and platform admin can edit the index page. Only teachers and platform admin can edit an assignment teacher
+ if(($current_row['reflink']=='index' || $current_row['reflink']=='' || $current_row['assignment']==1) && (!api_is_allowed_to_edit()))
+ {
+ Display::display_normal_message(get_lang('OnlyEditPagesCourseManager'));
+ }
+ else
+ {
+ $PassEdit=false;
+
+ //check if is a wiki group
+ if($current_row['group_id']!=0)
+ {
+ //Only teacher, platform admin and group members can edit a wiki group
+ if(api_is_allowed_to_edit() || api_is_platform_admin() || GroupManager :: is_user_in_group($_user['user_id'],$_SESSION['_gid']))
+ {
+ $PassEdit=true;
+ }
+ else
+ {
+ Display::display_normal_message(get_lang('OnlyEditPagesGroupMembers'));
+ }
+ }
+ else
+ {
+ $PassEdit=true;
+ }
+
+ // check if is a assignment
+ if(stripslashes($current_row['assignment'])==1)
+ {
+ Display::display_normal_message(get_lang('EditAssignmentWarning'));
+ $icon_assignment='
';
+ }
+ elseif(stripslashes($current_row['assignment'])==2)
+ {
+ $icon_assignment='
';
+ if((api_get_user_id()==$current_row['user_id'])==false)
+ {
+ if(api_is_allowed_to_edit() || api_is_platform_admin())
+ {
+ $PassEdit=true;
+ }
+ else
+ {
+ Display::display_warning_message(get_lang('LockByTeacher'));
+ $PassEdit=false;
+ }
+ }
+ else
+ {
+ $PassEdit=true;
+ }
+ }
+
+ if($PassEdit) //show editor if edit is allowed
+ {
+ if (check_protect_page() && (api_is_allowed_to_edit()==false || api_is_platform_admin()==false))
+ {
+ Display::display_normal_message(get_lang('PageLockedExtra'));
+ }
+ else
+ {
+ Display::display_confirmation_message(restore_wikipage($current_row['reflink'], $current_row['title'], $current_row['content'], $current_row['group_id'], $current_row['assignment'], $current_row['comment'], $current_row['progress'], $last_row['version'], $current_row['linksto']).': '.$last_row['title'].'',false);
+ }
+ }
+ }
+ }
}
@@ -731,7 +797,7 @@ if ($_GET['action']=='wanted')
{
if(!in_array($v, $pages))
{
- if (trim($v)!=="")
+ if (trim($v)!="")
{
echo '