From 33de97cc48cc2f7d79db38568ee74cb93f7b0041 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Sat, 15 Mar 2014 14:44:13 -0300 Subject: Squashed 'mod/curatedgroups/' content from commit fb2fc6f git-subtree-dir: mod/curatedgroups git-subtree-split: fb2fc6f267b9c3c7e6c5055412b716ce22b34a32 --- views/default/forms/groups/edit.php | 77 +++++++++++++++++++++++++++ views/default/settings/curatedgroups/edit.php | 39 ++++++++++++++ 2 files changed, 116 insertions(+) create mode 100644 views/default/forms/groups/edit.php create mode 100644 views/default/settings/curatedgroups/edit.php (limited to 'views/default') diff --git a/views/default/forms/groups/edit.php b/views/default/forms/groups/edit.php new file mode 100644 index 000000000..72b017832 --- /dev/null +++ b/views/default/forms/groups/edit.php @@ -0,0 +1,77 @@ + + * + * This file is part of the CuratedGroups plugin for Elgg. + * + * CuratedGroups is free software: you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License + * as published by the Free Software Foundation, either version 3 of + * the License, or (at your option) any later version. + * + * CuratedGroups is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public + * License along with this program. If not, see + * . + */ + + $creator=false; + // check if user is admin + if (isadminloggedin()) $creator=true; + + // check if user is one of the specified group creators + if (!$creator) { + $creators_text = str_replace(' ', '', elgg_get_plugin_setting("creators", "curatedgroups")); + $creators = explode(",", $creators_text); + if (!empty($creators)) { + if (in_array(elgg_get_logged_in_user_entity()->username, $creators)) { + $creator = true; + // Compatibility with CuratedGroups 1.0 + } elseif (in_array(elgg_get_logged_in_user_guid(), $creators)) { + $creator = true; + } + } + } + + // check if user is admin of the current group (for editing an + // existing group) + if (!$creator && isset($vars['entity'])) { + if ($vars['entity']->canEdit()) + $creator = true; + } + + // check if user is admin of the parent group if defined (for + // subgroups) + if (!$creator) { + $parent_guid = (int)get_input("parent", 0); + if (!empty($parent_guid)) { + $parent = get_entity($parent_guid); + if ($parent->canEdit()) + $creator = true; + } + } + + // show group creation form if we're a creator, otherwise show the not + // allowed message + if ($creator) { + if (elgg_is_active_plugin("subgroups")) + include elgg_get_plugins_path() . "subgroups/views/default/forms/groups/edit.php"; + else + include elgg_get_plugins_path() . "groups/views/default/forms/groups/edit.php"; + } + else { + $message = elgg_get_plugin_setting("message", "curatedgroups"); + if (empty($message)) + $message = elgg_echo("curatedgroups:message"); + echo $message; + } +?> diff --git a/views/default/settings/curatedgroups/edit.php b/views/default/settings/curatedgroups/edit.php new file mode 100644 index 000000000..9c383b258 --- /dev/null +++ b/views/default/settings/curatedgroups/edit.php @@ -0,0 +1,39 @@ + + * + * This file is part of the CuratedGroups plugin for Elgg. + * + * CuratedGroups is free software: you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License + * as published by the Free Software Foundation, either version 3 of + * the License, or (at your option) any later version. + * + * CuratedGroups is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public + * License along with this program. If not, see + * . + */ +?> +

+ : + 'params[message]', 'value' => $vars['entity']->message)); + ?> +

+ +

+ : + 'params[creators]', 'value' => $vars['entity']->creators)); + ?> +

-- cgit v1.2.3