Updated: Comment #N

Problem/Motivation

Proposed resolution

Remaining tasks

  • Rework the access hooks to show the correct view display

User interface changes

API changes

Original report by @username

When managing platforms, it's useful to know which packages are being used. The Project Status extension for Drush was created to that end. Now that we have Views listing packages, it'd be nice to be able to integrate this into the front-end.

In the 'dev/site-count' branch, I have a very basic implementation that is modelled after the 'Site count' field on platforms. Unfortunately, it's very limited, as it functions at Views' render() function, after the query is complete. As a result, it can't be sorted, which is essential for it to be really useful.

Comments

ergonlogic’s picture

Status: Active » Needs review

We now have a sortable implementation in 'dev/packages-count' branch. Basically, we insert a subquery like so:

function query() {
    parent::query();
    $this->query->add_field(NULL, '(SELECT count(iid) FROM {hosting_package_instance} pi WHERE pi.package_id = node_hosting_package_instance_nid AND pi.platform = ' . $this->view->args[0] . ' AND pi.status = 1)', 'site_count');
  }

It's kinda ugly and could use some error-handling, but it works well enough.

helmo’s picture

I didn't see this straight away on the platform node packages page. I still got the 'Page: Site packages' view result. Extra update hook?
The site count column worked fine in the views preview though.

anarcat’s picture

Status: Needs review » Needs work
ergonlogic’s picture

Status: Needs work » Needs review

#2 is actually an issue with #2031747: Properly control Views access. I removed the PHP we were injecting into our blocks, but since access control isn't enforced for UID1, you sometimes get views where they shouldn't be.

ergonlogic’s picture

Status: Needs review » Fixed

Actually, the problem in #2 is because we now have 2 views displays that are trying to react to the /node/%/packages path, and the first one is winning. This is resolved by our access plugin, but since this isn't checked for UID1, the admin user will only ever see the basic ('site') packages page. This should work for any other user though.

Merged into 6.x-2.x.

helmo’s picture

After installation the user gets a uli for the 'admin' user, and I guess many will keep on using that account.... :(

ergonlogic’s picture

Status: Fixed » Active

IIRC, the general indication for Drupal is not to normally operate as UID1, except when performing db updates. I know I find myself doing so a lot though. I believe it is a contributing factor to our roles not having been as useful as they should be now. Maybe we need better documentation to this effect? Either way, though, this is a fairly minor UI degradation when operating as UID1.

Anyway, I've done everything I can think of within the Views UI to get this to work for UID1, but then using an access plugin isn't necessarily the right way to proceed here either. I think we could implement our own display type, extending views_plugin_display_page and overriding execute_hook_menu(). Or perhaps there's a hook_views_alter() for that, but I don't see it.

Another option might be to go back to using a single display for packages, and altering it selectively based on the node type. That is, remove the useless 'status' filter on platform nodes, and remove the confusing 'sites' column from site nodes. Maybe somewhere in hook_views_pre_build() or hook_views_post_build()?

I'm pretty new to Views development though, so I'm open to better ways of proceeding.

helmo’s picture

Version: 6.x-2.x-dev » 7.x-3.x-dev
Issue summary: View changes

Lets see if we can rework this while we update the views for 7.x

ergonlogic’s picture

As per #5 on #2177705: [META] Fix Views integration, I've begun using views and block alter hook with some success. They should work here too.

  • Commit c10be50 on 6.x-2.x, 7.x-3.x, dev/packages-count, dev-ssl-ip-allocation-refactor, dev-sni, dev-helmo-3.x by ergonlogic:
    Issue #2035873: Show count of sites using packages.
    

  • Commit c10be50 on 6.x-2.x, 7.x-3.x, dev/packages-count, dev-ssl-ip-allocation-refactor, dev-sni, dev-helmo-3.x by ergonlogic:
    Issue #2035873: Show count of sites using packages.
    

  • ergonlogic committed c10be50 on dev-helmo-3.x
    Issue #2035873: Show count of sites using packages.
    

  • ergonlogic committed c10be50 on 7.x-3.x-1995506
    Issue #2035873: Show count of sites using packages.
    

  • ergonlogic committed c10be50 on dev-2223033
    Issue #2035873: Show count of sites using packages.
    

  • ergonlogic committed c10be50 on dev-2359571
    Issue #2035873: Show count of sites using packages.
    

  • ergonlogic committed c10be50 on 7.x-4.x
    Issue #2035873: Show count of sites using packages.
    
ergonlogic’s picture

Status: Active » Fixed

This has been fixed for a long time, AFAICT.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.