diff --git a/main/admin/class_add.php b/main/admin/class_add.php index 92632dda45..0ca969e200 100644 --- a/main/admin/class_add.php +++ b/main/admin/class_add.php @@ -29,48 +29,43 @@ ============================================================================== */ -// name of the language file that needs to be included +// Language files that should be included. $language_file = 'admin'; -// resetting the course id +// Resetting the course id. $cidReset = true; -// including some necessary dokeos files -require_once('../inc/global.inc.php'); -require_once (api_get_path(LIBRARY_PATH).'classmanager.lib.php'); -require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php'); +// Including some necessary dokeos files. +require_once '../inc/global.inc.php'; +require_once api_get_path(LIBRARY_PATH).'classmanager.lib.php'; +require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php'; -// setting the section (for the tabs) +// Setting the section (for the tabs). $this_section = SECTION_PLATFORM_ADMIN; -// Access restrictions +// Access restrictions. api_protect_admin_script(); -// setting breadcrumbs +// Setting breadcrumbs. $interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin')); -// setting the name of the tool +// Setting the name of the tool. $tool_name = get_lang("AddClasses"); $form = new FormValidator('add_class'); -$form->add_textfield('name',get_lang('ClassName')); -$form->addElement('submit','submit',get_lang('Ok')); -if($form->validate()) -{ +$form->add_textfield('name', get_lang('ClassName')); +$form->addElement('style_submit_button', 'submit', get_lang('Ok'), 'class="add"'); +if ($form->validate()) { $values = $form->exportValues(); - ClassManager :: create_class($values['name']); + ClassManager::create_class($values['name']); header('Location: class_list.php'); } -// Displaying the header +// Displaying the header. Display :: display_header($tool_name); -// Displaying the form +// Displaying the form. $form->display(); -/* -============================================================================== - FOOTER -============================================================================== -*/ + +// Displaying the footer. Display :: display_footer(); -?> \ No newline at end of file diff --git a/main/admin/class_edit.php b/main/admin/class_edit.php index 231f046a35..98b2c80b79 100644 --- a/main/admin/class_edit.php +++ b/main/admin/class_edit.php @@ -29,37 +29,36 @@ ============================================================================== */ -// name of the language file that needs to be included +// Language files that should be included. $language_file = 'admin'; -// resetting the course id +// Resetting the course id. $cidReset = true; -// including some necessary dokeos files -include ('../inc/global.inc.php'); -require_once(api_get_path(LIBRARY_PATH).'classmanager.lib.php'); -require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php'); +// Including some necessary dokeos files. +include '../inc/global.inc.php'; +require_once api_get_path(LIBRARY_PATH).'classmanager.lib.php'; +require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php'; -// setting the section (for the tabs) -$this_section=SECTION_PLATFORM_ADMIN; +// Setting the section (for the tabs). +$this_section = SECTION_PLATFORM_ADMIN; -// Access restrictions +// Access restrictions. api_protect_admin_script(); -// setting breadcrumbs -$interbreadcrumb[] = array ("url" => 'index.php', "name" => get_lang('PlatformAdmin')); -$interbreadcrumb[] = array ("url" => "class_list.php", "name" => get_lang('AdminClasses')); - -// setting the name of the tool -$tool_name = get_lang("AddClasses"); +// Setting breadcrumbs. +$interbreadcrumb[] = array ('url' => 'index.php', 'name' => get_lang('PlatformAdmin')); +$interbreadcrumb[] = array ('url' => 'class_list.php', 'name' => get_lang('AdminClasses')); +// Setting the name of the tool. +$tool_name = get_lang('AddClasses'); $tool_name = get_lang('ModifyClassInfo'); $class_id = intval($_GET['idclass']); $class = ClassManager :: get_class_info($class_id); -$form = new FormValidator('edit_class','post','class_edit.php?idclass='.$class_id); +$form = new FormValidator('edit_class', 'post', 'class_edit.php?idclass='.$class_id); $form->add_textfield('name',get_lang('ClassName')); -$form->addElement('submit','submit',get_lang('Ok')); +$form->addElement('style_submit_button', 'submit', get_lang('Ok'), 'class="add"'); $form->setDefaults(array('name'=>$class['name'])); if($form->validate()) { @@ -68,14 +67,9 @@ if($form->validate()) header('Location: class_list.php'); } - Display :: display_header($tool_name); //api_display_tool_title($tool_name); $form->display(); -/* -============================================================================== - FOOTER -============================================================================== -*/ + +// Displaying the footer. Display :: display_footer(); -?> \ No newline at end of file diff --git a/main/admin/class_import.php b/main/admin/class_import.php index b9f121fadd..6cc37427cc 100644 --- a/main/admin/class_import.php +++ b/main/admin/class_import.php @@ -30,100 +30,91 @@ * @package dokeos.admin ============================================================================== */ + /** - * Validate the imported data + * Validates imported data. */ -function validate_data($classes) -{ +function validate_data($classes) { $errors = array(); - foreach($classes as $index => $class) - { - //1. Check if ClassName is available - if(!isset($class['ClassName']) || strlen(trim($class['ClassName'])) == 0) - { - $class['line'] = $index+2; + foreach ($classes as $index => $class) { + // 1. Check wheter ClassName is available. + if (!isset($class['ClassName']) || strlen(trim($class['ClassName'])) == 0) { + $class['line'] = $index + 2; $class['error'] = get_lang('MissingClassName'); $errors[] = $class; } - //2. Check if class doesn't exist yet - else - { - if(ClassManager::class_name_exists($class['ClassName'])) - { - $class['line'] = $index+2; - $class['error'] = get_lang('ClassNameExists'); + // 2. Check whether class doesn't exist yet. + else { + if (ClassManager::class_name_exists($class['ClassName'])) { + $class['line'] = $index + 2; + $class['error'] = get_lang('ClassNameExists').' '.$class['ClassName'].''; $errors[] = $class; } } } return $errors; } + /** * Save imported class data to database */ -function save_data($classes) -{ +function save_data($classes) { $number_of_added_classes = 0; - foreach($classes as $index => $class) - { - if(ClassManager::create_class($class['ClassName'])) - { + foreach ($classes as $index => $class) { + if (ClassManager::create_class($class['ClassName'])) { $number_of_added_classes++; } } return $number_of_added_classes; } - - -// name of the language file that needs to be included +// Language files that should be included. $language_file = array ('admin', 'registration'); -// resetting the course id +// Resetting the course id. $cidReset = true; -// including some necessary dokeos files -include ('../inc/global.inc.php'); -require_once (api_get_path(LIBRARY_PATH).'fileManage.lib.php'); -require_once (api_get_path(LIBRARY_PATH).'classmanager.lib.php'); -require_once (api_get_path(LIBRARY_PATH).'import.lib.php'); -require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php'); +// Including some necessary dokeos files. +include '../inc/global.inc.php'; +require_once api_get_path(LIBRARY_PATH).'fileManage.lib.php'; +require_once api_get_path(LIBRARY_PATH).'classmanager.lib.php'; +require_once api_get_path(LIBRARY_PATH).'import.lib.php'; +require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php'; -// setting the section (for the tabs) +// Setting the section (for the tabs). $this_section = SECTION_PLATFORM_ADMIN; -// Access restrictions +// Access restrictions. api_protect_admin_script(); // setting breadcrumbs -$interbreadcrumb[] = array ("url" => 'index.php', "name" => get_lang('PlatformAdmin')); +$interbreadcrumb[] = array ('url' => 'index.php', 'name' => get_lang('PlatformAdmin')); // Database Table Definitions -// setting the name of the tool +// Setting the name of the tool. $tool_name = get_lang('ImportClassListCSV'); -// Displaying the header +// Displaying the header. Display :: display_header($tool_name); //api_display_tool_title($tool_name); + +set_time_limit(0); + $form = new FormValidator('import_classes'); -$form->addElement('file','import_file',get_lang('ImportCSVFileLocation')); -$form->addElement('submit','submit',get_lang('Ok')); -if( $form->validate()) -{ +$form->addElement('file', 'import_file', get_lang('ImportCSVFileLocation')); +$form->addElement('style_submit_button', 'submit', get_lang('Import'), 'class="save"'); + +if ($form->validate()) { $classes = Import::csv_to_array($_FILES['import_file']['tmp_name']); $errors = validate_data($classes); - if (count($errors) == 0) - { + if (count($errors) == 0) { $number_of_added_classes = save_data($classes); Display::display_normal_message($number_of_added_classes.' '.get_lang('ClassesCreated')); - } - else - { + } else { $error_message = get_lang('ErrorsWhenImportingFile'); $error_message .= '