예제 #1
0
function bebop_setup_user_nav()
{
    global $bp;
    $should_users_verify_content = bebop_tables::get_option_value('bebop_content_user_verification');
    //Shows in the profile all the time.
    bp_core_new_nav_item(array('name' => __('Resources', 'bebop'), 'slug' => 'bebop', 'position' => 30, 'show_for_displayed_user' => true, 'screen_function' => 'bebop_user_settings', 'default_subnav_slug' => 'bebop-content'));
    bp_core_new_subnav_item(array('name' => __('Content', 'bebop'), 'slug' => 'bebop-content', 'parent_url' => bp_displayed_user_domain() . 'bebop/', 'parent_slug' => 'bebop', 'screen_function' => 'bebop_user_settings', 'position' => 10));
    //only show if current user is the owner of the profile.
    if (bp_is_my_profile()) {
        if ($should_users_verify_content != 'no') {
            bp_core_new_subnav_item(array('name' => __('Content Manager', 'bebop'), 'slug' => 'bebop-manager', 'parent_url' => $bp->loggedin_user->domain . 'bebop/', 'parent_slug' => 'bebop', 'screen_function' => 'bebop_user_settings', 'position' => 20));
        }
        bp_core_new_subnav_item(array('name' => __('Accounts', 'bebop'), 'slug' => 'bebop-accounts', 'parent_url' => $bp->loggedin_user->domain . 'bebop/', 'parent_slug' => 'bebop', 'screen_function' => 'bebop_user_settings', 'position' => 20));
    }
}
예제 #2
0
 public function import_limit_reached($extension, $user_id, $username = null)
 {
     //different day ot no day set, set the day and the counter to 0;
     if (bebop_tables::get_user_meta_value($user_id, 'bebop_' . $extension . '_' . $username . '_counterdate') != date('dmy')) {
         bebop_tables::update_user_meta($user_id, $extension, 'bebop_' . $extension . '_' . $username . '_daycounter', '0');
         bebop_tables::update_user_meta($user_id, $extension, 'bebop_' . $extension . '_' . $username . '_counterdate', date('dmy'));
     }
     //max items per day * < should return false*
     $maximport_value = bebop_tables::get_option_value('bebop_' . $extension . '_maximport');
     if (empty($maximport_value) || $maximport_value === 0) {
         //its empty. no value is set (unlimited)
         return false;
     } else {
         if (is_numeric($maximport_value)) {
             //not empty but value is numeric
             if (bebop_tables::get_user_meta_value($user_id, 'bebop_' . $extension . '_' . $username . '_daycounter') < $maximport_value) {
                 return false;
             }
         }
     }
     //otherwise limit must be have been met.
     return true;
 }
예제 #3
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>';
}
예제 #4
0
		<div class="button_container"><input class="button" type="submit" id="submit" name="submit" value="Save Changes"></div>';
        wp_nonce_field('bebop_' . $extension['name'] . '_user_settings');
        echo '<div class="clear_both"></div>';
        if (bebop_tables::get_user_meta_value($bp->loggedin_user->id, 'bebop_' . $extension['name'] . '_oauth_token')) {
            echo '<div class="button_container"><a class="button" href="' . $bp->loggedin_user->domain . bp_current_component() . '/' . bp_current_action() . '/' . $extension['name'] . '?reset=true">';
            _e(' Remove Authorisation', 'bebop');
            echo '</a></div>';
            echo '<div class="clear_both"></div>';
        }
        echo '</form>';
    } else {
        echo '<h5>' . sprintf(__('%1$s Setup', 'bebop'), $extension['display_name']) . '</h5>
		<p>' . sprintf(__('You can setup %1$s integration here.', 'bebop'), $extension['display_name']) . '</p>
		</p>' . sprintf(__('Before you can begin using %1$s with this site you must authorise on %1$s by clicking the link below.', 'bebop'), $extension['display_name']) . '</p>';
        $app_id = bebop_tables::get_option_value('bebop_' . $extension['name'] . '_consumer_key');
        $app_secret = bebop_tables::get_option_value('bebop_' . $extension['name'] . '_consumer_secret');
        $my_url = urlencode($bp->loggedin_user->domain . bp_current_component() . '/' . bp_current_action() . '/' . $extension['name'] . '?scope=read_stream');
        if (!isset($_REQUEST['code'])) {
            // Redirect to Login Dialog
            $_SESSION['facebook_state'] = md5(uniqid(rand(), TRUE));
            $redirectUrl = str_replace('APP_ID', $app_id, $extension['request_token_url']);
            $redirectUrl = str_replace('REDIRECT_URI', $my_url, $redirectUrl);
            $redirectUrl = str_replace('STATE', $_SESSION['facebook_state'], $redirectUrl);
            echo '<div class="button_container"><a class="button" href="' . $redirectUrl . '">' . __(' Start Authorisation', 'bebop') . '</a></div>';
            echo '<div class="clear_both"></div>';
        } else {
            if (isset($_GET['error_reason'])) {
                if (isset($_GET['state']) && $_SESSION['facebook_state'] == $_GET['state']) {
                    echo 'You denied the request.';
                } else {
                    echo 'You are a victim of CSRF';
예제 #5
0
		</fieldset>
		
		<fieldset>
			<span class='header'><?php 
echo sprintf(__('%1$s RSS Settings', 'bebop'), $extension['display_name']);
?>
</span>
			<p><?php 
_e('By default, RSS feeds are available for each extension in Bebop, and are automaticlly generated when an extension is active. You can turn the rss feeds off by simply unchecking the "enabled" option of the RSS feed settings below. Please note
				that RSS feeds will only be available when the extension is active.', 'bebop');
?>
</p>
			<?php 
if (bebop_tables::get_option_value('bebop_' . $extension['name'] . '_provider') == 'on') {
    echo "<label for='bebop_" . $extension['name'] . "_rss_feed'>" . __('RSS Enabled', 'bebop') . ":</label><input id='bebop_" . $extension['name'] . "_rss_feed' name='bebop_" . $extension['name'] . "_rss_feed' type='checkbox'";
    if (bebop_tables::get_option_value('bebop_' . $extension['name'] . '_rss_feed') == 'on') {
        echo 'CHECKED';
    }
    echo '>';
} else {
    echo '<p>' . sprintf(__('RSS feeds cannot be enabled because %1$s is not an active extension.', 'bebop'), $extension['display_name']) . '</p>';
}
?>
		</fieldset>
		
		<?php 
wp_nonce_field('bebop_' . $extension['name'] . '_admin_settings');
?>
		
		<input class='button-primary' type='submit' id='submit' name='submit' value='<?php 
_e('Save Changes', 'bebop');
예제 #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';
}
</p>
			<p><?php 
_e('As of version 1.1, a cron can be forced to run at the click of a button. This can be used to test whether content is being imported and does not affect the WordPress cron.', 'bebop');
?>
</p>
			<p><?php 
_e('As of version 1.2, the content verification has been moved from the general settings, and has been added to each extension.', 'bebop');
?>
</p>
			
			<label for='bebop_general_crontime'><?php 
_e('WordPress Cron time (in seconds):', 'bebop');
?>
</label>
			<input type='text' id='bebop_general_crontime' name='bebop_general_crontime' value='<?php 
echo bebop_tables::get_option_value('bebop_general_crontime');
?>
' size='10'><br><br>
			
			<label for='traditional_cron'><?php 
_e('Traditional Cron:', 'bebop');
?>
</label>
			<input type='text' id='traditional_cron' value="wget <?php 
echo plugins_url() . '/bebop/import.php -O /dev/null -q';
?>
" size='75' READONLY><br><br>
			
			<label><?php 
_e('Force Main Cron:', 'bebop');
?>
예제 #8
0
 function bebop_get_active_extension_names($addslashes = false)
 {
     //save to static property.
     static $active_extensions;
     if (empty($active_extensions)) {
         $extensions = bebop_extensions::bebop_gather_extensions();
         $active_extensions = array();
         foreach ($extensions as $extension_path) {
             if (file_exists($extension_path . 'import.php')) {
                 $extension_name = bebop_extensions::bebop_get_extension_name_from_path($extension_path);
                 if (bebop_tables::get_option_value('bebop_' . $extension_name . '_provider') == 'on') {
                     if ($addslashes == true) {
                         $active_extensions[] = "'" . $extension_name . "'";
                     } else {
                         $active_extensions[] = $extension_name;
                     }
                 }
             }
         }
     }
     return $active_extensions;
 }
예제 #9
0
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 {
                bebop_tables::log_error(__('Main Importer', 'bebop'), sprintf(__('The function: %1$s/import.php does not exist.', 'bebop'), WP_PLUGIN_DIR . '/bebop/extensions/' . strtolower($extension)));
            }
        }
        unset($extension);
    }
    $log_array = array();
    foreach ($return_array as $key => $value) {
예제 #10
0
/*
 * '$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' && bebop_tables::get_option_value('bebop_' . $extension['name'] . '_consumer_key')) {
    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">	
	<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 '>
	<label for="yes">' . __('Yes', 'bebop') . '</label>
	<input type="radio" name="bebop_' . $extension['name'] . '_active_for_user" id="bebop_' . $extension['name'] . '_active_for_user" value="0"';
    if (${$active} == 0) {
        echo 'checked';
    }
    echo '>
예제 #11
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;
    }
}
예제 #12
0
<div id='bebop_user_container'>
	
<?php 
if (bp_is_my_profile()) {
    if (bp_is_current_component('bebop')) {
        if (bp_is_current_action('bebop-manager')) {
            $should_users_verify_content = bebop_tables::get_option_value('bebop_content_user_verification');
            if ($should_users_verify_content != 'no') {
                include WP_PLUGIN_DIR . '/bebop/core/templates/user/oer-manager.php';
            }
        } else {
            if (bp_is_current_action('bebop-accounts')) {
                $query_string = bp_action_variables();
                if (!empty($query_string)) {
                    $provider = $query_string[0];
                    if (bebop_extensions::bebop_extension_exists($provider)) {
                        include WP_PLUGIN_DIR . '/bebop/extensions/' . $provider . '/templates/user-settings.php';
                    } else {
                        _e('Could not locate this extensions user settings template.', 'bebop');
                    }
                } else {
                    $active_extensions = bebop_extensions::bebop_get_active_extension_names();
                    if (count($active_extensions) == 0) {
                        echo '<p>';
                        _e('No extensions are currently active. Please activate them in the bebop content providers admin panel.', 'bebop');
                        echo '</p>';
                    } else {
                        echo '<div class="help"><p>';
                        _e('Bebop allows you to add content from external accounts to your profile. This means you can pull in content from sites such as YouTube, Vimeo, Flickr and others. This content is then added to your activity stream, once you have verified it in the content manager.', 'bebop');
                        echo '</p>
					<p>';
예제 #13
0
function bebop_twitter_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			*
                 * ******************************************************************************************************************
                 */
                //Twitter uses oAuth - so let the pre-built oAuth class handle the data request.
                //Handle the OAuth requests
                $OAuth = new bebop_oauth();
                $OAuth->set_callback_url($bp->root_domain);
                $OAuth->set_consumer_key(bebop_tables::get_option_value('bebop_' . $this_extension['name'] . '_consumer_key'));
                $OAuth->set_consumer_secret(bebop_tables::get_option_value('bebop_' . $this_extension['name'] . '_consumer_secret'));
                $OAuth->set_access_token(bebop_tables::get_user_meta_value($user_meta->user_id, 'bebop_' . $this_extension['name'] . '_oauth_token'));
                $OAuth->set_access_token_secret(bebop_tables::get_user_meta_value($user_meta->user_id, 'bebop_' . $this_extension['name'] . '_oauth_token_secret'));
                $items = $OAuth->oauth_request($this_extension['data_feed']);
                $items = simplexml_load_string($items);
                /* 
                 * ******************************************************************************************************************
                 * 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:
                $errors = $items->error;
                $username = $items->status->user->screen_name[0];
                if (!$errors) {
                    if ($items) {
                        bebop_tables::update_user_meta($user_meta->user_id, $this_extension['name'], 'bebop_' . $this_extension['name'] . '_username', $username);
                        foreach ($items as $item) {
                            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->text;
                                $item_published = gmdate('Y-m-d H:i:s', strtotime($item->created_at));
                                $action_link = str_replace('bebop_replace_username', $username, $this_extension['action_link']) . $id;
                                //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++;
                                    }
                                }
                            }
                            unset($item);
                        }
                    }
                } else {
                    bebop_tables::log_error(sprintf(__('Importer - %1$s', 'bebop'), $this_extension['display_name']), sprintf(__('Feed Error: %1$s', 'bebop'), $errors));
                }
                unset($user_meta);
            }
        }
    }
    //return the result
    return $itemCounter . ' ' . $this_extension['content_type'] . 's';
}
예제 #14
0
            echo '<div class="button_container"><a class="button" href="' . $bp->loggedin_user->domain . bp_current_component() . '/' . bp_current_action() . '/' . $extension['name'] . '?reset=true">' . __(' Remove Authorisation', 'bebop') . '</a></div>';
            echo '<div class="clear_both"></div>';
        }
        echo '</form>';
    } else {
        echo '<h5>' . sprintf(__('%1$s Setup', 'bebop'), $extension['display_name']) . '</h5>
		<p>' . sprintf(__('You can setup %1$s integration here.', 'bebop'), $extension['display_name']) . '</p>
		</p>' . sprintf(__('Before you can begin using %1$s with this site you must authorise on %1$s by clicking the link below.', 'bebop'), $extension['display_name']) . '</p>';
        //oauth
        $OAuth = new bebop_oauth();
        $OAuth->set_request_token_url($extension['request_token_url']);
        $OAuth->set_access_token_url($extension['access_token_url']);
        $OAuth->set_authorize_url($extension['authorize_url']);
        $OAuth->set_callback_url($bp->loggedin_user->domain . bp_current_component() . '/' . bp_current_action() . '/' . $extension['name']);
        $OAuth->set_consumer_key(bebop_tables::get_option_value('bebop_' . $extension['name'] . '_consumer_key'));
        $OAuth->set_consumer_secret(bebop_tables::get_option_value('bebop_' . $extension['name'] . '_consumer_secret'));
        //get the oauth token
        $requestToken = $OAuth->request_token();
        $OAuth->set_request_token($requestToken['oauth_token']);
        $OAuth->set_request_token_secret($requestToken['oauth_token_secret']);
        bebop_tables::update_user_meta($bp->loggedin_user->id, $extension['name'], 'bebop_' . $extension['name'] . '_oauth_token_temp', '' . $requestToken['oauth_token'] . '');
        bebop_tables::update_user_meta($bp->loggedin_user->id, $extension['name'], 'bebop_' . $extension['name'] . '_oauth_token_secret_temp', '' . $requestToken['oauth_token_secret'] . '');
        //get the redirect url for the user
        $redirectUrl = $OAuth->get_redirect_url();
        if ($redirectUrl) {
            echo '<div class="button_container"><a class="button" href="' . $redirectUrl . '">' . __(' Start Authorisation', 'bebop') . '</a></div>';
            echo '<div class="clear_both"></div>';
        } else {
            _e('authentication is all broken :(', 'bebop');
        }
    }
예제 #15
0
/*
 * '$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 '>
	<label for="yes">';
    _e('Yes', 'bebop');
    echo '</label>
	<input type="radio" name="bebop_' . $extension['name'] . '_active_for_user" id="bebop_' . $extension['name'] . '_active_for_user" value="0"';
    if (${$active} == 0) {
        echo 'checked';
예제 #16
0
function bebop_main_cron_schedule($schedules)
{
    $crontime = bebop_tables::get_option_value('bebop_general_crontime');
    if (is_numeric($crontime)) {
        $time = $crontime;
    } else {
        $time = 600;
        bebop_tables::update_option('bebop_general_crontime', $time);
    }
    $schedules['bebop_main_cron_time'] = array('interval' => $time, 'display' => __('main_cron'));
    return $schedules;
}
예제 #17
0
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']) ) {
}
예제 #18
0
//2 - update column definitions
$update_2 = bebop_tables::get_option_value('bebop_db_update_2');
if (!$update_2) {
    $wpdb->get_results('ALTER TABLE ' . bp_core_get_table_prefix() . 'bp_bebop_oer_manager MODIFY secondary_item_id VARCHAR(32)');
    $wpdb->get_results('ALTER TABLE ' . bp_core_get_table_prefix() . 'bp_bebop_oer_manager MODIFY id BIGINT(20) NOT NULL AUTO_INCREMENT');
    $wpdb->get_results('ALTER TABLE ' . bp_core_get_table_prefix() . 'bp_bebop_oer_manager MODIFY user_id BIGINT(20)');
    $wpdb->get_results('ALTER TABLE ' . bp_core_get_table_prefix() . 'bp_bebop_user_meta MODIFY id BIGINT(20) NOT NULL AUTO_INCREMENT');
    $wpdb->get_results('ALTER TABLE ' . bp_core_get_table_prefix() . 'bp_bebop_user_meta MODIFY user_id BIGINT(20)');
    $wpdb->get_results('ALTER TABLE ' . bp_core_get_table_prefix() . 'bp_bebop_first_imports MODIFY id BIGINT(20) NOT NULL AUTO_INCREMENT');
    $wpdb->get_results('ALTER TABLE ' . bp_core_get_table_prefix() . 'bp_bebop_first_imports MODIFY user_id BIGINT(20)');
    $wpdb->get_results('ALTER TABLE ' . bp_core_get_table_prefix() . 'bp_bebop_error_log MODIFY id BIGINT(20) NOT NULL AUTO_INCREMENT');
    $wpdb->get_results('ALTER TABLE ' . bp_core_get_table_prefix() . 'bp_bebop_general_log MODIFY id BIGINT(20) NOT NULL AUTO_INCREMENT');
    bebop_tables::add_option('bebop_db_update_2', true);
}
//3 - hash secondary_item_ids
$update_3 = bebop_tables::get_option_value('bebop_db_update_3');
if (!$update_3) {
    $update_secondary_item_id = array();
    $results = $wpdb->get_results('SELECT id, secondary_item_id FROM ' . bp_core_get_table_prefix() . 'bp_bebop_oer_manager');
    if (!empty($results)) {
        foreach ($results as $result) {
            $update_secondary_item_id[] = array('indices' => array('id' => $result->id), 'data' => md5($result->secondary_item_id));
        }
        $update_array = array('secondary_item_id' => $update_secondary_item_id);
        $update_string = array();
        foreach ($update_array as $key => $data) {
            $string = $key . ' = CASE ';
            foreach ($data as $update_data) {
                $indices_loop = array();
                foreach ($update_data['indices'] as $index_name => $index_data) {
                    $indices_loop[] = $index_name . ' = \'' . $index_data . '\'';