? l10n_client-774794.patch
? l10n_client_i18n_textgroup_2.patch
Index: l10n_client.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/l10n_client/Attic/l10n_client.module,v
retrieving revision 1.22.2.1
diff -u -p -r1.22.2.1 l10n_client.module
--- l10n_client.module	14 Jul 2009 18:02:54 -0000	1.22.2.1
+++ l10n_client.module	18 Apr 2010 21:48:19 -0000
@@ -20,26 +20,26 @@ function l10n_client_menu() {
   $items['l10n_client/save'] = array(
     'title' => 'Save string',
     'page callback' => 'l10n_client_save_string',
-    'access arguments' => array('use on-page translation'),
+    'access callback' => 'l10n_client_access',
     'type' => MENU_CALLBACK,
   );
   // Helper pages to group all translated/untranslated strings.  
   $items['locale'] = array(
     'title' => 'Translate strings',
     'page callback' => 'l10n_client_translate_page',
-    'access arguments' => array('use on-page translation'),
+    'access callback' => 'l10n_client_access',
   );
   $items['locale/untranslated'] = array(
     'title' => 'Untranslated',
     'page arguments' => array('untranslated'),
-    'access arguments' => array('use on-page translation'),
+    'access callback' => 'l10n_client_access',
     'type' => MENU_DEFAULT_LOCAL_TASK,
     'weight' => -10,
   );
   $items['locale/translated'] = array(
     'title' => 'Translated',
     'page arguments' => array('translated'),
-    'access arguments' => array('use on-page translation'),
+    'access callback' => 'l10n_client_access',
     'type' => MENU_LOCAL_TASK,
     'weight' => 10,
   );
@@ -96,7 +96,7 @@ function l10n_client_perm() {
 function l10n_client_init() {
   global $conf, $language;
   
-  if (user_access('use on-page translation')) {
+  if (l10n_client_access()) {
     // Turn off the short string cache *in this request*, so we will
     // have an accurate picture of strings used to assemble the page.
     $conf['locale_cache_strings'] = 0;
@@ -117,6 +117,18 @@ function l10n_client_init() {
 }
 
 /**
+ * Detects whether a user can access l10n_client.
+ */
+function l10n_client_access($account = NULL) {
+  if (!isset($account)) {
+    global $user;
+    $account = $user;
+  }
+  return user_access('use on-page translation', $account) && 
+    (isset($account->l10n_client_enable) ? $account->l10n_client_enable : TRUE);
+}
+
+/**
  * Menu callback. Translation pages.
  * 
  * These pages just list strings so they can be added to the string list for
@@ -193,7 +205,7 @@ function l10n_client_footer() {
   global $conf, $language;
   
   // Check permission and get all strings used on the page.
-  if (user_access('use on-page translation') && ($page_strings = _l10n_client_page_strings())) {
+  if (l10n_client_access() && ($page_strings = _l10n_client_page_strings())) {
     // If we have strings for the page language, restructure the data.
     $l10n_strings = array();
     foreach ($page_strings as $string => $translation) {
@@ -405,7 +417,7 @@ function l10n_client_search_form() {
 function l10n_client_save_string() {
   global $user, $language;
   
-  if (user_access('use on-page translation')) {
+  if (l10n_client_access()) {
     if (isset($_POST['source']) && isset($_POST['target']) && !empty($_POST['form_token']) && drupal_valid_token($_POST['form_token'], 'l10n_client_form')) {
       include_once 'includes/locale.inc';
       $report = array(0, 0, 0);
@@ -545,7 +557,9 @@ function l10n_client_settings_form_valid
  * Set up API key for localization server.
  */
 function l10n_client_user($type, $edit, &$account, $category = NULL) { 
-  if ($type == 'form' && $category == 'account' && variable_get('l10n_client_use_server', FALSE) && user_access('submit translations to localization server', $account)) {
+  if ($type == 'form' && $category == 'account') {
+    if ((variable_get('l10n_client_use_server', FALSE) && user_access('submit translations to localization server', $account))
+     || user_access('use on-page translation')) {
     $form['l10n_client'] = array(
       '#type' => 'fieldset',
       '#title' => t('Localization client'),
@@ -559,6 +573,15 @@ function l10n_client_user($type, $edit, 
       '#default_value' => !empty($account->l10n_client_key) ? $account->l10n_client_key : '',
       '#description' => t('This is a unique key that will allow you to send translations to the remote server. To get your API key go to !server-link.', array('!server-link' => l($server_link, $server_link))),
     );
+    // Add a setting ot make the translation disable.
+    if (user_access('use on-page translation')) {
+      $form['l10n_client']['l10n_client_enable'] = array(
+        '#type' => 'checkbox',
+        '#title' => t('Enable on-page translation'),
+        '#default_value' => !empty($edit['l10n_client_enable']) ? $edit['l10n_client_enable'] : TRUE,
+        '#description' => t('Use the localization client on the bottom of each page to edit localization data.'),
+      );
+    }
     return $form;
   }
 }
