$sql='SELECT * FROM '.$tbl_wiki.' WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.' ORDER BY id ASC';
$result=Database::query($sql);
$row=Database::fetch_array($result);
$status_addlock=$row['addlock'];
//change status
$sql = 'SELECT *
FROM '.$tbl_wiki.'
WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.'
ORDER BY id ASC';
$result = Database::query($sql);
$row = Database::fetch_array($result);
$status_addlock = $row['addlock'];
// Change status
if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
if (isset($_GET['actionpage']) && $_GET['actionpage'] =='lockaddnew' && $status_addlock==1) {
$status_addlock=0;
@ -1010,11 +1033,15 @@ class Wiki
$status_addlock=1;
}
Database::query('UPDATE '.$tbl_wiki.' SET addlock="'.Database::escape_string($status_addlock).'" WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.'');
Database::query('UPDATE '.$tbl_wiki.' SET addlock="'.Database::escape_string($status_addlock).'"
WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.'');
$sql='SELECT * FROM '.$tbl_wiki.' WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.' ORDER BY id ASC';
$result=Database::query($sql);
$row=Database::fetch_array($result);
$sql = 'SELECT *
FROM '.$tbl_wiki.'
WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.'
ORDER BY id ASC';
$result = Database::query($sql);
$row = Database::fetch_array($result);
}
return $row['addlock'];
@ -1042,7 +1069,7 @@ class Wiki
$result=Database::query($sql);
$row=Database::fetch_array($result);
$status_editlock=$row['editlock'];
$status_editlock=$row['editlock'];
$id = $row['id'];
///change status
@ -1053,8 +1080,11 @@ class Wiki
if (isset($_GET['actionpage']) && $_GET['actionpage']=='unlock' && $status_editlock==1) {
$status_editlock=0;
}
$sql='UPDATE '.$tbl_wiki.' SET editlock="'.Database::escape_string($status_editlock).'" WHERE c_id = '.$course_id.' AND id="'.$id.'"';
$sql = 'UPDATE '.$tbl_wiki.' SET editlock="'.Database::escape_string($status_editlock).'"
WHERE c_id = '.$course_id.' AND id="'.$id.'"';
Database::query($sql);
$sql='SELECT * FROM '.$tbl_wiki.'
WHERE
c_id = '.$course_id.' AND
@ -1062,8 +1092,9 @@ class Wiki
'.$groupfilter.$condition_session.'
ORDER BY id ASC';
$result=Database::query($sql);
$row=Database::fetch_array($result);
$row=Database::fetch_array($result);
}
//show status
return $row['editlock'];
}
@ -1081,9 +1112,9 @@ class Wiki
$groupfilter = $this->groupfilter;
$course_id = api_get_course_int_id();
$sql='SELECT * FROM '.$tbl_wiki.'
WHERE c_id = '.$course_id.' AND reflink="'.Database::escape_string($page).'" AND '.$groupfilter.$condition_session.'
ORDER BY id ASC';
$sql='SELECT * FROM '.$tbl_wiki.'
WHERE c_id = '.$course_id.' AND reflink="'.Database::escape_string($page).'" AND '.$groupfilter.$condition_session.'
ORDER BY id ASC';
$result=Database::query($sql);
$row=Database::fetch_array($result);
$status_visibility=$row['visibility'];
@ -1101,9 +1132,12 @@ class Wiki
WHERE c_id = '.$course_id.' AND reflink="'.Database::escape_string($page).'" AND '.$groupfilter.$condition_session;
Database::query($sql);
//Although the value now is assigned to all (not only the first), these three lines remain necessary. They do that by changing the page state is made when you press the button and not have to wait to change his page
//Although the value now is assigned to all (not only the first), these three lines remain necessary. They do that by changing the page state is made when you press the button and not have to wait to change his page
$sql = 'SELECT * FROM '.$tbl_wiki.'
WHERE c_id = '.$course_id.' AND reflink="'.Database::escape_string($page).'" AND '.$groupfilter.$condition_session.'
WHERE
c_id = '.$course_id.' AND
reflink="'.Database::escape_string($page).'" AND
'.$groupfilter.$condition_session.'
ORDER BY id ASC';
$result=Database::query($sql);
$row = Database::fetch_array($result);
@ -1132,12 +1166,15 @@ class Wiki
$course_id = api_get_course_int_id();
$sql = 'SELECT * FROM '.$tbl_wiki.'
WHERE c_id = '.$course_id.' AND reflink="'.Database::escape_string($page).'" AND '.$groupfilter.$condition_session.'
WHERE
c_id = '.$course_id.' AND
reflink="'.Database::escape_string($page).'" AND
'.$groupfilter.$condition_session.'
ORDER BY id ASC';
$result=Database::query($sql);
$row=Database::fetch_array($result);
$status_visibility_disc=$row['visibility_disc'];
$status_visibility_disc=$row['visibility_disc'];
//change status
if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
@ -1149,7 +1186,10 @@ class Wiki
}
$sql = 'UPDATE '.$tbl_wiki.' SET visibility_disc="'.Database::escape_string($status_visibility_disc).'"
WHERE c_id = '.$course_id.' AND reflink="'.Database::escape_string($page).'" AND '.$groupfilter.$condition_session;
WHERE
c_id = '.$course_id.' AND
reflink="'.Database::escape_string($page).'" AND
'.$groupfilter.$condition_session;
Database::query($sql);
//Although the value now is assigned to all (not only the first), these three lines remain necessary. They do that by changing the page state is made when you press the button and not have to wait to change his page
@ -1159,8 +1199,8 @@ class Wiki
reflink="'.Database::escape_string($page).'" AND
'.$groupfilter.$condition_session.'
ORDER BY id ASC';
$result=Database::query($sql);
$row=Database::fetch_array($result);
$result=Database::query($sql);
$row=Database::fetch_array($result);
}
return $row['visibility_disc'];
}
@ -1179,10 +1219,13 @@ class Wiki
$course_id = api_get_course_int_id();
$sql = 'SELECT * FROM '.$tbl_wiki.'
WHERE c_id = '.$course_id.' AND reflink="'.Database::escape_string($page).'" AND '.$groupfilter.$condition_session.'
WHERE
c_id = '.$course_id.' AND
reflink="'.Database::escape_string($page).'" AND
'.$groupfilter.$condition_session.'
ORDER BY id ASC';
$result=Database::query($sql);
$row=Database::fetch_array($result);
$result=Database::query($sql);
$row=Database::fetch_array($result);
$status_addlock_disc=$row['addlock_disc'];
@ -1195,8 +1238,8 @@ class Wiki
$status_addlock_disc=0;
}
$sql='UPDATE '.$tbl_wiki.' SET addlock_disc="'.Database::escape_string($status_addlock_disc).'"
WHERE c_id = '.$course_id.' AND reflink="'.Database::escape_string($page).'" AND '.$groupfilter.$condition_session;
$sql='UPDATE '.$tbl_wiki.' SET addlock_disc="'.Database::escape_string($status_addlock_disc).'"
WHERE c_id = '.$course_id.' AND reflink="'.Database::escape_string($page).'" AND '.$groupfilter.$condition_session;
Database::query($sql);
//Although the value now is assigned to all (not only the first), these three lines remain necessary. They do that by changing the page state is made when you press the button and not have to wait to change his page
@ -1227,7 +1270,6 @@ class Wiki
WHERE c_id = '.$course_id.' AND reflink="'.Database::escape_string($page).'" AND '.$groupfilter.$condition_session.' ORDER BY id ASC';
$result=Database::query($sql);
$row=Database::fetch_array($result);
$status_ratinglock_disc=$row['ratinglock_disc'];
//change status
@ -1239,13 +1281,21 @@ class Wiki
$status_ratinglock_disc=0;
}
$sql='UPDATE '.$tbl_wiki.' SET ratinglock_disc="'.Database::escape_string($status_ratinglock_disc).'"
WHERE c_id = '.$course_id.' AND reflink="'.Database::escape_string($page).'" AND '.$groupfilter.$condition_session; //Visibility. Value to all,not only for the first
$sql = 'UPDATE '.$tbl_wiki.' SET ratinglock_disc="'.Database::escape_string($status_ratinglock_disc).'"
WHERE
c_id = '.$course_id.' AND
reflink="'.Database::escape_string($page).'" AND
'.$groupfilter.$condition_session;
//Visibility. Value to all,not only for the first
Database::query($sql);
//Although the value now is assigned to all (not only the first), these three lines remain necessary. They do that by changing the page state is made when you press the button and not have to wait to change his page
$sql='SELECT * FROM '.$tbl_wiki.'
WHERE c_id = '.$course_id.' AND reflink="'.Database::escape_string($page).'" AND '.$groupfilter.$condition_session.' ORDER BY id ASC';
WHERE
c_id = '.$course_id.' AND
reflink="'.Database::escape_string($page).'" AND
'.$groupfilter.$condition_session.'
ORDER BY id ASC';
$result=Database::query($sql);
$row=Database::fetch_array($result);
}
@ -1289,7 +1339,8 @@ class Wiki
// Change status
if (isset($_GET['actionpage']) && $_GET['actionpage'] =='locknotify' && $status_notify==0) {
$sql = "SELECT id FROM $tbl_wiki_mailcue WHERE c_id = $course_id AND id = $id AND user_id = $userId";
$sql = "SELECT id FROM $tbl_wiki_mailcue
WHERE c_id = $course_id AND id = $id AND user_id = $userId";
$result = Database::query($sql);
$exist = false;
if (Database::num_rows($result)) {
@ -1338,10 +1389,9 @@ class Wiki
$id=$row['id'];
$sql = 'SELECT * FROM '.$tbl_wiki_mailcue.'
WHERE c_id = '.$course_id.' AND id="'.$id.'" AND user_id="'.api_get_user_id().'" AND type="D"';
$result=Database::query($sql);
$row=Database::fetch_array($result);
$idm=$row['id'];
$result = Database::query($sql);
$row = Database::fetch_array($result);
$idm = $row['id'];
if (empty($idm)) {
$status_notify_disc=0;
@ -1378,7 +1428,12 @@ class Wiki
$session_id=api_get_session_id();
$sql = 'SELECT * FROM '.$tbl_wiki_mailcue.'
WHERE c_id = '.$course_id.' AND user_id="'.api_get_user_id().'" AND type="F" AND group_id="'.$groupId.'" AND session_id="'.$session_id.'"';
WHERE
c_id = '.$course_id.' AND
user_id="'.api_get_user_id().'" AND
type="F" AND
group_id="'.$groupId.'" AND
session_id="'.$session_id.'"';
$result=Database::query($sql);
$row=Database::fetch_array($result);
@ -1400,7 +1455,13 @@ class Wiki
if (isset($_GET['actionpage']) && isset($_GET['actionpage']) && $_GET['actionpage'] =='unlocknotifyall' && $status_notify_all==1) {
$sql ='DELETE FROM '.$tbl_wiki_mailcue.'
WHERE c_id = '.$course_id.' AND user_id="'.api_get_user_id().'" AND type="F" AND group_id="'.$groupId.'" AND session_id="'.$session_id.'" AND c_id = '.$course_id;
WHERE
c_id = '.$course_id.' AND
user_id="'.api_get_user_id().'" AND
type="F" AND
group_id="'.$groupId.'" AND
session_id="'.$session_id.'" AND
c_id = '.$course_id;
Database::query($sql);
$status_notify_all=0;
}
@ -1455,7 +1516,14 @@ class Wiki
if ($row['visibility']==1) {
$allow_send_mail=true; //if visibility off - notify off
$sql = 'SELECT * FROM '.$tbl_wiki_mailcue.'
WHERE c_id = '.$course_id.' AND id="'.$id.'" AND type="'.$type.'" OR type="F" AND group_id="'.$groupId.'" AND session_id="'.$session_id.'"'; //type: P=page, D=discuss, F=full.
$sql='SELECT * FROM '.$tbl_wiki.' WHERE c_id = '.$course_id.' AND id="'.$id.'" ORDER BY id ASC';
$sql = 'SELECT * FROM '.$tbl_wiki.'
WHERE c_id = '.$course_id.' AND id="'.$id.'"
ORDER BY id ASC';
$result=Database::query($sql);
$row=Database::fetch_array($result);
@ -1489,7 +1559,14 @@ class Wiki
if ($row['visibility_disc']==1) {
$allow_send_mail=true; //if visibility off - notify off
$sql = 'SELECT * FROM '.$tbl_wiki_mailcue.'
WHERE c_id = '.$course_id.' AND id="'.$id.'" AND type="'.$type.'" OR type="F" AND group_id="'.$groupId.'" AND session_id="'.$session_id.'"'; //type: P=page, D=discuss, F=full
WHERE c_id = '.$course_id.' AND id="'.$id.'" AND type="F" AND group_id="'.$groupId.'" AND session_id="'.$session_id.'"'; //type: P=page, D=discuss, F=full
WHERE c_id = '.$course_id.' AND id="'.$id.'" AND type="F" AND group_id="'.$groupId.'" AND session_id="'.$session_id.'"';
$is_tutor_of_group = GroupManager :: is_tutor_of_group($assig_user_id,$groupId); //student is tutor
$is_tutor_and_member = (GroupManager :: is_tutor_of_group($assig_user_id,$groupId) && GroupManager :: is_subscribed($assig_user_id, $groupId)); //student is tutor and member
$is_tutor_of_group = GroupManager::is_tutor_of_group($assig_user_id,$groupId); //student is tutor
WHERE c_id = $course_id AND title LIKE '%".Database::escape_string($search_term)."%' OR content LIKE '%".Database::escape_string($search_term)."%' AND ".$groupfilter.$condition_session."";//search all pages and all versions
WHERE
c_id = $course_id AND
title LIKE '%".Database::escape_string($search_term)."%' OR
content LIKE '%".Database::escape_string($search_term)."%' AND
".$groupfilter.$condition_session."";
//search all pages and all versions
} else {
$sql = "SELECT * FROM ".$tbl_wiki."
WHERE c_id = $course_id AND title LIKE '%".Database::escape_string($search_term)."%' AND ".$groupfilter.$condition_session."";//search all pages and all versions
WHERE
c_id = $course_id AND
title LIKE '%".Database::escape_string($search_term)."%' AND
".$groupfilter.$condition_session."";
//search all pages and all versions
}
} else {
if ($search_content=='1') {
$sql = "SELECT * FROM ".$tbl_wiki." s1
WHERE s1.c_id = $course_id AND title LIKE '%".Database::escape_string($search_term)."%' OR content LIKE '%".Database::escape_string($search_term)."%' 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.")";// warning don't use group by reflink because don't return the last version
WHERE
s1.c_id = $course_id AND
title LIKE '%".Database::escape_string($search_term)."%' OR
content LIKE '%".Database::escape_string($search_term)."%' 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.")";
// warning don't use group by reflink because don't return the last version
}
else {
$sql = " SELECT * FROM ".$tbl_wiki." s1
WHERE s1.c_id = $course_id AND title LIKE '%".Database::escape_string($search_term)."%' 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.")";// warning don't use group by reflink because don't return the last version
WHERE
s1.c_id = $course_id AND
title LIKE '%".Database::escape_string($search_term)."%' 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.")";
// warning don't use group by reflink because don't return the last version
}
}
} else {
if($all_vers=='1') {
if ($search_content=='1') {
$sql = "SELECT * FROM ".$tbl_wiki."
WHERE c_id = $course_id AND visibility=1 AND title LIKE '%".Database::escape_string($search_term)."%' OR content LIKE '%".Database::escape_string($search_term)."%' AND ".$groupfilter.$condition_session."";//search all pages and all versions
WHERE
c_id = $course_id AND
visibility=1 AND
title LIKE '%".Database::escape_string($search_term)."%' OR
content LIKE '%".Database::escape_string($search_term)."%' AND
".$groupfilter.$condition_session."";
//search all pages and all versions
} else {
$sql = "SELECT * FROM ".$tbl_wiki."
WHERE c_id = $course_id AND visibility=1 AND title LIKE '%".Database::escape_string($search_term)."%' AND ".$groupfilter.$condition_session."";//search all pages and all versions
WHERE
c_id = $course_id AND
visibility=1 AND
title LIKE '%".Database::escape_string($search_term)."%' AND
".$groupfilter.$condition_session."";
//search all pages and all versions
}
} else {
if($search_content=='1') {
$sql = " SELECT * FROM ".$tbl_wiki." s1
WHERE s1.c_id = $course_id AND visibility=1 AND title LIKE '%".Database::escape_string($search_term)."%' OR content LIKE '%".Database::escape_string($search_term)."%' 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.")";// warning don't use group by reflink because don't return the last version
$sql = "SELECT * FROM ".$tbl_wiki." s1
WHERE
s1.c_id = $course_id AND
visibility=1 AND
title LIKE '%".Database::escape_string($search_term)."%' OR
content LIKE '%".Database::escape_string($search_term)."%' 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.")";
// warning don't use group by reflink because don't return the last version
} else {
$sql = " SELECT * FROM ".$tbl_wiki." s1
WHERE s1.c_id = $course_id AND visibility=1 AND title LIKE '%".Database::escape_string($search_term)."%' 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.")";// warning don't use group by reflink because don't return the last version
$sql = "SELECT * FROM ".$tbl_wiki." s1
WHERE
s1.c_id = $course_id AND
visibility=1 AND
title LIKE '%".Database::escape_string($search_term)."%' 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.")";
// warning don't use group by reflink because don't return the last version
$total_flash_lv = $total_flash_lv+substr_count($clean_total_flash_lv, '.swf"');//.swf" end quotes prevent insert swf through flvplayer (is not counted)