diff options
author | Thomas Steur <thomas.steur@gmail.com> | 2015-12-10 00:50:07 +0300 |
---|---|---|
committer | Thomas Steur <thomas.steur@gmail.com> | 2015-12-10 00:50:07 +0300 |
commit | ebced800c0184f5ce93663afab6b0337c3755cbb (patch) | |
tree | fb26c2506d37586ff0d38fb902d63d17701bd883 /plugins/MobileMessaging | |
parent | 3d26af780d8fe0e4f7c5824a88b95c4a0d0d25d7 (diff) | |
parent | db36ca384809ea36457a465a3b6d1ecf951b0e26 (diff) |
Merge master into "3.0"
Conflicts:
.travis.yml
CHANGELOG.md
core/Plugin/ControllerAdmin.php
core/Version.php
core/testMinimumPhpVersion.php
plugins/API/API.php
plugins/Actions/Reports/GetPageUrls.php
plugins/AnonymousPiwikUsageMeasurement
plugins/CoreHome/CoreHome.php
plugins/CoreHome/templates/_menu.twig
plugins/CoreVisualizations/javascripts/jqplotEvolutionGraph.js
plugins/CustomVariables/tests/System/expected/test_CustomVariablesSystemTest__CustomVariables.getCustomVariables_day.xml
plugins/Goals/Controller.php
tests/PHPUnit/Fixtures/ManyVisitsWithGeoIP.php
tests/PHPUnit/Integration/Plugin/ManagerTest.php
tests/PHPUnit/System/expected/test_FlattenReports__CustomVariables.getCustomVariables_day.xml
tests/PHPUnit/System/expected/test_TwoVisitors_twoWebsites_differentDays_scheduled_report_in_html_tables_only__ScheduledReports.generateReport_month.original.html
tests/PHPUnit/System/expected/test_apiGetReportMetadata__API.getSegmentsMetadata.xml
tests/PHPUnit/System/expected/test_ecommerceOrderWithItems_scheduled_report_in_html_tables_only__ScheduledReports.generateReport_week.original.html
tests/PHPUnit/System/expected/test_periodIsRange_dateIsLastN_MetadataAndNormalAPI__CustomVariables.getCustomVariables_range.xml
tests/PHPUnit/System/expected/test_periodIsRange_dateIsLastN_MetadataAndNormalAPI_pagesegment__CustomVariables.getCustomVariables_range.xml
tests/PHPUnit/System/expected/test_reportLimiting__CustomVariables.getCustomVariables_day.xml
tests/PHPUnit/System/expected/test_reportLimiting_rankingQuery__CustomVariables.getCustomVariables_day.xml
tests/PHPUnit/System/expected/test_twoVisitsWithCustomVariables_segmentMatchALL_noGoalData__CustomVariables.getCustomVariables_day.xml
tests/PHPUnit/System/expected/test_twoVisitsWithCustomVariables_segmentMatchALL_noGoalData__CustomVariables.getCustomVariables_week.xml
tests/PHPUnit/System/expected/test_twoVisitsWithCustomVariables_segmentMatchVisitorType__CustomVariables.getCustomVariables_day.xml
tests/PHPUnit/System/expected/test_twoVisitsWithCustomVariables_segmentMatchVisitorType__CustomVariables.getCustomVariables_week.xml
tests/UI/expected-ui-screenshots
tests/UI/specs/Overlay_spec.js
tests/UI/specs/UIIntegration_spec.js
Diffstat (limited to 'plugins/MobileMessaging')
-rw-r--r-- | plugins/MobileMessaging/API.php | 16 | ||||
-rw-r--r-- | plugins/MobileMessaging/Controller.php | 7 | ||||
-rw-r--r-- | plugins/MobileMessaging/SMSProvider.php | 151 | ||||
-rw-r--r-- | plugins/MobileMessaging/SMSProvider/Clockwork.php | 24 | ||||
-rw-r--r-- | plugins/MobileMessaging/SMSProvider/Development.php | 17 | ||||
-rw-r--r-- | plugins/MobileMessaging/SMSProvider/StubbedProvider.php | 16 | ||||
-rw-r--r-- | plugins/MobileMessaging/lang/cs.json | 16 | ||||
-rw-r--r-- | plugins/MobileMessaging/lang/tr.json | 22 |
8 files changed, 187 insertions, 82 deletions
diff --git a/plugins/MobileMessaging/API.php b/plugins/MobileMessaging/API.php index aaf30e6a64..345c633b15 100644 --- a/plugins/MobileMessaging/API.php +++ b/plugins/MobileMessaging/API.php @@ -8,7 +8,6 @@ */ namespace Piwik\Plugins\MobileMessaging; -use Piwik\Common; use Piwik\Option; use Piwik\Piwik; use Piwik\Plugins\MobileMessaging\SMSProvider; @@ -27,15 +26,6 @@ class API extends \Piwik\Plugin\API const SMS_FROM = 'Piwik'; /** - * @param string $provider - * @return SMSProvider - */ - private static function getSMSProviderInstance($provider) - { - return SMSProvider::factory($provider); - } - - /** * determine if SMS API credential are available for the current user * * @return bool true if SMS API credential are available for the current user @@ -83,7 +73,7 @@ class API extends \Piwik\Plugin\API { $this->checkCredentialManagementRights(); - $smsProviderInstance = self::getSMSProviderInstance($provider); + $smsProviderInstance = SMSProvider::factory($provider); $smsProviderInstance->verifyCredential($apiKey); $settings = $this->getCredentialManagerSettings(); @@ -160,7 +150,7 @@ class API extends \Piwik\Plugin\API Piwik::checkUserIsNotAnonymous(); $credential = $this->getSMSAPICredential(); - $SMSProvider = self::getSMSProviderInstance($credential[MobileMessaging::PROVIDER_OPTION]); + $SMSProvider = SMSProvider::factory($credential[MobileMessaging::PROVIDER_OPTION]); $SMSProvider->sendSMS( $credential[MobileMessaging::API_KEY_OPTION], $content, @@ -183,7 +173,7 @@ class API extends \Piwik\Plugin\API $this->checkCredentialManagementRights(); $credential = $this->getSMSAPICredential(); - $SMSProvider = self::getSMSProviderInstance($credential[MobileMessaging::PROVIDER_OPTION]); + $SMSProvider = SMSProvider::factory($credential[MobileMessaging::PROVIDER_OPTION]); return $SMSProvider->getCreditLeft( $credential[MobileMessaging::API_KEY_OPTION] ); diff --git a/plugins/MobileMessaging/Controller.php b/plugins/MobileMessaging/Controller.php index 2bb6f8d5f5..7ba976c67e 100644 --- a/plugins/MobileMessaging/Controller.php +++ b/plugins/MobileMessaging/Controller.php @@ -94,7 +94,12 @@ class Controller extends ControllerAdmin $view->creditLeft = $mobileMessagingAPI->getCreditLeft(); } - $view->smsProviders = SMSProvider::getAvailableSMSProviders(); + $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(); diff --git a/plugins/MobileMessaging/SMSProvider.php b/plugins/MobileMessaging/SMSProvider.php index 1711bfafed..14aec1bb24 100644 --- a/plugins/MobileMessaging/SMSProvider.php +++ b/plugins/MobileMessaging/SMSProvider.php @@ -8,63 +8,120 @@ */ namespace Piwik\Plugins\MobileMessaging; -use Exception; -use Piwik\Development; +use Piwik\Container\StaticContainer; +use Piwik\Plugin; use Piwik\Piwik; -use Piwik\BaseFactory; /** - * The SMSProvider abstract class is used as a base class for SMS provider implementations. + * The SMSProvider abstract class is used as a base class for SMS provider implementations. To create your own custom + * SMSProvider extend this class and implement the methods to send text messages. The class needs to be placed in a + * `SMSProvider` directory of your plugin. * + * @api */ -abstract class SMSProvider extends BaseFactory +abstract class SMSProvider { const MAX_GSM_CHARS_IN_ONE_UNIQUE_SMS = 160; const MAX_GSM_CHARS_IN_ONE_CONCATENATED_SMS = 153; const MAX_UCS2_CHARS_IN_ONE_UNIQUE_SMS = 70; const MAX_UCS2_CHARS_IN_ONE_CONCATENATED_SMS = 67; - protected static $availableSMSProviders = array( - 'Clockwork' => 'You can use <a target="_blank" href="?module=Proxy&action=redirect&url=http://www.clockworksms.com/platforms/piwik/"><img src="plugins/MobileMessaging/images/Clockwork.png"/></a> to send SMS Reports from Piwik.<br/> - <ul> - <li> First, <a target="_blank" href="?module=Proxy&action=redirect&url=http://www.clockworksms.com/platforms/piwik/">get an API Key from Clockwork</a> (Signup is free!) - </li><li> Enter your Clockwork API Key on this page. </li> - </ul> - <br/><em>About Clockwork: </em><ul> - <li>Clockwork gives you fast, reliable high quality worldwide SMS delivery, over 450 networks in every corner of the globe. - </li><li>Cost per SMS message is around ~0.08USD (0.06EUR). - </li><li>Most countries and networks are supported but we suggest you check the latest position on their coverage map <a target="_blank" href="?module=Proxy&action=redirect&url=http://www.clockworksms.com/sms-coverage/">here</a>. - </li> - </ul> - ', - ); - - protected static function getClassNameFromClassId($id) + /** + * Get the ID of the SMS Provider. Eg 'Clockwork' or 'FreeMobile' + * @return string + */ + abstract public function getId(); + + /** + * Get a description about the SMS Provider. For example who the SMS Provider is, instructions how the API Key + * needs to be set, and more. You may return HTML here for better formatting. + * + * @return string + */ + abstract public function getDescription(); + + /** + * Verify the SMS API credential. + * + * @param string $apiKey API Key + * @return bool true if SMS API Key is valid, false otherwise + */ + abstract public function verifyCredential($apiKey); + + /** + * Get the amount of remaining credits. + * + * @param string $apiKey API Key + * @return string remaining credits + */ + abstract public function getCreditLeft($apiKey); + + /** + * Actually send the given text message. This method should only send the text message, it should not trigger + * any notifications etc. + * + * @param string $apiKey + * @param string $smsText + * @param string $phoneNumber + * @param string $from + * @return bool true + */ + abstract public function sendSMS($apiKey, $smsText, $phoneNumber, $from); + + /** + * Defines whether the SMS Provider is available. If a certain provider should be used only be a limited + * range of users you can restrict the provider here. For example there is a Development SMS Provider that is only + * available when the development is actually enabled. You could also create a SMS Provider that is only available + * to Super Users etc. Usually this method does not have to be implemented by a SMS Provider. + * + * @return bool + */ + public function isAvailable() { - return __NAMESPACE__ . '\\SMSProvider\\' . $id; + return true; } - protected static function getInvalidClassIdExceptionMessage($id) + /** + * @param string $provider The name of the string + * @return SMSProvider + * @throws \Exception + * @ignore + */ + public static function factory($provider) { - return Piwik::translate('MobileMessaging_Exception_UnknownProvider', - array($id, implode(', ', array_keys(self::getAvailableSMSProviders()))) - ); + $providers = self::findAvailableSmsProviders(); + + if (!array_key_exists($provider, $providers)) { + throw new \Exception(Piwik::translate('MobileMessaging_Exception_UnknownProvider', + array($provider, implode(', ', array_keys($providers))) + )); + } + + return $providers[$provider]; } /** * Returns all available SMS Providers - * - * @return array + * + * @return SMSProvider[] + * @ignore */ - public static function getAvailableSMSProviders() + public static function findAvailableSmsProviders() { - $smsProviders = self::$availableSMSProviders; + /** @var SMSProvider[] $smsProviders */ + $smsProviders = Plugin\Manager::getInstance()->findMultipleComponents('SMSProvider', 'Piwik\Plugins\MobileMessaging\SMSProvider'); + + $providers = array(); - if (Development::isEnabled()) { - $smsProviders['Development'] = 'Development SMS Provider<br />All sent SMS will be displayed as Notification'; + foreach ($smsProviders as $provider) { + /** @var SMSProvider $provider */ + $provider = StaticContainer::get($provider); + if ($provider->isAvailable()) { + $providers[$provider->getId()] = $provider; + } } - return $smsProviders; + return $providers; } /** @@ -72,6 +129,7 @@ abstract class SMSProvider extends BaseFactory * * @param string $string * @return bool true if $string contains UCS2 characters + * @ignore */ public static function containsUCS2Characters($string) { @@ -94,6 +152,7 @@ abstract class SMSProvider extends BaseFactory * @param int $maximumNumberOfConcatenatedSMS * @param string $appendedString * @return string original $string or truncated $string appended with $appendedString + * @ignore */ public static function truncate($string, $maximumNumberOfConcatenatedSMS, $appendedString = 'MobileMessaging_SMS_Content_Too_Long') { @@ -150,30 +209,4 @@ abstract class SMSProvider extends BaseFactory $maxCharsInOneConcatenatedSMS * $maximumNumberOfConcatenatedSMS; } - /** - * verify the SMS API credential - * - * @param string $apiKey API Key - * @return bool true if SMS API credential are valid, false otherwise - */ - abstract public function verifyCredential($apiKey); - - /** - * get remaining credits - * - * @param string $apiKey API Key - * @return string remaining credits - */ - abstract public function getCreditLeft($apiKey); - - /** - * send SMS - * - * @param string $apiKey - * @param string $smsText - * @param string $phoneNumber - * @param string $from - * @return bool true - */ - abstract public function sendSMS($apiKey, $smsText, $phoneNumber, $from); } diff --git a/plugins/MobileMessaging/SMSProvider/Clockwork.php b/plugins/MobileMessaging/SMSProvider/Clockwork.php index 2ae8e95da4..50a7f0e50b 100644 --- a/plugins/MobileMessaging/SMSProvider/Clockwork.php +++ b/plugins/MobileMessaging/SMSProvider/Clockwork.php @@ -15,8 +15,9 @@ use Piwik\Plugins\MobileMessaging\APIException; use Piwik\Plugins\MobileMessaging\SMSProvider; require_once PIWIK_INCLUDE_PATH . "/plugins/MobileMessaging/APIException.php"; + /** - * + * @ignore */ class Clockwork extends SMSProvider { @@ -31,6 +32,27 @@ class Clockwork extends SMSProvider const MAXIMUM_FROM_LENGTH = 11; const MAXIMUM_CONCATENATED_SMS = 3; + public function getId() + { + return 'Clockwork'; + } + + public function getDescription() + { + return 'You can use <a target="_blank" href="?module=Proxy&action=redirect&url=http://www.clockworksms.com/platforms/piwik/"><img src="plugins/MobileMessaging/images/Clockwork.png"/></a> to send SMS Reports from Piwik.<br/> + <ul> + <li> First, <a target="_blank" href="?module=Proxy&action=redirect&url=http://www.clockworksms.com/platforms/piwik/">get an API Key from Clockwork</a> (Signup is free!) + </li><li> Enter your Clockwork API Key on this page. </li> + </ul> + <br/><em>About Clockwork: </em><ul> + <li>Clockwork gives you fast, reliable high quality worldwide SMS delivery, over 450 networks in every corner of the globe. + </li><li>Cost per SMS message is around ~0.08USD (0.06EUR). + </li><li>Most countries and networks are supported but we suggest you check the latest position on their coverage map <a target="_blank" href="?module=Proxy&action=redirect&url=http://www.clockworksms.com/sms-coverage/">here</a>. + </li> + </ul> + '; + } + public function verifyCredential($apiKey) { $this->getCreditLeft($apiKey); diff --git a/plugins/MobileMessaging/SMSProvider/Development.php b/plugins/MobileMessaging/SMSProvider/Development.php index ef6cbe951d..18cc57809a 100644 --- a/plugins/MobileMessaging/SMSProvider/Development.php +++ b/plugins/MobileMessaging/SMSProvider/Development.php @@ -10,14 +10,31 @@ namespace Piwik\Plugins\MobileMessaging\SMSProvider; use Piwik\Notification; use Piwik\Plugins\MobileMessaging\SMSProvider; +use Piwik\Development as PiwikDevelopment; /** * Used for development only * + * @ignore */ class Development extends SMSProvider { + public function getId() + { + return 'Development'; + } + + public function getDescription() + { + return 'Development SMS Provider<br />All sent SMS will be displayed as Notification'; + } + + public function isAvailable() + { + return PiwikDevelopment::isEnabled(); + } + public function verifyCredential($apiKey) { return true; diff --git a/plugins/MobileMessaging/SMSProvider/StubbedProvider.php b/plugins/MobileMessaging/SMSProvider/StubbedProvider.php index b9527a3b8d..8bda726a3e 100644 --- a/plugins/MobileMessaging/SMSProvider/StubbedProvider.php +++ b/plugins/MobileMessaging/SMSProvider/StubbedProvider.php @@ -13,10 +13,26 @@ use Piwik\Plugins\MobileMessaging\SMSProvider; /** * Used for testing * + * @ignore */ class StubbedProvider extends SMSProvider { + public function getId() + { + return 'StubbedProvider'; + } + + public function getDescription() + { + return 'Only during testing available'; + } + + public function isAvailable() + { + return defined('PIWIK_TEST_MODE') && PIWIK_TEST_MODE; + } + public function verifyCredential($apiKey) { return true; diff --git a/plugins/MobileMessaging/lang/cs.json b/plugins/MobileMessaging/lang/cs.json index efe1d113af..6b4d0ad68b 100644 --- a/plugins/MobileMessaging/lang/cs.json +++ b/plugins/MobileMessaging/lang/cs.json @@ -6,24 +6,24 @@ "MobileReport_NoPhoneNumbers": "Prosím aktivujte aspoň jedno telefonní číslo přejitím na", "MultiSites_Must_Be_Activated": "Pro vytváření SMS zpráv se statistikami povolte v Piwiku plugin MultiSites.", "PhoneNumbers": "Telefonní čísla", - "PluginDescription": "Vytvářejte a stahujte vlastní SMS hlášení a nechte si je zasílat do vašeho telefonu denně, týdnnebo ě měsíčně.", + "PluginDescription": "Vytvářejte a stahujte vlastní SMS hlášení a nechte si je zasílat do svého telefonu denně, týdně nebo měsíčně.", "Settings_APIKey": "Klíč k API", "Settings_CountryCode": "Kód země", - "Settings_CredentialNotProvided": "Než budete moct vytvářet a spravovat telefonní čísla, musíte připojit Piwik k vašemu SMS účtu výše.", - "Settings_CredentialNotProvidedByAdmin": "Než budete moct vytvářet a spravovat telefonní čísla, požádejte vašeho administrátora, aby připojil Piwik k SMS účtu.", + "Settings_CredentialNotProvided": "Než budete moci vytvářet a spravovat telefonní čísla, musíte připojit Piwik ke svému SMS účtu výše.", + "Settings_CredentialNotProvidedByAdmin": "Než budete moci vytvářet a spravovat telefonní čísla, požádejte svého administrátora, aby připojil Piwik k SMS účtu.", "Settings_CredentialProvided": ";Váš %s SMS účet je nastaven správně.", "Settings_DeleteAccountConfirm": "Opravdu chcete odstranit tento SMS účet?", "Settings_InvalidActivationCode": "Zadaný kód nebyl platný, prosím zkuste to znovu.", "Settings_LetUsersManageAPICredential": "Povolit uživatelům správu vlastních pověření API SMS účtů", "Settings_LetUsersManageAPICredential_No_Help": "Všichni uživatelé mohou přijímat hlášení prostřednictvím SMS a budou používat kredity vašeho účtu.", - "Settings_LetUsersManageAPICredential_Yes_Help": "Každý uživatel bude moct nastavit svůj SMS API účet an nebude používat váš kredit.", + "Settings_LetUsersManageAPICredential_Yes_Help": "Každý uživatel bude moci nastavit svůj SMS API účet a nebude používat váš kredit.", "Settings_ManagePhoneNumbers": "Spravovat telefonní čísla", "Settings_PhoneActivated": "Telefonní číslo ověřeno! Nyní můžete přijímat SMS se statistikami.", "Settings_PhoneNumber": "Telefonní číslo", "Settings_PhoneNumbers_Add": "Přidat nové telefonní číslo", "Settings_PhoneNumbers_CountryCode_Help": "Pokud nevíte telefonní kód vaší země, podívejte se zde", - "Settings_PhoneNumbers_Help": "Než budete moct přijímat SMS se statistikami, telefonní číslo musí být zadáno níže.", - "Settings_PhoneNumbers_HelpAdd": "Po stisknutí \"přidat\" bude na telefon odeslána SMS s kódem. Uživatel, který obdrží SMS by se měl přihlásit do Piwiku, kliknout na nastavení, pak na Mobilní zprávy a zadat kód. Poté bude moct dostávat statistiky do svého telefonu.", + "Settings_PhoneNumbers_Help": "Než budete moci přijímat SMS se statistikami, telefonní číslo musí být zadáno níže.", + "Settings_PhoneNumbers_HelpAdd": "Po stisknutí \"přidat\" bude na telefon odeslána SMS s kódem. Uživatel, který obdrží SMS by se měl přihlásit do Piwiku, kliknout na nastavení, pak na Mobilní zprávy a zadat kód. Poté bude moci dostávat statistiky do svého telefonu.", "Settings_PleaseSignUp": "Pokud chcetevytvářet SMS hlášení a dostávat krátké zprávy o statistikách do svého telefonu, zaregistrujte se na SMS API a zadejte svoje informace níže.", "Settings_SMSAPIAccount": "Správa SMS API účtu", "Settings_SMSProvider": "SMS Provider", @@ -34,8 +34,8 @@ "Settings_VerificationCodeJustSent": "Právě jsme na zadané telefonní číslo odeslali SMS s kódem. Zadejte ho výše a stiskněte \"ověřit\".", "SettingsMenu": "Mobilní zprávy", "SMS_Content_Too_Long": "[příliš dlouhé]", - "TopLinkTooltip": "Nechte si webové analýzi zasílat na e-mail nebo na váš mobilní telefon.", - "TopMenu": "Email & SMS Reporty", + "TopLinkTooltip": "Nechte si webové analýzy zasílat na email nebo na svůj mobilní telefon.", + "TopMenu": "Email a SMS reporty", "VerificationText": "Kód je %s. Pro ověření vašeh otelefonního čísla tento kód zkopírujte do formuláře přístupného na Piwik > %s > %s." } }
\ No newline at end of file diff --git a/plugins/MobileMessaging/lang/tr.json b/plugins/MobileMessaging/lang/tr.json new file mode 100644 index 0000000000..3a034272ba --- /dev/null +++ b/plugins/MobileMessaging/lang/tr.json @@ -0,0 +1,22 @@ +{ + "MobileMessaging": { + "PhoneNumbers": "Telefon Numaraları", + "Settings_APIKey": "API Anahtarı", + "Settings_CountryCode": "Ülke Kodu", + "Settings_DeleteAccountConfirm": "Bu SMS hesabını silmek istediğinizden emin misiniz?", + "Settings_InvalidActivationCode": "Girilen kod geçerli değil, lütfen tekrar deneyin.", + "Settings_ManagePhoneNumbers": "Telefon Numaralarını Yönet", + "Settings_PhoneActivated": "Telefon numarası doğrulandı! Artık istatistikleri SMS ile alabilirsiniz.", + "Settings_PhoneNumber": "Telefon Numarası", + "Settings_PhoneNumbers_Add": "Yeni telefon numarası ekle", + "Settings_PhoneNumbers_CountryCode_Help": "Telefon ülke kodunu bilmiyorsanız, buradan ülkelere bakabilirsiniz.", + "Settings_SMSAPIAccount": "SMS API Hesabını Yönet", + "Settings_SMSProvider": "SMS Sağlayıcı", + "Settings_ValidatePhoneNumber": "Onayla", + "Settings_VerificationCodeJustSent": "Biz az önce SMS ile numaranıza kod gönderdik: lütfen yukarıya kodu girin ve \"Onayla\" 'ya tıklayın.", + "SettingsMenu": "Mobil Mesajlaşma", + "SMS_Content_Too_Long": "[çok uzun]", + "TopLinkTooltip": "Web Analytics Raporlarını e-posta kutunuza veya cep telefonunuza teslim alın.", + "TopMenu": "E-posta ve SMS Raporları" + } +}
\ No newline at end of file |