From: Tobias Diekershoff Date: Fri, 23 Mar 2018 07:00:37 +0000 (+0100) Subject: Merge branch '3.6-rc' X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=39dd3dffe07efd69fa1ac6d0bd243c7fc0e3a66f;p=friendica-addons.git Merge branch '3.6-rc' --- 39dd3dffe07efd69fa1ac6d0bd243c7fc0e3a66f diff --cc blackout/blackout.php index 3678969e,28e5567f..ec7215ab --- a/blackout/blackout.php +++ b/blackout/blackout.php @@@ -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
(YYYY-MM-DD hh:mm)", $mystart, "format is YYYY year, MM month, DD day, hh hour and mm minute"), - '$enddate' => array("enddate", "End of the Blackout
(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
(YYYY-MM-DD hh:mm)", $mystart, "format is YYYY year, MM month, DD day, hh hour and mm minute"], + '$enddate' => ["enddate", "End of the Blackout
(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) { diff --cc blockem/blockem.php index 223a1990,45272e00..6f2b6d89 --- a/blockem/blockem.php +++ b/blockem/blockem.php @@@ -1,41 -1,39 +1,39 @@@ - * + * */ - - 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); } diff --cc blogger/blogger.php index 892e8a45,30c450bd..97d488bc --- a/blogger/blogger.php +++ b/blogger/blogger.php @@@ -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'] .= '' . "\r\n"; + $a->page['htmlhead'] .= '' . "\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 .= ''; - $s .= '

'. t('Blogger Export').'

'; - $s .= '
'; - $s .= ''; - + /* Add some HTML to the existing form */ + $s .= ''; + $s .= '

'. L10n::t('Blogger Export').'

'; + $s .= '
'; + $s .= ''; } - 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 = '' . (($b['title']) ? $b['title'] : t('Post from Friendica')) . ''; - $post = $title . bbcode($b['body']); + if ($bl_username && $bl_password && $bl_blog) { + $title = '' . (($b['title']) ? $b['title'] : L10n::t('Post from Friendica')) . ''; + $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); + } } - diff --cc buffer/buffer.php index ca33708c,bb1d8482..9b0979ee --- a/buffer/buffer.php +++ b/buffer/buffer.php @@@ -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 .= '
' - . t('Post to Buffer') . '
'; + . L10n::t('Post to Buffer') . ''; } } @@@ -136,12 -146,12 +146,12 @@@ function buffer_settings(&$a,&$s) $s .= ''; $s .= ''; } } diff --cc forumdirectory/forumdirectory.php index a709c9b1,a72c45ba..751384a8 --- a/forumdirectory/forumdirectory.php +++ b/forumdirectory/forumdirectory.php @@@ -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) ? '

' . t('Finding: ') . "'" . $search . "'" . '

' : ""), - '$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) ? '

' . L10n::t('Finding: ') . "'" . $search . "'" . '

' : ""), + '$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'] . '
' : ''); $details = ''; diff --cc fromapp/fromapp.php index de858744,afdb087b..a3944d6d --- a/fromapp/fromapp.php +++ b/fromapp/fromapp.php @@@ -79,28 -79,32 +79,27 @@@ function fromapp_settings(&$a, &$s /* provide a submit button */ - $s .= '
'; - + $s .= '
'; } -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; + } diff --cc fromgplus/fromgplus.php index 097bac18,b8d9511a..b2c9b97f --- a/fromgplus/fromgplus.php +++ b/fromgplus/fromgplus.php @@@ -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 .= ''; - $s .= '

'. t('Google+ Mirror').'

'; + $s .= '

'. L10n::t('Google+ Mirror').'

'; $s .= '
'; $s .= '
'; - - $s .= '
'; - $s .= ''; - $s .= ''; - $s .= '
'; - - $s .= '
'; - $s .= ''; - + $s .= '

' . L10n::t('Body for "new status message"') . '

'; + $s .= '

' . htmlentities('key=' . $key . '&type=status&msg=<<<{{Message}}>>>&date=<<<{{UpdatedAt}}>>>&url=<<<{{PageUrl}}>>>') . '

'; + $s .= '

' . L10n::t('Body for "new photo upload"') . '

'; + $s .= '

' . htmlentities('key=' . $key . '&type=photo&link=<<<{{Link}}>>>&image=<<<{{ImageSource}}>>>&msg=<<<{{Caption}}>>>&date=<<<{{CreatedAt}}>>>&url=<<<{{PageUrl}}>>>') . '

'; + $s .= '

' . L10n::t('Body for "new link post"') . '

'; + $s .= '

' . htmlentities('key=' . $key . '&type=link&link=<<<{{Link}}>>>&title=<<<{{Title}}>>>&msg=<<<{{Message}}>>>&description=<<<{{Description}}>>>&date=<<<{{CreatedAt}}>>>&url=<<<{{PageUrl}}>>>') . '

'; + $s .= '
'; + + $s .= '
'; + $s .= ''; + $s .= ''; + $s .= '
'; + + $s .= '
'; + $s .= ''; } -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; } diff --cc ijpost/ijpost.php index 3e57610a,8d529085..091edec3 --- a/ijpost/ijpost.php +++ b/ijpost/ijpost.php @@@ -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 .= '
' - . t('Post to Insanejournal') . '
'; + . L10n::t('Post to Insanejournal') . ''; } } diff --cc irc/irc.php index 0ac7be37,6aeacbe6..e8dd92f4 --- a/irc/irc.php +++ b/irc/irc.php @@@ -29,17 -33,17 +33,17 @@@ function irc_addon_settings(&$a,&$s) // $a->page['htmlhead'] .= '' . "\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'] .= '

' . t('Popular Channels') . '

'; } } @@@ -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 076b7b13,bd5adb57..422c6277 --- a/xmpp/xmpp.php +++ b/xmpp/xmpp.php @@@ -5,35 -5,45 +5,43 @@@ * Version: 0.1 * Author: Michael Vogel */ - - 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 */ @@@ -79,69 -89,78 +87,70 @@@ /* provide a submit button */ - $s .= '
'; - + $s .= '
'; } -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'] .= '' . "\n"; - $a->page['htmlhead'] .= '' . "\n"; + $a->page['htmlhead'] .= ''."\n"; + $a->page['htmlhead'] .= ''."\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', diff --cc yourls/yourls.php index beea2619,c5cd12ac..10155b95 --- a/yourls/yourls.php +++ b/yourls/yourls.php @@@ -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 .= ''; - $s .= '

' . t('YourLS') . '

'; + $s .= '

' . L10n::t('YourLS') . '

'; $s .= '
'; $s .= '