diff options
Diffstat (limited to 'trunk/views/default/event_calendar/forms/add_to_group.php')
-rw-r--r-- | trunk/views/default/event_calendar/forms/add_to_group.php | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/trunk/views/default/event_calendar/forms/add_to_group.php b/trunk/views/default/event_calendar/forms/add_to_group.php new file mode 100644 index 000000000..fc77495e1 --- /dev/null +++ b/trunk/views/default/event_calendar/forms/add_to_group.php @@ -0,0 +1,64 @@ +<?php +// Game plan - display two drop downs: one with a list of groups +// without this event, one with - can add using one and remove using +// the other +// the user must have the authority to edit the groups + +$event_id = $vars['event']->guid; +$event_container = $vars['event']->container_guid; + +// get the list of all groups: + +if (isadminloggedin()) { + $groups = get_entities("group","",0,"",5000); +} else { + $groups = get_entities("group","",get_loggedin_userid(),"",5000); +} + +// split the group list into two lists + +$add_options = array(); +$remove_options = array(); +$remove_group = get_entities_from_relationship("display_on_group",$event_id,FALSE,"","",0,"",5000); +$remove_group_ids = array(); +foreach ($remove_group as $group) { + $remove_group_ids[] = $group->guid; + if ($group->guid != $event_container && $group->canEdit()) { + $remove_options[$group->guid] = $group->name; + } +} + +if ($remove_group) { + foreach($groups as $group) { + if (($group->guid != $event_container) && !in_array($group->guid,$remove_group_ids)) { + $add_options[$group->guid] = $group->name; + } + } +} else { + foreach($groups as $group) { + if ($group->guid != $event_container && $group->canEdit()) { + $add_options[$group->guid] = $group->name; + } + } +} + +if ($add_options || $remove_options) { + echo '<div class="contentWrapper" >'; + $event_bit = elgg_view('input/hidden', array("internalname" => "event_id","value" => $event_id)); + if ($add_options) { + echo "<h4>".elgg_echo('event_calendar:add_to_group:add_group_title')."</h4>"; + $add_pulldown = elgg_view("input/pulldown",array("internalname" => "group_id","options_values" => $add_options)); + $submit_button = "<p>".elgg_view("input/submit",array("value"=>elgg_echo('event_calendar:add_to_group:add_group_button')))."</p>"; + echo elgg_view ('input/form',array("body" => $event_bit.$add_pulldown.$submit_button,"action" => $vars['url']."action/event_calendar/add_to_group")); + } + + if ($remove_options) { + echo "<h4>".elgg_echo('event_calendar:add_to_group:remove_group_title')."</h4>"; + $remove_pulldown = elgg_view("input/pulldown",array("internalname" => "group_id","options_values" => $remove_options)); + $submit_button = "<p>".elgg_view("input/submit",array("value"=>elgg_echo('event_calendar:add_to_group:remove_group_button')))."</p>"; + echo elgg_view ('input/form',array("body" => $event_bit.$remove_pulldown.$submit_button,"action" => $vars['url']."action/event_calendar/remove_from_group")); + } + echo '</div>'; +} + +?>
\ No newline at end of file |