Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(developers): explorer entity information in developer tools #10318

Merged
merged 1 commit into from
Oct 10, 2016

Conversation

jdalsem
Copy link
Member

@jdalsem jdalsem commented Sep 30, 2016

With the developer tools you can now lookup attributes, metadata,
relationships and private settings of entities. You can also remove
individual metadata, relationships or private settings for an entity or
remove an entity completely.

fixes #9384

entity_explorer

Copy link
Contributor

@hypeJunction hypeJunction left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In hypeDBExplorer (https://github.com/hypejunction/hypedbexplorer) I also have subgrids for metadata owned by the entities, entity annotations and annotations owned, entities owned and contained by the entity, access collections owned by the entity, access collections the entity is member of, river items that the entity is subject/object/target of

if (empty($entity) || empty($type) || $key === null) {
register_error(elgg_echo('error:missing_data'));
access_show_hidden_entities($show_hidden);
forward(REFERER);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should start using response objects for new actions.
return elgg_error_response()

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

}

// Entity Information
$entity_rows = ['type', 'subtype', 'owner_guid', 'site_guid', 'container_guid', 'access_id', 'time_created', 'time_updated', 'last_action', 'enabled'];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a static method to ElggEntity to get those from there?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

meh... maybe later... schema is being overhauled... could add it later on...


$entity_info .= '</table>';

echo elgg_view_module('inline', elgg_echo('developers:entity_explorer:info:attributes'), $entity_info);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One module - one view. Makes it easier to read and modify.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

}
$metadata_info .= '<td>' . elgg_view('output/url', [
'text' => elgg_view_icon('remove'),
'href' => 'action/developers/entity_explorer_delete?guid=' . $entity->guid . '&type=metadata&key=' . $md->name,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use elgg_http_add_url_query_elements()

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

if (empty($entity_relationships)) {
$relationship_info = elgg_echo('notfound');
} else {
$relationship_columns = ['id', 'time_created', 'guid_one', 'relationship', 'guid_two'];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make guid_one and guid_two links that open a new tab/ligthbox with Entity explorer for that entity

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool but can wait

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will wait...

echo elgg_view_module('inline', elgg_echo('developers:entity_explorer:info:attributes'), $entity_info);

// Metadata Information
$entity_metadata = elgg_get_metadata(['guid' => $guid, 'limit' => false]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably use elgg_list_* where possible with proper offset keys, in case these get too much on a large site.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

metadata is manageable... offsets makes it more complex... you will just have to wait a few secs longer

@mrclay
Copy link
Member

mrclay commented Oct 1, 2016

I think non-tech admins could really wreck things with this. I wouldn't mind requiring a setting be checked to enable editing, with a big red warning. And a hook to override so sites could decide who can edit. But I'm paranoid.

@jdalsem
Copy link
Member Author

jdalsem commented Oct 3, 2016

subgrids for metadata owned by the entities, entity annotations and annotations owned, entities owned and contained by the entity, access collections owned by the entity, access collections the entity is member of, river items that the entity is subject/object/target of

i was trying to add a basic feature for debugging... dbexplorer brings way more features... like it, but may be a bit too much for core...

I think non-tech admins could really wreck things with this.

it is developer tools... i do not expect non-tech to use it a lot.

And a hook to override so sites could decide who can edit.

can always make a view_var hook to quick return if you want to limit it....

@jdalsem
Copy link
Member Author

jdalsem commented Oct 3, 2016

hoping this can go in in current state... if you see need for improvements you can always add a PR for it

<?php
$entity = elgg_extract('entity', $vars);

$entity_rows = ['type', 'subtype', 'owner_guid', 'site_guid', 'container_guid', 'access_id', 'time_created', 'time_updated', 'last_action', 'enabled'];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Entities are iterators:

foreach ($entity as $attr => $value) {
    // just need to strip password_hash, password, and salt.
}


foreach ($entity_rows as $entity_row) {
$entity_info .= '<tr>';
$entity_info .= '<td>' . $entity_row . '</td><td>' . $entity->$entity_row . '</td>';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs htmlspecialchars(..., ENT_QUOTES)

if (empty($entity_metadata)) {
$metadata_info = elgg_echo('notfound');
} else {
$md_columns = ['id', 'name_id', 'name', 'value_id', 'value', 'value_type', 'access_id', 'time_created', 'enabled'];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ElggMetadata iterate their attributes, too.

foreach ($entity_metadata as $md) {
$metadata_info .= '<tr>';
foreach ($md_columns as $md_col) {
$metadata_info .= '<td>' . $md->$md_col . '</td>';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here...


foreach ($private_settings as $key => $value) {
$private_settings_info .= '<tr>';
$private_settings_info .= "<td>$key</td><td>$value</td>";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HTML escape both

Copy link
Member

@mrclay mrclay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HTML escaping is a must. Reworking to use iterators (for everything) to get attributes/values can wait.

@mrclay
Copy link
Member

mrclay commented Oct 4, 2016

I suppose filter_tags() would be OK instead of escaping.

@jdalsem
Copy link
Member Author

jdalsem commented Oct 4, 2016

i think going for output/text is more the elgg way

With the developer tools you can now lookup attributes, metadata,
relationships and private settings of entities. You can also remove
individual metadata, relationships or private settings for an entity or
remove an entity completely.

fixes Elgg#9384
@jdalsem
Copy link
Member Author

jdalsem commented Oct 7, 2016

now using output/text, so html is escaped where needed

@jdalsem jdalsem merged commit 939a4b3 into Elgg:2.x Oct 10, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants