Beispiel #1
0
 private function ensureLanguageSetForUser($currentUser)
 {
     $lang = Piwik_LanguagesManager_API::getInstance()->getLanguageForUser($currentUser);
     if (empty($lang)) {
         Piwik_LanguagesManager_API::getInstance()->setLanguageForUser($currentUser, Piwik_LanguagesManager::getLanguageCodeForCurrentUser());
     }
 }
Beispiel #2
0
 public function index()
 {
     Piwik::checkUserIsNotAnonymous();
     $view = Piwik_View::factory('index');
     $this->setGeneralVariablesView($view);
     $view->currentUserEmail = Piwik::getCurrentUserEmail();
     $availableReports = Piwik_API_API::getInstance()->getReportMetadata($this->idSite);
     $reportsByCategory = array();
     foreach ($availableReports as $report) {
         $reportsByCategory[$report['category']][] = $report;
     }
     unset($reportsByCategory['API']);
     $reports = Piwik_PDFReports_API::getInstance()->getReports($this->idSite, $period = false, $idReport = false, $ifSuperUserReturnOnlySuperUserReports = true);
     $reportsById = array();
     foreach ($reports as &$report) {
         $report['additional_emails'] = str_replace(',', "\n", $report['additional_emails']);
         $report['reports'] = explode(',', str_replace('.', '_', $report['reports']));
         $reportsById[$report['idreport']] = $report;
     }
     $view->downloadOutputType = Piwik_PDFReports_API::OUTPUT_DOWNLOAD;
     $columnsCount = 2;
     $view->newColumnAfter = ceil(count($reportsByCategory) / $columnsCount);
     $view->reportsByCategory = $reportsByCategory;
     $view->reportsJSON = Piwik_Common::json_encode($reportsById);
     $view->periods = array_merge(array('never' => Piwik_Translate('General_Never')), Piwik_PDFReports_API::getPeriodToFrequency());
     $view->defaultFormat = Piwik_PDFReports::DEFAULT_FORMAT;
     $view->formats = Piwik_ReportRenderer::$availableReportRenderers;
     $view->aggregateReportsFormats = Piwik_PDFReports_API::getAggregateReportsFormats();
     $view->reports = $reports;
     $view->language = Piwik_LanguagesManager::getLanguageCodeForCurrentUser();
     echo $view->render();
 }
Beispiel #3
0
 function index()
 {
     Piwik::checkUserIsNotAnonymous();
     $view = Piwik_View::factory('Settings');
     $view->isSuperUser = Piwik::isUserIsSuperUser();
     $mobileMessagingAPI = Piwik_MobileMessaging_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('UserSettings_SubmenuSettings'), Piwik_Translate('MobileMessaging_SettingsMenu')));
     if ($view->credentialSupplied && $view->accountManagedByCurrentUser) {
         $view->provider = $mobileMessagingAPI->getSMSProvider();
         $view->creditLeft = $mobileMessagingAPI->getCreditLeft();
     }
     $view->smsProviders = Piwik_MobileMessaging_SMSProvider::$availableSMSProviders;
     // construct the list of countries from the lang files
     $countries = array();
     foreach (Piwik_Common::getCountriesList() as $countryCode => $continentCode) {
         if (isset(Piwik_MobileMessaging_CountryCallingCodes::$countryCallingCodes[$countryCode])) {
             $countries[$countryCode] = array('countryName' => Piwik_CountryTranslate($countryCode), 'countryCallingCode' => Piwik_MobileMessaging_CountryCallingCodes::$countryCallingCodes[$countryCode]);
         }
     }
     $view->countries = $countries;
     $view->defaultCountry = Piwik_Common::getCountry(Piwik_LanguagesManager::getLanguageCodeForCurrentUser(), true, Piwik_IP::getIpFromHeader());
     $view->phoneNumbers = $mobileMessagingAPI->getPhoneNumbers();
     $this->setBasicVariablesView($view);
     $view->menu = Piwik_GetAdminMenu();
     echo $view->render();
 }
Beispiel #4
0
 public function index()
 {
     $view = Piwik_View::factory('index');
     $this->setGeneralVariablesView($view);
     $view->countWebsites = count(Piwik_SitesManager_API::getInstance()->getSitesIdWithAtLeastViewAccess());
     // get report types
     $reportTypes = Piwik_PDFReports_API::getReportTypes();
     $view->reportTypes = $reportTypes;
     $view->defaultReportType = self::DEFAULT_REPORT_TYPE;
     $view->defaultReportFormat = Piwik_PDFReports::DEFAULT_REPORT_FORMAT;
     $reportsByCategoryByType = array();
     $reportFormatsByReportType = array();
     $allowMultipleReportsByReportType = array();
     foreach ($reportTypes as $reportType => $reportTypeIcon) {
         // get report formats
         $reportFormatsByReportType[$reportType] = Piwik_PDFReports_API::getReportFormats($reportType);
         $allowMultipleReportsByReportType[$reportType] = Piwik_PDFReports_API::allowMultipleReports($reportType);
         // get report metadata
         $reportsByCategory = array();
         $availableReportMetadata = Piwik_PDFReports_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 = Piwik_PDFReports_API::getInstance()->getReports($this->idSite, $period = false, $idReport = false, $ifSuperUserReturnOnlySuperUserReports = true);
         foreach ($reports as &$report) {
             $report['recipients'] = Piwik_PDFReports_API::getReportRecipients($report);
             $reportsById[$report['idreport']] = $report;
         }
     }
     $view->reports = $reports;
     $view->reportsJSON = Piwik_Common::json_encode($reportsById);
     $view->downloadOutputType = Piwik_PDFReports_API::OUTPUT_INLINE;
     $periods = array_merge(array('never' => Piwik_Translate('General_Never')), Piwik_PDFReports::getPeriodToFrequency());
     // Do not display date range in selector
     unset($periods['range']);
     $view->periods = $periods;
     $view->defaultPeriod = Piwik_PDFReports::DEFAULT_PERIOD;
     $view->language = Piwik_LanguagesManager::getLanguageCodeForCurrentUser();
     echo $view->render();
 }
Beispiel #5
0
 /**
  * Shows the "Track Visits" checkbox.
  */
 public function optOut()
 {
     $trackVisits = !Piwik_Tracker_IgnoreCookie::isIgnoreCookieFound();
     $nonce = Piwik_Common::getRequestVar('nonce', false);
     $language = Piwik_Common::getRequestVar('language', '');
     if ($nonce !== false && Piwik_Nonce::verifyNonce('Piwik_OptOut', $nonce)) {
         Piwik_Nonce::discardNonce('Piwik_OptOut');
         Piwik_Tracker_IgnoreCookie::setIgnoreCookie();
         $trackVisits = !$trackVisits;
     }
     $view = Piwik_View::factory('optOut');
     $view->trackVisits = $trackVisits;
     $view->nonce = Piwik_Nonce::getNonce('Piwik_OptOut', 3600);
     $view->language = Piwik_LanguagesManager_API::getInstance()->isLanguageAvailable($language) ? $language : Piwik_LanguagesManager::getLanguageCodeForCurrentUser();
     echo $view->render();
 }
Beispiel #6
0
 public function privacySettings()
 {
     Piwik::checkUserHasSomeAdminAccess();
     $view = Piwik_View::factory('privacySettings');
     if (Piwik::isUserIsSuperUser()) {
         $deleteLogs = array();
         $view->deleteLogs = $this->getDeleteLogsInfo();
         $view->anonymizeIP = $this->getAnonymizeIPInfo();
     }
     $view->language = Piwik_LanguagesManager::getLanguageCodeForCurrentUser();
     if (!Zend_Registry::get('config')->isFileWritable()) {
         $view->configFileNotWritable = true;
     }
     $this->setBasicVariablesView($view);
     $view->menu = Piwik_GetAdminMenu();
     echo $view->render();
 }
Beispiel #7
0
 /**
  * Sets general variables to the view that are used by
  * various templates and Javascript.
  * If any error happens, displays the login screen
  *
  * @param Piwik_View  $view
  * @throws Exception
  * @return void
  */
 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 = Piwik_Common::getRequestVar('date');
         $periodStr = Piwik_Common::getRequestVar('period');
         if ($periodStr != 'range') {
             $date = Piwik_Date::factory($this->strDate);
             $period = Piwik_Period::factory($periodStr, $date);
         } else {
             $period = new Piwik_Period_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 = Piwik_Date::factory($datetimeMinDate, $this->site->getTimezone());
         $this->setMinDateView($minDate, $view);
         $maxDate = Piwik_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 = Piwik_LanguagesManager::getLanguageForSession();
         $view->language = !empty($language) ? $language : Piwik_LanguagesManager::getLanguageCodeForCurrentUser();
         $view->config_action_url_category_delimiter = Piwik_Config::getInstance()->General['action_url_category_delimiter'];
         $this->setBasicVariablesView($view);
     } catch (Exception $e) {
         Piwik_ExitWithMessage($e->getMessage());
     }
 }