本文整理汇总了PHP中elgg_get_logged_in_user_entity函数的典型用法代码示例。如果您正苦于以下问题:PHP elgg_get_logged_in_user_entity函数的具体用法?PHP elgg_get_logged_in_user_entity怎么用?PHP elgg_get_logged_in_user_entity使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了elgg_get_logged_in_user_entity函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setup
/**
* {@inheritdoc}
*/
public function setup()
{
parent::setup();
$this->post = get_entity($this->guid);
$this->poster = elgg_get_logged_in_user_entity();
// GUIDs of friends that were tagged in the post
if (!is_array($this->friend_guids)) {
$this->friend_guids = string_to_tag_array((string) $this->friend_guids);
}
if (!is_array($this->attachment_guids)) {
$this->attachment_guids = string_to_tag_array((string) $this->attachment_guids);
}
if (!is_array($this->upload_guids)) {
$this->upload_guids = array();
}
$this->subtype = Post::SUBTYPE;
$this->container = $this->poster;
if ($this->container_guid) {
$container = get_entity($this->container_guid);
if ($container) {
$this->container = $container;
}
if ($this->container->guid != $this->poster->guid) {
$this->subtype = hypeWall()->config->getPostSubtype();
}
}
// For underlying views to know who the container is
elgg_set_page_owner_guid($this->container->guid);
}
示例2: friend_request_entity_menu_handler
function friend_request_entity_menu_handler($hook, $type, $returnvalue, $params)
{
$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();
}
// are we friends
if (!$entity->isFriendOf($user->getGUID())) {
// no, check if pending request
if (check_entity_relationship($user->getGUID(), "friendrequest", $entity->getGUID())) {
// pending request
$result[] = ElggMenuItem::factory(array("name" => "friend_request", "text" => elgg_echo("friend_request:friend:add:pending"), "href" => "friend_request/" . $user->username . "#friend_request_sent_listing", "priority" => 500));
} else {
// add as friend
$result[] = ElggMenuItem::factory(array("name" => "add_friend", "text" => elgg_echo("friend:add"), "href" => "action/friends/add?friend=" . $entity->getGUID(), "is_action" => true, "priority" => 500));
}
} else {
// is friend, se remove friend link
$result[] = ElggMenuItem::factory(array("name" => "remove_friend", "text" => elgg_echo("friend:remove"), "href" => "action/friends/remove?friend=" . $entity->getGUID(), "is_action" => true, "priority" => 500));
}
}
}
return $result;
}
示例3: 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);
}
}
示例4: stripe_page_handler
/**
* Stripe related pages
*
* @param array $page
* @param string $handler
* @return boolean
*/
function stripe_page_handler($page, $handler)
{
gatekeeper();
$username = elgg_extract(0, $page, false);
if ($username) {
$user = get_user_by_username($username);
}
if (!elgg_instanceof($user) || !$user->canEdit()) {
$user = elgg_get_logged_in_user_entity();
forward("{$handler}/{$user->username}");
}
elgg_set_context('settings');
elgg_set_page_owner_guid($user->guid);
elgg_push_breadcrumb(elgg_echo('stripe:billing'), 'billing');
$context = elgg_extract(1, $page, 'cards');
$action = elgg_extract(2, $page, 'all');
$view = "stripe/pages/{$context}/{$action}";
if (elgg_view_exists($view)) {
$params = array('entity' => $user, 'id' => elgg_extract(3, $page, false), 'context' => $page);
$title = elgg_echo("stripe:{$context}:{$action}");
$content = elgg_view($view, $params);
$sidebar = elgg_view('stripe/sidebar', $params);
$filter = elgg_view("stripe/filters/{$context}/{$action}", $params);
}
if ($content) {
if (elgg_is_xhr()) {
echo $content;
} else {
$layout = elgg_view_layout('content', array('title' => $title, 'content' => $content, 'sidebar' => $sidebar, 'filter' => $filter));
echo elgg_view_page($title, $layout);
}
return true;
}
return false;
}
示例5: basic_pagesetup_handler
function basic_pagesetup_handler()
{
elgg_unextend_view('page/elements/header', 'search/header');
elgg_unregister_menu_item('topbar', 'dashboard');
elgg_unregister_menu_item('topbar', 'elgg_logo');
// Extend footer with copyright
$year = date('Y');
$href = "http://www.perjensen-online.dk";
elgg_register_menu_item('footer', array('name' => 'copyright_this', 'href' => $href, 'title' => elgg_echo('basic_light:tooltip'), 'text' => elgg_echo('basic_light:copyright') . $year . elgg_echo(' Elggzone'), 'priority' => 1, 'section' => 'alt'));
// Extend footer with elgg link
$href = "http://elgg.org";
elgg_register_menu_item('footer', array('name' => 'elgg', 'href' => $href, 'text' => elgg_echo('basic_light:elgg'), 'priority' => 2, 'section' => 'alt'));
if (elgg_is_logged_in()) {
$user = elgg_get_logged_in_user_entity();
if (elgg_is_active_plugin('dashboard')) {
elgg_register_menu_item('topbar', array('name' => 'dashboard', 'href' => 'dashboard', 'text' => elgg_view_icon('home') . elgg_echo('dashboard'), 'priority' => 1000, 'section' => 'alt'));
}
if (elgg_is_active_plugin('reportedcontent')) {
elgg_unregister_menu_item('footer', 'report_this');
$href = "javascript:elgg.forward('reportedcontent/add'";
$href .= "+'?address='+encodeURIComponent(location.href)";
$href .= "+'&title='+encodeURIComponent(document.title));";
elgg_register_menu_item('extras', array('name' => 'report_this', 'href' => $href, 'text' => elgg_view_icon('report-this') . elgg_echo(''), 'title' => elgg_echo('reportedcontent:this:tooltip'), 'priority' => 100));
}
}
}
示例6: ws_pack_users_unregister_from_push_notifications
/**
* Unregisters the current user from a given push notification service
*
* @param string $service_name name of the service
*
* @return SuccessResult|ErrorResult
*/
function ws_pack_users_unregister_from_push_notifications($service_name)
{
$result = false;
$user = elgg_get_logged_in_user_entity();
$api_application = ws_pack_get_current_api_application();
if (!empty($user) && !empty($api_application)) {
if ($api_application_user_settings = ws_pack_get_application_user_settings($user, $api_application)) {
switch ($service_name) {
case "appcelerator":
if ($api_application_user_settings->unregisterFromPushNotifications($service_name)) {
$result = new SuccessResult($service_name);
}
break;
default:
$result = new ErrorResult(elgg_echo("ws_pack:push_notifications:error:unsupported_service", array($service_name)));
break;
}
} else {
$result = new ErrorResult(elgg_echo("ws_pack:user_settings:error:notfound"));
}
}
if ($result === false) {
$result = new ErrorResult(elgg_echo("ws_pack:users:unregister_from_push_notifications:error"));
}
return $result;
}
示例7: 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);
}
}
示例8: ws_pack_get_lang_file
function ws_pack_get_lang_file()
{
$result = false;
$user = elgg_get_logged_in_user_entity();
$api_application = ws_pack_get_current_api_application();
if (!empty($user) && !empty($api_application)) {
$translations = array();
//kinds of translations
$fields = array("members", "search", "groups", "friends", "notifications", "messages", "messageboard", "likes", "invitefriends", "discussion", "profile", "user", "usersettings", "date", "email");
//load and iterate the language cached by the site
foreach ($GLOBALS["CONFIG"]->translations as $trans) {
foreach ($trans as $k => $v) {
if (strpos($k, ":")) {
$parts = explode(':', $k);
$new_key = $parts[1];
foreach ($fields as $field) {
if ($parts[0] == $field) {
$translations[$field][$new_key] = $v;
}
}
} else {
$translations["general"][$k] = $v;
}
}
}
$translations = json_encode($translations);
$result = new SuccessResult($translations);
}
if ($result === false) {
$result = new ErrorResult(elgg_echo("ws_pack:error:notfound"));
}
return $result;
}
示例9: show_members_json
function show_members_json($context, $limit = 30, $offset = 0, $username)
{
if (!$username) {
$user = elgg_get_logged_in_user_entity();
} else {
$user = get_user_by_username($username);
if (!$user) {
throw new InvalidParameterException('registration:usernamenotvalid');
}
}
if ($context == "newest") {
$params = array('types' => 'user', 'limit' => $limit, 'full_view' => FALSE);
$latest_member = elgg_get_entities($params);
//return $return;
}
if ($context == "online") {
$latest_member = get_online_users();
}
if ($context == "popular") {
$params = array('types' => 'user', 'relationship' => 'friend', 'inverse_relationship' => false);
$latest_member = elgg_list_entities_from_relationship_count($params);
}
if ($latest_member) {
foreach ($latest_member as $single) {
$member['guid'] = $single->guid;
$member['name'] = $single->name;
//$member['avatar_url'] = get_entity_icon_url($single,'small');
$return[] = $member;
}
}
//return $return;
return json_encode($return, true);
}
示例10: app2_blog_save
function app2_blog_save($title, $text, $excerpt, $tags, $access, $container_guid)
{
$user = elgg_get_logged_in_user_entity();
if (!$user) {
throw new InvalidParameterException('registration:usernamenotvalid');
}
$obj = new ElggObject();
$obj->subtype = "blog";
$obj->owner_guid = $user->guid;
$obj->container_guid = $container_guid;
$obj->access_id = strip_tags($access);
$obj->method = "api";
$obj->description = strip_tags($text);
$obj->title = elgg_substr(strip_tags($title), 0, 140);
$obj->status = 'published';
$obj->comments_on = 'On';
$obj->excerpt = strip_tags($excerpt);
$obj->tags = strip_tags($tags);
$guid = $obj->save();
elgg_create_river_item('river/object/blog/create', 'create', $user->guid, $obj->guid);
if ($guid) {
return true;
} else {
return false;
}
}
示例11: canReshareEntity
/**
* Check if resharing of this entity is allowed
*
* @param \ElggEntity $entity the entity to check
*
* @return bool
*/
protected static function canReshareEntity(\ElggEntity $entity)
{
if (!$entity instanceof \ElggEntity) {
return false;
}
// only allow objects and groups
if (!$entity instanceof \ElggObject && !$entity instanceof \ElggGroup) {
return false;
}
// comments and discussion replies are never allowed
$blocked_subtypes = ['comment', 'discussion_reply'];
if (in_array($entity->getSubtype(), $blocked_subtypes)) {
return false;
}
// by default allow searchable entities
$reshare_allowed = false;
if ($entity instanceof \ElggGroup) {
$reshare_allowed = true;
} else {
$searchable_entities = get_registered_entity_types($entity->getType());
if (!empty($searchable_entities)) {
$reshare_allowed = in_array($entity->getSubtype(), $searchable_entities);
}
}
// trigger hook to allow others to change
$params = ['entity' => $entity, 'user' => elgg_get_logged_in_user_entity()];
return (bool) elgg_trigger_plugin_hook('reshare', $entity->getType(), $params, $reshare_allowed);
}
示例12: ws_pack_users_unregister_from_push_notifications
/**
* Unregisters the current user from a given push notification service
*
* @param string $service_name name of the service
*
* @return SuccessResult|ErrorResult
*/
function ws_pack_users_unregister_from_push_notifications($service_name)
{
$result = false;
$user = elgg_get_logged_in_user_entity();
$api_application = ws_pack_get_current_api_application();
if (!empty($user) && !empty($api_application)) {
// is the service registered
if ($api_application->isRegisteredPushNotificationService($service_name)) {
$api_application_user_settings = ws_pack_get_application_user_settings($user, $api_application);
if (!empty($api_application_user_settings)) {
if ($api_application_user_settings->unregisterFromPushNotifications($service_name)) {
$result = new SuccessResult($service_name);
}
} else {
$result = new ErrorResult(elgg_echo("ws_pack:user_settings:error:notfound"));
}
} else {
$result = new ErrorResult(elgg_echo("ws_pack:push_notifications:error:unsupported_service", [$service_name]));
}
}
if ($result === false) {
$result = new ErrorResult(elgg_echo("ws_pack:users:unregister_from_push_notifications:error"));
}
return $result;
}
示例13: show_my_stuff_widget
/**
* Show "My ..." widget content
*/
function show_my_stuff_widget($entity, $type, $base_path = '', $show_more_link = true)
{
$num = $entity->num_display;
if (elgg_in_context('profile')) {
$owner = elgg_get_page_owner_entity();
} else {
$owner = elgg_get_logged_in_user_entity();
}
$options = array('type' => 'object', 'owner_guid' => $owner->guid, 'limit' => $num, 'full_view' => FALSE, 'pagination' => FALSE);
if (is_array($type)) {
$options['subtypes'] = $type;
$base_type = $type[0];
if ($base_path == '') {
$base_path = $base_type;
}
} else {
$options['subtype'] = $type;
$base_type = $type;
if ($base_path == '') {
$base_path = $base_type;
}
}
$content = elgg_list_entities($options);
echo $content;
if ($content) {
if ($show_more_link) {
$url_more = "{$base_path}/owner/" . $owner->username;
$more_link = elgg_view('output/url', array('href' => $url_more, 'text' => elgg_echo("{$base_type}:more"), 'is_trusted' => true));
echo "<span class=\"elgg-widget-more\">{$more_link}</span>";
}
} else {
echo elgg_echo("{$base_type}:none");
}
}
示例14: aalborg_theme_pagesetup
function aalborg_theme_pagesetup()
{
elgg_unextend_view('page/elements/header', 'search/header');
if (elgg_is_logged_in()) {
elgg_extend_view('page/elements/sidebar', 'search/header', 0);
}
elgg_unregister_menu_item('topbar', 'dashboard');
if (elgg_is_active_plugin('dashboard')) {
elgg_register_menu_item('site', array('name' => 'dashboard', 'href' => 'dashboard', 'text' => elgg_echo('dashboard')));
}
if (elgg_is_logged_in()) {
$user = elgg_get_logged_in_user_entity();
elgg_register_menu_item('topbar', array('name' => 'account', 'text' => elgg_echo('account'), 'href' => "#", 'priority' => 100, 'section' => 'alt', 'link_class' => 'elgg-topbar-dropdown'));
elgg_unregister_menu_item('topbar', 'usersettings');
elgg_register_menu_item('topbar', array('name' => 'usersettings', 'parent_name' => 'account', 'href' => "/settings/user/{$user->username}", 'text' => elgg_echo('settings'), 'priority' => 103, 'section' => 'alt'));
elgg_unregister_menu_item('topbar', 'logout');
elgg_register_menu_item('topbar', array('name' => 'logout', 'parent_name' => 'account', 'href' => '/action/logout', 'is_action' => TRUE, 'text' => elgg_echo('logout'), 'priority' => 104, 'section' => 'alt'));
elgg_unregister_menu_item('topbar', 'administration');
if (elgg_is_admin_logged_in()) {
elgg_register_menu_item('topbar', array('name' => 'administration', 'parent_name' => 'account', 'href' => 'admin', 'text' => elgg_echo('admin'), 'priority' => 101, 'section' => 'alt'));
}
elgg_unregister_menu_item('footer', 'report_this');
if (elgg_is_active_plugin('reportedcontent')) {
$href = "javascript:elgg.forward('reportedcontent/add'";
$href .= "+'?address='+encodeURIComponent(location.href)";
$href .= "+'&title='+encodeURIComponent(document.title));";
elgg_register_menu_item('extras', array('name' => 'report_this', 'href' => $href, 'title' => elgg_echo('reportedcontent:this:tooltip'), 'text' => elgg_view_icon('report-this'), 'priority' => 500));
}
}
}
示例15: __construct
/**
* Constructor
*
* @param ElggEntity $entity Agent entity
*/
public function __construct($entity = null)
{
if (!$entity) {
$entity = elgg_get_logged_in_user_entity();
}
$this->entity = $entity;
}