[svn r15181] Cleanup in link and description tools

skala
Yannick Warnier 18 years ago
parent f705aad0f7
commit 5203267ec7
  1. 18
      main/course_description/index.php
  2. 6
      main/inc/lib/formvalidator/FormValidator.class.php
  3. 138
      main/link/link.php
  4. 17
      main/link/linkfunctions.php

@ -1,9 +1,9 @@
<?php // $Id: index.php 13294 2007-09-27 02:14:48Z yannoo $
<?php // $Id: index.php 15181 2008-04-30 02:12:58Z yannoo $
/*
==============================================================================
Dokeos - elearning and course management software
Copyright (c) 2004 Dokeos S.A.
Copyright (c) 2004 Dokeos SPRL
Copyright (c) 2003 Ghent University (UGent)
Copyright (c) 2001 Universite catholique de Louvain (UCL)
Copyright (c) Bart Mollet, Hogeschool Gent
@ -18,7 +18,7 @@
See the GNU General Public License for more details.
Contact address: Dokeos, 44 rue des palais, B-1030 Brussels, Belgium
Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
Mail: info@dokeos.com
==============================================================================
*/
@ -29,7 +29,7 @@
*
* @author Thomas Depraetere
* @author Hugues Peeters
* @author Christophe Gesché
* @author Christophe Gesché
* @author Olivier brouckaert
* @package dokeos.course_description
==============================================================================
@ -55,7 +55,7 @@ include_once(api_get_path(LIBRARY_PATH).'WCAG/WCAG_rendering.php');
-----------------------------------------------------------
*/
$interbreadcrumb[] = array ("url" => "index.php", "name" => get_lang('CourseProgram'));
//$interbreadcrumb[] = array ("url" => "index.php", "name" => get_lang('CourseProgram'));
if(isset($_GET['description_id']) && $_GET['description_id']==1) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('GeneralDescription'));
if(isset($_GET['description_id']) && $_GET['description_id']==2) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('Objectives'));
@ -67,9 +67,9 @@ if(isset($_GET['description_id']) && $_GET['description_id']==7) $interbreadcrum
if(isset($_GET['description_id']) && $_GET['description_id']==8) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('NewBloc'));
api_protect_course_script();
Display :: display_header($nameTools, "Description");
api_display_tool_title($nameTools);
$nameTools = get_lang('CourseProgram');
Display :: display_header($nameTools, 'Description');
//api_display_tool_title($nameTools);
@ -291,7 +291,7 @@ if ($show_description_list)
echo '<br>';
}
if (count($descriptions) > 0)
if (isset($descriptions) && count($descriptions) > 0)
{
foreach ($descriptions as $id => $description)
{

@ -141,7 +141,11 @@ EOT;
{
$this->addElement('html_editor',$name,$label,'rows="15" cols="80"');
$this->applyFilter($name,'trim');
$html_type = $_SESSION['status'] == COURSEMANAGER ? TEACHER_HTML : STUDENT_HTML;
$html_type = STUDENT_HTML;
if(!empty($_SESSION['status']))
{
$html_type = $_SESSION['status'] == COURSEMANAGER ? TEACHER_HTML : STUDENT_HTML;
}
if($full_page)
{
$html_type = $_SESSION['status'] == COURSEMANAGER ? TEACHER_HTML_FULLPAGE : STUDENT_HTML_FULLPAGE;

@ -3,7 +3,7 @@
==============================================================================
Dokeos - elearning and course management software
Copyright (c) 2004-2008 Dokeos S.A.
Copyright (c) 2004-2008 Dokeos SPRL
Copyright (c) 2003-2005 Ghent University (UGent)
Copyright (c) 2001 Universite catholique de Louvain (UCL)
@ -60,41 +60,41 @@ api_protect_course_script();
// @todo change the $_REQUEST into $_POST or $_GET
// @todo remove this code
$link_submitted = $_POST["submitLink"];
$category_submitted = $_POST["submitCategory"];
$urlview = $_GET["urlview"];
$submitImport = $_POST["submitImport"];
$down = $_GET['down'];
$up = $_GET['up'];
$catmove = $_GET['catmove'];
$editlink = $_REQUEST['editlink'];
$id = $_REQUEST['id'];
$urllink = $_REQUEST['urllink'];
$title = $_REQUEST['title'];
$description = $_REQUEST['description'];
$selectcategory = $_REQUEST['selectcategory'];
$submitLink = $_REQUEST['submitLink'];
$action = $_REQUEST['action'];
$category_title = $_REQUEST['category_title'];
$submitCategory = $_REQUEST['submitCategory'];
$link_submitted = (!empty($_POST['submitLink'])?$_POST['submitLink']:'');
$category_submitted = (!empty($_POST['submitCategory'])?$_POST['submitCategory']:'');
$urlview = (!empty($_GET['urlview'])?$_GET['urlview']:'');
$submitImport = (!empty($_POST['submitImport'])?$_POST['submitImport']:'');
$down = (!empty($_GET['down'])?$_GET['down']:'');
$up = (!empty($_GET['up'])?$_GET['up']:'');
$catmove = (!empty($_GET['catmove'])?$_GET['catmove']:'');
$editlink = (!empty($_REQUEST['editlink'])?$_REQUEST['editlink']:'');
$id = (!empty($_REQUEST['id'])?$_REQUEST['id']:'');
$urllink = (!empty($_REQUEST['urllink'])?$_REQUEST['urllink']:'');
$title = (!empty($_REQUEST['title'])?$_REQUEST['title']:'');
$description = (!empty($_REQUEST['description'])?$_REQUEST['description']:'');
$selectcategory = (!empty($_REQUEST['selectcategory'])?$_REQUEST['selectcategory']:'');
$submitLink = (!empty($_REQUEST['submitLink'])?$_REQUEST['submitLink']:'');
$action = (!empty($_REQUEST['action'])?$_REQUEST['action']:'');
$category_title = (!empty($_REQUEST['category_title'])?$_REQUEST['category_title']:'');
$submitCategory = (!empty($_REQUEST['submitCategory'])?$_REQUEST['submitCategory']:'');
$nameTools = get_lang('Links');
if ($_GET['action']=='addlink')
if (isset($_GET['action']) && $_GET['action']=='addlink')
{
$nameTools = '';
$interbreadcrumb[] = array ('url' => 'link.php', 'name' => get_lang('Links'));
$interbreadcrumb[] = array ('url' => 'link.php?action=addlink', 'name' => get_lang('AddLink'));
}
if ($_GET['action']=='addcategory')
if (isset($_GET['action']) && $_GET['action']=='addcategory')
{
$nameTools = '';
$interbreadcrumb[] = array ('url' => 'link.php', 'name' => get_lang('Links'));
$interbreadcrumb[] = array ('url' => 'link.php?action=addcategory', 'name' => get_lang('AddCategory'));
}
if ($_GET['action']=='editlink')
if (isset($_GET['action']) && $_GET['action']=='editlink')
{
$nameTools = '';
$interbreadcrumb[] = array ('url' => 'link.php', 'name' => get_lang('Links'));
@ -131,54 +131,56 @@ function MM_popupMsg(msg) { //v1.0
*/
$nameTools = get_lang("Links");
switch($_GET['action'])
if(isset($_GET['action']))
{
case "addlink":
if($link_submitted)
{
if(!addlinkcategory("link")) // here we add a link
switch($_GET['action'])
{
case "addlink":
if($link_submitted)
{
unset($submitLink);
if(!addlinkcategory("link")) // here we add a link
{
unset($submitLink);
}
}
}
break;
case "addcategory":
if($category_submitted)
{
if(!addlinkcategory("category")) // here we add a category
break;
case "addcategory":
if($category_submitted)
{
unset($submitCategory);
if(!addlinkcategory("category")) // here we add a category
{
unset($submitCategory);
}
}
}
break;
case "importcsv":
if($_POST["submitImport"])
{
import_csvfile();
}
break;
case "deletelink":
deletelinkcategory("link"); // here we delete a link
break;
case "deletecategory":
deletelinkcategory("category"); // here we delete a category
break;
case "editlink":
editlinkcategory("link"); // here we edit a link
break;
case "editcategory":
editlinkcategory("category"); // here we edit a category
break;
case "visible":
change_visibility($_GET['id'],$_GET['scope']); // here we edit a category
break;
case "invisible":
change_visibility($_GET['id'],$_GET['scope']); // here we edit a category
break;
break;
case "importcsv":
if($_POST["submitImport"])
{
import_csvfile();
}
break;
case "deletelink":
deletelinkcategory("link"); // here we delete a link
break;
case "deletecategory":
deletelinkcategory("category"); // here we delete a category
break;
case "editlink":
editlinkcategory("link"); // here we edit a link
break;
case "editcategory":
editlinkcategory("category"); // here we edit a category
break;
case "visible":
change_visibility($_GET['id'],$_GET['scope']); // here we edit a category
break;
case "invisible":
change_visibility($_GET['id'],$_GET['scope']); // here we edit a category
break;
}
}
/*
-----------------------------------------------------------
Introduction section
@ -187,11 +189,11 @@ switch($_GET['action'])
Display::display_introduction_section(TOOL_LINK);
if (is_allowed_to_edit())
if (is_allowed_to_edit() and isset($_GET['action']))
{
// Displaying the correct title and the form for adding a category or link. This is only shown when nothing
// has been submitted yet, hence !isset($submitLink)
if (($_GET['action']=="addlink" or $_GET['action']=="editlink") and !$_POST['submitLink'])
if (($_GET['action']=="addlink" or $_GET['action']=="editlink") and empty($_POST['submitLink']))
{
echo "<h4>";
if ($_GET['action']=="addlink")
@ -280,16 +282,16 @@ if (is_allowed_to_edit())
}
if (isset($down))
if (!empty($down))
{
movecatlink($down);
}
if (isset($up))
if (!empty($up))
{
movecatlink($up);
}
if ($_GET['action']!='editlink' && $_GET['action']!='addcategory' && $_GET['action']!='addlink' || $link_submitted || $category_submitted)
if (empty($_GET['action']) || ($_GET['action']!='editlink' && $_GET['action']!='addcategory' && $_GET['action']!='addlink') || $link_submitted || $category_submitted)
{
/*
-----------------------------------------------------------
@ -299,7 +301,7 @@ if ($_GET['action']!='editlink' && $_GET['action']!='addcategory' && $_GET['acti
if(is_allowed_to_edit())
{
echo Display::return_icon('file_html_new.gif')." <a href=\"".api_get_self()."?".api_get_cidreq()."&action=addlink&amp;category=".$category."&amp;urlview=$urlview\">".get_lang("LinkAdd")."</a>\n";
echo Display::return_icon('file_html_new.gif')." <a href=\"".api_get_self()."?".api_get_cidreq()."&action=addlink&amp;category=".(!empty($category)?$category:'')."&amp;urlview=$urlview\">".get_lang("LinkAdd")."</a>\n";
echo Display::return_icon('folder_new.gif')." <a href=\"".api_get_self()."?".api_get_cidreq()."&action=addcategory&amp;urlview=".$urlview."\">".get_lang("CategoryAdd")."</a>\n";
/* "<a href=\"".api_get_self()."?".api_get_cidreq()."&action=importcsv&amp;urlview=".$urlview."\">".get_lang('CsvImport')."</a>\n", // RH*/
}

@ -395,7 +395,7 @@ function showlinksofcategory($catid)
echo '<td style="text-align:center;">';
if (api_is_allowed_to_edit())
{
echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&action=editlink&amp;category=$category&amp;id=$myrow[0]&amp;urlview=$urlview\" title=\"".get_lang('Modify')."\" >", "<img src=\"../img/edit.gif\" border=\"0\" alt=\"", get_lang('Modify'), "\" />", "</a>";
echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&action=editlink&amp;category=".(!empty($category)?$category:'')."&amp;id=$myrow[0]&amp;urlview=$urlview\" title=\"".get_lang('Modify')."\" >", "<img src=\"../img/edit.gif\" border=\"0\" alt=\"", get_lang('Modify'), "\" />", "</a>";
echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&action=deletelink&amp;id=", $myrow[0], "&amp;urlview=", $urlview, "\" onclick=\"javascript:if(!confirm('".get_lang('LinkDelconfirm')."')) return false;\" title=\"".get_lang('Delete')."\" >", "<img src=\"../img/delete.gif\" border=\"0\" alt=\"", get_lang('Delete'), "\" />", "</a>";
// DISPLAY MOVE UP COMMAND only if it is not the top link
if ($i != 1)
@ -479,12 +479,12 @@ function movecatlink($catlinkid)
$tbl_link = Database :: get_course_table(TABLE_LINK);
$tbl_categories = Database :: get_course_table(TABLE_LINK_CATEGORY);
if ($_GET['down'])
if (!empty($_GET['down']))
{
$thiscatlinkId = $_GET['down'];
$sortDirection = "DESC";
}
if ($_GET['up'])
if (!empty($_GET['up']))
{
$thiscatlinkId = $_GET['up'];
$sortDirection = "ASC";
@ -500,13 +500,16 @@ function movecatlink($catlinkid)
{
$movetable = $tbl_link;
//getting the category of the link
$sql = "SELECT category_id from ".$movetable." WHERE id='$thiscatlinkId'";
$result = api_sql_query($sql, __FILE__, __LINE__);
$catid = mysql_fetch_array($result);
if(!empty($thiscatlinkId))
{
$sql = "SELECT category_id from ".$movetable." WHERE id='$thiscatlinkId'";
$result = api_sql_query($sql, __FILE__, __LINE__);
$catid = mysql_fetch_array($result);
}
}
// this code is copied and modified from announcements.php
if ($sortDirection)
if (!empty($sortDirection))
{
if (!in_array(trim(strtoupper($sortDirection)), array ('ASC', 'DESC')))
die("Bad sort direction used."); //sanity check of sortDirection var

Loading…
Cancel
Save