### Eclipse Workspace Patch 1.0
#P extranet-client
Index: src/drupal/sites/all/modules/contrib/update_api/contrib/shib_auth.inc
===================================================================
--- src/drupal/sites/all/modules/contrib/update_api/contrib/shib_auth.inc	(revision 0)
+++ src/drupal/sites/all/modules/contrib/update_api/contrib/shib_auth.inc	(revision 0)
@@ -0,0 +1,10 @@
+<?php
+
+/**
+ * Set Shib auth vars
+ * @roles array with roles array('rid' => 'name')
+ */
+function update_api_set_shib_auth_vars(&$ret, $field, $regex, $roles) {  
+  db_query("DELETE FROM {shib_auth} WHERE regexpression = $regex");
+  $ret[] = update_sql("INSERT INTO {shib_auth} (field, regexpression, role) VALUES ('".urlencode($field)."', '".urlencode($regex)."', '".urlencode(serialize($roles)).")");
+}
\ No newline at end of file
Index: src/drupal/sites/all/modules/contrib/update_api/contrib/i18n.inc
===================================================================
--- src/drupal/sites/all/modules/contrib/update_api/contrib/i18n.inc	(revision 0)
+++ src/drupal/sites/all/modules/contrib/update_api/contrib/i18n.inc	(revision 0)
@@ -0,0 +1,57 @@
+<?php
+
+/**
+ * Sets a variable for all languages
+ * 
+ * @param $ret
+ * @param $name
+ * @param $value
+ */
+function update_api_i18n_variable_set(&$ret, $name, $values, $langcode = NULL) {
+  if (!$langcode) {
+    foreach (language_list() as $lang) {
+      i18n_variable_set($name, $values[$lang->language], $lang->language);
+    }
+  }
+  else {
+    i18n_variable_set($name, $values, $langcode);
+  }
+  
+  $message = t('i18n variable @var set', array('@var' => $name));
+  $ret[] = array('success' => true, 'query' => $message); 
+}
+
+/**
+ * Resaves primary menu links and generates translation
+ * @return unknown_type
+ */
+function _update_api_regenerate_primary_menulinks_translations(){
+  $result = db_query("SELECT mlid FROM {menu_links} WHERE menu_name = '%s'", 'primary-links');
+  $item_tmp = array();
+  $form_state = array();
+  
+  while ($row = db_fetch_object($result)) {
+    unset($item);
+   
+    $item = menu_link_load($row->mlid);
+    
+    $item_tmp['link_path'] = $item["link_path"];
+    $item_tmp['mlid'] = $item["mlid"];
+    $item_tmp['module'] = $item["module"];
+    $item_tmp['has_children'] = $item["has_children"];
+    $item_tmp['customized'] = $item["customized"];
+    $item_tmp['link_title'] = $item["title"];
+    $item_tmp['original_item'] = $item;
+    $item_tmp['description'] = $item["description"];
+    $item_tmp['expanded'] = $item["expanded"];
+    $item_tmp['parent'] = 0;
+    $item_tmp['weight'] = $item["weight"];
+    $item_tmp['language'] = '';
+    $item_tmp['hidden'] = $item["hidden"];
+    $item_tmp['plid'] = $item["plid"];
+    $item_tmp['menu_name'] = $item["menu_name"];
+    
+    menu_link_save($item_tmp);
+    _i18nmenu_update_item($item_tmp);
+  }  
+}
\ No newline at end of file
Index: src/drupal/sites/all/modules/contrib/update_api/core/system.inc
===================================================================
--- src/drupal/sites/all/modules/contrib/update_api/core/system.inc	(revision 632)
+++ src/drupal/sites/all/modules/contrib/update_api/core/system.inc	(working copy)
@@ -102,14 +102,14 @@
  * @param $modules
  *   An array of modules to disable and uninstall.
  */
-function update_api_modules_uninstall(&$ret, $modules = array()) {
+function update_api_modules_uninstall(&$ret, $modules = array(), $error = TRUE) {
   // Make sure the install API is available.
   include_once './includes/install.inc';
 
   $uninstalled = $failed = array();
 
   // Disable the modules, just to be safe.
-  update_api_modules_disable($ret, $modules, FALSE);
+  update_api_modules_disable($ret, $modules, $error);
 
   foreach($modules as $name) {
     if ($module = _update_api_module_uninstallable($name)) {
@@ -164,4 +164,11 @@
   }
 
   return isset($uninstallables[$name]) ? $uninstallables[$name] : FALSE;
+}
+
+/**
+ * Set a module weight 
+ */
+function update_api_set_module_weight(&$ret, $weight, $module) {  
+  $ret[] = update_sql("UPDATE {system} SET weight = " . $weight . " WHERE name  = '" . $module . "'");
 }
\ No newline at end of file
Index: src/drupal/sites/all/modules/contrib/update_api/core/locale.inc
===================================================================
--- src/drupal/sites/all/modules/contrib/update_api/core/locale.inc	(revision 0)
+++ src/drupal/sites/all/modules/contrib/update_api/core/locale.inc	(revision 0)
@@ -0,0 +1,27 @@
+<?php
+
+/**
+ * Import locale file
+ */
+function update_api_import_locale(&$ret, $path, $name) {
+  include_once update_api_get_basepath() . '/includes/locale.inc';
+
+  //Build in interface
+  $ob = _update_api_create_file_object($path, $name);
+  _locale_import_po($ob, 'fr', LOCALE_IMPORT_OVERWRITE, 'default');
+  $ret[] = array('success' => true, 'query' => t('Locale file @path installed', array('@path' => $path)));
+}
+
+function update_api_import_locale_primary_links_menu(&$ret, $path, $name) {    
+  i18nstrings_refresh_group('menu', TRUE);
+  update_api_import_locale($ret, $path, $name);  
+  _update_api_regenerate_primary_menulinks_translations();
+}
+
+function _update_api_create_file_object($path, $name) {  
+  $file = new stdClass();
+  $file->filepath = $path;
+  $file->filename = $name;
+  
+  return $file;
+}
Index: src/drupal/sites/all/modules/contrib/update_api/update_api.module
===================================================================
--- src/drupal/sites/all/modules/contrib/update_api/update_api.module	(revision 632)
+++ src/drupal/sites/all/modules/contrib/update_api/update_api.module	(working copy)
@@ -35,7 +35,7 @@
     // database table. Avoiding drupal_get_path() allows this function to be
     // called even when the database has not been initialized.
     $path = dirname(__FILE__);
-
+    
     if (file_exists("$path/contrib/$package.inc")) {
       include_once "$path/contrib/$package.inc";
     }
@@ -45,4 +45,52 @@
   }
 
   $included[$package] = TRUE;
+}
+
+/**
+ * Returns list of support modules
+ */
+function update_api_info() {
+  $packages = array(
+    'block', 
+    'locale', 
+    'node', 
+    'system', 
+    'user', 
+    'content', 
+    'features', 
+    'i18n', 
+    'imagecache', 
+    'shib_auth'
+  );  
+  
+  return $packages;
+}
+
+/**
+ * Loads the entire api
+ */
+function update_api_load_api() {
+  $packages = update_api_info();
+  foreach ($packages as $package) {
+    update_api_include($package);
+  }
+}
+
+/**
+ * Constructs base path
+ */
+function update_api_get_basepath() {
+  $dir = dirname(__FILE__);
+  $bdir = explode('/', $dir);
+  foreach ($bdir as $piece) {    
+    if ($piece == 'sites') {
+      break;
+    }
+    $path_out[] = $piece;
+  }  
+
+  $path = implode('/', $path_out);
+  
+  return $path;
 }
\ No newline at end of file
Index: src/drupal/sites/all/modules/contrib/update_api/core/block.inc
===================================================================
--- src/drupal/sites/all/modules/contrib/update_api/core/block.inc	(revision 0)
+++ src/drupal/sites/all/modules/contrib/update_api/core/block.inc	(revision 0)
@@ -0,0 +1,21 @@
+<?php
+
+/**
+ * Update a block
+ * 
+ * @param $ret
+ * @param $t_key theme key ofr which theme you want to set the blocks
+ * @param $title
+ * @param $region
+ * @param $status
+ * @param $module
+ * @param $delta
+ * @return unknown_type
+ */
+function update_api_set_block(&$ret, $t_key, $title, $region, $status, $module, $delta) {
+  global $theme_key;
+  $theme_key = $t_key;
+  _block_rehash();
+  
+  $ret[] = update_sql("UPDATE {blocks} SET title = '$title', region = '$region', status = $status WHERE module = '$module' AND delta = '$delta'");
+}
Index: src/drupal/sites/all/modules/contrib/update_api/core/node.inc
===================================================================
--- src/drupal/sites/all/modules/contrib/update_api/core/node.inc	(revision 632)
+++ src/drupal/sites/all/modules/contrib/update_api/core/node.inc	(working copy)
@@ -15,7 +15,7 @@
  *   An array of node types to be updated, keyed by the type name.  The value 
  *   should be an array of fields to be updated for this node type.
  */
-function update_api_node_type(&$ret, $types) {
+function update_api_nodetype(&$ret, $types) {
   foreach($types as $name => $fields) {
     foreach($fields as $field_name => $value) {
       if (is_string($value)) {
@@ -26,4 +26,38 @@
       }
     }
   }
-}
\ No newline at end of file
+}
+
+/**
+ * Delete nodes by type
+ * @param $ret
+ * @param $type
+ * @return unknown_type
+ */
+function update_api_delete_nodes_by_type($ret, $type) {
+  $result = db_query("SELECT nid FROM {node} WHERE type = '$type'");
+  while ($row = db_fetch_object($result)) {
+    node_delete($row->nid);
+    $message = t('Node @nid of @type was deleted', array('@nid' => $row->nid, '@type' => $type));
+    $ret[] = array('success' => TRUE, 'query' => $message);
+  }
+}
+
+/**
+ * Create multilingual node
+ * @langs all languages set default lang first
+ */
+function update_api_multiling_node(&$ret, $nodes) {
+  foreach ($nodes as $lang => $node) {
+    if (!$first) {
+      //set tnid
+      $status = db_fetch_object(db_query("SHOW TABLE STATUS WHERE Name='node'"));
+      $tnid = $status->Auto_increment;
+      $first = true;   
+    }
+    
+    $node->tnid = $tnid;
+    $node->language = $lang;
+    node_save($node);
+  }
+}  
\ No newline at end of file
Index: src/drupal/sites/all/modules/contrib/update_api/core/theme.inc
===================================================================
--- src/drupal/sites/all/modules/contrib/update_api/core/theme.inc	(revision 0)
+++ src/drupal/sites/all/modules/contrib/update_api/core/theme.inc	(revision 0)
@@ -0,0 +1,22 @@
+<?php
+
+/**
+ * Set the new theme
+ * @param $theme
+ * @param $settings
+ */
+function update_api_set_theme($theme, $settings) {
+  cache_clear_all();
+  $ret[] = update_sql("UPDATE {system} SET status = 0 WHERE type = 'theme'");
+  system_initialize_theme_blocks($theme);
+  drupal_rebuild_theme_registry();  
+  $ret[] = update_sql("UPDATE {system} SET status = 1 WHERE type = 'theme' and name = '$theme'");
+  variable_set('theme_default', $theme);
+  $ret[] = update_sql("DELETE FROM {variable} WHERE name = 'theme_".$theme."_settings'");
+  $ret[] = update_sql("INSERT INTO variable (name, value) VALUES ('theme_".$theme."_settings', '$settings')");
+  list_themes(TRUE);
+  menu_rebuild();
+  drupal_rebuild_theme_registry();
+  $message = t('@theme installed', array('@theme' => $message));
+  $ret[] = array('success' => true, 'query' => $message); 
+}
\ No newline at end of file
Index: src/drupal/sites/all/modules/contrib/update_api/core/user.inc
===================================================================
--- src/drupal/sites/all/modules/contrib/update_api/core/user.inc	(revision 632)
+++ src/drupal/sites/all/modules/contrib/update_api/core/user.inc	(working copy)
@@ -111,3 +111,16 @@
   }
   return $permissions;
 }
+
+/**
+ * Delete role
+ */
+function update_api_delete_role(&$ret, $rid) {
+  if ($rid > 0) {
+    $ret[] = update_sql("DELETE FROM {role} WHERE rid = $rid");
+    $ret[] = update_sql("DELETE FROM {permission} WHERE rid = $rid");
+    // Update the users who have this role set:
+    $ret[] = update_sql("DELETE FROM {users_roles} WHERE rid = $rid");  
+    $ret[] = update_sql('DELETE FROM {blocks_roles} WHERE rid = %d', $rid);
+  }
+}  
\ No newline at end of file
