Example #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));
    }
}
Example #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;
 }
				<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>
						<td><a class="button-secondary" style="display:inline-block;margin:6px 0 6px 0;" href="?page=bebop_providers&provider=' . strtolower($extension['name']) . '">' . __('Settings', 'bebop') . '</a></td>
					</tr>';
    }
    ?>
				</tbody>
			</table>
			
			<?php 
    wp_nonce_field('bebop_content_provider_settings');
    ?>
			
			<input class='button-primary' type='submit' id='submit' name='submit' value='<?php 
Example #4
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';
}
</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');
?>
Example #6
0
 function get_initial_import_feeds($user_id, $extension)
 {
     global $wpdb;
     $return = array();
     $results = $wpdb->get_results('SELECT value FROM ' . bp_core_get_table_prefix() . "bp_bebop_first_imports WHERE user_id = '" . $wpdb->escape($user_id) . "' AND extension = '" . $wpdb->escape($extension) . "'");
     foreach ($results as $result) {
         $return[] = bebop_tables::sanitise_element($result->value);
     }
     return $return;
 }
Example #7
0
			<tbody>
				<?php 
    /*
     * Loops through each user and prints their details to the screen.
     */
    foreach ($user_metas as $user) {
        $this_user = get_userdata($user->user_id);
        $user_feeds = bebop_tables::get_user_feeds($user->user_id, $extension['name']);
        $feed_array = array();
        foreach ($user_feeds as $user_feed) {
            $feed_array[] = $user_feed->meta_value;
        }
        $user_feeds = implode(',', $feed_array);
        echo '<tr>
						<td>' . bebop_tables::sanitise_element($user->user_id) . '</td>
						<td>' . bebop_tables::sanitise_element($this_user->user_login) . '</td>
						<td>' . bebop_tables::sanitise_element($this_user->user_email) . '</td>
						<td>' . bebop_tables::sanitise_element($user_feeds) . "</td>\n\t\t\t\t\t\t<td><a href='?page=bebop_providers&provider=" . $extension['name'] . "&reset_user_id=" . bebop_tables::sanitise_element($user->user_id) . "'>" . __('Reset User', 'bebop') . "</a></td>\n\t\t\t\t\t</tr>";
    }
    ?>
			<!-- <End bebop_table -->
			</tbody>
		</table>
		<?php 
} else {
    echo sprintf(__('No users found for the %1$s extension.', 'bebop'), $extension['display_name']);
}
?>
<!-- End bebop_admin_container -->
</div>
Example #8
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';
Example #9
0
    _e('Save Changes', 'bebop');
    echo '"></div>';
    wp_nonce_field('bebop_' . $extension['name'] . '_user_settings');
    echo '<div class="clear_both"></div>';
    echo '</form>';
    //table of user feeds
    $user_feeds = bebop_tables::get_user_feeds($bp->loggedin_user->id, $extension['name']);
    if (count($user_feeds) > 0) {
        echo '<h5>Your ' . $extension['display_name'] . ' feeds</h5>';
        echo '<table class="bebop_user_table">
				<tr class="nodata">
					<th>';
        _e('Username', 'bebop');
        echo '</th>
					<th>';
        _e('Options', 'bebop');
        echo '</th>
				</tr>';
        foreach ($user_feeds as $user_feed) {
            echo '<tr>
				<td>' . bebop_tables::sanitise_element($user_feed->meta_value) . '</td>
				<td><a href="' . $bp->loggedin_user->domain . bp_current_component() . '/' . bp_current_action() . '/' . $extension['name'] . '?remove_username='******'">';
            _e('Delete Feed', 'bebop');
            echo '</a></td>
			</tr>';
        }
        echo '</table>';
    }
} else {
    echo sprintf(__('%1$s has not yet been configured. Please contact the blog admin to make sure %1$s is configured properly.', 'bebop'), $extension['display_name']);
}
Example #10
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 #11
0
			</tfoot>
			<?php 
    }
    ?>
			<tbody>
				<?php 
    /*
     * Loops through each user and prints their details to the screen.
     */
    foreach ($user_metas as $user) {
        $this_user = get_userdata($user->user_id);
        echo '<tr>
						<td>' . bebop_tables::sanitise_element($user->user_id) . '</td>
						<td>' . bebop_tables::sanitise_element($this_user->user_login) . '</td>
						<td>' . bebop_tables::sanitise_element($this_user->user_email) . '</td>
						<td>' . bebop_tables::sanitise_element(bebop_tables::get_user_meta_value($user->user_id, 'bebop_' . $extension['name'] . '_username')) . "</td>\n\t\t\t\t\t\t<td><a href='?page=bebop_providers&provider=" . $extension['name'] . "&reset_user_id=" . bebop_tables::sanitise_element($user->user_id) . "'>";
        _e('Reset User', 'bebop');
        echo "</a></td>\n\t\t\t\t\t</tr>";
    }
    ?>
			<!-- <End bebop_table -->
			</tbody>
		</table>
		<?php 
} else {
    echo sprintf(__('No users found for the %1$s extension.', 'bebop'), $extension['display_name']);
}
?>
<!-- End bebop_admin_container -->
</div>
<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>';
Example #13
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;
    }
}
Example #14
0
	
	<label for="bebop_' . $extension['name'] . '_newfeedurl">' . __('New Feed URL', 'bebop') . '</label>
	<input type="text" name="bebop_' . $extension['name'] . '_newfeedurl" size="75"><br><br>
	
	<div class="button_container"><input class="button" type="submit" id="submit" name="submit" value="' . __('Save Changes', 'bebop') . '"></div>';
    wp_nonce_field('bebop_' . $extension['name'] . '_user_settings');
    echo '<div class="clear_both"></div>
	</form>';
    //table of user feeds
    $user_feeds = bebop_tables::get_user_feeds($bp->loggedin_user->id, $extension['name']);
    if (count($user_feeds) > 0) {
        echo '<h5>' . sprintf(__('Your %1$s feeds', 'bebop'), $extension['display_name']) . '</h5>';
        echo '<table class="bebop_user_table">
				<tr class="nodata">
					<th>' . __('Feed Name', 'bebop') . '</th>
					<th>' . __('Feed URL', 'bebop') . '</th>
					<th>' . __('Options', 'bebop') . '</th>
				</tr>';
        foreach ($user_feeds as $user_feed) {
            $feed_name = str_replace('_', ' ', bebop_tables::sanitise_element($user_feed->meta_name));
            echo '<tr>
				<td>' . stripslashes($feed_name) . '</td>
				<td>' . substr(bebop_tables::sanitise_element($user_feed->meta_value), 0, 150) . '</td>
				<td><a href="' . $bp->loggedin_user->domain . bp_current_component() . '/' . bp_current_action() . '/' . $extension['name'] . '?delete_feed=' . urlencode($feed_name) . '">' . __('Delete Feed', 'bebop') . '</a></td>
			</tr>';
        }
        echo '</table>';
    }
} else {
    echo sprintf(__('%1$s has not yet been configured. Please contact the blog admin to make sure %1$s is configured properly.', 'bebop'), $extension['display_name']);
}
Example #15
0
        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');
        }
    }
} else {
    echo sprintf(__('%1$s has not yet been configured. Please contact the blog admin to make sure %1$s is configured properly.', 'bebop'), $extension['display_name']);
}
 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;
 }
Example #17
0
?>
</a></h3>
			<div class='inside'>
				<?php 
$contents = bebop_tables::admin_fetch_content_data('verified', 0, 20);
if (count($contents) > 0) {
    echo '<table class="postbox_table">
						<tr class="nodata">
							<th>' . __('Username', 'bebop') . '</th>
							<th>' . __('Type', 'bebop') . '</th>
							<th>' . __('Imported', 'bebop') . '</th>
							<th>' . __('Published', 'bebop') . '</th>
							<th>' . __('Content', 'bebop') . '</th>
						</tr>';
    foreach ($contents as $content) {
        echo '<tr>
							<td>' . bp_core_get_username($content->user_id) . '</td>' . '<td>' . bebop_tables::sanitise_element(ucfirst($content->type)) . '</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, $allow_tags = true) . '</td>' . '</tr>';
    }
    echo '</table>';
} else {
    echo '<p>' . __('No verified content exists in the content manager.', 'bebop') . '</p>';
}
?>
				
			</div>
		</div></div>
	</div>
	
	<div class="clear"></div>
</div>
<!-- end bebop_admin_container -->
Example #18
0
        echo '<form id="oer_table" class="bebop_user_form" method="post">';
        echo '<h5>' . ucfirst($type) . ' ' . __('Content', 'bebop') . '</h5>';
        echo $bebop_pagination;
        echo '<div class="button_container button_right"><a class="button" rel="#oer_table" href="#select_all">' . __('Select All', 'bebop') . '</a></div>';
        echo '<div class="button_container button_right"><a class="button" rel="#oer_table" href="#select_none">' . __('Select None', 'bebop') . '</a></div>';
        echo '<div class="clear_both"></div>';
        echo '<table class="bebop_user_table">
			<tr class="nodata">
				<th>' . __('Type', 'bebop') . '</th>
				<th>' . __('Imported', 'bebop') . '</th>
				<th>' . __('Published', 'bebop') . '</th>
				<th>' . __('Content', 'bebop') . '</th>
				<th>' . __('Select', 'bebop') . '</th>
			</tr>';
        foreach ($oers as $oer) {
            echo '<tr>' . '<td><label for="' . $oer->id . '">' . bebop_tables::sanitise_element($oer->type) . '</label></td>' . '<td><label for="' . $oer->id . '">' . bebop_tables::sanitise_element(bp_core_time_since($oer->date_imported)) . '</label></td>' . '<td><label for="' . $oer->id . '">' . bp_core_time_since($oer->date_recorded) . '</label></td>' . '<td class="content"><label for="' . $oer->id . '">' . bebop_tables::sanitise_element($oer->content, $allow_tags = true) . '</label></td>' . "<td class='checkbox_container'><label for='" . $oer->id . "'><div class='checkbox'><input type='checkbox' id='" . $oer->id . "' name='" . $oer->id . "'></div></label></td>" . '</tr>';
        }
        echo '</table>';
        echo '<div class="button_container button_right"><a class="button" rel="#oer_table" href="#select_all">' . __('Select All', 'bebop') . '</a></div>';
        echo '<div class="button_container button_right"><a class="button" rel="#oer_table" href="#select_none">' . __('Select None', 'bebop') . '</a></div>';
        echo '<h5>' . __('Action', 'bebop') . '</h5>';
        $verify_oer_option = '<label class="alt" for="verify">' . __('Verify', 'bebop') . ':</label><input type="radio" name="action" id="verify" value="verify"><br>';
        $delete_oer_option = '<label class="alt" for="delete">' . __('Delete', 'bebop') . ':</label><input type="radio" name="action" id="delete" value="delete"><br>';
        $undelete_oer_option = '<label class="alt" for="undelete">' . __('Undelete', 'bebop') . ':</label><input type="radio" name="action" id="undelete" value="undelete"><br>';
        if ($type == 'unverified') {
            echo $verify_oer_option . $delete_oer_option;
        } else {
            if ($type == 'verified') {
                echo $delete_oer_option;
            } else {
                if ($type == 'deleted') {
Example #19
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 #20
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 -->
Example #21
0
</th>
					<th><?php 
    _e('Error Type', 'bebop');
    ?>
</th>
					<th><?php 
    _e('Error Message', 'bebop');
    ?>
</th>
				</tr>
			</tfoot>
			<tbody>
				<?php 
    foreach ($table_row_data as $row_data) {
        echo '<tr>
					<td>' . bebop_tables::sanitise_element($row_data->id) . '</td>' . '<td>' . bebop_tables::sanitise_element($row_data->timestamp) . '</td>
					<td>' . bebop_tables::sanitise_element($row_data->error_type) . '</td>
					<td>' . bebop_tables::sanitise_element($row_data->error_message) . '</td>
				</tr>';
    }
    ?>
			</tbody>
		</table>
		<?php 
    echo $bebop_pagination;
} else {
    _e('No data for this page was found.', 'bebop');
}
?>
<!-- End bebop_admin_container -->
</div>
Example #22
0
                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) {
        if (!empty($value)) {
            $log_array[] = $value;
        }
    }
    $log_results = implode(', ', $log_array);
    if (!empty($log_results)) {
        $message = sprintf(__('Main importer service completed. Imported %1$s.', 'bebop'), $log_results);
        echo $message;
    } else {
        $message = __('Main importer service completed. Nothing was imported.', 'bebop');
        echo $message;
    }
    bebop_tables::log_general(__('Main Importer', 'bebop'), $message);
}
if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
    gc_disable();
}
Example #23
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 #24
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;
}
function bebop_admin_flush_table()
{
    if (!empty($_GET['page'])) {
        $current_page = $_GET['page'];
        if ($current_page == 'bebop_error_log' || $current_page == 'bebop_general_log') {
            if (isset($_GET)) {
                if (isset($_GET['clear_table'])) {
                    if ($table_row_data = bebop_tables::flush_table_data('bp_' . $current_page)) {
                        $_SESSION['bebop_admin_notice'] = true;
                    } else {
                        $_SESSION['bebop_admin_notice'] = __('Error clearing table data.', 'bebop');
                    }
                    wp_safe_redirect($_SERVER['PHP_SELF'] . '?page=' . $current_page);
                    exit;
                }
            }
        }
    }
}
Example #26
0
}
//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 . '\'';
                }
                $string .= 'WHEN ' . implode(' AND ', $indices_loop) . ' THEN  \'' . $update_data['data'] . '\' ';
            }
            $update_string[] = $string . 'ELSE ' . $key . ' END';
        }
        $query = implode(', ', $update_string);
        $update = $wpdb->get_results('UPDATE ' . bp_core_get_table_prefix() . 'bp_bebop_oer_manager SET ' . $query);
        unset($update_secondary_item_id);
    }
    bebop_tables::add_option('bebop_db_update_3', true);
}
bebop_tables::add_option('bebop_db_version', '1.3.1');