function poll_get_page_edit($page_type, $guid = 0) { gatekeeper(); // Get the current page's owner $page_owner = elgg_get_page_owner_entity(); if ($page_owner === false || is_null($page_owner)) { $page_owner = elgg_get_logged_in_user_entity(); elgg_set_page_owner_guid($page_owner->guid); } $form_vars = array('id' => 'poll-edit-form'); // Get the post, if it exists if ($page_type == 'edit') { $poll = get_entity($guid); if ($poll instanceof Poll) { $container_guid = $poll->container_guid; elgg_set_page_owner_guid($container_guid); $title = elgg_echo('poll:editpost', array($poll->title)); $body_vars = array('fd' => poll_prepare_edit_body_vars($poll), 'entity' => $poll); if ($poll->canEdit()) { $content = elgg_view_form("poll/edit", $form_vars, $body_vars); } else { $content = elgg_echo('poll:permission_error'); } $container = get_entity($container_guid); if (elgg_instanceof($container, 'group')) { elgg_push_breadcrumb($container->name, 'poll/group/' . $container->getGUID()); } else { elgg_push_breadcrumb($container->name, 'poll/owner/' . $container->username); } elgg_push_breadcrumb(elgg_echo("poll:edit")); } else { $title = elgg_echo('poll:error_title'); $content = elgg_echo('poll:no_such_poll'); } } else { if ($guid) { elgg_set_page_owner_guid($guid); $container = get_entity($guid); elgg_push_breadcrumb($container->name, 'poll/group/' . $container->getGUID()); } else { $user = elgg_get_logged_in_user_entity(); elgg_set_page_owner_guid($user->getGUID()); elgg_push_breadcrumb($user->name, 'poll/owner/' . $user->username); } elgg_push_breadcrumb(elgg_echo('poll:add')); $title = elgg_echo('poll:addpost'); $body_vars = array('fd' => poll_prepare_edit_body_vars(), 'container_guid' => $guid); $content = elgg_view_form("poll/edit", $form_vars, $body_vars); } $params = array('title' => $title, 'content' => $content, 'filter' => ''); $body = elgg_view_layout('content', $params); // Display page return elgg_view_page($title, $body); }
function poll_get_page_edit($page_type, $guid = 0) { gatekeeper(); $form_vars = array('id' => 'poll-edit-form'); // Get the post, if it exists if ($page_type == 'edit') { $poll = get_entity($guid); if (!$poll instanceof Poll) { register_error(elgg_echo('poll:not_found')); forward(REFERER); } if (!$poll->canEdit()) { register_error(elgg_echo('poll:permission_error')); forward(REFERER); } $container = $poll->getContainerEntity(); elgg_set_page_owner_guid($container->guid); $title = elgg_echo('poll:editpost', array($poll->title)); $body_vars = array('fd' => poll_prepare_edit_body_vars($poll), 'entity' => $poll); if ($container instanceof ElggGroup) { elgg_push_breadcrumb($container->name, 'poll/group/' . $container->guid); } else { elgg_push_breadcrumb($container->name, 'poll/owner/' . $container->username); } elgg_push_breadcrumb(elgg_echo("poll:edit")); } else { if ($guid) { $container = get_entity($guid); elgg_push_breadcrumb($container->name, 'poll/group/' . $container->guid); } else { $container = elgg_get_logged_in_user_entity(); elgg_push_breadcrumb($container->name, 'poll/owner/' . $container->username); } elgg_set_page_owner_guid($container->guid); elgg_push_breadcrumb(elgg_echo('poll:add')); $title = elgg_echo('poll:addpost'); $body_vars = array('fd' => poll_prepare_edit_body_vars(), 'container_guid' => $guid); } $content = elgg_view_form("poll/edit", $form_vars, $body_vars); $params = array('title' => $title, 'content' => $content, 'filter' => ''); $body = elgg_view_layout('content', $params); // Display page return elgg_view_page($title, $body); }