Merge branch '3.6-rc'
authorTobias Diekershoff <tobias.diekershoff@gmx.net>
Fri, 23 Mar 2018 07:00:37 +0000 (08:00 +0100)
committerTobias Diekershoff <tobias.diekershoff@gmx.net>
Fri, 23 Mar 2018 07:00:37 +0000 (08:00 +0100)
75 files changed:
1  2 
blackout/blackout.php
blockem/blockem.php
blogger/blogger.php
buffer/buffer.php
communityhome/communityhome.php
convert/convert.php
curweather/curweather.php
dav/README.md
dav/common/wdcal_configuration.php
dav/friendica/calendar.friendica.fnk.php
dav/friendica/dav_caldav_backend_virtual_friendica.inc.php
dav/friendica/dav_carddav_backend_virtual_friendica.inc.php
dav/friendica/layout.fnk.php
dav/friendica/main.php
diaspora/diaspora.php
dwpost/dwpost.php
forumdirectory/forumdirectory.php
fromapp/fromapp.php
fromgplus/fromgplus.php
geocoordinates/geocoordinates.php
geonames/geonames.php
gnot/gnot.php
googlemaps/googlemaps.php
gravatar/gravatar.php
group_text/group_text.php
ifttt/ifttt.php
ijpost/ijpost.php
impressum/impressum.php
irc/irc.php
jappixmini/jappixmini.php
js_upload/js_upload.php
krynn/krynn.php
langfilter/langfilter.php
ldapauth/ldapauth.php
leistungsschutzrecht/leistungsschutzrecht.php
libertree/libertree.php
libravatar/libravatar.php
ljpost/ljpost.php
mailstream/mailstream.php
mathjax/mathjax.php
notifyall/notifyall.php
notimeline/notimeline.php
nsfw/nsfw.php
numfriends/numfriends.php
openstreetmap/openstreetmap.php
pageheader/pageheader.php
piwik/piwik.php
planets/planets.php
pledgie/pledgie.php
public_server/public_server.php
pumpio/pumpio.php
qcomment/qcomment.php
randplace/randplace.php
remote_permissions/remote_permissions.php
rendertime/rendertime.php
securemail/securemail.php
showmore/showmore.php
smileybutton/smileybutton.php
startpage/startpage.php
statusnet/statusnet.php
superblock/superblock.php
testdrive/testdrive.php
tictac/tictac.php
tumblr/tumblr.php
twitter/twitter.php
viewsrc/viewsrc.php
webrtc/webrtc.php
widgets/widget_friendheader.php
widgets/widget_friends.php
widgets/widget_like.php
widgets/widgets.php
windowsphonepush/windowsphonepush.php
wppost/wppost.php
xmpp/xmpp.php
yourls/yourls.php

index 3678969e340e7f689f522acfeab1946525657fb8,28e5567f75243f1fa509b283fd3be4b8d4809010..ec7215ab22dce5ed5810923c17a2eac8a6ac5818
@@@ -86,22 -89,22 +89,22 @@@ function blackout_redirect ($a, $b) 
      }
  }
  
- function blackout_plugin_admin(&$a, &$o) {
-     $mystart = get_config('blackout','begindate');
+ function blackout_addon_admin(&$a, &$o) {
+     $mystart = Config::get('blackout','begindate');
      if (! is_string($mystart)) { $mystart = "YYYY-MM-DD:hhmm"; }
 -    $myend   = Config::get('blackout','enddate');
 +    $myend   = get_config('blackout','enddate');
      if (! is_string($myend)) { $myend = "YYYY-MM-DD:hhmm"; }
 -    $myurl   = Config::get('blackout','url');
 +    $myurl   = get_config('blackout','url');
      if (! is_string($myurl)) { $myurl = "http://www.example.com"; }
      $t = get_markup_template( "admin.tpl", "addon/blackout/" );
-  
-    $o = replace_macros($t, array(
-         '$submit' => t('Save Settings'),
-         '$rurl' => array("rurl", "Redirect URL", $myurl, "all your visitors from the web will be redirected to this URL"),
-         '$startdate' => array("startdate", "Begin of the Blackout<br />(YYYY-MM-DD hh:mm)", $mystart, "format is <em>YYYY</em> year, <em>MM</em> month, <em>DD</em> day, <em>hh</em> hour and <em>mm</em> minute"),
-         '$enddate' => array("enddate", "End of the Blackout<br />(YYYY-MM-DD hh:mm)", $myend, ""),
+    $o = replace_macros($t, [
+         '$submit' => L10n::t('Save Settings'),
+         '$rurl' => ["rurl", "Redirect URL", $myurl, "all your visitors from the web will be redirected to this URL"],
+         '$startdate' => ["startdate", "Begin of the Blackout<br />(YYYY-MM-DD hh:mm)", $mystart, "format is <em>YYYY</em> year, <em>MM</em> month, <em>DD</em> day, <em>hh</em> hour and <em>mm</em> minute"],
+         '$enddate' => ["enddate", "End of the Blackout<br />(YYYY-MM-DD hh:mm)", $myend, ""],
  
 -    ]);
 +    ));
      $date1 = DateTime::createFromFormat('Y-m-d G:i', $mystart);
      $date2 = DateTime::createFromFormat('Y-m-d G:i', $myend);
      if ($date2 < $date1) {
index 223a1990c336d17a20635017e16d6d222695fad8,45272e00628d5dfa6bee3107ddb83a54ed41ebc1..6f2b6d89e0929840e1785fe53c0fa276671faf1f
@@@ -1,41 -1,39 +1,39 @@@
  <?php
  /**
   * Name: blockem
-  * Description: block people
+  * Description: Allows users to hide content by collapsing posts and replies.
   * Version: 1.0
   * Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
 - *
 + * 
   */
- function blockem_install() {
-       register_hook('prepare_body', 'addon/blockem/blockem.php', 'blockem_prepare_body');
-       register_hook('display_item', 'addon/blockem/blockem.php', 'blockem_display_item');
-       register_hook('plugin_settings', 'addon/blockem/blockem.php', 'blockem_addon_settings');
-       register_hook('plugin_settings_post', 'addon/blockem/blockem.php', 'blockem_addon_settings_post');
-       register_hook('conversation_start', 'addon/blockem/blockem.php', 'blockem_conversation_start');
-       register_hook('item_photo_menu', 'addon/blockem/blockem.php', 'blockem_item_photo_menu');
-       register_hook('enotify_store', 'addon/blockem/blockem.php', 'blockem_enotify_store' );
+ use Friendica\Core\Addon;
+ use Friendica\Core\L10n;
+ use Friendica\Core\PConfig;
+ function blockem_install()
+ {
+       Addon::registerHook('prepare_body', 'addon/blockem/blockem.php', 'blockem_prepare_body');
+       Addon::registerHook('display_item', 'addon/blockem/blockem.php', 'blockem_display_item');
+       Addon::registerHook('addon_settings', 'addon/blockem/blockem.php', 'blockem_addon_settings');
+       Addon::registerHook('addon_settings_post', 'addon/blockem/blockem.php', 'blockem_addon_settings_post');
+       Addon::registerHook('conversation_start', 'addon/blockem/blockem.php', 'blockem_conversation_start');
+       Addon::registerHook('item_photo_menu', 'addon/blockem/blockem.php', 'blockem_item_photo_menu');
+       Addon::registerHook('enotify_store', 'addon/blockem/blockem.php', 'blockem_enotify_store');
  }
  
- function blockem_uninstall() {
-       unregister_hook('prepare_body', 'addon/blockem/blockem.php', 'blockem_prepare_body');
-       unregister_hook('display_item', 'addon/blockem/blockem.php', 'blockem_display_item');
-       unregister_hook('plugin_settings', 'addon/blockem/blockem.php', 'blockem_addon_settings');
-       unregister_hook('plugin_settings_post', 'addon/blockem/blockem.php', 'blockem_addon_settings_post');
-       unregister_hook('conversation_start', 'addon/blockem/blockem.php', 'blockem_conversation_start');
-       unregister_hook('item_photo_menu', 'addon/blockem/blockem.php', 'blockem_item_photo_menu');
-       unregister_hook('enotify_store', 'addon/blockem/blockem.php', 'blockem_enotify_store' );
+ function blockem_uninstall()
+ {
+       Addon::unregisterHook('prepare_body', 'addon/blockem/blockem.php', 'blockem_prepare_body');
+       Addon::unregisterHook('display_item', 'addon/blockem/blockem.php', 'blockem_display_item');
+       Addon::unregisterHook('addon_settings', 'addon/blockem/blockem.php', 'blockem_addon_settings');
+       Addon::unregisterHook('addon_settings_post', 'addon/blockem/blockem.php', 'blockem_addon_settings_post');
+       Addon::unregisterHook('conversation_start', 'addon/blockem/blockem.php', 'blockem_conversation_start');
+       Addon::unregisterHook('item_photo_menu', 'addon/blockem/blockem.php', 'blockem_item_photo_menu');
+       Addon::unregisterHook('enotify_store', 'addon/blockem/blockem.php', 'blockem_enotify_store');
  }
  
- function blockem_addon_settings(&$a,&$s) {
+ function blockem_addon_settings(&$a, &$s)
+ {
  
        if(! local_user())
                return;
@@@ -79,10 -78,9 +78,9 @@@ function blockem_addon_settings_post(&$
        }
  }
  
  function blockem_enotify_store(&$a,&$b) {
  
 -      $words = PConfig::get($b['uid'],'blockem','words');
 +      $words = get_pconfig($b['uid'],'blockem','words');
        if($words) {
                $arr = explode(',',$words);
        }
index 892e8a452e830587e2ca9be7e42da3697a66ae83,30c450bda9f6e5c180c597fdb70fee59c381750c..97d488bc2012acb88768c6a5cea5b84a12d762a0
@@@ -4,29 -3,36 +3,36 @@@
   * Name: Blogger Post Connector
   * Description: Post to Blogger (or anything else which uses blogger XMLRPC API)
   * Version: 1.0
 - *
 + * 
   */
  
- function blogger_install() {
-     register_hook('post_local',           'addon/blogger/blogger.php', 'blogger_post_local');
-     register_hook('notifier_normal',      'addon/blogger/blogger.php', 'blogger_send');
-     register_hook('jot_networks',         'addon/blogger/blogger.php', 'blogger_jot_nets');
-     register_hook('connector_settings',      'addon/blogger/blogger.php', 'blogger_settings');
-     register_hook('connector_settings_post', 'addon/blogger/blogger.php', 'blogger_settings_post');
+ use Friendica\Content\Text\BBCode;
+ use Friendica\Core\Addon;
+ use Friendica\Core\L10n;
+ use Friendica\Core\PConfig;
+ use Friendica\Util\Network;
+ function blogger_install()
+ {
+       Addon::registerHook('post_local',           'addon/blogger/blogger.php', 'blogger_post_local');
+       Addon::registerHook('notifier_normal',      'addon/blogger/blogger.php', 'blogger_send');
+       Addon::registerHook('jot_networks',         'addon/blogger/blogger.php', 'blogger_jot_nets');
+       Addon::registerHook('connector_settings',      'addon/blogger/blogger.php', 'blogger_settings');
+       Addon::registerHook('connector_settings_post', 'addon/blogger/blogger.php', 'blogger_settings_post');
  }
- function blogger_uninstall() {
-     unregister_hook('post_local',       'addon/blogger/blogger.php', 'blogger_post_local');
-     unregister_hook('notifier_normal',  'addon/blogger/blogger.php', 'blogger_send');
-     unregister_hook('jot_networks',     'addon/blogger/blogger.php', 'blogger_jot_nets');
-     unregister_hook('connector_settings',      'addon/blogger/blogger.php', 'blogger_settings');
-     unregister_hook('connector_settings_post', 'addon/blogger/blogger.php', 'blogger_settings_post');
  
-       // obsolete - remove
-     unregister_hook('post_local_end',   'addon/blogger/blogger.php', 'blogger_send');
-     unregister_hook('plugin_settings',  'addon/blogger/blogger.php', 'blogger_settings');
-     unregister_hook('plugin_settings_post',  'addon/blogger/blogger.php', 'blogger_settings_post');
+ function blogger_uninstall()
+ {
+       Addon::unregisterHook('post_local',       'addon/blogger/blogger.php', 'blogger_post_local');
+       Addon::unregisterHook('notifier_normal',  'addon/blogger/blogger.php', 'blogger_send');
+       Addon::unregisterHook('jot_networks',     'addon/blogger/blogger.php', 'blogger_jot_nets');
+       Addon::unregisterHook('connector_settings',      'addon/blogger/blogger.php', 'blogger_settings');
+       Addon::unregisterHook('connector_settings_post', 'addon/blogger/blogger.php', 'blogger_settings_post');
  
+       // obsolete - remove
+       Addon::unregisterHook('post_local_end',   'addon/blogger/blogger.php', 'blogger_send');
+       Addon::unregisterHook('addon_settings',  'addon/blogger/blogger.php', 'blogger_settings');
+       Addon::unregisterHook('addon_settings_post',  'addon/blogger/blogger.php', 'blogger_settings_post');
  }
  
  
@@@ -44,139 -52,139 +52,130 @@@ function blogger_jot_nets(&$a, &$b
  }
  
  
- function blogger_settings(&$a,&$s) {
-     if(! local_user())
-         return;
+ function blogger_settings(&$a, &$s)
+ {
+       if (! local_user()) {
+               return;
+       }
  
 -      /* Add our stylesheet to the page so we can make our settings look nice */
 +    /* Add our stylesheet to the page so we can make our settings look nice */
  
 -      $a->page['htmlhead'] .= '<link rel="stylesheet"  type="text/css" href="' . $a->get_baseurl() . '/addon/blogger/blogger.css' . '" media="all" />' . "\r\n";
 +    $a->page['htmlhead'] .= '<link rel="stylesheet"  type="text/css" href="' . $a->get_baseurl() . '/addon/blogger/blogger.css' . '" media="all" />' . "\r\n";
  
 -      /* Get the current state of our config variables */
 +    /* Get the current state of our config variables */
  
-     $enabled = get_pconfig(local_user(),'blogger','post');
-     $checked = (($enabled) ? ' checked="checked" ' : '');
-     $css = (($enabled) ? '' : '-disabled');
+       $enabled = PConfig::get(local_user(), 'blogger', 'post');
+       $checked = (($enabled) ? ' checked="checked" ' : '');
+       $css = (($enabled) ? '' : '-disabled');
  
-     $def_enabled = get_pconfig(local_user(),'blogger','post_by_default');
+       $def_enabled = PConfig::get(local_user(), 'blogger', 'post_by_default');
  
 -      $def_checked = (($def_enabled) ? ' checked="checked" ' : '');
 +    $def_checked = (($def_enabled) ? ' checked="checked" ' : '');
  
 -      $bl_username = PConfig::get(local_user(), 'blogger', 'bl_username');
 -      $bl_password = PConfig::get(local_user(), 'blogger', 'bl_password');
 -      $bl_blog = PConfig::get(local_user(), 'blogger', 'bl_blog');
 +      $bl_username = get_pconfig(local_user(), 'blogger', 'bl_username');
 +      $bl_password = get_pconfig(local_user(), 'blogger', 'bl_password');
 +      $bl_blog = get_pconfig(local_user(), 'blogger', 'bl_blog');
  
-     /* Add some HTML to the existing form */
-     $s .= '<span id="settings_blogger_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_blogger_expanded\'); openClose(\'settings_blogger_inflated\');">';
-     $s .= '<img class="connector'.$css.'" src="images/blogger.png" /><h3 class="connector">'. t('Blogger Export').'</h3>';
-     $s .= '</span>';
-     $s .= '<div id="settings_blogger_expanded" class="settings-block" style="display: none;">';
-     $s .= '<span class="fakelink" onclick="openClose(\'settings_blogger_expanded\'); openClose(\'settings_blogger_inflated\');">';
-     $s .= '<img class="connector'.$css.'" src="images/blogger.png" /><h3 class="connector">'. t('Blogger Export').'</h3>';
-     $s .= '</span>';
-     $s .= '<div id="blogger-enable-wrapper">';
-     $s .= '<label id="blogger-enable-label" for="blogger-checkbox">' . t('Enable Blogger Post Plugin') . '</label>';
-     $s .= '<input id="blogger-checkbox" type="checkbox" name="blogger" value="1" ' . $checked . '/>';
-     $s .= '</div><div class="clear"></div>';
-     $s .= '<div id="blogger-username-wrapper">';
-     $s .= '<label id="blogger-username-label" for="blogger-username">' . t('Blogger username') . '</label>';
-     $s .= '<input id="blogger-username" type="text" name="bl_username" value="' . $bl_username . '" />';
-     $s .= '</div><div class="clear"></div>';
-     $s .= '<div id="blogger-password-wrapper">';
-     $s .= '<label id="blogger-password-label" for="blogger-password">' . t('Blogger password') . '</label>';
-     $s .= '<input id="blogger-password" type="password" name="bl_password" value="' . $bl_password . '" />';
-     $s .= '</div><div class="clear"></div>';
-     $s .= '<div id="blogger-blog-wrapper">';
-     $s .= '<label id="blogger-blog-label" for="blogger-blog">' . t('Blogger API URL') . '</label>';
-     $s .= '<input id="blogger-blog" type="text" name="bl_blog" value="' . $bl_blog . '" />';
-     $s .= '</div><div class="clear"></div>';
-     $s .= '<div id="blogger-bydefault-wrapper">';
-     $s .= '<label id="blogger-bydefault-label" for="blogger-bydefault">' . t('Post to Blogger by default') . '</label>';
-     $s .= '<input id="blogger-bydefault" type="checkbox" name="bl_bydefault" value="1" ' . $def_checked . '/>';
-     $s .= '</div><div class="clear"></div>';
-     /* provide a submit button */
-     $s .= '<div class="settings-submit-wrapper" ><input type="submit" id="blogger-submit" name="blogger-submit" class="settings-submit" value="' . t('Save Settings') . '" /></div></div>';
+       /* Add some HTML to the existing form */
+       $s .= '<span id="settings_blogger_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_blogger_expanded\'); openClose(\'settings_blogger_inflated\');">';
+       $s .= '<img class="connector'.$css.'" src="images/blogger.png" /><h3 class="connector">'. L10n::t('Blogger Export').'</h3>';
+       $s .= '</span>';
+       $s .= '<div id="settings_blogger_expanded" class="settings-block" style="display: none;">';
+       $s .= '<span class="fakelink" onclick="openClose(\'settings_blogger_expanded\'); openClose(\'settings_blogger_inflated\');">';
+       $s .= '<img class="connector'.$css.'" src="images/blogger.png" /><h3 class="connector">'. L10n::t('Blogger Export').'</h3>';
+       $s .= '</span>';
+       $s .= '<div id="blogger-enable-wrapper">';
+       $s .= '<label id="blogger-enable-label" for="blogger-checkbox">' . L10n::t('Enable Blogger Post Addon') . '</label>';
+       $s .= '<input id="blogger-checkbox" type="checkbox" name="blogger" value="1" ' . $checked . '/>';
+       $s .= '</div><div class="clear"></div>';
+       $s .= '<div id="blogger-username-wrapper">';
+       $s .= '<label id="blogger-username-label" for="blogger-username">' . L10n::t('Blogger username') . '</label>';
+       $s .= '<input id="blogger-username" type="text" name="bl_username" value="' . $bl_username . '" />';
+       $s .= '</div><div class="clear"></div>';
+       $s .= '<div id="blogger-password-wrapper">';
+       $s .= '<label id="blogger-password-label" for="blogger-password">' . L10n::t('Blogger password') . '</label>';
+       $s .= '<input id="blogger-password" type="password" name="bl_password" value="' . $bl_password . '" />';
+       $s .= '</div><div class="clear"></div>';
+       $s .= '<div id="blogger-blog-wrapper">';
+       $s .= '<label id="blogger-blog-label" for="blogger-blog">' . L10n::t('Blogger API URL') . '</label>';
+       $s .= '<input id="blogger-blog" type="text" name="bl_blog" value="' . $bl_blog . '" />';
+       $s .= '</div><div class="clear"></div>';
+       $s .= '<div id="blogger-bydefault-wrapper">';
+       $s .= '<label id="blogger-bydefault-label" for="blogger-bydefault">' . L10n::t('Post to Blogger by default') . '</label>';
+       $s .= '<input id="blogger-bydefault" type="checkbox" name="bl_bydefault" value="1" ' . $def_checked . '/>';
+       $s .= '</div><div class="clear"></div>';
+       /* provide a submit button */
+       $s .= '<div class="settings-submit-wrapper" ><input type="submit" id="blogger-submit" name="blogger-submit" class="settings-submit" value="' . L10n::t('Save Settings') . '" /></div></div>';
  }
  
  
- function blogger_settings_post(&$a,&$b) {
-       if(x($_POST,'blogger-submit')) {
-               set_pconfig(local_user(),'blogger','post',intval($_POST['blogger']));
-               set_pconfig(local_user(),'blogger','post_by_default',intval($_POST['bl_bydefault']));
-               set_pconfig(local_user(),'blogger','bl_username',trim($_POST['bl_username']));
-               set_pconfig(local_user(),'blogger','bl_password',trim($_POST['bl_password']));
-               set_pconfig(local_user(),'blogger','bl_blog',trim($_POST['bl_blog']));
+ function blogger_settings_post(&$a, &$b)
+ {
+       if (x($_POST, 'blogger-submit')) {
+               PConfig::set(local_user(), 'blogger', 'post', intval($_POST['blogger']));
+               PConfig::set(local_user(), 'blogger', 'post_by_default', intval($_POST['bl_bydefault']));
+               PConfig::set(local_user(), 'blogger', 'bl_username', trim($_POST['bl_username']));
+               PConfig::set(local_user(), 'blogger', 'bl_password', trim($_POST['bl_password']));
+               PConfig::set(local_user(), 'blogger', 'bl_blog', trim($_POST['bl_blog']));
        }
 +
  }
  
- function blogger_post_local(&$a,&$b) {
+ function blogger_post_local(&$a, &$b)
+ {
        // This can probably be changed to allow editing by pointing to a different API endpoint
  
 -      if ($b['edit']) {
 +      if($b['edit'])
                return;
 -      }
  
 -      if (!local_user() || (local_user() != $b['uid'])) {
 +      if((! local_user()) || (local_user() != $b['uid']))
                return;
 -      }
  
 -      if ($b['private'] || $b['parent']) {
 +      if($b['private'] || $b['parent'])
                return;
 -      }
  
-     $bl_post   = intval(get_pconfig(local_user(),'blogger','post'));
+       $bl_post   = intval(PConfig::get(local_user(), 'blogger', 'post'));
  
-       $bl_enable = (($bl_post && x($_REQUEST,'blogger_enable')) ? intval($_REQUEST['blogger_enable']) : 0);
+       $bl_enable = (($bl_post && x($_REQUEST, 'blogger_enable')) ? intval($_REQUEST['blogger_enable']) : 0);
  
-       if($b['api_source'] && intval(get_pconfig(local_user(),'blogger','post_by_default')))
+       if ($b['api_source'] && intval(PConfig::get(local_user(), 'blogger', 'post_by_default'))) {
                $bl_enable = 1;
 -      }
 -
 -      if (!$bl_enable) {
 -              return;
 -      }
  
 -      if (strlen($b['postopts'])) {
 -              $b['postopts'] .= ',';
 -      }
 +    if(! $bl_enable)
 +       return;
  
 -       $b['postopts'] .= 'blogger';
 +    if(strlen($b['postopts']))
 +       $b['postopts'] .= ',';
 +     $b['postopts'] .= 'blogger';
  }
  
  
  
  
- function blogger_send(&$a,&$b) {
-     if($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited']))
-         return;
-     if(! strstr($b['postopts'],'blogger'))
-         return;
-     if($b['parent'] != $b['id'])
-         return;
+ function blogger_send(&$a, &$b)
+ {
+       if ($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) {
+               return;
+       }
  
-       $bl_username = xmlify(get_pconfig($b['uid'],'blogger','bl_username'));
-       $bl_password = xmlify(get_pconfig($b['uid'],'blogger','bl_password'));
-       $bl_blog = get_pconfig($b['uid'],'blogger','bl_blog');
+       if (! strstr($b['postopts'], 'blogger')) {
+               return;
+       }
  
-       if($bl_username && $bl_password && $bl_blog) {
 -      if ($b['parent'] != $b['id']) {
 -              return;
 -      }
  
-               require_once('include/bbcode.php');
+       $bl_username = xmlify(PConfig::get($b['uid'], 'blogger', 'bl_username'));
+       $bl_password = xmlify(PConfig::get($b['uid'], 'blogger', 'bl_password'));
+       $bl_blog = PConfig::get($b['uid'], 'blogger', 'bl_blog');
  
-               $title = '<title>' . (($b['title']) ? $b['title'] : t('Post from Friendica')) . '</title>';
-               $post = $title . bbcode($b['body']);
+       if ($bl_username && $bl_password && $bl_blog) {
+               $title = '<title>' . (($b['title']) ? $b['title'] : L10n::t('Post from Friendica')) . '</title>';
+               $post = $title . BBCode::convert($b['body']);
                $post = xmlify($post);
  
                $xml = <<< EOT
@@@ -197,10 -205,10 +196,11 @@@ EOT
  
                logger('blogger: data: ' . $xml, LOGGER_DATA);
  
-               if($bl_blog !== 'test')
-                       $x = post_url($bl_blog,$xml);
+               if ($bl_blog !== 'test') {
+                       $x = Network::post($bl_blog, $xml);
+               }
                logger('posted to blogger: ' . (($x) ? $x : ''), LOGGER_DEBUG);
 +
        }
  }
index ca33708c831e191228d43c2964de67aad8a84226,bb1d8482e5405d23a3b642bba7f74e8d3277a3f7..9b0979ee7b4e5bd0effe15f32c42c795271c7e4a
@@@ -102,12 -112,12 +112,12 @@@ function buffer_jot_nets(&$a,&$b) 
        if(! local_user())
                return;
  
 -      $buffer_post = PConfig::get(local_user(),'buffer','post');
 +      $buffer_post = get_pconfig(local_user(),'buffer','post');
        if(intval($buffer_post) == 1) {
 -              $buffer_defpost = PConfig::get(local_user(),'buffer','post_by_default');
 +              $buffer_defpost = get_pconfig(local_user(),'buffer','post_by_default');
                $selected = ((intval($buffer_defpost) == 1) ? ' checked="checked" ' : '');
                $b .= '<div class="profile-jot-net"><input type="checkbox" name="buffer_enable"' . $selected . ' value="1" /> '
-                   . t('Post to Buffer') . '</div>';
+                   . L10n::t('Post to Buffer') . '</div>';
        }
  }
  
@@@ -136,12 -146,12 +146,12 @@@ function buffer_settings(&$a,&$s) 
        $s .= '</span>';
        $s .= '<div id="settings_buffer_expanded" class="settings-block" style="display: none;">';
        $s .= '<span class="fakelink" onclick="openClose(\'settings_buffer_expanded\'); openClose(\'settings_buffer_inflated\');">';
-       $s .= '<img class="connector'.$css.'" src="images/buffer.png" /><h3 class="connector">'. t('Buffer Export').'</h3>';
+       $s .= '<img class="connector'.$css.'" src="images/buffer.png" /><h3 class="connector">'. L10n::t('Buffer Export').'</h3>';
        $s .= '</span>';
  
 -      $client_id = Config::get("buffer", "client_id");
 -      $client_secret = Config::get("buffer", "client_secret");
 -      $access_token = PConfig::get(local_user(), "buffer", "access_token");
 +      $client_id = get_config("buffer", "client_id");
 +      $client_secret = get_config("buffer", "client_secret");
 +      $access_token = get_pconfig(local_user(), "buffer", "access_token");
  
        $s .= '<div id="buffer-password-wrapper">';
        if ($access_token == "") {
@@@ -248,16 -268,13 +258,13 @@@ function buffer_send(&$a,&$b) 
        //if($b['app'] == "Buffer")
        //      return;
  
 -      $client_id = Config::get("buffer", "client_id");
 -      $client_secret = Config::get("buffer", "client_secret");
 -      $access_token = PConfig::get($b['uid'], "buffer","access_token");
 +      $client_id = get_config("buffer", "client_id");
 +      $client_secret = get_config("buffer", "client_secret");
 +      $access_token = get_pconfig($b['uid'], "buffer","access_token");
  
-       if($access_token) {
+       if ($access_token) {
                $buffer = new BufferApp($client_id, $client_secret, $callback_url, $access_token);
  
-               require_once("include/plaintext.php");
-               require_once("include/network.php");
                $profiles = $buffer->go('/profiles');
                if (is_array($profiles)) {
                        logger("Will send these parameter ".print_r($b, true), LOGGER_DEBUG);
index ff3215d36aa00aaf64fe203ddd8de8847d0d7aef,dc0a6bafaca64b0d7dec64cefc5e2c395dd71e63..f2908ab0e38d6cad4fdc7a0da6ce6df6b49eff06
@@@ -55,18 -102,18 +102,18 @@@ function communityhome_home(App $a, &$o
                        0,
                        12
                );
-       #       $tpl = file_get_contents( dirname(__file__).'/directory_item.tpl');
-               $tpl = get_markup_template( 'directory_item.tpl', 'addon/communityhome/' );
-               if(count($r)) {
+               #       $tpl = file_get_contents( dirname(__file__).'/directory_item.tpl');
+               $tpl = get_markup_template('directory_item.tpl', 'addon/communityhome/');
+               if (count($r)) {
                        $photo = 'thumb';
-                       foreach($r as $rr) {
+                       foreach ($r as $rr) {
                                $profile_link = $a->get_baseurl() . '/profile/' . ((strlen($rr['nickname'])) ? $rr['nickname'] : $rr['profile_uid']);
-                               $entry = replace_macros($tpl,array(
+                               $entry = replace_macros($tpl, [
                                        '$id' => $rr['id'],
                                        '$profile_link' => $profile_link,
 -                                      '$photo' => $rr[$photo],
 +                                      '$photo' => $a->get_cached_avatar_image($rr[$photo]),
                                        '$alt_text' => $rr['name'],
 -                              ]);
 +                              ));
                                $aside['$lastusers_items'][] = $entry;
                        }
                }
        }
  
        // last 10 liked items
-       if (get_config('communityhome','showlastlike')===true){
-               $aside['$like_title'] = t('Latest likes');
-               $aside['$like_items'] = array();
-               $r = q("SELECT `T1`.`created`, `T1`.`liker`, `T1`.`liker-link`, `item`.* FROM 
-                               (SELECT `parent-uri`, `created`, `author-name` AS `liker`,`author-link` AS `liker-link` 
+       if (Config::get('communityhome', 'showlastlike')) {
+               $aside['$like_title'] = L10n::t('Latest likes');
+               $aside['$like_items'] = [];
+               $r = q("SELECT `T1`.`created`, `T1`.`liker`, `T1`.`liker-link`, `item`.* FROM
+                               (SELECT `parent-uri`, `created`, `author-name` AS `liker`,`author-link` AS `liker-link`
                                        FROM `item` WHERE `verb`='http://activitystrea.ms/schema/1.0/like' GROUP BY `parent-uri` ORDER BY `created` DESC) AS T1
 -                              INNER JOIN `item` ON `item`.`uri`=`T1`.`parent-uri`
 +                              INNER JOIN `item` ON `item`.`uri`=`T1`.`parent-uri` 
                                WHERE `T1`.`liker-link` LIKE '%s%%' OR `item`.`author-link` LIKE '%s%%'
                                GROUP BY `uri`
                                ORDER BY `T1`.`created` DESC
Simple merge
index 71d95e4640cb2fd8443786b1047ef4dd604ba497,edf96c3eb517947b21368406f016f99657c9bc5e..82ea2915ffc90e876d42e5705660e8665f7bb438
@@@ -136,14 -143,14 +143,14 @@@ function curweather_network_mod_init(&$
  }
  
  
- function curweather_plugin_settings_post($a,$post) {
+ function curweather_addon_settings_post($a,$post) {
        if(! local_user() || (! x($_POST,'curweather-settings-submit')))
                return;
 -      PConfig::set(local_user(),'curweather','curweather_loc',trim($_POST['curweather_loc']));
 -      PConfig::set(local_user(),'curweather','curweather_enable',intval($_POST['curweather_enable']));
 -      PConfig::set(local_user(),'curweather','curweather_units',trim($_POST['curweather_units']));
 +      set_pconfig(local_user(),'curweather','curweather_loc',trim($_POST['curweather_loc']));
 +      set_pconfig(local_user(),'curweather','curweather_enable',intval($_POST['curweather_enable']));
 +      set_pconfig(local_user(),'curweather','curweather_units',trim($_POST['curweather_units']));
  
-       info( t('Current Weather settings updated.') . EOL);
+       info(L10n::t('Current Weather settings updated.') . EOL);
  }
  
  
@@@ -162,20 -169,20 +169,20 @@@ function curweather_addon_settings(&$a,
        } else {
            $noappidtext = '';
        }
 -      $enable = intval(PConfig::get(local_user(),'curweather','curweather_enable'));
 +      $enable = intval(get_pconfig(local_user(),'curweather','curweather_enable'));
        $enable_checked = (($enable) ? ' checked="checked" ' : '');
 -
 +      
        // load template and replace the macros
        $t = get_markup_template("settings.tpl", "addon/curweather/" );
-       $s = replace_macros ($t, array(
-               '$submit' => t('Save Settings'),            
-               '$header' => t('Current Weather').' '.t('Settings'),
+       $s = replace_macros ($t, [
+               '$submit' => L10n::t('Save Settings'),
+               '$header' => L10n::t('Current Weather').' '.L10n::t('Settings'),
                '$noappidtext' => $noappidtext,
-               '$info' => t('Enter either the name of your location or the zip code.'),
-               '$curweather_loc' => array( 'curweather_loc', t('Your Location'), $curweather_loc, t('Identifier of your location (name or zip code), e.g. <em>Berlin,DE</em> or <em>14476,DE</em>.') ),
-               '$curweather_units' => array( 'curweather_units', t('Units'), $curweather_units, t('select if the temperature should be displayed in &deg;C or &deg;F'), array('metric'=>'°C', 'imperial'=>'°F')),
-               '$enabled' => array( 'curweather_enable', t('Show weather data'), $enable, '')
-           ));
+               '$info' => L10n::t('Enter either the name of your location or the zip code.'),
+               '$curweather_loc' => [ 'curweather_loc', L10n::t('Your Location'), $curweather_loc, L10n::t('Identifier of your location (name or zip code), e.g. <em>Berlin,DE</em> or <em>14476,DE</em>.') ],
+               '$curweather_units' => [ 'curweather_units', L10n::t('Units'), $curweather_units, L10n::t('select if the temperature should be displayed in &deg;C or &deg;F'), ['metric'=>'°C', 'imperial'=>'°F']],
+               '$enabled' => [ 'curweather_enable', L10n::t('Show weather data'), $enable, '']
+           ]);
        return;
  
  }
@@@ -185,20 -192,20 +192,20 @@@ function curweather_addon_admin_post (&
        if(! is_site_admin())
            return;
        if ($_POST['curweather-submit']) {
-           set_config('curweather','appid',trim($_POST['appid']));
-           set_config('curweather','cachetime',trim($_POST['cachetime']));
-           info( t('Curweather settings saved.'.EOL));
+           Config::set('curweather','appid',trim($_POST['appid']));
+           Config::set('curweather','cachetime',trim($_POST['cachetime']));
+           info(L10n::t('Curweather settings saved.'.EOL));
        }
  }
- function curweather_plugin_admin (&$a, &$o) {
+ function curweather_addon_admin (&$a, &$o) {
      if(! is_site_admin())
            return;
 -    $appid = Config::get('curweather','appid');
 -    $cachetime = Config::get('curweather','cachetime');
 +    $appid = get_config('curweather','appid');
 +    $cachetime = get_config('curweather','cachetime');
      $t = get_markup_template("admin.tpl", "addon/curweather/" );
-     $o = replace_macros ($t, array(
-       '$submit' => t('Save Settings'),
-       '$cachetime' => array('cachetime', t('Caching Interval'), $cachetime, t('For how long should the weather data be cached? Choose according your OpenWeatherMap account type.'), array('0'=>t('no cache'), '300'=>'5 '.t('minutes'), '900'=>'15 '.t('minutes'), '1800'=>'30 '.t('minutes'), '3600'=>'60 '.t('minutes'))),
-       '$appid' => array('appid', t('Your APPID'), $appid, t('Your API key provided by OpenWeatherMap'))
-     ));
+     $o = replace_macros ($t, [
+       '$submit' => L10n::t('Save Settings'),
+       '$cachetime' => ['cachetime', L10n::t('Caching Interval'), $cachetime, L10n::t('For how long should the weather data be cached? Choose according your OpenWeatherMap account type.'), ['0'=>L10n::t('no cache'), '300'=>'5 '.L10n::t('minutes'), '900'=>'15 '.L10n::t('minutes'), '1800'=>'30 '.L10n::t('minutes'), '3600'=>'60 '.L10n::t('minutes')]],
+       '$appid' => ['appid', L10n::t('Your APPID'), $appid, L10n::t('Your API key provided by OpenWeatherMap')]
+     ]);
  }
diff --cc dav/README.md
Simple merge
Simple merge
index 60dd9c6bd190a4e9f97ad5570218398d4a4405a4,c9007bf3bee598c5e93123b1b1429c8299bf756d..98e552e6f6952261744391250cd53a523b308f84
@@@ -200,13 -202,13 +202,13 @@@ function wdcal_calendar_factory_by_id($
   */
  function wdcal_create_std_calendars_get_statements($user_id, $withcheck = true)
  {
 -      $stms = [];
 +      $stms = array();
        $a = get_app();
-       $uris = array(
-               'private'                 => t("Private Calendar"),
-               CALDAV_FRIENDICA_MINE     => t("Friendica Events: Mine"),
-               CALDAV_FRIENDICA_CONTACTS => t("Friendica Events: Contacts"),
-       );
+       $uris = [
+               'private'                 => L10n::t("Private Calendar"),
+               CALDAV_FRIENDICA_MINE     => L10n::t("Friendica Events: Mine"),
+               CALDAV_FRIENDICA_CONTACTS => L10n::t("Friendica Events: Contacts"),
+       ];
        foreach ($uris as $uri => $name) {
                $cals = q("SELECT * FROM %s%scalendars WHERE `namespace` = %d AND `namespace_id` = %d AND `uri` = '%s'",
                        CALDAV_SQL_DB, CALDAV_SQL_PREFIX, CALDAV_NAMESPACE_PRIVATE, IntVal($user_id), dbesc($uri));
@@@ -242,12 -244,12 +244,12 @@@ function wdcal_create_std_calendars(
   */
  function wdcal_create_std_addressbooks_get_statements($user_id, $withcheck = true)
  {
 -      $stms = [];
 +      $stms = array();
        $a = get_app();
-       $uris = array(
-               'private'                 => t("Private Addresses"),
-               CARDDAV_FRIENDICA_CONTACT     => t("Friendica Contacts"),
-       );
+       $uris = [
+               'private'                 => L10n::t("Private Addresses"),
+               CARDDAV_FRIENDICA_CONTACT     => L10n::t("Friendica Contacts"),
+       ];
        foreach ($uris as $uri => $name) {
                $cals = q("SELECT * FROM %s%saddressbooks WHERE `namespace` = %d AND `namespace_id` = %d AND `uri` = '%s'",
                        CALDAV_SQL_DB, CALDAV_SQL_PREFIX, CALDAV_NAMESPACE_PRIVATE, IntVal($user_id), dbesc($uri));
index 0afc03bd74406087643b92e473bc1221d0bac3dc,b02b9150a6a754e8856d9d6a67d5169648acbb5d..c108d8dcfec73bc7952c087be55a917d3805c228
@@@ -176,10 -179,10 +179,10 @@@ class Sabre_CalDAV_Backend_Friendica ex
                        else $sql_where .= " AND `finish` >= '" . dbesc($date_from) . "'";
                }
                if ($date_to != "") {
-                       if (is_numeric($date_to)) $sql_where .= " AND `start` <= '" . date("Y-m-d H:i:s", $date_to) . "'";
+                       if (is_numeric($date_to)) $sql_where .= " AND `start` <= '" . date(DateTimeFormat::MYSQL, $date_to) . "'";
                        else $sql_where .= " AND `start` <= '" . dbesc($date_to) . "'";
                }
 -              $ret = [];
 +              $ret = array();
  
                $r = q("SELECT * FROM `event` WHERE `uid` = %d " . $sql_where . " ORDER BY `start`", IntVal($calendar["namespace_id"]));
  
Simple merge
index 05f6f71406164b5fcf22764e2352980605e4cebb,2534ce9c104cc4451f9c069cf3b2c6b9ac8e9745..0974696c502d8828e0333f70a6c70eb4f2c9f6c3
@@@ -271,16 -276,16 +276,16 @@@ function dav_cron(&$a, &$b
                        case "email":
                        case "display": // @TODO implement "Display"
                                foreach ($users as $user) {
 -                                      $find      = ["%to%", "%event%", "%url%"];
 -                                      $repl      = [$user["username"], $event[0]["Summary"], $a->get_baseurl() . "/dav/wdcal/" . $calendar[0]["id"] . "/" . $not["calendarobject_id"] . "/"];
 +                                      $find      = array("%to%", "%event%", "%url%");
 +                                      $repl      = array($user["username"], $event[0]["Summary"], $a->get_baseurl() . "/dav/wdcal/" . $calendar[0]["id"] . "/" . $not["calendarobject_id"] . "/");
                                        $text_text = str_replace($find, $repl, "Hi %to%!\n\nThe event \"%event%\" is about to begin:\n%url%");
                                        $text_html = str_replace($find, $repl, "Hi %to%!<br>\n<br>\nThe event \"%event%\" is about to begin:<br>\n<a href='" . "%url%" . "'>%url%</a>");
 -                                      $params    = [
 +                                      $params    = array(
                                                'fromName'             => FRIENDICA_PLATFORM,
-                                               'fromEmail'            => t('noreply') . '@' . $a->get_hostname(),
-                                               'replyTo'              => t('noreply') . '@' . $a->get_hostname(),
+                                               'fromEmail'            => L10n::t('noreply') . '@' . $a->get_hostname(),
+                                               'replyTo'              => L10n::t('noreply') . '@' . $a->get_hostname(),
                                                'toEmail'              => $user["email"],
-                                               'messageSubject'       => t("Notification: " . $event[0]["Summary"]),
+                                               'messageSubject'       => L10n::t("Notification: " . $event[0]["Summary"]),
                                                'htmlVersion'          => $text_html,
                                                'textVersion'          => $text_text,
                                                'additionalMailHeader' => "",
index f637f468ed8d7a75f0ef518dad13a4a6e8d9b560,49a9cfc471bca2e57bbd5e9366958fd1b855f8ab..8c7a5762069b9e70443d5033ee3404d382f0d033
@@@ -31,12 -37,12 +37,12 @@@ function diaspora_jot_nets(&$a,&$b) 
      if(! local_user())
          return;
  
 -    $diaspora_post = PConfig::get(local_user(),'diaspora','post');
 +    $diaspora_post = get_pconfig(local_user(),'diaspora','post');
      if(intval($diaspora_post) == 1) {
 -        $diaspora_defpost = PConfig::get(local_user(),'diaspora','post_by_default');
 +        $diaspora_defpost = get_pconfig(local_user(),'diaspora','post_by_default');
          $selected = ((intval($diaspora_defpost) == 1) ? ' checked="checked" ' : '');
          $b .= '<div class="profile-jot-net"><input type="checkbox" name="diaspora_enable"' . $selected . ' value="1" /> '
-             . t('Post to Diaspora') . '</div>';
+             . L10n::t('Post to Diaspora') . '</div>';
      }
  }
  
index 25f7ac87484e56c3a3f87746bd9f11755314a1a0,a46f55b2a3d30c817ce6134349aef882af5c70a8..1cdd87a99a2306080621e0db53c3815e96d1362b
@@@ -31,12 -37,12 +37,12 @@@ function dwpost_jot_nets(&$a,&$b) 
      if(! local_user())
          return;
  
 -    $dw_post = PConfig::get(local_user(),'dwpost','post');
 +    $dw_post = get_pconfig(local_user(),'dwpost','post');
      if(intval($dw_post) == 1) {
 -        $dw_defpost = PConfig::get(local_user(),'dwpost','post_by_default');
 +        $dw_defpost = get_pconfig(local_user(),'dwpost','post_by_default');
          $selected = ((intval($dw_defpost) == 1) ? ' checked="checked" ' : '');
          $b .= '<div class="profile-jot-net"><input type="checkbox" name="dwpost_enable" ' . $selected . ' value="1" /> '
-             . t('Post to Dreamwidth') . '</div>';
+             . L10n::t('Post to Dreamwidth') . '</div>';
      }
  }
  
index a709c9b1edc88979db81ba2bc284c6c14f3b87a4,a72c45ba49026885993a9b388ccc0b5ddf94061a..751384a8ec0e92a12309deca860c531e3c56b055
@@@ -73,46 -86,50 +86,50 @@@ function forumdirectory_content(&$a
  
        $admin = '';
  
-       $o .= replace_macros($tpl, array(
-               '$search' => $search,
+       $o .= replace_macros($tpl, [
+               '$search'    => $search,
                '$globaldir' => $globaldir,
-               '$desc' => t('Find on this site'),
-               '$admin' => $admin,
-               '$finding' => (strlen($search) ? '<h4>' . t('Finding: ') . "'" . $search . "'" . '</h4>' : ""),
-               '$sitedir' => t('Site Directory'),
-               '$submit' => t('Find')
-       ));
-       if($search)
-               $search = dbesc($search);
-       $sql_extra = ((strlen($search)) ? " AND MATCH (`profile`.`name`, `user`.`nickname`, `pdesc`, `locality`,`region`,`country-name`,`gender`,`marital`,`sexual`,`about`,`romance`,`work`,`education`,`pub_keywords`,`prv_keywords` ) AGAINST ('$search' IN BOOLEAN MODE) " : "");
-       $publish = ((get_config('system','publish_all')) ? '' : " AND `publish` = 1 " );
+               '$desc'      => L10n::t('Find on this site'),
+               '$admin'     => $admin,
+               '$finding'   => (strlen($search) ? '<h4>' . L10n::t('Finding: ') . "'" . $search . "'" . '</h4>' : ""),
+               '$sitedir'   => L10n::t('Site Directory'),
+               '$submit'    => L10n::t('Find')
+       ]);
+       $sql_extra = '';
+       if (strlen($search)) {
+               $sql_extra = " AND MATCH (`profile`.`name`, `user`.`nickname`, `pdesc`, `locality`,`region`,`country-name`,"
+                       . "`gender`,`marital`,`sexual`,`about`,`romance`,`work`,`education`,`pub_keywords`,`prv_keywords` )"
+                       . " AGAINST ('" . dbesc($search) . "' IN BOOLEAN MODE) ";
+       }
  
+       $publish = Config::get('system', 'publish_all') ? '' : " AND `publish` = 1 ";
  
-       $r = q("SELECT COUNT(*) AS `total` FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid` WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 AND `page-flags` = 2 $sql_extra ");
-       if(count($r))
+       $r = q("SELECT COUNT(*) AS `total` FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid`"
+               . " WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 AND `page-flags` = 2 $sql_extra ");
+       if (DBM::is_result($r)) {
                $a->set_pager_total($r[0]['total']);
+       }
  
 -      $order = " ORDER BY `name` ASC ";
 +      $order = " ORDER BY `name` ASC "; 
  
-       $r = q("SELECT `profile`.*, `profile`.`uid` AS `profile_uid`, `user`.`nickname`, `user`.`timezone` , `user`.`page-flags` FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid` WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 AND `page-flags` = 2 $sql_extra $order LIMIT %d , %d ",
+       $r = q("SELECT `profile`.*, `profile`.`uid` AS `profile_uid`, `user`.`nickname`, `user`.`timezone` , `user`.`page-flags`"
+               . " FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid` WHERE `is-default` = 1 $publish"
+               . " AND `user`.`blocked` = 0 AND `page-flags` = 2 $sql_extra $order LIMIT %d , %d ",
                intval($a->pager['start']),
                intval($a->pager['itemspage'])
        );
-       if(count($r)) {
  
-               if(in_array('small', $a->argv))
+       if (DBM::is_result($r)) {
+               if (in_array('small', $a->argv)) {
                        $photo = 'thumb';
-               else
+               } else {
                        $photo = 'photo';
+               }
  
-               foreach($r as $rr) {
+               foreach ($r as $rr) {
                        $profile_link = $a->get_baseurl() . '/profile/' . ((strlen($rr['nickname'])) ? $rr['nickname'] : $rr['profile_uid']);
 -
 +              
                        $pdesc = (($rr['pdesc']) ? $rr['pdesc'] . '<br />' : '');
  
                        $details = '';
index de8587445d9e32b621db06ae22752711139e91dc,afdb087b37cf163da27dd5d1d84ce5bb012ed5c1..a3944d6dbaef43268d5b264dcdde644647a0593b
@@@ -79,28 -79,32 +79,27 @@@ function fromapp_settings(&$a, &$s
  
        /* provide a submit button */
  
-       $s .= '<div class="settings-submit-wrapper" ><input type="submit" name="fromapp-submit" class="settings-submit" value="' . t('Save Settings') . '" /></div></div>';
+       $s .= '<div class="settings-submit-wrapper" ><input type="submit" name="fromapp-submit" class="settings-submit" value="' . L10n::t('Save Settings') . '" /></div></div>';
  }
  
 -function fromapp_post_hook(&$a, &$item)
 -{
 -      if (! local_user()) {
 -              return;
 -      }
 +function fromapp_post_hook(&$a,&$item) {
 +   if(! local_user())
 +        return;
  
 -      if (local_user() != $item['uid']) {
 -              return;
 -      }
 +    if(local_user() != $item['uid'])
 +        return;
  
 -      $app = PConfig::get(local_user(), 'fromapp', 'app');
 -      $force = intval(PConfig::get(local_user(), 'fromapp', 'force'));
 +    $app = get_pconfig(local_user(), 'fromapp', 'app');
 +      $force = intval(get_pconfig(local_user(), 'fromapp','force'));
  
 -      if (is_null($app) || (! strlen($app))) {
 -              return;
 -      }
 +    if(($app === false) || (! strlen($app)))
 +        return;
  
 -      if (strlen(trim($item['app'])) && (! $force)) {
 +      if(strlen(trim($item['app'])) && (! $force))
                return;
 -      }
  
 -      $apps = explode(',', $app);
 -      $item['app'] = trim($apps[mt_rand(0, count($apps)-1)]);
 -      
 +      $apps = explode(',',$app);
 +      $item['app'] = trim($apps[mt_rand(0,count($apps)-1)]);
        return;
 +
  }
index 097bac18599b1c4c3a29365a3d9f4692d54ff7e7,b8d9511a52f48c7628dde6c8f33dec05f8b5d4f2..b2c9b97f6132afff40738753e440feeb00545bda
@@@ -39,12 -47,12 +47,12 @@@ function fromgplus_addon_settings(&$a,&
        if (count($result) > 0)
                return;
  
 -      $enable_checked = (intval(PConfig::get(local_user(),'fromgplus','enable')) ? ' checked="checked"' : '');
 -      $keywords_checked = (intval(PConfig::get(local_user(), 'fromgplus', 'keywords')) ? ' checked="checked"' : '');
 -      $account = PConfig::get(local_user(),'fromgplus','account');
 +      $enable_checked = (intval(get_pconfig(local_user(),'fromgplus','enable')) ? ' checked="checked"' : '');
 +      $keywords_checked = (intval(get_pconfig(local_user(), 'fromgplus', 'keywords')) ? ' checked="checked"' : '');
 +      $account = get_pconfig(local_user(),'fromgplus','account');
  
        $s .= '<span id="settings_fromgplus_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_fromgplus_expanded\'); openClose(\'settings_fromgplus_inflated\');">';
-       $s .= '<img class="connector" src="images/googleplus.png" /><h3 class="connector">'. t('Google+ Mirror').'</h3>';
+       $s .= '<img class="connector" src="images/googleplus.png" /><h3 class="connector">'. L10n::t('Google+ Mirror').'</h3>';
        $s .= '</span>';
        $s .= '<div id="settings_fromgplus_expanded" class="settings-block" style="display: none;">';
        $s .= '<span class="fakelink" onclick="openClose(\'settings_fromgplus_expanded\'); openClose(\'settings_fromgplus_inflated\');">';
@@@ -76,16 -84,16 +84,16 @@@ function fromgplus_addon_settings_post(
                return;
  
        if($_POST['fromgplus-submit']) {
 -              PConfig::set(local_user(),'fromgplus','account',trim($_POST['fromgplus-account']));
 +              set_pconfig(local_user(),'fromgplus','account',trim($_POST['fromgplus-account']));
                $enable = ((x($_POST,'fromgplus-enable')) ? intval($_POST['fromgplus-enable']) : 0);
 -              PConfig::set(local_user(),'fromgplus','enable', $enable);
 +              set_pconfig(local_user(),'fromgplus','enable', $enable);
                $keywords = ((x($_POST, 'fromgplus-keywords')) ? intval($_POST['fromgplus-keywords']) : 0);
 -              PConfig::set(local_user(),'fromgplus', 'keywords', $keywords);
 +              set_pconfig(local_user(),'fromgplus', 'keywords', $keywords);
  
                if (!$enable)
 -                      PConfig::delete(local_user(),'fromgplus','lastdate');
 +                      del_pconfig(local_user(),'fromgplus','lastdate');
  
-               info( t('Google+ Import Settings saved.') . EOL);
+               info(L10n::t('Google+ Import Settings saved.') . EOL);
        }
  }
  
@@@ -429,10 -439,10 +437,10 @@@ function fromgplus_fetch($a, $uid) 
        // Special blank to identify postings from the googleplus connector
        $blank = html_entity_decode("&#x00A0;", ENT_QUOTES, 'UTF-8');
  
 -      $account = PConfig::get($uid,'fromgplus','account');
 -      $key = Config::get('fromgplus','key');
 +      $account = get_pconfig($uid,'fromgplus','account');
 +      $key = get_config('fromgplus','key');
  
-       $result = fetch_url("https://www.googleapis.com/plus/v1/people/".$account."/activities/public?alt=json&pp=1&key=".$key."&maxResults=".$maxfetch);
+       $result = Network::fetchUrl("https://www.googleapis.com/plus/v1/people/".$account."/activities/public?alt=json&pp=1&key=".$key."&maxResults=".$maxfetch);
        //$result = file_get_contents("google.txt");
        //file_put_contents("google.txt", $result);
  
index 34f850cb307ddb150c9cc347b0d1e98b9bf1a97c,89ccd88396441eabeb1c679f8d876ca11d5fee27..3c272c9b361370e3c895fa388e834eb3efcf763e
@@@ -12,12 -18,14 +18,13 @@@ function geocoordinates_install(
  }
  
  
- function geocoordinates_uninstall() {
-       unregister_hook('post_local',    'addon/geocoordinates/geocoordinates.php', 'geocoordinates_post_hook');
-       unregister_hook('post_remote',    'addon/geocoordinates/geocoordinates.php', 'geocoordinates_post_hook');
+ function geocoordinates_uninstall()
+ {
+       Addon::unregisterHook('post_local',    'addon/geocoordinates/geocoordinates.php', 'geocoordinates_post_hook');
+       Addon::unregisterHook('post_remote',    'addon/geocoordinates/geocoordinates.php', 'geocoordinates_post_hook');
  }
  
 -function geocoordinates_resolve_item(&$item)
 -{
 +function geocoordinates_resolve_item(&$item) {
        if((!$item["coord"]) || ($item["location"]))
                return;
  
index c10653a71f7f726c6a3ed11693af2ac3af439243,79e268e6eeddb2d948953fa2b41d32e97636d6ca..905dfdc599f7de36b4b0a9ef21d102bb750459e5
@@@ -135,12 -140,12 +140,12 @@@ function geonames_post_hook($a, &$item
   *
   */
  
- function geonames_plugin_admin_post($a,$post) {
+ function geonames_addon_admin_post($a,$post) {
        if(! local_user() || (! x($_POST,'geonames-submit')))
                return;
 -      PConfig::set(local_user(),'geonames','enable',intval($_POST['geonames']));
 +      set_pconfig(local_user(),'geonames','enable',intval($_POST['geonames']));
  
-       info( t('Geonames settings updated.') . EOL);
+       info(L10n::t('Geonames settings updated.') . EOL);
  }
  
  
diff --cc gnot/gnot.php
index fcdc7319f1520205258a55ace1f84e27558c0693,c7678a2185e8dbc0e08308e633df7d553980f7f6..87d28063b591ac29589b61f8c73e99a0c8fc881c
@@@ -91,9 -93,8 +93,8 @@@ function gnot_settings(&$a,&$s) 
  
  
  function gnot_enotify_mail(&$a,&$b) {
 -      if((! $b['uid']) || (! intval(PConfig::get($b['uid'], 'gnot','enable'))))
 +      if((! $b['uid']) || (! intval(get_pconfig($b['uid'], 'gnot','enable'))))
                return;
        if($b['type'] == NOTIFY_COMMENT)
-               $b['subject'] = sprintf( t('[Friendica:Notify] Comment to conversation #%d'), $b['parent']);
+               $b['subject'] = L10n::t('[Friendica:Notify] Comment to conversation #%d', $b['parent']);
  }
Simple merge
index eb38db78f6cc3859ac37d962c87c4c2c111a2c93,a765a2e0762150bd760a26fdccb31c231ecc8cdf..88db743b751b461e9696b6d2430323be10439535
@@@ -54,11 -57,11 +57,11 @@@ function gravatar_lookup($a, &$b) 
  /**
   * Display admin settings for this addon
   */
- function gravatar_plugin_admin (&$a, &$o) {
+ function gravatar_addon_admin (&$a, &$o) {
        $t = get_markup_template( "admin.tpl", "addon/gravatar/" );
  
 -      $default_avatar = Config::get('gravatar', 'default_img');
 -      $rating = Config::get('gravatar', 'rating');
 +      $default_avatar = get_config('gravatar', 'default_img');
 +      $rating = get_config('gravatar', 'rating');
  
        // set default values for first configuration
        if(! $default_avatar)
index 29b0675feec933bed4b033519b778f036fdbbd24,4c0cb14a9a3aeb211ae2626fbecedcb14323f9f9..d07d8aa56bcbb3f0517537cd30034acfc41c02db
@@@ -41,9 -41,9 +41,9 @@@ function group_text_uninstall() 
  function group_text_settings_post($a,$post) {
        if(! local_user() || (! x($_POST,'group_text-submit')))
                return;
 -      PConfig::set(local_user(),'system','groupedit_image_limit',intval($_POST['group_text']));
 +      set_pconfig(local_user(),'system','groupedit_image_limit',intval($_POST['group_text']));
  
-       info( t('Group Text settings updated.') . EOL);
+       info(L10n::t('Group Text settings updated.') . EOL);
  }
  
  
diff --cc ifttt/ifttt.php
index e5428e82b45b08935cdb0571e86098e018fec26f,bdb2b6076234c2ab808179dcb1b2b687eb08eec1..70aff1bfb3c0a9468e94edfd0c14de3cde968363
@@@ -5,36 -6,49 +5,44 @@@
   * Version: 0.1
   * Author: Michael Vogel <https://pirati.ca/profile/heluecht>
   */
- require_once("mod/item.php");
- require_once("include/items.php");
- function ifttt_install() {
-       register_hook('connector_settings',     'addon/ifttt/ifttt.php', 'ifttt_settings');
-       register_hook('connector_settings_post','addon/ifttt/ifttt.php', 'ifttt_settings_post');
+ require_once 'mod/item.php';
+ require_once 'include/items.php';
+ require_once 'include/text.php';
+ use Friendica\App;
+ use Friendica\Core\Addon;
+ use Friendica\Core\L10n;
+ use Friendica\Core\PConfig;
+ use Friendica\Database\DBM;
+ function ifttt_install()
+ {
+       Addon::registerHook('connector_settings', 'addon/ifttt/ifttt.php', 'ifttt_settings');
+       Addon::registerHook('connector_settings_post', 'addon/ifttt/ifttt.php', 'ifttt_settings_post');
  }
  
- function ifttt_uninstall() {
-       unregister_hook('connector_settings',   'addon/ifttt/ifttt.php', 'ifttt_settings');
-       unregister_hook('connector_settings_post', 'addon/ifttt/ifttt.php', 'ifttt_settings_post');
+ function ifttt_uninstall()
+ {
+       Addon::unregisterHook('connector_settings', 'addon/ifttt/ifttt.php', 'ifttt_settings');
+       Addon::unregisterHook('connector_settings_post', 'addon/ifttt/ifttt.php', 'ifttt_settings_post');
  }
  
 -function ifttt_module()
 -{
 -
 +function ifttt_module() {
  }
  
 -function ifttt_content()
 -{
 -
 +function ifttt_content(&$a) {
  }
  
 -function ifttt_settings(App $a, &$s)
 -{
 -      if (!local_user()) {
 -              return;
 -      }
 +function ifttt_settings(&$a,&$s) {
 +
 +        if(! local_user())
 +                return;
  
 -      $key = PConfig::get(local_user(), 'ifttt', 'key');
 +        $key = get_pconfig(local_user(),'ifttt','key');
  
        if (!$key) {
 -              $key = random_string(20);
 -              PConfig::set(local_user(), 'ifttt', 'key', $key);
 +              $key = substr(random_string(),0,20);
 +              set_pconfig(local_user(),'ifttt','key', $key);
        }
  
        $s .= '<span id="settings_ifttt_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_ifttt_expanded\'); openClose(\'settings_ifttt_inflated\');">';
        $s .= '<p>POST</p>';
        $s .= '<h4>Content Type</h4>';
        $s .= '<p>application/x-www-form-urlencoded</p>';
-       $s .= '<h4>'.t("Body for 'new status message'").'</h4>';
-       $s .= '<p><code>'.htmlentities('key='.$key.'&type=status&msg=<<<{{Message}}>>>&date=<<<{{UpdatedAt}}>>>&url=<<<{{PageUrl}}>>>').'</code></p>';
-       $s .= '<h4>'.t("Body for 'new photo upload'").'</h4>';
-       $s .= '<p><code>'.htmlentities('key='.$key.'&type=photo&link=<<<{{Link}}>>>&image=<<<{{ImageSource}}>>>&msg=<<<{{Caption}}>>>&date=<<<{{CreatedAt}}>>>&url=<<<{{PageUrl}}>>>').'</code></p>';
-       $s .= '<h4>'.t("Body for 'new link post'").'</h4>';
-       $s .= '<p><code>'.htmlentities('key='.$key.'&type=link&link=<<<{{Link}}>>>&title=<<<{{Title}}>>>&msg=<<<{{Message}}>>>&description=<<<{{Description}}>>>&date=<<<{{CreatedAt}}>>>&url=<<<{{PageUrl}}>>>').'</code></p>';
-         $s .= '</div><div class="clear"></div>';
-         $s .= '<div id="ifttt-rekey-wrapper">';
-         $s .= '<label id="ifttt-rekey-label" for="ifttt-checkbox">' . t('Generate new key') . '</label>';
-         $s .= '<input id="ifttt-checkbox" type="checkbox" name="ifttt-rekey" value="1" />';
-         $s .= '</div><div class="clear"></div>';
-       $s .= '<div class="settings-submit-wrapper" ><input type="submit" name="ifttt-submit" class="settings-submit" value="' . t('Save Settings') . '" /></div>';
-         $s .= '</div>';
+       $s .= '<h4>' . L10n::t('Body for "new status message"') . '</h4>';
+       $s .= '<p><code>' . htmlentities('key=' . $key . '&type=status&msg=<<<{{Message}}>>>&date=<<<{{UpdatedAt}}>>>&url=<<<{{PageUrl}}>>>') . '</code></p>';
+       $s .= '<h4>' . L10n::t('Body for "new photo upload"') . '</h4>';
+       $s .= '<p><code>' . htmlentities('key=' . $key . '&type=photo&link=<<<{{Link}}>>>&image=<<<{{ImageSource}}>>>&msg=<<<{{Caption}}>>>&date=<<<{{CreatedAt}}>>>&url=<<<{{PageUrl}}>>>') . '</code></p>';
+       $s .= '<h4>' . L10n::t('Body for "new link post"') . '</h4>';
+       $s .= '<p><code>' . htmlentities('key=' . $key . '&type=link&link=<<<{{Link}}>>>&title=<<<{{Title}}>>>&msg=<<<{{Message}}>>>&description=<<<{{Description}}>>>&date=<<<{{CreatedAt}}>>>&url=<<<{{PageUrl}}>>>') . '</code></p>';
+       $s .= '</div><div class="clear"></div>';
+       $s .= '<div id="ifttt-rekey-wrapper">';
+       $s .= '<label id="ifttt-rekey-label" for="ifttt-checkbox">' . L10n::t('Generate new key') . '</label>';
+       $s .= '<input id="ifttt-checkbox" type="checkbox" name="ifttt-rekey" value="1" />';
+       $s .= '</div><div class="clear"></div>';
+       $s .= '<div class="settings-submit-wrapper" ><input type="submit" name="ifttt-submit" class="settings-submit" value="' . L10n::t('Save Settings') . '" /></div>';
+       $s .= '</div>';
  }
  
 -function ifttt_settings_post()
 -{
 -      if (x($_POST, 'ifttt-submit') && isset($_POST['ifttt-rekey'])) {
 -              PConfig::delete(local_user(), 'ifttt', 'key');
 -      }
 +function ifttt_settings_post(&$a,&$b) {
 +
 +        if(x($_POST,'ifttt-submit'))
 +                if (isset($_POST['ifttt-rekey']))
 +                        del_pconfig(local_user(), 'ifttt', 'key');
  }
  
 -function ifttt_post(App $a)
 -{
 -      if ($a->argc != 2) {
 +function ifttt_post(&$a) {
 +      if ($a->argc != 2)
                return;
 -      }
  
 -      $nickname = $a->argv[1];
 +      $user = $a->argv[1];
  
 -      $user = dba::selectFirst('user', ['uid'], ['nickname' => $nickname]);
 -      if (!DBM::is_result($user)) {
 -              logger('User ' . $nickname . ' not found.', LOGGER_DEBUG);
 +      $r = q("SELECT `uid` FROM `user` WHERE `nickname` = '%s' LIMIT 1", dbesc($user));
 +      if (!$r) {
 +              logger("User ".$user." not found.", LOGGER_DEBUG);
                return;
        }
  
index 3e57610a3f9454eb1016ee4410bc20c1d69a0a7b,8d5290855f0e08496b9dc56e6f1ed18125862eed..091edec388c196007bf7cb7777ab6e6c2b7e4232
@@@ -31,12 -37,12 +37,12 @@@ function ijpost_jot_nets(&$a,&$b) 
      if(! local_user())
          return;
  
 -    $ij_post = PConfig::get(local_user(),'ijpost','post');
 +    $ij_post = get_pconfig(local_user(),'ijpost','post');
      if(intval($ij_post) == 1) {
 -        $ij_defpost = PConfig::get(local_user(),'ijpost','post_by_default');
 +        $ij_defpost = get_pconfig(local_user(),'ijpost','post_by_default');
          $selected = ((intval($ij_defpost) == 1) ? ' checked="checked" ' : '');
          $b .= '<div class="profile-jot-net"><input type="checkbox" name="ijpost_enable" ' . $selected . ' value="1" /> '
-             . t('Post to Insanejournal') . '</div>';
+             . L10n::t('Post to Insanejournal') . '</div>';
      }
  }
  
Simple merge
diff --cc irc/irc.php
index 0ac7be37e8ed3c27fa7ec56d887381a82aa8c73d,6aeacbe65ce4c90d59ef3f7b262eb09607461b2e..e8dd92f46f586dfb704e4755ce58479365403967
@@@ -29,17 -33,17 +33,17 @@@ function irc_addon_settings(&$a,&$s) 
  //    $a->page['htmlhead'] .= '<link rel="stylesheet"  type="text/css" href="' . $a->get_baseurl() . '/addon/irc/irc.css' . '" media="all" />' . "\r\n";
  
      /* setting popular channels, auto connect channels */
 -      $sitechats = PConfig::get( local_user(), 'irc','sitechats'); /* popular channels */
 -      $autochans = PConfig::get( local_user(), 'irc','autochans');  /* auto connect chans */
 +      $sitechats = get_pconfig( local_user(), 'irc','sitechats'); /* popular channels */
 +      $autochans = get_pconfig( local_user(), 'irc','autochans');  /* auto connect chans */
  
        $t = get_markup_template( "settings.tpl", "addon/irc/" );
-       $s .= replace_macros($t, array(
-               '$header' => t('IRC Settings'),
-               '$info' => t('Here you can change the system wide settings for the channels to automatically join and access via the side bar. Note the changes you do here, only effect the channel selection if you are logged in.'),
-               '$submit' => t('Save Settings'),
-               '$autochans' => array( 'autochans', t('Channel(s) to auto connect (comma separated)'), $autochans, t('List of channels that shall automatically connected to when the app is launched.')),
-               '$sitechats' => array( 'sitechats', t('Popular Channels (comma separated)'), $sitechats, t('List of popular channels, will be displayed at the side and hotlinked for easy joining.') )
-       ));
+       $s .= replace_macros($t, [
+               '$header' => L10n::t('IRC Settings'),
+               '$info' => L10n::t('Here you can change the system wide settings for the channels to automatically join and access via the side bar. Note the changes you do here, only effect the channel selection if you are logged in.'),
+               '$submit' => L10n::t('Save Settings'),
+               '$autochans' => [ 'autochans', L10n::t('Channel(s) to auto connect (comma separated)'), $autochans, L10n::t('List of channels that shall automatically connected to when the app is launched.')],
+               '$sitechats' => [ 'sitechats', L10n::t('Popular Channels (comma separated)'), $sitechats, L10n::t('List of popular channels, will be displayed at the side and hotlinked for easy joining.') ]
+       ]);
  
  
        return;
@@@ -51,10 -55,10 +55,10 @@@ function irc_addon_settings_post(&$a,&$
                return;
  
        if($_POST['irc-submit']) {
 -              PConfig::set( local_user(), 'irc','autochans',trim($_POST['autochans']));
 -              PConfig::set( local_user(), 'irc','sitechats',trim($_POST['sitechats']));
 +              set_pconfig( local_user(), 'irc','autochans',trim($_POST['autochans']));
 +              set_pconfig( local_user(), 'irc','sitechats',trim($_POST['sitechats']));
                /* upid pop-up thing */
-               info( t('IRC settings saved.') . EOL);
+               info(L10n::t('IRC settings saved.') . EOL);
        }
  }
  
@@@ -84,10 -88,10 +88,10 @@@ function irc_content(&$a) 
        if($sitechats)
                $chats = explode(',',$sitechats);
        else
 -              $chats = ['friendica','chat','chatback','hottub','ircbar','dateroom','debian'];
 +              $chats = array('friendica','chat','chatback','hottub','ircbar','dateroom','debian');
  
  
-       $a->page['aside'] .= '<div class="widget"><h3>' . t('Popular Channels') . '</h3><ul>';
+       $a->page['aside'] .= '<div class="widget"><h3>' . L10n::t('Popular Channels') . '</h3><ul>';
        foreach($chats as $chat) {
                $a->page['aside'] .= '<li><a href="' . $a->get_baseurl() . '/irc?channels=' . $chat . '" >' . '#' . $chat . '</a></li>';
        }
  EOT;
  
  return $o;
 -
 +    
  }
  
- function irc_plugin_admin_post (&$a) {
+ function irc_addon_admin_post (&$a) {
        if(! is_site_admin())
                return;
  
        if($_POST['irc-submit']) {
 -              Config::set('irc','autochans',trim($_POST['autochans']));
 -              Config::set('irc','sitechats',trim($_POST['sitechats']));
 +              set_config('irc','autochans',trim($_POST['autochans']));
 +              set_config('irc','sitechats',trim($_POST['sitechats']));
                /* stupid pop-up thing */
-               info( t('IRC settings saved.') . EOL);
+               info(L10n::t('IRC settings saved.') . EOL);
        }
  }
- function irc_plugin_admin (&$a, &$o) {
-       $sitechats = get_config('irc','sitechats'); /* popular channels */
-       $autochans = get_config('irc','autochans');  /* auto connect chans */
+ function irc_addon_admin (&$a, &$o) {
+       $sitechats = Config::get('irc','sitechats'); /* popular channels */
+       $autochans = Config::get('irc','autochans');  /* auto connect chans */
        $t = get_markup_template( "admin.tpl", "addon/irc/" );
-       $o = replace_macros($t, array(
-               '$submit' => t('Save Settings'),
-               '$autochans' => array( 'autochans', t('Channel(s) to auto connect (comma separated)'), $autochans, t('List of channels that shall automatically connected to when the app is launched.')),
-               '$sitechats' => array( 'sitechats', t('Popular Channels (comma separated)'), $sitechats, t('List of popular channels, will be displayed at the side and hotlinked for easy joining.') )
-       ));
+       $o = replace_macros($t, [
+               '$submit' => L10n::t('Save Settings'),
+               '$autochans' => [ 'autochans', L10n::t('Channel(s) to auto connect (comma separated)'), $autochans, L10n::t('List of channels that shall automatically connected to when the app is launched.')],
+               '$sitechats' => [ 'sitechats', L10n::t('Popular Channels (comma separated)'), $sitechats, L10n::t('List of popular channels, will be displayed at the side and hotlinked for easy joining.') ]
+       ]);
  }
index 370d2c7b7e6a1d550db0fb7656a2488f10298e98,23f99f17ad211fabf1278ce96d2d857e57fed0ec..fb9034935dcdb0c3ef4751263417d3815ef0a0dd
@@@ -55,59 -54,72 +55,67 @@@ reply with encrypted_address to Alice, 
    decrypted_address = openssl_*_decrypt(encrypted_address)
    save decrypted_address
  
 -  Interface for this:
 -  GET /jappixmini/?role=%s&signed_address=%s&dfrn_id=%s
 -
 -  Response:
 -  json({"status":"ok", "encrypted_address":"%s"})
 +Interface for this:
 +GET /jappixmini/?role=%s&signed_address=%s&dfrn_id=%s
  
 - */
 +Response:
 +json({"status":"ok", "encrypted_address":"%s"})
  
- */
+ use Friendica\App;
+ use Friendica\Core\Addon;
+ use Friendica\Core\Config;
+ use Friendica\Core\L10n;
+ use Friendica\Core\PConfig;
+ use Friendica\Model\User;
+ use Friendica\Util\Network;
  
- function jappixmini_install() {
- register_hook('plugin_settings', 'addon/jappixmini/jappixmini.php', 'jappixmini_settings');
- register_hook('plugin_settings_post', 'addon/jappixmini/jappixmini.php', 'jappixmini_settings_post');
+ function jappixmini_install()
+ {
+       Addon::registerHook('addon_settings', 'addon/jappixmini/jappixmini.php', 'jappixmini_settings');
+       Addon::registerHook('addon_settings_post', 'addon/jappixmini/jappixmini.php', 'jappixmini_settings_post');
  
register_hook('page_end', 'addon/jappixmini/jappixmini.php', 'jappixmini_script');
register_hook('authenticate', 'addon/jappixmini/jappixmini.php', 'jappixmini_login');
      Addon::registerHook('page_end', 'addon/jappixmini/jappixmini.php', 'jappixmini_script');
      Addon::registerHook('authenticate', 'addon/jappixmini/jappixmini.php', 'jappixmini_login');
  
register_hook('cron', 'addon/jappixmini/jappixmini.php', 'jappixmini_cron');
      Addon::registerHook('cron', 'addon/jappixmini/jappixmini.php', 'jappixmini_cron');
  
- // Jappix source download as required by AGPL
register_hook('about_hook', 'addon/jappixmini/jappixmini.php', 'jappixmini_download_source');
      // Jappix source download as required by AGPL
      Addon::registerHook('about_hook', 'addon/jappixmini/jappixmini.php', 'jappixmini_download_source');
  
 -      // set standard configuration
 -      $info_text = Config::get("jappixmini", "infotext");
 -      if (!$info_text)
 -              set_confConfig::setig("jappixmini", "infotext", "To get the chat working, you need to know a BOSH host which works with your Jabber account. " .
 -                      "An example of a BOSH server that works for all accounts is https://bind.jappix.com/, but keep " .
 -                      "in mind that the BOSH server can read along all chat messages. If you know that your Jabber " .
 -                      "server also provides an own BOSH server, it is much better to use this one!"
 -              );
 -
 -      $bosh_proxy = Config::get("jappixmini", "bosh_proxy");
 -      if ($bosh_proxy === "") {
 -              Config::set("jappixmini", "bosh_proxy", "1");
 -      }
 -
 -      // set addon version so that safe updates are possible later
 -      $addon_version = Config::get("jappixmini", "version");
 -      if ($addon_version === "") {
 -              Config::set("jappixmini", "version", "1");
 -      }
 +// set standard configuration
 +$info_text = get_config("jappixmini", "infotext");
 +if (!$info_text) set_config("jappixmini", "infotext",
 +      "To get the chat working, you need to know a BOSH host which works with your Jabber account. ".
 +      "An example of a BOSH server that works for all accounts is https://bind.jappix.com/, but keep ".
 +      "in mind that the BOSH server can read along all chat messages. If you know that your Jabber ".
 +      "server also provides an own BOSH server, it is much better to use this one!"
 +);
 +
 +$bosh_proxy = get_config("jappixmini", "bosh_proxy");
 +if ($bosh_proxy==="") set_config("jappixmini", "bosh_proxy", "1");
 +
 +// set addon version so that safe updates are possible later
 +$addon_version = get_config("jappixmini", "version");
 +if ($addon_version==="") set_config("jappixmini", "version", "1");
  }
  
+ function jappixmini_uninstall()
+ {
+       Addon::unregisterHook('addon_settings', 'addon/jappixmini/jappixmini.php', 'jappixmini_settings');
+       Addon::unregisterHook('addon_settings_post', 'addon/jappixmini/jappixmini.php', 'jappixmini_settings_post');
  
- function jappixmini_uninstall() {
- unregister_hook('plugin_settings', 'addon/jappixmini/jappixmini.php', 'jappixmini_settings');
- unregister_hook('plugin_settings_post', 'addon/jappixmini/jappixmini.php', 'jappixmini_settings_post');
- unregister_hook('page_end', 'addon/jappixmini/jappixmini.php', 'jappixmini_script');
- unregister_hook('authenticate', 'addon/jappixmini/jappixmini.php', 'jappixmini_login');
+       Addon::unregisterHook('page_end', 'addon/jappixmini/jappixmini.php', 'jappixmini_script');
+       Addon::unregisterHook('authenticate', 'addon/jappixmini/jappixmini.php', 'jappixmini_login');
  
unregister_hook('cron', 'addon/jappixmini/jappixmini.php', 'jappixmini_cron');
      Addon::unregisterHook('cron', 'addon/jappixmini/jappixmini.php', 'jappixmini_cron');
  
unregister_hook('about_hook', 'addon/jappixmini/jappixmini.php', 'jappixmini_download_source');
      Addon::unregisterHook('about_hook', 'addon/jappixmini/jappixmini.php', 'jappixmini_download_source');
  }
  
- function jappixmini_plugin_admin(&$a, &$o) {
+ function jappixmini_addon_admin(App $a, &$o)
+ {
        // display instructions and warnings on addon settings page for admin
 +
        if (!file_exists("addon/jappixmini.tgz")) {
                $o .= '<p><strong style="color:#fff;background-color:#f00">The source archive jappixmini.tgz does not exist. This is probably a violation of the Jappix License (AGPL).</strong></p>';
        }
@@@ -206,13 -227,16 +215,15 @@@ function jappixmini_init(&$a) 
                $decrypt_func($signed_address, $trusted_address, $key);
  
                $now = intval(time());
 -              PConfig::set($uid, "jappixmini", "id:$dfrn_id", "$now:$trusted_address");
 +              set_pconfig($uid, "jappixmini", "id:$dfrn_id", "$now:$trusted_address");
        } catch (Exception $e) {
 -
        }
  
-       // do not return an address if user deactivated plugin
-       $activated = get_pconfig($uid, 'jappixmini', 'activate');
-       if (!$activated) killme();
+       // do not return an address if user deactivated addon
+       $activated = PConfig::get($uid, 'jappixmini', 'activate');
+       if (!$activated) {
+               killme();
+       }
  
        // return the requested Jabber address
        try {
index 148fde313a43557d9b2068aa773c029127731590,2b15720b4fa5eeb0c72ae00fcbb82499346756e1..e16ee2d074bf655754cb78685ef7262cae16615d
@@@ -39,21 -40,21 +40,21 @@@ function js_upload_form(&$a,&$b) 
  
        $b['addon_text'] .= '<link href="' . $a->get_baseurl() . '/addon/js_upload/file-uploader/client/fileuploader.css" rel="stylesheet" type="text/css">';
        $b['addon_text'] .= '<script src="' . $a->get_baseurl() . '/addon/js_upload/file-uploader/client/fileuploader.js" type="text/javascript"></script>';
-    
-       $upload_msg = t('Upload a file');
-       $drop_msg = t('Drop files here to upload');
-       $cancel = t('Cancel');
-       $failed = t('Failed');
+       $upload_msg = L10n::t('Upload a file');
+       $drop_msg = L10n::t('Drop files here to upload');
+       $cancel = L10n::t('Cancel');
+       $failed = L10n::t('Failed');
  
 -      $maximagesize = intval(Config::get('system','maximagesize'));
 +      $maximagesize = intval(get_config('system','maximagesize'));
  
        $b['addon_text'] .= <<< EOT
 -
 - <div id="file-uploader-demo1">
 -  <noscript>
 +      
 + <div id="file-uploader-demo1">               
 +  <noscript>                  
     <p>Please enable JavaScript to use file uploader.</p>
     <!-- or put a simple form for upload here -->
 -  </noscript>
 +  </noscript> 
   </div>
  
  <script type="text/javascript">
@@@ -298,27 -299,27 +299,27 @@@ class qqFileUploader 
       * Returns array('success'=>true) or array('error'=>'error message')
       */
      function handleUpload(){
 -
 +        
          if (!$this->file){
-             return array('error' => t('No files were uploaded.'));
+             return ['error' => L10n::t('No files were uploaded.')];
          }
 -
 +        
          $size = $this->file->getSize();
 -
 +        
          if ($size == 0) {
-             return array('error' => t('Uploaded file is empty'));
+             return ['error' => L10n::t('Uploaded file is empty')];
          }
 -
 +        
  //        if ($size > $this->sizeLimit) {
  
- //            return array('error' => t('Uploaded file is too large'));
+ //            return array('error' => L10n::t('Uploaded file is too large'));
  //        }
 +        
  
 -
 -              $maximagesize = Config::get('system','maximagesize');
 +              $maximagesize = get_config('system','maximagesize');
  
                if(($maximagesize) && ($size > $maximagesize)) {
-                       return array('error' => t('Image exceeds size limit of ') . $maximagesize );
+                       return ['error' => L10n::t('Image exceeds size limit of ') . $maximagesize ];
  
                }
  
  
          if($this->allowedExtensions && !in_array(strtolower($ext), $this->allowedExtensions)){
              $these = implode(', ', $this->allowedExtensions);
-             return array('error' => t('File has an invalid extension, it should be one of ') . $these . '.');
+             return ['error' => L10n::t('File has an invalid extension, it should be one of ') . $these . '.'];
          }
 -
 +        
          if ($this->file->save()){
 -            return [
 +            return array(
                                'success'=>true,
 -                              'path' => $this->file->getPath(),
 +                              'path' => $this->file->getPath(), 
                                'filename' => $filename . '.' . $ext
 -                      ];
 +                      );
          } else {
-             return array(
-                               'error'=> t('Upload was cancelled, or server error encountered'),
-                               'path' => $this->file->getPath(), 
+             return [
+                               'error'=> L10n::t('Upload was cancelled, or server error encountered'),
+                               'path' => $this->file->getPath(),
                                'filename' => $filename . '.' . $ext
 -                      ];
 +                      );
          }
 -
 -    }
 +        
 +    }    
  }
diff --cc krynn/krynn.php
Simple merge
index d4fe942d0b23c1fe19b44461d9aaa5fe8cc3d052,81f9f6ecb4bf12f772a540a35eabd9f5c952ca96..5df153eb978a1ce26bf99f8eeb90670231e44969
@@@ -29,27 -36,32 +36,27 @@@ function langfilter_uninstall(
   * 2nd get the current settings
   * 3rd parse a SMARTY3 template, replacing some translateable strings for the form
   */
 -
 -function langfilter_addon_settings(App $a, &$s)
 -{
 -      if (!local_user()) {
 +function langfilter_addon_settings(&$a,&$s) {
 +      if(! local_user())
                return;
 -      }
 -
 -      $enable_checked = (intval(PConfig::get(local_user(), 'langfilter', 'disable')) ? '' : ' checked="checked" ');
 -      $languages      = PConfig::get(local_user(), 'langfilter', 'languages');
 -      $minconfidence  = PConfig::get(local_user(), 'langfilter', 'minconfidence') * 100;
 -      $minlength      = PConfig::get(local_user(), 'langfilter', 'minlength');
  
 -      if (!$languages) {
 +      $enable_checked = (intval(get_pconfig(local_user(),'langfilter','disable')) ? '' : ' checked="checked" ');
 +      $languages = get_pconfig(local_user(),'langfilter','languages');
 +      $minconfidence = get_pconfig(local_user(),'langfilter','minconfidence')*100;
 +      $minlength = get_pconfig(local_user(),'langfilter','minlength');
 +      if(! $languages)
                $languages = 'en,de,fr,it,es';
 -      }
  
-       $t = get_markup_template("settings.tpl", "addon/langfilter/" );
-       $s .= replace_macros ($t, array(
-           '$title' => t("Language Filter"),
-           '$intro' => t ('This addon tries to identify the language of a postings. If it does not match any language spoken by you (see below) the posting will be collapsed. Remember detecting the language is not perfect, especially with short postings.'),
-           '$enabled' => array('langfilter_enable', t('Use the language filter'), $enable_checked, ''),
-           '$languages' => array('langfilter_languages', t('I speak'), $languages, t('List of abbreviations (iso2 codes) for languages you speak, comma separated. For example "de,it".') ),
-           '$minconfidence' => array('langfilter_minconfidence', t('Minimum confidence in language detection'), $minconfidence, t('Minimum confidence in language detection being correct, from 0 to 100. Posts will not be filtered when the confidence of language detection is below this percent value.') ),
-           '$minlength' => array('langfilter_minlength', t('Minimum length of message body'), $minlength, t('Minimum length of message body for language filter to be used. Posts shorter than this number of characters will not be filtered.') ),
-           '$submit' => t('Save Settings'),
-       ));
+       $t = get_markup_template("settings.tpl", "addon/langfilter/");
+       $s .= replace_macros($t, [
+               '$title'         => L10n::t("Language Filter"),
+               '$intro'         => L10n::t('This addon tries to identify the language of a postings. If it does not match any language spoken by you (see below) the posting will be collapsed. Remember detecting the language is not perfect, especially with short postings.'),
+               '$enabled'       => ['langfilter_enable', L10n::t('Use the language filter'), $enable_checked, ''],
+               '$languages'     => ['langfilter_languages', L10n::t('I speak'), $languages, L10n::t('List of abbreviations (iso2 codes) for languages you speak, comma separated. For example "de,it".')],
+               '$minconfidence' => ['langfilter_minconfidence', L10n::t('Minimum confidence in language detection'), $minconfidence, L10n::t('Minimum confidence in language detection being correct, from 0 to 100. Posts will not be filtered when the confidence of language detection is below this percent value.')],
+               '$minlength'     => ['langfilter_minlength', L10n::t('Minimum length of message body'), $minlength, L10n::t('Minimum length of message body for language filter to be used. Posts shorter than this number of characters will not be filtered.')],
+               '$submit'        => L10n::t('Save Settings'),
+       ]);
  
        return;
  }
   * 2nd check the langfilter form is to be saved
   * 3rd save the settings to the DB for later usage
   */
 -
 -function langfilter_addon_settings_post(App $a, &$b)
 -{
 -      if (!local_user()) {
 +function langfilter_addon_settings_post(&$a,&$b) {
 +      if(! local_user())
                return;
 -      }
  
-       if($_POST['langfilter-settings-submit']) {
-               set_pconfig(local_user(),'langfilter','languages',trim($_POST['langfilter_languages']));
-               $enable = ((x($_POST,'langfilter_enable')) ? intval($_POST['langfilter_enable']) : 0);
-               $disable = 1-$enable;
-               set_pconfig(local_user(),'langfilter','disable', $disable);
-               $minconfidence = 0+$_POST['langfilter_minconfidence'];
-               if ( ! $minconfidence ) $minconfidence = 0;
-               else if ( $minconfidence < 0 ) $minconfidence = 0;
-               else if ( $minconfidence > 100 ) $minconfidence = 100;
-               set_pconfig(local_user(),'langfilter','minconfidence', $minconfidence/100.0);
-               $minlength = 0+$_POST['langfilter_minlength'];
-               if ( ! $minlength ) $minlength = 32;
-               else if ( $minlength < 0 ) $minlength = 32;
-               set_pconfig(local_user(),'langfilter','minlength', $minlength);
-               info( t('Language Filter Settings saved.') . EOL);
+       if ($_POST['langfilter-settings-submit']) {
+               PConfig::set(local_user(), 'langfilter', 'languages', trim($_POST['langfilter_languages']));
+               $enable = ((x($_POST, 'langfilter_enable')) ? intval($_POST['langfilter_enable']) : 0);
+               $disable = 1 - $enable;
+               PConfig::set(local_user(), 'langfilter', 'disable', $disable);
+               $minconfidence = 0 + $_POST['langfilter_minconfidence'];
+               if (!$minconfidence) {
+                       $minconfidence = 0;
+               } elseif ($minconfidence < 0) {
+                       $minconfidence = 0;
+               } elseif ($minconfidence > 100) {
+                       $minconfidence = 100;
+               }
+               PConfig::set(local_user(), 'langfilter', 'minconfidence', $minconfidence / 100.0);
+               $minlength = 0 + $_POST['langfilter_minlength'];
+               if (!$minlength) {
+                       $minlength = 32;
+               } elseif ($minlengt8h < 0) {
+                       $minlength = 32;
+               }
+               PConfig::set(local_user(), 'langfilter', 'minlength', $minlength);
+               info(L10n::t('Language Filter Settings saved.') . EOL);
        }
  }
 -
  /* Actually filter postings by their language
   * 1st check if the user wants to filter postings
   * 2nd get the user settings which languages shall be not filtered out
   *     of the user, then collapse the posting, but provide a link to
   *     expand it again.
   */
 +function langfilter_prepare_body(&$a,&$b) {
  
 -function langfilter_prepare_body(App $a, &$b)
 -{
 -      $logged_user = local_user();
 -      if (!$logged_user) {
 -              return;
 -      }
 +    $logged_user = local_user();
 +    if ( ! $logged_user ) return;
  
 -      // Never filter own messages
 -      // TODO: find a better way to extract this
 -      $logged_user_profile = $a->get_baseurl() . '/profile/' . $a->user['nickname'];
 -      if ($logged_user_profile == $b['item']['author-link']) {
 -              return;
 -      }
 +    # Never filter own messages
 +    # TODO: find a better way to extract this
 +    $logged_user_profile = $a->config['system']['url'] . '/profile/' . $a->user['nickname'];
 +    if ( $logged_user_profile == $b['item']['author-link'] ) return;
  
 -      // Don't filter if language filter is disabled
 -      if (PConfig::get($logged_user, 'langfilter', 'disable')) {
 -              return;
 -      }
 +    # Don't filter if language filter is disabled
 +    if( get_pconfig($logged_user,'langfilter','disable') ) return;
  
 -      // Don't filter if body lenght is below minimum
 -      $minlen = PConfig::get(local_user(), 'langfilter', 'minlength');
 -      if (!$minlen) {
 -              $minlen = 32;
 -      }
 -      if (strlen($b['item']['body']) < $minlen) {
 -              return;
 -      }
 +    # Don't filter if body lenght is below minimum
 +    $minlen = get_pconfig(local_user(),'langfilter','minlength');
 +    if ( ! $minlen ) $minlen = 32;
 +    if ( strlen($b['item']['body']) < $minlen ) return;
  
 -      $spoken_config = PConfig::get(local_user(), 'langfilter', 'languages');
 -      $minconfidence = PConfig::get(local_user(), 'langfilter', 'minconfidence');
 +    $spoken_config = get_pconfig(local_user(),'langfilter','languages');
 +    $minconfidence = get_pconfig(local_user(),'langfilter','minconfidence');
  
 -      // Don't filter if no spoken languages are configured
 -      if (!$spoken_config)
 -              return;
 -      $spoken_languages = explode(',', $spoken_config);
 +    # Don't filter if no spoken languages are configured 
 +    if ( ! $spoken_config ) return;
 +    $spoken_languages = explode(',', $spoken_config);
  
 -      // Extract the language of the post
 -      $opts = $b['item']['postopts'];
 -      if (!$opts) {
 -              // no options associated to post
 -              return;
 -      }
 -      if (!preg_match('/\blang=([^;]*);([^:]*)/', $opts, $matches)) {
 -              // no lang options associated to post
 -              return;
 -      }
 +    # Extract the language of the post
 +    $opts = $b['item']['postopts'];
 +    if ( ! $opts ) return; # no options associated to post
 +    if ( ! preg_match('/\blang=([^;]*);([^:]*)/', $opts, $matches ) )
 +            return; # no lang options associated to post
  
 -      $lang = $matches[1];
 -      $confidence = $matches[2];
 +    $lang = $matches[1];
 +    $confidence = $matches[2];
  
 -      // Do not filter if language detection confidence is too low
 -      if ($minconfidence && $confidence < $minconfidence) {
 -              return;
 -      }
 +    # Do not filter if language detection confidence is too low
 +    if ( $minconfidence && $confidence < $minconfidence ) return;
  
 -      $iso2 = Text_LanguageDetect_ISO639::nameToCode2($lang);
 +    $iso2 = Text_LanguageDetect_ISO639::nameToCode2($lang);
  
 -      if (!$iso2) {
 -              return;
 -      }
 -      $spoken = in_array($iso2, $spoken_languages);
 +    if ( ! $iso2 ) return;
 +    $spoken = in_array($iso2, $spoken_languages);
  
-     if( ! $spoken ) {
-         $rnd = random_string(8);
-         $b['html'] = '<div id="langfilter-wrap-' . $rnd . '" class="fakelink" onclick=openClose(\'langfilter-' . $rnd . '\'); >' . sprintf( t('unspoken language %s - Click to open/close'),$lang ) . '</div><div id="langfilter-' . $rnd . '" style="display: none; " >' . $b['html'] . '</div>';
-     }
+       if (!$spoken) {
+               $rnd = random_string(8);
+               $b['html'] = '<div id="langfilter-wrap-' . $rnd . '" class="fakelink" onclick=openClose(\'langfilter-' . $rnd . '\'); >' . L10n::t('unspoken language %s - Click to open/close', $lang) . '</div><div id="langfilter-' . $rnd . '" style="display: none; " >' . $b['html'] . '</div>';
+       }
  }
 +?>
index 60273c3b824d29398e10471f4e403d923368ee2f,d06874b7cbfaf1696e7a0416a4ee0c7ee28c2573..4a882a212df686e480581e48b57f9634de566085
   *
   * ...etc.
   */
+ use Friendica\Core\Addon;
+ use Friendica\Core\Config;
+ use Friendica\Model\User;
  
- require_once('include/user.php');
- function ldapauth_install() {
-       register_hook('authenticate', 'addon/ldapauth/ldapauth.php', 'ldapauth_hook_authenticate');
+ function ldapauth_install()
+ {
+       Addon::registerHook('authenticate', 'addon/ldapauth/ldapauth.php', 'ldapauth_hook_authenticate');
  }
  
function ldapauth_uninstall() {
-       unregister_hook('authenticate', 'addon/ldapauth/ldapauth.php', 'ldapauth_hook_authenticate');
+ function ldapauth_uninstall()
+ {
+       Addon::unregisterHook('authenticate', 'addon/ldapauth/ldapauth.php', 'ldapauth_hook_authenticate');
  }
  
 -function ldapauth_hook_authenticate($a, &$b)
 -{
 -      if (ldapauth_authenticate($b['username'], $b['password'])) {
 -              $results = get_existing_account($b['username']);
 -              if (!empty($results)) {
 -                      $b['user_record'] = $results[0];
 -                      $b['authenticated'] = 1;
 -              }
 -      }
 -      return;
 +
 +function ldapauth_hook_authenticate($a,&$b) {
 +    if(ldapauth_authenticate($b['username'],$b['password'])) {
 +      $results = get_existing_account($b['username']);
 +      if(! empty($results)){
 +            $b['user_record'] = $results[0];
 +            $b['authenticated'] = 1;
 +      }
 +    }
 +    return;
  }
  
 -function ldapauth_authenticate($username, $password)
 -{
 -      $ldap_server   = Config::get('ldapauth', 'ldap_server');
 -      $ldap_binddn   = Config::get('ldapauth', 'ldap_binddn');
 -      $ldap_bindpw   = Config::get('ldapauth', 'ldap_bindpw');
 -      $ldap_searchdn = Config::get('ldapauth', 'ldap_searchdn');
 -      $ldap_userattr = Config::get('ldapauth', 'ldap_userattr');
 -      $ldap_group    = Config::get('ldapauth', 'ldap_group');
 -      $ldap_autocreateaccount = Config::get('ldapauth', 'ldap_autocreateaccount');
 -      $ldap_autocreateaccount_emailattribute = Config::get('ldapauth', 'ldap_autocreateaccount_emailattribute');
 -      $ldap_autocreateaccount_nameattribute  = Config::get('ldapauth', 'ldap_autocreateaccount_nameattribute');
 -
 -      if (!(strlen($password) && function_exists('ldap_connect') && strlen($ldap_server))) {
 -              logger("ldapauth: not configured or missing php-ldap module");
 -              return false;
 -      }
 -
 -      $connect = @ldap_connect($ldap_server);
 -
 -      if ($connect === false) {
 -              logger("ldapauth: could not connect to $ldap_server");
 -              return false;
 -      }
 -
 -      @ldap_set_option($connect, LDAP_OPT_PROTOCOL_VERSION, 3);
 -      @ldap_set_option($connect, LDAP_OPT_REFERRALS, 0);
 -      if ((@ldap_bind($connect, $ldap_binddn, $ldap_bindpw)) === false) {
 -              logger("ldapauth: could not bind $ldap_server as $ldap_binddn");
 -              return false;
 -      }
 -
 -      $res = @ldap_search($connect, $ldap_searchdn, $ldap_userattr . '=' . $username);
 -
 -      if (!$res) {
 -              logger("ldapauth: $ldap_userattr=$username,$ldap_searchdn not found");
 -              return false;
 -      }
 -
 -      $id = @ldap_first_entry($connect, $res);
 -
 -      if (!$id) {
 -              return false;
 -      }
 -
 -      $dn = @ldap_get_dn($connect, $id);
 -
 -      if (!@ldap_bind($connect, $dn, $password)) {
 -              return false;
 -      }
 -
 -      $emailarray = [];
 -      $namearray = [];
 -      if ($ldap_autocreateaccount == "true") {
 -              if (!strlen($ldap_autocreateaccount_emailattribute)) {
 -                      $ldap_autocreateaccount_emailattribute = "mail";
 -              }
 -              if (!strlen($ldap_autocreateaccount_nameattribute)) {
 -                      $ldap_autocreateaccount_nameattribute = "givenName";
 -              }
 -              $emailarray = @ldap_get_values($connect, $id, $ldap_autocreateaccount_emailattribute);
 -              $namearray = @ldap_get_values($connect, $id, $ldap_autocreateaccount_nameattribute);
 -      }
 -
 -      if (!strlen($ldap_group)) {
 -              ldap_autocreateaccount($ldap_autocreateaccount, $username, $password, $emailarray[0], $namearray[0]);
 -              return true;
 -      }
 -
 -      $r = @ldap_compare($connect, $ldap_group, 'member', $dn);
 -      if ($r === -1) {
 -              $err = @ldap_error($connect);
 -              $eno = @ldap_errno($connect);
 -              @ldap_close($connect);
 -
 -              if ($eno === 32) {
 -                      logger("ldapauth: access control group Does Not Exist");
 -                      return false;
 -              } elseif ($eno === 16) {
 -                      logger('ldapauth: membership attribute does not exist in access control group');
 -                      return false;
 -              } else {
 -                      logger('ldapauth: error: ' . $err);
 -                      return false;
 -              }
 -      } elseif ($r === false) {
 -              @ldap_close($connect);
 -              return false;
 -      }
 -
 -      ldap_autocreateaccount($ldap_autocreateaccount, $username, $password, $emailarray[0], $namearray[0]);
 -      return true;
 +function ldapauth_authenticate($username,$password) {
 +
 +    $ldap_server   = get_config('ldapauth','ldap_server');
 +    $ldap_binddn   = get_config('ldapauth','ldap_binddn');
 +    $ldap_bindpw   = get_config('ldapauth','ldap_bindpw');
 +    $ldap_searchdn = get_config('ldapauth','ldap_searchdn');
 +    $ldap_userattr = get_config('ldapauth','ldap_userattr');
 +    $ldap_group    = get_config('ldapauth','ldap_group');
 +    $ldap_autocreateaccount = get_config('ldapauth','ldap_autocreateaccount');
 +    $ldap_autocreateaccount_emailattribute = get_config('ldapauth','ldap_autocreateaccount_emailattribute');
 +    $ldap_autocreateaccount_nameattribute = get_config('ldapauth','ldap_autocreateaccount_nameattribute');
 +      
 +    if(! ((strlen($password))
 +            && (function_exists('ldap_connect'))
 +            && (strlen($ldap_server)))) {
 +            logger("ldapauth: not configured or missing php-ldap module");
 +            return false;
 +    }
 +
 +    $connect = @ldap_connect($ldap_server);
 +
 +    if($connect === false) {
 +        logger("ldapauth: could not connect to $ldap_server");
 +        return false;
 +    }
 +
 +    @ldap_set_option($connect, LDAP_OPT_PROTOCOL_VERSION,3);
 +    @ldap_set_option($connect, LDAP_OPT_REFERRALS, 0);
 +    if((@ldap_bind($connect,$ldap_binddn,$ldap_bindpw)) === false) {
 +        logger("ldapauth: could not bind $ldap_server as $ldap_binddn");
 +        return false;
 +    }
 +
 +    $res = @ldap_search($connect,$ldap_searchdn, $ldap_userattr . '=' . $username);
 +
 +    if(! $res) {
 +        logger("ldapauth: $ldap_userattr=$username,$ldap_searchdn not found");
 +        return false;
 +    }
 +
 +    $id = @ldap_first_entry($connect,$res);
 +
 +    if(! $id) {
 +        return false;
 +    }
 +
 +    $dn = @ldap_get_dn($connect,$id);
 +
 +    if(! @ldap_bind($connect,$dn,$password))
 +        return false;
 +    
 +    $emailarray = [];
 +    $namearray = [];
 +    if($ldap_autocreateaccount == "true"){
 +        if(! strlen($ldap_autocreateaccount_emailattribute))
 +            $ldap_autocreateaccount_emailattribute = "mail";
 +        if(! strlen($ldap_autocreateaccount_nameattribute))
 +            $ldap_autocreateaccount_nameattribute = "givenName";
 +      $emailarray = @ldap_get_values($connect, $id, $ldap_autocreateaccount_emailattribute);
 +      $namearray = @ldap_get_values($connect, $id, $ldap_autocreateaccount_nameattribute);
 +    }
 +
 +    if(! strlen($ldap_group)){
 +      ldap_autocreateaccount($ldap_autocreateaccount,$username,$password,$emailarray[0],$namearray[0]);
 +        return true;
 +    }
 +
 +    $r = @ldap_compare($connect,$ldap_group,'member',$dn);
 +    if ($r === -1) {
 +        $err = @ldap_error($connect);
 +        $eno = @ldap_errno($connect);
 +        @ldap_close($connect);
 +
 +        if ($eno === 32) {
 +            logger("ldapauth: access control group Does Not Exist");
 +            return false;
 +        }
 +        elseif ($eno === 16) {
 +            logger('ldapauth: membership attribute does not exist in access control group');
 +            return false;
 +        }
 +        else {
 +            logger('ldapauth: error: ' . $err);
 +            return false;
 +        }
 +    }
 +    elseif ($r === false) {
 +        @ldap_close($connect);
 +        return false;
 +    }
 +
 +    ldap_autocreateaccount($ldap_autocreateaccount,$username,$password,$emailarray[0],$namearray[0]);
 +    return true;
  }
  
 -function ldap_autocreateaccount($ldap_autocreateaccount, $username, $password, $email, $name)
 -{
 -      if ($ldap_autocreateaccount == "true") {
 -              $results = get_existing_account($username);
 -              if (empty($results)) {
 -                      if (strlen($email) > 0 && strlen($name) > 0) {
 -                              $arr = ['username' => $name, 'nickname' => $username, 'email' => $email, 'password' => $password, 'verified' => 1];
 -
 -                              try {
 -                                      User::create($arr);
 -                                      logger("ldapauth: account " . $username . " created");
 -                              } catch (Exception $ex) {
 -                                      logger("ldapauth: account " . $username . " was not created ! : " . $ex->getMessage());
 -                              }
 -                      } else {
 -                              logger("ldapauth: unable to create account, no email or nickname found");
 -                      }
 -              }
 -      }
 +function ldap_autocreateaccount($ldap_autocreateaccount,$username,$password,$email,$name) {
 +    if($ldap_autocreateaccount == "true"){
 +        $results = get_existing_account($username);
 +        if(empty($results)){
 +            if (strlen($email) > 0 && strlen($name) > 0){
 +                $arr = array('username'=>$name,'nickname'=>$username,'email'=>$email,'password'=>$password,'verified'=>1);
 +                $result = create_user($arr);
 +                if ($result['success']){
 +                    logger("ldapauth: account " . $username . " created");
 +                }else{
 +                    logger("ldapauth: account " . $username . " was not created ! : " . implode($result));
 +                }
 +            }else{
 +                logger("ldapauth: unable to create account, no email or nickname found");
 +            }
 +        }
 +    }
  }
  
 -function get_existing_account($username)
 -{
 -      return q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `blocked` = 0 AND `verified` = 1 LIMIT 1", $username);
 +function get_existing_account($username){
 +    return q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `blocked` = 0 AND `verified` = 1 LIMIT 1",$username);
  }
index c58c707f0275647b29f426dcbcf03f4fda670bb5,04d3e556d6bbba17babed29cec1b3e6e37266a17..0c3136a4c326d7a1a0da084594b7233637951a49
@@@ -63,18 -66,17 +66,17 @@@ function leistungsschutzrecht_cuttext($
        return $text;
  }
  
- function leistungsschutzrecht_fetchsites() {
-       require_once("include/network.php");
+ function leistungsschutzrecht_fetchsites()
+ {
        // This list works - but question is how current it is
        $url = "http://leistungsschutzrecht-stoppen.d-64.org/blacklist.txt";
-       $sitelist = fetch_url($url);
+       $sitelist = Network::fetchUrl($url);
        $siteurls = explode(',', $sitelist);
  
 -      $whitelist = ['tagesschau.de', 'heute.de', 'wdr.de'];
 +      $whitelist = array('tagesschau.de', 'heute.de', 'wdr.de');
  
-       $sites = array();
-       foreach ($siteurls AS $site) {
+       $sites = [];
+       foreach ($siteurls as $site) {
                if (!in_array($site, $whitelist)) {
                        $sites[$site] = $site;
                }
index c87a71043799d05626a705c77c27d74d6ae0c182,0685123842d189fb43cc336e04dee181cfdfc0cd..9ecabc2fb001ef75eb297d1ffed43205f7cc4579
@@@ -28,12 -31,12 +31,12 @@@ function libertree_jot_nets(&$a,&$b) 
      if(! local_user())
          return;
  
 -    $ltree_post = PConfig::get(local_user(),'libertree','post');
 +    $ltree_post = get_pconfig(local_user(),'libertree','post');
      if(intval($ltree_post) == 1) {
 -        $ltree_defpost = PConfig::get(local_user(),'libertree','post_by_default');
 +        $ltree_defpost = get_pconfig(local_user(),'libertree','post_by_default');
          $selected = ((intval($ltree_defpost) == 1) ? ' checked="checked" ' : '');
          $b .= '<div class="profile-jot-net"><input type="checkbox" name="libertree_enable"' . $selected . ' value="1" /> '
-             . t('Post to libertree') . '</div>';
+             . L10n::t('Post to libertree') . '</div>';
      }
  }
  
@@@ -216,11 -228,9 +219,9 @@@ function libertree_send(&$a,&$b) 
                        'text' => $body,
                        'source' => $ltree_source
                //      'token' => $ltree_api_token
 -              ];
 +              );
  
-               $result = post_url($ltree_blog,$params);
+               $result = Network::post($ltree_blog, $params);
                logger('libertree: ' . $result);
        }
  }
index d958dba44ab206f32b81bffe7ea76189e9ee3570,dd1d613f0d31e7f2fc44f784451116beb3df32bc..133b8a8f1a0cff371a6a549b4fcf39dc48012e8f
@@@ -40,10 -45,11 +45,11 @@@ function libravatar_lookup($a, &$b
  
        if (! $default_avatar) {
                // if not set, look up if there was one from the gravatar addon
 -              $default_avatar = Config::get('gravatar', 'default_img');
 +              $default_avatar = get_config('gravatar', 'default_img');
                // setting default avatar if nothing configured
-               if (! $default_avatar)
+               if (!$default_avatar) {
                        $default_avatar = 'identicon'; // default image will be a random pattern
+               }
        }
  
        require_once 'Services/Libravatar.php';
  /**
   * Display admin settings for this addon
   */
- function libravatar_plugin_admin (&$a, &$o) {
-       $t = get_markup_template( "admin.tpl", "addon/libravatar" );
+ function libravatar_addon_admin(&$a, &$o)
+ {
+       $t = get_markup_template("admin.tpl", "addon/libravatar");
  
 -      $default_avatar = Config::get('libravatar', 'default_img');
 +      $default_avatar = get_config('libravatar', 'default_img');
  
        // set default values for first configuration
-       if(! $default_avatar)
+       if (!$default_avatar) {
                $default_avatar = 'identicon'; // pseudo-random geometric pattern based on email hash
+       }
  
        // Available options for the select boxes
-       $default_avatars = array(
-               'mm' => t('generic profile image'),
-               'identicon' => t('random geometric pattern'),
-               'monsterid' => t('monster face'),
-               'wavatar' => t('computer generated face'),
-               'retro' => t('retro arcade style face'),
-       );
+       $default_avatars = [
+               'mm' => L10n::t('generic profile image'),
+               'identicon' => L10n::t('random geometric pattern'),
+               'monsterid' => L10n::t('monster face'),
+               'wavatar' => L10n::t('computer generated face'),
+               'retro' => L10n::t('retro arcade style face'),
+       ];
  
        // Show warning if PHP version is too old
        if (! version_compare(PHP_VERSION, '5.3.0', '>=')) {
index c8690c26e18a1a1bfbdc352d7824e778d31278b2,ec99f9ba9361585971ed4b12810d44230fd67828..7cfba81ed5074d1a12bb335982fe65c245488b4c
@@@ -31,12 -37,12 +37,12 @@@ function ljpost_jot_nets(&$a,&$b) 
      if(! local_user())
          return;
  
 -    $lj_post = PConfig::get(local_user(),'ljpost','post');
 +    $lj_post = get_pconfig(local_user(),'ljpost','post');
      if(intval($lj_post) == 1) {
 -        $lj_defpost = PConfig::get(local_user(),'ljpost','post_by_default');
 +        $lj_defpost = get_pconfig(local_user(),'ljpost','post_by_default');
          $selected = ((intval($lj_defpost) == 1) ? ' checked="checked" ' : '');
          $b .= '<div class="profile-jot-net"><input type="checkbox" name="ljpost_enable" ' . $selected . ' value="1" /> '
-             . t('Post to LiveJournal') . '</div>';
+             . L10n::t('Post to LiveJournal') . '</div>';
      }
  }
  
index c3e4974de2225ab5df9d443e3d0ee51db4e40eec,6c057b21b9bfa15aa1d65605242c350854b1f923..50f820e7e2d09948df9415dccbf30744031a6667
@@@ -6,14 -6,22 +6,22 @@@
   * Author: Matthew Exon <http://mat.exon.name>
   */
  
+ use Friendica\Content\Text\BBCode;
+ use Friendica\Core\Addon;
+ use Friendica\Core\Config;
+ use Friendica\Core\L10n;
+ use Friendica\Core\PConfig;
+ use Friendica\Database\DBM;
+ use Friendica\Util\Network;
  function mailstream_install() {
-       register_hook('plugin_settings', 'addon/mailstream/mailstream.php', 'mailstream_plugin_settings');
-       register_hook('plugin_settings_post', 'addon/mailstream/mailstream.php', 'mailstream_plugin_settings_post');
-       register_hook('post_local_end', 'addon/mailstream/mailstream.php', 'mailstream_post_hook');
-       register_hook('post_remote_end', 'addon/mailstream/mailstream.php', 'mailstream_post_hook');
-       register_hook('cron', 'addon/mailstream/mailstream.php', 'mailstream_cron');
+       Addon::registerHook('addon_settings', 'addon/mailstream/mailstream.php', 'mailstream_addon_settings');
+       Addon::registerHook('addon_settings_post', 'addon/mailstream/mailstream.php', 'mailstream_addon_settings_post');
+       Addon::registerHook('post_local_end', 'addon/mailstream/mailstream.php', 'mailstream_post_hook');
+       Addon::registerHook('post_remote_end', 'addon/mailstream/mailstream.php', 'mailstream_post_hook');
+       Addon::registerHook('cron', 'addon/mailstream/mailstream.php', 'mailstream_cron');
  
 -      if (Config::get('mailstream', 'dbversion') == '0.1') {
 +      if (get_config('mailstream', 'dbversion') == '0.1') {
                q('ALTER TABLE `mailstream_item` DROP INDEX `uid`');
                q('ALTER TABLE `mailstream_item` DROP INDEX `contact-id`');
                q('ALTER TABLE `mailstream_item` DROP INDEX `plink`');
@@@ -62,21 -70,21 +70,21 @@@ function mailstream_uninstall() 
  
  function mailstream_module() {}
  
- function mailstream_plugin_admin(&$a,&$o) {
-       $frommail = get_config('mailstream', 'frommail');
+ function mailstream_addon_admin(&$a,&$o) {
+       $frommail = Config::get('mailstream', 'frommail');
        $template = get_markup_template('admin.tpl', 'addon/mailstream/');
-       $config = array('frommail',
-                       t('From Address'),
+       $config = ['frommail',
+                       L10n::t('From Address'),
                        $frommail,
-                       t('Email address that stream items will appear to be from.'));
-       $o .= replace_macros($template, array(
+                       L10n::t('Email address that stream items will appear to be from.')];
+       $o .= replace_macros($template, [
                                 '$frommail' => $config,
-                                '$submit' => t('Save Settings')));
+                                '$submit' => L10n::t('Save Settings')]);
  }
  
- function mailstream_plugin_admin_post ($a) {
+ function mailstream_addon_admin_post ($a) {
        if (x($_POST, 'frommail')) {
 -              Config::set('mailstream', 'frommail', $_POST['frommail']);
 +              set_config('mailstream', 'frommail', $_POST['frommail']);
        }
  }
  
@@@ -149,11 -157,11 +157,11 @@@ function mailstream_do_images($a, &$ite
        foreach (array_merge($matches1[3], $matches2[1]) as $url) {
                $redirects;
                $cookiejar = tempnam(get_temppath(), 'cookiejar-mailstream-');
-               $attachments[$url] = array(
-                       'data' => fetch_url($url, true, $redirects, 0, Null, $cookiejar),
+               $attachments[$url] = [
+                       'data' => Network::fetchUrl($url, true, $redirects, 0, null, $cookiejar),
                        'guid' => hash("crc32", $url),
                        'filename' => basename($url),
 -                      'type' => $a->get_curl_content_type()];
 +                      'type' => $a->get_curl_content_type());
                if (strlen($attachments[$url]['data'])) {
                        $item['body'] = str_replace($url, 'cid:' . $attachments[$url]['guid'], $item['body']);
                        continue;
@@@ -249,10 -257,10 +257,10 @@@ function mailstream_send($a, $message_i
                return;
        }
        require_once(dirname(__file__).'/phpmailer/class.phpmailer.php');
-       require_once('include/bbcode.php');
-       $attachments = array();
+       $attachments = [];
        mailstream_do_images($a, $item, $attachments);
 -      $frommail = Config::get('mailstream', 'frommail');
 +      $frommail = get_config('mailstream', 'frommail');
        if ($frommail == "") {
                $frommail = 'friendica@localhost.local';
        }
@@@ -342,60 -350,60 +350,60 @@@ function mailstream_cron($a, $b) 
        mailstream_tidy();
  }
  
- function mailstream_plugin_settings(&$a,&$s) {
-       $enabled = get_pconfig(local_user(), 'mailstream', 'enabled');
-       $address = get_pconfig(local_user(), 'mailstream', 'address');
-       $nolikes = get_pconfig(local_user(), 'mailstream', 'nolikes');
-       $attachimg= get_pconfig(local_user(), 'mailstream', 'attachimg');
+ function mailstream_addon_settings(&$a,&$s) {
+       $enabled = PConfig::get(local_user(), 'mailstream', 'enabled');
+       $address = PConfig::get(local_user(), 'mailstream', 'address');
+       $nolikes = PConfig::get(local_user(), 'mailstream', 'nolikes');
+       $attachimg= PConfig::get(local_user(), 'mailstream', 'attachimg');
        $template = get_markup_template('settings.tpl', 'addon/mailstream/');
 -      $s .= replace_macros($template, [
 -                               '$enabled' => [
 +      $s .= replace_macros($template, array(
 +                               '$enabled' => array(
                                        'mailstream_enabled',
-                                       t('Enabled'),
-                                       $enabled),
-                                '$address' => array(
+                                       L10n::t('Enabled'),
+                                       $enabled],
+                                '$address' => [
                                        'mailstream_address',
-                                       t('Email Address'),
+                                       L10n::t('Email Address'),
                                        $address,
-                                       t("Leave blank to use your account email address")),
-                                '$nolikes' => array(
+                                       L10n::t("Leave blank to use your account email address")],
+                                '$nolikes' => [
                                        'mailstream_nolikes',
-                                       t('Exclude Likes'),
+                                       L10n::t('Exclude Likes'),
                                        $nolikes,
-                                       t("Check this to omit mailing \"Like\" notifications")),
-                                '$attachimg' => array(
+                                       L10n::t("Check this to omit mailing \"Like\" notifications")],
+                                '$attachimg' => [
                                        'mailstream_attachimg',
-                                       t('Attach Images'),
+                                       L10n::t('Attach Images'),
                                        $attachimg,
-                                       t("Download images in posts and attach them to the email.  Useful for reading email while offline.")),
-                                '$title' => t('Mail Stream Settings'),
-                                '$submit' => t('Save Settings')));
+                                       L10n::t("Download images in posts and attach them to the email.  Useful for reading email while offline.")],
+                                '$title' => L10n::t('Mail Stream Settings'),
+                                '$submit' => L10n::t('Save Settings')]);
  }
  
- function mailstream_plugin_settings_post($a,$post) {
+ function mailstream_addon_settings_post($a,$post) {
        if ($_POST['mailstream_address'] != "") {
 -              PConfig::set(local_user(), 'mailstream', 'address', $_POST['mailstream_address']);
 +              set_pconfig(local_user(), 'mailstream', 'address', $_POST['mailstream_address']);
        }
        else {
 -              PConfig::delete(local_user(), 'mailstream', 'address');
 +              del_pconfig(local_user(), 'mailstream', 'address');
        }
        if ($_POST['mailstream_nolikes']) {
 -              PConfig::set(local_user(), 'mailstream', 'nolikes', $_POST['mailstream_enabled']);
 +              set_pconfig(local_user(), 'mailstream', 'nolikes', $_POST['mailstream_enabled']);
        }
        else {
 -              PConfig::delete(local_user(), 'mailstream', 'nolikes');
 +              del_pconfig(local_user(), 'mailstream', 'nolikes');
        }
        if ($_POST['mailstream_enabled']) {
 -              PConfig::set(local_user(), 'mailstream', 'enabled', $_POST['mailstream_enabled']);
 +              set_pconfig(local_user(), 'mailstream', 'enabled', $_POST['mailstream_enabled']);
        }
        else {
 -              PConfig::delete(local_user(), 'mailstream', 'enabled');
 +              del_pconfig(local_user(), 'mailstream', 'enabled');
        }
        if ($_POST['mailstream_attachimg']) {
 -              PConfig::set(local_user(), 'mailstream', 'attachimg', $_POST['mailstream_attachimg']);
 +              set_pconfig(local_user(), 'mailstream', 'attachimg', $_POST['mailstream_attachimg']);
        }
        else {
 -              PConfig::delete(local_user(), 'mailstream', 'attachimg');
 +              del_pconfig(local_user(), 'mailstream', 'attachimg');
        }
  }
  
index 9bff86a2a56bf04f76c021bdd30a587fe66f71ae,d51857f3f789edca46d772c1a52ee32ca0151b1b..62c33c9c191713de4d5f5cb8547c48fea14838e2
@@@ -30,10 -33,10 +33,10 @@@ function mathjax_settings_post ($a, $po
  function mathjax_settings (&$a, &$s) {
      if (! local_user())
          return;
 -    $use = PConfig::get(local_user(),'mathjax','use');
 +    $use = get_pconfig(local_user(),'mathjax','use');
      $usetext = (($use) ? ' checked="checked" ' : '');
      $s .= '<span id="settings_mathjax_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_mathjax_expanded\'); openClose(\'settings_mathjax_inflated\');">';
-     $s .= '<h3>MathJax '.t('Settings').'</h3>';
+     $s .= '<h3>MathJax '.L10n::t('Settings').'</h3>';
      $s .= '</span>';
      $s .= '<div id="settings_mathjax_expanded" class="settings-block" style="display: none;">';
      $s .= '<span class="fakelink" onclick="openClose(\'settings_mathjax_expanded\'); openClose(\'settings_mathjax_inflated\');">';
@@@ -65,19 -68,19 +68,19 @@@ function mathjax_page_header($a, &$b) 
          }
      }
  }
- function mathjax_plugin_admin_post (&$a) {
+ function mathjax_addon_admin_post (&$a) {
      $baseurl = ((x($_POST, 'baseurl')) ? trim($_POST['baseurl']) : 'http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML');
-     set_config('mathjax','baseurl',$baseurl);
-     info( t('Settings updated.'). EOL);
+     Config::set('mathjax','baseurl',$baseurl);
+     info(L10n::t('Settings updated.'). EOL);
  }
- function mathjax_plugin_admin (&$a, &$o) {
+ function mathjax_addon_admin (&$a, &$o) {
        $t = get_markup_template( "admin.tpl", "addon/mathjax/" );
 -      if (Config::get('mathjax','baseurl','') == '') {
 -              Config::set('mathjax','baseurl','http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML');
 +      if (get_config('mathjax','baseurl','') == '') {
 +              set_config('mathjax','baseurl','http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML');
        }
  
-       $o = replace_macros( $t, array(
-               '$submit' => t('Save Settings'),
-               '$baseurl' => array('baseurl', t('MathJax Base URL'), get_config('mathjax','baseurl' ), t('The URL for the javascript file that should be included to use MathJax. Can be either the MathJax CDN or another installation of MathJax.')),
-       ));
+       $o = replace_macros( $t, [
+               '$submit' => L10n::t('Save Settings'),
+               '$baseurl' => ['baseurl', L10n::t('MathJax Base URL'), Config::get('mathjax','baseurl' ), L10n::t('The URL for the javascript file that should be included to use MathJax. Can be either the MathJax CDN or another installation of MathJax.')],
+       ]);
  }
index 3f2cdc890ab0fa6f565a587996f026d7c9d934ea,5ea0db38c614749007d33a81d8254a16713d6642..c49128319f3ce102340e7316bbe514efafd315b4
@@@ -51,15 -51,15 +51,17 @@@ function notifyall_post(&$a) 
        $subject = $_REQUEST['subject'];
  
  
-       $textversion = strip_tags(html_entity_decode(bbcode(stripslashes(str_replace(array("\\r", "\\n"),array( "", "\n"), $text))),ENT_QUOTES,'UTF-8'));
+       $textversion = strip_tags(html_entity_decode(BBCode::convert(stripslashes(str_replace(["\\r", "\\n"], ["", "\n"], $text))), ENT_QUOTES, 'UTF-8'));
+       $htmlversion = BBCode::convert(stripslashes(str_replace(["\\r", "\\n"], ["", "<br />\n"], $text)));
  
 +      $htmlversion = bbcode(stripslashes(str_replace(array("\\r","\\n"), array("","<br />\n"),$text)));
 +      
        // if this is a test, send it only to the admin(s)
        // admin_email might be a comma separated list, but we need "a@b','c@d','e@f
-       if ( intval($_REQUEST['test'])) {
+       if (intval($_REQUEST['test'])) {
                $email = $a->config['admin_email'];
 -              $email = "'" . str_replace([" ",","], ["","','"], $email) . "'";
 +              $email = "'" . str_replace(array(" ",","), array("","','"), $email) . "'";
        }
        $sql_extra = ((intval($_REQUEST['test'])) ? sprintf(" AND `email` in ( %s )", $email) : '');
  
                        'messageSubject'       => $subject,
                        'htmlVersion'          => $htmlversion,
                        'textVersion'          => $textversion
 -              ]);
 +              ));
        }
  
-       notice( t('Emails sent'));
+       notice(L10n::t('Emails sent'));
        goaway('admin');
  }
  
index c2bca211beb398479e7c36c23f514c858d81011e,93782878a246e6dea1a993d2449183c70b34ab66..fb32717965c2ed79453014694c9b9c0d756c3087
@@@ -4,38 -4,39 +4,38 @@@
   * Description: Disable "Archives" widget on profile page
   * Version: 1.0
   * Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
-  * 
   *
   */
- function notimeline_install() {
-       register_hook('plugin_settings', 'addon/notimeline/notimeline.php', 'notimeline_settings');
-       register_hook('plugin_settings_post', 'addon/notimeline/notimeline.php', 'notimeline_settings_post');
+ use Friendica\Core\Addon;
+ use Friendica\Core\L10n;
+ use Friendica\Core\PConfig;
+ function notimeline_install()
+ {
+       Addon::registerHook('addon_settings', 'addon/notimeline/notimeline.php', 'notimeline_settings');
+       Addon::registerHook('addon_settings_post', 'addon/notimeline/notimeline.php', 'notimeline_settings_post');
  }
  
- function notimeline_uninstall() {
-       unregister_hook('plugin_settings', 'addon/notimeline/notimeline.php', 'notimeline_settings');
-       unregister_hook('plugin_settings_post', 'addon/notimeline/notimeline.php', 'notimeline_settings_post');
+ function notimeline_uninstall()
+ {
+       Addon::unregisterHook('addon_settings', 'addon/notimeline/notimeline.php', 'notimeline_settings');
+       Addon::unregisterHook('addon_settings_post', 'addon/notimeline/notimeline.php', 'notimeline_settings_post');
  }
  
function notimeline_settings_post($a,$post) {
-       if(! local_user() || (! x($_POST,'notimeline-submit')))
+ function notimeline_settings_post($a, $post)
+ {
+       if (!local_user() || (!x($_POST, 'notimeline-submit'))) {
                return;
+       }
  
-       set_pconfig(local_user(),'system','no_wall_archive_widget',intval($_POST['notimeline']));
-       info( t('No Timeline settings updated.') . EOL);
+       PConfig::set(local_user(), 'system', 'no_wall_archive_widget', intval($_POST['notimeline']));
+       info(L10n::t('No Timeline settings updated.') . EOL);
  }
  
 -function notimeline_settings(&$a, &$s)
 -{
 -      if (! local_user()) {
 +function notimeline_settings(&$a,&$s) {
 +
 +      if(! local_user())
                return;
 -      }
  
        /* Add our stylesheet to the page so we can make our settings look nice */
  
diff --cc nsfw/nsfw.php
index af383d20b7cfb6d9f45ebe0e47a704b1bacaa17c,836f6541f9b5825c93cad706a02708ebadc6d197..74c64cbe07a099ec28aa662bc87bda11dcce898c
@@@ -6,35 -4,38 +4,38 @@@
   * Description: Collapse posts with inappropriate content
   * Version: 1.0
   * Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
 - *
 + * 
   */
- function nsfw_install() {
-       register_hook('prepare_body', 'addon/nsfw/nsfw.php', 'nsfw_prepare_body', 10);
-       register_hook('plugin_settings', 'addon/nsfw/nsfw.php', 'nsfw_addon_settings');
-       register_hook('plugin_settings_post', 'addon/nsfw/nsfw.php', 'nsfw_addon_settings_post');
+ use Friendica\Core\Addon;
+ use Friendica\Core\L10n;
+ use Friendica\Core\PConfig;
+ function nsfw_install()
+ {
+       Addon::registerHook('prepare_body', 'addon/nsfw/nsfw.php', 'nsfw_prepare_body', 10);
+       Addon::registerHook('addon_settings', 'addon/nsfw/nsfw.php', 'nsfw_addon_settings');
+       Addon::registerHook('addon_settings_post', 'addon/nsfw/nsfw.php', 'nsfw_addon_settings_post');
  }
  
  
- function nsfw_uninstall() {
-       unregister_hook('prepare_body', 'addon/nsfw/nsfw.php', 'nsfw_prepare_body');
-       unregister_hook('plugin_settings', 'addon/nsfw/nsfw.php', 'nsfw_addon_settings');
-       unregister_hook('plugin_settings_post', 'addon/nsfw/nsfw.php', 'nsfw_addon_settings_post');
+ function nsfw_uninstall()
+ {
+       Addon::unregisterHook('prepare_body', 'addon/nsfw/nsfw.php', 'nsfw_prepare_body');
+       Addon::unregisterHook('addon_settings', 'addon/nsfw/nsfw.php', 'nsfw_addon_settings');
+       Addon::unregisterHook('addon_settings_post', 'addon/nsfw/nsfw.php', 'nsfw_addon_settings_post');
  }
  
 -// This function isn't perfect and isn't trying to preserve the html structure - it's just a
 -// quick and dirty filter to pull out embedded photo blobs because 'nsfw' seems to come up
 +// This function isn't perfect and isn't trying to preserve the html structure - it's just a 
 +// quick and dirty filter to pull out embedded photo blobs because 'nsfw' seems to come up 
  // inside them quite often. We don't need anything fancy, just pull out the data blob so we can
- // check against the rest of the body. 
-  
- function nsfw_extract_photos($body) {
+ // check against the rest of the body.
  
+ function nsfw_extract_photos($body)
+ {
        $new_body = '';
-       
-       $img_start = strpos($body,'src="data:');
-       $img_end = (($img_start !== false) ? strpos(substr($body,$img_start),'>') : false);
+       $img_start = strpos($body, 'src="data:');
+       $img_end = (($img_start !== false) ? strpos(substr($body, $img_start), '>') : false);
  
        $cnt = 0;
  
@@@ -158,11 -158,12 +158,12 @@@ function nsfw_prepare_body(&$a, &$b
                                                }
                                        }
                                }
 -                      }
 -              }
 +                      } 
 +              }               
        }
-       if($found) {
+       if ($found) {
                $rnd = random_string(8);
-               $b['html'] = '<div id="nsfw-wrap-' . $rnd . '" class="fakelink" onclick=openClose(\'nsfw-' . $rnd . '\'); >' . sprintf( t('%s - Click to open/close'),$word ) . '</div><div id="nsfw-' . $rnd . '" style="display: none; " >' . $b['html'] . '</div>';  
+               $b['html'] = '<div id="nsfw-wrap-' . $rnd . '" class="fakelink" onclick=openClose(\'nsfw-' . $rnd . '\'); >' . L10n::t('%s - Click to open/close', $word) . '</div><div id="nsfw-' . $rnd . '" style="display: none; " >' . $b['html'] . '</div>';
        }
  }
index 2f48a0d7d369926412f381b7b9854a8f5ad5594c,247c7dc7593e98aa9fa66e4ba42c12e12b7cd55c..7acb914dc7d6a7df820a712d92dd987a7ddba3cf
@@@ -53,13 -50,11 +50,10 @@@ function numfriends_settings_post($a,$p
   * Add our own settings info to the page.
   *
   */
- function numfriends_settings(&$a,&$s) {
-       if(! local_user())
+ function numfriends_settings(&$a, &$s)
+ {
+       if (! local_user()) {
                return;
 -      }
  
        /* Add our stylesheet to the page so we can make our settings look nice */
  
index 135451698d9cae89d70f17775f9c85fe42c869b2,974be0a0a0c651488cb486526d324157f3d2f9a3..bfe960fad5e347fcec2b0c3595a977919f78019e
@@@ -44,10 -57,11 +56,10 @@@ function openstreetmap_alterheader($a, 
   * @param mixed $a
   * @param array& $item
   */
- function openstreetmap_location($a, &$item) {
-       if(! (strlen($item['location']) || strlen($item['coord'])))
+ function openstreetmap_location($a, &$item)
+ {
+       if (!(strlen($item['location']) || strlen($item['coord']))) {
                return;
 -      }
  
        /*
         * Get the configuration variables from the config.
@@@ -140,48 -161,58 +157,60 @@@ function openstreetmap_generate_map(&$a
        logger('lat: ' . $lat, LOGGER_DATA);
        logger('lon: ' . $lon, LOGGER_DATA);
  
+       $cardlink = '<a href="' . $tmsserver;
  
-       $b['html'] = '<iframe style="width:100%; height:300px; border:1px solid #ccc" src="' . $tmsserver . '/export/embed.html?bbox=' . ($lon - 0.01) . '%2C' . ($lat - 0.01) . '%2C' . ($lon + 0.01) . '%2C' . ($lat + 0.01) ;
+       if ($marker > 0) {
+               $cardlink .= '?mlat=' . $lat . '&mlon=' . $lon;
+       }
  
-       $b['html'] .=  '&amp;layer=mapnik&amp;marker=' . $lat . '%2C' . $lon . '" style="border: 1px solid black"></iframe><br/><small><a href="' . $tmsserver . '/?mlat=' . $lat . '&mlon=' . $lon . '#map=16/' . $lat . '/' . $lon . '">' . (($b['location']) ? escape_tags($b['location']) : t('View Larger')) . '</a></small>';
+       $cardlink .= '#map=' . $zoom . '/' . $lat . '/' . $lon . '">' . ($b['location'] ? escape_tags($b['location']) : L10n::t('View Larger')) . '</a>';
+       if (empty($b['mode'])) {
+               $b['html'] = '<iframe style="width:100%; height:300px; border:1px solid #ccc" src="' . $tmsserver .
+                               '/export/embed.html?bbox=' . ($lon - 0.01) . '%2C' . ($lat - 0.01) . '%2C' . ($lon + 0.01) . '%2C' . ($lat + 0.01) .
+                               '&amp;layer=mapnik&amp;marker=' . $lat . '%2C' . $lon . '" style="border: 1px solid black"></iframe>' .
+                               '<br/><small>' . $cardlink . '</small>';
+       } else {
+               $b['html'] .= '<br/>' . $cardlink;
+       }
  
        logger('generate_map: ' . $b['html'], LOGGER_DATA);
  }
  
- function openstreetmap_plugin_admin(&$a, &$o) {
+ function openstreetmap_addon_admin(&$a, &$o)
+ {
        $t = get_markup_template("admin.tpl", "addon/openstreetmap/");
-       $tmsserver = get_config('openstreetmap', 'tmsserver');
-       if(! $tmsserver)
-               $tmsserver = 'http://www.openstreetmap.org';
-       $nomserver = get_config('openstreetmap', 'nomserver');
-       if(! $nomserver)
-               $nomserver = 'http://nominatim.openstreetmap.org/search.php';
-       $zoom = get_config('openstreetmap', 'zoom');
-       if(! $zoom)
-               $zoom = 16;
-       $marker = get_config('openstreetmap', 'marker');
-       if(! $marker)
-               $marker = 0;
-       $o = replace_macros($t, array(
-                       '$submit' => t('Submit'),
-                       '$tmsserver' => array('tmsserver', t('Tile Server URL'), $tmsserver, t('A list of <a href="http://wiki.openstreetmap.org/wiki/TMS" target="_blank">public tile servers</a>')),
-                       '$nomserver' => array('nomserver', t('Nominatim (reverse geocoding) Server URL'), $nomserver, t('A list of <a href="http://wiki.openstreetmap.org/wiki/Nominatim" target="_blank">Nominatim servers</a>')),
-                       '$zoom' => array('zoom', t('Default zoom'), $zoom, t('The default zoom level. (1:world, 18:highest, also depends on tile server)')),
-                       '$marker' => array('marker', t('Include marker on map'), $marker, t('Include a marker on the map.')),
-       ));
+       $tmsserver = Config::get('openstreetmap', 'tmsserver', OSM_TMS);
+       $nomserver = Config::get('openstreetmap', 'nomserver', OSM_NOM);
+       $zoom = Config::get('openstreetmap', 'zoom', OSM_ZOOM);
+       $marker = Config::get('openstreetmap', 'marker', OSM_MARKER);
+       // This is needed since we stored an empty string in the config in previous versions
+       if (empty($nomserver)) {
+               $nomserver = OSM_NOM;
+       }
+       $o = replace_macros($t, [
+                       '$submit' => L10n::t('Submit'),
+                       '$tmsserver' => ['tmsserver', L10n::t('Tile Server URL'), $tmsserver, L10n::t('A list of <a href="http://wiki.openstreetmap.org/wiki/TMS" target="_blank">public tile servers</a>')],
+                       '$nomserver' => ['nomserver', L10n::t('Nominatim (reverse geocoding) Server URL'), $nomserver, L10n::t('A list of <a href="http://wiki.openstreetmap.org/wiki/Nominatim" target="_blank">Nominatim servers</a>')],
+                       '$zoom' => ['zoom', L10n::t('Default zoom'), $zoom, L10n::t('The default zoom level. (1:world, 18:highest, also depends on tile server)')],
+                       '$marker' => ['marker', L10n::t('Include marker on map'), $marker, L10n::t('Include a marker on the map.')],
+       ]);
  }
- function openstreetmap_plugin_admin_post(&$a) {
-       $urltms = ((x($_POST, 'tmsserver')) ? notags(trim($_POST['tmsserver'])) : '');
-       $urlnom = ((x($_POST, 'nomserver')) ? notags(trim($_POST['nomserver'])) : '');
-       $zoom = ((x($_POST, 'zoom')) ? intval(trim($_POST['zoom'])) : '16');
-       $marker = ((x($_POST, 'marker')) ? intval(trim($_POST['marker'])) : '0');
-       set_config('openstreetmap', 'tmsserver', $urltms);
-       set_config('openstreetmap', 'nomserver', $urlnom);
-       set_config('openstreetmap', 'zoom', $zoom);
-       set_config('openstreetmap', 'marker', $marker);
-       info( t('Settings updated.') . EOL);
+ function openstreetmap_addon_admin_post(&$a)
+ {
+       $urltms = defaults($_POST, 'tmsserver', OSM_TMS);
+       $urlnom = defaults($_POST, 'nomserver', OSM_NOM);
+       $zoom = defaults($_POST, 'zoom', OSM_ZOOM);
+       $marker = defaults($_POST, 'marker', OSM_MARKER);
+       Config::set('openstreetmap', 'tmsserver', $urltms);
+       Config::set('openstreetmap', 'nomserver', $urlnom);
+       Config::set('openstreetmap', 'zoom', $zoom);
+       Config::set('openstreetmap', 'marker', $marker);
+       info(L10n::t('Settings updated.') . EOL);
  }
 +
 +
Simple merge
diff --cc piwik/piwik.php
Simple merge
Simple merge
Simple merge
index 7d8b81365762edd95f8d8764956a2033f53944e8,cfcb8fd74fe52ed7d5f05fa119dbf51daa98a16a..f6eb03e6a951c4c754d982b28f39970d2dd0e71a
@@@ -61,15 -61,13 +61,13 @@@ function public_server_cron($a, $b
                                'language'     => $rr['language'],
                                'to_name'      => $rr['username'],
                                'to_email'     => $rr['email'],
-                               'source_name'  => t('Administrator'),
+                               'source_name'  => L10n::t('Administrator'),
                                'source_link'  => $a->get_baseurl(),
                                'source_photo' => $a->get_baseurl() . '/images/person-80.jpg',
 -                      ]);
 +                      ));
  
-                       q("update user set expire_notification_sent = '%s' where uid = %d",
-                               dbesc(datetime_convert()),
-                               intval($rr['uid'])
-                       );
+                       $fields = ['expire_notification_sent' => DateTimeFormat::utcNow()];
+                       dba::update('user', $fields, ['uid' => $rr['uid']]);
                }
        }
  
index f70801a85d1b09ab12f0be4693b81f4af80967e5,a1ca2ade7dec6f125c2b76ade46fb17ddf8f7468..05ab4626e99f307975c05d9c28463cd6349d4437
@@@ -191,12 -205,12 +205,12 @@@ function pumpio_jot_nets(&$a,&$b) 
        if(! local_user())
                return;
  
 -      $pumpio_post = PConfig::get(local_user(),'pumpio','post');
 +      $pumpio_post = get_pconfig(local_user(),'pumpio','post');
        if(intval($pumpio_post) == 1) {
 -              $pumpio_defpost = PConfig::get(local_user(),'pumpio','post_by_default');
 +              $pumpio_defpost = get_pconfig(local_user(),'pumpio','post_by_default');
                $selected = ((intval($pumpio_defpost) == 1) ? ' checked="checked" ' : '');
                $b .= '<div class="profile-jot-net"><input type="checkbox" name="pumpio_enable"' . $selected . ' value="1" /> '
-                       . t('Post to pumpio') . '</div>';
+                       . L10n::t('Post to pumpio') . '</div>';
        }
  }
  
@@@ -439,24 -461,21 +453,21 @@@ function pumpio_send(&$a,&$b) 
        // Support for native shares
        // http://<hostname>/api/<type>/shares?id=<the-object-id>
  
 -      $oauth_token = PConfig::get($b['uid'], "pumpio", "oauth_token");
 -      $oauth_token_secret = PConfig::get($b['uid'], "pumpio", "oauth_token_secret");
 -      $consumer_key = PConfig::get($b['uid'], "pumpio","consumer_key");
 -      $consumer_secret = PConfig::get($b['uid'], "pumpio","consumer_secret");
 +      $oauth_token = get_pconfig($b['uid'], "pumpio", "oauth_token");
 +      $oauth_token_secret = get_pconfig($b['uid'], "pumpio", "oauth_token_secret");
 +      $consumer_key = get_pconfig($b['uid'], "pumpio","consumer_key");
 +      $consumer_secret = get_pconfig($b['uid'], "pumpio","consumer_secret");
  
 -      $host = PConfig::get($b['uid'], "pumpio", "host");
 -      $user = PConfig::get($b['uid'], "pumpio", "user");
 -      $public = PConfig::get($b['uid'], "pumpio", "public");
 +      $host = get_pconfig($b['uid'], "pumpio", "host");
 +      $user = get_pconfig($b['uid'], "pumpio", "user");
 +      $public = get_pconfig($b['uid'], "pumpio", "public");
  
        if($oauth_token && $oauth_token_secret) {
-               require_once('include/bbcode.php');
                $title = trim($b['title']);
  
-               $content = bbcode($b['body'], false, false, 4);
+               $content = BBCode::convert($b['body'], false, 4);
  
 -              $params = [];
 +              $params = array();
  
                $params["verb"] = "post";
  
@@@ -704,9 -718,9 +711,9 @@@ function pumpio_fetchtimeline(&$a, $uid
        //  get the application name for the pump.io app
        //  1st try personal config, then system config and fallback to the
        //  hostname of the node if neither one is set.
-       $application_name  = get_pconfig( $uid, 'pumpio', 'application_name');
+       $application_name  = PConfig::get($uid, 'pumpio', 'application_name');
        if ($application_name == "")
 -              $application_name  = Config::get('pumpio', 'application_name');
 +              $application_name  = get_config('pumpio', 'application_name');
        if ($application_name == "")
                $application_name = $a->get_hostname();
  
index 2c98cba72335fe3be6fbd6c5f2f91178e25acf26,c499fb868cd744a3ad3b0a8a3e589874969be131..deb6a02f47131608c26530bb33cda503047161a2
@@@ -33,32 -33,27 +33,26 @@@ function qcomment_uninstall() 
  
  }
  
- function qcomment_addon_settings(&$a,&$s) {
-       if(! local_user())
+ function qcomment_addon_settings(&$a, &$s)
+ {
+       if (! local_user()) {
                return;
 -      }
  
 -      /* Add our stylesheet to the page so we can make our settings look nice */
 +    /* Add our stylesheet to the page so we can make our settings look nice */
  
 -      $a->page['htmlhead'] .= '<link rel="stylesheet"  type="text/css" href="' . $a->get_baseurl() . '/addon/qcomment/qcomment.css' . '" media="all" />' . "\r\n";
 +    $a->page['htmlhead'] .= '<link rel="stylesheet"  type="text/css" href="' . $a->get_baseurl() . '/addon/qcomment/qcomment.css' . '" media="all" />' . "\r\n";
  
-       $words = get_pconfig(local_user(),'qcomment','words');
-       if($words === false)
-               $words = t(':-)') . "\n" . t(':-(') . "\n" .  t('lol');
+       $words = PConfig::get(local_user(), 'qcomment', 'words', L10n::t(':-)') . "\n" . L10n::t(':-(') . "\n" .  L10n::t('lol'));
  
-     $s .= '<div class="settings-block">';
-     $s .= '<h3>' . t('Quick Comment Settings') . '</h3>';
-     $s .= '<div id="qcomment-wrapper">';
-       $s .= '<div id="qcomment-desc">' . t("Quick comments are found near comment boxes, sometimes hidden. Click them to provide simple replies.") . '</div>';
-     $s .= '<label id="qcomment-label" for="qcomment-words">' . t('Enter quick comments, one per line') . ' </label>';
-     $s .= '<textarea id="qcomment-words" type="text" name="qcomment-words" >' . htmlspecialchars(unxmlify($words)) . '</textarea>';
-     $s .= '</div><div class="clear"></div>';
+       $s .= '<div class="settings-block">';
+       $s .= '<h3>' . L10n::t('Quick Comment Settings') . '</h3>';
+       $s .= '<div id="qcomment-wrapper">';
+       $s .= '<div id="qcomment-desc">' . L10n::t("Quick comments are found near comment boxes, sometimes hidden. Click them to provide simple replies.") . '</div>';
+       $s .= '<label id="qcomment-label" for="qcomment-words">' . L10n::t('Enter quick comments, one per line') . ' </label>';
+       $s .= '<textarea id="qcomment-words" type="text" name="qcomment-words" >' . htmlspecialchars(unxmlify($words)) . '</textarea>';
+       $s .= '</div><div class="clear"></div>';
  
-     $s .= '<div class="settings-submit-wrapper" ><input type="submit" id="qcomment-submit" name="qcomment-submit" class="settings-submit" value="' . t('Save Settings') . '" /></div>';
+       $s .= '<div class="settings-submit-wrapper" ><input type="submit" id="qcomment-submit" name="qcomment-submit" class="settings-submit" value="' . L10n::t('Save Settings') . '" /></div>';
        $s .= '</div>';
  
        return;
index 27589b1ceceb756ac52e144254e892b17b802bf0,abf59e2dffd1ab852041109a4734092ede016311..ca4d3d797d0783d24a5becefb3f1aabc448a3dcc
@@@ -1,20 -1,20 +1,20 @@@
  <?php
  /**
   * Name: Random place
-  * Description: Sample Friendica plugin/addon. Set a random place when posting.
+  * Description: Sample Friendica addon. Set a random place when posting.
   * Version: 1.0
   * Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
 - *
 - *
 - *
 + * 
 + * 
 + * 
   *
   * Addons are registered with the system through the admin
   * panel.
   *
-  * When registration is detected, the system calls the plugin
+  * When registration is detected, 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
 + * If the addon is removed from the configuration list, the 
   * system will call the name_uninstall() function.
   *
   */
index 5cba005ab2848914837470239fddff1157bbaee5,94bdf5c11ea0d89a8a7320cf9882287e015759c9..b1651517408060f029fe3061a15248c7a5beddd3
@@@ -4,14 -4,17 +4,17 @@@
   * Description: Allow the recipients of private posts to see who else can see the post by clicking the lock icon
   * Version: 1.0
   * Author: Zach <https://f.shmuz.in/profile/techcity>
 - *
 + * 
   */
+ use Friendica\Core\Addon;
+ use Friendica\Core\Config;
+ use Friendica\Core\L10n;
+ use Friendica\Core\PConfig;
  
  function remote_permissions_install() {
-       register_hook('lockview_content', 'addon/remote_permissions/remote_permissions.php', 'remote_permissions_content');
-       register_hook('plugin_settings', 'addon/remote_permissions/remote_permissions.php', 'remote_permissions_settings');
-       register_hook('plugin_settings_post', 'addon/remote_permissions/remote_permissions.php', 'remote_permissions_settings_post');
+       Addon::registerHook('lockview_content', 'addon/remote_permissions/remote_permissions.php', 'remote_permissions_content');
+       Addon::registerHook('addon_settings', 'addon/remote_permissions/remote_permissions.php', 'remote_permissions_settings');
+       Addon::registerHook('addon_settings_post', 'addon/remote_permissions/remote_permissions.php', 'remote_permissions_settings_post');
  }
  
  function remote_permissions_uninstall() {
index 034fdec71d42bf2db2525a947e709792fa9cdf90,81aea8b18a4b4aa82a06874c0c7137862561fd78..a638865a210e3aedc8137dd71454cd704cf8f2ee
@@@ -30,22 -31,22 +31,22 @@@ function rendertime_page_end(&$a, &$o) 
        $ignored = in_array($a->module, $ignored_modules);
  
        if (is_site_admin() && ($_GET["mode"] != "minimal") && !$a->is_mobile && !$a->is_tablet && !$ignored) {
-               $o = $o.'<div class="renderinfo">'.sprintf(t("Database: %s/%s, Network: %s, Rendering: %s, Session: %s, I/O: %s, Other: %s, Total: %s"),
-                                               round($a->performance["database"] - $a->performance["database_write"], 3),
-                                               round($a->performance["database_write"], 3),
-                                               round($a->performance["network"], 2),
-                                               round($a->performance["rendering"], 2),
-                                               round($a->performance["parser"], 2),
-                                               round($a->performance["file"], 2),
-                                               round($duration - $a->performance["database"]
-                                                        - $a->performance["network"] - $a->performance["rendering"]
-                                                        - $a->performance["parser"] - $a->performance["file"], 2),
-                                               round($duration, 2)
-                                               //round($a->performance["markstart"], 3)
-                                               //round($a->performance["plugin"], 3)
-                                               )."</div>";
+               $o = $o.'<div class="renderinfo">'. L10n::t("Database: %s/%s, Network: %s, Rendering: %s, Session: %s, I/O: %s, Other: %s, Total: %s",
+                       round($a->performance["database"] - $a->performance["database_write"], 3),
+                       round($a->performance["database_write"], 3),
+                       round($a->performance["network"], 2),
+                       round($a->performance["rendering"], 2),
+                       round($a->performance["parser"], 2),
+                       round($a->performance["file"], 2),
+                       round($duration - $a->performance["database"]
+                                       - $a->performance["network"] - $a->performance["rendering"]
+                                       - $a->performance["parser"] - $a->performance["file"], 2),
+                       round($duration, 2)
+                       //round($a->performance["markstart"], 3)
+                       //round($a->performance["plugin"], 3)
+                       )."</div>";
  
 -              if (Config::get("rendertime", "callstack")) {
 +              if (get_config("rendertime", "callstack")) {
                        $o .= "<pre>";
                        $o .= "\nDatabase Read:\n";
                        foreach ($a->callstack["database"] AS $func => $time) {
index b20eab9c21edb1522f47bb914be511ab3927a85f,d63c2ee97df2d0a4c8c8d0294eef5c86c1f99a2b..21ed28331d0dc27e09ce344824335d999efb5e19
@@@ -86,12 -88,12 +88,12 @@@ function securemail_settings_post(App &
      }
  
      if ($_POST['securemail-submit']) {
 -        PConfig::set(local_user(), 'securemail', 'pkey', trim($_POST['securemail-pkey']));
 +        set_pconfig(local_user(), 'securemail', 'pkey', trim($_POST['securemail-pkey']));
          $enable = ((x($_POST, 'securemail-enable')) ? 1 : 0);
-         set_pconfig(local_user(), 'securemail', 'enable', $enable);
-         info(t('Secure Mail Settings saved.') . EOL);
+         PConfig::set(local_user(), 'securemail', 'enable', $enable);
+         info(L10n::t('Secure Mail Settings saved.') . EOL);
  
-         if ($_POST['securemail-submit'] == t('Save and send test')) {
+         if ($_POST['securemail-submit'] == L10n::t('Save and send test')) {
              $sitename = $a->config['sitename'];
  
              $hostname = $a->get_hostname();
              $res = Emailer::send($params);
  
              // revert to saved value
 -            PConfig::set(local_user(), 'securemail', 'enable', $enable);
 +            set_pconfig(local_user(), 'securemail', 'enable', $enable);
  
              if ($res) {
-                 info(t('Test email sent') . EOL);
+                 info(L10n::t('Test email sent') . EOL);
              } else {
-                 notice(t('There was an error sending the test email') . EOL);
+                 notice(L10n::t('There was an error sending the test email') . EOL);
              }
          }
      }
index a9d8334f3e41dea7532d2df1d11599cf95fb2a70,89cec83d4d6dc75590c3eb356ef8eadeed12762c..d3753e6fdc1340b3d4c3f26974195d3e8b9a93b0
@@@ -64,11 -67,11 +67,11 @@@ function showmore_addon_settings_post(&
                return;
  
        if($_POST['showmore-submit']) {
 -              PConfig::set(local_user(),'showmore','chars',trim($_POST['showmore-chars']));
 +              set_pconfig(local_user(),'showmore','chars',trim($_POST['showmore-chars']));
                $enable = ((x($_POST,'showmore-enable')) ? intval($_POST['showmore-enable']) : 0);
                $disable = 1-$enable;
-               set_pconfig(local_user(),'showmore','disable', $disable);
-               info( t('Show More Settings saved.') . EOL);
+               PConfig::set(local_user(),'showmore','disable', $disable);
+               info(L10n::t('Show More Settings saved.') . EOL);
        }
  }
  
index d8c1533024704673b0ce5534d9d475e427912b4b,2d4a0743e62cf737c8a62317dcf85a2d66e7261e..7c5e84f92e816215e5f6b564587a9494f6c36502
@@@ -92,11 -92,11 +92,11 @@@ function show_button($a, &$b) 
                '<img class="smiley" src="' . $a->get_baseurl() . '/images/dislike.gif" alt=":dislike" />',
                '<img class="smiley" src="' . $a->get_baseurl() . '/images/friendica-16.png" alt="~friendica" />',
                '<img class="smiley" src="' . $a->get_baseurl() . '/images/rhash-16.png" alt="red" />'
 -      ];
 -
 +      );
 +      
        // Call hooks to get aditional smileies from other addons
-       $params = array('texts' => $texts, 'icons' => $icons, 'string' => ""); //changed
-       call_hooks('smilie', $params);
+       $params = ['texts' => $texts, 'icons' => $icons, 'string' => ""]; //changed
+       Addon::callHooks('smilie', $params);
  
        //Generate html for smiley list
        $s = "<table class=\"smiley-preview\"><tr>\n\t";
index e0d822ac27594dfb83f85f70930ccc1552c57b39,840b547e5ecc76f0c560e75118d5f5ce4f05ff69..a70e657397e9477d2f56a334d5eca6cc2c7a5218
@@@ -4,14 -4,16 +4,16 @@@
   * Description: Set a preferred page to load on login from home page
   * Version: 1.0
   * Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
 - *
 + * 
   */
+ use Friendica\Core\Addon;
+ use Friendica\Core\L10n;
+ use Friendica\Core\PConfig;
  
  function startpage_install() {
-       register_hook('home_init', 'addon/startpage/startpage.php', 'startpage_home_init');
-       register_hook('plugin_settings', 'addon/startpage/startpage.php', 'startpage_settings');
-       register_hook('plugin_settings_post', 'addon/startpage/startpage.php', 'startpage_settings_post');
+       Addon::registerHook('home_init', 'addon/startpage/startpage.php', 'startpage_home_init');
+       Addon::registerHook('addon_settings', 'addon/startpage/startpage.php', 'startpage_settings');
+       Addon::registerHook('addon_settings_post', 'addon/startpage/startpage.php', 'startpage_settings_post');
  }
  
  
@@@ -50,13 -49,12 +52,12 @@@ function startpage_settings_post($a,$po
        if(! local_user())
                return;
        if($_POST['startpage-submit'])
 -              PConfig::set(local_user(),'startpage','startpage',strip_tags(trim($_POST['startpage'])));
 +              set_pconfig(local_user(),'startpage','startpage',strip_tags(trim($_POST['startpage'])));
  }
  
  /**
   *
-  * Called from the Plugin Setting form. 
+  * Called from the Addon Setting form.
   * Add our own settings info to the page.
   *
   */
index a004a6243cbc4c8c1aa7246b873d00b49f99f904,c54ff55f6c923ce65d4b4e3051bf2d770144884c..16f68a8aa1f5b36f5cf190ebdcddb4b8278b9896
   * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   *
   */
- /***
-  * We have to alter the TwitterOAuth class a little bit to work with any GNU Social
-  * installation abroad. Basically it's only make the API path variable and be happy.
-  *
-  * Thank you guys for the Twitter compatible API!
-  */
  define('STATUSNET_DEFAULT_POLL_INTERVAL', 5); // given in minutes
  
- require_once('library/twitteroauth.php');
- require_once('include/enotify.php');
- require_once("include/socgraph.php");
- class StatusNetOAuth extends TwitterOAuth {
-     function get_maxlength() {
-       $config = $this->get($this->host . 'statusnet/config.json');
-       return $config->site->textlimit;
-     }
-     function accessTokenURL()  { return $this->host.'oauth/access_token'; }
-     function authenticateURL() { return $this->host.'oauth/authenticate'; }
-     function authorizeURL() { return $this->host.'oauth/authorize'; }
-     function requestTokenURL() { return $this->host.'oauth/request_token'; }
-     function __construct($apipath, $consumer_key, $consumer_secret, $oauth_token = NULL, $oauth_token_secret = NULL) {
-       parent::__construct($consumer_key, $consumer_secret, $oauth_token, $oauth_token_secret);
-       $this->host = $apipath;
-     }
-   /**
-    * Make an HTTP request
-    *
-    * @return API results
-    *
-    * Copied here from the twitteroauth library and complemented by applying the proxy settings of friendica
-    */
-   function http($url, $method, $postfields = NULL) {
-     $this->http_info = array();
-     $ci = curl_init();
-     /* Curl settings */
-     $prx = get_config('system','proxy');
-     if(strlen($prx)) {
-       curl_setopt($ci, CURLOPT_HTTPPROXYTUNNEL, 1);
-       curl_setopt($ci, CURLOPT_PROXY, $prx);
-       $prxusr = get_config('system','proxyuser');
-       if(strlen($prxusr))
-           curl_setopt($ci, CURLOPT_PROXYUSERPWD, $prxusr);
-     }
-     curl_setopt($ci, CURLOPT_USERAGENT, $this->useragent);
-     curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, $this->connecttimeout);
-     curl_setopt($ci, CURLOPT_TIMEOUT, $this->timeout);
-     curl_setopt($ci, CURLOPT_RETURNTRANSFER, TRUE);
-     curl_setopt($ci, CURLOPT_HTTPHEADER, array('Expect:'));
-     curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, $this->ssl_verifypeer);
-     curl_setopt($ci, CURLOPT_HEADERFUNCTION, array($this, 'getHeader'));
-     curl_setopt($ci, CURLOPT_HEADER, FALSE);
-     switch ($method) {
-       case 'POST':
-       curl_setopt($ci, CURLOPT_POST, TRUE);
-       if (!empty($postfields)) {
-         curl_setopt($ci, CURLOPT_POSTFIELDS, $postfields);
-       }
-       break;
-       case 'DELETE':
-       curl_setopt($ci, CURLOPT_CUSTOMREQUEST, 'DELETE');
-       if (!empty($postfields)) {
-         $url = "{$url}?{$postfields}";
-       }
-     }
-     curl_setopt($ci, CURLOPT_URL, $url);
-     $response = curl_exec($ci);
-     $this->http_code = curl_getinfo($ci, CURLINFO_HTTP_CODE);
-     $this->http_info = array_merge($this->http_info, curl_getinfo($ci));
-     $this->url = $url;
-     curl_close ($ci);
-     return $response;
-   }
- }
+ require_once __DIR__ . DIRECTORY_SEPARATOR . 'library' . DIRECTORY_SEPARATOR . 'statusnetoauth.php';
+ require_once 'include/enotify.php';
+ use Codebird\Codebird;
+ use CodebirdSN\CodebirdSN;
+ use Friendica\App;
+ use Friendica\Content\OEmbed;
+ use Friendica\Content\Text\BBCode;
+ use Friendica\Content\Text\Plaintext;
+ use Friendica\Core\Addon;
+ use Friendica\Core\Config;
+ use Friendica\Core\L10n;
+ use Friendica\Core\PConfig;
+ use Friendica\Model\GContact;
+ use Friendica\Model\Group;
+ use Friendica\Model\Item;
+ use Friendica\Model\Photo;
+ use Friendica\Model\User;
+ use Friendica\Util\DateTimeFormat;
+ use Friendica\Util\Network;
  
 -function statusnet_install()
 -{
 +function statusnet_install() {
        //  we need some hooks, for the configuration and for sending tweets
-       register_hook('connector_settings', 'addon/statusnet/statusnet.php', 'statusnet_settings');
-       register_hook('connector_settings_post', 'addon/statusnet/statusnet.php', 'statusnet_settings_post');
-       register_hook('notifier_normal', 'addon/statusnet/statusnet.php', 'statusnet_post_hook');
-       register_hook('post_local', 'addon/statusnet/statusnet.php', 'statusnet_post_local');
-       register_hook('jot_networks',    'addon/statusnet/statusnet.php', 'statusnet_jot_nets');
-       register_hook('cron', 'addon/statusnet/statusnet.php', 'statusnet_cron');
-       register_hook('prepare_body', 'addon/statusnet/statusnet.php', 'statusnet_prepare_body');
-       register_hook('check_item_notification','addon/statusnet/statusnet.php', 'statusnet_check_item_notification');
+       Addon::registerHook('connector_settings', 'addon/statusnet/statusnet.php', 'statusnet_settings');
+       Addon::registerHook('connector_settings_post', 'addon/statusnet/statusnet.php', 'statusnet_settings_post');
+       Addon::registerHook('notifier_normal', 'addon/statusnet/statusnet.php', 'statusnet_post_hook');
+       Addon::registerHook('post_local', 'addon/statusnet/statusnet.php', 'statusnet_post_local');
+       Addon::registerHook('jot_networks', 'addon/statusnet/statusnet.php', 'statusnet_jot_nets');
+       Addon::registerHook('cron', 'addon/statusnet/statusnet.php', 'statusnet_cron');
+       Addon::registerHook('prepare_body', 'addon/statusnet/statusnet.php', 'statusnet_prepare_body');
+       Addon::registerHook('check_item_notification', 'addon/statusnet/statusnet.php', 'statusnet_check_item_notification');
        logger("installed GNU Social");
  }
  
function statusnet_uninstall() {
-       unregister_hook('connector_settings', 'addon/statusnet/statusnet.php', 'statusnet_settings');
-       unregister_hook('connector_settings_post', 'addon/statusnet/statusnet.php', 'statusnet_settings_post');
-       unregister_hook('notifier_normal', 'addon/statusnet/statusnet.php', 'statusnet_post_hook');
-       unregister_hook('post_local', 'addon/statusnet/statusnet.php', 'statusnet_post_local');
-       unregister_hook('jot_networks',    'addon/statusnet/statusnet.php', 'statusnet_jot_nets');
-       unregister_hook('cron', 'addon/statusnet/statusnet.php', 'statusnet_cron');
-       unregister_hook('prepare_body', 'addon/statusnet/statusnet.php', 'statusnet_prepare_body');
-       unregister_hook('check_item_notification','addon/statusnet/statusnet.php', 'statusnet_check_item_notification');
+ function statusnet_uninstall()
+ {
+       Addon::unregisterHook('connector_settings', 'addon/statusnet/statusnet.php', 'statusnet_settings');
+       Addon::unregisterHook('connector_settings_post', 'addon/statusnet/statusnet.php', 'statusnet_settings_post');
+       Addon::unregisterHook('notifier_normal', 'addon/statusnet/statusnet.php', 'statusnet_post_hook');
+       Addon::unregisterHook('post_local', 'addon/statusnet/statusnet.php', 'statusnet_post_local');
+       Addon::unregisterHook('jot_networks', 'addon/statusnet/statusnet.php', 'statusnet_jot_nets');
+       Addon::unregisterHook('cron', 'addon/statusnet/statusnet.php', 'statusnet_cron');
+       Addon::unregisterHook('prepare_body', 'addon/statusnet/statusnet.php', 'statusnet_prepare_body');
+       Addon::unregisterHook('check_item_notification', 'addon/statusnet/statusnet.php', 'statusnet_check_item_notification');
  
        // old setting - remove only
-       unregister_hook('post_local_end', 'addon/statusnet/statusnet.php', 'statusnet_post_hook');
-       unregister_hook('plugin_settings', 'addon/statusnet/statusnet.php', 'statusnet_settings');
-       unregister_hook('plugin_settings_post', 'addon/statusnet/statusnet.php', 'statusnet_settings_post');
+       Addon::unregisterHook('post_local_end', 'addon/statusnet/statusnet.php', 'statusnet_post_hook');
+       Addon::unregisterHook('addon_settings', 'addon/statusnet/statusnet.php', 'statusnet_settings');
+       Addon::unregisterHook('addon_settings_post', 'addon/statusnet/statusnet.php', 'statusnet_settings_post');
  }
  
 -function statusnet_check_item_notification(App $a, &$notification_data)
 -{
 -      $notification_data["profiles"][] = PConfig::get($notification_data["uid"], 'statusnet', 'own_url');
 +function statusnet_check_item_notification($a, &$notification_data) {
 +      $notification_data["profiles"][] = get_pconfig($notification_data["uid"], 'statusnet', 'own_url');
  }
  
 -function statusnet_jot_nets(App $a, &$b)
 -{
 -      if (!local_user()) {
 +function statusnet_jot_nets(&$a,&$b) {
 +      if(! local_user())
                return;
 -      }
  
 -      $statusnet_post = PConfig::get(local_user(), 'statusnet', 'post');
 -      if (intval($statusnet_post) == 1) {
 -              $statusnet_defpost = PConfig::get(local_user(), 'statusnet', 'post_by_default');
 +      $statusnet_post = get_pconfig(local_user(),'statusnet','post');
 +      if(intval($statusnet_post) == 1) {
 +              $statusnet_defpost = get_pconfig(local_user(),'statusnet','post_by_default');
                $selected = ((intval($statusnet_defpost) == 1) ? ' checked="checked" ' : '');
                $b .= '<div class="profile-jot-net"><input type="checkbox" name="statusnet_enable"' . $selected . ' value="1" /> '
-                       . t('Post to GNU Social') . '</div>';
+                       . L10n::t('Post to GNU Social') . '</div>';
        }
  }
  
 -function statusnet_settings_post(App $a, $post)
 -{
 -      if (!local_user()) {
 +function statusnet_settings_post ($a,$post) {
 +      if(! local_user())
                return;
 -      }
        // don't check GNU Social settings if GNU Social submit button is not clicked
 -      if (!x($_POST, 'statusnet-submit')) {
 +      if (!x($_POST,'statusnet-submit'))
                return;
 -      }
  
        if (isset($_POST['statusnet-disconnect'])) {
 -              /*               * *
 +              /***
                 * if the GNU Social-disconnect checkbox is set, clear the GNU Social configuration
                 */
 -              PConfig::delete(local_user(), 'statusnet', 'consumerkey');
 -              PConfig::delete(local_user(), 'statusnet', 'consumersecret');
 -              PConfig::delete(local_user(), 'statusnet', 'post');
 -              PConfig::delete(local_user(), 'statusnet', 'post_by_default');
 -              PConfig::delete(local_user(), 'statusnet', 'oauthtoken');
 -              PConfig::delete(local_user(), 'statusnet', 'oauthsecret');
 -              PConfig::delete(local_user(), 'statusnet', 'baseapi');
 -              PConfig::delete(local_user(), 'statusnet', 'lastid');
 -              PConfig::delete(local_user(), 'statusnet', 'mirror_posts');
 -              PConfig::delete(local_user(), 'statusnet', 'import');
 -              PConfig::delete(local_user(), 'statusnet', 'create_user');
 -              PConfig::delete(local_user(), 'statusnet', 'own_id');
 +              del_pconfig(local_user(), 'statusnet', 'consumerkey');
 +              del_pconfig(local_user(), 'statusnet', 'consumersecret');
 +              del_pconfig(local_user(), 'statusnet', 'post');
 +              del_pconfig(local_user(), 'statusnet', 'post_by_default');
 +              del_pconfig(local_user(), 'statusnet', 'oauthtoken');
 +              del_pconfig(local_user(), 'statusnet', 'oauthsecret');
 +              del_pconfig(local_user(), 'statusnet', 'baseapi');
 +              del_pconfig(local_user(), 'statusnet', 'lastid');
 +              del_pconfig(local_user(), 'statusnet', 'mirror_posts');
 +              del_pconfig(local_user(), 'statusnet', 'import');
 +              del_pconfig(local_user(), 'statusnet', 'create_user');
 +              del_pconfig(local_user(), 'statusnet', 'own_id');
        } else {
-       if (isset($_POST['statusnet-preconf-apiurl'])) {
-               /***
-                * If the user used one of the preconfigured GNU Social server credentials
-                * use them. All the data are available in the global config.
-                * Check the API Url never the less and blame the admin if it's not working ^^
-                */
-               $globalsn = get_config('statusnet', 'sites');
-               foreach ( $globalsn as $asn) {
-                       if ($asn['apiurl'] == $_POST['statusnet-preconf-apiurl'] ) {
-                               $apibase = $asn['apiurl'];
-                               $c = fetch_url( $apibase . 'statusnet/version.xml' );
+               if (isset($_POST['statusnet-preconf-apiurl'])) {
+                       /*                       * *
+                        * If the user used one of the preconfigured GNU Social server credentials
+                        * use them. All the data are available in the global config.
+                        * Check the API Url never the less and blame the admin if it's not working ^^
+                        */
+                       $globalsn = Config::get('statusnet', 'sites');
+                       foreach ($globalsn as $asn) {
+                               if ($asn['apiurl'] == $_POST['statusnet-preconf-apiurl']) {
+                                       $apibase = $asn['apiurl'];
+                                       $c = Network::fetchUrl($apibase . 'statusnet/version.xml');
+                                       if (strlen($c) > 0) {
+                                               PConfig::set(local_user(), 'statusnet', 'consumerkey', $asn['consumerkey']);
+                                               PConfig::set(local_user(), 'statusnet', 'consumersecret', $asn['consumersecret']);
+                                               PConfig::set(local_user(), 'statusnet', 'baseapi', $asn['apiurl']);
+                                               //PConfig::set(local_user(), 'statusnet', 'application_name', $asn['applicationname'] );
+                                       } else {
+                                               notice(L10n::t('Please contact your site administrator.<br />The provided API URL is not valid.') . EOL . $asn['apiurl'] . EOL);
+                                       }
+                               }
+                       }
+                       goaway('settings/connectors');
+               } else {
+                       if (isset($_POST['statusnet-consumersecret'])) {
+                               //  check if we can reach the API of the GNU Social server
+                               //  we'll check the API Version for that, if we don't get one we'll try to fix the path but will
+                               //  resign quickly after this one try to fix the path ;-)
+                               $apibase = $_POST['statusnet-baseapi'];
+                               $c = Network::fetchUrl($apibase . 'statusnet/version.xml');
                                if (strlen($c) > 0) {
 -                                      //  ok the API path is correct, let's save the settings
 -                                      PConfig::set(local_user(), 'statusnet', 'consumerkey', $_POST['statusnet-consumerkey']);
 -                                      PConfig::set(local_user(), 'statusnet', 'consumersecret', $_POST['statusnet-consumersecret']);
 -                                      PConfig::set(local_user(), 'statusnet', 'baseapi', $apibase);
 -                                      //PConfig::set(local_user(), 'statusnet', 'application_name', $_POST['statusnet-applicationname'] );
 +                                      set_pconfig(local_user(), 'statusnet', 'consumerkey', $asn['consumerkey'] );
 +                                      set_pconfig(local_user(), 'statusnet', 'consumersecret', $asn['consumersecret'] );
 +                                      set_pconfig(local_user(), 'statusnet', 'baseapi', $asn['apiurl'] );
 +                                      //set_pconfig(local_user(), 'statusnet', 'application_name', $asn['applicationname'] );
                                } else {
-                                       notice( t('Please contact your site administrator.<br />The provided API URL is not valid.').EOL.$asn['apiurl'].EOL );
+                                       //  the API path is not correct, maybe missing trailing / ?
+                                       $apibase = $apibase . '/';
+                                       $c = Network::fetchUrl($apibase . 'statusnet/version.xml');
+                                       if (strlen($c) > 0) {
+                                               //  ok the API path is now correct, let's save the settings
+                                               PConfig::set(local_user(), 'statusnet', 'consumerkey', $_POST['statusnet-consumerkey']);
+                                               PConfig::set(local_user(), 'statusnet', 'consumersecret', $_POST['statusnet-consumersecret']);
+                                               PConfig::set(local_user(), 'statusnet', 'baseapi', $apibase);
+                                       } else {
+                                               //  still not the correct API base, let's do noting
+                                               notice(L10n::t('We could not contact the GNU Social API with the Path you entered.') . EOL);
+                                       }
                                }
 -                              goaway('settings/connectors');
 +                      }
 +              }
 +              goaway($a->get_baseurl().'/settings/connectors');
 +      } else {
 +      if (isset($_POST['statusnet-consumersecret'])) {
 +              //  check if we can reach the API of the GNU Social server
 +              //  we'll check the API Version for that, if we don't get one we'll try to fix the path but will
 +              //  resign quickly after this one try to fix the path ;-)
 +              $apibase = $_POST['statusnet-baseapi'];
 +              $c = fetch_url( $apibase . 'statusnet/version.xml' );
 +              if (strlen($c) > 0) {
 +                      //  ok the API path is correct, let's save the settings
 +                      set_pconfig(local_user(), 'statusnet', 'consumerkey', $_POST['statusnet-consumerkey']);
 +                      set_pconfig(local_user(), 'statusnet', 'consumersecret', $_POST['statusnet-consumersecret']);
 +                      set_pconfig(local_user(), 'statusnet', 'baseapi', $apibase );
 +                      //set_pconfig(local_user(), 'statusnet', 'application_name', $_POST['statusnet-applicationname'] );
 +              } else {
 +                      //  the API path is not correct, maybe missing trailing / ?
 +                      $apibase = $apibase . '/';
 +                      $c = fetch_url( $apibase . 'statusnet/version.xml' );
 +                      if (strlen($c) > 0) {
 +                              //  ok the API path is now correct, let's save the settings
 +                              set_pconfig(local_user(), 'statusnet', 'consumerkey', $_POST['statusnet-consumerkey']);
 +                              set_pconfig(local_user(), 'statusnet', 'consumersecret', $_POST['statusnet-consumersecret']);
 +                              set_pconfig(local_user(), 'statusnet', 'baseapi', $apibase );
                        } else {
-                               //  still not the correct API base, let's do noting
-                               notice( t('We could not contact the GNU Social API with the Path you entered.').EOL );
+                               if (isset($_POST['statusnet-pin'])) {
+                                       //  if the user supplied us with a PIN from GNU Social, let the magic of OAuth happen
+                                       $api = PConfig::get(local_user(), 'statusnet', 'baseapi');
+                                       $ckey = PConfig::get(local_user(), 'statusnet', 'consumerkey');
+                                       $csecret = PConfig::get(local_user(), 'statusnet', 'consumersecret');
+                                       //  the token and secret for which the PIN was generated were hidden in the settings
+                                       //  form as token and token2, we need a new connection to GNU Social using these token
+                                       //  and secret to request a Access Token with the PIN
+                                       $connection = new StatusNetOAuth($api, $ckey, $csecret, $_POST['statusnet-token'], $_POST['statusnet-token2']);
+                                       $token = $connection->getAccessToken($_POST['statusnet-pin']);
+                                       //  ok, now that we have the Access Token, save them in the user config
+                                       PConfig::set(local_user(), 'statusnet', 'oauthtoken', $token['oauth_token']);
+                                       PConfig::set(local_user(), 'statusnet', 'oauthsecret', $token['oauth_token_secret']);
+                                       PConfig::set(local_user(), 'statusnet', 'post', 1);
+                                       PConfig::set(local_user(), 'statusnet', 'post_taglinks', 1);
+                                       //  reload the Addon Settings page, if we don't do it see Bug #42
+                                       goaway('settings/connectors');
+                               } else {
+                                       //  if no PIN is supplied in the POST variables, the user has changed the setting
+                                       //  to post a dent for every new __public__ posting to the wall
+                                       PConfig::set(local_user(), 'statusnet', 'post', intval($_POST['statusnet-enable']));
+                                       PConfig::set(local_user(), 'statusnet', 'post_by_default', intval($_POST['statusnet-default']));
+                                       PConfig::set(local_user(), 'statusnet', 'mirror_posts', intval($_POST['statusnet-mirror']));
+                                       PConfig::set(local_user(), 'statusnet', 'import', intval($_POST['statusnet-import']));
+                                       PConfig::set(local_user(), 'statusnet', 'create_user', intval($_POST['statusnet-create_user']));
+                                       if (!intval($_POST['statusnet-mirror']))
+                                               PConfig::delete(local_user(), 'statusnet', 'lastid');
+                                       info(L10n::t('GNU Social settings updated.') . EOL);
+                               }
                        }
                }
 -      }
 +              goaway($a->get_baseurl().'/settings/connectors');
 +      } else {
 +      if (isset($_POST['statusnet-pin'])) {
 +              //  if the user supplied us with a PIN from GNU Social, let the magic of OAuth happen
 +              $api     = get_pconfig(local_user(), 'statusnet', 'baseapi');
 +              $ckey    = get_pconfig(local_user(), 'statusnet', 'consumerkey'  );
 +              $csecret = get_pconfig(local_user(), 'statusnet', 'consumersecret' );
 +              //  the token and secret for which the PIN was generated were hidden in the settings
 +              //  form as token and token2, we need a new connection to GNU Social using these token
 +              //  and secret to request a Access Token with the PIN
 +              $connection = new StatusNetOAuth($api, $ckey, $csecret, $_POST['statusnet-token'], $_POST['statusnet-token2']);
 +              $token   = $connection->getAccessToken( $_POST['statusnet-pin'] );
 +              //  ok, now that we have the Access Token, save them in the user config
 +              set_pconfig(local_user(),'statusnet', 'oauthtoken',  $token['oauth_token']);
 +              set_pconfig(local_user(),'statusnet', 'oauthsecret', $token['oauth_token_secret']);
 +              set_pconfig(local_user(),'statusnet', 'post', 1);
 +              set_pconfig(local_user(),'statusnet', 'post_taglinks', 1);
 +              //  reload the Addon Settings page, if we don't do it see Bug #42
 +              goaway($a->get_baseurl().'/settings/connectors');
 +      } else {
 +              //  if no PIN is supplied in the POST variables, the user has changed the setting
 +              //  to post a dent for every new __public__ posting to the wall
 +              set_pconfig(local_user(),'statusnet','post',intval($_POST['statusnet-enable']));
 +              set_pconfig(local_user(),'statusnet','post_by_default',intval($_POST['statusnet-default']));
 +              set_pconfig(local_user(), 'statusnet', 'mirror_posts', intval($_POST['statusnet-mirror']));
 +              set_pconfig(local_user(), 'statusnet', 'import', intval($_POST['statusnet-import']));
 +              set_pconfig(local_user(), 'statusnet', 'create_user', intval($_POST['statusnet-create_user']));
 +
 +              if (!intval($_POST['statusnet-mirror']))
 +                      del_pconfig(local_user(),'statusnet','lastid');
 +
 +              info( t('GNU Social settings updated.') . EOL);
 +      }}}}
  }
 -
 -function statusnet_settings(App $a, &$s)
 -{
 -      if (!local_user()) {
 +function statusnet_settings(&$a,&$s) {
 +      if(! local_user())
                return;
 -      }
        $a->page['htmlhead'] .= '<link rel="stylesheet"  type="text/css" href="' . $a->get_baseurl() . '/addon/statusnet/statusnet.css' . '" media="all" />' . "\r\n";
 -      /*       * *
 +      /***
         * 1) Check that we have a base api url and a consumer key & secret
         * 2) If no OAuthtoken & stuff is present, generate button to get some
         *    allow the user to cancel the connection process at this step
        $s .= '</span>';
        $s .= '<div id="settings_statusnet_expanded" class="settings-block" style="display: none;">';
        $s .= '<span class="fakelink" onclick="openClose(\'settings_statusnet_expanded\'); openClose(\'settings_statusnet_inflated\');">';
-       $s .= '<img class="connector'.$css.'" src="images/gnusocial.png" /><h3 class="connector">'. t('GNU Social Import/Export/Mirror').'</h3>';
+       $s .= '<img class="connector' . $css . '" src="images/gnusocial.png" /><h3 class="connector">' . L10n::t('GNU Social Import/Export/Mirror') . '</h3>';
        $s .= '</span>';
  
 -      if ((!$ckey) && (!$csecret)) {
 -              /*               * *
 +      if ( (!$ckey) && (!$csecret) ) {
 +              /***
                 * no consumer keys
                 */
 -              $globalsn = Config::get('statusnet', 'sites');
 -              /*               * *
 +              $globalsn = get_config('statusnet', 'sites');
 +              /***
                 * lets check if we have one or more globally configured GNU Social
                 * server OAuth credentials in the configuration. If so offer them
                 * with a little explanation to the user as choice - otherwise
                 * ignore this option entirely.
                 */
-               if (! $globalsn == null) {
-                       $s .= '<h4>' . t('Globally Available GNU Social OAuthKeys') . '</h4>';
-                       $s .= '<p>'. t("There are preconfigured OAuth key pairs for some GNU Social servers available. If you are using one of them, please use these credentials. If not feel free to connect to any other GNU Social instance \x28see below\x29.") .'</p>';
+               if (!$globalsn == null) {
+                       $s .= '<h4>' . L10n::t('Globally Available GNU Social OAuthKeys') . '</h4>';
+                       $s .= '<p>' . L10n::t("There are preconfigured OAuth key pairs for some GNU Social servers available. If you are using one of them, please use these credentials. If not feel free to connect to any other GNU Social instance \x28see below\x29.") . '</p>';
                        $s .= '<div id="statusnet-preconf-wrapper">';
                        foreach ($globalsn as $asn) {
 -                              $s .= '<input type="radio" name="statusnet-preconf-apiurl" value="' . $asn['apiurl'] . '">' . $asn['sitename'] . '<br />';
 +                              $s .= '<input type="radio" name="statusnet-preconf-apiurl" value="'. $asn['apiurl'] .'">'. $asn['sitename'] .'<br />';
                        }
                        $s .= '<p></p><div class="clear"></div></div>';
-                       $s .= '<div class="settings-submit-wrapper" ><input type="submit" name="statusnet-submit" class="settings-submit" value="' . t('Save Settings') . '" /></div>';
+                       $s .= '<div class="settings-submit-wrapper" ><input type="submit" name="statusnet-submit" class="settings-submit" value="' . L10n::t('Save Settings') . '" /></div>';
                }
-               $s .= '<h4>' . t('Provide your own OAuth Credentials') . '</h4>';
-               $s .= '<p>'. t('No consumer key pair for GNU Social found. Register your Friendica Account as an desktop client on your GNU Social account, copy the consumer key pair here and enter the API base root.<br />Before you register your own OAuth key pair ask the administrator if there is already a key pair for this Friendica installation at your favorited GNU Social installation.') .'</p>';
+               $s .= '<h4>' . L10n::t('Provide your own OAuth Credentials') . '</h4>';
+               $s .= '<p>' . L10n::t('No consumer key pair for GNU Social found. Register your Friendica Account as an desktop client on your GNU Social account, copy the consumer key pair here and enter the API base root.<br />Before you register your own OAuth key pair ask the administrator if there is already a key pair for this Friendica installation at your favorited GNU Social installation.') . '</p>';
                $s .= '<div id="statusnet-consumer-wrapper">';
-               $s .= '<label id="statusnet-consumerkey-label" for="statusnet-consumerkey">'. t('OAuth Consumer Key') .'</label>';
+               $s .= '<label id="statusnet-consumerkey-label" for="statusnet-consumerkey">' . L10n::t('OAuth Consumer Key') . '</label>';
                $s .= '<input id="statusnet-consumerkey" type="text" name="statusnet-consumerkey" size="35" /><br />';
                $s .= '<div class="clear"></div>';
-               $s .= '<label id="statusnet-consumersecret-label" for="statusnet-consumersecret">'. t('OAuth Consumer Secret') .'</label>';
+               $s .= '<label id="statusnet-consumersecret-label" for="statusnet-consumersecret">' . L10n::t('OAuth Consumer Secret') . '</label>';
                $s .= '<input id="statusnet-consumersecret" type="text" name="statusnet-consumersecret" size="35" /><br />';
                $s .= '<div class="clear"></div>';
-               $s .= '<label id="statusnet-baseapi-label" for="statusnet-baseapi">'. t("Base API Path \x28remember the trailing /\x29") .'</label>';
+               $s .= '<label id="statusnet-baseapi-label" for="statusnet-baseapi">' . L10n::t("Base API Path \x28remember the trailing /\x29") . '</label>';
                $s .= '<input id="statusnet-baseapi" type="text" name="statusnet-baseapi" size="35" /><br />';
                $s .= '<div class="clear"></div>';
-               //$s .= '<label id="statusnet-applicationname-label" for="statusnet-applicationname">'.t('GNU Socialapplication name').'</label>';
+               //$s .= '<label id="statusnet-applicationname-label" for="statusnet-applicationname">'.L10n::t('GNU Socialapplication name').'</label>';
                //$s .= '<input id="statusnet-applicationname" type="text" name="statusnet-applicationname" size="35" /><br />';
                $s .= '<p></p><div class="clear"></div>';
-               $s .= '<div class="settings-submit-wrapper" ><input type="submit" name="statusnet-submit" class="settings-submit" value="' . t('Save Settings') . '" /></div>';
+               $s .= '<div class="settings-submit-wrapper" ><input type="submit" name="statusnet-submit" class="settings-submit" value="' . L10n::t('Save Settings') . '" /></div>';
                $s .= '</div>';
        } else {
 -              /*               * *
 +              /***
                 * ok we have a consumer key pair now look into the OAuth stuff
                 */
 -              if ((!$otoken) && (!$osecret)) {
 -                      /*                       * *
 +              if ( (!$otoken) && (!$osecret) ) {
 +                      /***
                         * the user has not yet connected the account to GNU Social
                         * get a temporary OAuth key/secret pair and display a button with
                         * which the user can request a PIN to connect the account to a
                        $connection = new StatusNetOAuth($api, $ckey, $csecret);
                        $request_token = $connection->getRequestToken('oob');
                        $token = $request_token['oauth_token'];
 -                      /*                       * *
 +                      /***
                         *  make some nice form
                         */
-                       $s .= '<p>'. t('To connect to your GNU Social account click the button below to get a security code from GNU Social which you have to copy into the input box below and submit the form. Only your <strong>public</strong> posts will be posted to GNU Social.') .'</p>';
-                       $s .= '<a href="'.$connection->getAuthorizeURL($token,False).'" target="_statusnet"><img src="addon/statusnet/signinwithstatusnet.png" alt="'. t('Log in with GNU Social') .'"></a>';
+                       $s .= '<p>' . L10n::t('To connect to your GNU Social account click the button below to get a security code from GNU Social which you have to copy into the input box below and submit the form. Only your <strong>public</strong> posts will be posted to GNU Social.') . '</p>';
+                       $s .= '<a href="' . $connection->getAuthorizeURL($token, False) . '" target="_statusnet"><img src="addon/statusnet/signinwithstatusnet.png" alt="' . L10n::t('Log in with GNU Social') . '"></a>';
                        $s .= '<div id="statusnet-pin-wrapper">';
-                       $s .= '<label id="statusnet-pin-label" for="statusnet-pin">'. t('Copy the security code from GNU Social here') .'</label>';
+                       $s .= '<label id="statusnet-pin-label" for="statusnet-pin">' . L10n::t('Copy the security code from GNU Social here') . '</label>';
                        $s .= '<input id="statusnet-pin" type="text" name="statusnet-pin" />';
 -                      $s .= '<input id="statusnet-token" type="hidden" name="statusnet-token" value="' . $token . '" />';
 -                      $s .= '<input id="statusnet-token2" type="hidden" name="statusnet-token2" value="' . $request_token['oauth_token_secret'] . '" />';
 +                      $s .= '<input id="statusnet-token" type="hidden" name="statusnet-token" value="'.$token.'" />';
 +                      $s .= '<input id="statusnet-token2" type="hidden" name="statusnet-token2" value="'.$request_token['oauth_token_secret'].'" />';
                        $s .= '</div><div class="clear"></div>';
-                       $s .= '<div class="settings-submit-wrapper" ><input type="submit" name="statusnet-submit" class="settings-submit" value="' . t('Save Settings') . '" /></div>';
-                       $s .= '<h4>'.t('Cancel Connection Process').'</h4>';
+                       $s .= '<div class="settings-submit-wrapper" ><input type="submit" name="statusnet-submit" class="settings-submit" value="' . L10n::t('Save Settings') . '" /></div>';
+                       $s .= '<h4>' . L10n::t('Cancel Connection Process') . '</h4>';
                        $s .= '<div id="statusnet-cancel-wrapper">';
-                       $s .= '<p>'.t('Current GNU Social API is').': '.$api.'</p>';
-                       $s .= '<label id="statusnet-cancel-label" for="statusnet-cancel">'t('Cancel GNU Social Connection') . '</label>';
+                       $s .= '<p>' . L10n::t('Current GNU Social API is') . ': ' . $api . '</p>';
+                       $s .= '<label id="statusnet-cancel-label" for="statusnet-cancel">' . L10n::t('Cancel GNU Social Connection') . '</label>';
                        $s .= '<input id="statusnet-cancel" type="checkbox" name="statusnet-disconnect" value="1" />';
                        $s .= '</div><div class="clear"></div>';
-                       $s .= '<div class="settings-submit-wrapper" ><input type="submit" name="statusnet-submit" class="settings-submit" value="' . t('Save Settings') . '" /></div>';
+                       $s .= '<div class="settings-submit-wrapper" ><input type="submit" name="statusnet-submit" class="settings-submit" value="' . L10n::t('Save Settings') . '" /></div>';
                } else {
 -                      /*                       * *
 +                      /***
                         *  we have an OAuth key / secret pair for the user
                         *  so let's give a chance to disable the postings to GNU Social
                         */
 -                      $connection = new StatusNetOAuth($api, $ckey, $csecret, $otoken, $osecret);
 +                      $connection = new StatusNetOAuth($api,$ckey,$csecret,$otoken,$osecret);
                        $details = $connection->get('account/verify_credentials');
-                       $s .= '<div id="statusnet-info" ><img id="statusnet-avatar" src="'.$details->profile_image_url.'" /><p id="statusnet-info-block">'. t('Currently connected to: ') .'<a href="'.$details->statusnet_profile_url.'" target="_statusnet">'.$details->screen_name.'</a><br /><em>'.$details->description.'</em></p></div>';
-                       $s .= '<p>'. t('If enabled all your <strong>public</strong> postings can be posted to the associated GNU Social account. You can choose to do so by default (here) or for every posting separately in the posting options when writing the entry.') .'</p>';
+                       $s .= '<div id="statusnet-info" ><img id="statusnet-avatar" src="' . $details->profile_image_url . '" /><p id="statusnet-info-block">' . L10n::t('Currently connected to: ') . '<a href="' . $details->statusnet_profile_url . '" target="_statusnet">' . $details->screen_name . '</a><br /><em>' . $details->description . '</em></p></div>';
+                       $s .= '<p>' . L10n::t('If enabled all your <strong>public</strong> postings can be posted to the associated GNU Social account. You can choose to do so by default (here) or for every posting separately in the posting options when writing the entry.') . '</p>';
                        if ($a->user['hidewall']) {
-                           $s .= '<p>'. t('<strong>Note</strong>: Due your privacy settings (<em>Hide your profile details from unknown viewers?</em>) the link potentially included in public postings relayed to GNU Social will lead the visitor to a blank page informing the visitor that the access to your profile has been restricted.') .'</p>';
+                               $s .= '<p>' . L10n::t('<strong>Note</strong>: Due your privacy settings (<em>Hide your profile details from unknown viewers?</em>) the link potentially included in public postings relayed to GNU Social will lead the visitor to a blank page informing the visitor that the access to your profile has been restricted.') . '</p>';
                        }
                        $s .= '<div id="statusnet-enable-wrapper">';
-                       $s .= '<label id="statusnet-enable-label" for="statusnet-checkbox">'. t('Allow posting to GNU Social') .'</label>';
+                       $s .= '<label id="statusnet-enable-label" for="statusnet-checkbox">' . L10n::t('Allow posting to GNU Social') . '</label>';
                        $s .= '<input id="statusnet-checkbox" type="checkbox" name="statusnet-enable" value="1" ' . $checked . '/>';
                        $s .= '<div class="clear"></div>';
-                       $s .= '<label id="statusnet-default-label" for="statusnet-default">'. t('Send public postings to GNU Social by default') .'</label>';
+                       $s .= '<label id="statusnet-default-label" for="statusnet-default">' . L10n::t('Send public postings to GNU Social by default') . '</label>';
                        $s .= '<input id="statusnet-default" type="checkbox" name="statusnet-default" value="1" ' . $defchecked . '/>';
                        $s .= '<div class="clear"></div>';
  
@@@ -564,30 -529,28 +564,27 @@@ function statusnet_post_hook(&$a,&$b) 
  
        logger('GNU Socialpost invoked');
  
 -      PConfig::load($b['uid'], 'statusnet');
 +      load_pconfig($b['uid'], 'statusnet');
 +
 +      $api     = get_pconfig($b['uid'], 'statusnet', 'baseapi');
 +      $ckey    = get_pconfig($b['uid'], 'statusnet', 'consumerkey');
 +      $csecret = get_pconfig($b['uid'], 'statusnet', 'consumersecret');
 +      $otoken  = get_pconfig($b['uid'], 'statusnet', 'oauthtoken');
 +      $osecret = get_pconfig($b['uid'], 'statusnet', 'oauthsecret');
  
 -      $api     = PConfig::get($b['uid'], 'statusnet', 'baseapi');
 -      $ckey    = PConfig::get($b['uid'], 'statusnet', 'consumerkey');
 -      $csecret = PConfig::get($b['uid'], 'statusnet', 'consumersecret');
 -      $otoken  = PConfig::get($b['uid'], 'statusnet', 'oauthtoken');
 -      $osecret = PConfig::get($b['uid'], 'statusnet', 'oauthsecret');
 +      if($ckey && $csecret && $otoken && $osecret) {
  
 -      if ($ckey && $csecret && $otoken && $osecret) {
                // If it's a repeated message from GNU Social then do a native retweet and exit
 -              if (statusnet_is_retweet($a, $b['uid'], $b['body'])) {
 +              if (statusnet_is_retweet($a, $b['uid'], $b['body']))
                        return;
 -              }
  
-               require_once('include/bbcode.php');
-               $dent = new StatusNetOAuth($api,$ckey,$csecret,$otoken,$osecret);
+               $dent = new StatusNetOAuth($api, $ckey, $csecret, $otoken, $osecret);
                $max_char = $dent->get_maxlength(); // max. length for a dent
  
 -              PConfig::set($b['uid'], 'statusnet', 'max_char', $max_char);
 +              set_pconfig($b['uid'], 'statusnet', 'max_char', $max_char);
  
                $tempfile = "";
-               require_once("include/plaintext.php");
-               require_once("include/network.php");
-               $msgarr = plaintext($a, $b, $max_char, true, 7);
+               $msgarr = BBCode::toPlaintext($b, $max_char, true, 7);
                $msg = $msgarr["text"];
  
                if (($msg == "") && isset($msgarr["title"]))
                $image = "";
  
                if (isset($msgarr["url"]) && ($msgarr["type"] != "photo")) {
-                       if ((strlen($msgarr["url"]) > 20) &&
-                               ((strlen($msg." \n".$msgarr["url"]) > $max_char)))
-                               $msg .= " \n".short_link($msgarr["url"]);
-                       else
-                               $msg .= " \n".$msgarr["url"];
-               } elseif (isset($msgarr["image"]) && ($msgarr["type"] != "video"))
+                       $msg .= " \n" . $msgarr["url"];
+               } elseif (isset($msgarr["image"]) && ($msgarr["type"] != "video")) {
                        $image = $msgarr["image"];
 -              }
  
                if ($image != "") {
-                       $img_str = fetch_url($image);
+                       $img_str = Network::fetchUrl($image);
                        $tempfile = tempnam(get_temppath(), "cache");
                        file_put_contents($tempfile, $img_str);
 -                      $postdata = ["status" => $msg, "media[]" => $tempfile];
 -              } else {
 -                      $postdata = ["status" => $msg];
 -              }
 +                      $postdata = array("status" => $msg, "media[]" => $tempfile);
 +              } else
 +                      $postdata = array("status"=>$msg);
  
-               // and now dent it :-)
-               if(strlen($msg)) {
+               // and now send it :-)
+               if (strlen($msg)) {
                        if ($iscomment) {
                                $postdata["in_reply_to_status_id"] = substr($orig_post["uri"], $hostlength);
 -                              logger('statusnet_post send reply ' . print_r($postdata, true), LOGGER_DEBUG);
 +                              logger('statusnet_post send reply '.print_r($postdata, true), LOGGER_DEBUG);
                        }
  
                        // New code that is able to post pictures
                        $cb->setToken($otoken, $osecret);
                        $result = $cb->statuses_update($postdata);
                        //$result = $dent->post('statuses/update', $postdata);
 -                      logger('statusnet_post send, result: ' . print_r($result, true) .
 -                              "\nmessage: " . $msg, LOGGER_DEBUG . "\nOriginal post: " . print_r($b, true) . "\nPost Data: " . print_r($postdata, true));
 +                      logger('statusnet_post send, result: ' . print_r($result, true).
 +                              "\nmessage: ".$msg, LOGGER_DEBUG."\nOriginal post: ".print_r($b, true)."\nPost Data: ".print_r($postdata, true));
  
 -                      if ($result->source) {
 -                              PConfig::set($b["uid"], "statusnet", "application_name", strip_tags($result->source));
 -                      }
 +                      if ($result->source)
 +                              set_pconfig($b["uid"], "statusnet", "application_name", strip_tags($result->source));
  
                        if ($result->error) {
 -                              logger('Send to GNU Social failed: "' . $result->error . '"');
 +                              logger('Send to GNU Social failed: "'.$result->error.'"');
                        } elseif ($iscomment) {
-                               logger('statusnet_post: Update extid '.$result->id." for post id ".$b['id']);
-                               q("UPDATE `item` SET `extid` = '%s', `body` = '%s' WHERE `id` = %d",
-                                       dbesc($hostname."::".$result->id),
-                                       dbesc($result->text),
-                                       intval($b['id'])
-                               );
+                               logger('statusnet_post: Update extid ' . $result->id . " for post id " . $b['id']);
+                               Item::update(['extid' => $hostname . "::" . $result->id, 'body' => $result->text], ['id' => $b['id']]);
                        }
                }
 -              if ($tempfile != "") {
 +              if ($tempfile != "")
                        unlink($tempfile);
 -              }
        }
  }
  
- function statusnet_plugin_admin_post(&$a){
+ function statusnet_addon_admin_post(App $a)
+ {
+       $sites = [];
  
 -      foreach ($_POST['sitename'] as $id => $sitename) {
 -              $sitename = trim($sitename);
 -              $apiurl = trim($_POST['apiurl'][$id]);
 -              if (!(substr($apiurl, -1) == '/')) {
 -                      $apiurl = $apiurl . '/';
 -              }
 -              $secret = trim($_POST['secret'][$id]);
 -              $key = trim($_POST['key'][$id]);
 +      $sites = array();
 +
 +      foreach($_POST['sitename'] as $id=>$sitename){
 +              $sitename=trim($sitename);
 +              $apiurl=trim($_POST['apiurl'][$id]);
 +              if (! (substr($apiurl, -1)=='/'))
 +                  $apiurl=$apiurl.'/';
 +              $secret=trim($_POST['secret'][$id]);
 +              $key=trim($_POST['key'][$id]);
                //$applicationname = ((x($_POST, 'applicationname')) ? notags(trim($_POST['applicationname'][$id])):'');
 -              if ($sitename != "" &&
 -                      $apiurl != "" &&
 -                      $secret != "" &&
 -                      $key != "" &&
 -                      !x($_POST['delete'][$id])) {
 -
 -                      $sites[] = [
 -                              'sitename' => $sitename,
 -                              'apiurl' => $apiurl,
 -                              'consumersecret' => $secret,
 -                              'consumerkey' => $key,
 -                              //'applicationname' => $applicationname
 -                      ];
 +              if ($sitename!="" &&
 +                      $apiurl!="" &&
 +                      $secret!="" &&
 +                      $key!="" &&
 +                      !x($_POST['delete'][$id])){
 +
 +                              $sites[] = Array(
 +                                      'sitename' => $sitename,
 +                                      'apiurl' => $apiurl,
 +                                      'consumersecret' => $secret,
 +                                      'consumerkey' => $key,
 +                                      //'applicationname' => $applicationname
 +                              );
                }
        }
  
 -      $sites = Config::set('statusnet', 'sites', $sites);
 +      $sites = set_config('statusnet','sites', $sites);
 +
  }
  
- function statusnet_plugin_admin(&$a, &$o){
-       $sites = get_config('statusnet','sites');
-       $sitesform=array();
-       if (is_array($sites)){
-               foreach($sites as $id=>$s){
-                       $sitesform[] = Array(
-                               'sitename' => Array("sitename[$id]", "Site name", $s['sitename'], ""),
-                               'apiurl' => Array("apiurl[$id]", "Api url", $s['apiurl'], t("Base API Path \x28remember the trailing /\x29") ),
-                               'secret' => Array("secret[$id]", "Secret", $s['consumersecret'], ""),
-                               'key' => Array("key[$id]", "Key", $s['consumerkey'], ""),
+ function statusnet_addon_admin(App $a, &$o)
+ {
+       $sites = Config::get('statusnet', 'sites');
+       $sitesform = [];
+       if (is_array($sites)) {
+               foreach ($sites as $id => $s) {
+                       $sitesform[] = [
+                               'sitename' => ["sitename[$id]", "Site name", $s['sitename'], ""],
+                               'apiurl' => ["apiurl[$id]", "Api url", $s['apiurl'], L10n::t("Base API Path \x28remember the trailing /\x29")],
+                               'secret' => ["secret[$id]", "Secret", $s['consumersecret'], ""],
+                               'key' => ["key[$id]", "Key", $s['consumerkey'], ""],
                                //'applicationname' => Array("applicationname[$id]", "Application name", $s['applicationname'], ""),
 -                              'delete' => ["delete[$id]", "Delete", False, "Check to delete this preset"],
 -                      ];
 +                              'delete' => Array("delete[$id]", "Delete", False , "Check to delete this preset"),
 +                      );
                }
        }
        /* empty form to add new site */
        $id++;
-       $sitesform[] = Array(
-               'sitename' => Array("sitename[$id]", t("Site name"), "", ""),
-               'apiurl' => Array("apiurl[$id]", "Api url", "", t("Base API Path \x28remember the trailing /\x29") ),
-               'secret' => Array("secret[$id]", t("Consumer Secret"), "", ""),
-               'key' => Array("key[$id]", t("Consumer Key"), "", ""),
-               //'applicationname' => Array("applicationname[$id]", t("Application name"), "", ""),
-       );
-       $t = get_markup_template( "admin.tpl", "addon/statusnet/" );
-       $o = replace_macros($t, array(
-               '$submit' => t('Save Settings'),
+       $sitesform[] = [
+               'sitename' => ["sitename[$id]", L10n::t("Site name"), "", ""],
+               'apiurl' => ["apiurl[$id]", "Api url", "", L10n::t("Base API Path \x28remember the trailing /\x29")],
+               'secret' => ["secret[$id]", L10n::t("Consumer Secret"), "", ""],
+               'key' => ["key[$id]", L10n::t("Consumer Key"), "", ""],
+               //'applicationname' => Array("applicationname[$id]", L10n::t("Application name"), "", ""),
+       ];
+       $t = get_markup_template("admin.tpl", "addon/statusnet/");
+       $o = replace_macros($t, [
+               '$submit' => L10n::t('Save Settings'),
                '$sites' => $sitesform,
 -      ]);
 +      ));
  }
  
 -function statusnet_prepare_body(App $a, &$b)
 -{
 -      if ($b["item"]["network"] != NETWORK_STATUSNET) {
 -              return;
 -      }
 +function statusnet_prepare_body(&$a,&$b) {
 +        if ($b["item"]["network"] != NETWORK_STATUSNET)
 +                return;
  
 -      if ($b["preview"]) {
 -              $max_char = PConfig::get(local_user(), 'statusnet', 'max_char');
 -              if (intval($max_char) == 0) {
 +        if ($b["preview"]) {
 +              $max_char = get_pconfig(local_user(),'statusnet','max_char');
 +              if (intval($max_char) == 0)
                        $max_char = 140;
 -              }
  
-                 require_once("include/plaintext.php");
-                 $item = $b["item"];
-                 $item["plink"] = $a->get_baseurl()."/display/".$a->user["nickname"]."/".$item["parent"];
+               $item = $b["item"];
+               $item["plink"] = $a->get_baseurl() . "/display/" . $a->user["nickname"] . "/" . $item["parent"];
  
                $r = q("SELECT `item`.`author-link`, `item`.`uri`, `contact`.`nick` AS contact_nick
                          FROM `item` INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
  
                        $nick = preg_replace("=https?://(.*)/(.*)=ism", "$2", $orig_post["author-link"]);
  
 -                      $nickname = "@[url=" . $orig_post["author-link"] . "]" . $nick . "[/url]";
 -                      $nicknameplain = "@" . $nick;
 +                      $nickname = "@[url=".$orig_post["author-link"]."]".$nick."[/url]";
 +                      $nicknameplain = "@".$nick;
  
 -                      if ((strpos($item["body"], $nickname) === false) && (strpos($item["body"], $nicknameplain) === false)) {
 -                              $item["body"] = $nickname . " " . $item["body"];
 -                      }
 -              }
 +                      if ((strpos($item["body"], $nickname) === false) && (strpos($item["body"], $nicknameplain) === false))
 +                              $item["body"] = $nickname." ".$item["body"];
 +                }
  
+               $msgarr = BBCode::toPlaintext($item, $max_char, true, 7);
+               $msg = $msgarr["text"];
  
 -              if (isset($msgarr["url"]) && ($msgarr["type"] != "photo")) {
 -                      $msg .= " " . $msgarr["url"];
 -              }
 +                $msgarr = plaintext($a, $item, $max_char, true, 7);
 +                $msg = $msgarr["text"];
  
 -              if (isset($msgarr["image"])) {
 -                      $msg .= " " . $msgarr["image"];
 -              }
 +                if (isset($msgarr["url"]) && ($msgarr["type"] != "photo"))
 +                        $msg .= " ".$msgarr["url"];
  
 -              $b['html'] = nl2br(htmlspecialchars($msg));
 -      }
 +                if (isset($msgarr["image"]))
 +                        $msg .= " ".$msgarr["image"];
 +
 +                $b['html'] = nl2br(htmlspecialchars($msg));
 +        }
  }
  
 -function statusnet_cron(App $a, $b)
 -{
 -      $last = Config::get('statusnet', 'last_poll');
 +function statusnet_cron($a,$b) {
 +      $last = get_config('statusnet','last_poll');
  
 -      $poll_interval = intval(Config::get('statusnet', 'poll_interval'));
 -      if (!$poll_interval) {
 +      $poll_interval = intval(get_config('statusnet','poll_interval'));
 +      if(! $poll_interval)
                $poll_interval = STATUSNET_DEFAULT_POLL_INTERVAL;
 -      }
  
 -      if ($last) {
 +      if($last) {
                $next = $last + ($poll_interval * 60);
 -              if ($next > time()) {
 +              if($next > time()) {
                        logger('statusnet: poll intervall not reached');
                        return;
                }
                }
        }
  
 -      $abandon_days = intval(Config::get('system', 'account_abandon_days'));
 -      if ($abandon_days < 1) {
 +      $abandon_days = intval(get_config('system','account_abandon_days'));
 +      if ($abandon_days < 1)
                $abandon_days = 0;
 -      }
  
-       $abandon_limit = date("Y-m-d H:i:s", time() - $abandon_days * 86400);
+       $abandon_limit = date(DateTimeFormat::MYSQL, time() - $abandon_days * 86400);
  
        $r = q("SELECT * FROM `pconfig` WHERE `cat` = 'statusnet' AND `k` = 'import' AND `v` ORDER BY RAND()");
 -      if (count($r)) {
 -              foreach ($r as $rr) {
 +      if(count($r)) {
 +              foreach($r as $rr) {
                        if ($abandon_days != 0) {
                                $user = q("SELECT `login_date` FROM `user` WHERE uid=%d AND `login_date` >= '%s'", $rr['uid'], $abandon_limit);
                                if (!count($user)) {
@@@ -1004,19 -977,14 +995,18 @@@ function statusnet_fetch_contact($uid, 
                );
        } else {
                // update profile photos once every two weeks as we have no notification of when they change.
-               //$update_photo = (($r[0]['avatar-date'] < datetime_convert('','','now -2 days')) ? true : false);
-               $update_photo = ($r[0]['avatar-date'] < datetime_convert('','','now -12 hours'));
+               //$update_photo = (($r[0]['avatar-date'] < DateTimeFormat::convert('now -2 days', '', '', )) ? true : false);
+               $update_photo = ($r[0]['avatar-date'] < DateTimeFormat::utc('now -12 hours'));
  
                // check that we have all the photos, this has been known to fail on occasion
 -              if ((!$r[0]['photo']) || (!$r[0]['thumb']) || (!$r[0]['micro']) || ($update_photo)) {
 -                      logger("statusnet_fetch_contact: Updating contact " . $contact->screen_name, LOGGER_DEBUG);
  
 -                      $photos = Photo::importProfilePhoto($contact->profile_image_url, $uid, $r[0]['id']);
 +              if((!$r[0]['photo']) || (!$r[0]['thumb']) || (!$r[0]['micro']) || ($update_photo)) {
 +
 +                      logger("statusnet_fetch_contact: Updating contact ".$contact->screen_name, LOGGER_DEBUG);
 +
 +                      require_once("Photo.php");
 +
 +                      $photos = import_profile_photo($contact->profile_image_url, $uid, $r[0]['id']);
  
                        q("UPDATE `contact` SET `photo` = '%s',
                                                `thumb` = '%s',
                }
        }
  
 -      return $r[0]["id"];
 +      return($r[0]["id"]);
  }
  
 -function statusnet_fetchuser(App $a, $uid, $screen_name = "", $user_id = "")
 -{
 -      $ckey    = PConfig::get($uid, 'statusnet', 'consumerkey');
 -      $csecret = PConfig::get($uid, 'statusnet', 'consumersecret');
 -      $api     = PConfig::get($uid, 'statusnet', 'baseapi');
 -      $otoken  = PConfig::get($uid, 'statusnet', 'oauthtoken');
 -      $osecret = PConfig::get($uid, 'statusnet', 'oauthsecret');
 +function statusnet_fetchuser($a, $uid, $screen_name = "", $user_id = "") {
 +      $ckey    = get_pconfig($uid, 'statusnet', 'consumerkey');
 +      $csecret = get_pconfig($uid, 'statusnet', 'consumersecret');
 +      $api     = get_pconfig($uid, 'statusnet', 'baseapi');
 +      $otoken  = get_pconfig($uid, 'statusnet', 'oauthtoken');
 +      $osecret = get_pconfig($uid, 'statusnet', 'oauthsecret');
  
-       require_once("addon/statusnet/codebird.php");
+       require_once __DIR__ . DIRECTORY_SEPARATOR . 'library' . DIRECTORY_SEPARATOR . 'codebirdsn.php';
  
-       $cb = \Codebird\Codebird::getInstance();
+       $cb = \CodebirdSN\CodebirdSN::getInstance();
        $cb->setConsumerKey($ckey, $csecret);
        $cb->setToken($otoken, $osecret);
  
@@@ -1215,53 -1192,45 +1205,53 @@@ function statusnet_createpost($a, $uid
        $postarray['body'] = $converted["body"];
        $postarray['tag'] = $converted["tags"];
  
-       $postarray['created'] = datetime_convert('UTC','UTC',$content->created_at);
-       $postarray['edited'] = datetime_convert('UTC','UTC',$content->created_at);
+       $postarray['created'] = DateTimeFormat::utc($content->created_at);
+       $postarray['edited'] = DateTimeFormat::utc($content->created_at);
  
 -      if (is_string($content->place->name)) {
 +      if (is_string($content->place->name))
                $postarray["location"] = $content->place->name;
 -      }
  
 -      if (is_string($content->place->full_name)) {
 +      if (is_string($content->place->full_name))
                $postarray["location"] = $content->place->full_name;
 -      }
  
 -      if (is_array($content->geo->coordinates)) {
 -              $postarray["coord"] = $content->geo->coordinates[0] . " " . $content->geo->coordinates[1];
 -      }
 +      if (is_array($content->geo->coordinates))
 +              $postarray["coord"] = $content->geo->coordinates[0]." ".$content->geo->coordinates[1];
  
 -      if (is_array($content->coordinates->coordinates)) {
 -              $postarray["coord"] = $content->coordinates->coordinates[1] . " " . $content->coordinates->coordinates[0];
 -      }
 +      if (is_array($content->coordinates->coordinates))
 +              $postarray["coord"] = $content->coordinates->coordinates[1]." ".$content->coordinates->coordinates[0];
  
 -      logger("statusnet_createpost: end", LOGGER_DEBUG);
 +      /*if (is_object($post->retweeted_status)) {
 +              $postarray['body'] = html2bbcode($post->retweeted_status->statusnet_html);
 +
 +              $converted = statusnet_convertmsg($a, $postarray['body'], false);
 +              $postarray['body'] = $converted["body"];
 +              $postarray['tag'] = $converted["tags"];
 +
 +              statusnet_fetch_contact($uid, $post->retweeted_status->user, false);
  
 -      return $postarray;
 +              // Let retweets look like wall-to-wall posts
 +              $postarray['author-name'] = $post->retweeted_status->user->name;
 +              $postarray['author-link'] = $post->retweeted_status->user->statusnet_profile_url;
 +              $postarray['author-avatar'] = $post->retweeted_status->user->profile_image_url;
 +      }*/
 +      logger("statusnet_createpost: end", LOGGER_DEBUG);
 +      return($postarray);
  }
  
 -function statusnet_checknotification(App $a, $uid, $own_url, $top_item, $postarray)
 -{
 +function statusnet_checknotification($a, $uid, $own_url, $top_item, $postarray) {
 +
        // This function necer worked and need cleanup
 +
        $user = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` LIMIT 1",
                        intval($uid)
 -      );
 +              );
  
 -      if (!count($user)) {
 +      if(!count($user))
                return;
 -      }
  
        // Is it me?
 -      if (link_compare($user[0]["url"], $postarray['author-link'])) {
 +      if (link_compare($user[0]["url"], $postarray['author-link']))
                return;
 -      }
  
        $own_user = q("SELECT * FROM `contact` WHERE `uid` = %d AND `alias` = '%s' LIMIT 1",
                        intval($uid),
  
                        $conv_parent = $conv['parent'];
  
 -                      notification([
 -                              'type' => NOTIFY_COMMENT,
 +                      notification(array(
 +                              'type'         => NOTIFY_COMMENT,
                                'notify_flags' => $user[0]['notify-flags'],
-                               'language'     => $user[0]['language'],
-                               'to_name'      => $user[0]['username'],
-                               'to_email'     => $user[0]['email'],
-                               'uid'          => $user[0]['uid'],
-                               'item'         => $postarray,
-                               'link'         => $a->get_baseurl().'/display/'.urlencode(get_item_guid($top_item)),
-                               'source_name'  => $postarray['author-name'],
-                               'source_link'  => $postarray['author-link'],
+                               'language' => $user[0]['language'],
+                               'to_name' => $user[0]['username'],
+                               'to_email' => $user[0]['email'],
+                               'uid' => $user[0]['uid'],
+                               'item' => $postarray,
+                               'link' => $a->get_baseurl() . '/display/' . urlencode(Item::getGuidById($top_item)),
+                               'source_name' => $postarray['author-name'],
+                               'source_link' => $postarray['author-link'],
                                'source_photo' => $postarray['author-avatar'],
 -                              'verb' => ACTIVITY_POST,
 -                              'otype' => 'item',
 -                              'parent' => $conv_parent,
 -                      ]);
 +                              'verb'         => ACTIVITY_POST,
 +                              'otype'        => 'item',
 +                              'parent'       => $conv_parent,
 +                      ));
  
                        // only send one notification
                        break;
@@@ -1328,12 -1299,11 +1318,11 @@@ function statusnet_fetchhometimeline($a
        // "create_user" is deactivated, since currently you cannot add users manually by now
        $create_user = true;
  
 -      logger("statusnet_fetchhometimeline: Fetching for user " . $uid, LOGGER_DEBUG);
 +      logger("statusnet_fetchhometimeline: Fetching for user ".$uid, LOGGER_DEBUG);
  
-       require_once('library/twitteroauth.php');
-       require_once('include/items.php');
+       require_once 'include/items.php';
  
 -      $connection = new StatusNetOAuth($api, $ckey, $csecret, $otoken, $osecret);
 +      $connection = new StatusNetOAuth($api, $ckey,$csecret,$otoken,$osecret);
  
        $own_contact = statusnet_fetch_own_contact($a, $uid);
  
                                } else {
                                        $postarray = statusnet_createpost($a, $uid, $post, $self, $create_user, true);
  
 -                                      if (trim($postarray['body']) == "") {
 +                                      if (trim($postarray['body']) == "")
                                                continue;
 -                                      }
  
-                                       $item = item_store($postarray);
+                                       $item = Item::insert($postarray);
                                        $postarray["id"] = $item;
  
 -                                      logger('statusnet_fetchhometimeline: User ' . $self["nick"] . ' posted home timeline item ' . $item);
 +                                      logger('statusnet_fetchhometimeline: User '.$self["nick"].' posted home timeline item '.$item);
  
 -                                      if ($item && !function_exists("check_item_notification")) {
 +                                      if ($item && !function_exists("check_item_notification"))
                                                statusnet_checknotification($a, $uid, $nick, $item, $postarray);
 -                                      }
                                }
 +
                        }
                }
 -              PConfig::set($uid, 'statusnet', 'lasthometimelineid', $lastid);
 +              set_pconfig($uid, 'statusnet', 'lasthometimelineid', $lastid);
        }
  
        // Fetching mentions
                                        $conversations[$post->statusnet_conversation_id] = $post->statusnet_conversation_id;
                                }
                        } else {
 -                              if (trim($postarray['body']) == "") {
 +                              if (trim($postarray['body']) != "") {
                                        continue;
 -                              }
  
-                                       $item = item_store($postarray);
-                                       $postarray["id"] = $item;
+                               $item = Item::insert($postarray);
+                               $postarray["id"] = $item;
  
 -                              logger('statusnet_fetchhometimeline: User ' . $self["nick"] . ' posted mention timeline item ' . $item);
 +                                      logger('statusnet_fetchhometimeline: User '.$self["nick"].' posted mention timeline item '.$item);
  
 -                              if ($item && function_exists("check_item_notification")) {
 -                                      check_item_notification($item, $uid, NOTIFY_TAGSELF);
 +                                      if ($item && function_exists("check_item_notification"))
 +                                              check_item_notification($item, $uid, NOTIFY_TAGSELF);
                                }
                        }
  
                }
        }
  
 -      PConfig::set($uid, 'statusnet', 'lastmentionid', $lastid);
 +      set_pconfig($uid, 'statusnet', 'lastmentionid', $lastid);
  }
  
 -function statusnet_complete_conversation(App $a, $uid, $self, $create_user, $nick, $conversation)
 -{
 -      $ckey    = PConfig::get($uid, 'statusnet', 'consumerkey');
 -      $csecret = PConfig::get($uid, 'statusnet', 'consumersecret');
 -      $api     = PConfig::get($uid, 'statusnet', 'baseapi');
 -      $otoken  = PConfig::get($uid, 'statusnet', 'oauthtoken');
 -      $osecret = PConfig::get($uid, 'statusnet', 'oauthsecret');
 -      $own_url = PConfig::get($uid, 'statusnet', 'own_url');
 +function statusnet_complete_conversation($a, $uid, $self, $create_user, $nick, $conversation) {
 +      $ckey    = get_pconfig($uid, 'statusnet', 'consumerkey');
 +      $csecret = get_pconfig($uid, 'statusnet', 'consumersecret');
 +      $api     = get_pconfig($uid, 'statusnet', 'baseapi');
 +      $otoken  = get_pconfig($uid, 'statusnet', 'oauthtoken');
 +      $osecret = get_pconfig($uid, 'statusnet', 'oauthsecret');
 +      $own_url = get_pconfig($uid, 'statusnet', 'own_url');
  
-       require_once('library/twitteroauth.php');
-       $connection = new StatusNetOAuth($api, $ckey,$csecret,$otoken,$osecret);
+       $connection = new StatusNetOAuth($api, $ckey, $csecret, $otoken, $osecret);
  
        $parameters["count"] = 200;
  
        if (is_array($items)) {
                $posts = array_reverse($items);
  
-               foreach($posts AS $post) {
+               foreach ($posts as $post) {
                        $postarray = statusnet_createpost($a, $uid, $post, $self, false, false);
  
 -                      if (trim($postarray['body']) == "") {
 +                      if (trim($postarray['body']) == "")
                                continue;
 -                      }
  
-                       //print_r($postarray);
-                       $item = item_store($postarray);
+                       $item = Item::insert($postarray);
                        $postarray["id"] = $item;
  
 -                      logger('statusnet_complete_conversation: User ' . $self["nick"] . ' posted home timeline item ' . $item);
 +                      logger('statusnet_complete_conversation: User '.$self["nick"].' posted home timeline item '.$item);
  
 -                      if ($item && !function_exists("check_item_notification")) {
 +                      if ($item && !function_exists("check_item_notification"))
                                statusnet_checknotification($a, $uid, $nick, $item, $postarray);
 -                      }
                }
        }
  }
  
- function statusnet_convertmsg($a, $body, $no_tags = false) {
-       require_once("include/oembed.php");
-       require_once("include/items.php");
-       require_once("include/network.php");
+ function statusnet_convertmsg(App $a, $body, $no_tags = false)
+ {
+       require_once "include/items.php";
  
 -      $body = preg_replace("=\[url\=https?://([0-9]*).([0-9]*).([0-9]*).([0-9]*)/([0-9]*)\](.*?)\[\/url\]=ism", "$1.$2.$3.$4/$5", $body);
 +      $body = preg_replace("=\[url\=https?://([0-9]*).([0-9]*).([0-9]*).([0-9]*)/([0-9]*)\](.*?)\[\/url\]=ism","$1.$2.$3.$4/$5",$body);
  
        $URLSearchString = "^\[\]";
 -      $links = preg_match_all("/[^!#@]\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", $body, $matches, PREG_SET_ORDER);
 +      $links = preg_match_all("/[^!#@]\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", $body,$matches,PREG_SET_ORDER);
  
        $footer = "";
        $footerurl = "";
  
        if ($links) {
                foreach ($matches AS $match) {
 -                      $search = "[url=" . $match[1] . "]" . $match[2] . "[/url]";
 +                      $search = "[url=".$match[1]."]".$match[2]."[/url]";
  
 -                      logger("statusnet_convertmsg: expanding url " . $match[1], LOGGER_DEBUG);
 +                      logger("statusnet_convertmsg: expanding url ".$match[1], LOGGER_DEBUG);
  
-                       $expanded_url = original_url($match[1]);
+                       $expanded_url = Network::finalUrl($match[1]);
  
 -                      logger("statusnet_convertmsg: fetching data for " . $expanded_url, LOGGER_DEBUG);
 +                      logger("statusnet_convertmsg: fetching data for ".$expanded_url, LOGGER_DEBUG);
  
 -                      $oembed_data = OEmbed::fetchURL($expanded_url, true);
 +                      $oembed_data = oembed_fetch_url($expanded_url, true);
  
                        logger("statusnet_convertmsg: fetching data: done", LOGGER_DEBUG);
  
                                //$body = str_replace($search, "[video]".$expanded_url."[/video]", $body);
                                $type = $oembed_data->type;
                                $footerurl = $expanded_url;
 -                              $footerlink = "[url=" . $expanded_url . "]" . $expanded_url . "[/url]";
 +                              $footerlink = "[url=".$expanded_url."]".$expanded_url."[/url]";
  
                                $body = str_replace($search, $footerlink, $body);
-                       } elseif (($oembed_data->type == "photo") && isset($oembed_data->url) && !$dontincludemedia)
-                               $body = str_replace($search, "[url=".$expanded_url."][img]".$oembed_data->url."[/img][/url]", $body);
-                       elseif ($oembed_data->type != "link")
-                               $body = str_replace($search,  "[url=".$expanded_url."]".$expanded_url."[/url]", $body);
-                       else {
-                               $img_str = fetch_url($expanded_url, true, $redirects, 4);
+                       } elseif (($oembed_data->type == "photo") && isset($oembed_data->url) && !$dontincludemedia) {
+                               $body = str_replace($search, "[url=" . $expanded_url . "][img]" . $oembed_data->url . "[/img][/url]", $body);
+                       } elseif ($oembed_data->type != "link") {
+                               $body = str_replace($search, "[url=" . $expanded_url . "]" . $expanded_url . "[/url]", $body);
+                       else {
+                               $img_str = Network::fetchUrl($expanded_url, true, $redirects, 4);
  
                                $tempfile = tempnam(get_temppath(), "cache");
                                file_put_contents($tempfile, $img_str);
Simple merge
index 9bbeb1d854b11cda874d6aa1277c026105d05338,5c3930cd35188167186d1b21fc185c18debf210e..4398ffbf9cb98575f32115fc62ec871bc80b5a14
@@@ -64,13 -66,13 +66,13 @@@ function testdrive_cron($a,$b) 
                                'language'     => $rr['language'],
                                'to_name'      => $rr['username'],
                                'to_email'     => $rr['email'],
-                               'source_name'  => t('Administrator'),
+                               'source_name'  => L10n::t('Administrator'),
                                'source_link'  => $a->get_baseurl(),
                                'source_photo' => $a->get_baseurl() . '/images/person-80.jpg',
 -                      ]);
 +                      ));
  
                        q("update user set expire_notification_sent = '%s' where uid = %d",
-                               dbesc(datetime_convert()),
+                               dbesc(DateTimeFormat::utcNow()),
                                intval($rr['uid'])
                        );
  
Simple merge
index 50530401d223df7fd8091d755e77ba8e8ed7b826,b2dec5b544a3735c35fc74fc785f011b66abb372..e038b843a80cda4a282368291b79d1dfb112f510
@@@ -158,11 -162,11 +162,11 @@@ function tumblr_callback($a) 
        }
  
        // What's next?  Now that we have an Access Token and Secret, we can make an API call.
 -      PConfig::set(local_user(), "tumblr", "oauth_token", $access_token['oauth_token']);
 -      PConfig::set(local_user(), "tumblr", "oauth_token_secret", $access_token['oauth_token_secret']);
 +      set_pconfig(local_user(), "tumblr", "oauth_token", $access_token['oauth_token']);
 +      set_pconfig(local_user(), "tumblr", "oauth_token_secret", $access_token['oauth_token_secret']);
  
-       $o = t("You are now authenticated to tumblr.");
-       $o .= '<br /><a href="'.$a->get_baseurl().'/settings/connectors">'.t("return to the connector page").'</a>';
+       $o = L10n::t("You are now authenticated to tumblr.");
+       $o .= '<br /><a href="'.$a->get_baseurl().'/settings/connectors">'.L10n::t("return to the connector page").'</a>';
        return($o);
  }
  
@@@ -170,12 -174,12 +174,12 @@@ function tumblr_jot_nets(&$a,&$b) 
        if(! local_user())
                return;
  
 -      $tmbl_post = PConfig::get(local_user(),'tumblr','post');
 +      $tmbl_post = get_pconfig(local_user(),'tumblr','post');
        if(intval($tmbl_post) == 1) {
 -              $tmbl_defpost = PConfig::get(local_user(),'tumblr','post_by_default');
 +              $tmbl_defpost = get_pconfig(local_user(),'tumblr','post_by_default');
                $selected = ((intval($tmbl_defpost) == 1) ? ' checked="checked" ' : '');
                $b .= '<div class="profile-jot-net"><input type="checkbox" name="tumblr_enable"' . $selected . ' value="1" /> '
-                       . t('Post to Tumblr') . '</div>';
+                       . L10n::t('Post to Tumblr') . '</div>';
        }
  }
  
@@@ -237,12 -241,12 +241,12 @@@ function tumblr_settings(&$a,&$s) 
  
                $userinfo = $tum_oauth->get('user/info');
  
 -              $blogs = [];
 +              $blogs = array();
  
-               $s .= '<label id="tumblr-page-label" for="tumblr-page">' . t('Post to page:') . '</label>';
+               $s .= '<label id="tumblr-page-label" for="tumblr-page">' . L10n::t('Post to page:') . '</label>';
                $s .= '<select name="tumblr_page" id="tumblr-page">';
                foreach($userinfo->response->user->blogs as $blog) {
 -                      $blogurl = substr(str_replace(["http://", "https://"], ["", ""], $blog->url), 0, -1);
 +                      $blogurl = substr(str_replace(array("http://", "https://"), array("", ""), $blog->url), 0, -1);
                        if ($page == $blogurl)
                                $s .= "<option value='".$blogurl."' selected>".$blogurl."</option>";
                        else
@@@ -344,11 -355,10 +345,10 @@@ function tumblr_send(&$a,&$b) 
                        $tags = implode(',',$tag_arr);
  
                $title = trim($b['title']);
-               require_once('include/plaintext.php');
  
-               $siteinfo = get_attached_data($b["body"]);
+               $siteinfo = BBCode::getAttachedData($b["body"]);
  
 -              $params = [
 +              $params = array(
                        'state' => 'published',
                        'tags' => $tags,
                        'tweet' => 'off',
                                                "<p>".$params['caption']."</p>";
  
                if (trim($params['caption']) == "")
-                       $params['caption'] = bbcode("[quote]".$siteinfo["description"]."[/quote]", false, false, 4);
+                       $params['caption'] = BBCode::convert("[quote]" . $siteinfo["description"] . "[/quote]", false, 4);
  
 -              $consumer_key = Config::get('tumblr','consumer_key');
 -              $consumer_secret = Config::get('tumblr','consumer_secret');
 +              $consumer_key = get_config('tumblr','consumer_key');
 +              $consumer_secret = get_config('tumblr','consumer_secret');
  
                $tum_oauth = new TumblrOAuth($consumer_key, $consumer_secret, $oauth_token, $oauth_token_secret);
  
index 7272957ca6e7294c7612ea0abdfcb0b4e9fe3849,a460fd70f14b894f506805bcb45a7accec0ca4d1..148a498b1d3fbbff5877c99426c80b4574f10c45
@@@ -65,45 -89,46 +89,44 @@@ require_once __DIR__ . DIRECTORY_SEPARA
  
  define('TWITTER_DEFAULT_POLL_INTERVAL', 5); // given in minutes
  
 -function twitter_install()
 -{
 +function twitter_install() {
        //  we need some hooks, for the configuration and for sending tweets
-       register_hook('connector_settings', 'addon/twitter/twitter.php', 'twitter_settings');
-       register_hook('connector_settings_post', 'addon/twitter/twitter.php', 'twitter_settings_post');
-       register_hook('post_local', 'addon/twitter/twitter.php', 'twitter_post_local');
-       register_hook('notifier_normal', 'addon/twitter/twitter.php', 'twitter_post_hook');
-       register_hook('jot_networks', 'addon/twitter/twitter.php', 'twitter_jot_nets');
-       register_hook('cron', 'addon/twitter/twitter.php', 'twitter_cron');
-       register_hook('queue_predeliver', 'addon/twitter/twitter.php', 'twitter_queue_hook');
-       register_hook('follow', 'addon/twitter/twitter.php', 'twitter_follow');
-       register_hook('expire', 'addon/twitter/twitter.php', 'twitter_expire');
-       register_hook('prepare_body', 'addon/twitter/twitter.php', 'twitter_prepare_body');
-       register_hook('check_item_notification','addon/twitter/twitter.php', 'twitter_check_item_notification');
+       Addon::registerHook('connector_settings', 'addon/twitter/twitter.php', 'twitter_settings');
+       Addon::registerHook('connector_settings_post', 'addon/twitter/twitter.php', 'twitter_settings_post');
+       Addon::registerHook('post_local', 'addon/twitter/twitter.php', 'twitter_post_local');
+       Addon::registerHook('notifier_normal', 'addon/twitter/twitter.php', 'twitter_post_hook');
+       Addon::registerHook('jot_networks', 'addon/twitter/twitter.php', 'twitter_jot_nets');
+       Addon::registerHook('cron', 'addon/twitter/twitter.php', 'twitter_cron');
+       Addon::registerHook('queue_predeliver', 'addon/twitter/twitter.php', 'twitter_queue_hook');
+       Addon::registerHook('follow', 'addon/twitter/twitter.php', 'twitter_follow');
+       Addon::registerHook('expire', 'addon/twitter/twitter.php', 'twitter_expire');
+       Addon::registerHook('prepare_body', 'addon/twitter/twitter.php', 'twitter_prepare_body');
+       Addon::registerHook('check_item_notification', 'addon/twitter/twitter.php', 'twitter_check_item_notification');
        logger("installed twitter");
  }
  
function twitter_uninstall() {
-       unregister_hook('connector_settings', 'addon/twitter/twitter.php', 'twitter_settings');
-       unregister_hook('connector_settings_post', 'addon/twitter/twitter.php', 'twitter_settings_post');
-       unregister_hook('post_local', 'addon/twitter/twitter.php', 'twitter_post_local');
-       unregister_hook('notifier_normal', 'addon/twitter/twitter.php', 'twitter_post_hook');
-       unregister_hook('jot_networks', 'addon/twitter/twitter.php', 'twitter_jot_nets');
-       unregister_hook('cron', 'addon/twitter/twitter.php', 'twitter_cron');
-       unregister_hook('queue_predeliver', 'addon/twitter/twitter.php', 'twitter_queue_hook');
-       unregister_hook('follow', 'addon/twitter/twitter.php', 'twitter_follow');
-       unregister_hook('expire', 'addon/twitter/twitter.php', 'twitter_expire');
-       unregister_hook('prepare_body', 'addon/twitter/twitter.php', 'twitter_prepare_body');
-       unregister_hook('check_item_notification','addon/twitter/twitter.php', 'twitter_check_item_notification');
+ function twitter_uninstall()
+ {
+       Addon::unregisterHook('connector_settings', 'addon/twitter/twitter.php', 'twitter_settings');
+       Addon::unregisterHook('connector_settings_post', 'addon/twitter/twitter.php', 'twitter_settings_post');
+       Addon::unregisterHook('post_local', 'addon/twitter/twitter.php', 'twitter_post_local');
+       Addon::unregisterHook('notifier_normal', 'addon/twitter/twitter.php', 'twitter_post_hook');
+       Addon::unregisterHook('jot_networks', 'addon/twitter/twitter.php', 'twitter_jot_nets');
+       Addon::unregisterHook('cron', 'addon/twitter/twitter.php', 'twitter_cron');
+       Addon::unregisterHook('queue_predeliver', 'addon/twitter/twitter.php', 'twitter_queue_hook');
+       Addon::unregisterHook('follow', 'addon/twitter/twitter.php', 'twitter_follow');
+       Addon::unregisterHook('expire', 'addon/twitter/twitter.php', 'twitter_expire');
+       Addon::unregisterHook('prepare_body', 'addon/twitter/twitter.php', 'twitter_prepare_body');
+       Addon::unregisterHook('check_item_notification', 'addon/twitter/twitter.php', 'twitter_check_item_notification');
  
        // old setting - remove only
-       unregister_hook('post_local_end', 'addon/twitter/twitter.php', 'twitter_post_hook');
-       unregister_hook('plugin_settings', 'addon/twitter/twitter.php', 'twitter_settings');
-       unregister_hook('plugin_settings_post', 'addon/twitter/twitter.php', 'twitter_settings_post');
+       Addon::unregisterHook('post_local_end', 'addon/twitter/twitter.php', 'twitter_post_hook');
+       Addon::unregisterHook('addon_settings', 'addon/twitter/twitter.php', 'twitter_settings');
+       Addon::unregisterHook('addon_settings_post', 'addon/twitter/twitter.php', 'twitter_settings_post');
  }
  
 -function twitter_check_item_notification(App $a, &$notification_data)
 -{
 -      $own_id = PConfig::get($notification_data["uid"], 'twitter', 'own_id');
 +function twitter_check_item_notification($a, &$notification_data) {
 +      $own_id = get_pconfig($notification_data["uid"], 'twitter', 'own_id');
  
        $own_user = q("SELECT `url` FROM `contact` WHERE `uid` = %d AND `alias` = '%s' LIMIT 1",
                        intval($notification_data["uid"]),
@@@ -149,102 -174,116 +170,107 @@@ function twitter_follow($a, &$contact) 
                FROM `contact` WHERE `uid` = %d AND `nick` = '%s'",
                                intval($uid),
                                dbesc($nickname));
 -      if (count($r)) {
 +      if (count($r))
                $contact["contact"] = $r[0];
 -      }
  }
  
 -function twitter_jot_nets(App $a, &$b)
 -{
 -      if (!local_user()) {
 +function twitter_jot_nets(&$a,&$b) {
 +      if(! local_user())
                return;
 -      }
  
 -      $tw_post = PConfig::get(local_user(), 'twitter', 'post');
 -      if (intval($tw_post) == 1) {
 -              $tw_defpost = PConfig::get(local_user(), 'twitter', 'post_by_default');
 +      $tw_post = get_pconfig(local_user(),'twitter','post');
 +      if(intval($tw_post) == 1) {
 +              $tw_defpost = get_pconfig(local_user(),'twitter','post_by_default');
                $selected = ((intval($tw_defpost) == 1) ? ' checked="checked" ' : '');
                $b .= '<div class="profile-jot-net"><input type="checkbox" name="twitter_enable"' . $selected . ' value="1" /> '
-                       . t('Post to Twitter') . '</div>';
+                       . L10n::t('Post to Twitter') . '</div>';
        }
  }
  
 -function twitter_settings_post(App $a, $post)
 -{
 -      if (!local_user()) {
 +function twitter_settings_post ($a,$post) {
 +      if(! local_user())
                return;
 -      }
        // don't check twitter settings if twitter submit button is not clicked
-       if (!x($_POST,'twitter-submit'))
+       if (empty($_POST['twitter-disconnect']) && empty($_POST['twitter-submit'])) {
                return;
 -      }
  
-       if (isset($_POST['twitter-disconnect'])) {
-               /***
+       if (!empty($_POST['twitter-disconnect'])) {
+               /*               * *
                 * if the twitter-disconnect checkbox is set, clear the OAuth key/secret pair
                 * from the user configuration
                 */
 -              PConfig::delete(local_user(), 'twitter', 'consumerkey');
 -              PConfig::delete(local_user(), 'twitter', 'consumersecret');
 -              PConfig::delete(local_user(), 'twitter', 'oauthtoken');
 -              PConfig::delete(local_user(), 'twitter', 'oauthsecret');
 -              PConfig::delete(local_user(), 'twitter', 'post');
 -              PConfig::delete(local_user(), 'twitter', 'post_by_default');
 -              PConfig::delete(local_user(), 'twitter', 'lastid');
 -              PConfig::delete(local_user(), 'twitter', 'mirror_posts');
 -              PConfig::delete(local_user(), 'twitter', 'import');
 -              PConfig::delete(local_user(), 'twitter', 'create_user');
 -              PConfig::delete(local_user(), 'twitter', 'own_id');
 +              del_pconfig(local_user(), 'twitter', 'consumerkey');
 +              del_pconfig(local_user(), 'twitter', 'consumersecret');
 +              del_pconfig(local_user(), 'twitter', 'oauthtoken');
 +              del_pconfig(local_user(), 'twitter', 'oauthsecret');
 +              del_pconfig(local_user(), 'twitter', 'post');
 +              del_pconfig(local_user(), 'twitter', 'post_by_default');
 +              del_pconfig(local_user(), 'twitter', 'lastid');
 +              del_pconfig(local_user(), 'twitter', 'mirror_posts');
 +              del_pconfig(local_user(), 'twitter', 'import');
 +              del_pconfig(local_user(), 'twitter', 'create_user');
 +              del_pconfig(local_user(), 'twitter', 'own_id');
        } else {
-       if (isset($_POST['twitter-pin'])) {
-               //  if the user supplied us with a PIN from Twitter, let the magic of OAuth happen
-               logger('got a Twitter PIN');
-               require_once('library/twitteroauth.php');
-               $ckey    = get_config('twitter', 'consumerkey');
-               $csecret = get_config('twitter', 'consumersecret');
-               //  the token and secret for which the PIN was generated were hidden in the settings
-               //  form as token and token2, we need a new connection to Twitter using these token
-               //  and secret to request a Access Token with the PIN
-               $connection = new TwitterOAuth($ckey, $csecret, $_POST['twitter-token'], $_POST['twitter-token2']);
-               $token   = $connection->getAccessToken( $_POST['twitter-pin'] );
-               //  ok, now that we have the Access Token, save them in the user config
-               set_pconfig(local_user(),'twitter', 'oauthtoken',  $token['oauth_token']);
-               set_pconfig(local_user(),'twitter', 'oauthsecret', $token['oauth_token_secret']);
-               set_pconfig(local_user(),'twitter', 'post', 1);
-               //  reload the Addon Settings page, if we don't do it see Bug #42
-               goaway($a->get_baseurl().'/settings/connectors');
-       } else {
-               //  if no PIN is supplied in the POST variables, the user has changed the setting
-               //  to post a tweet for every new __public__ posting to the wall
-               set_pconfig(local_user(),'twitter','post',intval($_POST['twitter-enable']));
-               set_pconfig(local_user(),'twitter','post_by_default',intval($_POST['twitter-default']));
-               set_pconfig(local_user(), 'twitter', 'mirror_posts', intval($_POST['twitter-mirror']));
-               set_pconfig(local_user(), 'twitter', 'import', intval($_POST['twitter-import']));
-               set_pconfig(local_user(), 'twitter', 'create_user', intval($_POST['twitter-create_user']));
-               if (!intval($_POST['twitter-mirror']))
-                       del_pconfig(local_user(),'twitter','lastid');
-               info(t('Twitter settings updated.') . EOL);
-       }}
+               if (isset($_POST['twitter-pin'])) {
+                       //  if the user supplied us with a PIN from Twitter, let the magic of OAuth happen
+                       logger('got a Twitter PIN');
+                       $ckey    = Config::get('twitter', 'consumerkey');
+                       $csecret = Config::get('twitter', 'consumersecret');
+                       //  the token and secret for which the PIN was generated were hidden in the settings
+                       //  form as token and token2, we need a new connection to Twitter using these token
+                       //  and secret to request a Access Token with the PIN
+                       try {
+                               if (empty($_POST['twitter-pin'])) {
+                                       throw new Exception(L10n::t('You submitted an empty PIN, please Sign In with Twitter again to get a new one.'));
+                               }
+                               $connection = new TwitterOAuth($ckey, $csecret, $_POST['twitter-token'], $_POST['twitter-token2']);
+                               $token = $connection->oauth("oauth/access_token", ["oauth_verifier" => $_POST['twitter-pin']]);
+                               //  ok, now that we have the Access Token, save them in the user config
+                               PConfig::set(local_user(), 'twitter', 'oauthtoken', $token['oauth_token']);
+                               PConfig::set(local_user(), 'twitter', 'oauthsecret', $token['oauth_token_secret']);
+                               PConfig::set(local_user(), 'twitter', 'post', 1);
+                       } catch(Exception $e) {
+                               info($e->getMessage());
+                       }
+                       //  reload the Addon Settings page, if we don't do it see Bug #42
+                       goaway('settings/connectors');
+               } else {
+                       //  if no PIN is supplied in the POST variables, the user has changed the setting
+                       //  to post a tweet for every new __public__ posting to the wall
+                       PConfig::set(local_user(), 'twitter', 'post', intval($_POST['twitter-enable']));
+                       PConfig::set(local_user(), 'twitter', 'post_by_default', intval($_POST['twitter-default']));
+                       PConfig::set(local_user(), 'twitter', 'mirror_posts', intval($_POST['twitter-mirror']));
+                       PConfig::set(local_user(), 'twitter', 'import', intval($_POST['twitter-import']));
+                       PConfig::set(local_user(), 'twitter', 'create_user', intval($_POST['twitter-create_user']));
+                       if (!intval($_POST['twitter-mirror'])) {
+                               PConfig::delete(local_user(), 'twitter', 'lastid');
+                       }
+                       info(L10n::t('Twitter settings updated.') . EOL);
+               }
+       }
  }
 -
 -function twitter_settings(App $a, &$s)
 -{
 -      if (!local_user()) {
 +function twitter_settings(&$a,&$s) {
 +      if(! local_user())
                return;
 -      }
        $a->page['htmlhead'] .= '<link rel="stylesheet"  type="text/css" href="' . $a->get_baseurl() . '/addon/twitter/twitter.css' . '" media="all" />' . "\r\n";
 -      /*       * *
 +      /***
         * 1) Check that we have global consumer key & secret
         * 2) If no OAuthtoken & stuff is present, generate button to get some
 -       * 3) Checkbox for "Send public notices (280 chars only)
 +       * 3) Checkbox for "Send public notices (140 chars only)
         */
-       $ckey    = get_config('twitter', 'consumerkey' );
-       $csecret = get_config('twitter', 'consumersecret' );
-       $otoken  = get_pconfig(local_user(), 'twitter', 'oauthtoken'  );
-       $osecret = get_pconfig(local_user(), 'twitter', 'oauthsecret' );
-       $enabled = get_pconfig(local_user(), 'twitter', 'post');
-       $checked = (($enabled) ? ' checked="checked" ' : '');
-       $defenabled = get_pconfig(local_user(),'twitter','post_by_default');
-       $defchecked = (($defenabled) ? ' checked="checked" ' : '');
-       $mirrorenabled = get_pconfig(local_user(),'twitter','mirror_posts');
-       $mirrorchecked = (($mirrorenabled) ? ' checked="checked" ' : '');
-       $importenabled = get_pconfig(local_user(),'twitter','import');
-       $importchecked = (($importenabled) ? ' checked="checked" ' : '');
-       $create_userenabled = get_pconfig(local_user(),'twitter','create_user');
-       $create_userchecked = (($create_userenabled) ? ' checked="checked" ' : '');
+       $ckey    = Config::get('twitter', 'consumerkey');
+       $csecret = Config::get('twitter', 'consumersecret');
+       $otoken  = PConfig::get(local_user(), 'twitter', 'oauthtoken');
+       $osecret = PConfig::get(local_user(), 'twitter', 'oauthsecret');
+       $enabled            = intval(PConfig::get(local_user(), 'twitter', 'post'));
+       $defenabled         = intval(PConfig::get(local_user(), 'twitter', 'post_by_default'));
+       $mirrorenabled      = intval(PConfig::get(local_user(), 'twitter', 'mirror_posts'));
+       $importenabled      = intval(PConfig::get(local_user(), 'twitter', 'import'));
+       $create_userenabled = intval(PConfig::get(local_user(), 'twitter', 'create_user'));
  
        $css = (($enabled) ? '' : '-disabled');
  
                         * which the user can request a PIN to connect the account to a
                         * account at Twitter.
                         */
-                       require_once('library/twitteroauth.php');
                        $connection = new TwitterOAuth($ckey, $csecret);
-                       $request_token = $connection->getRequestToken();
-                       $token = $request_token['oauth_token'];
-                       /***
-                        *  make some nice form
-                        */
-                       $s .= '<p>'. t('At this Friendica instance the Twitter plugin was enabled but you have not yet connected your account to your Twitter account. To do so click the button below to get a PIN from Twitter which you have to copy into the input box below and submit the form. Only your <strong>public</strong> posts will be posted to Twitter.') .'</p>';
-                       $s .= '<a href="'.$connection->getAuthorizeURL($token).'" target="_twitter"><img src="addon/twitter/lighter.png" alt="'.t('Log in with Twitter').'"></a>';
+                       $result = $connection->oauth('oauth/request_token', ['oauth_callback' => 'oob']);
+                       $s .= '<p>' . L10n::t('At this Friendica instance the Twitter addon was enabled but you have not yet connected your account to your Twitter account. To do so click the button below to get a PIN from Twitter which you have to copy into the input box below and submit the form. Only your <strong>public</strong> posts will be posted to Twitter.') . '</p>';
+                       $s .= '<a href="' . $connection->url('oauth/authorize', ['oauth_token' => $result['oauth_token']]) . '" target="_twitter"><img src="addon/twitter/lighter.png" alt="' . L10n::t('Log in with Twitter') . '"></a>';
                        $s .= '<div id="twitter-pin-wrapper">';
-                       $s .= '<label id="twitter-pin-label" for="twitter-pin">'. t('Copy the PIN from Twitter here') .'</label>';
+                       $s .= '<label id="twitter-pin-label" for="twitter-pin">' . L10n::t('Copy the PIN from Twitter here') . '</label>';
                        $s .= '<input id="twitter-pin" type="text" name="twitter-pin" />';
-                       $s .= '<input id="twitter-token" type="hidden" name="twitter-token" value="'.$token.'" />';
-                       $s .= '<input id="twitter-token2" type="hidden" name="twitter-token2" value="'.$request_token['oauth_token_secret'].'" />';
-           $s .= '</div><div class="clear"></div>';
-           $s .= '<div class="settings-submit-wrapper" ><input type="submit" name="twitter-submit" class="settings-submit" value="' . t('Save Settings') . '" /></div>';
+                       $s .= '<input id="twitter-token" type="hidden" name="twitter-token" value="' . $result['oauth_token'] . '" />';
+                       $s .= '<input id="twitter-token2" type="hidden" name="twitter-token2" value="' . $result['oauth_token_secret'] . '" />';
+                       $s .= '</div><div class="clear"></div>';
+                       $s .= '<div class="settings-submit-wrapper" ><input type="submit" name="twitter-submit" class="settings-submit" value="' . L10n::t('Save Settings') . '" /></div>';
                } else {
 -                      /*                       * *
 +                      /***
                         *  we have an OAuth key / secret pair for the user
                         *  so let's give a chance to disable the postings to Twitter
                         */
-                       require_once('library/twitteroauth.php');
-                       $connection = new TwitterOAuth($ckey,$csecret,$otoken,$osecret);
+                       $connection = new TwitterOAuth($ckey, $csecret, $otoken, $osecret);
                        $details = $connection->get('account/verify_credentials');
 +                      $s .= '<div id="twitter-info" ><img id="twitter-avatar" src="'.$details->profile_image_url.'" /><p id="twitter-info-block">'. t('Currently connected to: ') .'<a href="https://twitter.com/'.$details->screen_name.'" target="_twitter">'.$details->screen_name.'</a><br /><em>'.$details->description.'</em></p></div>';
 +                      $s .= '<p>'. t('If enabled all your <strong>public</strong> postings can be posted to the associated Twitter account. You can choose to do so by default (here) or for every posting separately in the posting options when writing the entry.') .'</p>';
 +                      if ($a->user['hidewall']) {
 +                          $s .= '<p>'. t('<strong>Note</strong>: Due your privacy settings (<em>Hide your profile details from unknown viewers?</em>) the link potentially included in public postings relayed to Twitter will lead the visitor to a blank page informing the visitor that the access to your profile has been restricted.') .'</p>';
 +                      }
 +                      $s .= '<div id="twitter-enable-wrapper">';
 +                      $s .= '<label id="twitter-enable-label" for="twitter-checkbox">'. t('Allow posting to Twitter'). '</label>';
 +                      $s .= '<input id="twitter-checkbox" type="checkbox" name="twitter-enable" value="1" ' . $checked . '/>';
 +                      $s .= '<div class="clear"></div>';
 +                      $s .= '<label id="twitter-default-label" for="twitter-default">'. t('Send public postings to Twitter by default') .'</label>';
 +                      $s .= '<input id="twitter-default" type="checkbox" name="twitter-default" value="1" ' . $defchecked . '/>';
 +                      $s .= '<div class="clear"></div>';
  
-                       $s .= '<label id="twitter-mirror-label" for="twitter-mirror">'.t('Mirror all posts from twitter that are no replies').'</label>';
-                       $s .= '<input id="twitter-mirror" type="checkbox" name="twitter-mirror" value="1" '. $mirrorchecked . '/>';
+                       $field_checkbox = get_markup_template('field_checkbox.tpl');
+                       $s .= '<div id="twitter-info" >
+                               <p>' . L10n::t('Currently connected to: ') . '<a href="https://twitter.com/' . $details->screen_name . '" target="_twitter">' . $details->screen_name . '</a>
+                                       <button type="submit" name="twitter-disconnect" value="1">' . L10n::t('Disconnect') . '</button>
+                               </p>
+                               <p id="twitter-info-block">
+                                       <a href="https://twitter.com/' . $details->screen_name . '" target="_twitter"><img id="twitter-avatar" src="' . $details->profile_image_url . '" /></a>
+                                       <em>' . $details->description . '</em>
+                               </p>
+                       </div>';
                        $s .= '<div class="clear"></div>';
 +                      $s .= '</div>';
  
-                       $s .= '<label id="twitter-import-label" for="twitter-import">'.t('Import the remote timeline').'</label>';
-                       $s .= '<input id="twitter-import" type="checkbox" name="twitter-import" value="1" '. $importchecked . '/>';
-                       $s .= '<div class="clear"></div>';
+                       $s .= replace_macros($field_checkbox, [
+                               '$field' => ['twitter-enable', L10n::t('Allow posting to Twitter'), $enabled, L10n::t('If enabled all your <strong>public</strong> postings can be posted to the associated Twitter account. You can choose to do so by default (here) or for every posting separately in the posting options when writing the entry.')]
+                       ]);
+                       if ($a->user['hidewall']) {
+                               $s .= '<p>' . L10n::t('<strong>Note</strong>: Due to your privacy settings (<em>Hide your profile details from unknown viewers?</em>) the link potentially included in public postings relayed to Twitter will lead the visitor to a blank page informing the visitor that the access to your profile has been restricted.') . '</p>';
+                       }
+                       $s .= replace_macros($field_checkbox, [
+                               '$field' => ['twitter-default', L10n::t('Send public postings to Twitter by default'), $defenabled, '']
+                       ]);
+                       $s .= replace_macros($field_checkbox, [
+                               '$field' => ['twitter-mirror', L10n::t('Mirror all posts from twitter that are no replies'), $mirrorenabled, '']
+                       ]);
+                       $s .= replace_macros($field_checkbox, [
+                               '$field' => ['twitter-import', L10n::t('Import the remote timeline'), $importenabled, '']
+                       ]);
+                       $s .= replace_macros($field_checkbox, [
+                               '$field' => ['twitter-create_user', L10n::t('Automatically create contacts'), $create_userenabled, '']
+                       ]);
  
 +                      $s .= '<label id="twitter-create_user-label" for="twitter-create_user">'.t('Automatically create contacts').'</label>';
 +                      $s .= '<input id="twitter-create_user" type="checkbox" name="twitter-create_user" value="1" '. $create_userchecked . '/>';
                        $s .= '<div class="clear"></div>';
-                       $s .= '<div id="twitter-disconnect-wrapper">';
-                       $s .= '<label id="twitter-disconnect-label" for="twitter-disconnect">'. t('Clear OAuth configuration') .'</label>';
-                       $s .= '<input id="twitter-disconnect" type="checkbox" name="twitter-disconnect" value="1" />';
-                       $s .= '</div><div class="clear"></div>';
-                       $s .= '<div class="settings-submit-wrapper" ><input type="submit" name="twitter-submit" class="settings-submit" value="' . t('Save Settings') . '" /></div>';
+                       $s .= '<div class="settings-submit-wrapper" ><input type="submit" name="twitter-submit" class="settings-submit" value="' . L10n::t('Save Settings') . '" /></div>';
                }
        }
        $s .= '</div><div class="clear"></div>';
@@@ -363,56 -396,50 +399,45 @@@ function twitter_post_local(&$a, &$b) 
        $b['postopts'] .= 'twitter';
  }
  
 -function twitter_action(App $a, $uid, $pid, $action)
 -{
 -      $ckey = Config::get('twitter', 'consumerkey');
 -      $csecret = Config::get('twitter', 'consumersecret');
 -      $otoken = PConfig::get($uid, 'twitter', 'oauthtoken');
 -      $osecret = PConfig::get($uid, 'twitter', 'oauthsecret');
 +function twitter_action($a, $uid, $pid, $action) {
  
-       $ckey    = get_config('twitter', 'consumerkey');
-       $csecret = get_config('twitter', 'consumersecret');
-       $otoken  = get_pconfig($uid, 'twitter', 'oauthtoken');
-       $osecret = get_pconfig($uid, 'twitter', 'oauthsecret');
-       require_once("addon/twitter/codebird.php");
-       $cb = \Codebird\Codebird::getInstance();
-       $cb->setConsumerKey($ckey, $csecret);
-       $cb->setToken($otoken, $osecret);
+       $connection = new TwitterOAuth($ckey, $csecret, $otoken, $osecret);
  
 -      $post = ['id' => $pid];
 +      $post = array('id' => $pid);
  
 -      logger("twitter_action '" . $action . "' ID: " . $pid . " data: " . print_r($post, true), LOGGER_DATA);
 +      logger("twitter_action '".$action."' ID: ".$pid." data: " . print_r($post, true), LOGGER_DATA);
  
        switch ($action) {
                case "delete":
-                       // To-Do: $result = $cb->statuses_destroy($post);
+                       // To-Do: $result = $connection->post('statuses/destroy', $post);
                        break;
                case "like":
-                       $result = $cb->favorites_create($post);
+                       $result = $connection->post('favorites/create', $post);
                        break;
                case "unlike":
-                       $result = $cb->favorites_destroy($post);
+                       $result = $connection->post('favorites/destroy', $post);
                        break;
        }
 -      logger("twitter_action '" . $action . "' send, result: " . print_r($result, true), LOGGER_DEBUG);
 +      logger("twitter_action '".$action."' send, result: " . print_r($result, true), LOGGER_DEBUG);
  }
  
- function twitter_post_hook(&$a,&$b) {
-       /**
-        * Post to Twitter
-        */
-       require_once("include/network.php");
-       if (!get_pconfig($b["uid"],'twitter','import')) {
-               if($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited']))
-                       return;
+ function twitter_post_hook(App $a, &$b)
+ {
+       // Post to Twitter
+       if (!PConfig::get($b["uid"], 'twitter', 'import')
+               && ($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited']))) {
+               return;
        }
  
 -      if ($b['parent'] != $b['id']) {
 -              logger("twitter_post_hook: parameter " . print_r($b, true), LOGGER_DATA);
 +      if($b['parent'] != $b['id']) {
 +              logger("twitter_post_hook: parameter ".print_r($b, true), LOGGER_DATA);
  
                // Looking if its a reply to a twitter post
-               if ((substr($b["parent-uri"], 0, 9) != "twitter::") && (substr($b["extid"], 0, 9) != "twitter::") && (substr($b["thr-parent"], 0, 9) != "twitter::")) {
-                       logger("twitter_post_hook: no twitter post ".$b["parent"]);
+               if ((substr($b["parent-uri"], 0, 9) != "twitter::")
+                       && (substr($b["extid"], 0, 9) != "twitter::")
+                       && (substr($b["thr-parent"], 0, 9) != "twitter::"))
+               {
+                       logger("twitter_post_hook: no twitter post " . $b["parent"]);
                        return;
                }
  
        } else {
                $iscomment = false;
  
 -              if ($b['private'] || !strstr($b['postopts'], 'twitter')) {
 +              if($b['private'] || !strstr($b['postopts'],'twitter'))
                        return;
 -              }
 -
 -              // Dont't post if the post doesn't belong to us.
 -              // This is a check for forum postings
 -              $self = dba::selectFirst('contact', ['id'], ['uid' => $b['uid'], 'self' => true]);
 -              if ($b['contact-id'] != $self['id']) {
 -                      return;
 -              }
        }
  
 -      if (($b['verb'] == ACTIVITY_POST) && $b['deleted']) {
 +      if (($b['verb'] == ACTIVITY_POST) && $b['deleted'])
                twitter_action($a, $b["uid"], substr($orig_post["uri"], 9), "delete");
 -      }
  
-       if($b['verb'] == ACTIVITY_LIKE) {
-               logger("twitter_post_hook: parameter 2 ".substr($b["thr-parent"], 9), LOGGER_DEBUG);
-               if ($b['deleted'])
+       if ($b['verb'] == ACTIVITY_LIKE) {
+               logger("twitter_post_hook: parameter 2 " . substr($b["thr-parent"], 9), LOGGER_DEBUG);
+               if ($b['deleted']) {
                        twitter_action($a, $b["uid"], substr($b["thr-parent"], 9), "unlike");
-               else
+               } else {
                        twitter_action($a, $b["uid"], substr($b["thr-parent"], 9), "like");
+               }
                return;
        }
  
                logger('twitter: we have customer key and oauth stuff, going to send.', LOGGER_DEBUG);
  
                // If it's a repeated message from twitter then do a native retweet and exit
 -              if (twitter_is_retweet($a, $b['uid'], $b['body'])) {
 +              if (twitter_is_retweet($a, $b['uid'], $b['body']))
                        return;
 -              }
  
-               require_once('library/twitteroauth.php');
-               require_once('include/bbcode.php');
-               $tweet = new TwitterOAuth($ckey,$csecret,$otoken,$osecret);
+               $connection = new TwitterOAuth($ckey, $csecret, $otoken, $osecret);
  
-               $max_char = 140;
-               require_once("include/plaintext.php");
-               $msgarr = plaintext($a, $b, $max_char, true, 8);
+               $max_char = 280;
+               $msgarr = BBCode::toPlaintext($b, $max_char, true, 8);
                $msg = $msgarr["text"];
  
-               if (($msg == "") && isset($msgarr["title"]))
-                       $msg = shortenmsg($msgarr["title"], $max_char - 50);
+               if (($msg == "") && isset($msgarr["title"])) {
+                       $msg = Plaintext::shorten($msgarr["title"], $max_char - 50);
+               }
  
                $image = "";
  
 -              if (isset($msgarr["url"]) && ($msgarr["type"] != "photo")) {
 -                      $msg .= "\n" . $msgarr["url"];
 -              }
 +              if (isset($msgarr["url"]) && ($msgarr["type"] != "photo"))
 +                      $msg .= "\n".$msgarr["url"];
  
 -              if (isset($msgarr["image"]) && ($msgarr["type"] != "video")) {
 +              if (isset($msgarr["image"]) && ($msgarr["type"] != "video"))
                        $image = $msgarr["image"];
 -              }
  
                // and now tweet it :-)
-               if(strlen($msg) && ($image != "")) {
-                       $img_str = fetch_url($image);
-                       $tempfile = tempnam(get_temppath(), "cache");
-                       file_put_contents($tempfile, $img_str);
+               if (strlen($msg) && ($image != "")) {
+                       $connection = new TwitterOAuth($ckey, $csecret, $otoken, $osecret);
+                       $media = $connection->upload('media/upload', ['media' => $image]);
  
-                       // Twitter had changed something so that the old library doesn't work anymore
-                       // so we are using a new library for twitter
-                       // To-Do:
-                       // Switching completely to this library with all functions
-                       require_once("addon/twitter/codebird.php");
-                       $cb = \Codebird\Codebird::getInstance();
-                       $cb->setConsumerKey($ckey, $csecret);
-                       $cb->setToken($otoken, $osecret);
-                       $post = array('status' => $msg, 'media[]' => $tempfile);
+                       $post = ['status' => $msg, 'media_ids' => $media->media_id_string];
  
 -                      if ($iscomment) {
 +                      if ($iscomment)
                                $post["in_reply_to_status_id"] = substr($orig_post["uri"], 9);
 -                      }
  
-                       $result = $cb->statuses_updateWithMedia($post);
-                       unlink($tempfile);
+                       $result = $connection->post('statuses/update', $post);
  
                        logger('twitter_post_with_media send, result: ' . print_r($result, true), LOGGER_DEBUG);
  
                                logger('Send to Twitter failed: "' . print_r($result->errors, true) . '"');
  
                                // Workaround: Remove the picture link so that the post can be reposted without it
 -                              $msg .= " " . $image;
 +                              $msg .= " ".$image;
                                $image = "";
                        } elseif ($iscomment) {
-                               logger('twitter_post: Update extid '.$result->id_str." for post id ".$b['id']);
-                               q("UPDATE `item` SET `extid` = '%s', `body` = '%s' WHERE `id` = %d",
-                                       dbesc("twitter::".$result->id_str),
-                                       dbesc($result->text),
-                                       intval($b['id'])
-                               );
+                               logger('twitter_post: Update extid ' . $result->id_str . " for post id " . $b['id']);
+                               Item::update(['extid' => "twitter::" . $result->id_str, 'body' => $result->text], ['id' => $b['id']]);
                        }
                }
  
-               if(strlen($msg) && ($image == "")) {
+               if (strlen($msg) && ($image == "")) {
+ // -----------------
+                       $max_char = 280;
+                       $msgarr = BBCode::toPlaintext($b, $max_char, true, 8);
+                       $msg = $msgarr["text"];
+                       if (($msg == "") && isset($msgarr["title"])) {
+                               $msg = Plaintext::shorten($msgarr["title"], $max_char - 50);
+                       }
+                       if (isset($msgarr["url"])) {
+                               $msg .= "\n" . $msgarr["url"];
+                       }
+ // -----------------
                        $url = 'statuses/update';
 -                      $post = ['status' => $msg, 'weighted_character_count' => 'true'];
 +                      $post = array('status' => $msg);
  
 -                      if ($iscomment) {
 +                      if ($iscomment)
                                $post["in_reply_to_status_id"] = substr($orig_post["uri"], 9);
 -                      }
  
-                       $result = $tweet->post($url, $post);
+                       $result = $connection->post($url, $post);
                        logger('twitter_post send, result: ' . print_r($result, true), LOGGER_DEBUG);
  
 -                      if ($result->source) {
 -                              Config::set("twitter", "application_name", strip_tags($result->source));
 -                      }
 +                      if ($result->source)
 +                              set_config("twitter", "application_name", strip_tags($result->source));
  
                        if ($result->errors) {
                                logger('Send to Twitter failed: "' . print_r($result->errors, true) . '"');
  
                                $r = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `self`", intval($b['uid']));
 -                              if (count($r)) {
 +                              if (count($r))
                                        $a->contact = $r[0]["id"];
 -                              }
  
-                               $s = serialize(array('url' => $url, 'item' => $b['id'], 'post' => $post));
-                               require_once('include/queue_fn.php');
-                               add_to_queue($a->contact,NETWORK_TWITTER,$s);
-                               notice(t('Twitter post failed. Queued for retry.').EOL);
+                               $s = serialize(['url' => $url, 'item' => $b['id'], 'post' => $post]);
+                               Queue::add($a->contact, NETWORK_TWITTER, $s);
+                               notice(L10n::t('Twitter post failed. Queued for retry.') . EOL);
                        } elseif ($iscomment) {
-                               logger('twitter_post: Update extid '.$result->id_str." for post id ".$b['id']);
-                               q("UPDATE `item` SET `extid` = '%s' WHERE `id` = %d",
-                                       dbesc("twitter::".$result->id_str),
-                                       intval($b['id'])
-                               );
-                               //q("UPDATE `item` SET `extid` = '%s', `body` = '%s' WHERE `id` = %d",
-                               //      dbesc("twitter::".$result->id_str),
-                               //      dbesc($result->text),
-                               //      intval($b['id'])
-                               //);
+                               logger('twitter_post: Update extid ' . $result->id_str . " for post id " . $b['id']);
+                               Item::update(['extid' => "twitter::" . $result->id_str], ['id' => $b['id']]);
                        }
                }
        }
  }
  
- function twitter_plugin_admin_post(&$a){
-       $consumerkey    =       ((x($_POST,'consumerkey'))              ? notags(trim($_POST['consumerkey']))   : '');
-       $consumersecret =       ((x($_POST,'consumersecret'))   ? notags(trim($_POST['consumersecret'])): '');
-       $applicationname = ((x($_POST, 'applicationname')) ? notags(trim($_POST['applicationname'])):'');
-       set_config('twitter','consumerkey',$consumerkey);
-       set_config('twitter','consumersecret',$consumersecret);
-       //set_config('twitter','application_name',$applicationname);
-       info( t('Settings updated.'). EOL );
+ function twitter_addon_admin_post(App $a)
+ {
+       $consumerkey    = x($_POST, 'consumerkey')    ? notags(trim($_POST['consumerkey']))    : '';
+       $consumersecret = x($_POST, 'consumersecret') ? notags(trim($_POST['consumersecret'])) : '';
+       Config::set('twitter', 'consumerkey', $consumerkey);
+       Config::set('twitter', 'consumersecret', $consumersecret);
+       info(L10n::t('Settings updated.') . EOL);
  }
 +function twitter_plugin_admin(&$a, &$o){
 +      $t = get_markup_template( "admin.tpl", "addon/twitter/" );
  
-       $o = replace_macros($t, array(
-               '$submit' => t('Save Settings'),
-                                                               // name, label, value, help, [extra values]
-               '$consumerkey' => array('consumerkey', t('Consumer key'),  get_config('twitter', 'consumerkey' ), ''),
-               '$consumersecret' => array('consumersecret', t('Consumer secret'),  get_config('twitter', 'consumersecret' ), ''),
-               //'$applicationname' => array('applicationname', t('Name of the Twitter Application'), get_config('twitter','application_name'),t('Set this to the exact name you gave the app on twitter.com/apps to avoid mirroring postings from ~friendica back to ~friendica'))
-       ));
+ function twitter_addon_admin(App $a, &$o)
+ {
+       $t = get_markup_template("admin.tpl", "addon/twitter/");
+       $o = replace_macros($t, [
+               '$submit' => L10n::t('Save Settings'),
+               // name, label, value, help, [extra values]
+               '$consumerkey' => ['consumerkey', L10n::t('Consumer key'), Config::get('twitter', 'consumerkey'), ''],
+               '$consumersecret' => ['consumersecret', L10n::t('Consumer secret'), Config::get('twitter', 'consumersecret'), ''],
+       ]);
  }
  
 -function twitter_cron(App $a, $b)
 -{
 -      $last = Config::get('twitter', 'last_poll');
 +function twitter_cron($a,$b) {
 +      $last = get_config('twitter','last_poll');
  
 -      $poll_interval = intval(Config::get('twitter', 'poll_interval'));
 -      if (!$poll_interval) {
 +      $poll_interval = intval(get_config('twitter','poll_interval'));
 +      if(! $poll_interval)
                $poll_interval = TWITTER_DEFAULT_POLL_INTERVAL;
 -      }
  
 -      if ($last) {
 +      if($last) {
                $next = $last + ($poll_interval * 60);
 -              if ($next > time()) {
 +              if($next > time()) {
                        logger('twitter: poll intervall not reached');
                        return;
                }
                }
        }
  
-       $abandon_days = intval(get_config('system','account_abandon_days'));
-       if ($abandon_days < 1)
+       $abandon_days = intval(Config::get('system', 'account_abandon_days'));
+       if ($abandon_days < 1) {
                $abandon_days = 0;
+       }
  
-       $abandon_limit = date("Y-m-d H:i:s", time() - $abandon_days * 86400);
+       $abandon_limit = date(DateTimeFormat::MYSQL, time() - $abandon_days * 86400);
  
        $r = q("SELECT * FROM `pconfig` WHERE `cat` = 'twitter' AND `k` = 'import' AND `v` = '1'");
 -      if (count($r)) {
 -              foreach ($r as $rr) {
 +      if(count($r)) {
 +              foreach($r as $rr) {
                        if ($abandon_days != 0) {
                                $user = q("SELECT `login_date` FROM `user` WHERE uid=%d AND `login_date` >= '%s'", $rr['uid'], $abandon_limit);
                                if (!count($user)) {
@@@ -709,15 -747,16 +725,14 @@@ function twitter_expire($a,$b) 
        logger('twitter_expire: expire_end');
  }
  
 -function twitter_prepare_body(App $a, &$b)
 -{
 -      if ($b["item"]["network"] != NETWORK_TWITTER) {
 +function twitter_prepare_body(&$a,&$b) {
 +      if ($b["item"]["network"] != NETWORK_TWITTER)
                return;
 -      }
  
        if ($b["preview"]) {
-               $max_char = 140;
-               require_once("include/plaintext.php");
+               $max_char = 280;
                $item = $b["item"];
 -              $item["plink"] = $a->get_baseurl() . "/display/" . $a->user["nickname"] . "/" . $item["parent"];
 +              $item["plink"] = $a->get_baseurl()."/display/".$a->user["nickname"]."/".$item["parent"];
  
                $r = q("SELECT `author-link` FROM item WHERE item.uri = '%s' AND item.uid = %d LIMIT 1",
                        dbesc($item["thr-parent"]),
                        $orig_post = $r[0];
  
                        $nicknameplain = preg_replace("=https?://twitter.com/(.*)=ism", "$1", $orig_post["author-link"]);
 -                      $nickname = "@[url=" . $orig_post["author-link"] . "]" . $nicknameplain . "[/url]";
 -                      $nicknameplain = "@" . $nicknameplain;
 +                      $nickname = "@[url=".$orig_post["author-link"]."]".$nicknameplain."[/url]";
 +                      $nicknameplain = "@".$nicknameplain;
  
 -                      if ((strpos($item["body"], $nickname) === false) && (strpos($item["body"], $nicknameplain) === false)) {
 -                              $item["body"] = $nickname . " " . $item["body"];
 -                      }
 +                      if ((strpos($item["body"], $nickname) === false) && (strpos($item["body"], $nicknameplain) === false))
 +                              $item["body"] = $nickname." ".$item["body"];
                }
  
-               $msgarr = plaintext($a, $item, $max_char, true, 8);
+               $msgarr = BBCode::toPlaintext($item, $max_char, true, 8);
                $msg = $msgarr["text"];
  
 -              if (isset($msgarr["url"]) && ($msgarr["type"] != "photo")) {
 -                      $msg .= " " . $msgarr["url"];
 -              }
 +              if (isset($msgarr["url"]) && ($msgarr["type"] != "photo"))
 +                      $msg .= " ".$msgarr["url"];
  
 -              if (isset($msgarr["image"])) {
 -                      $msg .= " " . $msgarr["image"];
 -              }
 +              if (isset($msgarr["image"]))
 +                      $msg .= " ".$msgarr["image"];
  
 -              $b['html'] = nl2br(htmlspecialchars($msg));
 +                $b['html'] = nl2br(htmlspecialchars($msg));
        }
  }
  
@@@ -768,14 -810,20 +782,20 @@@ function twitter_do_mirrorpost($a, $uid
  
        if (is_object($post->retweeted_status)) {
                // We don't support nested shares, so we mustn't show quotes as shares on retweets
 -              $item = twitter_createpost($a, $uid, $post->retweeted_status, ['id' => 0], false, false, true);
 +              $item = twitter_createpost($a, $uid, $post->retweeted_status, array('id' => 0), false, false, true);
  
-               $datarray['body'] = "\n".share_header($item['author-name'], $item['author-link'], $item['author-avatar'], "",
-                                       $item['created'], $item['plink']);
+               $datarray['body'] = "\n" . share_header(
+                       $item['author-name'],
+                       $item['author-link'],
+                       $item['author-avatar'],
+                       "",
+                       $item['created'],
+                       $item['plink']
+               );
  
 -              $datarray['body'] .= $item['body'] . '[/share]';
 +              $datarray['body'] .= $item['body'].'[/share]';
        } else {
 -              $item = twitter_createpost($a, $uid, $post, ['id' => 0], false, false, false);
 +              $item = twitter_createpost($a, $uid, $post, array('id' => 0), false, false, false);
  
                $datarray['body'] = $item['body'];
        }
@@@ -808,14 -857,14 +828,13 @@@ function twitter_fetchtimeline($a, $uid
  
        $has_picture = false;
  
 -      require_once 'mod/item.php';
 -      require_once 'include/items.php';
 -      require_once 'mod/share.php';
 +      require_once('mod/item.php');
 +      require_once('include/items.php');
 +      require_once('mod/share.php');
  
-       require_once('library/twitteroauth.php');
-       $connection = new TwitterOAuth($ckey,$csecret,$otoken,$osecret);
+       $connection = new TwitterOAuth($ckey, $csecret, $otoken, $osecret);
  
 -      $parameters = ["exclude_replies" => true, "trim_user" => false, "contributor_details" => true, "include_rts" => true, "tweet_mode" => "extended"];
 +      $parameters = array("exclude_replies" => true, "trim_user" => false, "contributor_details" => true, "include_rts" => true, "tweet_mode" => "extended");
  
        $first_time = ($lastid == "");
  
        $posts = array_reverse($items);
  
        if (count($posts)) {
 -              foreach ($posts as $post) {
 -                      if ($post->id_str > $lastid) {
 -                              $lastid = $post->id_str;
 -                              PConfig::set($uid, 'twitter', 'lastid', $lastid);
 -                      }
 +          foreach ($posts as $post) {
 +              if ($post->id_str > $lastid) {
 +                      $lastid = $post->id_str;
 +                      set_pconfig($uid, 'twitter', 'lastid', $lastid);
 +              }
  
 -                      if ($first_time) {
 -                              continue;
 -                      }
 +              if ($first_time)
 +                      continue;
  
 -                      if (!stristr($post->source, $application_name)) {
 -                              $_SESSION["authenticated"] = true;
 -                              $_SESSION["uid"] = $uid;
 +              if (!stristr($post->source, $application_name)) {
  
 -                              $_REQUEST = twitter_do_mirrorpost($a, $uid, $post);
 +                      $_SESSION["authenticated"] = true;
 +                      $_SESSION["uid"] = $uid;
  
 -                              logger('twitter: posting for user ' . $uid);
 +                      $_REQUEST = twitter_do_mirrorpost($a, $uid, $post);
  
 -                              item_post($a);
 -                      }
 +                      logger('twitter: posting for user '.$uid);
 +
 +                      item_post($a);
                }
 +          }
        }
 -      PConfig::set($uid, 'twitter', 'lastid', $lastid);
 +      set_pconfig($uid, 'twitter', 'lastid', $lastid);
  }
  
 -function twitter_queue_hook(App $a, &$b)
 -{
 +function twitter_queue_hook(&$a,&$b) {
 +
        $qi = q("SELECT * FROM `queue` WHERE `network` = '%s'",
                dbesc(NETWORK_TWITTER)
 -      );
 -      if (!count($qi)) {
 +              );
 +      if(! count($qi))
                return;
 -      }
  
-       require_once('include/queue_fn.php');
-       foreach($qi as $x) {
-               if($x['network'] !== NETWORK_TWITTER)
+       foreach ($qi as $x) {
+               if ($x['network'] !== NETWORK_TWITTER) {
                        continue;
 -              }
  
                logger('twitter_queue: run');
  
  
                        logger('twitter_queue: post result: ' . print_r($result, true), LOGGER_DEBUG);
  
 -                      if ($result->errors) {
 +                      if ($result->errors)
                                logger('twitter_queue: Send to Twitter failed: "' . print_r($result->errors, true) . '"');
 -                      else {
 +                      else {
                                $success = true;
-                               remove_queue_item($x['id']);
+                               Queue::removeItem($x['id']);
                        }
 -              } else {
 -                      logger("twitter_queue: Error getting tokens for user " . $user['uid']);
 -              }
 +              } else
 +                      logger("twitter_queue: Error getting tokens for user ".$user['uid']);
  
                if (!$success) {
                        logger('twitter_queue: delayed');
@@@ -939,37 -986,39 +950,38 @@@ function twitter_fetch_contact($uid, $c
  
        $avatar = twitter_fix_avatar($contact->profile_image_url_https);
  
 -      GContact::update(["url" => "https://twitter.com/" . $contact->screen_name,
 -              "network" => NETWORK_TWITTER, "photo" => $avatar, "hide" => true,
 -              "name" => $contact->name, "nick" => $contact->screen_name,
 -              "location" => $contact->location, "about" => $contact->description,
 -              "addr" => $contact->screen_name . "@twitter.com", "generation" => 2]);
 +      update_gcontact(array("url" => "https://twitter.com/".$contact->screen_name,
 +                      "network" => NETWORK_TWITTER, "photo" => $avatar,  "hide" => true,
 +                      "name" => $contact->name, "nick" => $contact->screen_name,
 +                      "location" => $contact->location, "about" => $contact->description,
 +                      "addr" => $contact->screen_name."@twitter.com", "generation" => 2));
  
        $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `alias` = '%s' LIMIT 1",
-               intval($uid), dbesc("twitter::".$contact->id_str));
+               intval($uid),
+               dbesc("twitter::" . $contact->id_str));
  
 -      if (!count($r) && !$create_user) {
 -              return 0;
 -      }
 +      if(!count($r) && !$create_user)
 +              return(0);
  
        if (count($r) && ($r[0]["readonly"] || $r[0]["blocked"])) {
 -              logger("twitter_fetch_contact: Contact '" . $r[0]["nick"] . "' is blocked or readonly.", LOGGER_DEBUG);
 -              return -1;
 +              logger("twitter_fetch_contact: Contact '".$r[0]["nick"]."' is blocked or readonly.", LOGGER_DEBUG);
 +              return(-1);
        }
  
 -      if (!count($r)) {
 +      if(!count($r)) {
                // create contact record
                q("INSERT INTO `contact` (`uid`, `created`, `url`, `nurl`, `addr`, `alias`, `notify`, `poll`,
                                        `name`, `nick`, `photo`, `network`, `rel`, `priority`,
                                        `location`, `about`, `writable`, `blocked`, `readonly`, `pending`)
                                        VALUES (%d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', '%s', %d, 0, 0, 0)",
                        intval($uid),
-                       dbesc(datetime_convert()),
-                       dbesc("https://twitter.com/".$contact->screen_name),
-                       dbesc(normalise_link("https://twitter.com/".$contact->screen_name)),
+                       dbesc(DateTimeFormat::utcNow()),
+                       dbesc("https://twitter.com/" . $contact->screen_name),
+                       dbesc(normalise_link("https://twitter.com/" . $contact->screen_name)),
                        dbesc($contact->screen_name."@twitter.com"),
 -                      dbesc("twitter::" . $contact->id_str),
 +                      dbesc("twitter::".$contact->id_str),
                        dbesc(''),
 -                      dbesc("twitter::" . $contact->id_str),
 +                      dbesc("twitter::".$contact->id_str),
                        dbesc($contact->name),
                        dbesc($contact->screen_name),
                        dbesc($avatar),
                }
        } else {
                // update profile photos once every two weeks as we have no notification of when they change.
-               //$update_photo = (($r[0]['avatar-date'] < datetime_convert('','','now -2 days')) ? true : false);
-               $update_photo = ($r[0]['avatar-date'] < datetime_convert('','','now -12 hours'));
+               //$update_photo = (($r[0]['avatar-date'] < DateTimeFormat::convert('now -2 days', '', '', )) ? true : false);
+               $update_photo = ($r[0]['avatar-date'] < DateTimeFormat::utc('now -12 hours'));
  
                // check that we have all the photos, this has been known to fail on occasion
 -              if ((!$r[0]['photo']) || (!$r[0]['thumb']) || (!$r[0]['micro']) || ($update_photo)) {
 -                      logger("twitter_fetch_contact: Updating contact " . $contact->screen_name, LOGGER_DEBUG);
  
 -                      $photos = Photo::importProfilePhoto($avatar, $uid, $r[0]['id'], true);
 +              if((! $r[0]['photo']) || (! $r[0]['thumb']) || (! $r[0]['micro']) || ($update_photo)) {
 +
 +                      logger("twitter_fetch_contact: Updating contact ".$contact->screen_name, LOGGER_DEBUG);
 +
 +                      require_once("Photo.php");
 +
 +                      $photos = import_profile_photo($avatar, $uid, $r[0]['id'], true);
  
                        if ($photos) {
                                q("UPDATE `contact` SET `photo` = '%s',
                }
        }
  
 -      return $r[0]["id"];
 +      return($r[0]["id"]);
  }
  
- function twitter_fetchuser($a, $uid, $screen_name = "", $user_id = "") {
-       $ckey    = get_config('twitter', 'consumerkey');
-       $csecret = get_config('twitter', 'consumersecret');
-       $otoken  = get_pconfig($uid, 'twitter', 'oauthtoken');
-       $osecret = get_pconfig($uid, 'twitter', 'oauthsecret');
-       require_once("addon/twitter/codebird.php");
-       $cb = \Codebird\Codebird::getInstance();
-       $cb->setConsumerKey($ckey, $csecret);
-       $cb->setToken($otoken, $osecret);
+ function twitter_fetchuser(App $a, $uid, $screen_name = "", $user_id = "")
+ {
+       $ckey = Config::get('twitter', 'consumerkey');
+       $csecret = Config::get('twitter', 'consumersecret');
+       $otoken = PConfig::get($uid, 'twitter', 'oauthtoken');
+       $osecret = PConfig::get($uid, 'twitter', 'oauthsecret');
  
        $r = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1",
                intval($uid));
  
 -      if (count($r)) {
 +      if(count($r)) {
                $self = $r[0];
 -      } else {
 +      } else
                return;
 -      }
  
 -      $parameters = [];
 +      $parameters = array();
  
 -      if ($screen_name != "") {
 +      if ($screen_name != "")
                $parameters["screen_name"] = $screen_name;
 -      }
  
 -      if ($user_id != "") {
 +      if ($user_id != "")
                $parameters["user_id"] = $user_id;
 -      }
  
        // Fetching user data
-       $user = $cb->users_show($parameters);
+       $connection = new TwitterOAuth($ckey, $csecret, $otoken, $osecret);
+       $user = $connection->get('users/show', $parameters);
  
 -      if (!is_object($user)) {
 +      if (!is_object($user))
                return;
 -      }
  
        $contact_id = twitter_fetch_contact($uid, $user, true);
  
@@@ -1132,17 -1177,18 +1148,16 @@@ function twitter_expand_entities(App $a
                        $plain = str_replace($url->url, '', $plain);
  
                        if ($url->url && $url->expanded_url && $url->display_url) {
-                               $expanded_url = original_url($url->expanded_url);
+                               $expanded_url = Network::finalUrl($url->expanded_url);
  
 -                              $oembed_data = OEmbed::fetchURL($expanded_url);
 +                              $oembed_data = oembed_fetch_url($expanded_url);
  
                                // Quickfix: Workaround for URL with "[" and "]" in it
 -                              if (strpos($expanded_url, "[") || strpos($expanded_url, "]")) {
 +                              if (strpos($expanded_url, "[") || strpos($expanded_url, "]"))
                                        $expanded_url = $url->url;
 -                              }
  
 -                              if ($type == "") {
 +                              if ($type == "")
                                        $type = $oembed_data->type;
 -                              }
  
                                if ($oembed_data->type == "video") {
                                        //$body = str_replace($url->url,
                                        //$dontincludemedia = true;
                                        $type = $oembed_data->type;
                                        $footerurl = $expanded_url;
 -                                      $footerlink = "[url=" . $expanded_url . "]" . $expanded_url . "[/url]";
 +                                      $footerlink = "[url=".$expanded_url."]".$expanded_url."[/url]";
  
                                        $body = str_replace($url->url, $footerlink, $body);
 -                                      //} elseif (($oembed_data->type == "photo") AND isset($oembed_data->url) AND !$dontincludemedia) {
 +                              //} elseif (($oembed_data->type == "photo") AND isset($oembed_data->url) AND !$dontincludemedia) {
                                } elseif (($oembed_data->type == "photo") && isset($oembed_data->url)) {
 -                                      $body = str_replace($url->url, "[url=" . $expanded_url . "][img]" . $oembed_data->url . "[/img][/url]", $body);
 +                                      $body = str_replace($url->url,
 +                                                      "[url=".$expanded_url."][img]".$oembed_data->url."[/img][/url]",
 +                                                      $body);
                                        //$dontincludemedia = true;
-                               } elseif ($oembed_data->type != "link")
-                                       $body = str_replace($url->url,
-                                                       "[url=".$expanded_url."]".$expanded_url."[/url]",
-                                                       $body);
-                               else {
-                                       $img_str = fetch_url($expanded_url, true, $redirects, 4);
+                               } elseif ($oembed_data->type != "link") {
+                                       $body = str_replace($url->url, "[url=" . $expanded_url . "]" . $expanded_url . "[/url]", $body);
+                               } else {
+                                       $img_str = Network::fetchUrl($expanded_url, true, $redirects, 4);
  
                                        $tempfile = tempnam(get_temppath(), "cache");
                                        file_put_contents($tempfile, $img_str);
                        $body .= $footer;
                }
  
 -              if (($footer == "") && ($picture != "")) {
 -                      $body .= "\n\n[img]" . $picture . "[/img]\n";
 -              } elseif (($footer == "") && ($picture == "")) {
 +              if (($footer == "") && ($picture != ""))
 +                      $body .= "\n\n[img]".$picture."[/img]\n";
 +              elseif (($footer == "") && ($picture == ""))
                        $body = add_page_info_to_body($body);
-               if ($no_tags)
-                       return array("body" => $body, "tags" => "", "plain" => $plain);
-               $tags_arr = array();
-               foreach ($item->entities->hashtags AS $hashtag) {
-                       $url = "#[url=".$a->get_baseurl()."/search?tag=".rawurlencode($hashtag->text)."]".$hashtag->text."[/url]";
-                       $tags_arr["#".$hashtag->text] = $url;
-                       $body = str_replace("#".$hashtag->text, $url, $body);
                }
+       }
  
-               foreach ($item->entities->user_mentions AS $mention) {
-                       $url = "@[url=https://twitter.com/".rawurlencode($mention->screen_name)."]".$mention->screen_name."[/url]";
-                       $tags_arr["@".$mention->screen_name] = $url;
-                       $body = str_replace("@".$mention->screen_name, $url, $body);
-               }
+       // it seems as if the entities aren't always covering all mentions. So the rest will be checked here
+       $tags = get_tags($body);
  
-               // it seems as if the entities aren't always covering all mentions. So the rest will be checked here
-               $tags = get_tags($body);
+       if (count($tags)) {
+               foreach ($tags as $tag) {
+                       if (strstr(trim($tag), " ")) {
+                               continue;
+                       }
  
-               if(count($tags)) {
-                       foreach($tags as $tag) {
-                               if (strstr(trim($tag), " "))
+                       if (strpos($tag, '#') === 0) {
+                               if (strpos($tag, '[url=')) {
                                        continue;
 -                              }
  
-                               if(strpos($tag,'#') === 0) {
-                                       if(strpos($tag,'[url='))
-                                               continue;
-                                       // don't link tags that are already embedded in links
-                                       if(preg_match('/\[(.*?)' . preg_quote($tag,'/') . '(.*?)\]/',$body))
-                                               continue;
-                                       if(preg_match('/\[(.*?)\]\((.*?)' . preg_quote($tag,'/') . '(.*?)\)/',$body))
-                                               continue;
+                               // don't link tags that are already embedded in links
+                               if (preg_match('/\[(.*?)' . preg_quote($tag, '/') . '(.*?)\]/', $body)) {
+                                       continue;
+                               }
+                               if (preg_match('/\[(.*?)\]\((.*?)' . preg_quote($tag, '/') . '(.*?)\)/', $body)) {
+                                       continue;
+                               }
  
-                                       $basetag = str_replace('_',' ',substr($tag,1));
-                                       $url = '#[url='.$a->get_baseurl().'/search?tag='.rawurlencode($basetag).']'.$basetag.'[/url]';
-                                       $body = str_replace($tag,$url,$body);
-                                       $tags_arr["#".$basetag] = $url;
+                               $basetag = str_replace('_', ' ', substr($tag, 1));
+                               $url = '#[url=' . $a->get_baseurl() . '/search?tag=' . rawurlencode($basetag) . ']' . $basetag . '[/url]';
+                               $body = str_replace($tag, $url, $body);
+                               $tags_arr["#" . $basetag] = $url;
+                       } elseif (strpos($tag, '@') === 0) {
+                               if (strpos($tag, '[url=')) {
                                        continue;
-                               } elseif(strpos($tag,'@') === 0) {
-                                       if(strpos($tag,'[url='))
-                                               continue;
-                                       $basetag = substr($tag,1);
-                                       $url = '@[url=https://twitter.com/'.rawurlencode($basetag).']'.$basetag.'[/url]';
-                                       $body = str_replace($tag,$url,$body);
-                                       $tags_arr["@".$basetag] = $url;
                                }
+                               $basetag = substr($tag, 1);
+                               $url = '@[url=https://twitter.com/' . rawurlencode($basetag) . ']' . $basetag . '[/url]';
+                               $body = str_replace($tag, $url, $body);
+                               $tags_arr["@" . $basetag] = $url;
                        }
                }
+       }
  
+       $tags = implode($tags_arr, ",");
  
-               $tags = implode($tags_arr, ",");
-       }
-       return array("body" => $body, "tags" => $tags, "plain" => $plain);
+       return ["body" => $body, "tags" => $tags, "plain" => $plain];
  }
  
  /**
   * @param object $post Twitter object with the post
   * @param array $postarray Array of the item that is about to be posted
   *
-  * @return $picture string Returns a a single picture string if it isn't a media post
+  * @return $picture string Image URL or empty string
   */
 -function twitter_media_entities($post, &$postarray)
 -{
 +function twitter_media_entities($post, &$postarray) {
 +
        // There are no media entities? So we quit.
        if (!is_array($post->extended_entities->media)) {
                return "";
@@@ -1339,25 -1369,24 +1337,25 @@@ function twitter_createpost($a, $uid, $
  
        // Don't import our own comments
        $r = q("SELECT * FROM `item` WHERE `extid` = '%s' AND `uid` = %d LIMIT 1",
-                       dbesc($postarray['uri']),
-                       intval($uid)
-               );
+               dbesc($postarray['uri']),
+               intval($uid)
+       );
  
        if (count($r)) {
 -              logger("Item with extid " . $postarray['uri'] . " found.", LOGGER_DEBUG);
 -              return [];
 +              logger("Item with extid ".$postarray['uri']." found.", LOGGER_DEBUG);
 +              return(array());
        }
  
        $contactid = 0;
  
        if ($post->in_reply_to_status_id_str != "") {
 -              $parent = "twitter::" . $post->in_reply_to_status_id_str;
 +
 +              $parent = "twitter::".$post->in_reply_to_status_id_str;
  
                $r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
-                               dbesc($parent),
-                               intval($uid)
-                       );
+                       dbesc($parent),
+                       intval($uid)
+               );
                if (count($r)) {
                        $postarray['thr-parent'] = $r[0]["uri"];
                        $postarray['parent-uri'] = $r[0]["parent-uri"];
  
                $postarray['body'] = $statustext;
  
-               $postarray['body'] .= "\n".share_header($quoted['author-name'], $quoted['author-link'], $quoted['author-avatar'], "",
-                                                       $quoted['created'], $quoted['plink']);
+               $postarray['body'] .= "\n" . share_header(
+                       $quoted['author-name'],
+                       $quoted['author-link'],
+                       $quoted['author-avatar'],
+                       "",
+                       $quoted['created'],
+                       $quoted['plink']
+               );
  
 -              $postarray['body'] .= $quoted['body'] . '[/share]';
 +              $postarray['body'] .= $quoted['body'].'[/share]';
        }
  
 -      return $postarray;
 +      return($postarray);
  }
  
 -function twitter_checknotification(App $a, $uid, $own_id, $top_item, $postarray)
 -{
 -      /// TODO: this whole function doesn't seem to work. Needs complete check
 +function twitter_checknotification($a, $uid, $own_id, $top_item, $postarray) {
 +
 +      // this whole function doesn't seem to work. Needs complete check
 +
        $user = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` LIMIT 1",
-                       intval($uid)
-               );
+               intval($uid)
+       );
  
 -      if (!count($user)) {
 +      if(!count($user))
                return;
 -      }
  
        // Is it me?
 -      if (link_compare($user[0]["url"], $postarray['author-link'])) {
 +      if (link_compare($user[0]["url"], $postarray['author-link']))
                return;
 -      }
  
        $own_user = q("SELECT * FROM `contact` WHERE `uid` = %d AND `alias` = '%s' LIMIT 1",
-                       intval($uid),
-                       dbesc("twitter::".$own_id)
-               );
+               intval($uid),
+               dbesc("twitter::".$own_id)
+       );
  
 -      if (!count($own_user)) {
 +      if(!count($own_user))
                return;
 -      }
  
        // Is it me from twitter?
 -      if (link_compare($own_user[0]["url"], $postarray['author-link'])) {
 +      if (link_compare($own_user[0]["url"], $postarray['author-link']))
                return;
 -      }
  
        $myconv = q("SELECT `author-link`, `author-avatar`, `parent` FROM `item` WHERE `parent-uri` = '%s' AND `uid` = %d AND `parent` != 0 AND `deleted` = 0",
-                       dbesc($postarray['parent-uri']),
-                       intval($uid)
-                       );
-       if(count($myconv)) {
+               dbesc($postarray['parent-uri']),
+               intval($uid)
+       );
  
 -      if (count($myconv)) {
 -              foreach ($myconv as $conv) {
 +              foreach($myconv as $conv) {
                        // now if we find a match, it means we're in this conversation
 -                      if (!link_compare($conv['author-link'], $user[0]["url"]) && !link_compare($conv['author-link'], $own_user[0]["url"])) {
 +
 +                      if(!link_compare($conv['author-link'],$user[0]["url"]) && !link_compare($conv['author-link'],$own_user[0]["url"]))
                                continue;
 -                      }
  
 -                      require_once 'include/enotify.php';
 +                      require_once('include/enotify.php');
  
                        $conv_parent = $conv['parent'];
  
 -                      notification([
 -                              'type' => NOTIFY_COMMENT,
 +                      notification(array(
 +                              'type'         => NOTIFY_COMMENT,
                                'notify_flags' => $user[0]['notify-flags'],
-                               'language'     => $user[0]['language'],
-                               'to_name'      => $user[0]['username'],
-                               'to_email'     => $user[0]['email'],
-                               'uid'          => $user[0]['uid'],
-                               'item'         => $postarray,
-                               'link'         => $a->get_baseurl().'/display/'.urlencode(get_item_guid($top_item)),
-                               'source_name'  => $postarray['author-name'],
-                               'source_link'  => $postarray['author-link'],
+                               'language' => $user[0]['language'],
+                               'to_name' => $user[0]['username'],
+                               'to_email' => $user[0]['email'],
+                               'uid' => $user[0]['uid'],
+                               'item' => $postarray,
+                               'link' => $a->get_baseurl() . '/display/' . urlencode(Item::getGuidById($top_item)),
+                               'source_name' => $postarray['author-name'],
+                               'source_link' => $postarray['author-link'],
                                'source_photo' => $postarray['author-avatar'],
 -                              'verb' => ACTIVITY_POST,
 -                              'otype' => 'item',
 -                              'parent' => $conv_parent,
 -                      ]);
 +                              'verb'         => ACTIVITY_POST,
 +                              'otype'        => 'item',
 +                              'parent'       => $conv_parent,
 +                      ));
  
                        // only send one notification
                        break;
@@@ -1579,12 -1617,13 +1581,12 @@@ function twitter_fetchparentposts($a, $
                }
  
                $r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
-                               dbesc("twitter::".$post->id_str),
-                               intval($uid)
-                       );
+                       dbesc("twitter::".$post->id_str),
+                       intval($uid)
+               );
  
 -              if (count($r)) {
 +              if (count($r))
                        break;
 -              }
  
                $posts[] = $post;
        }
                foreach ($posts as $post) {
                        $postarray = twitter_createpost($a, $uid, $post, $self, false, false, false);
  
-                       if (trim($postarray['body']) == "")
+                       if (trim($postarray['body']) == "") {
                                continue;
+                       }
  
-                       $item = item_store($postarray);
+                       $item = Item::insert($postarray);
                        $postarray["id"] = $item;
  
 -                      logger('twitter_fetchparentpost: User ' . $self["nick"] . ' posted parent timeline item ' . $item);
 +                      logger('twitter_fetchparentpost: User '.$self["nick"].' posted parent timeline item '.$item);
  
 -                      if ($item && !function_exists("check_item_notification")) {
 +                      if ($item && !function_exists("check_item_notification"))
                                twitter_checknotification($a, $uid, $own_id, $item, $postarray);
 -                      }
                }
        }
  }
  
 -function twitter_fetchhometimeline(App $a, $uid)
 -{
 -      $ckey    = Config::get('twitter', 'consumerkey');
 -      $csecret = Config::get('twitter', 'consumersecret');
 -      $otoken  = PConfig::get($uid, 'twitter', 'oauthtoken');
 -      $osecret = PConfig::get($uid, 'twitter', 'oauthsecret');
 -      $create_user = PConfig::get($uid, 'twitter', 'create_user');
 -      $mirror_posts = PConfig::get($uid, 'twitter', 'mirror_posts');
 +function twitter_fetchhometimeline($a, $uid) {
 +      $ckey    = get_config('twitter', 'consumerkey');
 +      $csecret = get_config('twitter', 'consumersecret');
 +      $otoken  = get_pconfig($uid, 'twitter', 'oauthtoken');
 +      $osecret = get_pconfig($uid, 'twitter', 'oauthsecret');
 +      $create_user = get_pconfig($uid, 'twitter', 'create_user');
 +      $mirror_posts = get_pconfig($uid, 'twitter', 'mirror_posts');
  
 -      logger("twitter_fetchhometimeline: Fetching for user " . $uid, LOGGER_DEBUG);
 +      logger("twitter_fetchhometimeline: Fetching for user ".$uid, LOGGER_DEBUG);
  
 -      $application_name = Config::get('twitter', 'application_name');
 +      $application_name  = get_config('twitter', 'application_name');
  
 -      if ($application_name == "") {
 +      if ($application_name == "")
                $application_name = $a->get_hostname();
 -      }
  
-       require_once('library/twitteroauth.php');
-       require_once('include/items.php');
+       require_once 'include/items.php';
  
 -      $connection = new TwitterOAuth($ckey, $csecret, $otoken, $osecret);
 +      $connection = new TwitterOAuth($ckey,$csecret,$otoken,$osecret);
  
        $own_contact = twitter_fetch_own_contact($a, $uid);
  
  
                        $postarray = twitter_createpost($a, $uid, $post, $self, $create_user, true, false);
  
 -                      if (trim($postarray['body']) == "") {
 +                      if (trim($postarray['body']) == "")
                                continue;
 -                      }
  
-                       $item = item_store($postarray);
+                       $item = Item::insert($postarray);
                        $postarray["id"] = $item;
  
 -                      logger('twitter_fetchhometimeline: User ' . $self["nick"] . ' posted home timeline item ' . $item);
 +                      logger('twitter_fetchhometimeline: User '.$self["nick"].' posted home timeline item '.$item);
  
 -                      if ($item && !function_exists("check_item_notification")) {
 +                      if ($item && !function_exists("check_item_notification"))
                                twitter_checknotification($a, $uid, $own_id, $item, $postarray);
 -                      }
 +
                }
        }
 -      PConfig::set($uid, 'twitter', 'lasthometimelineid', $lastid);
 +      set_pconfig($uid, 'twitter', 'lasthometimelineid', $lastid);
  
        // Fetching mentions
 -      $lastid = PConfig::get($uid, 'twitter', 'lastmentionid');
 +      $lastid  = get_pconfig($uid, 'twitter', 'lastmentionid');
  
        $first_time = ($lastid == "");
  
  
                        $postarray = twitter_createpost($a, $uid, $post, $self, false, false, false);
  
 -                      if (trim($postarray['body']) == "") {
 +                      if (trim($postarray['body']) == "")
                                continue;
 -                      }
  
-                       $item = item_store($postarray);
+                       $item = Item::insert($postarray);
                        $postarray["id"] = $item;
  
 -                      if ($item && function_exists("check_item_notification")) {
 +                      if ($item && function_exists("check_item_notification"))
                                check_item_notification($item, $uid, NOTIFY_TAGSELF);
 -                      }
  
 -                      if (!isset($postarray["parent"]) || ($postarray["parent"] == 0)) {
 +                      if (!isset($postarray["parent"]) || ($postarray["parent"] == 0))
                                $postarray["parent"] = $item;
 -                      }
  
 -                      logger('twitter_fetchhometimeline: User ' . $self["nick"] . ' posted mention timeline item ' . $item);
 +                      logger('twitter_fetchhometimeline: User '.$self["nick"].' posted mention timeline item '.$item);
  
                        if ($item == 0) {
                                $r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
                                        $item = $r[0]['id'];
                                        $parent_id = $r[0]['parent'];
                                }
-                       } else
+                       } else {
                                $parent_id = $postarray['parent'];
+                       }
  
                        if (($item != 0) && !function_exists("check_item_notification")) {
 -                              require_once 'include/enotify.php';
 -                              notification([
 +                              require_once('include/enotify.php');
 +                              notification(array(
                                        'type'         => NOTIFY_TAGSELF,
                                        'notify_flags' => $u[0]['notify-flags'],
                                        'language'     => $u[0]['language'],
@@@ -1861,31 -1916,31 +1862,29 @@@ function twitter_is_retweet($a, $uid, $
  
        $link = "";
        preg_match("/link='(.*?)'/ism", $attributes, $matches);
 -      if ($matches[1] != "") {
 +      if ($matches[1] != "")
                $link = $matches[1];
 -      }
  
        preg_match('/link="(.*?)"/ism', $attributes, $matches);
 -      if ($matches[1] != "") {
 +      if ($matches[1] != "")
                $link = $matches[1];
 -      }
  
        $id = preg_replace("=https?://twitter.com/(.*)/status/(.*)=ism", "$2", $link);
 -      if ($id == $link) {
 -              return false;
 -      }
 +      if ($id == $link)
 +              return(false);
  
 -      logger('twitter_is_retweet: Retweeting id ' . $id . ' for user ' . $uid, LOGGER_DEBUG);
 +      logger('twitter_is_retweet: Retweeting id '.$id.' for user '.$uid, LOGGER_DEBUG);
  
 -      $ckey    = Config::get('twitter', 'consumerkey');
 -      $csecret = Config::get('twitter', 'consumersecret');
 -      $otoken  = PConfig::get($uid, 'twitter', 'oauthtoken');
 -      $osecret = PConfig::get($uid, 'twitter', 'oauthsecret');
 +      $ckey    = get_config('twitter', 'consumerkey');
 +      $csecret = get_config('twitter', 'consumersecret');
 +      $otoken  = get_pconfig($uid, 'twitter', 'oauthtoken');
 +      $osecret = get_pconfig($uid, 'twitter', 'oauthsecret');
  
-       require_once('library/twitteroauth.php');
-       $connection = new TwitterOAuth($ckey,$csecret,$otoken,$osecret);
-       $result = $connection->post('statuses/retweet/'.$id);
+       $connection = new TwitterOAuth($ckey, $csecret, $otoken, $osecret);
+       $result = $connection->post('statuses/retweet/' . $id);
  
 -      logger('twitter_is_retweet: result ' . print_r($result, true), LOGGER_DEBUG);
 +      logger('twitter_is_retweet: result '.print_r($result, true), LOGGER_DEBUG);
  
 -      return !isset($result->errors);
 +      return(!isset($result->errors));
  }
 +?>
index 687d925372a0000b955556ea3777079cfac8dd8c,c7ed10c717023bea22c63556292952cc5b884ce3..d3d9876b44742d8eafbda47b3992d777643d968b
@@@ -6,12 -4,14 +4,14 @@@
   * Description: Add "View Source" link to item context
   * Version: 1.0
   * Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
 - *
 + * 
   */
+ use Friendica\Core\Addon;
+ use Friendica\Core\L10n;
  
  function viewsrc_install() {
-       register_hook('item_photo_menu', 'addon/viewsrc/viewsrc.php', 'viewsrc_item_photo_menu');
-       register_hook('page_end', 'addon/viewsrc/viewsrc.php', 'viewsrc_page_end');
+       Addon::registerHook('item_photo_menu', 'addon/viewsrc/viewsrc.php', 'viewsrc_item_photo_menu');
+       Addon::registerHook('page_end', 'addon/viewsrc/viewsrc.php', 'viewsrc_page_end');
  }
  
  
index 8b3a243e32e49174dca797c13d0ca843b31d4df6,47cd734ccd22ecc3a9322210a8228890e6e8ef13..cdf7fd2a4df055063cfe682c2b9b529bf7c209fa
@@@ -41,13 -44,13 +44,13 @@@ function webrtc_content(&$a) 
          $o = '';
  
          /* landingpage to create chatrooms */
 -        $webrtcurl = Config::get('webrtc','webrtcurl');
 +        $webrtcurl = get_config('webrtc','webrtcurl');
  
          /* embedd the landing page in an iframe */
-         $o .= '<h2>'.t('Video Chat').'</h2>';
-         $o .= '<p>'.t('WebRTC is a video and audio conferencing tool that works with Firefox (version 21 and above) and Chrome/Chromium (version 25 and above). Just create a new chat room and send the link to someone you want to chat with.').'</p>';
+         $o .= '<h2>'.L10n::t('Video Chat').'</h2>';
+         $o .= '<p>'.L10n::t('WebRTC is a video and audio conferencing tool that works with Firefox (version 21 and above) and Chrome/Chromium (version 25 and above). Just create a new chat room and send the link to someone you want to chat with.').'</p>';
        if ($webrtcurl == '') {
-           $o .= '<p>'.t('Please contact your friendica admin and send a reminder to configure the WebRTC addon.').'</p>';
+           $o .= '<p>'.L10n::t('Please contact your friendica admin and send a reminder to configure the WebRTC addon.').'</p>';
        } else {
            $o .= '<iframe src="'.$webrtcurl.'" width="600px" height="600px"></iframe>';
        }
index 20a84e253e8ca3a47278b595c03684e409694803,f8033667563656f08a92cde29d1980ded0bd7410..cd3083c489c914d5c3aa4db59713e973d04fc791
@@@ -34,10 -43,10 +43,10 @@@ function friendheader_widget_content(&$
                .allcontact-link { float: right; margin: 0px; }
                .contact-block-content { clear:both; }
                .contact-block-div { display: block !important; float: left!important; width: 50px!important; height: 50px!important; margin: 2px!important;}
 -
 +              
        </style>";
        $o .= _abs_url(contact_block());
-       $o .= "<a href='".$a->get_baseurl().'/profile/'.$a->profile['nickname']."' target=new>". t('Get added to this list!') ."</a>";
-       
+       $o .= "<a href='".$a->get_baseurl().'/profile/'.$a->profile['nickname']."' target=new>". L10n::t('Get added to this list!') ."</a>";
        return $o;
  }
index 195667e89bb4962612950534e150f8a78ee567e8,b5a078861e949f0229f63bd26f83f98b40e8ccc6..0d218b13604e48fc8fe69141594c5fc67c52fb96
@@@ -34,9 -45,9 +45,9 @@@ function friends_widget_content(&$a, $c
                .allcontact-link { float: right; margin: 0px; }
                .contact-block-content { clear:both; }
                .contact-block-div { display: block !important; float: left!important; width: 50px!important; height: 50px!important; margin: 2px!important;}
 -
 +              
        </style>";
        $o .= _abs_url(contact_block());
-       $o .= "<a href='".$a->get_baseurl().'/profile/'.$a->profile['nickname']."'>". t('Connect on Friendica!') ."</a>";
+       $o .= "<a href='".$a->get_baseurl().'/profile/'.$a->profile['nickname']."'>". L10n::t('Connect on Friendica!') ."</a>";
        return $o;
  }
index 8f356da976b856b9326a3ceb217be18086314802,5f03c12eb6abf96954216642578af1daa3cda146..27b5fbe6681928bd15bbb4c6a0f44dd836d2c7d0
@@@ -46,23 -48,23 +48,23 @@@ function like_widget_content(&$a, $conf
                        dbesc($args[0])
        );
        $dislikes = $r[0]['c'];
 -
 -
 +      
 +      
        require_once("include/conversation.php");
 -
 +      
        $o = "";
 -
 +      
  #     $t = file_get_contents( dirname(__file__). "/widget_like.tpl" );
        $t = get_markup_template("widget_like.tpl", "addon/widgets/");
 -      $o .= replace_macros($t, [
 +      $o .= replace_macros($t, array(
                '$like'         => $likes,
-               '$strlike'      => sprintf( tt("%d person likes this", "%d people like this", $likes), $likes),
-               
+               '$strlike'      => L10n::tt("%d person likes this", "%d people like this", $likes),
                '$dislike'      => $dislikes,
-               '$strdislike'=> sprintf( tt("%d person doesn't like this", "%d people don't like this", $dislikes), $dislikes),
-               
+               '$strdislike'=> L10n::tt("%d person doesn't like this", "%d people don't like this", $dislikes),
                '$baseurl' => $a->get_baseurl(),
 -      ]);
 -
 +      ));
 +              
        return $o;
  }
index 72534ce3bb75863556051ffbbbe91c13738eacc0,1c7489f1ca6503f05c142721048db92e277cd900..76fc14b48b4270a49d4623c1b95c04d62509ffed
@@@ -49,20 -51,20 +51,20 @@@ function widgets_settings(&$a,&$o) 
                 }
        }
  
 -
 -
 +      
 +      
  #     $t = file_get_contents( dirname(__file__). "/settings.tpl" );
        $t = get_markup_template("settings.tpl", "addon/widgets/");
-       $o .= replace_macros($t, array(
-               '$submit' => t('Generate new key'),
+       $o .= replace_macros($t, [
+               '$submit' => L10n::t('Generate new key'),
                '$baseurl' => $a->get_baseurl(),
                '$title' => "Widgets",
-               '$label' => t('Widgets key'),
+               '$label' => L10n::t('Widgets key'),
                '$key' => $key,
-               '$widgets_h' => t('Widgets available'),
+               '$widgets_h' => L10n::t('Widgets available'),
                '$widgets' => $widgets,
 -      ]);
 -
 +      ));
 +      
  }
  
  function widgets_module() {
@@@ -163,12 -165,11 +165,11 @@@ function widgets_content(&$a) 
                        .htmlspecialchars('"></script>')
                        ."</code>";
  
 -
 +                      
                        return $o;
-               }       
-               
-       }       
-       
+               }
+       }
        echo $o;
        killme();
  }
index 21f986e0ff8d1e7839b7d15a6baa73996566e365,206b0883e4b03241db96b7909d50ea28372a853e..9837e1fe573fbac0f6787d523e611639cfa29ba2
   * 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
 + * If the addon is removed from the configuration list, the 
   * system will call the name_uninstall() function.
   *
   * Version history:
   *        count only unseen elements which are not type=activity (likes and dislikes not seen as new elements)
   */
  
- function windowsphonepush_install() {
-       /**
-        * 
-        * Our plugin will attach in three places.
-        * The first is within cron - so the push notifications will be 
+ use Friendica\App;
+ use Friendica\Content\Text\BBCode;
+ use Friendica\Core\Addon;
+ use Friendica\Core\L10n;
+ use Friendica\Core\PConfig;
+ use Friendica\Model\User;
+ function windowsphonepush_install()
+ {
+       /* 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).
 +       *
         */
+       Addon::registerHook('cron', 'addon/windowsphonepush/windowsphonepush.php', 'windowsphonepush_cron');
  
-       register_hook('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");
  }
  
 -function windowsphonepush_uninstall()
 -{
 -      /* uninstall unregisters any hooks created with register_hook
 +
 +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");
  }
@@@ -81,34 -74,32 +80,31 @@@ function windowsphonepush_module() {
   * $post contains the $_POST array.
   * We will make sure we've got a valid user account
   * and if so set our configuration setting for this person.
 + *
   */
 -function windowsphonepush_settings_post($a, $post)
 -{
 -      if (!local_user() || (!x($_POST, 'windowsphonepush-submit'))) {
 +function windowsphonepush_settings_post($a,$post) {
 +      if(! local_user() || (! x($_POST,'windowsphonepush-submit')))
                return;
 -      }
        $enable = intval($_POST['windowsphonepush']);
 -      PConfig::set(local_user(), 'windowsphonepush', 'enable', $enable);
 +      set_pconfig(local_user(),'windowsphonepush','enable',$enable);
  
 -      if ($enable) {
 -              PConfig::set(local_user(), 'windowsphonepush', 'counterunseen', 0);
 +      if($enable) {
 +              set_pconfig(local_user(),'windowsphonepush','counterunseen', 0);
        }
  
 -      PConfig::set(local_user(), 'windowsphonepush', 'senditemtext', intval($_POST['windowsphonepush-senditemtext']));
 +      set_pconfig(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)
 -{
 -      if (!local_user()) {
 +function windowsphonepush_settings(&$a,&$s) {
 +
 +      if(! local_user())
                return;
 -      }
  
        /* Add our stylesheet to the page so we can make our settings look nice */
        $a->page['htmlhead'] .= '<link rel="stylesheet"  type="text/css" href="' . $a->get_baseurl() . '/addon/windowsphonepush/windowsphonepush.css' . '" media="all" />' . "\r\n";
        $s .= '<label id="windowsphonepush-device_url-label" for="windowsphonepush-device_url-text">Device-URL</label>';
        $s .= '<input id="windowsphonepush-device_url-text" type="text" readonly value=' . $device_url . '/>';
        $s .= '</div><div class="clear"></div></div>';
 -
 +      
        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
+ function windowsphonepush_cron()
+ {
+       // 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) {
 +      if(count($r)) {
 +              foreach($r as $rr) {
                        // load stored information for the user-id of the current loop
 -                      $device_url = PConfig::get($rr['uid'], 'windowsphonepush', 'device_url');
 -                      $lastpushid = PConfig::get($rr['uid'], 'windowsphonepush', 'lastpushid');
 +                      $device_url = get_pconfig($rr['uid'], 'windowsphonepush', 'device_url');
 +                      $lastpushid = get_pconfig($rr['uid'], 'windowsphonepush', 'lastpushid');
  
 -                      // pushing only possible if device_url (the URI on Microsoft server) is available or not "NA" (which will be sent
 +                      // 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
+                       if (( $device_url == "" ) || ( $device_url == "NA" )) {
+                               // 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
 +                              // retrieve the number of unseen items and the id of the latest one (if there are more than 
                                // one new entries since last poller run, only the latest one will be pushed)
 -                              $count = q("SELECT count(`id`) as count, max(`id`) as max FROM `item` WHERE `unseen` = 1 AND `type` <> 'activity' AND `uid` = %d", intval($rr['uid']));
 +                              $count = q("SELECT count(`id`) as count, max(`id`) as max FROM `item` WHERE `unseen` = 1 AND `type` <> 'activity' AND `uid` = %d",
 +                                      intval($rr['uid'])
 +                              );
  
 -                              // send number of unseen items to the device (the number will be displayed on Start screen until
 -                              // App will be started by user) - this update will be sent every 10 minutes to update the number to 0 if
 +                              // send number of unseen items to the device (the number will be displayed on Start screen until 
 +                              // App will be started by user) - this update will be sent every 10 minutes to update the number to 0 if 
                                // user has loaded the timeline through app or website
                                $res_tile = send_tile_update($device_url, "", $count[0]['count'], "");
                                switch (trim($res_tile)) {
                                                // Otherwise BBcode-Tags will be eliminated and plain text cutted to 140 chars (incl. dots)
                                                // BTW: information only possible in English
                                                $body = $item[0]['body'];
 -                                              if (substr($body, 0, 4) == "[url") {
 +                                              if (substr($body, 0, 4) == "[url") 
                                                        $body = "URL/Image ...";
-                                               else {
-                                                       require_once('include/bbcode.php');
+                                               } else {
                                                        require_once("include/html2plain.php");
-                                                       $body = bbcode($body, false, false, 2, true);
+                                                       $body = BBCode::convert($body, false, 2, true);
                                                        $body = html2plain($body, 0);
                                                        $body = ((strlen($body) > 137) ? substr($body, 0, 137) . "..." : $body);
                                                }
@@@ -477,40 -447,31 +470,41 @@@ function windowsphonepush_updatecounter
        return "Counter set to zero";
  }
  
 -/* helper function to login to the server with the specified Network credentials
 +/*
 + * helper function to login to the server with the specified Network credentials
   * (mainly copied from api.php)
   */
 -function windowsphonepush_login(App $a)
 -{
 +function windowsphonepush_login() {
        if (!isset($_SERVER['PHP_AUTH_USER'])) {
 -              logger('API_login: ' . print_r($_SERVER, true), LOGGER_DEBUG);
 -              header('WWW-Authenticate: Basic realm="Friendica"');
 -              header('HTTP/1.0 401 Unauthorized');
 -              die('This api requires login');
 +          logger('API_login: ' . print_r($_SERVER, true), LOGGER_DEBUG);
 +          header('WWW-Authenticate: Basic realm="Friendica"');
 +          header('HTTP/1.0 401 Unauthorized');
 +          die('This api requires login');
        }
  
 -      $user_id = User::authenticate($_SERVER['PHP_AUTH_USER'], trim($_SERVER['PHP_AUTH_PW']));
 +      $user = $_SERVER['PHP_AUTH_USER'];
 +      $encrypted = hash('whirlpool',trim($_SERVER['PHP_AUTH_PW']));
  
 -      if ($user_id) {
 -              $record = dba::selectFirst('user', [], ['uid' => $user_id]);
 +      // check if user specified by app is available in the user table
 +      $r = q("SELECT * FROM `user` WHERE ( `email` = '%s' OR `nickname` = '%s' )
 +          AND `password` = '%s' AND `blocked` = 0 AND `account_expired` = 0 AND `account_removed` = 0 AND `verified` = 1 LIMIT 1",
 +          dbesc(trim($user)),
 +          dbesc(trim($user)),
 +          dbesc($encrypted)
 +      );
 +
 +      if(count($r)){
 +          $record = $r[0];
        } else {
 -              logger('API_login failure: ' . print_r($_SERVER, true), LOGGER_DEBUG);
 -              header('WWW-Authenticate: Basic realm="Friendica"');
 -              header('HTTP/1.0 401 Unauthorized');
 -              die('This api requires login');
 +          logger('API_login failure: ' . print_r($_SERVER,true), LOGGER_DEBUG);
 +          header('WWW-Authenticate: Basic realm="Friendica"');
 +          header('HTTP/1.0 401 Unauthorized');
 +          die('This api requires login');
        }
  
-       require_once('include/security.php');
-       authenticate_success($record); $_SESSION["allow_api"] = true;
-       call_hooks('logged_in', $a->user);
+       require_once 'include/security.php';
+       authenticate_success($record);
+       $_SESSION["allow_api"] = true;
+       Addon::callHooks('logged_in', $a->user);
  }
 +
index fc9244af6ee72193d8b9e0aee060753ff4ebcf2b,8d14b17016ec1deee552e7ee5acfe0ab6131ff42..96209b1513358afd6468f53fca5fe66fe4c7482e
@@@ -34,12 -38,12 +38,12 @@@ function wppost_jot_nets(&$a,&$b) 
      if(! local_user())
          return;
  
 -    $wp_post = PConfig::get(local_user(),'wppost','post');
 +    $wp_post = get_pconfig(local_user(),'wppost','post');
      if(intval($wp_post) == 1) {
 -        $wp_defpost = PConfig::get(local_user(),'wppost','post_by_default');
 +        $wp_defpost = get_pconfig(local_user(),'wppost','post_by_default');
          $selected = ((intval($wp_defpost) == 1) ? ' checked="checked" ' : '');
          $b .= '<div class="profile-jot-net"><input type="checkbox" name="wppost_enable" ' . $selected . ' value="1" /> '
-             . t('Post to Wordpress') . '</div>';
+             . L10n::t('Post to Wordpress') . '</div>';
      }
  }
  
@@@ -133,17 -137,17 +137,17 @@@ function wppost_settings_post(&$a,&$b) 
  
        if(x($_POST,'wppost-submit')) {
  
 -              PConfig::set(local_user(),'wppost','post',intval($_POST['wppost']));
 -              PConfig::set(local_user(),'wppost','post_by_default',intval($_POST['wp_bydefault']));
 -              PConfig::set(local_user(),'wppost','wp_username',trim($_POST['wp_username']));
 -              PConfig::set(local_user(),'wppost','wp_password',trim($_POST['wp_password']));
 -              PConfig::set(local_user(),'wppost','wp_blog',trim($_POST['wp_blog']));
 -              PConfig::set(local_user(),'wppost','backlink',trim($_POST['wp_backlink']));
 -              PConfig::set(local_user(),'wppost','shortcheck',trim($_POST['wp_shortcheck']));
 +              set_pconfig(local_user(),'wppost','post',intval($_POST['wppost']));
 +              set_pconfig(local_user(),'wppost','post_by_default',intval($_POST['wp_bydefault']));
 +              set_pconfig(local_user(),'wppost','wp_username',trim($_POST['wp_username']));
 +              set_pconfig(local_user(),'wppost','wp_password',trim($_POST['wp_password']));
 +              set_pconfig(local_user(),'wppost','wp_blog',trim($_POST['wp_blog']));
 +              set_pconfig(local_user(),'wppost','backlink',trim($_POST['wp_backlink']));
 +              set_pconfig(local_user(),'wppost','shortcheck',trim($_POST['wp_shortcheck']));
                $wp_backlink_text = notags(trim($_POST['wp_backlink_text']));
-               $wp_backlink_text = bbcode($wp_backlink_text, false, false, 8);
+               $wp_backlink_text = BBCode::convert($wp_backlink_text, false, 8);
                $wp_backlink_text = html2plain($wp_backlink_text, 0, true);
 -              PConfig::set(local_user(),'wppost','wp_backlink_text', $wp_backlink_text);
 +              set_pconfig(local_user(),'wppost','wp_backlink_text', $wp_backlink_text);
  
        }
  
@@@ -189,29 -193,35 +193,26 @@@ function wppost_post_local(&$a, &$b) 
  
  function wppost_send(&$a,&$b) {
  
 -      if($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) {
 +      if($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited']))
                return;
 -      }
  
 -      if(! strstr($b['postopts'],'wppost')) {
 +      if(! strstr($b['postopts'],'wppost'))
                return;
 -      }
  
 -      if($b['parent'] != $b['id']) {
 +      if($b['parent'] != $b['id'])
                return;
 -      }
  
 -      // Dont't post if the post doesn't belong to us.
 -      // This is a check for forum postings
 -      $self = dba::selectFirst('contact', ['id'], ['uid' => $b['uid'], 'self' => true]);
 -      if ($b['contact-id'] != $self['id']) {
 -              return;
 -      }
  
 -      $wp_username = xmlify(PConfig::get($b['uid'],'wppost','wp_username'));
 -      $wp_password = xmlify(PConfig::get($b['uid'],'wppost','wp_password'));
 -      $wp_blog = PConfig::get($b['uid'],'wppost','wp_blog');
 -      $wp_backlink_text = PConfig::get($b['uid'],'wppost','wp_backlink_text');
 +      $wp_username = xmlify(get_pconfig($b['uid'],'wppost','wp_username'));
 +      $wp_password = xmlify(get_pconfig($b['uid'],'wppost','wp_password'));
 +      $wp_blog = get_pconfig($b['uid'],'wppost','wp_blog');
 +      $wp_backlink_text = get_pconfig($b['uid'],'wppost','wp_backlink_text');
        if ($wp_backlink_text == '') {
-               $wp_backlink_text = t('Read the orig­i­nal post and com­ment stream on Friendica');
+               $wp_backlink_text = L10n::t('Read the orig­i­nal post and com­ment stream on Friendica');
        }
  
-       if($wp_username && $wp_password && $wp_blog) {
-               require_once('include/bbcode.php');
-               require_once('include/html2plain.php');
-               require_once('include/plaintext.php');
+       if ($wp_username && $wp_password && $wp_blog) {
+               require_once 'include/html2plain.php';
  
                $wptitle = trim($b['title']);
  
diff --cc xmpp/xmpp.php
index 076b7b130f7852a27c15ef70ea4ea52e58186dba,bd5adb574e2714513e779c867569a98e2a9f272c..422c6277de9117d91ecf295bf7b7f3bec2543432
@@@ -5,35 -5,45 +5,43 @@@
   * Version: 0.1
   * Author: Michael Vogel <https://pirati.ca/profile/heluecht>
   */
- function xmpp_install() {
-       register_hook('plugin_settings', 'addon/xmpp/xmpp.php', 'xmpp_plugin_settings');
-       register_hook('plugin_settings_post', 'addon/xmpp/xmpp.php', 'xmpp_plugin_settings_post');
-       register_hook('page_end', 'addon/xmpp/xmpp.php', 'xmpp_script');
-       register_hook('logged_in', 'addon/xmpp/xmpp.php', 'xmpp_login');
+ use Friendica\App;
+ use Friendica\Core\Addon;
+ use Friendica\Core\Config;
+ use Friendica\Core\L10n;
+ use Friendica\Core\PConfig;
+ function xmpp_install()
+ {
+       Addon::registerHook('addon_settings', 'addon/xmpp/xmpp.php', 'xmpp_addon_settings');
+       Addon::registerHook('addon_settings_post', 'addon/xmpp/xmpp.php', 'xmpp_addon_settings_post');
+       Addon::registerHook('page_end', 'addon/xmpp/xmpp.php', 'xmpp_script');
+       Addon::registerHook('logged_in', 'addon/xmpp/xmpp.php', 'xmpp_login');
  }
  
- function xmpp_uninstall() {
-       unregister_hook('plugin_settings', 'addon/xmpp/xmpp.php', 'xmpp_plugin_settings');
-       unregister_hook('plugin_settings_post', 'addon/xmpp/xmpp.php', 'xmpp_plugin_settings_post');
-       unregister_hook('page_end', 'addon/xmpp/xmpp.php', 'xmpp_script');
-       unregister_hook('logged_in', 'addon/xmpp/xmpp.php', 'xmpp_login');
+ function xmpp_uninstall()
+ {
+       Addon::unregisterHook('addon_settings', 'addon/xmpp/xmpp.php', 'xmpp_addon_settings');
+       Addon::unregisterHook('addon_settings_post', 'addon/xmpp/xmpp.php', 'xmpp_addon_settings_post');
+       Addon::unregisterHook('page_end', 'addon/xmpp/xmpp.php', 'xmpp_script');
+       Addon::unregisterHook('logged_in', 'addon/xmpp/xmpp.php', 'xmpp_login');
  }
  
- function xmpp_plugin_settings_post($a,$post) {
-       if(! local_user() || (! x($_POST,'xmpp-settings-submit')))
+ function xmpp_addon_settings_post()
+ {
+       if (!local_user() || (!x($_POST, 'xmpp-settings-submit'))) {
                return;
 -      }
 -      PConfig::set(local_user(), 'xmpp', 'enabled', intval($_POST['xmpp_enabled']));
 -      PConfig::set(local_user(), 'xmpp', 'individual', intval($_POST['xmpp_individual']));
 -      PConfig::set(local_user(), 'xmpp', 'bosh_proxy', $_POST['xmpp_bosh_proxy']);
 +      set_pconfig(local_user(),'xmpp','enabled',intval($_POST['xmpp_enabled']));
 +      set_pconfig(local_user(),'xmpp','individual',intval($_POST['xmpp_individual']));
 +      set_pconfig(local_user(),'xmpp','bosh_proxy',$_POST['xmpp_bosh_proxy']);
  
-       info( t('XMPP settings updated.') . EOL);
+       info(L10n::t('XMPP settings updated.') . EOL);
  }
  
- function xmpp_plugin_settings(&$a,&$s) {
-       if(! local_user())
+ function xmpp_addon_settings(App $a, &$s)
+ {
+       if (!local_user()) {
                return;
 -      }
  
        /* Add our stylesheet to the xmpp so we can make our settings look nice */
  
  
        /* provide a submit button */
  
-       $s .= '<div class="settings-submit-wrapper" ><input type="submit" name="xmpp-settings-submit" class="settings-submit" value="' . t('Save Settings') . '" /></div></div>';
+       $s .= '<div class="settings-submit-wrapper" ><input type="submit" name="xmpp-settings-submit" class="settings-submit" value="' . L10n::t('Save Settings') . '" /></div></div>';
  }
  
 -function xmpp_login()
 -{
 +function xmpp_login($a,$b) {
        if (!$_SESSION["allow_api"]) {
 -              $password = random_string(16);
 -              PConfig::set(local_user(), "xmpp", "password", $password);
 +              $password = substr(random_string(),0,16);
 +              set_pconfig(local_user(), "xmpp", "password", $password);
        }
  }
  
- function xmpp_plugin_admin(&$a, &$o){
+ function xmpp_addon_admin(App $a, &$o)
+ {
        $t = get_markup_template("admin.tpl", "addon/xmpp/");
  
-       $o = replace_macros($t, array(
-               '$submit' => t('Save Settings'),
-               '$bosh_proxy'       => array('bosh_proxy', t('Jabber BOSH host'),            get_config('xmpp', 'bosh_proxy'), ''),
-               '$central_userbase' => array('central_userbase', t('Use central userbase'), get_config('xmpp', 'central_userbase'), t('If enabled, users will automatically login to an ejabberd server that has to be installed on this machine with synchronized credentials via the "auth_ejabberd.php" script.')),
-       ));
+       $o = replace_macros($t, [
+               '$submit' => L10n::t('Save Settings'),
+               '$bosh_proxy' => ['bosh_proxy', L10n::t('Jabber BOSH host'), Config::get('xmpp', 'bosh_proxy'), ''],
+               '$central_userbase' => ['central_userbase', L10n::t('Use central userbase'), Config::get('xmpp', 'central_userbase'), L10n::t('If enabled, users will automatically login to an ejabberd server that has to be installed on this machine with synchronized credentials via the "auth_ejabberd.php" script.')],
+       ]);
  }
  
- function xmpp_plugin_admin_post(&$a){
-       $bosh_proxy       = ((x($_POST,'bosh_proxy')) ?       trim($_POST['bosh_proxy']) : '');
-       $central_userbase = ((x($_POST,'central_userbase')) ? intval($_POST['central_userbase']) : false);
-       set_config('xmpp','bosh_proxy',$bosh_proxy);
-       set_config('xmpp','central_userbase',$central_userbase);
-       info( t('Settings updated.'). EOL );
+ function xmpp_addon_admin_post()
+ {
+       $bosh_proxy = ((x($_POST, 'bosh_proxy')) ? trim($_POST['bosh_proxy']) : '');
+       $central_userbase = ((x($_POST, 'central_userbase')) ? intval($_POST['central_userbase']) : false);
+       Config::set('xmpp', 'bosh_proxy', $bosh_proxy);
+       Config::set('xmpp', 'central_userbase', $central_userbase);
+       info(L10n::t('Settings updated.') . EOL);
  }
  
 -function xmpp_script(App $a)
 -{
 -      xmpp_converse($a);
 +function xmpp_script(&$a,&$s) {
 +      xmpp_converse($a,$s);
  }
  
 -function xmpp_converse(App $a)
 -{
 -      if (!local_user()) {
 +function xmpp_converse(&$a,&$s) {
 +      if (!local_user())
                return;
 -      }
  
 -      if ($_GET["mode"] == "minimal") {
 +      if ($_GET["mode"] == "minimal")
                return;
 -      }
  
 -      if ($a->is_mobile || $a->is_tablet) {
 +      if ($a->is_mobile || $a->is_tablet)
                return;
 -      }
  
 -      if (!PConfig::get(local_user(), "xmpp", "enabled")) {
 +      if (!get_pconfig(local_user(),"xmpp","enabled"))
                return;
 -      }
  
 -      if (in_array($a->query_string, ["admin/federation/"])) {
 +      if (in_array($a->query_string, array("admin/federation/")))
                return;
 -      }
  
 -      $a->page['htmlhead'] .= '<link type="text/css" rel="stylesheet" media="screen" href="addon/xmpp/converse/css/converse.css" />' . "\n";
 -      $a->page['htmlhead'] .= '<script src="addon/xmpp/converse/builds/converse.min.js"></script>' . "\n";
 +      $a->page['htmlhead'] .= '<link type="text/css" rel="stylesheet" media="screen" href="addon/xmpp/converse/css/converse.css" />'."\n";
 +      $a->page['htmlhead'] .= '<script src="addon/xmpp/converse/builds/converse.min.js"></script>'."\n";
  
 -      if (Config::get("xmpp", "central_userbase") && !PConfig::get(local_user(), "xmpp", "individual")) {
 -              $bosh_proxy = Config::get("xmpp", "bosh_proxy");
 +      if (get_config("xmpp", "central_userbase") && !get_pconfig(local_user(),"xmpp","individual")) {
 +              $bosh_proxy = get_config("xmpp", "bosh_proxy");
  
 -              $password = PConfig::get(local_user(), "xmpp", "password", '', true);
 +              $password = get_pconfig(local_user(), "xmpp", "password");
  
                if ($password == "") {
 -                      $password = random_string(16);
 -                      PConfig::set(local_user(), "xmpp", "password", $password);
 +                      $password = substr(random_string(),0,16);
 +                      set_pconfig(local_user(), "xmpp", "password", $password);
                }
  
 -              $jid = $a->user["nickname"] . "@" . $a->get_hostname() . "/converse-" . random_string(5);
 +              $jid = $a->user["nickname"]."@".$a->get_hostname()."/converse-".substr(random_string(),0,5);;
  
                $auto_login = "auto_login: true,
                        authentication: 'login',
index beea2619c8f858e98195bcacca1fbf59934a4003,c5cd12acf5de8e34cf4eac31ff312ee1a178ae87..10155b95c0fdb26ac072f0e97a1669a61a2b968c
@@@ -49,10 -50,10 +50,10 @@@ function yourls_addon_settings(&$a,&$s
  
  
  
 -      $yourls_ssl = Config::get('yourls', 'ssl1');
 +      $yourls_ssl = get_config('yourls', 'ssl1');
  
        $s .= '<span id="settings_yourls_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_yourls_expanded\'); openClose(\'settings_yourls_inflated\');">';
-       $s .= '<h3>' . t('YourLS') . '</h3>';
+       $s .= '<h3>' . L10n::t('YourLS') . '</h3>';
        $s .= '</span>';
        $s .= '<div id="settings_yourls_expanded" class="settings-block" style="display: none;">';
        $s .= '<span class="fakelink" onclick="openClose(\'settings_yourls_expanded\'); openClose(\'settings_yourls_inflated\');">';