index.php 97 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400
  1. <?php
  2. /*
  3. ==============================================================================
  4. Dokeos - elearning and course management software
  5. Copyright (c) 2004-2008 Dokeos SPRL
  6. Copyright (c) 2003 Ghent University (UGent)
  7. For a full list of contributors, see "credits.txt".
  8. The full license can be read in "license.txt".
  9. This program is free software; you can redistribute it and/or
  10. modify it under the terms of the GNU General Public License
  11. as published by the Free Software Foundation; either version 2
  12. of the License, or (at your option) any later version.
  13. See the GNU General Public License for more details.
  14. Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
  15. Mail: info@dokeos.com
  16. ==============================================================================
  17. */
  18. /**
  19. * The Dokeos wiki is a further development of the CoolWiki plugin.
  20. *
  21. * @Author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium
  22. * @Author Juan Carlos Raña <herodoto@telefonica.net>
  23. * @Copyright Ghent University
  24. * @Copyright Patrick Cool
  25. *
  26. * @package dokeos.wiki
  27. */
  28. // name of the language file that needs to be included
  29. $language_file = 'wiki';
  30. // security
  31. if(isset($_GET['id_session'])) {
  32. $_SESSION['id_session'] = intval($_GET['id_session']);
  33. }
  34. // including the global dokeos file
  35. include('../inc/global.inc.php');
  36. // section (for the tabs)
  37. $this_section=SECTION_COURSES;
  38. // including additional library scripts
  39. require_once api_get_path(LIBRARY_PATH).'course.lib.php';
  40. require_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php';
  41. require_once api_get_path(LIBRARY_PATH).'text.lib.php';
  42. require_once api_get_path(LIBRARY_PATH).'security.lib.php';
  43. require_once api_get_path(INCLUDE_PATH).'lib/mail.lib.inc.php';
  44. require_once api_get_path(INCLUDE_PATH).'conf/mail.conf.php';
  45. require_once api_get_path(LIBRARY_PATH).'sortabletable.class.php';
  46. require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
  47. require_once 'wiki.inc.php';
  48. // additional style information
  49. $htmlHeadXtra[] ='<link rel="stylesheet" type="text/css" href="'.api_get_path(WEB_CODE_PATH).'wiki/css/default.css"/>';
  50. // javascript for advanced parameters menu
  51. $htmlHeadXtra[] = '<script type="text/javascript" language="javascript">
  52. function advanced_parameters() {
  53. if(document.getElementById(\'options\').style.display == \'none\') {
  54. document.getElementById(\'options\').style.display = \'block\';
  55. document.getElementById(\'plus_minus\').innerHTML=\'&nbsp;'.Display::return_icon('div_hide.gif',get_lang('Hide'),array('style'=>'vertical-align:middle')).'&nbsp;'.get_lang('AdvancedParameters').'\';
  56. } else {
  57. document.getElementById(\'options\').style.display = \'none\';
  58. document.getElementById(\'plus_minus\').innerHTML=\'&nbsp;'.Display::return_icon('div_show.gif',get_lang('Show'),array('style'=>'vertical-align:middle')).'&nbsp;'.get_lang('AdvancedParameters').'\';
  59. }
  60. }
  61. </script>';
  62. // Database table definition
  63. $tbl_wiki = Database::get_course_table(TABLE_WIKI);
  64. $tbl_wiki_discuss = Database::get_course_table(TABLE_WIKI_DISCUSS);
  65. $tbl_wiki_mailcue = Database::get_course_table(TABLE_WIKI_MAILCUE);
  66. $tbl_wiki_conf = Database::get_course_table(TABLE_WIKI_CONF);
  67. /*
  68. -----------------------------------------------------------
  69. Constants and variables
  70. -----------------------------------------------------------
  71. */
  72. $tool_name = get_lang('Wiki');
  73. $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"));
  74. /*
  75. ----------------------------------------------------------
  76. ACCESS
  77. -----------------------------------------------------------
  78. */
  79. api_protect_course_script();
  80. api_block_anonymous_users();
  81. /*
  82. -----------------------------------------------------------
  83. TRACKING
  84. -----------------------------------------------------------
  85. */
  86. event_access_tool(TOOL_WIKI);
  87. /*
  88. -----------------------------------------------------------
  89. HEADER & TITLE
  90. -----------------------------------------------------------
  91. */
  92. // If it is a group wiki then the breadcrumbs will be different.
  93. if ($_SESSION['_gid'] OR $_GET['group_id']) {
  94. if (isset($_SESSION['_gid'])) {
  95. $_clean['group_id']=(int)$_SESSION['_gid'];
  96. }
  97. if (isset($_GET['group_id'])) {
  98. $_clean['group_id']=(int)Database::escape_string($_GET['group_id']);
  99. }
  100. $group_properties = GroupManager :: get_group_properties($_clean['group_id']);
  101. $interbreadcrumb[] = array ("url" => "../group/group.php", "name" => get_lang('Groups'));
  102. $interbreadcrumb[] = array ("url"=>"../group/group_space.php?gidReq=".$_SESSION['_gid'], "name"=> get_lang('GroupSpace').' ('.$group_properties['name'].')');
  103. $add_group_to_title = ' ('.$group_properties['name'].')';
  104. $groupfilter='group_id="'.$_clean['group_id'].'"';
  105. //ensure this tool in groups whe it's private or deactivated
  106. if ($group_properties['wiki_state']==0)
  107. {
  108. echo api_not_allowed();
  109. }
  110. elseif ($group_properties['wiki_state']==2)
  111. {
  112. if (!api_is_allowed_to_edit() and !GroupManager :: is_user_in_group($_user['user_id'], $_SESSION['_gid']))
  113. {
  114. echo api_not_allowed();
  115. }
  116. }
  117. }
  118. else
  119. {
  120. $groupfilter='group_id=0';
  121. }
  122. Display::display_header($tool_name, 'Wiki');
  123. $is_allowed_to_edit = api_is_allowed_to_edit();
  124. //api_display_tool_title($tool_name.$add_group_to_title);
  125. /*
  126. -----------------------------------------------------------
  127. INITIALISATION
  128. -----------------------------------------------------------
  129. */
  130. //the page we are dealing with
  131. if (!isset($_GET['title'])){
  132. $page='index';
  133. }
  134. else
  135. {
  136. $page=Security::remove_XSS($_GET['title']);
  137. }
  138. // some titles are not allowed
  139. // $not_allowed_titles=array("Index", "RecentChanges","AllPages", "Categories"); //not used for now
  140. /*
  141. ==============================================================================
  142. MAIN CODE
  143. ==============================================================================
  144. */
  145. // Tool introduction
  146. Display::display_introduction_section(TOOL_WIKI);
  147. /*
  148. -----------------------------------------------------------
  149. ACTIONS
  150. -----------------------------------------------------------
  151. */
  152. //release of blocked pages to prevent concurrent editions
  153. $sql='SELECT * FROM '.$tbl_wiki.'WHERE is_editing!="0"';
  154. $result=Database::query($sql,__LINE__,__FILE__);
  155. while ($is_editing_block=Database::fetch_array($result))
  156. {
  157. $max_edit_time=1200; // 20 minutes
  158. $timestamp_edit=strtotime($is_editing_block['time_edit']);
  159. $time_editing=time()-$timestamp_edit;
  160. //first prevent concurrent users and double version
  161. if($is_editing_block['is_editing']==$_user['user_id'])
  162. {
  163. $_SESSION['_version']=$is_editing_block['version'];
  164. }
  165. else
  166. {
  167. unset ( $_SESSION['_version'] );
  168. }
  169. //second checks if has exceeded the time that a page may be available or if a page was edited and saved by its author
  170. if ($time_editing>$max_edit_time || ($is_editing_block['is_editing']==$_user['user_id'] && $_GET['action']!='edit'))
  171. {
  172. $sql='UPDATE '.$tbl_wiki.' SET is_editing="0", time_edit="0000-00-00 00:00:00" WHERE is_editing="'.$is_editing_block['is_editing'].'"';
  173. Database::query($sql,__FILE__,__LINE__);
  174. }
  175. }
  176. // saving a change
  177. if (isset($_POST['SaveWikiChange']) AND $_POST['title']<>'')
  178. {
  179. if(empty($_POST['title']))
  180. {
  181. Display::display_error_message(get_lang("NoWikiPageTitle"));
  182. }
  183. elseif(!double_post($_POST['wpost_id']))
  184. {
  185. //double post
  186. }
  187. elseif ($_POST['version']!='' && $_POST['version']!=$_SESSION['_version'])
  188. {
  189. //prevent concurrent users and double version
  190. Display::display_error_message(get_lang("EditedByAnotherUser"));
  191. }
  192. else
  193. {
  194. $return_message=save_wiki();
  195. Display::display_confirmation_message($return_message, false);
  196. }
  197. }
  198. //saving a new wiki entry
  199. if (isset($_POST['SaveWikiNew']))
  200. {
  201. if(empty($_POST['title']))
  202. {
  203. Display::display_error_message(get_lang("NoWikiPageTitle"));
  204. }
  205. elseif (strtotime(get_date_from_select('startdate_assig')) > strtotime(get_date_from_select('enddate_assig')))
  206. {
  207. Display::display_error_message(get_lang("EndDateCannotBeBeforeTheStartDate"));
  208. }
  209. elseif(!double_post($_POST['wpost_id']))
  210. {
  211. //double post
  212. }
  213. else
  214. {
  215. $_clean['assignment']=Database::escape_string($_POST['assignment']); // for mode assignment
  216. if ($_clean['assignment']==1)
  217. {
  218. auto_add_page_users($_clean['assignment']);
  219. }
  220. else
  221. {
  222. $return_message=save_new_wiki();
  223. Display::display_confirmation_message($return_message, false);
  224. }
  225. }
  226. }
  227. // check last version
  228. if ($_GET['view'])
  229. {
  230. $sql='SELECT * FROM '.$tbl_wiki.'WHERE id="'.Database::escape_string($_GET['view']).'"'; //current view
  231. $result=Database::query($sql,__LINE__,__FILE__);
  232. $current_row=Database::fetch_array($result);
  233. $sql='SELECT * FROM '.$tbl_wiki.'WHERE reflink="'.html_entity_decode(Database::escape_string(stripslashes(urldecode($page)))).'" AND '.$groupfilter.' ORDER BY id DESC'; //last version
  234. $result=Database::query($sql,__LINE__,__FILE__);
  235. $last_row=Database::fetch_array($result);
  236. if ($_GET['view']<$last_row['id'])
  237. {
  238. $message= '<center>'.get_lang('NoAreSeeingTheLastVersion').'<br /> '.get_lang("Version").' (<a href="index.php?cidReq='.$_course[id].'&action=showpage&amp;title='.$current_row['reflink'].'&view='.Security::remove_XSS($_GET['view']).'&group_id='.$current_row['group_id'].'" title="'.get_lang('CurrentVersion').'">'.$current_row['version'].'</a> / <a href="index.php?cidReq='.$_course[id].'&action=showpage&amp;title='.$last_row['reflink'].'&group_id='.$last_row['group_id'].'" title="'.get_lang('LastVersion').'">'.$last_row['version'].'</a>) <br />'.get_lang("ConvertToLastVersion").': <a href="index.php?cidReq='.$_course[id].'&action=restorepage&amp;title='.$last_row['reflink'].'&view='.Security::remove_XSS($_GET['view']).'">'.get_lang("Restore").'</a></center>';
  239. Display::display_warning_message($message,false);
  240. }
  241. ///restore page
  242. if ($_GET['action']=='restorepage')
  243. {
  244. //Only teachers and platform admin can edit the index page. Only teachers and platform admin can edit an assignment teacher
  245. if(($current_row['reflink']=='index' || $current_row['reflink']=='' || $current_row['assignment']==1) && (!api_is_allowed_to_edit() && $_clean['group_id']==0))
  246. {
  247. Display::display_normal_message(get_lang('OnlyEditPagesCourseManager'));
  248. }
  249. else
  250. {
  251. $PassEdit=false;
  252. //check if is a wiki group
  253. if($current_row['group_id']!=0)
  254. {
  255. //Only teacher, platform admin and group members can edit a wiki group
  256. if(api_is_allowed_to_edit() || api_is_platform_admin() || GroupManager :: is_user_in_group($_user['user_id'],$_SESSION['_gid']))
  257. {
  258. $PassEdit=true;
  259. }
  260. else
  261. {
  262. Display::display_normal_message(get_lang('OnlyEditPagesGroupMembers'));
  263. }
  264. }
  265. else
  266. {
  267. $PassEdit=true;
  268. }
  269. // check if is an assignment
  270. if(stripslashes($current_row['assignment'])==1)
  271. {
  272. Display::display_normal_message(get_lang('EditAssignmentWarning'));
  273. $icon_assignment='<img src="../img/wiki/assignment.gif" title="'.get_lang('AssignmentDescExtra').'" alt="'.get_lang('AssignmentDescExtra').'" />';
  274. }
  275. elseif(stripslashes($current_row['assignment'])==2)
  276. {
  277. $icon_assignment='<img src="../img/wiki/works.gif" title="'.get_lang('AssignmentWorkExtra').'" alt="'.get_lang('AssignmentWorkExtra').'" />';
  278. if((api_get_user_id()==$current_row['user_id'])==false)
  279. {
  280. if(api_is_allowed_to_edit() || api_is_platform_admin())
  281. {
  282. $PassEdit=true;
  283. }
  284. else
  285. {
  286. Display::display_warning_message(get_lang('LockByTeacher'));
  287. $PassEdit=false;
  288. }
  289. }
  290. else
  291. {
  292. $PassEdit=true;
  293. }
  294. }
  295. if($PassEdit) //show editor if edit is allowed
  296. {
  297. if (check_protect_page() && (api_is_allowed_to_edit()==false || api_is_platform_admin()==false))
  298. {
  299. Display::display_normal_message(get_lang('PageLockedExtra'));
  300. }
  301. else
  302. {
  303. if($last_row['is_editing']!=0 && $last_row['is_editing']!=$_user['user_id'])
  304. {
  305. //checking for concurrent users
  306. $timestamp_edit=strtotime($last_row['time_edit']);
  307. $time_editing=time()-$timestamp_edit;
  308. $max_edit_time=1200; // 20 minutes
  309. $rest_time=$max_edit_time-$time_editing;
  310. $userinfo=Database::get_user_info_from_id($last_row['is_editing']);
  311. $is_being_edited= get_lang('ThisPageisBeginEditedBy').' <a href=../user/userInfo.php?uInfo='.$userinfo['user_id'].'>'.api_get_person_name($userinfo['firstname'], $userinfo['lastname']).'</a>. '.get_lang('ThisPageisBeginEditedTryLater').' '.date( "i",$rest_time).' '.get_lang('MinMinutes').'';
  312. Display::display_normal_message($is_being_edited, false);
  313. }
  314. else
  315. {
  316. Display::display_confirmation_message(restore_wikipage($current_row['page_id'], $current_row['reflink'], $current_row['title'], $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&amp;title='.$last_row['reflink'].'&group_id='.$last_row['group_id'].'">'.$last_row['title'].'</a>',false);
  317. }
  318. }
  319. }
  320. }
  321. }
  322. }
  323. if ($_GET['action']=='deletewiki'){
  324. if(api_is_allowed_to_edit() || api_is_platform_admin())
  325. {
  326. if ($_GET['delete'] == 'yes')
  327. {
  328. $return_message=delete_wiki();
  329. Display::display_confirmation_message($return_message);
  330. }
  331. }
  332. }
  333. if ($_GET['action']=='discuss' && $_POST['Submit'])
  334. {
  335. Display::display_confirmation_message(get_lang('CommentAdded'));
  336. }
  337. /*
  338. -----------------------------------------------------------
  339. WIKI WRAPPER
  340. -----------------------------------------------------------
  341. */
  342. echo "<div id='wikiwrapper'>";
  343. /** Actions bar (= action of the wiki tool, not of the page)**/
  344. echo '<div id="menuwiki">';
  345. echo '<table width="210">';
  346. echo '<tr>';
  347. echo '<td>';
  348. echo get_lang('Menu');
  349. echo '</td>';
  350. echo '</tr>';
  351. echo '<tr>';
  352. echo '<td>';
  353. ///menu home
  354. echo '<ul><li><a href="index.php?cidReq='.$_course[id].'&action=show&amp;title=index&group_id='.$_clean['group_id'].'"'.is_active_navigation_tab('show').'>'.get_lang('HomeWiki').'</a></li>';
  355. ///menu add page
  356. echo '<li><a href="index.php?cidReq='.$_course[id].'&action=addnew&group_id='.$_clean['group_id'].'"'.is_active_navigation_tab('addnew').'>'.get_lang('AddNew').'</a> ';
  357. // page action: enable or disable the adding of new pages
  358. if (check_addnewpagelock())
  359. {
  360. if(api_is_allowed_to_edit() || api_is_platform_admin())
  361. {
  362. $protect_addnewpage= '<img src="../img/wiki/lockadd.gif" title="'.get_lang('AddOptionProtected').'" alt="'.get_lang('AddOptionProtected').'" width="8" height="8" />';
  363. }
  364. }
  365. else
  366. {
  367. if(api_is_allowed_to_edit() || api_is_platform_admin())
  368. {
  369. $protect_addnewpage= '<img src="../img/wiki/unlockadd.gif" title="'.get_lang('AddOptionUnprotected').'" alt="'.get_lang('AddOptionUnprotected').'" width="8" height="8" />';
  370. }
  371. }
  372. echo '<a href="index.php?action=show&amp;actionpage=addlock&amp;title='.$page.'">'.$protect_addnewpage.'</a></li>';
  373. ///menu find
  374. echo '<li><a href="index.php?cidReq='.$_course[id].'&action=searchpages&group_id='.$_clean['group_id'].'"'.is_active_navigation_tab('searchpages').'>'.get_lang('SearchPages').'</a></li>';
  375. ///menu all pages
  376. echo '<li><a href="index.php?cidReq='.$_course[id].'&action=allpages&group_id='.$_clean['group_id'].'"'.is_active_navigation_tab('allpages').'>'.get_lang('AllPages').'</a></li>';
  377. ///menu recent changes
  378. echo '<li><a href="index.php?cidReq='.$_course[id].'&action=recentchanges&group_id='.$_clean['group_id'].'"'.is_active_navigation_tab('recentchanges').'>'.get_lang('RecentChanges').'</a></li>';
  379. ///menu delete all wiki
  380. if(api_is_allowed_to_edit() || api_is_platform_admin())
  381. {
  382. echo '<li><a href="index.php?action=deletewiki&amp;title='.$page.'"'.is_active_navigation_tab('deletewiki').'>'.get_lang('DeleteWiki').'</a></li>';
  383. }
  384. ///menu more
  385. echo '<li><a href="index.php?action=more&amp;title='.$page.'"'.is_active_navigation_tab('more').'>'.get_lang('More').'</a></li>';
  386. echo '</ul>';
  387. echo '</td>';
  388. echo '</tr>';
  389. echo '</table>';
  390. echo '</div>';
  391. /*
  392. -----------------------------------------------------------
  393. MAIN WIKI AREA
  394. -----------------------------------------------------------
  395. */
  396. echo "<div id='mainwiki'>";
  397. /** menuwiki (= actions of the page, not of the wiki tool) **/
  398. if (!in_array($_GET['action'], array('addnew', 'searchpages', 'allpages', 'recentchanges', 'deletewiki', 'more', 'mactiveusers', 'mvisited', 'mostchanged', 'orphaned', 'wanted')))
  399. {
  400. echo "<div class='actions'>";
  401. //menu show page
  402. echo '<a href="index.php?cidReq='.$_course[id].'&action=showpage&amp;title='.$page.'&group_id='.$_clean['group_id'].'"'.is_active_navigation_tab('showpage').'>'.Display::display_icon('lp_document.png',get_lang('ShowThisPage')).' '.get_lang('Page').'</a>';
  403. //menu edit page
  404. echo '<a href="index.php?cidReq='.$_course[id].'&action=edit&amp;title='.$page.'&group_id='.$_clean['group_id'].'"'.is_active_navigation_tab('edit').'>'.Display::display_icon('lp_quiz.png',get_lang('EditThisPage')).' '.get_lang('EditPage').'</a>';
  405. //menu discuss page
  406. echo '<a href="index.php?action=discuss&amp;title='.$page.'"'.is_active_navigation_tab('discuss').'>'.Display::display_icon('comment_bubble.gif',get_lang('DiscussThisPage')).' '.get_lang('Discuss').'</a>';
  407. //menu history
  408. echo '<a href="index.php?cidReq='.$_course[id].'&action=history&amp;title='.$page.'&group_id='.$_clean['group_id'].'"'.is_active_navigation_tab('history').'>'.Display::display_icon('history.gif',get_lang('ShowPageHistory')).' '.get_lang('History').'</a>';
  409. //menu linkspages
  410. echo '<a href="index.php?action=links&amp;title='.$page.'"'.is_active_navigation_tab('links').'>'.Display::display_icon('lp_link.png',get_lang('ShowLinksPages')).' '.get_lang('LinksPages').'</a>';
  411. //menu delete wikipage
  412. if(api_is_allowed_to_edit() || api_is_platform_admin())
  413. {
  414. echo '<a href="index.php?action=delete&amp;title='.$page.'"'.is_active_navigation_tab('delete').'>'.Display::display_icon('delete.gif',get_lang('DeleteThisPage')).' '.get_lang('Delete').'</a>';
  415. }
  416. echo '</div>';
  417. }
  418. /////////////////////// more options /////////////////////// Juan Carlos Raña Trabado
  419. if ($_GET['action']=='more')
  420. {
  421. echo '<div class="actions">'.get_lang('More').'</div>';
  422. if(api_is_allowed_to_edit() || api_is_platform_admin())
  423. {
  424. //TODO: config area and private stats
  425. }
  426. echo '<table border="0">';
  427. echo '<tr>';
  428. echo '<td>';
  429. echo '<ul>';
  430. //Submenu Most active users
  431. echo '<li><a href="index.php?cidReq='.$_course[id].'&action=mactiveusers&group_id='.$_clean['group_id'].'">'.get_lang('MostActiveUsers').'</a></li>';
  432. //Submenu Most visited pages
  433. echo '<li><a href="index.php?cidReq='.$_course[id].'&action=mvisited&group_id='.$_clean['group_id'].'">'.get_lang('MostVisitedPages').'</a></li>';
  434. //Submenu Most changed pages
  435. echo '<li><a href="index.php?cidReq='.$_course[id].'&action=mostchanged&group_id='.$_clean['group_id'].'">'.get_lang('MostChangedPages').'</a></li>';
  436. echo '</ul>';
  437. echo '</td>';
  438. echo '<td>';
  439. echo '<ul>';
  440. //Submenu Orphaned pages
  441. echo '<li><a href="index.php?cidReq='.$_course[id].'&action=orphaned&group_id='.$_clean['group_id'].'">'.get_lang('OrphanedPages').'</a></li>';
  442. //Submenu Wanted pages
  443. echo '<li><a href="index.php?cidReq='.$_course[id].'&action=wanted&group_id='.$_clean['group_id'].'">'.get_lang('WantedPages').'</a></li>';
  444. echo '</ul>';
  445. echo'</td>';
  446. echo '</tr>';
  447. echo '</table>';
  448. //Submenu Most linked pages
  449. //echo '<li><a href="index.php?cidReq='.$_course[id].'&action=mostlinked&group_id='.$_clean['group_id'].'">'.get_lang('MostLinkedPages').'</a></li>';//TODO:
  450. //Submenu Dead end pages
  451. //echo '<li><a href="index.php?cidReq='.$_course[id].'&action=deadend&group_id='.$_clean['group_id'].'">'.get_lang('DeadEndPages').'</a></li>';//TODO:
  452. //Submenu Most new pages (not versions)
  453. //echo '<li><a href="index.php?cidReq='.$_course[id].'&action=mnew&group_id='.$_clean['group_id'].'">'.get_lang('MostNewPages').'</a></li>';//TODO:
  454. //Submenu Most long pages
  455. //echo '<li><a href="index.php?cidReq='.$_course[id].'&action=mnew&group_id='.$_clean['group_id'].'">'.get_lang('MostLongPages').'</a></li>';//TODO:
  456. //Submenu Protected pages
  457. //echo '<li><a href="index.php?cidReq='.$_course[id].'&action=protected&group_id='.$_clean['group_id'].'">'.get_lang('ProtectedPages').'</a></li>';//TODO:
  458. //Submenu Hidden pages
  459. //echo '<li><a href="index.php?cidReq='.$_course[id].'&action=hidden&group_id='.$_clean['group_id'].'">'.get_lang('HiddenPages').'</a></li>';//TODO:
  460. //Submenu Most discuss pages
  461. //echo '<li><a href="index.php?cidReq='.$_course[id].'&action=mdiscuss&group_id='.$_clean['group_id'].'">'.get_lang('MostDiscussPages').'</a></li>';//TODO:
  462. //Submenu Best scored pages
  463. //echo '<li><a href="index.php?cidReq='.$_course[id].'&action=mscored&group_id='.$_clean['group_id'].'">'.get_lang('BestScoredPages').'</a></li>';//TODO:
  464. //Submenu Pages with more progress
  465. //echo '<li><a href="index.php?cidReq='.$_course[id].'&action=mprogress&group_id='.$_clean['group_id'].'">'.get_lang('MProgressPages').'</a></li>';//TODO:
  466. //Submenu Most active users in discuss
  467. //echo '<li><a href="index.php?cidReq='.$_course[id].'&action=mactiveusers&group_id='.$_clean['group_id'].'">'.get_lang('MostDiscussUsers').'</a></li>';//TODO:
  468. //Submenu Random page
  469. //echo '<li><a href="index.php?cidReq='.$_course[id].'&action=mrandom&group_id='.$_clean['group_id'].'">'.get_lang('RandomPage').'</a></li>';//TODO:
  470. }
  471. /////////////////////// Most active users /////////////////////// Juan Carlos Raña Trabado
  472. if ($_GET['action']=='mactiveusers')
  473. {
  474. echo '<div class="actions">'.get_lang('MostActiveUsers').'</div>';
  475. $sql='SELECT *, COUNT(*) AS NUM_EDIT FROM '.$tbl_wiki.' WHERE '.$groupfilter.' GROUP BY user_id';
  476. $allpages=Database::query($sql,__FILE__,__LINE__);
  477. //show table
  478. if (mysql_num_rows($allpages) > 0)
  479. {
  480. $row = array ();
  481. while ($obj = mysql_fetch_object($allpages))
  482. {
  483. $userinfo=Database::get_user_info_from_id($obj->user_id);
  484. $row = array ();
  485. $row[] = $obj->user_id <>0 ? '<a href="../user/userInfo.php?uInfo='.$userinfo['user_id'].'">'.api_get_person_name($userinfo['firstname'], $userinfo['lastname']).'</a><a href="'.api_get_self().'?cidReq='.$_course[id].'&action=usercontrib&user_id='.urlencode($row['user_id']).'&group_id='.Security::remove_XSS($_GET['group_id']).'"></a>' : get_lang('Anonymous').' ('.$obj->user_ip.')';
  486. $row[] ='<a href="'.api_get_self().'?cidReq='.$_course[id].'&action=usercontrib&user_id='.urlencode($obj->user_id).'&group_id='.Security::remove_XSS($_GET['group_id']).'">'.$obj->NUM_EDIT.'</a>';
  487. $rows[] = $row;
  488. }
  489. $table = new SortableTableFromArrayConfig($rows,1,10,'MostActiveUsersA_table','','','DESC');
  490. $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'])));
  491. $table->set_header(0,get_lang('Author'), true, array ('style' => 'width:30px;'));
  492. $table->set_header(1,get_lang('Contributions'), true);
  493. $table->display();
  494. }
  495. }
  496. /////////////////////// User contributions /////////////////////// Juan Carlos Raña Trabado
  497. if ($_GET['action']=='usercontrib')
  498. {
  499. $userinfo=Database::get_user_info_from_id(Security::remove_XSS($_GET['user_id']));
  500. echo '<div class="actions">'.get_lang('UserContributions').': <a href="../user/userInfo.php?uInfo='.$userinfo['user_id'].'">'.api_get_person_name($userinfo['firstname'], $userinfo['lastname']).'</a><a href="'.api_get_self().'?cidReq='.$_course[id].'&action=usercontrib&user_id='.urlencode($row['user_id']).'&group_id='.Security::remove_XSS($_GET['group_id']).'"></a></div>';
  501. if(api_is_allowed_to_edit() || api_is_platform_admin()) //only by professors if page is hidden
  502. {
  503. $sql='SELECT * FROM '.$tbl_wiki.' WHERE '.$groupfilter.' AND user_id="'.Security::remove_XSS($_GET['user_id']).'"';
  504. }
  505. else
  506. {
  507. $sql='SELECT * FROM '.$tbl_wiki.' WHERE '.$groupfilter.' AND user_id="'.Security::remove_XSS($_GET['user_id']).'" AND visibility=1';
  508. }
  509. $allpages=Database::query($sql,__FILE__,__LINE__);
  510. //show table
  511. if (mysql_num_rows($allpages) > 0)
  512. {
  513. $row = array ();
  514. while ($obj = mysql_fetch_object($allpages))
  515. {
  516. //get author
  517. $userinfo=Database::get_user_info_from_id($obj->user_id);
  518. //get time
  519. $year = substr($obj->dtime, 0, 4);
  520. $month = substr($obj->dtime, 5, 2);
  521. $day = substr($obj->dtime, 8, 2);
  522. $hours = substr($obj->dtime, 11,2);
  523. $minutes = substr($obj->dtime, 14,2);
  524. $seconds = substr($obj->dtime, 17,2);
  525. //get type assignment icon
  526. if($obj->assignment==1)
  527. {
  528. $ShowAssignment='<img src="../img/wiki/assignment.gif" title="'.get_lang('AssignmentDesc').'" alt="'.get_lang('AssignmentDesc').'" />';
  529. }
  530. elseif ($obj->assignment==2)
  531. {
  532. $ShowAssignment='<img src="../img/wiki/works.gif" title="'.get_lang('AssignmentWork').'" alt="'.get_lang('AssignmentWork').'" />';
  533. }
  534. elseif ($obj->assignment==0)
  535. {
  536. $ShowAssignment='<img src="../img/wiki/trans.gif" />';
  537. }
  538. $row = array ();
  539. $row[] = $year.'-'.$month.'-'.$day.' '.$hours.":".$minutes.":".$seconds;
  540. $row[] =$ShowAssignment;
  541. $row[] = '<a href="'.api_get_self().'?cidReq='.$_course[id].'&action=showpage&title='.urlencode($obj->reflink).'&view='.$obj->id.'&group_id='.Security::remove_XSS($_GET['group_id']).'">'.$obj->title.'</a>';
  542. $row[] =$obj->version;
  543. $row[] =$obj->comment;
  544. //$row[] = api_strlen($obj->comment)>30 ? api_substr($obj->comment,0,30).'...' : $obj->comment;
  545. $row[] =$obj->progress.' %';
  546. $row[] =$obj->score;
  547. //if(api_is_allowed_to_edit() || api_is_platform_admin())
  548. //{
  549. //$row[] =$obj->user_ip;
  550. //}
  551. $rows[] = $row;
  552. }
  553. $table = new SortableTableFromArrayConfig($rows,2,10,'UsersContributions_table','','','ASC');
  554. $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']),'group_id'=>Security::remove_XSS($_GET['group_id'])));
  555. $table->set_header(0,get_lang('Date'), true, array ('style' => 'width:200px;'));
  556. $table->set_header(1,get_lang('Type'), true, array ('style' => 'width:30px;'));
  557. $table->set_header(2,get_lang('Title'), true, array ('style' => 'width:200px;'));
  558. $table->set_header(3,get_lang('Version'), true, array ('style' => 'width:30px;'));
  559. $table->set_header(4,get_lang('Comment'), true, array ('style' => 'width:200px;'));
  560. $table->set_header(5,get_lang('Progress'), true, array ('style' => 'width:30px;'));
  561. $table->set_header(6,get_lang('Rating'), true, array ('style' => 'width:30px;'));
  562. //if(api_is_allowed_to_edit() || api_is_platform_admin())
  563. //{
  564. //$table->set_header(7,get_lang('IP'), true, array ('style' => 'width:30px;'));
  565. //}
  566. $table->display();
  567. }
  568. }
  569. /////////////////////// Most changed pages /////////////////////// Juan Carlos Raña Trabado
  570. if ($_GET['action']=='mostchanged')
  571. {
  572. echo '<div class="actions">'.get_lang('MostChangedPages').'</div>';
  573. if(api_is_allowed_to_edit() || api_is_platform_admin()) //only by professors if page is hidden
  574. {
  575. $sql='SELECT *, MAX(version) AS MAX FROM '.$tbl_wiki.' WHERE '.$groupfilter.' GROUP BY reflink';
  576. }
  577. else
  578. {
  579. $sql='SELECT *, MAX(version) AS MAX FROM '.$tbl_wiki.' WHERE '.$groupfilter.' AND visibility=1 GROUP BY reflink';
  580. }
  581. $allpages=Database::query($sql,__FILE__,__LINE__);
  582. //show table
  583. if (mysql_num_rows($allpages) > 0)
  584. {
  585. $row = array ();
  586. while ($obj = mysql_fetch_object($allpages))
  587. {
  588. //get type assignment icon
  589. if($obj->assignment==1)
  590. {
  591. $ShowAssignment='<img src="../img/wiki/assignment.gif" title="'.get_lang('AssignmentDesc').'" alt="'.get_lang('AssignmentDesc').'" />';
  592. }
  593. elseif ($obj->assignment==2)
  594. {
  595. $ShowAssignment='<img src="../img/wiki/works.gif" title="'.get_lang('AssignmentDesc').'" alt="'.get_lang('AssignmentWork').'" />';
  596. }
  597. elseif ($obj->assignment==0)
  598. {
  599. $ShowAssignment='<img src="../img/wiki/trans.gif" />';
  600. }
  601. $row = array ();
  602. $row[] =$ShowAssignment;
  603. $row[] = '<a href="'.api_get_self().'?cidReq='.$_course[id].'&action=showpage&title='.urlencode($obj->reflink).'&group_id='.Security::remove_XSS($_GET['group_id']).'">'.$obj->title.'</a>';
  604. $row[] = $obj->MAX;
  605. $rows[] = $row;
  606. }
  607. $table = new SortableTableFromArrayConfig($rows,2,10,'MostChangedPages_table','','','DESC');
  608. $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'])));
  609. $table->set_header(0,get_lang('Type'), true, array ('style' => 'width:30px;'));
  610. $table->set_header(1,get_lang('Title'), true);
  611. $table->set_header(2,get_lang('Changes'), true);
  612. $table->display();
  613. }
  614. }
  615. /////////////////////// Most visited pages /////////////////////// Juan Carlos Raña Trabado
  616. if ($_GET['action']=='mvisited')
  617. {
  618. echo '<div class="actions">'.get_lang('MostVisitedPages').'</div>';
  619. if(api_is_allowed_to_edit() || api_is_platform_admin()) //only by professors if page is hidden
  620. {
  621. $sql='SELECT *, SUM(hits) AS tsum FROM '.$tbl_wiki.' WHERE '.$groupfilter.' GROUP BY reflink';
  622. }
  623. else
  624. {
  625. $sql='SELECT *, SUM(hits) AS tsum FROM '.$tbl_wiki.' WHERE '.$groupfilter.' AND visibility=1 GROUP BY reflink';
  626. }
  627. $allpages=Database::query($sql,__FILE__,__LINE__);
  628. //show table
  629. if (mysql_num_rows($allpages) > 0)
  630. {
  631. $row = array ();
  632. while ($obj = mysql_fetch_object($allpages))
  633. {
  634. //get type assignment icon
  635. if($obj->assignment==1)
  636. {
  637. $ShowAssignment='<img src="../img/wiki/assignment.gif" title="'.get_lang('AssignmentDesc').'" alt="'.get_lang('AssignmentDesc').'" />';
  638. }
  639. elseif ($obj->assignment==2)
  640. {
  641. $ShowAssignment='<img src="../img/wiki/works.gif" title="'.get_lang('AssignmentWork').'" alt="'.get_lang('AssignmentWork').'" />';
  642. }
  643. elseif ($obj->assignment==0)
  644. {
  645. $ShowAssignment='<img src="../img/wiki/trans.gif" />';
  646. }
  647. $row = array ();
  648. $row[] =$ShowAssignment;
  649. $row[] = '<a href="'.api_get_self().'?cidReq='.$_course[id].'&action=showpage&title='.urlencode($obj->reflink).'&group_id='.Security::remove_XSS($_GET['group_id']).'">'.$obj->title.'</a>';
  650. $row[] = $obj->tsum;
  651. $rows[] = $row;
  652. }
  653. $table = new SortableTableFromArrayConfig($rows,2,10,'MostVisitedPages_table','','','DESC');
  654. $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'])));
  655. $table->set_header(0,get_lang('Type'), true, array ('style' => 'width:30px;'));
  656. $table->set_header(1,get_lang('Title'), true);
  657. $table->set_header(2,get_lang('Visits'), true);
  658. $table->display();
  659. }
  660. }
  661. /////////////////////// Wanted pages /////////////////////// Juan Carlos Raña Trabado
  662. if ($_GET['action']=='wanted')
  663. {
  664. echo '<div class="actions">'.get_lang('WantedPages').'</div>';
  665. $pages = array();
  666. $refs = array();
  667. $sort_wanted=array();
  668. //get name pages
  669. $sql='SELECT * FROM '.$tbl_wiki.' WHERE '.$groupfilter.' GROUP BY reflink ORDER BY reflink ASC';
  670. $allpages=Database::query($sql,__FILE__,__LINE__);
  671. while ($row=Database::fetch_array($allpages))
  672. {
  673. $pages[] = $row['reflink'];
  674. }
  675. //get name refs in last pages and make a unique list
  676. //$sql='SELECT * FROM '.$tbl_wiki.' s1 WHERE id=(SELECT MAX(s2.id) FROM '.$tbl_wiki.' s2 WHERE s1.reflink = s2.reflink AND '.$groupfilter.')'; //old version TODO: Replace by the bottom line
  677. $sql='SELECT * FROM '.$tbl_wiki.', '.$tbl_wiki_conf.' WHERE visibility=1 AND '.$tbl_wiki_conf.'.page_id='.$tbl_wiki.'.page_id AND '.$tbl_wiki.'.'.$groupfilter; // new version
  678. $allpages=Database::query($sql,__FILE__,__LINE__);
  679. while ($row=Database::fetch_array($allpages))
  680. {
  681. //$row['linksto']= str_replace("\n".$row["reflink"]."\n", "\n", $row["linksto"]); //remove self reference. TODO: check
  682. $rf = explode(" ", trim($row["linksto"]));//wanted pages without /n only blank " "
  683. $refs = array_merge($refs, $rf);
  684. if ($n++ > 299)
  685. {
  686. $refs = array_unique($refs);
  687. $n=0;
  688. } // (clean-up only every 300th loop). Thanks to Erfurt Wiki
  689. }
  690. //sort linksto. Find linksto into reflink. If not found ->page is wanted
  691. natcasesort($refs);
  692. echo '<ul>';
  693. foreach($refs as $v)
  694. {
  695. if(!in_array($v, $pages))
  696. {
  697. if (trim($v)!="")
  698. {
  699. echo '<li><a href="'.api_get_path(WEB_PATH).'main/wiki/index.php?cidReq=&action=addnew&title='.urlencode(str_replace('_',' ',$v)).'&group_id='.Security::remove_XSS($_GET['group_id']).'" class="new_wiki_link">'.str_replace('_',' ',$v).'</a></li>';
  700. }
  701. }
  702. }
  703. echo '</ul>';
  704. }
  705. /////////////////////// Orphaned pages /////////////////////// Juan Carlos Raña Trabado
  706. if ($_GET['action']=='orphaned')
  707. {
  708. echo '<div class="actions">'.get_lang('OrphanedPages').'</div>';
  709. $pages = array();
  710. $refs = array();
  711. $orphaned = array();
  712. //get name pages
  713. $sql='SELECT * FROM '.$tbl_wiki.' WHERE '.$groupfilter.' GROUP BY reflink ORDER BY reflink ASC';
  714. $allpages=Database::query($sql,__FILE__,__LINE__);
  715. while ($row=Database::fetch_array($allpages))
  716. {
  717. $pages[] = $row['reflink'];
  718. }
  719. //get name refs in last pages and make a unique list
  720. //$sql='SELECT * FROM '.$tbl_wiki.' s1 WHERE id=(SELECT MAX(s2.id) FROM '.$tbl_wiki.' s2 WHERE s1.reflink = s2.reflink AND '.$groupfilter.')'; //old version TODO: Replace by the bottom line
  721. $sql='SELECT * FROM '.$tbl_wiki.', '.$tbl_wiki_conf.' WHERE '.$tbl_wiki_conf.'.page_id='.$tbl_wiki.'.page_id AND '.$tbl_wiki.'.'.$groupfilter.' '; // new version
  722. $allpages=Database::query($sql,__FILE__,__LINE__);
  723. while ($row=Database::fetch_array($allpages))
  724. {
  725. //$row['linksto']= str_replace("\n".$row["reflink"]."\n", "\n", $row["linksto"]); //remove self reference. TODO: check
  726. $rf = explode(" ", trim($row["linksto"])); //fix replace explode("\n", trim($row["linksto"])) with explode(" ", trim($row["linksto"]))
  727. $refs = array_merge($refs, $rf);
  728. if ($n++ > 299)
  729. {
  730. $refs = array_unique($refs);
  731. $n=0;
  732. } // (clean-up only every 300th loop). Thanks to Erfurt Wiki
  733. }
  734. //search each name of list linksto into list reflink
  735. foreach($pages as $v)
  736. {
  737. if(!in_array($v, $refs))
  738. {
  739. $orphaned[] = $v;
  740. }
  741. }
  742. //change reflink by title
  743. foreach($orphaned as $vshow)
  744. {
  745. if(api_is_allowed_to_edit() || api_is_platform_admin()) //only by professors if page is hidden
  746. {
  747. $sql='SELECT * FROM '.$tbl_wiki.' WHERE '.$groupfilter.' AND reflink="'.$vshow.'" GROUP BY reflink';
  748. }
  749. else
  750. {
  751. $sql='SELECT * FROM '.$tbl_wiki.' WHERE '.$groupfilter.' AND reflink="'.$vshow.'" AND visibility=1 GROUP BY reflink';
  752. }
  753. $allpages=Database::query($sql,__FILE__,__LINE__);
  754. echo '<ul>';
  755. while ($row=Database::fetch_array($allpages))
  756. {
  757. //fix assignment icon
  758. if($row['assignment']==1)
  759. {
  760. $ShowAssignment='<img src="../img/wiki/assignment.gif" />';
  761. }
  762. elseif ($row['assignment']==2)
  763. {
  764. $ShowAssignment='<img src="../img/wiki/works.gif" />';
  765. }
  766. elseif ($row['assignment']==0)
  767. {
  768. $ShowAssignment='<img src="../img/wiki/trans.gif" />';
  769. }
  770. echo '<li>'.$ShowAssignment.'<a href="'.api_get_self().'?cidReq='.$_course[id].'&action=showpage&title='.urlencode($row['reflink']).'&group_id='.Security::remove_XSS($_GET['group_id']).'">'.$row['title'].'</a></li>';
  771. }
  772. echo '</ul>';
  773. }
  774. }
  775. /////////////////////// delete current page /////////////////////// Juan Carlos Raña Trabado
  776. if ($_GET['action']=='delete')
  777. {
  778. if(!$_GET['title'])
  779. {
  780. Display::display_error_message(get_lang('MustSelectPage'));
  781. exit;
  782. }
  783. echo '<div style="overflow:hidden">';
  784. if(api_is_allowed_to_edit() || api_is_platform_admin())
  785. {
  786. echo '<div id="wikititle">'.get_lang('DeletePageHistory').'</div>';
  787. if($page=="index")
  788. {
  789. Display::display_warning_message(get_lang('WarningDeleteMainPage'),false);
  790. }
  791. $message = get_lang('ConfirmDeletePage')."</p>"."<p>"."<a href=\"index.php\">".get_lang("No")."</a>"."&nbsp;&nbsp;|&nbsp;&nbsp;"."<a href=\"".api_get_self()."?action=delete&amp;title=".$page."&amp;delete=yes\">".get_lang("Yes")."</a>"."</p>";
  792. if (!isset ($_GET['delete']))
  793. {
  794. Display::display_warning_message($message,false);
  795. }
  796. if ($_GET['delete'] == 'yes')
  797. {
  798. $sql='DELETE '.$tbl_wiki_discuss.' FROM '.$tbl_wiki.', '.$tbl_wiki_discuss.' WHERE '.$tbl_wiki.'.reflink="'.html_entity_decode(Database::escape_string(stripslashes(urldecode($page)))).'" AND '.$tbl_wiki.'.'.$groupfilter.' AND '.$tbl_wiki_discuss.'.publication_id='.$tbl_wiki.'.id';
  799. Database::query($sql,__FILE__,__LINE__);
  800. $sql='DELETE '.$tbl_wiki_mailcue.' FROM '.$tbl_wiki.', '.$tbl_wiki_mailcue.' WHERE '.$tbl_wiki.'.reflink="'.html_entity_decode(Database::escape_string(stripslashes(urldecode($page)))).'" AND '.$tbl_wiki.'.'.$groupfilter.' AND '.$tbl_wiki_mailcue.'.id='.$tbl_wiki.'.id';
  801. Database::query($sql,__FILE__,__LINE__);
  802. $sql='DELETE FROM '.$tbl_wiki.' WHERE reflink="'.html_entity_decode(Database::escape_string(stripslashes(urldecode($page)))).'" AND '.$groupfilter.'';
  803. Database::query($sql,__FILE__,__LINE__);
  804. check_emailcue(0, 'E');
  805. Display::display_confirmation_message(get_lang('WikiPageDeleted'));
  806. }
  807. }
  808. else
  809. {
  810. Display::display_normal_message(get_lang("OnlyAdminDeletePageWiki"));
  811. }
  812. echo '</div>';
  813. }
  814. /////////////////////// delete all wiki /////////////////////// Juan Carlos Raña Trabado
  815. if ($_GET['action']=='deletewiki')
  816. {
  817. echo '<div class="actions">'.get_lang('DeleteWiki').'</div>';
  818. echo '<div style="overflow:hidden">';
  819. if(api_is_allowed_to_edit() || api_is_platform_admin())
  820. {
  821. $message = get_lang('ConfirmDeleteWiki');
  822. $message .= '<p>
  823. <a href="index.php">'.get_lang('No').'</a>
  824. &nbsp;&nbsp;|&nbsp;&nbsp;
  825. <a href="'.api_get_self().'?action=deletewiki&amp;delete=yes">'.get_lang('Yes').'</a>
  826. </p>';
  827. if (!isset($_GET['delete']))
  828. {
  829. Display::display_warning_message($message,false);
  830. }
  831. }
  832. else
  833. {
  834. Display::display_normal_message(get_lang("OnlyAdminDeleteWiki"));
  835. }
  836. echo '</div>';
  837. }
  838. /////////////////////// search wiki pages ///////////////////////
  839. if ($_GET['action']=='searchpages')
  840. {
  841. echo '<div class="actions">'.get_lang('SearchPages').'</div>';
  842. echo '<div style="overflow:hidden">';
  843. // initiate the object
  844. $form = new FormValidator('wiki_search','post', api_get_self().'?cidReq='.Security::remove_XSS($_GET['cidReq']).'&action='.Security::remove_XSS($_GET['action']).'&group_id='.Security::remove_XSS($_GET['group_id']));
  845. // settting the form elements
  846. $form->addElement('text', 'search_term', get_lang('SearchTerm'),'class="input_titles"');
  847. $form->addElement('checkbox', 'search_content', null, get_lang('AlsoSearchContent'));
  848. $form->addElement('style_submit_button', 'SubmitWikiSearch', get_lang('Search'), 'class="search"');
  849. // setting the rules
  850. $form->addRule('search_term', '<span class="required">'.get_lang('ThisFieldIsRequired').'</span>', 'required');
  851. $form->addRule('search_term', get_lang('TooShort'),'minlength',3);
  852. if ($form->validate())
  853. {
  854. $form->display();
  855. $values = $form->exportValues();
  856. display_wiki_search_results($values['search_term'], $values['search_content']);
  857. }
  858. else
  859. {
  860. $form->display();
  861. }
  862. echo '</div>';
  863. }
  864. /////////////////////// What links here. Show pages that have linked this page /////////////////////// Juan Carlos Raña Trabado
  865. if ($_GET['action']=='links')
  866. {
  867. if (!$_GET['title'])
  868. {
  869. Display::display_error_message(get_lang("MustSelectPage"));
  870. }
  871. else
  872. {
  873. $sql='SELECT * FROM '.$tbl_wiki.' WHERE reflink="'.html_entity_decode(Database::escape_string(stripslashes(urldecode($page)))).'" AND '.$groupfilter.'';
  874. $result=Database::query($sql,__FILE__,__LINE__);
  875. $row=Database::fetch_array($result);
  876. //get type assignment icon
  877. if($row['assignment']==1)
  878. {
  879. $ShowAssignment='<img src="../img/wiki/assignment.gif" title="'.get_lang('AssignmentDesc').'" alt="'.get_lang('AssignmentDesc').'" />';
  880. }
  881. elseif ($row['assignment']==2)
  882. {
  883. $ShowAssignment='<img src="../img/wiki/works.gif" title="'.get_lang('AssignmentWork').'" alt="'.get_lang('AssignmentWork').'" />';
  884. }
  885. elseif ($row['assignment']==0)
  886. {
  887. $ShowAssignment='<img src="../img/wiki/trans.gif" />';
  888. }
  889. //fix Title to reflink (link Main Page)
  890. if ($page==get_lang('DefaultTitle'))
  891. {
  892. $page='index';
  893. }
  894. echo '<div id="wikititle">';
  895. echo get_lang('LinksPagesFrom').': '.$ShowAssignment.' <a href="'.api_get_self().'?cidReq='.$_course[id].'&action=showpage&title='.Security::remove_XSS($page).'&group_id='.Security::remove_XSS($_GET['group_id']).'">'.Security::remove_XSS($row['title']).'</a>';
  896. echo '</div>';
  897. //fix index to title Main page into linksto
  898. if ($page=='index')
  899. {
  900. $page=str_replace(' ','_',get_lang('DefaultTitle'));
  901. }
  902. //table
  903. if(api_is_allowed_to_edit() || api_is_platform_admin()) //only by professors if page is hidden
  904. {
  905. //$sql="SELECT * FROM ".$tbl_wiki." s1 WHERE linksto LIKE '%".html_entity_decode(Database::escape_string(stripslashes(urldecode($page))))." %' AND id=(SELECT MAX(s2.id) FROM ".$tbl_wiki." s2 WHERE s1.reflink = s2.reflink AND ".$groupfilter.")"; //add blank space after like '%" " %' to identify each word. //Old version TODO: Replace by the bottom line
  906. $sql="SELECT * FROM ".$tbl_wiki.", ".$tbl_wiki_conf." WHERE linksto LIKE '%".html_entity_decode(Database::escape_string(stripslashes(urldecode($page))))." %' AND ".$tbl_wiki_conf.".page_id=".$tbl_wiki.".page_id AND ".$tbl_wiki.".".$groupfilter.""; //add blank space after like '%" " %' to identify each word. // new version
  907. }
  908. else
  909. {
  910. //$sql="SELECT * FROM ".$tbl_wiki." s1 WHERE visibility=1 AND linksto LIKE '%".html_entity_decode(Database::escape_string(stripslashes(urldecode($page))))." %' AND id=(SELECT MAX(s2.id) FROM ".$tbl_wiki." s2 WHERE s1.reflink = s2.reflink AND ".$groupfilter.")"; //add blank space after like '%" " %' to identify each word //old version TODO: Replace by the bottom line
  911. $sql="SELECT * FROM ".$tbl_wiki.", ".$tbl_wiki_conf." WHERE visibility=1 AND linksto LIKE '%".html_entity_decode(Database::escape_string(stripslashes(urldecode($page))))." %' AND ".$tbl_wiki_conf.".page_id=".$tbl_wiki.".page_id AND ".$tbl_wiki.".".$groupfilter.""; //add blank space after like '%" " %' to identify each word // new version
  912. }
  913. $allpages=Database::query($sql,__LINE__,__FILE__);
  914. //show table
  915. if (mysql_num_rows($allpages) > 0)
  916. {
  917. $row = array ();
  918. while ($obj = mysql_fetch_object($allpages))
  919. {
  920. //get author
  921. $userinfo=Database::get_user_info_from_id($obj->user_id);
  922. //get time
  923. $year = substr($obj->dtime, 0, 4);
  924. $month = substr($obj->dtime, 5, 2);
  925. $day = substr($obj->dtime, 8, 2);
  926. $hours = substr($obj->dtime, 11,2);
  927. $minutes = substr($obj->dtime, 14,2);
  928. $seconds = substr($obj->dtime, 17,2);
  929. //get type assignment icon
  930. if($obj->assignment==1)
  931. {
  932. $ShowAssignment='<img src="../img/wiki/assignment.gif" title="'.get_lang('AssignmentDesc').'" alt="'.get_lang('AssignmentDesc').'" />';
  933. }
  934. elseif ($obj->assignment==2)
  935. {
  936. $ShowAssignment='<img src="../img/wiki/works.gif" title="'.get_lang('AssignmentWork').'" alt="'.get_lang('AssignmentWork').'" />';
  937. }
  938. elseif ($obj->assignment==0)
  939. {
  940. $ShowAssignment='<img src="../img/wiki/trans.gif" />';
  941. }
  942. $row = array ();
  943. $row[] =$ShowAssignment;
  944. $row[] = '<a href="'.api_get_self().'?cidReq='.$_course[id].'&action=showpage&title='.urlencode($obj->reflink).'&group_id='.Security::remove_XSS($_GET['group_id']).'">'.Security::remove_XSS($obj->title).'</a>';
  945. $row[] = $obj->user_id <>0 ? '<a href="../user/userInfo.php?uInfo='.$userinfo['user_id'].'">'.api_get_person_name($userinfo['firstname'], $userinfo['lastname']).'</a>' : get_lang('Anonymous').' ('.$obj->user_ip.')';
  946. $row[] = $year.'-'.$month.'-'.$day.' '.$hours.":".$minutes.":".$seconds;
  947. $rows[] = $row;
  948. }
  949. $table = new SortableTableFromArrayConfig($rows,1,10,'AllPages_table','','','ASC');
  950. $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'])));
  951. $table->set_header(0,get_lang('Type'), true, array ('style' => 'width:30px;'));
  952. $table->set_header(1,get_lang('Title'), true);
  953. $table->set_header(2,get_lang('Author'), true);
  954. $table->set_header(3,get_lang('Date'), true);
  955. $table->display();
  956. }
  957. }
  958. }
  959. /////////////////////// adding a new page ///////////////////////
  960. // Display the form for adding a new wiki page
  961. if ($_GET['action']=='addnew')
  962. {
  963. echo '<div class="actions">'.get_lang('AddNew').'</div>';
  964. //first, check if page index was created. chektitle=false
  965. if (checktitle('index'))
  966. {
  967. if(api_is_allowed_to_edit() || api_is_platform_admin() || GroupManager :: is_user_in_group($_user['user_id'],$_SESSION['_gid']))
  968. {
  969. Display::display_normal_message(get_lang('GoAndEditMainPage'));
  970. }
  971. else
  972. {
  973. return Display::display_normal_message(get_lang('WikiStandBy'));
  974. }
  975. }
  976. elseif (check_addnewpagelock() && (api_is_allowed_to_edit()==false || api_is_platform_admin()==false))
  977. {
  978. Display::display_error_message(get_lang('AddPagesLocked'));
  979. }
  980. else
  981. {
  982. if(api_is_allowed_to_edit() || api_is_platform_admin() || GroupManager :: is_user_in_group($_user['user_id'],$_SESSION['_gid']) || Security::remove_XSS($_GET['group_id'])==0)
  983. {
  984. display_new_wiki_form();
  985. }
  986. else
  987. {
  988. Display::display_normal_message(get_lang('OnlyAddPagesGroupMembers'));
  989. }
  990. }
  991. }
  992. /////////////////////// show home page ///////////////////////
  993. if (!$_GET['action'] OR $_GET['action']=='show' AND !isset($_POST['SaveWikiNew']))
  994. {
  995. display_wiki_entry();
  996. }
  997. /////////////////////// show current page ///////////////////////
  998. if ($_GET['action']=='showpage' AND !isset($_POST['SaveWikiNew']))
  999. {
  1000. if($_GET['title'])
  1001. {
  1002. display_wiki_entry();
  1003. }
  1004. else
  1005. {
  1006. Display::display_error_message(get_lang('MustSelectPage'));
  1007. }
  1008. }
  1009. /////////////////////// edit current page ///////////////////////
  1010. if ($_GET['action']=='edit')
  1011. {
  1012. $_clean['group_id']=(int)$_SESSION['_gid'];
  1013. $sql='SELECT * FROM '.$tbl_wiki.', '.$tbl_wiki_conf.' WHERE '.$tbl_wiki_conf.'.page_id='.$tbl_wiki.'.page_id AND '.$tbl_wiki.'.reflink="'.html_entity_decode(Database::escape_string(stripslashes(urldecode($page)))).'" AND '.$tbl_wiki.'.'.$groupfilter.' ORDER BY id DESC';
  1014. $result=Database::query($sql,__LINE__,__FILE__);
  1015. $row=Database::fetch_array($result); // we do not need a while loop since we are always displaying the last version
  1016. if ($row['content']=='' AND $row['title']=='' AND $page=='')
  1017. {
  1018. Display::display_error_message(get_lang('MustSelectPage'));
  1019. exit;
  1020. }
  1021. elseif ($row['content']=='' AND $row['title']=='' AND $page=='index')
  1022. {
  1023. //Table structure for better export to pdf
  1024. $default_table_for_content_Start='<table align="center" border="0"><tr><td align="center">';
  1025. $default_table_for_content_End='</td></tr></table>';
  1026. $content=$default_table_for_content_Start.sprintf(get_lang('DefaultContent'),api_get_path(WEB_IMG_PATH)).$default_table_for_content_End;
  1027. $title=get_lang('DefaultTitle');
  1028. $page_id=0;
  1029. }
  1030. else
  1031. {
  1032. $content=$row['content'];
  1033. $title=$row['title'];
  1034. $page_id=$row['page_id'];
  1035. }
  1036. //Only teachers and platform admin can edit the index page. Only teachers and platform admin can edit an assignment teacher. And users in groups
  1037. if(($row['reflink']=='index' || $row['reflink']=='' || $row['assignment']==1) && (!api_is_allowed_to_edit() && $_clean['group_id']==0))
  1038. {
  1039. Display::display_error_message(get_lang('OnlyEditPagesCourseManager'));
  1040. }
  1041. else
  1042. {
  1043. $PassEdit=false;
  1044. //check if is a wiki group
  1045. if($_clean['group_id']!=0)
  1046. {
  1047. //Only teacher, platform admin and group members can edit a wiki group
  1048. if(api_is_allowed_to_edit() || api_is_platform_admin() || GroupManager :: is_user_in_group($_user['user_id'],$_SESSION['_gid']))
  1049. {
  1050. $PassEdit=true;
  1051. }
  1052. else
  1053. {
  1054. Display::display_normal_message(get_lang('OnlyEditPagesGroupMembers'));
  1055. }
  1056. }
  1057. else
  1058. {
  1059. $PassEdit=true;
  1060. }
  1061. // check if is a assignment
  1062. if(stripslashes($row['assignment'])==1)
  1063. {
  1064. Display::display_normal_message(get_lang('EditAssignmentWarning'));
  1065. $icon_assignment='<img src="../img/wiki/assignment.gif" title="'.get_lang('AssignmentDescExtra').'" alt="'.get_lang('AssignmentDescExtra').'" />';
  1066. }
  1067. elseif(stripslashes($row['assignment'])==2)
  1068. {
  1069. $icon_assignment='<img src="../img/wiki/works.gif" title="'.get_lang('AssignmentWorkExtra').'" alt="'.get_lang('AssignmentWorkExtra').'" />';
  1070. if((api_get_user_id()==$row['user_id'])==false)
  1071. {
  1072. if(api_is_allowed_to_edit() || api_is_platform_admin())
  1073. {
  1074. $PassEdit=true;
  1075. }
  1076. else
  1077. {
  1078. Display::display_warning_message(get_lang('LockByTeacher'));
  1079. $PassEdit=false;
  1080. }
  1081. }
  1082. else
  1083. {
  1084. $PassEdit=true;
  1085. }
  1086. }
  1087. if($PassEdit) //show editor if edit is allowed
  1088. {
  1089. if (check_protect_page() && (api_is_allowed_to_edit()==false || api_is_platform_admin()==false))
  1090. {
  1091. Display::display_normal_message(get_lang('PageLockedExtra'));
  1092. }
  1093. else
  1094. {
  1095. //check tasks
  1096. if (!empty($row['startdate_assig']) && $row['startdate_assig']!='0000-00-00 00:00:00' && time()<strtotime($row['startdate_assig']))
  1097. {
  1098. $message=get_lang('TheTaskDoesNotBeginUntil').': '.$row['startdate_assig'];
  1099. Display::display_warning_message($message);
  1100. if(!api_is_allowed_to_edit())
  1101. {
  1102. exit;
  1103. }
  1104. }
  1105. //
  1106. 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)
  1107. {
  1108. $message=get_lang('TheDeadlineHasBeenCompleted').': '.$row['enddate_assig'];
  1109. Display::display_warning_message($message);
  1110. if(!api_is_allowed_to_edit())
  1111. {
  1112. exit;
  1113. }
  1114. }
  1115. //
  1116. if(!empty($row['max_version']) && $row['version']>=$row['max_version'])
  1117. {
  1118. $message=get_lang('HasReachedMaxiNumVersions');
  1119. Display::display_warning_message($message);
  1120. if(!api_is_allowed_to_edit())
  1121. {
  1122. exit;
  1123. }
  1124. }
  1125. //
  1126. if (!empty($row['max_text']) && $row['max_text']<=word_count($row['content']))
  1127. {
  1128. $message=get_lang('HasReachedMaxNumWords');
  1129. Display::display_warning_message($message);
  1130. if(!api_is_allowed_to_edit())
  1131. {
  1132. exit;
  1133. }
  1134. }
  1135. ////
  1136. if (!empty($row['task']))
  1137. {
  1138. //previous change 0 by text
  1139. if ($row['startdate_assig']=='0000-00-00 00:00:00')
  1140. {
  1141. $message_task_startdate=get_lang('No');
  1142. }
  1143. else
  1144. {
  1145. $message_task_startdate=$row['startdate_assig'];
  1146. }
  1147. if ($row['enddate_assig']=='0000-00-00 00:00:00')
  1148. {
  1149. $message_task_enddate=get_lang('No');
  1150. }
  1151. else
  1152. {
  1153. $message_task_endate=$row['enddate_assig'];
  1154. }
  1155. if ($row['delayedsubmit']==0)
  1156. {
  1157. $message_task_delayedsubmit=get_lang('No');
  1158. }
  1159. else
  1160. {
  1161. $message_task_delayedsubmit=get_lang('Yes');
  1162. }
  1163. if ($row['max_version']==0)
  1164. {
  1165. $message_task_max_version=get_lang('No');
  1166. }
  1167. else
  1168. {
  1169. $message_task_max_version=$row['max_version'];
  1170. }
  1171. if ($row['max_text']==0)
  1172. {
  1173. $message_task_max_text=get_lang('No');
  1174. }
  1175. else
  1176. {
  1177. $message_task_max_text=$row['max_text'];
  1178. }
  1179. //comp message
  1180. $message_task='<b>'.get_lang('DescriptionOfTheTask').'</b><p>'.$row['task'].'</p><hr>';
  1181. $message_task.='<p>'.get_lang('StartDate').': '.$message_task_startdate.'</p>';
  1182. $message_task.='<p>'.get_lang('EndDate').': '.$message_task_enddate;
  1183. $message_task.=' ('.get_lang('AllowLaterSends').') '.$message_task_delayedsubmit.'</p>';
  1184. $message_task.='<p>'.get_lang('OtherSettings').': '.get_lang('NMaxVersion').': '.$message_task_max_version;
  1185. $message_task.=' '.get_lang('NMaxWords').': '.$message_task_max_text;
  1186. //display message
  1187. Display::display_normal_message($message_task,false);
  1188. }
  1189. if($row['progress']==$row['fprogress1'] && !empty($row['fprogress1']))
  1190. {
  1191. $feedback_message='<b>'.get_lang('Feedback').'</b><p>'.$row['feedback1'].'</p>';
  1192. Display::display_normal_message($feedback_message, false);
  1193. }
  1194. elseif($row['progress']==$row['fprogress2'] && !empty($row['fprogress2']))
  1195. {
  1196. $feedback_message='<b>'.get_lang('Feedback').'</b><p>'.$row['feedback2'].'</p>';
  1197. Display::display_normal_message($feedback_message, false);
  1198. }
  1199. elseif($row['progress']==$row['fprogress3'] && !empty($row['fprogress3']))
  1200. {
  1201. $feedback_message='<b>'.get_lang('Feedback').'</b><p>'.$row['feedback3'].'</p>';
  1202. Display::display_normal_message($feedback_message, false);
  1203. }
  1204. //previous checking for concurrent editions
  1205. if($row['is_editing']==0)
  1206. {
  1207. Display::display_normal_message(get_lang('WarningMaxEditingTime'));
  1208. $time_edit = date("Y-m-d H:i:s");
  1209. $sql='UPDATE '.$tbl_wiki.' SET is_editing="'.$_user['user_id'].'", time_edit="'.$time_edit.'" WHERE id="'.$row['id'].'"';
  1210. Database::query($sql,__FILE__,__LINE__);
  1211. }
  1212. elseif($row['is_editing']!=$_user['user_id'])
  1213. {
  1214. $timestamp_edit=strtotime($row['time_edit']);
  1215. $time_editing=time()-$timestamp_edit;
  1216. $max_edit_time=1200; // 20 minutes
  1217. $rest_time=$max_edit_time-$time_editing;
  1218. $userinfo=Database::get_user_info_from_id($row['is_editing']);
  1219. $is_being_edited= get_lang('ThisPageisBeginEditedBy').' <a href=../user/userInfo.php?uInfo='.$userinfo['user_id'].'>'.api_get_person_name($userinfo['firstname'], $userinfo['lastname']).'</a>. '.get_lang('ThisPageisBeginEditedTryLater').' '.date( "i",$rest_time).' '.get_lang('MinMinutes').'';
  1220. Display::display_normal_message($is_being_edited, false);
  1221. exit;
  1222. }
  1223. //form
  1224. echo '<form name="form1" method="post" action="'.api_get_self().'?action=showpage&amp;title='.$page.'&group_id='.Security::remove_XSS($_GET['group_id']).'">';
  1225. echo '<div id="wikititle">';
  1226. echo $icon_assignment.'&nbsp;&nbsp;&nbsp;'.$title;
  1227. //
  1228. if((api_is_allowed_to_edit() || api_is_platform_admin()) && $row['reflink']!='index')
  1229. {
  1230. echo'<a href="javascript://" onclick="advanced_parameters()" ><span id="plus_minus" style="float:right">&nbsp;'.Display::return_icon('div_show.gif',get_lang('Show'),array('style'=>'vertical-align:middle')).'&nbsp;'.get_lang('AdvancedParameters').'</span></a>';
  1231. echo '<div id="options" style="display:none; margin: 20px;" >';
  1232. //task
  1233. echo '<div>&nbsp;</div><input type="checkbox" value="1" name="checktask" onclick="if(this.checked==true){document.getElementById(\'option4\').style.display=\'block\';}else{document.getElementById(\'option4\').style.display=\'none\';}"/>&nbsp;<img src="../img/wiki/task.gif" title="'.get_lang('DefineTask').'" alt="'.get_lang('DefineTask').'"/>'.get_lang('DescriptionOfTheTask').'';
  1234. echo '&nbsp;&nbsp;&nbsp;<span id="msg_error4" style="display:none;color:red"></span>';
  1235. echo '<div id="option4" style="padding:4px; margin:5px; border:1px dotted; display:none;">';
  1236. echo '<table border="0" style="font-weight:normal">';
  1237. echo '<tr>';
  1238. echo '<td>'.get_lang('DescriptionOfTheTask').'</td>';
  1239. echo '</tr>';
  1240. echo '<tr>';
  1241. echo '<td>'.api_disp_html_area('task', stripslashes($row['task']), '', '', null, array('ToolbarSet' => 'wiki_task', 'Width' => '600', 'Height' => '200')).'</td>';
  1242. echo '</tr>';
  1243. echo '</table>';
  1244. echo '</div>';
  1245. //feedback
  1246. echo '<div>&nbsp;</div><input type="checkbox" value="1" name="checkfeedback" onclick="if(this.checked==true){document.getElementById(\'option2\').style.display=\'block\';}else{document.getElementById(\'option2\').style.display=\'none\';}"/>&nbsp;'.get_lang('AddFeedback').'';
  1247. echo '&nbsp;&nbsp;&nbsp;<span id="msg_error2" style="display:none;color:red"></span>';
  1248. echo '<div id="option2" style="padding:4px; margin:5px; border:1px dotted; display:none;">';
  1249. echo '<table border="0" style="font-weight:normal" align="center">';
  1250. echo '<tr>';
  1251. echo '<td colspan="2">'.get_lang('Feedback1').'</td>';
  1252. echo '<td colspan="2">'.get_lang('Feedback2').'</td>';
  1253. echo '<td colspan="2">'.get_lang('Feedback3').'</td>';
  1254. echo '</tr>';
  1255. echo '<tr>';
  1256. echo '<td colspan="2"><textarea name="feedback1" cols="23" rows="4" >'.stripslashes($row['feedback1']).'</textarea></td>';
  1257. echo '<td colspan="2"><textarea name="feedback2" cols="23" rows="4" >'.stripslashes($row['feedback2']).'</textarea></td>';
  1258. echo '<td colspan="2"><textarea name="feedback3" cols="23" rows="4" >'.stripslashes($row['feedback3']).'</textarea></td>';
  1259. echo '</tr>';
  1260. echo '<tr>';
  1261. echo '<td>'.get_lang('FProgress').':</td>';
  1262. echo '<td><select name="fprogress1">';
  1263. echo '<option value="'.stripslashes($row['fprogress1']).'" selected>'.stripslashes($row['fprogress1']).'</option>';
  1264. echo '<option value="10">10</option>
  1265. <option value="20">20</option>
  1266. <option value="30">30</option>
  1267. <option value="40">40</option>
  1268. <option value="50">50</option>
  1269. <option value="60">60</option>
  1270. <option value="70">70</option>
  1271. <option value="80">80</option>
  1272. <option value="90">90</option>
  1273. <option value="100">100</option>
  1274. </select> %</td>';
  1275. echo '<td>'.get_lang('FProgress').':</td>';
  1276. echo '<td><select name="fprogress2">';
  1277. echo '<option value="'.stripslashes($row['fprogress2']).'" selected>'.stripslashes($row['fprogress2']).'</option>';
  1278. echo '<option value="10">10</option>
  1279. <option value="20">20</option>
  1280. <option value="30">30</option>
  1281. <option value="40">40</option>
  1282. <option value="50">50</option>
  1283. <option value="60">60</option>
  1284. <option value="70">70</option>
  1285. <option value="80">80</option>
  1286. <option value="90">90</option>
  1287. <option value="100">100</option>
  1288. </select> %</td>';
  1289. echo '<td>'.get_lang('FProgress').':</td>';
  1290. echo '<td><select name="fprogress3">';
  1291. echo '<option value="'.stripslashes($row['fprogress3']).'" selected>'.stripslashes($row['fprogress3']).'</option>';
  1292. echo '<option value="10">10</option>
  1293. <option value="20">20</option>
  1294. <option value="30">30</option>
  1295. <option value="40">40</option>
  1296. <option value="50">50</option>
  1297. <option value="60">60</option>
  1298. <option value="70">70</option>
  1299. <option value="80">80</option>
  1300. <option value="90">90</option>
  1301. <option value="100">100</option>
  1302. </select> %</td>';
  1303. echo '</tr>';
  1304. echo '</table>';
  1305. echo '</div>';
  1306. //time limit
  1307. echo '<div>&nbsp;</div><input type="checkbox" value="1" name="checktimelimit" onclick="if(this.checked==true){document.getElementById(\'option1\').style.display=\'block\'; $pepe=\'a\';}else{document.getElementById(\'option1\').style.display=\'none\';}"/>&nbsp;'.get_lang('PutATimeLimit').'';
  1308. echo '&nbsp;&nbsp;&nbsp;<span id="msg_error1" style="display:none;color:red"></span>';
  1309. echo '<div id="option1" style="padding:4px; margin:5px; border:1px dotted; display:none;">';
  1310. echo '<table width="100%" border="0" style="font-weight:normal">';
  1311. echo '<tr>';
  1312. echo '<td align="right">'.get_lang("StartDate").':</td>';
  1313. echo '<td>';
  1314. if ($row['startdate_assig']=='0000-00-00 00:00:00')
  1315. {
  1316. echo draw_date_picker('startdate_assig').' <input type="checkbox" name="initstartdate" value="1"> '.get_lang('Yes').'/'.get_lang('No').'';
  1317. }
  1318. else
  1319. {
  1320. echo draw_date_picker('startdate_assig', $row['startdate_assig']).' <input type="checkbox" name="initstartdate" value="1"> '.get_lang('Yes').'/'.get_lang('No').'';
  1321. }
  1322. echo '</td>';
  1323. echo '</tr>';
  1324. echo '<tr>';
  1325. echo '<td align="right">'.get_lang("EndDate").':</td>';
  1326. echo '<td>';
  1327. if ($row['enddate_assig']=='0000-00-00 00:00:00')
  1328. {
  1329. echo draw_date_picker('enddate_assig').' <input type="checkbox" name="initenddate" value="1"> '.get_lang('Yes').'/'.get_lang('No').'';
  1330. }
  1331. else
  1332. {
  1333. echo draw_date_picker('enddate_assig', $row['enddate_assig']).' <input type="checkbox" name="initenddate" value="1"> '.get_lang('Yes').'/'.get_lang('No').'';
  1334. }
  1335. echo '</td>';
  1336. echo '</tr>';
  1337. echo '<tr>';
  1338. echo '<td align="right">'.get_lang('AllowLaterSends').':</td>';
  1339. if (stripslashes($row['delayedsubmit'])==1)
  1340. {
  1341. $check_uncheck='checked';
  1342. }
  1343. echo '<td><input type="checkbox" name="delayedsubmit" value="1" '.$check_uncheck.'></td>';
  1344. echo '</tr>';
  1345. echo'</table>';
  1346. echo '</div>';
  1347. //other limit
  1348. echo '<div>&nbsp;</div><input type="checkbox" value="1" name="checkotherlimit" onclick="if(this.checked==true){document.getElementById(\'option3\').style.display=\'block\';}else{document.getElementById(\'option3\').style.display=\'none\';}"/>&nbsp;'.get_lang('OtherSettings').'';
  1349. echo '&nbsp;&nbsp;&nbsp;<span id="msg_error3" style="display:none;color:red"></span>';
  1350. echo '<div id="option3" style="padding:4px; margin:5px; border:1px dotted; display:none;">';
  1351. echo '<div style="font-weight:normal"; align="center">'.get_lang('NMaxWords').':&nbsp;<input type="text" name="max_text" size="3" value="'.stripslashes($row['max_text']).'">&nbsp;&nbsp;'.get_lang('NMaxVersion').':&nbsp;<input type="text" name="max_version" size="3" value="'.stripslashes($row['max_version']).'"></div>';
  1352. echo '</div>';
  1353. //
  1354. echo '</div>';
  1355. }
  1356. echo '</div>';
  1357. echo '<div id="wikicontent">';
  1358. echo '<input type="hidden" name="page_id" value="'.$page_id.'">';
  1359. echo '<input type="hidden" name="reflink" value="'.$page.'">';
  1360. echo '<input type="hidden" name="title" value="'.stripslashes($title).'">';
  1361. api_disp_html_area('content', stripslashes($content), '', '', null, api_is_allowed_to_edit()
  1362. ? array('ToolbarSet' => 'Wiki', 'Width' => '100%', 'Height' => '400')
  1363. : array('ToolbarSet' => 'WikiStudent', 'Width' => '100%', 'Height' => '400', 'UserStatus' => 'student')
  1364. );
  1365. echo '<br/>';
  1366. echo '<br/>';
  1367. //if(api_is_allowed_to_edit() || api_is_platform_admin()) //off for now
  1368. //{
  1369. echo get_lang('Comments').':&nbsp;&nbsp;<input type="text" name="comment" size="40">&nbsp;&nbsp;&nbsp;';
  1370. //}
  1371. echo '<INPUT TYPE="hidden" NAME="assignment" VALUE="'.stripslashes($row['assignment']).'"/>';
  1372. echo '<INPUT TYPE="hidden" NAME="version" VALUE="'.stripslashes($row['version']).'"/>';
  1373. //hack date for edit
  1374. echo '<INPUT TYPE="hidden" NAME="startdate_assig" VALUE="'.stripslashes($row['startdate_assig']).'"/>';
  1375. echo '<INPUT TYPE="hidden" NAME="enddate_assig" VALUE="'.stripslashes($row['enddate_assig']).'"/>';
  1376. //
  1377. echo get_lang('Progress').':&nbsp;&nbsp;<select name="progress" id="progress">';
  1378. echo '<option value="'.stripslashes($row['progress']).'" selected>'.stripslashes($row['progress']).'</option>';
  1379. echo '<option value="10">10</option>
  1380. <option value="20">20</option>
  1381. <option value="30">30</option>
  1382. <option value="40">40</option>
  1383. <option value="50">50</option>
  1384. <option value="60">60</option>
  1385. <option value="70">70</option>
  1386. <option value="80">80</option>
  1387. <option value="90">90</option>
  1388. <option value="100">100</option>
  1389. </select> %';
  1390. echo '<br/><br/>';
  1391. echo '<input type="hidden" name="wpost_id" value="'.md5(uniqid(rand(), true)).'">';//prevent double post
  1392. echo '<input type="hidden" name="SaveWikiChange" value="'.get_lang('langSave').'">'; //for save icon
  1393. echo '<button class="save" type="submit" name="SaveWikiChange">'.get_lang('langSave').'</button>';//for save button
  1394. echo '</div>';
  1395. echo '</form>';
  1396. }
  1397. }
  1398. }
  1399. }
  1400. /////////////////////// page history ///////////////////////
  1401. if ($_GET['action']=='history' or Security::remove_XSS($_POST['HistoryDifferences']))
  1402. {
  1403. if (!$_GET['title'])
  1404. {
  1405. Display::display_error_message(get_lang("MustSelectPage"));
  1406. exit;
  1407. }
  1408. echo '<div style="overflow:hidden">';
  1409. $_clean['group_id']=(int)$_SESSION['_gid'];
  1410. //First, see the property visibility that is at the last register and therefore we should select descending order. But to give ownership to each record, this is no longer necessary except for the title. TODO: check this
  1411. $sql='SELECT * FROM '.$tbl_wiki.'WHERE reflink="'.html_entity_decode(Database::escape_string(stripslashes(urldecode($page)))).'" AND '.$groupfilter.' ORDER BY id DESC';
  1412. $result=Database::query($sql,__LINE__,__FILE__);
  1413. while ($row=Database::fetch_array($result))
  1414. {
  1415. $KeyVisibility=$row['visibility'];
  1416. $KeyAssignment=$row['assignment'];
  1417. $KeyTitle=$row['title'];
  1418. $KeyUserId=$row['user_id'];
  1419. }
  1420. if($KeyAssignment==1)
  1421. {
  1422. $icon_assignment='<img src="../img/wiki/assignment.gif" title="'.get_lang('AssignmentDescExtra').'" alt="'.get_lang('AssignmentDescExtra').'" />';
  1423. }
  1424. elseif($KeyAssignment==2)
  1425. {
  1426. $icon_assignment='<img src="../img/wiki/works.gif" title="'.get_lang('AssignmentWorkExtra').'" alt="'.get_lang('AssignmentWorkExtra').'" />';
  1427. }
  1428. //Second, show
  1429. //if the page is hidden and is a job only sees its author and professor
  1430. if($KeyVisibility==1 || api_is_allowed_to_edit() || api_is_platform_admin() || ($KeyAssignment==2 && $KeyVisibility==0 && (api_get_user_id()==$KeyUserId)))
  1431. {
  1432. // We show the complete history
  1433. if (!$_POST['HistoryDifferences'] && !$_POST['HistoryDifferences2'] )
  1434. {
  1435. $sql='SELECT * FROM '.$tbl_wiki.'WHERE reflink="'.html_entity_decode(Database::escape_string(stripslashes(urldecode($page)))).'" AND '.$groupfilter.' ORDER BY id DESC';
  1436. $result=Database::query($sql,__LINE__,__FILE__);
  1437. $title = Security::remove_XSS($_GET['title']);
  1438. $group_id = Security::remove_XSS($_GET['group_id']);
  1439. echo '<div id="wikititle">';
  1440. echo $icon_assignment.'&nbsp;&nbsp;&nbsp;'.$KeyTitle;
  1441. echo '</div>';
  1442. echo '<div id="wikicontent">';
  1443. echo '<form id="differences" method="POST" action="index.php?cidReq='.$_course[id].'&action=history&title='.$title.'&group_id='.$group_id.'">';
  1444. echo '<ul style="list-style-type: none;">';
  1445. echo '<br/>';
  1446. echo '<button class="search" type="submit" name="HistoryDifferences" value="HistoryDifferences">'.get_lang('ShowDifferences').' '.get_lang('LinesDiff').'</button>';
  1447. echo '<button class="search" type="submit" name="HistoryDifferences2" value="HistoryDifferences2">'.get_lang('ShowDifferences').' '.get_lang('WordsDiff').'</button>';
  1448. echo '<br/><br/>';
  1449. $counter=0;
  1450. $total_versions=Database::num_rows($result);
  1451. while ($row=Database::fetch_array($result))
  1452. {
  1453. $userinfo=Database::get_user_info_from_id($row['user_id']);
  1454. $year = substr($row['dtime'], 0, 4);
  1455. $month = substr($row['dtime'], 5, 2);
  1456. $day = substr($row['dtime'], 8, 2);
  1457. $hours=substr($row['dtime'], 11,2);
  1458. $minutes=substr($row['dtime'], 14,2);
  1459. $seconds=substr($row['dtime'], 17,2);
  1460. echo '<li style="margin-bottom: 5px;">';
  1461. ($counter==0) ? $oldstyle='style="visibility: hidden;"':$oldstyle='';
  1462. ($counter==0) ? $newchecked=' checked':$newchecked='';
  1463. ($counter==$total_versions-1) ? $newstyle='style="visibility: hidden;"':$newstyle='';
  1464. ($counter==1) ? $oldchecked=' checked':$oldchecked='';
  1465. echo '<input name="old" value="'.$row['id'].'" type="radio" '.$oldstyle.' '.$oldchecked.'/> ';
  1466. echo '<input name="new" value="'.$row['id'].'" type="radio" '.$newstyle.' '.$newchecked.'/> ';
  1467. echo '<a href="'.api_get_self().'?action=showpage&amp;title='.$page.'&amp;view='.$row['id'].'">';
  1468. echo '<a href="'.api_get_self().'?cidReq='.$_course[id].'&action=showpage&amp;title='.$page.'&amp;view='.$row['id'].'&group_id='.$group_id.'">';
  1469. echo $year.'-'.$month.'-'.$day.' '.$hours.":".$minutes.":".$seconds;
  1470. echo '</a>';
  1471. echo ' ('.get_lang('Version').' '.$row['version'].')';
  1472. echo ' '.get_lang('By').' ';
  1473. if ($row['user_id']<>0)
  1474. {
  1475. echo '<a href="../user/userInfo.php?uInfo='.$userinfo['user_id'].'">'.api_get_person_name($userinfo['firstname'], $userinfo['lastname']).'</a>';
  1476. }
  1477. else
  1478. {
  1479. echo get_lang('Anonymous').' ('.$row[user_ip].')';
  1480. }
  1481. echo ' ( '.get_lang('Progress').': '.$row['progress'].'%, ';
  1482. $comment=$row['comment'];
  1483. if (!empty($comment))
  1484. {
  1485. echo get_lang('Comments').': '.api_substr(api_htmlentities($row['comment'], ENT_QUOTES, $charset),0,100);
  1486. if (api_strlen($row['comment'])>100)
  1487. {
  1488. echo '... ';
  1489. }
  1490. }
  1491. else
  1492. {
  1493. echo get_lang('Comments').': ---';
  1494. }
  1495. echo ' ) </li>';
  1496. $counter++;
  1497. } //end while
  1498. echo '<br/>';
  1499. echo '<button class="search" type="submit" name="HistoryDifferences" value="HistoryDifferences">'.get_lang('ShowDifferences').' '.get_lang('LinesDiff').'</button>';
  1500. echo '<button class="search" type="submit" name="HistoryDifferences2" value="HistoryDifferences2">'.get_lang('ShowDifferences').' '.get_lang('WordsDiff').'</button>';
  1501. echo '</ul></form></div>';
  1502. }
  1503. // We show the differences between two versions
  1504. else
  1505. {
  1506. $sql_old="SELECT * FROM $tbl_wiki WHERE id='".Database::escape_string($_POST['old'])."'";
  1507. $result_old=Database::query($sql_old,__LINE__,__FILE__);
  1508. $version_old=Database::fetch_array($result_old);
  1509. $sql_new="SELECT * FROM $tbl_wiki WHERE id='".Database::escape_string($_POST['new'])."'";
  1510. $result_new=Database::query($sql_new,__LINE__,__FILE__);
  1511. $version_new=Database::fetch_array($result_new);
  1512. if(isset($_POST['HistoryDifferences']))
  1513. {
  1514. include('diff.inc.php');
  1515. //title
  1516. echo '<div id="wikititle">'.stripslashes($version_new['title']).' <font size="-2"><i>('.get_lang('DifferencesNew').'</i> <font style="background-color:#aaaaaa">'.stripslashes($version_new['dtime']).'</font> <i>'.get_lang('DifferencesOld').'</i> <font style="background-color:#aaaaaa">'.stripslashes($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>';
  1517. }
  1518. if(isset($_POST['HistoryDifferences2']))
  1519. {
  1520. require_once 'Text/Diff.php';
  1521. require_once 'Text/Diff/Renderer/inline.php';
  1522. //title
  1523. echo '<div id="wikititle">'.stripslashes($version_new['title']).' <font size="-2"><i>('.get_lang('DifferencesNew').'</i> <font style="background-color:#aaaaaa">'.stripslashes($version_new['dtime']).'</font> <i>'.get_lang('DifferencesOld').'</i> <font style="background-color:#aaaaaa">'.stripslashes($version_old['dtime']).'</font>) '.get_lang('Legend').': <span class="diffAddedTex" >'.get_lang(WikiDiffAddedTex).'</span> <span class="diffDeletedTex" >'.get_lang(WikiDiffDeletedTex).'</span></font></div>';
  1524. }
  1525. echo '<div class="diff"><br /><br />';
  1526. if(isset($_POST['HistoryDifferences']))
  1527. {
  1528. echo '<table>'.diff( stripslashes($version_old['content']), stripslashes($version_new['content']), true, 'format_table_line' ).'</table>'; // format_line mode is better for words
  1529. echo '</div>';
  1530. echo '<br />';
  1531. echo '<strong>'.get_lang('Legend').'</strong><div class="diff">' . "\n";
  1532. echo '<table><tr>';
  1533. echo '<td>';
  1534. echo '</td><td>';
  1535. echo '<span class="diffEqual" >'.get_lang('WikiDiffUnchangedLine').'</span><br />';
  1536. echo '<span class="diffAdded" >'.get_lang('WikiDiffAddedLine').'</span><br />';
  1537. echo '<span class="diffDeleted" >'.get_lang('WikiDiffDeletedLine').'</span><br />';
  1538. echo '<span class="diffMoved" >'.get_lang('WikiDiffMovedLine').'</span><br />';
  1539. echo '</td>';
  1540. echo '</tr></table>';
  1541. echo '</div>';
  1542. }
  1543. if(isset($_POST['HistoryDifferences2']))
  1544. {
  1545. $lines1 = array(strip_tags($version_old['content'])); //without <> tags
  1546. $lines2 = array(strip_tags($version_new['content'])); //without <> tags
  1547. $diff = &new Text_Diff($lines1, $lines2);
  1548. $renderer = &new Text_Diff_Renderer_inline();
  1549. echo '<style>del{background:#fcc}ins{background:#cfc}</style>'.$renderer->render($diff); // Code inline
  1550. //echo '<div class="diffEqual">'.html_entity_decode($renderer->render($diff)).'</div>'; // Html inline. By now, turned off by problems in comparing pages separated by more than one version
  1551. echo '</div>';
  1552. echo '<br />';
  1553. echo '<strong>'.get_lang('Legend').'</strong><div class="diff">' . "\n";
  1554. echo '<table><tr>';
  1555. echo '<td>';
  1556. echo '</td><td>';
  1557. echo '<span class="diffAddedTex" >'.get_lang('WikiDiffAddedTex').'</span><br />';
  1558. echo '<span class="diffDeletedTex" >'.get_lang('WikiDiffDeletedTex').'</span><br />';
  1559. echo '</td>';
  1560. echo '</tr></table>';
  1561. echo '</div>';
  1562. }
  1563. }
  1564. }
  1565. echo '</div>';
  1566. }
  1567. /////////////////////// recent changes ///////////////////////
  1568. //
  1569. //rss feed. TODO:
  1570. //
  1571. if ($_GET['action']=='recentchanges')
  1572. {
  1573. $_clean['group_id']=(int)$_SESSION['_gid'];
  1574. if (check_notify_all())
  1575. {
  1576. $notify_all= '<a href="index.php?action=recentchanges&amp;actionpage=notify_all&amp;title='.$page.'"><img src="../img/wiki/send_mail_checked.gif" title="'.get_lang('FullNotifyByEmail').'" alt="'.get_lang('FullNotifyByEmail').'" style="vertical-align:middle;" />'.get_lang('NotNotifyChanges').'</a>';
  1577. }
  1578. else
  1579. {
  1580. $notify_all= '<a href="index.php?action=recentchanges&amp;actionpage=notify_all&amp;title='.$page.'"><img src="../img/wiki/send_mail.gif" title="'.get_lang('FullCancelNotifyByEmail').'" alt="'.get_lang('FullCancelNotifyByEmail').'" style="vertical-align:middle;"/>'.get_lang('NotifyChanges').'</a>';
  1581. }
  1582. echo '<div class="actions"><span style="float: right;">'.$notify_all.'</span>'.get_lang('RecentChanges').'</div>';
  1583. if(api_is_allowed_to_edit() || api_is_platform_admin()) //only by professors if page is hidden
  1584. {
  1585. //$sql='SELECT * FROM '.$tbl_wiki.' WHERE '.$groupfilter.' ORDER BY dtime DESC'; // old version TODO: Replace by the bottom line
  1586. $sql='SELECT * FROM '.$tbl_wiki.', '.$tbl_wiki_conf.' WHERE '.$tbl_wiki_conf.'.page_id='.$tbl_wiki.'.page_id AND '.$tbl_wiki.'.'.$groupfilter.' ORDER BY dtime DESC'; // new version
  1587. }
  1588. else
  1589. {
  1590. $sql='SELECT * FROM '.$tbl_wiki.' WHERE '.$groupfilter.' AND visibility=1 ORDER BY dtime DESC'; // old version TODO: Replace by the bottom line
  1591. //$sql='SELECT * FROM '.$tbl_wiki.', '.$tbl_wiki_conf.' WHERE '.$tbl_wiki_conf.'.page_id='.$tbl_wiki.'.page_id AND visibility=1 AND '.$tbl_wiki.'.'.$groupfilter.' ORDER BY dtime DESC'; // new version
  1592. }
  1593. $allpages=Database::query($sql,__LINE__,__FILE__);
  1594. //show table
  1595. if (mysql_num_rows($allpages) > 0)
  1596. {
  1597. $row = array ();
  1598. while ($obj = mysql_fetch_object($allpages))
  1599. {
  1600. //get author
  1601. $userinfo=Database::get_user_info_from_id($obj->user_id);
  1602. //get time
  1603. $year = substr($obj->dtime, 0, 4);
  1604. $month = substr($obj->dtime, 5, 2);
  1605. $day = substr($obj->dtime, 8, 2);
  1606. $hours = substr($obj->dtime, 11,2);
  1607. $minutes = substr($obj->dtime, 14,2);
  1608. $seconds = substr($obj->dtime, 17,2);
  1609. //get type assignment icon
  1610. if($obj->assignment==1)
  1611. {
  1612. $ShowAssignment='<img src="../img/wiki/assignment.gif" title="'.get_lang('AssignmentDesc').'" alt="'.get_lang('AssignmentDesc').'" />';
  1613. }
  1614. elseif ($obj->assignment==2)
  1615. {
  1616. $ShowAssignment='<img src="../img/wiki/works.gif" title="'.get_lang('AssignmentWork').'" alt="'.get_lang('AssignmentWork').'" />';
  1617. }
  1618. elseif ($obj->assignment==0)
  1619. {
  1620. $ShowAssignment='<img src="../img/wiki/trans.gif" />';
  1621. }
  1622. //get icon task
  1623. if (!empty($obj->task))
  1624. {
  1625. $icon_task='<img src="../img/wiki/task.gif" title="'.get_lang('StandardTask').'" alt="'.get_lang('StandardTask').'" />';
  1626. }
  1627. else
  1628. {
  1629. $icon_task='<img src="../img/wiki/trans.gif" />';
  1630. }
  1631. $row = array ();
  1632. $row[] = $year.'-'.$month.'-'.$day.' '.$hours.':'.$minutes.":".$seconds;
  1633. $row[] = $ShowAssignment.$icon_task;
  1634. $row[] = '<a href="'.api_get_self().'?cidReq='.$_course[id].'&action=showpage&title='.urlencode($obj->reflink).'&amp;view='.$obj->id.'&group_id='.Security::remove_XSS($_GET['group_id']).'">'.$obj->title.'</a>';
  1635. $row[] = $obj->version>1 ? get_lang('EditedBy') : get_lang('AddedBy');
  1636. $row[] = $obj->user_id <>0 ? '<a href="../user/userInfo.php?uInfo='.$userinfo['user_id'].'">'.api_get_person_name($userinfo['firstname'], $userinfo['lastname']).'</a>' : get_lang('Anonymous').' ('.$obj->user_ip.')';
  1637. $rows[] = $row;
  1638. }
  1639. $table = new SortableTableFromArrayConfig($rows,0,10,'RecentPages_table','','','DESC');
  1640. $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'])));
  1641. $table->set_header(0,get_lang('Date'), true, array ('style' => 'width:200px;'));
  1642. $table->set_header(1,get_lang('Type'), true, array ('style' => 'width:30px;'));
  1643. $table->set_header(2,get_lang('Title'), true);
  1644. $table->set_header(3,get_lang('Actions'), true, array ('style' => 'width:80px;'));
  1645. $table->set_header(4,get_lang('Author'), true);
  1646. $table->display();
  1647. }
  1648. }
  1649. /////////////////////// all pages ///////////////////////
  1650. if ($_GET['action']=='allpages')
  1651. {
  1652. echo '<div class="actions">'.get_lang('AllPages').'</div>';
  1653. $_clean['group_id']=(int)$_SESSION['_gid'];
  1654. if(api_is_allowed_to_edit() || api_is_platform_admin()) //only by professors if page is hidden
  1655. {
  1656. //$sql='SELECT * FROM '.$tbl_wiki.' s1 WHERE id=(SELECT MAX(s2.id) FROM '.$tbl_wiki.' s2 WHERE s1.reflink = s2.reflink AND '.$groupfilter.')'; // warning don't use group by reflink because don't return the last version// old version TODO: Replace by the bottom line
  1657. $sql='SELECT * FROM '.$tbl_wiki.', '.$tbl_wiki_conf.' WHERE '.$tbl_wiki_conf.'.page_id='.$tbl_wiki.'.page_id AND '.$tbl_wiki.'.'.$groupfilter.' GROUP BY '.$tbl_wiki.'.page_id'; // new version
  1658. }
  1659. else
  1660. {
  1661. //$sql='SELECT * FROM '.$tbl_wiki.' s1 WHERE visibility=1 AND id=(SELECT MAX(s2.id) FROM '.$tbl_wiki.' s2 WHERE s1.reflink = s2.reflink AND '.$groupfilter.')'; // warning don't use group by reflink because don't return the last version // old version TODO: Replace by the bottom line
  1662. $sql='SELECT * FROM '.$tbl_wiki.', '.$tbl_wiki_conf.' WHERE visibility=1 AND '.$tbl_wiki_conf.'.page_id='.$tbl_wiki.'.page_id AND '.$tbl_wiki.'.'.$groupfilter.' GROUP BY '.$tbl_wiki.'.page_id'; // new version
  1663. }
  1664. $allpages=Database::query($sql,__LINE__,__FILE__);
  1665. //show table
  1666. if (mysql_num_rows($allpages) > 0)
  1667. {
  1668. $row = array ();
  1669. while ($obj = mysql_fetch_object($allpages))
  1670. {
  1671. //get author
  1672. $userinfo=Database::get_user_info_from_id($obj->user_id);
  1673. //get time
  1674. $year = substr($obj->dtime, 0, 4);
  1675. $month = substr($obj->dtime, 5, 2);
  1676. $day = substr($obj->dtime, 8, 2);
  1677. $hours = substr($obj->dtime, 11,2);
  1678. $minutes = substr($obj->dtime, 14,2);
  1679. $seconds = substr($obj->dtime, 17,2);
  1680. //get type assignment icon
  1681. if($obj->assignment==1)
  1682. {
  1683. $ShowAssignment='<img src="../img/wiki/assignment.gif" title="'.get_lang('AssignmentDesc').'" alt="'.get_lang('AssignmentDesc').'" />';
  1684. }
  1685. elseif ($obj->assignment==2)
  1686. {
  1687. $ShowAssignment='<img src="../img/wiki/works.gif" title="'.get_lang('AssignmentWork').'" alt="'.get_lang('AssignmentWork').'" />';
  1688. }
  1689. elseif ($obj->assignment==0)
  1690. {
  1691. $ShowAssignment='<img src="../img/wiki/trans.gif" />';
  1692. }
  1693. //get icon task
  1694. if (!empty($obj->task))
  1695. {
  1696. $icon_task='<img src="../img/wiki/task.gif" title="'.get_lang('StandardTask').'" alt="'.get_lang('StandardTask').'" />';
  1697. }
  1698. else
  1699. {
  1700. $icon_task='<img src="../img/wiki/trans.gif" />';
  1701. }
  1702. $row = array ();
  1703. $row[] =$ShowAssignment.$icon_task;
  1704. $row[] = '<a href="'.api_get_self().'?cidReq='.$_course[id].'&action=showpage&title='.urlencode(Security::remove_XSS($obj->reflink)).'&group_id='.Security::remove_XSS($_GET['group_id']).'">'.Security::remove_XSS($obj->title).'</a>';
  1705. $row[] = $obj->user_id <>0 ? '<a href="../user/userInfo.php?uInfo='.$userinfo['user_id'].'">'.api_get_person_name($userinfo['firstname'], $userinfo['lastname']).'</a>' : get_lang('Anonymous').' ('.$obj->user_ip.')';
  1706. $row[] = $year.'-'.$month.'-'.$day.' '.$hours.":".$minutes.":".$seconds;
  1707. if(api_is_allowed_to_edit()|| api_is_platform_admin())
  1708. {
  1709. $showdelete=' <a href="'.api_get_self().'?cidReq='.$_course[id].'&action=delete&title='.urlencode(Security::remove_XSS($obj->reflink)).'&group_id='.Security::remove_XSS($_GET['group_id']).'"><img src="../img/delete.gif" title="'.get_lang('Delete').'" alt="'.get_lang('Delete').'" />';
  1710. }
  1711. $row[] = '<a href="'.api_get_self().'?cidReq='.$_course[id].'&action=edit&title='.urlencode(Security::remove_XSS($obj->reflink)).'&group_id='.Security::remove_XSS($_GET['group_id']).'"><img src="../img/lp_quiz.png" title="'.get_lang('EditPage').'" alt="'.get_lang('EditPage').'" /></a> <a href="'.api_get_self().'?cidReq='.$_course[id].'&action=discuss&title='.urlencode(Security::remove_XSS($obj->reflink)).'&group_id='.Security::remove_XSS($_GET['group_id']).'"><img src="../img/comment_bubble.gif" title="'.get_lang('Discuss').'" alt="'.get_lang('Discuss').'" /></a> <a href="'.api_get_self().'?cidReq='.$_course[id].'&action=history&title='.urlencode(Security::remove_XSS($obj->reflink)).'&group_id='.Security::remove_XSS($_GET['group_id']).'"><img src="../img/history.gif" title="'.get_lang('History').'" alt="'.get_lang('History').'" /></a> <a href="'.api_get_self().'?cidReq='.$_course[id].'&action=links&title='.urlencode(Security::remove_XSS($obj->reflink)).'&group_id='.Security::remove_XSS($_GET['group_id']).'"><img src="../img/lp_link.png" title="'.get_lang('LinksPages').'" alt="'.get_lang('LinksPages').'" /></a>'.$showdelete;
  1712. $rows[] = $row;
  1713. }
  1714. $table = new SortableTableFromArrayConfig($rows,1,10,'AllPages_table','','','ASC');
  1715. $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'])));
  1716. $table->set_header(0,get_lang('Type'), true, array ('style' => 'width:30px;'));
  1717. $table->set_header(1,get_lang('Title'), true);
  1718. $table->set_header(2,get_lang('Author').' ('.get_lang('LastVersion').')', true);
  1719. $table->set_header(3,get_lang('Date').' ('.get_lang('LastVersion').')', true);
  1720. $table->set_header(4,get_lang('Actions'), true, array ('style' => 'width:100px;'));
  1721. $table->display();
  1722. }
  1723. }
  1724. /////////////////////// discuss pages ///////////////////////
  1725. if ($_GET['action']=='discuss')
  1726. {
  1727. if (!$_GET['title'])
  1728. {
  1729. Display::display_error_message(get_lang("MustSelectPage"));
  1730. exit;
  1731. }
  1732. //first extract the date of last version
  1733. $sql='SELECT * FROM '.$tbl_wiki.'WHERE reflink="'.html_entity_decode(Database::escape_string(stripslashes(urldecode($page)))).'" AND '.$groupfilter.' ORDER BY id DESC';
  1734. $result=Database::query($sql,__LINE__,__FILE__);
  1735. $row=Database::fetch_array($result);
  1736. $lastversiondate=$row['dtime'];
  1737. $lastuserinfo=Database::get_user_info_from_id($row['user_id']);
  1738. //select page to discuss
  1739. $sql='SELECT * FROM '.$tbl_wiki.'WHERE reflink="'.html_entity_decode(Database::escape_string(stripslashes(urldecode($page)))).'" AND '.$groupfilter.' ORDER BY id ASC';
  1740. $result=Database::query($sql,__LINE__,__FILE__);
  1741. $row=Database::fetch_array($result);
  1742. $id=$row['id'];
  1743. $firstuserid=$row['user_id'];
  1744. //mode assignment: previous to show page type
  1745. if(stripslashes($row['assignment'])==1)
  1746. {
  1747. $icon_assignment='<img src="../img/wiki/assignment.gif" title="'.get_lang('AssignmentDescExtra').'" alt="'.get_lang('AssignmentDescExtra').'" />';
  1748. }
  1749. elseif(stripslashes($row['assignment'])==2)
  1750. {
  1751. $icon_assignment='<img src="../img/wiki/works.gif" title="'.get_lang('AssignmentWorkExtra').'" alt="'.get_lang('AssignmentWorkExtra').'" />';
  1752. }
  1753. //Show title and form to discuss if page exist
  1754. if ($id!='')
  1755. {
  1756. //Show discussion to students if isn't hidden. Show page to all teachers if is hidden. Mode assignments: If is hidden, show pages to student only if student is the author
  1757. if($row['visibility_disc']==1 || api_is_allowed_to_edit() || api_is_platform_admin() || ($row['assignment']==2 && $row['visibility_disc']==0 && (api_get_user_id()==$row['user_id'])))
  1758. {
  1759. echo '<div id="wikititle">';
  1760. // discussion action: protecting (locking) the discussion
  1761. if (check_addlock_discuss())
  1762. {
  1763. if(api_is_allowed_to_edit() || api_is_platform_admin())
  1764. {
  1765. $addlock_disc= '<img src="../img/wiki/lock.gif" title="'.get_lang('LockDiscussExtra').'" alt="'.get_lang('LockDiscussExtra').'" />';
  1766. }
  1767. else
  1768. {
  1769. $addlock_disc= '<img src="../img/wiki/lock.gif" title="'.get_lang('LockDiscussExtra').'" alt="'.get_lang('LockDiscussExtra').'" />';
  1770. }
  1771. }
  1772. else
  1773. {
  1774. if(api_is_allowed_to_edit() || api_is_platform_admin())
  1775. {
  1776. $addlock_disc= '<img src="../img/wiki/unlock.gif" title="'.get_lang('UnlockDiscussExtra').'" alt="'.get_lang('UnlockDiscussExtra').'" />';
  1777. }
  1778. }
  1779. echo '<span style="float:right">';
  1780. echo '<a href="index.php?action=discuss&amp;actionpage=addlock_disc&amp;title='.$page.'">'.$addlock_disc.'</a>';
  1781. echo '</span>';
  1782. // discussion action: visibility. Show discussion to students if isn't hidden. Show page to all teachers if is hidden.
  1783. if (check_visibility_discuss())
  1784. {
  1785. //Mode assignments: If is hidden, show pages to student only if student is the author
  1786. if(($row['assignment']==2 && $row['visibility_disc']==0 && (api_get_user_id()==$row['user_id']))==false)
  1787. {
  1788. $visibility_disc= '<img src="../img/wiki/invisible.gif" title="'.get_lang('HideDiscussExtra').'" alt="'.get_lang('HideDiscussExtra').'" />';
  1789. }
  1790. }
  1791. else
  1792. {
  1793. if(api_is_allowed_to_edit() || api_is_platform_admin())
  1794. {
  1795. $visibility_disc= '<img src="../img/wiki/visible.gif" title="'.get_lang('ShowDiscussExtra').'" alt="'.get_lang('ShowDiscussExtra').'" />';
  1796. }
  1797. }
  1798. echo '<span style="float:right">';
  1799. echo '<a href="index.php?action=discuss&amp;actionpage=visibility_disc&amp;title='.$page.'">'.$visibility_disc.'</a>';
  1800. echo '</span>';
  1801. //discussion action: check add rating lock. Show/Hide list to rating for all student
  1802. if (check_ratinglock_discuss())
  1803. {
  1804. //Mode assignment: only the teacher can assign scoring
  1805. if(($row['assignment']==2 && $row['ratinglock_disc']==0 && (api_get_user_id()==$row['user_id']))==false)
  1806. {
  1807. $ratinglock_disc= '<img src="../img/wiki/rating_na.gif" title="'.get_lang('LockRatingDiscussExtra').'" alt="'.get_lang('LockRatingDiscussExtra').'" />';
  1808. }
  1809. }
  1810. else
  1811. {
  1812. if(api_is_allowed_to_edit() || api_is_platform_admin())
  1813. {
  1814. $ratinglock_disc= '<img src="../img/wiki/rating.gif" title="'.get_lang('UnlockRatingDiscussExtra').'" alt="'.get_lang('UnlockRatingDiscussExtra').'" />';
  1815. }
  1816. }
  1817. echo '<span style="float:right">';
  1818. echo '<a href="index.php?action=discuss&amp;actionpage=ratinglock_disc&amp;title='.$page.'">'.$ratinglock_disc.'</a>';
  1819. echo '</span>';
  1820. //discussion action: email notification
  1821. if (check_notify_discuss($page))
  1822. {
  1823. $notify_disc= '<img src="../img/wiki/send_mail_checked.gif" title="'.get_lang('NotifyDiscussByEmail').'" alt="'.get_lang('NotifyDiscussByEmail').'" />';
  1824. }
  1825. else
  1826. {
  1827. $notify_disc= '<img src="../img/wiki/send_mail.gif" title="'.get_lang('CancelNotifyDiscussByEmail').'" alt="'.get_lang('CancelNotifyDiscussByEmail').'" />';
  1828. }
  1829. echo '<span style="float:right">';
  1830. echo '<a href="index.php?action=discuss&amp;actionpage=notify_disc&amp;title='.$page.'">'.$notify_disc.'</a>';
  1831. echo '</span>';
  1832. echo $icon_assignment.'&nbsp;&nbsp;&nbsp;'.$row['title'];
  1833. echo ' ('.get_lang('MostRecentVersionBy').' <a href="../user/userInfo.php?uInfo='.$lastuserinfo['user_id'].'">'.api_get_person_name($lastuserinfo['firstname'], $lastuserinfo['lastname']).'</a> '.$lastversiondate.$countWPost.')'.$avg_WPost_score.' '; //TODO: read avg score
  1834. echo '</div>';
  1835. if($row['addlock_disc']==1 || api_is_allowed_to_edit() || api_is_platform_admin()) //show comments but students can't add theirs
  1836. {
  1837. ?>
  1838. <form name="form1" method="post" action="">
  1839. <table>
  1840. <tr>
  1841. <td valign="top" ><?php echo get_lang('Comments');?>:</td>
  1842. <?php echo '<input type="hidden" name="wpost_id" value="'.md5(uniqid(rand(), true)).'">';//prevent double post ?>
  1843. <td><textarea name="comment" cols="80" rows="5" id="comment"></textarea></td>
  1844. </tr>
  1845. <tr>
  1846. <?php
  1847. //check if rating is allowed
  1848. if($row['ratinglock_disc']==1 || api_is_allowed_to_edit() || api_is_platform_admin())
  1849. {
  1850. ?>
  1851. <td><?php echo get_lang('Rating');?>: </td>
  1852. <td valign="top"><select name="rating" id="rating">
  1853. <option value="-" selected>-</option>
  1854. <option value="0">0</option>
  1855. <option value="1">1</option>
  1856. <option value="2">2</option>
  1857. <option value="3">3</option>
  1858. <option value="4">4</option>
  1859. <option value="5">5</option>
  1860. <option value="6">6</option>
  1861. <option value="7">7</option>
  1862. <option value="8">8</option>
  1863. <option value="9">9</option>
  1864. <option value="10">10</option>
  1865. </select></td>
  1866. <?php
  1867. }
  1868. else
  1869. {
  1870. echo '<input type=hidden name="rating" value="-">';// must pass a default value to avoid rate automatically
  1871. }
  1872. ?>
  1873. </tr>
  1874. <tr>
  1875. <td>&nbsp;</td>
  1876. <td> <?php echo '<button class="save" type="submit" name="Submit"> '.get_lang('Send').'</button>'; ?></td>
  1877. </tr>
  1878. </table>
  1879. </form>
  1880. <?php
  1881. if (isset($_POST['Submit']) && double_post($_POST['wpost_id']))
  1882. {
  1883. $dtime = date( "Y-m-d H:i:s" );
  1884. $message_author=api_get_user_id();
  1885. $sql="INSERT INTO $tbl_wiki_discuss (publication_id, userc_id, comment, p_score, dtime) VALUES ('".$id."','".$message_author."','".$_POST['comment']."','".$_POST['rating']."','".$dtime."')";
  1886. $result=Database::query($sql,__FILE__,__LINE__) or die(mysql_error());
  1887. check_emailcue($id, 'D', $dtime, $message_author);
  1888. }
  1889. }//end discuss lock
  1890. echo '<hr noshade size="1">';
  1891. $user_table = Database :: get_main_table(TABLE_MAIN_USER);
  1892. $sql="SELECT * FROM $tbl_wiki_discuss reviews, $user_table user WHERE reviews.publication_id='".$id."' AND user.user_id='".$firstuserid."' ORDER BY id DESC";
  1893. $result=Database::query($sql,__FILE__,__LINE__) or die(mysql_error());
  1894. $countWPost = Database::num_rows($result);
  1895. echo get_lang('NumComments').": ".$countWPost; //comment's numbers
  1896. $sql="SELECT SUM(p_score) as sumWPost FROM $tbl_wiki_discuss WHERE publication_id='".$id."' AND NOT p_score='-' ORDER BY id DESC";
  1897. $result2=Database::query($sql,__FILE__,__LINE__) or die(mysql_error());
  1898. $row2=Database::fetch_array($result2);
  1899. $sql="SELECT * FROM $tbl_wiki_discuss WHERE publication_id='".$id."' AND NOT p_score='-'";
  1900. $result3=Database::query($sql,__FILE__,__LINE__) or die(mysql_error());
  1901. $countWPost_score= Database::num_rows($result3);
  1902. echo ' - '.get_lang('NumCommentsScore').': '.$countWPost_score;//
  1903. if ($countWPost_score!=0)
  1904. {
  1905. $avg_WPost_score = round($row2['sumWPost'] / $countWPost_score,2).' / 10';
  1906. }
  1907. else
  1908. {
  1909. $avg_WPost_score = $countWPost_score;
  1910. }
  1911. echo ' - '.get_lang('RatingMedia').': '.$avg_WPost_score; // average rating
  1912. $sql='UPDATE '.$tbl_wiki.' SET score="'.Database::escape_string($avg_WPost_score).'" WHERE reflink="'.html_entity_decode(Database::escape_string(stripslashes(urldecode($page)))).'" AND '.$groupfilter; // check if work ok. TODO:
  1913. Database::query($sql,__FILE__,__LINE__);
  1914. echo '<hr noshade size="1">';
  1915. //echo '<div style="overflow:auto; height:170px;">';
  1916. while ($row=Database::fetch_array($result))
  1917. {
  1918. $userinfo=Database::get_user_info_from_id($row['userc_id']);
  1919. if (($userinfo['status'])=="5")
  1920. {
  1921. $author_status=get_lang('Student');
  1922. }
  1923. else
  1924. {
  1925. $author_status=get_lang('Teacher');
  1926. }
  1927. require_once api_get_path(INCLUDE_PATH).'/lib/usermanager.lib.php';
  1928. $user_id=$row['userc_id'];
  1929. $name = api_get_person_name($userinfo['firstname'], $userinfo['lastname']);
  1930. $attrb=array();
  1931. if ($user_id<>0)
  1932. {
  1933. $image_path = UserManager::get_user_picture_path_by_id($user_id,'web',false, true);
  1934. $image_repository = $image_path['dir'];
  1935. $existing_image = $image_path['file'];
  1936. $author_photo= '<img src="'.$image_repository.$existing_image.'" alt="'.$name.'" width="40" height="50" align="top" title="'.$name.'" />';
  1937. }
  1938. else
  1939. {
  1940. $author_photo= '<img src="'.api_get_path(WEB_CODE_PATH)."img/unknown.jpg".'" alt="'.$name.'" width="40" height="50" align="top" title="'.$name.'" />';
  1941. }
  1942. //stars
  1943. $p_score=$row['p_score'];
  1944. switch($p_score){
  1945. case 0:
  1946. $imagerating='<img src="../img/wiki/rating/stars_0.gif"/>';
  1947. break;
  1948. case 1:
  1949. $imagerating='<img src="../img/wiki/rating/stars_5.gif"/>';
  1950. break;
  1951. case 2:
  1952. $imagerating='<img src="../img/wiki/rating/stars_10.gif"/>';
  1953. break;
  1954. case 3:
  1955. $imagerating='<img src="../img/wiki/rating/stars_15.gif"/>';
  1956. break;
  1957. case 4:
  1958. $imagerating='<img src="../img/wiki/rating/stars_20.gif"/>';
  1959. break;
  1960. case 5:
  1961. $imagerating='<img src="../img/wiki/rating/stars_25.gif"/>';
  1962. break;
  1963. case 6:
  1964. $imagerating='<img src="../img/wiki/rating/stars_30.gif"/>';
  1965. break;
  1966. case 7:
  1967. $imagerating='<img src="../img/wiki/rating/stars_35.gif"/>';
  1968. break;
  1969. case 8:
  1970. $imagerating='<img src="../img/wiki/rating/stars_40.gif"/>';
  1971. break;
  1972. case 9:
  1973. $imagerating='<img src="../img/wiki/rating/stars_45.gif"/>';
  1974. break;
  1975. case 10:
  1976. $imagerating='<img src="../img/wiki/rating/stars_50.gif"/>';
  1977. break;
  1978. }
  1979. echo '<p><table>';
  1980. echo '<tr>';
  1981. echo '<td rowspan="2">'.$author_photo.'</td>';
  1982. echo '<td style=" color:#999999"><a href="../user/userInfo.php?uInfo='.$userinfo['user_id'].'">'.api_get_person_name($userinfo['firstname'], $userinfo['lastname']).'</a> ('.$author_status.') '.$row['dtime'].' - '.get_lang('Rating').': '.$row['p_score'].' '.$imagerating.' </td>';
  1983. echo '</tr>';
  1984. echo '<tr>';
  1985. echo '<td>'.$row['comment'].'</td>';
  1986. echo '</tr>';
  1987. echo "</table>";
  1988. echo '<hr noshade size="1">';
  1989. }
  1990. // echo"</div>";
  1991. }
  1992. else
  1993. {
  1994. Display::display_warning_message(get_lang('LockByTeacher'),false);
  1995. }
  1996. }
  1997. else
  1998. {
  1999. Display::display_normal_message(get_lang('DiscussNotAvailable'));
  2000. }
  2001. }
  2002. echo "</div>"; // echo "<div id='mainwiki'>";
  2003. echo "</div>"; // echo "<div id='wikiwrapper'>";
  2004. /*
  2005. ==============================================================================
  2006. FOOTER
  2007. ==============================================================================
  2008. */
  2009. //$_SESSION['_gid'];
  2010. Display::display_footer();
  2011. ?>