2 /****************************************************************/
4 /****************************************************************/
5 /* Copyright (c) 2002-2006 by Greg Gay & Joel Kronenberg */
6 /* Adaptive Technology Resource Centre / University of Toronto */
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 /****************************************************************/
13 // $Id: merlot.php 6614 2006-09-27 19:32:29Z greg $
15 define('AT_INCLUDE_PATH', '../../include/');
16 require (AT_INCLUDE_PATH.'vitals.inc.php');
18 //$_custom_css = $_base_path . 'mods/merlot/module.css'; // use a custom stylesheet
20 $add_to_links = intval($_GET['add_to_links']);
21 $title = stripslashes(htmlspecialchars($_GET['title']));
22 $description = stripslashes(htmlspecialchars($_GET['desc']));
23 $url = stripslashes(htmlspecialchars($_GET['url']));
25 require (AT_INCLUDE_PATH.'lib/links.inc.php');
27 if (isset($_POST['cancel'])) {
28 $msg->addFeedback('CANCELLED');
29 header('Location: '.$_base_href.'mods/merlot/index.php');
31 }else if (isset($_POST['add_link']) && isset($_POST['submit'])) {
32 $missing_fields = array();
33 if ($_POST['cat'] == 0 || $_POST['cat'] == '') {
34 $missing_fields[] = _AT('category');
36 if (trim($_POST['title']) == '') {
37 $missing_fields[] = _AT('title');
39 if (trim($_POST['url']) == '' || $_POST['url'] == 'http://') {
40 $missing_fields[] = _AT('url');
42 if (trim($_POST['description']) == '') {
43 $missing_fields[] = _AT('description');
46 if ($missing_fields) {
47 $missing_fields = implode(', ', $missing_fields);
48 $msg->addError(array('EMPTY_FIELDS', $missing_fields));
51 if (!$msg->containsErrors() && isset($_POST['submit'])) {
53 $_POST['cat'] = intval($_POST['cat']);
54 $_POST['title'] = $addslashes($_POST['title']);
55 $_POST['url'] == $addslashes($_POST['url']);
56 $_POST['description'] = $addslashes($_POST['description']);
58 $name = get_display_name($_SESSION['member_id']);
61 // approve link if submitter is a group member or instructor
62 $sql = "SELECT * from ".TABLE_PREFIX."links_categories WHERE cat_id='$_POST[cat]' AND owner_type='2' ";
63 $result = mysql_query($sql, $db);
65 while($row = mysql_fetch_assoc($result)){
66 $sql2 = "SELECT * from ".TABLE_PREFIX."groups_members WHERE member_id= '$_SESSION[member_id]' AND group_id = '$row[owner_id]' ";
68 if($result2 = mysql_query($sql2, $db)){
73 if($_SESSION['is_admin']){
74 $approved = 1; //approved for instructor submissions
75 }else if($group_member){
76 $approved = 1; //approved for group member submissions to group links
77 }else if(authenticate(AT_PRIV_LINKS, true)){
78 $approved = 1; //approved for privileged user submissions
80 $approved = 0; //not approved for student submissions to course links
83 $sql = "INSERT INTO ".TABLE_PREFIX."links VALUES (NULL, $_POST[cat], '$_POST[url]', '$_POST[title]', '$_POST[description]', $approved, '$name', '$email', NOW(), 0)";
84 mysql_query($sql, $db);
86 $msg->addFeedback('LINK_ADDED');
87 header('Location: '.$_base_href.'mods/merlot/index.php');
90 $_POST['title'] = stripslashes($_POST['title']);
91 $_POST['url'] == stripslashes($_POST['url']);
92 $_POST['description'] = stripslashes($_POST['description']);
96 $onload = 'document.form.title.focus();';
97 $categories = get_link_categories();
99 require(AT_INCLUDE_PATH.'header.inc.php');
103 <h3><?php echo _AT('merlot_add_link'); ?></h3>
106 <form action="<?php echo $_SERVER['PHP_SELF']; ?>#search_results" method="post" name="form">
107 <div class="input-form" style="width: 60%;padding:5px;">
109 <?php echo _AT('merlot_add_to_link_howto'); ?>
112 <input type="hidden" name="add_link" value="true" />
113 <label for="title"><?php echo _AT('merlot_title'); ?></label><br />
114 <input type="text" id="title" name="title" size="70" value="<?php echo $title; ?>" /><br />
116 <label for="description"><?php echo _AT('merlot_description'); ?></label><br />
117 <textarea id="description" name="description" rows="4" cols="60"><?php echo $description; ?></textarea><br />
118 <label for="url"><?php echo _AT('merlot_url'); ?></label> <br />
119 <input type="text" id="url" name="url" size="70" value="<?php echo $url; ?>" /><br />
120 <label for="cat"><?php echo _AT('merlot_category'); ?></label><br />
121 <select name="cat" id="cat"><?php
123 $current_cat_id = $pcat_id;
124 $exclude = false; /* don't exclude the children */
126 $current_cat_id = $cat_id;
127 $exclude = true; /* exclude the children */
129 select_link_categories($categories, 0, $_POST['cat'], FALSE);
134 <div class="row buttons">
135 <input type="submit" name="submit" value="<?php echo _AT('merlot_submit'); ?>" accesskey="s" />
136 <input type="submit" name="cancel" value="<?php echo _AT('merlot_cancel'); ?> " />
146 require(AT_INCLUDE_PATH.'footer.inc.php');