当前位置: 首页>>代码示例>>PHP>>正文


PHP Piwik::setUserIsSuperUser方法代码示例

本文整理汇总了PHP中Piwik::setUserIsSuperUser方法的典型用法代码示例。如果您正苦于以下问题:PHP Piwik::setUserIsSuperUser方法的具体用法?PHP Piwik::setUserIsSuperUser怎么用?PHP Piwik::setUserIsSuperUser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Piwik的用法示例。


在下文中一共展示了Piwik::setUserIsSuperUser方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: update

 static function update()
 {
     // force regeneration of cache files following #648
     Piwik::setUserIsSuperUser();
     $allSiteIds = Piwik_SitesManager_API::getAllSitesId();
     Piwik_Common::regenerateCacheWebsiteAttributes($allSiteIds);
 }
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:7,代码来源:0.2.34.php

示例2: getCacheWebsiteAttributes

 /**
  * Returns array containing data about the website: goals, URLs, etc.
  *
  * @param int $idSite
  * @return array
  */
 static function getCacheWebsiteAttributes($idSite)
 {
     require_once PIWIK_INCLUDE_PATH . '/core/Loader.php';
     static $cache = null;
     if (is_null($cache)) {
         $cache = new Piwik_CacheFile('tracker');
     }
     $filename = $idSite;
     $cacheContent = $cache->get($filename);
     if ($cacheContent !== false) {
         return $cacheContent;
     }
     if (defined('PIWIK_TRACKER_MODE') && PIWIK_TRACKER_MODE) {
         require_once PIWIK_INCLUDE_PATH . '/core/PluginsManager.php';
         require_once PIWIK_INCLUDE_PATH . '/core/Translate.php';
         require_once PIWIK_INCLUDE_PATH . '/core/Option.php';
         Zend_Registry::set('db', Piwik_Tracker::getDatabase());
         Piwik::createAccessObject();
         Piwik::createConfigObject();
         Piwik::setUserIsSuperUser();
         $pluginsManager = Piwik_PluginsManager::getInstance();
         $pluginsManager->setPluginsToLoad(Zend_Registry::get('config')->Plugins->Plugins->toArray());
     }
     $content = array();
     Piwik_PostEvent('Common.fetchWebsiteAttributes', $content, $idSite);
     // if nothing is returned from the plugins, we don't save the content
     // this is not expected: all websites are expected to have at least one URL
     if (!empty($content)) {
         $cache->set($filename, $content);
     }
     return $content;
 }
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:38,代码来源:Common.php

示例3: test_callableApiMethods_doNotFail

 function test_callableApiMethods_doNotFail()
 {
     Piwik::createConfigObject();
     Piwik_Config::getInstance()->setTestEnvironment();
     Piwik::createLogObject();
     Piwik::createAccessObject();
     Piwik::createDatabaseObject();
     Piwik::setUserIsSuperUser();
     Piwik_Translate::getInstance()->loadEnglishTranslation();
     $pluginsManager = Piwik_PluginsManager::getInstance();
     $pluginsManager->loadPlugins(Piwik_Config::getInstance()->Plugins['Plugins']);
     Piwik_SitesManager_API::getInstance()->addSite("name", "http://example.org");
     $apiGenerator = new Piwik_API_DocumentationGenerator_CallAllMethods();
     $requestUrls = $apiGenerator->getAllRequestsWithParameters();
     $this->assertTrue(count($requestUrls) > 20);
     foreach ($requestUrls as $url) {
         $call = new Piwik_API_Request($url);
         $output = $call->process();
         //			var_dump($url);
         //			var_dump($output);
         $this->assertTrue(!empty($output));
     }
     Piwik_Translate::getInstance()->unloadEnglishTranslation();
     $this->pass();
 }
开发者ID:nnnnathann,项目名称:piwik,代码行数:25,代码来源:DocumentationGenerator.test.php

示例4: update

	static function update()
	{
		$obsoleteFiles = array(
			PIWIK_INCLUDE_PATH . '/core/Db/Mysqli.php',
		);
		foreach($obsoleteFiles as $obsoleteFile)
		{
			if(file_exists($obsoleteFile))
			{
				@unlink($obsoleteFile);
			}
		}

		$obsoleteDirectories = array(
			PIWIK_INCLUDE_PATH . '/core/Db/Pdo',
		);
		foreach($obsoleteDirectories as $dir)
		{
			if(file_exists($dir))
			{
				Piwik::unlinkRecursive($dir, true);
			}
		}

		// force regeneration of cache files
		Piwik::setUserIsSuperUser();
		$allSiteIds = Piwik_SitesManager_API::getInstance()->getAllSitesId();
		Piwik_Common::regenerateCacheWebsiteAttributes($allSiteIds);
	}
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:29,代码来源:0.6.2.php

示例5: setUpBeforeClass

 public static function setUpBeforeClass($dbName = false, $createEmptyDatabase = true, $createConfig = true)
 {
     try {
         Piwik::$piwikUrlCache = '';
         if ($createConfig) {
             self::createTestConfig();
         }
         if ($dbName === false) {
             $dbName = Piwik_Config::getInstance()->database['dbname'];
         }
         self::connectWithoutDatabase();
         if ($createEmptyDatabase) {
             Piwik::dropDatabase();
         }
         Piwik::createDatabase($dbName);
         Piwik::disconnectDatabase();
         // reconnect once we're sure the database exists
         Piwik_Config::getInstance()->database['dbname'] = $dbName;
         Piwik::createDatabaseObject();
         Piwik::createTables();
         Piwik::createLogObject();
         Piwik_PluginsManager::getInstance()->loadPlugins(array());
     } catch (Exception $e) {
         self::fail("TEST INITIALIZATION FAILED: " . $e->getMessage());
     }
     include "DataFiles/SearchEngines.php";
     include "DataFiles/Languages.php";
     include "DataFiles/Countries.php";
     include "DataFiles/Currencies.php";
     include "DataFiles/LanguageToCountry.php";
     Piwik::createAccessObject();
     Piwik_PostEvent('FrontController.initAuthenticationObject');
     // We need to be SU to create websites for tests
     Piwik::setUserIsSuperUser();
     // Load and install plugins
     $pluginsManager = Piwik_PluginsManager::getInstance();
     $plugins = $pluginsManager->readPluginsDirectory();
     $pluginsManager->loadPlugins($plugins);
     if ($createEmptyDatabase) {
         $pluginsManager->installLoadedPlugins();
     }
     $_GET = $_REQUEST = array();
     $_SERVER['HTTP_REFERER'] = '';
     // Make sure translations are loaded to check messages in English
     Piwik_Translate::getInstance()->loadEnglishTranslation();
     Piwik_LanguagesManager_API::getInstance()->setLanguageForUser('superUserLogin', 'en');
     // List of Modules, or Module.Method that should not be called as part of the XML output compare
     // Usually these modules either return random changing data, or are already tested in specific unit tests.
     self::setApiNotToCall(self::$defaultApiNotToCall);
     self::setApiToCall(array());
 }
开发者ID:nomoto-ubicast,项目名称:piwik,代码行数:51,代码来源:IntegrationTestCase.php

示例6: init

 public function init()
 {
     $this->initCore();
     $this->initTokenAuth();
     $this->initCheckCli();
     $this->initLog();
     $this->displayHelp();
     $this->initPiwikHost();
     $this->initStateFromParameters();
     Piwik::setUserIsSuperUser(true);
     $this->logSection("INIT");
     $this->log("Querying Piwik API at: {$this->piwikUrl}");
     $this->log("Running as Super User: " . $this->login);
     $this->acceptInvalidSSLCertificate = $this->isParameterSet("accept-invalid-ssl-certificate");
     // Test the specified piwik URL is valid
     $response = $this->request("?module=API&method=API.getDefaultMetricTranslations&format=php");
     $responseUnserialized = @unserialize($response);
     if ($response === false || !is_array($responseUnserialized)) {
         $this->logFatalError("The Piwik URL {$this->piwikUrl} does not seem to be pointing to a Piwik server. Response was '{$response}'.");
     }
     $this->log("Notes");
     // Information about timeout
     $this->todayArchiveTimeToLive = Piwik_ArchiveProcessing::getTodayArchiveTimeToLive();
     $this->log("- Reports for today will be processed at most every " . Piwik_ArchiveProcessing::getTodayArchiveTimeToLive() . " seconds. You can change this value in Piwik UI > Settings > General Settings.");
     $this->log("- Reports for the current week/month/year will be refreshed at most every " . $this->processPeriodsMaximumEverySeconds . " seconds.");
     // Fetching segments to process
     $this->segments = Piwik_CoreAdminHome_API::getInstance()->getKnownSegmentsToArchive();
     if (empty($this->segments)) {
         $this->segments = array();
     }
     if (!empty($this->segments)) {
         $this->log("- Segments to pre-process for each website and each period: " . implode(", ", $this->segments));
     }
     // Try and not request older data we know is already archived
     if ($this->timeLastCompleted !== false) {
         $dateLast = time() - $this->timeLastCompleted;
         $this->log("- Archiving was last executed without error " . Piwik::getPrettyTimeFromSeconds($dateLast, true, $isHtml = false) . " ago");
     }
     $this->initWebsitesToProcess();
     flush();
 }
开发者ID:nomoto-ubicast,项目名称:piwik,代码行数:41,代码来源:archive.php

示例7: test_callableApiMethods_doNotFail

 function test_callableApiMethods_doNotFail()
 {
     Piwik::createConfigObject();
     Piwik::createLogObject();
     Piwik::createAccessObject();
     Piwik::createDatabaseObject();
     Piwik::setUserIsSuperUser();
     $pluginsManager = Piwik_PluginsManager::getInstance();
     $pluginsManager->setPluginsToLoad(Zend_Registry::get('config')->Plugins->Plugins->toArray());
     $apiGenerator = new Piwik_API_DocumentationGenerator_CallAllMethods();
     $requestUrls = $apiGenerator->getAllRequestsWithParameters();
     $this->assertTrue(count($requestUrls) > 20);
     foreach ($requestUrls as $url) {
         $call = new Piwik_API_Request($url);
         $output = $call->process();
         //			var_dump($url);
         //			var_dump($output);
         $this->assertTrue(!empty($output));
     }
     $this->pass();
 }
开发者ID:klando,项目名称:pgpiwik,代码行数:21,代码来源:DocumentationGenerator.test.php

示例8:

<?php

// force regeneration of cache files following #648
Piwik::setUserIsSuperUser();
$allSiteIds = Piwik_SitesManager_API::getAllSitesId();
Piwik_Common::regenerateCacheWebsiteAttributes($allSiteIds);
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:6,代码来源:0.2.34.php

示例9: runScheduledTasks

 /**
  * Tracker requests will automatically trigger the Scheduled tasks.
  * This is useful for users who don't setup the cron,
  * but still want daily/weekly/monthly PDF reports emailed automatically.
  *
  * This is similar to calling the API CoreAdminHome.runScheduledTasks (see misc/cron/archive.sh)
  *
  * @param int  $now  Current timestamp
  */
 public static function runScheduledTasks($now)
 {
     // Currently, there is no hourly tasks. When there are some,
     // this could be too agressive minimum interval (some hours would be skipped in case of low traffic)
     $minimumInterval = Piwik_Config::getInstance()->Tracker['scheduled_tasks_min_interval'];
     // If the user disabled browser archiving, he has already setup a cron
     // To avoid parallel requests triggering the Scheduled Tasks,
     // Get last time tasks started executing
     $cache = Piwik_Common::getCacheGeneral();
     if ($minimumInterval <= 0 || empty($cache['isBrowserTriggerArchivingEnabled'])) {
         printDebug("-> Scheduled tasks not running in Tracker: Browser archiving is disabled.");
         return;
     }
     $nextRunTime = $cache['lastTrackerCronRun'] + $minimumInterval;
     if (isset($GLOBALS['PIWIK_TRACKER_DEBUG_FORCE_SCHEDULED_TASKS']) && $GLOBALS['PIWIK_TRACKER_DEBUG_FORCE_SCHEDULED_TASKS'] || $cache['lastTrackerCronRun'] === false || $nextRunTime < $now) {
         $cache['lastTrackerCronRun'] = $now;
         Piwik_Common::setCacheGeneral($cache);
         Piwik_Common::initCorePiwikInTrackerMode();
         Piwik_SetOption('lastTrackerCronRun', $cache['lastTrackerCronRun']);
         printDebug('-> Scheduled Tasks: Starting...');
         // save current user privilege and temporarily assume super user privilege
         $isSuperUser = Piwik::isUserIsSuperUser();
         // Scheduled tasks assume Super User is running
         Piwik::setUserIsSuperUser();
         // While each plugins should ensure that necessary languages are loaded,
         // we ensure English translations at least are loaded
         Piwik_Translate::getInstance()->loadEnglishTranslation();
         $resultTasks = Piwik_TaskScheduler::runTasks();
         // restore original user privilege
         Piwik::setUserIsSuperUser($isSuperUser);
         printDebug($resultTasks);
         printDebug('Finished Scheduled Tasks.');
     } else {
         printDebug("-> Scheduled tasks not triggered.");
     }
     printDebug("Next run will be from: " . date('Y-m-d H:i:s', $nextRunTime) . ' UTC');
 }
开发者ID:nomoto-ubicast,项目名称:piwik,代码行数:46,代码来源:Common.php

示例10: initObjectsToCallAPI

	/**
	 * Instantiate access and log objects
	 */
	protected function initObjectsToCallAPI()
	{
		// connect to the database using the DB infos currently in the session
		$this->createDbFromSessionInformation();

		Piwik::createAccessObject();
		Piwik::setUserIsSuperUser();
		Piwik::createLogObject();
	}
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:12,代码来源:Controller.php

示例11: getUserInformation

 /**
  * Get user information
  *
  * @param string $loginMail (user login or email address)
  * @return array ("login" => '...', "email" => '...', "password" => '...') or null, if user not found
  */
 protected function getUserInformation($loginMail)
 {
     Piwik::setUserIsSuperUser();
     $user = null;
     if ($loginMail == Zend_Registry::get('config')->superuser->email || $loginMail == Zend_Registry::get('config')->superuser->login) {
         $user = array('login' => Zend_Registry::get('config')->superuser->login, 'email' => Zend_Registry::get('config')->superuser->email, 'password' => Zend_Registry::get('config')->superuser->password);
     } else {
         if (Piwik_UsersManager_API::getInstance()->userExists($loginMail)) {
             $user = Piwik_UsersManager_API::getInstance()->getUser($loginMail);
         } else {
             if (Piwik_UsersManager_API::getInstance()->userEmailExists($loginMail)) {
                 $user = Piwik_UsersManager_API::getInstance()->getUserByEmail($loginMail);
             }
         }
     }
     return $user;
 }
开发者ID:Doluci,项目名称:tomatocart,代码行数:23,代码来源:Controller.php

示例12: getUserInformation

 /**
  * Get user information
  *
  * @param string $loginMail user login or email address
  * @return array ("login" => '...', "email" => '...', "password" => '...') or null, if user not found
  */
 protected function getUserInformation($loginMail)
 {
     Piwik::setUserIsSuperUser();
     $user = null;
     if ($loginMail == Piwik::getSuperUserEmail() || $loginMail == Piwik_Config::getInstance()->superuser['login']) {
         $user = array('login' => Piwik_Config::getInstance()->superuser['login'], 'email' => Piwik::getSuperUserEmail(), 'password' => Piwik_Config::getInstance()->superuser['password']);
     } else {
         if (Piwik_UsersManager_API::getInstance()->userExists($loginMail)) {
             $user = Piwik_UsersManager_API::getInstance()->getUser($loginMail);
         } else {
             if (Piwik_UsersManager_API::getInstance()->userEmailExists($loginMail)) {
                 $user = Piwik_UsersManager_API::getInstance()->getUserByEmail($loginMail);
             }
         }
     }
     return $user;
 }
开发者ID:nomoto-ubicast,项目名称:piwik,代码行数:23,代码来源:Controller.php

示例13: lostPasswordFormValidated

 protected function lostPasswordFormValidated($loginMail, $urlToRedirect)
 {
     Piwik::setUserIsSuperUser();
     $user = null;
     $isSuperUser = false;
     if ($loginMail == Zend_Registry::get('config')->superuser->email || $loginMail == Zend_Registry::get('config')->superuser->login) {
         $isSuperUser = true;
         $user = array('login' => Zend_Registry::get('config')->superuser->login, 'email' => Zend_Registry::get('config')->superuser->email);
     } else {
         if (Piwik_UsersManager_API::userExists($loginMail)) {
             $user = Piwik_UsersManager_API::getUser($loginMail);
         } else {
             if (Piwik_UsersManager_API::userEmailExists($loginMail)) {
                 $user = Piwik_UsersManager_API::getUserByEmail($loginMail);
             }
         }
     }
     if ($user === null) {
         $messageNoAccess = Piwik_Translate('Login_InvalidUsernameEmail');
     } else {
         $view = new Piwik_View('Login/templates/passwordsent.tpl');
         $login = $user['login'];
         $email = $user['email'];
         $randomPassword = Piwik_Common::getRandomString(8);
         if ($isSuperUser) {
             $user['password'] = md5($randomPassword);
             Zend_Registry::get('config')->superuser = $user;
         } else {
             Piwik_UsersManager_API::updateUser($login, $randomPassword);
         }
         // send email with new password
         try {
             $mail = new Piwik_Mail();
             $mail->addTo($email, $login);
             $mail->setSubject(Piwik_Translate('Login_MailTopicPasswordRecovery'));
             $mail->setBodyText(str_replace('\\n', "\n", sprintf(Piwik_Translate('Login_MailPasswordRecoveryBody'), $login, $randomPassword, Piwik_Url::getCurrentUrlWithoutQueryString())));
             $piwikHost = $_SERVER['HTTP_HOST'];
             if (strlen($piwikHost) == 0) {
                 $piwikHost = 'piwik.org';
             }
             $fromEmailName = Zend_Registry::get('config')->General->login_password_recovery_email_name;
             $fromEmailAddress = Zend_Registry::get('config')->General->login_password_recovery_email_address;
             $fromEmailAddress = str_replace('{DOMAIN}', $piwikHost, $fromEmailAddress);
             $mail->setFrom($fromEmailAddress, $fromEmailName);
             @$mail->send();
         } catch (Exception $e) {
             $view->ErrorString = $e->getMessage();
         }
         $view->linkTitle = Piwik::getRandomTitle();
         $view->urlToRedirect = $urlToRedirect;
         echo $view->render();
     }
 }
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:53,代码来源:Controller.php

示例14: __construct

 /**
  * Initializes the test
  * @param $title
  * @return void
  */
 function __construct($title = '')
 {
     parent::__construct($title);
     if (Test_Integration::$widgetTestingLevel != self::NO_WIDGET_TESTING) {
         self::initializeControllerTesting();
     }
     Piwik::createAccessObject();
     Piwik_PostEvent('FrontController.initAuthenticationObject');
     // We need to be SU to create websites for tests
     Piwik::setUserIsSuperUser();
     // Load and install plugins
     $pluginsManager = Piwik_PluginsManager::getInstance();
     $plugins = Piwik_Config::getInstance()->Plugins['Plugins'];
     $pluginsManager->loadPlugins($plugins);
     $pluginsManager->installLoadedPlugins();
 }
开发者ID:0h546f6f78696342756e4e59,项目名称:piwik,代码行数:21,代码来源:Integration.php

示例15: getCacheWebsiteAttributes

 /**
  * Returns array containing data about the website: goals, URLs, etc.
  *
  * @param int $idSite
  * @return array
  */
 static function getCacheWebsiteAttributes($idSite)
 {
     static $cache = null;
     if (is_null($cache)) {
         require_once "CacheFile.php";
         $cache = new Piwik_CacheFile('tracker');
     }
     $filename = $idSite;
     $cacheContent = $cache->get($filename);
     if ($cacheContent !== false) {
         return $cacheContent;
     }
     if (defined('PIWIK_TRACKER_MODE') && PIWIK_TRACKER_MODE) {
         //TODO we can remove these includes when #620 is done
         require_once "Zend/Exception.php";
         require_once "Zend/Loader.php";
         require_once "Zend/Auth.php";
         require_once "Timer.php";
         require_once "PluginsManager.php";
         require_once "Piwik.php";
         require_once "Access.php";
         require_once "Auth.php";
         require_once "API/Proxy.php";
         require_once "Archive.php";
         require_once "Site.php";
         require_once "Date.php";
         require_once "DataTable.php";
         require_once "Translate.php";
         require_once "Mail.php";
         require_once "Url.php";
         require_once "Controller.php";
         require_once "Option.php";
         require_once "View.php";
         require_once "UpdateCheck.php";
         Zend_Registry::set('db', Piwik_Tracker::getDatabase());
         Piwik::createAccessObject();
         Piwik::createConfigObject();
         Piwik::setUserIsSuperUser();
         $pluginsManager = Piwik_PluginsManager::getInstance();
         $pluginsManager->setPluginsToLoad(Zend_Registry::get('config')->Plugins->Plugins->toArray());
     }
     $content = array();
     Piwik_PostEvent('Common.fetchWebsiteAttributes', $content, $idSite);
     // if nothing is returned from the plugins, we don't save the content
     // this is not expected: all websites are expected to have at least one URL
     if (!empty($content)) {
         $cache->set($filename, $content);
     }
     return $content;
 }
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:56,代码来源:Common.php


注:本文中的Piwik::setUserIsSuperUser方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。