You are here

function hackedProject::identify_project in Hacked! 7.2

Same name and namespace in other branches
  1. 6.2 includes/hacked_project.inc \hackedProject::identify_project()

Identify the project from the name we've been created with.

We leverage the update (status) module to get the data we require about projects. We just pull the information in, and make descisions about this project being from CVS or not.

2 calls to hackedProject::identify_project()
hackedProject::download_remote_project in includes/hackedProject.inc
Downloads the remote project to be hashed later.
hackedProject::title in includes/hackedProject.inc
Get the Human readable title of this project.

File

includes/hackedProject.inc, line 60

Class

hackedProject
Encapsulates a Hacked! project.

Code

function identify_project() {

  // Only do this once, no matter how many times we're called.
  if (!empty($this->project_identified)) {
    return;
  }

  // Fetch the required data from the update (status) module.
  // TODO: clean this up.
  $available = update_get_available(TRUE);
  $data = update_calculate_project_data($available);
  $releases = _update_get_cached_available_releases();
  foreach ($data as $key => $project) {
    if ($key == $this->name) {
      $this->project_info = $project;
      if (!isset($this->project_info['releases']) || !is_array($this->project_info['releases'])) {
        $this->project_info['releases'] = array();
      }
      if (isset($releases[$key]['releases']) && is_array($releases[$key]['releases'])) {
        $this->project_info['releases'] += $releases[$key]['releases'];
      }

      // Add in the additional info that update module strips out.
      // This is a really naff way of doing this, but update (status) module
      // ripped out a lot of useful stuff in issue:
      // http://drupal.org/node/669554
      // Find an item that this project includes:
      if (hacked_cvs_enabled()) {
        foreach ($project['includes'] as $name => $title) {
          if (is_dir(drupal_get_path($project['project_type'], $name) . '/CVS')) {
            $this->remote_files_downloader = new hackedProjectWebCVSDownloader($this, drupal_get_filename($project['project_type'], $name));
            break;
          }
        }
      }
      elseif ($this
        ->isDevVersion()) {
        foreach ($project['includes'] as $name => $title) {
          if (is_dir(drupal_get_path($project['project_type'], $name))) {

            // Use the dev downloader as this isn't a formal release.
            $this->remote_files_downloader = new hackedProjectWebDevDownloader($this);
            break;
          }
        }
      }
      $this->project_identified = TRUE;
      $this->existing_version = $this->project_info['existing_version'];
      $this->project_type = $this->project_info['project_type'];
      break;
    }
  }

  // Logging.
  if (!$this->project_identified) {
    watchdog('hacked', 'Could not identify project: @name', array(
      '@name' => $this->name,
    ), WATCHDOG_WARNING);
  }
}