--- translation_management/icl_content/icl_content.dashboard.inc.ORIGINAL	2011-05-19 08:06:57.000000000 +0200
+++ translation_management/icl_content/icl_content.dashboard.inc		2011-09-15 14:55:32.000000000 +0200
@@ -1,10 +1,13 @@
 <?php
+define ( 'ICL_CONTENT_PERM_TRANSLATE', 'submit content for translation');
 
 module_load_include ( 'inc', 'icl_core', 'icl_core.constants' );
 module_load_include ( 'inc', 'icl_core', 'icl_core.settings' );
 module_load_include ( 'inc', 'icl_content', 'icl_content.contact_form' );
 module_load_include ( 'inc', 'icl_content', 'icl_content.node' );
 
+drupal_load('module', 'user');
+
 // Manual verification of previously translated contents
 if (user_access(ICL_CONTENT_PERM_TRANSLATE) && isset($_GET['verify']) && isset($_GET['id']) && isset($_GET['type'])) {
--- translation_management/icl_content/icl_content.install.ORIGINAL	2011-05-19 08:06:57.000000000 +0200
+++ translation_management/icl_content/icl_content.install		2011-09-15 12:01:52.000000000 +0200
@@ -224,8 +224,7 @@ function icl_content_schema() {
           'description' => 'strings in the image/data that need translation.',
           'type' => 'text',
           'not null' => TRUE,
-          'size' => 'big',
-          'default' => ''),
+          'size' => 'big'),
         ),
 
       'primary key' => array('id'),
--- translation_management/icl_content/icl_content.module.ORIGINAL	2011-05-19 08:06:57.000000000 +0200
+++ translation_management/icl_content/icl_content.module		2011-09-15 14:15:11.000000000 +0200
@@ -6,7 +6,7 @@
  */
 
 define ( 'ICL_CONTENT_PERM_COMMENT', 'moderate comments in own language');
-define ( 'ICL_CONTENT_PERM_TRANSLATE', 'submit content for translation');
+//define ( 'ICL_CONTENT_PERM_TRANSLATE', 'submit content for translation');
 
 module_load_include('inc', 'icl_core', 'icl_core.wrapper');
 module_load_include('inc', 'icl_content', 'icl_content.wrapper');
@@ -36,7 +36,7 @@ define ( 'ICL_CONTENT_TRANSLATE_PUBLISHE
 define ( 'ICL_CONTENT_TRANSLATE_NEXT', 'next' );
 define ( 'ICL_CONTENT_TRANSLATE_NOT', 'not' );
 
-define ( 'ICL_CONTENT_UPDATE_LINKS', 'update_links' );
+//define ( 'ICL_CONTENT_UPDATE_LINKS', 'update_links' );
 define ( 'ICL_CONTENT_DONT_UPDATE_LINKS', 'dont_update_links' );
 
 
@@ -1304,35 +1304,6 @@ function _icl_content_get_link_paths($bo
   return $links;
 }
 
-function icl_content_fix_links_in_all_dirty_nodes($exclude_nid = -1) {
-  $query = _icl_wrapper_db_query("SELECT nid FROM {icl_node} WHERE links_fixed = 0 OR links_fixed is NULL");
-
-  while ( $nid = db_fetch_object ( $query ) ) {
-
-    $nid = $nid->nid;
-
-    if ($nid != $exclude_nid) {    
-      $node = node_load($nid, NULL, TRUE); // make sure it's not loaded from the cache otherwise the domain access setting can be lost.
-      if ($node == FALSE) {
-        _icl_wrapper_db_query("UPDATE {icl_node} SET links_fixed = 1 WHERE nid = %s", $nid);
-      } else {
-        if($node->nid == $node->tnid || $node->tnid == 0) {
-          // this is the original source
-          _icl_wrapper_db_query("UPDATE {icl_node} SET links_fixed = 1 WHERE nid = %s", $nid);
-        } else {
-          // A translation, fix the links and save the node
-          _icl_content_fix_links($node);
-          $node->icanlocalize_link_fix = TRUE;
-          
-          $node->pathauto_perform_alias = FALSE;
-          
-          node_save($node);
-        }      
-      }
-    }    
-  }
-}
-
 /**
  * NOTE: This is a duplicate of the function in translation module
  * NOTE: The db_rewrite_sql has been removed to stop the domain access module
@@ -1818,96 +1789,6 @@ function _icl_content_save_translation_t
   
 }
 
-function icl_content_sync_blocks() {
-  $table_name = _icl_wrapper_table_name('blocks');
-  $query = _icl_wrapper_db_query("SELECT * FROM {" . $table_name . "} WHERE module='block' and pages <> '' ");
-  while ( $block = db_fetch_array ( $query ) ) {
-    
-    $bid = $block['bid'];
-    
-    $pages = explode("\r\n", $block['pages']);
-    
-    $translated_pages = array();
-    
-    foreach($pages as $page) {
-      if (strpos($page, 'node/') === 0) {
-        $nid = substr($page, 5);
-        
-        $translations = icl_content_translation_node_get_translations($nid);
-        
-        if (is_array($translation)) {
-        
-          foreach($translations as $translation) {
-            $translation = "node/" . $translation->nid;
-            
-            if (!in_array($translation, $pages)) {
-              $translated_pages[] = $translation;
-            }
-          }
-        }
-        
-      }
-    }
-    
-    foreach ($translated_pages as $translation) {
-      if (!in_array($translation, $pages)) {
-        $pages[] = $translation;
-      }
-      
-    }
-    $new_pages = implode("\r\n", $pages);
-    
-    if ($pages != $new_pages) {
-      $table_name = _icl_wrapper_table_name('blocks');
-      _icl_wrapper_db_query("UPDATE {" . $table_name . "} SET pages = '%s' WHERE bid = %d", $new_pages, $bid);
-      
-    }
-
-  }
-  
-}
-
-function icl_content_update_links_in_blocks() {
-
-  $languages = language_list('enabled');
-  $languages = $languages[1];
-
-  $query = _icl_wrapper_db_query("SELECT bid FROM {icl_block} WHERE links_fixed <> 1");
-
-  while ( $bid = db_fetch_object ( $query ) ) {
-    $bid = $bid->bid;
-    $table_name = _icl_wrapper_table_name('blocks');
-    $block_title_original = _icl_wrapper_db_result(_icl_wrapper_db_query("SELECT title FROM {" . $table_name . "} WHERE delta = %d", $bid));
-    $block_original = _icl_wrapper_block_box_get($bid);
-
-    $all_languages_fixed = TRUE;
-    if ($block_original['body'] != "") {
-      $lid = _icl_wrapper_db_result(_icl_wrapper_db_query("SELECT lid FROM {locales_source} WHERE source = '%s' and textgroup = 'blocks'", $block_original['body']));
-
-      foreach($languages as $code => $language) {
-        $translation = _icl_wrapper_db_result(_icl_wrapper_db_query("SELECT translation FROM {locales_target} WHERE lid = %d AND language = '%s'", $lid, $code));
-        if (!empty($translation)) {
-          $all_links_fixed = FALSE;
-          $fixed_translation = _icl_content_fix_links_in_text($translation, "en", $code, $all_links_fixed);
-          if ($fixed_translation != $translation) {
-            _icl_wrapper_db_query("UPDATE {locales_target} SET translation = '%s' WHERE lid = %d AND language = '%s'", $fixed_translation, $lid, $code);
-            
-            cache_clear_all('locale:', 'cache', TRUE);
-            
-          }
-          if(!$all_links_fixed) {
-            $all_languages_fixed = FALSE;
-          }
-        }
-      }
-    }    
-    if($all_languages_fixed) {
-      _icl_wrapper_db_query("UPDATE {icl_block} SET links_fixed = 1 WHERE bid = %d", $bid);
-    }
-  }
-  
-}
-
 function icl_content_update_locale_translation($lid, $language, $value) {
   $translation = _icl_wrapper_db_result(_icl_wrapper_db_query("SELECT translation FROM {locales_target} WHERE lid = %d AND language = '%s'", $lid, $language));
   if (!empty($translation)) {
@@ -2490,51 +2371,6 @@ function icl_content_icanlocalize($op, $
   return false;
 }
 
-/**
- * update the weight of translated pages in books so they are the same as
- * the original book. This will keep the book pages in order.
- */
-  
-function icl_content_update_books() {
-  
-  $books_to_update = variable_get('icl_content_books_to_update', array());
-
-  $changed = FALSE;
-  
-  foreach ($books_to_update as $bid => $state) {
-    $book_toc = _icl_wrapper_book_toc($bid, array(), 10);
-    
-    foreach($book_toc as $mlid => $title) {
-      $menu = db_fetch_array(_icl_wrapper_db_query("SELECT * FROM {menu_links} WHERE mlid=%d", $mlid));
-      $nid = substr($menu['link_path'], 5);
-      $translations = icl_content_translation_node_get_translations($nid);
-      
-      foreach ($translations as $lang => $trans) {
-        if ($trans->nid != $nid) {
-          // get the menu for the translated page
-          $trans_menu = db_fetch_array(_icl_wrapper_db_query("SELECT * FROM {menu_links} WHERE link_path='%s'", "node/" . $trans->nid));
-          
-          // set the weight to be the same as the original
-          if ($menu['weight'] != $trans_menu['weight']) {
-            _icl_wrapper_db_query("UPDATE {menu_links} SET weight=%d WHERE mlid=%d", $menu['weight'], $trans_menu['mlid']);
-            $changed = TRUE;
-          }
-          
-        }
-        
-      }
-      
-    }
-  }
-
-  if ($changed) {
-    menu_cache_clear_all();
-  }
-  
-  // clear the books.
-  variable_set('icl_content_books_to_update', array());
-}
-
 function icl_content_get_translated_menu($mlid, $language) {
   // find the node this menu points to.
   $node = _icl_wrapper_db_result(_icl_wrapper_db_query("SELECT link_path FROM {menu_links} where mlid = %d", $mlid));
--- translation_management/icl_core/icl_core.module.ORIGINAL	2011-05-19 08:06:57.000000000 +0200
+++ translation_management/icl_core/icl_core.module		2011-09-15 14:15:10.000000000 +0200
@@ -39,6 +39,8 @@ define ( 'ICL_CORE_SELECT_TRANSLATORS_IC
 define ( 'ICL_CORE_SELECT_TRANSLATORS_CLIENT', 'client_translators');
 define ( 'ICL_CORE_SELECT_TRANSLATORS_PRIVATE', 'private_translators');
 
+define ( 'ICL_CONTENT_UPDATE_LINKS', 'update_links' );
+
 include_once dirname(__FILE__) . '/icl_core.wrapper.inc';
 include_once dirname(__FILE__) . '/../icl_content/icl_content.stats.inc';
 
@@ -1684,3 +1686,167 @@ function icl_core_ignore_url_submit($for
   variable_set('icl_current_url_ignore', $icl_url_ignore);
   _icl_wrapper_drupal_goto($_GET['q']);
 }
+
+function icl_content_fix_links_in_all_dirty_nodes($exclude_nid = -1) {
+  $query = _icl_wrapper_db_query("SELECT nid FROM {icl_node} WHERE links_fixed = 0 OR links_fixed is NULL");
+
+  while ( $nid = db_fetch_object ( $query ) ) {
+
+    $nid = $nid->nid;
+
+    if ($nid != $exclude_nid) {    
+      $node = node_load($nid, NULL, TRUE); // make sure it's not loaded from the cache otherwise the domain access setting can be lost.
+      if ($node == FALSE) {
+        _icl_wrapper_db_query("UPDATE {icl_node} SET links_fixed = 1 WHERE nid = %s", $nid);
+      } else {
+        if($node->nid == $node->tnid || $node->tnid == 0) {
+          // this is the original source
+          _icl_wrapper_db_query("UPDATE {icl_node} SET links_fixed = 1 WHERE nid = %s", $nid);
+        } else {
+          // A translation, fix the links and save the node
+          _icl_content_fix_links($node);
+          $node->icanlocalize_link_fix = TRUE;
+          
+          $node->pathauto_perform_alias = FALSE;
+          
+          node_save($node);
+        }      
+      }
+    }    
+  }
+}
+
+/**
+ * update the weight of translated pages in books so they are the same as
+ * the original book. This will keep the book pages in order.
+ */
+  
+function icl_content_update_books() {
+  
+  $books_to_update = variable_get('icl_content_books_to_update', array());
+
+  $changed = FALSE;
+  
+  foreach ($books_to_update as $bid => $state) {
+    $book_toc = _icl_wrapper_book_toc($bid, array(), 10);
+    
+    foreach($book_toc as $mlid => $title) {
+      $menu = db_fetch_array(_icl_wrapper_db_query("SELECT * FROM {menu_links} WHERE mlid=%d", $mlid));
+      $nid = substr($menu['link_path'], 5);
+      $translations = icl_content_translation_node_get_translations($nid);
+      
+      foreach ($translations as $lang => $trans) {
+        if ($trans->nid != $nid) {
+          // get the menu for the translated page
+          $trans_menu = db_fetch_array(_icl_wrapper_db_query("SELECT * FROM {menu_links} WHERE link_path='%s'", "node/" . $trans->nid));
+          
+          // set the weight to be the same as the original
+          if ($menu['weight'] != $trans_menu['weight']) {
+            _icl_wrapper_db_query("UPDATE {menu_links} SET weight=%d WHERE mlid=%d", $menu['weight'], $trans_menu['mlid']);
+            $changed = TRUE;
+          }
+          
+        }
+        
+      }
+      
+    }
+  }
+
+  if ($changed) {
+    menu_cache_clear_all();
+  }
+  
+  // clear the books.
+  variable_set('icl_content_books_to_update', array());
+}
+
+function icl_content_sync_blocks() {
+  $table_name = _icl_wrapper_table_name('blocks');
+  $query = _icl_wrapper_db_query("SELECT * FROM {" . $table_name . "} WHERE module='block' and pages <> '' ");
+  while ( $block = db_fetch_array ( $query ) ) {
+    
+    $bid = $block['bid'];
+    
+    $pages = explode("\r\n", $block['pages']);
+    
+    $translated_pages = array();
+    
+    foreach($pages as $page) {
+      if (strpos($page, 'node/') === 0) {
+        $nid = substr($page, 5);
+        
+        $translations = icl_content_translation_node_get_translations($nid);
+        
+        if (is_array($translation)) {
+        
+          foreach($translations as $translation) {
+            $translation = "node/" . $translation->nid;
+            
+            if (!in_array($translation, $pages)) {
+              $translated_pages[] = $translation;
+            }
+          }
+        }
+        
+      }
+    }
+    
+    foreach ($translated_pages as $translation) {
+      if (!in_array($translation, $pages)) {
+        $pages[] = $translation;
+      }
+      
+    }
+    $new_pages = implode("\r\n", $pages);
+    
+    if ($pages != $new_pages) {
+      $table_name = _icl_wrapper_table_name('blocks');
+      _icl_wrapper_db_query("UPDATE {" . $table_name . "} SET pages = '%s' WHERE bid = %d", $new_pages, $bid);
+      
+    }
+
+  }
+  
+}
+
+function icl_content_update_links_in_blocks() {
+
+  $languages = language_list('enabled');
+  $languages = $languages[1];
+
+  $query = _icl_wrapper_db_query("SELECT bid FROM {icl_block} WHERE links_fixed <> 1");
+
+  while ( $bid = db_fetch_object ( $query ) ) {
+    $bid = $bid->bid;
+    $table_name = _icl_wrapper_table_name('blocks');
+    $block_title_original = _icl_wrapper_db_result(_icl_wrapper_db_query("SELECT title FROM {" . $table_name . "} WHERE delta = %d", $bid));
+    $block_original = _icl_wrapper_block_box_get($bid);
+
+    $all_languages_fixed = TRUE;
+    if ($block_original['body'] != "") {
+      $lid = _icl_wrapper_db_result(_icl_wrapper_db_query("SELECT lid FROM {locales_source} WHERE source = '%s' and textgroup = 'blocks'", $block_original['body']));
+
+      foreach($languages as $code => $language) {
+        $translation = _icl_wrapper_db_result(_icl_wrapper_db_query("SELECT translation FROM {locales_target} WHERE lid = %d AND language = '%s'", $lid, $code));
+        if (!empty($translation)) {
+          $all_links_fixed = FALSE;
+          $fixed_translation = _icl_content_fix_links_in_text($translation, "en", $code, $all_links_fixed);
+          if ($fixed_translation != $translation) {
+            _icl_wrapper_db_query("UPDATE {locales_target} SET translation = '%s' WHERE lid = %d AND language = '%s'", $fixed_translation, $lid, $code);
+            
+            cache_clear_all('locale:', 'cache', TRUE);
+            
+          }
+          if(!$all_links_fixed) {
+            $all_languages_fixed = FALSE;
+          }
+        }
+      }
+    }    
+    if($all_languages_fixed) {
+      _icl_wrapper_db_query("UPDATE {icl_block} SET links_fixed = 1 WHERE bid = %d", $bid);
+    }
+  }
+  
+}
