123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460 |
- <?php // $Id: 2column.php,v 1.5 2006/08/10 14:34:54 pcool Exp $
- /*
- ==============================================================================
- Dokeos - elearning and course management software
- Copyright (c) 2004-2005 Dokeos S.A.
- Copyright (c) 2003 Ghent University
- Copyright (c) 2001 Universite Catholique de Louvain
- Copyright (c) various contributors
- For a full list of contributors, see "credits.txt".
- The full license can be read in "license.txt".
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
- See the GNU General Public License for more details.
- Contact address: Dokeos, 44 rue des palais, B-1030 Brussels, Belgium
- Mail: info@dokeos.com
- ==============================================================================
- */
- /**
- ==============================================================================
- * HOME PAGE FOR EACH COURSE
- *
- * This page, included in every course's index.php is the home
- * page. To make administration simple, the teacher edits his
- * course from the home page. Only the login detects that the
- * visitor is allowed to activate, deactivate home page links,
- * access to the teachers tools (statistics, edit forums...).
- *
- * @package dokeos.course_home
- ==============================================================================
- */
- /*
- ==============================================================================
- FUNCTIONS
- ==============================================================================
- */
- /**
- * Displays the tools of a certain category.
- *
- * @return void
- * @param string $course_tool_category contains the category of tools to display:
- * "Public", "PublicButHide", "courseAdmin", "claroAdmin"
- */
- function show_tools($course_tool_category)
- {
- global $charset;
- $web_code_path = api_get_path(WEB_CODE_PATH);
- $course_tool_table = Database::get_course_table(TABLE_TOOL_LIST);
- switch ($course_tool_category)
- {
- case TOOL_PUBLIC:
- $result = Database::query("SELECT * FROM $course_tool_table WHERE visibility=1 ORDER BY id",__FILE__,__LINE__);
- $colLink ="##003399";
- break;
- case TOOL_PUBLIC_BUT_HIDDEN:
- $result = Database::query("SELECT * FROM $course_tool_table WHERE visibility=0 AND admin=0 ORDER BY id",__FILE__,__LINE__);
- $colLink ="##808080";
- break;
- case TOOL_COURSE_ADMIN:
- $result = Database::query("SELECT * FROM $course_tool_table WHERE admin=1 AND visibility != 2 ORDER BY id",__FILE__,__LINE__);
- $colLink ="##003399";
- break;
- case TOOL_PLATFORM_ADMIN:
- $result = Database::query("SELECT * FROM $course_tool_table WHERE visibility = 2 ORDER BY id",__FILE__,__LINE__);
- $colLink ="##003399";
- }
- $i=0;
- // grabbing all the tools from $course_tool_table
- while ($temp_row = Database::fetch_array($result))
- {
- if($course_tool_category == TOOL_PUBLIC_BUT_HIDDEN && $temp_row['image'] != 'scormbuilder.gif')
- {
- $temp_row['image']=str_replace('.gif','_na.gif',$temp_row['image']);
- }
- $all_tools_list[]=$temp_row;
- }
- // grabbing all the links that have the property on_homepage set to 1
- $course_link_table = Database::get_course_table(TABLE_LINK);
- $course_item_property_table = Database::get_course_table(TABLE_ITEM_PROPERTY);
- switch ($course_tool_category)
- {
- case TOOL_PUBLIC:
- $sql_links="SELECT tl.*, tip.visibility
- FROM $course_link_table tl
- LEFT JOIN $course_item_property_table tip ON tip.tool='link' AND tip.ref=tl.id
- WHERE tl.on_homepage='1' AND tip.visibility = 1";
- break;
- case TOOL_PUBLIC_BUT_HIDDEN:
- $sql_links="SELECT tl.*, tip.visibility
- FROM $course_link_table tl
- LEFT JOIN $course_item_property_table tip ON tip.tool='link' AND tip.ref=tl.id
- WHERE tl.on_homepage='1' AND tip.visibility = 0";
- break;
- default:
- $sql_links = null;
- break;
- }
- if( $sql_links != null )
- {
- $properties = array();
- $result_links=Database::query($sql_links,__FILE__,__LINE__);
- while ($links_row=Database::fetch_array($result_links))
- {
- unset($properties);
- $properties['name']=$links_row['title'];
- $properties['link']=$links_row['url'];
- $properties['visibility']=$links_row['visibility'];
- $properties['image']=($course_tool_category == TOOL_PUBLIC_BUT_HIDDEN)?"external_na.gif":"external.gif";
- $properties['adminlink']=api_get_path(WEB_CODE_PATH)."link/link.php?action=editlink&id=".$links_row['id'];
- $all_tools_list[]=$properties;
- }
- }
- if (isset($all_tools_list))
- {
- $lnk = array();
- foreach ($all_tools_list as $toolsRow)
- {
- if (api_get_session_id()!=0 && in_array($toolsRow['name'],array('course_maintenance','course_setting'))) {
- continue;
- }
- if (!($i%2))
- {
- echo "<tr valign=\"top\">\n";
- }
- // NOTE : table contains only the image file name, not full path
- if(!stristr($toolsRow['link'],'http://') && !stristr($toolsRow['link'],'https://') && !stristr($toolsRow['link'],'ftp://'))
- {
- $toolsRow['link']=$web_code_path.$toolsRow['link'];
- }
- if ($course_tool_category == TOOL_PUBLIC_BUT_HIDDEN)
- {
- $class="class=\"invisible\"";
- }
- $qm_or_amp = ((strpos($toolsRow['link'],'?')===FALSE)?'?':'&');
- $toolsRow['link'] = $toolsRow['link'];
- echo '<td width="50%" height="30">';
- if(strpos($toolsRow['name'],'visio_')!==false)
- {
- echo '<a '.$class.' href="javascript: void(0);" onclick="window.open(\'' . htmlspecialchars($toolsRow['link']).(($toolsRow['image']=="external.gif" || $toolsRow['image']=="external_na.gif") ? '' : $qm_or_amp.api_get_cidreq()) . '\',\'window_visio'.$_SESSION['_cid'].'\',config=\'height=\'+730+\', width=\'+1020+\', left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no\')" target="' . $toolsRow['target'] . '">';
- }
- else if(strpos($toolsRow['name'],'chat')!==false && api_get_course_setting('allow_open_chat_window')==true)
- {
- /*
- echo '<a href="#" onclick="window.open(\'' . htmlspecialchars($toolsRow['link']) .(($toolsRow['image']=="external.gif" || $toolsRow['image']=="external_na.gif") ? '' : $qm_or_amp.api_get_cidreq()). '\',\'window_chat'.$_SESSION['_cid'].'\',config=\'height=\'+380+\', width=\'+625+\', left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no\')" target="' . $toolsRow['target'] . '"'.$class.'>';
- */
- echo '<a href="javascript: void(0);" onclick="window.open(\'' . htmlspecialchars($toolsRow['link']).$qm_or_amp.api_get_cidreq() . '\',\'window_chat'.$_SESSION['_cid'].'\',config=\'height=\'+380+\', width=\'+625+\', left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no\')" target="' . $toolsRow['target'] . '"'.$class.'>';
- }
- else
- {
- echo '<a href="'. htmlspecialchars($toolsRow['link']).(($toolsRow['image']=="external.gif" || $toolsRow['image']=="external_na.gif") ? '' : $qm_or_amp.api_get_cidreq()).'" target="' , $toolsRow['target'], '" '.$class.'>';
- }
- /*
- echo Display::return_icon($toolsRow['image'], get_lang(ucfirst($toolsRow['name']))),' ', ($toolsRow['image']=="external.gif" || $toolsRow['image']=="external_na.gif" || $toolsRow['image']=="scormbuilder.gif" || $toolsRow['image']=="blog.gif") ? htmlspecialchars( $toolsRow['name'],ENT_QUOTES,$charset) : get_lang(ucfirst($toolsRow['name'])),'</a>';
- */
- if ($toolsRow['image'] == 'file_html.gif' || $toolsRow['image'] == 'file_html_na.gif'
- || $toolsRow['image'] == 'scormbuilder.gif' || $toolsRow['image'] == 'scormbuilder_na.gif'
- || $toolsRow['image'] == 'blog.gif' || $toolsRow['image'] == 'blog_na.gif'
- || $toolsRow['image'] == 'external.gif' || $toolsRow['image'] == 'external_na.gif')
- {
- $tool_name = htmlspecialchars($toolsRow['name'], ENT_QUOTES, $charset);
- }
- else
- {
- $tool_name = get_lang(ucfirst($toolsRow['name']));
- }
- echo Display::return_icon($toolsRow['image'], $tool_name),' ', $tool_name,'</a>';
- // This part displays the links to hide or remove a tool.
- // These links are only visible by the course manager.
- unset($lnk);
- if (api_is_allowed_to_edit(null,true) && !api_is_coach())
- {
- if ($toolsRow["visibility"] == '1')
- {
- $link['name'] = Display::return_icon('remove.gif', get_lang('Deactivate'));
- $link['cmd'] = "hide=yes";
- $lnk[] = $link;
- }
- if ($course_tool_category == TOOL_PUBLIC_BUT_HIDDEN)
- {
- $link['name'] = Display::return_icon('add.gif', get_lang('Activate'));
- $link['cmd'] = "restore=yes";
- $lnk[] = $link;
- if($toolsRow["added_tool"] == 1)
- {
- $link['name'] = Display::return_icon('delete.gif', get_lang('Remove'));
- $link['cmd'] = "remove=yes";
- $lnk[] = $link;
- }
- }
- if ($toolsRow['adminlink'])
- {
- echo '<a href="'.$toolsRow['adminlink'].'">'.Display::return_icon('edit.gif', get_lang('Edit')).'</a>';
- //echo "edit link:".$properties['adminlink'];
- }
- }
- if ( api_is_platform_admin() )
- {
- if ($toolsRow["visibility"]==2)
- {
- $link['name'] = Display::return_icon('undelete.gif', get_lang('Activate'));
- $link['cmd'] = "hide=yes";
- $lnk[] = $link;
- if($toolsRow["added_tool"] == 1)
- {
- $link['name'] = get_lang("Delete");
- $link['cmd'] = "askDelete=yes";
- $lnk[] = $link;
- }
- }
- if ($toolsRow["visibility"] == 0 && $toolsRow["added_tool"] == 0)
- {
- $link['name'] = Display::return_icon('delete.gif', get_lang('Remove'));
- $link['cmd'] = "remove=yes";
- $lnk[] = $link;
- }
- }
- if (is_array($lnk))
- {
- foreach($lnk as $this_link)
- {
- if (!$toolsRow['adminlink'])
- {
- echo "<a href=\"" .api_get_self(). "?".api_get_cidreq()."&id=" . $toolsRow["id"] . "&" . $this_link['cmd'] . "\">" . $this_link['name'] . "</a>";
- }
- }
- }
- // Allow editing of invisible homepage links (modified external_module)
- /*
- if ($toolsRow["added_tool"] == 1 &&
- api_is_allowed_to_edit() && !$toolsRow["visibility"])
- */
- if ($toolsRow["added_tool"] == 1 && api_is_allowed_to_edit(null,true) && !$toolsRow["visibility"]
- && $toolsRow['image'] != 'scormbuilder.gif' && $toolsRow['image'] != 'scormbuilder_na.gif')
- echo "<a class=\"nobold\" href=\"" . api_get_path(WEB_PATH) .
- 'main/external_module/external_module.php' .
- "?".api_get_cidreq()."&id=".$toolsRow["id"]."\">". get_lang("Edit"). "</a>";
- echo "</td>\n";
- if($i%2)
- {
- echo "</tr>\n";
- }
- $i++;
- }
- }
- if($i%2)
- {
- echo "<td width=\"50%\"> </td>\n",
- "</tr>\n";
- }
- }
- /*
- ==============================================================================
- MAIN CODE
- ==============================================================================
- */
- /*
- -----------------------------------------------------------
- Work with data post askable by admin of course (franglais, clean this)
- -----------------------------------------------------------
- */
- if (api_is_allowed_to_edit(null,true))
- {
- /* Work request */
- /*
- -----------------------------------------------------------
- Modify home page
- -----------------------------------------------------------
- */
- /*
- * display message to confirm that a tool must be hidden from the list of available tools
- * (visibility 0,1->2)
- */
- if($_GET["remove"])
- {
- $msgDestroy=get_lang('DelLk').'<br />';
- $msgDestroy.='<a href="'.api_get_self().'">'.get_lang('No').'</a> | ';
- $msgDestroy.='<a href="'.api_get_self().'?destroy=yes&id='.$_GET["id"].'">'.get_lang('Yes').'</a>';
- Display :: display_confirmation_message($msgDestroy,false);
- }
- /*
- * Process hiding a tools from available tools.
- * visibility=2 are only view by Dokeos Administrator (visibility 0,1->2)
- */
- elseif ($_GET["destroy"])
- {
- Database::query("UPDATE $tool_table SET visibility='2' WHERE id='".$_GET["id"]."'",__FILE__,__LINE__);
- }
- /*
- -----------------------------------------------------------
- HIDE
- -----------------------------------------------------------
- */
- elseif ($_GET["hide"]) // visibility 1 -> 0
- {
- Database::query("UPDATE $tool_table SET visibility=0 WHERE id='".$_GET["id"]."'",__FILE__,__LINE__);
- Display::display_confirmation_message(get_lang('ToolIsNowHidden'));
- }
- /*
- -----------------------------------------------------------
- REACTIVATE
- -----------------------------------------------------------
- */
- elseif ($_GET["restore"]) // visibility 0,2 -> 1
- {
- Database::query("UPDATE $tool_table SET visibility=1 WHERE id='".$_GET["id"]."'",__FILE__,__LINE__);
- Display::display_confirmation_message(get_lang('ToolIsNowVisible'));
- }
- }
- // work with data post askable by admin of course
- if (api_is_platform_admin())
- {
- // Show message to confirm that a tools must be hide from available tools
- // visibility 0,1->2
- if($_GET["askDelete"])
- {
- ?>
- <div id="toolhide">
- <?php echo get_lang("DelLk"); ?>
- <br />
- <a href="<?php echo api_get_self(); ?>"><?php echo get_lang("No"); ?></a> |
- <a href="<?php echo api_get_self(); ?>?delete=yes&id=<?php echo $_GET["id"]; ?>"><?php echo get_lang("Yes"); ?></a>
- </div>
- <?php
- }
- /*
- * Process hiding a tools from available tools.
- * visibility=2 are only view by Dokeos Administrator visibility 0,1->2
- */
- elseif (isset($_GET["delete"]) && $_GET["delete"])
- {
- Database::query("DELETE FROM $tool_table WHERE id='$id' AND added_tool=1",__FILE__,__LINE__);
- }
- }
- /*
- ==============================================================================
- TOOLS VISIBLE FOR EVERYBODY
- ==============================================================================
- */
- echo "<div class=\"everybodyview\">";
- echo "<table width=\"100%\">";
- show_tools(TOOL_PUBLIC);
- echo "</table>";
- echo "</div>";
- /*
- ==============================================================================
- COURSE ADMIN ONLY VIEW
- ==============================================================================
- */
- // start of tools for CourseAdmins (teachers/tutors)
- if (api_is_allowed_to_edit(null,true) && !api_is_coach())
- {
- echo "<div class=\"courseadminview\">";
- echo "<span class=\"viewcaption\">";
- echo get_lang("CourseAdminOnly");
- echo "</span>";
- echo "<table width=\"100%\">";
- show_tools(TOOL_COURSE_ADMIN);
- /*
- -----------------------------------------------------------
- INACTIVE TOOLS - HIDDEN (GREY) LINKS
- -----------------------------------------------------------
- */
- echo "<tr><td colspan=\"4\"><hr style='color:\"#4171B5\"' noshade=\"noshade\" size=\"1\" /></td></tr>\n",
- "<tr>\n",
- "<td colspan=\"4\">\n",
- "<div style=\"margin-bottom: 10px;\"><font color=\"#808080\">\n",get_lang("InLnk"),"</font></div>",
- "</td>\n",
- "</tr>\n";
- show_tools(TOOL_PUBLIC_BUT_HIDDEN);
- echo "</table>";
- echo "</div> ";
- }
- /*
- -----------------------------------------------------------
- Tools for platform admin only
- -----------------------------------------------------------
- */
- if (api_is_platform_admin() && api_is_allowed_to_edit(null,true) && !api_is_coach())
- {
- ?>
- <div class="platformadminview">
- <span class="viewcaption"><?php echo get_lang("PlatformAdminOnly"); ?></span>
- <table width="100%">
- <?php
- show_tools(TOOL_PLATFORM_ADMIN);
- ?>
- </table>
- </div>
- <?php
- }
- ?>
|