diff --git a/main/wiki/index.php b/main/wiki/index.php index 8f5785173f..3b01cfd4ff 100644 --- a/main/wiki/index.php +++ b/main/wiki/index.php @@ -344,24 +344,36 @@ if ($_GET['action']=='more') echo '
'; echo ''.get_lang('More').'
'; echo '
'; - echo ''; + } /////////////////////// Most active users /////////////////////// Juan Carlos Raña Trabado @@ -416,82 +424,120 @@ if ($_GET['action']=='mactiveusers') echo ''.get_lang('MostActiveUsers').'
'; echo '
'; - $sql='SELECT *, COUNT(*) AS NEDIT FROM '.$tbl_wiki.' WHERE '.$groupfilter.' GROUP BY user_id ORDER BY NEDIT DESC LIMIT 10'; //first ten users with more versions + $sql='SELECT *, COUNT(*) AS NUM_EDIT FROM '.$tbl_wiki.' WHERE '.$groupfilter.' GROUP BY user_id'; $allpages=api_sql_query($sql,__FILE__,__LINE__); + + //show table + if (mysql_num_rows($allpages) > 0) + { + $row = array (); + while ($obj = mysql_fetch_object($allpages)) + { + $userinfo=Database::get_user_info_from_id($obj->user_id); + $row = array (); + + $row[] = $obj->user_id <>0 ? ''.$userinfo['lastname'].', '.$userinfo['firstname'].'' : get_lang('Anonymous').' ('.$obj->user_ip.')'; + $row[] =''.$obj->NUM_EDIT.''; + $rows[] = $row; + } - echo ''; - + $table = new SortableTableFromArrayConfig($rows,1,10,'MostActiveUsersA_table','','','DESC'); + $table->set_additional_parameters(array('cidReq' =>Security::remove_XSS($_GET['cidReq']),'action'=>Security::remove_XSS($_GET['action']),'group_id'=>Security::remove_XSS($_GET['group_id']))); + $table->set_header(0,get_lang('Author'), true, array ('style' => 'width:30px;')); + $table->set_header(1,get_lang('Contributions'), true); + $table->display(); + } } + /////////////////////// User contributions /////////////////////// Juan Carlos Raña Trabado if ($_GET['action']=='usercontrib') { - $userinfo=Database::get_user_info_from_id($_GET['user_id']); + $userinfo=Database::get_user_info_from_id(Security::remove_XSS($_GET['user_id'])); echo '
'; - echo ''.get_lang('UserContributions').': '.$userinfo['lastname'].', '.$userinfo['firstname'].'
'; + echo ''.get_lang('UserContributions').': '.$userinfo['lastname'].', '.$userinfo['firstname'].'
'; echo '
'; if(api_is_allowed_to_edit() || api_is_platform_admin()) //only by professors if page is hidden { - $sql='SELECT * FROM '.$tbl_wiki.' WHERE '.$groupfilter.' AND user_id="'.$_GET['user_id'].'" ORDER BY reflink,version ASC'; + $sql='SELECT * FROM '.$tbl_wiki.' WHERE '.$groupfilter.' AND user_id="'.Security::remove_XSS($_GET['user_id']).'"'; } else { - $sql='SELECT * FROM '.$tbl_wiki.' WHERE '.$groupfilter.' AND user_id="'.$_GET['user_id'].'" AND visibility=1 ORDER BY reflink,version ASC'; + $sql='SELECT * FROM '.$tbl_wiki.' WHERE '.$groupfilter.' AND user_id="'.Security::remove_XSS($_GET['user_id']).'" AND visibility=1'; } $allpages=api_sql_query($sql,__FILE__,__LINE__); - - echo ''; - + $table->set_header(0,get_lang('Date'), true, array ('style' => 'width:175px;')); + $table->set_header(1,get_lang('Type'), true, array ('style' => 'width:30px;')); + $table->set_header(2,get_lang('Title'), true, array ('style' => 'width:200px;')); + $table->set_header(3,get_lang('Version'), true, array ('style' => 'width:30px;')); + $table->set_header(4,get_lang('Comment'), true, array ('style' => 'width:200px;')); + $table->set_header(5,get_lang('Progress'), true, array ('style' => 'width:30px;')); + $table->set_header(6,get_lang('Rating'), true, array ('style' => 'width:30px;')); + //if(api_is_allowed_to_edit() || api_is_platform_admin()) + //{ + //$table->set_header(7,get_lang('IP'), true, array ('style' => 'width:30px;')); + //} + + $table->display(); + } } /////////////////////// Most changed pages /////////////////////// Juan Carlos Raña Trabado @@ -505,35 +551,50 @@ if ($_GET['action']=='mostchanged') if(api_is_allowed_to_edit() || api_is_platform_admin()) //only by professors if page is hidden { - $sql='SELECT *, MAX(version) AS MAX FROM '.$tbl_wiki.' WHERE '.$groupfilter.' GROUP BY reflink ORDER BY MAX DESC, reflink LIMIT 10'; //first ten users + $sql='SELECT *, MAX(version) AS MAX FROM '.$tbl_wiki.' WHERE '.$groupfilter.' GROUP BY reflink'; } else { - $sql='SELECT *, MAX(version) AS MAX FROM '.$tbl_wiki.' WHERE '.$groupfilter.' AND visibility=1 GROUP BY reflink ORDER BY MAX DESC, reflink LIMIT 10';//first ten users + $sql='SELECT *, MAX(version) AS MAX FROM '.$tbl_wiki.' WHERE '.$groupfilter.' AND visibility=1 GROUP BY reflink'; } - $allpages=api_sql_query($sql,__FILE__,__LINE__); - echo ''; + $table = new SortableTableFromArrayConfig($rows,2,10,'MostChangedPages_table','','','DESC'); + $table->set_additional_parameters(array('cidReq' =>Security::remove_XSS($_GET['cidReq']),'action'=>Security::remove_XSS($_GET['action']),'group_id'=>Security::remove_XSS($_GET['group_id']))); + $table->set_header(0,get_lang('Type'), true, array ('style' => 'width:30px;')); + $table->set_header(1,get_lang('Title'), true); + $table->set_header(2,get_lang('Changes'), true); + $table->display(); + } + } /////////////////////// Most visited pages /////////////////////// Juan Carlos Raña Trabado @@ -546,11 +607,11 @@ if ($_GET['action']=='mvisited') 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'; // warning GROUP BY reflink don't return the last version, always the first id + $sql='SELECT *, SUM(hits) AS tsum FROM '.$tbl_wiki.' WHERE '.$groupfilter.' GROUP BY reflink'; } else { - $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 + $sql='SELECT *, SUM(hits) AS tsum FROM '.$tbl_wiki.' WHERE '.$groupfilter.' AND visibility=1 GROUP BY reflink'; } $allpages=api_sql_query($sql,__FILE__,__LINE__); @@ -583,7 +644,7 @@ if ($_GET['action']=='mvisited') } $table = new SortableTableFromArrayConfig($rows,2,10,'MostVisitedPages_table','','','DESC'); - $table->set_additional_parameters(array('cidReq' =>$_GET['cidReq'],'action'=>$_GET['action'],'group_id'=>Security::remove_XSS($_GET['group_id']))); + $table->set_additional_parameters(array('cidReq' =>Security::remove_XSS($_GET['cidReq']),'action'=>Security::remove_XSS($_GET['action']),'group_id'=>Security::remove_XSS($_GET['group_id']))); $table->set_header(0,get_lang('Type'), true, array ('style' => 'width:30px;')); $table->set_header(1,get_lang('Title'), true); $table->set_header(2,get_lang('Visits'), true); @@ -599,8 +660,7 @@ if ($_GET['action']=='wanted') echo ''.get_lang('WantedPages').'
'; echo '
'; $pages = array(); - $refs = array(); - $orphaned = array(); + $refs = array(); $sort_wanted=array(); //get name pages @@ -635,8 +695,8 @@ if ($_GET['action']=='wanted') if(!in_array($v, $pages)) { if (trim($v)!=="") - { - echo '
  • '.str_replace('_',' ',$v).'
  • '; + { + echo '
  • '.str_replace('_',' ',$v).'
  • '; } } } @@ -654,7 +714,6 @@ if ($_GET['action']=='orphaned') $pages = array(); $refs = array(); $orphaned = array(); - $sort_orphaned=array(); //get name pages $sql='SELECT * FROM '.$tbl_wiki.' WHERE '.$groupfilter.' GROUP BY reflink ORDER BY reflink ASC'; @@ -670,7 +729,7 @@ if ($_GET['action']=='orphaned') while ($row=Database::fetch_array($allpages)) { //$row['linksto']= str_replace("\n".$row["reflink"]."\n", "\n", $row["linksto"]); //remove self reference. TODO check - $rf = explode(" ", trim($row["linksto"])); //TODO: check fix replace explode("\n", trim($row["linksto"])) with explode(" ", trim($row["linksto"])) + $rf = explode(" ", trim($row["linksto"])); //fix replace explode("\n", trim($row["linksto"])) with explode(" ", trim($row["linksto"])) $refs = array_merge($refs, $rf); if ($n++ > 299) @@ -706,8 +765,6 @@ if ($_GET['action']=='orphaned') echo ''; } - //sort titles //TODO: check to delete this line - //natcasesort($sort_orphaned);//TODO: check to delete this line - //foreach($sort_orphaned as $vshow_so)//TODO: check to delete this line - //{ - //echo $vshow_so.'
    '; //TODO: link to page //TODO: check to delete this line - //}//TODO: check to delete this line - } /////////////////////// delete current page /////////////////////// Juan Carlos Raña Trabado @@ -745,7 +795,13 @@ if ($_GET['action']=='delete') { echo '
    '; echo ''.get_lang('DeletePageHistory').''; - echo '
    '; + echo '
    '; + + if($page=="index") + { + Display::display_warning_message(get_lang('WarningDeleteMainPage'),false); + } + $message = get_lang('ConfirmDeletePage')."

    "."

    "."".get_lang("No").""."  |  "."".get_lang("Yes").""."

    "; if (!isset ($_GET['delete'])) @@ -993,7 +1049,7 @@ if ($_GET['action']=='links') } $table = new SortableTableFromArrayConfig($rows,1,10,'AllPages_table','','','ASC'); - $table->set_additional_parameters(array('cidReq' =>$_GET['cidReq'],'action'=>$_GET['action'],'group_id'=>Security::remove_XSS($_GET['group_id']))); + $table->set_additional_parameters(array('cidReq' =>Security::remove_XSS($_GET['cidReq']),'action'=>Security::remove_XSS($_GET['action']),'group_id'=>Security::remove_XSS($_GET['group_id']))); $table->set_header(0,get_lang('Type'), true, array ('style' => 'width:30px;')); $table->set_header(1,get_lang('Title'), true); $table->set_header(2,get_lang('Author'), true); @@ -1030,28 +1086,17 @@ if ($_GET['action']=='addnew') } else { - if(GroupManager :: is_user_in_group($_user['user_id'],$_SESSION['_gid'])) - { - if(api_is_allowed_to_edit() || api_is_platform_admin() || GroupManager :: is_user_in_group($_user['user_id'],$_SESSION['_gid'])) - { - echo '
    '; - echo ''.get_lang('AddNew').''; - echo '
    '; - display_new_wiki_form(); - - } - else - { - Display::display_normal_message(get_lang('OnlyAddPagesGroupMembers')); - } + if(api_is_allowed_to_edit() || api_is_platform_admin() || GroupManager :: is_user_in_group($_user['user_id'],$_SESSION['_gid']) || Security::remove_XSS($_GET['group_id'])==0) + { + echo '
    '; + echo ''.get_lang('AddNew').''; + echo '
    '; + display_new_wiki_form(); } else - { - echo '
    '; - echo ''.get_lang('AddNew').''; - echo '
    '; - display_new_wiki_form(); - } + { + Display::display_normal_message(get_lang('OnlyAddPagesGroupMembers')); + } } } @@ -1468,7 +1513,7 @@ if ($_GET['action']=='recentchanges') } $table = new SortableTableFromArrayConfig($rows,0,10,'RecentPages_table','','','DESC'); - $table->set_additional_parameters(array('cidReq' =>$_GET['cidReq'],'action'=>$_GET['action'],'group_id'=>Security::remove_XSS($_GET['group_id']))); + $table->set_additional_parameters(array('cidReq' =>Security::remove_XSS($_GET['cidReq']),'action'=>Security::remove_XSS($_GET['action']),'group_id'=>Security::remove_XSS($_GET['group_id']))); $table->set_header(0,get_lang('Date'), true, array ('style' => 'width:175px;')); $table->set_header(1,get_lang('Type'), true, array ('style' => 'width:30px;')); $table->set_header(2,get_lang('Title'), true); @@ -1543,7 +1588,7 @@ if ($_GET['action']=='allpages') } $table = new SortableTableFromArrayConfig($rows,1,10,'AllPages_table','','','ASC'); - $table->set_additional_parameters(array('cidReq' =>$_GET['cidReq'],'action'=>$_GET['action'],'group_id'=>Security::remove_XSS($_GET['group_id']))); + $table->set_additional_parameters(array('cidReq' =>Security::remove_XSS($_GET['cidReq']),'action'=>Security::remove_XSS($_GET['action']),'group_id'=>Security::remove_XSS($_GET['group_id']))); $table->set_header(0,get_lang('Type'), true, array ('style' => 'width:30px;')); $table->set_header(1,get_lang('Title'), true); $table->set_header(2,get_lang('Author'), true); @@ -2454,7 +2499,7 @@ function display_wiki_entry() //export to zip - echo ''.get_lang('Export2ZIP').''; //TODO + //echo ''.get_lang('Export2ZIP').''; //TODO echo ''; echo '
    '. make_wiki_link_clickable(detect_external_link(stripslashes($content))).'
    '; @@ -3295,8 +3340,13 @@ function auto_add_page_users($assignment_type) //extract group members $subscribed_users = GroupManager :: get_subscribed_users($_clean['group_id']); $subscribed_tutors = GroupManager :: get_subscribed_tutors($_clean['group_id']); - $a_users_to_add=array_merge($subscribed_users, $subscribed_tutors);//TODO: check if one tutor subscribed -> filter duplicates - + $a_users_to_add_with_duplicates=array_merge($subscribed_users, $subscribed_tutors); + + //remove duplicates + $a_users_to_add = $a_users_to_add_with_duplicates; + array_walk($a_users_to_add, create_function('&$value,$key', '$value = json_encode($value);')); + $a_users_to_add = array_unique($a_users_to_add); + array_walk($a_users_to_add, create_function('&$value,$key', '$value = json_decode($value, true);')); }