]>
git.datanom.net - webcal.git/blob - utils/calendar.php
3 require_once 'config.inc.php';
4 require_once 'user_settings.inc.php';
5 require_once 'user_validate.php';
6 require_once 'helper.php';
10 if (! defined($_SESSION['__ROOT__']) && empty($_SESSION['__ROOT__'])) {
13 header('Location: ' . WEB_ROOT
. 'error.html');
17 require_once 'persistens.php';
20 include TOP_FOLDER
.'/include/header.inc.php';
21 include TOP_FOLDER
.'/include/menu.inc.php';
23 function colors($selected = null) {
24 $list = array('aqua', 'black', 'blue', 'fuchsia', 'gray', 'green',
25 'lime', 'maroon', 'navy', 'olive', 'purple', 'red', 'silver',
26 'teal', 'white', 'yellow');
29 foreach ($list as $color) {
30 $colors .= "<option value=\"$color\" style=\"background: $color\"";
31 if ($selected && $selected == $color)
32 $colors .= ' selected="true"';
33 $colors .= ">$color</option>";
38 $user = $_SESSION['user_settings'];
39 if (count($_POST) > 0 && isset($_POST['action'])) {
40 $db = Persistens
::getInstance(DBDRIVER
);
41 $calconf = $_POST['calendar'];
42 if ($_POST['action'] == 'new') {
44 $text = "url={$row['url']}\nuid={$row['uid']}\npwd={$row['pwd']}";
45 $text = encode($text);
46 $calendar = new CalendarInfo();
47 $calendar->name
= $row['name'];
48 $calendar->color
= $row['color'];
49 $calendar->config
= $text;
50 $id = $db->addCalendar($user->getUid(), $calendar);
51 if (is_numeric($id)) {
52 $user->addCalendar($id, $calendar);
53 $pageView = "<p class=\"usermanage\">Calendar was added with id $id</p>";
56 $pageView = "<p class=\"usermanage\">$id</p>";
60 foreach ($calconf as $id => $row) {
61 if (! isset($row[check
]))
63 if ($_POST['action'] == 'update') {
64 $text = "url={$row['url']}\nuid={$row['uid']}\npwd={$row['pwd']}";
65 $text = encode($text);
66 $calendar = new CalendarInfo();
67 $calendar->name
= $row['name'];
68 $calendar->color
= $row['color'];
69 $calendar->config
= $text;
70 $res = $db->updateCalendar($user->getUid(), $id, $calendar);
72 $user->addCalendar($id, $calendar);
73 $pageView = "<p class=\"usermanage\">Calendar with id $id was updated</p>";
76 $pageView = "<p class=\"usermanage\">$id</p>";
80 $res = $db->deleteCalendar($user->getUid(), $id);
82 $user->removeCalendar($id);
83 $pageView = "<p class=\"usermanage\">Calendar with id $id was removed</p>";
86 $pageView = "<p class=\"usermanage\">$id</p>";
91 $pageView .= '</table>';
93 else if (count($_POST) > 0 && isset($_POST['new'])) {
95 $pageView = '<form id="form" action="'.$_SERVER[PHP_SELF
].'" method="post">
96 <table class="config">';
97 $pageView .= "<tr><td>Name</td>
98 <td><input name=\"calendar[name]\" type=\"text\" size=\"20\"/></td>
103 <select name=\"calendar[color]\">
110 <td><input name=\"calendar[url]\" type=\"text\" size=\"50\"/></td>
114 <td><input name=\"calendar[uid]\" type=\"text\" size=\"20\"/></td>
118 <td><input name=\"calendar[pwd]\" type=\"password\" size=\"20\"/></td>
121 <td colspan="6" style="text-align: center">
122 <input type="button" value="Submit"
123 onclick="document.getElementById(\'form\').submit()">
124 <input type="hidden" name="action" value="new"/>
127 $pageView .= '</table></form>';
130 //var_dump($_SESSION['authenticate']);
133 $calendars = $user->getCalendars();
134 //var_dump($calendars);
136 $pageView = '<form id="form" action="'.$_SERVER[PHP_SELF
].'" method="post">
139 if (count($calendars) > 0) {
140 foreach ($calendars as $id => $cal) {
141 $text = decode($cal->config
);
142 $color = colors($cal->color
);
143 $info = implode_cal($text);
144 $pageView .= "<tr><td>Name</td>
145 <td><input name=\"calendar[$id][name]\" type=\"text\" size=\"8\" value=\"{$cal->name}\"/></td>
148 <select name=\"calendar[$id][color]\">
153 <td><input name=\"calendar[$id][url]\" type=\"text\" size=\"40\" value=\"{$info['url']}\"/>
156 <td><input name=\"calendar[$id][uid]\" type=\"text\" size=\"8\" value=\"{$info['uid']}\"/></td>
158 <td><input name=\"calendar[$id][pwd]\" type=\"password\" size=\"8\" value=\"{$info['pwd']}\"/></td>
159 <td><input type=\"checkbox\" name=\"calendar[$id][check]\" value=\"$id\"/></td>
163 <td colspan="11" style="text-align: center">
164 <input type="radio" name="action" value="delete">Delete</input>
165 <input type="radio" name="action" value="update">Update</input>
169 <td colspan="11" style="text-align: center">
170 <input type="button" value="Submit"
171 onclick="document.getElementById(\'form\').submit()">
172 <input type="submit" name="new" value="New Calendar"/>
179 <input type="submit" name="new" value="New Calendar"/>
183 $pageView .= '</table></form>';
185 print "<div id=\"ui\">$pageView</div>";
187 include TOP_FOLDER
.'/include/footer.inc.php';
This page took 0.089063 seconds and 6 git commands to generate.