Skip to:
Content

bbPress.org

Changeset 5544


Ignore:
Timestamp:
10/10/2014 06:44:33 AM (7 years ago)
Author:
netweb
Message:

Move callback callback_check_anonymous from individual importers to BBP_Converter_Base in converter.php.

  • Allows us to lean on callback_userid to determine multiple anonymous or guest topic and reply authors during import and reduces code duplication

Props netweb. See #2347

Location:
trunk/src/includes/admin
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/admin/converter.php

    r5543 r5544  
    15721572
    15731573    /**
     1574     * Check if the topic or reply author is anonymous
     1575     *
     1576     * @since  (r5544)
     1577     *
     1578     * @param  string $field
     1579     * @return string
     1580     */
     1581    private function callback_check_anonymous( $field ) {
     1582
     1583        if ( $this->callback_userid( $field ) == 0 ) {
     1584            $field = 'true';
     1585        } else {
     1586            $field = 'false';
     1587        }
     1588
     1589        return $field;
     1590    }
     1591
     1592    /**
    15741593     * A mini cache system to reduce database calls map topics ID's to forum ID's
    15751594     *
  • trunk/src/includes/admin/converters/Drupal7.php

    r5541 r5544  
    657657        return $count;
    658658    }
    659 
    660     /**
    661      * Check the anonymous topic or reply status
    662      *
    663      * @since  (r5539)
    664      *
    665      * @param int $status Drupal v7.x anonymous topic/reply status
    666      * @return string WordPress safe
    667      */
    668     public function callback_check_anonymous( $status = 0 ) {
    669         if ( $status == 0 ) {
    670             $status = 'true';
    671         } else {
    672             $status = 'false';
    673         }
    674         return $status;
    675     }
    676659}
  • trunk/src/includes/admin/converters/SMF.php

    r5539 r5544  
    678678        $count = absint( (int) $count - 1 );
    679679        return $count;
    680     }
    681 
    682     /**
    683      * Check the anonymous topic or reply status
    684      *
    685      * @since  (r5539)
    686      *
    687      * @param int $status SMF v2.x anonymous topic/reply status
    688      * @return string WordPress safe
    689      */
    690     public function callback_check_anonymous( $status = 0 ) {
    691         if ( $status == 0 ) {
    692             $status = 'true';
    693         } else {
    694             $status = 'false';
    695         }
    696         return $status;
    697680    }
    698681
  • trunk/src/includes/admin/converters/Vanilla.php

    r5542 r5544  
    576576        $count = absint( (int) $count - 1 );
    577577        return $count;
    578     }
    579 
    580     /**
    581      * Check the anonymous topic or reply status.
    582      *
    583      * This method checks each imported topic or reply if the author user ID
    584      * was imported to determine if the topic or reply author is anonymous as
    585      * Vanilla v2.x does not store a topic or reply status for deleted users.
    586      *
    587      * @since  (r5541)
    588      *
    589      * @param string $is_user_anonymous Vanilla v2.x numeric topic status
    590      * @return string WordPress safe
    591      */
    592     public function callback_check_anonymous( $is_user_anonymous = 0 ) {
    593         if ( !empty( $this->sync_table ) ) {
    594             $row = $this->wpdb->get_row( $this->wpdb->prepare( 'SELECT meta_value FROM ' . $this->sync_table_name . ' WHERE meta_key = "_bbp_old_user_id" AND meta_value = "%d" LIMIT 1', $is_user_anonymous ) );
    595         } else {
    596             $row = $this->wpdb->get_row( $this->wpdb->prepare( 'SELECT meta_value FROM ' . $this->wpdb->usermeta .  ' WHERE meta_key = "_bbp_old_user_id" AND meta_value = "%d" LIMIT 1', $is_user_anonymous ) );
    597         }
    598 
    599         // An imported user ID exists therefore the topic/reply is not anonymous
    600         if ( !is_null( $row ) ) {
    601             $is_user_anonymous = 'false';
    602         // No imported user ID there the topic/reply is anonymous
    603         } else {
    604             $is_user_anonymous = 'true';
    605         }
    606 
    607         return $is_user_anonymous;
    608578    }
    609579
  • trunk/src/includes/admin/converters/phpBB.php

    r5539 r5544  
    826826
    827827    /**
    828      * Check the anonymous topic or reply status
    829      *
    830      * @since  (r5539)
    831      *
    832      * @param int $status phpBB v3.x anonymous topic/reply status
    833      * @return string WordPress safe
    834      */
    835     public function callback_check_anonymous( $status = 0 ) {
    836         if ( $status == 1 ) {
    837             $status = 'true';
    838         } else {
    839             $status = 'false';
    840         }
    841         return $status;
    842     }
    843 
    844     /**
    845828     * This callback processes any custom parser.php attributes and custom code with preg_replace
    846829     */
Note: See TracChangeset for help on using the changeset viewer.