2 /****************************************************************************/
\r
4 /****************************************************************************/
\r
5 /* Copyright (c) 2002-2008 by Greg Gay, Joel Kronenberg & Heidi Hazelton */
\r
6 /* Adaptive Technology Resource Centre / University of Toronto */
\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
14 define('AT_INCLUDE_PATH', '../include/');
\r
15 require (AT_INCLUDE_PATH.'vitals.inc.php');
\r
17 if (!$_SESSION['enroll']) {
\r
18 $msg->addInfo('NOT_ENROLLED');
\r
19 require(AT_INCLUDE_PATH.'header.inc.php');
\r
20 require(AT_INCLUDE_PATH.'footer.inc.php');
\r
24 require (AT_INCLUDE_PATH.'lib/links.inc.php');
\r
26 if (!manage_links()) {
\r
27 $_pages['links/index.php']['children'] = array('links/add.php');
\r
30 if (!isset($_POST['url'])) {
\r
31 $_POST['url'] = "http://";
\r
34 if (isset($_POST['cancel'])) {
\r
35 $msg->addFeedback('CANCELLED');
\r
36 header('Location: '.AT_BASE_HREF.'links/index.php');
\r
38 } else if (isset($_POST['add_link']) && isset($_POST['submit'])) {
\r
39 $missing_fields = array();
\r
40 if ($_POST['cat'] == 0 || $_POST['cat'] == '') {
\r
41 $missing_fields[] = _AT('category');
\r
43 if (trim($_POST['title']) == '') {
\r
44 $missing_fields[] = _AT('title');
\r
46 if (trim($_POST['url']) == '' || $_POST['url'] == 'http://') {
\r
47 $missing_fields[] = _AT('url');
\r
49 if (trim($_POST['description']) == '') {
\r
50 $missing_fields[] = _AT('description');
\r
53 if ($missing_fields) {
\r
54 $missing_fields = implode(', ', $missing_fields);
\r
55 $msg->addError(array('EMPTY_FIELDS', $missing_fields));
\r
59 if (!$msg->containsErrors() && isset($_POST['submit'])) {
\r
61 $_POST['cat'] = intval($_POST['cat']);
\r
62 $_POST['title'] = $addslashes($_POST['title']);
\r
63 $_POST['url'] == $addslashes($_POST['url']);
\r
64 $_POST['description'] = $addslashes($_POST['description']);
\r
66 $name = get_display_name($_SESSION['member_id']);
\r
69 $approved = 0; //not approved for student submissions
\r
71 $sql = "INSERT INTO ".TABLE_PREFIX."links VALUES (NULL, $_POST[cat], '$_POST[url]', '$_POST[title]', '$_POST[description]', $approved, '$name', '$email', NOW(), 0)";
\r
72 mysql_query($sql, $db);
\r
74 $msg->addFeedback('LINK_ADDED');
\r
76 header('Location: '.AT_BASE_HREF.'links/index.php');
\r
79 $_POST['title'] = stripslashes($_POST['title']);
\r
80 $_POST['url'] == stripslashes($_POST['url']);
\r
81 $_POST['description'] = stripslashes($_POST['description']);
\r
84 $onload = 'document.form.title.focus();';
\r
86 require(AT_INCLUDE_PATH.'header.inc.php');
\r
88 $categories = get_link_categories();
\r
90 if (empty($categories)) {
\r
91 $msg->addInfo('NO_LINK_CATEGORIES');
\r
96 <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="form">
\r
97 <input type="hidden" name="add_link" value="true" />
\r
99 <div class="input-form">
\r
101 <div class="required" title="<?php echo _AT('required_field'); ?>">*</div><label for="title"><?php echo _AT('title'); ?></label><br />
\r
102 <input type="text" name="title" size="40" id="title" value="<?php echo $_POST['title']; ?>"/>
\r
106 <div class="required" title="<?php echo _AT('required_field'); ?>">*</div><label for="cat"><?php echo _AT('category'); ?></label><br />
\r
107 <select name="cat" id="cat"><?php
\r
109 $current_cat_id = $pcat_id;
\r
110 $exclude = false; /* don't exclude the children */
\r
112 $current_cat_id = $cat_id;
\r
113 $exclude = true; /* exclude the children */
\r
115 select_link_categories($categories, 0, $_POST['cat'], FALSE);
\r
121 <div class="required" title="<?php echo _AT('required_field'); ?>">*</div><label for="url"><?php echo _AT('url'); ?></label><br />
\r
122 <input type="text" name="url" size="40" id="url" value="<?php echo $_POST['url']; ?>" />
\r
126 <div class="required" title="<?php echo _AT('required_field'); ?>">*</div><label for="description"><?php echo _AT('description'); ?></label><br />
\r
127 <textarea name="description" cols="55" rows="2" id="description" ><?php echo $_POST['description']; ?></textarea>
\r
130 <div class="row buttons">
\r
131 <input type="submit" name="submit" value="<?php echo _AT('submit'); ?>" accesskey="s" />
\r
132 <input type="submit" name="cancel" value="<?php echo _AT('cancel'); ?> " />
\r
139 require(AT_INCLUDE_PATH.'footer.inc.php'); ?>