'; + echo ''.get_lang('DeletePageHistory').''; + echo '
'; + $message = get_lang('ConfirmDeletePage').""."
"."".get_lang("No").""." | "."".get_lang("Yes").""."
"; + + if (!isset ($_GET['delete'])) + { + Display::display_warning_message($message,false); + } + + if ($_GET['delete'] == 'yes') + { + $sql='DELETE FROM '.$tbl_wiki.' WHERE reflink="'.html_entity_decode(Database::escape_string(stripslashes(urldecode($page)))).'" AND '.$groupfilter.' ORDER BY id DESC'; + api_sql_query($sql,__FILE__,__LINE__); + + //// + //here to do: delete discussion and mailcue too + /// + + Display::display_confirmation_message(get_lang('WikiPageDeleted')); + } + } + else + { + Display::display_normal_message(get_lang("OnlyAdminDeletePageWiki")); + } +} + + +/////////////////////// delete all wiki /////////////////////// Juan Carlos Raña Trabado + +if ($_GET['action']=='deletewiki') +{ + echo ''; + echo ''.get_lang('DeleteWiki').''; + echo '
'; +} + + +/////////////////////// search pages /////////////////////// Juan Carlos Raña Trabado + +if ($_GET['action']=='searchpages') +{ + echo '
'; + echo ''.$SearchPages.''; + echo '
'; + + if (!$_POST['Skeyword']) + { + echo ''; + } + else + { + if($_POST['Scontent']=="1") + { + $sql="SELECT * FROM ".$tbl_wiki." WHERE ".$groupfilter." AND title LIKE '%".$_POST['Skeyword']."%' OR content LIKE '%".$_POST['Skeyword']."%' GROUP BY reflink ORDER BY title ASC"; + } + else + { + $sql="SELECT * FROM ".$tbl_wiki." WHERE ".$groupfilter." AND title LIKE '%".$_POST['Skeyword']."%' GROUP BY reflink ORDER BY title ASC"; + } + + //show result + $_clean['group_id']=(int)$_SESSION['_gid']; + $result=api_sql_query($sql,__LINE__,__FILE__); + + echo '
- ';
+
+ while ($row=Database::fetch_array($result))
+ {
+ $userinfo=Database::get_user_info_from_id($row['user_id']);
+
+ //Show page to students if not is hidden. Show page to all teachers if is hidden. Mode assignments: show pages to student only if student it the author
+ if($row['visibility']==1 || api_is_allowed_to_edit() || api_is_platform_admin() || ($row['assignment']==2 && $row['visibility']==0 && (api_get_user_id()==$row['user_id'])))
+ {
+ $year = substr($row['timestamp'], 0, 4);
+ $month = substr($row['timestamp'], 5, 2);
+ $day = substr($row['timestamp'], 8, 2);
+ $hours=substr($row['timestamp'], 11,2);
+ $minutes=substr($row['timestamp'], 14,2);
+ $seconds=substr($row['timestamp'], 17,2);
+
+ //show teacher assignment
+ if($row['assignment']==1)
+ {
+ //teachers assigment pages only list for teachers
+ if(api_is_allowed_to_edit() || api_is_platform_admin())
+ {
+ $ShowAssignment='
- '; + echo ''.$ShowAssignment.$row['title'].''; + + echo '...'.$userinfo['lastname'].', '.$userinfo['firstname']; + echo '...'.$day.' '.$MonthsLong[$month-1].' '.$year.' '.$hours.":".$minutes.":".$seconds.' '; + + } + } + //show student assignment + if ($row['assignment']==2) + { + //student assignment pages only list for each student author and for teachers + if ($row['user_id']==(int)api_get_user_id() || api_is_allowed_to_edit() || api_is_platform_admin()) + { + $ShowAssignment='
- '; + echo ''.$ShowAssignment.$row['title'].''; + + echo '...'.$userinfo['lastname'].', '.$userinfo['firstname']; + echo '...'.$day.' '.$MonthsLong[$month-1].' '.$year.' '.$hours.":".$minutes.":".$seconds.' '; + } + } + //show wiki pages standard + if ($row['assignment']==0) + { + $ShowAssignment='
- '; + echo ''.$ShowAssignment.$row['title'].''; + + if ($row['user_id']<>0) + { + echo '...'.$userinfo['lastname'].', '.$userinfo['firstname']; + } + else + { + echo get_lang('Anonymous').' ('.$row[user_ip].')'; + } + echo '...'.$day.' '.$MonthsLong[$month-1].' '.$year.' '.$hours.":".$minutes.":".$seconds.' '; + } + } + } + echo '
';
+ echo '
';
+ echo '
';
+ echo ''; + echo ''.$LinksPages.''; + echo '
'; + + if (!$_GET['title']) + { + Display::display_normal_message(get_lang("MustSelectPage")); + } + else + { + + $sql='SELECT * FROM '.$tbl_wiki.' WHERE reflink="'.html_entity_decode(Database::escape_string(stripslashes(urldecode($page)))).'" AND '.$groupfilter.''; + $result=api_sql_query($sql,__FILE__,__LINE__); //necessary for pages with compound name + + $row=Database::fetch_array($result); + echo $LinksPagesFrom.': '.$row['title'].''; + + + if ($page==get_lang('DefaultTitle')) + { + $page='index'; + } + + $sql="SELECT * FROM ".$tbl_wiki." WHERE ".$groupfilter." AND linksto LIKE '%".html_entity_decode(Database::escape_string(stripslashes(urldecode($page))))."%' GROUP BY reflink ORDER BY title ASC"; + $result=api_sql_query($sql,__LINE__,__FILE__); + + //show result + + echo '
- ';
+
+ while ($row=Database::fetch_array($result))
+ {
+ $userinfo=Database::get_user_info_from_id($row['user_id']);
+
+ //Show page to students if not is hidden, but the author can see. Show page to all teachers if is hidden. Mode assignments: show pages to student only if student is the author
+ if($row['visibility']==1 || api_is_allowed_to_edit() || api_is_platform_admin() || ($row['assignment']==2 && $row['visibility']==0 && (api_get_user_id()==$row['user_id'])))
+ {
+ $year = substr($row['timestamp'], 0, 4);
+ $month = substr($row['timestamp'], 5, 2);
+ $day = substr($row['timestamp'], 8, 2);
+ $hours=substr($row['timestamp'], 11,2);
+ $minutes=substr($row['timestamp'], 14,2);
+ $seconds=substr($row['timestamp'], 17,2);
+
+ //Description assignments visible for all teachers
+ if($row['assignment']==1)
+ {
+ if(api_is_allowed_to_edit() || api_is_platform_admin())
+ {
+ $ShowAssignment='
- '; + echo ''.$ShowAssignment.$row['title'].''; + echo '...'.$userinfo['lastname'].', '.$userinfo['firstname']; + echo '...'.$day.' '.$MonthsLong[$month-1].' '.$year.' '.$hours.":".$minutes.":".$seconds.' '; + } + } + + //Work on the assignments visible for each student + if ($row['assignment']==2) + { + if ($row['user_id']==(int)api_get_user_id() || api_is_allowed_to_edit() || api_is_platform_admin()) + { + $ShowAssignment='
- '; + echo ''.$ShowAssignment.$row['title'].''; + echo '...'.$userinfo['lastname'].', '.$userinfo['firstname']; + echo '...'.$day.' '.$MonthsLong[$month-1].' '.$year.' '.$hours.":".$minutes.":".$seconds.' '; + } + } + + //show wiki pages standard + if ($row['assignment']==0) + { + $ShowAssignment='
- '; + echo ''.$ShowAssignment.$row['title'].''; + + if ($row['user_id']<>0) + { + echo '...'.$userinfo['lastname'].', '.$userinfo['firstname']; + } + else + { + echo get_lang('Anonymous').' ('.$row[user_ip].')'; + } + + echo '...'.$day.' '.$MonthsLong[$month-1].' '.$year.' '.$hours.":".$minutes.":".$seconds.' '; + } + } + } + + echo '
';
+ echo '
';
+ echo '
';
+ echo ''; + echo ''.get_lang('AddNew').''; + echo '
'; + display_new_wiki_form(); + + } + else + { + Display::display_normal_message(get_lang('OnlyAddPagesGroupMembers')); + } + } + else + { + echo '
'; + echo ''.get_lang('AddNew').''; + echo '
'; + display_new_wiki_form(); + } + } +} + + + +/////////////////////// show home page /////////////////////// + +if (!$_GET['action'] OR $_GET['action']=='show' AND !$_POST['SaveWikiNew']) +{ + display_wiki_entry(); +} + + +/////////////////////// show current page /////////////////////// + +if ($_GET['action']=='showpage' AND !$_POST['SaveWikiNew']) +{ + display_wiki_entry(); +} + + +/////////////////////// edit current page /////////////////////// + +if ($_GET['action']=='edit') +{ + $_clean['group_id']=(int)$_SESSION['_gid']; + + $sql='SELECT * FROM '.$tbl_wiki.'WHERE reflink="'.html_entity_decode(Database::escape_string(stripslashes(urldecode($page)))).'" AND '.$groupfilter.' ORDER BY id DESC'; + $result=api_sql_query($sql,__LINE__,__FILE__); + $row=Database::fetch_array($result); // we do not need a while loop since we are always displaying the last version + + //Only teachers and platform admin can edit the index page. Only teachers and platform admin can edit an assignment teacher + if(($row['reflink']=='index' || $row['assignment']==1) && (!api_is_allowed_to_edit() || !api_is_platform_admin())) + { + + Display::display_normal_message(get_lang('OnlyEditPagesCourseManager')); + + } + else + { + $PassEdit=false; + + if(stripslashes($row['assignment'])==1) + { + Display::display_normal_message(get_lang('EditAssignmentWarning')); + $icon_assignment='
';
+ }
+ elseif(stripslashes($row['assignment'])==2)
+ {
+ $icon_assignment='
';
+ }
+
+ //check if is a wiki group
+ if($_clean['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;
+ }
+
+ 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
+ {
+ if ($row['content']=='' AND $row['title']=='' AND $page='index')
+ {
+ $content=get_lang('DefaultContent');
+ $title=get_lang('DefaultTitle');
+ }
+ else
+ {
+ $content=$row['content'];
+ $title=$row['title'];
+ }
+ echo '
';
+ }
+ elseif($KeyAssignment==2)
+ {
+ $icon_assignment='
';
+ }
+
+
+ //Second, show
+
+ //if the page is hidden and is a job only sees its author and professor
+ if($KeyVisibility==1 || api_is_allowed_to_edit() || api_is_platform_admin() || ($KeyAssignment==2 && $KeyVisibility==0 && (api_get_user_id()==$KeyUserId)))
+ {
+ // We show the complete history
+ if (!$_POST['HistoryDifferences'] && !$_POST['HistoryDifferences2'] )
+ {
+
+ $sql='SELECT * FROM '.$tbl_wiki.'WHERE reflink="'.html_entity_decode(Database::escape_string(stripslashes(urldecode($page)))).'" AND '.$groupfilter.' ORDER BY id DESC';
+ $result=api_sql_query($sql,__LINE__,__FILE__);
+
+ $title=Security::remove_XSS($_GET['title']);
+ $group_id=Security::remove_XSS($_GET['group_id']);
+
+ echo ''; + + if($_POST['HistoryDifferences']) + { + echo '
'.get_lang('HomeWiki').'





'.get_lang('Page').'
'.get_lang('EditPage').'
'.get_lang('Discuss').'
'.get_lang('History').'
'.$LinksPages.'
'.get_lang('Delete').'
'.get_lang('ShowDiscuss').'';
+ }
+ }
+ else
+ {
+ if(api_is_allowed_to_edit() || api_is_platform_admin())
+ {
+ $visibility_disc= '
'.get_lang('HideDiscuss').'';
+ }
+ }
+
+ //check add messages lock.
+ if (check_addlock_discuss())
+ {
+ $addlock_disc= '
'.get_lang('UnlockDiscuss').'';
+ }
+ else
+ {
+ if(api_is_allowed_to_edit() || api_is_platform_admin())
+ {
+ $addlock_disc= '
'.get_lang('LockDiscuss').'';
+ }
+ }
+
+ //check add rating lock. Show/Hide list to rating for all student
+ if (check_ratinglock_discuss())
+ {
+ //Mode assignment: check. to do
+ if(($row['assignment']==2 && $row['ratinglock_disc']==0 && (api_get_user_id()==$row['user_id']))==false)
+ {
+ $ratinglock_disc= '
'.get_lang('UnlockRatingDiscuss').'';
+ }
+ }
+ else
+ {
+ if(api_is_allowed_to_edit() || api_is_platform_admin())
+ {
+ $ratinglock_disc= '
'.get_lang('LockRatingDiscuss').'';
+ }
+ }
+
+ //check notify by email
+ if (check_notify_discuss())
+ {
+ $notify_disc= '
'.get_lang('NotifyDiscussChanges').'';
+ }
+ else
+ {
+ $notify_disc= '
'.get_lang('NotNotifyDiscussChanges').'';
+ }
+
+ //mode assignment: previous to show page type
+ if(stripslashes($row['assignment'])==1)
+ {
+ $icon_assignment='
';
+ break;
+ case 1:
+ $imagerating='
';
+ break;
+ case 2:
+ $imagerating='
';
+ break;
+ case 3:
+ $imagerating='
';
+ break;
+ case 4:
+ $imagerating='
';
+ break;
+ case 5:
+ $imagerating='
';
+ break;
+ case 6:
+ $imagerating='
';
+ break;
+ case 7:
+ $imagerating='
';
+ break;
+ case 8:
+ $imagerating='
';
+ break;
+ case 9:
+ $imagerating='
';
+ break;
+ case 10:
+ $imagerating='
';
+ break;
+ }
+
+ echo '
'.get_lang('ShowAddOption').'';
+ }
+ }
+ else
+ {
+ if(api_is_allowed_to_edit() || api_is_platform_admin())
+ {
+ $protect_addnewpage= '
'.get_lang('HideAddOption').'';
+ }
+ }
+
+ //Button lock page
+ if (check_protect_page())
+ {
+ $protect_page= '
';
+ echo '';
+
+ //export to zip
+
+ echo '