b98a49e102b0936afb594349a6f8f6442034589e
[atutor.git] / mods / plog / admin_plog.php
1 <?php\r
2 /*\r
3 This is the ATutor admin plog module page. It allows an admin user\r
4 to set or edit  the URL for the plog installation for ATutor, and edit\r
5 the plog location URL.\r
6 */\r
7 define('AT_INCLUDE_PATH', '../../include/');\r
8 require (AT_INCLUDE_PATH.'vitals.inc.php');\r
9 \r
10 // switch the comments in the two lines to switch between LifeType 1.0.2 and 1.1\r
11 //require ('sync_plog11.php');\r
12 require ('sync_plog.php');\r
13 \r
14 \r
15 // Insert the initial pLog location in the ATutor config table\r
16 if($_REQUEST['saved_plog_url'] == 1){\r
17         if($_REQUEST['plog_url'] == ''){\r
18                         $msg->addError('PLOG_URL_ADD_EMPTY');\r
19         }else{\r
20                 $plog_url = addslashes(stripslashes($_REQUEST['plog_url']));\r
21                 $sql = "INSERT INTO ".TABLE_PREFIX."config VALUES('plog', '".$plog_url."')";\r
22                 if(!$result = mysql_query($sql)){\r
23                         $msg->addError('PLOG_URL_ADD_FAILED');\r
24                 }else{\r
25                         $msg->addFeedback('PLOG_URL_ADD_SAVED');\r
26                 }\r
27         }\r
28 }\r
29 \r
30 // Update the pLog location if it is being edited\r
31 if($_REQUEST['edited_plog_url'] == 1){\r
32         if($_REQUEST['plog_url'] == ''){\r
33 \r
34                         $msg->addError('PLOG_URL_ADD_EMPTY');\r
35                         //      $_POST['edit_plog_url'] = 1;\r
36                         \r
37         }else{\r
38 \r
39                 $plog_url = addslashes(stripslashes($_REQUEST['plog_url']));\r
40                 $sql = "UPDATE ".TABLE_PREFIX."config SET  value='".$plog_url."' WHERE name = 'plog'";\r
41                 if(!$result = mysql_query($sql)){\r
42 \r
43                         $msg->addError('PLOG_URL_ADD_FAILED');\r
44 \r
45                 }else{\r
46 \r
47                         $msg->addFeedback('PLOG_URL_ADD_SAVED');\r
48                 }\r
49         }\r
50 }\r
51 \r
52 \r
53 \r
54 //Check to see if the url to plog exists in the db \r
55 $sql = 'SELECT * from '.TABLE_PREFIX.'config WHERE name="plog"';\r
56 $result = mysql_query($sql, $db);\r
57 \r
58 while($row = mysql_fetch_array($result)){\r
59         $plog_url_db = $row[1];\r
60 }\r
61 \r
62 require (AT_INCLUDE_PATH.'header.inc.php');\r
63 \r
64 // Display the form the enter the initial pLog URL, or display the form to edit the location\r
65 if($plog_url_db == '' || $_POST['edit_plog_url']){ \r
66 \r
67 ?>\r
68                 <div class="input-form">\r
69                 <div class="row">\r
70                         <p><?php echo _AT('plog_add_url'); ?>\r
71                 </p>\r
72                         <div class="row buttons">\r
73                         <form action="<?php $_SERVER['PHP_SELF']?>" method="post">\r
74 \r
75                         <?php if($_POST['edit_plog_url']){ ?>\r
76                                 <input type="hidden" name="edited_plog_url" value="1">\r
77                         <?php }else{ ?>\r
78                                 <input type="hidden" name="saved_plog_url" value="1">\r
79                         <?php } ?>\r
80                         <?php if($_POST['edit_plog_url']){ ?>\r
81                                 <input type="text" name="plog_url" value="<?php echo $plog_url_db; ?>" size="80" length="150" />\r
82                                 <?php }else{ ?>\r
83                                 <input type="text" name="plog_url" value="<?php echo $plog_url; ?>" size="80" length="150" />\r
84                         \r
85                         <?php } ?>      \r
86                         <input type="submit" value="<?php echo _AT('plog_save'); ?>" style="botton">\r
87                         </form>\r
88                         </div>\r
89                 </div>\r
90                 </div>\r
91 \r
92 <?php }else{?>\r
93 \r
94                 <div class="input-form">\r
95                 <div class="row">\r
96                         <p><?php echo _AT('plog_sync'); ?></p>\r
97                         <p>     <strong><?php echo $plog_sync; ?> </strong>                                                                     </p>\r
98                         <div class="row buttons">\r
99                         <form action="<?php  $_SERVER['PHP_SELF']; ?>" method="post">\r
100                         <input type="hidden" name="plog_sync" value="1">\r
101                         <input type="submit" value="<?php echo _AT('plog_sync_button'); ?>" style="botton">\r
102                         </form>\r
103                         </div>\r
104                 </div>\r
105                 </div>\r
106                 <div class="input-form">\r
107                 <div class="row">\r
108                         <p><?php echo _AT('plog_location'); ?></p>\r
109                         <p>     <strong><?php echo $plog_url_db; ?> </strong>                                                                   </p>\r
110                         <div class="row buttons">\r
111                         <form action="<?php  $_SERVER['PHP_SELF']; ?>" method="post">\r
112                         <input type="hidden" name="edit_plog_url" value="1">\r
113                         <input type="submit" value="<?php echo _AT('plog_edit'); ?>" style="botton">\r
114                         </form>\r
115                         </div>\r
116                 </div>\r
117                 </div>\r
118 \r
119 \r
120                 <div class="input-form">\r
121                 <div class="row">\r
122 \r
123 <?php } \r
124 // Display the pLog admin screen, or login screen\r
125 ?>\r
126         <iframe name="plog" id="plog" title="pLog" scrolling="yes" src="<?php echo $plog_url_db; ?>admin.php" height="800" width="100%" align="center" style="border:thin white solid; align:center;"></iframe>\r
127 <?php\r
128 \r
129  require (AT_INCLUDE_PATH.'footer.inc.php'); ?>