Skip to content

#2498 - Metrics - Personal Layers Map #2542

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

Merged

Conversation

kodinkat
Copy link
Contributor

return $params;
}

private function list_assigned_post_ids( $post_type, $user_id, $fields = [ 'ID' ], $limit = 500000 ): array {
Copy link
Member

Choose a reason for hiding this comment

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

@kodinkat, lets add an extra param post_type_geojson with the restrict param and add the sql directly if it is present.
Only query subassigned of the post_type is contacts.
Also remember that "subassinged" does not use the $user_id, it needs to be the contact id.

@corsacca
Copy link
Member

@kodinkat, can we separate what layers are added to the personal map and the dynamic map? Right now those are synced.

@corsacca
Copy link
Member

corsacca commented Aug 5, 2024

@kodinkat
A random multiplier seems to be able to see all contacts:
image

@@ -36,7 +36,7 @@ public static function get_by_grid_id( $grid_id ) {
", $grid_id ), ARRAY_A );

if ( empty( $results ) ) {
$results = [];
$results = array();
Copy link
Member

Choose a reason for hiding this comment

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

@kodinkat why all these array() changes?

@@ -18,17 +18,21 @@ class DT_Metrics_Dynamic_Records_Map extends DT_Metrics_Chart_Base
public $slug = 'dynamic_records_map'; // lowercase
public $js_object_name = 'wp_js_object'; // This object will be loaded into the metrics.js file by the wp_localize_script.
public $js_file_name = '/dt-metrics/records/dynamic-records-map.js'; // should be full file name plus extension
public $permissions = [ 'dt_all_access_contacts', 'view_project_metrics' ];
public $permissions = [ 'dt_all_access_contacts', 'view_project_metrics', 'multiplier' ];
Copy link
Member

Choose a reason for hiding this comment

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

@kodinkat multiplier is not a permission. Please explain

Copy link
Member

@corsacca corsacca left a comment

Choose a reason for hiding this comment

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

@kodinkat please sanity check this one

$shared_user_condition_sql = '';
if ( isset( $args['list_all'], $args['list_all_by_user_id'] ) && !$args['list_all'] ) {
$post_id_filter_sql = $wpdb->prepare( "
SELECT * FROM
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this outer layer is needed

SELECT api_p.ID
FROM $wpdb->posts api_p
LEFT JOIN $wpdb->postmeta as field_type ON ( field_type.post_id = api_p.ID AND field_type.meta_key = 'type' )
WHERE (field_type.meta_value = 'access' OR field_type.meta_value = 'user' OR field_type.meta_value = 'access_placeholder')
Copy link
Member

Choose a reason for hiding this comment

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

This keeps groups from showing.
We don't need to filter by type for personal contacts

$post_id_filter_sql = '';
$shared_user_join_sql = '';
$shared_user_condition_sql = '';
if ( isset( $args['list_all'], $args['list_all_by_user_id'] ) && !$args['list_all'] ) {
Copy link
Member

Choose a reason for hiding this comment

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

list_all seems to be set by the browser.
Consider checking if the user can actually list all. the new genmapper should have code to copy.

AND api_p.post_type = %s
GROUP BY api_p.ID
LIMIT 0, 50000
) AS assigned_post_ids
Copy link
Member

Choose a reason for hiding this comment

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

I'm confused at this whole section. It says assigned_post_ids, but no sql to to with assignment?
Could be that just the share filter is needed here.

@corsacca
Copy link
Member

@kodinkat The records map no longer shows up for non admin users.
We should be using the same strategy as: #2483

Once that is addressed, please make user the https://multisite.lwp/wp-json/dt-metrics/personal/dynamic_records_map/post_type_geojson endpoint is secure. (Ie, that removing the "slug" param from the api call doesn't let the non admin user have access to all records.

@corsacca
Copy link
Member

Thank you @kodinkat!

@corsacca corsacca merged commit ac0886e into DiscipleTools:develop Aug 22, 2024
2 checks passed
micahmills added a commit that referenced this pull request Sep 13, 2024
…#2558)

* moves component services to header

* SSO: uncomment recaptcha check, save SSO methods used in user meta(#2518)

* chore: uncomment recaptcha check in backend

* feat: save a list of sign in providers

* Add color variables to css (#2516)

* add color variables to css

This allows their easy re-use within plugins

* update from style guide

* rebuild styles

* Fix errors saving dropdown option translations (#2513)

* fix parsing of option translation locale

* don't reset option label upon saving translation

* Fix translations on field option labels from being overwritten.
Fix saving custom label over default translated label.

* phpcs

---------

Co-authored-by: corsac <corsacca@gmail.com>

* Translated using Weblate (Croatian) (#2520)

Currently translated at 99.8% (1206 of 1208 strings)

Translated using Weblate (Swahili)

Currently translated at 100.0% (1208 of 1208 strings)

Translated using Weblate (Swahili)

Currently translated at 83.5% (1009 of 1208 strings)

Translated using Weblate (French (fr_FR))

Currently translated at 85.5% (1034 of 1208 strings)

Translated using Weblate (Italian (it_IT))

Currently translated at 100.0% (1208 of 1208 strings)

Translated using Weblate (Croatian)

Currently translated at 99.9% (1207 of 1208 strings)

Translated using Weblate (Bosnian (bs_BA))

Currently translated at 100.0% (1208 of 1208 strings)

Translated using Weblate (Bosnian (bs_BA))

Currently translated at 99.9% (1207 of 1208 strings)

Translated using Weblate (Bosnian (bs_BA))

Currently translated at 99.9% (1207 of 1208 strings)

Update translation files

Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.







Translate-URL: https://translate.disciple.tools/projects/disciple-tools/disciple-tools-theme/
Translate-URL: https://translate.disciple.tools/projects/disciple-tools/disciple-tools-theme/bs_BA/
Translate-URL: https://translate.disciple.tools/projects/disciple-tools/disciple-tools-theme/fr_FR/
Translate-URL: https://translate.disciple.tools/projects/disciple-tools/disciple-tools-theme/hr/
Translate-URL: https://translate.disciple.tools/projects/disciple-tools/disciple-tools-theme/it_IT/
Translate-URL: https://translate.disciple.tools/projects/disciple-tools/disciple-tools-theme/sw/
Translation: Disciple.Tools/Disciple Tools Theme

Co-authored-by: Weblate <noreply@weblate.org>
Co-authored-by: Dragana <celikdragana0@gmail.com>
Co-authored-by: Kyle Koval <kyle.koval@gmail.com>
Co-authored-by: Leila Mohamed <nevergvup.leila@gmail.com>
Co-authored-by: Paul Bruss <mosquitoacres@gmail.com>
Co-authored-by: Zlatko Celik <zlatko.celik@gmail.com>

* Disciple.Tools v1.64

* User Profile: Ensure user display name is maintained (#2521)

* D.T Reports: add list function to dt-reports class (#2484)

* feat: add where function to dt-reports class

* feat: return error if wrong value type is given

* feat: move value of where clause into array; refactor: where name to list

putting the value in an array will mean we can add operators and other upgrades to how the where works later

* Workflows: Ensure connection fields trigger associated workflow execution (#2522)

* Settings D.T: limit number for users listed in base user select

* Workflows: Added custom Comments action (#2517)

* Added custom Comments action to workflows

* Prevents comments from being added multiple times

* Resolved comments

* code styles fixes

* Removed comments from step 2

* Ran prettier

* Metrics - Personal - Gen-Map - Restrict To Records Responsible For (#2504)

* Ensure to only restrict to records user is responsible for

* Filter accordingly by slug & post type

* Simplified query results generation logic

* Removed unwanted write log statement

* Ensure record node shares are forced for administrators

* Access to view all records can view entire tree. Multipliers can see the name of their own record.

* #2496 - Select & Tags Cumulative Activity Metrics Charts (#2514)

* Select & tags cumulative activity metrics charts

* UI tweaks & end of time range cumulative total matches

* Improved modal count mismatches

* Added pm.meta_value group by to updated month sql

* wording

* Cleaned up stale code blocks

* Cleaned up straggling stale code blocks

* Check for create_users permission when displaying Add User submenu (#2530)

* Translated using Weblate (Swahili) (#2531)

Currently translated at 100.0% (1208 of 1208 strings)

Translated using Weblate (Italian (it_IT))

Currently translated at 100.0% (1208 of 1208 strings)

Translated using Weblate (Bosnian (bs_BA))

Currently translated at 100.0% (1208 of 1208 strings)

Update translation files

Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.





Translate-URL: https://translate.disciple.tools/projects/disciple-tools/disciple-tools-theme/
Translate-URL: https://translate.disciple.tools/projects/disciple-tools/disciple-tools-theme/bs_BA/
Translate-URL: https://translate.disciple.tools/projects/disciple-tools/disciple-tools-theme/it_IT/
Translate-URL: https://translate.disciple.tools/projects/disciple-tools/disciple-tools-theme/sw/
Translation: Disciple.Tools/Disciple Tools Theme

Co-authored-by: Weblate <noreply@weblate.org>
Co-authored-by: Dragana <celikdragana0@gmail.com>
Co-authored-by: Kyle Koval <kyle.koval@gmail.com>
Co-authored-by: Leila Mohamed <nevergvup.leila@gmail.com>

* Disciple.Tools v1.65.0

* Fix personal genmap access to records

* Custom password reset flow: Clear user cache when saving the reset key

* Fix email headers and login template errors (#2534)

* fix: add content-type: text/html correctly if headers is a string

fix: deal with  being a string when checking for content-type: text/html

* fix: Undefined array key 0 in login-user-manager

* phpcs

* Metrics: Collapse field selects down to a single row (#2533)

* SOO Login: fix issue where email wasn't being captured

* Metrics - Genmapper - Show Data Layers (#2515)

* Introduced data layer field filters for generational tree metrics

* Addressed sql placeholders code smells

* Ignore string array escaping

* Revised ui and data layer flow logic

* Introduced displaying of field icons

* Added switch to toggle between labels and icons

* wording

* Enforce data layer display ordering

* Hide data layer settings by default + Also display status field label

* Plus icon count for each field line + White icons with fixed size

* Ensure mdi font icons default to white

* SSO Login: setting to persist login (#2537)

* SOO Login: setting to persist login

* phpcs

* phpcs

* Metrics > Genmapper: fix icon sizing and alignment (#2539)

* Template integration in dt-modal of duplicate detected button

* Customizations: Fix tile label translations and clearing field translations (#2550)

* Customizations: Fix tile label translations and clearing field translations

* revert phpcs

* #1873 - Default Reply To On Email Notifications (#2545)

* Default reply-to on email notifications

* Wording and order

* Don't overwrite existing reply to values

* Change default email name and address

* revert phpcs

---------

Co-authored-by: corsac <corsacca@gmail.com>

* Admin Actions integration on edit page.

* Workflow action: Comment replace user or connection tokens with values (#2541)

* Comments {subassigned} functionality

* removed hardcoded {connections}

* PR cleanup/optimizations

* Copied Jon's Fixes

* Customizations: Resolved missing permissions on role updates bug (#2552)

* SSO Login: allow logging in with firebase ID when email is not provided. (#2536)

* SOO Login: allow logging in with firebase ID when email is not provided.

* phpcs

* fix typo

* #2523 - Ensure Geocoded Locations Are Copied When Transferring Contact To Another Instance (#2525)

* Ensure geocoded locations are copied when transferring contact to another instance

* Transfer additional geolocation grid meta info

* Transfer actual grid meta to be used + Avoid duplicate location_grid values

* Add by pre-defined meta grid values

* Reverted posts.php auto formatting

* Reverted contacts-transfer.php auto formatting

* Undefined error fix

* revert structure change

* allow dup locations

* Translated using Weblate (Italian (it_IT)) (#2556)

Currently translated at 100.0% (1209 of 1209 strings)

Translated using Weblate (Arabic)

Currently translated at 83.3% (1008 of 1209 strings)

Translated using Weblate (Vietnamese)

Currently translated at 100.0% (1209 of 1209 strings)

Translated using Weblate (Vietnamese)

Currently translated at 85.7% (1037 of 1209 strings)

Update translation files

Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translated using Weblate (French (fr_FR))

Currently translated at 85.6% (1035 of 1208 strings)






Translate-URL: https://translate.disciple.tools/projects/disciple-tools/disciple-tools-theme/
Translate-URL: https://translate.disciple.tools/projects/disciple-tools/disciple-tools-theme/ar/
Translate-URL: https://translate.disciple.tools/projects/disciple-tools/disciple-tools-theme/fr_FR/
Translate-URL: https://translate.disciple.tools/projects/disciple-tools/disciple-tools-theme/it_IT/
Translate-URL: https://translate.disciple.tools/projects/disciple-tools/disciple-tools-theme/vi/
Translation: Disciple.Tools/Disciple Tools Theme

Co-authored-by: Weblate <noreply@weblate.org>
Co-authored-by: Charlie Ritchie <ritchiecharlie@gmail.com>
Co-authored-by: Corsacca <corsacca@gmail.com>
Co-authored-by: FarahDoumani <farahdoumani@gmail.com>
Co-authored-by: Kyle Koval <kyle.koval@gmail.com>

* Disciple.Tools v1.66

* removed unwanted code and added comments

* corrected heading and styling duplicate detected

* Metrics - Personal Layers Map (#2542)

* Support record maps within personal metrics

* Embedded filter by post id sql + Split local storage cookie across menu slugs

* Updated sql to ensure only shared records are returned

* Resolved auto formatting issue

* Additional tidy-ups

* Simplified sql

* Ensure metrics is only shown for specific user roles

* Personal for all. Dynamics by permissions

* Prevent non-slug related requests

* Moved permissions check to endpoint

* Revised permission checks + Updated genmap to follow new checks

* Lists: Split By - Option To Clear Filters (#2544)

* Display current filter labels

* Deleted console logs

* Ignore sorting labels

* Support multiple split-by filters with dynamic count refreshes

* Avoid auto filter refreshes on split by option selections

* Enforce overwriting of previously selected field options

* PHPCS - Upgrade WP-Coding Standards To v3 (#2546)

* Updated to v3.1.0

* Introduced additional rules to reduce error counts

* Further reduced sniff exceptions

* Resolved remaining exceptions

* Revert "Resolved remaining exceptions"

This reverts commit f5103bb.

* fix MultiLineFunctionDeclaration errors

* remove some rules

* remove commented excludes

* enable Generic.WhiteSpace.IncrementDecrementSpacing

* enable Universal.Arrays.DuplicateArrayKey

* enable Universal.WhiteSpace.CommaSpacing

* enable NormalizedArrays.Arrays.ArrayBraceSpacing

* enable PSR2.Classes.ClassDeclaration

* enable PSR2.Files.EndFileNewline

* enable Generic.CodeAnalysis.RequireExplicitBooleanOperatorPrecedence

* enable PSR2.Methods.FunctionClosingBrace

* enable WordPress.DB.PreparedSQL

* enable WordPress.Security.NonceVerification

---------

Co-authored-by: corsac <corsacca@gmail.com>

* Only set D.T base email name and email address if none other is set (#2562)

* feat: add a hook when deleting a post (#2568)

* feat: add before post deleted hook (#2569)

* phpcbf

* fixes camel case error

* phpcs fix

* phpcs fixes for proper snake case

* prettier styling fixes

* gulp build files

---------

Co-authored-by: Micah Mills <micahmills@gmail.com>
Co-authored-by: squigglybob <squigglybob@users.noreply.github.com>
Co-authored-by: cairocoder01 <44169599+cairocoder01@users.noreply.github.com>
Co-authored-by: corsac <corsacca@gmail.com>
Co-authored-by: discipletoolsbot <115006603+discipletoolsbot@users.noreply.github.com>
Co-authored-by: Weblate <noreply@weblate.org>
Co-authored-by: Dragana <celikdragana0@gmail.com>
Co-authored-by: Kyle Koval <kyle.koval@gmail.com>
Co-authored-by: Leila Mohamed <nevergvup.leila@gmail.com>
Co-authored-by: Paul Bruss <mosquitoacres@gmail.com>
Co-authored-by: Zlatko Celik <zlatko.celik@gmail.com>
Co-authored-by: kodinkat <me@karlkatewu.com>
Co-authored-by: jlamanskygitt <125215675+jlamanskygitt@users.noreply.github.com>
Co-authored-by: brady-lamansky-gtt <125215973+brady-lamansky-gtt@users.noreply.github.com>
Co-authored-by: Charlie Ritchie <ritchiecharlie@gmail.com>
Co-authored-by: FarahDoumani <farahdoumani@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Metrics > Personal Layers Map
2 participants