/**
  * Execute the action
  *
  * @return	void
  */
 public function execute()
 {
     // call parent, this will probably add some general CSS/JS or other required files
     parent::execute();
     // fork is no longer authorized to collect analytics data
     if (BackendAnalyticsHelper::getStatus() == 'UNAUTHORIZED') {
         // remove all parameters from the module settings
         BackendModel::setModuleSetting($this->getModule(), 'session_token', null);
         BackendModel::setModuleSetting($this->getModule(), 'account_name', null);
         BackendModel::setModuleSetting($this->getModule(), 'table_id', null);
         BackendModel::setModuleSetting($this->getModule(), 'profile_title', null);
         // remove cache files
         BackendAnalyticsModel::removeCacheFiles();
         // clear tables
         BackendAnalyticsModel::clearTables();
         // return status
         $this->output(self::OK, array('status' => 'unauthorized', 'message' => BL::msg('Redirecting')), 'No longer authorized.');
     }
     // get data
     $this->getData();
     // get html
     $referrersHtml = $this->parseReferrers();
     $keywordsHtml = $this->parseKeywords();
     // return status
     $this->output(self::OK, array('status' => 'success', 'referrersHtml' => $referrersHtml, 'keywordsHtml' => $keywordsHtml, 'date' => BL::lbl('Today'), 'message' => BL::msg('RefreshedTrafficSources')), 'Data has been retrieved.');
 }
 /**
  * Execute the action
  */
 public function execute()
 {
     parent::execute();
     // fork is no longer authorized to collect analytics data
     if (BackendAnalyticsHelper::getStatus() == 'UNAUTHORIZED') {
         // remove all parameters from the module settings
         BackendModel::setModuleSetting('analytics', 'session_token', null);
         BackendModel::setModuleSetting('analytics', 'account_name', null);
         BackendModel::setModuleSetting('analytics', 'table_id', null);
         BackendModel::setModuleSetting('analytics', 'profile_title', null);
         BackendAnalyticsModel::removeCacheFiles();
         BackendAnalyticsModel::clearTables();
         return;
     }
     $this->getData();
 }
Exemplo n.º 3
0
 /**
  * Execute the action
  */
 public function execute()
 {
     parent::execute();
     $this->cachePath = BACKEND_CACHE_PATH . '/analytics';
     // get parameters
     $page = trim(SpoonFilter::getGetValue('page', null, ''));
     $pageId = trim(SpoonFilter::getGetValue('page_id', null, ''));
     $identifier = trim(SpoonFilter::getGetValue('identifier', null, ''));
     $startTimestamp = (int) trim(SpoonFilter::getGetValue('start_date', null, ''));
     $endTimestamp = (int) trim(SpoonFilter::getGetValue('end_date', null, ''));
     $force = trim(SpoonFilter::getGetValue('force', array('Y', 'N'), 'N')) == 'Y';
     $filename = null;
     // no parameters given? cronjob called
     if ($page == '' && $identifier == '' && $startTimestamp === 0 && $endTimestamp === 0) {
         // is everything still set?
         if (BackendAnalyticsHelper::getStatus() != 'UNAUTHORIZED') {
             $interval = BackendModel::getModuleSetting('analytics', 'interval', 'week');
             if ($interval == 'week') {
                 $interval .= ' -2 days';
             }
             $page = 'all';
             $startTimestamp = strtotime('-1' . $interval);
             $endTimestamp = time();
         }
     } elseif ($page != '' && $identifier != '' && $startTimestamp !== 0 && $endTimestamp !== 0) {
         // init vars
         $filename = $this->cachePath . '/' . $page . ($pageId != '' ? '_' . $pageId : '') . '_' . $identifier . '.txt';
         // is everything still set?
         if (BackendAnalyticsHelper::getStatus() != 'UNAUTHORIZED') {
             // create temporary file to indicate we're getting data
             SpoonFile::setContent($filename, 'busy1');
         } else {
             // set status in cache
             SpoonFile::setContent($filename, 'unauthorized');
             return;
         }
     } else {
         throw new SpoonException('Some parameters are missing.');
     }
     $this->getDashboardData();
     $this->getData($startTimestamp, $endTimestamp, $force, $page, $pageId, $filename);
     $this->cleanupCache();
     $this->cleanupDatabase();
 }
 /**
  * Execute the action
  *
  * @return	void
  */
 public function execute()
 {
     // call parent, this will probably add some general CSS/JS or other required files
     parent::execute();
     // fork is no longer authorized to collect analytics data
     if (BackendAnalyticsHelper::getStatus() == 'UNAUTHORIZED') {
         // remove all parameters from the module settings
         BackendModel::setModuleSetting('analytics', 'session_token', null);
         BackendModel::setModuleSetting('analytics', 'account_name', null);
         BackendModel::setModuleSetting('analytics', 'table_id', null);
         BackendModel::setModuleSetting('analytics', 'profile_title', null);
         // remove cache files
         BackendAnalyticsModel::removeCacheFiles();
         // clear tables
         BackendAnalyticsModel::clearTables();
         // stop here
         return;
     }
     // get data
     $this->getData();
 }