diff options
author | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2011-03-14 02:06:04 +0000 |
---|---|---|
committer | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2011-03-14 02:06:04 +0000 |
commit | 444611b49a56b2b282d0f9b9290d17aecd9ae321 (patch) | |
tree | accdc8b21c5b6c3612bad4c78512c5a7b23c9f3a /mod | |
parent | e62ce5cca46c015629b39c3356bdb5df65f1369e (diff) | |
download | elgg-444611b49a56b2b282d0f9b9290d17aecd9ae321.tar.gz elgg-444611b49a56b2b282d0f9b9290d17aecd9ae321.tar.bz2 |
Refs #3115. Migrated twitterservice to twitter_api. Added upgrade to migrate plugin and user settings.
git-svn-id: http://code.elgg.org/elgg/trunk@8699 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'mod')
-rw-r--r-- | mod/twitter_api/graphics/sign_in_with_twitter.gif (renamed from mod/twitterservice/graphics/sign_in_with_twitter.gif) | bin | 3028 -> 3028 bytes | |||
-rw-r--r-- | mod/twitter_api/languages/en.php | 34 | ||||
-rw-r--r-- | mod/twitter_api/lib/twitter_api.php (renamed from mod/twitterservice/twitterservice_lib.php) | 106 | ||||
-rw-r--r-- | mod/twitter_api/manifest.xml (renamed from mod/twitterservice/manifest.xml) | 2 | ||||
-rw-r--r-- | mod/twitter_api/start.php (renamed from mod/twitterservice/start.php) | 85 | ||||
-rwxr-xr-x | mod/twitter_api/vendors/twitteroauth/LICENSE (renamed from mod/twitterservice/vendors/twitteroauth/LICENSE) | 0 | ||||
-rwxr-xr-x | mod/twitter_api/vendors/twitteroauth/OAuth.php (renamed from mod/twitterservice/vendors/twitteroauth/OAuth.php) | 0 | ||||
-rwxr-xr-x | mod/twitter_api/vendors/twitteroauth/README (renamed from mod/twitterservice/vendors/twitteroauth/README) | 0 | ||||
-rwxr-xr-x | mod/twitter_api/vendors/twitteroauth/twitterOAuth.php (renamed from mod/twitterservice/vendors/twitteroauth/twitterOAuth.php) | 0 | ||||
-rw-r--r-- | mod/twitter_api/views/default/settings/twitter_api/edit.php (renamed from mod/twitterservice/views/default/settings/twitterservice/edit.php) | 8 | ||||
-rw-r--r-- | mod/twitter_api/views/default/twitter_api/css.php (renamed from mod/twitterservice/views/default/twitterservice/css.php) | 4 | ||||
-rw-r--r-- | mod/twitter_api/views/default/twitter_api/login.php (renamed from mod/twitterservice/views/default/twitterservice/login.php) | 4 | ||||
-rw-r--r-- | mod/twitter_api/views/default/twitter_api/metatags.php (renamed from mod/twitterservice/views/default/twitterservice/metatags.php) | 4 | ||||
-rw-r--r-- | mod/twitter_api/views/default/usersettings/twitter_api/edit.php | 22 | ||||
-rw-r--r-- | mod/twitterservice/languages/en.php | 32 | ||||
-rw-r--r-- | mod/twitterservice/views/default/usersettings/twitterservice/edit.php | 22 |
16 files changed, 171 insertions, 152 deletions
diff --git a/mod/twitterservice/graphics/sign_in_with_twitter.gif b/mod/twitter_api/graphics/sign_in_with_twitter.gif Binary files differindex a686590fc..a686590fc 100644 --- a/mod/twitterservice/graphics/sign_in_with_twitter.gif +++ b/mod/twitter_api/graphics/sign_in_with_twitter.gif diff --git a/mod/twitter_api/languages/en.php b/mod/twitter_api/languages/en.php new file mode 100644 index 000000000..b63cebcf8 --- /dev/null +++ b/mod/twitter_api/languages/en.php @@ -0,0 +1,34 @@ +<?php +/** + * An english language definition file + */ + +$english = array( + 'twitter_api' => 'Twitter Services', + + 'twitter_api:requires_oauth' => 'Twitter Services requires the OAuth Libraries plugin to be enabled.', + + 'twitter_api:consumer_key' => 'Consumer Key', + 'twitter_api:consumer_secret' => 'Consumer Secret', + + 'twitter_api:settings:instructions' => 'You must obtain a consumer key and secret from <a href="https://twitter.com/oauth_clients" target="_blank">Twitter</a>. Most of the fields are self explanatory, the one piece of data you will need is the callback url which takes the form http://[yoursite]/action/twitterlogin/return - [yoursite] is the url of your Elgg network.', + + 'twitter_api:usersettings:description' => "Link your %s account with Twitter.", + 'twitter_api:usersettings:request' => "You must first <a href=\"%s\">authorize</a> %s to access your Twitter account.", + 'twitter_api:authorize:error' => 'Unable to authorize Twitter.', + 'twitter_api:authorize:success' => 'Twitter access has been authorized.', + + 'twitter_api:usersettings:authorized' => "You have authorized %s to access your Twitter account: @%s.", + 'twitter_api:usersettings:revoke' => 'Click <a href="%s">here</a> to revoke access.', + 'twitter_api:revoke:success' => 'Twitter access has been revoked.', + + 'twitter_api:login' => 'Allow existing users who have connected their Twitter account to sign in with Twitter?', + 'twitter_api:new_users' => 'Allow new users to sign up using their Twitter account even if manual registration is disabled?', + 'twitter_api:login:success' => 'You have been logged in.', + 'twitter_api:login:error' => 'Unable to login with Twitter.', + 'twitter_api:login:email' => "You must enter a valid email address for your new %s account.", + + 'twitter_api:deprecated_callback_url' => 'The callback URL has changed for Twitter API to %s. Please ask your administrator to change it.', +); + +add_translation('en', $english); diff --git a/mod/twitterservice/twitterservice_lib.php b/mod/twitter_api/lib/twitter_api.php index 8e886f2d9..c7c31c76d 100644 --- a/mod/twitterservice/twitterservice_lib.php +++ b/mod/twitter_api/lib/twitter_api.php @@ -2,7 +2,7 @@ /** * Common library of functions used by Twitter Services. * - * @package TwitterService + * @package twitter_api */ /** @@ -11,16 +11,16 @@ * @param void * @return bool */ -function twitterservice_allow_sign_on_with_twitter() { - if (!$consumer_key = elgg_get_plugin_setting('consumer_key', 'twitterservice')) { +function twitter_api_allow_sign_on_with_twitter() { + if (!$consumer_key = elgg_get_plugin_setting('consumer_key', 'twitter_api')) { return FALSE; } - if (!$consumer_secret = elgg_get_plugin_setting('consumer_secret', 'twitterservice')) { + if (!$consumer_secret = elgg_get_plugin_setting('consumer_secret', 'twitter_api')) { return FALSE; } - return elgg_get_plugin_setting('sign_on', 'twitterservice') == 'yes'; + return elgg_get_plugin_setting('sign_on', 'twitter_api') == 'yes'; } /** @@ -28,31 +28,31 @@ function twitterservice_allow_sign_on_with_twitter() { * * @todo what is this? */ -function twitterservice_forward() { +function twitter_api_forward() { // sanity check - if (!twitterservice_allow_sign_on_with_twitter()) { + if (!twitter_api_allow_sign_on_with_twitter()) { forward(); } - $callback = elgg_normalize_url("twitterservice/login"); - $request_link = twitterservice_get_authorize_url($callback); + $callback = elgg_normalize_url("twitter_api/login"); + $request_link = twitter_api_get_authorize_url($callback); - forward($request_link, 'twitterservice'); + forward($request_link, 'twitter_api'); } /** * Log in a user with twitter. */ -function twitterservice_login() { +function twitter_api_login() { // sanity check - if (!twitterservice_allow_sign_on_with_twitter()) { + if (!twitter_api_allow_sign_on_with_twitter()) { forward(); } - $token = twitterservice_get_access_token(get_input('oauth_verifier')); + $token = twitter_api_get_access_token(get_input('oauth_verifier')); if (!isset($token['oauth_token']) or !isset($token['oauth_token_secret'])) { - register_error(elgg_echo('twitterservice:login:error')); + register_error(elgg_echo('twitter_api:login:error')); forward(); } @@ -71,19 +71,21 @@ function twitterservice_login() { if ($users) { if (count($users) == 1 && login($users[0])) { - system_message(elgg_echo('twitterservice:login:success')); + system_message(elgg_echo('twitter_api:login:success')); // trigger login hook - elgg_trigger_plugin_hook('login', 'twitterservice', array('user' => $users[0])); + elgg_trigger_plugin_hook('login', 'twitter_api', array('user' => $users[0])); } else { - system_message(elgg_echo('twitterservice:login:error')); + system_message(elgg_echo('twitter_api:login:error')); } forward(); } else { // need Twitter account credentials - $consumer_key = elgg_get_plugin_setting('consumer_key', 'twitterservice'); - $consumer_secret = elgg_get_plugin_setting('consumer_secret', 'twitterservice'); + elgg_load_library('twitter_oauth'); + + $consumer_key = elgg_get_plugin_setting('consumer_key', 'twitter_api'); + $consumer_secret = elgg_get_plugin_setting('consumer_secret', 'twitter_api'); $api = new TwitterOAuth($consumer_key, $consumer_secret, $token['oauth_token'], $token['oauth_token_secret']); $twitter = $api->get('account/verify_credentials'); @@ -100,7 +102,7 @@ function twitterservice_login() { // create new user if (!$user) { // check new registration allowed - if (!twitterservice_allow_new_users_with_twitter()) { + if (!twitter_api_allow_new_users_with_twitter()) { register_error(elgg_echo('registerdisabled')); forward(); } @@ -108,7 +110,7 @@ function twitterservice_login() { // trigger a hook for plugin authors to intercept if (!elgg_trigger_plugin_hook('new_twitter_user', 'twitter_service', array('account' => $twitter), TRUE)) { // halt execution - register_error(elgg_echo('twitterservice:login:error')); + register_error(elgg_echo('twitter_api:login:error')); forward(); } @@ -138,7 +140,7 @@ function twitterservice_login() { // @todo require email address? $site_name = elgg_get_site_entity()->name; - system_message(elgg_echo('twitterservice:login:email', array($site_name))); + system_message(elgg_echo('twitter_api:login:email', array($site_name))); $forward = "settings/user/{$user->username}"; } @@ -149,23 +151,23 @@ function twitterservice_login() { elgg_set_plugin_user_setting('access_secret', $token['oauth_token_secret'], $user->guid); // pull in Twitter icon - twitterservice_update_user_avatar($user, $twitter->profile_image_url); + twitter_api_update_user_avatar($user, $twitter->profile_image_url); // login new user if (login($user)) { - system_message(elgg_echo('twitterservice:login:success')); + system_message(elgg_echo('twitter_api:login:success')); // trigger login hook for new user - elgg_trigger_plugin_hook('first_login', 'twitterservice', array('user' => $user)); + elgg_trigger_plugin_hook('first_login', 'twitter_api', array('user' => $user)); } else { - system_message(elgg_echo('twitterservice:login:error')); + system_message(elgg_echo('twitter_api:login:error')); } - forward($forward, 'twitterservice'); + forward($forward, 'twitter_api'); } // register login error - register_error(elgg_echo('twitterservice:login:error')); + register_error(elgg_echo('twitter_api:login:error')); forward(); } @@ -175,7 +177,7 @@ function twitterservice_login() { * @param unknown_type $user * @param unknown_type $file_location */ -function twitterservice_update_user_avatar($user, $file_location) { +function twitter_api_update_user_avatar($user, $file_location) { $sizes = array( 'topbar' => array(16, 16, TRUE), 'tiny' => array(25, 25, TRUE), @@ -211,14 +213,14 @@ function twitterservice_update_user_avatar($user, $file_location) { * the authorization tokens. Will revoke access from previous users when a * conflict exists. * - * Depends upon {@link twitterservice_get_authorize_url} being called previously + * Depends upon {@link twitter_api_get_authorize_url} being called previously * to establish session request tokens. */ -function twitterservice_authorize() { - $token = twitterservice_get_access_token(); +function twitter_api_authorize() { + $token = twitter_api_get_access_token(); if (!isset($token['oauth_token']) || !isset($token['oauth_token_secret'])) { - register_error(elgg_echo('twitterservice:authorize:error')); - forward('settings/plugins', 'twitterservice'); + register_error(elgg_echo('twitter_api:authorize:error')); + forward('settings/plugins', 'twitter_api'); } // make sure no other users are registered to this twitter account. @@ -248,23 +250,23 @@ function twitterservice_authorize() { elgg_set_plugin_user_setting('access_secret', $token['oauth_token_secret']); // trigger authorization hook - elgg_trigger_plugin_hook('authorize', 'twitterservice', array('token' => $token)); + elgg_trigger_plugin_hook('authorize', 'twitter_api', array('token' => $token)); - system_message(elgg_echo('twitterservice:authorize:success')); - forward('settings/plugins', 'twitterservice'); + system_message(elgg_echo('twitter_api:authorize:success')); + forward('settings/plugins', 'twitter_api'); } /** * Remove twitter access for the currently logged in user. */ -function twitterservice_revoke() { +function twitter_api_revoke() { // unregister user's access tokens elgg_unset_plugin_user_setting('twitter_name'); elgg_unset_plugin_user_setting('access_key'); elgg_unset_plugin_user_setting('access_secret'); - system_message(elgg_echo('twitterservice:revoke:success')); - forward('settings/plugins', 'twitterservice'); + system_message(elgg_echo('twitter_api:revoke:success')); + forward('settings/plugins', 'twitter_api'); } /** @@ -272,18 +274,19 @@ function twitterservice_revoke() { * * @param string $callback The callback URL? */ -function twitterservice_get_authorize_url($callback = NULL) { +function twitter_api_get_authorize_url($callback = NULL) { global $SESSION; + elgg_load_library('twitter_oauth'); - $consumer_key = elgg_get_plugin_setting('consumer_key', 'twitterservice'); - $consumer_secret = elgg_get_plugin_setting('consumer_secret', 'twitterservice'); + $consumer_key = elgg_get_plugin_setting('consumer_key', 'twitter_api'); + $consumer_secret = elgg_get_plugin_setting('consumer_secret', 'twitter_api'); // request tokens from Twitter $twitter = new TwitterOAuth($consumer_key, $consumer_secret); $token = $twitter->getRequestToken($callback); // save token in session for use after authorization - $SESSION['twitterservice'] = array( + $SESSION['twitter_api'] = array( 'oauth_token' => $token['oauth_token'], 'oauth_token_secret' => $token['oauth_token_secret'], ); @@ -296,16 +299,17 @@ function twitterservice_get_authorize_url($callback = NULL) { * * @param unknown_type $oauth_verifier */ -function twitterservice_get_access_token($oauth_verifier = FALSE) { +function twitter_api_get_access_token($oauth_verifier = FALSE) { global $SESSION; + elgg_load_library('twitter_oauth'); - $consumer_key = elgg_get_plugin_setting('consumer_key', 'twitterservice'); - $consumer_secret = elgg_get_plugin_setting('consumer_secret', 'twitterservice'); + $consumer_key = elgg_get_plugin_setting('consumer_key', 'twitter_api'); + $consumer_secret = elgg_get_plugin_setting('consumer_secret', 'twitter_api'); // retrieve stored tokens - $oauth_token = $SESSION['twitterservice']['oauth_token']; - $oauth_token_secret = $SESSION['twitterservice']['oauth_token_secret']; - $SESSION->offsetUnset('twitterservice'); + $oauth_token = $SESSION['twitter_api']['oauth_token']; + $oauth_token_secret = $SESSION['twitter_api']['oauth_token_secret']; + $SESSION->offsetUnset('twitter_api'); // fetch an access token $api = new TwitterOAuth($consumer_key, $consumer_secret, $oauth_token, $oauth_token_secret); @@ -317,7 +321,7 @@ function twitterservice_get_access_token($oauth_verifier = FALSE) { * Admins can disable manual registration, but some might want to allow * twitter-only logins. */ -function twitterservice_allow_new_users_with_twitter() { +function twitter_api_allow_new_users_with_twitter() { $site_reg = elgg_get_config('allow_registration'); $twitter_reg = elgg_get_plugin_setting('new_users'); diff --git a/mod/twitterservice/manifest.xml b/mod/twitter_api/manifest.xml index aabc1cb30..fc0aa44c5 100644 --- a/mod/twitterservice/manifest.xml +++ b/mod/twitter_api/manifest.xml @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <plugin_manifest xmlns="http://www.elgg.org/plugin_manifest/1.8"> - <name>Twitter Services</name> + <name>Twitter API</name> <author>Core developers</author> <version>1.8</version> <description>Allows users to authenticate their Elgg account with Twitter.</description> diff --git a/mod/twitterservice/start.php b/mod/twitter_api/start.php index 33319a659..8a49db719 100644 --- a/mod/twitterservice/start.php +++ b/mod/twitter_api/start.php @@ -3,64 +3,77 @@ * Elgg Twitter Service * This service plugin allows users to authenticate their Elgg account with Twitter. * - * @package TwitterService + * @package TwitterAPI */ -elgg_register_event_handler('init', 'system', 'twitterservice_init'); +elgg_register_event_handler('init', 'system', 'twitter_api_init'); -function twitterservice_init() { - - $notice_id = 'twitter_services_disable'; - - // cleanup notices - elgg_delete_admin_notice($notice_id); +function twitter_api_init() { // require libraries - $base = elgg_get_plugins_path() . 'twitterservice'; - require_once "$base/vendors/twitteroauth/twitterOAuth.php"; - require_once "$base/twitterservice_lib.php"; + $base = elgg_get_plugins_path() . 'twitter_api'; + elgg_register_library('twitter_oauth', "$base/vendors/twitteroauth/twitterOAuth.php"); + elgg_register_library('twitter_api', "$base/lib/twitter_api.php"); + + elgg_load_library('twitter_api'); // extend site views - elgg_extend_view('metatags', 'twitterservice/metatags'); - elgg_extend_view('css', 'twitterservice/css'); + elgg_extend_view('metatags', 'twitter_api/metatags'); + elgg_extend_view('css', 'twitter_api/css'); // sign on with twitter - if (twitterservice_allow_sign_on_with_twitter()) { - elgg_extend_view('login/extend', 'twitterservice/login'); + if (twitter_api_allow_sign_on_with_twitter()) { + elgg_extend_view('login/extend', 'twitter_api/login'); } // register page handler - elgg_register_page_handler('twitterservice', 'twitterservice_pagehandler'); + elgg_register_page_handler('twitter_api', 'twitter_api_pagehandler'); + // backward compatibility + elgg_register_page_handler('twitterservice', 'twitter_api_pagehandler_deprecated'); // register Walled Garden public pages - elgg_register_plugin_hook_handler('public_pages', 'walled_garden', 'twitterservice_public_pages'); + elgg_register_plugin_hook_handler('public_pages', 'walled_garden', 'twitter_api_public_pages'); // allow plugin authors to hook into this service - elgg_register_plugin_hook_handler('tweet', 'twitter_service', 'twitterservice_tweet'); + elgg_register_plugin_hook_handler('tweet', 'twitter_service', 'twitter_api_tweet'); } /** + * Handles old pg/twitterservice/ handler + * + * @param array$page + */ +function twitter_api_pagehandler_deprecated($page) { + $url = elgg_get_site_url() . 'pg/twitter_api/authorize'; + $msg = elgg_echo('twitter_api:deprecated_callback_url', array($url)); + register_error($msg); + + return twitter_api_pagehandler($page); +} + + +/** * Serves pages for twitter. * * @param array$page */ -function twitterservice_pagehandler($page) { +function twitter_api_pagehandler($page) { if (!isset($page[0])) { forward(); } switch ($page[0]) { case 'authorize': - twitterservice_authorize(); + twitter_api_authorize(); break; case 'revoke': - twitterservice_revoke(); + twitter_api_revoke(); break; case 'forward': - twitterservice_forward(); + twitter_api_forward(); break; case 'login': - twitterservice_login(); + twitter_api_login(); break; default: forward(); @@ -76,7 +89,7 @@ function twitterservice_pagehandler($page) { * @param unknown_type $returnvalue * @param unknown_type $params */ -function twitterservice_tweet($hook, $entity_type, $returnvalue, $params) { +function twitter_api_tweet($hook, $entity_type, $returnvalue, $params) { static $plugins; if (!$plugins) { $plugins = elgg_trigger_plugin_hook('plugin_list', 'twitter_service', NULL, array()); @@ -88,16 +101,16 @@ function twitterservice_tweet($hook, $entity_type, $returnvalue, $params) { } // check admin settings - $consumer_key = elgg_get_plugin_setting('consumer_key', 'twitterservice'); - $consumer_secret = elgg_get_plugin_setting('consumer_secret', 'twitterservice'); + $consumer_key = elgg_get_plugin_setting('consumer_key', 'twitter_api'); + $consumer_secret = elgg_get_plugin_setting('consumer_secret', 'twitter_api'); if (!($consumer_key && $consumer_secret)) { return NULL; } // check user settings $user_id = elgg_get_logged_in_user_guid(); - $access_key = elgg_get_plugin_user_setting('access_key', $user_id, 'twitterservice'); - $access_secret = elgg_get_plugin_user_setting('access_secret', $user_id, 'twitterservice'); + $access_key = elgg_get_plugin_user_setting('access_key', $user_id, 'twitter_api'); + $access_secret = elgg_get_plugin_user_setting('access_secret', $user_id, 'twitter_api'); if (!($access_key && $access_secret)) { return NULL; } @@ -115,17 +128,17 @@ function twitterservice_tweet($hook, $entity_type, $returnvalue, $params) { * @param int $user_id The Elgg user GUID * @param array $options */ -function twitterservice_fetch_tweets($user_guid, $options=array()) { +function twitter_api_fetch_tweets($user_guid, $options=array()) { // check admin settings - $consumer_key = elgg_get_plugin_setting('consumer_key', 'twitterservice'); - $consumer_secret = elgg_get_plugin_setting('consumer_secret', 'twitterservice'); + $consumer_key = elgg_get_plugin_setting('consumer_key', 'twitter_api'); + $consumer_secret = elgg_get_plugin_setting('consumer_secret', 'twitter_api'); if (!($consumer_key && $consumer_secret)) { return FALSE; } // check user settings - $access_key = elgg_get_plugin_user_setting('access_key', $user_guid, 'twitterservice'); - $access_secret = elgg_get_plugin_user_setting('access_secret', $user_guid, 'twitterservice'); + $access_key = elgg_get_plugin_user_setting('access_key', $user_guid, 'twitter_api'); + $access_secret = elgg_get_plugin_user_setting('access_secret', $user_guid, 'twitter_api'); if (!($access_key && $access_secret)) { return FALSE; } @@ -143,9 +156,9 @@ function twitterservice_fetch_tweets($user_guid, $options=array()) { * @param unknown_type $return_value * @param unknown_type $params */ -function twitterservice_public_pages($hook, $type, $return_value, $params) { - $return_value[] = 'twitterservice/forward'; - $return_value[] = 'twitterservice/login'; +function twitter_api_public_pages($hook, $type, $return_value, $params) { + $return_value[] = 'twitter_api/forward'; + $return_value[] = 'twitter_api/login'; return $return_value; } diff --git a/mod/twitterservice/vendors/twitteroauth/LICENSE b/mod/twitter_api/vendors/twitteroauth/LICENSE index 233854f16..233854f16 100755 --- a/mod/twitterservice/vendors/twitteroauth/LICENSE +++ b/mod/twitter_api/vendors/twitteroauth/LICENSE diff --git a/mod/twitterservice/vendors/twitteroauth/OAuth.php b/mod/twitter_api/vendors/twitteroauth/OAuth.php index b0e3cfd5e..b0e3cfd5e 100755 --- a/mod/twitterservice/vendors/twitteroauth/OAuth.php +++ b/mod/twitter_api/vendors/twitteroauth/OAuth.php diff --git a/mod/twitterservice/vendors/twitteroauth/README b/mod/twitter_api/vendors/twitteroauth/README index 33cb91f21..33cb91f21 100755 --- a/mod/twitterservice/vendors/twitteroauth/README +++ b/mod/twitter_api/vendors/twitteroauth/README diff --git a/mod/twitterservice/vendors/twitteroauth/twitterOAuth.php b/mod/twitter_api/vendors/twitteroauth/twitterOAuth.php index a1021ce6f..a1021ce6f 100755 --- a/mod/twitterservice/vendors/twitteroauth/twitterOAuth.php +++ b/mod/twitter_api/vendors/twitteroauth/twitterOAuth.php diff --git a/mod/twitterservice/views/default/settings/twitterservice/edit.php b/mod/twitter_api/views/default/settings/twitter_api/edit.php index 1e7dc1edd..9deac3989 100644 --- a/mod/twitterservice/views/default/settings/twitterservice/edit.php +++ b/mod/twitter_api/views/default/settings/twitter_api/edit.php @@ -4,21 +4,21 @@ */ $insert_view = elgg_view('twittersettings/extend'); -$consumer_key_string = elgg_echo('twitterservice:consumer_key'); +$consumer_key_string = elgg_echo('twitter_api:consumer_key'); $consumer_key_view = elgg_view('input/text', array( 'name' => 'params[consumer_key]', 'value' => $vars['entity']->consumer_key, 'class' => 'text_input', )); -$consumer_secret_string = elgg_echo('twitterservice:consumer_secret'); +$consumer_secret_string = elgg_echo('twitter_api:consumer_secret'); $consumer_secret_view = elgg_view('input/text', array( 'name' => 'params[consumer_secret]', 'value' => $vars['entity']->consumer_secret, 'class' => 'text_input', )); -$sign_on_with_twitter_string = elgg_echo('twitterservice:login'); +$sign_on_with_twitter_string = elgg_echo('twitter_api:login'); $sign_on_with_twitter_view = elgg_view('input/dropdown', array( 'name' => 'params[sign_on]', 'options_values' => array( @@ -28,7 +28,7 @@ $sign_on_with_twitter_view = elgg_view('input/dropdown', array( 'value' => $vars['entity']->sign_on ? $vars['entity']->sign_on : 'no', )); -$new_users_with_twitter = elgg_echo('twitterservice:new_users'); +$new_users_with_twitter = elgg_echo('twitter_api:new_users'); $new_users_with_twitter_view = elgg_view('input/dropdown', array( 'name' => 'params[new_users]', 'options_values' => array( diff --git a/mod/twitterservice/views/default/twitterservice/css.php b/mod/twitter_api/views/default/twitter_api/css.php index 572144067..140ce6a52 100644 --- a/mod/twitterservice/views/default/twitterservice/css.php +++ b/mod/twitter_api/views/default/twitter_api/css.php @@ -1,10 +1,10 @@ <?php /** - * Elgg TwitterService CSS + * Elgg Twitter API CSS */ ?> -#twitterservice_site_settings .text_input { +#twitter_api_site_settings .text_input { width: 350px; } #login_with_twitter { diff --git a/mod/twitterservice/views/default/twitterservice/login.php b/mod/twitter_api/views/default/twitter_api/login.php index d4bc04150..d0aca87ac 100644 --- a/mod/twitterservice/views/default/twitterservice/login.php +++ b/mod/twitter_api/views/default/twitter_api/login.php @@ -3,8 +3,8 @@ * */ -$url = elgg_get_site_url() . 'twitterservice/forward'; -$img_url = elgg_get_site_url() . 'mod/twitterservice/graphics/sign_in_with_twitter.gif'; +$url = elgg_get_site_url() . 'twitter_api/forward'; +$img_url = elgg_get_site_url() . 'mod/twitter_api/graphics/sign_in_with_twitter.gif'; $login = <<<__HTML <div id="login_with_twitter"> diff --git a/mod/twitterservice/views/default/twitterservice/metatags.php b/mod/twitter_api/views/default/twitter_api/metatags.php index 64c9910fb..67c66dc37 100644 --- a/mod/twitterservice/views/default/twitterservice/metatags.php +++ b/mod/twitter_api/views/default/twitter_api/metatags.php @@ -2,10 +2,10 @@ /** * Adds required HTML head tags for Twitter Services. * - * @package TwitterService + * @package TwitterAPI */ -if ($api_key = elgg_get_plugin_setting('consumer_key', 'twitterservice')) { +if ($api_key = elgg_get_plugin_setting('consumer_key', 'twitter_api')) { $tags = <<<__HTML <script src="http://platform.twitter.com/anywhere.js?id=$api_key&v=1" type="text/javascript"></script> <script type="text/javascript"> diff --git a/mod/twitter_api/views/default/usersettings/twitter_api/edit.php b/mod/twitter_api/views/default/usersettings/twitter_api/edit.php new file mode 100644 index 000000000..77dd5cc5d --- /dev/null +++ b/mod/twitter_api/views/default/usersettings/twitter_api/edit.php @@ -0,0 +1,22 @@ +<?php +/** + * + */ + +$user_id = elgg_get_logged_in_user_guid(); +$twitter_name = get_plugin_usersetting('twitter_name', $user_id, 'twitter_api'); +$access_key = get_plugin_usersetting('access_key', $user_id, 'twitter_api'); +$access_secret = get_plugin_usersetting('access_secret', $user_id, 'twitter_api'); + +$site_name = elgg_get_site_entity()->name; +echo '<div>' . elgg_echo('twitter_api:usersettings:description', array($site_name)) . '</div>'; + +if (!$access_key || !$access_secret) { + // send user off to validate account + $request_link = twitter_api_get_authorize_url(); + echo '<div>' . elgg_echo('twitter_api:usersettings:request', array($request_link, $site_name)) . '</div>'; +} else { + $url = elgg_get_site_url() . "twitter_api/revoke"; + echo '<div class="twitter_anywhere">' . elgg_echo('twitter_api:usersettings:authorized', array($site_name, $twitter_name)) . '</div>'; + echo '<div>' . sprintf(elgg_echo('twitter_api:usersettings:revoke'), $url) . '</div>'; +} diff --git a/mod/twitterservice/languages/en.php b/mod/twitterservice/languages/en.php deleted file mode 100644 index 78d5877b2..000000000 --- a/mod/twitterservice/languages/en.php +++ /dev/null @@ -1,32 +0,0 @@ -<?php -/** - * An english language definition file - */ - -$english = array( - 'twitterservice' => 'Twitter Services', - - 'twitterservice:requires_oauth' => 'Twitter Services requires the OAuth Libraries plugin to be enabled.', - - 'twitterservice:consumer_key' => 'Consumer Key', - 'twitterservice:consumer_secret' => 'Consumer Secret', - - 'twitterservice:settings:instructions' => 'You must obtain a consumer key and secret from <a href="https://twitter.com/oauth_clients" target="_blank">Twitter</a>. Most of the fields are self explanatory, the one piece of data you will need is the callback url which takes the form http://[yoursite]/action/twitterlogin/return - [yoursite] is the url of your Elgg network.', - - 'twitterservice:usersettings:description' => "Link your %s account with Twitter.", - 'twitterservice:usersettings:request' => "You must first <a href=\"%s\">authorize</a> %s to access your Twitter account.", - 'twitterservice:authorize:error' => 'Unable to authorize Twitter.', - 'twitterservice:authorize:success' => 'Twitter access has been authorized.', - - 'twitterservice:usersettings:authorized' => "You have authorized %s to access your Twitter account: @%s.", - 'twitterservice:usersettings:revoke' => 'Click <a href="%s">here</a> to revoke access.', - 'twitterservice:revoke:success' => 'Twitter access has been revoked.', - - 'twitterservice:login' => 'Allow existing users who have connected their Twitter account to sign in with Twitter?', - 'twitterservice:new_users' => 'Allow new users to sign up using their Twitter account even if manual registration is disabled?', - 'twitterservice:login:success' => 'You have been logged in.', - 'twitterservice:login:error' => 'Unable to login with Twitter.', - 'twitterservice:login:email' => "You must enter a valid email address for your new %s account.", -); - -add_translation('en', $english);
\ No newline at end of file diff --git a/mod/twitterservice/views/default/usersettings/twitterservice/edit.php b/mod/twitterservice/views/default/usersettings/twitterservice/edit.php deleted file mode 100644 index 2a5ef8b05..000000000 --- a/mod/twitterservice/views/default/usersettings/twitterservice/edit.php +++ /dev/null @@ -1,22 +0,0 @@ -<?php -/** - * - */ - -$user_id = elgg_get_logged_in_user_guid(); -$twitter_name = get_plugin_usersetting('twitter_name', $user_id, 'twitterservice'); -$access_key = get_plugin_usersetting('access_key', $user_id, 'twitterservice'); -$access_secret = get_plugin_usersetting('access_secret', $user_id, 'twitterservice'); - -$site_name = elgg_get_site_entity()->name; -echo '<div>' . elgg_echo('twitterservice:usersettings:description', array($site_name)) . '</div>'; - -if (!$access_key || !$access_secret) { - // send user off to validate account - $request_link = twitterservice_get_authorize_url(); - echo '<div>' . elgg_echo('twitterservice:usersettings:request', array($request_link, $site_name)) . '</div>'; -} else { - $url = elgg_get_site_url() . "twitterservice/revoke"; - echo '<div class="twitter_anywhere">' . elgg_echo('twitterservice:usersettings:authorized', array($site_name, $twitter_name)) . '</div>'; - echo '<div>' . sprintf(elgg_echo('twitterservice:usersettings:revoke'), $url) . '</div>'; -} |