Index: sites/all/modules/l10n_server/l10n_community/l10n_community.install
===================================================================
RCS file: /cvs/drupal/contributions/modules/l10n_server/l10n_community/Attic/l10n_community.install,v
retrieving revision 1.1.2.11.2.15.2.7
diff -u -r1.1.2.11.2.15.2.7 l10n_community.install
--- sites/all/modules/l10n_server/l10n_community/l10n_community.install	31 Mar 2010 13:53:00 -0000	1.1.2.11.2.15.2.7
+++ sites/all/modules/l10n_server/l10n_community/l10n_community.install	16 Apr 2010 11:14:51 -0000
@@ -6,6 +6,451 @@
  *   Localization community UI installation, update and uninstallation.
  */
 
+/**
+ * Implementation of hook_install().
+ */
+function l10n_community_install() {
+  drupal_install_schema('l10n_community');
+}
+
+/**
+ * Implementation of hook_uninstall().
+ */
+function l10n_community_uninstall() {
+  drupal_uninstall_schema('l10n_community');
+}
+
+/**
+ * Implementation of hook_schema().
+ */
+function l10n_community_schema() {
+  $schema = array();
+
+  $schema['l10n_server_project'] = array(
+    'description' => 'Projects for which translation is running on the server.',
+    'fields' => array(
+      'pid' => array(
+        'description' => 'Internal numeric identifier for a project.',
+        'type' => 'serial',
+        'not null' => TRUE,
+        'disp-width' => '11'
+      ),
+      'uri' => array(
+        'description' => 'A unique short name to identify the project nicely in paths.',
+        'type' => 'varchar',
+        'length' => '50',
+        'not null' => TRUE
+      ),
+      'title' => array(
+        'description' => 'Human readable name for project used on the interface.',
+        'type' => 'varchar',
+        'length' => '128',
+        'not null' => TRUE
+      ),
+      'home_link' => array(
+        'description' => 'Link to project home page.',
+        'type' => 'text',
+        'not null' => TRUE
+      ),
+      'last_parsed' => array(
+        'description' => 'Unix timestamp of last time project was parsed.',
+        'type' => 'int',
+        'not null' => FALSE,
+        'disp-width' => '11'
+      ),
+      'connector_module' => array(
+        'description' => 'Connector module for this project, such as l10n_localpacks or l10n_drupalorg.',
+        'type' => 'varchar',
+        'length' => '50',
+        'not null' => TRUE,
+      ),
+      'status' => array(
+        'description' => 'Status flag. 1 if new project releases should be looked for, 0 if new scanning and parsing is disabled.',
+        'type' => 'int',
+        'not null' => TRUE,
+      )
+    ),
+    'primary key' => array('pid'),
+    'indexes' => array(
+      'uri' => array('uri')
+    ),
+    'unique keys' => array(
+      'uri_connector_module' => array('uri', 'connector_module')
+    ),
+  );
+
+  $schema['l10n_server_release'] = array(
+    'description' => 'The releases we handle for each project.',
+    'fields' => array(
+      'rid' => array(
+        'description' => 'Internal numeric identifier for a release.',
+        'type' => 'serial',
+        'not null' => TRUE,
+        'disp-width' => '11'
+      ),
+      'pid' => array(
+        'description' => 'Reference to the {l10n_server_project}.pid of the parent project.',
+        'type' => 'int',
+        'not null' => FALSE,
+        'disp-width' => '11'
+      ),
+      'title' => array(
+        'description' => 'Human readable name for release used on the interface.',
+        'type' => 'varchar',
+        'length' => '128',
+        'not null' => TRUE
+      ),
+      'download_link' => array(
+        'description' => 'Link to download this release.',
+        'type' => 'text',
+        'not null' => TRUE
+      ),
+      'file_date' => array(
+        'description' => 'Unix timestamp with release file date. Used to identify file changes.',
+        'type' => 'int',
+        'not null' => FALSE,
+        'disp-width' => '11'
+      ),
+      'file_hash' => array(
+        'description' => 'Hash of file for easy identification of changed files.',
+        'type' => 'varchar',
+        'length' => '32',
+        'not null' => FALSE
+      ),
+      'last_parsed' => array(
+        'description' => 'Unix timestamp of last parsing time for this release package.',
+        'type' => 'int',
+        'not null' => FALSE,
+        'disp-width' => '11'
+      )
+    ),
+    'primary key' => array('rid'),
+    'indexes' => array(
+      'pid' => array('pid')
+    ),
+  );
+
+  $schema['l10n_server_error'] = array(
+    'description' => 'Errors found while parsing release packages. Although we find errors in the release files, we store error notes on a release level, to make them easily accessible without the need for extraneous detail.',
+    'fields' => array(
+      'eid' => array(
+        'description' => 'Internal numeric identifier for an error.',
+        'type' => 'serial',
+        'not null' => TRUE,
+        'disp-width' => '11'
+      ),
+      'rid' => array(
+        'description' => 'Reference to the {l10n_server_release}.rid of the affected release.',
+        'type' => 'int',
+        'not null' => FALSE,
+        'disp-width' => '11'
+      ),
+      'value' => array(
+        'description' => 'Text of the error message.',
+        'type' => 'text',
+        'not null' => TRUE
+      )
+    ),
+    'primary key' => array('eid'),
+    'indexes' => array(
+      'rid' => array('rid')
+    ),
+  );
+
+  $schema['l10n_server_file'] = array(
+    'description' => 'Information on files found and parsed in a release.',
+    'fields' => array(
+      'fid' => array(
+        'description' => 'Internal numeric identifier for a file.',
+        'type' => 'serial',
+        'not null' => TRUE,
+        'disp-width' => '11'
+      ),
+      'pid' => array(
+        'description' => 'Reference to the {l10n_server_project}.pid of the parent project.',
+        'type' => 'int',
+        'not null' => FALSE,
+        'disp-width' => '11'
+      ),
+      'rid' => array(
+        'description' => 'Reference to the {l10n_server_release}.rid of the parent release.',
+        'type' => 'int',
+        'not null' => FALSE,
+        'disp-width' => '11'
+      ),
+      'location' => array(
+        'description' => 'Path to the file within the release package.',
+        'type' => 'varchar',
+        'length' => '255',
+        'not null' => TRUE
+      ),
+      'revision' => array(
+        'description' => 'CVS revision number extracted for reuse in exports.',
+        'type' => 'varchar',
+        'length' => '255',
+        'not null' => TRUE
+      )
+    ),
+    'primary key' => array('fid'),
+    'indexes' => array(
+      'rid' => array('rid')
+    ),
+  );
+
+  $schema['l10n_server_line'] = array(
+    'description' => 'Information on occurances of strings on lines of specific files.',
+    'fields' => array(
+      'pid' => array(
+        'description' => 'Reference to the {l10n_server_project}.pid of the parent project.',
+        'type' => 'int',
+        'not null' => FALSE,
+        'disp-width' => '11'
+      ),
+      'rid' => array(
+        'description' => 'Reference to the {l10n_server_release}.rid of the parent release.',
+        'type' => 'int',
+        'not null' => FALSE,
+        'disp-width' => '11'
+      ),
+      'fid' => array(
+        'description' => 'Reference to the {l10n_server_file}.fid of the parent file.',
+        'type' => 'int',
+        'not null' => FALSE,
+        'disp-width' => '11'
+      ),
+      'lineno' => array(
+        'description' => 'Number of line where the string occurance was found.',
+        'type' => 'int',
+        'not null' => FALSE,
+        'disp-width' => '11'
+      ),
+      'type' => array(
+        'description' => 'Type of occurance. Possible values are constants POTX_STRING_INSTALLER, POTX_STRING_RUNTIME or POTX_STRING_BOTH.',
+        'type' => 'int',
+        'not null' => TRUE,
+        'default' => 0,
+        'disp-width' => '11'
+      ),
+      'sid' => array(
+        'description' => 'Reference to the {l10n_server_string}.sid found on this line.',
+        'type' => 'int',
+        'not null' => FALSE,
+        'disp-width' => '11'
+      )
+    ),
+    'indexes' => array(
+      'fid' => array('fid'),
+      'sid' => array('sid'),
+      'pid' => array('pid'),
+      'rid' => array('rid'),
+    ),
+  );
+
+  $schema['l10n_server_string'] = array(
+    'description' => 'Value of translatable strings found.',
+    'fields' => array(
+      'sid' => array(
+        'description' => 'Internal numeric identifier for a source string.',
+        'type' => 'serial',
+        'not null' => TRUE,
+        'disp-width' => '11'
+      ),
+      'value' => array(
+        'description' => 'The actual translatable string. For strings with multiple plural versions, we store them as the same translatable with a \0 separator (unlike Drupal itself), because it is easier to match translations with them (for multiple plural versions) this way, and we can force people to translate both at once.',
+        'type' => 'text',
+        'not null' => TRUE
+      ),
+      'context' => array(
+        'type' => 'varchar',
+        'length' => 255,
+        'not null' => TRUE,
+        'default' => '',
+        'description' => 'The context this string applies to. Only applicable to some strings in Drupal 7 and its modules.',
+      ),
+      'hashkey' => array(
+        'description' => 'MD5 hash of the concatenation of value and context, used for quick lookups when these two are known (imports, new releases, remote submissions).',
+        'type' => 'char',
+        'length' => 32,
+        'not null' => TRUE
+      ),
+    ),
+    'primary key' => array('sid'),
+    'unique keys' => array(
+      'hashkey' => array('hashkey'),
+    ),
+  );
+
+  $schema['l10n_server_translation'] = array(
+    'fields' => array(
+      'tid' => array(
+        'description' => 'Internal numeric identifier for a translation.',
+        'type' => 'serial',
+        'not null' => TRUE,
+        'disp-width' => '11'
+      ),
+      'sid' => array(
+        'description' => 'Reference to the {l10n_server_string}.sid which is being translated.',
+        'type' => 'int',
+        'not null' => TRUE,
+        'disp-width' => '11'
+      ),
+      'language' => array(
+        'description' => 'Reference to the {languages}.language to which the string is being translated.',
+        'type' => 'varchar',
+        'length' => '12',
+        'not null' => TRUE
+      ),
+      'translation' => array(
+        'description' => 'The actual translation or suggestion.',
+        'type' => 'text',
+        'not null' => TRUE
+      ),
+      'uid_entered' => array(
+        'description' => 'Reference to the {users}.uid who entered this translation or suggestion.',
+        'type' => 'int',
+        'not null' => TRUE,
+        'default' => 0,
+        'disp-width' => '11'
+      ),
+      'uid_approved' => array(
+        'description' => 'Reference to the {users}.uid who approved this translation or suggestion.',
+        'type' => 'int',
+        'not null' => TRUE,
+        'default' => 0,
+        'disp-width' => '11'
+      ),
+      'time_entered' => array(
+        'description' => 'Unix timestamp of time when the translation or suggestion was entered.',
+        'type' => 'int',
+        'not null' => TRUE,
+        'default' => 0,
+        'disp-width' => '11'
+      ),
+      'time_approved' => array(
+        'description' => 'Unix timestamp of time when the translation or suggestion was approved.',
+        'type' => 'int',
+        'not null' => TRUE,
+        'default' => 0,
+        'disp-width' => '11'
+      ),
+      'is_suggestion' => array(
+        'description' => 'Flag of whether this is a suggestion (1) or not (0). If 0, *_approved fields should also be 0.',
+        'type' => 'int',
+        'not null' => TRUE,
+        'default' => 0,
+        'disp-width' => '11'
+      ),
+      'is_active' => array(
+        'description' => 'Flag of whether this is an active (1) suggestion or translation. Older suggestions and translations are kept (0). Unprocessed suggestions and active translations have this as 1.',
+        'type' => 'int',
+        'not null' => TRUE,
+        'default' => 0,
+        'disp-width' => '11'
+      )
+    ),
+    'primary key' => array('tid'),
+    'indexes' => array(
+      'uid_entered' => array('uid_entered'),
+      'is_suggestion_is_active_language' => array('is_suggestion', 'is_active', 'language'),
+      'sid_language_is_suggestion_is_active' => array('sid', 'language', 'is_suggestion', 'is_active')
+    ),
+  );
+
+  $schema['l10n_server_status_flag'] = array(
+    'fields' => array(
+      'sid' => array(
+        'description' => 'Reference to the {l10n_server_string}.sid which is being translated.',
+        'type' => 'int',
+        'not null' => TRUE,
+        'disp-width' => '11'
+      ),
+      'language' => array(
+        'description' => 'Reference to the {languages}.language to which the string is being translated.',
+        'type' => 'varchar',
+        'length' => '12',
+        'not null' => TRUE
+      ),
+      'has_suggestion' => array(
+        'description' => 'Cached status flag of whether there is at least one row in {l10n_server_translation} where is_suggestion = 1, is_active = 1 and sid and language is the same as this one.',
+        'type' => 'int',
+        'not null' => TRUE,
+        'default' => 0,
+        'disp-width' => '11'
+      ),
+      'has_translation' => array(
+        'description' => 'Cached status flag of whether there is at least one row in {l10n_server_translation} where is_suggestion = 0, is_active = 1, translation is not empty and sid and language is the same as this one.',
+        'type' => 'int',
+        'not null' => TRUE,
+        'default' => 0,
+        'disp-width' => '11'
+      ),
+    ),
+    'primary key' => array('sid', 'language'),
+    'indexes' => array(
+      'sid_language_has_suggestion' => array('sid', 'language', 'has_suggestion'),
+      'sid_language_has_translation' => array('sid', 'language', 'has_translation'),
+    ),
+  );
+
+  return $schema;
+}
+
+/**
+ * Implementation of hook_requirements().
+ */
+function l10n_community_requirements($phase) {
+  $requirements = array();
+  // Ensure translations don't break at install time.
+  $t = get_t();
+
+  // Look for Tar library used for compression and uncompression.
+  $tar_library = @file_get_contents('Archive/Tar.php', TRUE);
+  $tar_available = !empty($tar_library);
+  $requirements['l10n_community_tar'] = array(
+    'title' => $t('Compression functionality'),
+    'value' => $t('Archive/Tar.php available'),
+  );
+  if (!$tar_available) {
+    $requirements['l10n_community_tar']['description'] = $t('The PEAR library Archive/Tar.php is missing. Please <a href="@pear">obtain PEAR</a> or a copy of this file and put it on the include path.', array('@pear' => 'http://pear.php.net/'));
+    $requirements['l10n_community_tar']['severity'] = REQUIREMENT_ERROR;
+    $requirements['l10n_community_tar']['value'] = $t('Not available');
+  }
+
+  if (module_exists('potx')) {
+    $requirements['l10n_community_potx'] = l10n_community_require_potx_with_context();
+  }
+
+  return $requirements;
+}
+
+/**
+ * Check that potx supports context.
+ *
+ * In its own function, so potx can itself cross-check that l10n_server is
+ * up to date in its API use.
+ */
+function l10n_community_require_potx_with_context() {
+  // If potx is already installed and enabled, check its version by looking at
+  // the specific API piece which lets us fingerprint the right version.
+  // The 3.x branch introduced _potx_find_t_calls_with_context().
+
+  // Ensure translations don't break at install time.
+  $t = get_t();
+
+  include_once drupal_get_path('module', 'potx') .'/potx.inc';
+  $requirement = array(
+    'title' => $t('Translation template extractor'),
+    'value' => $t('Localization Server compatible version'),
+  );
+  if (!function_exists('_potx_find_t_calls_with_context')) {
+    $requirement['description'] = $t('The Translation template extractor should be from the 6.x-3.x branch to be compatible with this Localization Server.');
+    $requirement['severity'] = REQUIREMENT_ERROR;
+    $requirement['value'] = $t('Not compatible with Localization Server');
+  }
+
+  return $requirement;
+}
+
 // -- Drupal 5 updates ---------------------------------------------------------
 
 /**
@@ -360,7 +805,7 @@
     $enable = TRUE;
     db_query("UPDATE {l10n_server_project} SET connector_module = 'l10n_drupal_drupalorg' WHERE connector_module = 'l10n_project'");
   }
-  
+
   if ($enable) {
     module_enable('l10n_drupal');
   }
