Exemplo n.º 1
0
 <?php 
// capture global state necessary for menus
$state = ['contexts' => elgg_get_context_stack(), 'input' => elgg_get_config("input"), 'page_owner_guid' => elgg_get_page_owner_guid()];
// g = guid, pog = page_owner_guid, c = contexts, m = mac
$guid = (int) get_input("g", 0, false);
$page_owner_guid = (int) get_input("pog", 0, false);
$contexts = (array) get_input("c", [], false);
$mac = get_input("m", "", false);
$input = (array) get_input("i", [], false);
// verify MAC
$data = serialize([$guid, $page_owner_guid, $contexts, $input]);
if (!elgg_build_hmac($data)->matchesToken($mac)) {
    return;
}
$user = get_user($guid);
if (!$user) {
    return;
}
// render view using state as it was in the placeholder view
elgg_set_context_stack($contexts);
elgg_set_config("input", $input);
elgg_set_page_owner_guid($page_owner_guid);
$params = ["entity" => $user, "username" => $user->username, "name" => $user->name];
echo elgg_view_menu("user_hover", $params);
// revert global state
elgg_set_context_stack($state['contexts']);
elgg_set_config("input", $state['input']);
elgg_set_page_owner_guid($state['page_owner_guid']);
Exemplo n.º 2
0
 /**
  * Checks if a permission rule should be executed for the current context
  *
  * @param string  $permission_details The permission rule configuration
  * @param boolean $strict             If strict context matching should be used.
  * 							          If true, only the last context will be checked for the rule matching.
  * 							          If false, any context value in the context stack will be considered.
  * @return bool True if the rule should be executed, false otherwise
  */
 public function checkContext($permission_details, $strict = false)
 {
     $context = elgg_extract('context', $permission_details);
     if (!isset($context)) {
         return true;
     }
     if (!is_array($context)) {
         $context = array($context);
     }
     if ($strict) {
         return in_array(elgg_get_context(), $context);
     }
     $stack = (array) elgg_get_context_stack();
     return count(array_intersect($context, $stack)) > 0;
 }
Exemplo n.º 3
0
<?php

/**
 * Button area for showing the add widgets panel
 */
elgg_load_js('lightbox');
elgg_load_css('lightbox');
$href_options = ['context' => elgg_extract('context', $vars), 'context_stack' => elgg_get_context_stack(), 'show_access' => elgg_extract('show_access', $vars), 'exact_match' => elgg_extract('exact_match', $vars), 'owner_guid' => elgg_get_page_owner_guid()];
$href = elgg_normalize_url(elgg_http_add_url_query_elements('ajax/view/page/layouts/widgets/add_panel', $href_options));
elgg_register_menu_item('title', ['id' => 'widgets-add-panel', 'name' => 'widgets:add', 'text' => elgg_echo('widgets:add'), 'link_class' => 'elgg-button elgg-button-action elgg-lightbox', 'href' => '#', 'onclick' => 'require(["widget_manager/add_panel"]);', 'data-colorbox-opts' => '{"href":"' . $href . '", "innerWidth": 600, "maxHeight": "80%"}']);
Exemplo n.º 4
0
<?php

$menus_present = (array) elgg_get_config("lazy_hover:menus");
$user = elgg_extract("entity", $vars);
if (!elgg_instanceof($user, "user")) {
    return;
}
$guid = (int) $user->getGUID();
$page_owner_guid = (int) elgg_get_page_owner_guid();
$contexts = elgg_get_context_stack();
$input = (array) elgg_get_config("input");
// generate MAC so we don't have to trust the client's choice of contexts
$data = serialize([$guid, $page_owner_guid, $contexts, $input]);
$mac = elgg_build_hmac($data)->getToken();
$attrs = ["rel" => $mac, "class" => "elgg-menu elgg-menu-hover elgg-ajax-loader"];
if (empty($menus_present[$mac])) {
    $attrs["data-elgg-menu-data"] = json_encode(["g" => $guid, "pog" => $page_owner_guid, "c" => $contexts, "m" => $mac, "i" => $input]);
    $menus_present[$mac] = true;
    elgg_set_config("lazy_hover:menus", $menus_present);
}
echo elgg_format_element('ul', $attrs);
Exemplo n.º 5
0
<?php

/**
 * Button area for showing the add widgets panel
 */
$href_options = ['context' => elgg_get_context(), 'context_stack' => elgg_get_context_stack(), 'show_access' => elgg_extract('show_access', $vars, true), 'owner_guid' => elgg_extract('owner_guid', $vars, elgg_get_page_owner_guid())];
$href = elgg_normalize_url(elgg_http_add_url_query_elements('widgets/add_panel', $href_options));
echo elgg_view_menu('title:widgets', ['items' => [['name' => 'widgets_add', 'href' => 'javascript: void(0)', 'text' => elgg_echo('widgets:add'), 'link_class' => 'elgg-button elgg-button-action elgg-lightbox', 'data-colorbox-opts' => json_encode(['href' => $href, 'maxWidth' => '900px', 'maxHeight' => '90%'])]], 'class' => 'elgg-menu-hz']);