Example #1
0
function bebop_init()
{
    load_plugin_textdomain('bebop', false, basename(dirname(__FILE__)) . '/languages');
    //include files from core. (also edit in import.php/secondary_import.php)
    include_once 'core/bebop-oauth.php';
    include_once 'core/bebop-tables.php';
    include_once 'core/bebop-filters.php';
    include_once 'core/bebop-extensions.php';
    include_once 'core/bebop-feeds.php';
    include_once 'core/bebop-pages.php';
    if (current_user_can('manage_options') && is_admin()) {
        include_once 'core/bebop-core-admin.php';
    }
    include_once 'core/bebop-core.php';
    //Plugin activation/deactivation hooks do not fire on plugin update, so check the current DB version and update as necessary.
    $db_version = bebop_tables::get_option_value('bebop_db_version');
    if (empty($db_version) || $db_version != '1.3.1') {
        include_once 'core/bebop-activate.php';
    }
    //fire crons
    add_action('bebop_main_import_cron', 'bebop_main_import_function');
    add_action('bebop_secondary_import_cron', 'bebop_secondary_import_function');
    //Adds the schedule filter for changing the standard interval time.
    add_filter('cron_schedules', 'bebop_main_cron_schedule');
    add_filter('cron_schedules', 'bebop_secondary_cron_schedule');
    //main cron
    if (!wp_next_scheduled('bebop_main_import_cron')) {
        wp_schedule_event(time(), 'bebop_main_cron_time', 'bebop_main_import_cron');
    }
    //secondary cron
    if (!wp_next_scheduled('bebop_secondary_import_cron')) {
        wp_schedule_event(time(), 'bebop_secondary_cron_time', 'bebop_secondary_import_cron');
    }
    //hook in any 3rd party extensions to this hook.
    do_action('bebop_loaded');
    //load all the extensions.
    bebop_extensions::bebop_load_extensions();
}
function bebop_extension_admin_update_settings()
{
    if (!empty($_GET['page'])) {
        $current_page = $_GET['page'];
        if (!empty($_GET['provider'])) {
            if ($current_page == 'bebop_providers') {
                $extension = bebop_extensions::bebop_get_extension_config_by_name(strtolower($_GET['provider']));
                if (isset($_POST['submit'])) {
                    check_admin_referer('bebop_' . $extension['name'] . '_admin_settings');
                    $success = true;
                    if (isset($_POST['bebop_' . $extension['name'] . '_consumer_key'])) {
                        bebop_tables::update_option('bebop_' . $extension['name'] . '_consumer_key', trim($_POST['bebop_' . $extension['name'] . '_consumer_key']));
                    }
                    if (isset($_POST['bebop_' . $extension['name'] . '_consumer_secret'])) {
                        bebop_tables::update_option('bebop_' . $extension['name'] . '_consumer_secret', trim($_POST['bebop_' . $extension['name'] . '_consumer_secret']));
                    }
                    if (isset($_POST['bebop_' . $extension['name'] . '_content_user_verification'])) {
                        bebop_tables::update_option('bebop_' . $extension['name'] . '_content_user_verification', trim(strip_tags(strtolower($_POST['bebop_' . $extension['name'] . '_content_user_verification']))));
                    }
                    if (isset($_POST['bebop_' . $extension['name'] . '_hide_sitewide'])) {
                        bebop_tables::update_option('bebop_' . $extension['name'] . '_hide_sitewide', trim(strip_tags(strtolower($_POST['bebop_' . $extension['name'] . '_hide_sitewide']))));
                    }
                    if (isset($_POST['bebop_' . $extension['name'] . '_maximport'])) {
                        if (empty($_POST['bebop_' . $extension['name'] . '_maximport']) || is_numeric($_POST['bebop_' . $extension['name'] . '_maximport'])) {
                            bebop_tables::update_option('bebop_' . $extension['name'] . '_maximport', trim($_POST['bebop_' . $extension['name'] . '_maximport']));
                        } else {
                            $success = __('"Imports per day" must be a number (or blank).', 'bebop');
                        }
                    }
                    /*rss stuff, dont touch */
                    if (isset($_POST['bebop_' . $extension['name'] . '_rss_feed'])) {
                        if (bebop_tables::get_option_value('bebop_' . $extension['name'] . '_provider') == 'on') {
                            bebop_tables::update_option('bebop_' . $extension['name'] . '_rss_feed', trim($_POST['bebop_' . $extension['name'] . '_rss_feed']));
                        } else {
                            $success = __('RSS feeds cannot be enabled while the extension is inactive.', 'bebop');
                        }
                    } else {
                        bebop_tables::update_option('bebop_' . $extension['name'] . '_rss_feed', '');
                    }
                    //Extension authors: use this hook to add your own admin data saves.
                    do_action('bebop_admin_settings_pre_save', $extension, $success);
                    $_SESSION['bebop_admin_notice'] = $success;
                    wp_safe_redirect(wp_get_referer());
                }
                /*
                 * Mechanics to remove a user from your extension is already provided - you do not need to modify this.
                 */
                if (isset($_GET['reset_user_id'])) {
                    $user_id = trim($_GET['reset_user_id']);
                    bebop_tables::remove_user_from_provider($user_id, $extension['name']);
                    $success = __('User has been removed', 'bebop');
                    $_SESSION['bebop_admin_notice'] = $success;
                    wp_safe_redirect(wp_get_referer());
                    exit;
                }
            }
            // End if ( $current_page == 'bebop_providers' ) {
        }
        //End if ( ! empty( $_GET['provider'] ) ) {
    }
    //End if ( ! empty( $_GET['page']) ) {
}
Example #3
0
 * for the extension. Removing/changing any of the pre defined functions will cause import errors,	*
 * and possible other unexpected or unwanted behaviour.												*
 * For information on bebop_tables:: functions, please see bebop/core/bebop-tables.php				*
 * **************************************************************************************************
 */
global $bp;
/*
 * '$extension' controls content on this page and is set to whatever admin-settings.php file is being viewed.
 * i.e. if you extension name is 'my_extension', the value of $extension will be 'my_extension'.
 * The extension has to exist if this page is being included.
 */
$query_string = bp_action_variables();
if (!empty($query_string)) {
    $provider = $query_string[0];
}
$extension = bebop_extensions::bebop_get_extension_config_by_name(strtolower($provider));
//put some options into variables
$active = 'bebop_' . $extension['name'] . '_active_for_user';
//the active boolean name
${$active} = bebop_tables::get_user_meta_value($bp->loggedin_user->id, 'bebop_' . $extension['name'] . '_active_for_user');
//the value of the boolean
if (bebop_tables::get_option_value('bebop_' . $extension['name'] . '_provider') == 'on') {
    echo '<h5>' . sprintf(__('%1$s Settings', 'bebop'), $extension['display_name']) . '</h5>
	<p>' . sprintf(__('Generic settings for %1$s. Here you can select whether content is actively imported into WordPress.', 'bebop'), $extension['display_name']) . '</p>';
    echo '<form id="settings_form" action="' . $bp->loggedin_user->domain . bp_current_component() . '/' . bp_current_action() . '/' . $extension['name'] . '" method="post">';
    echo '<label>' . sprintf(__('Enable %1$s import', 'bebop'), $extension['display_name']) . ':</label>
	<input type="radio" name="bebop_' . $extension['name'] . '_active_for_user" id="bebop_' . $extension['name'] . '_active_for_user" value="1"';
    if (${$active} == 1) {
        echo 'checked';
    }
    echo '>
Example #4
0
function bebop_rss_buttons()
{
    global $bp;
    $count = 0;
    $rss_active_extensions = array();
    $extensions = bebop_extensions::bebop_get_active_extension_names();
    $user = $bp->displayed_user->userdata;
    echo '<div class="rss_feed_container">';
    foreach ($extensions as $extension) {
        if (bebop_tables::get_option_value('bebop_' . $extension . '_rss_feed') == 'on') {
            $extension = bebop_extensions::bebop_get_extension_config_by_name(strtolower($extension));
            if (bebop_tables::get_user_meta_value($user->ID, 'bebop_' . $extension['name'] . '_active_for_user') == 1) {
                echo '<a class="button bp-secondary-action" href="' . get_bloginfo('url') . '/' . bp_get_members_slug() . '/' . $user->user_nicename . '/' . bp_get_activity_slug() . '/' . $extension['name'] . '"><img style="vertical-align: text-top;"' . 'src="' . plugins_url() . '/bebop/core/resources/images/feed_14px.png"> ' . $extension['display_name'] . '</a>';
                $count++;
            }
        }
    }
    if ($count >= 2) {
        echo ' <a class="button bp-secondary-action" href="' . get_bloginfo('url') . '/' . bp_get_members_slug() . '/' . $user->user_nicename . '/' . bp_get_activity_slug() . '/all_oers"><img style="vertical-align: text-top;"' . 'src="' . plugins_url() . '/bebop/core/resources/images/feed_14px.png"> All</a>';
    }
    echo '</div>';
}
Example #5
0
function bebop_facebook_import($extension, $user_metas = null)
{
    global $wpdb, $bp;
    if (empty($extension)) {
        bebop_tables::log_general('Importer', 'The $extension parameter is empty.');
        return false;
    } else {
        if (!bebop_tables::check_option_exists('bebop_' . $extension . '_consumer_key')) {
            bebop_tables::log_general('Importer', 'No consumer key was found for ' . $extension);
            return false;
        } else {
            $this_extension = bebop_extensions::bebop_get_extension_config_by_name($extension);
        }
    }
    //item counter for in the logs
    $itemCounter = 0;
    //if no user_metas are supplied, serarch for them.
    if (!isset($user_metas)) {
        $user_metas = bebop_tables::get_user_ids_from_meta_name('bebop_' . $this_extension['name'] . '_oauth_token');
    }
    if (isset($user_metas)) {
        foreach ($user_metas as $user_meta) {
            $errors = null;
            $items = null;
            //Ensure the user is currently wanting to import items.
            if (bebop_tables::get_user_meta_value($user_meta->user_id, 'bebop_' . $this_extension['name'] . '_active_for_user') == 1) {
                //if it is the first import, update the flag.
                if (bebop_tables::check_for_first_import($user_meta->user_id, $this_extension['name'], 'bebop_' . $this_extension['name'] . '_do_initial_import')) {
                    bebop_tables::delete_from_first_importers($user_meta->user_id, $this_extension['name'], 'bebop_' . $this_extension['name'] . '_do_initial_import');
                }
                /* 
                 * ******************************************************************************************************************
                 * Depending on the data source, you will need to switch how the data is retrieved. If the feed is RSS, use the 	*
                 * SimplePie method, as shown in the youtube extension. If the feed is oAuth API based, use the oAuth implementation*
                 * as shown in the twitter extension. If the feed is an API without oAuth authentication, use SlideShare			*
                 * ******************************************************************************************************************
                 */
                $data_request = new bebop_data();
                $params = array('limit' => '30', 'access_token' => bebop_tables::get_user_meta_value($user_meta->user_id, 'bebop_' . $this_extension['name'] . '_oauth_token'));
                $data = $data_request->execute_request($this_extension['data_feed'], $params);
                $items = json_decode($data);
                /* 
                 * ******************************************************************************************************************
                 * We can get as far as loading the items, but you will need to adjust the values of the variables below to match 	*
                 * the values from the extension's API.																				*
                 * This is because each API return data under different parameter names, and the simplest way to get around this is *
                 * to quickly match the values. To find out what values you should be using, consult the provider's documentation.	*
                 * You can also contact us if you get stuck - details are in the 'support' section of the admin homepage.			*
                 * ******************************************************************************************************************
                 * 
                 * Values you will need to check and update are:
                 *		$errors 				- Must point to the error boolean value (true/false)
                 *		$username				- Must point to the value holding the username of the person.
                 *		$id						- Must be the ID of the item returned through the data API.
                 *		$item_content			- The actual content of the imported item.
                 *		$item_published			- The time the item was published.
                 *		$action_link			- This is where the link will point to - i.e. where the user can click to get more info.
                 */
                //Edit the following two variables to point to where the relevant content is being stored in the API:
                if (isset($items->error)) {
                    bebop_tables::log_error(sprintf(__('Importer - %1$s', 'bebop'), $this_extension['display_name']), sprintf(__('Feed Error: %1$s', 'bebop'), serialize($data->error)));
                } else {
                    if (!bebop_tables::check_user_meta_exists($user_meta->user_id, 'bebop_' . $this_extension['name'] . '_username')) {
                        $get_username = true;
                    } else {
                        $get_username = false;
                        $username = bebop_tables::get_user_meta_value($user_meta->user_id, 'bebop_' . $this_extension['name'] . '_username');
                    }
                    if ($items) {
                        foreach ($items->data as $item) {
                            //if its a story, break as we only want wall posts, not comments.
                            if (isset($item->message)) {
                                //if the username doesnt exist, add it.
                                if ($get_username == true) {
                                    $this_user_id = substr($item->id, 0, strpos($item->id, '_'));
                                    $user_query_data = $data_request->execute_request($this_extension['people_data'] . $this_user_id);
                                    $user = json_decode($user_query_data);
                                    $username = $user->name;
                                    bebop_tables::update_user_meta($user_meta->user_id, $this_extension['name'], 'bebop_' . $this_extension['name'] . '_username', $username);
                                    $get_username = false;
                                }
                                if (!bebop_filters::import_limit_reached($this_extension['name'], $user_meta->user_id, $username)) {
                                    //Edit the following three variables to point to where the relevant content is being stored:
                                    $id = $item->id;
                                    $item_content = $item->message;
                                    $item_published = gmdate('Y-m-d H:i:s', strtotime($item->created_time));
                                    if (isset($item->actions[0]->link)) {
                                        $action_link = $item->actions[0]->link;
                                    } else {
                                        if (isset($item->link)) {
                                            $action_link = $item->link;
                                        }
                                    }
                                    //Stop editing - you should be all done.
                                    //generate an $item_id
                                    $item_id = bebop_generate_secondary_id($user_meta->user_id, $id, $item_published);
                                    //if the id is not found, import the content.
                                    if (!bebop_tables::check_existing_content_id($user_meta->user_id, $this_extension['name'], $item_id)) {
                                        if (bebop_create_buffer_item(array('user_id' => $user_meta->user_id, 'extension' => $this_extension['name'], 'type' => $this_extension['content_type'], 'username' => $username, 'content' => $item_content, 'content_oembed' => $this_extension['content_oembed'], 'item_id' => $item_id, 'raw_date' => $item_published, 'actionlink' => $action_link))) {
                                            $itemCounter++;
                                        }
                                    }
                                }
                            }
                            //End if ( isset( $item->message ) ) {
                            unset($item);
                        }
                    }
                }
                //End else
                unset($user_meta);
            }
        }
    }
    //return the result
    return $itemCounter . ' ' . $this_extension['content_type'] . 's';
}
Example #6
0
function bebop_flickr_import($extension, $user_metas = null)
{
    global $wpdb, $bp;
    $itemCounter = 0;
    if (empty($extension)) {
        bebop_tables::log_general('Importer', 'The $extension parameter is empty.');
        return false;
    } else {
        if (!bebop_tables::check_option_exists('bebop_' . $extension . '_consumer_key')) {
            bebop_tables::log_general('Importer', 'No consumer key was found for ' . $extension);
            return false;
        } else {
            $this_extension = bebop_extensions::bebop_get_extension_config_by_name($extension);
        }
    }
    //if user_metas is not defined, get some user meta.
    if (!isset($user_metas)) {
        $user_metas = bebop_tables::get_user_ids_from_meta_type($this_extension['name']);
    } else {
        $secondary_importers = true;
    }
    if (isset($user_metas)) {
        foreach ($user_metas as $user_meta) {
            //Ensure the user is currently wanting to import items.
            if (bebop_tables::get_user_meta_value($user_meta->user_id, 'bebop_' . $this_extension['name'] . '_active_for_user') == 1) {
                if (isset($secondary_importers) && $secondary_importers === true) {
                    $user_feeds = bebop_tables::get_initial_import_feeds($user_meta->user_id, $this_extension['name']);
                } else {
                    $user_feeds = bebop_tables::get_user_feeds($user_meta->user_id, $this_extension['name']);
                }
                foreach ($user_feeds as $user_feed) {
                    $errors = null;
                    $items = null;
                    //extract the username as appropriate
                    if (isset($secondary_importers) && $secondary_importers === true) {
                        $username = $user_feed;
                    } else {
                        $username = $user_feed->meta_value;
                    }
                    $import_username = str_replace(' ', '_', $username);
                    //Check the user has not gone past their import limit for the day.
                    if (!bebop_filters::import_limit_reached($this_extension['name'], $user_meta->user_id, $import_username)) {
                        if (bebop_tables::check_for_first_import($user_meta->user_id, $this_extension['name'], 'bebop_' . $this_extension['name'] . '_' . $import_username . '_do_initial_import')) {
                            bebop_tables::delete_from_first_importers($user_meta->user_id, $this_extension['name'], 'bebop_' . $this_extension['name'] . '_' . $import_username . '_do_initial_import');
                        }
                        /* 
                         * ******************************************************************************************************************
                         * Depending on the data source, you will need to switch how the data is retrieved. If the feed is RSS, use the 	*
                         * SimplePie method, as shown in the youtube extension. If the feed is oAuth API based, use the oAuth implementation*
                         * as shown in the twitter extension. If the feed is an API without oAuth authentication, use SlideShare			*
                         * ******************************************************************************************************************
                         */
                        //We are not using oauth for flickr - so just build the api request and send it using our bebop-data class.
                        //If you are using a service that uses oAuth, then use the oAuth class and set the paramaters required for the request.
                        //These are custom for flickr - edit these to match the paremeters required by the API.
                        $data_request = new bebop_data();
                        //send a request to see if we have a username or a user_id.
                        $params = array('method' => 'flickr.people.getPublicPhotos', 'api_key' => bebop_tables::get_option_value('bebop_' . $this_extension['name'] . '_consumer_key'), 'user_id' => $username, 'extras' => 'date_upload,url_m,url_t,description');
                        $data = $data_request->execute_request($this_extension['data_feed'], $params);
                        $data = simplexml_load_string($data);
                        //if the previous request failed. we have a username not a user_id.
                        if (empty($data->photos)) {
                            //Go and get the user_id
                            $params = array('method' => 'flickr.urls.lookupuser', 'api_key' => bebop_tables::get_option_value('bebop_' . $this_extension['name'] . '_consumer_key'), 'url' => 'http://www.flickr.com/photos/' . $username);
                            $data = $data_request->execute_request($this_extension['data_feed'], $params);
                            $data = simplexml_load_string($data);
                            //retry the request
                            $params = array('method' => 'flickr.people.getPublicPhotos', 'api_key' => bebop_tables::get_option_value('bebop_' . $this_extension['name'] . '_consumer_key'), 'user_id' => urldecode($data->user['id']), 'extras' => 'date_upload,url_m,url_t,description');
                            $data = $data_request->execute_request($this_extension['data_feed'], $params);
                            $data = simplexml_load_string($data);
                        }
                        /* 
                         * ******************************************************************************************************************
                         * We can get as far as loading the items, but you will need to adjust the values of the variables below to match 	*
                         * the values from the extension's feed.																			*
                         * This is because each feed return data under different parameter names, and the simplest way to get around this is*
                         * to quickly match the values. To find out what values you should be using, consult the provider's documentation.	*
                         * You can also contact us if you get stuck - details are in the 'support' section of the admin homepage.			*
                         * ******************************************************************************************************************
                         * 
                         * Values you will need to check and update are:
                         * 		$items					- Must point to the items that will be imported into the plugin.
                         * 		$id						- Must be the ID of the item returned through the data feed.
                         * 		$description			- The actual content of the imported item.
                         * 		$item_published			- The time the item was published.
                         * 		$action_link			- This is where the link will point to - i.e. where the user can click to get more info.
                         */
                        //Edit the following variable to point to where the relevant content is being stored in the :
                        $items = $data->photos->photo;
                        if (!empty($items)) {
                            foreach ($items as $item) {
                                if (!bebop_filters::import_limit_reached($this_extension['name'], $user_meta->user_id, $import_username)) {
                                    //Edit the following variables to point to where the relevant content is being stored:
                                    $id = $item['id'];
                                    $action_link = $this_extension['action_link'] . $item['owner'] . '/' . $id;
                                    $description = $item['description'];
                                    $item_published = gmdate('Y-m-d H:i:s', (int) $item['dateupload']);
                                    //Stop editing - you should be all done.
                                    //generate an $item_id
                                    $item_id = bebop_generate_secondary_id($user_meta->user_id, $id, $item_published);
                                    //if the id is not found, import the content.
                                    if (!bebop_tables::check_existing_content_id($user_meta->user_id, $this_extension['name'], $item_id)) {
                                        //Only for content which has a description.
                                        if (!empty($description)) {
                                            //This manually puts the link and description together with a line break, which is needed for oembed.
                                            $item_content = $action_link . '
											' . $description;
                                        } else {
                                            $item_content = $action_link;
                                        }
                                        if (bebop_create_buffer_item(array('user_id' => $user_meta->user_id, 'extension' => $this_extension['name'], 'type' => $this_extension['content_type'], 'username' => $import_username, 'content' => $item_content, 'content_oembed' => $this_extension['content_oembed'], 'item_id' => $item_id, 'raw_date' => $item_published, 'actionlink' => $action_link . '/lightbox'))) {
                                            $itemCounter++;
                                        }
                                    }
                                    //End if ( ! empty( $secondary->secondary_item_id ) ) {
                                }
                                unset($item);
                            }
                        }
                    }
                    //End if ( ! bebop_filters::import_limit_reached( $this_extension['name'], $user_meta->user_id, $import_username ) ) {
                }
                //End foreach ($user_feeds as $user_feed ) {
            }
            unset($user_meta);
        }
    }
    //return the result
    return $itemCounter . ' ' . $this_extension['content_type'] . 's';
}
Example #7
0
function bebop_user_settings()
{
    bebop_extensions::bebop_user_page_loader('default', 'settings');
}
Example #8
0
function bebop_rss_import($extension, $user_metas = null)
{
    global $wpdb, $bp;
    $itemCounter = 0;
    if (empty($extension)) {
        bebop_tables::log_general('Importer', 'The $extension parameter is empty.');
        return false;
    } else {
        $this_extension = bebop_extensions::bebop_get_extension_config_by_name($extension);
    }
    require_once ABSPATH . WPINC . '/class-feed.php';
    //if user_metas is not defined, get some user meta.
    if (!isset($user_metas)) {
        $user_metas = bebop_tables::get_user_ids_from_meta_type($this_extension['name']);
    } else {
        $secondary_importers = true;
    }
    if (isset($user_metas)) {
        foreach ($user_metas as $user_meta) {
            //Ensure the user is wanting to import items.
            if (bebop_tables::get_user_meta_value($user_meta->user_id, 'bebop_' . $this_extension['name'] . '_active_for_user')) {
                if (isset($secondary_importers) && $secondary_importers === true) {
                    $feeds = bebop_tables::get_initial_import_feeds($user_meta->user_id, $this_extension['name']);
                    $user_feeds = bebop_tables::get_user_feeds_from_array($user_meta->user_id, $this_extension['name'], $feeds);
                } else {
                    $user_feeds = bebop_tables::get_user_feeds($user_meta->user_id, $this_extension['name']);
                }
                foreach ($user_feeds as $user_feed) {
                    $errors = null;
                    $items = null;
                    $feed_name = $user_feed->meta_name;
                    $feed_url = $user_feed->meta_value;
                    $import_username = stripslashes($feed_name);
                    //Check the user has not gone past their import limit for the day.
                    if (!bebop_filters::import_limit_reached($this_extension['name'], $user_meta->user_id, $import_username)) {
                        if (bebop_tables::check_for_first_import($user_meta->user_id, $this_extension['name'], 'bebop_' . $this_extension['name'] . '_' . $import_username . '_do_initial_import')) {
                            bebop_tables::delete_from_first_importers($user_meta->user_id, $this_extension['name'], 'bebop_' . $this_extension['name'] . '_' . $import_username . '_do_initial_import');
                        }
                        /* 
                         * ******************************************************************************************************************
                         * Depending on the data source, you will need to switch how the data is retrieved. If the feed is RSS, use the 	*
                         * SimplePie method, as shown in the youtube extension. If the feed is oAuth API based, use the oAuth implementation*
                         * as shown in the twitter extension. If the feed is an API without oAuth authentication, use SlideShare			*
                         * ******************************************************************************************************************
                         */
                        //import the url
                        //Configure the feed
                        $feed = new SimplePie();
                        $feed->set_feed_url($feed_url);
                        $feed->set_cache_class('WP_Feed_Cache');
                        $feed->set_file_class('WP_SimplePie_File');
                        $feed->enable_cache(false);
                        $feed->set_cache_duration(0);
                        do_action_ref_array('wp_feed_options', array($feed, $feed_url));
                        $feed->init();
                        $feed->handle_content_type();
                        /* 
                         * ******************************************************************************************************************
                         * We can get as far as loading the items, but you will need to adjust the values of the variables below to match 	*
                         * the values from the extension's feed.																			*
                         * This is because each feed return data under different parameter names, and the simplest way to get around this is*
                         * to quickly match the values. To find out what values you should be using, consult the provider's documentation.	*
                         * You can also contact us if you get stuck - details are in the 'support' section of the admin homepage.			*
                         * ******************************************************************************************************************
                         * 
                         * Values you will need to check and update are:
                         * 		$errors 				- Must point to the error boolean value (true/false)
                         * 		$id						- Must be the ID of the item returned through the data feed.
                         * 		$description			- The actual content of the imported item.
                         * 		$item_published			- The time the item was published.
                         * 		$action_link			- This is where the link will point to - i.e. where the user can click to get more info.
                         */
                        //Edit the following variables to point to where the relevant content is being stored in the feed:
                        $errors = $feed->error;
                        if (!$errors) {
                            //Edit the following variable to point to where the relevant content is being stored in the feed:
                            $items = $feed->get_items();
                            if ($items) {
                                foreach ($items as $item) {
                                    if (!bebop_filters::import_limit_reached($this_extension['name'], $user_meta->user_id, $import_username)) {
                                        //Edit the following variables to point to where the relevant content is being stored:
                                        //$description	= $item->get_content();
                                        $item_published = date('Y-m-d H:i:s', strtotime($item->get_date()));
                                        $title = $item->get_title();
                                        $action_link = $item->get_permalink();
                                        $id_array = array_reverse(explode('/', $action_link));
                                        $id = $id_array[1];
                                        //Stop editing - you should be all done.
                                        //generate an $item_id
                                        $item_id = bebop_generate_secondary_id($user_meta->user_id, $id, $item_published);
                                        //if the id is not found, import the content.
                                        if (!bebop_tables::check_existing_content_id($user_meta->user_id, $this_extension['name'], $item_id)) {
                                            $item_content = $title . '
											' . $action_link;
                                            if (bebop_create_buffer_item(array('user_id' => $user_meta->user_id, 'extension' => $this_extension['name'], 'type' => $this_extension['content_type'], 'username' => $import_username, 'content' => $item_content, 'content_oembed' => $this_extension['content_oembed'], 'item_id' => $item_id, 'raw_date' => $item_published, 'actionlink' => $action_link))) {
                                                $itemCounter++;
                                            }
                                        }
                                        //End if ( ! empty( $secondary->secondary_item_id ) ) {
                                    }
                                    unset($item);
                                }
                            }
                        } else {
                            bebop_tables::log_error(sprintf(__('Importer - %1$s', 'bebop'), $this_extension['display_name']), sprintf(__('RSS Error: %1$s', 'bebop'), $errors));
                        }
                    }
                }
                //End foreach ($user_feeds as $user_feed ) {
                unset($user_meta);
            }
        }
    }
    //return the result
    return $itemCounter . ' ' . $this_extension['content_type'] . 's';
}
Example #9
0
ini_set('include_path', $inc_path);
include_once 'wp-load.php';
//include files from core.
include_once 'core/bebop-data.php';
include_once 'core/bebop-oauth.php';
include_once 'core/bebop-tables.php';
include_once 'core/bebop-filters.php';
include_once 'core/bebop-pages.php';
include_once 'core/bebop-extensions.php';
//Main content file
include_once 'core/bebop-core.php';
//if import a specific OER.
if (isset($_GET['extension'])) {
    $importers[] = $_GET['extension'];
} else {
    $importers = bebop_extensions::bebop_get_active_extension_names();
}
//Check that the importers queue isn't empty, then start calling the import functions
if (!empty($importers[0])) {
    bebop_tables::log_general(__('Main Importer', 'bebop'), __('Main importer service started.', 'bebop'));
    $return_array = array();
    foreach ($importers as $extension) {
        if (bebop_tables::get_option_value('bebop_' . strtolower($extension) . '_provider') == 'on') {
            if (file_exists(WP_PLUGIN_DIR . '/bebop/extensions/' . strtolower($extension) . '/import.php')) {
                include_once WP_PLUGIN_DIR . '/bebop/extensions/' . strtolower($extension) . '/import.php';
                if (function_exists('bebop_' . strtolower($extension) . '_import')) {
                    $return_array[] = call_user_func('bebop_' . strtolower($extension) . '_import', strtolower($extension));
                } else {
                    bebop_tables::log_error(__('Main Importer', 'bebop'), sprintf(__('The function: bebop_%1$s_import does not exist.', 'bebop'), strtolower($extension)));
                }
            } else {
Example #10
0
			</thead>
			<tfoot>
				<tr>
					<th>' . __('Buffer ID', 'bebop') . '</th>
					<th>' . __('Secondary ID', 'bebop') . '</th>
					<th>' . __('Activity Stream ID', 'bebop') . '</th>
					<th>' . __('Username', 'bebop') . '</th>
					<th>' . __('Type', 'bebop') . '</th>
					<th>' . __('Imported', 'bebop') . '</th>
					<th>' . __('Published', 'bebop') . '</th>
					<th>' . __('Content', 'bebop') . '</th>
				</tr>
			</tfoot>
			<tbody>';
    foreach ($contents as $content) {
        $extension = bebop_extensions::bebop_get_extension_config_by_name($content->type);
        echo '<tr>
					<td>' . $content->id . '</td>' . '<td>' . $content->secondary_item_id . '</td>' . '<td>' . $content->activity_stream_id . '</td>' . '<td>' . bp_core_get_username($content->user_id) . '</td>' . '<td>' . bebop_tables::sanitise_element($extension['display_name']) . '</td>' . '<td>' . bp_core_time_since($content->date_imported) . '</td>' . '<td>' . bp_core_time_since($content->date_recorded) . '</td>' . '<td class="content">' . bebop_tables::sanitise_element($content->content) . '</td>' . '</tr>';
    }
    echo '
			</tbody>
		</table>';
    echo $bebop_pagination;
} else {
    echo '<h4>' . ucfirst($type) . ' ' . __('Content', 'bebop') . '</h4>';
    echo '<p>' . __('No content was found in the content manager.', 'bebop') . '</p>';
}
?>
	<div class="clear"></div>
</div>
<!-- end bebop_admin_container -->
    ?>
</th>
						<th colspan=><?php 
    _e('Deleted Content', 'bebop');
    ?>
</th>
						<th colspan='2'><?php 
    _e('Options', 'bebop');
    ?>
</th>
					</tr>
				</tfoot>
				<tbody>
				<?php 
    //loop throught extensions directory and get all extensions
    foreach (bebop_extensions::bebop_get_extension_configs() as $extension) {
        echo '<tr>
						<td>' . $extension['display_name'] . '</td>
						<td>' . bebop_tables::count_users_using_extension($extension['name'], 1) . '</td>
						<td>' . bebop_tables::count_users_using_extension($extension['name'], 0) . '</td>
						<td><a href="?page=bebop_content&type=unverified">' . bebop_tables::count_content_by_extension($extension['name'], 'unverified') . '</a></td>
						<td><a href="?page=bebop_content&type=verified">' . bebop_tables::count_content_by_extension($extension['name'], 'verified') . '</a></td>
						<td><a href="?page=bebop_content&type=deleted">' . bebop_tables::count_content_by_extension($extension['name'], 'deleted') . '</a></td>
						<td>';
        echo "<label class='alt' for='bebop_" . $extension['name'] . "_provider'>";
        _e('Enabled:', 'bebop');
        echo "</label><input id='bebop_" . $extension['name'] . "_provider' name='bebop_" . $extension['name'] . "_provider' type='checkbox'";
        if (bebop_tables::get_option_value('bebop_' . $extension['name'] . '_provider') == 'on') {
            echo 'CHECKED';
        }
        echo '></td>
Example #12
0
function bebop_get_activity_args()
{
    global $bp, $this_bp_feed;
    //get the count limit
    $action_variables = bp_action_variables();
    $standard_limit = 40;
    $max_limit = 500;
    if ($action_variables[0] == 'feed') {
        if (isset($action_variables[1])) {
            if (is_numeric($action_variables[1])) {
                if ($action_variables[1] <= $max_limit) {
                    $limit = $action_variables[1];
                } else {
                    $limit = $max_limit;
                }
            }
        }
    }
    if (!isset($limit)) {
        $limit = $standard_limit;
    }
    if (!empty($this_bp_feed)) {
        if ($this_bp_feed == 'all_oers') {
            //only want to import active feeds
            $import_feeds = array();
            $active_extensions = bebop_extensions::bebop_get_active_extension_names();
            foreach ($active_extensions as $extension) {
                if (bebop_tables::check_option_exists('bebop_' . $extension . '_rss_feed')) {
                    if (bebop_tables::get_option_value('bebop_' . $extension . '_rss_feed') == 'on') {
                        $import_feeds[] = $extension;
                    }
                }
            }
            if (!empty($import_feeds)) {
                if (count($import_feeds) >= 2) {
                    $query_feeds = implode(',', $import_feeds);
                } else {
                    $query_feeds = $import_feeds[0];
                }
                return 'user_id=' . bp_displayed_user_id() . '&object=bebop_oer_plugin&action=' . $query_feeds . '&per_page=' . $limit . '&max=' . $limit . '&show_hidden=true&display_comments=stream';
            }
        }
        return 'user_id=' . bp_displayed_user_id() . '&object=bebop_oer_plugin&action=' . $this_bp_feed . '&per_page=' . $limit . '&max=' . $limit . '&show_hidden=true&display_comments=stream';
    } else {
        return false;
    }
}
 function bebop_page_loader($extension)
 {
     $extension_name = strtolower($extension);
     $extension_path = bebop_extensions::bebop_get_extension_path_from_name($extension_name);
     if (file_exists($extension_path . 'config.php')) {
         if (!function_exists('get_' . $extension_name . '_config')) {
             require $extension_path . 'config.php';
         }
         $config = call_user_func('get_' . $extension_name . '_config');
         if (!isset($_GET['settings'])) {
             $page = strtolower($config['defaultpage']);
         } else {
             $page = strtolower($_GET['settings']);
         }
         include $extension_path . 'templates/admin-settings.php';
     } else {
         echo '<div class="bebop_error_box"><b>' . __('Bebop Error', 'bebop') . ':</b> ' . sprintf(__('%1$s is not a valid extension.', 'bebop'), $extension_name) . '</div>';
         include_once WP_PLUGIN_DIR . '/bebop/core/templates/admin/bebop-admin-menu.php';
     }
 }