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


PHP API::getInstance方法代码示例

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


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

示例1: authenticate

 /**
  * Authenticates user
  *
  * @return AuthResult
  */
 public function authenticate()
 {
     if (!empty($this->md5Password)) {
         // favor authenticating by password
         $this->token_auth = UsersManagerAPI::getInstance()->getTokenAuth($this->login, $this->getTokenAuthSecret());
     }
     if (is_null($this->login)) {
         $model = new Model();
         $user = $model->getUserByTokenAuth($this->token_auth);
         if (!empty($user['login'])) {
             $code = $user['superuser_access'] ? AuthResult::SUCCESS_SUPERUSER_AUTH_CODE : AuthResult::SUCCESS;
             return new AuthResult($code, $user['login'], $this->token_auth);
         }
     } else {
         if (!empty($this->login)) {
             $model = new Model();
             $user = $model->getUser($this->login);
             if (!empty($user['token_auth']) && (SessionInitializer::getHashTokenAuth($this->login, $user['token_auth']) === $this->token_auth || $user['token_auth'] === $this->token_auth)) {
                 $this->setTokenAuth($user['token_auth']);
                 $code = !empty($user['superuser_access']) ? AuthResult::SUCCESS_SUPERUSER_AUTH_CODE : AuthResult::SUCCESS;
                 return new AuthResult($code, $this->login, $user['token_auth']);
             }
         }
     }
     return new AuthResult(AuthResult::FAILURE, $this->login, $this->token_auth);
 }
开发者ID:CaptainSharf,项目名称:SSAD_Project,代码行数:31,代码来源:Auth.php

示例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'));
     }
 }
开发者ID:dorelljames,项目名称:piwik,代码行数:31,代码来源:Menu.php

示例3: __construct

 public function __construct($name = null)
 {
     parent::__construct($name);
     $this->loginLdapAPI = LoginLdapAPI::getInstance();
     $this->ldapUsers = LdapUsers::makeConfigured();
     $this->usersManagerAPI = UsersManagerAPI::getInstance();
 }
开发者ID:heiglandreas,项目名称:plugin-LoginLdap,代码行数:7,代码来源:SynchronizeUsers.php

示例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);
     }
 }
开发者ID:CaptainSharf,项目名称:SSAD_Project,代码行数:26,代码来源:Menu.php

示例5: migrateConfigSuperUserToDb

 private static function migrateConfigSuperUserToDb()
 {
     $config = Config::getInstance();
     if (!$config->existsLocalConfig()) {
         return;
     }
     try {
         $superUser = $config->superuser;
     } catch (\Exception $e) {
         $superUser = null;
     }
     if (!empty($superUser['bridge']) || empty($superUser) || empty($superUser['login'])) {
         // there is a super user which is not from the config but from the bridge, that means we already have
         // a super user in the database
         return;
     }
     $userApi = UsersManagerApi::getInstance();
     try {
         Db::get()->insert(Common::prefixTable('user'), array('login' => $superUser['login'], 'password' => $superUser['password'], 'alias' => $superUser['login'], 'email' => $superUser['email'], 'token_auth' => $userApi->getTokenAuth($superUser['login'], $superUser['password']), 'date_registered' => Date::now()->getDatetime(), 'superuser_access' => 1));
     } catch (\Exception $e) {
         echo "There was an issue, but we proceed: " . $e->getMessage();
     }
     if (array_key_exists('salt', $superUser)) {
         $salt = $superUser['salt'];
     } else {
         $salt = Common::generateUniqId();
     }
     $config->General['salt'] = $salt;
     $config->superuser = array();
     $config->forceSave();
 }
开发者ID:piwik,项目名称:piwik,代码行数:31,代码来源:2.0.4-b5.php

示例6: test_authenticateRequests_shouldThrowAnException_IfTokenIsNotValid

 /**
  * @expectedException \Exception
  * @expectedExceptionMessage token_auth specified does not have Admin permission for idsite=1
  */
 public function test_authenticateRequests_shouldThrowAnException_IfTokenIsNotValid()
 {
     $dummyToken = API::getInstance()->getTokenAuth('test', UsersManager::getPasswordHash('2'));
     $superUserToken = $this->getSuperUserToken();
     $requests = array($this->buildDummyRequest($superUserToken), $this->buildDummyRequest($dummyToken));
     $this->requests->authenticateRequests($requests);
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:11,代码来源:RequestsTest.php

示例7: configureAdminMenu

 public function configureAdminMenu(MenuAdmin $menu)
 {
     if (Piwik::isUserHasSomeAdminAccess()) {
         $menu->addManageItem('UsersManager_MenuUsers', $this->urlForAction('index'), $order = 2);
     }
     if (Piwik::hasUserSuperUserAccess() && API::getInstance()->getSitesAccessFromUser('anonymous')) {
         $menu->addSettingsItem('UsersManager_AnonymousUser', $this->urlForAction('anonymousSettings'), $order = 20);
     }
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:9,代码来源:Menu.php

示例8: setUp

 public function setUp()
 {
     parent::setUp();
     $this->api = API::getInstance();
     FakeAccess::$superUser = true;
     Fixture::createWebsite('2014-01-01 00:00:00');
     Fixture::createWebsite('2014-01-01 00:00:00');
     Fixture::createWebsite('2014-01-01 00:00:00');
     $this->api->addUser($this->login, 'password', 'userlogin@password.de');
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:10,代码来源:APITest.php

示例9: recordAdminUsersInCache

 /**
  * Hooks when a website tracker cache is flushed (website/user updated, cache deleted, or empty cache)
  * Will record in the tracker config file the list of Admin token_auth for this website. This
  * will be used when the Tracking API is used with setIp(), setForceDateTime(), setVisitorId(), etc.
  *
  * @param $attributes
  * @param $idSite
  * @return void
  */
 public function recordAdminUsersInCache(&$attributes, $idSite)
 {
     // add the 'hosts' entry in the website array
     $users = API::getInstance()->getUsersWithSiteAccess($idSite, 'admin');
     $tokens = array();
     foreach ($users as $user) {
         $tokens[] = $user['token_auth'];
     }
     $attributes['admin_token_auth'] = $tokens;
 }
开发者ID:dorelljames,项目名称:piwik,代码行数:19,代码来源:UsersManager.php

示例10: setUpBeforeClass

 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     DbHelper::createAnonymousUser();
     // the api_internal_call.php uses idSite=7, so we create 7 sites
     for ($i = 0; $i != 7; ++$i) {
         Fixture::createWebsite("2011-01-01 00:00:00", $ecommerce = 1, $siteName = "Site #{$i}");
     }
     // the script uses anonymous token auth, so give the anonymous user access
     \Piwik\Plugins\UsersManager\API::getInstance()->setUserAccess('anonymous', 'view', array(7));
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:11,代码来源:ExternalScriptsTest.php

示例11: setUp

 public function setUp()
 {
     parent::setUp();
     self::updateDatabase();
     // make sure site has an early enough creation date (for period selector tests)
     Db::get()->update(Common::prefixTable("site"), array('ts_created' => '2011-01-01'), "idsite = 1");
     $this->addOverlayVisits();
     $this->addNewSitesForSiteSelector();
     DbHelper::createAnonymousUser();
     UsersManagerAPI::getInstance()->setSuperUserAccess('superUserLogin', true);
     SitesManagerAPI::getInstance()->updateSite(1, null, null, true);
 }
开发者ID:TensorWrenchOSS,项目名称:piwik,代码行数:12,代码来源:UITestFixture.php

示例12: setUp

 public function setUp()
 {
     parent::setUp();
     // make sure templates will be found
     Plugin\Manager::getInstance()->loadPlugin('CustomAlerts');
     Plugin\Manager::getInstance()->loadPlugin('Morpheus');
     Translate::loadAllTranslations();
     \Piwik\Plugins\UsersManager\API::getInstance()->addUser('login1', 'p2kK2msAw1', 'test1@example.com');
     \Piwik\Plugins\UsersManager\API::getInstance()->addUser('login2', 'p2kK2msAw1', 'test2@example.com');
     \Piwik\Plugins\UsersManager\API::getInstance()->addUser('login3', 'p2kK2msAw1', 'test3@example.com');
     $this->notifier = new CustomNotifier();
 }
开发者ID:andrzejewsky,项目名称:plugin-CustomAlerts,代码行数:12,代码来源:NotifierTest.php

示例13: sendEmailNotification

 /**
  * Send an email notification to all super users.
  *
  * @param $subject
  * @param $message
  */
 protected function sendEmailNotification($subject, $message)
 {
     $superUsers = UsersManagerApi::getInstance()->getUsersHavingSuperUserAccess();
     foreach ($superUsers as $superUser) {
         $mail = new Mail();
         $mail->setDefaultFromPiwik();
         $mail->addTo($superUser['email']);
         $mail->setSubject($subject);
         $mail->setBodyText($message);
         $mail->send();
     }
 }
开发者ID:TensorWrenchOSS,项目名称:piwik,代码行数:18,代码来源:UpdateCommunication.php

示例14: setUp

 public function setUp()
 {
     parent::setUp();
     $this->api = API::getInstance();
     $pseudoMockAccess = new FakeAccess();
     FakeAccess::$superUser = true;
     Access::setSingletonInstance($pseudoMockAccess);
     Fixture::createWebsite('2014-01-01 00:00:00');
     Fixture::createWebsite('2014-01-01 00:00:00');
     Fixture::createWebsite('2014-01-01 00:00:00');
     $this->api->addUser('userLogin', 'password', 'userlogin@password.de');
 }
开发者ID:a4tunado,项目名称:piwik,代码行数:12,代码来源:APITest.php

示例15: configureAdminMenu

 public function configureAdminMenu(MenuAdmin $menu)
 {
     if (Piwik::isUserHasSomeAdminAccess()) {
         $menu->addSystemItem('UsersManager_MenuUsers', $this->urlForAction('index'), $order = 15);
     }
     if (Piwik::hasUserSuperUserAccess() && API::getInstance()->getSitesAccessFromUser('anonymous')) {
         $menu->addSystemItem('UsersManager_AnonymousUser', $this->urlForAction('anonymousSettings'), $order = 16);
     }
     if (!Piwik::isUserIsAnonymous()) {
         $menu->addItem('UsersManager_MenuPersonal', 'General_Settings', $this->urlForAction('userSettings'), 0);
     }
 }
开发者ID:piwik,项目名称:piwik,代码行数:12,代码来源:Menu.php


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