aboutsummaryrefslogtreecommitdiff
path: root/mod/twitter_api/views/default/plugins
diff options
context:
space:
mode:
authorBrett Profitt <brett.profitt@gmail.com>2011-09-29 18:16:03 -0700
committerBrett Profitt <brett.profitt@gmail.com>2011-09-29 18:16:03 -0700
commitbfdb9bb8a87a29038ba1ae25355684ae19678fdd (patch)
treea074e2d6bfa19c17b284c3950b4555cf584eabe2 /mod/twitter_api/views/default/plugins
parent7be23080f34a8f92ca1f8d49c3aa0e6ce3472f4c (diff)
parenta458ae4e0f8e5b19884860fead6e5f901b95eca4 (diff)
downloadelgg-bfdb9bb8a87a29038ba1ae25355684ae19678fdd.tar.gz
elgg-bfdb9bb8a87a29038ba1ae25355684ae19678fdd.tar.bz2
Merge branch 'master' of github.com:brettp/Elgg
Diffstat (limited to 'mod/twitter_api/views/default/plugins')
-rw-r--r--mod/twitter_api/views/default/plugins/twitter_api/settings.php50
-rw-r--r--mod/twitter_api/views/default/plugins/twitter_api/usersettings.php29
2 files changed, 79 insertions, 0 deletions
diff --git a/mod/twitter_api/views/default/plugins/twitter_api/settings.php b/mod/twitter_api/views/default/plugins/twitter_api/settings.php
new file mode 100644
index 000000000..0b9afd4cf
--- /dev/null
+++ b/mod/twitter_api/views/default/plugins/twitter_api/settings.php
@@ -0,0 +1,50 @@
+<?php
+/**
+ * Twitter API plugin settings
+ */
+
+$instructions = elgg_echo('twitter_api:settings:instructions', array(elgg_get_site_url()));
+
+$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' => 'elgg-input-thin',
+));
+
+$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' => 'elgg-input-thin',
+));
+
+$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(
+ 'yes' => elgg_echo('option:yes'),
+ 'no' => elgg_echo('option:no'),
+ ),
+ 'value' => $vars['entity']->sign_on ? $vars['entity']->sign_on : 'no',
+));
+
+$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(
+ 'yes' => elgg_echo('option:yes'),
+ 'no' => elgg_echo('option:no'),
+ ),
+ 'value' => $vars['entity']->new_users ? $vars['entity']->new_users : 'no',
+));
+
+$settings = <<<__HTML
+<div class="elgg-content-thin mtm"><p>$instructions</p></div>
+<div><label>$consumer_key_string</label><br /> $consumer_key_view</div>
+<div><label>$consumer_secret_string</label><br /> $consumer_secret_view</div>
+<div>$sign_on_with_twitter_string $sign_on_with_twitter_view</div>
+<div>$new_users_with_twitter $new_users_with_twitter_view</div>
+__HTML;
+
+echo $settings;
diff --git a/mod/twitter_api/views/default/plugins/twitter_api/usersettings.php b/mod/twitter_api/views/default/plugins/twitter_api/usersettings.php
new file mode 100644
index 000000000..65d04b883
--- /dev/null
+++ b/mod/twitter_api/views/default/plugins/twitter_api/usersettings.php
@@ -0,0 +1,29 @@
+<?php
+/**
+ * User settings for Twitter API
+ */
+
+$user = elgg_get_logged_in_user_entity();
+$user_guid = $user->getGUID();
+$twitter_name = elgg_get_plugin_user_setting('twitter_name', $user_guid, 'twitter_api');
+$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');
+
+$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(null, false);
+ echo '<div>' . elgg_echo('twitter_api:usersettings:request', array($request_link, $site_name)) . '</div>';
+} else {
+ // if this user logged in through twitter and never set up an email address, don't
+ // let them disassociate their account.
+ if ($user->email) {
+ $url = elgg_get_site_url() . "twitter_api/revoke";
+ echo '<div>' . elgg_echo('twitter_api:usersettings:authorized', array($site_name, $twitter_name)) . '</div>';
+ echo '<div>' . sprintf(elgg_echo('twitter_api:usersettings:revoke'), $url) . '</div>';
+ } else {
+ echo elgg_echo('twitter_api:usersettings:cannot_revoke', array(elgg_normalize_url('twitter_api/interstitial')));
+ }
+}