dokeos-external_module
[ class tree: dokeos-external_module ] [ index: dokeos-external_module ] [ all elements ]

Source for file external_module.php

Documentation is available at external_module.php

  1. <?php
  2. /*
  3. ==============================================================================
  4.     Dokeos - elearning and course management software
  5.  
  6.     Copyright (c) 2004 Dokeos S.A.
  7.     Copyright (c) 2003 Ghent University (UGent)
  8.     Copyright (c) 2001 Universite catholique de Louvain (UCL)
  9.     Copyright (c) various contributors
  10.  
  11.     For a full list of contributors, see "credits.txt".
  12.     The full license can be read in "license.txt".
  13.  
  14.     This program is free software; you can redistribute it and/or
  15.     modify it under the terms of the GNU General Public License
  16.     as published by the Free Software Foundation; either version 2
  17.     of the License, or (at your option) any later version.
  18.  
  19.     See the GNU General Public License for more details.
  20.  
  21.     Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
  22. ==============================================================================
  23. */
  24. /**
  25. ==============================================================================
  26. *    This script is used for adding hyperlinks to a course homepage.
  27. *    It used to be able to link html documents as well,
  28. *    which it displayed in context, but that was abandoned
  29. *    because of changes in documents tool:
  30. *
  31. *    Html files are displayed by default with frames now in the documents tool
  32. *    so the external module - html file include has to be refactored to
  33. *    reuse documents tool code.
  34. *
  35. *    @package dokeos.external_module
  36. ==============================================================================
  37. */
  38.  
  39. // name of the language file that needs to be included 
  40. $language_file='external_module';
  41.  
  42. $iconForImportedTools='external.gif';
  43. $iconForInactiveImportedTools='external_inactive.gif';
  44.  
  45. include('../inc/global.inc.php');
  46.  
  47. $toolid $_GET['id'];  // RH: all lines with $toolid added/changed by me
  48.  
  49. if($toolid)
  50. {
  51.         $nameTools get_lang('EditLink');
  52.         $noPHP_SELF TRUE;  // RH: no click to self on edit
  53. }
  54. else    $nameTools get_lang('AddLink');
  55.  
  56.  
  57. $is_allowedToEdit=$is_courseAdmin;
  58.  
  59. $linkAdded=false;
  60.  
  61. if($is_allowedToEdit && $_POST['formSent'&& $toolid)  // RH: new section
  62. {
  63.     $name_link=trim(stripslashes($_POST['name_link']));
  64.     $link=trim(stripslashes($_POST['link']));
  65.     $target=($_POST['target'== '_blank')?'_blank':'_self';
  66.  
  67.     if(empty($name_link)) $msgErr=get_lang('NoLinkName');
  68.     elseif(empty($link|| $link == 'http://'$msgErr=get_lang('NoLinkURL');
  69.     else
  70.     {
  71.         $sql =  "UPDATE $tbl_courseHome SET .
  72.                 "name='" .   Database::escape_string($name_link.
  73.                 "', link='" .    Database::escape_string($link.
  74.                 "', target='" .  Database::escape_string($target.
  75.                 "' WHERE id='" Database::escape_string($id"'";
  76.  
  77.         api_sql_query($sql__FILE____LINE__);
  78.  
  79.         $linkAdded TRUE;
  80.     }
  81. }
  82. elseif($is_allowedToEdit && $_POST['formSent'])
  83. {
  84.     $name_link=trim(stripslashes($_POST['name_link']));
  85.     $link=trim(stripslashes($_POST['link']));
  86.     $target=($_POST['target'== '_blank')?'_blank':'_self';
  87.  
  88.     if(empty($name_link)) $msgErr=get_lang('NoLinkName');
  89.     elseif(empty($link|| $link == 'http://'$msgErr=get_lang('NoLinkURL');
  90.     else
  91.     {
  92.         if(!stristr($link,'http://'))
  93.         {
  94.             $link='http://'.$link;
  95.         }
  96.  
  97.         api_sql_query("INSERT INTO $tbl_courseHome(name,link,image,visibility,admin,address,target) VALUES('".Database::escape_string($name_link)."','".Database::escape_string($link)."','$iconForImportedTools','1','0','$iconForInactiveImportedTools','$target')",__FILE__,__LINE__);
  98.  
  99.         $linkAdded=true;
  100.     }
  101. }
  102.  
  103. Display::display_header($nameTools,"External");
  104. ?>
  105.  
  106. <h3><?php echo $toolid get_lang('EditLink'$nameTools?></h3>
  107.  
  108. <?php
  109.  
  110.  
  111. if(!$is_allowedToEdit)
  112. {
  113.     api_not_allowed();
  114. }
  115.  
  116. if($linkAdded)
  117. {
  118.     echo $toolid get_lang('LinkChanged':get_lang('OkSentLink');
  119. }
  120. else
  121. {
  122.     if ($toolid)  // RH: new section
  123.     {
  124.         $sql =  "SELECT name,link,target FROM $tbl_courseHome.
  125.         " WHERE id='" Database::escape_string($id"'";
  126.  
  127.         $result api_sql_query($sql__FILE____LINE__);
  128.  
  129.         (Database::num_rows($result== && ($row Database::fetch_array($result)))
  130.             or die('? Could not fetch data with ' htmlspecialchars($sql));
  131.     }
  132.  
  133. ?>
  134.  
  135. <p><?php echo $toolid get_lang('ChangePress'get_lang('SubTitle')?></p>
  136.  
  137. <table border="0">
  138. <form method="post" action="<?php echo $toolid api_get_self('?id=' $id api_get_self()?>">
  139. <input type="hidden" name="formSent" value="1">
  140.  
  141. <?php
  142. if(!empty($msgErr))
  143. {
  144. ?>
  145.  
  146. <tr>
  147.   <td colspan="2">
  148.  
  149. <?php
  150.     Display::display_normal_message($msgErr)//main API
  151. ?>
  152.  
  153.   </td>
  154. </tr>
  155.  
  156. <?php
  157. }
  158. ?>
  159.  
  160. <tr>
  161.   <td align="right"><?php echo get_lang('Link')?> :</td>
  162.   <td><input type="text" name="link" size="50" value="<?php if($_POST['formSent']echo htmlentities($link)else echo $toolid htmlspecialchars($row['link']'http://'?>"></td>
  163. </tr>
  164. <tr>
  165.   <td align="right"><?php echo get_lang('Name')?> :</td>
  166.   <td><input type="text" name="name_link" size="50" value="<?php if($_POST['formSent']echo htmlentities($name_link,ENT_QUOTES,$charset)else echo $toolid htmlspecialchars($row['name'],ENT_QUOTES,$charset''?>"></td>
  167. </tr>
  168. <tr>
  169.   <td align="right"><?php echo get_lang('LinkTarget')?> :</td>
  170.   <td><select name="target">
  171.   <option value="_self"><?php echo get_lang('SameWindow')?></option>
  172.   <option value="_blank" <?php if(($_POST['formSent'&& $target == '_blank'|| ($toolid && $row['target'== '_blank')) echo 'selected="selected"'?>><?php echo get_lang('NewWindow')?></option>
  173.   </select></td>
  174. </tr>
  175. <tr>
  176.   <td>&nbsp;</td>
  177.   <td><input type="submit" value="<?php echo get_lang('Ok')?>"></td>
  178. </tr>
  179. </table>
  180.  
  181. <?php
  182. }
  183.  
  184. ?>

Documentation generated on Thu, 12 Jun 2008 13:27:58 -0500 by phpDocumentor 1.4.1