public function authControl()
 {
     $config = Config::getInstance();
     Loader::definePathConstants();
     $this->setViewTemplate(THINKUP_WEBAPP_PATH . 'plugins/instagram/view/instagram.account.index.tpl');
     $this->view_mgr->addHelp('instagram', 'userguide/settings/plugins/instagram');
     /** set option fields **/
     // Application ID text field
     $this->addPluginOption(self::FORM_TEXT_ELEMENT, array('name' => 'instagram_app_id', 'label' => 'Client ID', 'size' => 18));
     // add element
     // set a special required message
     $this->addPluginOptionRequiredMessage('instagram_app_id', 'The instagram plugin requires a valid Client ID.');
     // Application Secret text field
     $this->addPluginOption(self::FORM_TEXT_ELEMENT, array('name' => 'instagram_api_secret', 'label' => 'Client Secret', 'size' => 37));
     // add element
     // set a special required message
     $this->addPluginOptionRequiredMessage('instagram_api_secret', 'The instagram plugin requires a valid Client Secret.');
     $max_crawl_time_label = 'Max crawl time in minutes';
     $max_crawl_time = array('name' => 'max_crawl_time', 'label' => $max_crawl_time_label, 'default_value' => '20', 'advanced' => true, 'size' => 3);
     $this->addPluginOption(self::FORM_TEXT_ELEMENT, $max_crawl_time);
     $this->addToView('thinkup_site_url', Utils::getApplicationURL());
     $instagram_plugin = new InstagramPlugin();
     if ($instagram_plugin->isConfigured()) {
         $this->setUpInstagramInteractions($instagram_plugin->getOptionsHash());
         $this->addToView('is_configured', true);
     } else {
         $this->addInfoMessage('Please complete plugin setup to start using it.', 'setup');
         $this->addToView('is_configured', false);
     }
     return $this->generateView();
 }
Пример #2
0
 public function testDeactivate()
 {
     //all instagram accounts should be set to inactive on plugin deactivation
     $webapp_plugin_registrar = PluginRegistrarWebapp::getInstance();
     $logger = Logger::getInstance();
     $pd = DAOFactory::getDAO('PostDAO');
     $instance = new Instance();
     $instance->network_user_id = 1;
     $instance_builder_1 = FixtureBuilder::build('instances', array('network_username' => 'julie', 'network' => 'instagram', 'crawler_last_run' => '-1d', 'is_activated' => '1', 'is_public' => '1'));
     $instance_dao = DAOFactory::getDAO('InstanceDAO');
     $fb_active_instances = $instance_dao->getAllInstances("DESC", true, "instagram");
     $this->assertEqual(sizeof($fb_active_instances), 1);
     $fb_plugin = new InstagramPlugin();
     $fb_plugin->deactivate();
     $fb_active_instances = $instance_dao->getAllInstances("DESC", true, "instagram");
     $this->assertEqual(sizeof($fb_active_instances), 0);
     $logger->close();
 }
 public function authControl()
 {
     $config = Config::getInstance();
     Loader::definePathConstants();
     $this->setViewTemplate(THINKUP_WEBAPP_PATH . 'plugins/instagram/view/instagram.account.index.tpl');
     $this->view_mgr->addHelp('instagram', 'userguide/settings/plugins/instagram');
     /** set option fields **/
     // Application ID text field
     $this->addPluginOption(self::FORM_TEXT_ELEMENT, array('name' => 'instagram_app_id', 'label' => 'Client ID', 'size' => 18));
     // add element
     // set a special required message
     $this->addPluginOptionRequiredMessage('instagram_app_id', 'The instagram plugin requires a valid Client ID.');
     // Application Secret text field
     $this->addPluginOption(self::FORM_TEXT_ELEMENT, array('name' => 'instagram_api_secret', 'label' => 'Client Secret', 'size' => 37));
     // add element
     // set a special required message
     $this->addPluginOptionRequiredMessage('instagram_api_secret', 'The instagram plugin requires a valid Client Secret.');
     $max_api_calls_label = 'API calls per crawl (5000 max)';
     $max_api_calls = array('name' => 'max_api_calls', 'label' => $max_api_calls_label, 'default_value' => '2500', 'advanced' => true, 'size' => 5);
     $this->addPluginOption(self::FORM_TEXT_ELEMENT, $max_api_calls);
     $this->addToView('thinkup_site_url', Utils::getApplicationURL());
     $instagram_plugin = new InstagramPlugin();
     $instance_dao = DAOFactory::getDAO('InstanceDAO');
     $owner_instances = $instance_dao->getByOwnerAndNetwork($this->owner, 'instagram');
     if ($instagram_plugin->isConfigured()) {
         $this->addToView('is_configured', true);
         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 Instagram account to ThinkUp, upgrade your " . "membership.", 'membership_cap');
                 }
             }
         }
         $this->setUpInstagramInteractions($instagram_plugin->getOptionsHash());
     } else {
         $this->addInfoMessage('Please complete plugin setup to start using it.', 'setup');
         $this->addToView('is_configured', false);
     }
     return $this->generateView();
 }