You are here

function hosting_platform_post_hosting_verify_task in Hosting 6.2

Same name and namespace in other branches
  1. 5 platform/hosting_platform.drush.inc \hosting_platform_post_hosting_verify_task()
  2. 7.4 platform/hosting_platform.drush.inc \hosting_platform_post_hosting_verify_task()
  3. 7.3 platform/hosting_platform.drush.inc \hosting_platform_post_hosting_verify_task()

Implementation hook_post_verify().

Sets the platform verified timestamp, to discren when it was verified. Imports all the profiles and modules into package and package release nodes.

File

platform/hosting_platform.drush.inc, line 47
Implement drush hooks for the Platforms module.

Code

function hosting_platform_post_hosting_verify_task($task, $data) {
  $node = $task->ref;
  if ($node->type == 'platform') {
    $context = $data['context'];
    $packages = $context['packages'];

    // Lock platforms by default
    if ($node->verified == 0 && variable_get('hosting_lock_platforms_by_default', FALSE)) {
      $node->platform_status = HOSTING_PLATFORM_LOCKED;
    }
    $node->verified = time();

    // set verified flag on platform, to let it know it has been checked.

    /**
     * If we are verifying a Locked platform (i.e if the publish_path has changed),
     * don't reset the status to Enabled. We don't need to check whether a platform
     * is deleted here for the same reason, because we don't allow a deleted platform
     * to be reverified.
     */
    if ($node->platform_status != HOSTING_PLATFORM_LOCKED) {
      $node->platform_status = HOSTING_PLATFORM_ENABLED;
    }
    $node->no_verify = TRUE;

    // Save the platform being verified
    node_save($node);
    hosting_package_sync($packages['base']);
    hosting_package_sync($packages['sites-all']);
    hosting_package_instance_sync($node->nid, $task->ref->type, $packages['base'], $packages['sites-all']);
    foreach ($context['profiles'] as $profile) {
      hosting_package_sync($packages['profiles'][$profile]);
      $instance = hosting_package_instance_load(array(
        'p.short_name' => $profile,
        'i.rid' => $node->nid,
        'p.package_type' => 'profile',
      ));
      hosting_package_instance_sync($instance->iid, $instance->package_type, $packages['base'], $packages['profiles'][$profile], $packages['sites-all']);

      // @todo : package instances of modules to profiles.
    }
    foreach ($context['sites'] as $url) {
      if (hosting_domain_allowed($url)) {

        // Import any sites that have not been created yet.
        $site = new StdClass();
        $site->type = 'site';
        $site->site_status = HOSTING_SITE_QUEUED;
        $site->import = TRUE;
        $site->title = $url;
        $site->platform = $node->nid;
        $site->client = HOSTING_DEFAULT_CLIENT;
        $site->db_server = HOSTING_DEFAULT_DB_SERVER;
        node_save($site);
        drush_log(dt("Imported existing site !domain", array(
          '!domain' => _hosting_node_link($site->nid),
        )));
        hosting_package_instance_sync($site->nid, $site->type, $packages['base']);
      }
    }
  }
}