Minor cosmetic changes

skala
Julio Montoya 12 years ago
parent 88eaf5d211
commit e700799597
  1. 35
      main/admin/usergroup_import.php
  2. 7
      main/admin/usergroup_user_import.php

@ -1,20 +1,20 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
/** /**
* @package chamilo.admin * @package chamilo.admin
*/ */
/** /**
* Code * Code
* This tool allows platform admins to add classes by uploading a CSV file * This tool allows platform admins to add classes by uploading a CSV file
* @todo Add some langvars to DLTT * @todo Add some langvars to DLTT
*/ */
/** /**
* Validates imported data. * Validates imported data.
*/ */
function validate_data($classes) { function validate_data($classes) {
$errors = array(); $errors = array();
$usergroup = new UserGroup(); $usergroup = new UserGroup();
foreach ($classes as $index => $class) { foreach ($classes as $index => $class) {
// 1. Check wheter ClassName is available. // 1. Check wheter ClassName is available.
if (!isset($class['name']) || strlen(trim($class['name'])) == 0) { if (!isset($class['name']) || strlen(trim($class['name'])) == 0) {
@ -26,7 +26,7 @@ function validate_data($classes) {
else { else {
if ($usergroup->usergroup_exists($class['name'])) { if ($usergroup->usergroup_exists($class['name'])) {
$class['line'] = $index + 2; $class['line'] = $index + 2;
$class['error'] = get_lang('ClassNameExists').' <strong>'.$class['ClassName'].'</strong>'; $class['error'] = get_lang('ClassNameExists') . ' <strong>' . $class['ClassName'] . '</strong>';
$errors[] = $class; $errors[] = $class;
} }
} }
@ -50,15 +50,15 @@ function save_data($classes) {
} }
// Language files that should be included. // Language files that should be included.
$language_file = array ('admin', 'registration'); $language_file = array('admin', 'registration');
// Resetting the course id. // Resetting the course id.
$cidReset = true; $cidReset = true;
// Including some necessary dokeos files. // Including some necessary dokeos files.
include '../inc/global.inc.php'; include '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'fileManage.lib.php'; require_once api_get_path(LIBRARY_PATH) . 'fileManage.lib.php';
require_once api_get_path(LIBRARY_PATH).'import.lib.php'; require_once api_get_path(LIBRARY_PATH) . 'import.lib.php';
// Setting the section (for the tabs). // Setting the section (for the tabs).
$this_section = SECTION_PLATFORM_ADMIN; $this_section = SECTION_PLATFORM_ADMIN;
@ -67,11 +67,10 @@ $this_section = SECTION_PLATFORM_ADMIN;
api_protect_admin_script(); api_protect_admin_script();
// setting breadcrumbs // setting breadcrumbs
$interbreadcrumb[] = array ('url' => 'index.php', 'name' => get_lang('PlatformAdmin')); $interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
$interbreadcrumb[] = array ('url' => 'usergroups.php', 'name' => get_lang('Classes')); $interbreadcrumb[] = array('url' => 'usergroups.php', 'name' => get_lang('Classes'));
// Database Table Definitions // Database Table Definitions
// Setting the name of the tool. // Setting the name of the tool.
$tool_name = get_lang('ImportClassListCSV'); $tool_name = get_lang('ImportClassListCSV');
@ -83,8 +82,7 @@ set_time_limit(0);
$form = new FormValidator('import_classes'); $form = new FormValidator('import_classes');
$form->addElement('file', 'import_file', get_lang('ImportCSVFileLocation')); $form->addElement('file', 'import_file', get_lang('ImportCSVFileLocation'));
$group = array(); $group = array();
$group[] = $form->createElement('radio', 'file_type', '', 'CSV (<a href="example_class.csv" target="_blank">'.get_lang('ExampleCSVFile').'</a>)', 'csv'); $group[] = $form->createElement('radio', 'file_type', '', 'CSV (<a href="example_class.csv" target="_blank">' . get_lang('ExampleCSVFile') . '</a>)', 'csv');
//$group[] = $form->createElement('radio', 'file_type', null, 'XML (<a href="example.xml" target="_blank">'.get_lang('ExampleXMLFile').'</a>)', 'xml');
$form->addGroup($group, '', get_lang('FileType'), '<br/>'); $form->addGroup($group, '', get_lang('FileType'), '<br/>');
$form->addElement('style_submit_button', 'submit', get_lang('Import'), 'class="save"'); $form->addElement('style_submit_button', 'submit', get_lang('Import'), 'class="save"');
@ -93,12 +91,12 @@ if ($form->validate()) {
$errors = validate_data($classes); $errors = validate_data($classes);
if (count($errors) == 0) { if (count($errors) == 0) {
$number_of_added_classes = save_data($classes); $number_of_added_classes = save_data($classes);
Display::display_normal_message($number_of_added_classes.' '.get_lang('Added')); Display::display_normal_message($number_of_added_classes . ' ' . get_lang('Added'));
} else { } else {
$error_message = get_lang('ErrorsWhenImportingFile'); $error_message = get_lang('ErrorsWhenImportingFile');
$error_message .= '<ul>'; $error_message .= '<ul>';
foreach ($errors as $index => $error_class) { foreach ($errors as $index => $error_class) {
$error_message .= '<li>'.$error_class['error'].' ('.get_lang('Line').' '.$error_class['line'].')'; $error_message .= '<li>' . $error_class['error'] . ' (' . get_lang('Line') . ' ' . $error_class['line'] . ')';
$error_message .= '</li>'; $error_message .= '</li>';
} }
$error_message .= '</ul>'; $error_message .= '</ul>';
@ -109,13 +107,12 @@ if ($form->validate()) {
$form->display(); $form->display();
?> ?>
<p><?php echo get_lang('CSVMustLookLike').' ('.get_lang('MandatoryFields').')'; ?> :</p> <p><?php echo get_lang('CSVMustLookLike') . ' (' . get_lang('MandatoryFields') . ')'; ?> :</p>
<pre> <pre>
<b>name;description</b> <b>name;description</b>
"User group 1";"Description" "User group 1";"Description"
</pre> </pre>
<?php <?php
// Displaying the footer. // Displaying the footer.
Display :: display_footer(); Display :: display_footer();

@ -16,13 +16,6 @@ function validate_data($user_classes) {
global $purification_option_for_usernames; global $purification_option_for_usernames;
$errors = array(); $errors = array();
$classcodes = array(); $classcodes = array();
/* if (!isset($_POST['subscribe']) && !isset($_POST['subscribe'])) {
$user_class['error'] = get_lang('SelectAnAction');
$errors[] = $user_class;
return $errors;
} */
$usergroup = new UserGroup(); $usergroup = new UserGroup();
foreach ($user_classes as $index => $user_class) { foreach ($user_classes as $index => $user_class) {

Loading…
Cancel
Save