commit 86b65fa0e4214fa9e9d71adb7dbc4281c90e5936
Author: Andreas Kohlbecker <a.kohlbecker@bgbm.org>
Date:   Fri Jun 21 21:25:42 2013 +0000

    module update and some bugfixes for #3316 (dataportal debug box as table and as block)

diff --git a/.gitattributes b/.gitattributes
index 41b4752f..458bb742 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1045,7 +1045,6 @@
 7.x/modules/cdm_dataportal/js/cluetip/jquery.dimensions.js -text
 7.x/modules/cdm_dataportal/js/cluetip/jquery.hoverIntent.js -text
 7.x/modules/cdm_dataportal/js/cluetip/wait.gif -text
-7.x/modules/cdm_dataportal/js/colorbox-master.zip -text svneol=unset#unset
 7.x/modules/cdm_dataportal/js/colorbox/README.md -text
 7.x/modules/cdm_dataportal/js/colorbox/colorbox.css -text
 7.x/modules/cdm_dataportal/js/colorbox/colorbox.jquery.json -text
diff --git a/7.x/modules/cdm_dataportal/cdm_api/cdm_api.module b/7.x/modules/cdm_dataportal/cdm_api/cdm_api.module
index 7127d529..2352127e 100644
--- a/7.x/modules/cdm_dataportal/cdm_api/cdm_api.module
+++ b/7.x/modules/cdm_dataportal/cdm_api/cdm_api.module
@@ -114,14 +114,16 @@ function cdm_api_block_view($delta) {
 
     _add_js_ws_debug();
 
-    $block['subject'] = t('CDM Debug');
-    // cannot use theme_tabel() since table footer is not jet supported in D7
+    $block['subject'] = ''; // no subject, title in content for having a defined element id
+    // otherwise it would depend on the theme
     $block['content'] =
-        '<table id="cdm-ws-debug-table">'
+        '<h4 id="cdm-ws-debug-button">' . t('CDM Debug') . '</h4>'
+          // cannot use theme_table() since table footer is not jet supported in D7
+        . '<div id="cdm-ws-debug-table-container"><table id="cdm-ws-debug-table">'
         . $header
         . '<tbody>' . join('', $rows) . '</tbody>'
         . $footer
-        . '</table>';
+        . '</table></div>';
 
     return $block;
   }
diff --git a/7.x/modules/cdm_dataportal/cdm_dataportal.css b/7.x/modules/cdm_dataportal/cdm_dataportal.css
index 2e219328..60700470 100644
--- a/7.x/modules/cdm_dataportal/cdm_dataportal.css
+++ b/7.x/modules/cdm_dataportal/cdm_dataportal.css
@@ -7,14 +7,27 @@
  * See also http://groups.drupal.org/node/6355.
  */
 
+
 #block-cdm-api-cdm-ws-debug {
-  background-color: #252525;
+  background-color: #373737;
   color: #fff;
-  border: 1px solid #b8d3e5;
+  border: 1px solid #fff;
+  -moz-box-shadow: inset 0 0 3px 2px #fff;
+  -webkit-box-shadow: inset 0 0 3px 2px #fff;
+  box-shadow: inset 0 0 3px 2px #fff;
 }
 
-#block-cdm-api-cdm-ws-debug h2 {
-  margin: 0;
+#cdm-ws-debug-table-container {
+  display: none;
+}
+
+#block-cdm-api-cdm-ws-debug h4 {
+  margin: 3px;
+  padding: 0;
+}
+
+#cdm-ws-debug-table {
+  width: 100%;
 }
 
 #cdm-ws-debug-table td.data_links a {
diff --git a/7.x/modules/cdm_dataportal/cdm_dataportal.install b/7.x/modules/cdm_dataportal/cdm_dataportal.install
index 13787034..d682bf3c 100644
--- a/7.x/modules/cdm_dataportal/cdm_dataportal.install
+++ b/7.x/modules/cdm_dataportal/cdm_dataportal.install
@@ -127,17 +127,77 @@ function cdm_dataportal_update_7303() {
  * update for RELEASE 3.2.2:
  *  - migrating variable cdm_dataportal_show_default_image to cdm_taxon_profile_image['show']
  *  - enabling required module file
+ *  - enable new debug block for all dataportals
  */
 function cdm_dataportal_update_7304() {
 
     module_enable(array('file'), TRUE);
     $tasks_performed[] = 'module file enabled';
 
-    $cdm_taxon_profile_image_settings = unserialize(CDM_TAXON_PROFILE_IMAGE_DEFAULT);
-    $cdm_taxon_profile_image_settings['show'] = variable_get('cdm_dataportal_show_default_image', 0);
-    variable_set(CDM_TAXON_PROFILE_IMAGE, $cdm_taxon_profile_image_settings);
-    variable_del('cdm_dataportal_show_default_image');
-    $tasks_performed[] = 'migrating variable cdm_dataportal_show_default_image to cdm_taxon_profile_image[\'show\']';
+    if(!variable_get(CDM_TAXON_PROFILE_IMAGE, FALSE)){
+      $cdm_taxon_profile_image_settings = unserialize(CDM_TAXON_PROFILE_IMAGE_DEFAULT);
+      $cdm_taxon_profile_image_settings['show'] = variable_get('cdm_dataportal_show_default_image', 0);
+      variable_set(CDM_TAXON_PROFILE_IMAGE, $cdm_taxon_profile_image_settings);
+      variable_del('cdm_dataportal_show_default_image');
+      $tasks_performed[] = 'migrating variable cdm_dataportal_show_default_image to cdm_taxon_profile_image[\'show\']';
+    }
+
+    $cdm_admin_role = user_role_load_by_name('CDM admin');
+    $admin_role = user_role_load_by_name("admin");
+    if(!$admin_role){
+      $admin_role = user_role_load_by_name("administrator");
+    }
+    user_multiple_role_edit(array(1), 'add_role', $admin_role->rid);
+    $tasks_performed[] = 'admin user (uid=1) added to role ' . $admin_role->name;
+
+    // CDM web service debug block
+    $cdm_ws_debug_block = array(
+        'block' => array(
+            'module' => 'cdm_api',
+            'delta' => 'cdm_ws_debug',
+            'theme' => NULL,
+            'status' => 1,
+            'weight' => -50,
+            'region' => 'sidebar_first',
+            'pages' => '',
+            'cache' => -1,
+        ),
+        'block_role' =>
+            array(
+                array(
+                  'module' => 'cdm_api',
+                  'delta' => 'cdm_ws_debug',
+                  'rid' => $cdm_admin_role->rid
+               ),
+                array(
+                  'module' => 'cdm_api',
+                  'delta' => 'cdm_ws_debug',
+                  'rid' => $admin_role->rid
+               )
+        )
+    );
+    // clean up existing block configuration which might be set by drupal automatically, we need to override this
+    db_delete('block')->condition('module', 'cdm_api')->execute();
+    db_delete('block_role')->condition('module', 'cdm_api')->execute();
+    // insert
+    $block_insert = db_insert('block')->fields(array('module', 'delta', 'theme', 'status', 'weight', 'region', 'pages', 'cache'));
+    $block_role_insert = db_insert('block_role')->fields(array('module', 'delta', 'rid'));
+
+    $themes = system_list('theme');
+    foreach ($themes as $theme) {
+      if($theme->status == "1"){ // only for enabled themes
+        $cdm_ws_debug_block['block']['theme'] = $theme->name;
+        $block_insert->values($cdm_ws_debug_block['block']);
+      }
+    }
+    foreach($cdm_ws_debug_block['block_role'] as $block_role){
+      $block_role_insert->values($block_role);
+    }
+    $block_insert->execute();
+    $block_role_insert->execute();
+    $tasks_performed[] = 'CDM web service debug block enabled for \'CDM admin\' users in all themes';
+    $tasks_performed[] = _remove_variable('cdm_webservice_debug');
+    $tasks_performed[] = _remove_variable('cdm_webservice_isStub');
 
     return  join(', ',$tasks_performed);
 }
@@ -161,7 +221,7 @@ function _rename_variable($old_name, $new_name) {
     $success = TRUE;
   }
 
-  return "Variable \'$old_name\' to \'$new_name\' renamed. ";
+  return "Variable '$old_name' to '$new_name' renamed. ";
 }
 
 /**
@@ -174,7 +234,7 @@ function _rename_variable($old_name, $new_name) {
  */
 function _remove_variable($name) {
   variable_del($name);
-  return "Variable \'$name\' removed. ";
+  return "Variable '$name' removed. ";
 }
 
 /**
@@ -187,7 +247,7 @@ function _remove_variable($name) {
  */
 function _create_variable($name, $value) {
   variable_set($name, $value);
-  return "Variable \'$name\' created with value: \'$value\'. ";
+  return "Variable '$name' created with value: '$value'. ";
 }
 
 /**
diff --git a/7.x/modules/cdm_dataportal/js/colorbox-master.zip b/7.x/modules/cdm_dataportal/js/colorbox-master.zip
deleted file mode 100644
index 6de6e11a..00000000
Binary files a/7.x/modules/cdm_dataportal/js/colorbox-master.zip and /dev/null differ
diff --git a/7.x/modules/cdm_dataportal/js/ws_debug_block.js b/7.x/modules/cdm_dataportal/js/ws_debug_block.js
index 6b3c7034..03342549 100644
--- a/7.x/modules/cdm_dataportal/js/ws_debug_block.js
+++ b/7.x/modules/cdm_dataportal/js/ws_debug_block.js
@@ -4,8 +4,6 @@
  */
 jQuery(document).ready(function($) {
 
-    $('#block-cdm-api-cdm-ws-debug .content').hide(); // hide parent element
-
     $('#cdm-ws-debug-table').dataTable({
         "bPaginate" : false,
         "bFilter" : true,
@@ -26,7 +24,7 @@ jQuery(document).ready(function($) {
                     for(var rowIndex = iStart; rowIndex < iEnd; rowIndex++){
                         sum += Number(aData[rowIndex][colIndex]);
                     }
-                    newHtml = sum;
+                    newHtml = sum.toFixed(3);
                 } else if(colums_to_sum_up[colIndex]) {
                     newHtml = colums_to_sum_up[colIndex];
                 }
@@ -38,7 +36,7 @@ jQuery(document).ready(function($) {
         }
     });
 
-    $('#block-cdm-api-cdm-ws-debug .title').css('cursor', 'pointer').colorbox({
+    $('#cdm-ws-debug-button').css('cursor', 'pointer').colorbox({
         "href" : '#cdm-ws-debug-table_wrapper', // wrapper created by dataTable()
         "inline" : true,
         "width" : '90%',
diff --git a/7.x/modules/cdm_dataportal/profile/CDM_Portal/CDM_Portal.install b/7.x/modules/cdm_dataportal/profile/CDM_Portal/CDM_Portal.install
index 51d3be2c..eda55197 100644
--- a/7.x/modules/cdm_dataportal/profile/CDM_Portal/CDM_Portal.install
+++ b/7.x/modules/cdm_dataportal/profile/CDM_Portal/CDM_Portal.install
@@ -74,59 +74,6 @@ function CDM_Portal_install() {
       'zen_rebuild_registry' => 0,
   ));
 
-
-  /****************************************
-   *  Blocks
-   ****************************************/
-
-  // >>> admin/structure/block
-  //    Disable the blocks that were enabled for the dashboard in the standard install.
-  //    In the CDM dataportals we use the admin_menu module instead of taskbar and dashboard.
-  $query = db_update('block')->fields(array('status' => '0'))
-    ->condition('region', 'dashboard_main', '=')
-    ->execute();
-  $query = db_update('block')->fields(array('status' => '0'))
-    ->condition('region', 'dashboard_sidebar', '=')
-    ->execute();
-
-  // disable "Search form"  block for all themes
-  $query = db_update('block')->fields(array('status' => '0'))
-    ->condition(
-        db_and()
-          ->condition('module', 'search', '=')
-          ->condition('delta', 'form', '=')
-        )
-    ->execute();
-
-  // disable the "Powered by Drupal" block for all themes
-  $query = db_update('block')->fields(array('status' => '0'))
-    ->condition(
-        db_and()
-          ->condition('module', 'system', '=')
-          ->condition('delta', 'powered-by', '=')
-        )
-    ->execute();
-
-  // enable "CDM Search Taxa" block for all themes
-  $new_blocks = array(
-      array(
-          'module' => 'cdm_dataportal',
-          'delta' => '2',
-          'theme' => $default_theme,
-          'status' => 1,
-          'weight' => -11,
-          'region' => 'sidebar_first',
-          'pages' => '',
-          'cache' => -1,
-      ),
-   );
-  $query = db_insert('block')->fields(array('module', 'delta', 'theme', 'status', 'weight', 'region', 'pages', 'cache'));
-  foreach ($new_blocks as $block) {
-    $query->values($block);
-  }
-  $query->execute();
-
-
  /****************************************
   *  Reconfigure Drupal core modules
   ****************************************/
@@ -282,8 +229,84 @@ function CDM_Portal_install() {
     ->execute();
 
   /****************************************
-   *  Create the front page
+   *  Blocks
    ****************************************/
+
+  // >>> admin/structure/block
+  //    Disable the blocks that were enabled for the dashboard in the standard install.
+  //    In the CDM dataportals we use the admin_menu module instead of taskbar and dashboard.
+  $query = db_update('block')->fields(array('status' => '0'))
+  ->condition('region', 'dashboard_main', '=')
+  ->execute();
+  $query = db_update('block')->fields(array('status' => '0'))
+  ->condition('region', 'dashboard_sidebar', '=')
+  ->execute();
+
+  // disable "Search form"  block for all themes
+  $query = db_update('block')->fields(array('status' => '0'))
+  ->condition(
+      db_and()
+      ->condition('module', 'search', '=')
+      ->condition('delta', 'form', '=')
+  )
+  ->execute();
+
+  // disable the "Powered by Drupal" block for all themes
+  $query = db_update('block')->fields(array('status' => '0'))
+  ->condition(
+      db_and()
+      ->condition('module', 'system', '=')
+      ->condition('delta', 'powered-by', '=')
+  )
+  ->execute();
+
+  $new_blocks = array(
+      // enable "CDM Search Taxa" block for all themes
+      array(
+          'block' => array(
+              'module' => 'cdm_dataportal',
+              'delta' => '2',
+              'theme' => $default_theme,
+              'status' => 1,
+              'weight' => -11,
+              'region' => 'sidebar_first',
+              'pages' => '',
+              'cache' => -1,
+          )
+      ),
+      // CDM web service debug block
+      array(
+          'block' => array(
+              'module' => 'cdm_api',
+              'delta' => 'cdm_ws_debug',
+              'theme' => $default_theme,
+              'status' => 1,
+              'weight' => -50,
+              'region' => 'sidebar_first',
+              'pages' => '',
+              'cache' => -1,
+          ),
+          'block_role' => array(
+              'module' => 'cdm_api',
+              'delta' => 'cdm_ws_debug',
+              'rid' => $admin_role->rid
+          )
+      )
+  );
+  $block_insert = db_insert('block')->fields(array('module', 'delta', 'theme', 'status', 'weight', 'region', 'pages', 'cache'));
+  $block_role_insert = db_insert('block_role')->fields(array('module', 'delta', 'rid'));
+  foreach ($new_blocks as $block) {
+    $block_insert->values($block['block']);
+    if(isset($block['block_role'])){
+      $block_role_insert->values($block['block_role']);
+    }
+  }
+  $block_insert->execute();
+  $block_role_insert->execute();
+
+ /****************************************
+  *  Create the front page
+  ****************************************/
   $node = new stdClass();
   $node->uid = 1;
   $node->type = 'page';
