本文整理汇总了PHP中Piwik\Piwik::checkUserHasSomeViewAccess方法的典型用法代码示例。如果您正苦于以下问题:PHP Piwik::checkUserHasSomeViewAccess方法的具体用法?PHP Piwik::checkUserHasSomeViewAccess怎么用?PHP Piwik::checkUserHasSomeViewAccess使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik\Piwik
的用法示例。
在下文中一共展示了Piwik::checkUserHasSomeViewAccess方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getRank
/**
* Returns SEO statistics for a URL.
*
* @param string $url URL to request SEO stats for
* @return DataTable
*/
public function getRank($url)
{
Piwik::checkUserHasSomeViewAccess();
$metricProvider = new ProviderCache(new Aggregator());
$domain = Url::getHostFromUrl($url);
$metrics = $metricProvider->getMetrics($domain);
return $this->toDataTable($metrics);
}
示例2: getAll
/**
* Returns a report displaying the total visits, actions and revenue, as
* well as the evolution of these values, of all existing sites over a
* specified period of time.
*
* If the specified period is not a 'range', this function will calculcate
* evolution metrics. Evolution metrics are metrics that display the
* percent increase/decrease of another metric since the last period.
*
* This function will merge the result of the archive query so each
* row in the result DataTable will correspond to the metrics of a single
* site. If a date range is specified, the result will be a
* DataTable\Map, but it will still be merged.
*
* @param string $period The period type to get data for.
* @param string $date The date(s) to get data for.
* @param bool|string $segment The segments to get data for.
* @param bool|string $_restrictSitesToLogin Hack used to enforce we restrict the returned data to the specified username
* Only used when a scheduled task is running
* @param bool|string $enhanced When true, return additional goal & ecommerce metrics
* @param bool|string $pattern If specified, only the website which names (or site ID) match the pattern will be returned using SitesManager.getPatternMatchSites
* @return DataTable
*/
public function getAll($period, $date, $segment = false, $_restrictSitesToLogin = false, $enhanced = false, $pattern = false)
{
Piwik::checkUserHasSomeViewAccess();
$idSites = $this->getSitesIdFromPattern($pattern);
if (empty($idSites)) {
return new DataTable();
}
return $this->buildDataTable($idSites, $period, $date, $segment, $_restrictSitesToLogin, $enhanced, $multipleWebsitesRequested = true);
}
示例3: renderWidget
public function renderWidget($widgetModule = null, $widgetAction = null)
{
Piwik::checkUserHasSomeViewAccess();
$widget = PluginWidgets::factory($widgetModule, $widgetAction);
if (!empty($widget)) {
return $widget->{$widgetAction}();
}
throw new Exception(Piwik::translate('General_ExceptionWidgetNotFound'));
}
示例4: getAll
/**
* Returns a report displaying the total visits, actions and revenue, as
* well as the evolution of these values, of all existing sites over a
* specified period of time.
*
* If the specified period is not a 'range', this function will calculcate
* evolution metrics. Evolution metrics are metrics that display the
* percent increase/decrease of another metric since the last period.
*
* This function will merge the result of the archive query so each
* row in the result DataTable will correspond to the metrics of a single
* site. If a date range is specified, the result will be a
* DataTable\Map, but it will still be merged.
*
* @param string $period The period type to get data for.
* @param string $date The date(s) to get data for.
* @param bool|string $segment The segments to get data for.
* @param bool|string $_restrictSitesToLogin Hack used to enforce we restrict the returned data to the specified username
* Only used when a scheduled task is running
* @param bool|string $enhanced When true, return additional goal & ecommerce metrics
* @param bool|string $pattern If specified, only the website which names (or site ID) match the pattern will be returned using SitesManager.getPatternMatchSites
* @param array $showColumns If specified, only the requested columns will be fetched
* @return DataTable
*/
public function getAll($period, $date, $segment = false, $_restrictSitesToLogin = false, $enhanced = false, $pattern = false, $showColumns = array())
{
Piwik::checkUserHasSomeViewAccess();
$sites = $this->getSitesIdFromPattern($pattern, $_restrictSitesToLogin);
if (!empty($showColumns) && !is_array($showColumns)) {
$showColumns = explode(',', $showColumns);
}
if (empty($sites)) {
return new DataTable();
}
return $this->buildDataTable($sites, $period, $date, $segment, $_restrictSitesToLogin, $enhanced, $multipleWebsitesRequested = true, $showColumns);
}
示例5: canGenerateInsights
/**
* Detects whether insights can be generated for this date/period combination or not.
* @param string $date eg 'today', '2012-12-12'
* @param string $period eg 'day' or 'week'
*
* @return bool
*/
public function canGenerateInsights($date, $period)
{
Piwik::checkUserHasSomeViewAccess();
try {
$lastDate = $this->model->getLastDate($date, $period, 1);
} catch (\Exception $e) {
return false;
}
if (empty($lastDate)) {
return false;
}
return true;
}
示例6: getRank
/**
* Returns SEO statistics for a URL.
*
* @param string $url URL to request SEO stats for
* @return DataTable
*/
public function getRank($url)
{
Piwik::checkUserHasSomeViewAccess();
$rank = new RankChecker($url);
$linkToMajestic = MajesticClient::getLinkForUrl($url);
$data = array('Google PageRank' => array('rank' => $rank->getPageRank(), 'logo' => \Piwik\Plugins\Referrers\getSearchEngineLogoFromUrl('http://google.com'), 'id' => 'pagerank'), Piwik::translate('SEO_Google_IndexedPages') => array('rank' => $rank->getIndexedPagesGoogle(), 'logo' => \Piwik\Plugins\Referrers\getSearchEngineLogoFromUrl('http://google.com'), 'id' => 'google-index'), Piwik::translate('SEO_Bing_IndexedPages') => array('rank' => $rank->getIndexedPagesBing(), 'logo' => \Piwik\Plugins\Referrers\getSearchEngineLogoFromUrl('http://bing.com'), 'id' => 'bing-index'), Piwik::translate('SEO_AlexaRank') => array('rank' => $rank->getAlexaRank(), 'logo' => \Piwik\Plugins\Referrers\getSearchEngineLogoFromUrl('http://alexa.com'), 'id' => 'alexa'), Piwik::translate('SEO_DomainAge') => array('rank' => $rank->getAge(), 'logo' => 'plugins/SEO/images/whois.png', 'id' => 'domain-age'), Piwik::translate('SEO_ExternalBacklinks') => array('rank' => $rank->getExternalBacklinkCount(), 'logo' => 'plugins/SEO/images/majesticseo.png', 'logo_link' => $linkToMajestic, 'logo_tooltip' => Piwik::translate('SEO_ViewBacklinksOnMajesticSEO'), 'id' => 'external-backlinks'), Piwik::translate('SEO_ReferrerDomains') => array('rank' => $rank->getReferrerDomainCount(), 'logo' => 'plugins/SEO/images/majesticseo.png', 'logo_link' => $linkToMajestic, 'logo_tooltip' => Piwik::translate('SEO_ViewBacklinksOnMajesticSEO'), 'id' => 'referrer-domains'));
// Add DMOZ only if > 0 entries found
$dmozRank = array('rank' => $rank->getDmoz(), 'logo' => \Piwik\Plugins\Referrers\getSearchEngineLogoFromUrl('http://dmoz.org'), 'id' => 'dmoz');
if ($dmozRank['rank'] > 0) {
$data[Piwik::translate('SEO_Dmoz')] = $dmozRank;
}
return DataTable::makeFromIndexedArray($data);
}
示例7: getGlobalSettings
public function getGlobalSettings()
{
Piwik::checkUserHasSomeViewAccess();
$response = new ResponseBuilder(Common::getRequestVar('format'));
$globalSettings = array();
$globalSettings['keepURLFragmentsGlobal'] = API::getInstance()->getKeepURLFragmentsGlobal();
$globalSettings['siteSpecificUserAgentExcludeEnabled'] = API::getInstance()->isSiteSpecificUserAgentExcludeEnabled();
$globalSettings['defaultCurrency'] = API::getInstance()->getDefaultCurrency();
$globalSettings['searchKeywordParametersGlobal'] = API::getInstance()->getSearchKeywordParametersGlobal();
$globalSettings['searchCategoryParametersGlobal'] = API::getInstance()->getSearchCategoryParametersGlobal();
$globalSettings['defaultTimezone'] = API::getInstance()->getDefaultTimezone();
$globalSettings['excludedIpsGlobal'] = API::getInstance()->getExcludedIpsGlobal();
$globalSettings['excludedQueryParametersGlobal'] = API::getInstance()->getExcludedQueryParametersGlobal();
$globalSettings['excludedUserAgentsGlobal'] = API::getInstance()->getExcludedUserAgentsGlobal();
return $response->getResponse($globalSettings);
}
示例8: sendFeedbackForFeature
/**
* Sends feedback for a specific feature to the Piwik team or alternatively to the email address configured in the
* config: "feedback_email_address".
*
* @param string $featureName The name of a feature you want to give feedback to.
* @param bool|int $like Whether you like the feature or not
* @param string|bool $message A message containing the actual feedback
*/
public function sendFeedbackForFeature($featureName, $like, $message = false)
{
Piwik::checkUserIsNotAnonymous();
Piwik::checkUserHasSomeViewAccess();
$featureName = $this->getEnglishTranslationForFeatureName($featureName);
$likeText = 'Yes';
if (empty($like)) {
$likeText = 'No';
}
$body = sprintf("Feature: %s\nLike: %s\n", $featureName, $likeText, $message);
$feedbackMessage = "";
if (!empty($message) && $message != 'undefined') {
$feedbackMessage = sprintf("Feedback:\n%s\n", trim($message));
}
$body .= $feedbackMessage ? $feedbackMessage : " \n";
$subject = sprintf("%s for %s %s", empty($like) ? "-1" : "+1", $featureName, empty($feedbackMessage) ? "" : "(w/ feedback)");
$this->sendMail($subject, $body);
}
示例9: renderWidget
/**
* @param Widget $widget
* @return mixed
* @throws Exception
*/
public function renderWidget($widget)
{
Piwik::checkUserHasSomeViewAccess();
$config = new WidgetConfig();
$widget::configure($config);
$content = $widget->render();
if ($config->getName() && Common::getRequestVar('showtitle', '', 'string') === '1') {
if (strpos($content, '<h2') !== false || strpos($content, ' content-title=') !== false || strpos($content, ' piwik-enriched-headline') !== false || strpos($content, '<h1') !== false) {
// already includes title
return $content;
}
if (strpos($content, 'piwik-content-block') === false && strpos($content, 'class="card"') === false && strpos($content, "class='card'") === false && strpos($content, 'class="card-content"') === false && strpos($content, "class='card-content'") === false) {
$view = new View('@CoreHome/_singleWidget');
$view->title = $config->getName();
$view->content = $content;
return $view->render();
}
}
return $content;
}
示例10: getSitesInfo
public function getSitesInfo($isWidgetized = false)
{
Piwik::checkUserHasSomeViewAccess();
$date = Common::getRequestVar('date', 'today');
$period = Common::getRequestVar('period', 'day');
$view = new View("@MultiSites/getSitesInfo");
$view->isWidgetized = $isWidgetized;
$view->displayRevenueColumn = Common::isGoalPluginEnabled();
$view->limit = Config::getInstance()->General['all_websites_website_per_page'];
$view->show_sparklines = Config::getInstance()->General['show_multisites_sparklines'];
$view->autoRefreshTodayReport = 0;
// if the current date is today, or yesterday,
// in case the website is set to UTC-12), or today in UTC+14, we refresh the page every 5min
if (in_array($date, array('today', date('Y-m-d'), 'yesterday', Date::factory('yesterday')->toString('Y-m-d'), Date::factory('now', 'UTC+14')->toString('Y-m-d')))) {
$view->autoRefreshTodayReport = Config::getInstance()->General['multisites_refresh_after_seconds'];
}
$params = $this->getGraphParamsModified();
$view->dateSparkline = $period == 'range' ? $date : $params['date'];
$this->setGeneralVariablesView($view);
return $view->render();
}
示例11: getSitesInfo
public function getSitesInfo($isWidgetized = false)
{
Piwik::checkUserHasSomeViewAccess();
$displayRevenueColumn = Common::isGoalPluginEnabled();
$date = Common::getRequestVar('date', 'today');
$period = Common::getRequestVar('period', 'day');
$siteIds = APISitesManager::getInstance()->getSitesIdWithAtLeastViewAccess();
list($minDate, $maxDate) = Site::getMinMaxDateAcrossWebsites($siteIds);
// overwrites the default Date set in the parent controller
// Instead of the default current website's local date,
// we set "today" or "yesterday" based on the default Piwik timezone
$piwikDefaultTimezone = APISitesManager::getInstance()->getDefaultTimezone();
if ($period != 'range') {
$date = $this->getDateParameterInTimezone($date, $piwikDefaultTimezone);
$this->setDate($date);
$date = $date->toString();
}
$dataTable = APIMultiSites::getInstance()->getAll($period, $date, $segment = false);
// put data into a form the template will understand better
$digestableData = array();
foreach ($siteIds as $idSite) {
$isEcommerceEnabled = Site::isEcommerceEnabledFor($idSite);
$digestableData[$idSite] = array('idsite' => $idSite, 'main_url' => Site::getMainUrlFor($idSite), 'name' => Site::getNameFor($idSite), 'visits' => 0, 'pageviews' => 0);
if ($period != 'range') {
$digestableData[$idSite]['visits_evolution'] = 0;
$digestableData[$idSite]['pageviews_evolution'] = 0;
}
if ($displayRevenueColumn) {
$revenueDefault = $isEcommerceEnabled ? 0 : "'-'";
if ($period != 'range') {
$digestableData[$idSite]['revenue_evolution'] = $revenueDefault;
}
}
}
foreach ($dataTable->getRows() as $row) {
$idsite = (int) $row->getMetadata('idsite');
$site =& $digestableData[$idsite];
$site['visits'] = (int) $row->getColumn('nb_visits');
$site['pageviews'] = (int) $row->getColumn('nb_pageviews');
if ($displayRevenueColumn) {
if ($row->getColumn('revenue') !== false) {
$site['revenue'] = $row->getColumn('revenue');
}
}
if ($period != 'range') {
$site['visits_evolution'] = $row->getColumn('visits_evolution');
$site['pageviews_evolution'] = $row->getColumn('pageviews_evolution');
if ($displayRevenueColumn) {
$site['revenue_evolution'] = $row->getColumn('revenue_evolution');
}
}
}
$this->applyPrettyMoney($digestableData);
$view = new View("@MultiSites/getSitesInfo");
$view->isWidgetized = $isWidgetized;
$view->sitesData = array_values($digestableData);
$view->evolutionBy = $this->evolutionBy;
$view->period = $period;
$view->page = $this->page;
$view->limit = $this->limit;
$view->orderBy = $this->orderBy;
$view->order = $this->order;
$view->totalVisits = $dataTable->getMetadata('total_nb_visits');
$view->totalRevenue = $dataTable->getMetadata('total_revenue');
$view->displayRevenueColumn = $displayRevenueColumn;
$view->totalPageviews = $dataTable->getMetadata('total_nb_pageviews');
$view->pastTotalVisits = $dataTable->getMetadata('last_period_total_nb_visits');
$view->totalVisitsEvolution = $dataTable->getMetadata('total_visits_evolution');
if ($view->totalVisitsEvolution > 0) {
$view->totalVisitsEvolution = '+' . $view->totalVisitsEvolution;
}
if ($period != 'range') {
$lastPeriod = Period::factory($period, $dataTable->getMetadata('last_period_date'));
$view->pastPeriodPretty = self::getCalendarPrettyDate($lastPeriod);
}
$params = $this->getGraphParamsModified();
$view->dateSparkline = $period == 'range' ? $date : $params['date'];
$view->autoRefreshTodayReport = false;
// if the current date is today, or yesterday,
// in case the website is set to UTC-12), or today in UTC+14, we refresh the page every 5min
if (in_array($date, array('today', date('Y-m-d'), 'yesterday', Date::factory('yesterday')->toString('Y-m-d'), Date::factory('now', 'UTC+14')->toString('Y-m-d')))) {
$view->autoRefreshTodayReport = Config::getInstance()->General['multisites_refresh_after_seconds'];
}
$this->setGeneralVariablesView($view);
$this->setMinDateView($minDate, $view);
$this->setMaxDateView($maxDate, $view);
$view->show_sparklines = Config::getInstance()->General['show_multisites_sparklines'];
return $view->render();
}
示例12: getAll
/**
* Returns all stored segments.
*
* @param bool|int $idSite Whether to return stored segments for a specific idSite, or all of them. If supplied, must be a valid site ID.
* @return array
*/
public function getAll($idSite = false)
{
if (!empty($idSite)) {
Piwik::checkUserHasViewAccess($idSite);
} else {
Piwik::checkUserHasSomeViewAccess();
}
$userLogin = Piwik::getCurrentUserLogin();
$model = $this->getModel();
if (Piwik::hasUserSuperUserAccess()) {
$segments = $model->getAllSegmentsForAllUsers($idSite);
} else {
if (empty($idSite)) {
$segments = $model->getAllSegments($userLogin);
} else {
$segments = $model->getAllSegmentsForSite($idSite, $userLogin);
}
}
$segments = $this->sortSegmentsCreatedByUserFirst($segments);
return $segments;
}
示例13: getPiwikVersion
/**
* Get Piwik version
* @return string
*/
public function getPiwikVersion()
{
Piwik::checkUserHasSomeViewAccess();
return Version::VERSION;
}
示例14: userEmailExists
/**
* Returns true if user with given email (userEmail) is known in the database, or the Super User
*
* @param string $userEmail
* @return bool true if the user is known
*/
public function userEmailExists($userEmail)
{
Piwik::checkUserIsNotAnonymous();
Piwik::checkUserHasSomeViewAccess();
return $this->model->userEmailExists($userEmail);
}
示例15: userExists
/**
* Returns true if the given userLogin is known in the database
*
* @param string $userLogin
* @return bool true if the user is known
*/
public function userExists($userLogin)
{
if ($userLogin == 'anonymous') {
return true;
}
Piwik::checkUserIsNotAnonymous();
Piwik::checkUserHasSomeViewAccess();
$count = Db::fetchOne("SELECT count(*)\n\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . Common::prefixTable("user") . "\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE login = ?", $userLogin);
return $count != 0;
}