Changeset 656366
- Timestamp:
- 01/21/2013 04:51:18 PM (13 years ago)
- Location:
- aeiou
- Files:
-
- 3 edited
- 5 copied
-
tags/0.5 (copied) (copied from aeiou/trunk)
-
tags/0.5/index.php (copied) (copied from aeiou/trunk/index.php) (12 diffs)
-
tags/0.5/languages (copied) (copied from aeiou/trunk/languages)
-
tags/0.5/parsers.php (copied) (copied from aeiou/trunk/parsers.php) (1 diff)
-
tags/0.5/readme.txt (copied) (copied from aeiou/trunk/readme.txt) (2 diffs)
-
trunk/index.php (modified) (12 diffs)
-
trunk/parsers.php (modified) (1 diff)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
aeiou/tags/0.5/index.php
r655730 r656366 5 5 Description: AEIOU is a powerfull plugin that export all wordpress users info into an XML file including user metadatas and allow to import the same xml file into a new wordpress keeping the metadata of each user. The plugin is able to export buddypress xprofile data too. 6 6 Author: toSend.it di Luisa Marra 7 Version: 0. 47 Version: 0.5 8 8 Author URI: http://tosend.it 9 9 */ … … 11 11 if(!class_exists('AEIOU')){ 12 12 class AEIOU{ 13 const VERSION = '0. 4';13 const VERSION = '0.5'; 14 14 const LANG_DOMAIN = 'AEIOU'; 15 15 … … 24 24 private $exportXProfile; 25 25 26 private static $instance; 27 28 public static function outputLog($data, $verbose = false){ 29 if(!isset(self::$instance) ) new AEIOU(); 30 31 $verbose = $verbose && self::$instance->verbose; 32 if($verbose){ 33 echo($data); 34 } 35 flush(); 36 $theDirectory = dirname(__FILE__) . '/logs/'; 37 if(is_dir($theDirectory)){ 38 $fileName = date('Y-m-d') . '.log'; 39 40 file_put_contents($theDirectory . $fileName, $data, FILE_APPEND ); 41 } 42 43 } 44 26 45 public function __construct(){ 27 add_action('admin_init', array($this , 'init')); 28 add_action('admin_menu', array($this, 'createPages')); 29 46 if(is_null(self::$instance) ){ 47 /* 48 * Singleton pattern: The hooks will be invoked once! 49 */ 50 add_action('admin_init', array($this , 'init')); 51 add_action('admin_menu', array($this, 'createPages')); 52 self::$instance = $this; 53 } 54 return self::$instance; 30 55 } 31 56 … … 396 421 * Starting import 397 422 */ 398 _e('Import started.', self::LANG_DOMAIN); echo "\n\n";423 $this->outputLog( __('Import started.', self::LANG_DOMAIN) . "\n\n" ); 399 424 _e('Please do not refresh the page and not go anywhere.'); echo "\n"; 400 425 _e('Interruption of page execution could cause data loss and user table to break!'); echo "\n"; … … 409 434 410 435 $login = $user['user_login']; 411 echo("\n<strong>$login</strong>");436 $this->outputLog("\n[$login] "); 412 437 $usr = get_user_by('login', $login); 413 438 … … 451 476 if(count($user)>0){ 452 477 $changes = array_keys($user); 453 $changes = " <code>".implode("</code>, <code>", $changes)."</code>";478 $changes = "`".implode("`, `", $changes)."`"; 454 479 455 echo sprintf(__("has new %s value(s).", self::LANG_DOMAIN),$changes) . "\n";480 $this->outputLog( sprintf(__("has new %s value(s).", self::LANG_DOMAIN),$changes) . "\n"); 456 481 $user['ID'] = $usr['ID']; 457 482 /* … … 472 497 if(!isset($user['user_pass'])) $user['user_pass'] = ''; 473 498 $userID = wp_insert_user($user); 474 $user['ID'] = $userID; 475 /* 476 * If password is defined in the XML file we should to import it 477 */ 478 wp_update_user($user); 479 echo sprintf(__("inserted with ID %d", self::LANG_DOMAIN),$userID) . "\n"; 499 500 # TODO: Gestire il caso in cui non è riusito ad inserire l'utente 501 if(is_wp_error($userID)){ 502 503 $this->outputLog( $userID->get_error_message() . "\n" ); 504 505 }else{ 506 $user['ID'] = $userID; 507 /* 508 * If password is defined in the XML file we should to import it 509 */ 510 wp_update_user($user); 511 $this->outputLog( sprintf(__("inserted with ID %d", self::LANG_DOMAIN),$userID) . "\n" ); 512 } 480 513 }else{ 481 echo __("skipped due it's already in the database", self::LANG_DOMAIN) . "\n";514 $this->outputLog( __("skipped due it's already in the database", self::LANG_DOMAIN) . "\n" ); 482 515 } 483 516 } 484 485 if($this->importMetadata && $userID != 0){ 486 do_action('aeiou_before_import_metadata', $user); 487 $this->importUserMetaData($userMeta, $userID, $login); 517 if(!is_wp_error($userID)){ 518 if($this->importMetadata && $userID != 0){ 519 do_action('aeiou_before_import_metadata', $user); 520 $this->importUserMetaData($userMeta, $userID, $login); 521 } 522 523 if($this->importOptions && $userID != 0){ 524 do_action('aeiou_before_import_options', $user); 525 $this->outputLog( __("Importing user options\n", self::LANG_DOMAIN) ); 526 $this->importUserOptions($userOptions, $userID, $login); 527 } 528 529 if($this->importXProfile && $userID != 0 && class_exists('BP_XProfile_Component')){ 530 do_action('aeiou_before_import_xprofile', $user); 531 $this->outputLog( __("Importing XProfile data\n", self::LANG_DOMAIN) ); 532 $this->importXProfileData($xprofile, $userID); 533 } 534 do_action('aeiou_after_import_user', $user); 488 535 } 489 536 490 if($this->importOptions && $userID != 0){491 do_action('aeiou_before_import_options', $user);492 echo __("Importing user options\n", self::LANG_DOMAIN);493 $this->importUserOptions($userOptions, $userID, $login);494 }495 496 if($this->importXProfile && $userID != 0 && class_exists('BP_XProfile_Component')){497 do_action('aeiou_before_import_xprofile', $user);498 echo __("Importing XProfile data\n", self::LANG_DOMAIN);499 $this->importXProfileData($xprofile, $userID);500 }501 do_action('aeiou_after_import_user', $user);502 flush();503 537 } 504 538 … … 529 563 530 564 $count+=1; 531 if($this->verbose) echo sprintf(__("Metadata <code>%s</code> updated for user <strong>%s</strong>", self::LANG_DOMAIN), $key, $login) . "\n";565 $this->outputLog( sprintf(__("Metadata `%s` updated for user [%s]", self::LANG_DOMAIN), $key, $login) . "\n", true); 532 566 533 567 update_user_meta($userID, $key, $value ); 534 568 }else{ 535 if($metaKey && $this->verbose) echo sprintf(__("Metadata <code>%s</code> removed for user <strong>%s</strong>", self::LANG_DOMAIN), $key, $login) . "\n";569 if($metaKey) $this->outputLog( sprintf(__("Metadata `%s` removed for user [%s]", self::LANG_DOMAIN), $key, $login) . "\n", true); 536 570 } 537 571 } … … 539 573 540 574 if($count>0) 541 echo sprintf(__("Updated %d metadatas for user <strong>%s</strong>", self::LANG_DOMAIN), $count, $login) . "\n";575 $this->outputLog( sprintf(__("Updated %d metadatas for user [%s]", self::LANG_DOMAIN), $count, $login) . "\n"); 542 576 543 577 } … … 564 598 565 599 $count+=1; 566 if($this->verbose) echo sprintf(__("Option <code>%s</code> updated for user <strong>%s</strong>", self::LANG_DOMAIN), $key, $login) . "\n";600 $this->outputLog( sprintf(__("Option `%s` updated for user [%s]", self::LANG_DOMAIN), $key, $login) . "\n" , true); 567 601 568 602 569 603 update_user_option($userID, $key, $value, $global ); 570 604 }else{ 571 if($optExists && $this->verbose) echo sprintf(__("Option <code>%s</code> removed for user <strong>%s</strong>", self::LANG_DOMAIN), $key, $login) . "\n"; 605 if($optExists) 606 $this->outputLog( sprintf(__("Option `%s` removed for user [%s]", self::LANG_DOMAIN), $key, $login) . "\n" ); 572 607 } 573 608 } … … 575 610 576 611 if($count>0) 577 echo sprintf(__("Updated %d metadatas for user <strong>%s</strong>", self::LANG_DOMAIN), $count, $login) . "\n";612 $this->outputLog( sprintf(__("Updated %d metadatas for user [%s]", self::LANG_DOMAIN), $count, $login) . "\n"); 578 613 579 614 } … … 591 626 $group = $data[1]; 592 627 593 if($this->verbose) echo sprintf(__("Importing field <code>%s</code> of group <code>%s</code>", self::LANG_DOMAIN), $name, $group) . "\n";628 $this->outputLog( sprintf(__("Importing field `%s` of group `%s`", self::LANG_DOMAIN), $name, $group) . "\n", true); 594 629 595 630 /* -
aeiou/tags/0.5/parsers.php
r655730 r656366 83 83 84 84 'user_login' => (string) $user->user_login, 85 'user_pass' => (string) isset($user->user_pass)?$us r->user_pass:'',85 'user_pass' => (string) isset($user->user_pass)?$user->user_pass:'', 86 86 'user_nicename' => (string) $user->user_nicename, 87 87 'user_email' => (string) $user->user_email, -
aeiou/tags/0.5/readme.txt
r655730 r656366 5 5 Requires at least: 3.4 6 6 Tested up to: 3.5 7 Stable tag: 0. 47 Stable tag: 0.5 8 8 License: GPLv2 9 9 … … 44 44 == Changelog == 45 45 46 = 0.5 (2013-01-21) = 47 * **New:** Added public static method ''outputLog'' callable by the aeiou extensions. 48 * **New:** Added static object $instance to keep always the instance of AEIOU 49 * **Update:** Import: In case of error the WP_Error object is threated correctly 50 * **Update:** Import: Output is generated in log file too (Ensure to have a writable directory log under the plugin) 51 * **Update:** Import: Changed output messages for better compatibility with text log 52 * **Bugfix:** Import: Mispelled $usr instead of $user in parser method for password field 53 46 54 = 0.4 (2013-01-21) = 47 55 * **Update:** All checks ''if is_serialized then unserialize'' were changed with method ''maybe_unserialize'' -
aeiou/trunk/index.php
r655730 r656366 5 5 Description: AEIOU is a powerfull plugin that export all wordpress users info into an XML file including user metadatas and allow to import the same xml file into a new wordpress keeping the metadata of each user. The plugin is able to export buddypress xprofile data too. 6 6 Author: toSend.it di Luisa Marra 7 Version: 0. 47 Version: 0.5 8 8 Author URI: http://tosend.it 9 9 */ … … 11 11 if(!class_exists('AEIOU')){ 12 12 class AEIOU{ 13 const VERSION = '0. 4';13 const VERSION = '0.5'; 14 14 const LANG_DOMAIN = 'AEIOU'; 15 15 … … 24 24 private $exportXProfile; 25 25 26 private static $instance; 27 28 public static function outputLog($data, $verbose = false){ 29 if(!isset(self::$instance) ) new AEIOU(); 30 31 $verbose = $verbose && self::$instance->verbose; 32 if($verbose){ 33 echo($data); 34 } 35 flush(); 36 $theDirectory = dirname(__FILE__) . '/logs/'; 37 if(is_dir($theDirectory)){ 38 $fileName = date('Y-m-d') . '.log'; 39 40 file_put_contents($theDirectory . $fileName, $data, FILE_APPEND ); 41 } 42 43 } 44 26 45 public function __construct(){ 27 add_action('admin_init', array($this , 'init')); 28 add_action('admin_menu', array($this, 'createPages')); 29 46 if(is_null(self::$instance) ){ 47 /* 48 * Singleton pattern: The hooks will be invoked once! 49 */ 50 add_action('admin_init', array($this , 'init')); 51 add_action('admin_menu', array($this, 'createPages')); 52 self::$instance = $this; 53 } 54 return self::$instance; 30 55 } 31 56 … … 396 421 * Starting import 397 422 */ 398 _e('Import started.', self::LANG_DOMAIN); echo "\n\n";423 $this->outputLog( __('Import started.', self::LANG_DOMAIN) . "\n\n" ); 399 424 _e('Please do not refresh the page and not go anywhere.'); echo "\n"; 400 425 _e('Interruption of page execution could cause data loss and user table to break!'); echo "\n"; … … 409 434 410 435 $login = $user['user_login']; 411 echo("\n<strong>$login</strong>");436 $this->outputLog("\n[$login] "); 412 437 $usr = get_user_by('login', $login); 413 438 … … 451 476 if(count($user)>0){ 452 477 $changes = array_keys($user); 453 $changes = " <code>".implode("</code>, <code>", $changes)."</code>";478 $changes = "`".implode("`, `", $changes)."`"; 454 479 455 echo sprintf(__("has new %s value(s).", self::LANG_DOMAIN),$changes) . "\n";480 $this->outputLog( sprintf(__("has new %s value(s).", self::LANG_DOMAIN),$changes) . "\n"); 456 481 $user['ID'] = $usr['ID']; 457 482 /* … … 472 497 if(!isset($user['user_pass'])) $user['user_pass'] = ''; 473 498 $userID = wp_insert_user($user); 474 $user['ID'] = $userID; 475 /* 476 * If password is defined in the XML file we should to import it 477 */ 478 wp_update_user($user); 479 echo sprintf(__("inserted with ID %d", self::LANG_DOMAIN),$userID) . "\n"; 499 500 # TODO: Gestire il caso in cui non è riusito ad inserire l'utente 501 if(is_wp_error($userID)){ 502 503 $this->outputLog( $userID->get_error_message() . "\n" ); 504 505 }else{ 506 $user['ID'] = $userID; 507 /* 508 * If password is defined in the XML file we should to import it 509 */ 510 wp_update_user($user); 511 $this->outputLog( sprintf(__("inserted with ID %d", self::LANG_DOMAIN),$userID) . "\n" ); 512 } 480 513 }else{ 481 echo __("skipped due it's already in the database", self::LANG_DOMAIN) . "\n";514 $this->outputLog( __("skipped due it's already in the database", self::LANG_DOMAIN) . "\n" ); 482 515 } 483 516 } 484 485 if($this->importMetadata && $userID != 0){ 486 do_action('aeiou_before_import_metadata', $user); 487 $this->importUserMetaData($userMeta, $userID, $login); 517 if(!is_wp_error($userID)){ 518 if($this->importMetadata && $userID != 0){ 519 do_action('aeiou_before_import_metadata', $user); 520 $this->importUserMetaData($userMeta, $userID, $login); 521 } 522 523 if($this->importOptions && $userID != 0){ 524 do_action('aeiou_before_import_options', $user); 525 $this->outputLog( __("Importing user options\n", self::LANG_DOMAIN) ); 526 $this->importUserOptions($userOptions, $userID, $login); 527 } 528 529 if($this->importXProfile && $userID != 0 && class_exists('BP_XProfile_Component')){ 530 do_action('aeiou_before_import_xprofile', $user); 531 $this->outputLog( __("Importing XProfile data\n", self::LANG_DOMAIN) ); 532 $this->importXProfileData($xprofile, $userID); 533 } 534 do_action('aeiou_after_import_user', $user); 488 535 } 489 536 490 if($this->importOptions && $userID != 0){491 do_action('aeiou_before_import_options', $user);492 echo __("Importing user options\n", self::LANG_DOMAIN);493 $this->importUserOptions($userOptions, $userID, $login);494 }495 496 if($this->importXProfile && $userID != 0 && class_exists('BP_XProfile_Component')){497 do_action('aeiou_before_import_xprofile', $user);498 echo __("Importing XProfile data\n", self::LANG_DOMAIN);499 $this->importXProfileData($xprofile, $userID);500 }501 do_action('aeiou_after_import_user', $user);502 flush();503 537 } 504 538 … … 529 563 530 564 $count+=1; 531 if($this->verbose) echo sprintf(__("Metadata <code>%s</code> updated for user <strong>%s</strong>", self::LANG_DOMAIN), $key, $login) . "\n";565 $this->outputLog( sprintf(__("Metadata `%s` updated for user [%s]", self::LANG_DOMAIN), $key, $login) . "\n", true); 532 566 533 567 update_user_meta($userID, $key, $value ); 534 568 }else{ 535 if($metaKey && $this->verbose) echo sprintf(__("Metadata <code>%s</code> removed for user <strong>%s</strong>", self::LANG_DOMAIN), $key, $login) . "\n";569 if($metaKey) $this->outputLog( sprintf(__("Metadata `%s` removed for user [%s]", self::LANG_DOMAIN), $key, $login) . "\n", true); 536 570 } 537 571 } … … 539 573 540 574 if($count>0) 541 echo sprintf(__("Updated %d metadatas for user <strong>%s</strong>", self::LANG_DOMAIN), $count, $login) . "\n";575 $this->outputLog( sprintf(__("Updated %d metadatas for user [%s]", self::LANG_DOMAIN), $count, $login) . "\n"); 542 576 543 577 } … … 564 598 565 599 $count+=1; 566 if($this->verbose) echo sprintf(__("Option <code>%s</code> updated for user <strong>%s</strong>", self::LANG_DOMAIN), $key, $login) . "\n";600 $this->outputLog( sprintf(__("Option `%s` updated for user [%s]", self::LANG_DOMAIN), $key, $login) . "\n" , true); 567 601 568 602 569 603 update_user_option($userID, $key, $value, $global ); 570 604 }else{ 571 if($optExists && $this->verbose) echo sprintf(__("Option <code>%s</code> removed for user <strong>%s</strong>", self::LANG_DOMAIN), $key, $login) . "\n"; 605 if($optExists) 606 $this->outputLog( sprintf(__("Option `%s` removed for user [%s]", self::LANG_DOMAIN), $key, $login) . "\n" ); 572 607 } 573 608 } … … 575 610 576 611 if($count>0) 577 echo sprintf(__("Updated %d metadatas for user <strong>%s</strong>", self::LANG_DOMAIN), $count, $login) . "\n";612 $this->outputLog( sprintf(__("Updated %d metadatas for user [%s]", self::LANG_DOMAIN), $count, $login) . "\n"); 578 613 579 614 } … … 591 626 $group = $data[1]; 592 627 593 if($this->verbose) echo sprintf(__("Importing field <code>%s</code> of group <code>%s</code>", self::LANG_DOMAIN), $name, $group) . "\n";628 $this->outputLog( sprintf(__("Importing field `%s` of group `%s`", self::LANG_DOMAIN), $name, $group) . "\n", true); 594 629 595 630 /* -
aeiou/trunk/parsers.php
r655730 r656366 83 83 84 84 'user_login' => (string) $user->user_login, 85 'user_pass' => (string) isset($user->user_pass)?$us r->user_pass:'',85 'user_pass' => (string) isset($user->user_pass)?$user->user_pass:'', 86 86 'user_nicename' => (string) $user->user_nicename, 87 87 'user_email' => (string) $user->user_email, -
aeiou/trunk/readme.txt
r655730 r656366 5 5 Requires at least: 3.4 6 6 Tested up to: 3.5 7 Stable tag: 0. 47 Stable tag: 0.5 8 8 License: GPLv2 9 9 … … 44 44 == Changelog == 45 45 46 = 0.5 (2013-01-21) = 47 * **New:** Added public static method ''outputLog'' callable by the aeiou extensions. 48 * **New:** Added static object $instance to keep always the instance of AEIOU 49 * **Update:** Import: In case of error the WP_Error object is threated correctly 50 * **Update:** Import: Output is generated in log file too (Ensure to have a writable directory log under the plugin) 51 * **Update:** Import: Changed output messages for better compatibility with text log 52 * **Bugfix:** Import: Mispelled $usr instead of $user in parser method for password field 53 46 54 = 0.4 (2013-01-21) = 47 55 * **Update:** All checks ''if is_serialized then unserialize'' were changed with method ''maybe_unserialize''
Note: See TracChangeset
for help on using the changeset viewer.