aboutsummaryrefslogtreecommitdiff
path: root/mod/subgroups/actions/subgroups/add.php
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2014-03-16 21:01:42 -0300
committerSilvio Rhatto <rhatto@riseup.net>2014-03-16 21:01:42 -0300
commit815bb3bf5a5e8da9a7962a4a532c3129f09d5735 (patch)
tree41bec5b730cc3dca936438f9e97810e7ab3ede0a /mod/subgroups/actions/subgroups/add.php
parentc102a5c9f4e9e2f78260019ccab6098435b1df19 (diff)
parent5f6dc365a8445a48156b45912827eac39fd64fc5 (diff)
downloadelgg-815bb3bf5a5e8da9a7962a4a532c3129f09d5735.tar.gz
elgg-815bb3bf5a5e8da9a7962a4a532c3129f09d5735.tar.bz2
Merge commit '5f6dc365a8445a48156b45912827eac39fd64fc5' as 'mod/subgroups'
Diffstat (limited to 'mod/subgroups/actions/subgroups/add.php')
-rw-r--r--mod/subgroups/actions/subgroups/add.php33
1 files changed, 33 insertions, 0 deletions
diff --git a/mod/subgroups/actions/subgroups/add.php b/mod/subgroups/actions/subgroups/add.php
new file mode 100644
index 000000000..92416ea05
--- /dev/null
+++ b/mod/subgroups/actions/subgroups/add.php
@@ -0,0 +1,33 @@
+<?php
+
+elgg_load_library('elgg:subgroups');
+
+$group_guid = get_input('group');
+$othergroup_guid = get_input('othergroup');
+$othergroup_url = get_input('othergroup_url'); // maybe it isn't used
+$group = get_entity($group_guid);
+$othergroup = get_entity($othergroup_guid);
+
+if(!$othergroup && $othergroup = subgroups_get_group_from_url($othergroup_url)){
+ $othergroup_guid = $othergroup->guid;
+}
+
+if ($group instanceof ElggGroup && $group->canEdit() && $othergroup instanceof ElggGroup) {
+ if ($othergroup->canEdit() && $group_guid != $othergroup_guid) {
+ // Check if other group isn't currently a supergroup
+ $tree_group = $group;
+ while ($tree_group->container_guid > 0 && $tree_group->guid != $othergroup_guid) {
+ $tree_group = get_entity($tree_group->container_guid);
+ }
+ // Only save if there isn't circles in the tree.
+ if ($tree_group->guid != $othergroup_guid) {
+ $othergroup->container_guid = $group_guid;
+ $othergroup->save();
+ forward(REFERER);
+ }
+ }
+}
+
+register_error(elgg_echo('subgroups:add:error'));
+forward(REFERER);
+