Requires #1861896: Make $type argument of function hosting_available_tasks() optional..

The current hosting_task.module code prevents any other node type from being able to use Tasks. The module hard codes site, platform, server into the logic of hook_menu:


/**
 * Implementation of hook_menu().
 */
function hosting_task_menu() {
  $items = array();
  foreach (array('site', 'platform', 'server') as $type) {
    if (!($tasks = hosting_available_tasks($type))) {
      // this is to workaround problems in the upgrade path where the
      // hook returns nothing (e.g. for server)
      continue;
    }
    foreach ($tasks as $task => $info) {
      if (empty($info['hidden'])) {
        $path = sprintf("node/%%hosting_%s_node/%s_%s", $type, $type, $task);
        $items[$path] = array(
           'title' => $info['title'],
           'description' => $info['description'],
           'page callback' => 'drupal_get_form',
           'page arguments' => array('hosting_task_confirm_form', 1, $task),
           'access callback' => 'hosting_task_menu_access_csrf',
           'access arguments' => array(1, $task),
           'type' => MENU_CALLBACK,
         );
        $items[$path] = array_merge($items[$path], $info);
      }
    }
  }
}

The following patch uses hook_hosting_tasks() to determine which Node Types and which tasks need Ajax. This allows other objects to use the Tasks functionality.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Jon Pugh’s picture

Steven Jones’s picture

Is this the only place that this is enforced, or are there lots of other places where Aegir asserts that you'll only run task against a site, platform or server?

anarcat’s picture

I don't know, but it seems like a good start, is this RTBC?

Steven Jones’s picture

Status: Needs review » Needs work

The patch in #1 seems to have a lot of unrelated code changes, was it diffed against the 6.x-2.x branch?

anarcat’s picture

Jon, we need a reroll here. It would also be useful if you published your code as sandboxes instead of patches, which would get rid of errors like this.

ergonlogic’s picture

Category: feature » bug

This kind of hardcoded limitation seems like more of a bug than a feature request.

anarcat’s picture

Priority: Normal » Major

i'd like to see this in 2.x.

ergonlogic’s picture

Status: Needs work » Needs review
FileSize
845 bytes

The relevant bit from #1 appears to be something like the attached patch. From my limited testing, it works just fine.

anarcat’s picture

this looks good, but i haven't tested it.

ergonlogic’s picture

Status: Needs review » Fixed

I've tested this quite a bit, and it appears to work well. So I've committed it in 15b6240.

Status: Fixed » Closed (fixed)

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