2 /****************************************************************************/
\r
4 /****************************************************************************/
\r
5 /* Copyright (c) 2002-2010 */
\r
6 /* Inclusive Design Institute */
\r
7 /* http://atutor.ca */
\r
9 /* This program is free software. You can redistribute it and/or */
\r
10 /* modify it under the terms of the GNU General Public License */
\r
11 /* as published by the Free Software Foundation. */
\r
12 /****************************************************************************/
\r
15 define('AT_INCLUDE_PATH', '../../../include/');
\r
16 require (AT_INCLUDE_PATH.'vitals.inc.php');
\r
18 if (!$_SESSION['enroll']) {
\r
19 $msg->addInfo('NOT_ENROLLED');
\r
20 require(AT_INCLUDE_PATH.'header.inc.php');
\r
21 require(AT_INCLUDE_PATH.'footer.inc.php');
\r
25 require (AT_INCLUDE_PATH.'../mods/_standard/links/lib/links.inc.php');
\r
27 if (!manage_links()) {
\r
28 $_pages['mods/_standard/links/index.php']['children'] = array('mods/_standard/links/add.php');
\r
31 if (!isset($_POST['url'])) {
\r
32 $_POST['url'] = "http://";
\r
35 if (isset($_POST['cancel'])) {
\r
36 $msg->addFeedback('CANCELLED');
\r
37 header('Location: '.AT_BASE_HREF.'mods/_standard/links/index.php');
\r
39 } else if (isset($_POST['add_link']) && isset($_POST['submit'])) {
\r
40 $missing_fields = array();
\r
41 if ($_POST['cat'] == 0 || $_POST['cat'] == '') {
\r
42 $missing_fields[] = _AT('category');
\r
44 if (trim($_POST['title']) == '') {
\r
45 $missing_fields[] = _AT('title');
\r
47 if (trim($_POST['url']) == '' || $_POST['url'] == 'http://') {
\r
48 $missing_fields[] = _AT('url');
\r
50 if (trim($_POST['description']) == '') {
\r
51 $missing_fields[] = _AT('description');
\r
54 if ($missing_fields) {
\r
55 $missing_fields = implode(', ', $missing_fields);
\r
56 $msg->addError(array('EMPTY_FIELDS', $missing_fields));
\r
60 if (!$msg->containsErrors() && isset($_POST['submit'])) {
\r
62 $_POST['cat'] = intval($_POST['cat']);
\r
63 $_POST['title'] = $addslashes($_POST['title']);
\r
64 $_POST['url'] == $addslashes($_POST['url']);
\r
65 $_POST['description'] = $addslashes($_POST['description']);
\r
67 $name = get_display_name($_SESSION['member_id']);
\r
70 $approved = 0; //not approved for student submissions
\r
72 $sql = "INSERT INTO ".TABLE_PREFIX."links VALUES (NULL, $_POST[cat], '$_POST[url]', '$_POST[title]', '$_POST[description]', $approved, '$name', '$email', NOW(), 0)";
\r
73 mysql_query($sql, $db);
\r
75 $msg->addFeedback('LINK_ADDED');
\r
77 header('Location: '.AT_BASE_HREF.'mods/_standard/links/index.php');
\r
80 $_POST['title'] = stripslashes($_POST['title']);
\r
81 $_POST['url'] == stripslashes($_POST['url']);
\r
82 $_POST['description'] = stripslashes($_POST['description']);
\r
85 $onload = 'document.form.title.focus();';
\r
87 require(AT_INCLUDE_PATH.'header.inc.php');
\r
89 $categories = get_link_categories();
\r
91 if (empty($categories)) {
\r
92 $msg->addInfo('NO_LINK_CATEGORIES');
\r
97 <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="form">
\r
98 <input type="hidden" name="add_link" value="true" />
\r
100 <div class="input-form">
\r
102 <span class="required" title="<?php echo _AT('required_field'); ?>">*</span><label for="title"><?php echo _AT('title'); ?></label><br />
\r
103 <input type="text" name="title" size="40" id="title" value="<?php echo AT_print($_POST['title'], 'input.text'); ?>"/>
\r
107 <span class="required" title="<?php echo _AT('required_field'); ?>">*</span><label for="cat"><?php echo _AT('category'); ?></label><br />
\r
108 <select name="cat" id="cat"><?php
\r
110 $current_cat_id = $pcat_id;
\r
111 $exclude = false; /* don't exclude the children */
\r
113 $current_cat_id = $cat_id;
\r
114 $exclude = true; /* exclude the children */
\r
116 select_link_categories($categories, 0, $_POST['cat'], FALSE);
\r
122 <span class="required" title="<?php echo _AT('required_field'); ?>">*</span><label for="url"><?php echo _AT('url'); ?></label><br />
\r
123 <input type="text" name="url" size="40" id="url" value="<?php echo AT_print($_POST['url'], 'input.text'); ?>" />
\r
127 <span class="required" title="<?php echo _AT('required_field'); ?>">*</span><label for="description"><?php echo _AT('description'); ?></label><br />
\r
128 <textarea name="description" cols="55" rows="2" id="description" ><?php echo AT_print($_POST['description'], 'input.text'); ?></textarea>
\r
131 <div class="row buttons">
\r
132 <input type="submit" name="submit" value="<?php echo _AT('submit'); ?>" accesskey="s" />
\r
133 <input type="submit" name="cancel" value="<?php echo _AT('cancel'); ?> " />
\r
140 require(AT_INCLUDE_PATH.'footer.inc.php'); ?>