@ -544,12 +544,12 @@ if ($_GET['action']=='mvisited')
echo '<hr>';
if(api_is_allowed_to_edit() || api_is_platform_admin()) //only by professors if page is hidden
{
$sql='SELECT *, SUM(hits) AS tsum FROM '.$tbl_wiki.' WHERE '.$groupfilter.' GROUP BY reflink ORDER BY tsum DESC, reflink';
{
$sql='SELECT *, SUM(hits) AS tsum FROM '.$tbl_wiki.' WHERE '.$groupfilter.' GROUP BY reflink'; // warning GROUP BY reflink don't return the last version, always the first id
}
else
{
$sql='SELECT *, SUM(hits) AS tsum FROM '.$tbl_wiki.' WHERE '.$groupfilter.' AND visibility=1 GROUP BY reflink ORDER BY tsum DESC, reflink';
$sql='SELECT *, SUM(hits) AS tsum FROM '.$tbl_wiki.' WHERE '.$groupfilter.' AND visibility=1 GROUP BY reflink'; // warning GROUP BY reflink don't return the last version, always the first id
}
$allpages=api_sql_query($sql,__FILE__,__LINE__);
@ -560,17 +560,6 @@ if ($_GET['action']=='mvisited')
echo '<b>'.$Search.'</b>: '.$_POST['Skeyword']; //TODO: post is lost when a table has some pages
echo '<hr>';
$_clean['group_id']=(int)$_SESSION['_gid'];
if(api_is_allowed_to_edit() || api_is_platform_admin()) //only by professors if page is hidden
{
if($_POST['Scontent']=="1")
{
$sql="SELECT * FROM ".$tbl_wiki." WHERE ".$groupfilter." AND title LIKE '%".$_POST['Skeyword']."%' OR content LIKE '%".$_POST['Skeyword']."%' GROUP BY reflink ORDER BY title ASC";
$sql="SELECT * FROM ".$tbl_wiki." s1 WHERE ".$groupfilter." AND title LIKE '%".$_POST['Skeyword']."%' OR content LIKE '%".$_POST['Skeyword']."%' AND id=(SELECT MAX(s2.id) FROM ".$tbl_wiki." s2 WHERE s1.reflink = s2.reflink)";// warning don't use group by reflink because don't return the last version
}
else
{
$sql="SELECT * FROM ".$tbl_wiki." WHERE ".$groupfilter." AND title LIKE '%".$_POST['Skeyword']."%' GROUP BY reflink ORDER BY title ASC";
$sql="SELECT * FROM ".$tbl_wiki." s1 WHERE ".$groupfilter." AND title LIKE '%".$_POST['Skeyword']."%' AND id=(SELECT MAX(s2.id) FROM ".$tbl_wiki." s2 WHERE s1.reflink = s2.reflink)";// warning don't use group by reflink because don't return the last version
$sql="SELECT * FROM ".$tbl_wiki." s1 WHERE ".$groupfilter." AND visibility=1 AND title LIKE '%".$_POST['Skeyword']."%' OR content LIKE '%".$_POST['Skeyword']."%' AND id=(SELECT MAX(s2.id) FROM ".$tbl_wiki." s2 WHERE s1.reflink = s2.reflink)";// warning don't use group by reflink because don't return the last version
}
else
{
$sql="SELECT * FROM ".$tbl_wiki." s1 WHERE ".$groupfilter." AND visibility=1 AND title LIKE '%".$_POST['Skeyword']."%' AND id=(SELECT MAX(s2.id) FROM ".$tbl_wiki." s2 WHERE s1.reflink = s2.reflink)";// warning don't use group by reflink because don't return the last version
}
}
//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
/////////////////////// What links here. Show pages that have linked this page /////////////////////// Juan Carlos Raña Trabado
@ -1493,66 +1486,75 @@ if ($_GET['action']=='recentchanges')
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
$result=api_sql_query($sql,__LINE__,__FILE__);
echo '<br>';
{
echo '<br>';
echo '<b>'.get_lang('AllPages').'</b>';
echo '<hr>';
echo '<hr>';
echo '<ul>';
while ($row=Database::fetch_array($result))
$_clean['group_id']=(int)$_SESSION['_gid'];
if(api_is_allowed_to_edit() || api_is_platform_admin()) //only by professors if page is hidden
{
$sql='SELECT * FROM '.$tbl_wiki.' s1 WHERE '.$groupfilter.' AND id=(SELECT MAX(s2.id) FROM '.$tbl_wiki.' s2 WHERE s1.reflink = s2.reflink)'; // warning don't use group by reflink because don't return the last version
}
else
{
$sql='SELECT * FROM '.$tbl_wiki.' s1 WHERE '.$groupfilter.' AND visibility=1 AND id=(SELECT MAX(s2.id) FROM '.$tbl_wiki.' s2 WHERE s1.reflink = s2.reflink)'; // warning don't use group by reflink because don't return the last 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