本文整理汇总了PHP中Piwik::isUserIsSuperUser方法的典型用法代码示例。如果您正苦于以下问题:PHP Piwik::isUserIsSuperUser方法的具体用法?PHP Piwik::isUserIsSuperUser怎么用?PHP Piwik::isUserIsSuperUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik
的用法示例。
在下文中一共展示了Piwik::isUserIsSuperUser方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addMenu
function addMenu()
{
Piwik_AddAdminMenu('CorePluginsAdmin_MenuPlugins',
array('module' => 'CorePluginsAdmin', 'action' => 'index'),
Piwik::isUserIsSuperUser(),
$order = 7);
}
示例2: generalSettings
public function generalSettings()
{
Piwik::checkUserHasSomeAdminAccess();
$view = Piwik_View::factory('generalSettings');
if (Piwik::isUserIsSuperUser()) {
$enableBrowserTriggerArchiving = Piwik_ArchiveProcessing::isBrowserTriggerArchivingEnabled();
$todayArchiveTimeToLive = Piwik_ArchiveProcessing::getTodayArchiveTimeToLive();
$showWarningCron = false;
if (!$enableBrowserTriggerArchiving && $todayArchiveTimeToLive < 3600) {
$showWarningCron = true;
}
$view->showWarningCron = $showWarningCron;
$view->todayArchiveTimeToLive = $todayArchiveTimeToLive;
$view->enableBrowserTriggerArchiving = $enableBrowserTriggerArchiving;
$view->language = Piwik_LanguagesManager::getLanguageCodeForCurrentUser();
if (!Zend_Registry::get('config')->isFileWritable()) {
$view->configFileNotWritable = true;
}
$view->mail = Zend_Registry::get('config')->mail->toArray();
}
$this->setBasicVariablesView($view);
$view->topMenu = Piwik_GetTopMenu();
$view->menu = Piwik_GetAdminMenu();
echo $view->render();
}
示例3: index
function index()
{
Piwik::checkUserIsNotAnonymous();
$view = Piwik_View::factory('Settings');
$view->isSuperUser = Piwik::isUserIsSuperUser();
$mobileMessagingAPI = Piwik_MobileMessaging_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('UserSettings_SubmenuSettings'), Piwik_Translate('MobileMessaging_SettingsMenu')));
if ($view->credentialSupplied && $view->accountManagedByCurrentUser) {
$view->provider = $mobileMessagingAPI->getSMSProvider();
$view->creditLeft = $mobileMessagingAPI->getCreditLeft();
}
$view->smsProviders = Piwik_MobileMessaging_SMSProvider::$availableSMSProviders;
// construct the list of countries from the lang files
$countries = array();
foreach (Piwik_Common::getCountriesList() as $countryCode => $continentCode) {
if (isset(Piwik_MobileMessaging_CountryCallingCodes::$countryCallingCodes[$countryCode])) {
$countries[$countryCode] = array('countryName' => Piwik_CountryTranslate($countryCode), 'countryCallingCode' => Piwik_MobileMessaging_CountryCallingCodes::$countryCallingCodes[$countryCode]);
}
}
$view->countries = $countries;
$view->defaultCountry = Piwik_Common::getCountry(Piwik_LanguagesManager::getLanguageCodeForCurrentUser(), true, Piwik_IP::getIpFromHeader());
$view->phoneNumbers = $mobileMessagingAPI->getPhoneNumbers();
$this->setBasicVariablesView($view);
$view->menu = Piwik_GetAdminMenu();
echo $view->render();
}
示例4: generalSettings
public function generalSettings()
{
Piwik::checkUserHasSomeAdminAccess();
$view = Piwik_View::factory('generalSettings');
if (Piwik::isUserIsSuperUser()) {
$enableBrowserTriggerArchiving = Piwik_ArchiveProcessing::isBrowserTriggerArchivingEnabled();
$todayArchiveTimeToLive = Piwik_ArchiveProcessing::getTodayArchiveTimeToLive();
$showWarningCron = false;
if (!$enableBrowserTriggerArchiving && $todayArchiveTimeToLive < 3600) {
$showWarningCron = true;
}
$view->showWarningCron = $showWarningCron;
$view->todayArchiveTimeToLive = $todayArchiveTimeToLive;
$view->enableBrowserTriggerArchiving = $enableBrowserTriggerArchiving;
if (!Piwik_Config::getInstance()->isFileWritable()) {
$view->configFileNotWritable = true;
}
$view->mail = Piwik_Config::getInstance()->mail;
$view->branding = Piwik_Config::getInstance()->branding;
$directoryWritable = is_writable(PIWIK_DOCUMENT_ROOT . '/themes/');
$logoFilesWriteable = is_writeable(PIWIK_DOCUMENT_ROOT . '/themes/logo.png') && is_writeable(PIWIK_DOCUMENT_ROOT . '/themes/logo-header.png');
$view->logosWriteable = ($logoFilesWriteable || $directoryWritable) && ini_get('file_uploads') == 1;
}
$view->language = Piwik_LanguagesManager::getLanguageCodeForCurrentUser();
$this->setBasicVariablesView($view);
$view->topMenu = Piwik_GetTopMenu();
$view->menu = Piwik_GetAdminMenu();
echo $view->render();
}
示例5: addMenu
function addMenu()
{
Piwik_AddAdminMenu('DBStats_DatabaseUsage',
array('module' => 'DBStats', 'action' => 'index'),
Piwik::isUserIsSuperUser(),
$order = 9);
}
示例6: render
public function render()
{
try {
$this->currentModule = Piwik::getModule();
$this->currentPluginName = Piwik::getCurrentPlugin()->getName();
$this->userLogin = Piwik::getCurrentUserLogin();
$showWebsiteSelectorInUserInterface = Zend_Registry::get('config')->General->show_website_selector_in_user_interface;
if ($showWebsiteSelectorInUserInterface) {
$sites = Piwik_SitesManager_API::getSitesWithAtLeastViewAccess();
usort($sites, create_function('$site1, $site2', 'return strcasecmp($site1["name"], $site2["name"]);'));
$this->sites = $sites;
}
$this->showWebsiteSelectorInUserInterface = $showWebsiteSelectorInUserInterface;
$this->url = Piwik_Url::getCurrentUrl();
$this->token_auth = Piwik::getCurrentUserTokenAuth();
$this->userHasSomeAdminAccess = Piwik::isUserHasSomeAdminAccess();
$this->userIsSuperUser = Piwik::isUserIsSuperUser();
$this->piwik_version = Piwik_Version::VERSION;
$this->latest_version_available = Piwik_UpdateCheck::isNewestVersionAvailable();
$this->loginModule = Zend_Registry::get('auth')->getName();
} catch (Exception $e) {
// can fail, for example at installation (no plugin loaded yet)
}
$this->totalTimeGeneration = Zend_Registry::get('timer')->getTime();
try {
$this->totalNumberOfQueries = Piwik::getQueryCount();
} catch (Exception $e) {
$this->totalNumberOfQueries = 0;
}
header('Content-Type: text/html; charset=utf-8');
header("Pragma: ");
header("Cache-Control: no-store, must-revalidate");
return $this->smarty->fetch($this->template);
}
示例7: addMenu
function addMenu()
{
Piwik_AddAdminMenu('SecurityInfo_Security',
array('module' => 'SecurityInfo', 'action' => 'index'),
Piwik::isUserIsSuperUser(),
$order = 10);
}
示例8: addMenu
public function addMenu() {
Piwik_AddAdminMenu(
'VisitorGenerator_VisitorGenerator',
array('module' => 'VisitorGenerator', 'action' => 'index'),
Piwik::isUserIsSuperUser(),
$order = 10
);
}
示例9: index
/**
* This method displays a text containing an help about "How to build plugins for Piwik".
* This help is then used on http://piwik.org/docs/plugins/functions
*
*/
function index()
{
$out = '';
$out .= '<i>This page aims to list the different functions you can use when programming plugins for Piwik.</i><br />';
$out .= '<b>Be careful, the following APIs may change in the near future as Piwik is still in development.</b><br />';
$out .= '<h2>General</h2>';
$out .= '<h3>Accessible from your plugin controller</h3>';
$out .= '<code>$this->date</code> = current selected <b>Piwik_Date</b> object (<a href="http://dev.piwik.org/trac/browser/trunk/core/Date.php">class</a>)<br />';
$out .= '<code>$period = Piwik_Common::getRequestVar("period");</code> - Get the current selected period<br />';
$out .= '<code>$idSite = Piwik_Common::getRequestVar("idSite");</code> - Get the selected idSite<br />';
$out .= '<code>$site = new Piwik_Site($idSite);</code> - Build the Piwik_Site object (<a href="http://dev.piwik.org/trac/browser/trunk/core/Site.php">class</a>)<br />';
$out .= '<code>$this->str_date</code> = current selected date in YYYY-MM-DD format<br />';
$out .= '<h3>Misc</h3>';
$out .= '<code>Piwik_AddMenu( $mainMenuName, $subMenuName, $url );</code> - Adds an entry to the menu in the Piwik interface (See the example in the <a href="http://dev.piwik.org/trac/browser/tags/1.0/plugins/UserCountry/UserCountry.php#L76">UserCountry Plugin file</a>)<br />';
$out .= '<code>Piwik_AddWidget( $widgetCategory, $widgetName, $controllerName, $controllerAction, $customParameters = array());</code> - Adds a widget that users can add in the dashboard, or export using the Widgets link at the top of the screen. See the example in the <a href="http://dev.piwik.org/trac/browser/tags/1.0/plugins/UserCountry/UserCountry.php#L70">UserCountry Plugin file</a> or any other plugin)<br />';
$out .= '<code>Piwik_Common::prefixTable("site")</code> = <b>' . Piwik_Common::prefixTable("site") . '</b><br />';
$out .= '<h2>User access</h2>';
$out .= '<code>Piwik::getCurrentUserLogin()</code> = <b>' . Piwik::getCurrentUserLogin() . '</b><br />';
$out .= '<code>Piwik::isUserHasSomeAdminAccess()</code> = <b>' . self::boolToString(Piwik::isUserHasSomeAdminAccess()) . '</b><br />';
$out .= '<code>Piwik::isUserHasAdminAccess( array $idSites = array(1,2) )</code> = <b>' . self::boolToString(Piwik::isUserHasAdminAccess(array(1, 2))) . '</b><br />';
$out .= '<code>Piwik::isUserHasViewAccess( array $idSites = array(1) ) </code> = <b>' . self::boolToString(Piwik::isUserHasViewAccess(array(1))) . '</b><br />';
$out .= '<code>Piwik::isUserIsSuperUser()</code> = <b>' . self::boolToString(Piwik::isUserIsSuperUser()) . '</b><br />';
$out .= '<h2>Execute SQL queries</h2>';
$txtQuery = "SELECT token_auth FROM " . Piwik_Common::prefixTable('user') . " WHERE login = ?";
$result = Piwik_FetchOne($txtQuery, array('anonymous'));
$out .= '<code>Piwik_FetchOne("' . $txtQuery . '", array("anonymous"))</code> = <b>' . var_export($result, true) . '</b><br />';
$out .= '<br />';
$query = Piwik_Query($txtQuery, array('anonymous'));
$fetched = $query->fetch();
$token_auth = $fetched['token_auth'];
$out .= '<code>$query = Piwik_Query("' . $txtQuery . '", array("anonymous"))</code><br />';
$out .= '<code>$fetched = $query->fetch();</code><br />';
$out .= 'At this point, we have: <code>$fetched[\'token_auth\'] == <b>' . var_export($token_auth, true) . '</b></code><br />';
$out .= '<h2>Example Sites information API</h2>';
$out .= '<code>Piwik_SitesManager_API::getInstance()->getSitesWithViewAccess()</code> = <b><pre>' . var_export(Piwik_SitesManager_API::getInstance()->getSitesWithViewAccess(), true) . '</pre></b><br />';
$out .= '<code>Piwik_SitesManager_API::getInstance()->getSitesWithAdminAccess()</code> = <b><pre>' . var_export(Piwik_SitesManager_API::getInstance()->getSitesWithAdminAccess(), true) . '</pre></b><br />';
$out .= '<h2>Example API Users information</h2>';
$out .= 'View the list of API methods you can call on <a href="http://piwik.org/docs/analytics-api/reference">API reference</a><br />';
$out .= 'For example you can try <code>Piwik_UsersManager_API::getInstance()->getUsersSitesFromAccess("view");</code> or <code>Piwik_UsersManager_API::getInstance()->deleteUser("userToDelete");</code><br />';
$out .= '<h2>Javascript in Piwik</h2>';
$out .= '<h3>i18n internationalization</h3>';
$out .= 'In order to translate strings within Javascript code, you can use the javascript function _pk_translate( token );.
<ul><li>The "token" parameter is the string unique key found in the translation file. For this token string to be available in Javascript, you must
suffix your token by "_js" in the language file. For example, you can add <code>\'Goals_AddGoal_js\' => \'Add Goal\',</code> in the lang/en.php file</li>
<li>You then need to instruct Piwik to load your Javascript translations for your plugin; by default, all translation strings are not loaded in Javascript for performance reasons. This can be done by calling a custom-made Smarty modifier before the Javascript code requiring translations, eg.
<code>{loadJavascriptTranslations plugins=\'$YOUR_PLUGIN_NAME\'}</code>. In our previous example, the $YOUR_PLUGIN_NAME being Goals, we would write <code>{loadJavascriptTranslations plugins=\'Goals\'}</code>
</li><li>You can then print this string from your JS code by doing <code>_pk_translate(\'Goals_AddGoal_js\');</code>.
</li></ul>';
$out .= '<h3>Reload a widget in the dashboard</h3>';
$out .= 'It is sometimes useful to reload one widget in the dashboard (for example, every 20 seconds for a real time widget, or after a setting change).
You can easily force your widget to reload in the dashboard by calling the helper function <code>piwik.dashboardObject.reloadEnclosingWidget($(this));</code>.';
$out .= '<h2>Smarty plugins</h2>';
$out .= 'There are some builtin plugins for Smarty especially developped for Piwik. <br />
You can find them on the <a href="http://dev.piwik.org/trac/browser/trunk/core/SmartyPlugins">SVN at /trunk/core/SmartyPlugins</a>. <br />
More documentation to come about smarty plugins.<br />';
echo $out;
}
示例10: redirectToIndex
function redirectToIndex()
{
if (Piwik::isUserIsSuperUser()) {
$module = 'CorePluginsAdmin';
} else {
$module = 'SitesManager';
}
header("Location:index.php?module=" . $module);
}
示例11: getAll
/**
* Returns a report displaying the total visits, actions and revenue, as
* well as the evolution of these values, of all existing sites over a
* specified period of time.
*
* If the specified period is not a 'range', this function will calculcate
* evolution metrics. Evolution metrics are metrics that display the
* percent increase/decrease of another metric since the last period.
*
* This function will merge the result of the archive query so each
* row in the result DataTable will correspond to the metrics of a single
* site. If a date range is specified, the result will be a
* DataTable_Array, but it will still be merged.
*
* @param string $period The period type to get data for.
* @param string $date The date(s) to get data for.
* @param string $segment The segments to get data for.
*/
public function getAll($period, $date, $segment = false)
{
Piwik::checkUserHasSomeViewAccess();
$isGoalPluginEnabled = Piwik_Common::isGoalPluginEnabled();
// get site data for every viewable site and cache them
if (Piwik::isUserIsSuperUser()) {
$sites = Piwik_SitesManager_API::getInstance()->getAllSites();
Piwik_Site::setSites($sites);
} else {
$sites = Piwik_SitesManager_API::getInstance()->getSitesWithAtLeastViewAccess();
Piwik_Site::setSitesFromArray($sites);
}
// build the archive type used to query archive data
$archive = Piwik_Archive::build('all', $period, $date, $segment);
// determine what data will be displayed
$fieldsToGet = array('nb_visits', 'nb_actions');
if ($isGoalPluginEnabled) {
$revenueMetric = Piwik_Goals::getRecordName('revenue');
$fieldsToGet[] = $revenueMetric;
}
// get the data
$dataTable = $archive->getDataTableFromNumeric($fieldsToGet);
// get rid of the DataTable_Array that is created by the IndexedBySite archive type
$dataTable = $dataTable->mergeChildren();
// if the period isn't a range & a lastN/previousN date isn't used, we get the same
// data for the last period to show the evolution of visits/actions/revenue
if ($period != 'range' && !preg_match('/(last|previous)([0-9]*)/', $date, $regs)) {
if (strpos($date, ',')) {
$rangePeriod = new Piwik_Period_Range($period, $date);
$lastStartDate = Piwik_Period_Range::removePeriod($period, $rangePeriod->getDateStart(), $n = 1);
$lastEndDate = Piwik_Period_Range::removePeriod($period, $rangePeriod->getDateEnd(), $n = 1);
$strLastDate = "{$lastStartDate},{$lastEndDate}";
} else {
$strLastDate = Piwik_Period_Range::removePeriod($period, Piwik_Date::factory($date), $n = 1)->toString();
}
$pastArchive = Piwik_Archive::build('all', $period, $strLastDate, $segment);
$pastData = $pastArchive->getDataTableFromNumeric($fieldsToGet);
$pastData = $pastData->mergeChildren();
// use past data to calculate evolution percentages
$this->calculateEvolutionPercentages($dataTable, $pastData, $fieldsToGet);
}
// move the site id to a metadata column
$dataTable->filter('ColumnCallbackAddMetadata', array('label', 'idsite'));
// set the label of each row to the site name
$getNameFor = array('Piwik_Site', 'getNameFor');
$dataTable->filter('ColumnCallbackReplace', array('label', $getNameFor));
// rename the revenue column from the metric name to 'revenue'
if ($isGoalPluginEnabled) {
$mapping = array($revenueMetric => 'revenue');
$dataTable->filter('ReplaceColumnNames', array($mapping));
}
// Ensures data set sorted, for Metadata output
$dataTable->filter('Sort', array('nb_visits', 'desc', $naturalSort = false));
return $dataTable;
}
示例12: privacySettings
public function privacySettings()
{
Piwik::checkUserHasSomeAdminAccess();
$view = Piwik_View::factory('privacySettings');
if (Piwik::isUserIsSuperUser()) {
$deleteLogs = array();
$view->deleteLogs = $this->getDeleteLogsInfo();
$view->anonymizeIP = $this->getAnonymizeIPInfo();
}
$view->language = Piwik_LanguagesManager::getLanguageCodeForCurrentUser();
if (!Zend_Registry::get('config')->isFileWritable()) {
$view->configFileNotWritable = true;
}
$this->setBasicVariablesView($view);
$view->menu = Piwik_GetAdminMenu();
echo $view->render();
}
示例13: setBasicVariablesAdminView
public static function setBasicVariablesAdminView($view)
{
$view->currentAdminMenuName = Piwik_GetCurrentAdminMenuName();
$view->enableFrames = Piwik_Config::getInstance()->General['enable_framed_settings'];
if (!$view->enableFrames) {
$view->setXFrameOptions('sameorigin');
}
$view->isSuperUser = Piwik::isUserIsSuperUser();
// for old geoip plugin warning
$view->usingOldGeoIPPlugin = Piwik_PluginsManager::getInstance()->isPluginActivated('GeoIP');
// for cannot find installed plugin warning
$missingPlugins = Piwik_PluginsManager::getInstance()->getMissingPlugins();
if (!empty($missingPlugins)) {
$pluginsLink = Piwik_Url::getCurrentQueryStringWithParametersModified(array('module' => 'CorePluginsAdmin', 'action' => 'index'));
$view->missingPluginsWarning = Piwik_Translate('CoreAdminHome_MissingPluginsWarning', array('<strong>' . implode('</strong>, <strong>', $missingPlugins) . '</strong>', '<a href="' . $pluginsLink . '"/>', '</a>'));
}
}
示例14: addAdminMenu
/** Admin menu hook */
public function addAdminMenu()
{
Piwik_AddAdminMenu('SiteSearch_SiteSearch', array('module' => 'SiteSearch', 'action' => 'admin'), Piwik::isUserIsSuperUser(), 8);
}
示例15: redirectToIndex
function redirectToIndex($moduleToRedirect, $actionToRedirect)
{
$sitesId = Piwik_SitesManager_API::getSitesIdWithAtLeastViewAccess();
if (!empty($sitesId)) {
$firstSiteId = $sitesId[0];
$firstSite = new Piwik_Site($firstSiteId);
if ($firstSite->getCreationDate()->isToday()) {
$defaultDate = 'today';
} else {
$defaultDate = Zend_Registry::get('config')->General->default_day;
}
$defaultPeriod = Zend_Registry::get('config')->General->default_period;
header("Location:index.php?module=" . $moduleToRedirect . "&action=" . $actionToRedirect . "&idSite={$firstSiteId}&period={$defaultPeriod}&date={$defaultDate}");
} else {
if (Piwik::isUserIsSuperUser()) {
Piwik_ExitWithMessage("Error: no website were found in this Piwik installation. \n\t\t\t\t<br>Check the table '" . Piwik::prefixTable('site') . "' that should contain your Piwik websites.", false, true);
}
$currentLogin = Piwik::getCurrentUserLogin();
if (!empty($currentLogin) && $currentLogin != 'anonymous') {
$errorMessage = sprintf(Piwik_Translate('CoreHome_NoPrivileges'), $currentLogin);
$errorMessage .= "<br /><br /> <b><a href='?module=" . Zend_Registry::get('auth')->getName() . "&action=logout'>› " . Piwik_Translate('General_Logout') . "</a></b><br />";
Piwik_ExitWithMessage($errorMessage, false, true);
} else {
Piwik_FrontController::dispatch('Login', false);
}
}
exit;
}