2 /****************************************************************************/
4 /****************************************************************************/
5 /* Copyright (c) 2002-2010 */
6 /* Inclusive Design Institute */
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 /****************************************************************************/
15 define('AT_INCLUDE_PATH', '../../../../include/');
16 require (AT_INCLUDE_PATH.'vitals.inc.php');
17 require (AT_INCLUDE_PATH.'../mods/_standard/links/lib/links.inc.php');
19 if (!manage_links()) {
20 $msg->addError('ACCESS_DENIED');
21 header('Location: '.AT_BASE_HREF.'mods/_standard/links/index.php');
25 if (!isset($_POST['approved'])) {
26 $_POST['approved'] = 1;
29 if (isset($_POST['cancel'])) {
30 $msg->addFeedback('CANCELLED');
31 header('Location: '.AT_BASE_HREF.'mods/_standard/links/tools/index.php');
35 if (isset($_POST['add_link']) && isset($_POST['submit'])) {
37 //check category_id and see if user is allowed..
38 $cat = explode('-', $_POST['cat']);
39 $cat_id = intval($cat[0]);
40 $owner_type = intval($cat[1]);
41 $owner_id = intval($cat[2]);
43 if (!links_authenticate($owner_type, $owner_id)) {
44 $msg->addError('ACCESS_DENIED');
45 header('Location: '.AT_BASE_HREF.'mods/_standard/links/index.php');
49 $missing_fields = array();
50 if ($_POST['cat'] == 0 || $_POST['cat'] == '') {
51 $missing_fields[] = _AT('category');
53 if (trim($_POST['title']) == '') {
54 $missing_fields[] = _AT('title');
56 if (trim($_POST['url']) == '' || $_POST['url'] == 'http://') {
57 $missing_fields[] = _AT('url');
59 if (trim($_POST['description']) == '') {
60 $missing_fields[] = _AT('description');
63 if ($missing_fields) {
64 $missing_fields = implode(', ', $missing_fields);
65 $msg->addError(array('EMPTY_FIELDS', $missing_fields));
68 if (!$msg->containsErrors() && isset($_POST['submit'])) {
69 $_POST['title'] = $addslashes($_POST['title']);
70 $_POST['url'] == $addslashes($_POST['url']);
71 $_POST['description'] = $addslashes($_POST['description']);
73 //Check length of the post, if it's exceeded 64 as defined in the db.
74 $_POST['title'] = validate_length($_POST['title'], 64);
75 $_POST['description'] = validate_length($_POST['description'], 250);
77 $name = get_display_name($_SESSION['member_id']);
80 $approved = intval($_POST['approved']);
82 $sql = "INSERT INTO ".TABLE_PREFIX."links VALUES (NULL, $cat_id, '$_POST[url]', '$_POST[title]', '$_POST[description]', $approved, '$name', '$email', NOW(), 0)";
83 mysql_query($sql, $db);
85 $msg->addFeedback('LINK_ADDED');
87 header('Location: '.AT_BASE_HREF.'mods/_standard/links/tools/index.php');
90 $_POST['title'] = stripslashes($_POST['title']);
91 $_POST['url'] == stripslashes($_POST['url']);
92 $_POST['description'] = stripslashes($_POST['description']);
96 if (!isset($_POST['url'])) {
97 $_POST['url'] = 'http://';
100 $categories = get_link_categories(true);
102 if (empty($categories)) {
103 $msg->addError('LINK_CAT_EMPTY');
104 header('Location: '.AT_BASE_HREF.'mods/_standard/links/tools/index.php');
108 $onload = 'document.form.title.focus();';
110 require(AT_INCLUDE_PATH.'header.inc.php');
115 <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="form">
116 <input type="hidden" name="add_link" value="true" />
118 <div class="input-form">
120 <span class="required" title="<?php echo _AT('required_field'); ?>">*</span><label for="title"><?php echo _AT('title'); ?></label><br />
121 <input type="text" name="title" size="40" id="title" value="<?php echo $_POST['title']; ?>"/>
125 <span class="required" title="<?php echo _AT('required_field'); ?>">*</span><label for="cat"><?php echo _AT('category'); ?></label><br />
126 <select name="cat" id="cat"><?php
128 $current_cat_id = $pcat_id;
129 $exclude = false; /* don't exclude the children */
131 $current_cat_id = $cat_id;
132 $exclude = true; /* exclude the children */
134 select_link_categories($categories, 0, $_POST['cat'], FALSE, '', TRUE);
140 <span class="required" title="<?php echo _AT('required_field'); ?>">*</span><label for="url"><?php echo _AT('url'); ?></label><br />
141 <input type="text" name="url" size="40" id="url" value="<?php echo AT_print($_POST['url'], 'input.text'); ?>" />
145 <span class="required" title="<?php echo _AT('required_field'); ?>">*</span><label for="description"><?php echo _AT('description'); ?></label><br />
146 <textarea name="description" cols="55" rows="5" id="description" style="width:90%;"><?php echo AT_print($_POST['description'], 'input.text'); ?></textarea>
150 <?php echo _AT('approve'); ?><br />
152 if ($_POST['approved']) {
153 $y = 'checked="checked"';
155 } else if (isset ($_POST['approved'])) {
156 $n = 'checked="checked"';
159 $y = 'checked="checked"';
163 <input type="radio" id="yes" name="approved" value="1" <?php echo $y; ?>><label for="yes"><?php echo _AT('yes'); ?></label> <input type="radio" id="no" name="approved" value="0" <?php echo $n; ?>><label for="no"><?php echo _AT('no'); ?></label>
166 <div class="row buttons">
167 <input type="submit" name="submit" value="<?php echo _AT('save'); ?>" accesskey="s" />
168 <input type="submit" name="cancel" value="<?php echo _AT('cancel'); ?> " />
173 <?php require(AT_INCLUDE_PATH.'footer.inc.php'); ?>