Index: views_service.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/services/services/views_service/Attic/views_service.module,v
retrieving revision 1.2.2.1
diff -u -p -r1.2.2.1 views_service.module
--- views_service.module	8 Feb 2007 02:11:44 -0000	1.2.2.1
+++ views_service.module	7 Mar 2008 16:08:54 -0000
@@ -20,6 +20,8 @@ function views_service_help($section) {
 
 function views_service_service() {
   return array(
+
+    // views.getView
     array(
       '#method'   => 'views.getView',
       '#callback' => 'views_service_get_view',
@@ -41,6 +43,39 @@ function views_service_service() {
           '#description'  => t('An array of arguments to pass to the view.'))),
       '#return'   => 'array',
       '#help'     => t('Retrieves a view defined in views.module.')),
+
+    // views.exportView
+    array(
+      '#method'   => 'views.exportView',
+      '#callback' => 'views_service_export_view',
+      '#args'     => array('string'),
+      '#args'     => array(
+        array(
+          '#name'         => 'view_name',
+          '#type'         => 'string',
+          '#description'  => t('View name.'),
+        ),
+      ),
+          
+      '#return'   => 'string',
+      '#help'     => t('Exports the code of a view, same as the output you would get from the Export tab.'),
+    ),
+
+    // views.importView
+    array(
+      '#method'   => 'views.importView',
+      '#callback' => 'views_service_import_view',
+      '#args'     => array('string'),
+      '#args'     => array(
+        array(
+          '#name'         => 'view_export',
+          '#type'         => 'string',
+          '#description'  => t('Code from a Views->Export.'),
+        ),
+      ),
+      '#return'   => 'int',
+      '#help'     => t('Imports a view through code, equivalent to using the Import tab in the views admin.'),
+    ),
   );
 }
 
@@ -49,8 +84,7 @@ function views_service_service() {
  */
 function views_service_get_view($view_name, $fields = array(), $args = array()) { 
   $view = views_get_view($view_name);
-  if ($view == null)
-  {
+  if ($view == null) {
     return services_error('View does not exist.');
   }
   
@@ -60,4 +94,41 @@ function views_service_get_view($view_na
   }
   
   return $nodes;
-}
\ No newline at end of file
+}
+
+/**
+ * export a view
+ */
+function views_service_export_view($view_name) { 
+  $view = views_get_view($view_name);
+  if ($view == null) {
+    return services_error('View does not exist.');
+  }
+  
+  return views_create_view_code($view_name);
+}
+
+/**
+ * import a view
+ */
+function views_service_import_view($view_export) { 
+  views_load_cache();
+  ob_start();
+  eval($view_export);
+  ob_end_clean();
+
+  // views exports don't contain vids, there we have to
+  // check and see if the view already exists. If so, save
+  // the existing vid into our imported view object. Otherwise
+  // _views_save_view will treat this as an insert rather than
+  // as an update
+  $existing_view = views_get_view($view->name);
+  if ($existing_view) {
+    $view->vid = $existing_view->vid;
+  }
+
+  views_sanitize_view($view);
+  $vid = _views_save_view($view);
+
+  return $vid;
+}
