Hey!

I'm trying to make a Panels install profile that ships with Total Control.

Unfortunately, total control's hook_requirements doesn't work in a .install profile.

1) the use of url() doesn't work in an install profile, because it eventually tries to call db_result() which isn't loaded yet
2) The version verification you're attempting doesn't work with the install profiles because the actual .module files are not loaded.

If you check out panels.install I actually check for definitions of CTOOLS_API_VERSION and load the module file manually. That seems to work there. If they've got a current version of CTools I wouldn't even bother checking for a current version of Panels, honestly.

My install profile can go forward without TC if it has to, but hopefully it won't have to.

Comments

jenlampton’s picture

Status: Active » Needs review

Okeydokey. I'm trying something like this...

function total_control_requirements($phase) {
  $requirements = array();
  // Ensure translations don't break at install time.
  $t = get_t();
  // Assume that if the user is running an installation profile that both
  // Panels and CTools are the same release.
  if ($phase == 'install' && !(defined('MAINTENANCE_MODE') && MAINTENANCE_MODE == 'install')) {

    // Get panels required version.
    if (!defined('TOTAL_CONTROL_REQUIRED_PANELS_API')) {
      include_once drupal_get_path('module', 'total_control') . '/total_control.module';
    }
    // Check panels current version.
    if (module_exists('panels')){
      include_once drupal_get_path('module', 'panels') . '/panels.module';
      $panels_version = module_invoke('panels', 'api_version');
      if ($panels_version[0] < 3) {
        drupal_set_message('checking panels version');
         $requirements['total_control_panels'] = array(
           'title' => $t('Panels API Version'),
           'value' => $panels_version[0],
           'severity' => REQUIREMENT_ERROR,
           'description' => t('The Version of Panels is too old. Total Control needs at least %version.0.', array('%version' => TOTAL_CONTROL_REQUIRED_PANELS_API))
         );
      } 
    }
    
    // Get views required version.
    if (!defined('TOTAL_CONTROL_REQUIRED_VIEWS_API')) {
      include_once drupal_get_path('module', 'total_control') . '/total_control.module';
    }
    // Check views current version.
    if (module_exists('views')){
      include_once drupal_get_path('module', 'views') . '/views.module';
      $views_version = module_invoke('views', 'api_version');
      if ($views_version < 2) {
        drupal_set_message('checking views version');
         $requirements['total_control_views'] = array(
           'title' => $t('Views API Version'),
           'value' => $views_version,
           'severity' => REQUIREMENT_ERROR,
           'description' => t('The Version of Views is too old. Total Control needs at least %version.0.', array('%version' => TOTAL_CONTROL_REQUIRED_VIEWS_API))
         );
      } 
    }
    
  }
  return $requirements;
}

and everything is working with the latest versions. It could be that I've done something wrong and nothing's happening at all, or it could actually be working :-) Unfortunately, I don't know where to grab a copy of panels 2.x or views 1.x to make it do its thing :(

jenlampton’s picture

Status: Needs review » Fixed

committed.

Status: Fixed » Closed (fixed)

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