From 2753d5336d227ee553a2306d4775113dea6c921d Mon Sep 17 00:00:00 2001 From: Jan Schneider Date: Tue, 15 Dec 2009 18:09:25 +0100 Subject: [PATCH] Fix editing remote cals. --- kronolith/calendars/remote_edit.php | 4 ++-- kronolith/lib/Forms/EditRemoteCalendar.php | 26 ++++++++++++-------------- kronolith/templates/calendar_list.php | 4 ++-- 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/kronolith/calendars/remote_edit.php b/kronolith/calendars/remote_edit.php index c2790a668..2905a028e 100644 --- a/kronolith/calendars/remote_edit.php +++ b/kronolith/calendars/remote_edit.php @@ -61,12 +61,12 @@ if ($key) { $vars->set('name', $calendar['name']); $vars->set('url', $calendar['url']); if (isset($calendar['desc'])) { - $vars->set('decription', $calendar['desc']); + $vars->set('desc', $calendar['desc']); } if (isset($calendar['color'])) { $vars->set('color', $calendar['color']); } -$vars->set('username', $username); +$vars->set('user', $username); $vars->set('password', $password); $title = $form->getTitle(); require KRONOLITH_TEMPLATES . '/common-header.inc'; diff --git a/kronolith/lib/Forms/EditRemoteCalendar.php b/kronolith/lib/Forms/EditRemoteCalendar.php index 1ce275d91..33fdfbb4f 100644 --- a/kronolith/lib/Forms/EditRemoteCalendar.php +++ b/kronolith/lib/Forms/EditRemoteCalendar.php @@ -31,45 +31,43 @@ class Kronolith_EditRemoteCalendarForm extends Horde_Form { $this->addVariable(_("Name"), 'name', 'text', true); $v = &$this->addVariable(_("URL"), 'new_url', 'text', true); $v->setDefault($vars->get('url')); - $this->addVariable(_("Username"), 'username', 'text', false); + $this->addVariable(_("Username"), 'user', 'text', false); $this->addVariable(_("Password"), 'password', 'password', false); + $this->addVariable(_("Color"), 'color', 'colorpicker', false); + $this->addVariable(_("Description"), 'desc', 'longtext', false, false, null, array(4, 60)); $this->setButtons(array(_("Save"))); } function execute() { - $name = trim($this->_vars->get('name')); + $info = array(); + foreach (array('name', 'new_url', 'user', 'password', 'color', 'desc') as $key) { + $info[$key == 'new_url' ? 'url' : $key] = $this->_vars->get($key); + } $url = trim($this->_vars->get('url')); - $new_url = trim($this->_vars->get('new_url')); - $username = trim($this->_vars->get('username')); - $password = trim($this->_vars->get('password')); - if (!(strlen($name) && strlen($url))) { + if (!strlen($info['name']) || !strlen($url)) { return false; } - if (strlen($username) || strlen($password)) { + if (strlen($info['username']) || strlen($info['password'])) { $key = Horde_Auth::getCredential('password'); if ($key) { - $username = base64_encode(Horde_Secret::write($key, $username)); - $password = base64_encode(Horde_Secret::write($key, $password)); + $info['username'] = base64_encode(Horde_Secret::write($key, $info['username'])); + $info['password'] = base64_encode(Horde_Secret::write($key, $info['password'])); } } $remote_calendars = unserialize($GLOBALS['prefs']->getValue('remote_cals')); foreach ($remote_calendars as $key => $calendar) { if ($calendar['url'] == $url) { - $remote_calendars[$key]['name'] = $name; - $remote_calendars[$key]['url'] = $new_url; - $remote_calendars[$key]['user'] = $username; - $remote_calendars[$key]['password'] = $password; + $remote_calendars[$key] = $info; break; } } $GLOBALS['prefs']->setValue('remote_cals', serialize($remote_calendars)); - return true; } } diff --git a/kronolith/templates/calendar_list.php b/kronolith/templates/calendar_list.php index b65344006..f28bc76aa 100644 --- a/kronolith/templates/calendar_list.php +++ b/kronolith/templates/calendar_list.php @@ -36,7 +36,7 @@ add('display_cal', 'remote_' . $calendar['url']); echo $url->link(array('title' => _("Click or copy this URL to display this calendar"), 'target' => '_blank')) . htmlspecialchars(shorten_url($url)) . '' ?> - link(array('title' => _("Click or copy this URL to display this calendar"), 'target' => '_blank')) . htmlspecialchars(shorten_url($calendar['url'])) . '' ?> + link(array('title' => _("Click or copy this URL to display this calendar"), 'target' => '_blank')) . htmlspecialchars(shorten_url($calendar['url'])) . '' ?> add('url', $calendar['url'])->link(array('title' => _("Edit"))) . $edit_img . '' ?>   @@ -46,7 +46,7 @@ get('name')) ?> add('display_cal', $calendar->getName()); echo $url->link(array('title' => _("Click or copy this URL to display this calendar"))) . htmlspecialchars(shorten_url($url)) . '' ?> - get('owner') ? $calendar->get('owner') : '-system-') . '/' . $calendar->getName() . '.ics'; echo $url->link(array('title' => _("Click or copy this URL to display this calendar"), 'target' => '_blank')) . htmlspecialchars(shorten_url($url)) . '' ?> + get('owner') ? $calendar->get('owner') : '-system-') . '/' . $calendar->getName() . '.ics'); echo $url->link(array('title' => _("Click or copy this URL to display this calendar"), 'target' => '_blank')) . htmlspecialchars(shorten_url($url)) . '' ?> add('c', $calendar->getName())->link(array('title' => _("Edit"))) . $edit_img . '' ?> add('share', $calendar->getName())->link(array('title' => _("Change Permissions"), 'target' => '_blank', 'onclick' => Horde::popupJs($perms_url_base, array('params' => array('share' => $calendar->getName()), 'urlencode' => true)) . 'return false;')) . $perms_img . '' ?> -- 2.11.0