loadL10n(); //create an istance of the main class for this situation bpModLoader::load_class('bpModeration'); $bpMod =& bpModeration::get_istance($mainclass); //load the default content types bpModLoader::load_class('bpModDefaultContentTypes'); bpModDefaultContentTypes::init($bpMod); do_action('bp_moderation_loaded', array(&$this)); do_action('bp_moderation_init', array(&$bpMod)); } /** * Load string translations * * will load the first translation found from: * - wp-content/plugins/bp-moderation-xx_XX.mo * - wp-content/plugins/bp-moderation/lang/bp-moderation-xx_XX.mo * * @return bool if a translation was found and loaded */ function loadL10n(){ return load_plugin_textdomain('bp-moderation') || load_plugin_textdomain('bp-moderation', false, plugin_basename(dirname(__FILE__)).'/lang'); } private function call_installer($method, $args = array()) { $this->loadL10n(); bpModLoader::load_class('bpModInstaller'); $installer = new bpModInstaller(); call_user_func_array(array($installer,$method), $args); } /** * activation callback */ function call_activate() { $this->call_installer('activate', func_get_args()); } /** * deactivation callback */ function call_deactivate() { $this->call_installer('deactivate', func_get_args()); } /** * load a class * * @param string $cname classname */ function load_class($cname) { if (class_exists($cname)) { return; } require_once dirname(__FILE__) . '/classes/' . $cname . '.php'; } /** * bpModLoader file path * * @return string this file path */ function file() { return __FILE__; } /** * generated random data */ function test_data() { set_time_limit(0); global $wpdb; $users = $wpdb->get_col("SELECT ID FROM $wpdb->users WHERE ID != 1"); if (is_multisite()) { $wpdb->query("DELETE FROM $wpdb->signups"); } foreach ($users as $id) { bp_core_delete_account($id); } $ngu = 2; #how much only good users $ngbu = 2; #how much not only good or only bad users $nbu = 2; #how much only bad users $content_types = array('A', 'B', 'C', 'D'); $bpmod =& bpModeration::get_istance(); $statuses = array_keys($bpmod->content_stati); $n_contents = 20; $flags_per_cont = 20; # +/- 30% $goodusers = array(); $badusers = array(); for ($i = 1; $i <= $ngu + $ngbu + $nbu; $i++) { $uid = bp_core_signup_user('user' . $i, 'pass', $i . '@foo.bar', array()); if (is_multisite()) { global $wpdb; $key_sql = "SELECT activation_key FROM $wpdb->signups WHERE user_email = '" . $i . "@foo.bar'"; $key = $wpdb->get_var($key_sql); } else { $key = get_user_meta($uid, 'activation_key'); } $uid = bp_core_activate_signup($key); is_multisite() and wp_set_password('pass', $uid); if ($i <= $ngu + $ngbu) { $goodusers[] = $uid; } if ($i > $ngu) { $badusers[] = $uid; } } bpModLoader::load_class('bpModObjContent'); bpModLoader::load_class('bpModObjFlag'); for ($i = 1; $i <= $n_contents; $i++) { $badu = $badusers[mt_rand(0, count($badusers) - 1)]; $cont = new bpModObjContent(); $cont->item_type = $content_types[mt_rand(0, count($content_types) - 1)]; $cont->item_id = mt_rand(1, 1000000); $cont->item_author = $badu; $cont->item_date = gmdate("Y-m-d H:i:s", time() - mt_rand(1000000, 2000000)); $cont->status = $statuses[mt_rand(0, count($statuses) - 1)]; $cont->save(); $flags = mt_rand($flags_per_cont * 0.7, $flags_per_cont * 1.3); for ($j = 1; $j <= $flags; $j++) { while ($badu == ($goodu = $goodusers[mt_rand(0, count($goodusers) - 1)])) { ; } $f = new bpModObjFlag(); $f->content_id = $cont->content_id; $f->reporter_id = $goodu; $f->date = gmdate("Y-m-d H:i:s", time() - mt_rand(0, 1000000)); $f->save(); } } update_site_option('bp_moderation_test_data_check', 'success'); } } ?>