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
17 require (AT_INCLUDE_PATH.'../mods/_standard/links/lib/links.inc.php');
\r
19 if (!manage_links()) {
\r
20 $msg->addError('ACCESS_DENIED');
\r
21 header('Location: '.AT_BASE_HREF.'mods/_standard/links/index.php');
\r
25 $lid = explode('-', $_REQUEST['lid']);
\r
26 $link_id = intval($lid[0]);
\r
28 if (isset($_POST['cancel'])) {
\r
29 $msg->addFeedback('CANCELLED');
\r
30 header('Location: '.AT_BASE_HREF.'mods/_standard/links/tools/index.php');
\r
32 } else if (isset($_POST['edit_link']) && isset($_POST['submit'])) {
\r
34 $missing_fields = array();
\r
35 if ($_POST['cat'] == 0 || $_POST['cat'] == '') {
\r
36 $missing_fields[] = _AT('category');
\r
38 if (trim($_POST['title']) == '') {
\r
39 $missing_fields[] = _AT('title');
\r
41 if (trim($_POST['url']) == '' || $_POST['url'] == 'http://') {
\r
42 $missing_fields[] = _AT('url');
\r
44 if (trim($_POST['description']) == '') {
\r
45 $missing_fields[] = _AT('description');
\r
48 if ($missing_fields) {
\r
49 $missing_fields = implode(', ', $missing_fields);
\r
50 $msg->addError(array('EMPTY_FIELDS', $missing_fields));
\r
53 if (!$msg->containsErrors() && isset($_POST['submit'])) {
\r
55 $_POST['cat'] = intval($_POST['cat']);
\r
56 $_POST['title'] = $addslashes($_POST['title']);
\r
57 $_POST['url'] == $addslashes($_POST['url']);
\r
58 $_POST['description'] = $addslashes($_POST['description']);
\r
59 //Check length of the post, if it's exceeded 64 as defined in the db.
\r
60 $_POST['title'] = validate_length($_POST['title'], 64);
\r
61 $_POST['description'] = validate_length($_POST['description'], 250);
\r
63 // $name = get_display_name($_SESSION['member_id']);
\r
66 //check if new cat is auth? -- shouldn't be a prob. since cat dropdown is already filtered
\r
68 $sql = "UPDATE ".TABLE_PREFIX."links SET cat_id=$_POST[cat], Url='$_POST[url]', LinkName='$_POST[title]', Description='$_POST[description]', Approved=$_POST[approved] WHERE link_id=".$link_id;
\r
69 mysql_query($sql, $db);
\r
71 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
\r
73 header('Location: '.AT_BASE_HREF.'mods/_standard/links/tools/index.php');
\r
76 $_POST['title'] = $stripslashes($_POST['title']);
\r
77 $_POST['url'] = $stripslashes($_POST['url']);
\r
78 $_POST['description'] = $stripslashes($_POST['description']);
\r
81 $sql = "SELECT * FROM ".TABLE_PREFIX."links WHERE link_id=".$link_id;
\r
82 $result = mysql_query($sql, $db);
\r
83 if ($row = mysql_fetch_assoc($result)) {
\r
85 //auth based on the link's cat
\r
86 $cat_row = get_cat_info($row['cat_id']);
\r
88 if (!links_authenticate($cat_row['owner_type'], $cat_row['owner_id'])) {
\r
89 $msg->addError('ACCESS_DENIED');
\r
90 header('Location: '.AT_BASE_HREF.'mods/_standard/links/tools/index.php');
\r
94 $_POST['title'] = $row['LinkName'];
\r
95 $_POST['cat'] = $row['cat_id'];
\r
96 $_POST['url'] = $row['Url'];
\r
97 $_POST['description'] = $row['Description'];
\r
98 $_POST['approved'] = $row['Approved'];
\r
102 $onload = 'document.form.title.focus();';
\r
103 require(AT_INCLUDE_PATH.'header.inc.php');
\r
105 $categories = get_link_categories(true);
\r
107 $msg->printErrors();
\r
110 <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="form">
\r
111 <input type="hidden" name="edit_link" value="true" />
\r
112 <input type="hidden" name="lid" value="<?php echo $_REQUEST['lid']; ?>" />
\r
114 <div class="input-form">
\r
116 <span class="required" title="<?php echo _AT('required_field'); ?>">*</span><label for="title"><?php echo _AT('title'); ?></label><br />
\r
117 <input type="text" name="title" size="40" id="title" value="<?php echo $_POST['title']; ?>"/>
\r
121 <span class="required" title="<?php echo _AT('required_field'); ?>">*</span><label for="cat"><?php echo _AT('category'); ?></label><br />
\r
122 <select name="cat" id="cat">
\r
123 <?php select_link_categories($categories, 0, $_POST['cat'], FALSE); ?>
\r
128 <span class="required" title="<?php echo _AT('required_field'); ?>">*</span><label for="url"><?php echo _AT('url'); ?></label><br />
\r
129 <input type="text" name="url" size="40" id="url" value="<?php echo $_POST['url']; ?>" />
\r
133 <span class="required" title="<?php echo _AT('required_field'); ?>">*</span><label for="description"><?php echo _AT('description'); ?></label><br />
\r
134 <textarea name="description" cols="55" rows="5" id="description" ><?php echo $_POST['description']; ?></textarea>
\r
138 <?php echo _AT('approve'); ?><br />
\r
140 if ($_POST['approved']) {
\r
141 $y = 'checked="checked"';
\r
144 $n = 'checked="checked"';
\r
148 <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>
\r
151 <div class="row buttons">
\r
152 <input type="submit" name="submit" value="<?php echo _AT('save'); ?>" accesskey="s" />
\r
153 <input type="submit" name="cancel" value="<?php echo _AT('cancel'); ?> " />
\r
158 <?php require(AT_INCLUDE_PATH.'footer.inc.php'); ?>