diff --git a/main/wiki/css/default.css b/main/wiki/css/default.css index b340f56b56..f0689c4b19 100644 --- a/main/wiki/css/default.css +++ b/main/wiki/css/default.css @@ -54,6 +54,7 @@ border-bottom-color: #ccc; padding: 3px; padding-top:5px; + border-top: 1px solid #ccc; } #wikititle input { border: 1px solid #333; @@ -66,9 +67,6 @@ #menuwiki { background-color: #FFFFFF; - border-bottom-width: 1px; - border-bottom-style: solid; - border-bottom-color: #ccc; } #menuwiki li{ display: inline; diff --git a/main/wiki/index.php b/main/wiki/index.php index d13379a271..7c7df3385b 100644 --- a/main/wiki/index.php +++ b/main/wiki/index.php @@ -2,33 +2,54 @@ /* ============================================================================== - INIT SECTION -============================================================================== + Dokeos - elearning and course management software + + Copyright (c) 2004-2008 Dokeos SPRL + Copyright (c) 2003 Ghent University (UGent) + + For a full list of contributors, see "credits.txt". + The full license can be read in "license.txt". + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + See the GNU General Public License for more details. + + Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium + Mail: info@dokeos.com +============================================================================== */ -/* ------------------------------------------------------------ - Language Initialisation ------------------------------------------------------------ +/** +* The Dokeos wiki is a further development of the CoolWiki plugin. +* +* @Author Patrick Cool , Ghent University, Belgium +* @Author Juan Carlos Ra�a +* @Copyright Ghent University +* @Copyright Patrick Cool +* +* @package dokeos.wiki */ -$language_file = 'wiki'; +// name of the language file that needs to be included +$language_file = 'wiki'; + +// security if(isset($_GET['id_session'])) { $_SESSION['id_session'] = Security::remove_XSS($_GET['id_session']); } -/* ------------------------------------------------------------ - Including necessary files ------------------------------------------------------------ -*/ + +// including the global dokeos file include('../inc/global.inc.php'); -// Section (for the tabs) +// section (for the tabs) $this_section=SECTION_COURSES; +// including additional library scripts require_once (api_get_path(LIBRARY_PATH).'course.lib.php'); require_once (api_get_path(LIBRARY_PATH).'groupmanager.lib.php'); require_once (api_get_path(LIBRARY_PATH).'text.lib.php'); @@ -37,27 +58,19 @@ require_once (api_get_path(LIBRARY_PATH).'security.lib.php'); require_once (api_get_path(INCLUDE_PATH).'lib/mail.lib.inc.php'); require_once (api_get_path(INCLUDE_PATH).'conf/mail.conf.php'); require_once (api_get_path(LIBRARY_PATH).'sortabletable.class.php'); -/* ------------------------------------------------------------ - ADDITIONAL STYLE INFORMATION ------------------------------------------------------------ -*/ -$htmlHeadXtra[] =''; +require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php'); -/* +// additional style information +$htmlHeadXtra[] =''; -/* ------------------------------------------------------------ - Table definitions ------------------------------------------------------------ -*/ +// Database table definition $tbl_wiki = Database::get_course_table(TABLE_WIKI); $tbl_wiki_discuss = Database::get_course_table(TABLE_WIKI_DISCUSS); $tbl_wiki_mailcue = Database::get_course_table(TABLE_WIKI_MAILCUE); /* ----------------------------------------------------------- - Constants and variables +Constants and variables ----------------------------------------------------------- */ $tool_name = get_lang('Wiki'); @@ -66,7 +79,7 @@ $MonthsLong = array (get_lang("JanuaryLong"), get_lang("FebruaryLong"), get_lang /* ---------------------------------------------------------- - ACCESS +ACCESS ----------------------------------------------------------- */ api_protect_course_script(); @@ -74,14 +87,14 @@ api_block_anonymous_users(); /* ----------------------------------------------------------- - TRACKING +TRACKING ----------------------------------------------------------- */ event_access_tool(TOOL_WIKI); /* ----------------------------------------------------------- - HEADER & TITLE +HEADER & TITLE ----------------------------------------------------------- */ // If it is a group wiki then the breadcrumbs will be different. @@ -130,7 +143,7 @@ api_display_tool_title($tool_name.$add_group_to_title); /* ----------------------------------------------------------- - INITIALISATION +INITIALISATION ----------------------------------------------------------- */ //the page we are dealing with @@ -144,33 +157,21 @@ else } // some titles are not allowed -//$not_allowed_titles=array("Index", "RecentChanges","AllPages", "Categories"); //not used for now +// $not_allowed_titles=array("Index", "RecentChanges","AllPages", "Categories"); //not used for now /* ============================================================================== - MAIN CODE +MAIN CODE ============================================================================== */ -/* ------------------------------------------------------------ - Introduction section ------------------------------------------------------------ -*/ - -$fck_attribute['Width'] = '100%'; -$fck_attribute['Height'] = '300'; -$fck_attribute['ToolbarSet'] = 'Introduction'; - +// introduction section Display::display_introduction_section(TOOL_WIKI); -$fck_attribute = null; // Clearing this global variable immediatelly after it has been used. - - /* ----------------------------------------------------------- - Wiki configuration settings +Wiki configuration settings ----------------------------------------------------------- */ @@ -198,11 +199,12 @@ if (isset($_POST['SaveWikiChange']) AND $_POST['title']<>'') { if(empty($_POST['title'])) { - Display::display_normal_message(get_lang("NoWikiPageTitle")); + Display::display_error_message(get_lang("NoWikiPageTitle")); } else { $return_message=save_wiki(); + Display::display_confirmation_message($return_message, false); } } @@ -211,7 +213,7 @@ if (isset($_POST['SaveWikiNew'])) { if(empty($_POST['title'])) { - Display::display_normal_message(get_lang("NoWikiPageTitle")); + Display::display_error_message(get_lang("NoWikiPageTitle")); } else { @@ -223,18 +225,12 @@ if (isset($_POST['SaveWikiNew'])) else { $return_message=save_new_wiki(); + Display::display_confirmation_message($return_message, false); } } } -// displaying the message if there is a message to be displayed -if (!empty($return_message)) -{ - Display::display_confirmation_message($return_message, false); -} - - // check last version if ($_GET['view']) { @@ -330,23 +326,12 @@ if ($_GET['action']=='deletewiki'){ if(api_is_allowed_to_edit() || api_is_platform_admin()) { - $message = get_lang('ConfirmDeleteWiki')."

"."

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

"; - - if (!isset($_GET['delete'])) - { - Display::display_warning_message($message,false); - } - if ($_GET['delete'] == 'yes') { $return_message=delete_wiki(); Display::display_confirmation_message($return_message); } } - else - { - Display::display_normal_message(get_lang("OnlyAdminDeleteWiki")); - } } @@ -358,89 +343,79 @@ if ($_GET['action']=='discuss' && $_POST['Submit']) /* ----------------------------------------------------------- - WIKI WRAPPER +WIKI WRAPPER ----------------------------------------------------------- */ echo "
"; -/* ------------------------------------------------------------ - WIKI MENU ------------------------------------------------------------ -*/ - -echo "'; /* ----------------------------------------------------------- - MAIN WIKI AREA +MAIN WIKI AREA ----------------------------------------------------------- */ echo "
"; @@ -450,9 +425,8 @@ echo "
"; if ($_GET['action']=='more') { - echo '
'; - echo ''.get_lang('More').'
'; - echo '
'; + + echo '
'.get_lang('More').'
'; if(api_is_allowed_to_edit() || api_is_platform_admin()) { @@ -529,9 +503,7 @@ if ($_GET['action']=='more') if ($_GET['action']=='mactiveusers') { - echo '
'; - echo ''.get_lang('MostActiveUsers').'
'; - echo '
'; + echo '
'.get_lang('MostActiveUsers').'
'; $sql='SELECT *, COUNT(*) AS NUM_EDIT FROM '.$tbl_wiki.' WHERE '.$groupfilter.' GROUP BY user_id'; $allpages=api_sql_query($sql,__FILE__,__LINE__); @@ -545,8 +517,8 @@ if ($_GET['action']=='mactiveusers') $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.''; + $row[] = $obj->user_id <>0 ? ''.$userinfo['lastname'].', '.$userinfo['firstname'].'' : get_lang('Anonymous').' ('.$obj->user_ip.')'; + $row[] =''.$obj->NUM_EDIT.''; $rows[] = $row; } @@ -564,9 +536,8 @@ if ($_GET['action']=='mactiveusers') if ($_GET['action']=='usercontrib') { $userinfo=Database::get_user_info_from_id(Security::remove_XSS($_GET['user_id'])); - echo '
'; - echo ''.get_lang('UserContributions').': '.$userinfo['lastname'].', '.$userinfo['firstname'].'
'; - echo '
'; + + echo ''; if(api_is_allowed_to_edit() || api_is_platform_admin()) //only by professors if page is hidden @@ -615,7 +586,7 @@ if ($_GET['action']=='usercontrib') $row[] = $day.' '.$MonthsLong[$month-1].' '.$year.' '.$hours.":".$minutes.":".$seconds; $row[] =$ShowAssignment; - $row[] = ''.$obj->title.''; + $row[] = ''.$obj->title.''; $row[] =$obj->version; $row[] =$obj->comment; //$row[] =strlen($obj->comment)>30 ? substr($obj->comment,0,30).'...' : $obj->comment; @@ -653,9 +624,7 @@ if ($_GET['action']=='usercontrib') if ($_GET['action']=='mostchanged') { - echo '
'; - echo ''.get_lang('MostChangedPages').'
'; - echo '
'; + echo '
'.get_lang('MostChangedPages').'
'; if(api_is_allowed_to_edit() || api_is_platform_admin()) //only by professors if page is hidden @@ -691,7 +660,7 @@ if ($_GET['action']=='mostchanged') $row = array (); $row[] =$ShowAssignment; - $row[] = ''.$obj->title.''; + $row[] = ''.$obj->title.''; $row[] = $obj->MAX; $rows[] = $row; } @@ -710,9 +679,7 @@ if ($_GET['action']=='mostchanged') if ($_GET['action']=='mvisited') { - echo '
'; - echo ''.get_lang('MostVisitedPages').'
'; - echo '
'; + echo '
'.get_lang('MostVisitedPages').'
'; if(api_is_allowed_to_edit() || api_is_platform_admin()) //only by professors if page is hidden { @@ -747,7 +714,7 @@ if ($_GET['action']=='mvisited') $row = array (); $row[] =$ShowAssignment; - $row[] = ''.$obj->title.''; + $row[] = ''.$obj->title.''; $row[] = $obj->tsum; $rows[] = $row; } @@ -765,9 +732,8 @@ if ($_GET['action']=='mvisited') if ($_GET['action']=='wanted') { - echo '
'; - echo ''.get_lang('WantedPages').'
'; - echo '
'; + echo '
'.get_lang('WantedPages').'
'; + $pages = array(); $refs = array(); $sort_wanted=array(); @@ -816,9 +782,7 @@ if ($_GET['action']=='wanted') if ($_GET['action']=='orphaned') { - echo '
'; - echo ''.get_lang('OrphanedPages').'
'; - echo '
'; + echo '
'.get_lang('OrphanedPages').'
'; $pages = array(); $refs = array(); @@ -888,7 +852,7 @@ if ($_GET['action']=='orphaned') $ShowAssignment=''; } - echo '
  • '.$ShowAssignment.''.$row['title'].'
  • '; + echo '
  • '.$ShowAssignment.''.$row['title'].'
  • '; } echo ''; } @@ -902,9 +866,7 @@ if ($_GET['action']=='delete') if(api_is_allowed_to_edit() || api_is_platform_admin()) { - echo '
    '; - echo ''.get_lang('DeletePageHistory').''; - echo '
    '; + echo '
    '.get_lang('DeletePageHistory').'
    '; if($page=="index") { @@ -945,116 +907,55 @@ if ($_GET['action']=='delete') if ($_GET['action']=='deletewiki') { - echo '
    '; - echo ''.get_lang('DeleteWiki').''; - echo '
    '; -} + echo '
    '.get_lang('DeleteWiki').'
    '; - -/////////////////////// search pages /////////////////////// Juan Carlos Ra�a Trabado -//// 1 Searchpages: input search - -if ($_GET['action']=='searchpages') -{ - echo '
    '; - echo ''.$SearchPages.''; - echo '
    '; - - if (!$_POST['Skeyword']) + if(api_is_allowed_to_edit() || api_is_platform_admin()) { - echo '
    '; - echo ''; - echo '

    '; - echo ' '.get_lang('AlsoSearchContent'); - echo '
    '; - } -} - -//// 2 SearchPages: find and show pages - -if ($_GET['action']=='showsearchpages') -{ - echo '
    '; - echo ''.$Search.': '.$_POST['Skeyword']; //TODO: post is lost when a table has some pages - echo '
    '; + $message = get_lang('ConfirmDeleteWiki'); + $message .= '

    + '.get_lang('No').' +   |   + '.get_lang('Yes').' +

    '; - $_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." 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 + if (!isset($_GET['delete'])) { - $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 - } + Display::display_warning_message($message,false); } - else - { - if($_POST['Scontent']=="1") - { - - $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 - } + Display::display_normal_message(get_lang("OnlyAdminDeleteWiki")); } +} - $result=api_sql_query($sql,__LINE__,__FILE__); - - //show table - if (mysql_num_rows($result) > 0) - { - $row = array (); - while ($obj = mysql_fetch_object($result)) - { - //get author - $userinfo=Database::get_user_info_from_id($obj->user_id); +/////////////////////// search wiki pages /////////////////////// +if ($_GET['action']=='searchpages') +{ + // initiate the object + $form = new FormValidator('wiki_search','post', api_get_self().'?cidReq='.Security::remove_XSS($_GET['cidReq']).'&action='.Security::remove_XSS($_GET['action']).'&group_id='.Security::remove_XSS($_GET['group_id'])); + + // settting the form elements + $form->addElement('header', '', get_lang('SearchPages')); + $form->addElement('text', 'search_term', get_lang('SearchTerm'),'class="input_titles"'); + $form->addElement('checkbox', 'search_content', null, get_lang('AlsoSearchContent')); + $form->addElement('style_submit_button', 'SubmitWikiSearch', get_lang('Search'), 'class="search"'); - //get time - $year = substr($obj->dtime, 0, 4); - $month = substr($obj->dtime, 5, 2); - $day = substr($obj->dtime, 8, 2); - $hours = substr($obj->dtime, 11,2); - $minutes = substr($obj->dtime, 14,2); - $seconds = substr($obj->dtime, 17,2); + // setting the rules + $form->addRule('search_term', '
    '.get_lang('ThisFieldIsRequired'), 'required'); + $form->addRule('search_term', get_lang('TooShort'),'minlength',3); - //get type assignment icon - if($obj->assignment==1) - { - $ShowAssignment=''.get_lang('AssignmentDesc').''; - } - elseif ($obj->assignment==2) + if ($form->validate()) { - $ShowAssignment=''.get_lang('AssignmentWork').''; + $form->display(); + $values = $form->exportValues(); + display_wiki_search_results($values['search_term'], $values['search_content']); } - elseif ($obj->assignment==0) + else { - $ShowAssignment=''; - } - - $row = array (); - $row[] =$ShowAssignment; - $row[] = ''.$obj->title.''; - $row[] = $obj->user_id <>0 ? ''.$userinfo['lastname'].', '.$userinfo['firstname'].'' : get_lang('Anonymous').' ('.$obj->user_ip.')'; - $row[] = $day.' '.$MonthsLong[$month-1].' '.$year.' '.$hours.":".$minutes.":".$seconds; - $rows[] = $row; + $form->display(); } - $table = new SortableTableFromArrayConfig($rows,1,10,'SearchPages_table','','','ASC'); - $table->set_additional_parameters(array('cidReq' =>$_GET['cidReq'],'action'=>$_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); - $table->set_header(3,get_lang('Date'), true); - - $table->display(); - } } @@ -1062,13 +963,12 @@ if ($_GET['action']=='showsearchpages') if ($_GET['action']=='links') { - echo '
    '; - echo ''.$LinksPages.''; - echo '
    '; + if (!$_GET['title']) { - Display::display_normal_message(get_lang("MustSelectPage")); + echo '
    '; + Display::display_error_message(get_lang("MustSelectPage")); } else { @@ -1099,7 +999,9 @@ if ($_GET['action']=='links') $page='index'; } - echo $LinksPagesFrom.': '.$ShowAssignment.''.$row['title'].''; + echo '
    '; + echo $LinksPagesFrom.': '.$ShowAssignment.' '.$row['title'].''; + echo '
    '; //fix index to title Main page into linksto if ($page=='index') @@ -1153,7 +1055,7 @@ if ($_GET['action']=='links') $row = array (); $row[] =$ShowAssignment; - $row[] = ''.$obj->title.''; + $row[] = ''.$obj->title.''; $row[] = $obj->user_id <>0 ? ''.$userinfo['lastname'].', '.$userinfo['firstname'].'' : get_lang('Anonymous').' ('.$obj->user_ip.')'; $row[] = $day.' '.$MonthsLong[$month-1].' '.$year.' '.$hours.":".$minutes.":".$seconds; $rows[] = $row; @@ -1193,16 +1095,18 @@ if ($_GET['action']=='addnew') elseif (check_addnewpagelock() && (api_is_allowed_to_edit()==false || api_is_platform_admin()==false)) { - Display::display_normal_message(get_lang('AddPagesLocked')); + Display::display_error_message(get_lang('AddPagesLocked')); } else { 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 '
    '; + echo '
    '; + echo '
    '.get_lang('AddNew').'
    '; + echo '
    '; + echo '
    '; display_new_wiki_form(); + echo '
    '; } else { @@ -1239,13 +1143,23 @@ if ($_GET['action']=='edit') $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 ($row['content']=='' AND $row['title']=='' AND $page='index') + { + $content=sprintf(get_lang('DefaultContent'),api_get_path(WEB_IMG_PATH)); + $title=get_lang('DefaultTitle'); + } + else + { + $content=$row['content']; + $title=$row['title']; + } + echo '
    '; + echo $icon_assignment.'   '.$title.'
    '; //Only teachers and platform admin can edit the index page. Only teachers and platform admin can edit an assignment teacher if(($row['reflink']=='index' || $row['reflink']=='' || $row['assignment']==1) && (!api_is_allowed_to_edit())) { - - Display::display_normal_message(get_lang('OnlyEditPagesCourseManager')); - + Display::display_error_message(get_lang('OnlyEditPagesCourseManager')); } else { @@ -1304,20 +1218,9 @@ if ($_GET['action']=='edit') } else { - if ($row['content']=='' AND $row['title']=='' AND $page='index') - { - $content=sprintf(get_lang('DefaultContent'),api_get_path(WEB_IMG_PATH)); - $title=get_lang('DefaultTitle'); - } - else - { - $content=$row['content']; - $title=$row['title']; - } - echo '
    '; - echo $icon_assignment.'   '.$title.'
    '; + echo '
    '; - echo '
    '; + echo ''; echo ''; echo ''; @@ -1400,8 +1303,8 @@ if ($_GET['action']=='history' or Security::remove_XSS($_POST['HistoryDifference $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__); - $title=Security::remove_XSS($_GET['title']); - $group_id=Security::remove_XSS($_GET['group_id']); + $title = Security::remove_XSS($_GET['title']); + $group_id = Security::remove_XSS($_GET['group_id']); echo '
    '; echo $icon_assignment.'   '.$KeyTitle; @@ -1429,20 +1332,20 @@ if ($_GET['action']=='history' or Security::remove_XSS($_POST['HistoryDifference $minutes=substr($row['dtime'], 14,2); $seconds=substr($row['dtime'], 17,2); - echo '
  • '; + echo '
  • '; ($counter==0) ? $oldstyle='style="visibility: hidden;"':$oldstyle=''; ($counter==0) ? $newchecked=' checked':$newchecked=''; ($counter==$total_versions-1) ? $newstyle='style="visibility: hidden;"':$newstyle=''; ($counter==1) ? $oldchecked=' checked':$oldchecked=''; echo ' '; echo ' '; - echo ''; - echo ''; + echo ''; + echo ''; echo $day.' '.$MonthsLong[$month-1].' '.$year.' '.$hours.":".$minutes.":".$seconds; echo ''; echo ' ('.get_lang('Version').' '.$row['version'].')'; - echo ' ... '; + echo ' '.get_lang('By').' '; if ($row['user_id']<>0) { echo ''.$userinfo['lastname'].', '.$userinfo['firstname'].''; @@ -1452,19 +1355,23 @@ if ($_GET['action']=='history' or Security::remove_XSS($_POST['HistoryDifference echo get_lang('Anonymous').' ('.$row[user_ip].')'; } - echo ' ... '.get_lang('Progress').': '.$row['progress'].'%'; + echo ' ( '.get_lang('Progress').': '.$row['progress'].'%, '; $comment=$row['comment']; if (!empty($comment)) { - echo ' ... '.get_lang('Comments').': '; + echo get_lang('Comments').': '.substr(htmlentities($row['comment']),0,100); + if (strlen($row['comment'])>100) + { + echo '... '; + } } else { - echo ' ... '. get_lang('Comments').': '; + echo get_lang('Comments').': ---'; } - echo '

  • '; + echo ' ) '; $counter++; } //end while @@ -1562,16 +1469,16 @@ if ($_GET['action']=='recentchanges') if (check_notify_all()) { - $notify_all= ''.get_lang('FullNotifyByEmail').''.get_lang('NotNotifyChanges').''; + $notify_all= ''.get_lang('FullNotifyByEmail').''.get_lang('NotNotifyChanges').''; } else { - $notify_all= ''.get_lang('FullCancelNotifyByEmail').''.get_lang('NotifyChanges').''; + $notify_all= ''.get_lang('FullCancelNotifyByEmail').''.get_lang('NotifyChanges').''; } - echo '
    '; - echo ''.get_lang('RecentChanges').' '.$notify_all.'
    '; - echo '
    '; + echo '
    '.$notify_all.''.get_lang('RecentChanges').'
    '; + + if(api_is_allowed_to_edit() || api_is_platform_admin()) //only by professors if page is hidden { @@ -1618,7 +1525,7 @@ if ($_GET['action']=='recentchanges') $row = array (); $row[] = $day.' '.$MonthsLong[$month-1].' '.$year.' '.$hours.':'.$minutes.":".$seconds; $row[] =$ShowAssignment; - $row[] = ''.$obj->title.''; + $row[] = ''.$obj->title.''; $row[] =$obj->version>1 ? get_lang('EditedBy') : get_lang('AddedBy'); $row[] = $obj->user_id <>0 ? ''.$userinfo['lastname'].', '.$userinfo['firstname'].'' : get_lang('Anonymous').' ('.$obj->user_ip.')'; $rows[] = $row; @@ -1642,9 +1549,7 @@ if ($_GET['action']=='recentchanges') if ($_GET['action']=='allpages') { - echo '
    '; - echo ''.get_lang('AllPages').''; - echo '
    '; + echo '
    '.get_lang('AllPages').'
    '; $_clean['group_id']=(int)$_SESSION['_gid']; @@ -1693,7 +1598,7 @@ if ($_GET['action']=='allpages') $row = array (); $row[] =$ShowAssignment; - $row[] = ''.$obj->title.''; + $row[] = ''.$obj->title.''; $row[] = $obj->user_id <>0 ? ''.$userinfo['lastname'].', '.$userinfo['firstname'].'' : get_lang('Anonymous').' ('.$obj->user_ip.')'; $row[] = $day.' '.$MonthsLong[$month-1].' '.$year.' '.$hours.":".$minutes.":".$seconds; $rows[] = $row; @@ -1729,33 +1634,35 @@ if ($_GET['action']=='discuss') $id=$row['id']; $firstuserid=$row['user_id']; - //check discuss visibility. Show discussion to students if isn't hidden. Show page to all teachers if is hidden. - if (check_visibility_discuss()) - { - //Mode assignments: If is hidden, show pages to student only if student is the author - if(($row['assignment']==2 && $row['visibility_disc']==0 && (api_get_user_id()==$row['user_id']))==false) + //mode assignment: previous to show page type + if(stripslashes($row['assignment'])==1) { - $visibility_disc= ''.get_lang('HideDiscussExtra').''.get_lang('ShowDiscuss').''; + $icon_assignment=''.get_lang('AssignmentDescExtra').''; } + elseif(stripslashes($row['assignment'])==2) + { + $icon_assignment=''.get_lang('AssignmentWorkExtra').''; } - else + + + //Show title and form to discuss if page exist + if ($id!='') { - if(api_is_allowed_to_edit() || api_is_platform_admin()) + //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 + if($row['visibility_disc']==1 || api_is_allowed_to_edit() || api_is_platform_admin() || ($row['assignment']==2 && $row['visibility_disc']==0 && (api_get_user_id()==$row['user_id']))) { - $visibility_disc= ''.get_lang('ShowDiscussExtra').''.get_lang('HideDiscuss').''; - } - } + echo '
    '; - //check add messages lock. + // discussion action: protecting (locking) the discussion if (check_addlock_discuss()) { if(api_is_allowed_to_edit() || api_is_platform_admin()) { - $addlock_disc= ''.get_lang('LockDiscussExtra').''.get_lang('UnlockDiscuss').''; + $addlock_disc= ''.get_lang('LockDiscussExtra').''; } else { - $addlock_disc= ''.get_lang('LockDiscussExtra').''.get_lang('PageLocked').''; + $addlock_disc= ''.get_lang('LockDiscussExtra').''; } } @@ -1763,57 +1670,72 @@ if ($_GET['action']=='discuss') { if(api_is_allowed_to_edit() || api_is_platform_admin()) { - $addlock_disc= ''.get_lang('UnlockDiscussExtra').''.get_lang('LockDiscuss').''; + $addlock_disc= ''.get_lang('UnlockDiscussExtra').''; } } + echo ''; + echo ''.$addlock_disc.''; + echo ''; - //check add rating lock. Show/Hide list to rating for all student - if (check_ratinglock_discuss()) + + // discussion action: visibility. Show discussion to students if isn't hidden. Show page to all teachers if is hidden. + if (check_visibility_discuss()) { - //Mode assignment: only the teacher can assign scoring - if(($row['assignment']==2 && $row['ratinglock_disc']==0 && (api_get_user_id()==$row['user_id']))==false) + //Mode assignments: If is hidden, show pages to student only if student is the author + if(($row['assignment']==2 && $row['visibility_disc']==0 && (api_get_user_id()==$row['user_id']))==false) { - $ratinglock_disc= ''.get_lang('LockRatingDiscussExtra').''.get_lang('UnlockRatingDiscuss').''; + $visibility_disc= ''.get_lang('HideDiscussExtra').''; } } else { if(api_is_allowed_to_edit() || api_is_platform_admin()) { - $ratinglock_disc= ''.get_lang('UnlockRatingDiscussExtra').''.get_lang('LockRatingDiscuss').''; + $visibility_disc= ''.get_lang('ShowDiscussExtra').''; } } + echo ''; + echo ''.$visibility_disc.''; + echo ''; + - //check notify by email - if (check_notify_discuss($page)) + //discussion action: check add rating lock. Show/Hide list to rating for all student + if (check_ratinglock_discuss()) { - $notify_disc= ''.get_lang('NotifyDiscussByEmail').''.get_lang('NotNotifyDiscussChanges').''; + //Mode assignment: only the teacher can assign scoring + if(($row['assignment']==2 && $row['ratinglock_disc']==0 && (api_get_user_id()==$row['user_id']))==false) + { + $ratinglock_disc= ''.get_lang('LockRatingDiscussExtra').''; + } } else { - $notify_disc= ''.get_lang('CancelNotifyDiscussByEmail').''.get_lang('NotifyDiscussChanges').''; - + if(api_is_allowed_to_edit() || api_is_platform_admin()) + { + $ratinglock_disc= ''.get_lang('UnlockRatingDiscussExtra').''; + } } + echo ''; + echo ''.$ratinglock_disc.''; + echo ''; - //mode assignment: previous to show page type - if(stripslashes($row['assignment'])==1) + //discussion action: email notification + if (check_notify_discuss($page)) { - $icon_assignment=''.get_lang('AssignmentDescExtra').''; + $notify_disc= ''.get_lang('NotifyDiscussByEmail').''; } - elseif(stripslashes($row['assignment'])==2) + else { - $icon_assignment=''.get_lang('AssignmentWorkExtra').''; + $notify_disc= ''.get_lang('CancelNotifyDiscussByEmail').''; } + echo ''; + echo ''.$notify_disc.''; + echo ''; + echo $icon_assignment.'   '.$row['title']; + + echo ' ('.get_lang('MostRecentVersionBy').' '.$lastuserinfo['firstname'].' '.$lastuserinfo['lastname'].' '.$lastversiondate.$countWPost.')'.$avg_WPost_score.' '; //TODO: read avg score - //Show title and form to discuss if page exist - if ($id!='') - { - //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 - if($row['visibility_disc']==1 || api_is_allowed_to_edit() || api_is_platform_admin() || ($row['assignment']==2 && $row['visibility_disc']==0 && (api_get_user_id()==$row['user_id']))) - { - echo '
    '; - echo $icon_assignment.'   '.$row['title'].'
    '.''.$addlock_disc.''.'   '.$visibility_disc.''.'   '.$ratinglock_disc.'   '.$notify_disc.'    ('.get_lang('MostRecentVersionBy').''.$lastuserinfo['firstname'].' '.$lastuserinfo['lastname'].' '.$lastversiondate.$countWPost.')'.$avg_WPost_score.' '; //TODO: read avg score echo '
    '; if($row['addlock_disc']==1 || api_is_allowed_to_edit() || api_is_platform_admin()) //show comments but students can't add theirs @@ -1824,13 +1746,17 @@ if ($_GET['action']=='discuss') : + + + - : @@ -2009,7 +1935,7 @@ echo "
    "; // echo "
    "; /* ============================================================================== - FOOTER +FOOTER ============================================================================== */ //$_SESSION['_gid']; @@ -2018,7 +1944,7 @@ Display::display_footer(); /* ============================================================================== - FUNCTIONS +FUNCTIONS ============================================================================== */ @@ -2473,16 +2399,16 @@ function display_new_wiki_form() //--> '; - echo '
    '; - echo get_lang(Title).': '; + echo ''; + //echo '
    '; + echo '* '.get_lang(Title).': '; if(api_is_allowed_to_edit() || api_is_platform_admin()) { $_clean['group_id']=(int)$_SESSION['_gid']; // TODO: check if delete ? - echo '    '.get_lang('DefineAssignmentPage').' '; // 1= teacher 2 =student + echo '
     '.get_lang('DefineAssignmentPage').' '; // 1= teacher 2 =student //by now turned off //echo'
    '; @@ -2496,7 +2422,7 @@ function display_new_wiki_form() api_disp_html_area('content','','300px'); echo '
    '; echo '
    '; - echo get_lang('Comments').':     '; + echo get_lang('Comments').':  

    '; echo get_lang('Progress').':   %'; + %'; echo '

    '; echo ''; //for save icon echo ''; //for button icon @@ -2575,100 +2501,99 @@ function display_wiki_entry() } - //Button lock add new pages + //assignment mode: for identify page type + if(stripslashes($row['assignment'])==1) + { + $icon_assignment=''.get_lang('AssignmentDescExtra').''; + } + elseif(stripslashes($row['assignment'])==2) + { + $icon_assignment=''.get_lang('AssignmentWorkExtra').''; + } + + + + //Show page. Show page to all users if isn't hide page. Mode assignments: if student is the author, can view + if($KeyVisibility=="1" || api_is_allowed_to_edit() || api_is_platform_admin() || ($row['assignment']==2 && $KeyVisibility=="0" && (api_get_user_id()==$row['user_id']))) + { + echo '
    '; + + // page action: enable or disable the adding of new pages if (check_addnewpagelock()) { if(api_is_allowed_to_edit() || api_is_platform_admin()) { - $protect_addnewpage= ''.get_lang('AddOptionProtected').''.get_lang('ShowAddOption').''; + $protect_addnewpage= ''.get_lang('AddOptionProtected').''; } } else { if(api_is_allowed_to_edit() || api_is_platform_admin()) { - $protect_addnewpage= ''.get_lang('AddOptionUnprotected').''.get_lang('HideAddOption').''; + $protect_addnewpage= ''.get_lang('AddOptionUnprotected').''; } } + echo ''; + echo ''.$protect_addnewpage.' '; + echo ''; - //Button lock page + // page action: protecting (locking) the page if (check_protect_page()) { if(api_is_allowed_to_edit() || api_is_platform_admin()) { - $protect_page= ''.get_lang('PageLockedExtra').''.get_lang('UnlockPage').''; + $protect_page= ''.get_lang('PageLockedExtra').''; } else { - $protect_page= ''.get_lang('PageLockedExtra').''.get_lang('PageLocked').''; + $protect_page= ''.get_lang('PageLockedExtra').''; } } else { if(api_is_allowed_to_edit() || api_is_platform_admin()) { - $protect_page= ''.get_lang('PageUnlockedExtra').''.get_lang('LockPage').''; + $protect_page= ''.get_lang('PageUnlockedExtra').''; } } + echo ''; + echo ''.$protect_page.''; + echo ''; - //Button visibility page + //page action: visibility if (check_visibility_page()) { //This hides the icon eye closed to users of work they can see yours if(($row['assignment']==2 && $KeyVisibility=="0" && (api_get_user_id()==$row['user_id']))==false) { - $visibility_page= ''.get_lang('HidePageExtra').''.get_lang('Show').''; + $visibility_page= ''.get_lang('HidePageExtra').''; } } else { if(api_is_allowed_to_edit() || api_is_platform_admin()) { - $visibility_page= ''.get_lang('ShowPageExtra').''.get_lang('Hide').''; + $visibility_page= ''.get_lang('ShowPageExtra').''; } } + echo ''; + echo ''.$visibility_page.''; + echo ''; - //Button notify page + //page action: notification if (check_notify_page($page)) { - $notify_page= ''.get_lang('NotifyByEmail').''.get_lang('NotNotifyChanges').''; - } - else - { - $notify_page= ''.get_lang('CancelNotifyByEmail').''.get_lang('NotifyChanges').''; - } - - //assignment mode: for identify page type - if(stripslashes($row['assignment'])==1) - { - $icon_assignment=''.get_lang('AssignmentDescExtra').''; - } - elseif(stripslashes($row['assignment'])==2) - { - $icon_assignment=''.get_lang('AssignmentWorkExtra').''; - } - - //Show page. Show page to all users if isn't hide page. Mode assignments: if studen is the author, can view - if($KeyVisibility=="1" || api_is_allowed_to_edit() || api_is_platform_admin() || ($row['assignment']==2 && $KeyVisibility=="0" && (api_get_user_id()==$row['user_id']))) - { - echo '
    '; - - if (empty($title)) - { - $title=get_lang('DefaultTitle'); - - } - - if (wiki_exist($title)) - { - echo $icon_assignment.'   '.stripslashes($title).'
    '.$protect_addnewpage.'
    '.'   '.$protect_page.''.'   '.$visibility_page.''.'   '.$notify_page.''.'   '.get_lang('Progress').': '.stripslashes($row['progress']).'%   '.get_lang('Rating').': '.stripslashes($row['score']).'   '.get_lang('Words').': '.word_count($content); + $notify_page= ''.get_lang('NotifyByEmail').''; } else { - echo stripslashes($title); + $notify_page= ''.get_lang('CancelNotifyByEmail').''; } + echo ''; + echo ''.$notify_page.''; + echo ''; - //export to pdf + //page action: export to pdf echo ''; echo ''; // also with export_tcpdf.php echo ''; @@ -2677,7 +2602,7 @@ function display_wiki_entry() echo ''; echo ''; - //copy last version to doc area + //page action: copy last version to doc area if(api_is_allowed_to_edit() || api_is_platform_admin()) { echo ''; @@ -2703,17 +2628,31 @@ function display_wiki_entry() } '; + echo ''; echo ''.get_lang('Print').''; echo ''; - //export to zip - //echo ''.get_lang('Export2ZIP').''; //TODO + if (empty($title)) + { + $title=get_lang('DefaultTitle'); + + } + + if (wiki_exist($title)) + { + echo $icon_assignment.'   '.stripslashes($title); + } + else + { + echo stripslashes($title); + } echo '
    '; echo '
    '. make_wiki_link_clickable(detect_external_link(detect_anchor_link(detect_mail_link(detect_ftp_link(detect_irc_link(detect_news_link(stripslashes($content)))))))).'
    '; + echo '
    '.get_lang('Progress').': '.stripslashes($row['progress']).'%   '.get_lang('Rating').': '.stripslashes($row['score']).'   '.get_lang('Words').': '.word_count($content).'
    '; + }//end filter visibility } // end function display_wiki_entry @@ -3703,4 +3642,93 @@ function auto_add_page_users($assignment_type) } //end foreach to teacher } + +function display_wiki_search_results($search_term, $search_content=0) +{ + global $tbl_wiki, $groupfilter, $MonthsLong; + + echo '
    '.get_lang('WikiSearchResults').'
    '; + + $_clean['group_id']=(int)$_SESSION['_gid']; + + if(api_is_allowed_to_edit() || api_is_platform_admin()) //only by professors if page is hidden + { + if($search_content=='1') + { + $sql="SELECT * FROM ".$tbl_wiki." s1 WHERE ".$groupfilter." 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 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 title LIKE '%".Database::escape_string($search_term)."%' 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 + { + if($search_content=='1') + { + + $sql="SELECT * FROM ".$tbl_wiki." s1 WHERE ".$groupfilter." 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 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 '%".Database::escape_string($search_term)."%' 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 + } + } + + $result=api_sql_query($sql,__LINE__,__FILE__); + + //show table + if (mysql_num_rows($result) > 0) + { + $row = array (); + while ($obj = mysql_fetch_object($result)) + { + //get author + $userinfo=Database::get_user_info_from_id($obj->user_id); + + //get time + $year = substr($obj->dtime, 0, 4); + $month = substr($obj->dtime, 5, 2); + $day = substr($obj->dtime, 8, 2); + $hours = substr($obj->dtime, 11,2); + $minutes = substr($obj->dtime, 14,2); + $seconds = substr($obj->dtime, 17,2); + + //get type assignment icon + if($obj->assignment==1) + { + $ShowAssignment=''.get_lang('AssignmentDesc').''; + } + elseif ($obj->assignment==2) + { + $ShowAssignment=''.get_lang('AssignmentWork').''; + } + elseif ($obj->assignment==0) + { + $ShowAssignment=''; + } + + $row = array (); + $row[] =$ShowAssignment; + $row[] = ''.$obj->title.''; + $row[] = $obj->user_id <>0 ? ''.$userinfo['lastname'].', '.$userinfo['firstname'].'' : get_lang('Anonymous').' ('.$obj->user_ip.')'; + $row[] = $day.' '.$MonthsLong[$month-1].' '.$year.' '.$hours.":".$minutes.":".$seconds; + $rows[] = $row; + } + + $table = new SortableTableFromArrayConfig($rows,1,10,'SearchPages_table','','','ASC'); + $table->set_additional_parameters(array('cidReq' =>$_GET['cidReq'],'action'=>$_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); + $table->set_header(3,get_lang('Date'), true); + + $table->display(); + } + else + { + echo get_lang('NoSearchResults'); + } +} ?> \ No newline at end of file