3f27259f2bac05e1a8bf1198b6f2b4f061e8776f
[atutor.git] / mods / disclaimer / tac_edit.php
1 <?php
2 /****************************************************************/
3 /* ATutor                                                       */
4 /****************************************************************/
5 /* Copyright (c) 2002-2008                                                                              */
6 /* Adaptive Technology Resource Centre / University of Toronto  */
7 /* http://atutor.ca                                             */
8 /*                                                              */
9 /* This program is free software. You can redistribute it and/or*/
10 /* modify it under the terms of the GNU General Public License  */
11 /* as published by the Free Software Foundation.                                */
12 /****************************************************************/
13 // $Id: tac_edit.php 8319 2009-03-03 16:38:19Z hwong $
14 define('AT_INCLUDE_PATH', '../../include/');
15 require(AT_INCLUDE_PATH.'vitals.inc.php');
16 require(AT_INCLUDE_PATH.'lib/tinymce.inc.php');
17 admin_authenticate(AT_ADMIN_TERMS_AND_CONDITIONS);
18
19 //handle save
20 if (isset($_POST['submit'])){
21         $_POST['enable_terms_and_conditions'] = intval($_POST['enable_terms_and_conditions']);
22         $_POST['formatting'] = intval($_POST['formatting']);
23         $_POST['body_text'] = trim($addslashes($_POST['body_text']));
24         $_POST['tac_link'] = (trim($addslashes($_POST['tac_link']))=='')?AT_BASE_HREF.'about.php':trim($addslashes($_POST['tac_link']));
25         if ($_POST['body_text']!=''){
26                 $sql = 'REPLACE INTO '.TABLE_PREFIX."config VALUES ('tac_link', '$_POST[tac_link]')";
27                 mysql_query($sql, $db);
28
29                 $sql = 'REPLACE INTO '.TABLE_PREFIX."config VALUES ('tac_body', '$_POST[body_text]')";
30                 mysql_query($sql, $db);
31
32                 $sql = 'REPLACE INTO '.TABLE_PREFIX."config VALUES ('enable_terms_and_conditions', $_POST[enable_terms_and_conditions])";
33                 mysql_query($sql, $db);
34
35                 $msg->addFeedback('TAC_SAVED'); 
36         }       
37         header('Location: tac_edit.php');
38         exit;
39 }
40
41 //get config preferences
42 $_POST['body_text'] = htmlentities($_config['tac_body']);
43 $_POST['tac_link'] = htmlentities($_config['tac_link']);
44
45 if (!isset($_REQUEST['setvisual']) && !isset($_REQUEST['settext'])) {
46         if ($_SESSION['prefs']['PREF_CONTENT_EDITOR'] == 1) {
47                 $_POST['formatting'] = 1;
48                 $_REQUEST['settext'] = 0;
49                 $_REQUEST['setvisual'] = 0;
50
51         } else if ($_SESSION['prefs']['PREF_CONTENT_EDITOR'] == 2) {
52                 $_POST['formatting'] = 1;
53                 $_POST['settext'] = 0;
54                 $_POST['setvisual'] = 1;
55
56         } else { // else if == 0
57                 $_POST['formatting'] = 0;
58                 $_REQUEST['settext'] = 0;
59                 $_REQUEST['setvisual'] = 0;
60         }
61 }
62
63 //template goes here
64 include(AT_INCLUDE_PATH.'header.inc.php');
65 if (($_POST['setvisual'] && !$_POST['settext']) || $_GET['setvisual']) {
66         $_SESSION['prefs']['PREF_CONTENT_EDITOR'] = 2;
67         load_editor();
68 } else if ($_POST['formatting']) {
69         $_SESSION['prefs']['PREF_CONTENT_EDITOR'] = 1;
70 } else {
71         $_SESSION['prefs']['PREF_CONTENT_EDITOR'] = 0;
72 }
73 ?>
74 <div class="input-form">
75 <form method="POST" action="<?php echo $_SERVER['PHP_SELF'];?>" name="form" >
76 <div>
77         <div class="row">
78                 <?php echo _AT('enable_terms_and_conditions'); ?> <br />
79                 <input type="radio" name="enable_terms_and_conditions" value="1" id="terms_and_conditions_y" <?php if($_config['enable_terms_and_conditions']) { echo 'checked="checked"'; }?>  /><label for="terms_and_conditions_y"><?php echo _AT('enable'); ?></label> <input type="radio" name="enable_terms_and_conditions" value="0" id="terms_and_conditions_n" <?php if(!$_config['enable_terms_and_conditions']) { echo 'checked="checked"'; }?>  /><label for="terms_and_conditions_n"><?php echo _AT('disable'); ?></label>
80         </div>
81         <div class="row">
82                 <label for="tac_link"><?php echo _AT('tac_link'); ?></label><br/>
83                 <input id="tac_link" type="text" name="tac_link" value="<?php echo $_POST['tac_link']; ?>" size="80"/>
84         </div>
85         <div class="row">
86                 <?php echo _AT('formatting'); ?><br />
87                 <input type="radio" name="formatting" value="0" id="text" <?php if ($_POST['formatting'] == 0) { echo 'checked="checked"'; } ?> onclick="javascript: document.form.setvisual.disabled=true;" <?php if ($_POST['setvisual'] && !$_POST['settext']) { echo 'disabled="disabled"'; } ?> />
88
89                 <label for="text"><?php echo _AT('plain_text'); ?></label>
90                 <input type="radio" name="formatting" value="1" id="html" <?php if ($_POST['formatting'] == 1 || $_POST['setvisual']) { echo 'checked="checked"'; } ?> onclick="javascript: document.form.setvisual.disabled=false;"/>
91
92                 <label for="html"><?php echo _AT('html'); ?></label>
93                 <?php   //Button for enabling/disabling visual editor
94                         if (($_POST['setvisual'] && !$_POST['settext']) || $_GET['setvisual']){
95                                 echo '<input type="hidden" name="setvisual" value="'.$_POST['setvisual'].'" />';
96                                 echo '<input type="submit" name="settext" value="'._AT('switch_text').'" />';
97                         } else {
98                                 echo '<input type="submit" name="setvisual" value="'._AT('switch_visual').'"  ';
99                                 if ($_POST['formatting']==0) { echo 'disabled="disabled"'; }
100                                 echo '/>';
101                         }
102                 ?>
103         </div>
104
105         <div class="row">
106                 <label for='body_text'><?php echo _AT('disclaimer');?></label><br/>
107                 <textarea name="body_text" cols="55" rows="15" id="body_text"><?php echo $_POST['body_text']; ?></textarea>
108         </div>
109
110         <div class="row buttons">
111                 <input type="submit" name="submit" value="<?php echo _AT('save'); ?>" accesskey="s" />
112                 <input type="reset" name="reset" value="<?php echo _AT('reset'); ?> " />
113         </div>
114 </div>
115 </form>
116 </div>
117 <?php include(AT_INCLUDE_PATH.'footer.inc.php'); ?>