Пример #1
0
 protected function init()
 {
     parent::init();
     $this->reportsToMerge = $this->getReportsToMerge();
     $this->module = 'API';
     $this->action = 'get';
     $this->categoryId = 'API';
     $this->name = Piwik::translate('General_MainMetrics');
     $this->documentation = '';
     $this->processedMetrics = array();
     foreach ($this->reportsToMerge as $report) {
         if (!is_array($report->processedMetrics)) {
             continue;
         }
         $this->processedMetrics = array_merge($this->processedMetrics, $report->processedMetrics);
     }
     $this->metrics = array();
     foreach ($this->reportsToMerge as $report) {
         if (!is_array($report->metrics)) {
             continue;
         }
         $this->metrics = array_merge($this->metrics, $report->metrics);
     }
     $this->order = 6;
 }
Пример #2
0
 public function saveSettings()
 {
     Piwik::checkUserIsSuperUser();
     if ($_SERVER["REQUEST_METHOD"] == "POST") {
         $this->checkTokenInUrl();
         switch (Common::getRequestVar('form')) {
             case "formMaskLength":
                 $this->handlePluginState(Common::getRequestVar("anonymizeIPEnable", 0));
                 $trackerConfig = Config::getInstance()->Tracker;
                 $trackerConfig['ip_address_mask_length'] = Common::getRequestVar("maskLength", 1);
                 $trackerConfig['use_anonymized_ip_for_visit_enrichment'] = Common::getRequestVar("useAnonymizedIpForVisitEnrichment", 1);
                 Config::getInstance()->Tracker = $trackerConfig;
                 Config::getInstance()->forceSave();
                 break;
             case "formDeleteSettings":
                 $this->checkDataPurgeAdminSettingsIsEnabled();
                 $settings = $this->getPurgeSettingsFromRequest();
                 PrivacyManager::savePurgeDataSettings($settings);
                 break;
             default:
                 //do nothing
                 break;
         }
     }
     $notification = new Notification(Piwik::translate('General_YourChangesHaveBeenSaved'));
     $notification->context = Notification::CONTEXT_SUCCESS;
     Notification\Manager::notify('PrivacyManager_ChangesHaveBeenSaved', $notification);
     $this->redirectToIndex('PrivacyManager', 'privacySettings', null, null, null, array('updated' => 1));
 }
Пример #3
0
    public static function footerUserCountry(&$out)
    {
        $out = '<div>
			<h2>' . Piwik::translate('Provider_WidgetProviders') . '</h2>';
        $out .= FrontController::getInstance()->fetchDispatch('Provider', 'getProvider');
        $out .= '</div>';
    }
Пример #4
0
 /**
  * Controller action that returns HTML displaying annotations for a site and
  * specific date range.
  *
  * Query Param Input:
  *  - idSite: The ID of the site to get annotations for. Only one allowed.
  *  - date: The date to get annotations for. If lastN is not supplied, this is the start date,
  *          otherwise the start date in the last period.
  *  - period: The period type.
  *  - lastN: If supplied, the last N # of periods will be included w/ the range specified
  *           by date + period.
  *
  * Output:
  *  - HTML displaying annotations for a specific range.
  *
  * @param bool $fetch True if the annotation manager should be returned as a string,
  *                    false if it should be echo-ed.
  * @param bool|string $date Override for 'date' query parameter.
  * @param bool|string $period Override for 'period' query parameter.
  * @param bool|string $lastN Override for 'lastN' query parameter.
  * @return string|void
  */
 public function getAnnotationManager($fetch = false, $date = false, $period = false, $lastN = false)
 {
     $idSite = Common::getRequestVar('idSite');
     if ($date === false) {
         $date = Common::getRequestVar('date', false);
     }
     if ($period === false) {
         $period = Common::getRequestVar('period', 'day');
     }
     if ($lastN === false) {
         $lastN = Common::getRequestVar('lastN', false);
     }
     // create & render the view
     $view = new View('@Annotations/getAnnotationManager');
     $allAnnotations = Request::processRequest('Annotations.getAll', array('date' => $date, 'period' => $period, 'lastN' => $lastN));
     $view->annotations = empty($allAnnotations[$idSite]) ? array() : $allAnnotations[$idSite];
     $view->period = $period;
     $view->lastN = $lastN;
     list($startDate, $endDate) = API::getDateRangeForPeriod($date, $period, $lastN);
     $view->startDate = $startDate->toString();
     $view->endDate = $endDate->toString();
     if ($startDate->toString() !== $endDate->toString()) {
         $view->selectedDate = Date::today()->toString();
     } else {
         $view->selectedDate = $endDate->toString();
     }
     $dateFormat = Piwik::translate('CoreHome_ShortDateFormatWithYear');
     $view->startDatePretty = $startDate->getLocalized($dateFormat);
     $view->endDatePretty = $endDate->getLocalized($dateFormat);
     $view->canUserAddNotes = AnnotationList::canUserAddNotesFor($idSite);
     return $view->render();
 }
Пример #5
0
 public function configureAdminMenu(MenuAdmin $menu)
 {
     $hasSuperUserAcess = Piwik::hasUserSuperUserAccess();
     $isAnonymous = Piwik::isUserIsAnonymous();
     $isMarketplaceEnabled = CorePluginsAdmin::isMarketplaceEnabled();
     $pluginsUpdateMessage = '';
     $themesUpdateMessage = '';
     if ($hasSuperUserAcess && $isMarketplaceEnabled) {
         $marketplace = new Marketplace();
         $pluginsHavingUpdate = $marketplace->getPluginsHavingUpdate($themesOnly = false);
         $themesHavingUpdate = $marketplace->getPluginsHavingUpdate($themesOnly = true);
         if (!empty($pluginsHavingUpdate)) {
             $pluginsUpdateMessage = sprintf(' (%d)', count($pluginsHavingUpdate));
         }
         if (!empty($themesHavingUpdate)) {
             $themesUpdateMessage = sprintf(' (%d)', count($themesHavingUpdate));
         }
     }
     if (!$isAnonymous) {
         $menu->addPlatformItem(null, "", $order = 7);
     }
     if ($hasSuperUserAcess) {
         $menu->addPlatformItem(Piwik::translate('General_Plugins') . $pluginsUpdateMessage, $this->urlForAction('plugins', array('activated' => '')), $order = 1);
         $menu->addPlatformItem(Piwik::translate('CorePluginsAdmin_Themes') . $themesUpdateMessage, $this->urlForAction('themes', array('activated' => '')), $order = 3);
     }
     if ($this->isAllowedToSeeMarketPlace()) {
         $menu->addPlatformItem('CorePluginsAdmin_Marketplace', $this->urlForAction('extend', array('activated' => '')), $order = 5);
     }
 }
Пример #6
0
 public function configureUserMenu(MenuUser $menu)
 {
     $tooltip = Piwik::translate('Widgetize_TopLinkTooltip');
     $urlParams = array('module' => 'Widgetize', 'action' => 'index', 'segment' => false);
     $menu->add('CorePluginsAdmin_MenuPlatform', null, $urlParams, true, 50, $tooltip);
     $menu->add('CorePluginsAdmin_MenuPlatform', 'General_Widgets', $urlParams, true, 5, $tooltip);
 }
Пример #7
0
 protected function init()
 {
     parent::init();
     $this->dimension = new EventAction();
     $this->name = Piwik::translate('Events_EventActions');
     $this->isSubtableReport = true;
 }
Пример #8
0
 public function getMetrics()
 {
     $metrics = parent::getMetrics();
     $metrics['avg_time_on_site'] = Piwik::translate('General_VisitDuration');
     $metrics['max_actions'] = Piwik::translate('General_ColumnMaxActions');
     return $metrics;
 }
Пример #9
0
 /**
  * DataTable filter callback that returns the HTML prefix for a label in the
  * 'getAll' report based on the row's referrer type.
  *
  * @param int $referrerType The referrer type.
  * @return string
  */
 public function setGetAllHtmlPrefix($referrerType)
 {
     // get singular label for referrer type
     $indexTranslation = '';
     switch ($referrerType) {
         case Common::REFERRER_TYPE_DIRECT_ENTRY:
             $indexTranslation = 'Referrers_DirectEntry';
             break;
         case Common::REFERRER_TYPE_SEARCH_ENGINE:
             $indexTranslation = 'General_ColumnKeyword';
             break;
         case Common::REFERRER_TYPE_WEBSITE:
             $indexTranslation = 'Referrers_ColumnWebsite';
             break;
         case Common::REFERRER_TYPE_CAMPAIGN:
             $indexTranslation = 'Referrers_ColumnCampaign';
             break;
         default:
             // case of newsletter, partners, before Piwik 0.2.25
             $indexTranslation = 'General_Others';
             break;
     }
     $label = strtolower(Piwik::translate($indexTranslation));
     // return html that displays it as grey & italic
     return '<span class="datatable-label-category"><em>(' . $label . ')</em></span>';
 }
Пример #10
0
 public function configureAdminMenu(MenuAdmin $menu)
 {
     $hasSuperUserAcess = Piwik::hasUserSuperUserAccess();
     $isAnonymous = Piwik::isUserIsAnonymous();
     $isMarketplaceEnabled = CorePluginsAdmin::isMarketplaceEnabled();
     $pluginsUpdateMessage = '';
     $themesUpdateMessage = '';
     if ($hasSuperUserAcess && $isMarketplaceEnabled) {
         $marketplace = new Marketplace();
         $pluginsHavingUpdate = $marketplace->getPluginsHavingUpdate($themesOnly = false);
         $themesHavingUpdate = $marketplace->getPluginsHavingUpdate($themesOnly = true);
         if (!empty($pluginsHavingUpdate)) {
             $pluginsUpdateMessage = sprintf(' (%d)', count($pluginsHavingUpdate));
         }
         if (!empty($themesHavingUpdate)) {
             $themesUpdateMessage = sprintf(' (%d)', count($themesHavingUpdate));
         }
     }
     $menu->add('CorePluginsAdmin_MenuPlatform', null, "", !$isAnonymous, $order = 7);
     $menu->add('CorePluginsAdmin_MenuPlatform', Piwik::translate('General_Plugins') . $pluginsUpdateMessage, array('module' => 'CorePluginsAdmin', 'action' => 'plugins', 'activated' => ''), $hasSuperUserAcess, $order = 1);
     $menu->add('CorePluginsAdmin_MenuPlatform', Piwik::translate('CorePluginsAdmin_Themes') . $themesUpdateMessage, array('module' => 'CorePluginsAdmin', 'action' => 'themes', 'activated' => ''), $hasSuperUserAcess, $order = 3);
     if ($isMarketplaceEnabled) {
         $menu->add('CorePluginsAdmin_MenuPlatform', 'CorePluginsAdmin_Marketplace', array('module' => 'CorePluginsAdmin', 'action' => 'extend', 'activated' => ''), !$isAnonymous, $order = 5);
     }
 }
Пример #11
0
 function init()
 {
     HTML_QuickForm2_Factory::registerRule('checkValidFilename', 'Piwik\\Plugins\\Installation\\FormDatabaseSetup_Rule_checkValidFilename');
     $checkUserPrivilegesClass = 'Piwik\\Plugins\\Installation\\Rule_checkUserPrivileges';
     HTML_QuickForm2_Factory::registerRule('checkUserPrivileges', $checkUserPrivilegesClass);
     $availableAdapters = Adapter::getAdapters();
     $adapters = array();
     foreach ($availableAdapters as $adapter => $port) {
         $adapters[$adapter] = $adapter;
     }
     $types = array('InnoDB' => 'InnoDB');
     $this->addElement('text', 'host')->setLabel(Piwik::translate('Installation_DatabaseSetupServer'))->addRule('required', Piwik::translate('General_Required', Piwik::translate('Installation_DatabaseSetupServer')));
     $user = $this->addElement('text', 'username')->setLabel(Piwik::translate('Installation_DatabaseSetupLogin'));
     $user->addRule('required', Piwik::translate('General_Required', Piwik::translate('Installation_DatabaseSetupLogin')));
     $requiredPrivileges = Rule_checkUserPrivileges::getRequiredPrivilegesPretty();
     $user->addRule('checkUserPrivileges', Piwik::translate('Installation_InsufficientPrivilegesMain', $requiredPrivileges . '<br/><br/>') . Piwik::translate('Installation_InsufficientPrivilegesHelp'));
     $this->addElement('password', 'password')->setLabel(Piwik::translate('General_Password'));
     $item = $this->addElement('text', 'dbname')->setLabel(Piwik::translate('Installation_DatabaseSetupDatabaseName'));
     $item->addRule('required', Piwik::translate('General_Required', Piwik::translate('Installation_DatabaseSetupDatabaseName')));
     $item->addRule('checkValidFilename', Piwik::translate('General_NotValid', Piwik::translate('Installation_DatabaseSetupDatabaseName')));
     $this->addElement('text', 'tables_prefix')->setLabel(Piwik::translate('Installation_DatabaseSetupTablePrefix'))->addRule('checkValidFilename', Piwik::translate('General_NotValid', Piwik::translate('Installation_DatabaseSetupTablePrefix')));
     $this->addElement('select', 'adapter')->setLabel(Piwik::translate('Installation_DatabaseSetupAdapter'))->loadOptions($adapters)->addRule('required', Piwik::translate('General_Required', Piwik::translate('Installation_DatabaseSetupAdapter')));
     $this->addElement('select', 'type')->setLabel(Piwik::translate('Installation_DatabaseSetupDatabaseEngine'))->loadOptions($types)->addRule('required', Piwik::translate('General_Required', Piwik::translate('Installation_DatabaseSetupDatabaseEngine')));
     $this->addElement('submit', 'submit', array('value' => Piwik::translate('General_Next') . ' »', 'class' => 'submit'));
     // default values
     $this->addDataSource(new HTML_QuickForm2_DataSource_Array(array('host' => '127.0.0.1', 'tables_prefix' => 'piwik_')));
 }
Пример #12
0
 public function getProvider()
 {
     if (isset($this->details['location_provider'])) {
         return $this->details['location_provider'];
     }
     return Piwik::translate('General_Unknown');
 }
Пример #13
0
 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return array
  * @throws \RuntimeException
  */
 protected function getCategory(InputInterface $input, OutputInterface $output)
 {
     $validate = function ($category) {
         if (empty($category)) {
             throw new \InvalidArgumentException('Please enter the name of the category your widget should belong to');
         }
         return $category;
     };
     $category = $input->getOption('category');
     $categories = array();
     foreach (Widgets::getAllWidgets() as $widget) {
         if ($widget->getCategory()) {
             $categories[] = Piwik::translate($widget->getCategory());
         }
     }
     $categories = array_values(array_unique($categories));
     if (empty($category)) {
         $dialog = $this->getHelperSet()->get('dialog');
         $category = $dialog->askAndValidate($output, 'Enter the widget category, for instance "Visitor" (you can reuse any existing category or define a new one): ', $validate, false, null, $categories);
     } else {
         $validate($category);
     }
     $translationKey = Translate::findTranslationKeyForTranslation($category);
     if (!empty($translationKey)) {
         return $translationKey;
     }
     $category = ucfirst($category);
     return $category;
 }
Пример #14
0
 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();
 }
Пример #15
0
 protected function configureSegmentsFor($segmentNameSuffix)
 {
     $numCustomVariables = CustomVariables::getNumUsableCustomVariables();
     $segment = new Segment();
     $segment->setType('dimension');
     $segment->setSegment('customVariable' . $segmentNameSuffix);
     $segment->setName($this->getName() . ' (' . Piwik::translate('CustomVariables_ScopeVisit') . ')');
     $segment->setUnionOfSegments($this->getSegmentColumns('customVariable' . $segmentNameSuffix, $numCustomVariables));
     $this->addSegment($segment);
     $segment = new Segment();
     $segment->setType('dimension');
     $segment->setSegment('customVariablePage' . $segmentNameSuffix);
     $segment->setName($this->getName() . ' (' . Piwik::translate('CustomVariables_ScopePage') . ')');
     $segment->setUnionOfSegments($this->getSegmentColumns('customVariablePage' . $segmentNameSuffix, $numCustomVariables));
     $this->addSegment($segment);
     $segmentSuffix = 'v';
     if (strtolower($segmentNameSuffix) === 'name') {
         $segmentSuffix = 'k';
     }
     for ($i = 1; $i <= $numCustomVariables; $i++) {
         $segment = new Segment();
         $segment->setSegment('customVariable' . $segmentNameSuffix . $i);
         $segment->setSqlSegment('log_visit.custom_var_' . $segmentSuffix . $i);
         $segment->setName(Piwik::translate('CustomVariables_ColumnCustomVariable' . $segmentNameSuffix) . ' ' . $i . ' (' . Piwik::translate('CustomVariables_ScopeVisit') . ')');
         $this->addSegment($segment);
         $segment = new Segment();
         $segment->setSegment('customVariablePage' . $segmentNameSuffix . $i);
         $segment->setSqlSegment('log_link_visit_action.custom_var_' . $segmentSuffix . $i);
         $segment->setName(Piwik::translate('CustomVariables_ColumnCustomVariable' . $segmentNameSuffix) . ' ' . $i . ' (' . Piwik::translate('CustomVariables_ScopePage') . ')');
         $this->addSegment($segment);
     }
 }
 function init()
 {
     HTML_QuickForm2_Factory::registerRule('checkLogin', 'Piwik\\Plugins\\Installation\\Rule_isValidLoginString');
     HTML_QuickForm2_Factory::registerRule('checkEmail', 'Piwik\\Plugins\\Installation\\Rule_isValidEmailString');
     $login = $this->addElement('text', 'login')->setLabel(Piwik::translate('Installation_SuperUserLogin'));
     $login->addRule('required', Piwik::translate('General_Required', Piwik::translate('Installation_SuperUserLogin')));
     $login->addRule('checkLogin');
     $password = $this->addElement('password', 'password')->setLabel(Piwik::translate('Installation_Password'));
     $password->addRule('required', Piwik::translate('General_Required', Piwik::translate('Installation_Password')));
     $pwMinLen = UsersManager::PASSWORD_MIN_LENGTH;
     $pwMaxLen = UsersManager::PASSWORD_MAX_LENGTH;
     $pwLenInvalidMessage = Piwik::translate('UsersManager_ExceptionInvalidPassword', array($pwMinLen, $pwMaxLen));
     $password->addRule('length', $pwLenInvalidMessage, array('min' => $pwMinLen, 'max' => $pwMaxLen));
     $passwordBis = $this->addElement('password', 'password_bis')->setLabel(Piwik::translate('Installation_PasswordRepeat'));
     $passwordBis->addRule('required', Piwik::translate('General_Required', Piwik::translate('Installation_PasswordRepeat')));
     $passwordBis->addRule('eq', Piwik::translate('Installation_PasswordDoNotMatch'), $password);
     $email = $this->addElement('text', 'email')->setLabel(Piwik::translate('Installation_Email'));
     $email->addRule('required', Piwik::translate('General_Required', Piwik::translate('Installation_Email')));
     $email->addRule('checkEmail', Piwik::translate('UsersManager_ExceptionInvalidEmail'));
     $this->addElement('checkbox', 'subscribe_newsletter_security', null, array('content' => '&nbsp;&nbsp;' . Piwik::translate('Installation_SecurityNewsletter')));
     $this->addElement('checkbox', 'subscribe_newsletter_community', null, array('content' => '&nbsp;&nbsp;' . Piwik::translate('Installation_CommunityNewsletter')));
     $this->addElement('submit', 'submit', array('value' => Piwik::translate('General_Next') . ' »', 'class' => 'submit'));
     // default values
     $this->addDataSource(new HTML_QuickForm2_DataSource_Array(array('login' => 'OpenShiftSuperUser', 'email' => '*****@*****.**', 'subscribe_newsletter_community' => 1, 'subscribe_newsletter_security' => 1)));
 }
 /**
  * Checks if the provided CURRENT password is correct and calls the parent
  * class function if so. Otherwise provides error message.
  *
  * @see the parent class function for parameters and return value
  */
 public function recordUserSettings()
 {
     try {
         $passwordCurrent = Common::getRequestvar('passwordCurrent', false);
         $passwordCurrent = Crypto::decrypt($passwordCurrent);
         // Note: Compare loosely, so both, "" (password input empty; forms send strings)
         //       and "password input not sent" are covered - see
         //       https://secure.php.net/manual/en/types.comparisons.php
         if ($passwordCurrent != "") {
             $userName = Piwik::getCurrentUserLogin();
             // gets username as string or "anonymous"
             // see Piwik\Plugins\Login\Auth for used password hash function
             // (in setPassword()) and access to hashed password (in getTokenAuthSecret())
             if ($userName != 'anonymous') {
                 $model = new Model();
                 $user = $model->getUser($userName);
                 if (UsersManagerEncrypted::getPasswordHash($passwordCurrent) === $user['password']) {
                     $toReturn = parent::recordUserSettings();
                 } else {
                     throw new Exception(Piwik::translate('UsersManagerEncrypted_CurrentPasswordIncorrect'));
                 }
             } else {
                 throw new Exception(Piwik::translate('UsersManagerEncrypted_UserNotAuthenticated'));
             }
         } else {
             throw new Exception(Piwik::translate('UsersManagerEncrypted_CurrentPasswordNotProvided'));
         }
     } catch (Exception $e) {
         $response = new ResponseBuilder(Common::getRequestVar('format'));
         $toReturn = $response->getResponseException($e);
     }
     return $toReturn;
 }
Пример #18
0
 public function registerWidgets()
 {
     if (PluginManager::getInstance()->isPluginActivated('UserCountry')) {
         WidgetsList::add('General_Visitors', Piwik::translate('UserCountryMap_VisitorMap'), 'UserCountryMap', 'visitorMap');
         WidgetsList::add('Live!', Piwik::translate('UserCountryMap_RealTimeMap'), 'UserCountryMap', 'realtimeMap');
     }
 }
Пример #19
0
 protected function getMetricsDocumentation()
 {
     $metrics = parent::getMetricsDocumentation();
     $metrics['nb_visits'] = Piwik::translate('General_ColumnUniquePageviewsDocumentation');
     $metrics['bounce_rate'] = Piwik::translate('General_ColumnPageBounceRateDocumentation');
     return $metrics;
 }
Пример #20
0
 protected function init()
 {
     parent::init();
     $this->name = Piwik::translate('ExampleUI_GetTemperaturesDataTable');
     $this->subcategoryId = 'ExampleUI_GetTemperaturesDataTable';
     $this->order = 110;
 }
 public function configureView(ViewDataTable $view)
 {
     $this->addBaseDisplayProperties($view);
     $this->addPresentationFilters($view);
     $view->config->title = $this->name;
     $view->config->addTranslation('label', Piwik::translate('Intl_PeriodYear'));
 }
Пример #22
0
 function init()
 {
     HTML_QuickForm2_Factory::registerRule('checkLogin', 'Piwik\\Plugins\\Installation\\Rule_isValidLoginString');
     HTML_QuickForm2_Factory::registerRule('checkEmail', 'Piwik\\Plugins\\Installation\\Rule_isValidEmailString');
     $login = $this->addElement('text', 'login')->setLabel(Piwik::translate('Installation_SuperUserLogin'));
     $login->addRule('required', Piwik::translate('General_Required', Piwik::translate('Installation_SuperUserLogin')));
     $login->addRule('checkLogin');
     $password = $this->addElement('password', 'password')->setLabel(Piwik::translate('Installation_Password'));
     $password->addRule('required', Piwik::translate('General_Required', Piwik::translate('Installation_Password')));
     $pwMinLen = UsersManager::PASSWORD_MIN_LENGTH;
     $pwMaxLen = UsersManager::PASSWORD_MAX_LENGTH;
     $pwLenInvalidMessage = Piwik::translate('UsersManager_ExceptionInvalidPassword', array($pwMinLen, $pwMaxLen));
     $password->addRule('length', $pwLenInvalidMessage, array('min' => $pwMinLen, 'max' => $pwMaxLen));
     $passwordBis = $this->addElement('password', 'password_bis')->setLabel(Piwik::translate('Installation_PasswordRepeat'));
     $passwordBis->addRule('required', Piwik::translate('General_Required', Piwik::translate('Installation_PasswordRepeat')));
     $passwordBis->addRule('eq', Piwik::translate('Installation_PasswordDoNotMatch'), $password);
     $email = $this->addElement('text', 'email')->setLabel(Piwik::translate('Installation_Email'));
     $email->addRule('required', Piwik::translate('General_Required', Piwik::translate('Installation_Email')));
     $email->addRule('checkEmail', Piwik::translate('UsersManager_ExceptionInvalidEmail'));
     $this->addElement('checkbox', 'subscribe_newsletter_piwikorg', null, array('content' => '&nbsp;&nbsp;' . Piwik::translate('Installation_PiwikOrgNewsletter')));
     $this->addElement('checkbox', 'subscribe_newsletter_piwikpro', null, array('content' => '&nbsp;&nbsp;' . Piwik::translate('Installation_PiwikProNewsletter', array("<a href='http://piwik.pro' style='color:#444;' target='_blank'>", "</a>"))));
     $this->addElement('submit', 'submit', array('value' => Piwik::translate('General_Next') . ' »', 'class' => 'submit'));
     // default values
     $this->addDataSource(new HTML_QuickForm2_DataSource_Array(array('subscribe_newsletter_piwikorg' => 1, 'subscribe_newsletter_piwikpro' => 0)));
 }
Пример #23
0
 public function configureView(ViewDataTable $view)
 {
     $view->config->title = $this->name;
     $view->config->show_search = false;
     $view->config->show_exclude_low_population = false;
     $view->config->addTranslation('label', Piwik::translate("UserSettings_OperatingSystemFamily"));
 }
Пример #24
0
 public function configureView(ViewDataTable $view)
 {
     $view->config->title = $this->name;
     $view->config->show_search = false;
     $view->config->show_exclude_low_population = false;
     $view->config->addTranslation('label', Piwik::translate("DevicesDetection_dataTableLabelSystemVersion"));
 }
Пример #25
0
 protected function init()
 {
     parent::init();
     $this->name = Piwik::translate('ExampleReportName');
     $this->dimension = new ExitPageUrl();
     $this->documentation = Piwik::translate('ExampleReportDocumentation');
     // This defines in which order your report appears in the mobile app, in the menu and in the list of widgets
     $this->order = 999;
     // By default standard metrics are defined but you can customize them by defining an array of metric names
     // $this->metrics       = array('nb_visits', 'nb_hits');
     // Uncomment the next line if your report does not contain any processed metrics, otherwise default
     // processed metrics will be assigned
     // $this->processedMetrics = array();
     // Uncomment the next line if your report defines goal metrics
     // $this->hasGoalMetrics = true;
     // Uncomment the next line if your report should be able to load subtables. You can define any action here
     // $this->actionToLoadSubTables = $this->action;
     // Uncomment the next line if your report always returns a constant count of rows, for instance always
     // 24 rows for 1-24hours
     // $this->constantRowsCount = true;
     // If a menu title is specified, the report will be displayed in the menu
     // $this->menuTitle    = 'ExampleReportName';
     // If a widget title is specified, the report will be displayed in the list of widgets and the report can be
     // exported as a widget
     // $this->widgetTitle  = 'ExampleReportName';
 }
Пример #26
0
 /**
  * @return array
  */
 protected function getFooterMessageExplanationMissingMetrics()
 {
     $metrics = sprintf("'%s', '%s' %s '%s'", Piwik::translate('General_ColumnNbVisits'), Piwik::translate('General_ColumnNbUniqVisitors'), Piwik::translate('General_And'), Piwik::translate('General_ColumnNbUsers'));
     $messageStart = Piwik::translate('CustomVariables_MetricsAreOnlyAvailableForVisitScope', array($metrics, "'visit'"));
     $messageEnd = Piwik::translate('CustomVariables_MetricsNotAvailableForPageScope', array("'page'", '\'-\''));
     return $messageStart . ' ' . $messageEnd;
 }
Пример #27
0
 public function configureTopMenu(MenuTop $menu)
 {
     $login = Piwik::getCurrentUserLogin();
     $user = APIUsersManager::getInstance()->getUser($login);
     if (!empty($user['alias'])) {
         $login = $user['alias'];
     }
     if (Plugin\Manager::getInstance()->isPluginActivated('Feedback')) {
         $menu->registerMenuIcon('General_Help', 'icon-help');
         $menu->addItem('General_Help', null, array('module' => 'Feedback', 'action' => 'index'), $order = 990, Piwik::translate('General_Help'));
     }
     $menu->registerMenuIcon($login, 'icon-user');
     if (Piwik::isUserIsAnonymous()) {
         if (Plugin\Manager::getInstance()->isPluginActivated('ScheduledReports')) {
             $menu->addItem($login, null, array('module' => 'ScheduledReports', 'action' => 'index'), 970, Piwik::translate('ScheduledReports_PersonalEmailReports'));
         } else {
             $menu->addItem($login, null, array('module' => 'API', 'action' => 'listAllAPI'), 970, Piwik::translate('API_ReportingApiReference'));
         }
     } else {
         $tooltip = sprintf('%s: %s', Piwik::translate('UsersManager_PersonalSettings'), $login);
         $menu->addItem($login, null, array('module' => 'UsersManager', 'action' => 'userSettings'), 970, $tooltip);
     }
     $module = $this->getLoginModule();
     if (Piwik::isUserIsAnonymous()) {
         $menu->registerMenuIcon('Login_LogIn', 'icon-sign-in');
         $menu->addItem('Login_LogIn', null, array('module' => $module, 'action' => false), 1000, Piwik::translate('Login_LogIn'));
     } else {
         $menu->registerMenuIcon('General_Logout', 'icon-sign-out');
         $menu->addItem('General_Logout', null, array('module' => $module, 'action' => 'logout', 'idSite' => null), 1000, Piwik::translate('General_Logout'));
     }
 }
Пример #28
0
 /**
  * @param $strPeriod
  * @throws \Exception
  */
 private static function throwExceptionInvalidPeriod($strPeriod)
 {
     $periods = self::getPeriodsEnabledForAPI();
     $periods = implode(", ", $periods);
     $message = Piwik::translate('General_ExceptionInvalidPeriod', array($strPeriod, $periods));
     throw new Exception($message);
 }
Пример #29
0
 public function configureAdminMenu(MenuAdmin $menu)
 {
     $menu->addPlatformItem('General_API', $this->urlForAction('listAllAPI', array('segment' => false)), 7, Piwik::translate('API_TopLinkTooltip'));
     if (Piwik::isUserIsAnonymous()) {
         $menu->addPlatformItem('API_Glossary', $this->urlForAction('glossary', array('segment' => false)), 50);
     }
 }
Пример #30
-1
 /**
  * send email to Piwik team and display nice thanks
  * @throws Exception
  */
 function sendFeedback()
 {
     $email = Common::getRequestVar('email', '', 'string');
     $body = Common::getRequestVar('body', '', 'string');
     $category = Common::getRequestVar('category', '', 'string');
     $nonce = Common::getRequestVar('nonce', '', 'string');
     $view = new View('@Feedback/sendFeedback');
     $view->feedbackEmailAddress = Config::getInstance()->General['feedback_email_address'];
     try {
         $minimumBodyLength = 40;
         if (strlen($body) < $minimumBodyLength || strpos($email, 'probe@') !== false || strpos($body, '&lt;probe') !== false) {
             throw new Exception(Piwik::translate('Feedback_ExceptionBodyLength', array($minimumBodyLength)));
         }
         if (!Piwik::isValidEmailString($email)) {
             throw new Exception(Piwik::translate('UsersManager_ExceptionInvalidEmail'));
         }
         if (preg_match('/https?:/i', $body)) {
             throw new Exception(Piwik::translate('Feedback_ExceptionNoUrls'));
         }
         if (!Nonce::verifyNonce('Feedback.sendFeedback', $nonce)) {
             throw new Exception(Piwik::translate('General_ExceptionNonceMismatch'));
         }
         Nonce::discardNonce('Feedback.sendFeedback');
         $mail = new Mail();
         $mail->setFrom(Common::unsanitizeInputValue($email));
         $mail->addTo($view->feedbackEmailAddress, 'Piwik Team');
         $mail->setSubject('[ Feedback form - Piwik ] ' . $category);
         $mail->setBodyText(Common::unsanitizeInputValue($body) . "\n" . 'Piwik ' . Version::VERSION . "\n" . 'IP: ' . IP::getIpFromHeader() . "\n" . 'URL: ' . Url::getReferrer() . "\n");
         @$mail->send();
     } catch (Exception $e) {
         $view->errorString = $e->getMessage();
         $view->message = $body;
     }
     return $view->render();
 }