';
-
-$result = $wiki->getAllWiki();
-foreach ($result as $is_editing_block) {
- $max_edit_time = 1200; // 20 minutes
- $timestamp_edit = strtotime($is_editing_block['time_edit']);
- $time_editing = time()-$timestamp_edit;
-
- //first prevent concurrent users and double version
- if ($is_editing_block['is_editing']==$_user['user_id']) {
- $_SESSION['_version']=$is_editing_block['version'];
- } else {
- unset( $_SESSION['_version'] );
- }
- //second checks if has exceeded the time that a page may be available or if a page was edited and saved by its author
- if ($time_editing>$max_edit_time || ($is_editing_block['is_editing']==$_user['user_id'] && $action!='edit')) {
- $wiki->updateWikiIsEditing($is_editing_block['is_editing']);
- }
-}
-echo '
';
// Saving a change
if (isset($_POST['SaveWikiChange']) AND $_POST['title']<>'') {
- if(empty($_POST['title'])) {
+ if (empty($_POST['title'])) {
Display::display_error_message(get_lang("NoWikiPageTitle"));
- } elseif(!$wiki->double_post($_POST['wpost_id'])) {
+ } elseif (!$wiki->double_post($_POST['wpost_id'])) {
//double post
} elseif ($_POST['version']!='' && $_SESSION['_version']!=0 && $_POST['version']!=$_SESSION['_version']) {
//prevent concurrent users and double version
@@ -176,8 +156,7 @@ if (isset($_POST['SaveWikiChange']) AND $_POST['title']<>'') {
}
}
-//saving a new wiki entry
-echo '
';
+// Saving a new wiki entry
if (isset($_POST['SaveWikiNew'])) {
if (empty($_POST['title'])) {
Display::display_error_message(get_lang("NoWikiPageTitle"));
@@ -195,7 +174,6 @@ if (isset($_POST['SaveWikiNew'])) {
if ($_clean['assignment'] == 1) {
$wiki->auto_add_page_users($_clean['assignment']);
}
-
$return_message = $wiki->save_new_wiki();
if ($return_message == false) {
Display::display_error_message(get_lang('NoWikiPageTitle'), false);
@@ -204,12 +182,13 @@ if (isset($_POST['SaveWikiNew'])) {
}
}
}
-echo '
';
// check last version
if (isset($_GET['view']) && $_GET['view']) {
$sql = 'SELECT * FROM '.$tbl_wiki.'
- WHERE c_id = '.$course_id.' AND id="'.Database::escape_string($_GET['view']).'"'; //current view
+ WHERE
+ c_id = '.$course_id.' AND
+ id="'.Database::escape_string($_GET['view']).'"'; //current view
$result=Database::query($sql);
$current_row=Database::fetch_array($result);
@@ -219,24 +198,30 @@ if (isset($_GET['view']) && $_GET['view']) {
$last_row=Database::fetch_array($result);
if ($_GET['view'] < $last_row['id']) {
- $message= '
';//TODO:Who and where everyone is working now?
}
// Statistics Juan Carlos Raña Trabado
if ($action =='statistics' && (api_is_allowed_to_edit(false,true) || api_is_platform_admin())) {
- echo '
';
- echo ' ';
+ $wiki->getStats();
}
// Most active users Juan Carlos Raña Trabado
if ($action =='mactiveusers') {
- echo '
'.get_lang('MostActiveUsers').'
';
- $sql='SELECT *, COUNT(*) AS NUM_EDIT FROM '.$tbl_wiki.' WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.' GROUP BY user_id';
- $allpages = Database::query($sql);
-
- //show table
- if (Database::num_rows($allpages) > 0) {
- while ($obj = Database::fetch_object($allpages)) {
- $userinfo = api_get_user_info($obj->user_id);
- $username = api_htmlentities(sprintf(get_lang('LoginX'), $userinfo['username']), ENT_QUOTES);
- $row = array();
- if ($obj->user_id <> 0) {
- $row[] = ''.
- Display::tag('span', api_htmlentities(api_get_person_name($userinfo['firstname'], $userinfo['lastname'])), array('title'=>$username)).
- '';
- } else {
- $row[] = get_lang('Anonymous').' ('.$obj->user_ip.')';
- }
- $row[] =''.$obj->NUM_EDIT.'';
- $rows[] = $row;
- }
-
- $table = new SortableTableFromArrayConfig($rows,1,10,'MostActiveUsersA_table','','','DESC');
- $table->set_additional_parameters(array('cidReq' =>Security::remove_XSS($_GET['cidReq']),'action'=>Security::remove_XSS($action),'session_id'=>Security::remove_XSS($_GET['session_id']),'group_id'=>Security::remove_XSS($_GET['group_id'])));
- $table->set_header(0,get_lang('Author'), true);
- $table->set_header(1,get_lang('Contributions'), true,array ('style' => 'width:30px;'));
- $table->display();
- }
+ $wiki->getActiveUsers($action);
}
// User contributions Juan Carlos Raña Trabado
@@ -1031,7 +446,8 @@ if ($action =='usercontrib') {
'';
- if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) { //only by professors if page is hidden
+ if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
+ //only by professors if page is hidden
$sql='SELECT * FROM '.$tbl_wiki.' WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.' AND user_id="'.Database::escape_string($_GET['user_id']).'"';
} else {
$sql='SELECT * FROM '.$tbl_wiki.' WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.' AND user_id="'.Database::escape_string($_GET['user_id']).'" AND visibility=1';
@@ -1138,9 +554,13 @@ if ($action =='mvisited') {
echo '
'.get_lang('MostVisitedPages').'
';
if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) { //only by professors if page is hidden
- $sql='SELECT *, SUM(hits) AS tsum FROM '.$tbl_wiki.' WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.' GROUP BY reflink';
+ $sql = 'SELECT *, SUM(hits) AS tsum FROM '.$tbl_wiki.'
+ WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.'
+ GROUP BY reflink';
} else {
- $sql='SELECT *, SUM(hits) AS tsum FROM '.$tbl_wiki.' WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.' AND visibility=1 GROUP BY reflink';
+ $sql = 'SELECT *, SUM(hits) AS tsum FROM '.$tbl_wiki.'
+ WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.' AND visibility=1
+ GROUP BY reflink';
}
$allpages=Database::query($sql);
@@ -1244,7 +664,10 @@ if ($action =='orphaned') {
$orphaned = array();
//get name pages
- $sql='SELECT * FROM '.$tbl_wiki.' WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.' GROUP BY reflink ORDER BY reflink ASC';
+ $sql = 'SELECT * FROM '.$tbl_wiki.'
+ WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.'
+ GROUP BY reflink
+ ORDER BY reflink ASC';
$allpages=Database::query($sql);
while ($row=Database::fetch_array($allpages)) {
$pages[] = $row['reflink'];
@@ -1252,7 +675,8 @@ if ($action =='orphaned') {
//get name refs in last pages and make a unique list
$sql = 'SELECT * FROM '.$tbl_wiki.' s1
- WHERE s1.c_id = '.$course_id.' AND id=(SELECT MAX(s2.id) FROM '.$tbl_wiki.' s2 WHERE s2.c_id = '.$course_id.' AND s1.reflink = s2.reflink AND '.$groupfilter.$condition_session.')';
+ WHERE s1.c_id = '.$course_id.' AND id=(
+ SELECT MAX(s2.id) FROM '.$tbl_wiki.' s2 WHERE s2.c_id = '.$course_id.' AND s1.reflink = s2.reflink AND '.$groupfilter.$condition_session.')';
$allpages=Database::query($sql);
while ($row=Database::fetch_array($allpages)) {
@@ -1296,8 +720,8 @@ if ($action =='orphaned') {
}
//show table
- $row = array ();
- $row[] =$ShowAssignment;
+ $row = array();
+ $row[] = $ShowAssignment;
$row[] = ''.api_htmlentities($orphaned_title).'';
$rows[] = $row;
}
@@ -1318,7 +742,9 @@ if ($action =='mostlinked') {
$linked = array();
//get name pages
- $sql='SELECT * FROM '.$tbl_wiki.' WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.' GROUP BY reflink ORDER BY reflink ASC';
+ $sql = 'SELECT * FROM '.$tbl_wiki.'
+ WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.'
+ GROUP BY reflink ORDER BY reflink ASC';
$allpages=Database::query($sql);
while ($row=Database::fetch_array($allpages)) {
@@ -1329,7 +755,8 @@ if ($action =='mostlinked') {
}
//get name refs in last pages
- $sql='SELECT * FROM '.$tbl_wiki.' s1 WHERE s1.c_id = '.$course_id.' AND id=(SELECT MAX(s2.id) FROM '.$tbl_wiki.' s2 WHERE s2.c_id = '.$course_id.' AND s1.reflink = s2.reflink AND '.$groupfilter.$condition_session.')';
+ $sql = 'SELECT * FROM '.$tbl_wiki.' s1 WHERE s1.c_id = '.$course_id.' AND id=(
+ SELECT MAX(s2.id) FROM '.$tbl_wiki.' s2 WHERE s2.c_id = '.$course_id.' AND s1.reflink = s2.reflink AND '.$groupfilter.$condition_session.')';
$allpages=Database::query($sql);
@@ -1347,7 +774,8 @@ if ($action =='mostlinked') {
}
}
- $linked=array_unique($linked);//make a unique list. TODO:delete this line and count how many for each page
+ $linked = array_unique($linked);
+ //make a unique list. TODO:delete this line and count how many for each page
//show table
$rows = array();
foreach ($linked as $linked_show) {
@@ -1367,19 +795,16 @@ if ($action =='mostlinked') {
);
$table->set_header(0,get_lang('Title'), true);
$table->display();
-
}
/* Delete current page */
if ($action =='delete') {
-
if (!$_GET['title']) {
Display::display_error_message(get_lang('MustSelectPage'));
exit;
}
- echo '
';
if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
echo '