Index: l10n_client.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/l10n_client/Attic/l10n_client.module,v
retrieving revision 1.22.2.4
diff -u -p -r1.22.2.4 l10n_client.module
--- l10n_client.module	20 Apr 2010 14:11:01 -0000	1.22.2.4
+++ l10n_client.module	20 Apr 2010 18:03:55 -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,17 @@ 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) && empty($account->l10n_client_disabled);
+}
+
+/**
  * Menu callback. Translation pages.
  *
  * These pages just list strings so they can be added to the string list for
@@ -193,7 +204,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 $textgroup => $group_strings) {
@@ -412,7 +423,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']) && isset($_POST['textgroup']) && !empty($_POST['form_token']) && drupal_valid_token($_POST['form_token'], 'l10n_client_form')) {
       include_once 'includes/locale.inc';
       $report = array(0, 0, 0);
@@ -554,20 +565,41 @@ 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)) {
-    $form['l10n_client'] = array(
-      '#type' => 'fieldset',
-      '#title' => t('Localization client'),
-      '#weight' => 1,
-    );
-    // Build link to retrieve user key.
-    $server_link = variable_get('l10n_client_server', '') .'?q=translate/remote/userkey/'. l10n_client_user_token($account);
-    $form['l10n_client']['l10n_client_key'] = array(
-      '#type' => 'textfield',
-      '#title' => t('Your Localization Server API key'),
-      '#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))),
-    );
+  if ($type == 'form' && $category == 'account') {
+    $items = $form = array();
+
+    if (variable_get('l10n_client_use_server', FALSE) && user_access('submit translations to localization server', $account)) {
+      // Build link to retrieve user key.
+      $server_link = variable_get('l10n_client_server', '') .'?q=translate/remote/userkey/'. l10n_client_user_token($account);
+      $items['l10n_client_key'] = array(
+        '#type' => 'textfield',
+        '#title' => t('Your Localization Server API key'),
+        '#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))),
+      );
+    }
+
+    if (user_access('use on-page translation', $account)) {
+      // Add an item to let the user disable the on-page tool.
+      $items['l10n_client_disabled'] = array(
+        '#type' => 'checkbox',
+        '#title' => t('Hide on-page translation from you'),
+        '#default_value' => !empty($account->l10n_client_disabled),
+      );
+    }
+    
+    if (!empty($items)) {
+      // Add items in a fieldset wrapper if any items available.
+      $form = array('l10n_client' =>
+        array(
+          '#type' => 'fieldset',
+          '#title' => t('Localization client'),
+          '#weight' => 1,
+          'items' => $items,
+        ),
+      );
+    }
+    
     return $form;
   }
   elseif ($type == 'submit' && $category == 'account' && isset($edit['l10n_client_key'])) {
