本文整理汇总了PHP中Piwik\ArchiveProcessor\Rules::setBrowserTriggerArchiving方法的典型用法代码示例。如果您正苦于以下问题:PHP Rules::setBrowserTriggerArchiving方法的具体用法?PHP Rules::setBrowserTriggerArchiving怎么用?PHP Rules::setBrowserTriggerArchiving使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik\ArchiveProcessor\Rules
的用法示例。
在下文中一共展示了Rules::setBrowserTriggerArchiving方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_purgeOutdatedArchives_Purges_WhenBrowserArchivingEnabled_AndCronArchiveTriggerPresent
public function test_purgeOutdatedArchives_Purges_WhenBrowserArchivingEnabled_AndCronArchiveTriggerPresent()
{
Rules::setBrowserTriggerArchiving(false);
$_GET['trigger'] = 'archivephp';
$wasPurged = $this->tasks->purgeOutdatedArchives();
$this->assertTrue($wasPurged);
}
示例2: setArchiveSettings
/**
* @internal
*/
public function setArchiveSettings($enableBrowserTriggerArchiving, $todayArchiveTimeToLive)
{
Piwik::checkUserHasSuperUserAccess();
if (!Controller::isGeneralSettingsAdminEnabled()) {
throw new Exception('General settings admin is ont enabled');
}
Rules::setBrowserTriggerArchiving((bool) $enableBrowserTriggerArchiving);
Rules::setTodayArchiveTimeToLive($todayArchiveTimeToLive);
return true;
}
示例3: setUp
public function setUp()
{
// drop all tables
Db::dropAllTables();
// download data dump if url supplied
if (is_file($this->dumpUrl)) {
$dumpPath = $this->dumpUrl;
} else {
$dumpPath = PIWIK_INCLUDE_PATH . '/tmp/logdump.sql.gz';
$bufferSize = 1024 * 1024;
$dump = fopen($this->dumpUrl, 'rb');
$outfile = fopen($dumpPath, 'wb');
$bytesRead = 0;
while (!feof($dump)) {
fwrite($outfile, fread($dump, $bufferSize), $bufferSize);
$bytesRead += $bufferSize;
}
fclose($dump);
fclose($outfile);
if ($bytesRead <= 40 * 1024 * 1024) {
// sanity check
throw new Exception("Could not download sql dump!");
}
}
// unzip the dump
if (substr($dumpPath, -3) === ".gz") {
$deflatedDumpPath = PIWIK_INCLUDE_PATH . '/tmp/logdump.sql';
// TODO: should depend on name of URL
exec("gunzip -c \"" . $dumpPath . "\" > \"{$deflatedDumpPath}\"", $output, $return);
if ($return !== 0) {
throw new Exception("gunzip failed: " . implode("\n", $output));
}
} else {
$deflatedDumpPath = $dumpPath;
}
// load the data into the correct database
$user = Config::getInstance()->database['username'];
$password = Config::getInstance()->database['password'];
Config::getInstance()->database['tables_prefix'] = $this->tablesPrefix;
$cmd = "mysql -u \"{$user}\" \"--password={$password}\" {$this->dbName} < \"" . $deflatedDumpPath . "\" 2>&1";
exec($cmd, $output, $return);
if ($return !== 0) {
throw new Exception("Failed to load sql dump: " . implode("\n", $output));
}
// make sure archiving will be called
Rules::setBrowserTriggerArchiving(true);
// reload access
Piwik::setUserHasSuperUserAccess();
$this->getTestEnvironment()->configOverride = array('database' => array('tables_prefix' => $this->tablesPrefix));
$this->getTestEnvironment()->save();
}
示例4: setUp
public function setUp()
{
// drop all tables
Db::dropAllTables();
// download data dump if url supplied
if (is_file($this->dumpUrl)) {
$dumpPath = $this->dumpUrl;
} else {
$dumpPath = PIWIK_INCLUDE_PATH . '/tmp/logdump.sql.gz';
$bytesRead = $this->downloadDumpInPath($dumpPath);
// sanity check
if ($bytesRead <= 40 * 1024 * 1024) {
$str = "Could not download sql dump! You can manually download %s into %s";
throw new Exception(sprintf($str, $this->dumpUrl, $dumpPath));
}
}
// unzip the dump
if (substr($dumpPath, -3) === ".gz") {
$deflatedDumpPath = PIWIK_INCLUDE_PATH . '/tmp/logdump.sql';
// TODO: should depend on name of URL
exec("gunzip -c \"" . $dumpPath . "\" > \"{$deflatedDumpPath}\"", $output, $return);
if ($return !== 0) {
throw new Exception("gunzip failed: " . implode("\n", $output));
}
} else {
$deflatedDumpPath = $dumpPath;
}
// load the data into the correct database
$user = Config::getInstance()->database['username'];
$password = Config::getInstance()->database['password'];
$host = Config::getInstance()->database['host'];
Config::getInstance()->database['tables_prefix'] = $this->tablesPrefix;
$cmd = "mysql -h \"{$host}\" -u \"{$user}\" \"--password={$password}\" {$this->dbName} < \"" . $deflatedDumpPath . "\" 2>&1";
exec($cmd, $output, $return);
if ($return !== 0) {
throw new Exception("Failed to load sql dump: " . implode("\n", $output));
}
// make sure archiving will be called
Rules::setBrowserTriggerArchiving(true);
// reload access
Access::getInstance()->reloadAccess();
$testVars = new TestingEnvironmentVariables();
$testVars->configOverride = array('database' => array('tables_prefix' => $this->tablesPrefix));
$testVars->save();
}
示例5: testInitTodayToronto
/**
* test of validity of an archive, for today's archive with toronto's timezone
* @group Core
*/
public function testInitTodayToronto()
{
if (!SettingsServer::isTimezoneSupportEnabled()) {
$this->markTestSkipped('timezones needs to be supported');
}
$now = time();
$siteTimezone = 'America/Toronto';
$timestamp = Date::factory('now', $siteTimezone)->getTimestamp();
$dateLabel = date('Y-m-d', $timestamp);
Rules::setBrowserTriggerArchiving(true);
$archiveProcessor = $this->_createArchiveProcessor('day', $dateLabel, $siteTimezone);
$archiveProcessor->time = $now;
// we look at anything processed within the time to live range
$dateMinArchived = $now - Rules::getTodayArchiveTimeToLive();
$this->compareTimestamps($dateMinArchived, $archiveProcessor->public_getMinTimeArchiveProcessed());
$this->assertTrue($archiveProcessor->public_isArchiveTemporary());
// when browsers don't trigger archives...
Rules::setBrowserTriggerArchiving(false);
// ...we force ArchiveProcessor to fetch any of the most recent archive
$dateMinArchived = false;
$this->compareTimestamps($dateMinArchived, $archiveProcessor->public_getMinTimeArchiveProcessed());
// this test varies with DST
$this->assertTrue($archiveProcessor->getParams()->getDateStart()->getDateStartUTC() == date('Y-m-d', $timestamp) . ' 04:00:00' || $archiveProcessor->getParams()->getDateStart()->getDateStartUTC() == date('Y-m-d', $timestamp) . ' 05:00:00');
$this->assertTrue($archiveProcessor->getParams()->getDateEnd()->getDateEndUTC() == date('Y-m-d', $timestamp + 86400) . ' 03:59:59' || $archiveProcessor->getParams()->getDateEnd()->getDateEndUTC() == date('Y-m-d', $timestamp + 86400) . ' 04:59:59');
$this->assertTrue($archiveProcessor->public_isArchiveTemporary());
}
示例6: saveGeneralSettings
private function saveGeneralSettings()
{
if (!self::isGeneralSettingsAdminEnabled()) {
// General settings + Beta channel + SMTP settings is disabled
return;
}
// General Setting
$enableBrowserTriggerArchiving = Common::getRequestVar('enableBrowserTriggerArchiving');
$todayArchiveTimeToLive = Common::getRequestVar('todayArchiveTimeToLive');
Rules::setBrowserTriggerArchiving((bool) $enableBrowserTriggerArchiving);
Rules::setTodayArchiveTimeToLive($todayArchiveTimeToLive);
// update beta channel setting
$debug = Config::getInstance()->Debug;
$debug['allow_upgrades_to_beta'] = Common::getRequestVar('enableBetaReleaseCheck', '0', 'int');
Config::getInstance()->Debug = $debug;
// Update email settings
$mail = array();
$mail['transport'] = Common::getRequestVar('mailUseSmtp') == '1' ? 'smtp' : '';
$mail['port'] = Common::getRequestVar('mailPort', '');
$mail['host'] = Common::unsanitizeInputValue(Common::getRequestVar('mailHost', ''));
$mail['type'] = Common::getRequestVar('mailType', '');
$mail['username'] = Common::unsanitizeInputValue(Common::getRequestVar('mailUsername', ''));
$mail['password'] = Common::unsanitizeInputValue(Common::getRequestVar('mailPassword', ''));
$mail['encryption'] = Common::getRequestVar('mailEncryption', '');
Config::getInstance()->mail = $mail;
// update trusted host settings
$trustedHosts = Common::getRequestVar('trustedHosts', false, 'json');
if ($trustedHosts !== false) {
Url::saveTrustedHostnameInConfig($trustedHosts);
}
Config::getInstance()->forceSave();
$pluginUpdateCommunication = new UpdateCommunication();
if (Common::getRequestVar('enablePluginUpdateCommunication', '0', 'int')) {
$pluginUpdateCommunication->enable();
} else {
$pluginUpdateCommunication->disable();
}
}
示例7: test_ArchiveIsLaunched_WhenForceOnBrowserRequest_IsFalse_AndArchivePhpTriggered
public function test_ArchiveIsLaunched_WhenForceOnBrowserRequest_IsFalse_AndArchivePhpTriggered()
{
$this->archiveDataForIndividualDays();
Config::getInstance()->General['archiving_range_force_on_browser_request'] = 0;
$_GET['trigger'] = 'archivephp';
Rules::setBrowserTriggerArchiving(false);
$data = $this->initiateArchivingForRange();
$this->assertNotEmpty($data);
$this->assertArchiveTablesAreNotEmpty('2010_03');
}
示例8: saveGeneralSettings
private function saveGeneralSettings()
{
if (!$this->isGeneralSettingsAdminEnabled()) {
// General settings + Beta channel + SMTP settings is disabled
return;
}
// General Setting
$enableBrowserTriggerArchiving = Common::getRequestVar('enableBrowserTriggerArchiving');
$todayArchiveTimeToLive = Common::getRequestVar('todayArchiveTimeToLive');
Rules::setBrowserTriggerArchiving((bool) $enableBrowserTriggerArchiving);
Rules::setTodayArchiveTimeToLive($todayArchiveTimeToLive);
// update beta channel setting
$debug = Config::getInstance()->Debug;
$debug['allow_upgrades_to_beta'] = Common::getRequestVar('enableBetaReleaseCheck', '0', 'int');
Config::getInstance()->Debug = $debug;
// Update email settings
$mail = array();
$mail['transport'] = Common::getRequestVar('mailUseSmtp') == '1' ? 'smtp' : '';
$mail['port'] = Common::getRequestVar('mailPort', '');
$mail['host'] = Common::unsanitizeInputValue(Common::getRequestVar('mailHost', ''));
$mail['type'] = Common::getRequestVar('mailType', '');
$mail['username'] = Common::unsanitizeInputValue(Common::getRequestVar('mailUsername', ''));
$mail['password'] = Common::unsanitizeInputValue(Common::getRequestVar('mailPassword', ''));
$mail['encryption'] = Common::getRequestVar('mailEncryption', '');
Config::getInstance()->mail = $mail;
}