hasDataTableUsers() public method

public hasDataTableUsers ( Piwik\DataTable\DataTableInterface $result )
$result Piwik\DataTable\DataTableInterface
コード例 #1
0
 /**
  * @param DataTable $table
  */
 public function filter($table)
 {
     $userId = new UserId();
     if (!$userId->hasDataTableUsers($table) && !$userId->isUsedInAtLeastOneSite(array($this->idSite), $this->period, $this->date)) {
         $table->deleteColumn(Metrics::INDEX_NB_USERS);
     }
 }
コード例 #2
0
 public function enrichProcessedReportIfVisitsSummaryGet(&$response, $infos)
 {
     if (empty($infos['parameters'][4]) || empty($response['reportData'])) {
         return;
     }
     $params = $infos['parameters'];
     $idSites = array($params[0]);
     $period = $params[1];
     $date = $params[2];
     $module = $params[3];
     $method = $params[4];
     if (!$this->isRequestingVisitsSummaryGet($module, $method)) {
         return;
     }
     $userId = new UserId();
     /** @var DataTable|DataTable\Map $dataTable */
     $dataTable = $response['reportData'];
     if (!$userId->hasDataTableUsers($dataTable) && !$userId->isUsedInAtLeastOneSite($idSites, $period, $date)) {
         $report = new Get();
         $report->removeUsersFromProcessedReport($response);
     }
 }
コード例 #3
0
 /**
  * Here you can configure how your report should be displayed. For instance whether your report supports a search
  * etc. You can also change the default request config. For instance change how many rows are displayed by default.
  *
  * @param ViewDataTable $view
  */
 public function configureView(ViewDataTable $view)
 {
     $idDimension = Common::getRequestVar('idDimension', 0, 'int');
     if ($idDimension < 1) {
         return;
     }
     $isWidget = Common::getRequestVar('widget', 0, 'int');
     $module = Common::getRequestVar('module', '', 'string');
     if ($isWidget && $module !== 'Widgetize' && $view->isViewDataTableId(HtmlTable::ID)) {
         // we disable row evolution as it would not forward the idDimension when requesting the row evolution
         // this is a limitation in row evolution
         $view->config->disable_row_evolution = true;
     }
     $module = $view->requestConfig->getApiModuleToRequest();
     $method = $view->requestConfig->getApiMethodToRequest();
     $idReport = sprintf('%s_%s_idDimension--%d', $module, $method, $idDimension);
     if ($view->requestConfig->idSubtable) {
         $view->config->addTranslation('label', Piwik::translate('Actions_ColumnActionURL'));
     } elseif (!empty($this->dimension)) {
         $view->config->addTranslation('label', $this->dimension->getName());
     }
     $view->requestConfig->request_parameters_to_modify['idDimension'] = $idDimension;
     $view->requestConfig->request_parameters_to_modify['reportUniqueId'] = $idReport;
     $view->config->custom_parameters['scopeOfDimension'] = $this->scopeOfDimension;
     if ($this->scopeOfDimension === CustomDimensions::SCOPE_VISIT) {
         // Goal metrics for each custom dimension  of 'visit' scope is processed in Archiver via aggregateFromConversions
         $view->config->show_goals = true;
         $view->config->columns_to_display = array('label', 'nb_visits', 'nb_uniq_visitors', 'nb_users', 'nb_actions', 'nb_actions_per_visit', 'avg_time_on_site', 'bounce_rate');
         $view->config->filters[] = function (DataTable $table) use($view) {
             $userId = new UserId();
             if (!$userId->hasDataTableUsers($table)) {
                 $view->config->removeColumnToDisplay('nb_users');
             }
             if ($table->getRowsCount() > 0 && !$table->getFirstRow()->hasColumn('nb_uniq_visitors')) {
                 $view->config->removeColumnToDisplay('nb_uniq_visitors');
             }
         };
     } elseif ($this->scopeOfDimension === CustomDimensions::SCOPE_ACTION) {
         $view->config->columns_to_display = array('label', 'nb_hits', 'nb_visits', 'bounce_rate', 'avg_time_on_dimension', 'exit_rate', 'avg_time_generation');
         $formatter = new Metrics\Formatter();
         // add avg_generation_time tooltip
         $tooltipCallback = function ($hits, $min, $max) use($formatter) {
             if (!$hits) {
                 return false;
             }
             return Piwik::translate("Actions_AvgGenerationTimeTooltip", array($hits, "<br />", $formatter->getPrettyTimeFromSeconds($min, true), $formatter->getPrettyTimeFromSeconds($max, true)));
         };
         $view->config->filters[] = array('ColumnCallbackAddMetadata', array(array('nb_hits_with_time_generation', 'min_time_generation', 'max_time_generation'), 'avg_time_generation_tooltip', $tooltipCallback));
     }
     $view->config->show_table_all_columns = false;
 }
コード例 #4
0
ファイル: UserIdTest.php プロジェクト: cemo/piwik
 private function assertDataTableHasUsers($table)
 {
     $has = $this->userId->hasDataTableUsers($table);
     $this->assertTrue($has);
 }