aa922a098f44dfe1451925d07d92f778db7965b1
[atutor.git] / docs / mods / _core / languages / language_delete.php
1 <?php
2 /************************************************************************/
3 /* ATutor                                                                                                                               */
4 /************************************************************************/
5 /* Copyright (c) 2002-2010                                              */
6 /* Inclusive Design Institute                                           */
7 /* http://atutor.ca                                                     */
8 /* This program is free software. You can redistribute it and/or        */
9 /* modify it under the terms of the GNU General Public License          */
10 /* as published by the Free Software Foundation.                        */
11 /************************************************************************/
12 // $Id$
13
14 define('AT_INCLUDE_PATH', '../../../include/');
15 require(AT_INCLUDE_PATH.'vitals.inc.php');
16 admin_authenticate(AT_ADMIN_PRIV_LANGUAGES);
17
18 if (isset($_POST['submit_no'])) {
19         $msg->addFeedback('CANCELLED');
20         //shozub -- is this supposed to be lang_codeinstead of delete_lang???
21         header('Location: language.php?lang_code='.$_POST['delete_lang']);
22         exit;
23 }
24
25 if (isset($_POST['submit_yes'])) {
26         require_once(AT_INCLUDE_PATH . '../mods/_core/languages/classes/LanguageEditor.class.php');
27
28         $lang = $languageManager->getLanguage($_POST['lang_code']);
29         $languageEditor = new LanguageEditor($lang);
30         $languageEditor->deleteLanguage();
31
32         $msg->addFeedback('LANG_DELETED');
33         header('Location: language.php');
34         exit;
35 }
36
37
38 $language = $languageManager->getLanguage($_GET['lang_code']);
39 if ($language === FALSE) {
40         $msg->addError('ITEM_NOT_FOUND'); // Originally AT_LANG_NOT_FOUND, make error code
41
42         header('Location: language.php?lang_code='.$_POST['delete_lang']);
43         exit;
44 }
45
46 require(AT_INCLUDE_PATH.'header.inc.php'); 
47
48 $hidden_vars['lang_code'] = $_GET['lang_code'];
49
50 $confirm = array('DELETE_LANG', $language->getEnglishName());
51 $msg->addConfirm($confirm, $hidden_vars);
52 $msg->printConfirm();
53         
54 require(AT_INCLUDE_PATH.'footer.inc.php'); 
55
56 ?>