I have a module called quickbar which is like admin 1.0 toolbar without the theme. Is there something I can do to help support this module? Or what is needed so this module can support quickbar?

Comments

Deciphered’s picture

Hi redndahead,

I really should have put together some api documentation, but I wrote this module last night during the Drupal Melbourne meetup and finished it off during my train trip home, so it's a bit of a quicky.

There's two hooks that your module (or admin_select on behalf of your module) needs to declare to add support, examples can be seen in 'includes/admin.inc' and 'includes/admin_menu.inc'.

hook_admin_select_module() adds your module to the list of available choices.

hook_admin_select_init() is passed a variable containing the name of the selected admin menu module, so you need to check if it's not your module, and if not you need to suppress your menu from showing up. Both admin and admin_menu have a _suppress() function that can be called, quickbar doesn't seem to, but you might have some other method to do it. At the least, you could right the code that disables quickbar directly inside this hook.

I'd be more than happy to help more with this if this information is not enough.

Cheers,
Deciphered.

Deciphered’s picture

I'd suggest holding off for a little bit, based on Dave Reids patches I will likely change the API in 1.1 (which should be out by today).

Deciphered’s picture

The new API (pending any last minute changes) will now be one single function, attached is the example for the api.php file:

/**
 * Implements hook_admin_select_info().
 *
 * @return
 *   An associative array of Administration Menu modules provided by this
 *   module, keyed by tag name with the following properties:
 *   - title: The human readable name of the module.
 *   - access arguments: An array of arguments for user_access().
 *   - suppress callback: The modules suppress function.
 *   - file: (optional) The include file where the callback function resides.
 */
function hook_admin_select_info() {
  $info = array();

  $info['MYMODULE'] = array(
    'title' => t('My Module'),
    'access arguments' => array('access MYMODULE'),
    'suppress callback' => 'MYMODULE_suppress',
    'file' => drupal_get_path('module', 'MYMODULE') . '/MYMODULE.admin_select.inc',
  );

  return $info;
}

If you need any help I would be more than happy to provide it.

redndahead’s picture

Version: 6.x-1.0 » 6.x-1.1
Status: Active » Fixed

so I added support for this module into quickbar. I ran into some issues though. Since admin_select is set weighted lower than quickbar the suppress never takes place. To fix this I did my own checking to see if the admin select data was set and work accordingly. So I think one of either 2 things would be nice.

1) admin_select gets weighted higher.
2) There is a function admin_select_is_active($module) It could look like this:

function admin_select_is_active($module) {
  global $user;
  $data = unserialize($user->data);
  if (isset($data['admin_select']) && $data['admin_select'] == $module) {
    return TRUE;
  }

  return FALSE;
}

so I can do admin_select_is_active('quickbar') and verify that quickbar should be active. Maybe a get active would work also. Which would return the active admin toolbar.

Deciphered’s picture

Title: Add support for quickbar module » Add support for Adminstration Menu select module
Project: Administration Menu select » Quickbar
Version: 6.x-1.1 » 6.x-1.x-dev
Status: Fixed » Active

HI redndahead,

I noticed a similar issue in the Toolbar module, the suppress call was being checked in hook_init(), whereas both Admin and Admin menu check in hook_footer(), which seems to work fine. They do still add there JS and CSS in hook_init(). Toolbar re-arranged some things and got it working fine, though I don't think it's using hook_footer().

Do either of those options appeal?

Also, on a side not, I added another feature to the Admin and Admin menu integrations in the dev releases, not something that I can really make a hook for as, but basically it's adding a quick-switched to each menu. Admin gets a block and Admin menu gets a menu (under the icon item). The Block and Menu are both defined by the Admin Menu select module, so if you can inject a menu or block into Quickbar anyway it would be great to also add this functionality.

Cheers,
Deciphered.

Deciphered’s picture

Also, correct me if I'm wrong, but you've only put the suppress method in dev? (just testing)

redndahead’s picture

Tagging

redndahead’s picture

Status: Active » Fixed

I think what's implemented is what it's going to be. ;)

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