diff --git a/main/wiki/index.php b/main/wiki/index.php
index c0bf3ac4bc..f6edd65722 100644
--- a/main/wiki/index.php
+++ b/main/wiki/index.php
@@ -77,7 +77,7 @@ api_block_anonymous_users();
TRACKING
-----------------------------------------------------------
*/
-event_access_tool('TOOL_WIKI');
+event_access_tool(TOOL_WIKI);
/*
-----------------------------------------------------------
@@ -288,7 +288,7 @@ echo '
";
if ($_GET['action']=='more')
{
-//to do
+ echo '
';
+ echo '
'.get_lang('More').' ';
+ echo '
';
+ if(api_is_allowed_to_edit() || api_is_platform_admin())
+ {
+ //TODO
+
+ }
+ //TODO
}
@@ -369,7 +377,7 @@ if ($_GET['action']=='delete')
api_sql_query($sql,__FILE__,__LINE__);
////
- //here to do: delete discussion and mailcue too
+ //here TODO: delete discussion and mailcue too
///
check_emailcue(0, 'E');
@@ -603,8 +611,15 @@ if ($_GET['action']=='addnew')
//first, check if page index was created. chektitle=false
if (checktitle('index'))
- {
- Display::display_normal_message(get_lang('GoAndEditMainPage'));
+ {
+ if(api_is_allowed_to_edit() || api_is_platform_admin())
+ {
+ Display::display_normal_message(get_lang('GoAndEditMainPage'));
+ }
+ else
+ {
+ return Display::display_normal_message(get_lang('WikiStandBy'));
+ }
}
elseif (check_addnewpagelock() && (api_is_allowed_to_edit()==false || api_is_platform_admin()==false))
@@ -667,7 +682,7 @@ if ($_GET['action']=='edit')
$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()))
+ if(($row['reflink']=='index' || $row['reflink']=='' || $row['assignment']==1) && (!api_is_allowed_to_edit() || !api_is_platform_admin()))
{
Display::display_normal_message(get_lang('OnlyEditPagesCourseManager'));
@@ -739,8 +754,10 @@ if ($_GET['action']=='edit')
//}
echo '
';
- //echo '
'; //off for now
- //echo '
'; //off for now
+ //echo '
'; //off for now
+ //echo '
'; //off for now
+ //echo '
'; //off for now
+
echo '
'; //get current version
echo get_lang('Progress').':
';
echo ''.stripslashes($row['progress']).' ';
@@ -771,7 +788,7 @@ if ($_GET['action']=='history' or Security::remove_XSS($_POST['HistoryDifference
{
$_clean['group_id']=(int)$_SESSION['_gid'];
- //First, see the property visibility that is at the last register and therefore we should select descending order. But to give ownership to each record, this is no longer necessary except for the title. TO DO: check this
+ //First, see the property visibility that is at the last register and therefore we should select descending order. But to give ownership to each record, this is no longer necessary except for the title. TODO: check this
$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__);
@@ -929,8 +946,8 @@ if ($_GET['action']=='history' or Security::remove_XSS($_POST['HistoryDifference
if($_POST['HistoryDifferences2'])
{
- $lines1 = array(stripslashes($version_old['content'])); //it may not be necessary stripslashes. to do
- $lines2 = array(stripslashes($version_new['content'])); //it may not be necessary stripslashes. to do
+ $lines1 = array(stripslashes($version_old['content'])); //it may not be necessary stripslashes. TODO
+ $lines2 = array(stripslashes($version_new['content'])); //it may not be necessary stripslashes. TODO
$diff = &new Text_Diff($lines1, $lines2);
@@ -959,7 +976,7 @@ if ($_GET['action']=='history' or Security::remove_XSS($_POST['HistoryDifference
/////////////////////// recent changes ///////////////////////
//
-//rss feed. to do
+//rss feed. TODO
//
if ($_GET['action']=='recentchanges')
@@ -1169,7 +1186,7 @@ if ($_GET['action']=='discuss')
//check add rating lock. Show/Hide list to rating for all student
if (check_ratinglock_discuss())
{
- //Mode assignment: check. to do
+ //Mode assignment: check. TODO
if(($row['assignment']==2 && $row['ratinglock_disc']==0 && (api_get_user_id()==$row['user_id']))==false)
{
$ratinglock_disc= ''.get_lang('UnlockRatingDiscuss').' ';
@@ -1186,11 +1203,11 @@ if ($_GET['action']=='discuss')
//check notify by email
if (check_notify_discuss($page))
{
- $notify_disc= ''.get_lang('NotifyDiscussChanges').' ';
+ $notify_disc= ''.get_lang('NotifyDiscussChanges').' ';
}
else
{
- $notify_disc= ''.get_lang('NotNotifyDiscussChanges').' ';
+ $notify_disc= ''.get_lang('NotNotifyDiscussChanges').' ';
}
//mode assignment: previous to show page type
@@ -1211,7 +1228,7 @@ if ($_GET['action']=='discuss')
if($row['visibility_disc']==1 || api_is_allowed_to_edit() || api_is_platform_admin() || ($row['assignment']==2 && $row['visibility_disc']==0 && (api_get_user_id()==$row['user_id'])))
{
echo '';
if($row['addlock_disc']==1 || api_is_allowed_to_edit() || api_is_platform_admin()) //show comments but students can't add theirs
@@ -1291,7 +1308,7 @@ if ($_GET['action']=='discuss')
echo ' - '.get_lang('RatingMedia').': '.$avg_WPost_score; // average rating
- $sql='UPDATE '.$tbl_wiki.' SET score="'.Database::escape_string($avg_WPost_score).'" WHERE reflink="'.html_entity_decode(Database::escape_string(stripslashes(urldecode($page)))).'" AND '.$groupfilter; // check if work ok. to do
+ $sql='UPDATE '.$tbl_wiki.' SET score="'.Database::escape_string($avg_WPost_score).'" WHERE reflink="'.html_entity_decode(Database::escape_string(stripslashes(urldecode($page)))).'" AND '.$groupfilter; // check if work ok. TODO
api_sql_query($sql,__FILE__,__LINE__);
echo ' ';
@@ -1439,7 +1456,7 @@ function checktitle($paramwk)
global $tbl_wiki;
global $groupfilter;
- $sql='SELECT * FROM '.$tbl_wiki.' WHERE reflink="'.html_entity_decode(Database::escape_string(stripslashes(urldecode($paramwk)))).'" AND '.$groupfilter.''; // to do: check if need entity
+ $sql='SELECT * FROM '.$tbl_wiki.' WHERE reflink="'.html_entity_decode(Database::escape_string(stripslashes(urldecode($paramwk)))).'" AND '.$groupfilter.''; // TODO: check if need entity
$result=api_sql_query($sql,__FILE__,__LINE__);
$numberofresults=Database::num_rows($result);
@@ -1592,6 +1609,7 @@ function save_wiki()
$_clean['progress']=Database::escape_string($_POST['progress']);
$_clean['startdate_assig']=Database::escape_string($_POST['startdate_assig']);
$_clean['enddate_assig']=Database::escape_string($_POST['enddate_assig']);
+ $_clean['delayedsubmit']=Database::escape_string($_POST['delayedsubmit']);
$_clean['version']=Database::escape_string($_POST['version'])+1;
$_clean['linksto'] = links_to($_clean['content']); //and check links content
@@ -1608,11 +1626,11 @@ function save_wiki()
if ($_clean['group_id'])
{
- $sql="INSERT INTO ".$tbl_wiki." (reflink, title,content,user_id, group_id, assignment, comment, progress, startdate_assig, enddate_assig, version, linksto, user_ip) VALUES ('".$_clean['reflink']."','".$_clean['title']."','".$_clean['content']."','".$_clean['user_id']."','".$_clean['group_id']."','".$_clean['assignment']."','".$_clean['comment']."','".$_clean['progress']."','".$_clean['startdate_assig']."','".$_clean['enddate_assig']."','".$_clean['version']."','".$_clean['linksto']."','".$_SERVER['REMOTE_ADDR']."')";
+ $sql="INSERT INTO ".$tbl_wiki." (reflink, title,content,user_id, group_id, assignment, comment, progress, startdate_assig, enddate_assig, delayedsubmit, version, linksto, user_ip) VALUES ('".$_clean['reflink']."','".$_clean['title']."','".$_clean['content']."','".$_clean['user_id']."','".$_clean['group_id']."','".$_clean['assignment']."','".$_clean['comment']."','".$_clean['progress']."','".$_clean['startdate_assig']."','".$_clean['enddate_assig']."','".$_clean['delayedsubmit']."','".$_clean['version']."','".$_clean['linksto']."','".$_SERVER['REMOTE_ADDR']."')";
}
else
{
- $sql="INSERT INTO ".$tbl_wiki." (reflink, title,content,user_id, assignment, comment, progress, startdate_assig, enddate_assig, version, linksto, user_ip) VALUES ('".$_clean['reflink']."','".$_clean['title']."','".$_clean['content']."','".$_clean['user_id']."','".$_clean['assignment']."','".$_clean['comment']."','".$_clean['progress']."','".$_clean['startdate_assig']."','".$_clean['enddate_assig']."','".$_clean['version']."','".$_clean['linksto']."','".$_SERVER['REMOTE_ADDR']."')";
+ $sql="INSERT INTO ".$tbl_wiki." (reflink, title,content,user_id, assignment, comment, progress, startdate_assig, enddate_assig, delayedsubmit, version, linksto, user_ip) VALUES ('".$_clean['reflink']."','".$_clean['title']."','".$_clean['content']."','".$_clean['user_id']."','".$_clean['assignment']."','".$_clean['comment']."','".$_clean['progress']."','".$_clean['startdate_assig']."','".$_clean['enddate_assig']."','".$_clean['delayedsubmit']."','".$_clean['version']."','".$_clean['linksto']."','".$_SERVER['REMOTE_ADDR']."')";
}
$result=api_sql_query($sql);
$Id = Database::insert_id();
@@ -1632,7 +1650,7 @@ function delete_wiki()
{
global $tbl_wiki, $tbl_discuss, $groupfilter;
api_sql_query('DELETE FROM '.$tbl_wiki.' WHERE '.$groupfilter.'',__FILE__,__LINE__);
- //to do: delete discuss and mailcue
+ //TODO: delete discuss and mailcue
return get_lang('WikiDeleted');
}
@@ -1652,7 +1670,7 @@ function save_new_wiki()
// cleaning the variables
$_clean['assignment']=Database::escape_string($_POST['assignment']);
-
+
if($_clean['assignment']==2 || $_clean['assignment']==1) // Unlike ordinary pages of pages of assignments. Allow create a ordinary page although there is a assignment with the same name
{
$_clean['reflink']=Database::escape_string(str_replace(' ','',$_POST['title']."_uass".$assig_user_id));
@@ -1667,6 +1685,7 @@ function save_new_wiki()
if($_clean['assignment']==2) // for automatic assignment. Identifies the user as a creator, not the teacher who created
{
+
$_clean['user_id']=(int)Database::escape_string($assig_user_id);
}
else
@@ -1677,8 +1696,9 @@ function save_new_wiki()
$_clean['comment']=Database::escape_string($_POST['comment']);
$_clean['progress']=Database::escape_string($_POST['progress']);
$_clean['startdate_assig']=Database::escape_string($_POST['startdate_assig']);
- $_clean['enddate_assig']=Database::escape_string($_POST['enddate_assig']);
- $_clean['version']=1;
+ $_clean['enddate_assig']=Database::escape_string($_POST['enddate_assig']);
+ $_clean['delayedsubmit']=Database::escape_string($_POST['delayedsubmit']);
+ $_clean['version']=1;
if (isset($_SESSION['_gid']))
{
@@ -1711,11 +1731,11 @@ function save_new_wiki()
{
if ($_clean['group_id'])
{
- $sql="INSERT INTO ".$tbl_wiki." (reflink, title, content, user_id, group_id, assignment, comment, progress, startdate_assig, enddate_assig, version, linksto, user_ip) VALUES ('".$_clean['reflink']."','".$_clean['title']."','".$_clean['content']."','".$_clean['user_id']."','".$_clean['group_id']."','".$_clean['assignment']."','".$_clean['comment']."','".$_clean['progress']."','".$_clean['startdate_assig']."','".$_clean['enddate_assig']."','".$_clean['version']."','".$_clean['linksto']."','".$_SERVER['REMOTE_ADDR']."')";
+ $sql="INSERT INTO ".$tbl_wiki." (reflink, title, content, user_id, group_id, assignment, comment, progress, startdate_assig, enddate_assig, delayedsubmit, version, linksto, user_ip) VALUES ('".$_clean['reflink']."','".$_clean['title']."','".$_clean['content']."','".$_clean['user_id']."','".$_clean['group_id']."','".$_clean['assignment']."','".$_clean['comment']."','".$_clean['progress']."','".$_clean['startdate_assig']."','".$_clean['enddate_assig']."','".$_clean['delayedsubmit']."','".$_clean['version']."','".$_clean['linksto']."','".$_SERVER['REMOTE_ADDR']."')";
}
else
{
- $sql="INSERT INTO ".$tbl_wiki." (reflink, title,content,user_id, assignment, comment, progress, startdate_assig, enddate_assig, version, linksto, user_ip) VALUES ('".$_clean['reflink']."','".$_clean['title']."','".$_clean['content']."','".$_clean['user_id']."','".$_clean['assignment']."','".$_clean['comment']."','".$_clean['progress']."','".$_clean['startdate_assig']."','".$_clean['enddate_assig']."','".$_clean['version']."','".$_clean['linksto']."','".$_SERVER['REMOTE_ADDR']."')";
+ $sql="INSERT INTO ".$tbl_wiki." (reflink, title,content, user_id, assignment, comment, progress, startdate_assig, enddate_assig, delayedsubmit, version, linksto, user_ip) VALUES ('".$_clean['reflink']."','".$_clean['title']."','".$_clean['content']."','".$_clean['user_id']."','".$_clean['assignment']."','".$_clean['comment']."','".$_clean['progress']."','".$_clean['startdate_assig']."','".$_clean['enddate_assig']."','".$_clean['delayedsubmit']."','".$_clean['version']."','".$_clean['linksto']."','".$_SERVER['REMOTE_ADDR']."')";
}
$result=api_sql_query($sql,__LINE__,__FILE__);
@@ -1763,11 +1783,15 @@ function display_new_wiki_form()
$_clean['group_id']=(int)$_SESSION['_gid'];
if($_clean['group_id']==0)
{
- echo ' '.get_lang('DefineAssignmentPage').' '; // 1 teacher 2 student
- //echo'';//by now turned off
- //echo ' Start. Date and time: (yyyy-mm-dd hh:mm:ss)'; //by now turned off
- //echo ' End. Date and time: (yyyy-mm-dd hh:mm:ss)'; //by now turned off
- //echo'
';
+ echo ' '.get_lang('DefineAssignmentPage').' '; // 1= teacher 2 =student
+
+ //by now turned off
+
+ //echo'';
+ //echo ' '.get_lang('StartDate').': (yyyy-mm-dd hh:mm:ss)'; //by now turned off
+ //echo ' '.get_lang('EndDate').': (yyyy-mm-dd hh:mm:ss)'; //by now turned off
+ //echo ' '.get_lang('AllowLaterSends').' '; //
+ //echo'
';
}
}
echo ' ';
@@ -1828,10 +1852,15 @@ function display_wiki_entry()
// if both are empty and we are displaying the index page then we display the default text.
if ($row['content']=='' AND $row['title']=='' AND $page='index')
{
-
- $content=sprintf(get_lang('DefaultContent'),api_get_path(WEB_IMG_PATH));
- $title=get_lang('DefaultTitle');
-
+ if(api_is_allowed_to_edit() || api_is_platform_admin())
+ {
+ $content=sprintf(get_lang('DefaultContent'),api_get_path(WEB_IMG_PATH));
+ $title=get_lang('DefaultTitle');
+ }
+ else
+ {
+ return Display::display_normal_message(get_lang('WikiStandBy'));
+ }
}
else
{
@@ -1936,15 +1965,17 @@ function display_wiki_entry()
echo '';
//copy last version to doc area
- echo '