Plugin Directory

Changeset 656366


Ignore:
Timestamp:
01/21/2013 04:51:18 PM (13 years ago)
Author:
tosend.it
Message:

New 0.5 version is available

Location:
aeiou
Files:
3 edited
5 copied

Legend:

Unmodified
Added
Removed
  • aeiou/tags/0.5/index.php

    r655730 r656366  
    55Description: 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.
    66Author: toSend.it di Luisa Marra
    7 Version: 0.4
     7Version: 0.5
    88Author URI: http://tosend.it
    99*/
     
    1111if(!class_exists('AEIOU')){
    1212    class AEIOU{
    13         const VERSION = '0.4';
     13        const VERSION = '0.5';
    1414        const LANG_DOMAIN = 'AEIOU';
    1515       
     
    2424        private $exportXProfile;
    2525       
     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       
    2645        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;
    3055        }
    3156
     
    396421                             * Starting import
    397422                             */
    398                             _e('Import started.', self::LANG_DOMAIN); echo "\n\n";
     423                            $this->outputLog( __('Import started.', self::LANG_DOMAIN) . "\n\n" );
    399424                            _e('Please do not refresh the page and not go anywhere.'); echo "\n";
    400425                            _e('Interruption of page execution could cause data loss and user table to break!'); echo "\n";
     
    409434                               
    410435                                $login = $user['user_login'];
    411                                 echo("\n<strong>$login</strong> ");
     436                                $this->outputLog("\n[$login] ");
    412437                                $usr = get_user_by('login', $login);
    413438                               
     
    451476                                    if(count($user)>0){
    452477                                        $changes = array_keys($user);
    453                                         $changes = "<code>".implode("</code>, <code>", $changes)."</code>";
     478                                        $changes = "`".implode("`, `", $changes)."`";
    454479                                       
    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");
    456481                                        $user['ID'] = $usr['ID'];
    457482                                        /*
     
    472497                                        if(!isset($user['user_pass'])) $user['user_pass'] = '';
    473498                                        $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                                        }
    480513                                    }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" );
    482515                                    }
    483516                                }
    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);
    488535                                }
    489536                               
    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();
    503537                            }
    504538                           
     
    529563           
    530564                        $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);
    532566           
    533567                        update_user_meta($userID, $key, $value );
    534568                    }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);
    536570                    }
    537571                }
     
    539573           
    540574            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");
    542576           
    543577        }
     
    564598                           
    565599                        $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);
    567601                       
    568602                       
    569603                        update_user_option($userID, $key, $value, $global );
    570604                    }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" );
    572607                    }
    573608                }
     
    575610               
    576611            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");
    578613               
    579614        }
     
    591626                $group = $data[1];
    592627               
    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);
    594629               
    595630                /*
  • aeiou/tags/0.5/parsers.php

    r655730 r656366  
    8383               
    8484                'user_login'            => (string) $user->user_login,
    85                 'user_pass'             => (string) isset($user->user_pass)?$usr->user_pass:'',
     85                'user_pass'             => (string) isset($user->user_pass)?$user->user_pass:'',
    8686                'user_nicename'         => (string) $user->user_nicename,
    8787                'user_email'            => (string) $user->user_email,
  • aeiou/tags/0.5/readme.txt

    r655730 r656366  
    55Requires at least: 3.4
    66Tested up to: 3.5
    7 Stable tag: 0.4
     7Stable tag: 0.5
    88License: GPLv2
    99
     
    4444== Changelog ==
    4545
     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
    4654= 0.4 (2013-01-21) =
    4755* **Update:** All checks ''if is_serialized then unserialize'' were changed with method ''maybe_unserialize''
  • aeiou/trunk/index.php

    r655730 r656366  
    55Description: 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.
    66Author: toSend.it di Luisa Marra
    7 Version: 0.4
     7Version: 0.5
    88Author URI: http://tosend.it
    99*/
     
    1111if(!class_exists('AEIOU')){
    1212    class AEIOU{
    13         const VERSION = '0.4';
     13        const VERSION = '0.5';
    1414        const LANG_DOMAIN = 'AEIOU';
    1515       
     
    2424        private $exportXProfile;
    2525       
     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       
    2645        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;
    3055        }
    3156
     
    396421                             * Starting import
    397422                             */
    398                             _e('Import started.', self::LANG_DOMAIN); echo "\n\n";
     423                            $this->outputLog( __('Import started.', self::LANG_DOMAIN) . "\n\n" );
    399424                            _e('Please do not refresh the page and not go anywhere.'); echo "\n";
    400425                            _e('Interruption of page execution could cause data loss and user table to break!'); echo "\n";
     
    409434                               
    410435                                $login = $user['user_login'];
    411                                 echo("\n<strong>$login</strong> ");
     436                                $this->outputLog("\n[$login] ");
    412437                                $usr = get_user_by('login', $login);
    413438                               
     
    451476                                    if(count($user)>0){
    452477                                        $changes = array_keys($user);
    453                                         $changes = "<code>".implode("</code>, <code>", $changes)."</code>";
     478                                        $changes = "`".implode("`, `", $changes)."`";
    454479                                       
    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");
    456481                                        $user['ID'] = $usr['ID'];
    457482                                        /*
     
    472497                                        if(!isset($user['user_pass'])) $user['user_pass'] = '';
    473498                                        $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                                        }
    480513                                    }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" );
    482515                                    }
    483516                                }
    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);
    488535                                }
    489536                               
    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();
    503537                            }
    504538                           
     
    529563           
    530564                        $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);
    532566           
    533567                        update_user_meta($userID, $key, $value );
    534568                    }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);
    536570                    }
    537571                }
     
    539573           
    540574            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");
    542576           
    543577        }
     
    564598                           
    565599                        $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);
    567601                       
    568602                       
    569603                        update_user_option($userID, $key, $value, $global );
    570604                    }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" );
    572607                    }
    573608                }
     
    575610               
    576611            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");
    578613               
    579614        }
     
    591626                $group = $data[1];
    592627               
    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);
    594629               
    595630                /*
  • aeiou/trunk/parsers.php

    r655730 r656366  
    8383               
    8484                'user_login'            => (string) $user->user_login,
    85                 'user_pass'             => (string) isset($user->user_pass)?$usr->user_pass:'',
     85                'user_pass'             => (string) isset($user->user_pass)?$user->user_pass:'',
    8686                'user_nicename'         => (string) $user->user_nicename,
    8787                'user_email'            => (string) $user->user_email,
  • aeiou/trunk/readme.txt

    r655730 r656366  
    55Requires at least: 3.4
    66Tested up to: 3.5
    7 Stable tag: 0.4
     7Stable tag: 0.5
    88License: GPLv2
    99
     
    4444== Changelog ==
    4545
     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
    4654= 0.4 (2013-01-21) =
    4755* **Update:** All checks ''if is_serialized then unserialize'' were changed with method ''maybe_unserialize''
Note: See TracChangeset for help on using the changeset viewer.