From: Duck (Jakob Munih) Date: Mon, 16 Feb 2009 19:34:11 +0000 (+0100) Subject: continue working on a shared friends groups X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=529cf9da884ce62b229c4c4ced522ff85a71d17c;p=horde.git continue working on a shared friends groups --- diff --git a/folks/edit/groups.php b/folks/edit/groups.php new file mode 100644 index 000000000..eba47dc21 --- /dev/null +++ b/folks/edit/groups.php @@ -0,0 +1,128 @@ + + * @package Folks + */ + +define('FOLKS_BASE', dirname(__FILE__) . '/..'); +require_once FOLKS_BASE . '/lib/base.php'; +require_once 'tabs.php'; + +$title = _("Groups"); + +// Load driver +require_once FOLKS_BASE . '/lib/Friends.php'; +$friends = Folks_Friends::singleton(); + +// Get groups +$groups = $friends->getGroups(); +if ($groups instanceof PEAR_Error) { + $notification->push($groups); + $groups = array(); +} + +// Handle action +$action = Util::getFormData('action'); +switch ($action) { + + case 'delete': + + $g = Util::getFormdata('g'); + $result = $friends->removeGroup($g); + if ($result instanceof PEAR_Error) { + $notification->push($result); + } elseif ($result) { + $notification->push(sprintf(_("Group \"%s\" has been deleted."), $groups[$g]), 'horde.success'); + } + + header('Location: ' . Horde::applicationUrl('edit/groups.php')); + exit; + + break; + + case 'edit': + + $g = Util::getFormdata('g'); + $form = new Horde_Form($vars, _("Rename group"), 'editgroup'); + $form->addHidden('action', 'action', 'text', 'edit'); + $form->addHidden('g', 'g', 'text', 'edit'); + $form->setButtons(array(_("Rename"), _("Cancel")), _("Reset")); + $v = $form->addVariable(_("Old name"), 'old_name', 'text', false, true); + $v->setDefault($groups[$g]); + $v = $form->addVariable(_("New name"), 'new_name', 'text', true); + $v->setDefault($groups[$g]); + + if (Util::getFormData('submitbutton') == _("Cancel")) { + $notification->push(sprintf(_("Group \"%s\" has not been renamed."), $groups[$g]), 'horde.warning'); + header('Location: ' . Horde::applicationUrl('edit/groups.php')); + exit; + } elseif (Util::getFormData('submitbutton') == _("Rename")) { + $new_name = Util::getFormData('new_name'); + $result = $friends->renameGroup($g, $new_name); + if ($result instanceof PEAR_Error) { + $notification->push($result); + } else { + $notification->push(sprintf(_("Group \"%s\" has been renamed to \"%s\"."), $groups[$g], $new_name), 'horde.success'); + header('Location: ' . Horde::applicationUrl('edit/groups.php')); + exit; + } + } + + break; + + default: + + // Manage adding groups + $form = new Horde_Form($vars, _("Add group"), 'addgroup'); + $translated = Horde::loadConfiguration('groups.php', 'groups', 'folks'); + asort($translated); + $form->addHidden('action', 'action', 'text', 'add'); + $form->addVariable(_("Name"), 'translated_name', 'radio', false, false, null, array($translated, true)); + $form->addVariable(_("Name"), 'custom_name', 'text', false, false, _("Enter custom name")); + + if ($form->validate()) { + $form->getInfo(null, $info); + if (empty($info['custom_name'])) { + $name = $info['translated_name']; + } else { + $name = $info['custom_name']; + } + $result = $friends->addGroup($name); + if ($result instanceof PEAR_Error) { + $notification->push($result); + } else { + if (empty($info['custom_name'])) { + $name = $translated[$info['translated_name']]; + } + $notification->push(sprintf(_("Group \"%s\" was success added."), $name), 'horde.success'); + header('Location: ' . Horde::applicationUrl('edit/groups.php')); + exit; + } + } + + break; +} + +$remove_url = Util::addParameter(Horde::applicationUrl('edit/groups.php'), 'action', 'delete'); +$remove_img = Horde::img('delete.png', '', '', $registry->getImageDir('horde')); +$edit_url = Util::addParameter(Horde::applicationUrl('edit/groups.php'), 'action', 'edit'); +$edit_img = Horde::img('edit.png', '', '', $registry->getImageDir('horde')); +$perms_url = Horde::applicationUrl('perms.php'); +$perms_img = Horde::img('perms.png', '', '', $registry->getImageDir('horde')); + +Horde::addScriptFile('popup.js', 'horde', true); + +require FOLKS_TEMPLATES . '/common-header.inc'; +require FOLKS_TEMPLATES . '/menu.inc'; + +echo $tabs->render('groups'); +require FOLKS_TEMPLATES . '/edit/groups.php'; + +require $registry->get('templates', 'horde') . '/common-footer.inc'; \ No newline at end of file diff --git a/folks/templates/edit/groups.php b/folks/templates/edit/groups.php new file mode 100644 index 000000000..a34663b18 --- /dev/null +++ b/folks/templates/edit/groups.php @@ -0,0 +1,22 @@ +renderActive(null, null, '', 'post'); ?> + +

+ + + + + + + + + $grouo_name) { + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; +} +?> + +
' . $grouo_name . '' . $edit_img . ' ' . _("Rename") . '' . $remove_img . ' ' . _("Delete") . '' . $perms_img . ' ' . _("Permissions") . '