/
man_notes.php
73 lines (61 loc) · 3.01 KB
/
man_notes.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
include("../config.php");
include("../include/common.php");
include("../include/db_connect.php");
include("../include/session.php");
if(isset($_SESSION['admin'])) {
$club_id = $_SESSION['admin_club_id'];
$user_id = $_SESSION['user_id'];
if($club_id != 0) {
//first, notes enabled/disabled settings
if(isset($_REQUEST['notesupdate'])) {
$box_enabled = isset($_REQUEST['box_enabled']) ? 1 : 0;
$cat_enabled = isset($_REQUEST['cat_enabled']) ? 1 : 0;
$comment_enabled = isset($_REQUEST['comment_enabled']) ? 1 : 0;
mysql_query("UPDATE admin_notes_settings SET box_enabled = '$box_enabled', cat_enabled = '$cat_enabled', comment_enabled = '$comment_enabled' WHERE user_id = '$user_id'");
$success = "Note preferences updated successfully!";
}
$result = mysql_query("SELECT box_enabled, cat_enabled, comment_enabled FROM admin_notes_settings WHERE user_id='$user_id'");
$box_enabled = false;
$cat_enabled = false;
$comment_enabled = false;
if($row = mysql_fetch_array($result)) {
$box_enabled = $row['box_enabled'] == 1;
$cat_enabled = $row['cat_enabled'] == 1;
$comment_enabled = $row['comment_enabled'] == 1;
}
//now, the categories for the notes_category feature
if(isset($_REQUEST['name']) && isset($_REQUEST['action'])) {
$catName = escape($_REQUEST['name']);
if($_REQUEST['action'] == "delete") {
mysql_query("DELETE FROM club_notes_categories WHERE club_id = '$club_id' AND name = '$catName'");
$success = "Category deleted!";
} else if($_REQUEST['action'] == "add") {
$result = mysql_query("SELECT name FROM club_notes_categories WHERE club_id = '$club_id' AND name = '$catName'");
if($row = mysql_fetch_array($result)) {
$error = "Category already exists!";
} else {
mysql_query("INSERT INTO club_notes_categories (name, club_id) VALUES ('$catName', '$club_id')");
$success = "Category added!";
}
}
}
$result = mysql_query("SELECT name FROM club_notes_categories WHERE club_id = '$club_id'");
$categories = array();
while($row = mysql_fetch_array($result)) {
array_push($categories, $row[0]);
}
if(isset($error)) {
get_page_advanced("man_notes", "admin", array('box_enabled' => $box_enabled, 'cat_enabled' => $cat_enabled, 'comment_enabled' => $comment_enabled, 'categories' => $categories, 'error' => $error));
} else if(isset($success)) {
get_page_advanced("man_notes", "admin", array('box_enabled' => $box_enabled, 'cat_enabled' => $cat_enabled, 'comment_enabled' => $comment_enabled, 'categories' => $categories, 'success' => $success));
} else {
get_page_advanced("man_notes", "admin", array('box_enabled' => $box_enabled, 'cat_enabled' => $cat_enabled, 'comment_enabled' => $comment_enabled, 'categories' => $categories));
}
} else {
get_page_advanced("message", "admin", array('message' => "General application cannot view submissions, so note functions are not available.", 'title' => "Manage Club"));
}
} else {
header('Location: index.php?error=' . urlencode("You are not logged in!"));
}
?>