chamilo /
chamilo-lms
| 1 | <?php |
||
| 2 | /* For licensing terms, see /license.txt */ |
||
| 3 | |||
| 4 | /** |
||
| 5 | * This script displays a data center edit form. |
||
| 6 | */ |
||
| 7 | require_once '../config.php'; |
||
| 8 | $plugin = SepePlugin::create(); |
||
| 9 | |||
| 10 | if (!empty($_POST)) { |
||
| 11 | $check = Security::check_token('post'); |
||
| 12 | if ($check) { |
||
| 13 | $centerOrigin = Database::escape_string(trim($_POST['center_origin'])); |
||
| 14 | $centerCode = Database::escape_string(trim($_POST['center_code'])); |
||
| 15 | $centerName = Database::escape_string(trim($_POST['center_name'])); |
||
| 16 | $url = Database::escape_string(trim($_POST['url'])); |
||
| 17 | $trackingUrl = Database::escape_string(trim($_POST['tracking_url'])); |
||
| 18 | $phone = Database::escape_string(trim($_POST['phone'])); |
||
| 19 | $mail = Database::escape_string(trim($_POST['mail'])); |
||
| 20 | $id = intval($_POST['id']); |
||
| 21 | |||
| 22 | if (checkIdentificationData()) { |
||
| 23 | $sql = "UPDATE $tableSepeCenter SET |
||
| 24 | center_origin = '".$centerOrigin."', |
||
| 25 | center_code = '".$centerCode."', |
||
| 26 | center_name = '".$centerName."', |
||
| 27 | url = '".$url."', |
||
| 28 | tracking_url = '".$trackingUrl."', |
||
| 29 | phone = '".$phone."', |
||
| 30 | mail = '".$mail."' |
||
| 31 | WHERE id = $id"; |
||
| 32 | } else { |
||
| 33 | $sql = "INSERT INTO $tableSepeCenter ( |
||
| 34 | id, |
||
| 35 | center_origin, |
||
| 36 | center_code, |
||
| 37 | center_name, |
||
| 38 | url, |
||
| 39 | tracking_url, |
||
| 40 | phone, |
||
| 41 | |||
| 42 | ) VALUES ( |
||
| 43 | 1, |
||
| 44 | '".$centerOrigin."', |
||
| 45 | '".$centerCode."', |
||
| 46 | '".$centerName."', |
||
| 47 | '".$url."', |
||
| 48 | '".$trackingUrl."', |
||
| 49 | '".$phone."', |
||
| 50 | '".$mail."' |
||
| 51 | );"; |
||
| 52 | } |
||
| 53 | $res = Database::query($sql); |
||
| 54 | if (!$res) { |
||
|
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
| 55 | $_SESSION['sepe_message_error'] = $plugin->get_lang('NoSaveChange'); |
||
| 56 | } else { |
||
| 57 | $_SESSION['sepe_message_info'] = $plugin->get_lang('SaveChange'); |
||
| 58 | } |
||
| 59 | header("Location: identification-data.php"); |
||
| 60 | } else { |
||
| 61 | $_SESSION['sepe_message_error'] = $plugin->get_lang('ProblemToken'); |
||
| 62 | Security::clear_token(); |
||
| 63 | $token = Security::get_token(); |
||
| 64 | } |
||
| 65 | } else { |
||
| 66 | $token = Security::get_token(); |
||
| 67 | } |
||
| 68 | |||
| 69 | if (api_is_platform_admin()) { |
||
| 70 | $interbreadcrumb[] = [ |
||
| 71 | "url" => "/plugin/sepe/src/sepe-administration-menu.php", |
||
| 72 | "name" => $plugin->get_lang('MenuSepe'), |
||
| 73 | ]; |
||
| 74 | $interbreadcrumb[] = ["url" => "identification-data.php", "name" => $plugin->get_lang('DataCenter')]; |
||
| 75 | $templateName = $plugin->get_lang('DataCenterEdit'); |
||
| 76 | $tpl = new Template($templateName); |
||
| 77 | $info = getInfoIdentificationData(); |
||
| 78 | $tpl->assign('info', $info); |
||
| 79 | if (isset($_SESSION['sepe_message_info'])) { |
||
| 80 | $tpl->assign('message_info', $_SESSION['sepe_message_info']); |
||
| 81 | unset($_SESSION['sepe_message_info']); |
||
| 82 | } |
||
| 83 | if (isset($_SESSION['sepe_message_error'])) { |
||
| 84 | $tpl->assign('message_error', $_SESSION['sepe_message_error']); |
||
| 85 | unset($_SESSION['sepe_message_error']); |
||
| 86 | } |
||
| 87 | $tpl->assign('sec_token', $token); |
||
| 88 | $listing_tpl = 'sepe/view/identification-data-edit.tpl'; |
||
| 89 | $content = $tpl->fetch($listing_tpl); |
||
| 90 | $tpl->assign('content', $content); |
||
| 91 | $tpl->display_one_col_template(); |
||
| 92 | } else { |
||
| 93 | header('Location:'.api_get_path(WEB_PATH)); |
||
| 94 | exit; |
||
| 95 | } |
||
| 96 |