Dokeos PHP Cross Reference Learning Management Systems

Source: /main/resourcelinker/resourcelinker.php - 1048 lines - 39601 bytes - Summary - Text - Print

   1  <?php
   2  /*
   3  ==============================================================================
   4      Dokeos - elearning and course management software
   5  
   6      Copyright (c) 2004-2005 Dokeos S.A.
   7      Copyright (c) 2003 Ghent University (UGent)
   8      Copyright (c) 2001 Universite catholique de Louvain (UCL)
   9      Copyright (c) Patrick Cool (patrick.cool@ugent.be)
  10      Copyright (c) Denes Nagy
  11  
  12      For a full list of contributors, see "credits.txt".
  13      The full license can be read in "license.txt".
  14  
  15      This program is free software; you can redistribute it and/or
  16      modify it under the terms of the GNU General Public License
  17      as published by the Free Software Foundation; either version 2
  18      of the License, or (at your option) any later version.
  19  
  20      See the GNU General Public License for more details.
  21  
  22      Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
  23  ==============================================================================
  24  */
  25  /**
  26  ==============================================================================
  27  * @author Patrick Cool, original code
  28  * @author Denes Nagy - many bugfixes and improvements, adjusted for learning path
  29  * @author Roan Embrechts - refactoring, code cleaning
  30  * @package dokeos.resourcelinker
  31  * @todo reorganise code,
  32  * use Database API instead of creating table names locally.
  33  ==============================================================================
  34  */
  35  
  36  /*
  37  ==============================================================================
  38          INIT SECTION
  39  ==============================================================================
  40  */
  41  // name of the language file that needs to be included
  42  //$language_file = 'resourcelinker';// TODO: Repeated deleting and moving the rest of this lang file to trad4all
  43  include  ('../inc/global.inc.php');
  44  $this_section=SECTION_COURSES;
  45  
  46  api_protect_course_script();
  47  
  48  /*
  49  -----------------------------------------------------------
  50      Libraries
  51  -----------------------------------------------------------
  52  */
  53  include_once (api_get_path(LIBRARY_PATH)."fileUpload.lib.php");
  54  include  ('resourcelinker.inc.php');
  55  
  56  /*
  57  -----------------------------------------------------------
  58      Constants and variables
  59  -----------------------------------------------------------
  60  */
  61  
  62  $link_table = Database :: get_course_table(TABLE_LINK);
  63  $item_property_table = Database :: get_course_table(TABLE_ITEM_PROPERTY);
  64  
  65  $tbl_learnpath_main = Database :: get_course_table(TABLE_LEARNPATH_MAIN);
  66  $tbl_learnpath_chapter = Database :: get_course_table(TABLE_LEARNPATH_CHAPTER);
  67  $tbl_learnpath_item = Database :: get_course_table(TABLE_LEARNPATH_ITEM);
  68  
  69  $action = $_REQUEST['action'];
  70  $add = $_REQUEST['add'];
  71  $chapter_id = $_REQUEST['chapter_id'];
  72  $content = $_REQUEST['content'];
  73  // Note by Patrick Cool: this has been solved belowd. This piece of code hacking produced too much errors.
  74  /*
  75  if(empty($content)){
  76      //adds a default to the item-type selection
  77      $content = 'Document';
  78  }
  79  */
  80  $folder = $_REQUEST['folder'];
  81  $id = $_REQUEST['id'];
  82  $learnpath_id = $_REQUEST['learnpath_id'];
  83  $originalresource = $_REQUEST['originalresource'];
  84  $show_resources = $_REQUEST['show_resources'];
  85  $source_forum = $_REQUEST['source_forum'];
  86  $source_id = $_REQUEST['source_id'];
  87  $target = $_REQUEST['target'];
  88  $external_link = $_REQUEST['external_link'];
  89  
  90  $from_learnpath = $_SESSION['from_learnpath'];
  91  
  92  // this variable controls wether the link to add a chapter in a module or
  93  // another chapter is shown. This allows to create multi-level learnpaths,
  94  // but export features are not ready for this, yet, so use at your own risks
  95  // default : false -> do not display link
  96  // This setting should be moved to the platform configuration page in time...
  97  $multi_level_learnpath = true;
  98  
  99  /*
 100  ==============================================================================
 101          MAIN CODE
 102  ==============================================================================
 103  */
 104  if ($from_learnpath == 'yes')
 105  {
 106      //start from clear every time in LearnPath Builder
 107      $_SESSION['addedresource'] = null;
 108      $_SESSION['addedresourceid'] = null;
 109      $_SESSION['addedresourceassigned'] = null;
 110      unset ($_SESSION['addedresource']);
 111      unset ($_SESSION['addedresourceid']);
 112      unset ($_SESSION['addedresourceassigned']);
 113  }
 114  
 115  // Process a new chapter?
 116  if (!empty ($_POST['add_chapter']) && !empty ($_POST['title']))
 117  {
 118      $title = $_POST['title'];
 119      $description = '';
 120      if (!empty ($_POST['description']))
 121      {
 122          $description = $_POST['description'];
 123      }
 124  
 125      // get max display_order so far in this parent chapter
 126      $sql = "SELECT MAX(display_order) FROM $tbl_learnpath_chapter WHERE learnpath_id = $learnpath_id "." AND parent_chapter_id = $chapter_id";
 127      $res = Database::query($sql, __FILE__, __LINE__);
 128      $row = Database::fetch_array($res);
 129      $max_temp = $row[0];
 130  
 131      $sql = "SELECT MAX(display_order) FROM $tbl_learnpath_item WHERE "." chapter_id = $chapter_id";
 132      $res = Database::query($sql, __FILE__, __LINE__);
 133      $row = Database::fetch_array($res);
 134      $max_temp2 = $row[0];
 135      if ($max_temp2 > $max_temp)
 136      {
 137          $order = $max_temp2 +1;
 138      }
 139      else
 140      {
 141          $order = $max_temp +1;
 142      }
 143  
 144      $sql = "INSERT INTO $tbl_learnpath_chapter "."(learnpath_id,chapter_name,chapter_description,parent_chapter_id,display_order) "." VALUES "."($learnpath_id, '$title', '$description', $chapter_id, $order )";
 145      $res = Database::query($sql, __FILE__, __LINE__);
 146      if ($res !== false)
 147      {
 148          $title = '';
 149          $description = '';
 150      }
 151  }
 152  
 153  // This if when a external link is submitted
 154  if (!empty ($_POST['external_link_submit']))
 155  {
 156      $add = true;
 157      if ($add_2_links != "niet toevoegen")
 158      {
 159          // add external link to the links table.
 160          $pos = strpos($external_link, 'ttp:');
 161          if ($pos == '')
 162          {
 163              $external_link = 'http://'.$external_link;
 164          }
 165  
 166          $sql = "INSERT INTO $link_table (url, title, category_id) VALUES ('$external_link','$external_link','$add_2_links')";
 167          $result = Database::query($sql, __FILE__, __LINE__);
 168          $addedresource[] = "Link";
 169          $addedresourceid[] = Database::insert_id();
 170          $_SESSION['addedresource'] = $addedresource;
 171          $_SESSION['addedresourceid'] = $addedresourceid;
 172      }
 173      else
 174      {
 175          // do not add external link to the links table
 176          $addedresource[] = "Externallink";
 177          $addedresourceid[] = $external_link;
 178          $_SESSION['addedresource'] = $addedresource;
 179          $_SESSION['addedresourceid'] = $addedresourceid;
 180      }
 181  }
 182  
 183  // loading the session variables into local array
 184  $addedresource = $_SESSION['addedresource'];
 185  $addedresourceid = $_SESSION['addedresourceid'];
 186  
 187  // This is when a resource was added to the session
 188  if ($add)
 189  {
 190      // adding the new variable to the local array
 191      if (empty ($_POST['external_link_submit']))
 192      {
 193          //that case is already arranged, see upwards
 194          $addedresource[] = $content;
 195          $addedresourceid[] = $add;
 196      }
 197      $addedresourceassigned[] = 0;
 198  
 199      // loading the local array into the session variable
 200      $_SESSION['addedresource'] = $addedresource;
 201      $_SESSION['addedresourceid'] = $addedresourceid;
 202  
 203      //---------------------------------------
 204      //we assign to chapters immediately !
 205      //---------------------------------------
 206      $resource_added = false;
 207      if ($from_learnpath == 'yes')
 208      {
 209          $i = 0;
 210          //calculating the last order of the items of this chapter
 211          $sql = "SELECT MAX(display_order) FROM $tbl_learnpath_item WHERE chapter_id=$chapter_id";
 212          $result = Database::query($sql, __FILE__, __LINE__);
 213          if(Database::num_rows($result)==0){
 214              $lastorder_item = 0;
 215          }else{
 216              $row = Database::fetch_array($result);
 217              $lastorder_item = ($row[0]);
 218          }
 219          $sql = "SELECT MAX(display_order) FROM $tbl_learnpath_chapter WHERE parent_chapter_id=$chapter_id";
 220          $result = Database::query($sql, __FILE__, __LINE__);
 221          if(Database::num_rows($result)==0){
 222              $lastorder_chapter = 0;
 223          }else{
 224              $row = Database::fetch_array($result);
 225              $lastorder_chapter = ($row[0]);
 226          }
 227          $lastorder = ($lastorder_chapter>$lastorder_item?$lastorder_chapter+1:$lastorder_item+1);
 228  
 229          foreach ($addedresource as $addedresource_item)
 230          {
 231              // in the case we added a chapter, add this into the chapters list with the correct parent_id
 232              if ($addedresource_item == "Chap")
 233              {
 234                  $sql = "INSERT INTO $tbl_learnpath_chapter ("."'learnpath_id','chapter_name','chapter_description','parent_chapter_id','display_order'".") VALUES (".$learnpath_id.",'".$learnpath_chapter_name."','".$learnpath_chapter_description."',".$chapter_id.",".$lastorder.")";
 235                  Database::query($sql, __FILE__, __LINE__);
 236              }
 237  
 238              if (!$addedresourceassigned[$i])
 239              {
 240                  //not to assign it twice
 241                  if ($addedresource_item == "Ass")
 242                  {
 243                      $addedresource_item = "Assignments";
 244                  }
 245                  if ($addedresource_item == "Drop")
 246                  {
 247                      $addedresource_item = "Dropbox";
 248                  }
 249                  if ($addedresource_item == "Intro")
 250                  {
 251                      $addedresource_item = "Introduction_text";
 252                  }
 253                  if ($addedresource_item == "Course_desc")
 254                  {
 255                      $addedresource_item = "Course_description";
 256                  }
 257                  if ($addedresource_item == "Group")
 258                  {
 259                      $addedresource_item = "Groups";
 260                  }
 261                  if ($addedresource_item == "User")
 262                  {
 263                      $addedresource_item = "Users";
 264                  }
 265                  if ($target == '')
 266                  {
 267                      $target = '_self';
 268                  }
 269                  if ($addedresource_item == 'Link')
 270                  {
 271                      $addedresource_item .= ' '.$target;
 272                  }
 273                  $sql = "INSERT INTO $tbl_learnpath_item (id, chapter_id, item_type, item_id, display_order) VALUES ( '$autoid', '$chapter_id', '$addedresource_item','$addedresourceid[$i]','".$lastorder."')";
 274                  $result = Database::query($sql, __FILE__, __LINE__);
 275                  $addedresourceassigned[$i] = 1;
 276                  $resource_added = true;
 277              }
 278              $i ++;
 279              $lastorder ++;
 280          }
 281          //$_SESSION['addedresource']=null;
 282          //$_SESSION['addedresourceid']=null;
 283          // cleaning up the session once again
 284          $_SESSION['addedresource'] = null;
 285             $_SESSION['addedresourceid'] = null;
 286             $_SESSION['addedresourceassigned'] = null;
 287             unset ($_SESSION['addedresource']);
 288             unset ($_SESSION['addedresourceid']);
 289             unset ($_SESSION['addedresourceassigned']);
 290      }
 291  }
 292  
 293  /*
 294  ==============================================================================
 295      BREADCRUMBS
 296      This part is to allow going back to the tool where you came from
 297      in a previous version I used the table tool_list, but since the forum can access the
 298      resource_linker from two different pages (newtopic.php and editpost.php) and this is different
 299      from the link field in tool_list, I decide to hardcode this stuff here.
 300      By doing this, you can easily control which pages can access the toollinker and which not.
 301  ==============================================================================
 302  */
 303  if ($_GET["source_id"])
 304  {
 305      switch ($_GET["source_id"])
 306      {
 307          case "1" : // coming from Agenda
 308              if ($action == "edit")
 309              {
 310                  $url = "../calendar/agenda.php?action=edit&id=49&originalresource=$originalresource";
 311              }
 312              elseif ($action == "add")
 313          {
 314                  $url = "../calendar/agenda.php?action=add&originalresource=$originalresource";
 315              }
 316              else
 317              {
 318                  $url = "../calendar/agenda.php?action=add";
 319              }
 320              $originaltoolname = get_lang("Agenda");
 321              $breadcrumbelement = array ("url" => $url, "name" => $originaltoolname);
 322              session_unregister('from_learnpath');
 323              unset ($from_learnpath);
 324              break;
 325          case "2" : // coming from forum: new topic
 326              $url = "../phpbb/newtopic.php?forum=$source_forum&md5=$md5";
 327              $originaltoolname = get_lang("ForumAddNewTopic");
 328              $breadcrumbelement = array ("url" => $url, "name" => $originaltoolname);
 329              session_unregister('from_learnpath');
 330              unset ($from_learnpath);
 331              break;
 332          case "3" : // coming from forum: edit topic
 333              $url = "../phpbb/editpost.php?post_id=$post_id&topic=$topic&forum=$forum&md5=$md5&originalresource=no";
 334              $originaltoolname = get_lang("ForumEditTopic");
 335              $breadcrumbelement = array ("url" => $url, "name" => $originaltoolname);
 336              session_unregister('from_learnpath');
 337              unset ($from_learnpath);
 338              break;
 339          case "4" : // coming from exercises: edit topic
 340              $url = "../exercice/admin.php?modifyAnswers=$modifyAnswers";
 341              $originaltoolname = get_lang("ExerciseAnswers");
 342              $breadcrumbelement = array ("url" => $url, "name" => $originaltoolname);
 343              session_unregister('from_learnpath');
 344              unset ($from_learnpath);
 345              break;
 346          case "5" : // coming from learning path
 347              $from_learnpath = 'yes';
 348              api_session_register('from_learnpath');
 349              break;
 350          case "6" : // coming from forum: reply
 351              $url = "../phpbb/reply.php?topic=$topic&forum=$forum&parentid=$parentid";
 352              $url = $_SESSION['origintoolurl'];
 353              $originaltoolname = get_lang("ForumReply");
 354              $breadcrumbelement = array ("url" => $url, "name" => $originaltoolname);
 355              session_unregister('from_learnpath');
 356              unset ($from_learnpath);
 357              break;
 358              /*************************************** add Frederik.Vermeire@pandora.be *************************************/
 359  
 360          case "7" : // coming from Ad_Valvas
 361              if ($action == "edit")
 362              {
 363                  $url = "../announcements/announcements.php?action=edit&id=49&originalresource=$originalresource";
 364              }
 365              elseif ($action == "add")
 366          {
 367                  $url = "../announcements/announcements.php?action=add&originalresource=$originalresource";
 368              }
 369              else
 370              {
 371                  $url = "../announcements/announcements.php?action=add";
 372              }
 373              $originaltoolname = get_lang("AdValvas");
 374              $breadcrumbelement = array ("url" => $url, "name" => $originaltoolname);
 375              session_unregister('from_learnpath');
 376              unset ($from_learnpath);
 377              break;
 378              /*************************************** end add Frederik.Vermeire@pandora.be *********************************/
 379  
 380      }
 381      // We do not come from the learning path. We store the name of the tool & url in a session.
 382      if ($from_learnpath != 'yes')
 383      {
 384          if (!$_SESSION["origintoolurl"] OR $_SESSION["origintoolurl"]<>$interbreadcrumb["url"])
 385          {
 386              $_SESSION["origintoolurl"] = $breadcrumbelement["url"];
 387              $_SESSION["origintoolname"] = $breadcrumbelement["name"];
 388              $interbreadcrumb = "";
 389          }
 390      }
 391  
 392  }
 393  
 394  // This part of the code is the actual breadcrumb mechanism. If we do not come from the learning path we use
 395  // the information from the session. Else we use the information of the learningpath itself.
 396  if ($from_learnpath != 'yes')
 397  {
 398      $nameTools = get_lang('AddResource');
 399      $interbreadcrumb[] = array ("url" => $_SESSION["origintoolurl"], "name" => $_SESSION["origintoolname"]);
 400  }
 401  else
 402  {
 403      $learnpath_select_query = "    SELECT * FROM $tbl_learnpath_main
 404                                            WHERE learnpath_id=$learnpath_id";
 405      $sql_result = Database::query($learnpath_select_query);
 406      $therow = Database::fetch_array($sql_result);
 407  
 408      $learnpath_chapter_query = "    SELECT * FROM $tbl_learnpath_chapter
 409                                            WHERE (learnpath_id = '$learnpath_id' and id = '$chapter_id')";
 410      $sql_result = Database::query($learnpath_chapter_query);
 411      $therow2 = Database::fetch_array($sql_result);
 412  
 413      $from_learnpath = 'yes';
 414      session_register('from_learnpath');
 415      $interbreadcrumb[] = array ("url" => "../scorm/scormdocument.php", "name" => get_lang('LearningPath'));
 416      $interbreadcrumb[] = array ("url" => "../learnpath/learnpath_handler.php?learnpath_id=$learnpath_id", "name" => "{$therow['learnpath_name']}");
 417      $interbreadcrumb[] = array ("url" => api_get_self()."?action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no", "name" => "{$therow2['chapter_name']}");
 418  
 419  }
 420  
 421  $htmlHeadXtra[] = '<script type="text/javascript">
 422  /* <![CDATA[ */
 423  	function targetfunc(input)
 424      {
 425          window.location=window.location+"&amp;target="+document.learnpath_link.target.value;
 426      }
 427  /* ]]> */
 428  </script>';
 429  
 430  Display :: display_header($nameTools);
 431  
 432  echo "<h3>".$nameTools;
 433  if ($from_learnpath == 'yes')
 434  {
 435      echo get_lang("AddResource")." - {$therow2['chapter_name']}";
 436  }
 437  echo "</h3>";
 438  
 439  // we retrieve the tools that are active.
 440  // We use this to check which resources a student may add (only the modules that are active)
 441  // see http://www.dokeos.com/forum/viewtopic.php?t=4858
 442  $active_modules=array();
 443  $tool_table = Database::get_course_table(TABLE_TOOL_LIST);
 444  $sql_select_active="SELECT * FROM $tool_table WHERE visibility='1'";
 445  $result_select_active=Database::query($sql_select_active);
 446  while ($row=Database::fetch_array($result_select_active))
 447  {
 448      $active_modules[]=$row['name'];
 449  }
 450  
 451  
 452  ?>
 453  
 454  <table width="100%" border="0" cellspacing="0" cellpadding="0">
 455    <tr>
 456      <td width="300" valign="top" style='padding-right:15px;'>
 457        <table width="300" border="0" cellspacing="0" cellpadding="0" style='border-right:1px solid grey;'>
 458          <?php if ($from_learnpath != 'yes') { ?>
 459          <tr>
 460            <td width="26%"><b><?php echo get_lang('CourseResources'); ?></b></td>
 461          </tr>
 462          <?php
 463          if (is_allowed_to_edit() OR in_array(TOOL_DOCUMENT,$active_modules))
 464          {
 465          ?>
 466          <tr>
 467            <td><?php echo "<a href=\"".api_get_self()."?content=Document&action=$action&id=$id&learnpath_id=$learnpath_id&chapter_id=$chapter_id&source_forum=$source_forum&originalresource=no\">".get_lang('Document')."</a>"; ?></td>
 468          </tr>
 469          <?php
 470          }
 471          if (is_allowed_to_edit() OR in_array(TOOL_CALENDAR_EVENT,$active_modules))
 472          {
 473          ?>
 474          <tr>
 475            <td><?php echo "<a href=\"".api_get_self()."?content=Agenda&action=$action&id=$id&learnpath_id=$learnpath_id&chapter_id=$chapter_id&source_forum=$source_forum&originalresource=no\">".get_lang('Agenda')."</a>"; ?></td>
 476          </tr>
 477          <?php
 478          }
 479          if (is_allowed_to_edit() OR in_array(TOOL_ANNOUNCEMENT,$active_modules))
 480          {
 481          ?>
 482          <tr>
 483            <td><?php echo "<a href=\"".api_get_self()."?content=Ad_Valvas&action=$action&id=$id&learnpath_id=$learnpath_id&chapter_id=$chapter_id&source_forum=$source_forum&originalresource=no\">".get_lang('AdValvas')."</a>"; ?></td>
 484          </tr>
 485          <?php
 486          }
 487          if (is_allowed_to_edit() OR in_array(TOOL_BB_FORUM,$active_modules))
 488          {
 489          ?>
 490          <tr>
 491            <td><?php echo "<a href=\"".api_get_self()."?content=Forum&action=$action&id=$id&learnpath_id=$learnpath_id&chapter_id=$chapter_id&source_forum=$source_forum&originalresource=no\">".get_lang('Forum')."</a>"; ?></td>
 492          </tr>
 493          <?php
 494          }
 495          if (is_allowed_to_edit() OR in_array(TOOL_LINK,$active_modules))
 496          {
 497          ?>
 498          <tr>
 499            <td><?php echo "<a href=\"".api_get_self()."?content=Link&action=$action&id=$id&learnpath_id=$learnpath_id&chapter_id=$chapter_id&source_forum=$source_forum&originalresource=no\">".get_lang('Link')."</a>"; ?></td>
 500          </tr>
 501          <?php
 502          }
 503          if (is_allowed_to_edit() OR in_array(TOOL_QUIZ,$active_modules))
 504          {
 505          ?>
 506          <tr>
 507            <td><?php echo "<a href=\"".api_get_self()."?content=Exercise&action=$action&id=$id&learnpath_id=$learnpath_id&chapter_id=$chapter_id&source_forum=$source_forum&originalresource=no\">".get_lang('Exercise')."</a>"; ?></td>
 508          </tr>
 509  
 510          <?php
 511          }
 512  
 513  }
 514  else
 515  {
 516  ?>
 517  
 518  
 519  
 520          <tr>
 521            <td width="26%"><b><?php echo get_lang('ExportableCourseResources'); ?></b></td>
 522          </tr>
 523  <?php if ($multi_level_learnpath === true ) { ?>
 524          <tr>
 525            <td><?php echo "<a href=\"".api_get_self()."?content=chapter&action=$action&id=$id&learnpath_id=$learnpath_id&chapter_id=$chapter_id&source_forum=$source_forum&originalresource=no\">".get_lang('Chapter')."</a>"; ?></td>
 526          </tr>
 527  <?php } ?>
 528          <tr>
 529            <td><?php echo "<a href=\"".api_get_self()."?content=Document&action=$action&id=$id&learnpath_id=$learnpath_id&chapter_id=$chapter_id&source_forum=$source_forum&originalresource=no\">".get_lang('Document')."</a>"; ?></td>
 530          </tr>
 531          <tr>
 532            <td><?php echo "<a href=\"".api_get_self()."?content=Exercise&action=$action&id=$id&learnpath_id=$learnpath_id&chapter_id=$chapter_id&source_forum=$source_forum&originalresource=no\">".get_lang('Exercise')."</a>"; ?></td>
 533          </tr>
 534          <tr>
 535            <td><?php echo "<a href=\"".api_get_self()."?content=Link&action=$action&id=$id&learnpath_id=$learnpath_id&chapter_id=$chapter_id&source_forum=$source_forum&originalresource=no\">".get_lang('Link')."</a>"; ?></td>
 536          </tr>
 537          <tr>
 538            <td><?php echo "<a href=\"".api_get_self()."?content=Forum&action=$action&id=$id&learnpath_id=$learnpath_id&chapter_id=$chapter_id&source_forum=$source_forum&originalresource=no\">".get_lang('Forum')."</a>"; ?></td>
 539          </tr>
 540          <tr>
 541            <td><?php echo "<a href=\"".api_get_self()."?content=Agenda&action=$action&id=$id&learnpath_id=$learnpath_id&chapter_id=$chapter_id&source_forum=$source_forum&originalresource=no\">".get_lang('Agenda')."</a>"; ?></td>
 542          </tr>
 543          <tr>
 544            <td><?php echo "<a href=\"".api_get_self()."?content=Ad_Valvas&action=$action&id=$id&learnpath_id=$learnpath_id&chapter_id=$chapter_id&source_forum=$source_forum&originalresource=no\">".get_lang('AdValvas')."</a>"; ?></td>
 545          </tr>
 546          <tr>
 547            <td><?php echo "<a href=\"".api_get_self()."?content=Course_description&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&source_forum=$source_forum&originalresource=no\">".get_lang('CourseDescription')."</a>"; ?></td>
 548          </tr>
 549          <tr>
 550            <td><?php echo "<a href=\"".api_get_self()."?content=Introduction_text&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&source_forum=$source_forum&originalresource=no\">".get_lang('IntroductionText')."</a>"; ?></td>
 551          </tr>
 552          <tr>
 553            <td>&nbsp;</td>
 554          </tr>
 555          <tr>
 556            <td width="26%"><b><?php echo get_lang('DokeosRelatedCourseMaterial'); ?></b></td>
 557          </tr>
 558          <tr>
 559            <td><?php echo "<a href=\"".api_get_self()."?content=Dropbox&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&source_forum=$source_forum&originalresource=no\">".get_lang('Dropbox')."</a>"; ?></td>
 560          </tr>
 561          <tr>
 562            <td><?php echo "<a href=\"".api_get_self()."?content=Assignment&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&source_forum=$source_forum&originalresource=no\">".get_lang('Assignments')."</a>"; ?></td>
 563          </tr>
 564          <tr>
 565            <td><?php echo "<a href=\"".api_get_self()."?content=Groups&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&source_forum=$source_forum&originalresource=no\">".get_lang('Groups')."</a>"; ?></td>
 566          </tr>
 567          <tr>
 568            <td><?php echo "<a href=\"".api_get_self()."?content=Users&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&source_forum=$source_forum&originalresource=no\">".get_lang('Users')."</a>"; ?></td>
 569          </tr>
 570  
 571          <?php
 572  
 573  }
 574  ?>
 575  
 576  
 577  
 578          <tr>
 579            <td>&nbsp;</td>
 580          </tr>
 581          <tr>
 582            <td><b><?php echo get_lang("ExternalResources"); ?></b></td>
 583          </tr>
 584          <tr>
 585            <td><?php echo "<a href=\"".api_get_self()."?content=Externallink&action=$action&id=$id&learnpath_id=$learnpath_id&chapter_id=$chapter_id&source_forum=$source_forum&originalresource=no\">".get_lang('ExternalLink')."</a>"; ?></td>
 586          </tr>
 587          <?php
 588  
 589  if ($from_learnpath != 'yes')
 590  {
 591      echo "<tr><td>&nbsp;</td></tr>";
 592      echo "<tr><td><b>".get_lang('ResourcesAdded')." (";
 593      echo count($addedresource);
 594      echo ")</b></td></tr>";
 595      echo "<tr><td nowrap><a href=\"".api_get_self()."?showresources=true&action=$action&id=$id&learnpath_id=$learnpath_id&chapter_id=$chapter_id&source_forum=$source_forum&originalresource=no\">".get_lang('ShowDelete')."</a>";
 596      echo "</td></tr>";
 597  }
 598  ?>
 599          <tr>
 600            <td>&nbsp;</td>
 601          </tr>
 602          <!--<tr>
 603            <td><b><?php echo get_lang('BackTo'); ?></b></td>
 604          </tr>//-->
 605          <tr>
 606            <td>
 607  
 608            <?php
 609  
 610  if ($from_learnpath != 'yes')
 611  {
 612      echo "<form method=\"post\" action=\"{$_SESSION['origintoolurl']}\" style=\"margin: 0px;\"><input type=\"submit\" value=\"".get_lang('Ok')."\"></form>";
 613  }
 614  else
 615  {
 616      echo "<form method=\"get\" action=\"../learnpath/learnpath_handler.php\" style=\"margin: 0px;\"><input type=\"hidden\" name=\"learnpath_id\" value=\"".htmlentities($learnpath_id)."\"><input type=\"submit\" value=\"".'  '.get_lang('Ok').'  '."\"></form>";
 617  }
 618  ?>
 619  
 620            </td>
 621          </tr>
 622          <tr>
 623            <td>&nbsp;</td>
 624          </tr>
 625        </table>
 626      </td>
 627      <td valign="top">
 628        <?php
 629  
 630  if ($resource_added)
 631  {
 632      Display :: display_normal_message(get_lang("ResourceAdded"));
 633  }
 634  
 635  if ($from_learnpath != 'yes')
 636  {
 637      echo count($addedresource)." ".api_strtolower(get_lang('ResourcesAdded'))."<br/>";
 638  }
 639  //echo "<hr>";
 640  
 641  // Agenda items -->
 642  if ($content == "Agenda")
 643  {
 644      $TABLEAGENDA             = Database::get_course_table(TABLE_AGENDA);
 645      $TABLE_ITEM_PROPERTY     = Database::get_course_table(TABLE_ITEM_PROPERTY);
 646  
 647      $sql="SELECT agenda.*, toolitemproperties.*
 648                      FROM ".$TABLEAGENDA." agenda, ".$TABLE_ITEM_PROPERTY." toolitemproperties
 649                      WHERE `agenda`.`id` = `toolitemproperties`.`ref`
 650                      AND `toolitemproperties`.`tool`='".TOOL_CALENDAR_EVENT."'
 651                      AND `toolitemproperties`.`to_group_id`='0'
 652                      AND `toolitemproperties`.`visibility`='1'";
 653  
 654      $result = Database::query($sql);
 655  
 656      while ($myrow = Database::fetch_array($result))
 657      {
 658          echo "<table width=\"100%\"><tr><td bgcolor=\"#E6E6E6\">";
 659          echo "<img src='../img/agenda.png' alt='agenda'>";
 660          echo api_ucfirst(format_locale_date($dateFormatLong, strtotime($myrow["start_date"])))."&nbsp;";
 661          echo api_ucfirst(strftime($timeNoSecFormat, strtotime($myrow["start_date"])))."<br />";
 662          echo "<b>".$myrow["title"]."</b></td></tr><tr><td>";
 663          echo $myrow["content"]."<br />";
 664          showorhide_addresourcelink($content, $myrow["id"]);
 665          echo "</td></tr></table><br />";
 666      }
 667  } // end if ($_GET["resource"]=="Agenda")
 668  
 669  /*
 670  -----------------------------------------------------------
 671      chapter
 672  -----------------------------------------------------------
 673  */
 674  if ($content == "chapter")
 675  {
 676      echo '<table><form name="add_chapter" action="'.'" method="POST">'."\n";
 677      echo '  <tr><td>'.get_lang('Title').'</td><td><input type="text" name="title" value="'.$title.'"></input></td></tr>'."\n";
 678      echo '  <tr><td>'.get_lang('Description').'</td><td><input type="text" name="description" value="'.$description.'"></input></td></tr>'."\n";
 679      echo '  <tr><td></td><td><input type="submit" name="add_chapter" value="'.get_lang('AddIt').'"/></td></tr>'."\n";
 680      echo '</form></table>'."\n";
 681      //echo "<hr>";
 682  }
 683  
 684  /*
 685  -----------------------------------------------------------
 686      Documents
 687  -----------------------------------------------------------
 688  */
 689  // We show the documents in the following cases
 690  // 1. the link to add documenets in the resource linker was clicked
 691  // 2. we come to the resource linker for the first time (documents = default). In this case it can only be shown if
 692  //              a. one is a teacher (documents can be shown even if the tool is inactive)
 693  //                b. one is a student AND the documents tool is active. Student cannot add documents if the documents tool is inactive (teacher can do this)
 694  if ($content == "Document" OR (empty($content) AND (is_allowed_to_edit() OR in_array(TOOL_DOCUMENT,$active_modules))) AND !$_GET['showresources'])
 695  {
 696      // setting variables for file locations
 697      $baseServDir = $_configuration['root_sys'];
 698      $courseDir = $_course['path']."/document";
 699      $baseWorkDir = $baseServDir.$courseDir;
 700      // showing the link to move one folder up (when not in the root folder)
 701      show_folder_up();
 702      // showing the blue bar with the path in it when we are not in the root
 703      if (get_levels($folder))
 704      {
 705          echo "<table width=\"100%\"><tr><td bgcolor=\"#4171B5\">";
 706          echo "<img src=\"../img/opendir.gif\" alt='directory'><font color=\"#ffffff\"><b>";
 707          echo $folder."</b></font></td></tr></table>";
 708      }
 709  
 710      // showing the documents and subfolders of the folder we are in.
 711      show_documents($folder);
 712      //echo "<hr>";
 713  }
 714  
 715  /*
 716  -----------------------------------------------------------
 717      Ad Valvas
 718  -----------------------------------------------------------
 719  */
 720  if ($content == "Ad_Valvas")
 721  {
 722      $tbl_announcement = Database :: get_course_table(TABLE_ANNOUNCEMENT);
 723      $sql = "SELECT * FROM ".$tbl_announcement." a, ".$item_property_table." i  WHERE i.tool = '".TOOL_ANNOUNCEMENT."' AND a.id=i.ref AND i.visibility='1' AND i.to_group_id = 0 AND i.to_user_id IS NULL ORDER BY a.display_order ASC";
 724  
 725      $result = Database::query($sql,__FILE__,__LINE__);
 726      while ($myrow = Database::fetch_array($result))
 727      {
 728          echo "<table width=\"100%\"><tr><td>";
 729          echo "<img src='../img/valves.png' alt='advalvas'>";
 730          echo api_ucfirst(format_locale_date($dateFormatLong, strtotime($myrow["end_date"])));
 731          echo "</td></tr><tr><td>";
 732          echo $myrow["title"]."<br />";
 733          showorhide_addresourcelink($content, $myrow["id"]);
 734          echo "</td></tr></table>";
 735      }
 736  }
 737  
 738  /*
 739  -----------------------------------------------------------
 740      Forums
 741  -----------------------------------------------------------
 742  */
 743  if ($content == "Forum")
 744  {
 745      $TBL_FORUMS         = Database::get_course_table(TABLE_FORUM);
 746      $TBL_CATAGORIES     = Database::get_course_table(TABLE_FORUM_CATEGORY);
 747      $TBL_FORUMTOPICS     = Database::get_course_table(TABLE_FORUM_POST);
 748      $tbl_posts             = Database::get_course_table(TABLE_FORUM_POST);
 749      $tbl_posts_text     = Database::get_course_table(TOOL_FORUM_POST_TEXT_TABLE);
 750  
 751      echo "<table width='100%'>";
 752  
 753      // displaying the categories and the forums
 754      if (!$forum and !$thread)
 755      {
 756          $sql = "SELECT * FROM ".$TBL_FORUMS." forums, ".$TBL_CATAGORIES." categories WHERE forums.cat_id=categories.cat_id ORDER BY forums.cat_id DESC";
 757          $result = Database::query($sql, __FILE__, __LINE__);
 758          while ($myrow = Database::fetch_array($result))
 759          {
 760              if ($myrow["cat_title"] !== $old_cat_title)
 761              {
 762                  echo "<tr><td bgcolor='#4171B5' colspan='2'><font color='white'><b>".$myrow["cat_title"]."</b></font></td></tr>";
 763              }
 764              $old_cat_title = $myrow["cat_title"];
 765              echo "<tr><td><img src='../img/forum.gif'><a href='".api_get_self()."?content=Forum&category=".$myrow["cat_id"]."&forum=".$myrow["forum_id"]."&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no'>".$myrow["forum_name"]."</td><td>";
 766              showorhide_addresourcelink("Forum", $myrow["forum_id"]);
 767              echo "</td></tr>";
 768          }
 769      }
 770      //displaying all the threads of one forum
 771      if ($forum)
 772      {
 773          // displaying the category title
 774          $sql = "SELECT * FROM ".$TBL_CATAGORIES." WHERE cat_id=$category";
 775          $result = Database::query($sql, __FILE__, __LINE__);
 776          $myrow = Database::fetch_array($result);
 777          echo "<tr><td bgcolor='#4171B5' colspan='2'><font color='white'><b>".$myrow["cat_title"]."</b></font></td></tr>";
 778  
 779          // displaying the forum title
 780          $sql = "SELECT * FROM ".$TBL_FORUMS." forums, ".$TBL_FORUMTOPICS." topics WHERE forums.forum_id=topics.forum_id";
 781          $result = Database::query($sql, __FILE__, __LINE__);
 782          $myrow = Database::fetch_array($result);
 783          echo "<tr><td bgcolor='#cccccc' colspan='2'><b>".$myrow["forum_name"]."</b></td></tr>";
 784  
 785          if (!$thread)
 786          {
 787              // displaying all the threads of this forum
 788              $sql = "SELECT * FROM ".$TBL_FORUMTOPICS." WHERE forum_id=$forum";
 789              $result = Database::query($sql, __FILE__, __LINE__);
 790              while ($myrow = Database::fetch_array($result))
 791              {
 792                  echo "<tr><td><a href='".api_get_self()."?content=Forum&category=$category&forum=1&thread=".$myrow["topic_id"]."&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no'>".$myrow["topic_title"]."</a>  (".$myrow["prenom"]." ".$myrow["nom"].")</td><td>";
 793                  showorhide_addresourcelink("Thread", $myrow["topic_id"]);
 794                  echo "</td></tr>";
 795              }
 796          }
 797          else
 798          {
 799              // displaying all the replies
 800              $sql = "SELECT * FROM ".$tbl_posts." post, ".$tbl_posts_text." post_text WHERE post_text.post_id=post.post_id and post.topic_id=$thread ORDER BY post_text.post_id ASC";
 801              $result = Database::query($sql, __FILE__, __LINE__);
 802              while ($myrow = Database::fetch_array($result))
 803              {
 804                  echo "<tr><td><b>".$myrow["post_title"]."</b><br>";
 805                  echo $myrow["post_text"]."</td>";
 806                  echo "<td>";
 807                  showorhide_addresourcelink("Post", $myrow["post_id"]);
 808                  echo "</td></tr><tr><td colspan='2'><hr noshade></td></tr>";
 809              }
 810  
 811          }
 812      }
 813      echo "</table>";
 814  }
 815  
 816  /*
 817  -----------------------------------------------------------
 818      Links
 819  -----------------------------------------------------------
 820  */
 821  if ($content == "Link")
 822  {
 823      // including the links language file
 824      include ("../lang/$language/link.inc.php");
 825  
 826      // including the links functions file
 827      include  ("../link/linkfunctions.php");
 828  
 829      $tbl_categories = Database::get_course_table(TABLE_LINK_CATEGORY);
 830      if (($learnpath_id != '') and ($content == 'Link'))
 831      {
 832          echo "<form name='learnpath_link'><table>";
 833          echo "<tr></td><td align='left'>".get_lang('LinkTarget')." :</td><td align='left'><select name='target' onchange='targetfunc()'><option value='_self' ";
 834          if ($target == '_self')
 835          {
 836              echo "selected";
 837          }
 838          echo ">".get_lang('SameWindow')."</option><option value='_blank'";
 839          if ($target == '_blank')
 840          {
 841              echo "selected";
 842          }
 843          echo ">".get_lang('NewWindow')."</option></select></td></tr></table></form>";
 844      }
 845  
 846      // showing the links that are in the root (having no category)
 847      $sql = "SELECT * FROM ".$link_table.", ".$item_property_table." WHERE (category_id=0 or category_id IS NULL) AND tool = '".TOOL_LINK."' AND id=ref AND visibility='1'";
 848      $result = Database::query($sql, __FILE__, __LINE__);
 849      if (Database::num_rows($result) > 0)
 850      {
 851          echo "<table width=\"100%\"><tr><td bgcolor=\"#E6E6E6\"><i>".get_lang('NoCategory')."</i></td></tr></table>";
 852          while ($myrow = Database::fetch_array($result))
 853          {
 854              echo "<img src='../img/links.gif'>".$myrow["title"];
 855              echo "<br>";
 856              showorhide_addresourcelink($content, $myrow["id"]);
 857              echo "<br><br>";
 858          }
 859      }
 860  
 861      // showing the categories and the links in it.
 862      $sqlcategories = "SELECT * FROM ".$tbl_categories." ORDER by display_order DESC";
 863      $resultcategories = Database::query($sqlcategories) or die;
 864      while ($myrow = @ Database::fetch_array($resultcategories))
 865      {
 866          $sql_links = "SELECT * FROM ".$link_table.", ".$item_property_table." WHERE category_id='".$myrow["id"]."' AND tool = '".TOOL_LINK."' AND id=ref AND visibility='1' ORDER BY display_order DESC";
 867          echo "<table width=\"100%\"><tr><td bgcolor=\"#E6E6E6\"><i>".$myrow["category_title"]."</i></td></tr></table>";
 868          $result_links = Database::query($sql_links, __FILE__, __LINE__);
 869          while ($myrow = Database::fetch_array($result_links))
 870          {
 871              echo "<img src='../img/links.gif' />".$myrow["title"];
 872              echo "<br>";
 873              showorhide_addresourcelink($content, $myrow["id"]);
 874              echo "<br><br>";
 875          }
 876      }
 877  }
 878  
 879  /*
 880  -----------------------------------------------------------
 881      Exercise
 882  -----------------------------------------------------------
 883  */
 884  if (($content == "Exercise") or ($content == "HotPotatoes"))
 885  {
 886      $TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST);
 887      $result = Database::query("SELECT * FROM ".$TBL_EXERCICES." WHERE active='1' ORDER BY id ASC");
 888      while ($myrow = Database::fetch_array($result))
 889      {
 890          echo "<img src='../img/quiz.gif'>".$myrow["title"]."<br>";
 891          showorhide_addresourcelink($content, $myrow["id"]);
 892          echo "<br><br>";
 893      }
 894  
 895      if ($from_learnpath == 'yes')
 896      {
 897          $uploadPath = "/HotPotatoes_files";
 898          $TBL_DOCUMENT = Database::get_course_table(TABLE_DOCUMENT);
 899          $documentPath = api_get_path('SYS_COURSE_PATH').$_course['path'].'/document';
 900          $sql = "SELECT * FROM ".$TBL_DOCUMENT." WHERE (path LIKE '%htm%' OR path LIKE '%html%') AND path LIKE '".$uploadPath."/%/%' ORDER BY `id` ASC";
 901          $result = Database::query($sql, __FILE__, __LINE__);
 902          while ($myrow = Database::fetch_array($result))
 903          {
 904              $path = $myrow["path"];
 905              echo "<img src='../img/jqz.gif'>".GetQuizName($path, $documentPath)."<br>";
 906              showorhide_addresourcelink("HotPotatoes", $myrow["id"]);
 907              echo "<br><br>";
 908  
 909          }
 910      }
 911  }
 912  
 913  /*
 914  -----------------------------------------------------------
 915      External Links
 916  -----------------------------------------------------------
 917  */
 918  if ($content == "Externallink")
 919  {
 920  ?>
 921    <form name="form1" method="post" action="">
 922    <table width="80%" border="0" cellspacing="0" cellpadding="0">
 923      <tr>
 924        <td align="right"><?php echo get_lang('ExternalLink'); ?> : &nbsp;</td>
 925        <td align="left"><input name="external_link" type="text" id="external_link" value="http://"></td>
 926        <?php
 927  
 928      if ($learnpath_id != '')
 929      {
 930          echo "</tr><tr><td align='right'>".get_lang('LinkTarget')." :</td><td align='left'><select name='target'><option value='_self'>".get_lang('SameWindow')."</option><option value='_blank'>".get_lang('NewWindow')."</option></select></td>";
 931      }
 932  ?>
 933      </tr>
 934      <tr>
 935        <td><?php if ($is_allowedToEdit) {echo get_lang('AddToLinks');} ?></td>
 936        <td>
 937          <?php if ($is_allowedToEdit){?>
 938        <select name="add_2_links" id="add_2_links">
 939        <option value="niet toevoegen" selected="selected">-<?php echo get_lang('DontAdd'); ?>-</option>
 940        <option value="0"><?php echo get_lang('MainCategory'); ?></option>
 941          <?php
 942  
 943      $tbl_categories = Database::get_course_table(TABLE_LINK_CATEGORY);
 944      $sql = "SELECT * FROM `$tbl_categories` ORDER BY display_order ASC";
 945      echo $sql;
 946      $result = Database::query($sql, __FILE__, __LINE__);
 947      while ($row = Database::fetch_array($result))
 948      {
 949          echo "<option value='".$row["id"]."'>".$row["category_title"]."</option>";
 950      }
 951  ?>
 952  
 953        </select><?php } ?></td>
 954      </tr>
 955      <tr>
 956        <td>&nbsp;</td>
 957        <td><input name="external_link_submit" type="submit" id="external_link_submit" value="<?php echo get_lang('AddIt'); ?>"></td>
 958      </tr>
 959      <tr>
 960        <td>&nbsp;</td>
 961        <td>&nbsp;</td>
 962      </tr>
 963      <tr>
 964        <td colspan="2">&nbsp;</td>
 965      </tr>
 966    </table>
 967  </form>
 968      <?php
 969  
 970  }
 971  
 972  /*
 973  -----------------------------------------------------------
 974      Assignments
 975  -----------------------------------------------------------
 976  */
 977  if ($content == "Assignment")
 978  {
 979      echo "<a href=".api_get_self()."?content=Ass&add=Ass&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no>".get_lang('AddAssignmentPage')."</a>";
 980  }
 981  
 982  /*
 983  -----------------------------------------------------------
 984      Dropbox
 985  -----------------------------------------------------------
 986  */
 987  if ($content == "Dropbox")
 988  {
 989      echo "<a href='".api_get_self()."?content=Drop&add=Drop&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no'>".get_lang('DropboxAdd')."</a>";
 990  }
 991  
 992  /*
 993  -----------------------------------------------------------
 994      Introduction text
 995  -----------------------------------------------------------
 996  */
 997  if ($content == "Introduction_text")
 998  {
 999      echo "<a href='".api_get_self()."?content=Intro&add=Intro&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no'>".get_lang('IntroductionTextAdd')."</a>";
1000  }
1001  
1002  /*
1003  -----------------------------------------------------------
1004      Course description
1005  -----------------------------------------------------------
1006  */
1007  if ($content == "Course_description")
1008  {
1009      echo "<a href='".api_get_self()."?content=Course_desc&add=Course_desc&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no'>".get_lang('CourseDescriptionAdd')."</a>";
1010  }
1011  
1012  /*
1013  -----------------------------------------------------------
1014      Groups
1015  -----------------------------------------------------------
1016  */
1017  if ($content == "Groups")
1018  {
1019      echo "<a href='".api_get_self()."?content=Group&add=Group&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no'>".get_lang('$GroupsAdd')."</a>";
1020  }
1021  
1022  /*
1023  -----------------------------------------------------------
1024      Users
1025  -----------------------------------------------------------
1026  */
1027  if ($content == "Users")
1028  {
1029      echo "<a href='".api_get_self()."?content=User&add=User&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no'>".get_lang('UsersAdd')."</a>";
1030  }
1031  
1032  if ($showresources)
1033  {
1034      //echo "<h4>".get_lang('ResourceAdded')."</h4>";
1035      display_resources(1);
1036  }
1037  
1038  echo "</td></tr></table>";
1039  
1040  /*
1041  ==============================================================================
1042          FOOTER
1043  ==============================================================================
1044  */
1045  
1046  Display :: display_footer();
1047  ?>
1048  

title

Description

title

Description

title

Description

title

title

Body