public static getLanguageCodeForCurrentUser ( ) : string | ||
리턴 | string | Two letters language code, eg. "fr" |
public function index() { Piwik::checkUserIsNotAnonymous(); $view = new View('@MobileMessaging/index'); $view->isSuperUser = Piwik::hasUserSuperUserAccess(); $mobileMessagingAPI = API::getInstance(); $view->delegatedManagement = $mobileMessagingAPI->getDelegatedManagement(); $view->credentialSupplied = $mobileMessagingAPI->areSMSAPICredentialProvided(); $view->accountManagedByCurrentUser = $view->isSuperUser || $view->delegatedManagement; $view->strHelpAddPhone = Piwik::translate('MobileMessaging_Settings_PhoneNumbers_HelpAdd', array(Piwik::translate('General_Settings'), Piwik::translate('MobileMessaging_SettingsMenu'))); if ($view->credentialSupplied && $view->accountManagedByCurrentUser) { $view->provider = $mobileMessagingAPI->getSMSProvider(); $view->creditLeft = $mobileMessagingAPI->getCreditLeft(); } $view->smsProviders = SMSProvider::$availableSMSProviders; // construct the list of countries from the lang files $countries = array(); foreach (Common::getCountriesList() as $countryCode => $continentCode) { if (isset(CountryCallingCodes::$countryCallingCodes[$countryCode])) { $countries[$countryCode] = array('countryName' => \Piwik\Plugins\UserCountry\countryTranslate($countryCode), 'countryCallingCode' => CountryCallingCodes::$countryCallingCodes[$countryCode]); } } $view->countries = $countries; $view->defaultCountry = Common::getCountry(LanguagesManager::getLanguageCodeForCurrentUser(), true, IP::getIpFromHeader()); $view->phoneNumbers = $mobileMessagingAPI->getPhoneNumbers(); $this->setBasicVariablesView($view); return $view->render(); }
public function index() { $view = new View('@ScheduledReports/index'); $this->setGeneralVariablesView($view); $view->countWebsites = count(APISitesManager::getInstance()->getSitesIdWithAtLeastViewAccess()); // get report types $reportTypes = API::getReportTypes(); $view->reportTypes = $reportTypes; $view->defaultReportType = self::DEFAULT_REPORT_TYPE; $view->defaultReportFormat = ScheduledReports::DEFAULT_REPORT_FORMAT; $view->displayFormats = ScheduledReports::getDisplayFormats(); $reportsByCategoryByType = array(); $reportFormatsByReportType = array(); $allowMultipleReportsByReportType = array(); foreach ($reportTypes as $reportType => $reportTypeIcon) { // get report formats $reportFormatsByReportType[$reportType] = API::getReportFormats($reportType); $allowMultipleReportsByReportType[$reportType] = API::allowMultipleReports($reportType); // get report metadata $reportsByCategory = array(); $availableReportMetadata = API::getReportMetadata($this->idSite, $reportType); foreach ($availableReportMetadata as $reportMetadata) { $reportsByCategory[$reportMetadata['category']][] = $reportMetadata; } $reportsByCategoryByType[$reportType] = $reportsByCategory; } $view->reportsByCategoryByReportType = $reportsByCategoryByType; $view->reportFormatsByReportType = $reportFormatsByReportType; $view->allowMultipleReportsByReportType = $allowMultipleReportsByReportType; $reports = array(); $reportsById = array(); if (!Piwik::isUserIsAnonymous()) { $reports = API::getInstance()->getReports($this->idSite, $period = false, $idReport = false, $ifSuperUserReturnOnlySuperUserReports = true); foreach ($reports as &$report) { $report['recipients'] = API::getReportRecipients($report); $reportsById[$report['idreport']] = $report; } } $view->reports = $reports; $view->reportsJSON = Common::json_encode($reportsById); $view->downloadOutputType = API::OUTPUT_INLINE; $view->periods = ScheduledReports::getPeriodToFrequency(); $view->defaultPeriod = ScheduledReports::DEFAULT_PERIOD; $view->defaultHour = ScheduledReports::DEFAULT_HOUR; $view->language = LanguagesManager::getLanguageCodeForCurrentUser(); $view->segmentEditorActivated = false; if (API::isSegmentEditorActivated()) { $savedSegmentsById = array(); foreach (APISegmentEditor::getInstance()->getAll($this->idSite) as $savedSegment) { $savedSegmentsById[$savedSegment['idsegment']] = $savedSegment['name']; } $view->savedSegmentsById = $savedSegmentsById; $view->segmentEditorActivated = true; } return $view->render(); }
public function index() { Piwik::checkUserHasSuperUserAccess(); $view = new View('@IP2Location/index'); $view->language = LanguagesManager::getLanguageCodeForCurrentUser(); $this->setBasicVariablesView($view); $view->adminMenu = MenuAdmin::getInstance()->getMenu(); $view->topMenu = MenuTop::getInstance()->getMenu(); $view->notifications = NotificationManager::getAllNotificationsToDisplay(); $view->userMenu = MenuUser::getInstance()->getMenu(); $view->phpVersion = phpversion(); $view->phpIsNewEnough = version_compare($view->phpVersion, '5.3.0', '>='); $view->assign('userMenu', 'IP2Location'); $view->assign('dbNotFound', false); $view->assign('dbOutDated', false); $view->assign('showResults', false); $view->assign('fileName', '-'); $view->assign('date', '-'); $view->assign('country', ''); $view->assign('regionName', ''); $view->assign('cityName', ''); $view->assign('position', ''); $ipAddress = trim(Common::getRequestVar('ipAddress', $_SERVER['REMOTE_ADDR'])); $view->assign('ipAddress', $ipAddress); $dbPath = PIWIK_INCLUDE_PATH . '/plugins/IP2Location/data/'; $dbFile = ''; if ($handle = opendir($dbPath)) { while (false !== ($file = readdir($handle))) { if (strtoupper(substr($file, -4)) == '.BIN') { $dbFile = $dbPath . $file; break; } } closedir($handle); } if (!$dbFile) { $view->assign('dbNotFound', true); } if ($dbFile) { $view->assign('fileName', $file); if (filemtime($dbFile) < strtotime('-2 months')) { $view->assign('dbOutDated', true); } else { $view->assign('date', date('d M, Y', filemtime($dbFile))); } if (!empty($_POST)) { $view->assign('showResults', true); $result = IP2LocationAPI::lookup($ipAddress, $dbFile); $view->assign('country', $result['countryCode'] != '-' ? $result['countryName'] . ' (' . $result['countryCode'] . ')' : '-'); $view->assign('regionName', !preg_match('/not supported/', $result['regionName']) ? $result['regionName'] : '-'); $view->assign('cityName', !preg_match('/not supported/', $result['cityName']) ? $result['cityName'] : '-'); $view->assign('position', !preg_match('/not supported/', $result['latitude']) && $result['latitude'] != '-' ? $result['latitude'] . ', ' . $result['longitude'] : '-'); } } echo $view->render(); }
/** * Main Plugin Index * * @return mixed * @throws \Exception */ public function index() { Piwik::checkUserHasSomeAdminAccess(); if (isset($_SERVER['REQUEST_METHOD']) && 'POST' == $_SERVER['REQUEST_METHOD']) { // Cannot use Common::getRequestVar, because the function remove whitespaces and newline breaks $postedSiteData = isset($_POST['site']) ? $_POST['site'] : null; if (is_array($postedSiteData) && count($postedSiteData) > 0) { foreach ($postedSiteData as $id => $site) { if (!isset($site['css'], $site['file'])) { continue; } // Check URL if (!UrlHelper::isLookLikeUrl($site['file'])) { $site['file'] = null; } API::getInstance()->saveSite($id, $site['css'], $site['file']); } // Redirect to, clear POST vars $this->redirectToIndex('CustomOptOut', 'index'); return; } } $view = new View('@CustomOptOut/index.twig'); Site::clearCache(); if (Piwik::hasUserSuperUserAccess()) { $sitesRaw = APISiteManager::getInstance()->getAllSites(); } else { $sitesRaw = APISiteManager::getInstance()->getSitesWithAdminAccess(); } // Gets sites after Site.setSite hook was called $sites = array_values(Site::getSites()); if (count($sites) != count($sitesRaw)) { throw new \Exception("One or more website are missing or invalid."); } foreach ($sites as &$site) { $site['alias_urls'] = APISiteManager::getInstance()->getSiteUrlsFromId($site['idsite']); } $view->adminSites = $sites; $view->adminSitesCount = count($sites); $view->language = LanguagesManager::getLanguageCodeForCurrentUser(); $view->isEditorEnabled = API::getInstance()->isCssEditorEnabled(); $view->editorTheme = API::getInstance()->getEditorTheme(); $view->showOldLinks = false; $this->setBasicVariablesView($view); return $view->render(); }
private function setManageVariables(View $view) { $view->isSuperUser = Piwik::hasUserSuperUserAccess(); $mobileMessagingAPI = API::getInstance(); $view->delegatedManagement = $mobileMessagingAPI->getDelegatedManagement(); $view->credentialSupplied = $mobileMessagingAPI->areSMSAPICredentialProvided(); $view->accountManagedByCurrentUser = $view->isSuperUser || $view->delegatedManagement; $view->strHelpAddPhone = $this->translator->translate('MobileMessaging_Settings_PhoneNumbers_HelpAdd', array($this->translator->translate('General_Settings'), $this->translator->translate('MobileMessaging_SettingsMenu'))); $view->creditLeft = 0; $currentProvider = ''; if ($view->credentialSupplied && $view->accountManagedByCurrentUser) { $currentProvider = $mobileMessagingAPI->getSMSProvider(); $view->creditLeft = $mobileMessagingAPI->getCreditLeft(); } $view->delegateManagementOptions = array(array('key' => '0', 'value' => Piwik::translate('General_No'), 'description' => Piwik::translate('General_Default') . '. ' . Piwik::translate('MobileMessaging_Settings_LetUsersManageAPICredential_No_Help')), array('key' => '1', 'value' => Piwik::translate('General_Yes'), 'description' => Piwik::translate('MobileMessaging_Settings_LetUsersManageAPICredential_Yes_Help'))); $providers = array(); $providerOptions = array(); foreach (SMSProvider::findAvailableSmsProviders() as $provider) { if (empty($currentProvider)) { $currentProvider = $provider->getId(); } $providers[$provider->getId()] = $provider->getDescription(); $providerOptions[$provider->getId()] = $provider->getId(); } $view->provider = $currentProvider; $view->smsProviders = $providers; $view->smsProviderOptions = $providerOptions; $defaultCountry = Common::getCountry(LanguagesManager::getLanguageCodeForCurrentUser(), true, IP::getIpFromHeader()); $view->defaultCallingCode = ''; // construct the list of countries from the lang files $countries = array(array('key' => '', 'value' => '')); foreach ($this->regionDataProvider->getCountryList() as $countryCode => $continentCode) { if (isset(CountryCallingCodes::$countryCallingCodes[$countryCode])) { if ($countryCode == $defaultCountry) { $view->defaultCallingCode = CountryCallingCodes::$countryCallingCodes[$countryCode]; } $countries[] = array('key' => CountryCallingCodes::$countryCallingCodes[$countryCode], 'value' => \Piwik\Plugins\UserCountry\countryTranslate($countryCode)); } } $view->countries = $countries; $view->phoneNumbers = $mobileMessagingAPI->getPhoneNumbers(); $this->setBasicVariablesView($view); }
public function generalSettings() { Piwik::checkUserHasSuperUserAccess(); $view = new View('@CoreAdminHome/generalSettings'); $this->handleGeneralSettingsAdmin($view); $view->trustedHosts = Url::getTrustedHostsFromConfig(); $logo = new CustomLogo(); $view->branding = array('use_custom_logo' => $logo->isEnabled()); $view->fileUploadEnabled = $logo->isFileUploadEnabled(); $view->logosWriteable = $logo->isCustomLogoWritable(); $view->pathUserLogo = CustomLogo::getPathUserLogo(); $view->pathUserFavicon = CustomLogo::getPathUserFavicon(); $view->pathUserLogoSmall = CustomLogo::getPathUserLogoSmall(); $view->pathUserLogoSVG = CustomLogo::getPathUserSvgLogo(); $view->pathUserLogoDirectory = realpath(dirname($view->pathUserLogo) . '/'); $view->language = LanguagesManager::getLanguageCodeForCurrentUser(); $this->setBasicVariablesView($view); return $view->render(); }
/** * Shows the "Track Visits" checkbox. */ public function optOut() { $trackVisits = !IgnoreCookie::isIgnoreCookieFound(); $nonce = Common::getRequestVar('nonce', false); $language = Common::getRequestVar('language', ''); if ($nonce !== false && Nonce::verifyNonce('Piwik_OptOut', $nonce)) { Nonce::discardNonce('Piwik_OptOut'); IgnoreCookie::setIgnoreCookie(); $trackVisits = !$trackVisits; } $view = new View('@CoreAdminHome/optOut'); $view->trackVisits = $trackVisits; $view->nonce = Nonce::getNonce('Piwik_OptOut', 3600); $view->language = APILanguagesManager::getInstance()->isLanguageAvailable($language) ? $language : LanguagesManager::getLanguageCodeForCurrentUser(); return $view->render(); }
/** * Assigns variables to {@link Piwik\View} instances that display an entire page. * * The following variables assigned: * * **date** - The value of the **date** query parameter. * **idSite** - The value of the **idSite** query parameter. * **rawDate** - The value of the **date** query parameter. * **prettyDate** - A pretty string description of the current period. * **siteName** - The current site's name. * **siteMainUrl** - The URL of the current site. * **startDate** - The start date of the current period. A {@link Piwik\Date} instance. * **endDate** - The end date of the current period. A {@link Piwik\Date} instance. * **language** - The current language's language code. * **config_action_url_category_delimiter** - The value of the `[General] action_url_category_delimiter` * INI config option. * **topMenu** - The result of `MenuTop::getInstance()->getMenu()`. * * As well as the variables set by {@link setPeriodVariablesView()}. * * Will exit on error. * * @param View $view * @return void * @api */ protected function setGeneralVariablesView($view) { $view->date = $this->strDate; try { $view->idSite = $this->idSite; if (empty($this->site) || empty($this->idSite)) { throw new Exception("The requested website idSite is not found in the request, or is invalid.\n\t\t\t\tPlease check that you are logged in Piwik and have permission to access the specified website."); } $this->setPeriodVariablesView($view); $rawDate = Common::getRequestVar('date'); $periodStr = Common::getRequestVar('period'); if ($periodStr != 'range') { $date = Date::factory($this->strDate); $period = Period\Factory::build($periodStr, $date); } else { $period = new Range($periodStr, $rawDate, $this->site->getTimezone()); } $view->rawDate = $rawDate; $view->prettyDate = self::getCalendarPrettyDate($period); $view->siteName = $this->site->getName(); $view->siteMainUrl = $this->site->getMainUrl(); $datetimeMinDate = $this->site->getCreationDate()->getDatetime(); $minDate = Date::factory($datetimeMinDate, $this->site->getTimezone()); $this->setMinDateView($minDate, $view); $maxDate = Date::factory('now', $this->site->getTimezone()); $this->setMaxDateView($maxDate, $view); // Setting current period start & end dates, for pre-setting the calendar when "Date Range" is selected $dateStart = $period->getDateStart(); if ($dateStart->isEarlier($minDate)) { $dateStart = $minDate; } $dateEnd = $period->getDateEnd(); if ($dateEnd->isLater($maxDate)) { $dateEnd = $maxDate; } $view->startDate = $dateStart; $view->endDate = $dateEnd; $language = LanguagesManager::getLanguageForSession(); $view->language = !empty($language) ? $language : LanguagesManager::getLanguageCodeForCurrentUser(); $this->setBasicVariablesView($view); $view->topMenu = MenuTop::getInstance()->getMenu(); $view->userMenu = MenuUser::getInstance()->getMenu(); $notifications = $view->notifications; if (empty($notifications)) { $view->notifications = NotificationManager::getAllNotificationsToDisplay(); NotificationManager::cancelAllNonPersistent(); } } catch (Exception $e) { Piwik_ExitWithMessage($e->getMessage(), $e->getTraceAsString()); } }
/** * The "User Settings" admin UI screen view */ public function userSettings() { Piwik::checkUserIsNotAnonymous(); $view = new View('@UsersManager/userSettings'); $userLogin = Piwik::getCurrentUserLogin(); $user = APIUsersManager::getInstance()->getUser($userLogin); $view->userAlias = $user['alias']; $view->userEmail = $user['email']; $view->ignoreSalt = $this->getIgnoreCookieSalt(); $userPreferences = new UserPreferences(); $defaultReport = $userPreferences->getDefaultReport(); if ($defaultReport === false) { $defaultReport = $userPreferences->getDefaultWebsiteId(); } $view->defaultReport = $defaultReport; if ($defaultReport == 'MultiSites') { $defaultSiteId = $userPreferences->getDefaultWebsiteId(); $view->defaultReportIdSite = $defaultSiteId; $view->defaultReportSiteName = Site::getNameFor($defaultSiteId); } else { $view->defaultReportIdSite = $defaultReport; $view->defaultReportSiteName = Site::getNameFor($defaultReport); } $view->defaultDate = $this->getDefaultDateForUser($userLogin); $view->availableDefaultDates = $this->getDefaultDates(); $view->languages = APILanguagesManager::getInstance()->getAvailableLanguageNames(); $view->currentLanguageCode = LanguagesManager::getLanguageCodeForCurrentUser(); $view->ignoreCookieSet = IgnoreCookie::isIgnoreCookieFound(); $view->piwikHost = Url::getCurrentHost(); $this->setBasicVariablesView($view); return $view->render(); }
public function privacySettings() { Piwik::checkUserHasSomeAdminAccess(); $view = new View('@PrivacyManager/privacySettings'); if (Piwik::hasUserSuperUserAccess()) { $view->deleteData = $this->getDeleteDataInfo(); $view->anonymizeIP = $this->getAnonymizeIPInfo(); $view->dntSupport = DoNotTrackHeaderChecker::isActive(); $view->canDeleteLogActions = Db::isLockPrivilegeGranted(); $view->dbUser = PiwikConfig::getInstance()->database['username']; $view->deactivateNonce = Nonce::getNonce(self::DEACTIVATE_DNT_NONCE); $view->activateNonce = Nonce::getNonce(self::ACTIVATE_DNT_NONCE); } $view->language = LanguagesManager::getLanguageCodeForCurrentUser(); $this->setBasicVariablesView($view); return $view->render(); }
/** * @return View * @throws \Exception */ public function getOptOutView() { if ($this->view) { return $this->view; } $trackVisits = !IgnoreCookie::isIgnoreCookieFound(); $dntFound = $this->getDoNotTrackHeaderChecker()->isDoNotTrackFound(); $setCookieInNewWindow = Common::getRequestVar('setCookieInNewWindow', false, 'int'); if ($setCookieInNewWindow) { $reloadUrl = Url::getCurrentQueryStringWithParametersModified(array('showConfirmOnly' => 1, 'setCookieInNewWindow' => 0)); } else { $reloadUrl = false; $nonce = Common::getRequestVar('nonce', false); if ($nonce !== false && Nonce::verifyNonce('Piwik_OptOut', $nonce)) { Nonce::discardNonce('Piwik_OptOut'); IgnoreCookie::setIgnoreCookie(); $trackVisits = !$trackVisits; } } $language = Common::getRequestVar('language', ''); $lang = APILanguagesManager::getInstance()->isLanguageAvailable($language) ? $language : LanguagesManager::getLanguageCodeForCurrentUser(); $this->addQueryParameters(array('module' => 'CoreAdminHome', 'action' => 'optOut', 'language' => $lang, 'setCookieInNewWindow' => 1), false); $this->view = new View("@CoreAdminHome/optOut"); $this->view->setXFrameOptions('allow'); $this->view->dntFound = $dntFound; $this->view->trackVisits = $trackVisits; $this->view->nonce = Nonce::getNonce('Piwik_OptOut', 3600); $this->view->language = $lang; $this->view->showConfirmOnly = Common::getRequestVar('showConfirmOnly', false, 'int'); $this->view->reloadUrl = $reloadUrl; $this->view->javascripts = $this->getJavascripts(); $this->view->stylesheets = $this->getStylesheets(); $this->view->title = $this->getTitle(); $this->view->queryParameters = $this->getQueryParameters(); return $this->view; }
/** * The "User Settings" admin UI screen view */ public function userSettings() { Piwik::checkUserIsNotAnonymous(); $view = new View('@UsersManager/userSettings'); $userLogin = Piwik::getCurrentUserLogin(); $user = Request::processRequest('UsersManager.getUser', array('userLogin' => $userLogin)); $view->userAlias = $user['alias']; $view->userEmail = $user['email']; $view->userTokenAuth = Piwik::getCurrentUserTokenAuth(); $view->ignoreSalt = $this->getIgnoreCookieSalt(); $userPreferences = new UserPreferences(); $defaultReport = $userPreferences->getDefaultReport(); if ($defaultReport === false) { $defaultReport = $userPreferences->getDefaultWebsiteId(); } $view->defaultReport = $defaultReport; if ($defaultReport == 'MultiSites') { $defaultSiteId = $userPreferences->getDefaultWebsiteId(); $reportOptionsValue = $defaultSiteId; $view->defaultReportIdSite = $defaultSiteId; $view->defaultReportSiteName = Site::getNameFor($defaultSiteId); } else { $reportOptionsValue = $defaultReport; $view->defaultReportIdSite = $defaultReport; $view->defaultReportSiteName = Site::getNameFor($defaultReport); } $view->defaultReportOptions = array(array('key' => 'MultiSites', 'value' => Piwik::translate('General_AllWebsitesDashboard')), array('key' => $reportOptionsValue, 'value' => Piwik::translate('General_DashboardForASpecificWebsite'))); $view->defaultDate = $this->getDefaultDateForUser($userLogin); $view->availableDefaultDates = $this->getDefaultDates(); $languages = APILanguagesManager::getInstance()->getAvailableLanguageNames(); $languageOptions = array(); foreach ($languages as $language) { $languageOptions[] = array('key' => $language['code'], 'value' => $language['name']); } $view->languageOptions = $languageOptions; $view->currentLanguageCode = LanguagesManager::getLanguageCodeForCurrentUser(); $view->currentTimeformat = (int) LanguagesManager::uses12HourClockForCurrentUser(); $view->ignoreCookieSet = IgnoreCookie::isIgnoreCookieFound(); $view->piwikHost = Url::getCurrentHost(); $this->setBasicVariablesView($view); $view->timeFormats = array('1' => Piwik::translate('General_12HourClock'), '0' => Piwik::translate('General_24HourClock')); return $view->render(); }
/** * Shows the "Track Visits" checkbox. */ public function optOut() { $trackVisits = !IgnoreCookie::isIgnoreCookieFound(); $dntChecker = new DoNotTrackHeaderChecker(); $dntFound = $dntChecker->isDoNotTrackFound(); $setCookieInNewWindow = Common::getRequestVar('setCookieInNewWindow', false, 'int'); if ($setCookieInNewWindow) { $reloadUrl = Url::getCurrentQueryStringWithParametersModified(array( 'showConfirmOnly' => 1, 'setCookieInNewWindow' => 0, )); } else { $reloadUrl = false; $nonce = Common::getRequestVar('nonce', false); if ($nonce !== false && Nonce::verifyNonce('Piwik_OptOut', $nonce)) { Nonce::discardNonce('Piwik_OptOut'); IgnoreCookie::setIgnoreCookie(); $trackVisits = !$trackVisits; } } $language = Common::getRequestVar('language', ''); $lang = APILanguagesManager::getInstance()->isLanguageAvailable($language) ? $language : LanguagesManager::getLanguageCodeForCurrentUser(); // should not use self::renderTemplate since that uses setBasicVariablesView. this will cause // an error when setBasicVariablesAdminView is called, and MenuTop is requested (the idSite query // parameter is required) $view = new View("@CoreAdminHome/optOut"); $view->setXFrameOptions('allow'); $view->dntFound = $dntFound; $view->trackVisits = $trackVisits; $view->nonce = Nonce::getNonce('Piwik_OptOut', 3600); $view->language = $lang; $view->isSafari = $this->isUserAgentSafari(); $view->showConfirmOnly = Common::getRequestVar('showConfirmOnly', false, 'int'); $view->reloadUrl = $reloadUrl; return $view->render(); }
/** * Shows the "Track Visits" checkbox. */ public function optOut() { $trackVisits = !IgnoreCookie::isIgnoreCookieFound(); $nonce = Common::getRequestVar('nonce', false); $language = Common::getRequestVar('language', ''); if ($nonce !== false && Nonce::verifyNonce('Piwik_OptOut', $nonce)) { Nonce::discardNonce('Piwik_OptOut'); IgnoreCookie::setIgnoreCookie(); $trackVisits = !$trackVisits; } $lang = APILanguagesManager::getInstance()->isLanguageAvailable($language) ? $language : LanguagesManager::getLanguageCodeForCurrentUser(); return $this->renderTemplate('optOut', array('trackVisits' => $trackVisits, 'nonce' => Nonce::getNonce('Piwik_OptOut', 3600), 'language' => $lang)); }
public function privacySettings() { Piwik::checkUserHasSomeAdminAccess(); $view = new View('@PrivacyManager/privacySettings'); if (Piwik::hasUserSuperUserAccess()) { $view->deleteData = $this->getDeleteDataInfo(); $view->anonymizeIP = $this->getAnonymizeIPInfo(); $dntChecker = new DoNotTrackHeaderChecker(); $view->dntSupport = $dntChecker->isActive(); $view->canDeleteLogActions = Db::isLockPrivilegeGranted(); $view->dbUser = PiwikConfig::getInstance()->database['username']; $view->deactivateNonce = Nonce::getNonce(self::DEACTIVATE_DNT_NONCE); $view->activateNonce = Nonce::getNonce(self::ACTIVATE_DNT_NONCE); $view->maskLengthOptions = array(array('key' => '1', 'value' => Piwik::translate('PrivacyManager_AnonymizeIpMaskLength', array("1", "192.168.100.xxx")), 'description' => ''), array('key' => '2', 'value' => Piwik::translate('PrivacyManager_AnonymizeIpMaskLength', array("2", "192.168.xxx.xxx")), 'description' => Piwik::translate('General_Recommended')), array('key' => '3', 'value' => Piwik::translate('PrivacyManager_AnonymizeIpMaskLength', array("3", "192.xxx.xxx.xxx")), 'description' => '')); $view->useAnonymizedIpForVisitEnrichmentOptions = array(array('key' => '1', 'value' => Piwik::translate('General_Yes'), 'description' => Piwik::translate('PrivacyManager_RecommendedForPrivacy')), array('key' => '0', 'value' => Piwik::translate('General_No'), 'description' => '')); $view->scheduleDeletionOptions = array(array('key' => '1', 'value' => Piwik::translate('Intl_PeriodDay')), array('key' => '7', 'value' => Piwik::translate('Intl_PeriodWeek')), array('key' => '30', 'value' => Piwik::translate('Intl_PeriodMonth'))); $view->doNotTrackOptions = array(array('key' => '1', 'value' => Piwik::translate('PrivacyManager_DoNotTrack_Enable'), 'description' => Piwik::translate('General_Recommended')), array('key' => '0', 'value' => Piwik::translate('PrivacyManager_DoNotTrack_Disable'), 'description' => Piwik::translate('General_NotRecommended'))); } $view->language = LanguagesManager::getLanguageCodeForCurrentUser(); $this->setBasicVariablesView($view); return $view->render(); }
private static function ensureLanguageSetForUser($currentUser) { $lang = \Piwik\Plugins\LanguagesManager\API::getInstance()->getLanguageForUser($currentUser); if (empty($lang)) { \Piwik\Plugins\LanguagesManager\API::getInstance()->setLanguageForUser($currentUser, LanguagesManager::getLanguageCodeForCurrentUser()); } }
/** * Shows the "Track Visits" checkbox. */ public function optOut() { $trackVisits = !IgnoreCookie::isIgnoreCookieFound(); $nonce = Common::getRequestVar('nonce', false); $language = Common::getRequestVar('language', ''); if ($nonce !== false && Nonce::verifyNonce('Piwik_OptOut', $nonce)) { Nonce::discardNonce('Piwik_OptOut'); IgnoreCookie::setIgnoreCookie(); $trackVisits = !$trackVisits; } $lang = APILanguagesManager::getInstance()->isLanguageAvailable($language) ? $language : LanguagesManager::getLanguageCodeForCurrentUser(); // should not use self::renderTemplate since that uses setBasicVariablesView. this will cause // an error when setBasicVariablesAdminView is called, and MenuTop is requested (the idSite query // parameter is required) $view = new View("@CoreAdminHome/optOut"); $view->setXFrameOptions('allow'); $view->trackVisits = $trackVisits; $view->nonce = Nonce::getNonce('Piwik_OptOut', 3600); $view->language = $lang; return $view->render(); }
/** * Assigns variables to {@link Piwik\View} instances that display an entire page. * * The following variables assigned: * * **date** - The value of the **date** query parameter. * **idSite** - The value of the **idSite** query parameter. * **rawDate** - The value of the **date** query parameter. * **prettyDate** - A pretty string description of the current period. * **siteName** - The current site's name. * **siteMainUrl** - The URL of the current site. * **startDate** - The start date of the current period. A {@link Piwik\Date} instance. * **endDate** - The end date of the current period. A {@link Piwik\Date} instance. * **language** - The current language's language code. * **config_action_url_category_delimiter** - The value of the `[General] action_url_category_delimiter` * INI config option. * **topMenu** - The result of `MenuTop::getInstance()->getMenu()`. * * As well as the variables set by {@link setPeriodVariablesView()}. * * Will exit on error. * * @param View $view * @return void * @api */ protected function setGeneralVariablesView($view) { $view->idSite = $this->idSite; $this->checkSitePermission(); $this->setPeriodVariablesView($view); $view->siteName = $this->site->getName(); $view->siteMainUrl = $this->site->getMainUrl(); $siteTimezone = $this->site->getTimezone(); $datetimeMinDate = $this->site->getCreationDate()->getDatetime(); $minDate = Date::factory($datetimeMinDate, $siteTimezone); $this->setMinDateView($minDate, $view); $maxDate = Date::factory('now', $siteTimezone); $this->setMaxDateView($maxDate, $view); $rawDate = Common::getRequestVar('date'); Period::checkDateFormat($rawDate); $periodStr = Common::getRequestVar('period'); if ($periodStr != 'range') { $date = Date::factory($this->strDate); $validDate = $this->getValidDate($date, $minDate, $maxDate); $period = Period\Factory::build($periodStr, $validDate); if ($date->toString() !== $validDate->toString()) { // we to not always change date since it could convert a strDate "today" to "YYYY-MM-DD" // only change $this->strDate if it was not valid before $this->setDate($validDate); } } else { $period = new Range($periodStr, $rawDate, $siteTimezone); } // Setting current period start & end dates, for pre-setting the calendar when "Date Range" is selected $dateStart = $period->getDateStart(); $dateStart = $this->getValidDate($dateStart, $minDate, $maxDate); $dateEnd = $period->getDateEnd(); $dateEnd = $this->getValidDate($dateEnd, $minDate, $maxDate); if ($periodStr == 'range') { // make sure we actually display the correct calendar pretty date $newRawDate = $dateStart->toString() . ',' . $dateEnd->toString(); $period = new Range($periodStr, $newRawDate, $siteTimezone); } $view->date = $this->strDate; $view->prettyDate = self::getCalendarPrettyDate($period); $view->prettyDateLong = $period->getLocalizedLongString(); $view->rawDate = $rawDate; $view->startDate = $dateStart; $view->endDate = $dateEnd; $language = LanguagesManager::getLanguageForSession(); $view->language = !empty($language) ? $language : LanguagesManager::getLanguageCodeForCurrentUser(); $this->setBasicVariablesView($view); $view->topMenu = MenuTop::getInstance()->getMenu(); $view->adminMenu = MenuAdmin::getInstance()->getMenu(); $notifications = $view->notifications; if (empty($notifications)) { $view->notifications = NotificationManager::getAllNotificationsToDisplay(); NotificationManager::cancelAllNonPersistent(); } }