/** * Override the index of the dashboard's settings controller in the to render new statistics. * * @param SettingsController $sender Instance of the dashboard's settings controller. */ public function settingsController_home_create($sender) { $statsUrl = $this->AnalyticsServer; if (!stringBeginsWith($statsUrl, 'http:') && !stringBeginsWith($statsUrl, 'https:')) { $statsUrl = Gdn::request()->scheme() . "://{$statsUrl}"; } Gdn_Theme::section('DashboardHome'); $sender->setData('IsWidePage', true); // Tell the page where to find the Vanilla Analytics provider $sender->addDefinition('VanillaStatsUrl', $statsUrl); $sender->setData('VanillaStatsUrl', $statsUrl); // Load javascript & css, check permissions, and load side menu for this page. $sender->addJsFile('settings.js'); $sender->title(t('Dashboard')); $sender->RequiredAdminPermissions = ['Garden.Settings.View', 'Garden.Settings.Manage', 'Garden.Community.Manage']; $sender->fireEvent('DefineAdminPermissions'); $sender->permission($sender->RequiredAdminPermissions, '', false); $sender->setHighlightRoute('dashboard/settings'); if (!Gdn_Statistics::checkIsEnabled() && Gdn_Statistics::checkIsLocalhost()) { $sender->render('dashboardlocalhost', '', 'plugins/VanillaStats'); } else { $sender->addCssFile('picker.css', 'plugins/VanillaStats'); $sender->addCssFile('vendors/c3.min.css', 'plugins/VanillaStats'); $sender->addJsFile('vanillastats.js', 'plugins/VanillaStats'); $sender->addJsFile('picker.js', 'plugins/VanillaStats'); $sender->addJsFile('d3.min.js'); $sender->addJsFile('c3.min.js'); $sender->addDefinition('VanillaID', Gdn::installationID()); $sender->addDefinition('AuthToken', Gdn_Statistics::generateToken()); $sender->addDefinition('ExpandText', t('more')); $sender->addDefinition('CollapseText', t('less')); // Render the custom dashboard view $sender->render('dashboard', '', 'plugins/VanillaStats'); } }
/** * Override the default index method of the settings controller in the * dashboard application to render new statistics. */ public function statsDashboard($Sender) { $StatsUrl = $this->AnalyticsServer; if (!stringBeginsWith($StatsUrl, 'http:') && !stringBeginsWith($StatsUrl, 'https:')) { $StatsUrl = Gdn::request()->scheme() . "://{$StatsUrl}"; } // Tell the page where to find the Vanilla Analytics provider $Sender->addDefinition('VanillaStatsUrl', $StatsUrl); $Sender->setData('VanillaStatsUrl', $StatsUrl); // Load javascript & css, check permissions, and load side menu for this page. $Sender->addJsFile('settings.js'); $Sender->title(t('Dashboard')); $Sender->RequiredAdminPermissions[] = 'Garden.Settings.View'; $Sender->RequiredAdminPermissions[] = 'Garden.Settings.Manage'; $Sender->RequiredAdminPermissions[] = 'Garden.Community.Manage'; $Sender->RequiredAdminPermissions[] = 'Garden.Users.Add'; $Sender->RequiredAdminPermissions[] = 'Garden.Users.Edit'; $Sender->RequiredAdminPermissions[] = 'Garden.Users.Delete'; $Sender->RequiredAdminPermissions[] = 'Garden.Users.Approve'; $Sender->fireEvent('DefineAdminPermissions'); $Sender->permission($Sender->RequiredAdminPermissions, '', false); $Sender->addSideMenu('dashboard/settings'); if (!Gdn_Statistics::checkIsEnabled() && Gdn_Statistics::checkIsLocalhost()) { $Sender->render('dashboardlocalhost', '', 'plugins/VanillaStats'); } else { $Sender->addJsFile('vanillastats.js', 'plugins/VanillaStats'); $Sender->addJsFile('picker.js', 'plugins/VanillaStats'); $Sender->addCSSFile('picker.css', 'plugins/VanillaStats'); $this->configureRange($Sender); $VanillaID = Gdn::installationID(); $Sender->setData('VanillaID', $VanillaID); $Sender->setData('VanillaVersion', APPLICATION_VERSION); $Sender->setData('SecurityToken', $this->securityToken()); // Render the custom dashboard view $Sender->render('dashboard', '', 'plugins/VanillaStats'); } }
<div class="StatsDisabled"> <div class="alert alert-warning padded"><?php echo t("Vanilla Statistics are currently disabled"); ?> </div> <?php if (!c('Garden.Analytics.Enabled', true)) { echo $this->Form->Hidden('Allow', array('value' => 1)); echo "<p>" . t("Garden.StatisticsDisabled", "You have specifically disabled Vanilla Statistics in your configuration file.") . "</p>"; echo $this->Form->button("Enable", array('class' => 'Button SliceSubmit')); } else { if (Gdn_Statistics::checkIsLocalhost() && !c('Garden.Analytics.AllowLocal', false)) { echo $this->Form->Hidden('AllowLocal', array('value' => 1)); echo "<p>" . t("Garden.StatisticsLocal.Explain", "This forum appears to be running in a test environment, or is otherwise reporting a private IP. By default, forums running on private IPs are not tracked.") . "</p>"; echo "<p>" . t("Garden.StatisticsLocal.Resolve", "If you're sure your forum is accessible from the internet you can force it to report statistics here:") . "</p>"; echo $this->Form->button("Enable", array('class' => 'Button SliceSubmit')); } else { if (!$this->data('ConfWritable')) { echo "<p>" . t("Garden.StatisticsReadonly.Explain", "Your config.php file appears to be read-only. This means that Vanilla will be unable to automatically register your forum's InstallationID and InstallationSecret.") . "</p>"; echo "<p>" . t("Garden.StatisticsReadonly.Resolve", "To solve this problem, assign file mode 777 to your conf/config.php file.") . "</p>"; } } } ?> </div>