Index: connectors/l10n_localpacks/l10n_localpacks.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/l10n_server/connectors/l10n_localpacks/Attic/l10n_localpacks.module,v retrieving revision 1.1.2.9.2.7 diff -u -p -r1.1.2.9.2.7 l10n_localpacks.module --- connectors/l10n_localpacks/l10n_localpacks.module 12 Jan 2010 08:43:25 -0000 1.1.2.9.2.7 +++ connectors/l10n_localpacks/l10n_localpacks.module 3 Feb 2010 11:57:34 -0000 @@ -179,6 +179,11 @@ function l10n_localpacks_scan($automated include_once drupal_get_path('module', 'l10n_community') .'/extractor.inc'; $result = l10n_community_parse_package($file_name, $release); + if (!isset($result['error'])) { + // Let others know that this release was made available. + module_invoke_all('l10n_community', 'release parsed', $release); + } + // User feedback, if not automated. Log messages are already done. if (isset($result['error']) && !$automated) { $user_feedback = TRUE; Index: connectors/l10n_project/l10n_project.sync.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/l10n_server/connectors/l10n_project/Attic/l10n_project.sync.inc,v retrieving revision 1.1.2.17 diff -u -p -r1.1.2.17 l10n_project.sync.inc --- connectors/l10n_project/l10n_project.sync.inc 11 Jan 2010 12:37:03 -0000 1.1.2.17 +++ connectors/l10n_project/l10n_project.sync.inc 3 Feb 2010 11:57:34 -0000 @@ -258,6 +258,10 @@ function l10n_project_pick_and_parse($re $return = l10n_project_parse_package($file, $release); // Clear stats cache, so new data shows up. cache_clear_all('l10n:stats', 'cache'); + if (!isset($result['error'])) { + // Let others know that this release was made available. + module_invoke_all('l10n_community', 'release parsed', $release); + } } if ($error) { Index: l10n_community/l10n_community.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/l10n_server/l10n_community/Attic/l10n_community.module,v retrieving revision 1.1.2.23.2.66.2.2 diff -u -p -r1.1.2.23.2.66.2.2 l10n_community.module --- l10n_community/l10n_community.module 26 Jan 2010 15:33:44 -0000 1.1.2.23.2.66.2.2 +++ l10n_community/l10n_community.module 3 Feb 2010 11:57:34 -0000 @@ -1577,3 +1577,107 @@ function l10n_community_add_url_modifier } drupal_add_js(array('l10nServerURLs' => $replacements), 'setting'); } + +// == Trigger and activity integration ========================================= + +/** + * Implementation of hook_l10n_community(). + */ +function l10n_community_l10n_community($op, $object) { + if (module_exists('trigger') && ($op == 'release parsed')) { + $aids = _trigger_get_hook_aids('l10n_community', $op); + if (!empty($aids)) { + // Prepare data for triggers, encapsulate project in release object, + // so we can pass on one self-contained object. + $release = $object; + $release->project = db_fetch_object(db_query("SELECT * FROM {l10n_community_project} WHERE pid = %d", $release->pid)); + + $context = array( + 'hook' => 'l10n_community', + 'op' => $op, + // This object type key is used in token and activity + // integration, so we made it unique enough. + 'l10n_community release' => $release, + ); + + foreach ($aids as $aid => $action_type) { + actions_do($aid, $release, $context); + } + } + } +} + +/** + * Implementation of hook_hook_info(). + */ +function l10n_community_hook_info() { + return array( + 'l10n_community' => array( + 'l10n_community' => array( + // Let people run an action when a release is parsed. + 'release parsed' => array( + 'runs when' => t('A project release was parsed'), + ), + ), + ), + ); +} + +/** + * Implementation of hook_activity_info(). + */ +function l10n_community_activity_info() { + $info = new stdClass; + $info->api = 2; + $info->name = 'Localization community'; + // This is the same object type used in action invocation and token integration. + $info->object_type = 'l10n_community release'; + // @todo: this is required to make the release object tokens available but makes us be + // able to record activity messages specific to "The release", which is rather odd. + $info->objects = array('The release' => 'l10n_community release'); + $info->hooks = array( + 'l10n_community' => array( + 'release parsed', + ), + ); + // Lets people delete activity related to this l10n_community release at once. + $info->eid_field = 'rid'; + return $info; +} + +/** + * Implementation of hook_token_list(). + */ +function l10n_community_token_list($type = 'all') { + if ($type == 'l10n_community release') { + // Provide basic tokens for this release object. + $tokens['l10n_community release']['full-release-title'] = t('Name of the release with project name (HTML linked)'); + $tokens['l10n_community release']['full-release-title-raw'] = t('Name of the release with project name (raw)'); + return $tokens; + } +} + +/** + * Implementation of hook_token_values(). + */ +function l10n_community_token_values($type, $object = NULL) { + $values = array(); + switch ($type) { + case 'l10n_community release': + + $values['full-release-title'] = ''; + if (!empty($object->title) && !empty($object->project->title)) { + $values['full-release-title-raw'] = check_plain($object->project->title .' '. $object->title); + if (isset($object->project->home_link)) { + // Link in the project name with the home link if possible. + $values['full-release-title'] = l($object->project->title, $object->project->home_link) .' '. check_plain($object->title); + } + else { + $values['full-release-title'] = $values['full-release-title-raw']; + } + return $values; + } + break; + } + return $values; +}