本文整理汇总了PHP中elgg_get_page_owner_entity函数的典型用法代码示例。如果您正苦于以下问题:PHP elgg_get_page_owner_entity函数的具体用法?PHP elgg_get_page_owner_entity怎么用?PHP elgg_get_page_owner_entity使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了elgg_get_page_owner_entity函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: todos_filter_menu_register
/**
* Adds the filter menu for todos
*
* @param string $hook name of the hook
* @param string $type type of the hook
* @param ElggMenuItem[] $return return value
* @param array $params hook parameters
*
* @return ElggMenuItem[]
*/
function todos_filter_menu_register($hook, $type, $return, $params)
{
if (elgg_get_context() !== 'todos') {
return $return;
}
$page_owner = elgg_get_page_owner_entity();
if (todos_enabled_for_container($page_owner)) {
$base_url = 'todos';
if (elgg_instanceof($page_owner, 'group')) {
$base_url .= "/group/{$page_owner->getGUID()}/all";
}
$return[] = ElggMenuItem::factory(array('name' => 'active', 'text' => elgg_echo('todos:filter:active'), 'href' => $base_url));
$return[] = ElggMenuItem::factory(array('name' => 'completed', 'text' => elgg_echo('todos:filter:completed'), 'href' => "{$base_url}?filter=completed"));
if ($page_owner instanceof ElggGroup) {
$return[] = ElggMenuItem::factory(array('name' => 'assigned_per_user', 'text' => elgg_echo('todos:filter:assigned_per_user'), 'href' => "todos/assigned_per_user/{$page_owner->getGUID()}"));
}
$return[] = ElggMenuItem::factory(array('name' => 'overdue', 'text' => elgg_echo('todos:filter:overdue'), 'href' => "{$base_url}?filter=overdue"));
}
$user = elgg_get_logged_in_user_entity();
if (!empty($user)) {
$href = "todos/assigned/{$user->username}";
if (elgg_instanceof($page_owner, 'group')) {
$href .= "/{$page_owner->getGUID()}";
}
$return[] = ElggMenuItem::factory(array('name' => 'assigned', 'text' => elgg_echo('todos:filter:assigned'), 'href' => $href));
}
return $return;
}
示例2: friend_request_pagesetup
function friend_request_pagesetup()
{
$context = elgg_get_context();
$page_owner = elgg_get_page_owner_entity();
// Remove link to friendsof
elgg_unregister_menu_item("page", "friends:of");
if ($user = elgg_get_logged_in_user_entity()) {
$options = array("type" => "user", "count" => true, "relationship" => "friendrequest", "relationship_guid" => $user->getGUID(), "inverse_relationship" => true);
if ($count = elgg_get_entities_from_relationship($options)) {
$params = array("name" => "friend_request", "href" => "friend_request/" . $user->username, "text" => elgg_view_icon("user") . "<span class='friend-request-new'>" . $count . "</span>", "title" => elgg_echo("friend_request:menu"), "priority" => 301);
elgg_register_menu_item("topbar", $params);
}
}
// Show menu link in the correct context
if (in_array($context, array("friends", "friendsof", "collections", "messages")) && !empty($page_owner) && $page_owner->canEdit()) {
$options = array("type" => "user", "count" => true, "relationship" => "friendrequest", "relationship_guid" => $page_owner->getGUID(), "inverse_relationship" => true);
if ($count = elgg_get_entities_from_relationship($options)) {
$extra = " [" . $count . "]";
} else {
$extra = "";
}
// add menu item
$menu_item = array("name" => "friend_request", "text" => elgg_echo("friend_request:menu") . $extra, "href" => "friend_request/" . $page_owner->username, "contexts" => array("friends", "friendsof", "collections", "messages"), "section" => "friend_request");
elgg_register_menu_item("page", $menu_item);
}
}
示例3: add_submenus
/**
* Sets up submenus. Triggered on pagesetup.
*
*/
function add_submenus()
{
$plugins_base = elgg_get_site_url() . "plugins";
if (elgg_get_context() == 'admin') {
elgg_register_admin_menu_item('administer', 'statistics', 'community_plugins');
elgg_register_admin_menu_item('administer', 'utilities', 'community_plugins');
elgg_register_admin_menu_item('configure', 'community_plugins', 'settings');
return;
}
if (elgg_get_context() != "plugins") {
return;
}
$page_owner = elgg_get_page_owner_entity();
if (elgg_is_logged_in() && elgg_get_page_owner_guid() == elgg_get_logged_in_user_guid()) {
elgg_register_menu_item('page', array('href' => "{$plugins_base}/developer/{$page_owner->username}", 'name' => 'plugins:yours', 'text' => elgg_echo("plugins:yours", array(elgg_echo('plugins:types:')))));
} else {
if (elgg_get_page_owner_guid()) {
$title = elgg_echo("plugins:user", array($page_owner->name, elgg_echo('plugins:types:')));
elgg_register_menu_item('page', array('href' => "{$plugins_base}/developer/{$page_owner->username}", 'name' => 'plugins:user', 'text' => $title));
}
}
elgg_register_menu_item('page', array('href' => '/plugins', 'name' => 'plugins:all', 'text' => elgg_echo('plugins:all')));
// add upload link when viewing own plugin page
if (elgg_get_logged_in_user_guid() == elgg_get_page_owner_guid()) {
elgg_register_menu_item('page', array('href' => "{$plugins_base}/new/project/{$page_owner->username}", 'name' => 'plugins:upload', 'text' => elgg_echo('plugins:upload')));
}
}
示例4: pleiofile_pagesetup
function pleiofile_pagesetup()
{
$page_owner = elgg_get_page_owner_entity();
if ($page_owner->file_enable == "no") {
elgg_unregister_widget_type("group_files");
}
}
示例5: testWriteAccessArray
/**
* https://github.com/Elgg/Elgg/pull/6393
* Hook handlers for 'access:collections:write','all' hook should respect
* group's content access mode and container write permissions
*/
public function testWriteAccessArray()
{
$membersonly = ElggGroup::CONTENT_ACCESS_MODE_MEMBERS_ONLY;
$unrestricted = ElggGroup::CONTENT_ACCESS_MODE_UNRESTRICTED;
$original_page_owner = elgg_get_page_owner_entity();
elgg_set_page_owner_guid($this->group->guid);
$ia = elgg_set_ignore_access(false);
// User is not a member of the group
// Member-only group
$this->group->setContentAccessMode($membersonly);
$write_access = get_write_access_array($this->user->guid, true);
$this->assertFalse(array_key_exists($this->group->group_acl, $write_access));
// Unrestricted group
$this->group->setContentAccessMode($unrestricted);
$write_access = get_write_access_array($this->user->guid, true);
$this->assertFalse(array_key_exists($this->group->group_acl, $write_access));
// User is a member (can write to container)
$this->group->join($this->user);
// Member-only group
$this->group->setContentAccessMode($membersonly);
$write_access = get_write_access_array($this->user->guid, true);
$this->assertTrue(array_key_exists($this->group->group_acl, $write_access));
// Unrestricted group
$this->group->setContentAccessMode($unrestricted);
$write_access = get_write_access_array($this->user->guid, true);
$this->assertTrue(array_key_exists($this->group->group_acl, $write_access));
elgg_set_ignore_access($ia);
$this->group->leave($this->user);
$original_page_owner_guid = elgg_instanceof($original_page_owner) ? $original_page_owner->guid : 0;
elgg_set_page_owner_guid($original_page_owner_guid);
}
示例6: hflts_page_handler
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);
}
示例7: _elgg_friends_page_setup
/**
* Register some menu items for friends UI
* @access private
*/
function _elgg_friends_page_setup() {
$owner = elgg_get_page_owner_entity();
$viewer = elgg_get_logged_in_user_entity();
if ($owner) {
$params = array(
'name' => 'friends',
'text' => elgg_echo('friends'),
'href' => 'friends/' . $owner->username,
'contexts' => array('friends')
);
elgg_register_menu_item('page', $params);
$params = array(
'name' => 'friends:of',
'text' => elgg_echo('friends:of'),
'href' => 'friendsof/' . $owner->username,
'contexts' => array('friends')
);
elgg_register_menu_item('page', $params);
}
// topbar
if ($viewer) {
elgg_register_menu_item('topbar', array(
'name' => 'friends',
'href' => "friends/{$viewer->username}",
'text' => elgg_view_icon('users'),
'title' => elgg_echo('friends'),
'priority' => 300,
));
}
}
示例8: pagesetup
/**
* Page setup event
*/
function pagesetup()
{
$group = elgg_get_page_owner_entity();
if (!$group instanceof \ElggGroup) {
return true;
}
$position = $group->au_group_notice_position;
switch ($position) {
case 'top':
elgg_extend_view('page/elements/body', 'au_group_notices/au_group_notices_show', 499);
break;
case 'bottom':
elgg_extend_view('page/elements/body', 'au_group_notices/au_group_notices_show', 501);
break;
case 'sidebottom':
elgg_extend_view('page/elements/sidebar', 'au_group_notices/au_group_notices_show', 600);
break;
case 'sidetop':
elgg_extend_view('group/default', 'au_group_notices/au_group_notices_show', 100);
break;
default:
// do nothing - if position not set, no settings provided
break;
}
}
示例9: widget_manager_write_access_hook
/**
* Returns a ACL for use in widgets
*
* @param string $hook_name name of the hook
* @param string $entity_type type of the hook
* @param string $return_value current return value
* @param array $params hook parameters
*
* @return array
*/
function widget_manager_write_access_hook($hook_name, $entity_type, $return_value, $params)
{
if (!elgg_in_context('widget_access')) {
return $return_value;
}
$widget = elgg_extract('entity', $params['input_params']);
if ($widget instanceof ElggWidget) {
$widget_context = $widget->context;
if ($widget_context == 'groups') {
$group = $widget->getContainerEntity();
if (!empty($group->group_acl)) {
$return_value = [$group->group_acl => elgg_echo('groups:group') . ': ' . $group->name, ACCESS_LOGGED_IN => elgg_echo('LOGGED_IN'), ACCESS_PUBLIC => elgg_echo('PUBLIC')];
}
} elseif ($widget->getContainerGUID() === elgg_get_site_entity()->getGUID()) {
// admins only have the following options for index widgets
if (elgg_is_admin_logged_in()) {
$return_value = [ACCESS_PRIVATE => elgg_echo('access:admin_only'), ACCESS_LOGGED_IN => elgg_echo('LOGGED_IN'), ACCESS_LOGGED_OUT => elgg_echo('LOGGED_OUT'), ACCESS_PUBLIC => elgg_echo('PUBLIC')];
} elseif (elgg_can_edit_widget_layout($widget_context)) {
// for non admins that can manage this widget context
$return_value = [ACCESS_LOGGED_IN => elgg_echo('LOGGED_IN'), ACCESS_PUBLIC => elgg_echo('PUBLIC')];
}
}
} elseif (elgg_in_context('index') && elgg_is_admin_logged_in()) {
// admins only have the following options for index widgets
$return_value = [ACCESS_PRIVATE => elgg_echo('access:admin_only'), ACCESS_LOGGED_IN => elgg_echo('LOGGED_IN'), ACCESS_LOGGED_OUT => elgg_echo('LOGGED_OUT'), ACCESS_PUBLIC => elgg_echo('PUBLIC')];
} elseif (elgg_in_context('groups')) {
$group = elgg_get_page_owner_entity();
if (!empty($group->group_acl)) {
$return_value = [$group->group_acl => elgg_echo('groups:group') . ': ' . $group->name, ACCESS_LOGGED_IN => elgg_echo('LOGGED_IN'), ACCESS_PUBLIC => elgg_echo('PUBLIC')];
}
}
return $return_value;
}
示例10: user_support_get_help_context
/**
* Get the context for a page, for the help system
*
* @param string $url the (optional) url to get the context for
*
* @return bool|string
*/
function user_support_get_help_context($url = "")
{
if (empty($url)) {
$url = current_page_url();
}
if (empty($url)) {
return false;
}
$path = parse_url($url, PHP_URL_PATH);
if (empty($path)) {
return false;
}
$parts = explode("/", $path);
$page_owner = elgg_get_page_owner_entity();
if (empty($page_owner)) {
$page_owner = elgg_get_logged_in_user_entity();
}
$new_parts = array();
foreach ($parts as $index => $part) {
if (empty($part)) {
continue;
} elseif (is_numeric($part) || !empty($page_owner) && $page_owner->username == $part) {
break;
} else {
$new_parts[] = $part;
}
}
if (empty($new_parts)) {
return false;
}
return implode("/", $new_parts);
}
示例11: group_member_entity_menu_handler
function group_member_entity_menu_handler($hook, $type, $returnvalue, $params)
{
$page_owner = elgg_get_page_owner_entity();
$user = elgg_get_logged_in_user_entity();
if (!$page_owner instanceof ElggGroup || empty($user) || $page_owner->owner_guid != $user->getGUID()) {
return $returnvalue;
}
$result = $returnvalue;
if (!empty($params) && is_array($params) && ($user = elgg_get_logged_in_user_entity())) {
$entity = elgg_extract("entity", $params);
if (elgg_instanceof($entity, "user") && $entity->getGUID() != $user->getGUID()) {
if (!empty($result) && !is_array($result)) {
$result = array($result);
} elseif (empty($result)) {
$result = array();
}
if (check_entity_relationship($page_owner->getGUID(), "manager", $entity->getGUID())) {
// pending request
$result[] = ElggMenuItem::factory(array("name" => "set_group_manager", "text" => elgg_echo("group:setmanager"), "href" => "groups/setmanager/" . $page_owner->getGUID() . "/" . $entity->getGUID(), "is_action" => true, "priority" => 503));
} else {
// add as friend
$result[] = ElggMenuItem::factory(array("name" => "set_group_manager", "text" => elgg_echo("group:removemanager"), "href" => "groups/removemanager/" . $page_owner->getGUID() . "/" . $entity->getGUID(), "is_action" => true, "priority" => 503));
}
}
}
return $result;
}
示例12: au_staff_options
function au_staff_options($pageowner)
{
$user = elgg_get_logged_in_user_entity();
$group = elgg_get_page_owner_entity();
if (elgg_instanceof($group, 'group')) {
//check group attributes - ignore if au staff
if ($group->staff_only_enable == 'yes') {
elgg_extend_view('group/default', 'groups/sidebar/staff_only', 502);
//do stuff if this is a staff-only group
//system_message("AU staff-only group: only AU staff members can join this group");
if (elgg_is_logged_in()) {
$invited = check_entity_relationship($group->getGUID(), "invited", $user->getGUID());
//allow invited users in
if (is_au_staff_member($user) || elgg_is_admin_logged_in() || $group->canEdit() || $invited) {
//do other stuff - welcome here
} else {
//remove buttons for non staff members who are not members of the group and not invited
if (!$group->isMember($user)) {
elgg_register_plugin_hook_handler('register', 'menu:title', 'au_landing_remove_group_join_button', 9999);
//remove the link we added in groups_ux to allow joining from discussion forum
elgg_unextend_view('discussion/replies', 'discussion/replies/join');
}
}
}
} else {
//this is a normal group
}
} else {
//not a group, do nothing
}
}
示例13: register
/**
* Set folder breadcrumb menu
*
* @param string $hook the name of the hook
* @param string $type the type of the hook
* @param ElggMenuItem[] $return_value current return value
* @param array $params supplied params
*
* @return void|ElggMenuItem[]
*/
public static function register($hook, $type, $return_value, $params)
{
if (empty($params) || !is_array($params)) {
return;
}
$container = elgg_get_page_owner_entity();
/* @var $folder \ElggObject */
$folder = elgg_extract('entity', $params);
if (elgg_instanceof($folder, 'object', FILE_TOOLS_SUBTYPE)) {
$container = $folder->getContainerEntity();
$priority = 9999999;
$return_value[] = \ElggMenuItem::factory(['name' => "folder_{$folder->getGUID()}", 'text' => $folder->getDisplayName(), 'href' => false, 'priority' => $priority]);
$parent_guid = (int) $folder->parent_guid;
while (!empty($parent_guid)) {
$parent = get_entity($parent_guid);
if (!elgg_instanceof($parent, 'object', FILE_TOOLS_SUBTYPE)) {
break;
}
$priority--;
$return_value[] = \ElggMenuItem::factory(['name' => "folder_{$parent->getGUID()}", 'text' => $parent->getDisplayName(), 'href' => $parent->getURL(), 'priority' => $priority]);
$parent_guid = (int) $parent->parent_guid;
}
}
// make main folder item
$main_folder_options = ['name' => 'main_folder', 'text' => elgg_echo('file_tools:list:folder:main'), 'priority' => 0];
if ($container instanceof \ElggGroup) {
$main_folder_options['href'] = "file/group/{$container->getGUID()}/all#";
} else {
$main_folder_options['href'] = "file/owner/{$container->username}/all#";
}
$return_value[] = \ElggMenuItem::factory($main_folder_options);
return $return_value;
}
示例14: widgetURL
/**
* Set the title URL for the discussions_tools widgets
*
* @param string $hook the name of the hook
* @param string $type the type of the hook
* @param string $return_value current return value
* @param array $params supplied params
*
* @return void|string
*/
public static function widgetURL($hook, $type, $return_value, $params)
{
if (!empty($return_value)) {
// someone already set an url
return;
}
$widget = elgg_extract('entity', $params);
if (!$widget instanceof \ElggWidget) {
return;
}
switch ($widget->handler) {
case 'start_discussion':
$owner = $widget->getOwnerEntity();
if ($owner instanceof \ElggGroup) {
$return_value = "discussion/add/{$owner->getGUID()}";
}
break;
case 'discussion':
$return_value = 'discussion/all';
break;
case 'group_forum_topics':
$page_owner = elgg_get_page_owner_entity();
if ($page_owner instanceof \ElggGroup) {
$return_value = "discussion/owner/{$page_owner->getGUID()}";
}
break;
}
return $return_value;
}
示例15: gvfriendrequest_pagesetup
function gvfriendrequest_pagesetup()
{
$context = elgg_get_context();
$page_owner = elgg_get_page_owner_entity();
// Remove link to friendsof
elgg_unregister_menu_item("page", "friends:of");
if ($user = elgg_get_logged_in_user_entity()) {
$options = array("type" => "user", "count" => true, "relationship" => "friendrequest", "relationship_guid" => $user->getGUID(), "inverse_relationship" => true);
if ($count = elgg_get_entities_from_relationship($options)) {
$class = "elgg-icon elgg-icon-users";
$text = "<span class='{$class}'></span>";
$tooltip = elgg_echo('gvtheme:myfriends');
if ($count > 0) {
$text .= "<span class=\"messages-new\">{$count}</span>";
$tooltip = elgg_echo("friend_request:unreadcount", array($count));
}
$params = array("name" => "friends", "href" => "friend_request/" . $user->username, "text" => $text, "section" => 'alt', "title" => $tooltip);
elgg_register_menu_item("topbar", $params);
}
}
// Show menu link in the correct context
if (in_array($context, array("friends", "friendsof", "collections")) && !empty($page_owner) && $page_owner->canEdit()) {
$options = array("type" => "user", "count" => true, "relationship" => "friendrequest", "relationship_guid" => $page_owner->getGUID(), "inverse_relationship" => true);
if ($count = elgg_get_entities_from_relationship($options)) {
$extra = " (" . $count . ")";
} else {
$extra = "";
}
// add menu item
$menu_item = array("name" => "friend_request", "text" => elgg_echo("friend_request:menu") . $extra, "href" => "friend_request/" . $page_owner->username, "contexts" => array("friends", "friendsof", "collections"), "section" => "friend_request");
elgg_register_menu_item("page", $menu_item);
}
}