/**
  * Initialize service.
  *
  * @codeCoverageIgnore
  */
 public function init()
 {
     // Get plugin
     $this->plugin = craft()->plugins->getPlugin('youtube');
     // Get plugin settings
     $this->settings = $this->plugin->getSettings();
 }
 public function authControl()
 {
     $config = Config::getInstance();
     Loader::definePathConstants();
     $this->setViewTemplate(THINKUP_WEBAPP_PATH . 'plugins/youtube/view/account.index.tpl');
     $this->view_mgr->addHelp('youtube', 'userguide/settings/plugins/youtube');
     /* set option fields **/
     // client ID text field
     $name_field = array('name' => 'youtube_client_id', 'label' => 'Client ID', 'size' => 50);
     $name_field['default_value'] = '';
     // set default value
     $this->addPluginOption(self::FORM_TEXT_ELEMENT, $name_field);
     // add element
     // set a special required message
     $this->addPluginOptionRequiredMessage('youtube_client_id', 'A client ID is required to use YouTube.');
     // client secret text field
     $name_field = array('name' => 'youtube_client_secret', 'label' => 'Client secret', 'size' => 40);
     $name_field['default_value'] = '';
     // set default value
     $this->addPluginOption(self::FORM_TEXT_ELEMENT, $name_field);
     // add element
     // set a special required message
     $this->addPluginOptionRequiredMessage('youtube_client_secret', 'A client secret is required to use YouTube.');
     // Three optional fields that will be useful for very active YouTubers
     $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);
     $developer_key_label = 'YouTube Developer Key';
     $developer_key = array('name' => 'developer_key', 'label' => $developer_key_label, 'default_value' => '', 'advanced' => true, 'size' => 40);
     $this->addPluginOption(self::FORM_TEXT_ELEMENT, $developer_key);
     $comments_label = 'Maximum Comments to Collect';
     $comments = array('name' => 'max_comments', 'label' => $comments_label, 'default_value' => '', 'advanced' => true, 'size' => 5);
     $this->addPluginOption(self::FORM_TEXT_ELEMENT, $comments);
     $plugin_option_dao = DAOFactory::getDAO('PluginOptionDAO');
     $options = $plugin_option_dao->getOptionsHash('youtube', true);
     //get cached
     $plugin = new YouTubePlugin();
     if ($plugin->isConfigured()) {
         $this->setUpYouTubeInteractions($options);
         $this->addToView('is_configured', true);
     } else {
         $this->addInfoMessage('Please complete plugin setup to start using it.', 'setup');
         $this->addToView('is_configured', false);
     }
     $this->addToView('thinkup_site_url', Utils::getApplicationURL());
     return $this->generateView();
 }