summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorroot2013-10-25 05:15:01 (GMT)
committer root2013-10-25 05:15:01 (GMT)
commita700403325d359506eef5bc3bb1fedd494b30ff5 (patch)
tree541fdda3fa750cafcac898b3ec056fd6e2ab1146
parent2ac34256ca77babd5c402c9ce2147ec5b6d666eb (diff)
Issus fixed and master branch updated by Sreyas.
-rw-r--r--meetup_login.module48
-rw-r--r--meetup_login.pages.inc15
-rw-r--r--meetupapi.lib.php4
3 files changed, 61 insertions, 6 deletions
diff --git a/meetup_login.module b/meetup_login.module
index ecbea67..0c99297 100644
--- a/meetup_login.module
+++ b/meetup_login.module
@@ -196,7 +196,7 @@ function meetup_login_theme() {
* Themable function for an image link for signing in with Meetup.
*/
function theme_meetup_login_button() {
- $img = drupal_get_path('module', 'meetup_login') . '/images/meetup/' . variable_get('meetup_signin_button', 'Sign-in-with-Meetup-lighter-small.png');
+ $img = drupal_get_path('module', 'meetup_login') . '/images/meetup/' . variable_get('meetup_login_signin_button', 'Sign-in-with-Meetup-lighter-small.png');
return l(theme('image', array('path' => $img, 'alt' => t('Sign in with Meetup'))), 'meetup/redirect', array('html' => TRUE));
}
/**
@@ -208,7 +208,7 @@ function meetup_login_form_alter(&$form, $form_state, $form_id) {
}
if ($form_id == 'user_login' || $form_id == 'user_login_block') {
- $img = drupal_get_path('module', 'meetup_login') . '/images/meetup/' . variable_get('meetup_signin_button', 'Sign-in-with-Meetup-lighter-small.png');
+ $img = drupal_get_path('module', 'meetup_login') . '/images/meetup/' . variable_get('meetup_login_signin_button', 'Sign-in-with-Meetup-lighter-small.png');
$image = theme('image', array('path' => $img, 'alt' => t('Sign in with Meetup')));
$key = variable_get('meetup_login_consumer_key', '');
if (isset($key)) {
@@ -245,8 +245,50 @@ function meetup_login_oauth_callback_submit(&$form, &$form_state) {
// We have an existing Meetup account - set it up for login.
$account = user_load($uid);
$edit["authname_meetup"] = $response['member_id'];
+ $edit['name'] = $response['name'];
+ $instances = field_info_instances('user', 'user');
+ foreach ($instances as $field_name => $instance) {
+ $values = variable_get($field_name);
+ if ($instance['widget']['type'] == 'link_field') {
+ if ($values == 'twitter') {
+ $response[$values] = isset($response[$values]) ? $response[$values] : '';
+ $explode = explode('@', $response[$values]);
+ $title = $explode[1];
+ $url = 'https://twitter.com/' . $title;
+ }
+ elseif ($values == 'flickr') {
+ $title = 'Flicker';
+ $url = $response[$values];
+ }
+ elseif ($values == 'facebook') {
+ $title = 'Facebook';
+ $url = 'https://www.facebook.com/' . $response[$values];
+ }
+ $title = isset($title) ? $title : '';
+ $url = isset($url) ? $url : '';
+ $fields[$field_name] = array('und' => array(0 => array('title' => $title, 'url' => $url)));
+ }
+ elseif ($instance['widget']['type'] == 'text_textfield') {
+ if ($values == 'facebook') {
+ $response[$values] = 'https://www.facebook.com/' . $response[$values];
+ }
+ elseif ($values == 'flickr') {
+ $response[$values] = $response[$values];
+ }
+ elseif ($values == 'twitter') {
+ $response[$values] = 'https://twitter.com/' . $response[$values];
+ }
+ $fields[$field_name] = array('und' => array(0 => array('value' => $response[$values])));
+ }
+ else {
+ $fields[$field_name] = array('und' => array(0 => array('value' => $response[$values])));
+ }
+ }
+ if (isset($fields)) {
+ $edit = array_merge($edit, $fields);
+ }
user_save($account, $edit);
- $account = $user;
+ $user = $account;
variable_set('meetup_auth_account', $account);
$success = TRUE;
}
diff --git a/meetup_login.pages.inc b/meetup_login.pages.inc
index c227d77..67ebde1 100644
--- a/meetup_login.pages.inc
+++ b/meetup_login.pages.inc
@@ -31,6 +31,12 @@ function meetup_login_admin_form($form, &$form_state) {
'#title' => t('OAuth Consumer secret'),
'#default_value' => variable_get('meetup_login_consumer_secret', NULL),
);
+ $form['oauth']['meetup_login_group_url'] = array(
+ '#type' => 'textfield',
+ '#required' => TRUE,
+ '#title' => t('Enter group url name'),
+ '#default_value' => variable_get('meetup_login_group_url', NULL),
+ );
// Meetup external APIs settings.
$form['meetup'] = array(
@@ -198,6 +204,13 @@ function meetup_login_oauth_callback_form_validate($form, &$form_state) {
$url_self = 'https://api.meetup.com/members.json/?relation=self';
$test = $meetup->authrequest($url_self);
$results = json_decode($test, TRUE);
+ $group_url_name = variable_get('meetup_login_group_url');
+ $group_url = 'https://api.meetup.com/2/groups?&sign=true&group_urlname=' . $group_url_name . '&page=20';
+ $group_res = $meetup->authrequest($group_url);
+ $group_results = json_decode($group_res, TRUE);
+ $group_photo_link = isset($group_results['results'][0]['group_photo']) ? $group_results['results'][0]['group_photo']['photo_link'] : '';
+ $profile_photo_link = isset($results['results'][0]['photo_url']) ? $results['results'][0]['photo_url'] : '';
+ $photo_url = isset($group_photo_link) ? $group_photo_link : $profile_photo_link;
$name = array("name" => $results['results'][0]['name']);
$zip = array('zip' => $results['results'][0]['zip']);
$upper_country = $results['results'][0]['country'];
@@ -205,7 +218,7 @@ function meetup_login_oauth_callback_form_validate($form, &$form_state) {
$country = array('country' => $upper_country);
$state = array('state' => $results['results'][0]['state']);
$city = array('city' => $results['results'][0]['city']);
- $photo_url = array('photo_url' => $results['results'][0]['photo_url']);
+ $photo_url = array('photo_url' => $photo_url);
$twitter_identifier = array('twitter' => $results['results'][0]['other_services']['twitter']['identifier']);
$flicker_identifier = array('flickr' => $results['results'][0]['other_services']['flickr']['identifier']);
$facebook_identifier = array('facebook' => $results['results'][0]['other_services']['facebook']['identifier']);
diff --git a/meetupapi.lib.php b/meetupapi.lib.php
index 07fa095..85399e6 100644
--- a/meetupapi.lib.php
+++ b/meetupapi.lib.php
@@ -2,7 +2,7 @@
/**
* @file
* This file contains methods common to all client classes and serves as
- * the base class, providing properties that child classes should override.
+ * the base class, providing properties that child classes should override.
*/
/**
@@ -12,7 +12,7 @@
* it needs to be supplied the method for the API request.
* @package MeetupAPI
* @version $id$
- * @copyright 2010 WizOne Solutions
+ * @copyright 2010 WizOne Solutions
* @license GNU Public License Version 2.0
*/
/**