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); }
public function configureUserMenu(MenuUser $menu) { $menu->addPlatformItem('General_API', $this->urlForAction('listAllAPI', array('segment' => false)), 6, Piwik::translate('API_TopLinkTooltip')); if (Piwik::isUserIsAnonymous()) { $menu->addPlatformItem('API_Glossary', $this->urlForAction('glossary', array('segment' => false)), 50); } }
public function configureUserMenu(MenuUser $menu) { $tooltip = Piwik::translate('Widgetize_TopLinkTooltip'); $urlParams = $this->urlForAction('index', array('segment' => false)); $menu->addPlatformItem(null, $urlParams, 50, $tooltip); $menu->addPlatformItem('General_Widgets', $urlParams, 5, $tooltip); }
public function configureUserMenu(MenuUser $menu) { $userPreferences = new UserPreferences(); $idSite = $this->getIdSite($userPreferences->getDefaultWebsiteId()); if (Piwik::isUserHasAdminAccess($idSite)) { $menu->addManageItem('Goals_Goals', $this->urlForAction('manage', array('idSite' => $idSite)), 1); } }
public function configureUserMenu(MenuUser $menu) { $userPreferences = new UserPreferences(); $default = $userPreferences->getDefaultWebsiteId(); $idSite = Common::getRequestVar('idSite', $default, 'int'); if (Piwik::isUserHasAdminAccess($idSite)) { $menu->addManageItem('Custom Variables', $this->urlForAction('manage'), $orderId = 15); } }
public function configureUserMenu(MenuUser $menu) { if (!Piwik::isUserIsAnonymous()) { $menu->addManageItem('CoreAdminHome_TrackingCode', $this->urlForAction('trackingCodeGenerator'), $order = 10); if (SettingsManager::hasUserPluginsSettingsForCurrentUser()) { $menu->addPersonalItem('CoreAdminHome_PluginSettings', $this->urlForAction('userPluginSettings'), $order = 15); } } }
public function configureUserMenu(MenuUser $menu) { $menu->registerMenuIcon('UsersManager_MenuPersonal', 'icon-user-personal'); $menu->registerMenuIcon('CoreAdminHome_MenuManage', 'icon-user-manage'); $menu->registerMenuIcon('CorePluginsAdmin_MenuPlatform', 'icon-user-platform'); if (Development::isEnabled() && Piwik::isUserHasSomeAdminAccess()) { $menu->addPlatformItem('UI Demo', $this->urlForAction('demo'), $order = 15); } }
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(); }
public function configureUserMenu(MenuUser $menu) { if (!Piwik::isUserIsAnonymous()) { $menu->addPersonalItem('MobileMessaging_SettingsMenu', $this->urlForAction('userSettings'), $order = 12); } }
/** * Assigns view properties that would be useful to views that render admin pages. * * Assigns the following variables: * * - **statisticsNotRecorded** - Set to true if the `[Tracker] record_statistics` INI * config is `0`. If not `0`, this variable will not be defined. * - **topMenu** - The result of `MenuTop::getInstance()->getMenu()`. * - **enableFrames** - The value of the `[General] enable_framed_pages` INI config option. If * true, {@link Piwik\View::setXFrameOptions()} is called on the view. * - **isSuperUser** - Whether the current user is a superuser or not. * - **usingOldGeoIPPlugin** - Whether this Piwik install is currently using the old GeoIP * plugin or not. * - **invalidPluginsWarning** - Set if some of the plugins to load (determined by INI configuration) * are invalid or missing. * - **phpVersion** - The current PHP version. * - **phpIsNewEnough** - Whether the current PHP version is new enough to run Piwik. * - **adminMenu** - The result of `MenuAdmin::getInstance()->getMenu()`. * * @param View $view * @api */ public static function setBasicVariablesAdminView(View $view) { self::notifyWhenTrackingStatisticsDisabled(); self::notifyIfEAcceleratorIsUsed(); $view->topMenu = MenuTop::getInstance()->getMenu(); $view->userMenu = MenuUser::getInstance()->getMenu(); $view->isDataPurgeSettingsEnabled = self::isDataPurgeSettingsEnabled(); $enableFrames = PiwikConfig::getInstance()->General['enable_framed_settings']; $view->enableFrames = $enableFrames; if (!$enableFrames) { $view->setXFrameOptions('sameorigin'); } $view->isSuperUser = Piwik::hasUserSuperUserAccess(); self::notifyAnyInvalidPlugin(); self::checkPhpVersion($view); self::notifyWhenPhpVersionIsEOL(); self::notifyWhenDebugOnDemandIsEnabled('debug'); self::notifyWhenDebugOnDemandIsEnabled('debug_on_demand'); $adminMenu = MenuAdmin::getInstance()->getMenu(); $view->adminMenu = $adminMenu; $notifications = $view->notifications; if (empty($notifications)) { $view->notifications = NotificationManager::getAllNotificationsToDisplay(); NotificationManager::cancelAllNonPersistent(); } }
public function configureUserMenu(MenuUser $menu) { $tooltip = Piwik::translate(\Piwik\Plugin\Manager::getInstance()->isPluginActivated('MobileMessaging') ? 'MobileMessaging_TopLinkTooltip' : 'ScheduledReports_TopLinkTooltip'); $menu->add('CoreAdminHome_MenuManage', null, array('module' => '', 'action' => '', 'segment' => false), true, 10); $menu->add('CoreAdminHome_MenuManage', $this->getTopMenuTranslationKey(), array('module' => 'ScheduledReports', 'action' => 'index', 'segment' => false), true, 13, $tooltip); }
public function configureUserMenu(MenuUser $menu) { $tooltip = Piwik::translate(\Piwik\Plugin\Manager::getInstance()->isPluginActivated('MobileMessaging') ? 'MobileMessaging_TopLinkTooltip' : 'ScheduledReports_TopLinkTooltip'); $menu->addManageItem(null, $this->urlForDefaultAction(array('segment' => false)), 10); $menu->addManageItem($this->getTopMenuTranslationKey(), $this->urlForAction('index', array('segment' => false)), 13, $tooltip); }
public function configureUserMenu(MenuUser $menu) { if (Development::isEnabled() && Piwik::isUserHasSomeAdminAccess()) { $menu->addPlatformItem('UI Demo', $this->urlForAction('demo'), $order = 15); } }
public function configureUserMenu(MenuUser $menu) { $menu->addPlatformItem('General_Help', $this->urlForAction('index', array('segment' => false)), $order = 99, $tooltip = Piwik::translate('Feedback_TopLinkTooltip')); }
public function configureUserMenu(MenuUser $menu) { if ($this->isAllowedToSeeMarketPlace()) { $menu->addPlatformItem('CorePluginsAdmin_Marketplace', array('module' => 'CorePluginsAdmin', 'action' => 'browsePlugins', 'activated' => ''), $order = 5); } }
public function configureUserMenu(MenuUser $menu) { $urlParams = array('module' => 'ExampleUI', 'action' => 'notifications'); $menu->add('CorePluginsAdmin_MenuPlatform', 'UI Notifications', $urlParams, $displayedForCurrentUser = true, $order = 3); }
public function configureUserMenu(MenuUser $menu) { if (!Piwik::isUserIsAnonymous()) { $menu->addPersonalItem('GoogleAuthenticator_Menu', $this->urlForAction('settings'), $order = 9); } }
/** * Assigns view properties that would be useful to views that render admin pages. * * Assigns the following variables: * * - **statisticsNotRecorded** - Set to true if the `[Tracker] record_statistics` INI * config is `0`. If not `0`, this variable will not be defined. * - **topMenu** - The result of `MenuTop::getInstance()->getMenu()`. * - **currentAdminMenuName** - The currently selected admin menu name. * - **enableFrames** - The value of the `[General] enable_framed_pages` INI config option. If * true, {@link Piwik\View::setXFrameOptions()} is called on the view. * - **isSuperUser** - Whether the current user is a superuser or not. * - **usingOldGeoIPPlugin** - Whether this Piwik install is currently using the old GeoIP * plugin or not. * - **invalidPluginsWarning** - Set if some of the plugins to load (determined by INI configuration) * are invalid or missing. * - **phpVersion** - The current PHP version. * - **phpIsNewEnough** - Whether the current PHP version is new enough to run Piwik. * - **adminMenu** - The result of `MenuAdmin::getInstance()->getMenu()`. * * @param View $view * @api */ public static function setBasicVariablesAdminView(View $view) { self::notifyWhenTrackingStatisticsDisabled(); self::notifyIfEAcceleratorIsUsed(); $view->topMenu = MenuTop::getInstance()->getMenu(); $view->userMenu = MenuUser::getInstance()->getMenu(); $view->currentAdminMenuName = MenuAdmin::getInstance()->getCurrentAdminMenuName(); $view->isDataPurgeSettingsEnabled = self::isDataPurgeSettingsEnabled(); $view->enableFrames = PiwikConfig::getInstance()->General['enable_framed_settings']; if (!$view->enableFrames) { $view->setXFrameOptions('sameorigin'); } $view->isSuperUser = Piwik::hasUserSuperUserAccess(); self::notifyAnyInvalidPlugin(); self::checkPhpVersion($view); if (Piwik::hasUserSuperUserAccess() && self::isPhpVersion53()) { $notification = new Notification(Piwik::translate('General_WarningPhpVersionXIsTooOld', '5.3')); $notification->title = Piwik::translate('General_Warning'); $notification->priority = Notification::PRIORITY_LOW; $notification->context = Notification::CONTEXT_WARNING; $notification->type = Notification::TYPE_TRANSIENT; $notification->flags = Notification::FLAG_NO_CLEAR; NotificationManager::notify('PHP53VersionCheck', $notification); } $adminMenu = MenuAdmin::getInstance()->getMenu(); $view->adminMenu = $adminMenu; $notifications = $view->notifications; if (empty($notifications)) { $view->notifications = NotificationManager::getAllNotificationsToDisplay(); NotificationManager::cancelAllNonPersistent(); } }
/** * 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()); } }
public function configureUserMenu(MenuUser $menu) { if (!Piwik::isUserIsAnonymous()) { $menu->addPersonalItem('CustomAlerts_Alerts', $this->urlForAction('index'), $order = 9); } }
public function configureUserMenu(MenuUser $menu) { $menu->addPlatformItem('UI Notifications', $this->urlForAction('notifications'), $order = 10); }
public function configureUserMenu(MenuUser $menu) { if (!Piwik::isUserIsAnonymous()) { $menu->addItem('', 'General_Settings', $this->urlForAction('userSettings'), 0); } }
public function configureUserMenu(MenuUser $menu) { $menu->add('General_Help', null, array('module' => 'Feedback', 'action' => 'index', 'segment' => false), true, $order = 99, $tooltip = Piwik::translate('Feedback_TopLinkTooltip')); }
public function configureUserMenu(MenuUser $menu) { if ($this->isAllowedToSeeMarketPlace()) { $menu->addPlatformItem('CorePluginsAdmin_Marketplace', $this->urlForAction('userBrowsePlugins', array('activated' => '')), $order = 5); } }
public function configureUserMenu(MenuUser $menu) { $apiUrlParams = $this->urlForAction('listAllAPI', array('segment' => false)); $tooltip = Piwik::translate('API_TopLinkTooltip'); $menu->addPlatformItem('General_API', $apiUrlParams, 6, $tooltip); }
public function configureUserMenu(MenuUser $menu) { $urlParams = array('module' => 'ExampleUI', 'action' => 'notifications'); $menu->addPlatformItem('UI Notifications', $urlParams, $order = 3); }
public function configureUserMenu(MenuUser $menu) { $menu->addPersonalItem(null, array(), 1, false); $menu->addManageItem(null, array(), 2, false); $menu->addPlatformItem(null, array(), 3, false); }
public function configureUserMenu(MenuUser $menu) { $apiUrlParams = array('module' => 'API', 'action' => 'listAllAPI', 'segment' => false); $tooltip = Piwik::translate('API_TopLinkTooltip'); $menu->addPlatformItem('General_API', $apiUrlParams, 6, $tooltip); }
/** * Renders and echo's an admin page that lets users generate custom JavaScript * tracking code and custom image tracker links. */ public function trackingCodeGenerator() { $view = new View('@CoreAdminHome/trackingCodeGenerator'); $this->setBasicVariablesView($view); $view->topMenu = MenuTop::getInstance()->getMenu(); $view->userMenu = MenuUser::getInstance()->getMenu(); $viewableIdSites = APISitesManager::getInstance()->getSitesIdWithAtLeastViewAccess(); $defaultIdSite = reset($viewableIdSites); $view->idSite = Common::getRequestVar('idSite', $defaultIdSite, 'int'); $view->defaultReportSiteName = Site::getNameFor($view->idSite); $view->defaultSiteRevenue = \Piwik\MetricsFormatter::getCurrencySymbol($view->idSite); $view->maxCustomVariables = CustomVariables::getMaxCustomVariables(); $allUrls = APISitesManager::getInstance()->getSiteUrlsFromId($view->idSite); if (isset($allUrls[1])) { $aliasUrl = $allUrls[1]; } else { $aliasUrl = 'x.domain.com'; } $view->defaultReportSiteAlias = $aliasUrl; $mainUrl = Site::getMainUrlFor($view->idSite); $view->defaultReportSiteDomain = @parse_url($mainUrl, PHP_URL_HOST); // get currencies for each viewable site $view->currencySymbols = APISitesManager::getInstance()->getCurrencySymbols(); $view->serverSideDoNotTrackEnabled = \Piwik\Plugins\PrivacyManager\DoNotTrackHeaderChecker::isActive(); 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'); $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->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->userMenu = MenuUser::getInstance()->getMenu(); $notifications = $view->notifications; if (empty($notifications)) { $view->notifications = NotificationManager::getAllNotificationsToDisplay(); NotificationManager::cancelAllNonPersistent(); } }