/** * The page handler vor vacaturebank * * @param array $page url segments * * @return bool */ function haarlem_tangram_page_handler($page) { $include_file = false; $pages_root = dirname(dirname(__FILE__)) . '/pages/'; $page_owner_guid = haarlem_tangram_get_page_owner_guid(); if (!empty($page_owner_guid)) { elgg_set_page_owner_guid($page_owner_guid); } switch ($page[0]) { case 'all': $include_file = "{$pages_root}all.php"; break; case 'view': set_input('vacaturenummer', $page[1]); $include_file = "{$pages_root}view.php"; break; default: forward('vacaturebank/all'); break; } if (!empty($include_file)) { include $include_file; return true; } return false; }
function au_subgroups_pagehandler($page) { // dirty check to avoid duplicate page handlers // since this should only be called from the route, groups hook if (strpos(current_page_url(), elgg_get_site_url() . 'au_subgroups') === 0) { return false; } switch ($page[0]) { case 'add': set_input('au_subgroup', true); set_input('au_subgroup_parent_guid', $page[1]); elgg_set_page_owner_guid($page[1]); echo elgg_view('resources/au_subgroups/add'); return true; break; case 'list': elgg_set_page_owner_guid($page[1]); echo elgg_view('resources/au_subgroups/list'); break; case 'delete': elgg_set_page_owner_guid($page[1]); echo elgg_view('resources/au_subgroups/delete'); break; case 'openclosed': set_input('filter', $page[1]); echo elgg_view('resources/au_subgroups/openclosed'); return true; break; } return false; }
/** * Bookmarks page handler; allows the use of fancy URLs * * @param array $page From the page_handler function * @return true|false Depending on success */ function bookmarks_page_handler($page) { // The first component of a bookmarks URL is the username if (isset($page[0])) { set_input('username', $page[0]); } // The second part dictates what we're doing if (isset($page[1])) { switch ($page[1]) { case "read": set_input('guid', $page[2]); @(include dirname(dirname(dirname(__FILE__))) . "/entities/index.php"); return true; break; case "friends": @(include dirname(__FILE__) . "/friends.php"); return true; break; case "inbox": @(include dirname(__FILE__) . "/inbox.php"); return true; break; case "items": @(include dirname(__FILE__) . "/index.php"); return true; break; } // If the URL is just 'bookmarks/username', or just 'bookmarks/', load the standard bookmarks index } else { @(include dirname(__FILE__) . "/index.php"); return true; } return false; }
/** * Route page requests * * @param array $page Array of url parameters * @return bool */ function notifications_page_handler($page) { elgg_gatekeeper(); $current_user = elgg_get_logged_in_user_entity(); // default to personal notifications if (!isset($page[0])) { $page[0] = 'personal'; } if (!isset($page[1])) { forward("notifications/{$page[0]}/{$current_user->username}"); } set_input('username', $page[1]); // note: $user passed in switch ($page[0]) { case 'group': echo elgg_view_resource('notifications/groups'); break; case 'personal': echo elgg_view_resource('notifications/index'); break; default: return false; } return true; }
/** * function to handle the nice urls for Custom Profile Fields * * @param $page * @return unknown_type */ function profile_manager_page_handler($page) { switch ($page[0]) { case "forms": $form = $page[1]; if (!empty($form) && elgg_is_admin_logged_in()) { set_input("guid", $page[2]); include dirname(__FILE__) . "/pages/forms/" . $form . ".php"; return true; } break; case "validate_username": if (elgg_is_logged_in()) { $new_username = get_input("username"); $valid = false; if (!empty($new_username)) { $valid = profile_manager_validate_username($new_username); } $result = array("valid" => $valid); echo json_encode($result); return true; } break; case "user_summary_control": include dirname(__FILE__) . "/pages/user_summary_control/preview.php"; return true; } }
/** * Messageboard dispatcher for flat message board. * Profile (and eventually group) widgets handle their own. * * URLs take the form of * User's messageboard: messageboard/owner/<username> * Y's history of posts on X's board: messageboard/owner/<X>/history/<Y> * New post: messageboard/add/<guid> (container: user or group) * Group messageboard: messageboard/group/<guid>/all (not implemented) * * @param array $page Array of page elements * @return bool */ function messageboard_page_handler($page) { $pages = dirname(__FILE__) . '/pages/messageboard'; switch ($page[0]) { case 'owner': //@todo if they have the widget disabled, don't allow this. $owner_name = elgg_extract(1, $page); $owner = get_user_by_username($owner_name); set_input('page_owner_guid', $owner->guid); $history = elgg_extract(2, $page); $username = elgg_extract(3, $page); if ($history && $username) { set_input('history_username', $username); } include "{$pages}/owner.php"; break; case 'add': $container_guid = elgg_extract(1, $page); set_input('container_guid', $container_guid); include "{$pages}/add.php"; break; case 'group': elgg_group_gatekeeper(); $owner_guid = elgg_extract(1, $page); set_input('page_owner_guid', $owner_guid); include "{$pages}/owner.php"; break; default: return false; } return true; }
/** * Messageboard dispatcher for flat message board. * Profile (and eventually group) widgets handle their own. * * URLs take the form of * User's messageboard: messageboard/owner/<username> * Y's history of posts on X's board: messageboard/owner/<X>/history/<Y> * New post: messageboard/add/<guid> (container: user or group) * Group messageboard: messageboard/group/<guid>/all (not implemented) * * @param array $page Array of page elements * @return bool */ function messageboard_page_handler($page) { switch ($page[0]) { case 'owner': //@todo if they have the widget disabled, don't allow this. $owner_name = elgg_extract(1, $page); $owner = get_user_by_username($owner_name); set_input('page_owner_guid', $owner->guid); $history = elgg_extract(2, $page); $username = elgg_extract(3, $page); if ($history && $username) { set_input('history_username', $username); } echo elgg_view('resources/messageboard/owner'); break; case 'add': $container_guid = elgg_extract(1, $page); set_input('container_guid', $container_guid); echo elgg_view('resources/messageboard/add'); break; case 'group': elgg_group_gatekeeper(); $owner_guid = elgg_extract(1, $page); set_input('page_owner_guid', $owner_guid); echo elgg_view('resources/messageboard/owner'); break; default: return false; } return true; }
/** * Unserialize tokeninput field values before performing an action */ function elgg_tokeninput_explode_field_values($hook, $type, $return, $params) { $elgg_tokeninput_fields = (array) get_input('elgg_tokeninput_fields', array()); $elgg_tokneinput_autocomplete = (array) get_input('elgg_tokeninput_autocomplete', array()); if (!empty($elgg_tokeninput_fields)) { foreach ($elgg_tokeninput_fields as $field_name) { $values = explode(',', get_input($field_name, '')); if (in_array($field_name, $elgg_tokneinput_autocomplete)) { foreach ($values as $key => $value) { $user = get_entity($value); if ($user instanceof ElggUser) { $values[$key] = $user->username; } } if (sizeof($values) === 1) { $values = array_values($values)[0]; } } set_input($field_name, $values); } } set_input('elgg_tokeninput_fields', null); set_input('elgg_tokeninput_autocomplete', null); return $return; }
function group_tools_route_groups_handler($hook, $type, $return_value, $params) { /** * $return_value contains: * $return_value['handler'] => requested handler * $return_value['segments'] => url parts ($page) */ $result = $return_value; if (!empty($return_value) && is_array($return_value)) { $page = $return_value['segments']; switch ($page[0]) { case "all": $filter = get_input("filter"); if (empty($filter) && ($default_filter = elgg_get_plugin_setting("group_listing", "group_tools"))) { $filter = $default_filter; set_input("filter", $default_filter); } if (in_array($filter, array("open", "closed", "alpha"))) { // we will handle the output $result = false; include dirname(dirname(__FILE__)) . "/pages/groups/all.php"; } break; case "requests": $result = false; set_input("group_guid", $page[1]); include dirname(dirname(__FILE__)) . "/pages/groups/membershipreq.php"; break; case "invite": $result = false; set_input("group_guid", $page[1]); include dirname(dirname(__FILE__)) . "/pages/groups/invite.php"; break; case "mail": $result = false; set_input("group_guid", $page[1]); include dirname(dirname(__FILE__)) . "/pages/mail.php"; break; case "group_invite_autocomplete": $result = false; include dirname(dirname(__FILE__)) . "/procedures/group_invite_autocomplete.php"; break; case "add": if (group_tools_is_group_creation_limited()) { admin_gatekeeper(); } break; default: // check if we have an old group profile link if (isset($page[0]) && is_numeric($page[0])) { if (($group = get_entity($page[0])) && elgg_instanceof($group, "group", null, "ElggGroup")) { register_error(elgg_echo("changebookmark")); forward($group->getURL()); } } break; } } return $result; }
/** * Diagnostics page. * * @param array $page Array of page elements, forwarded by the page handling mechanism */ function diagnostics_page_handler($page) { global $CONFIG; if (isset($page[0])) { switch ($page[0]) { case 'tests': if (isset($page[1]) && $page[1]) { switch ($page[1]) { case 'all': break; default: set_input('test_func', $page[1]); } include $CONFIG->pluginspath . "diagnostics/testreport.php"; } else { include $CONFIG->pluginspath . "diagnostics/unittester.php"; } break; default: include $CONFIG->pluginspath . "diagnostics/index.php"; } } else { // only interested in one page for now include $CONFIG->pluginspath . "diagnostics/index.php"; } }
/** * Profile page handler * * @param array $page Array of URL segments passed by the page handling mechanism * @return bool */ function profile_page_handler($page) { if (isset($page[0])) { $username = $page[0]; $user = get_user_by_username($username); elgg_set_page_owner_guid($user->guid); } elseif (elgg_is_logged_in()) { forward(elgg_get_logged_in_user_entity()->getURL()); } // short circuit if invalid or banned username if (!$user || $user->isBanned() && !elgg_is_admin_logged_in()) { register_error(elgg_echo('profile:notfound')); forward(); } $action = NULL; if (isset($page[1])) { $action = $page[1]; } if ($action == 'edit') { // use the core profile edit page echo elgg_view_resource('profile/edit'); return true; } set_input('username', $page[0]); echo elgg_view_resource('profile/view'); return true; }
function news_page_handler($segments) { switch ($segments[0]) { case "add": include dirname(__FILE__) . "/pages/edit.php"; break; case "edit": set_input('guid', $segments[1]); include dirname(__FILE__) . "/pages/edit.php"; break; case "view": set_input('guid', $segments[1]); include dirname(__FILE__) . "/pages/view.php"; break; case "photo": set_input('guid', $segments[1]); include dirname(__FILE__) . "/pages/photo.php"; break; case "all": default: include dirname(__FILE__) . "/pages/all.php"; break; } return true; }
/** * Listen to the blog page handler, to takeover some pages * * @param string $hook 'route' * @param string $type 'blog' * @param array $return_value the current page_handler params * @param null $params null * * @return void|false */ public static function blog($hook, $type, $return_value, $params) { $page = elgg_extract('segments', $return_value); if (empty($page)) { return; } $include_file = false; $resouce_loaded = false; $pages_path = elgg_get_plugins_path() . 'blog_tools/pages/'; switch ($page[0]) { case 'read': // Elgg 1.7 compatibility // Elgg 1.7 compatibility case 'view': set_input('guid', $page[1]); // to be used in the blog_tools/full/related view break; case 'featured': $resouce_loaded = true; echo elgg_view_resource('blog_tools/blog/featured'); break; } if (!empty($resouce_loaded)) { return false; } elseif (!empty($include_file)) { include $include_file; return false; } }
function zhgroups_page_handler($page) { $result = false; switch ($page[0]) { case 'find': include dirname(dirname(__FILE__)) . "/pages/find.php"; break; case 'topic': include dirname(dirname(__FILE__)) . "/pages/topic.php"; break; case "mail": set_input("group_guid", $page[1]); include dirname(dirname(__FILE__)) . "/pages/mail.php"; break; case "members": set_input("group_guid", $page[1]); include dirname(dirname(__FILE__)) . "/pages/members.php"; break; case "contact": set_input("group_guid", $page[1]); include dirname(dirname(__FILE__)) . "/pages/contact.php"; break; case "invite": set_input("group_guid", $page[1]); include dirname(dirname(__FILE__)) . "/pages/invite.php"; break; case "notifications": zhgroups_toggle_notifications(); break; case "emUnsub": zhgroupsUnsub(); break; } return $result; }
function hflts_page_handler($page) { if (elgg_extract(0, $page) === 'collective') { $content = elgg_view('hflts/collective', array('nAlternativas' => $page[1], 'nCriterios' => $page[2], 'nExpertos' => $page[3], 'G' => $page[4], 'import_file' => $page[5], 'weight_file' => $page[6])); $params = array('title' => 'DM con datos de samples/set_' . $page[5] . '.csv (' . $page[6] . ')', 'content' => $content, 'filter' => ''); $body = elgg_view_layout('content', $params); echo elgg_view_page('hflts', $body); return true; } set_input('username', $page[0]); //necesario $user = elgg_get_page_owner_entity(); // ej strem $guid = elgg_get_page_owner_guid(); // id de strem //aqui es donde tengo que filtrar por guid como en https://elgg.org/discussion/view/2268999/doubt-in-elgg-get-entities-from-metadata $valorations = elgg_get_entities_from_metadata(['type' => 'object', 'subtype' => 'evaluation_content', 'metadata_name_value_pairs' => array('name' => 'user_guid', 'value' => $guid), 'limit' => $vars['entity']->num_display, 'pagination' => false, 'order_by_metadata' => ['name' => 'state', 'direction' => 'ASC', 'as' => 'text']]); if (!$valorations) { $valorations = '<p class="mtm">' . elgg_echo('evaluationcontent:none') . '</p>'; } $content = elgg_view('hflts/driver', array('valorations' => $valorations)); $params = array('title' => 'Valoraciones de ' . $user->name, 'content' => $content, 'filter' => ''); $body = elgg_view_layout('content', $params); echo elgg_view_page('hflts', $body); }
/** * The page handler for all saml/ pages * * @param array $page the array of the different page elements * * @return bool */ public static function saml($page) { $pages_path = elgg_get_plugins_path() . 'simplesaml/pages/'; $include_file = false; switch ($page[0]) { case 'login': if (!empty($page[1])) { set_input('saml_source', $page[1]); } $include_file = "{$pages_path}login.php"; break; case 'no_linked_account': if (!empty($page[1])) { set_input('saml_source', $page[1]); } $include_file = "{$pages_path}no_linked_account.php"; break; case 'authorize': if (!empty($page[1])) { set_input('saml_source', $page[1]); } $include_file = "{$pages_path}authorize.php"; break; case 'idp_login': $include_file = "{$pages_path}idp_login.php"; break; } if (!empty($include_file)) { include $include_file; return true; } return false; }
/** * Serve pages. URLs in the form: * * pg/block_users/blocked_users/<username> - Users blocked by <username>. If not set, defaults to logged in. * pg/block_users/blocked - The page to display when a user is blocked. * * @param array $page * @return bool Depending on success */ function page_handler($page) { gatekeeper(); if (!isset($page[0])) { $page[0] = 'blocked_users'; } switch ($page[0]) { case 'blocked_user_content': $site = elgg_get_site_entity(); elgg_set_page_owner_guid($site->guid); include dirname(__FILE__) . '/pages/block_users/blocked_user_content.php'; break; case 'blocked_content': $site = elgg_get_site_entity(); elgg_set_page_owner_guid($site->guid); include dirname(__FILE__) . '/pages/block_users/blocked_content.php'; break; default: case 'blocked_users': $logged_in_user = elgg_get_logged_in_user_entity(); if (!isset($page[1])) { $page[1] = $logged_in_user->username; } set_input('blocking_username', $page[1]); // only admins can see another user's block list if ($page[1] != $logged_in_user->username) { admin_gatekeeper(); } include dirname(__FILE__) . '/pages/block_users/blocked_users.php'; } return true; }
/** * Handle /wizard * * @param array $page url elements * * @return bool */ function wizard_page_handler($page) { $include_file = false; $pages_base = elgg_get_plugins_path() . 'wizard/pages/'; switch ($page[0]) { case 'view': if (!empty($page[1]) && is_numeric($page[1])) { set_input('guid', $page[1]); $include_file = "{$pages_base}view.php"; } break; default: // try to find a wizard if (!empty($page[0])) { $options = array('type' => 'object', 'subtype' => Wizard::SUBTYPE, 'limit' => 1, 'metadata_name_value_pairs' => array('friendly_title' => $page[0])); $entities = elgg_get_entities_from_metadata($options); if (!empty($entities)) { set_input('guid', $entities[0]->getGUID()); $include_file = "{$pages_base}view.php"; } } break; } if (!empty($include_file)) { include $include_file; return true; } return false; }
/** * Dispatches odt_editor pages. * URLs take the form of * Save as: odt_editor/saveas/<guid> * * @param array $page * @return bool */ function odt_editor_page_handler($page) { $odt_editor_pages_dir = elgg_get_plugins_path() . 'odt_editor/pages'; $page_type = $page[0]; switch ($page_type) { case 'saveas': set_input('guid', $page[1]); include "{$odt_editor_pages_dir}/odt_editor/saveas.php"; break; case 'create': $container = get_entity($page[1]); if (!$container) { $container = get_loggedin_userid(); } // show new document in WebODF editor page // 0 as indicator for new document set_input('guid', 0); set_input('container_guid', $page[1]); include "{$odt_editor_pages_dir}/file/odt_editor.php"; $result = false; break; case 'gettemplate': include "{$odt_editor_pages_dir}/odt_editor/gettemplate.php"; break; default: return false; } return true; }
function pages_tools_route_pages_hook($hook, $type, $return_value, $params) { $result = $return_value; if (!empty($return_value) && is_array($return_value)) { $page = elgg_extract("segments", $result); switch ($page[0]) { case "export": if (isset($page[1])) { $result = false; set_input("page_guid", $page[1]); include dirname(dirname(__FILE__)) . "/pages/export.php"; } break; case "view": $result = false; set_input("guid", $page[1]); include dirname(dirname(__FILE__)) . "/pages/pages/view.php"; break; case "owner": $result = false; include dirname(dirname(__FILE__)) . "/pages/pages/owner.php"; break; case "friends": $result = false; include dirname(dirname(__FILE__)) . "/pages/pages/friends.php"; break; case "all": $result = false; include dirname(dirname(__FILE__)) . "/pages/pages/world.php"; break; } } return $result; }
/** * The birthday page handler * * @param array $page the url segments * * @return bool */ function birthdays_page_handler($page) { switch ($page[0]) { case "upcoming": include dirname(dirname(__FILE__)) . "/pages/upcoming.php"; break; case "day": if (isset($page[1])) { set_input("limit_month", $page[1]); } if (isset($page[2])) { set_input("limit_day", $page[2]); } include dirname(dirname(__FILE__)) . "/pages/day.php"; break; case "friends": include dirname(dirname(__FILE__)) . "/pages/friends.php"; break; case "group": include dirname(dirname(__FILE__)) . "/pages/group.php"; break; default: forward("birthdays/upcoming"); break; } return true; }
/** * Cron handler for redirecting pages. * * @param unknown_type $page */ function cron_page_handler($page) { global $CONFIG; if ($page[0]) { switch (strtolower($page[0])) { case 'minute': case 'fiveminute': case 'fifteenmin': case 'halfhour': case 'hourly': case 'daily': case 'weekly': case 'monthly': case 'yearly': case 'reboot': set_input('period', $page[0]); break; default: throw new CronException(sprintf(elgg_echo('CronException:unknownperiod'), $page[0])); } // Include cron handler include $CONFIG->path . "engine/handlers/cron_handler.php"; } else { forward(); } }
function captcha_page_handler($page) { if (isset($page[0])) { set_input('captcha_token', $page[0]); } include elgg_get_plugins_path() . "captcha/captcha.php"; }
function action_submit($h, $t, $r, $p) { $granular_inputs = get_input('granular_access_names'); if (!is_array($granular_inputs)) { return $r; } foreach ($granular_inputs as $name) { $input = get_input('ga_build_' . $name); $original = get_input($name); if ($original != 'granular') { continue; } if (!$input && is_numeric($original)) { // leave it alone continue; } elseif (!$input && $original == 'granular') { set_input($name, ACCESS_PRIVATE); continue; } // lets build a collection $access_id = get_access_for_guids($input); set_input($name, $access_id); } set_input('granular_access_names', null); return $r; }
/** * Dispatcher for projects. * URLs take the form of * All projects: projects/all * View project: projects/view/<guid>/<title> * New project: projects/add/<guid> (container: group) * Edit project: projects/edit/<guid> * Group projects: projects/group/<guid>/all * * @param array $page * @return bool */ function gvproject_page_handler($page) { if (!isset($page[0])) { $page[0] = 'all'; } $base_dir = elgg_get_plugins_path() . 'gvproject/pages/'; $page_type = $page[0]; switch ($page_type) { case 'view': set_input('guid', $page[1]); include "{$base_dir}/view.php"; break; case 'add': set_input('guid', $page[1]); include "{$base_dir}/new.php"; break; case 'edit': set_input('guid', $page[1]); include "{$base_dir}/edit.php"; break; case 'group': set_input('guid', $page[1]); include "{$base_dir}/owner.php"; break; case 'all': include "{$base_dir}/world.php"; break; default: return false; } return true; }
function au_subgroups_breadcrumb_override($params) { switch ($params['segments'][0]) { case 'profile': $group = get_entity($params['segments'][1]); if (!$group) { return; } $breadcrumbs[] = array('title' => elgg_echo('groups'), 'link' => elgg_get_site_url() . 'groups/all'); $parentcrumbs = au_subgroups_parent_breadcrumbs($group, false); foreach ($parentcrumbs as $parentcrumb) { $breadcrumbs[] = $parentcrumb; } $breadcrumbs[] = array('title' => $group->name, 'link' => NULL); set_input('au_subgroups_breadcrumbs', $breadcrumbs); break; case 'edit': $group = get_entity($params['segments'][1]); if (!$group) { return; } $breadcrumbs[] = array('title' => elgg_echo('groups'), 'link' => elgg_get_site_url() . 'groups/all'); $parentcrumbs = au_subgroups_parent_breadcrumbs($group, false); foreach ($parentcrumbs as $parentcrumb) { $breadcrumbs[] = $parentcrumb; } $breadcrumbs[] = array('title' => $group->name, 'link' => $group->getURL()); $breadcrumbs[] = array('title' => elgg_echo('groups:edit'), 'link' => NULL); set_input('au_subgroups_breadcrumbs', $breadcrumbs); break; } }
/** * The page handler for all saml/ pages * * @param array $page the array of the different page elements * * @return bool true if we get a valid page, false on failure */ function simplesaml_page_handler($page) { $result = false; $include_file = ""; switch ($page[0]) { case "login": if (!empty($page[1])) { set_input("saml_source", $page[1]); } $include_file = dirname(dirname(__FILE__)) . "/procedures/login.php"; break; case "no_linked_account": if (!empty($page[1])) { set_input("saml_source", $page[1]); } $include_file = dirname(dirname(__FILE__)) . "/pages/no_linked_account.php"; break; case "authorize": if (!empty($page[1])) { set_input("saml_source", $page[1]); } $include_file = dirname(dirname(__FILE__)) . "/procedures/authorize.php"; break; case "idp_login": $include_file = dirname(dirname(__FILE__)) . "/pages/idp_login.php"; break; } if (!empty($include_file)) { $result = true; include $include_file; } return $result; }
function friends_of_friends_page_handler($page) { global $CONFIG; if (isset($page[0]) && !empty($page[0])) { set_input('username', $page[0]); } include $CONFIG->pluginspath . "friends_of_friends/index.php"; }
public function testElggGetViewtype() { $this->assertEquals('default', elgg_get_viewtype()); set_input('view', 'foo'); $this->assertEquals('foo', elgg_get_viewtype()); set_input('view', 'a;b'); $this->assertEquals('default', elgg_get_viewtype()); }
function friend_request_page_handler($page) { if (isset($page[0])) { set_input("username", $page[0]); } include dirname(__FILE__) . "/pages/index.php"; return true; }