isConfigured() public method

public isConfigured ( ) : boolean
return boolean
 public function authControl()
 {
     $config = Config::getInstance();
     Loader::definePathConstants();
     $this->setViewTemplate(THINKUP_WEBAPP_PATH . 'plugins/twitter/view/twitter.account.index.tpl');
     $this->view_mgr->addHelp('twitter', 'userguide/settings/plugins/twitter/index');
     $instance_dao = DAOFactory::getDAO('InstanceDAO');
     // get plugin option values if defined...
     $plugin_options = $this->getPluginOptions();
     $oauth_consumer_key = $this->getPluginOption('oauth_consumer_key');
     $oauth_consumer_secret = $this->getPluginOption('oauth_consumer_secret');
     $archive_limit = $this->getPluginOption('archive_limit');
     $num_twitter_errors = $this->getPluginOption('num_twitter_errors');
     $this->addToView('twitter_app_name', "ThinkUp " . $_SERVER['SERVER_NAME']);
     $this->addToView('thinkup_site_url', Utils::getApplicationURL(true));
     $plugin = new TwitterPlugin();
     if ($plugin->isConfigured()) {
         $this->addToView('is_configured', true);
         $owner_instances = $instance_dao->getByOwnerAndNetwork($this->owner, 'twitter');
         $this->addToView('owner_instances', $owner_instances);
         if (isset($this->owner) && $this->owner->isMemberAtAnyLevel()) {
             if ($this->owner->isMemberLevel()) {
                 if (sizeof($owner_instances) > 0) {
                     $this->do_show_add_button = false;
                     $this->addInfoMessage("To connect another Twitter account to ThinkUp, upgrade your membership.", 'membership_cap');
                 }
             }
         }
         if (isset($_GET['oauth_token']) || $this->do_show_add_button) {
             $twitter_oauth = new TwitterOAuth($oauth_consumer_key, $oauth_consumer_secret);
             /* Request tokens from twitter */
             $token_array = $twitter_oauth->getRequestToken(Utils::getApplicationURL(true) . "account/?p=twitter");
             if (isset($token_array['oauth_token']) || isset($_SESSION["MODE"]) && $_SESSION["MODE"] == "TESTS" || getenv("MODE") == "TESTS") {
                 //testing
                 $token = $token_array['oauth_token'];
                 SessionCache::put('oauth_request_token_secret', $token_array['oauth_token_secret']);
                 if (isset($_GET['oauth_token'])) {
                     self::addAuthorizedUser($oauth_consumer_key, $oauth_consumer_secret, $num_twitter_errors);
                 }
                 if ($this->do_show_add_button) {
                     /* Build the authorization URL */
                     $oauthorize_link = $twitter_oauth->getAuthorizeURL($token);
                     $this->addToView('oauthorize_link', $oauthorize_link);
                 }
             } else {
                 //set error message here
                 $this->addErrorMessage("Unable to obtain OAuth tokens from Twitter. Please double-check the consumer key and secret " . "are correct.", "setup");
                 $oauthorize_link = '';
                 $this->addToView('is_configured', false);
             }
         }
     } else {
         $this->addInfoMessage('Please complete plugin setup to start using it.', 'setup');
         $this->addToView('is_configured', false);
     }
     // add plugin options from
     $this->addOptionForm();
     return $this->generateView();
 }
 public function authControl()
 {
     $config = Config::getInstance();
     Loader::definePathConstants();
     $this->setViewTemplate(THINKUP_WEBAPP_PATH . 'plugins/twitter/view/twitter.account.index.tpl');
     $this->view_mgr->addHelp('twitter', 'userguide/settings/plugins/twitter');
     $id = DAOFactory::getDAO('InstanceDAO');
     $od = DAOFactory::getDAO('OwnerDAO');
     // get plugin option values if defined...
     $plugin_options = $this->getPluginOptions();
     $oauth_consumer_key = $this->getPluginOption('oauth_consumer_key');
     $oauth_consumer_secret = $this->getPluginOption('oauth_consumer_secret');
     $archive_limit = $this->getPluginOption('archive_limit');
     $num_twitter_errors = $this->getPluginOption('num_twitter_errors');
     $max_api_calls_per_crawl = $this->getPluginOption('max_api_calls_per_crawl');
     //Add public user instance
     if (isset($_GET['twitter_username'])) {
         // if form was submitted
         $logger = Logger::getInstance();
         $api = new TwitterAPIAccessorOAuth('NOAUTH', 'NOAUTH', $oauth_consumer_key, $oauth_consumer_secret, $num_twitter_errors, $max_api_calls_per_crawl);
         $api_call = str_replace("[id]", $_GET['twitter_username'], $api->cURL_source['show_user']);
         list($cURL_status, $data) = $api->apiRequestFromWebapp($api_call);
         if ($cURL_status == 200) {
             $thisFeed = array();
             try {
                 $xml = $api->createParserFromString(utf8_encode($data));
                 $user = array('user_id' => $xml->id, 'user_name' => $xml->screen_name, 'is_protected' => $xml->protected);
             } catch (Exception $e) {
                 $this->addErrorMessage($e->getMessage());
             }
             if (isset($user) && $user["is_protected"] == 'false') {
                 // if so, add to instances table and owners table
                 $i = $id->getByUsernameOnNetwork($_GET['twitter_username'], 'twitter');
                 $oid = DAOFactory::getDAO('OwnerInstanceDAO');
                 $msg = '';
                 if (isset($i)) {
                     //Instance exists
                     $oi = $oid->get($this->owner->id, $i->id);
                     if ($oi == null) {
                         //Owner_instance doesn't exist
                         $oid->insert($this->owner->id, $i->id, '', '');
                     }
                 } else {
                     //Instance does not exist
                     $id->insert($user["user_id"], $user["user_name"]);
                     $i = $id->getByUsernameOnNetwork($user["user_name"], 'twitter');
                     $oid->insert($this->owner->id, $i->id, '', '');
                 }
                 $this->addSuccessMessage($_GET['twitter_username'] . " has been added to ThinkUp.");
                 $this->addSuccessMessage("Added " . $_GET['twitter_username'] . " to ThinkUp.");
             } else {
                 // if not, return error
                 $this->addErrorMessage($_GET['twitter_username'] . " is a private Twitter account; ThinkUp cannot track it without authorization.");
             }
         } else {
             $this->addErrorMessage($_GET['twitter_username'] . " is not a valid Twitter username.");
         }
     }
     $this->addToView('twitter_app_name', "ThinkUp " . $_SERVER['SERVER_NAME']);
     $this->addToView('thinkup_site_url', Utils::getApplicationURL(true));
     $plugin = new TwitterPlugin();
     if ($plugin->isConfigured()) {
         $to = new TwitterOAuth($oauth_consumer_key, $oauth_consumer_secret);
         /* Request tokens from twitter */
         $tok = $to->getRequestToken(Utils::getApplicationURL(true) . "plugins/twitter/auth.php");
         if (isset($tok['oauth_token']) || isset($_SESSION["MODE"]) && $_SESSION["MODE"] == "TESTS" || getenv("MODE") == "TESTS") {
             //testing
             $token = $tok['oauth_token'];
             SessionCache::put('oauth_request_token_secret', $tok['oauth_token_secret']);
             /* Build the authorization URL */
             $oauthorize_link = $to->getAuthorizeURL($token);
             $owner_instances = $id->getByOwnerAndNetwork($this->owner, 'twitter');
             $this->addToView('owner_instances', $owner_instances);
             $this->addToView('oauthorize_link', $oauthorize_link);
             $this->addToView('is_configured', true);
         } else {
             //set error message here
             $this->addErrorMessage("Unable to obtain OAuth tokens from Twitter. Please double-check the consumer key and secret " . "are correct.", "setup");
             $oauthorize_link = '';
             $this->addToView('is_configured', false);
         }
     } else {
         $this->addInfoMessage('Please complete plugin setup to start using it.', 'setup');
         $this->addToView('is_configured', false);
     }
     // Secret config file value enables public Twitter name search
     $this->addToView('enable_twitter_search', $config->getValue('enable_twitter_search'));
     // add plugin options from
     $this->addOptionForm();
     return $this->generateView();
 }