当前位置: 首页>>代码示例>>PHP>>正文


PHP Piwik::checkUserHasViewAccess方法代码示例

本文整理汇总了PHP中Piwik\Piwik::checkUserHasViewAccess方法的典型用法代码示例。如果您正苦于以下问题:PHP Piwik::checkUserHasViewAccess方法的具体用法?PHP Piwik::checkUserHasViewAccess怎么用?PHP Piwik::checkUserHasViewAccess使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Piwik\Piwik的用法示例。


在下文中一共展示了Piwik::checkUserHasViewAccess方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getNumeric

 protected function getNumeric($idSite, $period, $date, $segment, $toFetch)
 {
     Piwik::checkUserHasViewAccess($idSite);
     $archive = Archive::build($idSite, $period, $date, $segment);
     $dataTable = $archive->getDataTableFromNumeric($toFetch);
     return $dataTable;
 }
开发者ID:piwik,项目名称:piwik,代码行数:7,代码来源:API.php

示例2: realtimeMap

 /**
  * @param bool $standalone When set to true, the Top controls will be hidden to provide better full screen view
  * @param bool $fetch
  * @param bool|string $segmentOverride
  *
  * @return string
  */
 public function realtimeMap($standalone = false, $fetch = false, $segmentOverride = false)
 {
     $this->checkUserCountryPluginEnabled();
     $idSite = Common::getRequestVar('idSite', 1, 'int');
     Piwik::checkUserHasViewAccess($idSite);
     $token_auth = Piwik::getCurrentUserTokenAuth();
     $view = new View('@UserCountryMap/realtimeMap');
     $view->mapIsStandaloneNotWidget = $standalone;
     $view->metrics = $this->getMetrics($idSite, 'range', self::REAL_TIME_WINDOW, $token_auth);
     $view->defaultMetric = 'nb_visits';
     $liveRefreshAfterMs = (int) Config::getInstance()->General['live_widget_refresh_after_seconds'] * 1000;
     $goals = APIGoals::getInstance()->getGoals($idSite);
     $site = new Site($idSite);
     $hasGoals = !empty($goals) || $site->isEcommerceEnabled();
     // maximum number of visits to be displayed in the map
     $maxVisits = Common::getRequestVar('filter_limit', 100, 'int');
     // some translations
     $locale = array('nb_actions' => Piwik::translate('VisitsSummary_NbActionsDescription'), 'local_time' => Piwik::translate('VisitTime_ColumnLocalTime'), 'from' => Piwik::translate('General_FromReferrer'), 'seconds' => Piwik::translate('UserCountryMap_Seconds'), 'seconds_ago' => Piwik::translate('UserCountryMap_SecondsAgo'), 'minutes' => Piwik::translate('UserCountryMap_Minutes'), 'minutes_ago' => Piwik::translate('UserCountryMap_MinutesAgo'), 'hours' => Piwik::translate('UserCountryMap_Hours'), 'hours_ago' => Piwik::translate('UserCountryMap_HoursAgo'), 'days_ago' => Piwik::translate('UserCountryMap_DaysAgo'), 'actions' => Piwik::translate('VisitsSummary_NbPageviewsDescription'), 'searches' => Piwik::translate('UserCountryMap_Searches'), 'goal_conversions' => Piwik::translate('UserCountryMap_GoalConversions'));
     $segment = $segmentOverride ?: Request::getRawSegmentFromRequest() ?: '';
     $params = array('period' => 'range', 'idSite' => $idSite, 'segment' => $segment, 'token_auth' => $token_auth);
     $realtimeWindow = Common::getRequestVar('realtimeWindow', self::REAL_TIME_WINDOW, 'string');
     if ($realtimeWindow != 'false') {
         // handle special value
         $params['date'] = $realtimeWindow;
     }
     $reqParams = $this->getEnrichedRequest($params, $encode = false);
     $view->config = array('metrics' => array(), 'svgBasePath' => $view->piwikUrl . 'plugins/UserCountryMap/svg/', 'liveRefreshAfterMs' => $liveRefreshAfterMs, '_' => $locale, 'reqParams' => $reqParams, 'siteHasGoals' => $hasGoals, 'maxVisits' => $maxVisits, 'changeVisitAlpha' => Common::getRequestVar('changeVisitAlpha', true, 'int'), 'removeOldVisits' => Common::getRequestVar('removeOldVisits', true, 'int'), 'showFooterMessage' => Common::getRequestVar('showFooterMessage', true, 'int'), 'showDateTime' => Common::getRequestVar('showDateTime', true, 'int'), 'doNotRefreshVisits' => Common::getRequestVar('doNotRefreshVisits', false, 'int'), 'enableAnimation' => Common::getRequestVar('enableAnimation', true, 'int'), 'forceNowValue' => Common::getRequestVar('forceNowValue', false, 'int'));
     return $view->render();
 }
开发者ID:Abine,项目名称:piwik,代码行数:36,代码来源:Controller.php

示例3: displayJavascriptCode

 /**
  * Displays the admin UI page showing all tracking tags
  * @return string
  */
 function displayJavascriptCode()
 {
     $idSite = Common::getRequestVar('idSite');
     Piwik::checkUserHasViewAccess($idSite);
     $jsTag = Piwik::getJavascriptCode($idSite, SettingsPiwik::getPiwikUrl());
     $site = new Site($idSite);
     return $this->renderTemplate('displayJavascriptCode', array('idSite' => $idSite, 'displaySiteName' => $site->getName(), 'jsTag' => $jsTag));
 }
开发者ID:a4tunado,项目名称:piwik,代码行数:12,代码来源:Controller.php

示例4: getDataTable

 private function getDataTable($name, $idSite, $period, $date, $segment, $expanded, $idSubtable)
 {
     Piwik::checkUserHasViewAccess($idSite);
     $recordName = Dimensions::getRecordNameForAction($name);
     $dataTable = Archive::getDataTableFromArchive($recordName, $idSite, $period, $date, $segment, $expanded, $idSubtable);
     $this->filterDataTable($dataTable);
     return $dataTable;
 }
开发者ID:a4tunado,项目名称:piwik,代码行数:8,代码来源:API.php

示例5: getDataTable

 /**
  * @param string $name
  * @param int $idSite
  * @param string $period
  * @param string $date
  * @param string $segment
  * @return DataTable
  */
 protected function getDataTable($name, $idSite, $period, $date, $segment)
 {
     Piwik::checkUserHasViewAccess($idSite);
     $archive = Archive::build($idSite, $period, $date, $segment);
     $dataTable = $archive->getDataTable($name);
     $dataTable->queueFilter('ReplaceColumnNames');
     $dataTable->queueFilter('ReplaceSummaryRowLabel');
     return $dataTable;
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:17,代码来源:API.php

示例6: getUsers

 /**
  * Get a report of all User Ids.
  *
  * @param int $idSite
  *
  * @param string  $period
  * @param int  $date
  * @param string|bool  $segment
  *
  * @return DataTable
  */
 public function getUsers($idSite, $period, $date, $segment = false)
 {
     Piwik::checkUserHasViewAccess($idSite);
     $archive = Archive::build($idSite, $period, $date, $segment);
     $dataTable = $archive->getDataTable(Archiver::USERID_ARCHIVE_RECORD);
     $dataTable->queueFilter('ReplaceColumnNames');
     $dataTable->queueFilter('ReplaceSummaryRowLabel');
     return $dataTable;
 }
开发者ID:diosmosis,项目名称:piwik,代码行数:20,代码来源:API.php

示例7: getCommonVisitors

 /**
  * Return the number of visitors that visited every site in the given list for the
  * given date range. Includes the number of visitors that visited at least one site
  * and the number that visited every site.
  *
  * This data is calculated on demand, and for very large tables can take a long time
  * to run.
  *
  * See {@link Model\DistinctMetricsAggregator} for more information.
  *
  * @param string $idSite comma separated list of site IDs, ie, `"1,2,3"`
  * @param string $period
  * @param string $date
  * @return array Metrics **nb_total_visitors** and **nb_shared_visitors**.
  * @throws Exception if $idSite references zero sites or just one site.
  */
 public function getCommonVisitors($idSite, $period, $date, $segment = false)
 {
     if (empty($idSite)) {
         throw new Exception("No sites to get common visitors for.");
     }
     $idSites = Site::getIdSitesFromIdSitesString($idSite);
     Piwik::checkUserHasViewAccess($idSites);
     $segment = new Segment($segment, $idSites);
     $period = PeriodFactory::build($period, $date);
     return $this->distinctMetricsAggregator->getCommonVisitorCount($idSites, $period->getDateStart(), $period->getDateEnd(), $segment);
 }
开发者ID:PiwikPRO,项目名称:plugin-InterSites,代码行数:27,代码来源:API.php

示例8: getProvider

 public function getProvider($idSite, $period, $date, $segment = false)
 {
     Piwik::checkUserHasViewAccess($idSite);
     $archive = Archive::build($idSite, $period, $date, $segment);
     $dataTable = $archive->getDataTable(Archiver::PROVIDER_RECORD_NAME);
     $dataTable->filter('ColumnCallbackAddMetadata', array('label', 'url', __NAMESPACE__ . '\\getHostnameUrl'));
     $dataTable->filter('GroupBy', array('label', __NAMESPACE__ . '\\getPrettyProviderName'));
     $dataTable->queueFilter('ReplaceColumnNames');
     $dataTable->queueFilter('ReplaceSummaryRowLabel');
     return $dataTable;
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:11,代码来源:API.php

示例9: spaceSummary

 /**
  * This method renders a widget as defined in "init()". It's on you how to generate the content of the
  * widget. As long as you return a string everything is fine. You can use for instance a "Piwik\View" to render a
  * twig template. In such a case don't forget to create a twig template (eg. myViewTemplate.twig) in the
  * "templates" directory of your plugin.
  *
  * @return string
  */
 public function spaceSummary()
 {
     // Make sure there is an idSite URL parameter
     $idSite = Common::getRequestVar('idSite', null, 'int');
     // Make sure the user has at least view access for the specified site. This is useful if you want to display data that is related to the specified site.
     Piwik::checkUserHasViewAccess($idSite);
     $space_id = Common::getRequestVar('space_id', null, 'int');
     $space_type = Common::getRequestVar('space_type', 'operation', 'string');
     // $view = new View('@HumanitarianResponse/myViewTemplate');
     // return $view->render();
     return $space_id;
 }
开发者ID:humanitarianresponse,项目名称:piwik_plugin,代码行数:20,代码来源:Widgets.php

示例10: getAverageVisitTimeData

 public function getAverageVisitTimeData($idSite, $lastMinutes = 30, $lastDays = 30)
 {
     \Piwik\Piwik::checkUserHasViewAccess($idSite);
     $lastMinutes = (int) $lastMinutes;
     $lastDays = (int) $lastDays;
     /* Time is UTC in database. */
     $refNow = Date::factory('now');
     $timeLimit = $refNow->subDay($lastDays)->toString('Y-m-d H:i:s');
     $sql = "SELECT MAX(g.average_time) AS maxtime\n                FROM (\n                  SELECT    AVG(visit_total_time) as average_time\n                  FROM      " . \Piwik\Common::prefixTable("log_visit") . "\n                  WHERE     visit_last_action_time >= ?\n                  AND       idsite = ?\n                  GROUP BY  round(UNIX_TIMESTAMP(visit_last_action_time) / ?)\n        ) g";
     $maxtime = \Piwik\Db::fetchOne($sql, array($timeLimit, $idSite, $lastMinutes * 60));
     $timeLimit = $refNow->subHour($lastMinutes / 60)->toString('Y-m-d H:i:s');
     $sql = "SELECT AVG(visit_total_time)\n                FROM " . \Piwik\Common::prefixTable("log_visit") . "\n                WHERE idsite = ?\n                AND visit_last_action_time >= ?";
     $average_time = \Piwik\Db::fetchOne($sql, array($idSite, $timeLimit));
     return array('maxtime' => (int) $maxtime, 'average_time' => (int) $average_time);
 }
开发者ID:ejouvin,项目名称:piwik-barometer-plugin,代码行数:15,代码来源:API.php

示例11: get

 /**
  * Returns the list of metrics (pages, downloads, outlinks)
  *
  * @param int $idSite
  * @param string $period
  * @param string $date
  * @param bool|string $segment
  * @param bool|array $columns
  * @return DataTable
  */
 public function get($idSite, $period, $date, $segment = false, $columns = false)
 {
     Piwik::checkUserHasViewAccess($idSite);
     $archive = Archive::build($idSite, $period, $date, $segment);
     $metrics = Archiver::$actionsAggregateMetrics;
     $metrics['Actions_avg_time_generation'] = 'avg_time_generation';
     // get requested columns
     $columns = Piwik::getArrayFromApiParameter($columns);
     if (!empty($columns)) {
         // get the columns that are available and requested
         $columns = array_intersect($columns, array_values($metrics));
         $columns = array_values($columns);
         // make sure indexes are right
         $nameReplace = array();
         foreach ($columns as $i => $column) {
             $fullColumn = array_search($column, $metrics);
             $columns[$i] = $fullColumn;
             $nameReplace[$fullColumn] = $column;
         }
         if (false !== ($avgGenerationTimeRequested = array_search('Actions_avg_time_generation', $columns))) {
             unset($columns[$avgGenerationTimeRequested]);
             $avgGenerationTimeRequested = true;
         }
     } else {
         // get all columns
         unset($metrics['Actions_avg_time_generation']);
         $columns = array_keys($metrics);
         $nameReplace =& $metrics;
         $avgGenerationTimeRequested = true;
     }
     if ($avgGenerationTimeRequested) {
         $tempColumns[] = Archiver::METRIC_SUM_TIME_RECORD_NAME;
         $tempColumns[] = Archiver::METRIC_HITS_TIMED_RECORD_NAME;
         $columns = array_merge($columns, $tempColumns);
         $columns = array_unique($columns);
         $nameReplace[Archiver::METRIC_SUM_TIME_RECORD_NAME] = 'sum_time_generation';
         $nameReplace[Archiver::METRIC_HITS_TIMED_RECORD_NAME] = 'nb_hits_with_time_generation';
     }
     $table = $archive->getDataTableFromNumeric($columns);
     // replace labels (remove Actions_)
     $table->filter('ReplaceColumnNames', array($nameReplace));
     // compute avg generation time
     if ($avgGenerationTimeRequested) {
         $table->filter('ColumnCallbackAddColumnQuotient', array('avg_time_generation', 'sum_time_generation', 'nb_hits_with_time_generation', 3));
         $table->deleteColumns(array('sum_time_generation', 'nb_hits_with_time_generation'));
     }
     return $table;
 }
开发者ID:KiwiJuicer,项目名称:handball-dachau,代码行数:58,代码来源:API.php

示例12: get

 /**
  * Returns the list of metrics (pages, downloads, outlinks)
  *
  * @param int $idSite
  * @param string $period
  * @param string $date
  * @param bool|string $segment
  * @param bool|array $columns
  * @return DataTable
  */
 public function get($idSite, $period, $date, $segment = false, $columns = false)
 {
     Piwik::checkUserHasViewAccess($idSite);
     $report = Report::factory("Actions", "get");
     $archive = Archive::build($idSite, $period, $date, $segment);
     $requestedColumns = Piwik::getArrayFromApiParameter($columns);
     $columns = $report->getMetricsRequiredForReport($allColumns = null, $requestedColumns);
     $inDbColumnNames = array_map(function ($value) {
         return 'Actions_' . $value;
     }, $columns);
     $dataTable = $archive->getDataTableFromNumeric($inDbColumnNames);
     $dataTable->deleteColumns(array_diff($requestedColumns, $columns));
     $newNameMapping = array_combine($inDbColumnNames, $columns);
     $dataTable->filter('ReplaceColumnNames', array($newNameMapping));
     $columnsToShow = $requestedColumns ?: $report->getAllMetrics();
     $dataTable->queueFilter('ColumnDelete', array($columnsToRemove = array(), $columnsToShow));
     return $dataTable;
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:28,代码来源:API.php

示例13: getTransitionsForAction

 /**
  * General method to get transitions for an action
  *
  * @param $actionName
  * @param $actionType "url"|"title"
  * @param $idSite
  * @param $period
  * @param $date
  * @param bool $segment
  * @param bool $limitBeforeGrouping
  * @param string $parts
  * @return array
  * @throws Exception
  */
 public function getTransitionsForAction($actionName, $actionType, $idSite, $period, $date, $segment = false, $limitBeforeGrouping = false, $parts = 'all')
 {
     Piwik::checkUserHasViewAccess($idSite);
     // get idaction of the requested action
     $idaction = $this->deriveIdAction($actionName, $actionType);
     if ($idaction < 0) {
         throw new Exception('NoDataForAction');
     }
     // prepare log aggregator
     $segment = new Segment($segment, $idSite);
     $site = new Site($idSite);
     $period = Period\Factory::build($period, $date);
     $params = new ArchiveProcessor\Parameters($site, $period, $segment);
     $logAggregator = new LogAggregator($params);
     // prepare the report
     $report = array('date' => Period\Factory::build($period->getLabel(), $date)->getLocalizedShortString());
     $partsArray = explode(',', $parts);
     if ($parts == 'all' || in_array('internalReferrers', $partsArray)) {
         $this->addInternalReferrers($logAggregator, $report, $idaction, $actionType, $limitBeforeGrouping);
     }
     if ($parts == 'all' || in_array('followingActions', $partsArray)) {
         $includeLoops = $parts != 'all' && !in_array('internalReferrers', $partsArray);
         $this->addFollowingActions($logAggregator, $report, $idaction, $actionType, $limitBeforeGrouping, $includeLoops);
     }
     if ($parts == 'all' || in_array('externalReferrers', $partsArray)) {
         $this->addExternalReferrers($logAggregator, $report, $idaction, $actionType, $limitBeforeGrouping);
     }
     // derive the number of exits from the other metrics
     if ($parts == 'all') {
         $report['pageMetrics']['exits'] = $report['pageMetrics']['pageviews'] - $this->getTotalTransitionsToFollowingActions() - $report['pageMetrics']['loops'];
     }
     // replace column names in the data tables
     $reportNames = array('previousPages' => true, 'previousSiteSearches' => false, 'followingPages' => true, 'followingSiteSearches' => false, 'outlinks' => true, 'downloads' => true);
     foreach ($reportNames as $reportName => $replaceLabel) {
         if (isset($report[$reportName])) {
             $columnNames = array(Metrics::INDEX_NB_ACTIONS => 'referrals');
             if ($replaceLabel) {
                 $columnNames[Metrics::INDEX_NB_ACTIONS] = 'referrals';
             }
             $report[$reportName]->filter('ReplaceColumnNames', array($columnNames));
         }
     }
     return $report;
 }
开发者ID:a4tunado,项目名称:piwik,代码行数:58,代码来源:API.php

示例14: getByDayOfWeek

 /**
  * Returns datatable describing the number of visits for each day of the week.
  *
  * @param string $idSite The site ID. Cannot refer to multiple sites.
  * @param string $period The period type: day, week, year, range...
  * @param string $date The start date of the period. Cannot refer to multiple dates.
  * @param bool|string $segment The segment.
  * @throws Exception
  * @return DataTable
  */
 public function getByDayOfWeek($idSite, $period, $date, $segment = false)
 {
     Piwik::checkUserHasViewAccess($idSite);
     // metrics to query
     $metrics = Metrics::getVisitsMetricNames();
     unset($metrics[Metrics::INDEX_MAX_ACTIONS]);
     // disabled for multiple dates
     if (Period::isMultiplePeriod($date, $period)) {
         throw new Exception("VisitTime.getByDayOfWeek does not support multiple dates.");
     }
     // get metric data for every day within the supplied period
     $oPeriod = Period\Factory::makePeriodFromQueryParams(Site::getTimezoneFor($idSite), $period, $date);
     $dateRange = $oPeriod->getDateStart()->toString() . ',' . $oPeriod->getDateEnd()->toString();
     $archive = Archive::build($idSite, 'day', $dateRange, $segment);
     // disabled for multiple sites
     if (count($archive->getParams()->getIdSites()) > 1) {
         throw new Exception("VisitTime.getByDayOfWeek does not support multiple sites.");
     }
     $dataTable = $archive->getDataTableFromNumeric($metrics)->mergeChildren();
     // if there's no data for this report, don't bother w/ anything else
     if ($dataTable->getRowsCount() == 0) {
         return $dataTable;
     }
     // group by the day of the week (see below for dayOfWeekFromDate function)
     $dataTable->filter('GroupBy', array('label', __NAMESPACE__ . '\\dayOfWeekFromDate'));
     // create new datatable w/ empty rows, then add calculated datatable
     $rows = array();
     foreach (array(1, 2, 3, 4, 5, 6, 7) as $day) {
         $rows[] = array('label' => $day, 'nb_visits' => 0);
     }
     $result = new DataTable();
     $result->addRowsFromSimpleArray($rows);
     $result->addDataTable($dataTable);
     // set day of week integer as metadata
     $result->filter('ColumnCallbackAddMetadata', array('label', 'day_of_week'));
     // translate labels
     $result->filter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\\translateDayOfWeek'));
     // set datatable metadata for period start & finish
     $result->setMetadata('date_start', $oPeriod->getDateStart());
     $result->setMetadata('date_end', $oPeriod->getDateEnd());
     return $result;
 }
开发者ID:carriercomm,项目名称:piwik,代码行数:52,代码来源:API.php

示例15: getCustomDimension

 /**
  * Fetch a report for the given idDimension. Only reports for active dimensions can be fetched. Requires at least
  * view access.
  *
  * @param int $idDimension
  * @param int $idSite
  * @param string $period
  * @param string $date
  * @param bool|false $segment
  * @param bool|false $expanded
  * @param bool|false $flat
  * @param int|null   $idSubtable
  * @return DataTable|DataTable\Map
  * @throws \Exception
  */
 public function getCustomDimension($idDimension, $idSite, $period, $date, $segment = false, $expanded = false, $flat = false, $idSubtable = null)
 {
     Piwik::checkUserHasViewAccess($idSite);
     $dimension = new Dimension($idDimension, $idSite);
     $dimension->checkActive();
     $record = Archiver::buildRecordNameForCustomDimensionId($idDimension);
     $dataTable = Archive::createDataTableFromArchive($record, $idSite, $period, $date, $segment, $expanded, $flat, $idSubtable);
     if (isset($idSubtable) && $dataTable->getRowsCount()) {
         $parentTable = Archive::createDataTableFromArchive($record, $idSite, $period, $date, $segment);
         foreach ($parentTable->getRows() as $row) {
             if ($row->getIdSubDataTable() == $idSubtable) {
                 $parentValue = $row->getColumn('label');
                 $dataTable->queueFilter('Piwik\\Plugins\\CustomDimensions\\DataTable\\Filter\\AddSubtableSegmentMetadata', array($idDimension, $parentValue));
                 break;
             }
         }
     } else {
         $dataTable->queueFilter('Piwik\\Plugins\\CustomDimensions\\DataTable\\Filter\\AddSegmentMetadata', array($idDimension));
     }
     $dataTable->filter('Piwik\\Plugins\\CustomDimensions\\DataTable\\Filter\\RemoveUserIfNeeded', array($idSite, $period, $date));
     return $dataTable;
 }
开发者ID:ep123,项目名称:plugin-CustomDimensions,代码行数:37,代码来源:API.php


注:本文中的Piwik\Piwik::checkUserHasViewAccess方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。