Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Some cleanup

  • Loading branch information...
commit 119c68079f1b59075a7194a5dcf53566404a1056 1 parent 78986a7
@ejackisch authored
View
8 adding-more-services.txt
@@ -1,13 +1,13 @@
Defining additional services:
---------------------------
-The existing ones are found in ubcpeople/include/services/
+The existing services are found in ubcpeople/include/services/
To add another you can create a new file in that directory and include it in the main file ubcpeople.php
Required functions
- ubcpeople_{service_name}_get_icon();
+ ubcpeople_{service_name}_get_parameters();
Get the information for the icon displayed on the profile page
ubcpeople_{service_name}();
@@ -21,4 +21,6 @@ Required functions
There's a hook 'ubcpeople_admin' to run code needed for the admin interface, most importantly the form to add a particular service. You can see how the other services use it
-Lastly add it to ubcpeople_get_available_services() in the main file
+Lastly add it to ubcpeople_get_available_services() in the main file
+
+Check out the services/ubc_blogs.php for a simple one that doesn't have fancy authentication or anything
View
13 css/style.css
@@ -178,4 +178,17 @@ h2 a{
.url{
color:#666;
font-size:75%;
+ }
+
+ #social-left-column{
+ width:180px;float:left;height:600px;background-color:#000;
+ }
+
+ #social-main-column{
+ float:left;
+ width:700px;
+ }
+
+ #social-tabs li{
+ width:100%;;
}
View
30 include/services/facebook.php
@@ -94,37 +94,7 @@ function ubcpeople_facebook_get_access_code($url, $username){
update_user_meta($user->ID, 'fb_access_token', $info['access_token']);
ubcpeople_add_service($username, 'facebook', $response['result']['id']);
}
-
-
-
-
- /*$options = get_option("people_settings");
-
- $client = new OAuth2\Client($options['fb_key'], $options['fb_secret']);
- $redirect_uri = $url;
- $token_endpoint = 'https://graph.facebook.com/oauth/access_token';
-
- //$redirect_uri = 'http://localhost';
-
- $params = array( 'code' => $_GET['code'], 'redirect_uri' => $redirect_uri );
- $response = $client->getAccessToken($token_endpoint, 'authorization_code', $params);
- print_r($response['result']);
- parse_str($response['result'], $info);
- $client->setAccessToken($info['access_token']);
- $fb_user_details = $client->fetch('https://graph.facebook.com/me');
- print_r( $fb_user_details );
- die();
- //store the access token
- update_user_meta($user->ID, 'fb_access_token', $info['access_token']);
-
- //Grab the user details so we have their ID/username
- $fb_user_details = json_decode(file_get_contents('https://graph.facebook.com/me?access_token='. $parsed_data['access_token']),true);
- ubcpeople_add_service($username, 'facebook', $fb_user_details['id']);
- */
- //temporary solution
- //echo '<meta http-equiv="refresh" content="0;url='.ubcpeople_get_person_url().'" />';
- exit;
endif;
}
View
56 include/services/linkedin.php
@@ -51,6 +51,55 @@ function ubcpeople_linkedin_get_data($person_id, $service_username){
function ubcpeople_linkedin_get_access_code($url, $username){
+
+ if( isset($_GET['act']) && $_GET['act'] == 'add-linkedin' ):
+
+ //Information the OAuth2 script needs
+
+
+ $user = get_user_by('login', $username);
+
+ $options = get_option("people_settings");
+ $client = new OAuth2\Client($options['linkedin_key'], $options['linkedin_secret']);
+
+ $redirect_url = 'http://'.$_SERVER['SERVER_NAME']. $_SERVER['REQUEST_URI']; //Where the User will be redirected after they come back from facebook.com
+ $authorization_endpoint = 'https://www.linkedin.com/uas/oauth/authenticate';
+
+ $token_endpoint = 'https://api.linkedin.com/uas/oauth/accessToken';
+
+ $auth_url = $client->getAuthenticationUrl ($authorization_endpoint, $redirect_url, array('scope'=>'user_status', 'act'=>'add-linkedin'));
+
+ $request_token_url = 'https://api.linkedin.com/uas/oauth/requestToken';
+
+ if (!isset($_GET['code']))
+ {
+ //STEP 1:
+ //redirect the user to the facebook auth page.
+ $auth_url = $client->getAuthenticationUrl($authorization_endpoint, $redirect_url);
+ header('Location: ' . $auth_url);
+ die('Redirect');
+ }
+ else
+ {
+ //STEP 2:
+ //Get access token from Linkedin server
+ $params = array('code' => $_GET['code'], 'redirect_uri' => $redirect_url);
+ $response = $client->getAccessToken($token_endpoint, 'authorization_code', $params);
+ parse_str($response['result'], $info);
+ $client->setAccessToken($info['access_token']);
+
+ //Retrieve users linkedin information
+ $response = $client->fetch('http://api.linkedin.com/v1/people/~');
+ print_r($response);
+ //Store the user's access token and linkedin user ID
+ //update_user_meta($user->ID, 'linkedin_access_token', $info['access_token']);
+ //ubcpeople_add_service($username, 'linkedin', $response['result']['id']);
+ }
+
+ endif;
+
+/*
+
$user = get_user_by('login', $username);
return;
if(isset($_GET['code']) && $_GET['app'] == 'linkedin'):
@@ -72,7 +121,7 @@ function ubcpeople_linkedin_get_access_code($url, $username){
//temporary solution
echo '<meta http-equiv="refresh" content="0;url='.ubcpeople_get_person_url().'" />';
exit;
- endif;
+ endif;*/
}
@@ -91,14 +140,13 @@ function ubcpeople_linkedin_get_parameters(){
* Output the HTML for the add Linkedin window
*/
function ubcpeople_linkedin_add(){
- $current_url = 'http://'.$_SERVER['SERVER_NAME']. $_SERVER['REQUEST_URI']; //temp
- $options = get_option("people_settings");
+ global $usermeta;
?>
<div style="display:none;">
<div id="add-service-linkedin" class="add-service">
<h2>LinkedIn</h2>
<p>You will be redirected to LinkedIn to authenticate. </p>
- <p><a class="submit-add-social" href="https://www.linkedin.com/uas/oauth/requestToken/?oauth_consumer_key=<?php echo $options['linkedin_key']; ?>&oauth_callback=<?php echo urlencode($current_url . '&app=linkedin'); ?>">Authenticate</a>
+ <p><a class="submit-add-social" href="<?php echo ubcpeople_get_person_url($usermeta['login'], array('act'=>'add-linkedin') ); ?>">Authenticate</a>
<span class="small">Any changes you have made will be saved.</span>
</p>
</div>
View
4 include/services/ubc_blog.php
@@ -25,7 +25,9 @@ function ubcpeople_ubc_blog($person_id, $service_username){
}
-
+/**
+ * Get the XML feed from UBC blogs
+ */
function ubcpeople_ubc_blog_get_data($username){
if(!($xml_string = get_transient('blogs_'.$username) ) ):
//temporary. maybe.
View
5 include/services/ubc_wiki.php
@@ -1,7 +1,7 @@
<?php
add_action('ubcpeople_add_service_form', 'ubcpeople_ubc_wiki_add');
/**
- *
+ * Content to be displayed in wiki tab on social overlay
*/
function ubcpeople_ubc_wiki($person_id, $service_username){ ?>
@@ -30,6 +30,9 @@ function ubcpeople_ubc_wiki($person_id, $service_username){ ?>
<?php }
+/**
+ * Get the XML feed for the users contribs from wiki
+ */
function ubcpeople_ubc_wiki_contributions($service_username){
if(!($xml_string = get_transient('ubcwiki_'.$service_username) ) ):
$xml_string = file_get_contents('http://wiki.ubc.ca/api.php?action=feedcontributions&user=' . $service_username . '&feedformat=atom', false);
View
9 js/profile.js
@@ -1,8 +1,9 @@
//todo: tidy this
jQuery(document).ready(function() {
var admin = true;
+
/*
- * Saves the person data. If provided, call a callback function after
+ * Saves the person data to the server via ajax. If provided, call a callback function after
*/
people_savePost = function(event, callback){
callback = callback || function(){};
@@ -19,14 +20,15 @@ jQuery(document).ready(function() {
}
+ /*
+ * Set up the image uploader
+ */
people_initUploader = function(post_id){
var uploader = new qq.FileUploader({
element: document.getElementById('file-uploader-demo1'),
action: '/wp-admin/admin-ajax.php?action=people_upload_photo&id='+post_id,
onComplete: function(id, filename, responseJSON){
- //console.log(postData);
- //jQuery('html').css("background-image", "url(/wp-content/uploads/people/"+post_id+"/"+responseJSON.filename+")");
jQuery.backstretch("/wp-content/uploads/people/"+post_id+"/"+responseJSON.filename);
postData.people.bg.url = responseJSON.filename;
postData.people.images.push(responseJSON.filename);
@@ -41,7 +43,6 @@ jQuery(document).ready(function() {
function convertLineBreaks(input_string){
return input_string.replace(/(\r\n|\r|\n)/g, "<br />");
}
-
/*
View
6 readme.txt
@@ -1,3 +1,7 @@
WordPress plugin to create fancy public profile pages which can pull in feeds from external sites like Facebook, Twitter, WordPress, etc
-Still very much under development.
+Still very much under development.
+
+Person profiles are currently accessed at www.example.com/?person=username
+
+Nothing shows up if the user hasn't enabled their public profile (controlled from the default wordpress edit profile screen)
View
2  settings.php
@@ -3,6 +3,8 @@
* Settings Page
*/
+//todo: if we're doing a network-wide install on a wpmu site then these settings should probably be at the network level
+
if( is_admin() ):
add_action( 'admin_menu', 'ubcpeople_admin_menu' );
add_action( 'admin_init', 'ubcpeople_register_settings' );
View
10 template/admin-overlay.php
@@ -1,15 +1,19 @@
<?php
global $current_user;
- do_action('ubcpeople_add_service_form');
+
if( ubcpeople_current_user_can_edit( $_REQUEST['person'] ) ): //if user has permission to edit this page
+
+ //Hook to add HTML for the add service form fancyboxes
+ do_action('ubcpeople_add_service_form');
?>
+
+
<!-- Floating admin interface-->
<div id="editor">
<form>
<div id="editor-tabs">
<ul>
- <li><a href="#tab-info">Information</a></li>
-
+ <li><a href="#tab-info">Information</a></li>
<li><a href="#tab-images">Background</a></li>
<li><a href="#tab-styles">Styles</a></li>
<li><a href="#tab-services">External Services</a></li>
View
10 template/person-template.php
@@ -44,8 +44,7 @@
<?php
- //$usermeta['social'] needs to be re-ordered with internal first and external second
-
+ //todo: do this somewhere else
$internal_services = array();
$external_services = array();
foreach($usermeta['social'] as $service=>$service_username):
@@ -88,9 +87,10 @@
</div>
</div>
- <?php include 'social-overlay.php'; ?>
-
- <?php include 'admin-overlay.php'; ?>
+ <?php
+ include 'social-overlay.php';
+ include 'admin-overlay.php';
+ ?>
<span class="ajax-spinner" style="display:none;float:left;">Saving...</span>
View
21 template/social-overlay.php
@@ -1,27 +1,10 @@
-<style>
- #social-left-column{
- width:180px;float:left;height:600px;background-color:#000;
- }
-
- #social-main-column{
- float:left;
- width:700px;
- }
-
- #social-tabs li{
- width:100%;;
- }
-</style>
-
-
<div id="social-overlay" style="display:none;">
<div id="social-inline-content">
<div id="social-tabs">
- <!--Sidebar tabs Area
- -->
+ <!--Sidebar tabs Area-->
<div id="social-left-column">
<div style="color:#fff;margin:10px;">@ubc</div>
@@ -36,7 +19,7 @@
$count++;
endforeach;
- //jquery ui tabs works with these list items, so we'll output these ones here even though they're no going to be displayed this way
+ //jquery ui tabs relies with these list items, so we'll output these ones here even though they're not going to be displayed this way
foreach( $external_services as $service=>$service_username ):
echo '<li style="display:none;"><a href="#tab-'.str_replace(array(' ','.'),'-', $service).'"></a></li>';
endforeach;
View
29 ubcpeople.php
@@ -28,6 +28,8 @@
require 'include/adoy-php-oauth2/GrantType/IGrantType.php';
require 'include/adoy-php-oauth2/GrantType/AuthorizationCode.php';
+
+//See adding-more-services.txt for how additional services are defined right now
include 'include/services/twitter.php';
include 'include/services/ubc_blog.php';
include 'include/services/ubc_wiki.php';
@@ -35,9 +37,10 @@
include 'include/services/facebook.php';
include 'include/services/linkedin.php';
+
/**
* ubcpeople_get_available_services
- * The list of services that are available to add to a profile slug=>name
+ * Returns a list of services that are available to add to a profile slug=>name
*/
function ubcpeople_get_available_services(){
return array(
@@ -55,6 +58,7 @@ function ubcpeople_get_available_services(){
/**
* ubcpeople_get_default_data
* The default values for a new profile
+ * todo: move this somewhere else
*/
function ubcpeople_get_default_data(){
return array(
@@ -93,6 +97,7 @@ function ubcpeople_get_default_data(){
/**
* ubcpeople_update_profile
* Called when profile is updated via the backend edit-profile page, adds the ability to make a profile public and set a profile as homepage
+ * @param $user_id WordPress User ID of profile being updated
*/
function ubcpeople_update_profile($user_id){
$user = get_user_by('id', $user_id);
@@ -222,7 +227,7 @@ function ubcpeople_include_template() {
wp_enqueue_script('jquery');
//Scripts that only need to be included for profile editing
- if( true ):
+ if( true ): //todo: check here if the user can edit this profile
wp_enqueue_script('jquery-ui-draggable');
wp_enqueue_script('jquery-ui-resizable');
wp_enqueue_script('jquery-ui-sortable');
@@ -244,11 +249,7 @@ function ubcpeople_include_template() {
wp_enqueue_style("colorbox", plugins_url( 'css/colorbox.css', __FILE__ ));
wp_enqueue_style("ubcpeople", plugins_url( 'css/style.css', __FILE__ ));
- wp_enqueue_style("people-jquery-ui", plugins_url( 'css/jquery-ui.css', __FILE__ ));
-
-
-
-
+ wp_enqueue_style("people-jquery-ui", plugins_url( 'css/jquery-ui.css', __FILE__ ));
include 'template/person-template.php';
exit;
@@ -275,7 +276,6 @@ function ubcpeople_update_post(){
$social = $social_data;
-
//If the order of social icons has been changed, update it..
if($social['order']):
$order = $social['order'];
@@ -286,13 +286,11 @@ function ubcpeople_update_post(){
$social = $new_social;
endif;
-
$id = $_POST['id'];
$post_data = array(
'ID' => $id,
);
- //wp_update_user( $post_data );
update_user_meta($id, 'people', $people);
update_user_meta($id, 'social', $social);
@@ -321,15 +319,15 @@ function ubcpeople_add_service($person_name, $service_name, $service_username){
$social = get_user_meta($user_id, 'social', true);
$social[$service_name] = $service_username;
update_user_meta($user_id, 'social', $social);
-
}
-
/**
* ubcpeople_remove_service
* Remove a service from a profile
+ * @param $person_name The WP username of the profile we're working with
+ * @param $service_name The service to delete from the profile
*/
function ubcpeople_remove_service($person_name, $service_name){
@@ -354,9 +352,6 @@ function ubcpeople_remove_service($person_name, $service_name){
*/
function ubcpeople_is_valid_service($service_slug){
$social_array = ubcpeople_get_available_services();
-
- //to do: this should be passed a slug, so all this function should need to do is verify that it exists in the array
-
if(array_key_exists($service_slug, $social_array)):
return true;
endif;
@@ -386,7 +381,9 @@ function ubcpeople_get_service_parameters($service_slug){
/**
* ubcpeople_display_service
* Calls the function to display the content for a particular service (in the overlay)
- *
+ * @param $service_slug
+ * @param $person_id The Wordpress user ID of the service to be displayed
+ * @param $service_username The person's username on service being displayed
*/
function ubcpeople_display_service($service_slug, $person_id, $service_username){
if( ubcpeople_is_valid_service( $service_slug ) ):
Please sign in to comment.
Something went wrong with that request. Please try again.