Skip to:
Content

bbPress.org


Ignore:
Timestamp:
09/19/2014 01:50:25 AM (11 years ago)
Author:
netweb
Message:

Use tabs not spaces for indentation in Kunena1.php

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/admin/converters/Kunena1.php

    r5428 r5521  
    2222     * Sets up the field mappings
    2323     */
    24     public function setup_globals() {
    25 
    26         /** Forum Section *****************************************************/
    27 
    28         // Forum id (Stored in postmeta)
    29         $this->field_map[] = array(
    30             'from_tablename' => 'kunena_categories',
    31             'from_fieldname' => 'id',
    32             'to_type'        => 'forum',
    33             'to_fieldname'   => '_bbp_forum_id'
    34         );
    35 
    36         // Forum parent id (If no parent, then 0, Stored in postmeta)
    37         $this->field_map[] = array(
    38             'from_tablename' => 'kunena_categories',
    39             'from_fieldname' => 'parent',
    40             'to_type'        => 'forum',
    41             'to_fieldname'   => '_bbp_old_forum_parent_id'
     24    public function setup_globals() {
     25
     26        /** Forum Section *****************************************************/
     27
     28        // Forum id (Stored in postmeta)
     29        $this->field_map[] = array(
     30            'from_tablename' => 'kunena_categories',
     31            'from_fieldname' => 'id',
     32            'to_type'        => 'forum',
     33            'to_fieldname'   => '_bbp_forum_id'
     34        );
     35
     36        // Forum parent id (If no parent, then 0, Stored in postmeta)
     37        $this->field_map[] = array(
     38            'from_tablename' => 'kunena_categories',
     39            'from_fieldname' => 'parent',
     40            'to_type'        => 'forum',
     41            'to_fieldname'   => '_bbp_old_forum_parent_id'
    4242        );
    4343
     
    7474        );
    7575
    76         // Forum title.
    77         $this->field_map[] = array(
    78             'from_tablename' => 'kunena_categories',
    79             'from_fieldname' => 'name',
    80             'to_type'        => 'forum',
    81             'to_fieldname'   => 'post_title'
    82         );
    83 
    84         // Forum slug (Clean name to avoid conflicts)
    85         $this->field_map[] = array(
    86             'from_tablename'  => 'kunena_categories',
    87             'from_fieldname'  => 'name',
    88             'to_type'         => 'forum',
    89             'to_fieldname'    => 'post_name',
    90             'callback_method' => 'callback_slug'
    91         );
    92 
    93         // Forum description.
    94         $this->field_map[] = array(
    95             'from_tablename'  => 'kunena_categories',
    96             'from_fieldname'  => 'description',
    97             'to_type'         => 'forum',
    98             'to_fieldname'    => 'post_content',
    99             'callback_method' => 'callback_null'
    100         );
    101 
    102         // Forum display order (Starts from 1)
    103         $this->field_map[] = array(
    104             'from_tablename' => 'kunena_categories',
    105             'from_fieldname' => 'ordering',
    106             'to_type'        => 'forum',
    107             'to_fieldname'   => 'menu_order'
     76        // Forum title.
     77        $this->field_map[] = array(
     78            'from_tablename' => 'kunena_categories',
     79            'from_fieldname' => 'name',
     80            'to_type'        => 'forum',
     81            'to_fieldname'   => 'post_title'
     82        );
     83
     84        // Forum slug (Clean name to avoid conflicts)
     85        $this->field_map[] = array(
     86            'from_tablename'  => 'kunena_categories',
     87            'from_fieldname'  => 'name',
     88            'to_type'         => 'forum',
     89            'to_fieldname'    => 'post_name',
     90            'callback_method' => 'callback_slug'
     91        );
     92
     93        // Forum description.
     94        $this->field_map[] = array(
     95            'from_tablename'  => 'kunena_categories',
     96            'from_fieldname'  => 'description',
     97            'to_type'         => 'forum',
     98            'to_fieldname'    => 'post_content',
     99            'callback_method' => 'callback_null'
     100        );
     101
     102        // Forum display order (Starts from 1)
     103        $this->field_map[] = array(
     104            'from_tablename' => 'kunena_categories',
     105            'from_fieldname' => 'ordering',
     106            'to_type'        => 'forum',
     107            'to_fieldname'   => 'menu_order'
    108108        );
    109109
     
    126126        );
    127127
    128         // Forum dates.
    129         $this->field_map[] = array(
    130             'to_type'      => 'forum',
    131             'to_fieldname' => 'post_date',
    132             'default'      => date('Y-m-d H:i:s')
    133         );
    134         $this->field_map[] = array(
    135             'to_type'      => 'forum',
    136             'to_fieldname' => 'post_date_gmt',
    137             'default'      => date('Y-m-d H:i:s')
    138         );
    139         $this->field_map[] = array(
    140             'to_type'      => 'forum',
    141             'to_fieldname' => 'post_modified',
    142             'default'      => date('Y-m-d H:i:s')
    143         );
    144         $this->field_map[] = array(
    145             'to_type'      => 'forum',
    146             'to_fieldname' => 'post_modified_gmt',
    147             'default'      => date('Y-m-d H:i:s')
    148         );
    149 
    150         /** Topic Section *****************************************************/
     128        // Forum dates.
     129        $this->field_map[] = array(
     130            'to_type'      => 'forum',
     131            'to_fieldname' => 'post_date',
     132            'default'      => date('Y-m-d H:i:s')
     133        );
     134        $this->field_map[] = array(
     135            'to_type'      => 'forum',
     136            'to_fieldname' => 'post_date_gmt',
     137            'default'      => date('Y-m-d H:i:s')
     138        );
     139        $this->field_map[] = array(
     140            'to_type'      => 'forum',
     141            'to_fieldname' => 'post_modified',
     142            'default'      => date('Y-m-d H:i:s')
     143        );
     144        $this->field_map[] = array(
     145            'to_type'      => 'forum',
     146            'to_fieldname' => 'post_modified_gmt',
     147            'default'      => date('Y-m-d H:i:s')
     148        );
     149
     150        /** Topic Section *****************************************************/
    151151
    152152        // Topic id (Stored in postmeta)
     
    269269        );
    270270
    271         /** Tags Section ******************************************************/
     271        /** Tags Section ******************************************************/
    272272
    273273        /**
     
    275275         */
    276276
    277         /** Reply Section *****************************************************/
    278 
    279         // Reply id (Stored in postmeta)
    280         $this->field_map[] = array(
    281             'from_tablename' => 'kunena_messages',
    282             'from_fieldname' => 'id',
    283             'to_type'        => 'reply',
    284             'to_fieldname'   => '_bbp_post_id'
    285         );
    286 
    287         // Reply parent forum id (If no parent, then 0. Stored in postmeta)
    288         $this->field_map[] = array(
    289             'from_tablename'  => 'kunena_messages',
    290             'from_fieldname'  => 'catid',
    291             'to_type'         => 'reply',
    292             'to_fieldname'    => '_bbp_forum_id',
    293             'callback_method' => 'callback_topicid_to_forumid'
    294         );
    295 
    296         // Reply parent topic id (If no parent, then 0. Stored in postmeta)
    297         $this->field_map[] = array(
    298             'from_tablename'  => 'kunena_messages',
    299             'from_fieldname'  => 'thread',
    300             'to_type'         => 'reply',
    301             'to_fieldname'    => '_bbp_topic_id',
    302             'callback_method' => 'callback_topicid'
    303         );
    304 
    305         // Reply author ip (Stored in postmeta)
    306         $this->field_map[] = array(
    307             'from_tablename' => 'kunena_messages',
    308             'from_fieldname' => 'ip',
    309             'to_type'        => 'reply',
    310             'to_fieldname'   => '_bbp_author_ip'
    311         );
    312 
    313         // Reply author.
    314         $this->field_map[] = array(
    315             'from_tablename'  => 'kunena_messages',
    316             'from_fieldname'  => 'userid',
    317             'to_type'         => 'reply',
    318             'to_fieldname'    => 'post_author',
    319             'callback_method' => 'callback_userid'
    320         );
    321 
    322         // Reply content.
    323         // Note: We join the 'kunena_messages_text' table because 'kunena_messages' table does not include reply content.
    324         $this->field_map[] = array(
    325             'from_tablename'  => 'kunena_messages_text',
    326             'from_fieldname'  => 'message',
    327             'join_tablename'  => 'kunena_messages',
    328             'join_type'       => 'INNER',
    329             'join_expression' => 'ON kunena_messages.id = kunena_messages_text.mesid WHERE kunena_messages.parent != 0',
    330             'to_type'         => 'reply',
    331             'to_fieldname'    => 'post_content',
    332             'callback_method' => 'callback_html'
    333         );
    334 
    335         // Reply parent topic id (If no parent, then 0)
    336         $this->field_map[] = array(
    337             'from_tablename'  => 'kunena_messages',
    338             'from_fieldname'  => 'thread',
    339             'to_type'         => 'reply',
    340             'to_fieldname'    => 'post_parent',
    341             'callback_method' => 'callback_topicid'
    342         );
    343 
    344         // Reply dates.
    345         $this->field_map[] = array(
    346             'from_tablename'  => 'kunena_messages',
    347             'from_fieldname'  => 'time',
    348             'to_type'         => 'reply',
    349             'to_fieldname'    => 'post_date',
    350             'callback_method' => 'callback_datetime'
    351         );
    352         $this->field_map[] = array(
    353             'from_tablename'  => 'kunena_messages',
    354             'from_fieldname'  => 'time',
    355             'to_type'         => 'reply',
    356             'to_fieldname'    => 'post_date_gmt',
    357             'callback_method' => 'callback_datetime'
    358         );
    359         $this->field_map[] = array(
    360             'from_tablename'  => 'kunena_messages',
    361             'from_fieldname'  => 'time',
    362             'to_type'         => 'reply',
    363             'to_fieldname'    => 'post_modified',
    364             'callback_method' => 'callback_datetime'
    365         );
    366         $this->field_map[] = array(
    367             'from_tablename'  => 'kunena_messages',
    368             'from_fieldname'  => 'time',
    369             'to_type'         => 'reply',
    370             'to_fieldname'    => 'post_modified_gmt',
    371             'callback_method' => 'callback_datetime'
    372         );
    373 
    374         /** User Section ******************************************************/
    375 
    376         //Note: We are importing the Joomla User details and the Kunena v1.x user profile details.
    377 
    378         // Store old User id (Stored in usermeta)
    379         $this->field_map[] = array(
    380             'from_tablename' => 'users',
    381             'from_fieldname' => 'id',
    382             'to_type'        => 'user',
    383             'to_fieldname'   => '_bbp_user_id'
    384         );
    385 
    386         // Store old User password (Stored in usermeta serialized with salt)
    387         $this->field_map[] = array(
    388             'from_tablename'  => 'users',
    389             'from_fieldname'  => 'password',
    390             'to_type'         => 'user',
    391             'to_fieldname'    => '_bbp_password',
    392             'callback_method' => 'callback_savepass'
    393         );
    394 
    395         // Store old User Salt (This is only used for the SELECT row info for the above password save)
    396 //        $this->field_map[] = array(
    397 //          'from_tablename' => 'user',
    398 //          'from_fieldname' => 'salt',
    399 //          'to_type'        => 'user',
    400 //          'to_fieldname'   => ''
     277        /** Reply Section *****************************************************/
     278
     279        // Reply id (Stored in postmeta)
     280        $this->field_map[] = array(
     281            'from_tablename' => 'kunena_messages',
     282            'from_fieldname' => 'id',
     283            'to_type'        => 'reply',
     284            'to_fieldname'   => '_bbp_post_id'
     285        );
     286
     287        // Reply parent forum id (If no parent, then 0. Stored in postmeta)
     288        $this->field_map[] = array(
     289            'from_tablename'  => 'kunena_messages',
     290            'from_fieldname'  => 'catid',
     291            'to_type'         => 'reply',
     292            'to_fieldname'    => '_bbp_forum_id',
     293            'callback_method' => 'callback_topicid_to_forumid'
     294        );
     295
     296        // Reply parent topic id (If no parent, then 0. Stored in postmeta)
     297        $this->field_map[] = array(
     298            'from_tablename'  => 'kunena_messages',
     299            'from_fieldname'  => 'thread',
     300            'to_type'         => 'reply',
     301            'to_fieldname'    => '_bbp_topic_id',
     302            'callback_method' => 'callback_topicid'
     303        );
     304
     305        // Reply author ip (Stored in postmeta)
     306        $this->field_map[] = array(
     307            'from_tablename' => 'kunena_messages',
     308            'from_fieldname' => 'ip',
     309            'to_type'        => 'reply',
     310            'to_fieldname'   => '_bbp_author_ip'
     311        );
     312
     313        // Reply author.
     314        $this->field_map[] = array(
     315            'from_tablename'  => 'kunena_messages',
     316            'from_fieldname'  => 'userid',
     317            'to_type'         => 'reply',
     318            'to_fieldname'    => 'post_author',
     319            'callback_method' => 'callback_userid'
     320        );
     321
     322        // Reply content.
     323        // Note: We join the 'kunena_messages_text' table because 'kunena_messages' table does not include reply content.
     324        $this->field_map[] = array(
     325            'from_tablename'  => 'kunena_messages_text',
     326            'from_fieldname'  => 'message',
     327            'join_tablename'  => 'kunena_messages',
     328            'join_type'       => 'INNER',
     329            'join_expression' => 'ON kunena_messages.id = kunena_messages_text.mesid WHERE kunena_messages.parent != 0',
     330            'to_type'         => 'reply',
     331            'to_fieldname'    => 'post_content',
     332            'callback_method' => 'callback_html'
     333        );
     334
     335        // Reply parent topic id (If no parent, then 0)
     336        $this->field_map[] = array(
     337            'from_tablename'  => 'kunena_messages',
     338            'from_fieldname'  => 'thread',
     339            'to_type'         => 'reply',
     340            'to_fieldname'    => 'post_parent',
     341            'callback_method' => 'callback_topicid'
     342        );
     343
     344        // Reply dates.
     345        $this->field_map[] = array(
     346            'from_tablename'  => 'kunena_messages',
     347            'from_fieldname'  => 'time',
     348            'to_type'         => 'reply',
     349            'to_fieldname'    => 'post_date',
     350            'callback_method' => 'callback_datetime'
     351        );
     352        $this->field_map[] = array(
     353            'from_tablename'  => 'kunena_messages',
     354            'from_fieldname'  => 'time',
     355            'to_type'         => 'reply',
     356            'to_fieldname'    => 'post_date_gmt',
     357            'callback_method' => 'callback_datetime'
     358        );
     359        $this->field_map[] = array(
     360            'from_tablename'  => 'kunena_messages',
     361            'from_fieldname'  => 'time',
     362            'to_type'         => 'reply',
     363            'to_fieldname'    => 'post_modified',
     364            'callback_method' => 'callback_datetime'
     365        );
     366        $this->field_map[] = array(
     367            'from_tablename'  => 'kunena_messages',
     368            'from_fieldname'  => 'time',
     369            'to_type'         => 'reply',
     370            'to_fieldname'    => 'post_modified_gmt',
     371            'callback_method' => 'callback_datetime'
     372        );
     373
     374        /** User Section ******************************************************/
     375
     376        //Note: We are importing the Joomla User details and the Kunena v1.x user profile details.
     377
     378        // Store old User id (Stored in usermeta)
     379        $this->field_map[] = array(
     380            'from_tablename' => 'users',
     381            'from_fieldname' => 'id',
     382            'to_type'        => 'user',
     383            'to_fieldname'   => '_bbp_user_id'
     384        );
     385
     386        // Store old User password (Stored in usermeta serialized with salt)
     387        $this->field_map[] = array(
     388            'from_tablename'  => 'users',
     389            'from_fieldname'  => 'password',
     390            'to_type'         => 'user',
     391            'to_fieldname'    => '_bbp_password',
     392            'callback_method' => 'callback_savepass'
     393        );
     394
     395        // Store old User Salt (This is only used for the SELECT row info for the above password save)
     396//      $this->field_map[] = array(
     397//          'from_tablename' => 'user',
     398//          'from_fieldname' => 'salt',
     399//          'to_type'        => 'user',
     400//          'to_fieldname'   => ''
    401401//      );
    402402
    403         // User password verify class (Stored in usermeta for verifying password)
    404 //        $this->field_map[] = array(
    405 //          'to_type'      => 'user',
    406 //          'to_fieldname' => '_bbp_class',
    407 //          'default'      => 'Kunena1'
     403        // User password verify class (Stored in usermeta for verifying password)
     404//      $this->field_map[] = array(
     405//          'to_type'      => 'user',
     406//          'to_fieldname' => '_bbp_class',
     407//          'default'      => 'Kunena1'
    408408//      );
    409409
    410         // User name.
    411         $this->field_map[] = array(
    412             'from_tablename' => 'users',
    413             'from_fieldname' => 'username',
    414             'to_type'        => 'user',
    415             'to_fieldname'   => 'user_login'
    416         );
    417 
    418         // User email.
    419         $this->field_map[] = array(
    420             'from_tablename' => 'users',
    421             'from_fieldname' => 'email',
    422             'to_type'        => 'user',
    423             'to_fieldname'   => 'user_email'
    424         );
    425 
    426         // User registered.
    427         $this->field_map[] = array(
    428             'from_tablename'  => 'users',
    429             'from_fieldname'  => 'registerDate',
    430             'to_type'         => 'user',
    431             'to_fieldname'    => 'user_registered',
    432             'callback_method' => 'callback_datetime'
    433         );
    434     }
    435 
    436     /**
    437     * This method allows us to indicates what is or is not converted for each
    438     * converter.
    439     */
    440     public function info() {
    441         return '';
    442     }
    443 
    444     /**
    445     * This method is to save the salt and password together.  That
    446     * way when we authenticate it we can get it out of the database
    447     * as one value. Array values are auto sanitized by WordPress.
    448     */
    449     public function callback_savepass($field, $row) {
    450         $pass_array = array('hash' => $field, 'salt' => $row['salt']);
    451         return $pass_array;
    452     }
    453 
    454     /**
    455     * This method is to take the pass out of the database and compare
    456     * to a pass the user has typed in.
    457     */
    458     public function authenticate_pass($password, $serialized_pass) {
    459         $pass_array = unserialize($serialized_pass);
    460         return ( $pass_array['hash'] == md5(md5($password) . $pass_array['salt']) );
    461     }
     410        // User name.
     411        $this->field_map[] = array(
     412            'from_tablename' => 'users',
     413            'from_fieldname' => 'username',
     414            'to_type'        => 'user',
     415            'to_fieldname'   => 'user_login'
     416        );
     417
     418        // User email.
     419        $this->field_map[] = array(
     420            'from_tablename' => 'users',
     421            'from_fieldname' => 'email',
     422            'to_type'        => 'user',
     423            'to_fieldname'   => 'user_email'
     424        );
     425
     426        // User registered.
     427        $this->field_map[] = array(
     428            'from_tablename'  => 'users',
     429            'from_fieldname'  => 'registerDate',
     430            'to_type'         => 'user',
     431            'to_fieldname'    => 'user_registered',
     432            'callback_method' => 'callback_datetime'
     433        );
     434    }
     435
     436    /**
     437    * This method allows us to indicates what is or is not converted for each
     438    * converter.
     439    */
     440    public function info() {
     441        return '';
     442    }
     443
     444    /**
     445    * This method is to save the salt and password together.  That
     446    * way when we authenticate it we can get it out of the database
     447    * as one value. Array values are auto sanitized by WordPress.
     448    */
     449    public function callback_savepass($field, $row) {
     450        $pass_array = array('hash' => $field, 'salt' => $row['salt']);
     451        return $pass_array;
     452    }
     453
     454    /**
     455    * This method is to take the pass out of the database and compare
     456    * to a pass the user has typed in.
     457    */
     458    public function authenticate_pass($password, $serialized_pass) {
     459        $pass_array = unserialize($serialized_pass);
     460        return ( $pass_array['hash'] == md5(md5($password) . $pass_array['salt']) );
     461    }
    462462
    463463    /**
Note: See TracChangeset for help on using the changeset viewer.