- added more type-hints
- cleaned up some files (curly braces, spaces)
This commit is contained in:
Roland Häder 2022-06-23 07:16:22 +02:00
parent a1e17968d1
commit 04df7f6e05
Signed by: roland
GPG key ID: C82EDE5DDFA0BA77
74 changed files with 603 additions and 529 deletions

View file

@ -117,7 +117,7 @@ function birdavatar_addon_settings_post(App $a, &$s)
* @param $a array * @param $a array
* @param &$b array * @param &$b array
*/ */
function birdavatar_lookup(App $a, &$b) function birdavatar_lookup(App $a, array &$b)
{ {
$user = DBA::selectFirst('user', ['uid'], ['email' => $b['email']]); $user = DBA::selectFirst('user', ['uid'], ['email' => $b['email']]);
if (DBA::isResult($user)) { if (DBA::isResult($user)) {

View file

@ -44,6 +44,7 @@
* THE SOFTWARE. * THE SOFTWARE.
*/ */
use Friendica\App;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\Core\Logger; use Friendica\Core\Logger;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
@ -54,7 +55,8 @@ function blackout_install() {
Hook::register('page_header', 'addon/blackout/blackout.php', 'blackout_redirect'); Hook::register('page_header', 'addon/blackout/blackout.php', 'blackout_redirect');
} }
function blackout_redirect ($a, $b) { function blackout_redirect (App $a, $b)
{
// if we have a logged in user, don't throw her out // if we have a logged in user, don't throw her out
if (local_user()) { if (local_user()) {
return true; return true;
@ -67,20 +69,21 @@ function blackout_redirect ($a, $b) {
$now = time(); $now = time();
$date1 = DateTime::createFromFormat('Y-m-d G:i', $mystart); $date1 = DateTime::createFromFormat('Y-m-d G:i', $mystart);
$date2 = DateTime::createFromFormat('Y-m-d G:i', $myend); $date2 = DateTime::createFromFormat('Y-m-d G:i', $myend);
if ( $date1 && $date2 ) { if ($date1 && $date2) {
$date1 = DateTime::createFromFormat('Y-m-d G:i', $mystart)->format('U'); $date1 = DateTime::createFromFormat('Y-m-d G:i', $mystart)->format('U');
$date2 = DateTime::createFromFormat('Y-m-d G:i', $myend)->format('U'); $date2 = DateTime::createFromFormat('Y-m-d G:i', $myend)->format('U');
} else { } else {
$date1 = 0; $date1 = 0;
$date2 = 0; $date2 = 0;
} }
if (( $date1 <= $now ) && ( $now <= $date2 )) { if (( $date1 <= $now ) && ( $now <= $date2 )) {
Logger::notice('redirecting user to blackout page'); Logger::notice('redirecting user to blackout page');
System::externalRedirect($myurl); System::externalRedirect($myurl);
} }
} }
function blackout_addon_admin(&$a, &$o) { function blackout_addon_admin(App $a, &$o) {
$mystart = DI::config()->get('blackout','begindate'); $mystart = DI::config()->get('blackout','begindate');
if (! is_string($mystart)) { $mystart = 'YYYY-MM-DD hh:mm'; } if (! is_string($mystart)) { $mystart = 'YYYY-MM-DD hh:mm'; }
$myend = DI::config()->get('blackout','enddate'); $myend = DI::config()->get('blackout','enddate');
@ -107,7 +110,7 @@ function blackout_addon_admin(&$a, &$o) {
'$aboutredirect' => DI::l10n()->t("<strong>Note</strong>: The redirect will be active from the moment you press the submit button. Users currently logged in will <strong>not</strong> be thrown out but can't login again after logging out while the blackout is still in place."), '$aboutredirect' => DI::l10n()->t("<strong>Note</strong>: The redirect will be active from the moment you press the submit button. Users currently logged in will <strong>not</strong> be thrown out but can't login again after logging out while the blackout is still in place."),
]); ]);
} }
function blackout_addon_admin_post (&$a) { function blackout_addon_admin_post (App $a) {
$begindate = trim($_POST['startdate']); $begindate = trim($_POST['startdate']);
$enddate = trim($_POST['enddate']); $enddate = trim($_POST['enddate']);
$url = trim($_POST['rurl']); $url = trim($_POST['rurl']);

View file

@ -19,12 +19,14 @@ use Friendica\Network\HTTPException\ForbiddenException;
require_once __DIR__ . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php'; require_once __DIR__ . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
function blockbot_install() { function blockbot_install()
{
Hook::register('init_1', __FILE__, 'blockbot_init_1'); Hook::register('init_1', __FILE__, 'blockbot_init_1');
} }
function blockbot_addon_admin(&$a, &$o) { function blockbot_addon_admin(App $a, &$o)
$t = Renderer::getMarkupTemplate("admin.tpl", "addon/blockbot/"); {
$t = Renderer::getMarkupTemplate('admin.tpl', 'addon/blockbot/');
$o = Renderer::replaceMacros($t, [ $o = Renderer::replaceMacros($t, [
'$submit' => DI::l10n()->t('Save Settings'), '$submit' => DI::l10n()->t('Save Settings'),
@ -34,13 +36,15 @@ function blockbot_addon_admin(&$a, &$o) {
]); ]);
} }
function blockbot_addon_admin_post(&$a) { function blockbot_addon_admin_post(App $a)
{
DI::config()->set('blockbot', 'good_crawlers', $_POST['good_crawlers'] ?? false); DI::config()->set('blockbot', 'good_crawlers', $_POST['good_crawlers'] ?? false);
DI::config()->set('blockbot', 'block_gab', $_POST['block_gab'] ?? false); DI::config()->set('blockbot', 'block_gab', $_POST['block_gab'] ?? false);
DI::config()->set('blockbot', 'training', $_POST['training'] ?? false); DI::config()->set('blockbot', 'training', $_POST['training'] ?? false);
} }
function blockbot_init_1(App $a) { function blockbot_init_1(App $a)
{
if (empty($_SERVER['HTTP_USER_AGENT'])) { if (empty($_SERVER['HTTP_USER_AGENT'])) {
return; return;
} }

View file

@ -15,7 +15,7 @@ function buglink_install()
Hook::register('page_end', 'addon/buglink/buglink.php', 'buglink_active'); Hook::register('page_end', 'addon/buglink/buglink.php', 'buglink_active');
} }
function buglink_active(App $a, &$b) function buglink_active(App $a, array &$b)
{ {
$b .= '<div id="buglink_wrapper" style="position: fixed; bottom: 5px; left: 5px;"><a href="https://github.com/friendica/friendica/issues" target="_blank" rel="noopener noreferrer" title="' . DI::l10n()->t('Report Bug') . '"><img src="addon/buglink/bug-x.gif" alt="' . DI::l10n()->t('Report Bug') . '" /></a></div>'; $b .= '<div id="buglink_wrapper" style="position: fixed; bottom: 5px; left: 5px;"><a href="https://github.com/friendica/friendica/issues" target="_blank" rel="noopener noreferrer" title="' . DI::l10n()->t('Report Bug') . '"><img src="addon/buglink/bug-x.gif" alt="' . DI::l10n()->t('Report Bug') . '" /></a></div>';
} }

View file

@ -5,6 +5,8 @@
* Version: 1.0 * Version: 1.0
* Author: Mike Macgirvin <http://macgirvin.com/profile/mike> * Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
*/ */
use Friendica\App;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\DI; use Friendica\DI;
@ -12,19 +14,19 @@ function calc_install() {
Hook::register('app_menu', 'addon/calc/calc.php', 'calc_app_menu'); Hook::register('app_menu', 'addon/calc/calc.php', 'calc_app_menu');
} }
function calc_app_menu($a,&$b) { function calc_app_menu(App $a, array &$b)
{
$b['app_menu'][] = '<div class="app-title"><a href="calc">Calculator</a></div>'; $b['app_menu'][] = '<div class="app-title"><a href="calc">Calculator</a></div>';
} }
function calc_module() {} function calc_module()
{
}
function calc_init(App $a)
{
$x = <<< EOT
function calc_init($a) {
$x = <<< EOT
<script language="JavaScript"> <script language="JavaScript">
/************************************** /**************************************
@ -354,6 +356,5 @@ $o .= <<< EOT
</td></tr></tbody></table> </td></tr></tbody></table>
EOT; EOT;
return $o; return $o;
} }

View file

@ -118,7 +118,7 @@ function catavatar_addon_settings_post(App $a, &$s)
* @param $a array * @param $a array
* @param &$b array * @param &$b array
*/ */
function catavatar_lookup(App $a, &$b) function catavatar_lookup(App $a, array &$b)
{ {
$user = DBA::selectFirst('user', ['uid'], ['email' => $b['email']]); $user = DBA::selectFirst('user', ['uid'], ['email' => $b['email']]);
if (DBA::isResult($user)) { if (DBA::isResult($user)) {

View file

@ -5,13 +5,16 @@
* Version: 1.0 * Version: 1.0
* Author: Mike Macgirvin <http://macgirvin.com/profile/mike> * Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
*/ */
use Friendica\App;
use Friendica\Core\Hook; use Friendica\Core\Hook;
function convert_install() { function convert_install() {
Hook::register('app_menu', 'addon/convert/convert.php', 'convert_app_menu'); Hook::register('app_menu', 'addon/convert/convert.php', 'convert_app_menu');
} }
function convert_app_menu($a,&$b) { function convert_app_menu(App $a, array &$b)
{
$b['app_menu'][] = '<div class="app-title"><a href="convert">Units Conversion</a></div>'; $b['app_menu'][] = '<div class="app-title"><a href="convert">Units Conversion</a></div>';
} }

View file

@ -83,7 +83,7 @@ function cookienotice_addon_admin_post(App $a)
* *
* @return void * @return void
*/ */
function cookienotice_page_content_top(App $a, &$b) function cookienotice_page_content_top(App $a, array &$b)
{ {
DI::page()->registerStylesheet(__DIR__ . '/cookienotice.css'); DI::page()->registerStylesheet(__DIR__ . '/cookienotice.css');
DI::page()->registerFooterScript(__DIR__ . '/cookienotice.js'); DI::page()->registerFooterScript(__DIR__ . '/cookienotice.js');
@ -99,7 +99,7 @@ function cookienotice_page_content_top(App $a, &$b)
* *
* @return void * @return void
*/ */
function cookienotice_page_end(App $a, &$b) function cookienotice_page_end(App $a, array &$b)
{ {
$text = (string)DI::config()->get('cookienotice', 'text', DI::l10n()->t('This website uses cookies to recognize revisiting and logged in users. You accept the usage of these cookies by continue browsing this website.')); $text = (string)DI::config()->get('cookienotice', 'text', DI::l10n()->t('This website uses cookies to recognize revisiting and logged in users. You accept the usage of these cookies by continue browsing this website.'));
$oktext = (string)DI::config()->get('cookienotice', 'oktext', DI::l10n()->t('OK')); $oktext = (string)DI::config()->get('cookienotice', 'oktext', DI::l10n()->t('OK'));

View file

@ -87,7 +87,7 @@ function getWeather($loc, $units = 'metric', $lang = 'en', $appid = '', $cacheti
return $r; return $r;
} }
function curweather_network_mod_init(App $a, &$b) function curweather_network_mod_init(App $a, array &$b)
{ {
if (!intval(DI::pConfig()->get(local_user(), 'curweather', 'curweather_enable'))) { if (!intval(DI::pConfig()->get(local_user(), 'curweather', 'curweather_enable'))) {
return; return;

View file

@ -118,7 +118,7 @@ function diaspora_settings(App $a, array &$data)
} }
function diaspora_settings_post(App $a, &$b) function diaspora_settings_post(App $a, array &$b)
{ {
if (!empty($_POST['diaspora-submit'])) { if (!empty($_POST['diaspora-submit'])) {
DI::pConfig()->set(local_user(),'diaspora', 'post' , intval($_POST['enabled'])); DI::pConfig()->set(local_user(),'diaspora', 'post' , intval($_POST['enabled']));
@ -137,7 +137,7 @@ function diaspora_settings_post(App $a, &$b)
} }
} }
function diaspora_hook_fork(&$a, &$b) function diaspora_hook_fork(App $a, array &$b)
{ {
if ($b['name'] != 'notifier_normal') { if ($b['name'] != 'notifier_normal') {
return; return;

View file

@ -21,7 +21,7 @@ function fromapp_install()
Logger::notice("installed fromapp"); Logger::notice("installed fromapp");
} }
function fromapp_settings_post($a, $post) function fromapp_settings_post(App $a, $post)
{ {
if (!local_user() || empty($_POST['fromapp-submit'])) { if (!local_user() || empty($_POST['fromapp-submit'])) {
return; return;
@ -53,7 +53,7 @@ function fromapp_settings(App &$a, array &$data)
]; ];
} }
function fromapp_post_hook(&$a, &$item) function fromapp_post_hook(App $a, &$item)
{ {
if (! local_user()) { if (! local_user()) {
return; return;

View file

@ -6,6 +6,7 @@
* Author: Michael Vogel <https://pirati.ca/profile/heluecht> * Author: Michael Vogel <https://pirati.ca/profile/heluecht>
*/ */
use Friendica\App;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\Core\Logger; use Friendica\Core\Logger;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
@ -71,12 +72,12 @@ function geocoordinates_resolve_item(&$item)
DI::cache()->set("geocoordinates:".$language.":".$coords[0]."-".$coords[1], $item["location"]); DI::cache()->set("geocoordinates:".$language.":".$coords[0]."-".$coords[1], $item["location"]);
} }
function geocoordinates_post_hook($a, &$item) function geocoordinates_post_hook(App $a, &$item)
{ {
geocoordinates_resolve_item($item); geocoordinates_resolve_item($item);
} }
function geocoordinates_addon_admin(&$a, &$o) function geocoordinates_addon_admin(App $a, &$o)
{ {
$t = Renderer::getMarkupTemplate("admin.tpl", "addon/geocoordinates/"); $t = Renderer::getMarkupTemplate("admin.tpl", "addon/geocoordinates/");
@ -88,7 +89,7 @@ function geocoordinates_addon_admin(&$a, &$o)
]); ]);
} }
function geocoordinates_addon_admin_post(&$a) function geocoordinates_addon_admin_post(App $a)
{ {
$api_key = trim($_POST['api_key'] ?? ''); $api_key = trim($_POST['api_key'] ?? '');
DI::config()->set('geocoordinates', 'api_key', $api_key); DI::config()->set('geocoordinates', 'api_key', $api_key);

View file

@ -15,8 +15,8 @@ use Friendica\Core\Renderer;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\Notification; use Friendica\Model\Notification;
function gnot_install() { function gnot_install()
{
Hook::register('addon_settings', 'addon/gnot/gnot.php', 'gnot_settings'); Hook::register('addon_settings', 'addon/gnot/gnot.php', 'gnot_settings');
Hook::register('addon_settings_post', 'addon/gnot/gnot.php', 'gnot_settings_post'); Hook::register('addon_settings_post', 'addon/gnot/gnot.php', 'gnot_settings_post');
Hook::register('enotify_mail', 'addon/gnot/gnot.php', 'gnot_enotify_mail'); Hook::register('enotify_mail', 'addon/gnot/gnot.php', 'gnot_enotify_mail');
@ -25,31 +25,22 @@ function gnot_install() {
} }
/** /**
*
* Callback from the settings post function. * Callback from the settings post function.
* $post contains the $_POST array. * $post contains the $_POST array.
* We will make sure we've got a valid user account * We will make sure we've got a valid user account
* and if so set our configuration setting for this person. * and if so set our configuration setting for this person.
*
*/ */
function gnot_settings_post(App $a, $post) {
function gnot_settings_post($a,$post) {
if(! local_user() || empty($_POST['gnot-submit'])) if(! local_user() || empty($_POST['gnot-submit']))
return; return;
DI::pConfig()->set(local_user(),'gnot','enable',intval($_POST['gnot'])); DI::pConfig()->set(local_user(),'gnot','enable',intval($_POST['gnot']));
} }
/** /**
*
* Called from the Addon Setting form. * Called from the Addon Setting form.
* Add our own settings info to the page. * Add our own settings info to the page.
*
*/ */
function gnot_settings(App &$a, array &$data) function gnot_settings(App &$a, array &$data)
{ {
if (!local_user()) { if (!local_user()) {
@ -71,10 +62,13 @@ function gnot_settings(App &$a, array &$data)
]; ];
} }
function gnot_enotify_mail(App $a, array &$b)
function gnot_enotify_mail(&$a,&$b) { {
if((! $b['uid']) || (! intval(DI::pConfig()->get($b['uid'], 'gnot','enable')))) if ((!$b['uid']) || (! intval(DI::pConfig()->get($b['uid'], 'gnot','enable')))) {
return; return;
if($b['type'] == Notification\Type::COMMENT) }
if ($b['type'] == Notification\Type::COMMENT) {
$b['subject'] = DI::l10n()->t('[Friendica:Notify] Comment to conversation #%d', $b['parent']); $b['subject'] = DI::l10n()->t('[Friendica:Notify] Comment to conversation #%d', $b['parent']);
}
} }

View file

@ -6,6 +6,8 @@
* Author: Michael Vogel <https://pirati.ca/profile/heluecht> * Author: Michael Vogel <https://pirati.ca/profile/heluecht>
* *
*/ */
use Friendica\App;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\Core\Logger; use Friendica\Core\Logger;
@ -13,27 +15,26 @@ function googlemaps_install()
{ {
Hook::register('render_location', 'addon/googlemaps/googlemaps.php', 'googlemaps_location'); Hook::register('render_location', 'addon/googlemaps/googlemaps.php', 'googlemaps_location');
Logger::notice("installed googlemaps"); Logger::notice('installed googlemaps');
} }
function googlemaps_location($a, &$item) function googlemaps_location(App $a, &$item)
{ {
if (!(strlen($item['location']) || strlen($item['coord']))) {
if(! (strlen($item['location']) || strlen($item['coord']))) {
return; return;
} }
if ($item['coord'] != ""){ if ($item['coord'] != '') {
$target = "http://maps.google.com/?q=".urlencode($item['coord']); $target = 'http://maps.google.com/?q=' . urlencode($item['coord']);
} else { } else {
$target = "http://maps.google.com/?q=".urlencode($item['location']); $target = 'http://maps.google.com/?q=' . urlencode($item['location']);
} }
if ($item['location'] != "") { if ($item['location'] != '') {
$title = $item['location']; $title = $item['location'];
} else { } else {
$title = $item['coord']; $title = $item['coord'];
} }
$item['html'] = '<a target="map" title="'.$title.'" href= "'.$target.'">'.$title.'</a>'; $item['html'] = '<a target="map" title="' . $title . '" href= "' . $target . '">' . $title . '</a>';
} }

View file

@ -37,7 +37,8 @@ function gravatar_load_config(App $a, ConfigFileLoader $loader)
* @param $a array * @param $a array
* @param &$b array * @param &$b array
*/ */
function gravatar_lookup($a, &$b) { function gravatar_lookup(App $a, array &$b)
{
$default_avatar = DI::config()->get('gravatar', 'default_avatar'); $default_avatar = DI::config()->get('gravatar', 'default_avatar');
$rating = DI::config()->get('gravatar', 'rating'); $rating = DI::config()->get('gravatar', 'rating');
@ -61,17 +62,20 @@ function gravatar_lookup($a, &$b) {
/** /**
* Display admin settings for this addon * Display admin settings for this addon
*/ */
function gravatar_addon_admin (&$a, &$o) { function gravatar_addon_admin (App $a, &$o)
{
$t = Renderer::getMarkupTemplate( "admin.tpl", "addon/gravatar/" ); $t = Renderer::getMarkupTemplate( "admin.tpl", "addon/gravatar/" );
$default_avatar = DI::config()->get('gravatar', 'default_avatar'); $default_avatar = DI::config()->get('gravatar', 'default_avatar');
$rating = DI::config()->get('gravatar', 'rating'); $rating = DI::config()->get('gravatar', 'rating');
// set default values for first configuration // set default values for first configuration
if(! $default_avatar) if (!$default_avatar) {
$default_avatar = 'identicon'; // pseudo-random geometric pattern based on email hash $default_avatar = 'identicon'; // pseudo-random geometric pattern based on email hash
if(! $rating) }
if (!$rating) {
$rating = 'g'; // suitable for display on all websites with any audience type $rating = 'g'; // suitable for display on all websites with any audience type
}
// Available options for the select boxes // Available options for the select boxes
$default_avatars = [ $default_avatars = [
@ -105,7 +109,8 @@ function gravatar_addon_admin (&$a, &$o) {
/** /**
* Save admin settings * Save admin settings
*/ */
function gravatar_addon_admin_post (&$a) { function gravatar_addon_admin_post (App $a)
{
BaseModule::checkFormSecurityToken('gravatarsave'); BaseModule::checkFormSecurityToken('gravatarsave');
$default_avatar = trim($_POST['avatar'] ?? 'identicon'); $default_avatar = trim($_POST['avatar'] ?? 'identicon');

View file

@ -29,7 +29,7 @@ function group_text_install() {
* *
*/ */
function group_text_settings_post($a,$post) { function group_text_settings_post(App $a, $post) {
if(! local_user() || empty($_POST['group_text-submit'])) if(! local_user() || empty($_POST['group_text-submit']))
return; return;
DI::pConfig()->set(local_user(),'system','groupedit_image_limit',intval($_POST['group_text'])); DI::pConfig()->set(local_user(),'system','groupedit_image_limit',intval($_POST['group_text']));

View file

@ -16,7 +16,7 @@ function highlightjs_install()
Hook::register('footer', __FILE__, 'highlightjs_footer'); Hook::register('footer', __FILE__, 'highlightjs_footer');
} }
function highlightjs_head(App $a, &$b) function highlightjs_head(App $a, array &$b)
{ {
if ($a->getCurrentTheme() == 'frio') { if ($a->getCurrentTheme() == 'frio') {
$style = 'bootstrap'; $style = 'bootstrap';
@ -27,7 +27,7 @@ function highlightjs_head(App $a, &$b)
DI::page()->registerStylesheet(__DIR__ . '/asset/styles/' . $style . '.css'); DI::page()->registerStylesheet(__DIR__ . '/asset/styles/' . $style . '.css');
} }
function highlightjs_footer(App $a, &$b) function highlightjs_footer(App $a, array &$b)
{ {
DI::page()->registerFooterScript(__DIR__ . '/asset/highlight.pack.js'); DI::page()->registerFooterScript(__DIR__ . '/asset/highlight.pack.js');
DI::page()->registerFooterScript(__DIR__ . '/highlightjs.js'); DI::page()->registerFooterScript(__DIR__ . '/highlightjs.js');

View file

@ -73,7 +73,7 @@ function ijpost_settings(App &$a, array &$data)
]; ];
} }
function ijpost_settings_post(&$a, &$b) function ijpost_settings_post(App $a, array &$b)
{ {
if (!empty($_POST['ijpost-submit'])) { if (!empty($_POST['ijpost-submit'])) {
DI::pConfig()->set(local_user(), 'ijpost', 'post', intval($_POST['ijpost'])); DI::pConfig()->set(local_user(), 'ijpost', 'post', intval($_POST['ijpost']));
@ -83,7 +83,7 @@ function ijpost_settings_post(&$a, &$b)
} }
} }
function ijpost_post_local(&$a, &$b) function ijpost_post_local(App $a, array &$b)
{ {
// This can probably be changed to allow editing by pointing to a different API endpoint // This can probably be changed to allow editing by pointing to a different API endpoint
@ -118,7 +118,7 @@ function ijpost_post_local(&$a, &$b)
$b['postopts'] .= 'ijpost'; $b['postopts'] .= 'ijpost';
} }
function ijpost_send(&$a, &$b) function ijpost_send(App $a, array &$b)
{ {
if ($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) { if ($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) {
return; return;

View file

@ -7,6 +7,7 @@
* License: 3-clause BSD license * License: 3-clause BSD license
*/ */
use Friendica\App;
use Friendica\Content\Text\BBCode; use Friendica\Content\Text\BBCode;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\Core\Logger; use Friendica\Core\Logger;
@ -15,25 +16,32 @@ use Friendica\DI;
use Friendica\Core\Config\Util\ConfigFileLoader; use Friendica\Core\Config\Util\ConfigFileLoader;
use Friendica\Util\Proxy as ProxyUtils; use Friendica\Util\Proxy as ProxyUtils;
function impressum_install() { function impressum_install()
{
Hook::register('load_config', 'addon/impressum/impressum.php', 'impressum_load_config'); Hook::register('load_config', 'addon/impressum/impressum.php', 'impressum_load_config');
Hook::register('about_hook', 'addon/impressum/impressum.php', 'impressum_show'); Hook::register('about_hook', 'addon/impressum/impressum.php', 'impressum_show');
Hook::register('page_end', 'addon/impressum/impressum.php', 'impressum_footer'); Hook::register('page_end', 'addon/impressum/impressum.php', 'impressum_footer');
Logger::notice("installed impressum Addon"); Logger::notice("installed impressum Addon");
} }
function impressum_module() { function impressum_module()
{
} }
function impressum_content() {
function impressum_content()
{
DI::baseUrl()->redirect('friendica/'); DI::baseUrl()->redirect('friendica/');
} }
function obfuscate_email ($s) { function obfuscate_email (string $s): string
$s = str_replace('@','(at)',$s); {
$s = str_replace('.','(dot)',$s); $s = str_replace('@', '(at)', $s);
$s = str_replace('.', '(dot)', $s);
return $s; return $s;
} }
function impressum_footer($a, &$b) {
function impressum_footer(App $a, array &$b)
{
$text = ProxyUtils::proxifyHtml(BBCode::convert(DI::config()->get('impressum','footer_text'))); $text = ProxyUtils::proxifyHtml(BBCode::convert(DI::config()->get('impressum','footer_text')));
if (! $text == '') { if (! $text == '') {
@ -43,56 +51,65 @@ function impressum_footer($a, &$b) {
} }
} }
function impressum_load_config(\Friendica\App $a, ConfigFileLoader $loader) function impressum_load_config(App $a, ConfigFileLoader $loader)
{ {
$a->getConfigCache()->load($loader->loadAddonConfig('impressum')); $a->getConfigCache()->load($loader->loadAddonConfig('impressum'));
} }
function impressum_show($a,&$b) { function impressum_show(App $a, array &$b)
$b .= '<h3>'.DI::l10n()->t('Impressum').'</h3>'; {
$b .= '<h3>' . DI::l10n()->t('Impressum') . '</h3>';
$owner = DI::config()->get('impressum', 'owner'); $owner = DI::config()->get('impressum', 'owner');
$owner_profile = DI::config()->get('impressum','ownerprofile'); $owner_profile = DI::config()->get('impressum', 'ownerprofile');
$postal = ProxyUtils::proxifyHtml(BBCode::convert(DI::config()->get('impressum', 'postal'))); $postal = ProxyUtils::proxifyHtml(BBCode::convert(DI::config()->get('impressum', 'postal')));
$notes = ProxyUtils::proxifyHtml(BBCode::convert(DI::config()->get('impressum', 'notes'))); $notes = ProxyUtils::proxifyHtml(BBCode::convert(DI::config()->get('impressum', 'notes')));
$email = obfuscate_email( DI::config()->get('impressum','email') ); $email = obfuscate_email( DI::config()->get('impressum', 'email') );
if (strlen($owner)) { if (strlen($owner)) {
if (strlen($owner_profile)) { if (strlen($owner_profile)) {
$tmp = '<a href="'.$owner_profile.'">'.$owner.'</a>'; $tmp = '<a href="' . $owner_profile . '">' . $owner . '</a>';
} else { } else {
$tmp = $owner; $tmp = $owner;
} }
if (strlen($email)) { if (strlen($email)) {
$b .= '<p><strong>'.DI::l10n()->t('Site Owner').'</strong>: '. $tmp .'<br /><strong>'.DI::l10n()->t('Email Address').'</strong>: '.$email.'</p>'; $b .= '<p><strong>' . DI::l10n()->t('Site Owner').'</strong>: ' . $tmp .'<br /><strong>' . DI::l10n()->t('Email Address') . '</strong>: ' . $email . '</p>';
} else { } else {
$b .= '<p><strong>'.DI::l10n()->t('Site Owner').'</strong>: '. $tmp .'</p>'; $b .= '<p><strong>' . DI::l10n()->t('Site Owner').'</strong>: ' . $tmp .'</p>';
} }
if (strlen($postal)) { if (strlen($postal)) {
$b .= '<p><strong>'.DI::l10n()->t('Postal Address').'</strong><br />'. $postal .'</p>'; $b .= '<p><strong>' . DI::l10n()->t('Postal Address') . '</strong><br />' . $postal . '</p>';
} }
if (strlen($notes)) { if (strlen($notes)) {
$b .= '<p>'.$notes.'</p>'; $b .= '<p>' . $notes . '</p>';
} }
} else { } else {
$b .= '<p>'.DI::l10n()->t('The impressum addon needs to be configured!<br />Please add at least the <tt>owner</tt> variable to your config file. For other variables please refer to the README file of the addon.').'</p>'; $b .= '<p>' . DI::l10n()->t('The impressum addon needs to be configured!<br />Please add at least the <tt>owner</tt> variable to your config file. For other variables please refer to the README file of the addon.') . '</p>';
} }
} }
function impressum_addon_admin_post (&$a) { function impressum_addon_admin_post (App $a)
{
$owner = trim($_POST['owner'] ?? ''); $owner = trim($_POST['owner'] ?? '');
$ownerprofile = trim($_POST['ownerprofile'] ?? ''); $ownerprofile = trim($_POST['ownerprofile'] ?? '');
$postal = trim($_POST['postal'] ?? ''); $postal = trim($_POST['postal'] ?? '');
$notes = trim($_POST['notes'] ?? ''); $notes = trim($_POST['notes'] ?? '');
$email = trim($_POST['email'] ?? ''); $email = trim($_POST['email'] ?? '');
$footer_text = trim($_POST['footer_text'] ?? ''); $footer_text = trim($_POST['footer_text'] ?? '');
DI::config()->set('impressum','owner',strip_tags($owner));
DI::config()->set('impressum','ownerprofile',strip_tags($ownerprofile)); DI::config()->set('impressum', 'owner', strip_tags($owner));
DI::config()->set('impressum','postal',strip_tags($postal)); DI::config()->set('impressum', 'ownerprofile', strip_tags($ownerprofile));
DI::config()->set('impressum','email',strip_tags($email)); DI::config()->set('impressum', 'postal', strip_tags($postal));
DI::config()->set('impressum','notes',strip_tags($notes)); DI::config()->set('impressum', 'email', strip_tags($email));
DI::config()->set('impressum','footer_text',strip_tags($footer_text)); DI::config()->set('impressum', 'notes', strip_tags($notes));
DI::config()->set('impressum', 'footer_text', strip_tags($footer_text));
} }
function impressum_addon_admin (&$a, &$o) {
$t = Renderer::getMarkupTemplate( "admin.tpl", "addon/impressum/" ); function impressum_addon_admin (App $a, &$o)
{
$t = Renderer::getMarkupTemplate('admin.tpl', 'addon/impressum/' );
$o = Renderer::replaceMacros($t, [ $o = Renderer::replaceMacros($t, [
'$submit' => DI::l10n()->t('Save Settings'), '$submit' => DI::l10n()->t('Save Settings'),
'$owner' => ['owner', DI::l10n()->t('Site Owner'), DI::config()->get('impressum','owner'), DI::l10n()->t('The page operators name.')], '$owner' => ['owner', DI::l10n()->t('Site Owner'), DI::config()->get('impressum','owner'), DI::l10n()->t('The page operators name.')],

View file

@ -5,6 +5,8 @@
* Version: 1.0 * Version: 1.0
* Author: Thomas Willingham <https://kakste.com/profile/beardyunixer> * Author: Thomas Willingham <https://kakste.com/profile/beardyunixer>
*/ */
use Friendica\App;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\DI; use Friendica\DI;
@ -13,7 +15,7 @@ function infiniteimprobabilitydrive_install()
Hook::register('app_menu', 'addon/infiniteimprobabilitydrive/infiniteimprobabilitydrive.php', 'infiniteimprobabilitydrive_app_menu'); Hook::register('app_menu', 'addon/infiniteimprobabilitydrive/infiniteimprobabilitydrive.php', 'infiniteimprobabilitydrive_app_menu');
} }
function infiniteimprobabilitydrive_app_menu($a, &$b) function infiniteimprobabilitydrive_app_menu(App $a, array &$b)
{ {
$b['app_menu'][] = '<div class="app-title"><a href="infiniteimprobabilitydrive">' . DI::l10n()->t('Infinite Improbability Drive') . '</a></div>'; $b['app_menu'][] = '<div class="app-title"><a href="infiniteimprobabilitydrive">' . DI::l10n()->t('Infinite Improbability Drive') . '</a></div>';
} }
@ -25,7 +27,7 @@ function infiniteimprobabilitydrive_module()
} }
function infiniteimprobabilitydrive_content(&$a) function infiniteimprobabilitydrive_content(App $a)
{ {
$baseurl = DI::baseUrl()->get() . '/addon/infiniteimprobabilitydrive'; $baseurl = DI::baseUrl()->get() . '/addon/infiniteimprobabilitydrive';
$o = ''; $o = '';

View file

@ -12,7 +12,8 @@ use Friendica\Core\Hook;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\DI; use Friendica\DI;
function irc_install() { function irc_install()
{
Hook::register('app_menu', 'addon/irc/irc.php', 'irc_app_menu'); Hook::register('app_menu', 'addon/irc/irc.php', 'irc_app_menu');
Hook::register('addon_settings', 'addon/irc/irc.php', 'irc_addon_settings'); Hook::register('addon_settings', 'addon/irc/irc.php', 'irc_addon_settings');
Hook::register('addon_settings_post', 'addon/irc/irc.php', 'irc_addon_settings_post'); Hook::register('addon_settings_post', 'addon/irc/irc.php', 'irc_addon_settings_post');
@ -41,11 +42,13 @@ function irc_addon_settings(App &$a, array &$data)
]; ];
} }
function irc_addon_settings_post(&$a, &$b) { function irc_addon_settings_post(App $a, array &$b)
if(!local_user()) {
if (!local_user()) {
return; return;
}
if(!empty($_POST['irc-submit'])) { if (!empty($_POST['irc-submit'])) {
if (isset($_POST['autochans'])) { if (isset($_POST['autochans'])) {
DI::pConfig()->set(local_user(), 'irc', 'autochans', trim(($_POST['autochans']))); DI::pConfig()->set(local_user(), 'irc', 'autochans', trim(($_POST['autochans'])));
} }
@ -56,7 +59,8 @@ function irc_addon_settings_post(&$a, &$b) {
} }
} }
function irc_app_menu($a,&$b) { function irc_app_menu(App $a, array &$b)
{
$b['app_menu'][] = '<div class="app-title"><a href="irc">' . DI::l10n()->t('IRC Chatroom') . '</a></div>'; $b['app_menu'][] = '<div class="app-title"><a href="irc">' . DI::l10n()->t('IRC Chatroom') . '</a></div>';
} }
@ -66,27 +70,30 @@ function irc_module() {
} }
function irc_content(&$a) { function irc_content(App $a)
{
$baseurl = DI::baseUrl()->get() . '/addon/irc'; $baseurl = DI::baseUrl()->get() . '/addon/irc';
$o = ''; $o = '';
/* set the list of popular channels */ /* set the list of popular channels */
if (local_user()) { if (local_user()) {
$sitechats = DI::pConfig()->get( local_user(), 'irc', 'sitechats'); $sitechats = DI::pConfig()->get( local_user(), 'irc', 'sitechats');
if (!$sitechats) if (!$sitechats) {
$sitechats = DI::config()->get('irc', 'sitechats'); $sitechats = DI::config()->get('irc', 'sitechats');
}
} else { } else {
$sitechats = DI::config()->get('irc','sitechats'); $sitechats = DI::config()->get('irc','sitechats');
} }
if($sitechats)
if ($sitechats) {
$chats = explode(',',$sitechats); $chats = explode(',',$sitechats);
else } else {
$chats = ['friendica','chat','chatback','hottub','ircbar','dateroom','debian']; $chats = ['friendica','chat','chatback','hottub','ircbar','dateroom','debian'];
}
DI::page()['aside'] .= '<div class="widget"><h3>' . DI::l10n()->t('Popular Channels') . '</h3><ul>'; DI::page()['aside'] .= '<div class="widget"><h3>' . DI::l10n()->t('Popular Channels') . '</h3><ul>';
foreach($chats as $chat) { foreach ($chats as $chat) {
DI::page()['aside'] .= '<li><a href="' . DI::baseUrl()->get() . '/irc?channels=' . $chat . '" >' . '#' . $chat . '</a></li>'; DI::page()['aside'] .= '<li><a href="' . DI::baseUrl()->get() . '/irc?channels=' . $chat . '" >' . '#' . $chat . '</a></li>';
} }
DI::page()['aside'] .= '</ul></div>'; DI::page()['aside'] .= '</ul></div>';
@ -99,10 +106,12 @@ function irc_content(&$a) {
} else { } else {
$autochans = DI::config()->get('irc','autochans'); $autochans = DI::config()->get('irc','autochans');
} }
if($autochans)
if ($autochans) {
$channels = $autochans; $channels = $autochans;
else } else {
$channels = ($_GET['channels'] ?? '') ?: 'friendica'; $channels = ($_GET['channels'] ?? '') ?: 'friendica';
}
/* add the chatroom frame and some html */ /* add the chatroom frame and some html */
$o .= <<< EOT $o .= <<< EOT
@ -111,23 +120,24 @@ function irc_content(&$a) {
<iframe src="//web.libera.chat?channels=$channels" style="width:100%; max-width:900px; height: 600px;"></iframe> <iframe src="//web.libera.chat?channels=$channels" style="width:100%; max-width:900px; height: 600px;"></iframe>
EOT; EOT;
return $o; return $o;
} }
function irc_addon_admin_post (&$a) { function irc_addon_admin_post (App $a)
if(!$a->isSiteAdmin()) {
if (!$a->isSiteAdmin()) {
return; return;
}
if($_POST['irc-submit']) { if ($_POST['irc-submit']) {
DI::config()->set('irc','autochans',trim($_POST['autochans'])); DI::config()->set('irc', 'autochans', trim($_POST['autochans']));
DI::config()->set('irc','sitechats',trim($_POST['sitechats'])); DI::config()->set('irc', 'sitechats', trim($_POST['sitechats']));
} }
} }
function irc_addon_admin (&$a, &$o) { function irc_addon_admin (App $a, &$o) {
$sitechats = DI::config()->get('irc','sitechats'); /* popular channels */ $sitechats = DI::config()->get('irc', 'sitechats'); /* popular channels */
$autochans = DI::config()->get('irc','autochans'); /* auto connect chans */ $autochans = DI::config()->get('irc', 'autochans'); /* auto connect chans */
$t = Renderer::getMarkupTemplate( "admin.tpl", "addon/irc/" ); $t = Renderer::getMarkupTemplate('admin.tpl', 'addon/irc/' );
$o = Renderer::replaceMacros($t, [ $o = Renderer::replaceMacros($t, [
'$submit' => DI::l10n()->t('Save Settings'), '$submit' => DI::l10n()->t('Save Settings'),
'$autochans' => [ 'autochans', DI::l10n()->t('Channel(s) to auto connect (comma separated)'), $autochans, DI::l10n()->t('List of channels that shall automatically connected to when the app is launched.')], '$autochans' => [ 'autochans', DI::l10n()->t('Channel(s) to auto connect (comma separated)'), $autochans, DI::l10n()->t('List of channels that shall automatically connected to when the app is launched.')],

View file

@ -43,7 +43,7 @@ function js_upload_form(App $a, array &$b)
]); ]);
} }
function js_upload_post_init(App $a, &$b) function js_upload_post_init(App $a, array &$b)
{ {
global $js_upload_result, $js_upload_jsonresponse; global $js_upload_result, $js_upload_jsonresponse;
@ -69,7 +69,7 @@ function js_upload_post_init(App $a, &$b)
$js_upload_result = $result; $js_upload_result = $result;
} }
function js_upload_post_file(App $a, &$b) function js_upload_post_file(App $a, array &$b)
{ {
global $js_upload_result; global $js_upload_result;
@ -81,7 +81,7 @@ function js_upload_post_file(App $a, &$b)
} }
function js_upload_post_end(App $a, &$b) function js_upload_post_end(App $a, array &$b)
{ {
global $js_upload_jsonresponse; global $js_upload_jsonresponse;

View file

@ -45,7 +45,7 @@ function keycloakpassword_request($client_id, $secret, $url, $params = [])
return $res; return $res;
} }
function keycloakpassword_authenticate($a, &$b) function keycloakpassword_authenticate(App $a, array &$b)
{ {
if (empty($b['password'])) { if (empty($b['password'])) {
return; return;
@ -110,7 +110,7 @@ function keycloakpassword_admin_input($key, $label, $description)
]; ];
} }
function keycloakpassword_addon_admin(&$a, &$o) function keycloakpassword_addon_admin(App $a, &$o)
{ {
$form = $form =
keycloakpassword_admin_input( keycloakpassword_admin_input(
@ -140,7 +140,7 @@ function keycloakpassword_addon_admin(&$a, &$o)
$o = Renderer::replaceMacros($t, $form); $o = Renderer::replaceMacros($t, $form);
} }
function keycloakpassword_addon_admin_post(&$a) function keycloakpassword_addon_admin_post(App $a)
{ {
if (!local_user()) { if (!local_user()) {
return; return;

View file

@ -41,7 +41,7 @@ function krynn_install() {
Logger::notice("installed krynn"); Logger::notice("installed krynn");
} }
function krynn_post_hook($a, &$item) { function krynn_post_hook(App $a, &$item) {
/** /**
* *
@ -97,7 +97,7 @@ function krynn_post_hook($a, &$item) {
* *
*/ */
function krynn_settings_post($a,$post) { function krynn_settings_post(App $a, $post) {
if(! local_user()) if(! local_user())
return; return;
if($_POST['krynn-submit']) if($_POST['krynn-submit'])

View file

@ -67,7 +67,7 @@ function langfilter_addon_settings(App $a, array &$data)
* 3rd save the settings to the DB for later usage * 3rd save the settings to the DB for later usage
*/ */
function langfilter_addon_settings_post(App $a, &$b) function langfilter_addon_settings_post(App $a, array &$b)
{ {
if (!local_user()) { if (!local_user()) {
return; return;

View file

@ -54,6 +54,7 @@
* ...etc. * ...etc.
*/ */
use Friendica\App;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\Core\Logger; use Friendica\Core\Logger;
use Friendica\Database\DBA; use Friendica\Database\DBA;
@ -67,12 +68,12 @@ function ldapauth_install()
Hook::register('authenticate', 'addon/ldapauth/ldapauth.php', 'ldapauth_hook_authenticate'); Hook::register('authenticate', 'addon/ldapauth/ldapauth.php', 'ldapauth_hook_authenticate');
} }
function ldapauth_load_config(\Friendica\App $a, ConfigFileLoader $loader) function ldapauth_load_config(App $a, ConfigFileLoader $loader)
{ {
$a->getConfigCache()->load($loader->loadAddonConfig('ldapauth')); $a->getConfigCache()->load($loader->loadAddonConfig('ldapauth'));
} }
function ldapauth_hook_authenticate($a, &$b) function ldapauth_hook_authenticate(App $a, array &$b)
{ {
$user = ldapauth_authenticate($b['username'], $b['password']); $user = ldapauth_authenticate($b['username'], $b['password']);
if (!empty($user['uid'])) { if (!empty($user['uid'])) {

View file

@ -27,7 +27,7 @@ function libertree_install()
function libertree_jot_nets(App &$a, array &$jotnets_fields) function libertree_jot_nets(App &$a, array &$jotnets_fields)
{ {
if(! local_user()) { if (!local_user()) {
return; return;
} }
@ -37,13 +37,12 @@ function libertree_jot_nets(App &$a, array &$jotnets_fields)
'field' => [ 'field' => [
'libertree_enable', 'libertree_enable',
DI::l10n()->t('Post to libertree'), DI::l10n()->t('Post to libertree'),
DI::pConfig()->get(local_user(), 'libertree', 'post_by_default') DI::pConfig()->get(local_user(), 'libertree', 'post_by_default'),
] ],
]; ];
} }
} }
function libertree_settings(App $a, array &$data) function libertree_settings(App $a, array &$data)
{ {
if (!local_user()) { if (!local_user()) {
@ -72,11 +71,9 @@ function libertree_settings(App $a, array &$data)
]; ];
} }
function libertree_settings_post(App $a, array &$b)
function libertree_settings_post(&$a,&$b) { {
if (!empty($_POST['libertree-submit'])) {
if(!empty($_POST['libertree-submit'])) {
DI::pConfig()->set(local_user(),'libertree','post',intval($_POST['libertree'])); DI::pConfig()->set(local_user(),'libertree','post',intval($_POST['libertree']));
DI::pConfig()->set(local_user(),'libertree','post_by_default',intval($_POST['libertree_bydefault'])); DI::pConfig()->set(local_user(),'libertree','post_by_default',intval($_POST['libertree_bydefault']));
DI::pConfig()->set(local_user(),'libertree','libertree_api_token',trim($_POST['libertree_api_token'])); DI::pConfig()->set(local_user(),'libertree','libertree_api_token',trim($_POST['libertree_api_token']));
@ -101,7 +98,8 @@ function libertree_hook_fork(App &$a, array &$b)
} }
} }
function libertree_post_local(&$a,&$b) { function libertree_post_local(App $a, array &$b)
{
// This can probably be changed to allow editing by pointing to a different API endpoint // This can probably be changed to allow editing by pointing to a different API endpoint
@ -136,11 +134,8 @@ function libertree_post_local(&$a,&$b) {
$b['postopts'] .= 'libertree'; $b['postopts'] .= 'libertree';
} }
function libertree_send(App $a, array &$b)
{
function libertree_send(&$a,&$b) {
Logger::notice('libertree_send: invoked'); Logger::notice('libertree_send: invoked');
if ($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) { if ($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) {
@ -195,8 +190,9 @@ function libertree_send(&$a,&$b) {
$body = BBCode::toMarkdown($body, false); $body = BBCode::toMarkdown($body, false);
// Adding the title // Adding the title
if(strlen($title)) if (strlen($title)) {
$body = "## ".html_entity_decode($title)."\n\n".$body; $body = '## ' . html_entity_decode($title) . "\n\n" . $body;
}
$params = [ $params = [

View file

@ -35,7 +35,7 @@ function libravatar_load_config(App $a, ConfigFileLoader $loader)
* @param $a array * @param $a array
* @param &$b array * @param &$b array
*/ */
function libravatar_lookup($a, &$b) function libravatar_lookup(array $a, array &$b)
{ {
$default_avatar = DI::config()->get('libravatar', 'default_avatar'); $default_avatar = DI::config()->get('libravatar', 'default_avatar');
if (empty($default_avatar)) { if (empty($default_avatar)) {
@ -44,6 +44,7 @@ function libravatar_lookup($a, &$b)
} }
require_once 'Services/Libravatar.php'; require_once 'Services/Libravatar.php';
$libravatar = new Services_Libravatar(); $libravatar = new Services_Libravatar();
$libravatar->setSize($b['size']); $libravatar->setSize($b['size']);
$libravatar->setDefault($default_avatar); $libravatar->setDefault($default_avatar);
@ -56,7 +57,7 @@ function libravatar_lookup($a, &$b)
/** /**
* Display admin settings for this addon * Display admin settings for this addon
*/ */
function libravatar_addon_admin(&$a, &$o) function libravatar_addon_admin(App $a, &$o)
{ {
$t = Renderer::getMarkupTemplate("admin.tpl", "addon/libravatar"); $t = Renderer::getMarkupTemplate("admin.tpl", "addon/libravatar");
@ -87,7 +88,7 @@ function libravatar_addon_admin(&$a, &$o)
/** /**
* Save admin settings * Save admin settings
*/ */
function libravatar_addon_admin_post(&$a) function libravatar_addon_admin_post(App $a)
{ {
$default_avatar = trim($_POST['avatar'] ?? 'identicon'); $default_avatar = trim($_POST['avatar'] ?? 'identicon');
DI::config()->set('libravatar', 'default_avatar', $default_avatar); DI::config()->set('libravatar', 'default_avatar', $default_avatar);

View file

@ -21,21 +21,21 @@ use Friendica\Util\DateTimeFormat;
use Friendica\Util\XML; use Friendica\Util\XML;
function ljpost_install() { function ljpost_install() {
Hook::register('post_local', 'addon/ljpost/ljpost.php', 'ljpost_post_local'); Hook::register('post_local', 'addon/ljpost/ljpost.php', 'ljpost_post_local');
Hook::register('notifier_normal', 'addon/ljpost/ljpost.php', 'ljpost_send'); Hook::register('notifier_normal', 'addon/ljpost/ljpost.php', 'ljpost_send');
Hook::register('jot_networks', 'addon/ljpost/ljpost.php', 'ljpost_jot_nets'); Hook::register('jot_networks', 'addon/ljpost/ljpost.php', 'ljpost_jot_nets');
Hook::register('connector_settings', 'addon/ljpost/ljpost.php', 'ljpost_settings'); Hook::register('connector_settings', 'addon/ljpost/ljpost.php', 'ljpost_settings');
Hook::register('connector_settings_post', 'addon/ljpost/ljpost.php', 'ljpost_settings_post'); Hook::register('connector_settings_post', 'addon/ljpost/ljpost.php', 'ljpost_settings_post');
} }
function ljpost_jot_nets(App &$a, array &$jotnets_fields) function ljpost_jot_nets(App &$a, array &$jotnets_fields)
{ {
if(! local_user()) { if(! local_user()) {
return; return;
} }
if (DI::pConfig()->get(local_user(),'ljpost','post')) { if (DI::pConfig()->get(local_user(),'ljpost','post')) {
$jotnets_fields[] = [ $jotnets_fields[] = [
'type' => 'checkbox', 'type' => 'checkbox',
'field' => [ 'field' => [
@ -44,9 +44,8 @@ function ljpost_jot_nets(App &$a, array &$jotnets_fields)
DI::pConfig()->get(local_user(),'ljpost','post_by_default') DI::pConfig()->get(local_user(),'ljpost','post_by_default')
] ]
]; ];
}
} }
}
function ljpost_settings(App &$a, array &$data) function ljpost_settings(App &$a, array &$data)
{ {
@ -58,7 +57,7 @@ function ljpost_settings(App &$a, array &$data)
$ij_username = DI::pConfig()->get(local_user(), 'ljpost', 'ij_username'); $ij_username = DI::pConfig()->get(local_user(), 'ljpost', 'ij_username');
$def_enabled = DI::pConfig()->get(local_user(), 'ljpost', 'post_by_default'); $def_enabled = DI::pConfig()->get(local_user(), 'ljpost', 'post_by_default');
$t = Renderer::getMarkupTemplate('connector_settings.tpl', 'addon/ljpost/'); $t= Renderer::getMarkupTemplate('connector_settings.tpl', 'addon/ljpost/');
$html = Renderer::replaceMacros($t, [ $html = Renderer::replaceMacros($t, [
'$enabled' => ['ljpost', DI::l10n()->t('Enable LiveJournal Post Addon'), $enabled], '$enabled' => ['ljpost', DI::l10n()->t('Enable LiveJournal Post Addon'), $enabled],
'$username' => ['ij_username', DI::l10n()->t('LiveJournal username'), $ij_username], '$username' => ['ij_username', DI::l10n()->t('LiveJournal username'), $ij_username],
@ -75,61 +74,61 @@ function ljpost_settings(App &$a, array &$data)
]; ];
} }
function ljpost_settings_post(App $a, array &$b)
function ljpost_settings_post(&$a,&$b) { {
if (!empty($_POST['ljpost-submit'])) {
if(!empty($_POST['ljpost-submit'])) { DI::pConfig()->set(local_user(), 'ljpost', 'post', intval($_POST['ljpost']));
DI::pConfig()->set(local_user(), 'ljpost', 'post_by_default', intval($_POST['lj_bydefault']));
DI::pConfig()->set(local_user(),'ljpost','post',intval($_POST['ljpost'])); DI::pConfig()->set(local_user(), 'ljpost', 'lj_username', trim($_POST['lj_username']));
DI::pConfig()->set(local_user(),'ljpost','post_by_default',intval($_POST['lj_bydefault'])); DI::pConfig()->set(local_user(), 'ljpost', 'lj_password', trim($_POST['lj_password']));
DI::pConfig()->set(local_user(),'ljpost','lj_username',trim($_POST['lj_username']));
DI::pConfig()->set(local_user(),'ljpost','lj_password',trim($_POST['lj_password']));
} }
} }
function ljpost_post_local(&$a,&$b) { function ljpost_post_local(App $a, array &$b)
{
// This can probably be changed to allow editing by pointing to a different API endpoint // This can probably be changed to allow editing by pointing to a different API endpoint
if ($b['edit']) {
if($b['edit'])
return; return;
}
if((! local_user()) || (local_user() != $b['uid'])) if ((! local_user()) || (local_user() != $b['uid'])) {
return; return;
}
if($b['private'] || $b['parent']) if ($b['private'] || $b['parent']) {
return; return;
}
$lj_post = intval(DI::pConfig()->get(local_user(),'ljpost','post')); $lj_post = intval(DI::pConfig()->get(local_user(),'ljpost','post'));
$lj_enable = (($lj_post && !empty($_REQUEST['ljpost_enable'])) ? intval($_REQUEST['ljpost_enable']) : 0); $lj_enable = (($lj_post && !empty($_REQUEST['ljpost_enable'])) ? intval($_REQUEST['ljpost_enable']) : 0);
if($b['api_source'] && intval(DI::pConfig()->get(local_user(),'ljpost','post_by_default'))) if ($b['api_source'] && intval(DI::pConfig()->get(local_user(), 'ljpost', 'post_by_default'))) {
$lj_enable = 1; $lj_enable = 1;
}
if(! $lj_enable) if (!$lj_enable) {
return; return;
}
if(strlen($b['postopts'])) if (strlen($b['postopts'])) {
$b['postopts'] .= ','; $b['postopts'] .= ',';
}
$b['postopts'] .= 'ljpost'; $b['postopts'] .= 'ljpost';
} }
function ljpost_send(App $a, array &$b)
{
if ($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) {
function ljpost_send(&$a,&$b) {
if($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited']))
return; return;
}
if(! strstr($b['postopts'],'ljpost')) if (!strstr($b['postopts'],'ljpost')) {
return; return;
}
if($b['parent'] != $b['id']) if ($b['parent'] != $b['id']) {
return; return;
}
$b['body'] = Post\Media::addAttachmentsToBody($b['uri-id'], $b['body']); $b['body'] = Post\Media::addAttachmentsToBody($b['uri-id'], $b['body']);
@ -147,10 +146,11 @@ function ljpost_send(&$a,&$b) {
// $lj_journal = $lj_username; // $lj_journal = $lj_username;
$lj_blog = XML::escape(DI::pConfig()->get($b['uid'],'ljpost','lj_blog')); $lj_blog = XML::escape(DI::pConfig()->get($b['uid'],'ljpost','lj_blog'));
if(! strlen($lj_blog)) if (!strlen($lj_blog)) {
$lj_blog = XML::escape('http://www.livejournal.com/interface/xmlrpc'); $lj_blog = XML::escape('http://www.livejournal.com/interface/xmlrpc');
}
if($lj_username && $lj_password && $lj_blog) { if ($lj_username && $lj_password && $lj_blog) {
$title = XML::escape($b['title']); $title = XML::escape($b['title']);
$post = BBCode::convertForUriId($b['uri-id'], $b['body'], BBCode::CONNECTORS); $post = BBCode::convertForUriId($b['uri-id'], $b['body'], BBCode::CONNECTORS);
$post = XML::escape($post); $post = XML::escape($post);
@ -166,9 +166,10 @@ function ljpost_send(&$a,&$b) {
$xml = <<< EOT $xml = <<< EOT
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<methodCall> <methodCall>
<methodName>LJ.XMLRPC.postevent</methodName> <methodName>LJ.XMLRPC.postevent</methodName>
<params> <params>
<param><value> <param>
<value>
<struct> <struct>
<member><name>username</name><value><string>$lj_username</string></value></member> <member><name>username</name><value><string>$lj_username</string></value></member>
<member><name>password</name><value><string>$lj_password</string></value></member> <member><name>password</name><value><string>$lj_password</string></value></member>
@ -197,10 +198,10 @@ function ljpost_send(&$a,&$b) {
</value> </value>
</member> </member>
</struct> </struct>
</value></param> </value>
</param>
</params> </params>
</methodCall> </methodCall>
EOT; EOT;
Logger::debug('ljpost: data: ' . $xml); Logger::debug('ljpost: data: ' . $xml);
@ -208,6 +209,7 @@ EOT;
if ($lj_blog !== 'test') { if ($lj_blog !== 'test') {
$x = DI::httpClient()->post($lj_blog, $xml, ['Content-Type' => 'text/xml'])->getBody(); $x = DI::httpClient()->post($lj_blog, $xml, ['Content-Type' => 'text/xml'])->getBody();
} }
Logger::info('posted to livejournal: ' . ($x) ? $x : ''); Logger::info('posted to livejournal: ' . ($x) ? $x : '');
} }
} }

View file

@ -70,7 +70,7 @@ function mailstream_module()
* @param Friendica\App $a App object (unused) * @param Friendica\App $a App object (unused)
* @param string $o HTML form data * @param string $o HTML form data
*/ */
function mailstream_addon_admin(&$a, &$o) function mailstream_addon_admin(App $a, &$o)
{ {
$frommail = DI::config()->get('mailstream', 'frommail'); $frommail = DI::config()->get('mailstream', 'frommail');
$template = Renderer::getMarkupTemplate('admin.tpl', 'addon/mailstream/'); $template = Renderer::getMarkupTemplate('admin.tpl', 'addon/mailstream/');
@ -110,7 +110,7 @@ function mailstream_generate_id($uri)
return $message_id; return $message_id;
} }
function mailstream_send_hook(&$a, $data) function mailstream_send_hook(App $a, $data)
{ {
$criteria = array('uid' => $data['uid'], 'contact-id' => $data['contact-id'], 'uri' => $data['uri']); $criteria = array('uid' => $data['uid'], 'contact-id' => $data['contact-id'], 'uri' => $data['uri']);
$item = Post::selectFirst([], $criteria); $item = Post::selectFirst([], $criteria);
@ -141,7 +141,7 @@ function mailstream_send_hook(&$a, $data)
* @param Friendica\App $a App object (unused) * @param Friendica\App $a App object (unused)
* @param array $item content of the item (may or may not already be stored in the item table) * @param array $item content of the item (may or may not already be stored in the item table)
*/ */
function mailstream_post_hook(&$a, &$item) function mailstream_post_hook(App $a, &$item)
{ {
mailstream_check_version(); mailstream_check_version();

View file

@ -37,7 +37,7 @@ function markdown_addon_settings(App $a, array &$data)
]; ];
} }
function markdown_addon_settings_post(App $a, &$b) function markdown_addon_settings_post(App $a, array &$b)
{ {
if (!local_user() || empty($_POST['markdown-submit'])) { if (!local_user() || empty($_POST['markdown-submit'])) {
return; return;

View file

@ -20,7 +20,7 @@ function mathjax_install()
Hook::register('addon_settings_post', __FILE__, 'mathjax_settings_post'); Hook::register('addon_settings_post', __FILE__, 'mathjax_settings_post');
} }
function mathjax_settings_post($a) function mathjax_settings_post(App $a)
{ {
if (!local_user() || empty($_POST['mathjax-submit'])) { if (!local_user() || empty($_POST['mathjax-submit'])) {
return; return;
@ -50,7 +50,7 @@ function mathjax_settings(App $a, array &$data)
]; ];
} }
function mathjax_footer(App $a, &$b) function mathjax_footer(App $a, array &$b)
{ {
// if the visitor of the page is not a local_user, use MathJax // if the visitor of the page is not a local_user, use MathJax
// otherwise check the users settings. // otherwise check the users settings.

View file

@ -16,7 +16,7 @@ function membersince_install()
Hook::register('profile_advanced', 'addon/membersince/membersince.php', 'membersince_display'); Hook::register('profile_advanced', 'addon/membersince/membersince.php', 'membersince_display');
} }
function membersince_display(Friendica\App $a, &$b) function membersince_display(Friendica\App $a, array &$b)
{ {
if ($a->getCurrentTheme() == 'frio') { if ($a->getCurrentTheme() == 'frio') {
// Works in Frio. // Works in Frio.

View file

@ -8,6 +8,7 @@
* Status: Deprecated * Status: Deprecated
*/ */
use Friendica\App;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\DI; use Friendica\DI;
@ -18,7 +19,7 @@ function morechoice_install() {
Hook::register('marital_selector', 'addon/morechoice/morechoice.php', 'morechoice_marital_selector'); Hook::register('marital_selector', 'addon/morechoice/morechoice.php', 'morechoice_marital_selector');
} }
function morechoice_gender_selector($a,&$b) { function morechoice_gender_selector(App $a, array &$b) {
$b['Androgyne'] = DI::l10n()->t('Androgyne'); $b['Androgyne'] = DI::l10n()->t('Androgyne');
$b['Bear'] = DI::l10n()->t('Bear'); $b['Bear'] = DI::l10n()->t('Bear');
$b['Bigender'] = DI::l10n()->t('Bigender'); $b['Bigender'] = DI::l10n()->t('Bigender');
@ -44,7 +45,7 @@ function morechoice_gender_selector($a,&$b) {
$b['Hard to tell these days'] = DI::l10n()->t('Hard to tell these days'); $b['Hard to tell these days'] = DI::l10n()->t('Hard to tell these days');
} }
function morechoice_sexpref_selector($a,&$b) { function morechoice_sexpref_selector(App $a, array &$b) {
$b['Girls with big tits'] = DI::l10n()->t('Girls with big tits'); $b['Girls with big tits'] = DI::l10n()->t('Girls with big tits');
$b['Millionaires'] = DI::l10n()->t('Millionaires'); $b['Millionaires'] = DI::l10n()->t('Millionaires');
$b['Guys with big schlongs'] = DI::l10n()->t('Guys with big schlongs'); $b['Guys with big schlongs'] = DI::l10n()->t('Guys with big schlongs');
@ -97,7 +98,7 @@ function morechoice_sexpref_selector($a,&$b) {
$b['I\'d rather just have some chocolate'] = DI::l10n()->t('I\'d rather just have some chocolate'); $b['I\'d rather just have some chocolate'] = DI::l10n()->t('I\'d rather just have some chocolate');
} }
function morechoice_marital_selector($a,&$b) { function morechoice_marital_selector(App $a, array &$b) {
$b['Married to my job'] = DI::l10n()->t('Married to my job'); $b['Married to my job'] = DI::l10n()->t('Married to my job');
$b['Polygamist'] = DI::l10n()->t('Polygamist'); $b['Polygamist'] = DI::l10n()->t('Polygamist');
$b['Half married'] = DI::l10n()->t('Half married'); $b['Half married'] = DI::l10n()->t('Half married');

View file

@ -6,6 +6,8 @@
* Author: Thomas Willingham <https://kakste.com/profile/beardyunixer> * Author: Thomas Willingham <https://kakste.com/profile/beardyunixer>
* *
*/ */
use Friendica\App;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\DI; use Friendica\DI;
@ -14,7 +16,7 @@ function morepokes_install()
Hook::register('poke_verbs', 'addon/morepokes/morepokes.php', 'morepokes_poke_verbs'); Hook::register('poke_verbs', 'addon/morepokes/morepokes.php', 'morepokes_poke_verbs');
} }
function morepokes_poke_verbs($a, &$b) function morepokes_poke_verbs(App $a, array &$b)
{ {
$b['bitchslap'] = ['bitchslapped', DI::l10n()->t('bitchslap'), DI::l10n()->t('bitchslapped')]; $b['bitchslap'] = ['bitchslapped', DI::l10n()->t('bitchslap'), DI::l10n()->t('bitchslapped')];
$b['shag'] = ['shag', DI::l10n()->t('shag'), DI::l10n()->t('shagged')]; $b['shag'] = ['shag', DI::l10n()->t('shag'), DI::l10n()->t('shagged')];

View file

@ -7,27 +7,33 @@
* Author: Mike Macgirvin <http://macgirvin.com/profile/mike> * Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
* Status: Unsupported * Status: Unsupported
*/ */
use Friendica\App;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\DI; use Friendica\DI;
function namethingy_install() { function namethingy_install()
{
Hook::register('app_menu', 'addon/namethingy/namethingy.php', 'namethingy_app_menu'); Hook::register('app_menu', 'addon/namethingy/namethingy.php', 'namethingy_app_menu');
} }
function namethingy_app_menu($a,&$b) { function namethingy_app_menu(App $a, array &$b)
{
$b['app_menu'][] = '<div class="app-title"><a href="namethingy">NameThingy</a></div>'; $b['app_menu'][] = '<div class="app-title"><a href="namethingy">NameThingy</a></div>';
} }
function namethingy_module() {} function namethingy_module()
{
}
function namethingy_content(&$a) { function namethingy_content(App $a)
{
$baseurl = DI::baseUrl()->get() . '/addon/namethingy';
$baseurl = DI::baseUrl()->get() . '/addon/namethingy'; $o .= <<< EOT
$o .= <<< EOT
<iframe src="http://namethingy.com" width="900" height="700" /> <iframe src="http://namethingy.com" width="900" height="700" />
EOT; EOT;
return $o; return $o;
} }

View file

@ -6,6 +6,7 @@
* Author: Tobias Diekershoff <https://f.diekershoff.de/profile/tobias> * Author: Tobias Diekershoff <https://f.diekershoff.de/profile/tobias>
***/ ***/
use Friendica\App;
use Friendica\Content\Text\BBCode; use Friendica\Content\Text\BBCode;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\Core\Logger; use Friendica\Core\Logger;
@ -18,7 +19,7 @@ function newmemberwidget_install()
Logger::notice('newmemberwidget installed'); Logger::notice('newmemberwidget installed');
} }
function newmemberwidget_network_mod_init ($a, $b) function newmemberwidget_network_mod_init (App $a, $b)
{ {
if (empty($_SESSION['new_member'])) { if (empty($_SESSION['new_member'])) {
return; return;
@ -45,7 +46,7 @@ function newmemberwidget_network_mod_init ($a, $b)
DI::page()['aside'] = $t . DI::page()['aside']; DI::page()['aside'] = $t . DI::page()['aside'];
} }
function newmemberwidget_addon_admin_post(&$a) function newmemberwidget_addon_admin_post(App $a)
{ {
$ft = (!empty($_POST['freetext']) ? trim($_POST['freetext']) : ""); $ft = (!empty($_POST['freetext']) ? trim($_POST['freetext']) : "");
$lsn = trim($_POST['localsupportname'] ?? ''); $lsn = trim($_POST['localsupportname'] ?? '');
@ -57,7 +58,7 @@ function newmemberwidget_addon_admin_post(&$a)
DI::config()->set('newmemberwidget', 'localsupport', trim($lsn)); DI::config()->set('newmemberwidget', 'localsupport', trim($lsn));
} }
function newmemberwidget_addon_admin(&$a, &$o) function newmemberwidget_addon_admin(App $a, &$o)
{ {
$t = Renderer::getMarkupTemplate('admin.tpl', 'addon/newmemberwidget'); $t = Renderer::getMarkupTemplate('admin.tpl', 'addon/newmemberwidget');
$o = Renderer::replaceMacros($t, [ $o = Renderer::replaceMacros($t, [

View file

@ -58,7 +58,7 @@ function nitter_addon_admin(App $a, &$o)
/* /*
* replace "twitter.com" with "nitter.net" * replace "twitter.com" with "nitter.net"
*/ */
function nitter_render(&$a, &$o) function nitter_render(App $a, &$o)
{ {
// this needs to be a system setting // this needs to be a system setting
$replaced = false; $replaced = false;

View file

@ -6,6 +6,7 @@
* Author: Michael Vogel <https://pirati.ca/profile/heluecht> * Author: Michael Vogel <https://pirati.ca/profile/heluecht>
*/ */
use Friendica\App;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\Core\Logger; use Friendica\Core\Logger;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
@ -64,12 +65,12 @@ function nominatim_resolve_item(&$item)
} }
} }
function nominatim_post_hook($a, &$item) function nominatim_post_hook(App $a, &$item)
{ {
nominatim_resolve_item($item); nominatim_resolve_item($item);
} }
function nominatim_addon_admin(&$a, &$o) function nominatim_addon_admin(App $a, &$o)
{ {
$t = Renderer::getMarkupTemplate('admin.tpl', 'addon/nominatim/'); $t = Renderer::getMarkupTemplate('admin.tpl', 'addon/nominatim/');
@ -80,7 +81,7 @@ function nominatim_addon_admin(&$a, &$o)
]); ]);
} }
function nominatim_addon_admin_post(&$a) function nominatim_addon_admin_post(App $a)
{ {
$language = !empty($_POST['language']) ? trim($_POST['language']) : ''; $language = !empty($_POST['language']) ? trim($_POST['language']) : '';
DI::config()->set('nominatim', 'language', $language); DI::config()->set('nominatim', 'language', $language);

View file

@ -60,7 +60,7 @@ function notifyall_post(App $a)
DI::baseUrl()->redirect('admin'); DI::baseUrl()->redirect('admin');
} }
function notifyall_content(&$a) function notifyall_content(App $a)
{ {
if (!$a->isSiteAdmin()) { if (!$a->isSiteAdmin()) {
return ''; return '';

View file

@ -74,7 +74,7 @@ function nsfw_addon_settings(App &$a, array &$data)
]; ];
} }
function nsfw_addon_settings_post(&$a, &$b) function nsfw_addon_settings_post(App $a, array &$b)
{ {
if (!local_user()) { if (!local_user()) {
return; return;

View file

@ -28,11 +28,12 @@ function numfriends_install() {
* and if so set our configuration setting for this person. * and if so set our configuration setting for this person.
* *
*/ */
function numfriends_settings_post($a,$post) { function numfriends_settings_post(App $a, $post) {
if(! local_user() || empty($_POST['numfriends-submit'])) if (! local_user() || empty($_POST['numfriends-submit'])) {
return; return;
}
DI::pConfig()->set(local_user(),'system','display_friend_count',intval($_POST['numfriends'])); DI::pConfig()->set(local_user(), 'system', 'display_friend_count', intval($_POST['numfriends']));
} }
@ -44,7 +45,7 @@ function numfriends_settings_post($a,$post) {
*/ */
function numfriends_settings(App &$a, array &$data) function numfriends_settings(App &$a, array &$data)
{ {
if (! local_user()) { if (!local_user()) {
return; return;
} }

View file

@ -9,6 +9,7 @@
* *
*/ */
use Friendica\App;
use Friendica\Core\Cache\Enum\Duration; use Friendica\Core\Cache\Enum\Duration;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\Core\Logger; use Friendica\Core\Logger;
@ -34,12 +35,12 @@ function openstreetmap_install()
Logger::notice("installed openstreetmap"); Logger::notice("installed openstreetmap");
} }
function openstreetmap_load_config(\Friendica\App $a, ConfigFileLoader $loader) function openstreetmap_load_config(App $a, ConfigFileLoader $loader)
{ {
$a->getConfigCache()->load($loader->loadAddonConfig('openstreetmap')); $a->getConfigCache()->load($loader->loadAddonConfig('openstreetmap'));
} }
function openstreetmap_alterheader($a, &$navHtml) function openstreetmap_alterheader(App $a, &$navHtml)
{ {
$addScriptTag = '<script type="text/javascript" src="' . DI::baseUrl()->get() . '/addon/openstreetmap/openstreetmap.js"></script>' . "\r\n"; $addScriptTag = '<script type="text/javascript" src="' . DI::baseUrl()->get() . '/addon/openstreetmap/openstreetmap.js"></script>' . "\r\n";
DI::page()['htmlhead'] .= $addScriptTag; DI::page()['htmlhead'] .= $addScriptTag;
@ -54,7 +55,7 @@ function openstreetmap_alterheader($a, &$navHtml)
* @param mixed $a * @param mixed $a
* @param array& $item * @param array& $item
*/ */
function openstreetmap_location($a, &$item) function openstreetmap_location(App $a, &$item)
{ {
if (!(strlen($item['location']) || strlen($item['coord']))) { if (!(strlen($item['location']) || strlen($item['coord']))) {
return; return;
@ -104,7 +105,7 @@ function openstreetmap_location($a, &$item)
$item['html'] = '<a target="map" title="'.$title.'" href= "'.$target.'">'.$title.'</a>'; $item['html'] = '<a target="map" title="'.$title.'" href= "'.$target.'">'.$title.'</a>';
} }
function openstreetmap_get_coordinates($a, &$b) function openstreetmap_get_coordinates(App $a, array &$b)
{ {
$nomserver = DI::config()->get('openstreetmap', 'nomserver', OSM_NOM); $nomserver = DI::config()->get('openstreetmap', 'nomserver', OSM_NOM);
@ -132,7 +133,7 @@ function openstreetmap_get_coordinates($a, &$b)
} }
} }
function openstreetmap_generate_named_map(&$a, &$b) function openstreetmap_generate_named_map(App $a, array &$b)
{ {
openstreetmap_get_coordinates($a, $b); openstreetmap_get_coordinates($a, $b);
@ -141,7 +142,7 @@ function openstreetmap_generate_named_map(&$a, &$b)
} }
} }
function openstreetmap_generate_map(&$a, &$b) function openstreetmap_generate_map(App $a, array &$b)
{ {
$tmsserver = DI::config()->get('openstreetmap', 'tmsserver', OSM_TMS); $tmsserver = DI::config()->get('openstreetmap', 'tmsserver', OSM_TMS);
@ -177,7 +178,7 @@ function openstreetmap_generate_map(&$a, &$b)
Logger::debug('generate_map: ' . $b['html']); Logger::debug('generate_map: ' . $b['html']);
} }
function openstreetmap_addon_admin(&$a, &$o) function openstreetmap_addon_admin(App $a, &$o)
{ {
$t = Renderer::getMarkupTemplate("admin.tpl", "addon/openstreetmap/"); $t = Renderer::getMarkupTemplate("admin.tpl", "addon/openstreetmap/");
$tmsserver = DI::config()->get('openstreetmap', 'tmsserver', OSM_TMS); $tmsserver = DI::config()->get('openstreetmap', 'tmsserver', OSM_TMS);
@ -199,7 +200,7 @@ function openstreetmap_addon_admin(&$a, &$o)
]); ]);
} }
function openstreetmap_addon_admin_post(&$a) function openstreetmap_addon_admin_post(App $a)
{ {
$urltms = ($_POST['tmsserver'] ?? '') ?: OSM_TMS; $urltms = ($_POST['tmsserver'] ?? '') ?: OSM_TMS;
$urlnom = ($_POST['nomserver'] ?? '') ?: OSM_NOM; $urlnom = ($_POST['nomserver'] ?? '') ?: OSM_NOM;

View file

@ -82,10 +82,11 @@ function opmlexport_addon_settings(App $a, array &$data)
} }
function opmlexport_addon_settings_post(App $a, &$b) function opmlexport_addon_settings_post(App $a, array &$b)
{ {
if (!local_user() || empty($_POST['opmlexport-submit'])) { if (!local_user() || empty($_POST['opmlexport-submit'])) {
return; return;
} }
opmlexport($a); opmlexport($a);
} }

View file

@ -52,7 +52,7 @@ function pageheader_addon_admin_post(App $a)
} }
} }
function pageheader_fetch(App $a, &$b) function pageheader_fetch(App $a, array &$b)
{ {
if(file_exists('pageheader.html')){ if(file_exists('pageheader.html')){
$s = file_get_contents('pageheader.html'); $s = file_get_contents('pageheader.html');

View file

@ -31,6 +31,7 @@
* setting. * setting.
*/ */
use Friendica\App;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\Core\Logger; use Friendica\Core\Logger;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
@ -44,13 +45,13 @@ function piwik_install() {
Logger::notice("installed piwik addon"); Logger::notice("installed piwik addon");
} }
function piwik_load_config(\Friendica\App $a, ConfigFileLoader $loader) function piwik_load_config(App $a, ConfigFileLoader $loader)
{ {
$a->getConfigCache()->load($loader->loadAddonConfig('piwik')); $a->getConfigCache()->load($loader->loadAddonConfig('piwik'));
} }
function piwik_analytics($a,&$b) { function piwik_analytics(App $a, array &$b)
{
/* /*
* styling of every HTML block added by this addon is done in the * styling of every HTML block added by this addon is done in the
* associated CSS file. We just have to tell Friendica to get it * associated CSS file. We just have to tell Friendica to get it
@ -90,7 +91,7 @@ function piwik_analytics($a,&$b) {
$b .= "</div>"; $b .= "</div>";
} }
} }
function piwik_addon_admin (&$a, &$o) { function piwik_addon_admin (App $a, &$o) {
$t = Renderer::getMarkupTemplate( "admin.tpl", "addon/piwik/" ); $t = Renderer::getMarkupTemplate( "admin.tpl", "addon/piwik/" );
$o = Renderer::replaceMacros( $t, [ $o = Renderer::replaceMacros( $t, [
'$submit' => DI::l10n()->t('Save Settings'), '$submit' => DI::l10n()->t('Save Settings'),
@ -100,7 +101,7 @@ function piwik_addon_admin (&$a, &$o) {
'$async' => ['async', DI::l10n()->t('Asynchronous tracking'), DI::config()->get('piwik','async' ), ''], '$async' => ['async', DI::l10n()->t('Asynchronous tracking'), DI::config()->get('piwik','async' ), ''],
]); ]);
} }
function piwik_addon_admin_post (&$a) { function piwik_addon_admin_post (App $a) {
$url = trim($_POST['baseurl'] ?? ''); $url = trim($_POST['baseurl'] ?? '');
$id = trim($_POST['siteid'] ?? ''); $id = trim($_POST['siteid'] ?? '');
$optout = trim($_POST['optout'] ?? ''); $optout = trim($_POST['optout'] ?? '');

View file

@ -38,7 +38,7 @@ function planets_install() {
Logger::notice("installed planets"); Logger::notice("installed planets");
} }
function planets_post_hook($a, &$item) { function planets_post_hook(App $a, &$item) {
/** /**
* *
@ -96,11 +96,13 @@ function planets_post_hook($a, &$item) {
* *
*/ */
function planets_settings_post($a,$post) { function planets_settings_post(App $a,$post) {
if(! local_user()) if (! local_user()) {
return; return;
if($_POST['planets-submit']) }
DI::pConfig()->set(local_user(),'planets','enable',intval($_POST['planets'])); if ($_POST['planets-submit']) {
DI::pConfig()->set(local_user(), 'planets', 'enable' ,intval($_POST['planets']));
}
} }

View file

@ -32,7 +32,7 @@ function public_server_load_config(App $a, ConfigFileLoader $loader)
$a->getConfigCache()->load($loader->loadAddonConfig('public_server')); $a->getConfigCache()->load($loader->loadAddonConfig('public_server'));
} }
function public_server_register_account($a, $b) function public_server_register_account(App $a, $b)
{ {
$uid = $b; $uid = $b;
@ -46,7 +46,7 @@ function public_server_register_account($a, $b)
DBA::update('user', $fields, ['uid' => $uid]); DBA::update('user', $fields, ['uid' => $uid]);
} }
function public_server_cron($a, $b) function public_server_cron(App $a, $b)
{ {
Logger::notice("public_server: cron start"); Logger::notice("public_server: cron start");
@ -99,7 +99,7 @@ function public_server_cron($a, $b)
Logger::notice("public_server: cron end"); Logger::notice("public_server: cron end");
} }
function public_server_enotify(&$a, &$b) function public_server_enotify(App $a, array &$b)
{ {
if (!empty($b['params']) && $b['params']['type'] == Notification\Type::SYSTEM if (!empty($b['params']) && $b['params']['type'] == Notification\Type::SYSTEM
&& !empty($b['params']['system_type']) && $b['params']['system_type'] === 'public_server_expire') { && !empty($b['params']['system_type']) && $b['params']['system_type'] === 'public_server_expire') {
@ -110,7 +110,7 @@ function public_server_enotify(&$a, &$b)
} }
} }
function public_server_login($a, $b) function public_server_login(App $a, $b)
{ {
$days = DI::config()->get('public_server', 'expiredays'); $days = DI::config()->get('public_server', 'expiredays');
if (!$days) { if (!$days) {
@ -122,7 +122,7 @@ function public_server_login($a, $b)
DBA::update('user', $fields, $condition); DBA::update('user', $fields, $condition);
} }
function public_server_addon_admin_post(&$a) function public_server_addon_admin_post(App $a)
{ {
BaseModule::checkFormSecurityTokenRedirectOnError('/admin/addons/publicserver', 'publicserver'); BaseModule::checkFormSecurityTokenRedirectOnError('/admin/addons/publicserver', 'publicserver');
$expiredays = trim($_POST['expiredays'] ?? ''); $expiredays = trim($_POST['expiredays'] ?? '');
@ -139,7 +139,7 @@ function public_server_addon_admin_post(&$a)
DI::config()->set('public_server', 'flagpostsexpire', $flagpostsexpire); DI::config()->set('public_server', 'flagpostsexpire', $flagpostsexpire);
} }
function public_server_addon_admin(&$a, &$o) function public_server_addon_admin(App $a, &$o)
{ {
$token = BaseModule::getFormSecurityToken("publicserver"); $token = BaseModule::getFormSecurityToken("publicserver");
$t = Renderer::getMarkupTemplate("admin.tpl", "addon/public_server"); $t = Renderer::getMarkupTemplate("admin.tpl", "addon/public_server");

View file

@ -59,7 +59,7 @@ function pumpio_content(App $a)
return ''; return '';
} }
require_once("mod/settings.php"); require_once 'mod/settings.php';
settings_init($a); settings_init($a);
if (isset(DI::args()->getArgv()[1])) { if (isset(DI::args()->getArgv()[1])) {
@ -77,7 +77,7 @@ function pumpio_content(App $a)
return $o; return $o;
} }
function pumpio_check_item_notification($a, &$notification_data) function pumpio_check_item_notification(App $a, &$notification_data)
{ {
$hostname = DI::pConfig()->get($notification_data["uid"], 'pumpio', 'host'); $hostname = DI::pConfig()->get($notification_data["uid"], 'pumpio', 'host');
$username = DI::pConfig()->get($notification_data["uid"], "pumpio", "user"); $username = DI::pConfig()->get($notification_data["uid"], "pumpio", "user");
@ -686,7 +686,7 @@ function pumpio_cron(App $a, $b)
Worker::add(PRIORITY_MEDIUM,"addon/pumpio/pumpio_sync.php"); Worker::add(PRIORITY_MEDIUM,"addon/pumpio/pumpio_sync.php");
} }
function pumpio_fetchtimeline(App $a, $uid) function pumpio_fetchtimeline(App $a, int $uid)
{ {
$ckey = DI::pConfig()->get($uid, 'pumpio', 'consumer_key'); $ckey = DI::pConfig()->get($uid, 'pumpio', 'consumer_key');
$csecret = DI::pConfig()->get($uid, 'pumpio', 'consumer_secret'); $csecret = DI::pConfig()->get($uid, 'pumpio', 'consumer_secret');
@ -1195,7 +1195,7 @@ function pumpio_dopost(App $a, $client, $uid, $self, $post, $own_id, $threadcomp
return $top_item; return $top_item;
} }
function pumpio_fetchinbox(App $a, $uid) function pumpio_fetchinbox(App $a, int $uid)
{ {
$ckey = DI::pConfig()->get($uid, 'pumpio', 'consumer_key'); $ckey = DI::pConfig()->get($uid, 'pumpio', 'consumer_key');
$csecret = DI::pConfig()->get($uid, 'pumpio', 'consumer_secret'); $csecret = DI::pConfig()->get($uid, 'pumpio', 'consumer_secret');
@ -1254,14 +1254,14 @@ function pumpio_fetchinbox(App $a, $uid)
} }
while ($item = DBA::fetch($lastitems)) { while ($item = DBA::fetch($lastitems)) {
pumpio_fetchallcomments($a, $uid, $item["uri"]); pumpio_fetchallcomments($a, $uid, $item['uri']);
} }
DBA::close($lastitems); DBA::close($lastitems);
DI::pConfig()->set($uid, 'pumpio', 'last_id', $last_id); DI::pConfig()->set($uid, 'pumpio', 'last_id', $last_id);
} }
function pumpio_getallusers(App &$a, $uid) function pumpio_getallusers(App &$a, int $uid)
{ {
$ckey = DI::pConfig()->get($uid, 'pumpio', 'consumer_key'); $ckey = DI::pConfig()->get($uid, 'pumpio', 'consumer_key');
$csecret = DI::pConfig()->get($uid, 'pumpio', 'consumer_secret'); $csecret = DI::pConfig()->get($uid, 'pumpio', 'consumer_secret');

View file

@ -2,10 +2,10 @@
use Friendica\Core\Logger; use Friendica\Core\Logger;
use Friendica\DI; use Friendica\DI;
function pumpio_sync_run($argv, $argc) { function pumpio_sync_run(array $argv, int $argc) {
$a = Friendica\DI::app(); $a = Friendica\DI::app();
require_once("addon/pumpio/pumpio.php"); require_once 'addon/pumpio/pumpio.php';
if (function_exists('sys_getloadavg')) { if (function_exists('sys_getloadavg')) {
$load = sys_getloadavg(); $load = sys_getloadavg();

View file

@ -31,7 +31,7 @@ function qcomment_install()
Hook::register('footer' , __FILE__, 'qcomment_footer'); Hook::register('footer' , __FILE__, 'qcomment_footer');
} }
function qcomment_footer(App $a, &$b) function qcomment_footer(App $a, array &$b)
{ {
DI::page()->registerFooterScript('addon/qcomment/qcomment.js'); DI::page()->registerFooterScript('addon/qcomment/qcomment.js');
} }
@ -57,7 +57,7 @@ function qcomment_addon_settings(App &$a, array &$data)
]; ];
} }
function qcomment_addon_settings_post(&$a, &$b) function qcomment_addon_settings_post(App $a, array &$b)
{ {
if (! local_user()) { if (! local_user()) {
return; return;

View file

@ -25,75 +25,67 @@ use Friendica\Core\Logger;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\DI; use Friendica\DI;
function randplace_install() { function randplace_install()
{
/** /*
*
* Our demo addon will attach in three places. * Our demo addon will attach in three places.
* The first is just prior to storing a local post. * The first is just prior to storing a local post.
*
*/ */
Hook::register('post_local', 'addon/randplace/randplace.php', 'randplace_post_hook'); Hook::register('post_local', 'addon/randplace/randplace.php', 'randplace_post_hook');
/** /*
*
* Then we'll attach into the addon 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 * settings post hook so that we can create and update
* user preferences. * user preferences.
*
*/ */
Hook::register('addon_settings', 'addon/randplace/randplace.php', 'randplace_settings'); Hook::register('addon_settings', 'addon/randplace/randplace.php', 'randplace_settings');
Hook::register('addon_settings_post', 'addon/randplace/randplace.php', 'randplace_settings_post'); Hook::register('addon_settings_post', 'addon/randplace/randplace.php', 'randplace_settings_post');
Logger::notice("installed randplace"); Logger::notice("installed randplace");
} }
function randplace_uninstall()
function randplace_uninstall() { {
/*
/**
*
* This function should undo anything that was done in name_install() * This function should undo anything that was done in name_install()
* *
* Except hooks, they are all unregistered automatically and don't need to be unregistered manually. * Except hooks, they are all unregistered automatically and don't need to be unregistered manually.
*
*/ */
Logger::notice("removed randplace"); Logger::notice("removed randplace");
} }
function randplace_post_hook(App $a, &$item)
{
function randplace_post_hook($a, &$item) { /*
/**
*
* An item was posted on the local system. * An item was posted on the local system.
* We are going to look for specific items: * We are going to look for specific items:
* - A status post by a profile owner * - A status post by a profile owner
* - The profile owner must have allowed our addon * - The profile owner must have allowed our addon
*
*/ */
Logger::notice('randplace invoked'); Logger::notice('randplace invoked');
if(! local_user()) /* non-zero if this is a logged in user of this system */ if (!local_user()) {
/* non-zero if this is a logged in user of this system */
return; return;
}
if(local_user() != $item['uid']) /* Does this person own the post? */ if (local_user() != $item['uid']) {
/* Does this person own the post? */
return; return;
}
if($item['parent']) /* If the item has a parent, this is a comment or something else, not a status post. */ if ($item['parent']) {
/* If the item has a parent, this is a comment or something else, not a status post. */
return; return;
}
/* Retrieve our personal config setting */ /* Retrieve our personal config setting */
$active = DI::pConfig()->get(local_user(), 'randplace', 'enable'); $active = DI::pConfig()->get(local_user(), 'randplace', 'enable');
if(! $active) if (!$active) {
return; return;
}
/** /**
* *
@ -107,47 +99,43 @@ function randplace_post_hook($a, &$item) {
$cities = []; $cities = [];
$zones = timezone_identifiers_list(); $zones = timezone_identifiers_list();
foreach($zones as $zone) { foreach($zones as $zone) {
if((strpos($zone,'/')) && (! stristr($zone,'US/')) && (! stristr($zone,'Etc/'))) if ((strpos($zone, '/')) && (! stristr($zone, 'US/')) && (! stristr($zone, 'Etc/'))) {
$cities[] = str_replace('_', ' ',substr($zone,strpos($zone,'/') + 1)); $cities[] = str_replace('_', ' ',substr($zone, strpos($zone, '/') + 1));
}
} }
if(! count($cities)) if (!count($cities)) {
return; return;
}
$city = array_rand($cities,1); $city = array_rand($cities,1);
$item['location'] = $cities[$city]; $item['location'] = $cities[$city];
return; return;
} }
/** /**
*
* Callback from the settings post function. * Callback from the settings post function.
* $post contains the $_POST array. * $post contains the $_POST array.
* We will make sure we've got a valid user account * We will make sure we've got a valid user account
* and if so set our configuration setting for this person. * and if so set our configuration setting for this person.
*
*/ */
function randplace_settings_post(App $a, $post)
function randplace_settings_post($a,$post) { {
if(! local_user()) if (!local_user()) {
return; return;
if($_POST['randplace-submit']) }
DI::pConfig()->set(local_user(),'randplace','enable',intval($_POST['randplace']));
if ($_POST['randplace-submit']) {
DI::pConfig()->set(local_user(), 'randplace', 'enable', intval($_POST['randplace']));
}
} }
/** /**
*
* Called from the Addon Setting form. * Called from the Addon Setting form.
* Add our own settings info to the page. * Add our own settings info to the page.
*
*/ */
function randplace_settings(App &$a, array &$data) function randplace_settings(App &$a, array &$data)
{ {
if(! local_user()) { if(! local_user()) {

View file

@ -7,6 +7,7 @@
* *
*/ */
use Friendica\App;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\DI; use Friendica\DI;
@ -16,14 +17,17 @@ function rendertime_install() {
DI::config()->set('system', 'profiler', true); DI::config()->set('system', 'profiler', true);
} }
function rendertime_uninstall() { function rendertime_uninstall()
{
DI::config()->delete('system', 'profiler'); DI::config()->delete('system', 'profiler');
} }
function rendertime_init_1(&$a) { function rendertime_init_1(App $a)
{
} }
function rendertime_addon_admin(&$a, &$o) { function rendertime_addon_admin(App $a, &$o)
{
$t = Renderer::getMarkupTemplate("admin.tpl", "addon/rendertime/"); $t = Renderer::getMarkupTemplate("admin.tpl", "addon/rendertime/");
$o = Renderer::replaceMacros($t, [ $o = Renderer::replaceMacros($t, [
@ -33,7 +37,8 @@ function rendertime_addon_admin(&$a, &$o) {
]); ]);
} }
function rendertime_addon_admin_post(&$a) { function rendertime_addon_admin_post(App $a)
{
DI::config()->set('rendertime', 'callstack', $_POST['callstack'] ?? false); DI::config()->set('rendertime', 'callstack', $_POST['callstack'] ?? false);
DI::config()->set('rendertime', 'minimal_time', $_POST['minimal_time'] ?? 0); DI::config()->set('rendertime', 'minimal_time', $_POST['minimal_time'] ?? 0);
} }

View file

@ -14,7 +14,7 @@ use Friendica\DI;
require_once __DIR__ . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php'; require_once __DIR__ . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
function s3_storage_install($a) function s3_storage_install(App $a)
{ {
Hook::register('storage_instance' , __FILE__, 's3_storage_instance'); Hook::register('storage_instance' , __FILE__, 's3_storage_instance');
Hook::register('storage_config' , __FILE__, 's3_storage_config'); Hook::register('storage_config' , __FILE__, 's3_storage_config');

View file

@ -5,6 +5,8 @@
* Version: 1.0 * Version: 1.0
* Author: Ryan <https://friendica.verya.pe/profile/ryan> * Author: Ryan <https://friendica.verya.pe/profile/ryan>
*/ */
use Friendica\App;
use Friendica\Content\Text\BBCode; use Friendica\Content\Text\BBCode;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\Core\Logger; use Friendica\Core\Logger;
@ -14,6 +16,7 @@ use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\User; use Friendica\Model\User;
use Friendica\Util\Strings; use Friendica\Util\Strings;
use OneLogin\Saml2\Utils;
require_once(__DIR__ . '/vendor/autoload.php'); require_once(__DIR__ . '/vendor/autoload.php');
@ -77,12 +80,12 @@ function saml_install()
Hook::register('footer', __FILE__, 'saml_footer'); Hook::register('footer', __FILE__, 'saml_footer');
} }
function saml_head(&$a, &$b) function saml_head(App $a, array &$b)
{ {
DI::page()->registerStylesheet(__DIR__ . '/saml.css'); DI::page()->registerStylesheet(__DIR__ . '/saml.css');
} }
function saml_footer(&$a, &$b) function saml_footer(App $a, array &$b)
{ {
$fragment = addslashes(BBCode::convert(DI::config()->get('saml', 'settings_statement'))); $fragment = addslashes(BBCode::convert(DI::config()->get('saml', 'settings_statement')));
$b .= <<<EOL $b .= <<<EOL
@ -106,7 +109,7 @@ function saml_is_configured()
DI::config()->get('saml', 'idp_cert'); DI::config()->get('saml', 'idp_cert');
} }
function saml_sso_initiate(&$a, &$b) function saml_sso_initiate(App $a, array &$b)
{ {
if (!saml_is_configured()) { if (!saml_is_configured()) {
Logger::warning('SAML SSO tried to trigger, but the SAML addon is not configured yet!'); Logger::warning('SAML SSO tried to trigger, but the SAML addon is not configured yet!');
@ -166,13 +169,12 @@ function saml_sso_reply($a)
DI::auth()->setForUser($a, $user); DI::auth()->setForUser($a, $user);
} }
if (isset($_POST['RelayState']) if (isset($_POST['RelayState']) && Utils::getSelfURL() != $_POST['RelayState']) {
&& \OneLogin\Saml2\Utils::getSelfURL() != $_POST['RelayState']) {
$auth->redirectTo($_POST['RelayState']); $auth->redirectTo($_POST['RelayState']);
} }
} }
function saml_slo_initiate(&$a, &$b) function saml_slo_initiate(App $a, array &$b)
{ {
if (!saml_is_configured()) { if (!saml_is_configured()) {
Logger::warning('SAML SLO tried to trigger, but the SAML addon is not configured yet!'); Logger::warning('SAML SLO tried to trigger, but the SAML addon is not configured yet!');
@ -223,7 +225,7 @@ function saml_input($key, $label, $description)
]; ];
} }
function saml_addon_admin(&$a, &$o) function saml_addon_admin(App $a, &$o)
{ {
$form = $form =
saml_input( saml_input(
@ -279,7 +281,7 @@ function saml_addon_admin(&$a, &$o)
$o = Renderer::replaceMacros($t, $form); $o = Renderer::replaceMacros($t, $form);
} }
function saml_addon_admin_post(&$a) function saml_addon_admin_post(App $a)
{ {
$set = function ($key) { $set = function ($key) {
$val = (!empty($_POST[$key]) ? trim($_POST[$key]) : ''); $val = (!empty($_POST[$key]) ? trim($_POST[$key]) : '');

View file

@ -45,7 +45,7 @@ function showmore_addon_settings(App &$a, array &$data)
]; ];
} }
function showmore_addon_settings_post(&$a, &$b) function showmore_addon_settings_post(App $a, array &$b)
{ {
if (!local_user()) { if (!local_user()) {
return; return;

View file

@ -24,12 +24,12 @@ function showmore_dyn_install()
Hook::register('addon_settings_post', __FILE__, 'showmore_dyn_settings_post'); Hook::register('addon_settings_post', __FILE__, 'showmore_dyn_settings_post');
} }
function showmore_dyn_head(App $a, &$b) function showmore_dyn_head(App $a, array &$b)
{ {
DI::page()->registerStylesheet(__DIR__ . '/showmore_dyn.css'); DI::page()->registerStylesheet(__DIR__ . '/showmore_dyn.css');
} }
function showmore_dyn_footer(App $a, &$b) function showmore_dyn_footer(App $a, array &$b)
{ {
DI::page()->registerFooterScript(__DIR__ . '/showmore_dyn.js'); DI::page()->registerFooterScript(__DIR__ . '/showmore_dyn.js');
} }

View file

@ -6,6 +6,8 @@
* Author: Thomas Willingham (based on Mike Macgirvin's Adult Smile template) * Author: Thomas Willingham (based on Mike Macgirvin's Adult Smile template)
* All smileys from sites offering them as Public Domain * All smileys from sites offering them as Public Domain
*/ */
use Friendica\App;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\DI; use Friendica\DI;
@ -13,7 +15,7 @@ function smiley_pack_es_install() {
Hook::register('smilie', 'addon/smiley_pack_es/smiley_pack_es.php', 'smiley_pack_smilies_es'); Hook::register('smilie', 'addon/smiley_pack_es/smiley_pack_es.php', 'smiley_pack_smilies_es');
} }
function smiley_pack_smilies_es(&$a,&$b) { function smiley_pack_smilies_es(App $a, array &$b) {
#Smileys are split into various directories by the intended range of emotions. This is in case we get too big and need to modularise things. We can then cut and paste the right lines, move the right directory, and just change the name of the addon to happy_smilies or whatever. #Smileys are split into various directories by the intended range of emotions. This is in case we get too big and need to modularise things. We can then cut and paste the right lines, move the right directory, and just change the name of the addon to happy_smilies or whatever.

View file

@ -8,14 +8,18 @@
* *
* *
*/ */
use Friendica\App;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\DI; use Friendica\DI;
function smiley_pack_fr_install() { function smiley_pack_fr_install()
{
Hook::register('smilie', 'addon/smiley_pack_fr/smiley_pack_fr.php', 'smiley_pack_fr_smilies'); Hook::register('smilie', 'addon/smiley_pack_fr/smiley_pack_fr.php', 'smiley_pack_fr_smilies');
} }
function smiley_pack_fr_smilies(&$a,&$b) { function smiley_pack_fr_smilies(App $a, array &$b)
{
#Smileys are split into various directories by the intended range of emotions. This is in case we get too big and need to modularise things. We can then cut and paste the right lines, move the right directory, and just change the name of the addon to happy_smilies or whatever. #Smileys are split into various directories by the intended range of emotions. This is in case we get too big and need to modularise things. We can then cut and paste the right lines, move the right directory, and just change the name of the addon to happy_smilies or whatever.
@ -400,5 +404,4 @@ function smiley_pack_fr_smilies(&$a,&$b) {
$b['texts'][] = ':tête'; $b['texts'][] = ':tête';
$b['icons'][] = '<img src="' . DI::baseUrl()->get() . '/addon/smiley_pack/icons/oldcore/headbang.gif' . '" alt="' . ':tête' . '" />'; $b['icons'][] = '<img src="' . DI::baseUrl()->get() . '/addon/smiley_pack/icons/oldcore/headbang.gif' . '" alt="' . ':tête' . '" />';
} }

View file

@ -8,6 +8,7 @@
* All smileys from sites offering them as Public Domain * All smileys from sites offering them as Public Domain
*/ */
use Friendica\App;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\DI; use Friendica\DI;
@ -15,8 +16,8 @@ function smiley_pack_install() {
Hook::register('smilie', 'addon/smiley_pack/smiley_pack.php', 'smiley_pack_smilies'); Hook::register('smilie', 'addon/smiley_pack/smiley_pack.php', 'smiley_pack_smilies');
} }
function smiley_pack_smilies(&$a,&$b) { function smiley_pack_smilies(App $a, array &$b)
{
#Smileys are split into various directories by the intended range of emotions. This is in case we get too big and need to modularise things. We can then cut and paste the right lines, move the right directory, and just change the name of the addon to happy_smilies or whatever. #Smileys are split into various directories by the intended range of emotions. This is in case we get too big and need to modularise things. We can then cut and paste the right lines, move the right directory, and just change the name of the addon to happy_smilies or whatever.
#Be careful with invocation strings. If you have a smiley called foo, and another called foobar, typing :foobar will call foo. Avoid this with clever naming, using ~ instead of : #Be careful with invocation strings. If you have a smiley called foo, and another called foobar, typing :foobar will call foo. Avoid this with clever naming, using ~ instead of :
@ -538,5 +539,4 @@ function smiley_pack_smilies(&$a,&$b) {
$b['texts'][] = ':twitch:'; $b['texts'][] = ':twitch:';
$b['icons'][] = '<img class="smiley" src="' . DI::baseUrl()->get() . '/addon/smiley_pack/icons/commercial/twitch.gif' . '" alt="' . ':twitch:' . '" />'; $b['icons'][] = '<img class="smiley" src="' . DI::baseUrl()->get() . '/addon/smiley_pack/icons/commercial/twitch.gif' . '" alt="' . ':twitch:' . '" />';
} }

View file

@ -16,7 +16,7 @@ function smileybutton_install()
Hook::register('jot_tool', 'addon/smileybutton/smileybutton.php', 'smileybutton_jot_tool'); Hook::register('jot_tool', 'addon/smileybutton/smileybutton.php', 'smileybutton_jot_tool');
} }
function smileybutton_jot_tool(Friendica\App $a, &$b) function smileybutton_jot_tool(Friendica\App $a, array &$b)
{ {
// Disable if theme is quattro // Disable if theme is quattro
// TODO add style for quattro // TODO add style for quattro

View file

@ -8,6 +8,8 @@
* This is a template for how to extend the "smily" code. * This is a template for how to extend the "smily" code.
* *
*/ */
use Friendica\App;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\DI; use Friendica\DI;
@ -15,8 +17,8 @@ function smilies_adult_install() {
Hook::register('smilie', 'addon/smilies_adult/smilies_adult.php', 'smilies_adult_smilies'); Hook::register('smilie', 'addon/smilies_adult/smilies_adult.php', 'smilies_adult_smilies');
} }
function smilies_adult_smilies(&$a,&$b) { function smilies_adult_smilies(App $a, array &$b)
{
$b['texts'][] = '(o)(o)'; $b['texts'][] = '(o)(o)';
$b['icons'][] = '<img class="smiley" src="' . DI::baseUrl()->get() . '/addon/smilies_adult/icons/tits.gif' . '" alt="' . '(o)(o)' . '" />'; $b['icons'][] = '<img class="smiley" src="' . DI::baseUrl()->get() . '/addon/smilies_adult/icons/tits.gif' . '" alt="' . '(o)(o)' . '" />';
@ -34,5 +36,4 @@ function smilies_adult_smilies(&$a,&$b) {
$b['texts'][] = ':finger'; $b['texts'][] = ':finger';
$b['icons'][] = '<img class="smiley" src="' . DI::baseUrl()->get() . '/addon/smilies_adult/icons/finger.gif' . '" alt="' . ':finger' . '" />'; $b['icons'][] = '<img class="smiley" src="' . DI::baseUrl()->get() . '/addon/smilies_adult/icons/finger.gif' . '" alt="' . ':finger' . '" />';
} }

View file

@ -18,7 +18,7 @@ function startpage_install() {
Hook::register('addon_settings_post', 'addon/startpage/startpage.php', 'startpage_settings_post'); Hook::register('addon_settings_post', 'addon/startpage/startpage.php', 'startpage_settings_post');
} }
function startpage_home_init($a, $b) function startpage_home_init(App $a, $b)
{ {
if (!local_user()) { if (!local_user()) {
return; return;
@ -40,7 +40,7 @@ function startpage_home_init($a, $b)
* *
*/ */
function startpage_settings_post($a, $post) function startpage_settings_post(App $a, $post)
{ {
if (!local_user()) { if (!local_user()) {
return; return;

View file

@ -373,7 +373,7 @@ function statusnet_hook_fork(App $a, array &$b)
} }
} }
function statusnet_post_local(App $a, &$b) function statusnet_post_local(App $a, array &$b)
{ {
if ($b['edit']) { if ($b['edit']) {
return; return;
@ -430,7 +430,7 @@ function statusnet_action(App $a, $uid, $pid, $action)
Logger::info('statusnet_action "' . $action . '" send, result: ' . print_r($result, true)); Logger::info('statusnet_action "' . $action . '" send, result: ' . print_r($result, true));
} }
function statusnet_post_hook(App $a, &$b) function statusnet_post_hook(App $a, array &$b)
{ {
/** /**
* Post to GNU Social * Post to GNU Social
@ -661,7 +661,7 @@ function statusnet_addon_admin(App $a, &$o)
]); ]);
} }
function statusnet_prepare_body(App $a, &$b) function statusnet_prepare_body(App $a, array &$b)
{ {
if ($b['item']['network'] != Protocol::STATUSNET) { if ($b['item']['network'] != Protocol::STATUSNET) {
return; return;
@ -753,7 +753,7 @@ function statusnet_cron(App $a, $b)
DI::config()->set('statusnet', 'last_poll', time()); DI::config()->set('statusnet', 'last_poll', time());
} }
function statusnet_fetchtimeline(App $a, $uid) function statusnet_fetchtimeline(App $a, int $uid)
{ {
$ckey = DI::pConfig()->get($uid, 'statusnet', 'consumerkey'); $ckey = DI::pConfig()->get($uid, 'statusnet', 'consumerkey');
$csecret = DI::pConfig()->get($uid, 'statusnet', 'consumersecret'); $csecret = DI::pConfig()->get($uid, 'statusnet', 'consumersecret');
@ -1011,7 +1011,7 @@ function statusnet_fetchuser(App $a, $uid, $screen_name = '', $user_id = '')
return $contact_id; return $contact_id;
} }
function statusnet_createpost(App $a, $uid, $post, $self, $create_user, $only_existing_contact) function statusnet_createpost(App $a, int $uid, $post, $self, $create_user, bool $only_existing_contact)
{ {
Logger::info('statusnet_createpost: start'); Logger::info('statusnet_createpost: start');
@ -1415,7 +1415,7 @@ function statusnet_convertmsg(App $a, $body)
return $body; return $body;
} }
function statusnet_fetch_own_contact(App $a, $uid) function statusnet_fetch_own_contact(App $a, int $uid)
{ {
$ckey = DI::pConfig()->get($uid, 'statusnet', 'consumerkey'); $ckey = DI::pConfig()->get($uid, 'statusnet', 'consumerkey');
$csecret = DI::pConfig()->get($uid, 'statusnet', 'consumersecret'); $csecret = DI::pConfig()->get($uid, 'statusnet', 'consumersecret');
@ -1450,7 +1450,7 @@ function statusnet_fetch_own_contact(App $a, $uid)
return $contact_id; return $contact_id;
} }
function statusnet_is_retweet(App $a, $uid, $body) function statusnet_is_retweet(App $a, int $uid, string $body)
{ {
$body = trim($body); $body = trim($body);

View file

@ -42,7 +42,7 @@ function superblock_addon_settings(App &$a, array &$data)
]; ];
} }
function superblock_addon_settings_post(&$a, &$b) function superblock_addon_settings_post(App $a, array &$b)
{ {
if (!local_user()) { if (!local_user()) {
return; return;
@ -53,7 +53,8 @@ function superblock_addon_settings_post(&$a, &$b)
} }
} }
function superblock_enotify_store(&$a,&$b) { function superblock_enotify_store(App $a, array &$b)
{
if (empty($b['uid'])) { if (empty($b['uid'])) {
return; return;
} }
@ -78,6 +79,7 @@ function superblock_enotify_store(&$a,&$b) {
} }
} }
} }
if ($found) { if ($found) {
// Empty out the fields // Empty out the fields
$b = []; $b = [];
@ -85,7 +87,7 @@ function superblock_enotify_store(&$a,&$b) {
} }
function superblock_conversation_start(&$a, &$b) function superblock_conversation_start(App $a, array &$b)
{ {
if (!local_user()) { if (!local_user()) {
return; return;
@ -95,8 +97,8 @@ function superblock_conversation_start(&$a, &$b)
if ($words) { if ($words) {
$a->data['superblock'] = explode(',', $words); $a->data['superblock'] = explode(',', $words);
} }
DI::page()['htmlhead'] .= <<< EOT
DI::page()['htmlhead'] .= <<< EOT
<script> <script>
function superblockBlock(author) { function superblockBlock(author) {
$.get('superblock?block=' +author, function(data) { $.get('superblock?block=' +author, function(data) {
@ -104,12 +106,11 @@ function superblockBlock(author) {
}); });
} }
</script> </script>
EOT; EOT;
} }
function superblock_item_photo_menu(&$a, &$b) function superblock_item_photo_menu(App $a, array &$b)
{ {
if (!local_user() || $b['item']['self']) { if (!local_user() || $b['item']['self']) {
return; return;
@ -132,7 +133,7 @@ function superblock_item_photo_menu(&$a, &$b)
function superblock_module() {} function superblock_module() {}
function superblock_init(&$a) function superblock_init(App $a)
{ {
if (!local_user()) { if (!local_user()) {
return; return;

View file

@ -16,14 +16,13 @@ use Friendica\Model\User;
use Friendica\Core\Config\Util\ConfigFileLoader; use Friendica\Core\Config\Util\ConfigFileLoader;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
function testdrive_install() { function testdrive_install()
{
Hook::register('load_config', 'addon/testdrive/testdrive.php', 'testdrive_load_config'); Hook::register('load_config', 'addon/testdrive/testdrive.php', 'testdrive_load_config');
Hook::register('register_account', 'addon/testdrive/testdrive.php', 'testdrive_register_account'); Hook::register('register_account', 'addon/testdrive/testdrive.php', 'testdrive_register_account');
Hook::register('cron', 'addon/testdrive/testdrive.php', 'testdrive_cron'); Hook::register('cron', 'addon/testdrive/testdrive.php', 'testdrive_cron');
Hook::register('enotify','addon/testdrive/testdrive.php', 'testdrive_enotify'); Hook::register('enotify','addon/testdrive/testdrive.php', 'testdrive_enotify');
Hook::register('globaldir_update','addon/testdrive/testdrive.php', 'testdrive_globaldir_update'); Hook::register('globaldir_update','addon/testdrive/testdrive.php', 'testdrive_globaldir_update');
} }
function testdrive_load_config(App $a, ConfigFileLoader $loader) function testdrive_load_config(App $a, ConfigFileLoader $loader)
@ -31,26 +30,30 @@ function testdrive_load_config(App $a, ConfigFileLoader $loader)
$a->getConfigCache()->load($loader->loadAddonConfig('testdrive')); $a->getConfigCache()->load($loader->loadAddonConfig('testdrive'));
} }
function testdrive_globaldir_update($a,&$b) { function testdrive_globaldir_update(App $a, array &$b)
{
$b['url'] = ''; $b['url'] = '';
} }
function testdrive_register_account($a,$b) { function testdrive_register_account(App $a, $b)
{
$uid = $b; $uid = $b;
$days = DI::config()->get('testdrive','expiredays'); $days = DI::config()->get('testdrive','expiredays');
if(! $days) if (!$days) {
return; return;
}
DBA::update('user', ['account_expires_on' => DateTimeFormat::convert('now +' . $days . ' days')], ['uid' => $uid]); DBA::update('user', ['account_expires_on' => DateTimeFormat::convert('now +' . $days . ' days')], ['uid' => $uid]);
}; }
function testdrive_cron($a,$b) { function testdrive_cron(App $a, $b)
{
$users = DBA::selectToArray('user', [], ["`account_expires_on` < ? AND `expire_notification_sent` <= ?", $users = DBA::selectToArray('user', [], ["`account_expires_on` < ? AND `expire_notification_sent` <= ?",
DateTimeFormat::utc('now + 5 days'), DBA::NULL_DATETIME]); DateTimeFormat::utc('now + 5 days'), DBA::NULL_DATETIME]);
foreach($users as $rr) {
foreach ($users as $rr) {
DI::notify()->createFromArray([ DI::notify()->createFromArray([
'type' => Notification\Type::SYSTEM, 'type' => Notification\Type::SYSTEM,
'uid' => $rr['uid'], 'uid' => $rr['uid'],
@ -69,7 +72,8 @@ function testdrive_cron($a,$b) {
} }
} }
function testdrive_enotify(&$a, &$b) { function testdrive_enotify(App $a, array &$b)
{
if (!empty($b['params']) && $b['params']['type'] == Notification\Type::SYSTEM if (!empty($b['params']) && $b['params']['type'] == Notification\Type::SYSTEM
&& !empty($b['params']['system_type']) && $b['params']['system_type'] === 'testdrive_expire') { && !empty($b['params']['system_type']) && $b['params']['system_type'] === 'testdrive_expire') {
$b['itemlink'] = DI::baseUrl()->get(); $b['itemlink'] = DI::baseUrl()->get();

View file

@ -5,27 +5,27 @@
* Version: 1.0 * Version: 1.0
* Author: Mike Macgirvin <http://macgirvin.com/profile/mike> * Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
*/ */
use Friendica\App;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\DI; use Friendica\DI;
function tictac_install() { function tictac_install()
{
Hook::register('app_menu', 'addon/tictac/tictac.php', 'tictac_app_menu'); Hook::register('app_menu', 'addon/tictac/tictac.php', 'tictac_app_menu');
} }
function tictac_app_menu($a,&$b) { function tictac_app_menu(App $a, array &$b)
{
$b['app_menu'][] = '<div class="app-title"><a href="tictac">' . DI::l10n()->t('Three Dimensional Tic-Tac-Toe') . '</a></div>'; $b['app_menu'][] = '<div class="app-title"><a href="tictac">' . DI::l10n()->t('Three Dimensional Tic-Tac-Toe') . '</a></div>';
} }
function tictac_module()
function tictac_module() { {
return; return;
} }
function tictac_content(App $a) {
function tictac_content(&$a) {
$o = ''; $o = '';

View file

@ -257,7 +257,7 @@ function tumblr_settings_post(App $a, array &$b)
} }
} }
function tumblr_hook_fork(&$a, &$b) function tumblr_hook_fork(App $a, array &$b)
{ {
if ($b['name'] != 'notifier_normal') { if ($b['name'] != 'notifier_normal') {
return; return;

View file

@ -1149,7 +1149,7 @@ function twitter_parse_link(App $a, array &$b)
* *
* @return array item data to be posted * @return array item data to be posted
*/ */
function twitter_do_mirrorpost(App $a, $uid, $post) function twitter_do_mirrorpost(App $a, int $uid, $post)
{ {
$datarray['uid'] = $uid; $datarray['uid'] = $uid;
$datarray['extid'] = 'twitter::' . $post->id; $datarray['extid'] = 'twitter::' . $post->id;
@ -1196,7 +1196,7 @@ function twitter_do_mirrorpost(App $a, $uid, $post)
return $datarray; return $datarray;
} }
function twitter_fetchtimeline(App $a, $uid) function twitter_fetchtimeline(App $a, int $uid)
{ {
$ckey = DI::config()->get('twitter', 'consumerkey'); $ckey = DI::config()->get('twitter', 'consumerkey');
$csecret = DI::config()->get('twitter', 'consumersecret'); $csecret = DI::config()->get('twitter', 'consumersecret');
@ -1740,7 +1740,7 @@ function twitter_media_entities($post, array &$postarray, int $uriid = -1)
* @param integer $uriid URI Id used to store tags. 0 = create a new one; -1 = don't store tags for this post. * @param integer $uriid URI Id used to store tags. 0 = create a new one; -1 = don't store tags for this post.
* @return array item array * @return array item array
*/ */
function twitter_createpost(App $a, $uid, $post, array $self, $create_user, $only_existing_contact, $noquote, int $uriid = 0) function twitter_createpost(App $a, int $uid, $post, array $self, $create_user, bool $only_existing_contact, $noquote, int $uriid = 0)
{ {
$postarray = []; $postarray = [];
$postarray['network'] = Protocol::TWITTER; $postarray['network'] = Protocol::TWITTER;
@ -1951,7 +1951,7 @@ function twitter_store_tags(int $uriid, array $taglist)
} }
} }
function twitter_fetchparentposts(App $a, $uid, $post, TwitterOAuth $connection, array $self) function twitter_fetchparentposts(App $a, int $uid, $post, TwitterOAuth $connection, array $self)
{ {
Logger::info('Fetching parent posts', ['user' => $uid, 'post' => $post->id_str]); Logger::info('Fetching parent posts', ['user' => $uid, 'post' => $post->id_str]);
@ -2003,7 +2003,7 @@ function twitter_fetchparentposts(App $a, $uid, $post, TwitterOAuth $connection,
} }
} }
function twitter_fetchhometimeline(App $a, $uid) function twitter_fetchhometimeline(App $a, int $uid)
{ {
$ckey = DI::config()->get('twitter', 'consumerkey'); $ckey = DI::config()->get('twitter', 'consumerkey');
$csecret = DI::config()->get('twitter', 'consumersecret'); $csecret = DI::config()->get('twitter', 'consumersecret');
@ -2192,7 +2192,7 @@ function twitter_fetchhometimeline(App $a, $uid)
Logger::info('Last mentions ID for user ' . $uid . ' is now ' . $lastid); Logger::info('Last mentions ID for user ' . $uid . ' is now ' . $lastid);
} }
function twitter_fetch_own_contact(App $a, $uid) function twitter_fetch_own_contact(App $a, int $uid)
{ {
$ckey = DI::config()->get('twitter', 'consumerkey'); $ckey = DI::config()->get('twitter', 'consumerkey');
$csecret = DI::config()->get('twitter', 'consumersecret'); $csecret = DI::config()->get('twitter', 'consumersecret');
@ -2228,7 +2228,7 @@ function twitter_fetch_own_contact(App $a, $uid)
return $contact_id; return $contact_id;
} }
function twitter_is_retweet(App $a, $uid, $body) function twitter_is_retweet(App $a, int $uid, string $body)
{ {
$body = trim($body); $body = trim($body);
@ -2283,7 +2283,7 @@ function twitter_retweet(int $uid, int $id, int $item_id = 0)
return !isset($result->errors); return !isset($result->errors);
} }
function twitter_update_mentions($body) function twitter_update_mentions(string $body): string
{ {
$URLSearchString = '^\[\]'; $URLSearchString = '^\[\]';
$return = preg_replace_callback( $return = preg_replace_callback(
@ -2303,7 +2303,7 @@ function twitter_update_mentions($body)
return $return; return $return;
} }
function twitter_convert_share(array $attributes, array $author_contact, $content, $is_quote_share) function twitter_convert_share(array $attributes, array $author_contact, string $content, bool $is_quote_share): string
{ {
if (empty($author_contact)) { if (empty($author_contact)) {
return $content . "\n\n" . $attributes['link']; return $content . "\n\n" . $attributes['link'];

View file

@ -6,6 +6,8 @@
* Author: Michael Vogel <http://pirati.ca/profile/heluecht> * Author: Michael Vogel <http://pirati.ca/profile/heluecht>
* Author: Matthias Ebers <https://loma.ml/profile/one> * Author: Matthias Ebers <https://loma.ml/profile/one>
*/ */
use Friendica\App;
use Friendica\Content\Smilies; use Friendica\Content\Smilies;
use Friendica\Core\Hook; use Friendica\Core\Hook;
@ -13,7 +15,8 @@ function unicode_smilies_install() {
Hook::register('smilie', 'addon/unicode_smilies/unicode_smilies.php', 'unicode_smilies_smilies'); Hook::register('smilie', 'addon/unicode_smilies/unicode_smilies.php', 'unicode_smilies_smilies');
} }
function unicode_smilies_smilies(&$a,&$b) { function unicode_smilies_smilies(App $a, array &$b)
{
Smilies::add($b, ':-)', '&#x1F600;'); Smilies::add($b, ':-)', '&#x1F600;');
Smilies::add($b, ':)', '&#x1F600;'); Smilies::add($b, ':)', '&#x1F600;');
Smilies::add($b, ':-(', '&#x1F641;'); Smilies::add($b, ':-(', '&#x1F641;');

View file

@ -6,6 +6,8 @@
* Author: Mike Macgirvin <http://macgirvin.com/profile/mike> * Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
* *
*/ */
use Friendica\App;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\DI; use Friendica\DI;
@ -14,7 +16,7 @@ function viewsrc_install() {
Hook::register('page_end', 'addon/viewsrc/viewsrc.php', 'viewsrc_page_end'); Hook::register('page_end', 'addon/viewsrc/viewsrc.php', 'viewsrc_page_end');
} }
function viewsrc_page_end(&$a, &$o){ function viewsrc_page_end(App $a, &$o){
DI::page()['htmlhead'] .= <<< EOS DI::page()['htmlhead'] .= <<< EOS
<script> <script>
$(function(){ $(function(){
@ -26,7 +28,7 @@ function viewsrc_page_end(&$a, &$o){
EOS; EOS;
} }
function viewsrc_item_photo_menu(&$a, &$b) function viewsrc_item_photo_menu(App $a, array &$b)
{ {
if (!local_user()) { if (!local_user()) {
return; return;

View file

@ -6,6 +6,8 @@
* Author: Stephen Mahood <https://friends.mayfirst.org/profile/marxistvegan> * Author: Stephen Mahood <https://friends.mayfirst.org/profile/marxistvegan>
* Author: Tobias Diekershoff <https://f.diekershoff.de/profile/tobias> * Author: Tobias Diekershoff <https://f.diekershoff.de/profile/tobias>
*/ */
use Friendica\App;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\DI; use Friendica\DI;
@ -14,18 +16,21 @@ function webrtc_install() {
Hook::register('app_menu', 'addon/webrtc/webrtc.php', 'webrtc_app_menu'); Hook::register('app_menu', 'addon/webrtc/webrtc.php', 'webrtc_app_menu');
} }
function webrtc_app_menu($a,&$b) { function webrtc_app_menu(App $a, array &$b)
{
$b['app_menu'][] = '<div class="app-title"><a href="webrtc">' . DI::l10n()->t('WebRTC Videochat') . '</a></div>'; $b['app_menu'][] = '<div class="app-title"><a href="webrtc">' . DI::l10n()->t('WebRTC Videochat') . '</a></div>';
} }
function webrtc_addon_admin (&$a, &$o) { function webrtc_addon_admin (App $a, &$o)
{
$t = Renderer::getMarkupTemplate( "admin.tpl", "addon/webrtc/" ); $t = Renderer::getMarkupTemplate( "admin.tpl", "addon/webrtc/" );
$o = Renderer::replaceMacros( $t, [ $o = Renderer::replaceMacros( $t, [
'$submit' => DI::l10n()->t('Save Settings'), '$submit' => DI::l10n()->t('Save Settings'),
'$webrtcurl' => ['webrtcurl', DI::l10n()->t('WebRTC Base URL'), DI::config()->get('webrtc','webrtcurl' ), DI::l10n()->t('Page your users will create a WebRTC chat room on. For example you could use https://live.mayfirst.org .')], '$webrtcurl' => ['webrtcurl', DI::l10n()->t('WebRTC Base URL'), DI::config()->get('webrtc','webrtcurl' ), DI::l10n()->t('Page your users will create a WebRTC chat room on. For example you could use https://live.mayfirst.org .')],
]); ]);
} }
function webrtc_addon_admin_post (&$a) { function webrtc_addon_admin_post (App $a)
{
$url = trim($_POST['webrtcurl'] ?? ''); $url = trim($_POST['webrtcurl'] ?? '');
DI::config()->set('webrtc', 'webrtcurl', $url); DI::config()->set('webrtc', 'webrtcurl', $url);
} }
@ -34,7 +39,8 @@ function webrtc_module() {
return; return;
} }
function webrtc_content(&$a) { function webrtc_content(App $a)
{
$o = ''; $o = '';
/* landingpage to create chatrooms */ /* landingpage to create chatrooms */
@ -49,6 +55,5 @@ function webrtc_content(&$a) {
$o .= '<iframe src="'.$webrtcurl.'" width="600px" height="600px"></iframe>'; $o .= '<iframe src="'.$webrtcurl.'" width="600px" height="600px"></iframe>';
} }
return $o; return $o;
} }

View file

@ -70,7 +70,7 @@ function windowsphonepush_module()
* We will make sure we've got a valid user account * We will make sure we've got a valid user account
* and if so set our configuration setting for this person. * and if so set our configuration setting for this person.
*/ */
function windowsphonepush_settings_post($a, $post) function windowsphonepush_settings_post(App $a, $post)
{ {
if (!local_user() || empty($_POST['windowsphonepush-submit'])) { if (!local_user() || empty($_POST['windowsphonepush-submit'])) {
return; return;

View file

@ -82,7 +82,7 @@ function wppost_settings(App &$a, array &$data)
} }
function wppost_settings_post(&$a, &$b) function wppost_settings_post(App $a, array &$b)
{ {
if(!empty($_POST['wppost-submit'])) { if(!empty($_POST['wppost-submit'])) {
DI::pConfig()->set(local_user(), 'wppost', 'post' , intval($_POST['wppost'])); DI::pConfig()->set(local_user(), 'wppost', 'post' , intval($_POST['wppost']));
@ -98,7 +98,7 @@ function wppost_settings_post(&$a, &$b)
} }
} }
function wppost_hook_fork(&$a, &$b) function wppost_hook_fork(App $a, array &$b)
{ {
if ($b['name'] != 'notifier_normal') { if ($b['name'] != 'notifier_normal') {
return; return;
@ -113,7 +113,7 @@ function wppost_hook_fork(&$a, &$b)
} }
} }
function wppost_post_local(&$a, &$b) { function wppost_post_local(App $a, array &$b) {
// This can probably be changed to allow editing by pointing to a different API endpoint // This can probably be changed to allow editing by pointing to a different API endpoint
@ -151,7 +151,7 @@ function wppost_post_local(&$a, &$b) {
function wppost_send(&$a, &$b) function wppost_send(App $a, array &$b)
{ {
if($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) { if($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) {
return; return;