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

Source for file btf_functions.php

Documentation is available at btf_functions.php

  1. <?php
  2. // $Id: btf_functions.php 13294 2007-09-27 02:14:48Z yannoo $
  3. /*
  4. ==============================================================================
  5.     Dokeos - elearning and course management software
  6.  
  7.     Copyright (c) 2004-2005 Dokeos S.A.
  8.     Copyright (c) 2003 Ghent University
  9.     Copyright (c) 2001 Universite Catholique de Louvain
  10.     Copyright (c) various contributors
  11.     Copyright (c) Bart Mollet, Hogeschool Gent
  12.  
  13.     For a full list of contributors, see "credits.txt".
  14.     The full license can be read in "license.txt".
  15.  
  16.     This program is free software; you can redistribute it and/or
  17.     modify it under the terms of the GNU General Public License
  18.     as published by the Free Software Foundation; either version 2
  19.     of the License, or (at your option) any later version.
  20.  
  21.     See the GNU General Public License for more details.
  22.  
  23.     Contact address: Dokeos, 44 rue des palais, B-1030 Brussels, Belgium
  24.     Mail: info@dokeos.com
  25. ==============================================================================
  26. */
  27.  
  28. /**
  29. ==============================================================================
  30. *                  HOME PAGE FUNCTIONS (BASIC TOOLS FIXED)
  31. *
  32. *    This page, included in every course's index.php is the home
  33. *    page.To make administration simple, the professor edits his
  34. *    course from it's home page. Only the login detects that the
  35. *    visitor is allowed to activate, deactivate home page links,
  36. *    access to Professor's tools (statistics, edit forums...).
  37. *
  38. *    @package dokeos.course_home
  39. ==============================================================================
  40. */
  41.  
  42. function showtools2($cat)
  43. {
  44.     global $_user$charset;
  45.  
  46.     $TBL_ACCUEIL Database :: get_course_table(TABLE_TOOL_LIST);
  47.     $TABLE_TOOLS Database :: get_main_table(TABLE_MAIN_COURSE_MODULE);
  48.  
  49.     $numcols 3;
  50.     $table new HTML_Table('width="100%"');
  51.     $toolsRow_all array ();
  52.     switch ($cat)
  53.     {
  54.         case 'Basic' :
  55.             $sql "SELECT a.*, t.image img, t.row, t.column  FROM $TBL_ACCUEIL a, $TABLE_TOOLS t
  56.                                     WHERE a.link=t.link AND t.position='basic' ORDER BY t.row, t.column";
  57.             break;
  58.  
  59.         case 'External' :
  60.             if (api_is_allowed_to_edit())
  61.             {
  62.                 $sql "SELECT a.*, t.image img FROM $TBL_ACCUEIL a, $TABLE_TOOLS t
  63.                                         WHERE (a.link=t.link AND t.position='external')
  64.                                         OR (a.visibility <= 1 AND (a.image = 'external.gif' OR a.image = 'scormbuilder.gif' OR t.image = 'blog.gif') AND a.image=t.image)
  65.                                         ORDER BY a.id";
  66.             }
  67.             else
  68.             {
  69.                 $sql "SELECT a.*, t.image img FROM $TBL_ACCUEIL a, $TABLE_TOOLS t
  70.                                         WHERE a.visibility = 1 AND ((a.link=t.link AND t.position='external')
  71.                                         OR ((a.image = 'external.gif' OR a.image = 'scormbuilder.gif' OR t.image = 'blog.gif') AND a.image=t.image))
  72.                                          ORDER BY a.id";
  73.             }
  74.             break;
  75.  
  76.         case 'courseAdmin' :
  77.             $sql "SELECT a.*, t.image img, t.row, t.column  FROM $TBL_ACCUEIL a, $TABLE_TOOLS t
  78.                                     WHERE admin=1 AND a.link=t.link ORDER BY t.row, t.column";
  79.             break;
  80.  
  81.         case 'claroAdmin' :
  82.             $sql "SELECT *, image img FROM $TBL_ACCUEIL WHERE visibility = 2 ORDER BY id";
  83.     }
  84.     $result api_sql_query($sql__FILE____LINE__);
  85.  
  86.     // grabbing all the tools from $course_tool_table
  87.     while ($tempRow mysql_fetch_array($result))
  88.     {
  89.         if ($tempRow['img'!== "scormbuilder.gif" AND $tempRow['img'!== "blog.gif")
  90.         {
  91.             $tempRow['name_translated'get_lang(ucfirst($tempRow['name']));
  92.         }
  93.         $toolsRow_all[$tempRow;
  94.     }
  95.     // grabbing all the links that have the property on_homepage set to 1
  96.     if ($cat == "External")
  97.     {
  98.         $tbl_link Database :: get_course_table(TABLE_LINK);
  99.         $tbl_item_property Database :: get_course_table(TABLE_ITEM_PROPERTY);
  100.         if (api_is_allowed_to_edit())
  101.         {
  102.             $sql_links "SELECT tl.*, tip.visibility
  103.                                 FROM $tbl_link tl
  104.                                 LEFT JOIN $tbl_item_property tip ON tip.tool='link' AND tip.ref=tl.id
  105.                                 WHERE tl.on_homepage='1' AND tip.visibility != 2";
  106.         }
  107.         else
  108.         {
  109.             $sql_links "SELECT tl.*, tip.visibility
  110.                                 FROM $tbl_link tl
  111.                                 LEFT JOIN $tbl_item_property tip ON tip.tool='link' AND tip.ref=tl.id
  112.                                 WHERE tl.on_homepage='1' AND tip.visibility = 1";
  113.         }
  114.         $result_links api_sql_query($sql_links);
  115.         while ($links_row mysql_fetch_array($result_links))
  116.         {
  117.             $properties array ();
  118.             $properties['name'$links_row['title'];
  119.             $properties['link'$links_row['url'];
  120.             $properties['visibility'$links_row['visibility'];
  121.             $properties['img''external.gif';
  122.             $properties['adminlink'api_get_path(WEB_CODE_PATH).'link/link.php?action=editlink&amp;id='.$links_row['id'];
  123.             $toolsRow_all[$properties;
  124.         }
  125.     }
  126.  
  127.     $cell_number 0;
  128.     // draw line between basic and external, only if there are entries in External
  129.     if ($cat == "External" && count($toolsRow_all))
  130.     {
  131.         $table->setCellContents(00'<hr noshade="noshade" size="1"/>');
  132.         $table->updateCellAttributes(00'colspan="3"');
  133.         $cell_number += $numcols;
  134.     }
  135.  
  136.     foreach ($toolsRow_all as $toolsRow)
  137.     {
  138.         $cell_content '';
  139.         // the name of the tool
  140.         $tool_name ($toolsRow['name_translated'!= "" $toolsRow['name_translated'htmlspecialchars($toolsRow['name'],ENT_QUOTES,$charset))// RH: added htmlspecialchars
  141.  
  142.         $link_annex '';
  143.         // the url of the tool
  144.         if ($toolsRow['img'!= "external.gif")
  145.         {
  146.             $toolsRow['link'api_get_path(WEB_CODE_PATH).$toolsRow['link'];
  147.             $qm_or_amp ((strpos($toolsRow['link']'?'=== FALSE'?' '&amp;');
  148.             $link_annex $qm_or_amp.api_get_cidreq();
  149.         }
  150.         else // if an external link ends with 'login=', add the actual login...
  151.             {
  152.             $pos strpos($toolsRow['link']"?login=");
  153.             $pos2 strpos($toolsRow['link']"&amp;login=");
  154.             if ($pos !== false or $pos2 !== false)
  155.             {
  156.                 $link_annex $_user['username'];
  157.             }
  158.         }
  159.  
  160.         // setting the actual image url
  161.         $toolsRow['img'api_get_path(WEB_IMG_PATH).$toolsRow['img'];
  162.  
  163.         // VISIBLE
  164.         if ($toolsRow['visibility'or $cat == 'courseAdmin' or $cat == 'claroAdmin')
  165.         {
  166.             $cell_content .= '<a href="'.$toolsRow['link'].$link_annex.'" target="'.$toolsRow['target'].'"><img src="'.$toolsRow['img'].'" alt="" border="0" style="vertical-align:middle;"/></a>'."\n";
  167.             $cell_content .= '<a href="'.$toolsRow['link'].$link_annex.'" target="'.$toolsRow['target'].'">'.$tool_name."</a>\n";
  168.         }
  169.         // INVISIBLE
  170.         else
  171.         {
  172.             if (api_is_allowed_to_edit())
  173.             {
  174.                 $cell_content .= '<a href="'.$toolsRow['link'].$link_annex.'" target="'.$toolsRow['target'].'"><img src="'.str_replace(".gif""_na.gif"$toolsRow['img']).'" alt="" border="0" style="vertical-align:middle;"/></a>'."\n";
  175.                 $cell_content .= '<a href="'.$toolsRow['link'].$link_annex.'" target="'.$toolsRow['target'].'" class="invisible">'.$tool_name.'</a>'."\n";
  176.             }
  177.             else
  178.             {
  179.                 $cell_content .= '<img src="'.str_replace(".gif""_na.gif"$toolsRow['img']).'" alt="" border="0" style="vertical-align:middle;">'."\n";
  180.                 $cell_content .= '<span class="invisible">'.$tool_name.'</span>';
  181.             }
  182.         }
  183.  
  184.         $lnk array ();
  185.         if (api_is_allowed_to_edit(and $cat != "courseAdmin" && !strpos($toolsRow['link']'learnpath_handler.php?learnpath_id'))
  186.         {
  187.             if ($toolsRow["visibility"])
  188.             {
  189.                 $link['name''<img src="'.api_get_path(WEB_IMG_PATH).'remove.gif"  style="vertical-align:middle;" alt="'.get_lang('Deactivate').'"/>';
  190.                 $link['cmd'"hide=yes";
  191.                 $lnk[$link;
  192.             }
  193.             else
  194.             {
  195.                 $link['name''<img src="'.api_get_path(WEB_IMG_PATH).'add.gif" style="vertical-align:middle;" alt="'.get_lang('Activate').'"/>';
  196.                 $link['cmd'"restore=yes";
  197.                 $lnk[$link;
  198.  
  199.                 /*if($toolsRow["img"] == $dokeosRepositoryWeb."img/external.gif")
  200.                 {
  201.                     $link['name'] = get_lang('Remove'); $link['cmd']  = "remove=yes";
  202.                     if ($toolsRow["visibility"]==2 and $cat=="claroAdmin")
  203.                     {
  204.                         $link['name'] = get_lang('Delete'); $link['cmd'] = "askDelete=yes";
  205.                         $lnk[] = $link;
  206.                     }
  207.                 }*/
  208.             }
  209.             //echo "<div class=courseadmin>";
  210.             if (is_array($lnk))
  211.             {
  212.                 foreach ($lnk as $thisLnk)
  213.                 {
  214.                     if ($toolsRow['adminlink'])
  215.                     {
  216.                         $cell_content .= '<a href="'.$properties['adminlink'].'">'.'<img src="'.api_get_path(WEB_IMG_PATH).'edit.gif" alt="'.get_lang('Edit').'"/>'.'</a>';
  217.                         //echo "edit link:".$properties['adminlink'];
  218.                     }
  219.                     else
  220.                     {
  221.                         $cell_content .= "<a href=\"".api_get_self()."?id=".$toolsRow["id"]."&amp;".$thisLnk['cmd']."\">".$thisLnk['name']."</a>";
  222.                     }
  223.                 }
  224.             }
  225.  
  226.             // RH: Allow editing of invisible homepage links (modified external_module)
  227.             if ($toolsRow["added_tool"== && api_is_allowed_to_edit(&& !$toolsRow["visibility"])
  228.             {
  229.                 $cell_content .= "<a class=\"nobold\" href=\"".api_get_path(WEB_CODE_PATH).'external_module/external_module.php'."?id=".$toolsRow["id"]."\">".get_lang("Edit")."</a>";
  230.             }
  231.         }
  232.         $table->setCellContents($cell_number $numcols($cell_number$numcols$cell_content);
  233.         $table->updateCellAttributes($cell_number $numcols($cell_number$numcols'width="32%" height="42"');
  234.         $cell_number ++;
  235.     }
  236.     $table->display();
  237. // end function showtools2($cat)
  238. ?>

Documentation generated on Thu, 12 Jun 2008 13:01:43 -0500 by phpDocumentor 1.4.1