* @author Patrick Cool <patrick.cool@ugent.be>, Ghent University
* @param
*/
function createreflink($testvalue) {
function createreflink($testvalue)
{
$counter='';
while (!checktitle($testvalue.$counter))
{
@ -42,12 +43,15 @@ function checktitle($paramwk) {
$course_id = api_get_course_int_id();
$sql = 'SELECT * FROM '.$tbl_wiki.' WHERE c_id = '.$course_id.' AND reflink="'.Database::escape_string($paramwk).'" AND '.$groupfilter.$condition_session.'';
$sql = 'SELECT * FROM '.$tbl_wiki.'
WHERE
c_id = '.$course_id.' AND
reflink="'.Database::escape_string($paramwk).'" AND
'.$groupfilter.$condition_session.'';
$result=Database::query($sql);
$numberofresults=Database::num_rows($result);
if ($numberofresults==0) // the value has not been found and is this available
{
// the value has not been found and is this available
if ($numberofresults==0) {
return true;
}
else // the value has been found
@ -56,12 +60,12 @@ function checktitle($paramwk) {
}
}
/**
* check wikilinks that has a page
* @author Juan Carlos Raña <herodoto@telefonica.net>
$titleg_ex='<sup><imgsrc="css/wgroup.gif"alt="('.$group_name.')"title="Link to Wikigroup:'.$group_name.'"/></sup>';
TODO:logic for sessions
}
}
else
{
TODO:logic for sessions
}
*/
/////////
*/
/////////
//now full wikilink
if (api_strpos($value, "|") !== false){
@ -213,7 +217,7 @@ function make_wiki_link_clickable($input) {
// note: checkreflink checks if the link is still free. If it is not used then it returns true, if it is used, then it returns false. Now the title may be different
if (checktitle(strtolower(str_replace(' ','_',$link)))) {
global $charset, $tbl_wiki, $tbl_wiki_conf, $groupfilter, $condition_session, $page;
global $tbl_wiki, $tbl_wiki_conf, $groupfilter, $condition_session, $page;
$course_id = api_get_course_int_id();
if($newtitle) {
if ($newtitle) {
$pageMIX=$newtitle; //display the page after it is created
} else {
$pageMIX=$page;//display current page
}
$groupId = api_get_group_id();
$session_id=api_get_session_id();
if ($_GET['view']) {
@ -704,13 +703,15 @@ function display_wiki_entry($newtitle) {
}
//first, check page visibility in the first page version
$sql='SELECT * FROM '.$tbl_wiki.' WHERE c_id = '.$course_id.' AND reflink="'.Database::escape_string($pageMIX).'" AND '.$groupfilter.$condition_session.' ORDER BY id ASC';
$sql='SELECT * FROM '.$tbl_wiki.'
WHERE c_id = '.$course_id.' AND
reflink="'.Database::escape_string($pageMIX).'" AND
'.$groupfilter.$condition_session.'
ORDER BY id ASC';
$result=Database::query($sql);
$row=Database::fetch_array($result);
$KeyVisibility=$row['visibility'];
// second, show the last version
$sql='SELECT * FROM '.$tbl_wiki.' w , '.$tbl_wiki_conf.' wc
WHERE wc.c_id = '.$course_id.' AND
@ -724,7 +725,6 @@ function display_wiki_entry($newtitle) {
$result = Database::query($sql);
$row = Database::fetch_array($result); // we do not need a while loop since we are always displaying the last version
//log users access to wiki (page_id)
if (!empty($row['page_id']))
{
@ -749,7 +749,7 @@ function display_wiki_entry($newtitle) {
* This function counted the words in a document. Thanks Adeel Khan
* @param string Document's text
@ -935,7 +930,12 @@ function wiki_exist($title) {
$course_id = api_get_course_int_id();
$sql='SELECT id FROM '.$tbl_wiki.'WHERE c_id = '.$course_id.' AND title="'.Database::escape_string($title).'" AND '.$groupfilter.$condition_session.' ORDER BY id ASC';
$sql='SELECT id FROM '.$tbl_wiki.'
WHERE
c_id = '.$course_id.' AND
title="'.Database::escape_string($title).'" AND
'.$groupfilter.$condition_session.'
ORDER BY id ASC';
$result=Database::query($sql);
$cant=Database::num_rows($result);
if ($cant>0) {
@ -1014,7 +1014,12 @@ function check_protect_page() {
$course_id = api_get_course_int_id();
$groupId = api_get_group_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);
@ -1031,7 +1036,12 @@ function check_protect_page() {
}
$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 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);
}
@ -1103,7 +1113,9 @@ function check_visibility_discuss() {
$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);
@ -1118,11 +1130,17 @@ function check_visibility_discuss() {
$status_visibility_disc=0;
}
$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;
$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;
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';
$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);
}
@ -1143,7 +1161,9 @@ function check_addlock_discuss() {
$course_id = api_get_course_int_id();
$groupId = api_get_group_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);
@ -1163,7 +1183,9 @@ function check_addlock_discuss() {
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';
$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);
}
@ -1284,7 +1306,9 @@ function check_notify_discuss($reflink) {
$groupId = api_get_group_id();
$session_id = api_get_session_id();
$sql='SELECT * FROM '.$tbl_wiki.'WHERE c_id = '.$course_id.' AND reflink="'.$reflink.'" AND '.$groupfilter.$condition_session.' ORDER BY id ASC';
$sql = 'SELECT * FROM '.$tbl_wiki.'
WHERE c_id = '.$course_id.' AND reflink="'.$reflink.'" AND '.$groupfilter.$condition_session.'
ORDER BY id ASC';
$result=Database::query($sql);
$row=Database::fetch_array($result);
@ -1315,9 +1339,7 @@ function check_notify_discuss($reflink) {
$status_notify_disc=0;
}
//show status
return $status_notify_disc;
return $status_notify_disc;
}
@ -1332,7 +1354,8 @@ function check_notify_all() {
$groupId = api_get_group_id();
$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.'"';
$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.'"';
$result=Database::query($sql);
$row=Database::fetch_array($result);
@ -1408,7 +1431,8 @@ function check_emailcue($id_or_ref, $type, $lastime='', $lastuser='') {
$email_page_name=$row['title'];
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_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.
@ -1476,7 +1500,8 @@ function check_emailcue($id_or_ref, $type, $lastime='', $lastuser='') {
$allow_send_mail=false; //Mode tasks: avoids notifications to all users about all users
}
$sql='SELECT * FROM '.$tbl_wiki_mailcue.' 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
$sql = 'SELECT * FROM '.$tbl_wiki_mailcue.'
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
@ -1840,9 +1854,11 @@ function display_wiki_search_results($search_term, $search_content=0, $all_vers=
} 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
$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
} 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
$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
}
} else {
if($search_content=='1') {
@ -1860,8 +1876,8 @@ function display_wiki_search_results($search_term, $search_content=0, $all_vers=
WHERE '.$tbl_wiki.'.c_id = '.$course_id.' AND '.$tbl_wiki_discuss.'.c_id = '.$course_id.' AND '.$tbl_wiki.'.reflink="'.Database::escape_string($page).'" AND '.$tbl_wiki.'.'.$groupfilter.' AND '.$tbl_wiki.'.session_id='.$session_id.' AND '.$tbl_wiki_discuss.'.publication_id='.$tbl_wiki.'.id';
Database::query($sql);*/
$sql = "DELETE FROM $tbl_wiki_conf WHERE c_id = $courseId AND page_id = $pageId";