about summary refs log tree commit diff stats
path: root/series/trunk/admin
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2008-09-14 15:49:20 +0000
committerKelly Rauchenberger <fefferburbia@gmail.com>2008-09-14 15:49:20 +0000
commitabb2d3c67ddc132c4cc7ea435e13731527c32634 (patch)
tree65aa76b08708397dd79cee29f4bc09826825a1bb /series/trunk/admin
parent7bb63b11cd21e97ddece876d46d9e06e81b95a55 (diff)
downloadinstadisc-abb2d3c67ddc132c4cc7ea435e13731527c32634.tar.gz
instadisc-abb2d3c67ddc132c4cc7ea435e13731527c32634.tar.bz2
instadisc-abb2d3c67ddc132c4cc7ea435e13731527c32634.zip
Series: Worked on ACP
Refs #53
Diffstat (limited to 'series/trunk/admin')
-rw-r--r--series/trunk/admin/deletesub.php70
-rw-r--r--series/trunk/admin/editsub.php151
-rw-r--r--series/trunk/admin/mansub.php39
3 files changed, 260 insertions, 0 deletions
diff --git a/series/trunk/admin/deletesub.php b/series/trunk/admin/deletesub.php new file mode 100644 index 0000000..37b0bee --- /dev/null +++ b/series/trunk/admin/deletesub.php
@@ -0,0 +1,70 @@
1<?php
2
3/* InstaDisc Series - A Four Island Project */
4
5/**
6 * require_once() is used to ensure
7 * the ACP files are being called by
8 * admin.php instead of their actual
9 * locations admin/.
10 * The _once() part ensures no problem
11 * arises as includes/instadisc.php has
12 * already been included from admin.php
13 */
14require_once('includes/instadisc.php');
15
16if (!isset($_SESSION['username']))
17{
18 header('Location: index.php');
19}
20
21if (!instaDisc_isAdmin($_SESSION['username']))
22{
23 $subs = instaDisc_listSubscriptions($_SESSION['username']);
24 $i=0;
25 $notfound=1;
26 for ($i=0;isset($subs[$i]);$i++)
27 {
28 if (!isset($_GET['submit']))
29 {
30 if ($subs[$i]['identity'] == $_POST['id'])
31 {
32 $notfound=0;
33 }
34 } else {
35 if ($subs[$i]['id'] == $_GET['subid'])
36 {
37 $notfound=0;
38 }
39 }
40 }
41
42 if ($notfound == 1)
43 {
44 header('Location: index.php');
45 exit;
46 }
47}
48
49if (!isset($_GET['submit']))
50{
51 $template = new FITemplate('deletesub');
52 $template->add('SITENAME',instaDisc_getConfig('siteName'));
53 $template->add('ID',$_GET['subid']);
54
55 $sub = instaDisc_getSubscription($_GET['subid']);
56 $template->add('IDENTITY',$sub['identity']);
57 $template->display();
58} else {
59 if ($_POST['submit'] == 'Yes')
60 {
61 instaDisc_deleteSubscription($_POST['id']);
62
63 $template = new FITemplate('deletedsub');
64 $template->display();
65 } else {
66 header('Location: admin.php?id=main');
67 }
68}
69
70?>
diff --git a/series/trunk/admin/editsub.php b/series/trunk/admin/editsub.php new file mode 100644 index 0000000..cafd217 --- /dev/null +++ b/series/trunk/admin/editsub.php
@@ -0,0 +1,151 @@
1<?php
2
3/* InstaDisc Series - A Four Island Project */
4
5/**
6 * require_once() is used to ensure
7 * the ACP files are being called by
8 * admin.php instead of their actual
9 * locations admin/.
10 * The _once() part ensures no problem
11 * arises as includes/instadisc.php has
12 * already been included from admin.php
13 */
14require_once('includes/instadisc.php');
15
16if (!isset($_SESSION['username']))
17{
18 header('Location: index.php');
19 exit;
20}
21
22if (!instaDisc_isAdmin($_SESSION['username']))
23{
24 $subs = instaDisc_listSubscriptions($_SESSION['username']);
25 $i=0;
26 $notfound=1;
27 for ($i=0;isset($subs[$i]);$i++)
28 {
29 if (!isset($_GET['submit']))
30 {
31 if ($subs[$i]['identity'] == $_POST['id'])
32 {
33 $notfound=0;
34 }
35 } else {
36 if ($subs[$i]['id'] == $_GET['subid'])
37 {
38 $notfound=0;
39 }
40 }
41 }
42
43 if ($notfound == 1)
44 {
45 header('Location: index.php');
46 exit;
47 }
48}
49
50if (!isset($_GET['submit']))
51{
52 $sub = instaDisc_getSubscription($_GET['subid']);
53 showForm($sub['identity'],$sub['title'],$sub['category'],$sub['url'],$sub['password'],array());
54} else {
55 $numOfErrors = 0;
56 $errors = array();
57
58 if ($_POST['title'] == '')
59 {
60 addError($numOfErrors, $errors, 'title', 'Title is a required field');
61 }
62
63 if ($_POST['url'] == '')
64 {
65 addError($numOfErrors, $errors, 'url', 'Subscription URL is a required field');
66 }
67
68 if ($_POST['category'] == '')
69 {
70 addError($numOfErrors, $errors, 'category', 'Category is a required field');
71 }
72
73 if ($numOfErrors > 0)
74 {
75 showForm($_POST['id'], $_POST['title'], $_POST['url'], $_POST['category'], $_POST['password'], $errors);
76 } else {
77 instaDisc_initSubscription($_SESSION['username'], $_POST['id'], $_POST['url'], $_POST['title'], $_POST['category'], $_POST['personal'], $_POST['password']);
78
79 $template = new FITemplate('editedsub');
80 $template->add('SITENAME', instaDisc_getConfig('siteName'));
81 $template->display();
82 }
83}
84
85function showForm($id, $title, $url, $category, $password, $errors)
86{
87 $template = new FITemplate('editsub');
88 $template->add('SITENAME', instaDisc_getConfig('siteName'));
89
90 if (isset($errors[1]))
91 {
92 $template->adds_block('ERROR', array('ex'=>'1'));
93
94 foreach ($errors as $name => $value)
95 {
96 $template->adds_block('ERRORS', array( 'NAME' => $name,
97 'MSG' => $value['msg']));
98 }
99 }
100
101 $template->add('TITLE_ERR', ifErrors($errors, 'title'));
102 $template->add('URL_ERR', ifErrors($errors, 'url'));
103 $template->add('CATEGORY_ERR', ifErrors($errors, 'url'));
104 $template->add('PASSWORD_ERR', ifErrors($errors, 'url'));
105
106 doErrors($template, $errors, 'title');
107 doErrors($template, $errors, 'url');
108 doErrors($template, $errors, 'category');
109 doErrors($template, $errors, 'password');
110
111 $template->add('ID', $id);
112 $template->add('TITLE', $title);
113 $template->add('URL', $url);
114 $template->add('CATEGORY', $category);
115 $template->add('PASSWORD', $password);
116
117 $template->display();
118}
119
120function ifErrors($errors, $id)
121{
122 foreach ($errors as $name => $value)
123 {
124 if ($value['field'] == $id)
125 {
126 return ' error';
127 }
128 }
129
130 return '';
131}
132
133function doErrors($template, $errors, $id)
134{
135 foreach ($errors as $name => $value)
136 {
137 if ($value['field'] == $id)
138 {
139 $template->adds_block(strtoupper($id) . '_ERRS', array( 'NAME' => $name,
140 'VALUE' => $value['msg']));
141 }
142 }
143}
144
145function addError(&$numOfErrors, &$errors, $field, $msg)
146{
147 $numOfErrors++;
148 $errors[$numOfErrors] = array('field' => $field, 'msg' => $msg);
149}
150
151?>
diff --git a/series/trunk/admin/mansub.php b/series/trunk/admin/mansub.php new file mode 100644 index 0000000..358365f --- /dev/null +++ b/series/trunk/admin/mansub.php
@@ -0,0 +1,39 @@
1<?php
2
3/* InstaDisc Series - A Four Island Project */
4
5/**
6 * require_once() is used to ensure
7 * the ACP files are being called by
8 * admin.php instead of their actual
9 * locations admin/.
10 * The _once() part ensures no problem
11 * arises as includes/instadisc.php has
12 * already been included from admin.php
13 */
14require_once('includes/instadisc.php');
15
16if (!isset($_SESSION['username']))
17{
18 header('Location: index.php');
19}
20
21$template = new FITemplate('mansub');
22$template->add('SITENAME', instaDisc_getConfig('siteName'));
23
24if (instaDisc_isAdmin($_SESSION['username']))
25{
26 $subs = instaDisc_getAllSubscriptions();
27} else {
28 $subs = instaDisc_listSubscriptions($_SESSION['username']);
29}
30$i=0;
31for ($i=0;isset($subs[$i]);$i++)
32{
33 $template->adds_block('SUBSCRIPTION', array( 'IDENTITY' => $subs['identity'],
34 'ID' => $subs['id']));
35}
36
37$template->display();
38
39?>