Пример #1
0
 private function setManageVariables(View $view)
 {
     $view->isSuperUser = Piwik::hasUserSuperUserAccess();
     $mobileMessagingAPI = API::getInstance();
     $view->delegatedManagement = $mobileMessagingAPI->getDelegatedManagement();
     $view->credentialSupplied = $mobileMessagingAPI->areSMSAPICredentialProvided();
     $view->accountManagedByCurrentUser = $view->isSuperUser || $view->delegatedManagement;
     $view->strHelpAddPhone = $this->translator->translate('MobileMessaging_Settings_PhoneNumbers_HelpAdd', array($this->translator->translate('General_Settings'), $this->translator->translate('MobileMessaging_SettingsMenu')));
     $view->creditLeft = 0;
     $view->provider = '';
     if ($view->credentialSupplied && $view->accountManagedByCurrentUser) {
         $view->provider = $mobileMessagingAPI->getSMSProvider();
         $view->creditLeft = $mobileMessagingAPI->getCreditLeft();
     }
     $providers = array();
     foreach (SMSProvider::findAvailableSmsProviders() as $provider) {
         $providers[$provider->getId()] = $provider->getDescription();
     }
     $view->smsProviders = $providers;
     // construct the list of countries from the lang files
     $countries = array();
     foreach ($this->regionDataProvider->getCountryList() as $countryCode => $continentCode) {
         if (isset(CountryCallingCodes::$countryCallingCodes[$countryCode])) {
             $countries[$countryCode] = array('countryName' => \Piwik\Plugins\UserCountry\countryTranslate($countryCode), 'countryCallingCode' => CountryCallingCodes::$countryCallingCodes[$countryCode]);
         }
     }
     $view->countries = $countries;
     $view->defaultCountry = Common::getCountry(LanguagesManager::getLanguageCodeForCurrentUser(), true, IP::getIpFromHeader());
     $view->phoneNumbers = $mobileMessagingAPI->getPhoneNumbers();
     $this->setBasicVariablesView($view);
 }
Пример #2
0
 /**
  * @param string $provider
  * @return SMSProvider
  */
 private static function getSMSProviderInstance($provider)
 {
     return SMSProvider::factory($provider);
 }
Пример #3
0
 /**
  * @group Plugins
  *
  * @dataProvider getContainsUCS2CharactersTestCases
  */
 public function testContainsUCS2Characters($expected, $stringToTest)
 {
     $this->assertEquals($expected, SMSProvider::containsUCS2Characters($stringToTest));
 }
Пример #4
0
 /**
  * get remaining credit
  *
  * @return string remaining credit
  */
 public function getCreditLeft()
 {
     $this->checkCredentialManagementRights();
     $credential = $this->getSMSAPICredential();
     $SMSProvider = SMSProvider::factory($credential[MobileMessaging::PROVIDER_OPTION]);
     return $SMSProvider->getCreditLeft($credential[MobileMessaging::API_KEY_OPTION]);
 }