$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
//echo '<li><ahref="index.php?action=more&title='.$page.'"'.is_active_navigation_tab('more').'"><imgsrc="../img/wiki/wmore.png"title="'.get_lang('More').'"align="absmiddle"/></a></li>'; //no avalaible so far. TO DO
$sql='DELETE FROM '.$tbl_wiki.' WHERE reflink="'.html_entity_decode(Database::escape_string(stripslashes(urldecode($page)))).'" AND '.$groupfilter.' ORDER BY id DESC';
$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 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
$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
$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";
//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
/////////////////////// 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
/////////////////////// page history ///////////////////////
if ($_GET['action']=='history' or Security::remove_XSS($_POST['HistoryDifferences']))
{
$_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
$sql='SELECT * FROM '.$tbl_wiki.'WHERE reflink="'.html_entity_decode(Database::escape_string(stripslashes(urldecode($page)))).'" AND '.$groupfilter.' ORDER BY id DESC';
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';
echo '<table>'.diff( stripslashes($version_old['content']), stripslashes($version_new['content']), true, 'format_table_line' ).'</table>'; // format_line mode is better for words
//echo '<divclass="diffEqual">'.html_entity_decode($renderer->render($diff)).'</div>'; // Html inline. By now, turned off by problems in comparing pages separated by more than one version
//Show page to students if isn't hidden. Show page to all teachers if is hidden. Mode assignments: If is hidden, show pages to student only if student is the author
if ($row['user_id']==(int)api_get_user_id() || api_is_allowed_to_edit() || api_is_platform_admin()) //Mode assignments: show pages assignment (works) only for teachers. Also show pages to student only if student is the author.
/////////////////////// all pages ///////////////////////
if ($_GET['action']=='allpages')
{
$_clean['group_id']=(int)$_SESSION['_gid'];
$sql='SELECT * FROM '.$tbl_wiki.' WHERE '.$groupfilter.' GROUP BY reflink ORDER BY title ASC'; //tasks grouped by reflink instead of tilte, because there may be pages with the same name but with different reflink. This is true of the tasks
//Show page to students if isn't hidden. Show page to all teachers if is hidden. Mode assignments: If is hidden, show pages to student only if student is the author
$sql='SELECT * FROM '.$tbl_wiki.'WHERE reflink="'.html_entity_decode(Database::escape_string(stripslashes(urldecode($page)))).'" AND '.$groupfilter.' ORDER BY id ASC';
$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
//Show discussion to students if isn't hidden. Show page to all teachers if is hidden. Mode assignments: If is hidden, show pages to student only if student is the author
$sql="SELECT * FROM `$tbl_wiki_discuss` reviews, $user_table user WHERE reviews.publication_id='".$id."' AND user.user_id='".$wuid."' ORDER BY id DESC";
$result=api_sql_query($sql,__FILE__,__LINE__) or die(mysql_error());
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
* @author Patrick Cool <patrick.cool@ugent.be>, Ghent University
* @desc This function checks weither the proposed reflink is not in use yet. It is a recursive function because every newly created reflink suggestion
* has to be checked also
*/
function createreflink($testvalue)
{
global $groupfilter;
$counter='';
while (!checktitle($testvalue.$counter))
{
$counter++;
echo $counter."-".$testvalue.$counter."<br>";
}
// the reflink has not been found yet, so it is OK
return $testvalue.$counter;
}
/**
* @author Patrick Cool <patrick.cool@ugent.be>, Ghent University
**/
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
$result=api_sql_query($sql,__FILE__,__LINE__);
$numberofresults=Database::num_rows($result);
if ($numberofresults==0) // the value has not been found and is this available
{
return true;
}
else // the value has been found
{
return false;
}
}
/**
* @author Juan Carlos Raña <herodoto@telefonica.net>
if ($input_array[$key-1]=='[[' AND $input_array[$key+1]==']]')
{
if (strpos($value, "|") !== false)
{
$full_link_array=explode("|", $value);
$link=trim($full_link_array[0]);
$title=trim($full_link_array[1]);
}
else
{
$link=$value;
$title=$value;
}
unset($input_array[$key-1]);
unset($input_array[$key+1]);
$all_links[]= Database::escape_string(str_replace(' ','',$link)).' '; //remove blank spaces within the links. But to remove links at the end add a blank space
}
}
$output=implode($all_links);
return $output;
}
/**
* This function allows users to have [link to a title]-style links like in most regular wikis.
* It is true that the adding of links is probably the most anoying part of Wiki for the people
* who know something about the wiki syntax.
* @author Patrick Cool <patrick.cool@ugent.be>, Ghent University
// 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))))
$input_array[$key]='<ahref="'.api_get_path(WEB_PATH).'main/wiki/index.php?cidReq='.$_course[id].'&action=showpage&title='.strtolower(str_replace(' ','',$link)).'&group_id='.$_clean['group_id'].'"class="wiki_link">'.$title.$titleg_ex.'</a>'; // juan esto recoge la posibilidad de que el titulo sea diferente a la url
}
unset($input_array[$key-1]);
unset($input_array[$key+1]);
}
}
$output=implode('',$input_array);
return $output;
}
/**
* This function saves a change in a wiki page
* @author Patrick Cool <patrick.cool@ugent.be>, Ghent University
* @return language string saying that the changes are stored
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
//first, check page visibility in the first page version
$sql='SELECT * FROM '.$tbl_wiki.'WHERE reflink="'.html_entity_decode(Database::escape_string(stripslashes(urldecode($page)))).'" AND '.$groupfilter.' ORDER BY id ASC';
$result=api_sql_query($sql,__LINE__,__FILE__);
$row=Database::fetch_array($result);
$KeyVisibility=$row['visibility'];
// second, show the last version
$sql="SELECT * FROM ".$tbl_wiki."WHERE reflink='".html_entity_decode(Database::escape_string(stripslashes(urldecode($page))))."' AND $groupfilter $filter 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
// 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')
echo '<spanstyle="float:right;"><imgsrc="../img/wiki/wzip_save.gif"alt="'.get_lang('Export2ZIP').'"onclick="alert(\'This is not implemented yet but it will be in the near future\')"/></span>'; //to do.
* Checks if this navigation tab has to be set to active
* @author Patrick Cool <patrick.cool@ugent.be>, Ghent University
* @return html code
*/
function is_active_navigation_tab($paramwk)
{
if ($_GET['action']==$paramwk)
{
return ' class="active"';
}
}
/**
* Lock add pages
* @author Juan Carlos Raña <herodoto@telefonica.net>
*/
function check_addnewpagelock()
{
global $tbl_wiki;
global $groupfilter;
$_clean['group_id']=(int)$_SESSION['_gid'];
$sql='SELECT * FROM '.$tbl_wiki.'WHERE '.$groupfilter.' ORDER BY id ASC';
$result=api_sql_query($sql,__LINE__,__FILE__);
$row=Database::fetch_array($result);
$status_addlock=$row['addlock'];
//change status
if ($_GET['actionpage']=='addlock' && (api_is_allowed_to_edit() || api_is_platform_admin()))
{
if ($row['addlock']==1)
{
$status_addlock=0;
}
else
{
$status_addlock=1;
}
api_sql_query('UPDATE '.$tbl_wiki.' SET addlock="'.Database::escape_string($status_addlock).'" WHERE '.$groupfilter.'',__LINE__,__FILE__);
$sql='SELECT * FROM '.$tbl_wiki.'WHERE '.$groupfilter.' ORDER BY id ASC';
$result=api_sql_query($sql,__LINE__,__FILE__);
$row=Database::fetch_array($result);
}
//show status
if ($row['addlock']==1 || ($row['content']=='' AND $row['title']=='' AND $page='index'))
{
return false;
}
else
{
return true;
}
}
/**
* Protect page
* @author Juan Carlos Raña <herodoto@telefonica.net>
*/
function check_protect_page()
{
global $tbl_wiki;
global $page;
global $groupfilter;
$_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 ASC';
$result=api_sql_query($sql,__LINE__,__FILE__);
$row=Database::fetch_array($result);
$status_editlock=$row['editlock'];
$id=$row['id'];
///change status
if ($_GET['actionpage']=='lock' && (api_is_allowed_to_edit() || api_is_platform_admin()))
{
if ($row['editlock']==0)
{
$status_editlock=1;
}
else
{
$status_editlock=0;
}
$sql='UPDATE '.$tbl_wiki.' SET editlock="'.Database::escape_string($status_editlock).'" WHERE id="'.$id.'"';
api_sql_query($sql,__FILE__,__LINE__);
$sql='SELECT * FROM '.$tbl_wiki.'WHERE reflink="'.html_entity_decode(Database::escape_string(stripslashes(urldecode($page)))).'" AND '.$groupfilter.' ORDER BY id ASC';
$result=api_sql_query($sql,__LINE__,__FILE__);
$row=Database::fetch_array($result);
}
//show status
if ($row['editlock']==0 || ($row['content']=='' AND $row['title']=='' AND $page=='index'))
{
return false;
}
else
{
return true;
}
}
/**
* Visibility page
* @author Juan Carlos Raña <herodoto@telefonica.net>
*/
function check_visibility_page()
{
global $tbl_wiki;
global $page;
global $groupfilter;
$_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 ASC';
$result=api_sql_query($sql,__LINE__,__FILE__);
$row=Database::fetch_array($result);
$status_visibility=$row['visibility'];
$id=$row['id']; //need ? check. to do
//change status
if ($_GET['actionpage']=='visibility' && (api_is_allowed_to_edit() || api_is_platform_admin()))
{
if ($row['visibility']==1)
{
$status_visibility=0;
}
else
{
$status_visibility=1;
}
$sql='UPDATE '.$tbl_wiki.' SET visibility="'.Database::escape_string($status_visibility).'" WHERE reflink="'.html_entity_decode(Database::escape_string(stripslashes(urldecode($page)))).'" AND '.$groupfilter;
api_sql_query($sql,__FILE__,__LINE__);
//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 reflink="'.html_entity_decode(Database::escape_string(stripslashes(urldecode($page)))).'" AND '.$groupfilter.' ORDER BY id ASC';
$result=api_sql_query($sql,__LINE__,__FILE__);
$row=Database::fetch_array($result);
}
//show status
if ($row['visibility']=="1" || ($row['content']=='' AND $row['title']=='' AND $page=='index'))
{
return false;
}
else
{
return true;
}
}
/**
* Visibility discussion
* @author Juan Carlos Raña <herodoto@telefonica.net>
*/
function check_visibility_discuss()
{
global $tbl_wiki;
global $page;
global $groupfilter;
$_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 ASC';
$result=api_sql_query($sql,__LINE__,__FILE__);
$row=Database::fetch_array($result);
$status_visibility_disc=$row['visibility_disc'];
$id=$row['id']; //need ? check. to do
//change status
if ($_GET['actionpage']=='visibility_disc' && (api_is_allowed_to_edit() || api_is_platform_admin()))
{
if ($row['visibility_disc']==1)
{
$status_visibility_disc=0;
}
else
{
$status_visibility_disc=1;
}
$sql='UPDATE '.$tbl_wiki.' SET visibility_disc="'.Database::escape_string($status_visibility_disc).'" WHERE reflink="'.html_entity_decode(Database::escape_string(stripslashes(urldecode($page)))).'" AND '.$groupfilter;
api_sql_query($sql,__FILE__,__LINE__);
//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 reflink="'.html_entity_decode(Database::escape_string(stripslashes(urldecode($page)))).'" AND '.$groupfilter.' ORDER BY id ASC';
$result=api_sql_query($sql,__LINE__,__FILE__);
$row=Database::fetch_array($result);
}
//show status
if ($row['visibility_disc']==1 || ($row['content']=='' AND $row['title']=='' AND $page=='index'))
{
return false;
}
else
{
return true;
}
}
/**
* Lock add discussion
* @author Juan Carlos Raña <herodoto@telefonica.net>
*/
function check_addlock_discuss()
{
global $tbl_wiki;
global $page;
global $groupfilter;
$_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 ASC';
$result=api_sql_query($sql,__LINE__,__FILE__);
$row=Database::fetch_array($result);
$status_addlock_disc=$row['addlock_disc'];
$id=$row['id']; //need ? check. to do
//change status
if ($_GET['actionpage']=='addlock_disc' && (api_is_allowed_to_edit() || api_is_platform_admin()))
{
if ($row['addlock_disc']==1)
{
$status_addlock_disc=0;
}
else
{
$status_addlock_disc=1;
}
$sql='UPDATE '.$tbl_wiki.' SET addlock_disc="'.Database::escape_string($status_addlock_disc).'" WHERE reflink="'.html_entity_decode(Database::escape_string(stripslashes(urldecode($page)))).'" AND '.$groupfilter;
api_sql_query($sql,__FILE__,__LINE__);
//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 reflink="'.html_entity_decode(Database::escape_string(stripslashes(urldecode($page)))).'" AND '.$groupfilter.' ORDER BY id ASC';
$result=api_sql_query($sql,__LINE__,__FILE__);
$row=Database::fetch_array($result);
}
//show status
if ($row['addlock_disc']==1 || ($row['content']=='' AND $row['title']=='' AND $page=='index'))
{
return false;
}
else
{
return true;
}
}
/**
* Lock rating discussion
* @author Juan Carlos Raña <herodoto@telefonica.net>
*/
function check_ratinglock_discuss()
{
global $tbl_wiki;
global $page;
global $groupfilter;
$_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 ASC';
$result=api_sql_query($sql,__LINE__,__FILE__);
$row=Database::fetch_array($result);
$status_ratinglock_disc=$row['ratinglock_disc'];
$id=$row['id']; //need ? check. to do
//change status
if ($_GET['actionpage']=='ratinglock_disc' && (api_is_allowed_to_edit() || api_is_platform_admin()))
{
if ($row['ratinglock_disc']==1)
{
$status_ratinglock_disc=0;
}
else
{
$status_ratinglock_disc=1;
}
$sql='UPDATE '.$tbl_wiki.' SET ratinglock_disc="'.Database::escape_string($status_ratinglock_disc).'" WHERE reflink="'.html_entity_decode(Database::escape_string(stripslashes(urldecode($page)))).'" AND '.$groupfilter; //juan carlos da valor de visible o no a todos los registros de la pagina, no solo al primero como antes
api_sql_query($sql,__FILE__,__LINE__);
//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 reflink="'.html_entity_decode(Database::escape_string(stripslashes(urldecode($page)))).'" AND '.$groupfilter.' ORDER BY id ASC';
$result=api_sql_query($sql,__LINE__,__FILE__);
$row=Database::fetch_array($result);
}
//show status
if ($row['ratinglock_disc']==1 || ($row['content']=='' AND $row['title']=='' AND $page=='index'))
{
return false;
}
else
{
return true;
}
}
/**
* Notify page changes
* @author Juan Carlos Raña <herodoto@telefonica.net>
*/
function check_notify_page()
{
global $tbl_wiki;
global $page;
global $groupfilter;
global $tbl_wiki_mailcue;
$_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 ASC';
$result=api_sql_query($sql,__LINE__,__FILE__);
$row=Database::fetch_array($result);
$status_notify=$row['notify'];
$id=$row['id'];
//change status
if ($_GET['actionpage']=='notify')
{
if ($row['notify']==0)
{
$status_notify=1;
}
else
{
$status_notify=0;
}
$sql='UPDATE '.$tbl_wiki.' SET notify="'.Database::escape_string($status_notify).'" WHERE id="'.$id.'"';
api_sql_query($sql,__FILE__,__LINE__);
$sql='SELECT * FROM '.$tbl_wiki.'WHERE reflink="'.html_entity_decode(Database::escape_string(stripslashes(urldecode($page)))).'" AND '.$groupfilter.' ORDER BY id ASC';
$result=api_sql_query($sql,__LINE__,__FILE__);
$row=Database::fetch_array($result);
$sql="INSERT INTO ".$tbl_wiki_mailcue." (id, user_id) VALUES ('".$id."','".api_get_user_id()."')";
$result=api_sql_query($sql);
}
//show status
if ($row['notify']==0 || ($row['content']=='' AND $row['title']=='' AND $page='index'))
{
return false;
}
else
{
return true;
}
}
/**
* Notify discussion changes
* @author Juan Carlos Raña <herodoto@telefonica.net>
*/
function check_notify_discuss()
{
global $tbl_wiki;
global $page;
global $groupfilter;
global $tbl_wiki_mailcue;
$_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 ASC';
$result=api_sql_query($sql,__LINE__,__FILE__);
$row=Database::fetch_array($result);
$status_notify_disc=$row['notify_disc'];
$id=$row['id']; //need ? check. to do
///change status
if ($_GET['actionpage']=='notify_disc')
{
if ($row['notify_disc']=="0")
{
$status_notify_disc="1";
}
else
{
$status_notify_disc="0";
}
$sql='UPDATE '.$tbl_wiki.' SET notify_disc="'.Database::escape_string($status_notify_disc).'" WHERE id="'.$id.'"';
api_sql_query($sql,__FILE__,__LINE__);
$sql='SELECT * FROM '.$tbl_wiki.'WHERE reflink="'.html_entity_decode(Database::escape_string(stripslashes(urldecode($page)))).'" AND '.$groupfilter.' ORDER BY id ASC';
$result=api_sql_query($sql,__LINE__,__FILE__);
$row=Database::fetch_array($result);
$sql="INSERT INTO ".$tbl_wiki_mailcue." (id, user_id) VALUES ('".$id."','".api_get_user_id()."')";
$result=api_sql_query($sql);
}
//show status
if ($row['notify_disc']=="0" || ($row['content']=='' AND $row['title']=='' AND $page='index'))
{
return false;
}
else
{
return true;
}
}
/**
* Function check emailcue
* TO DO
*/
/**
* Function send email when a page change
* TO DO
*/
/**
* Function export last wiki page version to document area
* @author Juan Carlos Raña <herodoto@telefonica.net>
*/
function export2doc($wikiTitle, $wikiContents, $groupId)
{
if ( 0 != $groupId)
{
$groupPart = '_group' . $groupId; // and add groupId to put the same title document in different groups