]> source.dussan.org Git - nextcloud-server.git/commitdiff
look for migrate.php in appinfo folder
authorTom Needham <needham.thomas@gmail.com>
Tue, 27 Mar 2012 20:45:37 +0000 (20:45 +0000)
committerTom Needham <needham.thomas@gmail.com>
Tue, 27 Mar 2012 20:45:37 +0000 (20:45 +0000)
apps/bookmarks/appinfo/migrate.php [new file with mode: 0644]
apps/bookmarks/lib/migrate.php [deleted file]
lib/migrate.php

diff --git a/apps/bookmarks/appinfo/migrate.php b/apps/bookmarks/appinfo/migrate.php
new file mode 100644 (file)
index 0000000..02c96e5
--- /dev/null
@@ -0,0 +1,69 @@
+<?php
+class OC_Migration_Provider_Bookmarks extends OC_Migration_Provider{
+       
+       // Create the xml for the user supplied
+       function export( ){
+               OC_Log::write('migration','starting export for bookmarks',OC_Log::INFO);
+               $options = array(
+                       'table'=>'bookmarks',
+                       'matchcol'=>'user_id',
+                       'matchval'=>$this->uid,
+                       'idcol'=>'id'
+               );
+               $ids = $this->content->copyRows( $options );
+
+               $options = array(
+                       'table'=>'bookmarks_tags',
+                       'matchcol'=>'bookmark_id',
+                       'matchval'=>$ids
+               );
+               
+               // Export tags
+               $ids2 = $this->content->copyRows( $options );
+               
+               // If both returned some ids then they worked
+               if( is_array( $ids ) && is_array( $ids2 ) )
+               {
+                       return true;    
+               } else {
+                       return false;
+               }
+               
+       }
+       
+       // Import function for bookmarks
+       function import( ){
+               switch( $this->appinfo->version ){
+                       default:
+                               // All versions of the app have had the same db structure, so all can use the same import function
+                               $query = $this->content->prepare( "SELECT * FROM bookmarks WHERE user_id LIKE ?" );
+                               $results = $query->execute( array( $this->olduid ) );
+                               $idmap = array();
+                               while( $row = $results->fetchRow() ){
+                                       // Import each bookmark, saving its id into the map     
+                                       $query = OC_DB::prepare( "INSERT INTO *PREFIX*bookmarks(url, title, user_id, public, added, lastmodified) VALUES (?, ?, ?, ?, ?, ?)" );
+                                       $query->execute( array( $row['url'], $row['title'], $this->uid, $row['public'], $row['added'], $row['lastmodified'] ) );
+                                       // Map the id
+                                       $idmap[$row['id']] = OC_DB::insertid();
+                               }
+                               // Now tags
+                               foreach($idmap as $oldid => $newid){
+                                       $query = $this->content->prepare( "SELECT * FROM bookmarks_tags WHERE user_id LIKE ?" );
+                                       $results = $query->execute( array( $oldid ) );
+                                       while( $row = $data->fetchRow() ){
+                                               // Import the tags for this bookmark, using the new bookmark id
+                                               $query = OC_DB::prepare( "INSERT INTO *PREFIX*bookmarks_tags(bookmark_id, tag) VALUES (?, ?)" );
+                                               $query->execute( array( $newid, $row['tag'] ) );        
+                                       }               
+                               }
+                               // All done!
+                       break;
+               }
+               
+               return true;
+       }
+       
+}
+
+// Load the provider
+new OC_Migration_Provider_Bookmarks( 'bookmarks' );
\ No newline at end of file
diff --git a/apps/bookmarks/lib/migrate.php b/apps/bookmarks/lib/migrate.php
deleted file mode 100644 (file)
index 02c96e5..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-<?php
-class OC_Migration_Provider_Bookmarks extends OC_Migration_Provider{
-       
-       // Create the xml for the user supplied
-       function export( ){
-               OC_Log::write('migration','starting export for bookmarks',OC_Log::INFO);
-               $options = array(
-                       'table'=>'bookmarks',
-                       'matchcol'=>'user_id',
-                       'matchval'=>$this->uid,
-                       'idcol'=>'id'
-               );
-               $ids = $this->content->copyRows( $options );
-
-               $options = array(
-                       'table'=>'bookmarks_tags',
-                       'matchcol'=>'bookmark_id',
-                       'matchval'=>$ids
-               );
-               
-               // Export tags
-               $ids2 = $this->content->copyRows( $options );
-               
-               // If both returned some ids then they worked
-               if( is_array( $ids ) && is_array( $ids2 ) )
-               {
-                       return true;    
-               } else {
-                       return false;
-               }
-               
-       }
-       
-       // Import function for bookmarks
-       function import( ){
-               switch( $this->appinfo->version ){
-                       default:
-                               // All versions of the app have had the same db structure, so all can use the same import function
-                               $query = $this->content->prepare( "SELECT * FROM bookmarks WHERE user_id LIKE ?" );
-                               $results = $query->execute( array( $this->olduid ) );
-                               $idmap = array();
-                               while( $row = $results->fetchRow() ){
-                                       // Import each bookmark, saving its id into the map     
-                                       $query = OC_DB::prepare( "INSERT INTO *PREFIX*bookmarks(url, title, user_id, public, added, lastmodified) VALUES (?, ?, ?, ?, ?, ?)" );
-                                       $query->execute( array( $row['url'], $row['title'], $this->uid, $row['public'], $row['added'], $row['lastmodified'] ) );
-                                       // Map the id
-                                       $idmap[$row['id']] = OC_DB::insertid();
-                               }
-                               // Now tags
-                               foreach($idmap as $oldid => $newid){
-                                       $query = $this->content->prepare( "SELECT * FROM bookmarks_tags WHERE user_id LIKE ?" );
-                                       $results = $query->execute( array( $oldid ) );
-                                       while( $row = $data->fetchRow() ){
-                                               // Import the tags for this bookmark, using the new bookmark id
-                                               $query = OC_DB::prepare( "INSERT INTO *PREFIX*bookmarks_tags(bookmark_id, tag) VALUES (?, ?)" );
-                                               $query->execute( array( $newid, $row['tag'] ) );        
-                                       }               
-                               }
-                               // All done!
-                       break;
-               }
-               
-               return true;
-       }
-       
-}
-
-// Load the provider
-new OC_Migration_Provider_Bookmarks( 'bookmarks' );
\ No newline at end of file
index 718dc57b9f37016759569f37b4e74358169d4205..6b1497d1d0c91500d91a1549b30174dfa7496803 100644 (file)
@@ -64,7 +64,7 @@ class OC_Migrate{
                $apps = OC_App::getAllApps();
                
                foreach($apps as $app){
-                       $path = OC::$SERVERROOT . '/apps/' . $app . '/lib/migrate.php';
+                       $path = OC::$SERVERROOT . '/apps/' . $app . '/appinfo/migrate.php';
                        if( file_exists( $path ) ){
                                include( $path );       
                        }