diff options
author | Bart Visscher <bartv@thisnet.nl> | 2012-08-29 08:38:33 +0200 |
---|---|---|
committer | Bart Visscher <bartv@thisnet.nl> | 2012-08-29 20:28:45 +0200 |
commit | 52f2e7112ea985203eca16aa787bd75a7cf92194 (patch) | |
tree | 1d1f5070b050652940847c569b1d3968bdae082c /lib/migration | |
parent | 76bc4753e9bd2698415b067108806d82ac56b663 (diff) | |
download | nextcloud-server-52f2e7112ea985203eca16aa787bd75a7cf92194.tar.gz nextcloud-server-52f2e7112ea985203eca16aa787bd75a7cf92194.zip |
Whitespace fixes in lib
Diffstat (limited to 'lib/migration')
-rw-r--r-- | lib/migration/content.php | 80 | ||||
-rw-r--r-- | lib/migration/provider.php | 18 |
2 files changed, 49 insertions, 49 deletions
diff --git a/lib/migration/content.php b/lib/migration/content.php index 5c89e6bacd6..e04ac224f79 100644 --- a/lib/migration/content.php +++ b/lib/migration/content.php @@ -25,13 +25,13 @@ * provides methods to add and access data from the migration */ class OC_Migration_Content{ - + private $zip=false; // Holds the MDB2 object private $db=null; // Holds an array of tmpfiles to delete after zip creation private $tmpfiles=false; - + /** * @brief sets up the * @param $zip ZipArchive object @@ -42,25 +42,25 @@ class OC_Migration_Content{ $this->zip = $zip; $this->db = $db; - + if( !is_null( $db ) ){ // Get db path $db = $this->db->getDatabase(); $this->tmpfiles[] = $db; } - + } - + // @brief prepares the db // @param $query the sql query to prepare public function prepare( $query ){ - + // Optimize the query $query = $this->processQuery( $query ); - + // Optimize the query $query = $this->db->prepare( $query ); - + // Die if we have an error (error means: bad query, not 0 results!) if( PEAR::isError( $query ) ) { $entry = 'DB Error: "'.$result->getMessage().'"<br />'; @@ -68,11 +68,11 @@ class OC_Migration_Content{ OC_Log::write( 'migration', $entry, OC_Log::FATAL ); return false; } else { - return $query; + return $query; } - + } - + /** * @brief processes the db query * @param $query the query to process @@ -86,7 +86,7 @@ class OC_Migration_Content{ $query = str_replace( '*PREFIX*', '', $query ); return $query; } - + /** * @brief copys rows to migration.db from the main database * @param $options array of options. @@ -94,19 +94,19 @@ class OC_Migration_Content{ */ public function copyRows( $options ){ if( !array_key_exists( 'table', $options ) ){ - return false; + return false; } - + $return = array(); - + // Need to include 'where' in the query? if( array_key_exists( 'matchval', $options ) && array_key_exists( 'matchcol', $options ) ){ - + // If only one matchval, create an array if(!is_array($options['matchval'])){ - $options['matchval'] = array( $options['matchval'] ); + $options['matchval'] = array( $options['matchval'] ); } - + foreach( $options['matchval'] as $matchval ){ // Run the query for this match value (where x = y value) $sql = 'SELECT * FROM `*PREFIX*' . $options['table'] . '` WHERE `' . $options['matchcol'] . '` LIKE ?'; @@ -122,13 +122,13 @@ class OC_Migration_Content{ $query = OC_DB::prepare( $sql ); $results = $query->execute(); $return = $this->insertData( $results, $options ); - + } - + return $return; - + } - + /** * @brief saves a sql data set into migration.db * @param $data a sql data set returned from self::prepare()->query() @@ -144,7 +144,7 @@ class OC_Migration_Content{ $fields[] = $field; $values[] = $value; } - + // Generate some sql $sql = "INSERT INTO `" . $options['table'] . '` ( `'; $fieldssql = implode( '`, `', $fields ); @@ -154,7 +154,7 @@ class OC_Migration_Content{ // Make the query $query = $this->prepare( $sql ); if( !$query ){ - OC_Log::write( 'migration', 'Invalid sql produced: '.$sql, OC_Log::FATAL ); + OC_Log::write( 'migration', 'Invalid sql produced: '.$sql, OC_Log::FATAL ); return false; exit(); } else { @@ -162,10 +162,10 @@ class OC_Migration_Content{ // Do we need to return some values? if( array_key_exists( 'idcol', $options ) ){ // Yes we do - $return[] = $row[$options['idcol']]; + $return[] = $row[$options['idcol']]; } else { // Take a guess and return the first field :) - $return[] = reset($row); + $return[] = reset($row); } } $fields = ''; @@ -173,11 +173,11 @@ class OC_Migration_Content{ } return $return; } - + /** * @brief adds a directory to the zip object * @param $dir string path of the directory to add - * @param $recursive bool + * @param $recursive bool * @param $internaldir string path of folder to add dir to in zip * @return bool */ @@ -186,13 +186,13 @@ class OC_Migration_Content{ $this->zip->addEmptyDir($internaldir . $dirname); $internaldir.=$dirname.='/'; if( !file_exists( $dir ) ){ - return false; + return false; } if ($dirhandle = opendir($dir)) { while (false !== ( $file = readdir($dirhandle))) { - + if (( $file != '.' ) && ( $file != '..' )) { - + if (is_dir($dir . '/' . $file) && $recursive) { $this->addDir($dir . '/' . $file, $recursive, $internaldir); } elseif (is_file($dir . '/' . $file)) { @@ -207,7 +207,7 @@ class OC_Migration_Content{ } return true; } - + /** * @brief adds a file to the zip from a given string * @param $data string of data to add @@ -220,13 +220,13 @@ class OC_Migration_Content{ $this->tmpfiles[] = $file; if( !file_put_contents( $file, $data ) ){ OC_Log::write( 'migation', 'Failed to save data to a temporary file', OC_Log::ERROR ); - return false; + return false; } // Add file to the zip $this->zip->addFile( $file, $path ); return true; } - + /** * @brief closes the zip, removes temp files * @return bool @@ -234,19 +234,19 @@ class OC_Migration_Content{ public function finish(){ if( !$this->zip->close() ){ OC_Log::write( 'migration', 'Failed to write the zip file with error: '.$this->zip->getStatusString(), OC_Log::ERROR ); - return false; + return false; } $this->cleanup(); - return true; - } - + return true; + } + /** * @brief cleans up after the zip */ private function cleanup(){ // Delete tmp files foreach($this->tmpfiles as $i){ - unlink( $i ); - } + unlink( $i ); + } } } diff --git a/lib/migration/provider.php b/lib/migration/provider.php index 91336f3019d..259b1fe7ae6 100644 --- a/lib/migration/provider.php +++ b/lib/migration/provider.php @@ -3,37 +3,37 @@ * provides search functionalty */ abstract class OC_Migration_Provider{ - + protected $id=false; - protected $content=false; + protected $content=false; protected $uid=false; protected $olduid=false; protected $appinfo=false; - + public function __construct( $appid ){ // Set the id $this->id = $appid; OC_Migrate::registerProvider( $this ); } - + /** * @brief exports data for apps * @return array appdata to be exported */ abstract function export( ); - + /** * @brief imports data for the app * @return void */ abstract function import( ); - + /** * @brief sets the OC_Migration_Content object to $this->content * @param $content a OC_Migration_Content object */ public function setData( $uid, $content, $info=null ){ - $this->content = $content; + $this->content = $content; $this->uid = $uid; $id = $this->id; if( !is_null( $info ) ){ @@ -41,12 +41,12 @@ abstract class OC_Migration_Provider{ $this->appinfo = $info->apps->$id; } } - + /** * @brief returns the appid of the provider * @return string */ public function getID(){ - return $this->id; + return $this->id; } } |