src/plugins/twitter/README -text
src/plugins/twitter/common/twitter-init.php -text
src/plugins/twitter/etc/twitter.ini -text
+src/plugins/twitter/include/twitterPlugin.class.php -text
src/plugins/twitter/packaging/control/222plugin-twitter -text
src/plugins/twitter/packaging/control/222plugin-twitter.shortdesc -text
src/plugins/twitter/packaging/dirs/plugin-twitter -text
src/plugins/twitter/packaging/install/plugin-twitter -text
src/plugins/twitter/packaging/links/plugin-twitter -text
+src/plugins/twitter/www/checks.php -text
+src/plugins/twitter/www/index.php -text
src/plugins/wiki/README -text
src/plugins/wiki/common/WikiGroupSearchEngine.class.php -text
src/plugins/wiki/common/WikiHtmlSearchRenderer.class.php -text
--- /dev/null
+<?php
+
+class twitterPlugin extends ForgeAuthPlugin {
+
+ public function __construct() {
+
+ $this->ForgeAuthPlugin() ;
+
+ $this->name = 'twitter';
+ $this->text = 'Twitter'; // To show in the tabs, use...
+ $this->_addHook("user_personal_links");//to make a link to the user's personal part of the plugin
+ $this->_addHook("usermenu");
+ $this->_addHook("userisactivecheckbox"); // The "use ..." checkbox in user account
+ $this->_addHook("userisactivecheckboxpost"); //
+
+ }
+
+ function usermenu() {
+ global $G_SESSION,$HTML;
+ $text = $this->text; // this is what shows in the tab
+ if ($G_SESSION->usesPlugin($this->name)) {
+ echo $HTML->PrintSubMenu (array ($text), array ('/plugins/twitter/index.php') );
+ }
+ }
+
+}
--- /dev/null
+<?php
+
+/*
+ * This file contains the functionality of the different checks
+ * needed to be done before displaying any page of the
+ * twitter plugin
+ */
+
+require_once $gfwww.'include/pre.php';
+
+$pluginname = 'twitter';
+
+$tabs = array( "Home",
+ "Public",
+ "My tweets",
+ "Post a tweet",
+ "Other API requests");
+
+$tablinks = array( '/plugins/'.$pluginname.'/index.php',
+ '/plugins/'.$pluginname.'/index.php?list=public',
+ '/plugins/'.$pluginname.'/index.php?list=user',
+ '/plugins/'.$pluginname.'/post.php',
+ '/plugins/'.$pluginname.'/others.php');
+
+// the header that displays for the user portion of the plugin
+function twitter_User_Header($params) {
+ global $DOCUMENT_ROOT,$HTML, $user_id, $pluginname;
+ $params['toptab']=$pluginname;
+ $params['user']=$user_id;
+ site_user_header($params);
+}
+
+/*
+ * checks whether the user is logged in and has activated the plugin
+ */
+function twitter_CheckUser() {
+
+ if (!session_loggedin()) { //check if user logged in
+ exit_not_logged_in();
+ }
+
+ global $pluginname;
+
+ $user = session_get_user(); // get the session user
+
+ if (!$user || !is_object($user) || $user->isError() || !$user->isActive()) {
+ exit_error("Invalid User, Cannot Process your request for this user.", $pluginname);
+ }
+
+ $id = $user->getID();
+
+ if (!$id) {
+ exit_error("Cannot Process your request: Invalid User", $pluginname);
+ }
+
+ $realuser = user_get_object($id);
+ if (!($realuser) || !($realuser->usesPlugin($pluginname))) { //check if user has activated the plugin
+ exit_error("First activate the User's $pluginname plugin through Account Maintenance Page", $pluginname);
+ }
+
+ //displays the page header and toolbar
+ twitter_User_Header();
+ twitter_toolbar();
+
+}
+
+function twitter_toolbar() {
+ global $tabs, $tablinks;
+ echo '<ul class="widget_toolbar">';
+ for($i=0; $i<count($tabs); $i++) {
+ echo "<li>".util_make_link($tablinks[$i], _($tabs[$i]))."</li>";
+ }
+ echo '</ul>';
+}
+
+function twitter_get_access_token() {
+ $userid = session_get_user()->getID();
+
+ $providers = OAuthProvider::get_all_oauthproviders();
+ foreach ($providers as $provider) {
+ if(strcasecmp(trim($provider->get_name()), "twitter")==0) {
+ $twitter_provider = $provider;
+ }
+ }
+
+ if($twitter_provider) {
+ $access_tokens = OAuthAccessToken::get_all_access_tokens_by_provider($twitter_provider->get_id(), $userid);
+
+ if($access_tokens) {
+ $twitter_token = $access_tokens[0];
+ for ($i=1; $i<count($access_tokens); $i++) {
+ //get the latest access token
+ if($access_token[$i]->get_time_stamp()>$twitter_token->get_time_stamp()) {
+ $twitter_token = $access_tokens[$i];
+ }
+ }
+ return array($twitter_provider, $twitter_token);
+ }else {
+ exit_error(_('You have no Twitter Access Tokens registered in the database currently'));
+ }
+ }else {
+ //error
+ exit_error(_("Couldn't find a twitter provider registered in the database. If a twitter provider exists, it needs to be named 'Twitter', else it has to be created in the OAuth Consumer plugin"));
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+
+require_once('../../env.inc.php');
+require_once 'checks.php';
+
+twitter_CheckUser();
+list($twitter_provider, $twitter_token) = twitter_get_access_token();
+
+if($_GET['list']=="public") {
+ $resource_url = "http://api.twitter.com/1/statuses/public_timeline.json";
+}if($_GET['list']=="user") {
+ $resource_url = "http://api.twitter.com/1/statuses/user_timeline.json";
+}else {
+ $resource_url = "http://api.twitter.com/1/statuses/home_timeline.json";
+}
+
+$http_method = "get";
+
+$resource = new OAuthResource($resource_url, $twitter_provider->get_id(), $http_method);
+$transaction = new OAuthTransaction($twitter_provider, $twitter_token, $resource);
+$response = $transaction->send_request();
+$response_array = json_decode($response);
+//print_r($response_array[0]->user);
+
+echo '<table cellpadding="10">';
+foreach ($response_array as $tweet) {
+ echo '<tr><th rowspan="2"><img src="'.$tweet->user->profile_image_url.'" alt="twitter"></th>';
+ echo '<th valign="bottom">'.$tweet->user->name.'</th></tr>';
+ echo '<tr><td valign="top">'.$tweet->text.'</th></tr>';
+}
+echo '</table>';
+
+site_user_footer();
\ No newline at end of file