--- /cvs/drupal/contributions/modules/l10n_client/Attic/l10n_client.module	2010/08/04 11:45:47	1.22.4.10
+++ /cvs/drupal/contributions/modules/l10n_client/Attic/l10n_client.module	2010/08/04 12:56:34	1.22.4.11
@@ -1,5 +1,5 @@
 <?php
-// $Id: l10n_client.module,v 1.22.4.9 2010/08/04 11:37:14 goba Exp $
+// $Id: l10n_client.module,v 1.22.4.10 2010/08/04 11:45:47 goba Exp $
 
 /**
  * @file
@@ -21,26 +21,26 @@
   $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,
   );
@@ -97,7 +97,7 @@
 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;
@@ -116,6 +116,17 @@
 }
 
 /**
+ * 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->data['l10n_client_disabled']);
+}
+
+/**
  * Menu callback. Translation pages.
  *
  * These pages just list strings so they can be added to the string list for
@@ -197,7 +208,7 @@
   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) {
@@ -423,7 +434,7 @@
 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('skips' => 0, 'additions' => 0, 'updates' => 0, 'deletes' => 0);
@@ -575,23 +586,37 @@
  * Set up API key for localization server.
  */
 function l10n_client_form_user_profile_form_alter(&$form, &$form_state) {
-  if ($form['#user_category'] == 'account' && variable_get('l10n_client_use_server', FALSE)) {
+  if ($form['#user_category'] == 'account') {
+    $items = array();
     $account = $form['#user'];
-    if (user_access('submit translations to localization server', $account)) {
-      $form['l10n_client'] = array(
-        '#type' => 'fieldset',
-        '#title' => t('Localization client'),
-        '#weight' => 1,
-      );
+
+    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);
-      $form['l10n_client']['l10n_client_key'] = array(
+      $items['l10n_client_key'] = array(
         '#type' => 'textfield',
         '#title' => t('Your Localization Server API key'),
         '#default_value' => !empty($account->data['l10n_client_key']) ? $account->data['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))),
       );
-      return $form;
+    }
+    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->data['l10n_client_disabled']),
+      );
+    }
+
+    if (!empty($items)) {
+      // Add items in a fieldset wrapper if any items available.
+      $form['l10n_client'] = array(
+        '#type' => 'fieldset',
+        '#title' => t('Localization client'),
+        '#weight' => 1,
+        'items' => $items,
+      );
     }
   }
 }
@@ -605,6 +630,7 @@
   if (isset($edit['l10n_client_key'])) {
     $edit['data']['l10n_client_key'] = trim($edit['l10n_client_key']);
   }
+  $edit['data']['l10n_client_disabled'] = !empty($edit['l10n_client_disabled']);
 }
 
 /**