X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=windowsphonepush%2Fwindowsphonepush.php;h=033d2a64a04127844e668a5b654e7b2183f8e2b0;hb=9c9088069a349b7370c35bbc6dfd38b7f820b746;hp=66b23a7ccbc4ec4acce5eb6049900369c0da5ad1;hpb=27b60e003f92dd9f3aebbeddb34ebb905488ca82;p=friendica-addons.git diff --git a/windowsphonepush/windowsphonepush.php b/windowsphonepush/windowsphonepush.php index 66b23a7c..033d2a64 100644 --- a/windowsphonepush/windowsphonepush.php +++ b/windowsphonepush/windowsphonepush.php @@ -10,7 +10,7 @@ * Pre-requisite: Windows Phone mobile device (at least WP 7.0) * Friendica mobile app on Windows Phone * - * When plugin is installed, the system calls the plugin + * When addon is installed, the system calls the addon * name_install() function, located in 'addon/name/name.php', * where 'name' is the name of the addon. * If the addon is removed from the configuration list, the @@ -26,24 +26,26 @@ * count only unseen elements which are not type=activity (likes and dislikes not seen as new elements) */ use Friendica\App; +use Friendica\Core\Addon; +use Friendica\Core\L10n; use Friendica\Core\PConfig; use Friendica\Model\User; function windowsphonepush_install() { - /* Our plugin will attach in three places. + /* Our addon will attach in three places. * The first is within cron - so the push notifications will be * sent every 10 minutes (or whatever is set in crontab). */ - register_hook('cron', 'addon/windowsphonepush/windowsphonepush.php', 'windowsphonepush_cron'); + Addon::registerHook('cron', 'addon/windowsphonepush/windowsphonepush.php', 'windowsphonepush_cron'); - /* Then we'll attach into the plugin settings page, and also the + /* Then we'll attach into the addon settings page, and also the * settings post hook so that we can create and update - * user preferences. User shall be able to activate the plugin and + * user preferences. User shall be able to activate the addon and * define whether he allows pushing first characters of item text */ - register_hook('plugin_settings', 'addon/windowsphonepush/windowsphonepush.php', 'windowsphonepush_settings'); - register_hook('plugin_settings_post', 'addon/windowsphonepush/windowsphonepush.php', 'windowsphonepush_settings_post'); + Addon::registerHook('addon_settings', 'addon/windowsphonepush/windowsphonepush.php', 'windowsphonepush_settings'); + Addon::registerHook('addon_settings_post', 'addon/windowsphonepush/windowsphonepush.php', 'windowsphonepush_settings_post'); logger("installed windowsphonepush"); } @@ -53,9 +55,9 @@ function windowsphonepush_uninstall() /* uninstall unregisters any hooks created with register_hook * during install. Don't delete data in table `pconfig`. */ - unregister_hook('cron', 'addon/windowsphonepush/windowsphonepush.php', 'windowsphonepush_cron'); - unregister_hook('plugin_settings', 'addon/windowsphonepush/windowsphonepush.php', 'windowsphonepush_settings'); - unregister_hook('plugin_settings_post', 'addon/windowsphonepush/windowsphonepush.php', 'windowsphonepush_settings_post'); + Addon::unregisterHook('cron', 'addon/windowsphonepush/windowsphonepush.php', 'windowsphonepush_cron'); + Addon::unregisterHook('addon_settings', 'addon/windowsphonepush/windowsphonepush.php', 'windowsphonepush_settings'); + Addon::unregisterHook('addon_settings_post', 'addon/windowsphonepush/windowsphonepush.php', 'windowsphonepush_settings_post'); logger("removed windowsphonepush"); } @@ -85,10 +87,10 @@ function windowsphonepush_settings_post($a, $post) PConfig::set(local_user(), 'windowsphonepush', 'senditemtext', intval($_POST['windowsphonepush-senditemtext'])); - info(t('WindowsPhonePush settings updated.') . EOL); + info(L10n::t('WindowsPhonePush settings updated.') . EOL); } -/* Called from the Plugin Setting form. +/* Called from the Addon Setting form. * Add our own settings info to the page. */ function windowsphonepush_settings(&$a, &$s) @@ -111,20 +113,20 @@ function windowsphonepush_settings(&$a, &$s) /* Add some HTML to the existing form */ $s .= '
'; - $s .= '

' . t('WindowsPhonePush Settings') . '

'; + $s .= '

' . L10n::t('WindowsPhonePush Settings') . '

'; $s .= '
'; - $s .= ''; + $s .= ''; $s .= ''; $s .= '
'; $s .= '
'; - $s .= ''; + $s .= ''; $s .= ''; $s .= '
'; /* provide a submit button - enable und senditemtext can be changed by the user */ - $s .= '
'; + $s .= '
'; /* provide further read-only information concerning the addon (useful for */ $s .= '
'; @@ -135,12 +137,12 @@ function windowsphonepush_settings(&$a, &$s) return; } -/* Cron function used to regularly check all users on the server with active windowsphonepushplugin and send +/* Cron function used to regularly check all users on the server with active windowsphonepushaddon and send * notifications to the Microsoft servers and consequently to the Windows Phone device */ function windowsphonepush_cron() { - // retrieve all UID's for which the plugin windowsphonepush is enabled and loop through every user + // retrieve all UID's for which the addon windowsphonepush is enabled and loop through every user $r = q("SELECT * FROM `pconfig` WHERE `cat` = 'windowsphonepush' AND `k` = 'enable' AND `v` = 1"); if (count($r)) { foreach ($r as $rr) { @@ -151,7 +153,7 @@ function windowsphonepush_cron() // pushing only possible if device_url (the URI on Microsoft server) is available or not "NA" (which will be sent // by app if user has switched the server setting in app - sending blank not possible as this would return an update error) if (( $device_url == "" ) || ( $device_url == "NA" )) { - // no Device-URL for the user availabe, but plugin is enabled --> write info to Logger + // no Device-URL for the user availabe, but addon is enabled --> write info to Logger logger("WARN: windowsphonepush is enable for user " . $rr['uid'] . ", but no Device-URL is specified for the user."); } else { // retrieve the number of unseen items and the id of the latest one (if there are more than @@ -392,7 +394,7 @@ function windowsphonepush_updatesettings() return "Not Authenticated"; } - // no updating if user hasn't enabled the plugin + // no updating if user hasn't enabled the addon $enable = PConfig::get(local_user(), 'windowsphonepush', 'enable'); if (!$enable) { return "Plug-in not enabled"; @@ -433,7 +435,7 @@ function windowsphonepush_updatecounterunseen() return "Not Authenticated"; } - // no updating if user hasn't enabled the plugin + // no updating if user hasn't enabled the addon $enable = PConfig::get(local_user(), 'windowsphonepush', 'enable'); if (!$enable) { return "Plug-in not enabled"; @@ -469,5 +471,5 @@ function windowsphonepush_login(App $a) require_once 'include/security.php'; authenticate_success($record); $_SESSION["allow_api"] = true; - call_hooks('logged_in', $a->user); + Addon::callHooks('logged_in', $a->user); }