move code up one directory
[atutor.git] / documentation / common / body_footer.inc.php
1 <?php if (!defined('AT_HANDBOOK')) { exit; } ?>\r
2 <?php\r
3 \r
4         // if ATutor config.inc is available, then:\r
5         // read it for DB info and comments_enabling option.\r
6         // else: use local configuration option for DB/comments option\r
7 \r
8         $enable_user_notes = false;\r
9 \r
10         $config_location = dirname(__FILE__) . '/../../include/config.inc.php';\r
11         if (is_file($config_location) && is_readable($config_location)) {\r
12                 require($config_location);\r
13                 if (defined('DB_HOST')) {\r
14                 \r
15                         $db = @mysql_connect(DB_HOST . ':' . DB_PORT, DB_USER, DB_PASSWORD);\r
16                         @mysql_select_db(DB_NAME, $db);\r
17 \r
18                         // check atutor config table to see if handbook notes is enabled.\r
19                         $sql    = "SELECT value FROM ".TABLE_PREFIX."config WHERE name='user_notes'";\r
20                         $result = @mysql_query($sql, $db);\r
21                         if (($row = mysql_fetch_assoc($result)) && $row['value']) {\r
22                                 define('AT_HANDBOOK_ENABLE', true);\r
23                                 $enable_user_notes = true;\r
24                         } else {\r
25                                 define('AT_HANDBOOK_ENABLE', false);\r
26                         }\r
27                         define('AT_HANDBOOK_DB_TABLE_PREFIX', TABLE_PREFIX);\r
28                 }\r
29         } \r
30         if (!defined('AT_HANDBOOK_ENABLE')) {\r
31                 // use local config file\r
32                 require(dirname(__FILE__) . '/../config.inc.php');\r
33         }\r
34 \r
35         if (defined('AT_HANDBOOK_ENABLE') && AT_HANDBOOK_ENABLE) {\r
36                 if (!$db) {\r
37                         $db = @mysql_connect(AT_HANDBOOK_DB_HOST . ':' . AT_HANDBOOK_DB_PORT, AT_HANDBOOK_DB_USER, AT_HANDBOOK_DB_PASSWORD);\r
38                         @mysql_select_db(AT_HANDBOOK_DB_DATABASE, $db);\r
39                 }\r
40                 if ($db) {\r
41                         $enable_user_notes = true;\r
42                         $sql = "SELECT note_id, date, email, note FROM ".AT_HANDBOOK_DB_TABLE_PREFIX."handbook_notes WHERE section='$section' AND page='$this_page' AND approved=1 ORDER BY date DESC";\r
43                         $result = mysql_query($sql, $db);\r
44                 }\r
45         }\r
46 ?>\r
47 \r
48 <?php if ($enable_user_notes): ?>\r
49         <div class="add-note">\r
50                 <a href="../add_note.php?<?php echo $section . SEP . 'p='.$this_page; ?>" style="float: right;">+ <?php get_text('add_note'); ?> +</a>\r
51                 <h3><?php get_text('user_contributed_notes'); ?></h3>\r
52         </div>\r
53 \r
54         <?php if ($result && mysql_num_rows($result) > 0): ?>\r
55                 <?php while ($row = mysql_fetch_assoc($result)): ?>\r
56                         <div class="note">\r
57                                 <h5><?php echo $row['date']; ?>\r
58                                         <?php if (isset($_SESSION['handbook_admin']) && $_SESSION['handbook_admin']): ?>\r
59                                                 <a href="../delete_note.php?<?php echo $section.SEP.'p='.$this_page.SEP.'id='.$row['note_id']; ?>" onclick="return confirm('<?php get_text('are_you_sure_delete_note'); ?>');"><?php get_text('delete'); ?></a>\r
60                                         <?php endif; ?>\r
61                                 </h5>\r
62                                 <h4><?php echo $row['email'];?></h4>\r
63                                 <p><?php echo nl2br($row['note']); ?></p>\r
64                         </div>\r
65                 <?php endwhile; ?>\r
66         <?php else: ?>\r
67                 <div class="note"><?php get_text('no_notes_on_page'); ?></div>\r
68         <?php endif; ?>\r
69 <?php endif; ?>\r
70 \r
71 <div class="seq">\r
72         <?php if (isset($previous_page)): ?>\r
73                 <?php get_text('previous_chapter'); ?>: <a href="<?php echo $rel_path; ?><?php echo $section; ?>/<?php echo $previous_page; ?>?<?php echo $req_lang; ?>" title="<?php echo $_pages[$previous_page]; ?> Alt+,"><?php echo $_pages[$previous_page]; ?></a><br /> \r
74         <?php endif; ?>\r
75 \r
76         <?php if (isset($next_page)): ?>\r
77                 <?php get_text('next_chapter'); ?>: <a href="<?php echo $rel_path; ?><?php echo $section; ?>/<?php echo $next_page; ?>?<?php echo $req_lang; ?>" title="<?php echo $_pages[$next_page]; ?> Alt+."><?php echo $_pages[$next_page]; ?></a>\r
78         <?php endif; ?>\r
79 </div>\r
80 \r
81 <div class="tag">\r
82         <?php echo htmlspecialchars($lm); ?><br />\r
83         All text is available under the terms of the GNU Free Documentation License. \r
84 </div>\r
85 </body>\r
86 </html>