function polls_get_page_list($page_type, $container_guid = NULL) { global $autofeed; $autofeed = TRUE; $user = elgg_get_logged_in_user_entity(); $params = array(); $options = array('type' => 'object', 'subtype' => 'poll', 'full_view' => FALSE, 'limit' => 15); if ($page_type == 'group') { $group = get_entity($container_guid); if (!elgg_instanceof($group, 'group') || !polls_activated_for_group($group)) { forward(); } $params['title'] = elgg_echo('polls:group_polls:listing:title', array(htmlspecialchars($group->name))); $params['filter'] = ""; // set breadcrumb elgg_push_breadcrumb(elgg_echo("gvgroups:" . $group->grouptype . "groups"), "groups/" . $group->grouptype); elgg_push_breadcrumb($group->name, "polls/group/" . $group->guid); elgg_push_context('groups'); elgg_set_page_owner_guid($container_guid); group_gatekeeper(); $options['container_guid'] = $container_guid; $user_guid = elgg_get_logged_in_user_guid(); if (elgg_get_page_owner_entity()->canWriteToContainer($user_guid)) { elgg_register_menu_item('title', array('name' => 'add', 'href' => "polls/add/" . $container_guid, 'text' => elgg_echo('polls:add'), 'class' => 'elgg-button elgg-button-action')); } } else { switch ($page_type) { case 'owner': $options['owner_guid'] = $container_guid; $container_entity = get_user($container_guid); elgg_push_breadcrumb(elgg_echo("menu:home"), "dashboard"); elgg_push_breadcrumb($container_entity->name, "polls/owner/" . $container_entity->username); if ($user->guid == $container_guid) { $params['title'] = elgg_echo('polls:your'); $params['filter_context'] = 'mine'; } else { $params['title'] = elgg_echo('polls:not_me', array(htmlspecialchars($container_entity->name))); $params['filter_context'] = ""; } break; case 'friends': $container_entity = get_user($container_guid); $friends = get_user_friends($container_guid, ELGG_ENTITIES_ANY_VALUE, 0); $options['container_guids'] = array(); foreach ($friends as $friend) { $options['container_guids'][] = $friend->getGUID(); } $params['filter_context'] = 'friends'; $params['title'] = elgg_echo('polls:friends'); elgg_push_breadcrumb(elgg_echo("menu:home"), "dashboard"); elgg_push_breadcrumb($container_entity->name, "polls/owner/" . $container_entity->username); elgg_push_breadcrumb(elgg_echo('friends')); break; case 'all': elgg_push_breadcrumb(elgg_echo("menu:home"), "dashboard"); elgg_push_breadcrumb(elgg_echo("polls")); $params['filter_context'] = 'all'; $params['title'] = elgg_echo('item:object:poll'); break; } $polls_site_access = elgg_get_plugin_setting('site_access', 'polls'); if (elgg_is_logged_in() && $polls_site_access != 'admins' || elgg_is_admin_logged_in()) { elgg_register_menu_item('title', array('name' => 'add', 'href' => "polls/add", 'text' => elgg_echo('polls:add'), 'class' => 'elgg-button elgg-button-action')); } } if ($page_type == 'friends' && count($options['container_guids']) == 0) { // this person has no friends $params['content'] = ''; } else { $params['content'] = elgg_list_entities($options); } if (!$params['content']) { $params['content'] = elgg_echo('polls:none'); } $params['sidebar'] = elgg_view('polls/sidebar', array('page' => $page_type)); $body = elgg_view_layout("content", $params); return elgg_view_page($params['title'], $body); }
<?php //function polls_get_page_list($page_type, $container_guid = NULL) { $page_type = get_input('page_type'); $container_guid = get_input('group_guid'); $offset = get_input('offset'); global $autofeed; $autofeed = TRUE; $user = elgg_get_logged_in_user_entity(); $params = array(); $options = array('type' => 'object', 'subtype' => 'poll', 'full_view' => FALSE, 'limit' => 15); $base_url = get_input('base_url'); $options['base_url'] = $base_url; if ($page_type == 'group') { $group = get_entity($container_guid); if (!elgg_instanceof($group, 'group') || !polls_activated_for_group($group)) { forward(); } $crumbs_title = $group->name; $params['title'] = elgg_echo('polls:group_polls:listing:title', array(htmlspecialchars($crumbs_title))); $params['filter'] = ""; // set breadcrumb elgg_push_breadcrumb($crumbs_title); elgg_push_context('groups'); elgg_set_page_owner_guid($container_guid); group_gatekeeper(); $options['container_guid'] = $container_guid; $user_guid = elgg_get_logged_in_user_guid(); if (elgg_get_page_owner_entity()->canWriteToContainer($user_guid)) { elgg_register_menu_item('title', array('name' => 'add', 'href' => "polls/add/" . $container_guid, 'text' => elgg_echo('polls:add'), 'link_class' => 'elgg-button elgg-button-action')); }
<?php /** * Group poll view * * @package Elggpoll_extended * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 * @author John Mellberg <*****@*****.**> * @copyright John Mellberg - 2009 * */ if (polls_activated_for_group($vars['entity'])) { ?> <div id="group_pages_widget"> <h2><?php echo elgg_echo('polls:group_polls'); ?> </h2> <?php $limit = 4; set_context("search"); //$objects = list_entities_from_metadata("content_owner",page_owner(), "object","poll",0, 5, false,false,false); if ($polls = get_entities('object', 'poll', 0, 'time_created desc', $limit, 0, false, 0, page_owner())) { foreach ($polls as $pollpost) { echo elgg_view("polls/widget", array('entity' => $pollpost)); } } else { echo elgg_view('page_elements/contentwrapper', array('body' => elgg_echo("group:polls:empty"))); } ?>
/** * Add a menu item to an owner block */ function polls_owner_block_menu($hook, $type, $return, $params) { if (elgg_instanceof($params['entity'], 'user')) { $url = "polls/owner/{$params['entity']->username}"; $item = new ElggMenuItem('polls', elgg_echo('polls'), $url); $return[] = $item; } else { elgg_load_library('elgg:polls'); if (polls_activated_for_group($params['entity'])) { $url = "polls/group/{$params['entity']->guid}/all"; $item = new ElggMenuItem('polls', elgg_echo('polls:group_polls'), $url); $return[] = $item; } } return $return; }
<?php /** * Group poll view * * @package Elggpoll_extended * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 * @author John Mellberg <*****@*****.**> * @copyright John Mellberg - 2009 * */ elgg_load_library('elgg:polls'); elgg_load_js('elgg.polls'); $group = elgg_get_page_owner_entity(); if (polls_activated_for_group($group)) { elgg_push_context('widgets'); $all_link = elgg_view('output/url', array('href' => "polls/group/{$group->guid}/all", 'text' => elgg_echo('link:view:all'), 'is_trusted' => true)); $new_link = elgg_view('output/url', array('href' => "polls/add/{$group->guid}", 'text' => elgg_echo('polls:addpost'), 'is_trusted' => true)); $limit = 4; //$objects = list_entities_from_metadata("content_owner",page_owner(), "object","poll",0, 5, false,false,false); $options = array('type' => 'object', 'subtype' => 'poll', 'container_guid' => elgg_get_page_owner_guid()); $content = ''; if ($polls = elgg_get_entities($options)) { foreach ($polls as $poll) { $content .= '<div class="polls-group-widget-box">' . elgg_view('polls/poll_widget', array('entity' => $poll)) . '</div>'; } } elgg_pop_context(); if (!$content) { $content = '<p>' . elgg_echo("group:polls:empty") . '</p>'; }