123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646 |
- <?php
- $language_file = 'wiki';
- require_once '../inc/global.inc.php';
- $this_section = SECTION_COURSES;
- $current_course_tool = TOOL_WIKI;
- require_once 'wiki.inc.php';
- $course_id = api_get_course_int_id();
- $htmlHeadXtra[] ='<link rel="stylesheet" type="text/css" href="'.api_get_path(WEB_CODE_PATH).'wiki/css/default.css"/>';
- $htmlHeadXtra[] = '<script type="text/javascript" language="javascript">
- function advanced_parameters() {
- if(document.getElementById(\'options\').style.display == \'none\') {
- document.getElementById(\'options\').style.display = \'block\';
- document.getElementById(\'plus_minus\').innerHTML=\' '.Display::return_icon('div_hide.gif',get_lang('Hide'),array('style'=>'vertical-align:middle')).' '.get_lang('AdvancedParameters').'\';
- } else {
- document.getElementById(\'options\').style.display = \'none\';
- document.getElementById(\'plus_minus\').innerHTML=\' '.Display::return_icon('div_show.gif',get_lang('Show'),array('style'=>'vertical-align:middle')).' '.get_lang('AdvancedParameters').'\';
- }
- }
- function setFocus(){
- $("#search_title").focus();
- }
- $(document).ready(function () {
- setFocus();
- });
- </script>';
- $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);
- $tbl_wiki_conf = Database::get_course_table(TABLE_WIKI_CONF);
- $tool_name = get_lang('ToolWiki');
- $MonthsLong = array (get_lang("JanuaryLong"), get_lang("FebruaryLong"), get_lang("MarchLong"), get_lang("AprilLong"), get_lang("MayLong"), get_lang("JuneLong"), get_lang("JulyLong"), get_lang("AugustLong"), get_lang("SeptemberLong"), get_lang("OctoberLong"), get_lang("NovemberLong"), get_lang("DecemberLong"));
- $session_id = api_get_session_id();
- $condition_session = api_get_session_condition($session_id);
- $course_id = api_get_course_int_id();
- api_protect_course_script();
- api_block_anonymous_users();
- event_access_tool(TOOL_WIKI);
- $_clean['group_id'] = 0;
- if ($_SESSION['_gid'] OR $_GET['group_id']) {
- if (isset($_SESSION['_gid'])) {
- $_clean['group_id']=intval($_SESSION['_gid']);
- }
- if (isset($_GET['group_id'])) {
- $_clean['group_id']=intval($_GET['group_id']);
- }
- $group_properties = GroupManager :: get_group_properties($_clean['group_id']);
- $interbreadcrumb[] = array ("url" => "../group/group.php", "name" => get_lang('Groups'));
- $interbreadcrumb[] = array ("url"=>"../group/group_space.php?gidReq=".$_clean['group_id'], "name"=> get_lang('GroupSpace').' '.$group_properties['name']);
- $add_group_to_title = ' '.$group_properties['name'];
- $groupfilter='group_id="'.$_clean['group_id'].'"';
-
- if ($group_properties['wiki_state']==0) {
- api_not_allowed();
- } elseif ($group_properties['wiki_state']==2) {
- if (!api_is_allowed_to_edit(false,true) and !GroupManager :: is_user_in_group($_user['user_id'], $_SESSION['_gid'])) {
- api_not_allowed();
- }
- }
- } else {
- $groupfilter='group_id=0';
- }
- if ($_POST['action']=='export_to_pdf' && isset($_POST['wiki_id']) && api_get_setting('students_export2pdf') == 'true') {
- export_to_pdf($_POST['wiki_id'], api_get_course_id());
- exit;
- }
- Display::display_header($tool_name, 'Wiki');
- $is_allowed_to_edit = api_is_allowed_to_edit(false,true);
- if (!isset($_GET['title'])) {
- $page = 'index';
- } else {
- $page = $_GET['title'];
- }
- Display::display_introduction_section(TOOL_WIKI);
- echo '<div style="overflow:hidden">';
- $sql = "SELECT * FROM $tbl_wiki WHERE c_id = $course_id AND is_editing != '0' ".$condition_session;
- $result=Database::query($sql);
- while ($is_editing_block=Database::fetch_array($result)) {
- $max_edit_time = 1200;
- $timestamp_edit = strtotime($is_editing_block['time_edit']);
- $time_editing = time()-$timestamp_edit;
-
- if ($is_editing_block['is_editing']==$_user['user_id']) {
- $_SESSION['_version']=$is_editing_block['version'];
- } else {
- unset ( $_SESSION['_version'] );
- }
-
- if ($time_editing>$max_edit_time || ($is_editing_block['is_editing']==$_user['user_id'] && $_GET['action']!='edit')) {
- $sql='UPDATE '.$tbl_wiki.' SET is_editing="0", time_edit="0000-00-00 00:00:00"
- WHERE c_id = '.$course_id.' AND is_editing="'.$is_editing_block['is_editing'].'" '.$condition_session;
- Database::query($sql);
- }
- }
- echo '</div>';
- if (isset($_POST['SaveWikiChange']) AND $_POST['title']<>'') {
- if(empty($_POST['title'])) {
- Display::display_error_message(get_lang("NoWikiPageTitle"));
- } elseif(!double_post($_POST['wpost_id'])) {
-
- } elseif ($_POST['version']!='' && $_SESSION['_version']!=0 && $_POST['version']!=$_SESSION['_version']) {
-
- Display::display_error_message(get_lang("EditedByAnotherUser"));
- } else {
- $return_message=save_wiki();
- Display::display_confirmation_message($return_message, false);
- }
- }
- echo '<div style="overflow:hidden">';
- if (isset($_POST['SaveWikiNew'])) {
- if (empty($_POST['title'])) {
- Display::display_error_message(get_lang("NoWikiPageTitle"));
- } elseif (strtotime(get_date_from_select('startdate_assig')) > strtotime(get_date_from_select('enddate_assig'))) {
- Display::display_error_message(get_lang("EndDateCannotBeBeforeTheStartDate"));
- } elseif(!double_post($_POST['wpost_id'])) {
-
- } else {
- $_clean['assignment']=Database::escape_string($_POST['assignment']);
- if ($_clean['assignment']==1) {
- auto_add_page_users($_clean['assignment']);
- } else {
- $return_message=save_new_wiki();
- if ($return_message==false) {
- Display::display_error_message(get_lang('NoWikiPageTitle'), false);
- } else {
- Display::display_confirmation_message($return_message, false);
- }
- }
- }
- }
- echo '</div>';
- if ($_GET['view']) {
- $sql='SELECT * FROM '.$tbl_wiki.' WHERE c_id = '.$course_id.' AND id="'.Database::escape_string($_GET['view']).'"';
- $result=Database::query($sql);
- $current_row=Database::fetch_array($result);
- $sql='SELECT * FROM '.$tbl_wiki.' WHERE c_id = '.$course_id.' AND reflink="'.Database::escape_string($page).'" AND '.$groupfilter.$condition_session.' ORDER BY id DESC';
- $result=Database::query($sql);
- $last_row=Database::fetch_array($result);
- if ($_GET['view']<$last_row['id']) {
- $message= '<center>'.get_lang('NoAreSeeingTheLastVersion').'<br /> '.get_lang("Version").' (<a href="index.php?cidReq='.$_course['id'].'&action=showpage&title='.api_htmlentities(urlencode($current_row['reflink'])).'&group_id='.$current_row['group_id'].'&session_id='.$current_row['session_id'].'&view='.Security::remove_XSS($_GET['view']).'" title="'.get_lang('CurrentVersion').'">'.$current_row['version'].'</a> / <a href="index.php?cidReq='.$_course['id'].'&action=showpage&title='.api_htmlentities(urlencode($last_row['reflink'])).'&group_id='.$last_row['group_id'].'&session_id='.$last_row['session_id'].'" title="'.get_lang('LastVersion').'">'.$last_row['version'].'</a>) <br />'.get_lang("ConvertToLastVersion").': <a href="index.php?cidReq='.$_course['id'].'&action=restorepage&title='.api_htmlentities(urlencode($last_row['reflink'])).'&group_id='.$last_row['group_id'].'&session_id='.$last_row['session_id'].'&view='.Security::remove_XSS($_GET['view']).'">'.get_lang("Restore").'</a></center>';
- Display::display_warning_message($message,false);
- }
-
- if ($_GET['action']=='restorepage') {
-
- if (($current_row['reflink']=='index' || $current_row['reflink']=='' || $current_row['assignment']==1) && (!api_is_allowed_to_edit(false,true) && intval($_GET['group_id'])==0)) {
- Display::display_normal_message(get_lang('OnlyEditPagesCourseManager'));
- } else {
- $PassEdit=false;
-
- if ($current_row['group_id']!=0) {
-
- if (api_is_allowed_to_edit(false,true) || api_is_platform_admin() || GroupManager :: is_user_in_group($_user['user_id'],intval($_GET['group_id']))) {
- $PassEdit=true;
- } else {
- Display::display_normal_message(get_lang('OnlyEditPagesGroupMembers'));
- }
- } else {
- $PassEdit=true;
- }
-
- if ($current_row['assignment']==1) {
- Display::display_normal_message(get_lang('EditAssignmentWarning'));
- $icon_assignment=Display::return_icon('wiki_assignment.png', get_lang('AssignmentDescExtra'),'',ICON_SIZE_SMALL);
- } elseif($current_row['assignment']==2) {
- $icon_assignment=Display::return_icon('wiki_work.png', get_lang('AssignmentWorkExtra'),'',ICON_SIZE_SMALL);
- if ((api_get_user_id()==$current_row['user_id'])==false) {
- if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
- $PassEdit=true;
- } else {
- Display::display_warning_message(get_lang('LockByTeacher'));
- $PassEdit=false;
- }
- } else {
- $PassEdit=true;
- }
- }
- if ($PassEdit) {
- if ($row['editlock']==1 && (api_is_allowed_to_edit(false,true)==false || api_is_platform_admin()==false)) {
- Display::display_normal_message(get_lang('PageLockedExtra'));
- } else {
- if ($last_row['is_editing']!=0 && $last_row['is_editing']!=$_user['user_id']) {
-
- $timestamp_edit=strtotime($last_row['time_edit']);
- $time_editing=time()-$timestamp_edit;
- $max_edit_time=1200;
- $rest_time=$max_edit_time-$time_editing;
- $userinfo = api_get_user_info($last_row['is_editing']);
- $is_being_edited= get_lang('ThisPageisBeginEditedBy').' <a href=../user/userInfo.php?uInfo='.
- $userinfo['user_id'].'>'.
- Display::tag('span', $userinfo['complete_name_login_as']).
- get_lang('ThisPageisBeginEditedTryLater').' '.date( "i",$rest_time).' '.get_lang('MinMinutes').'';
- Display::display_normal_message($is_being_edited, false);
- } else {
- Display::display_confirmation_message(restore_wikipage($current_row['page_id'], $current_row['reflink'], api_htmlentities($current_row['title']), api_htmlentities($current_row['content']), $current_row['group_id'], $current_row['assignment'], $current_row['progress'], $current_row['version'], $last_row['version'], $current_row['linksto']).': <a href="index.php?cidReq='.$_course['id'].'&action=showpage&title='.api_htmlentities(urlencode($last_row['reflink'])).'&session_id='.$last_row['session_id'].'&group_id='.$last_row['group_id'].'">'.api_htmlentities($last_row['title']).'</a>',false);
- }
- }
- }
- }
- }
- }
- echo '<div style="overflow:hidden">';
- if ($_GET['action']=='deletewiki') {
- if(api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
- if ($_GET['delete'] == 'yes') {
- $return_message=delete_wiki();
- Display::display_confirmation_message($return_message);
- }
- }
- }
- if ($_GET['action']=='discuss' && $_POST['Submit']) {
- Display::display_confirmation_message(get_lang('CommentAdded'));
- }
- echo '</div>';
- echo '<div id="wikiwrapper">';
- ?>
- <script type="text/javascript">
- function menu_wiki(){
- if(document.getElementById("menuwiki").style.width=="180px"){
- var w=74;
- var b=2;
- var h=30;
- }
- else{
- var w=180;
- var b=1;
- var h=220;
- }
- document.getElementById("menuwiki").style.width=w+"px";
- document.getElementById("menuwiki").style.height=h+"px";
- document.getElementById("menuwiki").style.border=b+"px solid #cccccc";
- }
- </script>
- <?php
- echo '<div id="menuwiki" style="padding:2px;">';
- echo ' <a href="index.php?cidReq='.$_course['id'].'&action=show&title=index&session_id='.$session_id.'&group_id='.$_clean['group_id'].'"'.is_active_navigation_tab('show').'>'.Display::return_icon('wiki.png',get_lang('HomeWiki'),'',ICON_SIZE_MEDIUM).'</a> ';
- echo ' <a href="javascript:void(0)" onClick="menu_wiki()">'.Display::return_icon('menu.png',get_lang('Menu'),'',ICON_SIZE_SMALL).'</a>';
- echo '<ul>';
- if ( api_is_allowed_to_session_edit(false,true) ) {
-
- echo '<li><a href="index.php?cidReq='.$_course['id'].'&action=addnew&session_id='.$session_id.'&group_id='.$_clean['group_id'].'"'.is_active_navigation_tab('addnew').'>'.get_lang('AddNew').'</a> ';
- }
- if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
-
- if (check_addnewpagelock()==0) {
- $protect_addnewpage= '<img src="../img/off.png" title="'.get_lang('AddOptionProtected').'" alt="'.get_lang('AddOptionProtected').'" width="8" height="8" />';
- $lock_unlock_addnew='unlockaddnew';
- } else {
- $protect_addnewpage= '<img src="../img/on.png" title="'.get_lang('AddOptionUnprotected').'" alt="'.get_lang('AddOptionUnprotected').'" width="8" height="8" />';
- $lock_unlock_addnew='lockaddnew';
- }
- }
- echo '<a href="index.php?action=show&actionpage='.$lock_unlock_addnew.'&title='.api_htmlentities(urlencode($page)).'">'.$protect_addnewpage.'</a></li>';
- echo '<li><a href="index.php?cidReq='.$_course['id'].'&action=searchpages&session_id='.$session_id.'&group_id='.$_clean['group_id'].'"'.is_active_navigation_tab('searchpages').'>'.get_lang('SearchPages').'</a></li>';
- echo '<li><a href="index.php?cidReq='.$_course['id'].'&action=allpages&session_id='.$session_id.'&group_id='.$_clean['group_id'].'"'.is_active_navigation_tab('allpages').'>'.get_lang('AllPages').'</a></li>';
- echo '<li><a href="index.php?cidReq='.$_course['id'].'&action=recentchanges&session_id='.$session_id.'&group_id='.$_clean['group_id'].'"'.is_active_navigation_tab('recentchanges').'>'.get_lang('RecentChanges').'</a></li>';
- if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
- echo '<li><a href="index.php?action=deletewiki&title='.api_htmlentities(urlencode($page)).'"'.is_active_navigation_tab('deletewiki').'>'.get_lang('DeleteWiki').'</a></li>';
- }
- echo '<li><a href="index.php?action=more&title='.api_htmlentities(urlencode($page)).'"'.is_active_navigation_tab('more').'>'.get_lang('More').'</a></li>';
- echo '</ul>';
- echo '</div>';
- echo '<div id="mainwiki">';
- if (!in_array($_GET['action'], array('addnew', 'searchpages', 'allpages', 'recentchanges', 'deletewiki', 'more', 'mactiveusers', 'mvisited', 'mostchanged', 'orphaned', 'wanted'))) {
- echo '<div class="actions">';
-
- echo ' <a href="index.php?cidReq='.$_course['id'].'&action=showpage&title='.api_htmlentities(urlencode($page)).'&session_id='.$session_id.'&group_id='.$_clean['group_id'].'"'.is_active_navigation_tab('showpage').'>'.Display::return_icon('page.png',get_lang('ShowThisPage'),'',ICON_SIZE_MEDIUM).'</a>';
- if (api_is_allowed_to_session_edit(false,true) ) {
-
- echo '<a href="index.php?cidReq='.$_course['id'].'&action=edit&title='.api_htmlentities(urlencode($page)).'&session_id='.$session_id.'&group_id='.$_clean['group_id'].'"'.is_active_navigation_tab('edit').'>'.Display::return_icon('edit.png',get_lang('EditThisPage'),'',ICON_SIZE_MEDIUM).'</a>';
-
- echo '<a href="index.php?action=discuss&title='.api_htmlentities(urlencode($page)).'"'.is_active_navigation_tab('discuss').'>'.Display::return_icon('discuss.png',get_lang('DiscussThisPage'),'',ICON_SIZE_MEDIUM).'</a>';
- }
-
- echo '<a href="index.php?cidReq='.$_course['id'].'&action=history&title='.api_htmlentities(urlencode($page)).'&session_id='.$session_id.'&group_id='.$_clean['group_id'].'"'.is_active_navigation_tab('history').'>'.Display::return_icon('history.png',get_lang('ShowPageHistory'),'',ICON_SIZE_MEDIUM).'</a>';
-
- echo '<a href="index.php?action=links&title='.api_htmlentities(urlencode($page)).'&session_id='.$session_id.'&group_id='.$_clean['group_id'].'"'.is_active_navigation_tab('links').'>'.Display::return_icon('what_link_here.png',get_lang('LinksPages'),'',ICON_SIZE_MEDIUM).'</a>';
-
- if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
- echo '<a href="index.php?action=delete&title='.api_htmlentities(urlencode($page)).'"'.is_active_navigation_tab('delete').'>'.Display::return_icon('delete.png',get_lang('DeleteThisPage'),'',ICON_SIZE_MEDIUM).'</a>';
- }
- echo '</div>';
- }
- if (isset($_POST['SaveWikiNew'])) {
- display_wiki_entry($_POST['reflink']);
- }
- if ($_POST['export2DOC']) {
- $doc_id = $_POST['doc_id'];
- $export2doc = export2doc($doc_id);
- if ($export2doc) {
- Display::display_confirmation_message(get_lang('ThePageHasBeenExportedToDocArea'));
- }
- }
- if ($_GET['action']=='more') {
- echo '<div class="actions">'.get_lang('More').'</div>';
- echo '<table border="0">';
- echo ' <tr>';
- echo ' <td>';
- echo ' <ul>';
-
- echo ' <li><a href="index.php?cidReq='.$_course['id'].'&action=mactiveusers&session_id='.$session_id.'&group_id='.$_clean['group_id'].'">'.get_lang('MostActiveUsers').'</a></li>';
-
- echo ' <li><a href="index.php?cidReq='.$_course['id'].'&action=mvisited&session_id='.$session_id.'&group_id='.$_clean['group_id'].'">'.get_lang('MostVisitedPages').'</a></li>';
-
- echo ' <li><a href="index.php?cidReq='.$_course['id'].'&action=mostchanged&session_id='.$session_id.'&group_id='.$_clean['group_id'].'">'.get_lang('MostChangedPages').'</a></li>';
- echo ' </ul>';
- echo ' </td>';
- echo ' <td>';
- echo ' <ul>';
-
- echo ' <li><a href="index.php?cidReq='.$_course['id'].'&action=orphaned&session_id='.$session_id.'&group_id='.$_clean['group_id'].'">'.get_lang('OrphanedPages').'</a></li>';
-
- echo ' <li><a href="index.php?cidReq='.$_course['id'].'&action=wanted&session_id='.$session_id.'&group_id='.$_clean['group_id'].'">'.get_lang('WantedPages').'</a></li>';
-
- echo '<li><a href="index.php?cidReq='.$_course['id'].'&action=mostlinked&session_id='.$session_id.'&group_id='.$_clean['group_id'].'">'.get_lang('MostLinkedPages').'</a></li>';
- echo '</ul>';
- echo '</td>';
- echo '<td style="vertical-align:top">';
- echo '<ul>';
-
- if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
- echo '<li><a href="index.php?cidReq='.$_course['id'].'&action=statistics&session_id='.$session_id.'&group_id='.$_clean['group_id'].'">'.get_lang('Statistics').'</a></li>';
- }
- echo ' </ul>';
- echo' </td>';
- echo ' </tr>';
- echo '</table>';
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- }
- if ($_GET['action']=='statistics' && (api_is_allowed_to_edit(false,true) || api_is_platform_admin())) {
- echo '<div class="actions">'.get_lang('Statistics').'</div>';
-
- $total_words = 0;
- $total_links = 0;
- $total_links_anchors = 0;
- $total_links_mail = 0;
- $total_links_ftp = 0;
- $total_links_irc = 0;
- $total_links_news = 0;
- $total_wlinks = 0;
- $total_images = 0;
- $clean_total_flash = 0;
- $total_flash = 0;
- $total_mp3 = 0;
- $total_flv_p = 0;
- $total_flv = 0;
- $total_youtube = 0;
- $total_multimedia = 0;
- $total_tables = 0;
- $sql="SELECT *, COUNT(*) AS TOTAL_VERS, SUM(hits) AS TOTAL_VISITS FROM ".$tbl_wiki." WHERE c_id = $course_id AND ".$groupfilter.$condition_session."";
- $allpages=Database::query($sql);
- while ($row=Database::fetch_array($allpages)) {
- $total_versions = $row['TOTAL_VERS'];
- $total_visits = intval($row['TOTAL_VISITS']);
- }
- $sql="SELECT * FROM ".$tbl_wiki." WHERE c_id = $course_id AND ".$groupfilter.$condition_session."";
- $allpages=Database::query($sql);
- while ($row=Database::fetch_array($allpages)) {
- $total_words = $total_words+word_count($row['content']);
- $total_links = $total_links+substr_count($row['content'], "href=");
- $total_links_anchors = $total_links_anchors+substr_count($row['content'], 'href="#');
- $total_links_mail = $total_links_mail+substr_count($row['content'], 'href="mailto');
- $total_links_ftp = $total_links_ftp+substr_count($row['content'], 'href="ftp');
- $total_links_irc = $total_links_irc+substr_count($row['content'], 'href="irc');
- $total_links_news = $total_links_news+substr_count($row['content'], 'href="news');
- $total_wlinks = $total_wlinks+substr_count($row['content'], "[[");
- $total_images = $total_images+substr_count($row['content'], "<img");
- $clean_total_flash = preg_replace('/player.swf/', ' ', $row['content']);
- $total_flash = $total_flash+substr_count($clean_total_flash, '.swf"');
- $total_mp3 = $total_mp3+substr_count($row['content'], ".mp3");
- $total_flv_p = $total_flv_p+substr_count($row['content'], ".flv");
- $total_flv = $total_flv_p/5;
- $total_youtube = $total_youtube+substr_count($row['content'], "http://www.youtube.com");
- $total_multimedia = $total_multimedia+substr_count($row['content'], "video/x-msvideo");
- $total_tables = $total_tables+substr_count($row['content'], "<table");
- }
-
- $sql =' SELECT *, COUNT(*) AS TOTAL_PAGES, SUM(hits) AS TOTAL_VISITS_LV FROM '.$tbl_wiki.' s1
- WHERE s1.c_id = '.$course_id.' AND id=(SELECT MAX(s2.id) FROM '.$tbl_wiki.' s2 WHERE s2.c_id = '.$course_id.' AND s1.reflink = s2.reflink AND '.$groupfilter.' AND session_id='.$session_id.')';
- $allpages=Database::query($sql);
- while ($row=Database::fetch_array($allpages)) {
- $total_pages = $row['TOTAL_PAGES'];
- $total_visits_lv = intval($row['TOTAL_VISITS_LV']);
- }
- $total_words_lv = 0;
- $total_links_lv = 0;
- $total_links_anchors_lv = 0;
- $total_links_mail_lv = 0;
- $total_links_ftp_lv = 0;
- $total_links_irc_lv = 0;
- $total_links_news_lv = 0;
- $total_wlinks_lv = 0;
- $total_images_lv = 0;
- $clean_total_flash_lv = 0;
- $total_flash_lv = 0;
- $total_mp3_lv = 0;
- $total_flv_p_lv = 0;
- $total_flv_lv = 0;
- $total_youtube_lv = 0;
- $total_multimedia_lv = 0;
- $total_tables_lv = 0;
- $sql='SELECT * FROM '.$tbl_wiki.' s1 WHERE s1.c_id = '.$course_id.' AND id=(SELECT MAX(s2.id) FROM '.$tbl_wiki.' s2 WHERE s2.c_id = '.$course_id.' AND s1.reflink = s2.reflink AND '.$groupfilter.' AND session_id='.$session_id.')';
- $allpages=Database::query($sql);
- while ($row=Database::fetch_array($allpages)) {
- $total_words_lv = $total_words_lv+word_count($row['content']);
- $total_links_lv = $total_links_lv+substr_count($row['content'], "href=");
- $total_links_anchors_lv = $total_links_anchors_lv+substr_count($row['content'], 'href="#');
- $total_links_mail_lv = $total_links_mail_lv+substr_count($row['content'], 'href="mailto');
- $total_links_ftp_lv = $total_links_ftp_lv+substr_count($row['content'], 'href="ftp');
- $total_links_irc_lv = $total_links_irc_lv+substr_count($row['content'], 'href="irc');
- $total_links_news_lv = $total_links_news_lv+substr_count($row['content'], 'href="news');
- $total_wlinks_lv = $total_wlinks_lv+substr_count($row['content'], "[[");
- $total_images_lv = $total_images_lv+substr_count($row['content'], "<img");
- $clean_total_flash_lv = preg_replace('/player.swf/', ' ', $row['content']);
- $total_flash_lv = $total_flash_lv+substr_count($clean_total_flash_lv, '.swf"');
- $total_mp3_lv = $total_mp3_lv+substr_count($row['content'], ".mp3");
- $total_flv_p_lv = $total_flv_p_lv+substr_count($row['content'], ".flv");
- $total_flv_lv = $total_flv_p_lv/5;
- $total_youtube_lv = $total_youtube_lv+substr_count($row['content'], "http://www.youtube.com");
- $total_multimedia_lv = $total_multimedia_lv+substr_count($row['content'], "video/x-msvideo");
- $total_tables_lv = $total_tables_lv+substr_count($row['content'], "<table");
- }
- $total_editing_now=0;
- $sql='SELECT *, COUNT(*) AS TOTAL_EDITING_NOW FROM '.$tbl_wiki.' s1
- WHERE is_editing!=0 AND s1.c_id = '.$course_id.' AND
- id=(SELECT MAX(s2.id) FROM '.$tbl_wiki.' s2 WHERE s2.c_id = '.$course_id.' AND s1.reflink = s2.reflink AND '.$groupfilter.' AND session_id='.$session_id.')';
- $allpages=Database::query($sql);
- while ($row=Database::fetch_array($allpages)) {
- $total_editing_now = $row['TOTAL_EDITING_NOW'];
- }
- $total_hidden=0;
- $sql='SELECT * FROM '.$tbl_wiki.' WHERE c_id = '.$course_id.' AND visibility=0 AND '.$groupfilter.$condition_session.' GROUP BY reflink';
- $allpages=Database::query($sql);
- while ($row=Database::fetch_array($allpages)) {
- $total_hidden = $total_hidden+1;
- }
- $total_protected=0;
- $sql='SELECT * FROM '.$tbl_wiki.' WHERE c_id = '.$course_id.' AND editlock=1 AND '.$groupfilter.$condition_session.' GROUP BY reflink';
- $allpages=Database::query($sql);
- while ($row=Database::fetch_array($allpages)) {
- $total_protected = $total_protected+1;
- }
- $total_empty_content=0;
- $sql='SELECT * FROM '.$tbl_wiki.' WHERE c_id = '.$course_id.' AND content="" AND '.$groupfilter.$condition_session.'';
- $allpages=Database::query($sql);
- while ($row=Database::fetch_array($allpages)) {
- $total_empty_content = $total_empty_content+1;
- }
- $total_empty_content_lv=0;
- $sql = 'SELECT * FROM '.$tbl_wiki.' s1
- WHERE s1.c_id = '.$course_id.' AND content="" AND id=(
- SELECT MAX(s2.id) FROM '.$tbl_wiki.' s2 WHERE s1.c_id = '.$course_id.' AND s1.reflink = s2.reflink AND '.$groupfilter.' AND session_id='.$session_id.')';
- $allpages=Database::query($sql);
- while ($row=Database::fetch_array($allpages)) {
- $total_empty_content_lv = $total_empty_content_lv+1;
- }
- $total_lock_disc=0;
- $sql='SELECT * FROM '.$tbl_wiki.' WHERE c_id = '.$course_id.' AND addlock_disc=0 AND '.$groupfilter.$condition_session.' GROUP BY reflink';
- $allpages=Database::query($sql);
- while ($row=Database::fetch_array($allpages)) {
- $total_lock_disc = $total_lock_disc+1;
- }
- $total_hidden_disc=0;
- $sql='SELECT * FROM '.$tbl_wiki.' WHERE c_id = '.$course_id.' AND visibility_disc=0 AND '.$groupfilter.$condition_session.' GROUP BY reflink';
- $allpages=Database::query($sql);
- while ($row=Database::fetch_array($allpages)) {
- $total_hidden_disc = $total_hidden_disc+1;
- }
- $total_comment_version=0;
- $sql='SELECT * FROM '.$tbl_wiki.' WHERE c_id = '.$course_id.' AND comment!="" AND '.$groupfilter.$condition_session.'';
- $allpages=Database::query($sql);
- while ($row=Database::fetch_array($allpages)) {
- $total_comment_version = $total_comment_version+1;
- }
- $total_only_teachers_rating=0;
- $sql='SELECT * FROM '.$tbl_wiki.' WHERE c_id = '.$course_id.' AND ratinglock_disc=0 AND '.$groupfilter.$condition_session.' GROUP BY reflink';
- $allpages=Database::query($sql);
- while ($row=Database::fetch_array($allpages)) {
- $total_only_teachers_rating = $total_only_teachers_rating+1;
- }
- $total_rating_by_peers=0;
- $total_rating_by_peers=$total_pages-$total_only_teachers_rating;
- $total_task=0;
- $sql='SELECT * FROM '.$tbl_wiki.', '.$tbl_wiki_conf.' WHERE '.$tbl_wiki_conf.'.c_id = '.$course_id.' AND '.$tbl_wiki_conf.'.task!="" AND '.$tbl_wiki_conf.'.page_id='.$tbl_wiki.'.page_id AND '.$tbl_wiki.'.'.$groupfilter.$condition_session;
- $allpages=Database::query($sql);
- while ($row=Database::fetch_array($allpages)) {
- $total_task=$total_task+1;
- }
- $total_teacher_assignment=0;
- $sql='SELECT * FROM '.$tbl_wiki.' s1 WHERE s1.c_id = '.$course_id.' AND assignment=1 AND id=(SELECT MAX(s2.id) FROM '.$tbl_wiki.' s2 WHERE s2.c_id = '.$course_id.' AND s1.reflink = s2.reflink AND '.$groupfilter.' AND session_id='.$session_id.')';
- $allpages=Database::query($sql);
- while ($row=Database::fetch_array($allpages)) {
- $total_teacher_assignment=$total_teacher_assignment+1;
- }
- $total_student_assignment=0;
- $sql = 'SELECT * FROM '.$tbl_wiki.' s1
- WHERE s1.c_id = '.$course_id.' AND assignment=2 AND
- id=(SELECT MAX(s2.id) FROM '.$tbl_wiki.' s2 WHERE s2.c_id = '.$course_id.' AND s1.reflink = s2.reflink AND '.$groupfilter.' AND session_id='.$session_id.')';
- $allpages=Database::query($sql);
- while ($row=Database::fetch_array($allpages)) {
- $total_student_assignment=$total_student_assignment+1;
- }
- $sql='SELECT * FROM '.$tbl_wiki.' WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.' GROUP BY addlock';
- $allpages=Database::query($sql);
- while ($row=Database::fetch_array($allpages)) {
- $wiki_add_lock=$row['addlock'];
- }
- if ($wiki_add_lock==1){
- $status_add_new_pag=get_lang('Yes');
- }
- else{
- $status_add_new_pag=get_lang('No');
- }
- $first_wiki_date='0000-00-00 00:00:00';
- $sql='SELECT * FROM '.$tbl_wiki.' WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.' ORDER BY dtime ASC LIMIT 1';
- $allpages=Database::query($sql);
- while ($row=Database::fetch_array($allpages)) {
- $first_wiki_date=$row['dtime'];
- }
- $last_wiki_date='0000-00-00 00:00:00';
- $sql='SELECT * FROM '.$tbl_wiki.' WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.' ORDER BY dtime DESC LIMIT 1';
- $allpages=Database::query($sql);
- while ($row=Database::fetch_array($allpages)) {
- $last_wiki_date=$row['dtime'];
- }
- $media_score =0;
- $sql="SELECT *, SUM(score) AS TOTAL_SCORE FROM ".$tbl_wiki." WHERE c_id = $course_id AND ".$groupfilter.$condition_session." GROUP BY reflink ";
- $allpages=Database::query($sql);
- while ($row=Database::fetch_array($allpages)) {
- $total_score=$total_score+$row['TOTAL_SCORE'];
- }
- if (!empty($total_pages)) {
- $media_score = $total_score/$total_pages;
- }
- $media_progress=0;
- $sql='SELECT *, SUM(progress) AS TOTAL_PROGRESS FROM '.$tbl_wiki.' s1 WHERE s1.c_id = '.$course_id.' AND id=(SELECT MAX(s2.id) FROM '.$tbl_wiki.' s2 WHERE s2.c_id = '.$course_id.' AND s1.reflink = s2.reflink AND '.$groupfilter.' AND session_id='.$session_id.')';
- $allpages=Database::query($sql);
- while ($row=Database::fetch_array($allpages)) {
- $total_progress = $row['TOTAL_PROGRESS'];
- }
- if (!empty($total_pages)) {
- $media_progress=$total_progress/$total_pages;
- }
- $total_users=0;
- $sql='SELECT * FROM '.$tbl_wiki.' WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.' GROUP BY user_id';
- $allpages=Database::query($sql);
- while ($row=Database::fetch_array($allpages)) {
- $total_users = $total_users+1;
- }
- $total_ip=0;
- $sql='SELECT * FROM '.$tbl_wiki.' WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.' GROUP BY user_ip';
- $allpages=Database::query($sql);
- while ($row=Database::fetch_array($allpages)) {
- $total_ip = $total_ip+1;
- }
- ?>
- <style>
- thead {background:
- tbody tr:hover {
- background:
- cursor:default;
- }
- </style>
- <?php
- echo '<table width="100%" border="1">';
- echo '<thead>';
- echo '<tr>';
- echo '<td colspan="2">'.get_lang('General').'</td>';
- echo '</tr>';
- echo '</thead>';
- echo '<tr>';
- echo '<td>'.get_lang('StudentAddNewPages').'</td>';
- echo '<td>'.$status_add_new_pag.'</td>';
- echo '</tr>';
- echo '<tr>';
- echo '<td>'.get_lang('DateCreateOldestWikiPage').'</td>';
- echo '<td>'.$first_wiki_date.'</td>';
- echo '</tr>';
- echo '<tr>';
- echo '<td>'.get_lang('DateEditLatestWikiVersion').'</td>';
- echo '<td>'.$last_wiki_date.'</td>';
- echo '</tr>';
- echo '<tr>';
- echo '<td>'.get_lang('AverageScoreAllPages').'</td>';
- echo '<td>'.$media_score.' %</td>';
- echo '</tr>';
- echo '<tr>';
- echo '<td>'.get_lang('AverageMediaUserProgress').'</td>';
- echo '<td>'.$media_progress.' %</td>';
- echo '</tr>';
- echo '<tr>';
- echo '<td>'.get_lang('TotalWikiUsers').'</td>';
- echo '<td>'.$total_users.'</td>';
- echo '</tr>';
- echo '<tr>';
- echo '<td>'.get_lang('TotalIpAdress').'</td>';
- echo '<td>'.$total_ip.'</td>';
- echo '</tr>';
- echo '</table>';
- echo '<br/>';
- echo '<table width="100%" border="1">';
- echo '<thead>';
- echo '<tr>';
- echo '<td colspan="2">'.get_lang('Pages').' '.get_lang('And').' '.get_lang('Versions').'</td>';
- echo '</tr>';
- echo '</thead>';
- echo '<tr>';
- echo '<td>'.get_lang('Pages').' - '.get_lang('NumContributions').'</td>';
- echo '<td>'.$total_pages.' ('.get_lang('Versions').': '.$total_versions.')</td>';
- echo '</tr>';
- echo '<tr>';
- echo '<td>'.get_lang('EmptyPages').'</td>';
- echo '<td>'.$total_empty_content_lv.' ('.get_lang('Versions').': '.$total_empty_content.')</td>';
- echo '</tr>';
- echo '<tr>';
- echo '<td>'.get_lang('NumAccess').'</td>';
- echo '<td>'.$total_visits_lv.' ('.get_lang('Versions').': '.$total_visits.')</td>';
- echo '</tr>';
- echo '<tr>';
- echo '<td>'.get_lang('TotalPagesEditedAtThisTime').'</td>';
- echo '<td>'.$total_editing_now.'</td>';
- echo '</tr>';
- echo '<tr>';
- echo '<td>'.get_lang('TotalHiddenPages').'</td>';
- echo '<td>'.$total_hidden.'</td>';
- echo '</tr>';
- echo '<tr>';
- echo '<td>'.get_lang('NumProtectedPages').'</td>';
- echo '<td>'.$total_protected.'</td>';
- echo '</tr>';
- echo '<tr>';
- echo '<td>'.get_lang('LockedDiscussPages').'</td>';
- echo '<td>'.$total_lock_disc.'</td>';
- echo '</tr>';
- echo '<tr>';
- echo '<td>'.get_lang('HiddenDiscussPages').'</td>';
- echo '<td>'.$total_hidden_disc.'</td>';
- echo '</tr>';
- echo '<tr>';
- echo '<td>'.get_lang('TotalComments').'</td>';
- echo '<td>'.$total_comment_version.'</td>';
- echo '</tr>';
- echo '<tr>';
- echo '<td>'.get_lang('TotalOnlyRatingByTeacher').'</td>';
- echo '<td>'.$total_only_teachers_rating.'</td>';
- echo '</tr>';
- echo '<tr>';
- echo '<td>'.get_lang('TotalRatingPeers').'</td>';
- echo '<td>'.$total_rating_by_peers.'</td>';
- echo '</tr>';
- echo '<tr>';
- echo '<td>'.get_lang('TotalTeacherAssignments').' - '.get_lang('PortfolioMode').'</td>';
- echo '<td>'.$total_teacher_assignment.'</td>';
- echo '</tr>';
- echo '<tr>';
- echo '<td>'.get_lang('TotalStudentAssignments').' - '.get_lang('PortfolioMode').'</td>';
- echo '<td>'.$total_student_assignment.'</td>';
- echo '</tr>';
- echo '<tr>';
- echo '<td>'.get_lang('TotalTask').' - '.get_lang('StandardMode').'</td>';
- echo '<td>'.$total_task.'</td>';
- echo '</tr>';
- echo '</table>';
- echo '<br/>';
- echo '<table width="100%" border="1">';
- echo '<thead>';
- echo '<tr>';
- echo '<td colspan="3">'.get_lang('ContentPagesInfo').'</td>';
- echo '</tr>';
- echo '<tr>';
- echo '<td></td>';
- echo '<td>'.get_lang('InTheLastVersion').'</td>';
- echo '<td>'.get_lang('InAllVersions').'</td>';
- echo '</tr>';
- echo '</thead>';
- echo '<tr>';
- echo '<td>'.get_lang('NumWords').'</td>';
- echo '<td>'.$total_words_lv.'</td>';
- echo '<td>'.$total_words.'</td>';
- echo '</tr>';
- echo '<tr>';
- echo '<td>'.get_lang('NumlinksHtmlImagMedia').'</td>';
- echo '<td>'.$total_links_lv.' ('.get_lang('Anchors').':'.$total_links_anchors_lv.', Mail:'.$total_links_mail_lv.', FTP:'.$total_links_ftp_lv.' IRC:'.$total_links_irc_lv.', News:'.$total_links_news_lv.', ... ) </td>';
- echo '<td>'.$total_links.' ('.get_lang('Anchors').':'.$total_links_anchors.', Mail:'.$total_links_mail.', FTP:'.$total_links_ftp.', IRC:'.$total_links_irc.', News:'.$total_links_news.', ... ) </td>';
- echo '</tr>';
- echo '<tr>';
- echo '<td>'.get_lang('NumWikilinks').'</td>';
- echo '<td>'.$total_wlinks_lv.'</td>';
- echo '<td>'.$total_wlinks.'</td>';
- echo '</tr>';
- echo '<tr>';
- echo '<td>'.get_lang('NumImages').'</td>';
- echo '<td>'.$total_images_lv.'</td>';
- echo '<td>'.$total_images.'</td>';
- echo '</tr>';
- echo '<tr>';
- echo '<td>'.get_lang('NumFlash').'</td>';
- echo '<td>'.$total_flash_lv.'</td>';
- echo '<td>'.$total_flash.'</td>';
- echo '</tr>';
- echo '<tr>';
- echo '<td>'.get_lang('NumMp3').'</td>';
- echo '<td>'.$total_mp3_lv.'</td>';
- echo '<td>'.$total_mp3.'</td>';
- echo '</tr>';
- echo '<tr>';
- echo '<td>'.get_lang('NumFlvVideo').'</td>';
- echo '<td>'.$total_flv_lv.'</td>';
- echo '<td>'.$total_flv.'</td>';
- echo '</tr>';
- echo '<tr>';
- echo '<td>'.get_lang('NumYoutubeVideo').'</td>';
- echo '<td>'.$total_youtube_lv.'</td>';
- echo '<td>'.$total_youtube.'</td>';
- echo '</tr>';
- echo '<tr>';
- echo '<td>'.get_lang('NumOtherAudioVideo').'</td>';
- echo '<td>'.$total_multimedia_lv.'</td>';
- echo '<td>'.$total_multimedia.'</td>';
- echo '</tr>';
- echo '<tr>';
- echo '<td>'.get_lang('NumTables').'</td>';
- echo '<td>'.$total_tables_lv.'</td>';
- echo '<td>'.$total_tables.'</td>';
- echo '</tr>';
- echo '</table>';
- echo '<br/>';
- }
- if ($_GET['action']=='mactiveusers') {
- echo '<div class="actions">'.get_lang('MostActiveUsers').'</div>';
- $sql='SELECT *, COUNT(*) AS NUM_EDIT FROM '.$tbl_wiki.' WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.' GROUP BY user_id';
- $allpages=Database::query($sql);
-
- if (Database::num_rows($allpages) > 0) {
- $row = array ();
- while ($obj = Database::fetch_object($allpages)) {
- $userinfo = api_get_user_info($obj->user_id);
- $row = array ();
- if ($obj->user_id <> 0) {
- $row[] = '<a href="../user/userInfo.php?uInfo='.$userinfo['user_id'].'">'.
- Display::tag('span', api_htmlentities($userinfo['complete_name_login_as'])).
- '</a><a href="'.api_get_self().'?cidReq='.$_course['id'].'&action=usercontrib&user_id='.urlencode($row['user_id']).
- '&session_id='.intval($_GET['session_id']).'&group_id='.intval($_GET['group_id']).'"></a>';
- }
- else {
- $row[] = get_lang('Anonymous').' ('.$obj->user_ip.')';
- }
- $row[] ='<a href="'.api_get_self().'?cidReq='.$_course['id'].'&action=usercontrib&user_id='.urlencode($obj->user_id).'&session_id='.intval($_GET['session_id']).'&group_id='.intval($_GET['group_id']).'">'.$obj->NUM_EDIT.'</a>';
- $rows[] = $row;
- }
- $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']),'session_id'=>intval($_GET['session_id']),'group_id'=>intval($_GET['group_id'])));
- $table->set_header(0,get_lang('Author'), true);
- $table->set_header(1,get_lang('Contributions'), true,array ('style' => 'width:30px;'));
- $table->display();
- }
- }
- if ($_GET['action']=='usercontrib') {
- $userinfo = api_get_user_info($_GET['user_id']);
- $username = api_htmlentities(sprintf(get_lang('LoginX'), $userinfo['username']), ENT_QUOTES);
- echo '<div class="actions">'.get_lang('UserContributions').': <a href="../user/userInfo.php?uInfo='.$userinfo['user_id'].'">'.
- Display::tag('span', api_htmlentities($userinfo['complete_name'])).
- '</a><a href="'.api_get_self().'?cidReq='.$_course['id'].'&action=usercontrib&user_id='.urlencode($row['user_id']).
- '&session_id='.intval($_GET['session_id']).'&group_id='.intval($_GET['group_id']).'"></a></div>';
- if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
- $sql='SELECT * FROM '.$tbl_wiki.' WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.' AND user_id="'.Database::escape_string($_GET['user_id']).'"';
- } else {
- $sql='SELECT * FROM '.$tbl_wiki.' WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.' AND user_id="'.Database::escape_string($_GET['user_id']).'" AND visibility=1';
- }
- $allpages=Database::query($sql);
-
- if (Database::num_rows($allpages) > 0) {
- $row = array ();
- while ($obj = Database::fetch_object($allpages)) {
-
-
-
- $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);
-
- if ($obj->assignment==1) {
- $ShowAssignment=Display::return_icon('wiki_assignment.png', get_lang('AssignmentDescExtra'),'',ICON_SIZE_SMALL);
- } elseif ($obj->assignment==2) {
- $ShowAssignment=Display::return_icon('wiki_work.png', get_lang('AssignmentWork'),'',ICON_SIZE_SMALL);
- } elseif ($obj->assignment==0) {
- $ShowAssignment='<img src="../img/px_transparent.gif" />';
- }
- $row = array ();
- $row[] = $year.'-'.$month.'-'.$day.' '.$hours.":".$minutes.":".$seconds;
- $row[] =$ShowAssignment;
- $row[] = '<a href="'.api_get_self().'?cidReq='.$_course['id'].'&action=showpage&title='.api_htmlentities(urlencode($obj->reflink)).'&view='.$obj->id.'&session_id='.Security::remove_XSS($_GET['$session_id']).'&group_id='.Security::remove_XSS($_GET['group_id']).'">'.api_htmlentities($obj->title).'</a>';
- $row[] =Security::remove_XSS($obj->version);
- $row[] =Security::remove_XSS($obj->comment);
- $row[] =Security::remove_XSS($obj->progress).' %';
- $row[] =Security::remove_XSS($obj->score);
- $rows[] = $row;
- }
- $table = new SortableTableFromArrayConfig($rows,2,10,'UsersContributions_table','','','ASC');
- $table->set_additional_parameters(array('cidReq' =>Security::remove_XSS($_GET['cidReq']),'action'=>Security::remove_XSS($_GET['action']),'user_id'=>Security::remove_XSS($_GET['user_id']),'session_id'=>Security::remove_XSS($_GET['session_id']),'group_id'=>Security::remove_XSS($_GET['group_id'])));
- $table->set_header(0,get_lang('Date'), true, array ('style' => 'width:200px;'));
- $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;'));
-
-
-
-
- $table->display();
- }
- }
- if ($_GET['action']=='mostchanged') {
- echo '<div class="actions">'.get_lang('MostChangedPages').'</div>';
- if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
- $sql='SELECT *, MAX(version) AS MAX FROM '.$tbl_wiki.' WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.' GROUP BY reflink';
- } else {
- $sql='SELECT *, MAX(version) AS MAX FROM '.$tbl_wiki.' WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.' AND visibility=1 GROUP BY reflink';
- }
- $allpages=Database::query($sql);
-
- if (Database::num_rows($allpages) > 0) {
- $row = array ();
- while ($obj = Database::fetch_object($allpages)) {
-
- if ($obj->assignment==1) {
- $ShowAssignment=Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'),'',ICON_SIZE_SMALL);
- } elseif ($obj->assignment==2) {
- $ShowAssignment=Display::return_icon('wiki_work.png', get_lang('AssignmentWork'),'',ICON_SIZE_SMALL);
- } elseif ($obj->assignment==0) {
- $ShowAssignment='<img src="../img/px_transparent.gif" />';
- }
- $row = array ();
- $row[] =$ShowAssignment;
- $row[] = '<a href="'.api_get_self().'?cidReq='.$_course['id'].'&action=showpage&title='.api_htmlentities(urlencode($obj->reflink)).'&session_id='.Security::remove_XSS($_GET['session_id']).'&group_id='.Security::remove_XSS($_GET['group_id']).'">'.api_htmlentities($obj->title).'</a>';
- $row[] = $obj->MAX;
- $rows[] = $row;
- }
- $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']),'session_id'=>Security::remove_XSS($_GET['session_id']),'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();
- }
- }
- if ($_GET['action']=='mvisited') {
- echo '<div class="actions">'.get_lang('MostVisitedPages').'</div>';
- if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
- $sql='SELECT *, SUM(hits) AS tsum FROM '.$tbl_wiki.' WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.' GROUP BY reflink';
- } else {
- $sql='SELECT *, SUM(hits) AS tsum FROM '.$tbl_wiki.' WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.' AND visibility=1 GROUP BY reflink';
- }
- $allpages=Database::query($sql);
-
- if (Database::num_rows($allpages) > 0) {
- $row = array ();
- while ($obj = Database::fetch_object($allpages)) {
-
- if ($obj->assignment==1) {
- $ShowAssignment=Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'),'',ICON_SIZE_SMALL);
- } elseif ($obj->assignment==2) {
- $ShowAssignment=$ShowAssignment=Display::return_icon('wiki_work.png', get_lang('AssignmentWork'),'',ICON_SIZE_SMALL);
- } elseif ($obj->assignment==0) {
- $ShowAssignment='<img src="../img/px_transparent.gif" />';
- }
- $row = array ();
- $row[] =$ShowAssignment;
- $row[] = '<a href="'.api_get_self().'?cidReq='.$_course['id'].'&action=showpage&title='.api_htmlentities(urlencode($obj->reflink)).'&session_id='.Security::remove_XSS($_GET['session_id']).'&group_id='.Security::remove_XSS($_GET['group_id']).'">'.api_htmlentities($obj->title).'</a>';
- $row[] = $obj->tsum;
- $rows[] = $row;
- }
- $table = new SortableTableFromArrayConfig($rows,2,10,'MostVisitedPages_table','','','DESC');
- $table->set_additional_parameters(array('cidReq' =>Security::remove_XSS($_GET['cidReq']),'action'=>Security::remove_XSS($_GET['action']),'session_id'=>Security::remove_XSS($_GET['session_id']),'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);
- $table->display();
- }
- }
- if ($_GET['action']=='wanted') {
- echo '<div class="actions">'.get_lang('WantedPages').'</div>';
- $pages = array();
- $refs = array();
- $wanted = array();
-
- $sql='SELECT * FROM '.$tbl_wiki.' WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.' GROUP BY reflink ORDER BY reflink ASC';
- $allpages=Database::query($sql);
- while ($row=Database::fetch_array($allpages)) {
- if ($row['reflink']=='index'){
- $row['reflink']=str_replace(' ','_',get_lang('DefaultTitle'));
- }
- $pages[] = $row['reflink'];
- }
-
- $sql = 'SELECT * FROM '.$tbl_wiki.' s1
- WHERE s1.c_id = '.$course_id.' AND id=(SELECT MAX(s2.id) FROM '.$tbl_wiki.' s2 WHERE s2.c_id = '.$course_id.' AND s1.reflink = s2.reflink AND '.$groupfilter.$condition_session.')';
- $allpages=Database::query($sql);
- while ($row=Database::fetch_array($allpages)) {
- $refs = explode(" ", trim($row["linksto"]));
-
- foreach ($refs as $v) {
- if (!in_array($v, $pages)) {
- if (trim($v)!="") {
- $wanted[]=$v;
- }
- }
- }
- }
- $wanted=array_unique($wanted);
-
- foreach ($wanted as $wanted_show) {
- $row = array ();
- $wanted_show=Security::remove_XSS($wanted_show);
- $row[] = '<a href="'.api_get_path(WEB_PATH).'main/wiki/index.php?cidReq=&action=addnew&title='.str_replace('_',' ',$wanted_show).'&session_id='.Security::remove_XSS($_GET['session_id']).'&group_id='.Security::remove_XSS($_GET['group_id']).'" class="new_wiki_link">'.str_replace('_',' ',$wanted_show).'</a>';
- $rows[] = $row;
- }
- $table = new SortableTableFromArrayConfig($rows,0,10,'WantedPages_table','','','DESC');
- $table->set_additional_parameters(array('cidReq' =>Security::remove_XSS($_GET['cidReq']),'action'=>Security::remove_XSS($_GET['action']),'session_id'=>Security::remove_XSS($_GET['session_id']),'group_id'=>Security::remove_XSS($_GET['group_id'])));
- $table->set_header(0,get_lang('Title'), true);
- $table->display();
- }
- if ($_GET['action']=='orphaned') {
- echo '<div class="actions">'.get_lang('OrphanedPages').'</div>';
- $pages = array();
- $refs = array();
- $list_refs = array();
- $orphaned = array();
-
- $sql='SELECT * FROM '.$tbl_wiki.' WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.' GROUP BY reflink ORDER BY reflink ASC';
- $allpages=Database::query($sql);
- while ($row=Database::fetch_array($allpages)) {
- $pages[] = $row['reflink'];
- }
-
- $sql = 'SELECT * FROM '.$tbl_wiki.' s1
- WHERE s1.c_id = '.$course_id.' AND id=(SELECT MAX(s2.id) FROM '.$tbl_wiki.' s2 WHERE s2.c_id = '.$course_id.' AND s1.reflink = s2.reflink AND '.$groupfilter.$condition_session.')';
- $allpages=Database::query($sql);
- while ($row=Database::fetch_array($allpages)) {
- $row['linksto']= str_replace($row["reflink"], " ", trim($row["linksto"]));
- $refs = explode(" ", trim($row["linksto"]));
- foreach ($refs as $ref_linked){
- if ($ref_linked==str_replace(' ','_',get_lang('DefaultTitle'))) {
- $ref_linked='index';
- }
- $array_refs_linked[]= $ref_linked;
- }
- }
- $array_refs_linked = array_unique($array_refs_linked);
-
- foreach ($pages as $v) {
- if (!in_array($v, $array_refs_linked)) {
- $orphaned[] = $v;
- }
- }
- foreach ($orphaned as $orphaned_show) {
-
- $sql='SELECT * FROM '.$tbl_wiki.' WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.' AND reflink="'.Database::escape_string($orphaned_show).'" GROUP BY reflink';
- $allpages=Database::query($sql);
- while ($row=Database::fetch_array($allpages)) {
- $orphaned_title=$row['title'];
- $orphaned_visibility=$row['visibility'];
- if ($row['assignment']==1) {
- $ShowAssignment=Display::return_icon('wiki_assignment.png','','',ICON_SIZE_SMALL);
- } elseif ($row['assignment']==2) {
- $ShowAssignment=Display::return_icon('wiki_work.png','','',ICON_SIZE_SMALL);
- } elseif ($row['assignment']==0) {
- $ShowAssignment='<img src="../img/px_transparent.gif" />';
- }
- }
- if (!api_is_allowed_to_edit(false,true) || !api_is_platform_admin() AND $orphaned_visibility==0){
- continue;
- }
-
- $row = array ();
- $row[] =$ShowAssignment;
- $row[] = '<a href="'.api_get_self().'?cidReq='.$_course['id'].'&action=showpage&title='.api_htmlentities(urlencode($orphaned_show)).'&session_id='.Security::remove_XSS($_GET['session_id']).'&group_id='.Security::remove_XSS($_GET['group_id']).'">'.api_htmlentities($orphaned_title).'</a>';
- $rows[] = $row;
- }
- $table = new SortableTableFromArrayConfig($rows,1,10,'OrphanedPages_table','','','DESC');
- $table->set_additional_parameters(array('cidReq' =>Security::remove_XSS($_GET['cidReq']),'action'=>Security::remove_XSS($_GET['action']),'session_id'=>Security::remove_XSS($_GET['session_id']),'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->display();
- }
- if ($_GET['action']=='mostlinked') {
- echo '<div class="actions">'.get_lang('MostLinkedPages').'</div>';
- $pages = array();
- $refs = array();
- $linked = array();
-
- $sql='SELECT * FROM '.$tbl_wiki.' WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.' GROUP BY reflink ORDER BY reflink ASC';
- $allpages=Database::query($sql);
- while ($row=Database::fetch_array($allpages)) {
- if ($row['reflink']=='index'){
- $row['reflink']=str_replace(' ','_',get_lang('DefaultTitle'));
- }
- $pages[] = $row['reflink'];
- }
-
- $sql='SELECT * FROM '.$tbl_wiki.' s1 WHERE s1.c_id = '.$course_id.' AND id=(SELECT MAX(s2.id) FROM '.$tbl_wiki.' s2 WHERE s2.c_id = '.$course_id.' AND s1.reflink = s2.reflink AND '.$groupfilter.$condition_session.')';
- $allpages=Database::query($sql);
- while ($row=Database::fetch_array($allpages)) {
- $row['linksto']= str_replace($row["reflink"], " ", trim($row["linksto"]));
- $refs = explode(" ", trim($row["linksto"]));
-
- foreach ($refs as $v) {
- if (in_array($v, $pages)) {
- if (trim($v)!="") {
- $linked[]=$v;
- }
- }
- }
- }
- $linked=array_unique($linked);
-
- foreach ($linked as $linked_show) {
- $row = array ();
- $row[] = '<a href="'.api_get_self().'?cidReq='.$_course['id'].'&action=showpage&title='.api_htmlentities(urlencode(str_replace('_',' ',$linked_show))).'&session_id='.Security::remove_XSS($_GET['session_id']).'&group_id='.Security::remove_XSS($_GET['group_id']).'">'.str_replace('_',' ',$linked_show).'</a>';
- $rows[] = $row;
- }
- $table = new SortableTableFromArrayConfig($rows,0,10,'LinkedPages_table','','','DESC');
- $table->set_additional_parameters(array('cidReq' =>Security::remove_XSS($_GET['cidReq']),'action'=>Security::remove_XSS($_GET['action']),'session_id'=>Security::remove_XSS($_GET['session_id']),'group_id'=>Security::remove_XSS($_GET['group_id'])));
- $table->set_header(0,get_lang('Title'), true);
- $table->display();
- }
- if ($_GET['action']=='delete') {
- if (!$_GET['title']) {
- Display::display_error_message(get_lang('MustSelectPage'));
- exit;
- }
- echo '<div style="overflow:hidden">';
- if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
- echo '<div id="wikititle">'.get_lang('DeletePageHistory').'</div>';
- if ($page=="index") {
- Display::display_warning_message(get_lang('WarningDeleteMainPage'),false);
- }
- $message = get_lang('ConfirmDeletePage')."</p>"."<p>"."<a href=\"index.php\">".get_lang("No")."</a>"." | "."<a href=\"".api_get_self()."?action=delete&title=".api_htmlentities(urlencode($page))."&delete=yes\">".get_lang("Yes")."</a>"."</p>";
- if (!isset ($_GET['delete'])) {
- Display::display_warning_message($message,false);
- }
- if ($_GET['delete'] == 'yes') {
- $sql='DELETE '.$tbl_wiki_discuss.' FROM '.$tbl_wiki.', '.$tbl_wiki_discuss.'
- 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 '.$tbl_wiki_mailcue.' FROM '.$tbl_wiki.', '.$tbl_wiki_mailcue.'
- WHERE '.$tbl_wiki.'.c_id = '.$course_id.' AND '.$tbl_wiki_mailcue.'.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_mailcue.'.id='.$tbl_wiki.'.id';
- Database::query($sql);
- $sql='DELETE FROM '.$tbl_wiki.' WHERE c_id = '.$course_id.' AND reflink="'.Database::escape_string($page).'" AND '.$groupfilter.$condition_session.'';
- Database::query($sql);
- check_emailcue(0, 'E');
- Display::display_confirmation_message(get_lang('WikiPageDeleted'));
- }
- } else {
- Display::display_normal_message(get_lang("OnlyAdminDeletePageWiki"));
- }
- echo '</div>';
- }
- if ($_GET['action']=='deletewiki') {
- echo '<div class="actions">'.get_lang('DeleteWiki').'</div>';
- echo '<div style="overflow:hidden">';
- if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
- $message = get_lang('ConfirmDeleteWiki');
- $message .= '<p>
- <a href="index.php">'.get_lang('No').'</a>
- |
- <a href="'.api_get_self().'?action=deletewiki&delete=yes">'.get_lang('Yes').'</a>
- </p>';
- if (!isset($_GET['delete'])) {
- Display::display_warning_message($message,false);
- }
- } else {
- Display::display_normal_message(get_lang("OnlyAdminDeleteWiki"));
- }
- echo '</div>';
- }
- if ($_GET['action']=='searchpages') {
- echo '<div class="actions">'.get_lang('SearchPages').'</div>';
- echo '<div style="overflow:hidden">';
- if ($_GET['mode_table']) {
- if (! $_GET['SearchPages_table_page_nr']) {
- $_GET['search_term']=$_POST['search_term'];
- $_GET['search_content']=$_POST['search_content'];
- $_GET['all_vers']=$_POST['all_vers'];
- }
- display_wiki_search_results(api_htmlentities($_GET['search_term']),api_htmlentities($_GET['search_content']),api_htmlentities($_GET['all_vers']));
- } else {
-
- $form = new FormValidator('wiki_search','post', api_get_self().'?cidReq='.Security::remove_XSS($_GET['cidReq']).'&action='.Security::remove_XSS($_GET['action']).'&session_id='.Security::remove_XSS($_GET['session_id']).'&group_id='.Security::remove_XSS($_GET['group_id']).'&mode_table=yes1&search_term='.Security::remove_XSS($_GET['search_term']).'&search_content='.Security::remove_XSS($_GET['search_content']).'&all_vers='.Security::remove_XSS($_GET['all_vers']));
-
- $form->addElement('text', 'search_term', get_lang('SearchTerm'),'class="input_titles" id="search_title"');
- $form->addElement('checkbox', 'search_content', null, get_lang('AlsoSearchContent'));
- $form->addElement('checkbox', 'all_vers', null, get_lang('IncludeAllVersions'));
- $form->addElement('style_submit_button', 'SubmitWikiSearch', get_lang('Search'), 'class="search"');
-
- $form->addRule('search_term', get_lang('ThisFieldIsRequired'), 'required');
- $form->addRule('search_term', get_lang('TooShort'),'minlength',3);
- if ($form->validate()) {
- $form->display();
- $values = $form->exportValues();
- display_wiki_search_results($values['search_term'], $values['search_content'], $values['all_vers']);
- } else {
- $form->display();
- }
- }
- echo '</div>';
- }
- if ($_GET['action']=='links') {
- if (!$_GET['title']) {
- Display::display_error_message(get_lang("MustSelectPage"));
- } else {
- $sql='SELECT * FROM '.$tbl_wiki.' WHERE c_id = '.$course_id.' AND reflink="'.Database::escape_string($page).'" AND '.$groupfilter.$condition_session.'';
- $result=Database::query($sql);
- $row=Database::fetch_array($result);
-
- if ($row['assignment']==1) {
- $ShowAssignment=Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'),'',ICON_SIZE_SMALL);
- } elseif ($row['assignment']==2) {
- $ShowAssignment=Display::return_icon('wiki_work.png', get_lang('AssignmentWork'),'',ICON_SIZE_SMALL);
- } elseif ($row['assignment']==0) {
- $ShowAssignment='<img src="../img/px_transparent.gif" />';
- }
-
- if ($page==get_lang('DefaultTitle')) {
- $page='index';
- }
- echo '<div id="wikititle">';
- echo get_lang('LinksPagesFrom').': '.$ShowAssignment.' <a href="'.api_get_self().'?cidReq='.$_course['id'].'&action=showpage&title='.Security::remove_XSS($page).'&session_id='.Security::remove_XSS($_GET['session_id']).'&group_id='.Security::remove_XSS($_GET['group_id']).'">'.Security::remove_XSS($row['title']).'</a>';
- echo '</div>';
-
- if ($page=='index') {
- $page=str_replace(' ','_',get_lang('DefaultTitle'));
- }
-
- if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
- $sql="SELECT * FROM ".$tbl_wiki." s1 WHERE s1.c_id = $course_id AND linksto LIKE '%".Database::escape_string($page)." %' AND id=(SELECT MAX(s2.id) FROM ".$tbl_wiki." s2 WHERE s2.c_id = $course_id AND s1.reflink = s2.reflink AND ".$groupfilter.$condition_session.")";
- } else {
- $sql="SELECT * FROM ".$tbl_wiki." s1 WHERE s1.c_id = $course_id AND visibility=1 AND linksto LIKE '%".Database::escape_string($page)." %' AND id=(SELECT MAX(s2.id) FROM ".$tbl_wiki." s2 WHERE s2.c_id = $course_id AND s1.reflink = s2.reflink AND ".$groupfilter.$condition_session.")";
- }
- $allpages=Database::query($sql);
-
- if (Database::num_rows($allpages) > 0) {
- $row = array ();
- while ($obj = Database::fetch_object($allpages)) {
-
- $userinfo = api_get_user_info($obj->user_id);
- $username = api_htmlentities(sprintf(get_lang('LoginX'), $userinfo['username']), ENT_QUOTES);
-
- $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);
-
- if ($obj->assignment==1) {
- $ShowAssignment=Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'),'',ICON_SIZE_SMALL);
- } elseif ($obj->assignment==2) {
- $ShowAssignment=Display::return_icon('wiki_work.png', get_lang('AssignmentWork'),'',ICON_SIZE_SMALL);
- } elseif ($obj->assignment==0) {
- $ShowAssignment='<img src="../img/px_transparent.gif" />';
- }
- $row = array ();
- $row[] =$ShowAssignment;
- $row[] = '<a href="'.api_get_self().'?cidReq='.$_course['id'].'&action=showpage&title='.Security::remove_XSS($obj->reflink).'&session_id='.Security::remove_XSS($_GET['session_id']).'&group_id='.Security::remove_XSS($_GET['group_id']).'">'.Security::remove_XSS($obj->title).'</a>';
- if ($obj->user_id <>0) {
- $row[] = '<a href="../user/userInfo.php?uInfo='.$userinfo['user_id'].'">'.
- Display::tag('span', api_htmlentities($userinfo['complete_name_login_as'])).'</a>';
- }
- else {
- $row[] = get_lang('Anonymous').' ('.$obj->user_ip.')';
- }
- $row[] = $year.'-'.$month.'-'.$day.' '.$hours.":".$minutes.":".$seconds;
- $rows[] = $row;
- }
- $table = new SortableTableFromArrayConfig($rows,1,10,'AllPages_table','','','ASC');
- $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);
- $table->set_header(3,get_lang('Date'), true);
- $table->display();
- }
- }
- }
- echo '<div style="overflow:hidden">';
- if ($_GET['action']=='addnew') {
- if (api_get_session_id()!=0 && api_is_allowed_to_session_edit(false,true)==false) {
- api_not_allowed();
- }
- echo '<div class="actions">'.get_lang('AddNew').'</div>';
- echo '<br/>';
-
- if (checktitle('index')) {
- if (api_is_allowed_to_edit(false,true) || api_is_platform_admin() || GroupManager :: is_user_in_group($_user['user_id'],$_SESSION['_gid'])) {
- Display::display_normal_message(get_lang('GoAndEditMainPage'));
- } else {
- return Display::display_normal_message(get_lang('WikiStandBy'));
- }
- } elseif (check_addnewpagelock()==0 && (api_is_allowed_to_edit(false,true)==false || api_is_platform_admin()==false)) {
- Display::display_error_message(get_lang('AddPagesLocked'));
- } else {
- if(api_is_allowed_to_edit(false,true) || api_is_platform_admin() || GroupManager :: is_user_in_group($_user['user_id'],$_SESSION['_gid']) || Security::remove_XSS($_GET['group_id'])==0) {
- display_new_wiki_form();
- } else {
- Display::display_normal_message(get_lang('OnlyAddPagesGroupMembers'));
- }
- }
- }
- if (!$_GET['action'] OR $_GET['action']=='show' AND !isset($_POST['SaveWikiNew'])) {
- display_wiki_entry($newtitle);
- }
- if ($_GET['action']=='showpage' AND !isset($_POST['SaveWikiNew'])) {
- if ($_GET['title']) {
- display_wiki_entry($newtitle);
- } else {
- Display::display_error_message(get_lang('MustSelectPage'));
- }
- }
- if ($_GET['action']=='edit') {
- if (api_get_session_id()!=0 && api_is_allowed_to_session_edit(false,true)==false) {
- api_not_allowed();
- }
- $_clean['group_id']=(int)$_SESSION['_gid'];
- $sql = 'SELECT * FROM '.$tbl_wiki.', '.$tbl_wiki_conf.'
- WHERE
- '.$tbl_wiki.'.c_id = '.$course_id.' AND
- '.$tbl_wiki_conf.'.c_id = '.$course_id.' AND
- '.$tbl_wiki_conf.'.page_id='.$tbl_wiki.'.page_id AND
- '.$tbl_wiki.'.reflink="'.Database::escape_string($page).'" AND
- '.$tbl_wiki.'.'.$groupfilter.$condition_session.'
- ORDER BY id DESC';
- $result=Database::query($sql);
- $row=Database::fetch_array($result);
- if ($row['content']=='' AND $row['title']=='' AND $page=='') {
- Display::display_error_message(get_lang('MustSelectPage'));
- exit;
- } elseif ($row['content']=='' AND $row['title']=='' AND $page=='index') {
-
- $default_table_for_content_Start='<table align="center" border="0"><tr><td align="center">';
- $default_table_for_content_End='</td></tr></table>';
- $content=$default_table_for_content_Start.sprintf(get_lang('DefaultContent'),api_get_path(WEB_IMG_PATH)).$default_table_for_content_End;
- $title=get_lang('DefaultTitle');
- $page_id=0;
- } else {
- $content = api_html_entity_decode($row['content']);
- $title = api_html_entity_decode($row['title']);
- $page_id = $row['page_id'];
- }
-
- if (($row['reflink']=='index' || $row['reflink']=='' || $row['assignment']==1) && (!api_is_allowed_to_edit(false,true) && $_GET['group_id'] == 0)) {
- Display::display_error_message(get_lang('OnlyEditPagesCourseManager'));
- } else {
- $PassEdit=false;
-
- if ($_clean['group_id']!=0) {
-
- if (api_is_allowed_to_edit(false,true) || api_is_platform_admin() || GroupManager :: is_user_in_group($_user['user_id'], $_GET['group_id'])) {
- $PassEdit=true;
- } else {
- Display::display_normal_message(get_lang('OnlyEditPagesGroupMembers'));
- }
- } else {
- $PassEdit=true;
- }
-
- if ($row['assignment']==1) {
- Display::display_normal_message(get_lang('EditAssignmentWarning'));
- $icon_assignment=Display::return_icon('wiki_assignment.png', get_lang('AssignmentDescExtra'),'',ICON_SIZE_SMALL);
- } elseif ($row['assignment']==2) {
- $icon_assignment=Display::return_icon('wiki_work.png', get_lang('AssignmentWorkExtra'),'',ICON_SIZE_SMALL);
- if ((api_get_user_id()==$row['user_id'])==false) {
- if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
- $PassEdit=true;
- } else {
- Display::display_warning_message(get_lang('LockByTeacher'));
- $PassEdit=false;
- }
- } else {
- $PassEdit=true;
- }
- }
- if ($PassEdit) {
- if ($row['editlock']==1 && (api_is_allowed_to_edit(false,true)==false || api_is_platform_admin()==false)) {
- Display::display_normal_message(get_lang('PageLockedExtra'));
- } else {
-
- if (!empty($row['startdate_assig']) && $row['startdate_assig']!='0000-00-00 00:00:00' && time()<strtotime($row['startdate_assig'])) {
- $message=get_lang('TheTaskDoesNotBeginUntil').': '.api_get_local_time($row['startdate_assig'], null, date_default_timezone_get());
- Display::display_warning_message($message);
- if (!api_is_allowed_to_edit(false,true)) {
- exit;
- }
- }
-
- if (!empty($row['enddate_assig']) && $row['enddate_assig']!='0000-00-00 00:00:00' && time()>strtotime($row['enddate_assig']) && $row['enddate_assig']!='0000-00-00 00:00:00' && $row['delayedsubmit']==0) {
- $message=get_lang('TheDeadlineHasBeenCompleted').': '.api_get_local_time($row['enddate_assig'], null, date_default_timezone_get());
- Display::display_warning_message($message);
- if (!api_is_allowed_to_edit(false,true)) {
- exit;
- }
- }
-
- if (!empty($row['max_version']) && $row['version']>=$row['max_version']) {
- $message=get_lang('HasReachedMaxiNumVersions');
- Display::display_warning_message($message);
- if (!api_is_allowed_to_edit(false,true)) {
- exit;
- }
- }
-
- if (!empty($row['max_text']) && $row['max_text']<=word_count($row['content'])) {
- $message=get_lang('HasReachedMaxNumWords');
- Display::display_warning_message($message);
- if (!api_is_allowed_to_edit(false,true)) {
- exit;
- }
- }
-
- if (!empty($row['task'])) {
-
- if ($row['startdate_assig']=='0000-00-00 00:00:00') {
- $message_task_startdate=get_lang('No');
- } else {
- $message_task_startdate=api_get_local_time($row['startdate_assig'], null, date_default_timezone_get());
- }
- if ($row['enddate_assig']=='0000-00-00 00:00:00') {
- $message_task_enddate=get_lang('No');
- } else {
- $message_task_endate=api_get_local_time($row['enddate_assig'], null, date_default_timezone_get());
- }
- if ($row['delayedsubmit']==0) {
- $message_task_delayedsubmit=get_lang('No');
- } else {
- $message_task_delayedsubmit=get_lang('Yes');
- }
- if ($row['max_version']==0) {
- $message_task_max_version=get_lang('No');
- } else {
- $message_task_max_version=$row['max_version'];
- }
- if ($row['max_text']==0) {
- $message_task_max_text=get_lang('No');
- } else {
- $message_task_max_text=$row['max_text'];
- }
-
- $message_task='<b>'.get_lang('DescriptionOfTheTask').'</b><p>'.$row['task'].'</p><hr>';
- $message_task.='<p>'.get_lang('StartDate').': '.$message_task_startdate.'</p>';
- $message_task.='<p>'.get_lang('EndDate').': '.$message_task_enddate;
- $message_task.=' ('.get_lang('AllowLaterSends').') '.$message_task_delayedsubmit.'</p>';
- $message_task.='<p>'.get_lang('OtherSettings').': '.get_lang('NMaxVersion').': '.$message_task_max_version;
- $message_task.=' '.get_lang('NMaxWords').': '.$message_task_max_text;
-
- Display::display_normal_message($message_task,false);
- }
- if ($row['progress']==$row['fprogress1'] && !empty($row['fprogress1'])) {
- $feedback_message='<b>'.get_lang('Feedback').'</b><p>'.api_htmlentities($row['feedback1']).'</p>';
- Display::display_normal_message($feedback_message, false);
- } elseif ($row['progress']==$row['fprogress2'] && !empty($row['fprogress2'])) {
- $feedback_message='<b>'.get_lang('Feedback').'</b><p>'.api_htmlentities($row['feedback2']).'</p>';
- Display::display_normal_message($feedback_message, false);
- } elseif ($row['progress']==$row['fprogress3'] && !empty($row['fprogress3'])) {
- $feedback_message='<b>'.get_lang('Feedback').'</b><p>'.api_htmlentities($row['feedback3']).'</p>';
- Display::display_normal_message($feedback_message, false);
- }
-
- if ($row['is_editing']==0) {
- echo '<div style="z-index:0">';
- Display::display_normal_message(get_lang('WarningMaxEditingTime'));
- echo '</div>';
- $time_edit = date("Y-m-d H:i:s");
- $sql='UPDATE '.$tbl_wiki.' SET is_editing="'.$_user['user_id'].'", time_edit="'.$time_edit.'" WHERE c_id = '.$course_id.' AND id="'.$row['id'].'"';
- Database::query($sql);
- } elseif ($row['is_editing']!=$_user['user_id']) {
- $timestamp_edit=strtotime($row['time_edit']);
- $time_editing=time()-$timestamp_edit;
- $max_edit_time=1200;
- $rest_time=$max_edit_time-$time_editing;
- $userinfo = api_get_user_info($row['is_editing']);
- $username = api_htmlentities(sprintf(get_lang('LoginX'), $userinfo['username']), ENT_QUOTES);
- $is_being_edited= get_lang('ThisPageisBeginEditedBy').
- ' <a href=../user/userInfo.php?uInfo='.
- $userinfo['user_id'].'>'.
- Display::tag('span', api_htmlentities(api_get_person_name($userinfo['firstname'], $userinfo['lastname'])), array('title'=>$username)).
- '</a>. '.get_lang('ThisPageisBeginEditedTryLater').' '.date( "i",$rest_time).' '.get_lang('MinMinutes').'';
- Display::display_normal_message($is_being_edited, false);
- exit;
- }
-
- echo '<form name="form1" method="post" action="'.api_get_self().'?action=showpage&title='.api_htmlentities(urlencode($page)).'&session_id='.Security::remove_XSS($_GET['session_id']).'&group_id='.Security::remove_XSS($_GET['group_id']).'">';
- echo '<div id="wikititle">';
- echo '<div style="width:70%;float:left;">'.$icon_assignment.str_repeat(' ',3).api_htmlentities($title).'</div>';
- if ((api_is_allowed_to_edit(false,true) || api_is_platform_admin()) && $row['reflink']!='index') {
- echo'<a href="javascript://" onclick="advanced_parameters()" ><span id="plus_minus" style="float:right"> '.Display::return_icon('div_show.gif',get_lang('Show'),array('style'=>'vertical-align:middle')).' '.get_lang('AdvancedParameters').'</span></a>';
- echo '<div id="options" style="display:none; margin: 20px;" >';
-
- echo '<div> </div><input type="checkbox" value="1" name="checktask" onclick="javascript: if(this.checked){document.getElementById(\'option4\').style.display=\'block\';}else{document.getElementById(\'option4\').style.display=\'none\';}"/> '.Display::return_icon('wiki_task.png', get_lang('DefineTask'),'',ICON_SIZE_SMALL).' '.get_lang('DescriptionOfTheTask').'';
- echo ' <span id="msg_error4" style="display:none;color:red"></span>';
- echo '<div id="option4" style="padding:4px; margin:5px; border:1px dotted; display:none;">';
- echo '<table border="0" style="font-weight:normal">';
- echo '<tr>';
- echo '<td>'.get_lang('DescriptionOfTheTask').'</td>';
- echo '</tr>';
- echo '<tr>';
- echo '<td>'.api_disp_html_area('task', $row['task'], '', '', null, array('ToolbarSet' => 'wiki_task', 'Width' => '585', 'Height' => '200')).'</td>';
- echo '</tr>';
- echo '</table>';
- echo '</div>';
-
- echo '<div> </div><input type="checkbox" value="1" name="checkfeedback" onclick="javascript: if(this.checked){document.getElementById(\'option2\').style.display=\'block\';}else{document.getElementById(\'option2\').style.display=\'none\';}"/> '.get_lang('AddFeedback').'';
- echo ' <span id="msg_error2" style="display:none;color:red"></span>';
- echo '<div id="option2" style="padding:4px; margin:5px; border:1px dotted; display:none;">';
- echo '<table border="0" style="font-weight:normal" align="center">';
- echo '<tr>';
- echo '<td colspan="2">'.get_lang('Feedback1').'</td>';
- echo '<td colspan="2">'.get_lang('Feedback2').'</td>';
- echo '<td colspan="2">'.get_lang('Feedback3').'</td>';
- echo '</tr>';
- echo '<tr>';
- echo '<td colspan="2"><textarea name="feedback1" cols="21" rows="4" >'.api_htmlentities($row['feedback1']).'</textarea></td>';
- echo '<td colspan="2"><textarea name="feedback2" cols="21" rows="4" >'.api_htmlentities($row['feedback2']).'</textarea></td>';
- echo '<td colspan="2"><textarea name="feedback3" cols="21" rows="4" >'.api_htmlentities($row['feedback3']).'</textarea></td>';
- echo '</tr>';
- echo '<tr>';
- echo '<td>'.get_lang('FProgress').':</td>';
- echo '<td><select name="fprogress1">';
- echo '<option value="'.api_htmlentities($row['fprogress1']).'" selected>'.api_htmlentities($row['fprogress1']).'</option>';
- echo '<option value="10">10</option>
- <option value="20">20</option>
- <option value="30">30</option>
- <option value="40">40</option>
- <option value="50">50</option>
- <option value="60">60</option>
- <option value="70">70</option>
- <option value="80">80</option>
- <option value="90">90</option>
- <option value="100">100</option>
- </select> %</td>';
- echo '<td>'.get_lang('FProgress').':</td>';
- echo '<td><select name="fprogress2">';
- echo '<option value="'.api_htmlentities($row['fprogress2']).'" selected>'.api_htmlentities($row['fprogress2']).'</option>';;
- echo '<option value="10">10</option>
- <option value="20">20</option>
- <option value="30">30</option>
- <option value="40">40</option>
- <option value="50">50</option>
- <option value="60">60</option>
- <option value="70">70</option>
- <option value="80">80</option>
- <option value="90">90</option>
- <option value="100">100</option>
- </select> %</td>';
- echo '<td>'.get_lang('FProgress').':</td>';
- echo '<td><select name="fprogress3">';
- echo '<option value="'.api_htmlentities($row['fprogress3']).'" selected>'.api_htmlentities($row['fprogress3']).'</option>';
- echo '<option value="10">10</option>
- <option value="20">20</option>
- <option value="30">30</option>
- <option value="40">40</option>
- <option value="50">50</option>
- <option value="60">60</option>
- <option value="70">70</option>
- <option value="80">80</option>
- <option value="90">90</option>
- <option value="100">100</option>
- </select> %</td>';
- echo '</tr>';
- echo '</table>';
- echo '</div>';
-
- echo '<div> </div><input type="checkbox" value="1" name="checktimelimit" onclick="javascript: if(this.checked){document.getElementById(\'option1\').style.display=\'block\'; $pepe=\'a\';}else{document.getElementById(\'option1\').style.display=\'none\';}"/> '.get_lang('PutATimeLimit').'';
- echo ' <span id="msg_error1" style="display:none;color:red"></span>';
- echo '<div id="option1" style="padding:4px; margin:5px; border:1px dotted; display:none;">';
- echo '<table width="100%" border="0" style="font-weight:normal">';
- echo '<tr>';
- echo '<td align="right" width="150">'.get_lang('StartDate').':</td>';
- echo '<td>';
- if ($row['startdate_assig']=='0000-00-00 00:00:00') {
- echo draw_date_picker('startdate_assig').' <input type="checkbox" name="initstartdate" value="1"> '.get_lang('Yes').'/'.get_lang('No').'';
- } else {
- echo draw_date_picker('startdate_assig', $row['startdate_assig']).' <input type="checkbox" name="initstartdate" value="1">'.get_lang('Yes').'/'.get_lang('No').'';
- }
- echo '</td>';
- echo '</tr>';
- echo '<tr>';
- echo '<td align="right" width="150">'.get_lang("EndDate").':</td>';
- echo '<td>';
- if ($row['enddate_assig']=='0000-00-00 00:00:00') {
- echo draw_date_picker('enddate_assig').' <input type="checkbox" name="initenddate" value="1"> '.get_lang('Yes').'/'.get_lang('No').'';
- } else {
- echo draw_date_picker('enddate_assig', $row['enddate_assig']).' <input type="checkbox" name="initenddate" value="1"> '.get_lang('Yes').'/'.get_lang('No').'';
- }
- echo '</td>';
- echo '</tr>';
- echo '<tr>';
- echo '<td align="right">'.get_lang('AllowLaterSends').':</td>';
- if ($row['delayedsubmit']==1) {
- $check_uncheck='checked';
- }
- echo '<td><input type="checkbox" name="delayedsubmit" value="1" '.$check_uncheck.'></td>';
- echo '</tr>';
- echo'</table>';
- echo '</div>';
-
- echo '<div> </div><input type="checkbox" value="1" name="checkotherlimit" onclick="javascript: if(this.checked){document.getElementById(\'option3\').style.display=\'block\';}else{document.getElementById(\'option3\').style.display=\'none\';}"/> '.get_lang('OtherSettings').'';
- echo ' <span id="msg_error3" style="display:none;color:red"></span>';
- echo '<div id="option3" style="padding:4px; margin:5px; border:1px dotted; display:none;">';
- echo '<div style="font-weight:normal"; align="center">'.get_lang('NMaxWords').': <input type="text" name="max_text" size="3" value="'.$row['max_text'].'"> '.get_lang('NMaxVersion').': <input type="text" name="max_version" size="3" value="'.$row['max_version'].'"></div>';
- echo '</div>';
-
- echo '</div>';
- }
- echo '</div>';
- echo '<div id="wikicontent">';
- echo '<input type="hidden" name="page_id" value="'.$page_id.'">';
- echo '<input type="hidden" name="reflink" value="'.api_htmlentities($page).'">';
- echo '<input type="hidden" name="title" value="'.api_htmlentities($title).'">';
- api_disp_html_area('content', $content, '', '', null, api_is_allowed_to_edit(null,true)
- ? array('ToolbarSet' => 'Wiki', 'Width' => '100%', 'Height' => '400')
- : array('ToolbarSet' => 'WikiStudent', 'Width' => '100%', 'Height' => '400', 'UserStatus' => 'student')
- );
- echo '<br/>';
- echo '<br/>';
-
-
- echo get_lang('Comments').': <input type="text" name="comment" size="40"> ';
-
- echo '<INPUT TYPE="hidden" NAME="assignment" VALUE="'.$row['assignment'].'"/>';
- echo '<INPUT TYPE="hidden" NAME="version" VALUE="'.$row['version'].'"/>';
-
- echo '<INPUT TYPE="hidden" NAME="startdate_assig" VALUE="'.$row['startdate_assig'].'"/>';
- echo '<INPUT TYPE="hidden" NAME="enddate_assig" VALUE="'.$row['enddate_assig'].'"/>';
-
- echo get_lang('Progress').': <select name="progress" id="progress">';
- echo '<option value="'.api_htmlentities($row['progress']).'" selected>'.api_htmlentities($row['progress']).'</option>';
- echo '<option value="10">10</option>
- <option value="20">20</option>
- <option value="30">30</option>
- <option value="40">40</option>
- <option value="50">50</option>
- <option value="60">60</option>
- <option value="70">70</option>
- <option value="80">80</option>
- <option value="90">90</option>
- <option value="100">100</option>
- </select> %';
- echo '<br/><br/>';
- echo '<input type="hidden" name="wpost_id" value="'.md5(uniqid(rand(), true)).'">';
- echo '<button class="save" type="submit" name="SaveWikiChange">'.get_lang('Save').'</button>';
- echo '</div>';
- echo '</form>';
- }
- }
- }
- }
- if ($_GET['action']=='history' or $_POST['HistoryDifferences']) {
- if (!$_GET['title']) {
- Display::display_error_message(get_lang("MustSelectPage"));
- exit;
- }
- echo '<div style="overflow:hidden">';
- $_clean['group_id']=(int)$_SESSION['_gid'];
-
- $sql='SELECT * FROM '.$tbl_wiki.'WHERE c_id = '.$course_id.' AND reflink="'.Database::escape_string($page).'" AND '.$groupfilter.$condition_session.' ORDER BY id DESC';
- $result=Database::query($sql);
- while ($row=Database::fetch_array($result)) {
- $KeyVisibility=$row['visibility'];
- $KeyAssignment=$row['assignment'];
- $KeyTitle=$row['title'];
- $KeyUserId=$row['user_id'];
- }
- if ($KeyAssignment==1) {
- $icon_assignment=Display::return_icon('wiki_assignment.png', get_lang('AssignmentDescExtra'),'',ICON_SIZE_SMALL);
- } elseif($KeyAssignment==2) {
- $icon_assignment=Display::return_icon('wiki_work.png', get_lang('AssignmentWorkExtra'),'',ICON_SIZE_SMALL);
- }
-
-
- if($KeyVisibility==1 || api_is_allowed_to_edit(false,true) || api_is_platform_admin() || ($KeyAssignment==2 && $KeyVisibility==0 && (api_get_user_id()==$KeyUserId))) {
-
- if (!$_POST['HistoryDifferences'] && !$_POST['HistoryDifferences2']) {
- $sql='SELECT * FROM '.$tbl_wiki.'WHERE c_id = '.$course_id.' AND reflink="'.Database::escape_string($page).'" AND '.$groupfilter.$condition_session.' ORDER BY id DESC';
- $result=Database::query($sql);
- $title = Security::remove_XSS($_GET['title']);
- $group_id = intval($_GET['group_id']);
- echo '<div id="wikititle">';
- echo $icon_assignment.' '.Security::remove_XSS($KeyTitle);
- echo '</div>';
- echo '<div id="wikicontent">';
- echo '<form id="differences" method="POST" action="index.php?cidReq='.$_course['id'].'&action=history&title='.$title.'&session_id='.$session_id.'&group_id='.$group_id.'">';
- echo '<ul style="list-style-type: none;">';
- echo '<br/>';
- echo '<button class="search" type="submit" name="HistoryDifferences" value="HistoryDifferences">'.get_lang('ShowDifferences').' '.get_lang('LinesDiff').'</button>';
- echo '<button class="search" type="submit" name="HistoryDifferences2" value="HistoryDifferences2">'.get_lang('ShowDifferences').' '.get_lang('WordsDiff').'</button>';
- echo '<br/><br/>';
- $counter=0;
- $total_versions=Database::num_rows($result);
- while ($row=Database::fetch_array($result)) {
- $userinfo = api_get_user_info($row['user_id']);
- $username = api_htmlentities(sprintf(get_lang('LoginX'), $userinfo['username']), ENT_QUOTES);
- echo '<li style="margin-bottom: 5px;">';
- ($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 '<input name="old" value="'.$row['id'].'" type="radio" '.$oldstyle.' '.$oldchecked.'/> ';
- echo '<input name="new" value="'.$row['id'].'" type="radio" '.$newstyle.' '.$newchecked.'/> ';
- echo '<a href="'.api_get_self().'?action=showpage&title='.api_htmlentities(urlencode($page)).'&view='.$row['id'].'">';
- echo '<a href="'.api_get_self().'?cidReq='.$_course['id'].'&action=showpage&title='.api_htmlentities(urlencode($page)).'&view='.$row['id'].'&session_id='.$session_id.'&group_id='.$group_id.'">';
- echo api_get_local_time($row['dtime'], null, date_default_timezone_get());
- echo '</a>';
- echo ' ('.get_lang('Version').' '.$row['version'].')';
- echo ' '.get_lang('By').' ';
- if ($row['user_id']<>0) {
- echo '<a href="../user/userInfo.php?uInfo='.$userinfo['user_id'].'">'.
- Display::tag('span', api_htmlentities($userinfo['complete_name_login_as'])).
- '</a>';
- } else {
- echo get_lang('Anonymous').' ('.api_htmlentities($row[user_ip]).')';
- }
- echo ' ( '.get_lang('Progress').': '.api_htmlentities($row['progress']).'%, ';
- $comment=$row['comment'];
- if (!empty($comment)) {
- echo get_lang('Comments').': '.api_htmlentities(api_substr($row['comment'],0,100));
- if (api_strlen($row['comment'])>100) {
- echo '... ';
- }
- } else {
- echo get_lang('Comments').': ---';
- }
- echo ' ) </li>';
- $counter++;
- }
- echo '<br/>';
- echo '<button class="search" type="submit" name="HistoryDifferences" value="HistoryDifferences">'.get_lang('ShowDifferences').' '.get_lang('LinesDiff').'</button>';
- echo '<button class="search" type="submit" name="HistoryDifferences2" value="HistoryDifferences2">'.get_lang('ShowDifferences').' '.get_lang('WordsDiff').'</button>';
- echo '</ul></form></div>';
- } else {
- $sql_old="SELECT * FROM $tbl_wiki WHERE c_id = $course_id AND id='".Database::escape_string($_POST['old'])."'";
- $result_old=Database::query($sql_old);
- $version_old=Database::fetch_array($result_old);
- $sql_new="SELECT * FROM $tbl_wiki WHERE c_id = $course_id AND id='".Database::escape_string($_POST['new'])."'";
- $result_new=Database::query($sql_new);
- $version_new=Database::fetch_array($result_new);
- if (isset($_POST['HistoryDifferences'])) {
- include('diff.inc.php');
-
- echo '<div id="wikititle">'.api_htmlentities($version_new['title']).' <font size="-2"><i>('.get_lang('DifferencesNew').'</i> <font style="background-color:#aaaaaa">'.$version_new['dtime'].'</font> <i>'.get_lang('DifferencesOld').'</i> <font style="background-color:#aaaaaa">'.$version_old['dtime'].'</font>) '.get_lang('Legend').': <span class="diffAdded" >'.get_lang(WikiDiffAddedLine).'</span> <span class="diffDeleted" >'.get_lang(WikiDiffDeletedLine).'</span> <span class="diffMoved" >'.get_lang(WikiDiffMovedLine).'</span></font></div>';
- }
- if (isset($_POST['HistoryDifferences2'])) {
-
- require_once 'Text/Diff.php';
- require_once 'Text/Diff/Renderer/inline.php';
-
- echo '<div id="wikititle">'.api_htmlentities($version_new['title']).' <font size="-2"><i>('.get_lang('DifferencesNew').'</i> <font style="background-color:#aaaaaa">'.$version_new['dtime'].'</font> <i>'.get_lang('DifferencesOld').'</i> <font style="background-color:#aaaaaa">'.$version_old['dtime'].'</font>) '.get_lang('Legend').': <span class="diffAddedTex" >'.get_lang(WikiDiffAddedTex).'</span> <span class="diffDeletedTex" >'.get_lang(WikiDiffDeletedTex).'</span></font></div>';
- }
- echo '<div class="diff"><br /><br />';
- if (isset($_POST['HistoryDifferences'])) {
- echo '<table>'.diff( $version_old['content'], $version_new['content'], true, 'format_table_line' ).'</table>';
- echo '</div>';
- echo '<br />';
- echo '<strong>'.get_lang('Legend').'</strong><div class="diff">' . "\n";
- echo '<table><tr>';
- echo '<td>';
- echo '</td><td>';
- echo '<span class="diffEqual" >'.get_lang('WikiDiffUnchangedLine').'</span><br />';
- echo '<span class="diffAdded" >'.get_lang('WikiDiffAddedLine').'</span><br />';
- echo '<span class="diffDeleted" >'.get_lang('WikiDiffDeletedLine').'</span><br />';
- echo '<span class="diffMoved" >'.get_lang('WikiDiffMovedLine').'</span><br />';
- echo '</td>';
- echo '</tr></table>';
- echo '</div>';
- }
- if (isset($_POST['HistoryDifferences2'])) {
- $lines1 = array(strip_tags($version_old['content']));
- $lines2 = array(strip_tags($version_new['content']));
- $diff = new Text_Diff($lines1, $lines2);
- $renderer = new Text_Diff_Renderer_inline();
- echo '<style>del{background:#fcc}ins{background:#cfc}</style>'.$renderer->render($diff);
-
- echo '</div>';
- echo '<br />';
- echo '<strong>'.get_lang('Legend').'</strong><div class="diff">' . "\n";
- echo '<table><tr>';
- echo '<td>';
- echo '</td><td>';
- echo '<span class="diffAddedTex" >'.get_lang('WikiDiffAddedTex').'</span><br />';
- echo '<span class="diffDeletedTex" >'.get_lang('WikiDiffDeletedTex').'</span><br />';
- echo '</td>';
- echo '</tr></table>';
- echo '</div>';
- }
- }
- }
- echo '</div>';
- }
- if ($_GET['action']=='recentchanges') {
- $_clean['group_id']=(int)$_SESSION['_gid'];
- if ( api_is_allowed_to_session_edit(false,true) ) {
- if (check_notify_all()==1) {
- $notify_all= Display::return_icon('messagebox_info.png', get_lang('NotifyByEmail'),'',ICON_SIZE_SMALL).' '.get_lang('NotNotifyChanges');
- $lock_unlock_notify_all='unlocknotifyall';
- } else {
- $notify_all=Display::return_icon('mail.png', get_lang('CancelNotifyByEmail'),'',ICON_SIZE_SMALL).' '.get_lang('NotifyChanges');
- $lock_unlock_notify_all='locknotifyall';
- }
- }
- echo '<div class="actions"><span style="float: right;">';
- echo '<a href="index.php?action=recentchanges&actionpage='.$lock_unlock_notify_all.'&title='.api_htmlentities(urlencode($page)).'">'.$notify_all.'</a>';
- echo '</span>'.get_lang('RecentChanges').'</div>';
- if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
- $sql = 'SELECT * FROM '.$tbl_wiki.', '.$tbl_wiki_conf.'
- WHERE '.$tbl_wiki_conf.'.c_id= '.$course_id.' AND
- '.$tbl_wiki.'.c_id= '.$course_id.' AND
- '.$tbl_wiki_conf.'.page_id='.$tbl_wiki.'.page_id AND
- '.$tbl_wiki.'.'.$groupfilter.$condition_session.'
- ORDER BY dtime DESC';
- } else {
- $sql='SELECT * FROM '.$tbl_wiki.' WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.' AND visibility=1 ORDER BY dtime DESC';
- }
- $allpages=Database::query($sql);
-
- if (Database::num_rows($allpages) > 0) {
- $row = array ();
- while ($obj = Database::fetch_object($allpages)) {
-
- $userinfo = api_get_user_info($obj->user_id);
- $username = api_htmlentities(sprintf(get_lang('LoginX'), $userinfo['username']), ENT_QUOTES);
-
- if ($obj->assignment==1) {
- $ShowAssignment=Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'),'',ICON_SIZE_SMALL);
- } elseif ($obj->assignment==2) {
- $ShowAssignment=Display::return_icon('wiki_work.png', get_lang('AssignmentWork'),'',ICON_SIZE_SMALL);
- } elseif ($obj->assignment==0) {
- $ShowAssignment='<img src="../img/px_transparent.gif" />';
- }
-
- if (!empty($obj->task)) {
- $icon_task=Display::return_icon('wiki_task.png', get_lang('StandardTask'),'',ICON_SIZE_SMALL);
- } else {
- $icon_task='<img src="../img/px_transparent.gif" />';
- }
- $row = array ();
- $row[] = api_get_local_time($obj->dtime, null, date_default_timezone_get());
- $row[] = $ShowAssignment.$icon_task;
- $row[] = '<a href="'.api_get_self().'?cidReq='.$_course['id'].'&action=showpage&title='.api_htmlentities(urlencode($obj->reflink)).'&view='.$obj->id.'&session_id='.Security::remove_XSS($_GET['session_id']).'&group_id='.Security::remove_XSS($_GET['group_id']).'">'.Security::remove_XSS($obj->title).'</a>';
- $row[] = $obj->version>1 ? get_lang('EditedBy') : get_lang('AddedBy');
- if ($obj->user_id <> 0 ) {
- $row[] = '<a href="../user/userInfo.php?uInfo='.$userinfo['user_id'].'">'.
- Display::tag('span', api_htmlentities($userinfo['complete_name_login_as'])).
- '</a>';
- }
- else {
- $row[] = get_lang('Anonymous').' ('.api_htmlentities($obj->user_ip).')';
- }
- $rows[] = $row;
- }
- $table = new SortableTableFromArrayConfig($rows,0,10,'RecentPages_table','','','DESC');
- $table->set_additional_parameters(array('cidReq' =>Security::remove_XSS($_GET['cidReq']),'action'=>Security::remove_XSS($_GET['action']),'session_id'=>Security::remove_XSS($_GET['session_id']),'group_id'=>Security::remove_XSS($_GET['group_id'])));
- $table->set_header(0,get_lang('Date'), true, array ('style' => 'width:200px;'));
- $table->set_header(1,get_lang('Type'), true, array ('style' => 'width:30px;'));
- $table->set_header(2,get_lang('Title'), true);
- $table->set_header(3,get_lang('Actions'), true, array ('style' => 'width:80px;'));
- $table->set_header(4,get_lang('Author'), true);
- $table->display();
- }
- }
- if ($_GET['action']=='allpages') {
- echo '<div class="actions">'.get_lang('AllPages').'</div>';
- $_clean['group_id']=(int)$_SESSION['_gid'];
- if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
- $sql = 'SELECT * FROM '.$tbl_wiki.' s1
- WHERE s1.c_id = '.$course_id.' AND id=(
- SELECT MAX(s2.id) FROM '.$tbl_wiki.' s2
- WHERE s2.c_id = '.$course_id.' AND s1.reflink = s2.reflink AND '.$groupfilter.' AND session_id='.$session_id.')';
- } else {
- $sql = 'SELECT * FROM '.$tbl_wiki.' s1
- WHERE visibility=1 AND s1.c_id = '.$course_id.' AND id=(
- SELECT MAX(s2.id) FROM '.$tbl_wiki.' s2 WHERE s2.c_id = '.$course_id.' AND s1.reflink = s2.reflink AND '.$groupfilter.' AND session_id='.$session_id.')';
- }
- $allpages=Database::query($sql);
-
- if (Database::num_rows($allpages) > 0) {
- $row = array ();
- while ($obj = Database::fetch_object($allpages)) {
-
- $userinfo = api_get_user_info($obj->user_id);
-
- if ($obj->assignment==1) {
- $ShowAssignment=Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'),'',ICON_SIZE_SMALL);
- } elseif ($obj->assignment==2) {
- $ShowAssignment=Display::return_icon('wiki_work.png', get_lang('AssignmentWork'),'',ICON_SIZE_SMALL);
- } elseif ($obj->assignment==0) {
- $ShowAssignment='<img src="../img/px_transparent.gif" />';
- }
-
- if (!empty($obj->task)) {
- $icon_task=Display::return_icon('wiki_task.png', get_lang('StandardTask'),'',ICON_SIZE_SMALL);
- } else {
- $icon_task='<img src="../img/px_transparent.gif" />';
- }
- $row = array ();
- $row[] =$ShowAssignment.$icon_task;
- $row[] = '<a href="'.api_get_self().'?cidReq='.$_course['id'].'&action=showpage&title='.Security::remove_XSS($obj->reflink).'&session_id='.Security::remove_XSS($_GET['session_id']).'&group_id='.Security::remove_XSS($_GET['group_id']).'">'.Security::remove_XSS($obj->title).'</a>';
- if ($obj->user_id <>0) {
- $row[] = '<a href="../user/userInfo.php?uInfo='.$userinfo['user_id'].'">'.
- Display::tag('span', api_htmlentities($userinfo['complete_name_login_as'])).
- '</a>';
- }
- else {
- $row[] = get_lang('Anonymous').' ('.api_htmlentities($obj->user_ip).')';
- }
- $row[] = api_get_local_time($obj->dtime, null, date_default_timezone_get());
- if (api_is_allowed_to_edit(false,true)|| api_is_platform_admin()) {
- $showdelete=' <a href="'.api_get_self().'?cidReq='.$_course['id'].'&action=delete&title='.Security::remove_XSS($obj->reflink).'&session_id='.Security::remove_XSS($_GET['session_id']).'&group_id='.Security::remove_XSS($_GET['group_id']).'">'.Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL);
- }
- if (api_is_allowed_to_session_edit(false,true) ) {
- $row[] = '<a href="'.api_get_self().'?cidReq='.$_course['id'].'&action=edit&title='.Security::remove_XSS($obj->reflink).'&session_id='.Security::remove_XSS($_GET['session_id']).'&group_id='.Security::remove_XSS($_GET['group_id']).'">'.Display::return_icon('edit.png', get_lang('EditPage'),'',ICON_SIZE_SMALL).'</a> <a href="'.api_get_self().'?cidReq='.$_course['id'].'&action=discuss&title='.Security::remove_XSS($obj->reflink).'&group_id='.Security::remove_XSS($_GET['group_id']).'">'.Display::return_icon('discuss.png', get_lang('Discuss'),'',ICON_SIZE_SMALL).'</a> <a href="'.api_get_self().'?cidReq='.$_course['id'].'&action=history&title='.api_htmlentities(urlencode($obj->reflink)).'&session_id='.Security::remove_XSS($_GET['session_id']).'&group_id='.Security::remove_XSS($_GET['group_id']).'">'.Display::return_icon('history.png', get_lang('History'),'',ICON_SIZE_SMALL).'</a> <a href="'.api_get_self().'?cidReq='.$_course['id'].'&action=links&title='.api_htmlentities(urlencode($obj->reflink)).'&session_id='.Security::remove_XSS($_GET['session_id']).'&group_id='.Security::remove_XSS($_GET['group_id']).'">'.Display::return_icon('what_link_here.png', get_lang('LinksPages'),'',ICON_SIZE_SMALL).'</a>'.$showdelete;
- }
- $rows[] = $row;
- }
- $table = new SortableTableFromArrayConfig($rows,1,10,'AllPages_table','','','ASC');
- $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').' ('.get_lang('LastVersion').')', true);
- $table->set_header(3,get_lang('Date').' ('.get_lang('LastVersion').')', true);
- if (api_is_allowed_to_session_edit(false,true) ) {
- $table->set_header(4,get_lang('Actions'), true, array ('style' => 'width:130px;'));
- }
- $table->display();
- }
- }
- if ($_GET['action']=='discuss') {
- if (api_get_session_id()!=0 && api_is_allowed_to_session_edit(false,true)==false) {
- api_not_allowed();
- }
- if (!$_GET['title']) {
- Display::display_error_message(get_lang("MustSelectPage"));
- exit;
- }
-
- $sql='SELECT * FROM '.$tbl_wiki.' WHERE c_id = '.$course_id.' AND reflink="'.Database::escape_string($page).'" AND '.$groupfilter.$condition_session.' ORDER BY id DESC';
- $result=Database::query($sql);
- $row=Database::fetch_array($result);
- $lastversiondate=api_get_local_time($row['dtime'], null, date_default_timezone_get());
- $lastuserinfo = api_get_user_info($row['user_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';
- $result=Database::query($sql);
- $row=Database::fetch_array($result);
- $id=$row['id'];
- $firstuserid=$row['user_id'];
-
- if ($row['assignment']==1) {
- $icon_assignment=Display::return_icon('wiki_assignment.png', get_lang('AssignmentDescExtra'),'',ICON_SIZE_SMALL);
- } elseif($row['assignment']==2) {
- $icon_assignment=Display::return_icon('wiki_work.png', get_lang('AssignmentWorkExtra'),'',ICON_SIZE_SMALL);
- }
-
- if ($id!='') {
-
- if ($row['visibility_disc']==1 || api_is_allowed_to_edit(false,true) || api_is_platform_admin() || ($row['assignment']==2 && $row['visibility_disc']==0 && (api_get_user_id()==$row['user_id']))) {
- echo '<div id="wikititle">';
-
- if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
- if (check_addlock_discuss()==1) {
- $addlock_disc= Display::return_icon('unlock.png', get_lang('UnlockDiscussExtra'),'',ICON_SIZE_SMALL);
- $lock_unlock_disc='unlockdisc';
- } else {
- $addlock_disc= Display::return_icon('lock.png', get_lang('LockDiscussExtra'),'',ICON_SIZE_SMALL);
- $lock_unlock_disc='lockdisc';
- }
- }
- echo '<span style="float:right">';
- echo '<a href="index.php?action=discuss&actionpage='.$lock_unlock_disc.'&title='.api_htmlentities(urlencode($page)).'">'.$addlock_disc.'</a>';
- echo '</span>';
-
- if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
- if (check_visibility_discuss()==1) {
-
-
-
-
-
- $visibility_disc= Display::return_icon('visible.png', get_lang('ShowDiscussExtra'),'',ICON_SIZE_SMALL);
- $hide_show_disc='hidedisc';
- } else {
- $visibility_disc= Display::return_icon('invisible.png', get_lang('HideDiscussExtra'),'',ICON_SIZE_SMALL);
- $hide_show_disc='showdisc';
- }
- }
- echo '<span style="float:right">';
- echo '<a href="index.php?action=discuss&actionpage='.$hide_show_disc.'&title='.api_htmlentities(urlencode($page)).'">'.$visibility_disc.'</a>';
- echo '</span>';
-
- if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
- if (check_ratinglock_discuss()==1) {
- $ratinglock_disc= Display::return_icon('star.png', get_lang('UnlockRatingDiscussExtra'),'',ICON_SIZE_SMALL);
- $lock_unlock_rating_disc='unlockrating';
- } else {
- $ratinglock_disc= Display::return_icon('star_na.png', get_lang('LockRatingDiscussExtra'),'',ICON_SIZE_SMALL);
- $lock_unlock_rating_disc='lockrating';
- }
- }
- echo '<span style="float:right">';
- echo '<a href="index.php?action=discuss&actionpage='.$lock_unlock_rating_disc.'&title='.api_htmlentities(urlencode($page)).'">'.$ratinglock_disc.'</a>';
- echo '</span>';
-
- if (check_notify_discuss($page)==1) {
- $notify_disc= Display::return_icon('messagebox_info.png', get_lang('NotifyDiscussByEmail'),'',ICON_SIZE_SMALL);
- $lock_unlock_notify_disc='unlocknotifydisc';
- } else {
- $notify_disc= Display::return_icon('mail.png', get_lang('CancelNotifyDiscussByEmail'),'',ICON_SIZE_SMALL);
- $lock_unlock_notify_disc='locknotifydisc';
- }
- echo '<span style="float:right">';
- echo '<a href="index.php?action=discuss&actionpage='.$lock_unlock_notify_disc.'&title='.api_htmlentities(urlencode($page)).'">'.$notify_disc.'</a>';
- echo '</span>';
- echo $icon_assignment.' '.api_htmlentities($row['title']);
- echo ' ('.get_lang('MostRecentVersionBy').' <a href="../user/userInfo.php?uInfo='.$lastuserinfo['user_id'].'">'.
- Display::tag('span', api_htmlentities($lastuserinfo['complete_name_login_as'])).
- '</a> '.$lastversiondate.$countWPost.')'.$avg_WPost_score.' ';
- echo '</div>';
- if ($row['addlock_disc']==1 || api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
- ?>
- <form name="form1" method="post" action="">
- <table>
- <tr>
- <td valign="top" ><?php echo get_lang('Comments');?>:</td>
- <?php echo '<input type="hidden" name="wpost_id" value="'.md5(uniqid(rand(), true)).'">';
- <td><textarea name="comment" cols="80" rows="5" id="comment"></textarea></td>
- </tr>
- <tr>
- <?php
-
- if ($row['ratinglock_disc']==1 || api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
- ?>
- <td><?php echo get_lang('Rating');?>: </td>
- <td valign="top"><select name="rating" id="rating">
- <option value="-" selected>-</option>
- <option value="0">0</option>
- <option value="1">1</option>
- <option value="2">2</option>
- <option value="3">3</option>
- <option value="4">4</option>
- <option value="5">5</option>
- <option value="6">6</option>
- <option value="7">7</option>
- <option value="8">8</option>
- <option value="9">9</option>
- <option value="10">10</option>
- </select></td>
- <?php
- } else {
- echo '<input type=hidden name="rating" value="-">';
- }
- ?>
- </tr>
- <tr>
- <td> </td>
- <td> <?php echo '<button class="save" type="submit" name="Submit"> '.get_lang('Send').'</button>'; ?></td>
- </tr>
- </table>
- </form>
- <?php
- if (isset($_POST['Submit']) && double_post($_POST['wpost_id'])) {
- $dtime = date( "Y-m-d H:i:s" );
- $message_author=api_get_user_id();
- $sql="INSERT INTO $tbl_wiki_discuss (c_id, publication_id, userc_id, comment, p_score, dtime) VALUES
- ($course_id, '".$id."','".$message_author."','".Database::escape_string($_POST['comment'])."','".Database::escape_string($_POST['rating'])."','".$dtime."')";
- $result=Database::query($sql) or die(Database::error());
- check_emailcue($id, 'D', $dtime, $message_author);
- }
- }
- echo '<hr noshade size="1">';
- $user_table = Database :: get_main_table(TABLE_MAIN_USER);
- $sql="SELECT * FROM $tbl_wiki_discuss reviews, $user_table user
- WHERE reviews.c_id = $course_id AND reviews.publication_id='".$id."' AND user.user_id='".$firstuserid."' ORDER BY id DESC";
- $result=Database::query($sql) or die(Database::error());
- $countWPost = Database::num_rows($result);
- echo get_lang('NumComments').": ".$countWPost;
- $sql="SELECT SUM(p_score) as sumWPost FROM $tbl_wiki_discuss WHERE c_id = $course_id AND publication_id = '".$id."' AND NOT p_score='-' ORDER BY id DESC";
- $result2=Database::query($sql) or die(Database::error());
- $row2=Database::fetch_array($result2);
- $sql="SELECT * FROM $tbl_wiki_discuss WHERE c_id = $course_id AND publication_id='".$id."' AND NOT p_score='-'";
- $result3=Database::query($sql) or die(Database::error());
- $countWPost_score= Database::num_rows($result3);
- echo ' - '.get_lang('NumCommentsScore').': '.$countWPost_score;
- if ($countWPost_score!=0) {
- $avg_WPost_score = round($row2['sumWPost'] / $countWPost_score,2).' / 10';
- } else {
- $avg_WPost_score = $countWPost_score;
- }
- echo ' - '.get_lang('RatingMedia').': '.$avg_WPost_score;
- $sql = 'UPDATE '.$tbl_wiki.' SET score="'.Database::escape_string($avg_WPost_score).'"
- WHERE c_id = '.$course_id.' AND reflink="'.Database::escape_string($page).'" AND '.$groupfilter.$condition_session;
-
- Database::query($sql);
- echo '<hr noshade size="1">';
- while ($row = Database::fetch_array($result)) {
- $userinfo = api_get_user_info($row['userc_id']);
- if (($userinfo['status'])=="5") {
- $author_status=get_lang('Student');
- } else {
- $author_status=get_lang('Teacher');
- }
- $user_id=$row['userc_id'];
- $name = $userinfo['complete_name'];
- $attrb=array();
- if ($user_id<>0) {
- $image_path = UserManager::get_user_picture_path_by_id($user_id,'web',false, true);
- $image_repository = $image_path['dir'];
- $existing_image = $image_path['file'];
- $author_photo= '<img src="'.$image_repository.$existing_image.'" alt="'.api_htmlentities($name).'" width="40" height="50" align="top" title="'.api_htmlentities($name).'" />';
- } else {
- $author_photo= '<img src="'.api_get_path(WEB_CODE_PATH)."img/unknown.jpg".'" alt="'.api_htmlentities($name).'" width="40" height="50" align="top" title="'.api_htmlentities($name).'" />';
- }
-
- $p_score=$row['p_score'];
- switch ($p_score) {
- case 0:
- $imagerating='<img src="../img/rating/stars_0.gif"/>';
- break;
- case 1:
- $imagerating='<img src="../img/rating/stars_5.gif"/>';
- break;
- case 2:
- $imagerating='<img src="../img/rating/stars_10.gif"/>';
- break;
- case 3:
- $imagerating='<img src="../img/rating/stars_15.gif"/>';
- break;
- case 4:
- $imagerating='<img src="../img/rating/stars_20.gif"/>';
- break;
- case 5:
- $imagerating='<img src="../img/rating/stars_25.gif"/>';
- break;
- case 6:
- $imagerating='<img src="../img/rating/stars_30.gif"/>';
- break;
- case 7:
- $imagerating='<img src="../img/rating/stars_35.gif"/>';
- break;
- case 8:
- $imagerating='<img src="../img/rating/stars_40.gif"/>';
- break;
- case 9:
- $imagerating='<img src="../img/rating/stars_45.gif"/>';
- break;
- case 10:
- $imagerating='<img src="../img/rating/stars_50.gif"/>';
- break;
- }
- echo '<p><table>';
- echo '<tr>';
- echo '<td rowspan="2">'.$author_photo.'</td>';
- echo '<td style=" color:#999999"><a href="../user/userInfo.php?uInfo='.$userinfo['user_id'].'">'.
- Display::tag('span', api_htmlentities(api_get_person_name($userinfo['firstname'], $userinfo['lastname'])), array('title'=>$username)).
- '</a> ('.$author_status.') '.api_get_local_time($row['dtime'], null, date_default_timezone_get()).' - '.get_lang('Rating').': '.$row['p_score'].' '.$imagerating.' </td>';
- echo '</tr>';
- echo '<tr>';
- echo '<td>'.api_htmlentities($row['comment']).'</td>';
- echo '</tr>';
- echo "</table>";
- echo '<hr noshade size="1">';
- }
- } else {
- Display::display_warning_message(get_lang('LockByTeacher'),false);
- }
- } else {
- Display::display_normal_message(get_lang('DiscussNotAvailable'));
- }
- }
- echo '</div>';
- echo "</div>";
- echo "</div>";
- Display::display_footer();
|