$color"; } return $colors; } $user = $_SESSION['user_settings']; if (count($_POST) > 0 && isset($_POST['action'])) { $db = Persistens::getInstance(DBDRIVER); $calconf = $_POST['calendar']; if ($_POST['action'] == 'new') { $row = $calconf; $text = "url={$row['url']}\nuid={$row['uid']}\npwd={$row['pwd']}"; $text = encode($text); $calendar = new CalendarInfo(); $calendar->name = $row['name']; $calendar->color = $row['color']; $calendar->config = $text; $id = $db->addCalendar($user->getUid(), $calendar); if (is_numeric($id)) { $user->addCalendar($id, $calendar); $pageView = "
Calendar was added with id $id
"; } else { $pageView = "$id
"; } } else { foreach ($calconf as $id => $row) { if (! isset($row[check])) continue; if ($_POST['action'] == 'update') { $text = "url={$row['url']}\nuid={$row['uid']}\npwd={$row['pwd']}"; $text = encode($text); $calendar = new CalendarInfo(); $calendar->name = $row['name']; $calendar->color = $row['color']; $calendar->config = $text; $res = $db->updateCalendar($user->getUid(), $id, $calendar); if ($res === TRUE) { $user->addCalendar($id, $calendar); $pageView = "Calendar with id $id was updated
"; } else { $pageView = "$id
"; } } else { $res = $db->deleteCalendar($user->getUid(), $id); if ($res === TRUE) { $user->removeCalendar($id); $pageView = "Calendar with id $id was removed
"; } else { $pageView = "$id
"; } } } } $pageView .= ''; } else if (count($_POST) > 0 && isset($_POST['new'])) { $colors = colors(); $pageView = ''; } else { //var_dump($_SESSION['authenticate']); //var_dump($user); //exit(); $calendars = $user->getCalendars(); //var_dump($calendars); //exit(); $pageView = ''; } print "