本文整理汇总了PHP中Piwik\Piwik::getCurrentUserLogin方法的典型用法代码示例。如果您正苦于以下问题:PHP Piwik::getCurrentUserLogin方法的具体用法?PHP Piwik::getCurrentUserLogin怎么用?PHP Piwik::getCurrentUserLogin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik\Piwik
的用法示例。
在下文中一共展示了Piwik::getCurrentUserLogin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct($username)
{
$this->username = $username;
$this->title = 'Piwik - ' . Url::getCurrentHost();
$this->description = Piwik::getCurrentUserLogin();
$this->load();
}
示例2: configureTopMenu
public function configureTopMenu(MenuTop $menu)
{
$login = Piwik::getCurrentUserLogin();
$user = APIUsersManager::getInstance()->getUser($login);
if (!empty($user['alias'])) {
$login = $user['alias'];
}
if (Plugin\Manager::getInstance()->isPluginActivated('Feedback')) {
$menu->registerMenuIcon('General_Help', 'icon-help');
$menu->addItem('General_Help', null, array('module' => 'Feedback', 'action' => 'index'), $order = 990, Piwik::translate('General_Help'));
}
$menu->registerMenuIcon($login, 'icon-user');
if (Piwik::isUserIsAnonymous()) {
if (Plugin\Manager::getInstance()->isPluginActivated('ScheduledReports')) {
$menu->addItem($login, null, array('module' => 'ScheduledReports', 'action' => 'index'), 970, Piwik::translate('ScheduledReports_PersonalEmailReports'));
} else {
$menu->addItem($login, null, array('module' => 'API', 'action' => 'listAllAPI'), 970, Piwik::translate('API_ReportingApiReference'));
}
} else {
$tooltip = sprintf('%s: %s', Piwik::translate('UsersManager_PersonalSettings'), $login);
$menu->addItem($login, null, array('module' => 'UsersManager', 'action' => 'userSettings'), 970, $tooltip);
}
$module = $this->getLoginModule();
if (Piwik::isUserIsAnonymous()) {
$menu->registerMenuIcon('Login_LogIn', 'icon-sign-in');
$menu->addItem('Login_LogIn', null, array('module' => $module, 'action' => false), 1000, Piwik::translate('Login_LogIn'));
} else {
$menu->registerMenuIcon('General_Logout', 'icon-sign-out');
$menu->addItem('General_Logout', null, array('module' => $module, 'action' => 'logout', 'idSite' => null), 1000, Piwik::translate('General_Logout'));
}
}
示例3: recordUserSettings
/**
* Checks if the provided CURRENT password is correct and calls the parent
* class function if so. Otherwise provides error message.
*
* @see the parent class function for parameters and return value
*/
public function recordUserSettings()
{
try {
$passwordCurrent = Common::getRequestvar('passwordCurrent', false);
$passwordCurrent = Crypto::decrypt($passwordCurrent);
// Note: Compare loosely, so both, "" (password input empty; forms send strings)
// and "password input not sent" are covered - see
// https://secure.php.net/manual/en/types.comparisons.php
if ($passwordCurrent != "") {
$userName = Piwik::getCurrentUserLogin();
// gets username as string or "anonymous"
// see Piwik\Plugins\Login\Auth for used password hash function
// (in setPassword()) and access to hashed password (in getTokenAuthSecret())
if ($userName != 'anonymous') {
$model = new Model();
$user = $model->getUser($userName);
if (UsersManagerEncrypted::getPasswordHash($passwordCurrent) === $user['password']) {
$toReturn = parent::recordUserSettings();
} else {
throw new Exception(Piwik::translate('UsersManagerEncrypted_CurrentPasswordIncorrect'));
}
} else {
throw new Exception(Piwik::translate('UsersManagerEncrypted_UserNotAuthenticated'));
}
} else {
throw new Exception(Piwik::translate('UsersManagerEncrypted_CurrentPasswordNotProvided'));
}
} catch (Exception $e) {
$response = new ResponseBuilder(Common::getRequestVar('format'));
$toReturn = $response->getResponseException($e);
}
return $toReturn;
}
示例4: configureTopMenu
public function configureTopMenu(MenuTop $menu)
{
$login = Piwik::getCurrentUserLogin();
$user = APIUsersManager::getInstance()->getUser($login);
if (!empty($user['alias'])) {
$login = $user['alias'];
}
if (Plugin\Manager::getInstance()->isPluginActivated('Feedback')) {
$menu->addItem('General_Help', null, array('module' => 'Feedback', 'action' => 'index'));
}
if (Piwik::isUserIsAnonymous()) {
if (Plugin\Manager::getInstance()->isPluginActivated('Feedback')) {
$menu->addItem($login, null, array('module' => 'Feedback', 'action' => 'index'), 998);
} else {
$menu->addItem($login, null, array('module' => 'API', 'action' => 'listAllAPI'), 998);
}
} else {
$menu->addItem($login, null, array('module' => 'UsersManager', 'action' => 'userSettings'), 998);
}
$module = $this->getLoginModule();
if (Piwik::isUserIsAnonymous()) {
$menu->addItem('Login_LogIn', null, array('module' => $module, 'action' => false), 999);
} else {
$menu->addItem('General_Logout', null, array('module' => $module, 'action' => 'logout', 'idSite' => null), 999);
}
}
示例5: makeSetting
/**
* Creates a new user setting.
*
* Settings will be displayed in the UI depending on the order of `makeSetting` calls. This means you can define
* the order of the displayed settings by calling makeSetting first for more important settings.
*
* @param string $name The name of the setting that shall be created
* @param mixed $defaultValue The default value for this setting. Note the value will not be converted to the
* specified type.
* @param string $type The PHP internal type the value of this setting should have.
* Use one of FieldConfig::TYPE_* constancts
* @param \Closure $fieldConfigCallback A callback method to configure the field that shall be displayed in the
* UI to define the value for this setting
* @return UserSetting Returns an instance of the created measurable setting.
*/
protected function makeSetting($name, $defaultValue, $type, $configureCallback)
{
$userLogin = Piwik::getCurrentUserLogin();
$setting = new UserSetting($name, $defaultValue, $type, $this->pluginName, $userLogin);
$setting->setConfigureCallback($configureCallback);
$this->addSetting($setting);
return $setting;
}
示例6: getUserDashboards
/**
* Get all dashboards which a user has created.
* @return \array[]
*/
private function getUserDashboards()
{
$userLogin = Piwik::getCurrentUserLogin();
$userDashboards = $this->dashboard->getAllDashboards($userLogin);
$dashboards = array();
foreach ($userDashboards as $userDashboard) {
$widgets = $this->getVisibleWidgetsWithinDashboard($userDashboard);
$dashboards[] = $this->buildDashboard($userDashboard, $widgets);
}
return $dashboards;
}
示例7: getUserDashboards
/**
* Get all dashboards which a user has created.
*
* @return array[]
*/
private function getUserDashboards()
{
$userLogin = Piwik::getCurrentUserLogin();
$userDashboards = $this->dashboard->getAllDashboards($userLogin);
$dashboards = array();
foreach ($userDashboards as $userDashboard) {
if ($this->hasDashboardColumns($userDashboard)) {
$widgets = $this->getExistingWidgetsWithinDashboard($userDashboard);
$dashboards[] = $this->buildDashboard($userDashboard, $widgets);
}
}
return $dashboards;
}
示例8: getDefaultPeriod
/**
* Returns default period type for Piwik reports.
*
* @return string `'day'`, `'week'`, `'month'`, `'year'` or `'range'`
* @api
*/
public function getDefaultPeriod()
{
$userSettingsDate = APIUsersManager::getInstance()->getUserPreference(Piwik::getCurrentUserLogin(), APIUsersManager::PREFERENCE_DEFAULT_REPORT_DATE);
if ($userSettingsDate === false) {
return Config::getInstance()->General['default_period'];
}
if (in_array($userSettingsDate, array('today', 'yesterday'))) {
return 'day';
}
if (strpos($userSettingsDate, 'last') === 0 || strpos($userSettingsDate, 'previous') === 0) {
return 'range';
}
return $userSettingsDate;
}
示例9: configureReportingMenu
public function configureReportingMenu(MenuReporting $menu)
{
$menu->addItem('Dashboard_Dashboard', '', $this->urlForAction('embeddedIndex', array('idDashboard' => 1)), 5);
if (!Piwik::isUserIsAnonymous()) {
$login = Piwik::getCurrentUserLogin();
$dashboard = new Dashboard();
$dashboards = $dashboard->getAllDashboards($login);
$pos = 0;
foreach ($dashboards as $dashboard) {
$menu->addItem('Dashboard_Dashboard', $dashboard['name'], $this->urlForAction('embeddedIndex', array('idDashboard' => $dashboard['iddashboard'])), $pos);
$pos++;
}
}
}
示例10: configureReportingMenu
public function configureReportingMenu(MenuReporting $menu)
{
$menu->add('Dashboard_Dashboard', '', array('module' => 'Dashboard', 'action' => 'embeddedIndex', 'idDashboard' => 1), true, 5);
if (!Piwik::isUserIsAnonymous()) {
$login = Piwik::getCurrentUserLogin();
$dashboard = new Dashboard();
$dashboards = $dashboard->getAllDashboards($login);
$pos = 0;
foreach ($dashboards as $dashboard) {
$menu->add('Dashboard_Dashboard', $dashboard['name'], array('module' => 'Dashboard', 'action' => 'embeddedIndex', 'idDashboard' => $dashboard['iddashboard']), true, $pos);
$pos++;
}
}
}
示例11: createAlert
private function createAlert($name, $period, $idSites, $metric, $report, $login = false)
{
if (false === $login) {
$login = Piwik::getCurrentUserLogin();
}
$emails = array('test1@example.com', 'test2@example.com');
$phoneNumbers = array('0123456789');
$reportMatched = '';
if ('VisitsSummary_get' != $report) {
$reportMatched = 'Piwik';
}
$model = new Model();
$model->createAlert($name, $idSites, $login, $period, 0, $emails, $phoneNumbers, $metric, 'less_than', 5, $comparedTo = 1, $report, 'matches_exactly', $reportMatched);
}
示例12: redirectToCoreHomeIndex
function redirectToCoreHomeIndex()
{
$defaultReport = API::getInstance()->getUserPreference(Piwik::getCurrentUserLogin(), API::PREFERENCE_DEFAULT_REPORT);
$module = 'CoreHome';
$action = 'index';
// User preference: default report to load is the All Websites dashboard
if ($defaultReport == 'MultiSites' && \Piwik\Plugin\Manager::getInstance()->isPluginActivated('MultiSites')) {
$module = 'MultiSites';
}
if ($defaultReport == Piwik::getLoginPluginName()) {
$module = Piwik::getLoginPluginName();
}
$idSite = Common::getRequestVar('idSite', false, 'int');
parent::redirectToIndex($module, $action, $idSite);
}
示例13: buildUserSettingName
private function buildUserSettingName($name, $userLogin = null)
{
if (empty($userLogin)) {
$userLogin = Piwik::getCurrentUserLogin();
}
// the asterisk tag is indeed important here and better than an underscore. Imagine a plugin has the settings
// "api_password" and "api". A user having the login "_password" could otherwise under circumstances change the
// setting for "api" although he is not allowed to. It is not so important at the moment because only alNum is
// currently allowed as a name this might change in the future.
$appendix = '#' . $userLogin . '#';
if (Common::stringEndsWith($name, $appendix)) {
return $name;
}
return $name . $appendix;
}
示例14: saveLanguage
/**
* anonymous = in the session
* authenticated user = in the session and in DB
*/
public function saveLanguage()
{
$language = Common::getRequestVar('language');
// Prevent CSRF only when piwik is not installed yet (During install user can change language)
if (DbHelper::isInstalled()) {
$this->checkTokenInUrl();
}
LanguagesManager::setLanguageForSession($language);
if (\Piwik\Registry::isRegistered('access')) {
$currentUser = Piwik::getCurrentUserLogin();
if ($currentUser && $currentUser !== 'anonymous') {
API::getInstance()->setLanguageForUser($currentUser, $language);
}
}
Url::redirectToReferrer();
}
示例15: addPiwikClientTracking
public function addPiwikClientTracking(&$out)
{
$settings = StaticContainer::get('Piwik\\Plugins\\AnonymousPiwikUsageMeasurement\\Settings');
$config = array('targets' => array(), 'visitorCustomVariables' => array(), 'trackingDomain' => self::TRACKING_DOMAIN, 'exampleDomain' => self::EXAMPLE_DOMAIN, 'userId' => Piwik::getCurrentUserLogin());
if (Piwik::isUserIsAnonymous() || !$settings->canUserOptOut->getValue() || !$settings->userTrackingEnabled->isReadableByCurrentUser() || $settings->userTrackingEnabled->getValue()) {
// an anonymous user is currently always tracked, an anonymous user would not have permission to read
// this user setting. The `isUserIsAnonymous()` check is not needed but there to improve performance
// in case user is anonymous. Then we avoid checking whether user has access to any sites which can be slow
// a user not having any view permission is also always tracked so far as such a user is not allowed to read
// this setting
$targets = StaticContainer::get('Piwik\\Plugins\\AnonymousPiwikUsageMeasurement\\Tracker\\Targets');
$customVars = StaticContainer::get('Piwik\\Plugins\\AnonymousPiwikUsageMeasurement\\Tracker\\CustomVariables');
$config['targets'] = $targets->getTargets();
$config['visitorCustomVariables'] = $customVars->getClientVisitCustomVariables();
}
$out .= "\nvar piwikUsageTracking = " . json_encode($config) . ";\n";
}
开发者ID:andrzejewsky,项目名称:plugin-AnonymousPiwikUsageMeasurement,代码行数:17,代码来源:AnonymousPiwikUsageMeasurement.php