Merge pull request #1265 from Quix0r/rewrites/double-quotes-single

Rewrites/double quotes single
This commit is contained in:
Hypolite Petovan 2022-06-24 18:49:05 -04:00 committed by GitHub
commit 3c5d0dc0cd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
83 changed files with 1422 additions and 1272 deletions

View file

@ -64,7 +64,7 @@ function advancedcontentfilter_install(App $a)
Hook::add('dbstructure_definition' , __FILE__, 'advancedcontentfilter_dbstructure_definition');
DBStructure::performUpdate();
Logger::notice("installed advancedcontentfilter");
Logger::notice('installed advancedcontentfilter');
}
/*
@ -73,20 +73,20 @@ function advancedcontentfilter_install(App $a)
function advancedcontentfilter_dbstructure_definition(App $a, &$database)
{
$database["advancedcontentfilter_rules"] = [
"comment" => "Advancedcontentfilter addon rules",
"fields" => [
"id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "Auto incremented rule id"],
"uid" => ["type" => "int unsigned", "not null" => "1", "comment" => "Owner user id"],
"name" => ["type" => "varchar(255)", "not null" => "1", "comment" => "Rule name"],
"expression" => ["type" => "mediumtext" , "not null" => "1", "comment" => "Expression text"],
"serialized" => ["type" => "mediumtext" , "not null" => "1", "comment" => "Serialized parsed expression"],
"active" => ["type" => "boolean" , "not null" => "1", "default" => "1", "comment" => "Whether the rule is active or not"],
"created" => ["type" => "datetime" , "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "Creation date"],
$database['advancedcontentfilter_rules'] = [
'comment' => 'Advancedcontentfilter addon rules',
'fields' => [
'id' => ['type' => 'int unsigned', 'not null' => '1', 'extra' => 'auto_increment', 'primary' => '1', 'comment' => 'Auto incremented rule id'],
'uid' => ['type' => 'int unsigned', 'not null' => '1', 'comment' => 'Owner user id'],
'name' => ['type' => 'varchar(255)', 'not null' => '1', 'comment' => 'Rule name'],
'expression' => ['type' => 'mediumtext' , 'not null' => '1', 'comment' => 'Expression text'],
'serialized' => ['type' => 'mediumtext' , 'not null' => '1', 'comment' => 'Serialized parsed expression'],
'active' => ['type' => 'boolean' , 'not null' => '1', 'default' => '1', 'comment' => 'Whether the rule is active or not'],
'created' => ['type' => 'datetime' , 'not null' => '1', 'default' => DBA::NULL_DATETIME, 'comment' => 'Creation date'],
],
"indexes" => [
"PRIMARY" => ["id"],
"uid_active" => ["uid", "active"],
'indexes' => [
'PRIMARY' => ['id'],
'uid_active' => ['uid', 'active'],
]
];
}
@ -180,6 +180,11 @@ function advancedcontentfilter_addon_settings(App $a, array &$data)
* Module
*/
/**
* This is a statement rather than an actual function definition. The simple
* existence of this method is checked to figure out if the addon offers a
* module.
*/
function advancedcontentfilter_module() {}
function advancedcontentfilter_init(App $a)

View file

@ -117,7 +117,7 @@ function birdavatar_addon_settings_post(App $a, &$s)
* @param $a 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']]);
if (DBA::isResult($user)) {
@ -136,9 +136,12 @@ function birdavatar_lookup(App $a, &$b)
$b['success'] = true;
}
function birdavatar_module()
{
}
/**
* This is a statement rather than an actual function definition. The simple
* existence of this method is checked to figure out if the addon offers a
* module.
*/
function birdavatar_module() {}
/**
* Returns image for user id

View file

@ -44,6 +44,7 @@
* THE SOFTWARE.
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
@ -54,7 +55,8 @@ function blackout_install() {
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 (local_user()) {
return true;
@ -74,25 +76,26 @@ function blackout_redirect ($a, $b) {
$date1 = 0;
$date2 = 0;
}
if (( $date1 <= $now ) && ( $now <= $date2 )) {
Logger::notice('redirecting user to blackout page');
System::externalRedirect($myurl);
}
}
function blackout_addon_admin(&$a, &$o) {
function blackout_addon_admin(App $a, &$o) {
$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');
if (! is_string($myend)) { $myend = "YYYY-MM-DD hh:mm"; }
if (! is_string($myend)) { $myend = 'YYYY-MM-DD hh:mm'; }
$myurl = DI::config()->get('blackout','url');
if (! is_string($myurl)) { $myurl = "https://www.example.com"; }
$t = Renderer::getMarkupTemplate( "admin.tpl", "addon/blackout/" );
if (! is_string($myurl)) { $myurl = 'https://www.example.com'; }
$t = Renderer::getMarkupTemplate( 'admin.tpl', 'addon/blackout/' );
$date1 = DateTime::createFromFormat('Y-m-d G:i', $mystart);
$date2 = DateTime::createFromFormat('Y-m-d G:i', $myend);
// a note for the admin
$adminnote = "";
$adminnote = '';
if ($date2 < $date1) {
$adminnote = DI::l10n()->t("The end-date is prior to the start-date of the blackout, you should fix this.");
} else {
@ -100,14 +103,14 @@ function blackout_addon_admin(&$a, &$o) {
}
$o = Renderer::replaceMacros($t, [
'$submit' => DI::l10n()->t('Save Settings'),
'$rurl' => ["rurl", DI::l10n()->t("Redirect URL"), $myurl, DI::l10n()->t("All your visitors from the web will be redirected to this URL."), "", "", "url"],
'$startdate' => ["startdate", DI::l10n()->t("Begin of the Blackout"), $mystart, DI::l10n()->t("Format is <tt>YYYY-MM-DD hh:mm</tt>; <em>YYYY</em> year, <em>MM</em> month, <em>DD</em> day, <em>hh</em> hour and <em>mm</em> minute.")],
'$enddate' => ["enddate", DI::l10n()->t("End of the Blackout"), $myend, ""],
'$rurl' => ['rurl', DI::l10n()->t("Redirect URL"), $myurl, DI::l10n()->t("All your visitors from the web will be redirected to this URL."), '', '', 'url'],
'$startdate' => ['startdate', DI::l10n()->t("Begin of the Blackout"), $mystart, DI::l10n()->t("Format is <tt>YYYY-MM-DD hh:mm</tt>; <em>YYYY</em> year, <em>MM</em> month, <em>DD</em> day, <em>hh</em> hour and <em>mm</em> minute.")],
'$enddate' => ['enddate', DI::l10n()->t("End of the Blackout"), $myend, ''],
'$adminnote' => $adminnote,
'$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']);
$enddate = trim($_POST['enddate']);
$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';
function blockbot_install() {
function blockbot_install()
{
Hook::register('init_1', __FILE__, 'blockbot_init_1');
}
function blockbot_addon_admin(&$a, &$o) {
$t = Renderer::getMarkupTemplate("admin.tpl", "addon/blockbot/");
function blockbot_addon_admin(App $a, &$o)
{
$t = Renderer::getMarkupTemplate('admin.tpl', 'addon/blockbot/');
$o = Renderer::replaceMacros($t, [
'$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', 'block_gab', $_POST['block_gab'] ?? 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'])) {
return;
}

View file

@ -186,9 +186,12 @@ function blockem_item_photo_menu(App $a, array &$b)
}
}
function blockem_module()
{
}
/**
* This is a statement rather than an actual function definition. The simple
* existence of this method is checked to figure out if the addon offers a
* module.
*/
function blockem_module() {}
function blockem_init(App $a)
{

View file

@ -15,7 +15,7 @@ function buglink_install()
Hook::register('page_end', 'addon/buglink/buglink.php', 'buglink_active');
}
function buglink_active(App $a, &$b)
function buglink_active(App $a, string &$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>';
}

View file

@ -5,6 +5,8 @@
* Version: 1.0
* Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\DI;
@ -12,18 +14,20 @@ function calc_install() {
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>';
}
/**
* This is a statement rather than an actual function definition. The simple
* existence of this method is checked to figure out if the addon offers a
* module.
*/
function calc_module() {}
function calc_init($a) {
function calc_init(App $a)
{
$x = <<< EOT
<script language="JavaScript">
@ -355,5 +359,4 @@ $o .= <<< EOT
EOT;
return $o;
}

View file

@ -118,7 +118,7 @@ function catavatar_addon_settings_post(App $a, &$s)
* @param $a 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']]);
if (DBA::isResult($user)) {
@ -137,6 +137,11 @@ function catavatar_lookup(App $a, &$b)
$b['success'] = true;
}
/**
* This is a statement rather than an actual function definition. The simple
* existence of this method is checked to figure out if the addon offers a
* module.
*/
function catavatar_module() {}
/**

View file

@ -5,64 +5,67 @@
* Version: 1.0
* Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
*/
use Friendica\App;
use Friendica\Core\Hook;
function convert_install() {
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>';
}
function convert_module() {}
function convert_content(App $a) {
// @TODO UnitConverter uses a deprecated constructor with the class' name
// @TODO Let's one day rewrite this to a modern composer package
include 'UnitConvertor.php';
function convert_content($app) {
include("UnitConvertor.php");
class TP_Converter extends UnitConvertor {
function TP_Converter($lang = "en")
class TP_Converter extends UnitConvertor
{
if ($lang != 'en' ) {
$dec_point = '.'; $thousand_sep = "'";
public function __construct(string $lang = 'en')
{
if ($lang == 'en' ) {
$dec_point = '.';
$thousand_sep = ',';
} else {
$dec_point = '.'; $thousand_sep = ",";
$dec_point = '.';
$thousand_sep = "'";
}
$this->UnitConvertor($dec_point , $thousand_sep );
parent::UnitConvertor($dec_point, $thousand_sep );
}
} // end func UnitConvertor
function find_base_unit($from,$to) {
private function findBaseUnit($from, $to)
{
while (list($skey, $sval) = each($this->bases)) {
if ($skey == $from || $to == $skey || in_array($to, $sval) || in_array($from, $sval)) {
return $skey;
}
}
return false;
}
function getTable($value, $from_unit, $to_unit, $precision) {
if ($base_unit = $this->find_base_unit($from_unit,$to_unit)) {
public function getTable(int $value, $from_unit, $to_unit, $precision): string
{
$string = '';
if ($base_unit = $this->findBaseUnit($from_unit, $to_unit)) {
// A baseunit was found now lets convert from -> $base_unit
$cell ['value'] = $this->convert($value, $from_unit, $base_unit, $precision)." ".$base_unit;
$cell ['class'] = ($base_unit == $from_unit || $base_unit == $to_unit) ? "framedred": "";
$cell ['value'] = $this->convert($value, $from_unit, $base_unit, $precision) . ' ' . $base_unit;
$cell ['class'] = ($base_unit == $from_unit || $base_unit == $to_unit) ? 'framedred' : '';
$cells[] = $cell;
// We now have the base unit and value now lets produce the table;
while (list($key, $val) = each($this->bases[$base_unit])) {
$cell ['value'] = $this->convert($value, $from_unit, $val, $precision)." ".$val;
$cell ['class'] = ($val == $from_unit || $val == $to_unit) ? "framedred": "";
$cell ['value'] = $this->convert($value, $from_unit, $val, $precision) . ' ' . $val;
$cell ['class'] = ($val == $from_unit || $val == $to_unit) ? 'framedred' : '';
$cells[] = $cell;
}
@ -79,16 +82,14 @@ include("UnitConvertor.php");
}
}
$string .= "</tr></table>";
}
return $string;
}
}
}
$conv = new TP_Converter('en');
$conversions = [
'Temperature' => ['base' => 'Celsius',
'conv' => [
@ -175,7 +176,6 @@ $conversions = [
]
];
while (list($key, $val) = each($conversions)) {
$conv->addConversion($val['base'], $val['conv']);
$list[$key][] = $val['base'];
@ -186,27 +186,22 @@ while (list($key,$val) = each($conversions)) {
$o .= '<h3>Unit Conversions</h3>';
if (isset($_POST['from_unit']) && isset($_POST['value'])) {
$_POST['value'] = $_POST['value'] + 0;
$o .= ($conv->getTable($_POST['value'], $_POST['from_unit'], $_POST['to_unit'], 5))."</p>";
$o .= ($conv->getTable(intval($_POST['value']), $_POST['from_unit'], $_POST['to_unit'], 5)) . '</p>';
} else {
$o .= "<p>Select:</p>";
$o .= '<p>Select:</p>';
}
if(isset($_POST['value']))
if (isset($_POST['value'])) {
$value = $_POST['value'];
else
} else {
$value = '';
}
$o .= '<form action="convert" method="post" name="conversion">';
$o .= '<input name="value" type="text" id="value" value="' . $value . '" size="10" maxlength="10" />';
$o .= '<select name="from_unit" size="12">';
reset($list);
while(list($key, $val) = each($list)) {
$o .= "\n\t<optgroup label=\"$key\">";
@ -218,7 +213,6 @@ while (list($key,$val) = each($conversions)) {
}
$o .= '</select>';
$o .= '<input type="submit" name="Submit" value="Submit" /></form>';
return $o;

View file

@ -83,7 +83,7 @@ function cookienotice_addon_admin_post(App $a)
*
* @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()->registerFooterScript(__DIR__ . '/cookienotice.js');
@ -99,7 +99,7 @@ function cookienotice_page_content_top(App $a, &$b)
*
* @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.'));
$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;
}
function curweather_network_mod_init(App $a, &$b)
function curweather_network_mod_init(App $a, string &$body)
{
if (!intval(DI::pConfig()->get(local_user(), 'curweather', 'curweather_enable'))) {
return;
@ -112,7 +112,7 @@ function curweather_network_mod_init(App $a, &$b)
$appid = DI::config()->get('curweather', 'appid');
$cachetime = intval(DI::config()->get('curweather', 'cachetime'));
if ($units === "") {
if ($units === '') {
$units = 'metric';
}
@ -221,7 +221,7 @@ function curweather_addon_admin(App $a, &$o)
$appid = DI::config()->get('curweather', 'appid');
$cachetime = DI::config()->get('curweather', 'cachetime');
$t = Renderer::getMarkupTemplate("admin.tpl", "addon/curweather/" );
$t = Renderer::getMarkupTemplate('admin.tpl', 'addon/curweather/' );
$o = Renderer::replaceMacros($t, [
'$submit' => DI::l10n()->t('Save Settings'),

View file

@ -110,4 +110,3 @@ class Diasphp {
return true;
}
}
?>

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'])) {
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') {
return;

View file

@ -25,10 +25,17 @@ function forumdirectory_install()
Hook::register('app_menu', 'addon/forumdirectory/forumdirectory.php', 'forumdirectory_app_menu');
}
function forumdirectory_module()
{
return;
}
/**
* This is a statement rather than an actual function definition. The simple
* existence of this method is checked to figure out if the addon offers a
* module.
*/
/**
* This is a statement rather than an actual function definition. The simple
* existence of this method is checked to figure out if the addon offers a
* module.
*/
function forumdirectory_module() {}
function forumdirectory_app_menu(App $a, array &$b)
{

View file

@ -21,7 +21,7 @@ function fromapp_install()
Logger::notice("installed fromapp");
}
function fromapp_settings_post($a, $post)
function fromapp_settings_post(App $a, $post)
{
if (!local_user() || empty($_POST['fromapp-submit'])) {
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()) {
return;

View file

@ -6,6 +6,7 @@
* Author: Michael Vogel <https://pirati.ca/profile/heluecht>
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
@ -71,12 +72,12 @@ function geocoordinates_resolve_item(&$item)
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);
}
function geocoordinates_addon_admin(&$a, &$o)
function geocoordinates_addon_admin(App $a, &$o)
{
$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'] ?? '');
DI::config()->set('geocoordinates', 'api_key', $api_key);

View file

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

View file

@ -6,6 +6,8 @@
* Author: Michael Vogel <https://pirati.ca/profile/heluecht>
*
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
@ -13,23 +15,22 @@ function googlemaps_install()
{
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']))) {
return;
}
if ($item['coord'] != ""){
$target = "http://maps.google.com/?q=".urlencode($item['coord']);
if ($item['coord'] != '') {
$target = 'http://maps.google.com/?q=' . urlencode($item['coord']);
} 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'];
} else {
$title = $item['coord'];

View file

@ -37,7 +37,8 @@ function gravatar_load_config(App $a, ConfigFileLoader $loader)
* @param $a array
* @param &$b array
*/
function gravatar_lookup($a, &$b) {
function gravatar_lookup(App $a, array &$b)
{
$default_avatar = DI::config()->get('gravatar', 'default_avatar');
$rating = DI::config()->get('gravatar', 'rating');
@ -61,17 +62,20 @@ function gravatar_lookup($a, &$b) {
/**
* 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/" );
$default_avatar = DI::config()->get('gravatar', 'default_avatar');
$rating = DI::config()->get('gravatar', 'rating');
// set default values for first configuration
if(! $default_avatar)
if (!$default_avatar) {
$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
}
// Available options for the select boxes
$default_avatars = [
@ -105,7 +109,8 @@ function gravatar_addon_admin (&$a, &$o) {
/**
* Save admin settings
*/
function gravatar_addon_admin_post (&$a) {
function gravatar_addon_admin_post (App $a)
{
BaseModule::checkFormSecurityToken('gravatarsave');
$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']))
return;
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');
}
function highlightjs_head(App $a, &$b)
function highlightjs_head(App $a, string &$str)
{
if ($a->getCurrentTheme() == 'frio') {
$style = 'bootstrap';
@ -27,7 +27,7 @@ function highlightjs_head(App $a, &$b)
DI::page()->registerStylesheet(__DIR__ . '/asset/styles/' . $style . '.css');
}
function highlightjs_footer(App $a, &$b)
function highlightjs_footer(App $a, string &$str)
{
DI::page()->registerFooterScript(__DIR__ . '/asset/highlight.pack.js');
DI::page()->registerFooterScript(__DIR__ . '/highlightjs.js');

View file

@ -24,15 +24,14 @@ function ifttt_install()
Hook::register('connector_settings_post', 'addon/ifttt/ifttt.php', 'ifttt_settings_post');
}
function ifttt_module()
{
/**
* This is a statement rather than an actual function definition. The simple
* existence of this method is checked to figure out if the addon offers a
* module.
*/
function ifttt_module() {}
}
function ifttt_content()
{
}
function ifttt_content() {}
function ifttt_settings(App $a, array &$data)
{

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'])) {
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
@ -118,7 +118,7 @@ function ijpost_post_local(&$a, &$b)
$b['postopts'] .= 'ijpost';
}
function ijpost_send(&$a, &$b)
function ijpost_send(App $a, array &$b)
{
if ($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) {
return;

View file

@ -7,6 +7,7 @@
* License: 3-clause BSD license
*/
use Friendica\App;
use Friendica\Content\Text\BBCode;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
@ -15,75 +16,92 @@ use Friendica\DI;
use Friendica\Core\Config\Util\ConfigFileLoader;
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('about_hook', 'addon/impressum/impressum.php', 'impressum_show');
Hook::register('page_end', 'addon/impressum/impressum.php', 'impressum_footer');
Logger::notice("installed impressum Addon");
}
function impressum_module() {
}
function impressum_content() {
/**
* This is a statement rather than an actual function definition. The simple
* existence of this method is checked to figure out if the addon offers a
* module.
*/
function impressum_module() {}
function impressum_content()
{
DI::baseUrl()->redirect('friendica/');
}
function obfuscate_email ($s) {
function obfuscate_email (string $s): string
{
$s = str_replace('@', '(at)', $s);
$s = str_replace('.', '(dot)', $s);
return $s;
}
function impressum_footer($a, &$b) {
function impressum_footer(App $a, string &$body)
{
$text = ProxyUtils::proxifyHtml(BBCode::convert(DI::config()->get('impressum','footer_text')));
if (! $text == '') {
if ($text != '') {
DI::page()['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . DI::baseUrl()->get() . '/addon/impressum/impressum.css" media="all" />';
$b .= '<div class="clear"></div>';
$b .= '<div id="impressum_footer">'.$text.'</div>';
$body .= '<div class="clear"></div>';
$body .= '<div id="impressum_footer">' . $text . '</div>';
}
}
function impressum_load_config(\Friendica\App $a, ConfigFileLoader $loader)
function impressum_load_config(App $a, ConfigFileLoader $loader)
{
$a->getConfigCache()->load($loader->loadAddonConfig('impressum'));
}
function impressum_show($a,&$b) {
$b .= '<h3>'.DI::l10n()->t('Impressum').'</h3>';
function impressum_show(App $a, string &$body)
{
$body .= '<h3>' . DI::l10n()->t('Impressum') . '</h3>';
$owner = DI::config()->get('impressum', 'owner');
$owner_profile = DI::config()->get('impressum', 'ownerprofile');
$postal = ProxyUtils::proxifyHtml(BBCode::convert(DI::config()->get('impressum', 'postal')));
$notes = ProxyUtils::proxifyHtml(BBCode::convert(DI::config()->get('impressum', 'notes')));
$email = obfuscate_email( DI::config()->get('impressum', 'email') );
if (strlen($owner)) {
if (strlen($owner_profile)) {
$tmp = '<a href="' . $owner_profile . '">' . $owner . '</a>';
} else {
$tmp = $owner;
}
if (strlen($email)) {
$b .= '<p><strong>'.DI::l10n()->t('Site Owner').'</strong>: '. $tmp .'<br /><strong>'.DI::l10n()->t('Email Address').'</strong>: '.$email.'</p>';
$body .= '<p><strong>' . DI::l10n()->t('Site Owner').'</strong>: ' . $tmp .'<br /><strong>' . DI::l10n()->t('Email Address') . '</strong>: ' . $email . '</p>';
} else {
$b .= '<p><strong>'.DI::l10n()->t('Site Owner').'</strong>: '. $tmp .'</p>';
$body .= '<p><strong>' . DI::l10n()->t('Site Owner').'</strong>: ' . $tmp .'</p>';
}
if (strlen($postal)) {
$b .= '<p><strong>'.DI::l10n()->t('Postal Address').'</strong><br />'. $postal .'</p>';
$body .= '<p><strong>' . DI::l10n()->t('Postal Address') . '</strong><br />' . $postal . '</p>';
}
if (strlen($notes)) {
$b .= '<p>'.$notes.'</p>';
$body .= '<p>' . $notes . '</p>';
}
} 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>';
$body .= '<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'] ?? '');
$ownerprofile = trim($_POST['ownerprofile'] ?? '');
$postal = trim($_POST['postal'] ?? '');
$notes = trim($_POST['notes'] ?? '');
$email = trim($_POST['email'] ?? '');
$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', 'postal', strip_tags($postal));
@ -91,8 +109,10 @@ function impressum_addon_admin_post (&$a) {
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, [
'$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.')],

View file

@ -5,6 +5,8 @@
* Version: 1.0
* Author: Thomas Willingham <https://kakste.com/profile/beardyunixer>
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\DI;
@ -13,19 +15,20 @@ function infiniteimprobabilitydrive_install()
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>';
}
function infiniteimprobabilitydrive_module()
{
return;
}
/**
* This is a statement rather than an actual function definition. The simple
* existence of this method is checked to figure out if the addon offers a
* module.
*/
function infiniteimprobabilitydrive_module() {}
function infiniteimprobabilitydrive_content(&$a)
function infiniteimprobabilitydrive_content(App $a)
{
$baseurl = DI::baseUrl()->get() . '/addon/infiniteimprobabilitydrive';
$o = '';

View file

@ -12,7 +12,8 @@ use Friendica\Core\Hook;
use Friendica\Core\Renderer;
use Friendica\DI;
function irc_install() {
function irc_install()
{
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_post', 'addon/irc/irc.php', 'irc_addon_settings_post');
@ -41,9 +42,11 @@ function irc_addon_settings(App &$a, array &$data)
];
}
function irc_addon_settings_post(&$a, &$b) {
if(!local_user())
function irc_addon_settings_post(App $a, array &$b)
{
if (!local_user()) {
return;
}
if (!empty($_POST['irc-submit'])) {
if (isset($_POST['autochans'])) {
@ -56,33 +59,38 @@ 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>';
}
/**
* This is a statement rather than an actual function definition. The simple
* existence of this method is checked to figure out if the addon offers a
* module.
*/
function irc_module() {}
function irc_module() {
return;
}
function irc_content(&$a) {
function irc_content(App $a)
{
$baseurl = DI::baseUrl()->get() . '/addon/irc';
$o = '';
/* set the list of popular channels */
if (local_user()) {
$sitechats = DI::pConfig()->get( local_user(), 'irc', 'sitechats');
if (!$sitechats)
if (!$sitechats) {
$sitechats = DI::config()->get('irc', 'sitechats');
}
} else {
$sitechats = DI::config()->get('irc','sitechats');
}
if($sitechats)
if ($sitechats) {
$chats = explode(',',$sitechats);
else
} else {
$chats = ['friendica','chat','chatback','hottub','ircbar','dateroom','debian'];
}
DI::page()['aside'] .= '<div class="widget"><h3>' . DI::l10n()->t('Popular Channels') . '</h3><ul>';
@ -99,10 +107,12 @@ function irc_content(&$a) {
} else {
$autochans = DI::config()->get('irc','autochans');
}
if($autochans)
if ($autochans) {
$channels = $autochans;
else
} else {
$channels = ($_GET['channels'] ?? '') ?: 'friendica';
}
/* add the chatroom frame and some html */
$o .= <<< EOT
@ -112,22 +122,23 @@ function irc_content(&$a) {
EOT;
return $o;
}
function irc_addon_admin_post (&$a) {
if(!$a->isSiteAdmin())
function irc_addon_admin_post (App $a)
{
if (!$a->isSiteAdmin()) {
return;
}
if ($_POST['irc-submit']) {
DI::config()->set('irc', 'autochans', trim($_POST['autochans']));
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 */
$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, [
'$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.')],

View file

@ -8,8 +8,9 @@ class qqUploadedFileXhr {
* Save the file to the specified path
* @return boolean TRUE on success
*/
function save($path) {
$input = fopen("php://input", "r");
public function save(string $path): bool
{
$input = fopen('php://input', 'r');
$temp = tmpfile();
$realSize = stream_copy_to_stream($input, $temp);
fclose($input);
@ -18,19 +19,23 @@ class qqUploadedFileXhr {
return false;
}
$target = fopen($path, "w");
$target = fopen($path, 'w');
fseek($temp, 0, SEEK_SET);
stream_copy_to_stream($temp, $target);
fclose($target);
return true;
}
function getName() {
public function getName(): string
{
return $_GET['qqfile'];
}
function getSize() {
if (isset($_SERVER["CONTENT_LENGTH"])){
return (int)$_SERVER["CONTENT_LENGTH"];
public function getSize(): int
{
if (isset($_SERVER['CONTENT_LENGTH'])) {
return (int)$_SERVER['CONTENT_LENGTH'];
} else {
throw new Exception('Getting content length is not supported.');
}
@ -45,27 +50,33 @@ class qqUploadedFileForm {
* Save the file to the specified path
* @return boolean TRUE on success
*/
function save($path) {
public function save(string $path): bool
{
if(!move_uploaded_file($_FILES['qqfile']['tmp_name'], $path)) {
return false;
}
return true;
}
function getName() {
public function getName(): string
{
return $_FILES['qqfile']['name'];
}
function getSize() {
public function getSize(): int
{
return $_FILES['qqfile']['size'];
}
}
class qqFileUploader {
private $allowedExtensions = array();
private $allowedExtensions = [];
private $sizeLimit = 10485760;
private $file;
function __construct(array $allowedExtensions = array(), $sizeLimit = 10485760){
$allowedExtensions = array_map("strtolower", $allowedExtensions);
public function __construct(array $allowedExtensions = [], $sizeLimit = 10485760)
{
$allowedExtensions = array_map('strtolower', $allowedExtensions);
$this->allowedExtensions = $allowedExtensions;
$this->sizeLimit = $sizeLimit;
@ -81,7 +92,8 @@ class qqFileUploader {
}
}
private function checkServerSettings(){
private function checkServerSettings()
{
$postSize = $this->toBytes(ini_get('post_max_size'));
$uploadSize = $this->toBytes(ini_get('upload_max_filesize'));
@ -91,37 +103,41 @@ class qqFileUploader {
}
}
private function toBytes($str){
private function toBytes(string $str): int
{
$val = trim($str);
$last = strtolower($str[strlen($str) - 1]);
switch($last) {
case 'g': $val *= 1024;
case 'm': $val *= 1024;
case 'k': $val *= 1024;
}
return $val;
}
/**
* Returns array('success'=>true) or array('error'=>'error message')
*/
function handleUpload($uploadDirectory, $replaceOldFile = FALSE){
public function handleUpload(string $uploadDirectory, bool $replaceOldFile = false): array
{
if (!is_writable($uploadDirectory)) {
return array('error' => "Server error. Upload directory isn't writable.");
return ['error' => "Server error. Upload directory isn't writable."];
}
if (!$this->file) {
return array('error' => 'No files were uploaded.');
return ['error' => 'No files were uploaded.'];
}
$size = $this->file->getSize();
if ($size == 0) {
return array('error' => 'File is empty');
return ['error' => 'File is empty'];
}
if ($size > $this->sizeLimit) {
return array('error' => 'File is too large');
return ['error' => 'File is too large'];
}
$pathinfo = pathinfo($this->file->getName());
@ -131,7 +147,7 @@ class qqFileUploader {
if($this->allowedExtensions && !in_array(strtolower($ext), $this->allowedExtensions)) {
$these = implode(', ', $this->allowedExtensions);
return array('error' => 'File has an invalid extension, it should be one of '. $these . '.');
return ['error' => 'File has an invalid extension, it should be one of '. $these . '.'];
}
if(!$replaceOldFile) {
@ -142,17 +158,16 @@ class qqFileUploader {
}
if ($this->file->save($uploadDirectory . $filename . '.' . $ext)) {
return array('success'=>true);
return ['success' => true];
} else {
return array('error'=> 'Could not save uploaded file.' .
'The upload was cancelled, or server error encountered');
return ['error'=> 'Could not save uploaded file. The upload was cancelled, or server error encountered'];
}
}
}
// list of valid extensions, ex. array("jpeg", "xml", "bmp")
$allowedExtensions = array();
$allowedExtensions = [];
// max file size in bytes
$sizeLimit = 10 * 1024 * 1024;

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;
@ -69,7 +69,7 @@ function js_upload_post_init(App $a, &$b)
$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;
@ -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;

View file

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

View file

@ -16,57 +16,54 @@ use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\DI;
function krynn_install() {
function krynn_install()
{
/**
*
* Our demo addon will attach in three places.
* The first is just prior to storing a local post.
*
*/
Hook::register('post_local', 'addon/krynn/krynn.php', 'krynn_post_hook');
/**
*
* Then we'll attach into the addon settings page, and also the
* settings post hook so that we can create and update
* user preferences.
*
*/
Hook::register('addon_settings', 'addon/krynn/krynn.php', 'krynn_settings');
Hook::register('addon_settings_post', 'addon/krynn/krynn.php', 'krynn_settings_post');
Logger::notice("installed krynn");
}
function krynn_post_hook($a, &$item) {
function krynn_post_hook(App $a, &$item)
{
/**
*
* An item was posted on the local system.
* We are going to look for specific items:
* - A status post by a profile owner
* - The profile owner must have allowed our addon
*
*/
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;
}
if(local_user() != $item['uid']) /* Does this person own the post? */
if (local_user() != $item['uid']) {
/* Does this person own the post? */
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;
}
/* Retrieve our personal config setting */
$active = DI::pConfig()->get(local_user(), 'krynn', 'enable');
if(! $active)
if (!$active) {
return;
}
/**
*
@ -85,35 +82,27 @@ function krynn_post_hook($a, &$item) {
return;
}
/**
*
* Callback from the settings post function.
* $post contains the $_POST array.
* We will make sure we've got a valid user account
* and if so set our configuration setting for this person.
*
*/
function krynn_settings_post($a,$post) {
if(! local_user())
function krynn_settings_post(App $a, $post)
{
if (!local_user()) {
return;
if($_POST['krynn-submit'])
DI::pConfig()->set(local_user(),'krynn','enable',intval($_POST['krynn']));
}
if ($_POST['krynn-submit']) {
DI::pConfig()->set(local_user(),'krynn','enable',intval($_POST['krynn']));
}
}
/**
*
* Called from the addon Setting form.
* Add our own settings info to the page.
*
*/
function krynn_settings(App &$a, array &$data)
{
if (!local_user()) {

View file

@ -67,7 +67,7 @@ function langfilter_addon_settings(App $a, array &$data)
* 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()) {
return;

View file

@ -54,6 +54,7 @@
* ...etc.
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Database\DBA;
@ -67,12 +68,12 @@ function ldapauth_install()
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'));
}
function ldapauth_hook_authenticate($a, &$b)
function ldapauth_hook_authenticate(App $a, array &$b)
{
$user = ldapauth_authenticate($b['username'], $b['password']);
if (!empty($user['uid'])) {

View file

@ -6,61 +6,66 @@
* Author: Michael Vogel <https://pirati.ca/profile/heluecht>
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\DI;
function leistungsschutzrecht_install() {
function leistungsschutzrecht_install()
{
Hook::register('cron', 'addon/leistungsschutzrecht/leistungsschutzrecht.php', 'leistungsschutzrecht_cron');
Hook::register('getsiteinfo', 'addon/leistungsschutzrecht/leistungsschutzrecht.php', 'leistungsschutzrecht_getsiteinfo');
Hook::register('page_info_data', 'addon/leistungsschutzrecht/leistungsschutzrecht.php', 'leistungsschutzrecht_getsiteinfo');
}
function leistungsschutzrecht_getsiteinfo($a, &$siteinfo) {
if (!isset($siteinfo["url"]) || empty($siteinfo['type'])) {
function leistungsschutzrecht_getsiteinfo(App $a, array &$siteinfo) {
if (!isset($siteinfo['url']) || empty($siteinfo['type'])) {
return;
}
// Avoid any third party pictures, to avoid copyright issues
if (!in_array($siteinfo['type'], ['photo', 'video']) && DI::config()->get('leistungsschutzrecht', 'suppress_photos', false)) {
unset($siteinfo["image"]);
unset($siteinfo["images"]);
unset($siteinfo['image']);
unset($siteinfo['images']);
}
if (!leistungsschutzrecht_is_member_site($siteinfo["url"])) {
if (!leistungsschutzrecht_is_member_site($siteinfo['url'])) {
return;
}
if (!empty($siteinfo["text"])) {
$siteinfo["text"] = leistungsschutzrecht_cuttext($siteinfo["text"]);
if (!empty($siteinfo['text'])) {
$siteinfo['text'] = leistungsschutzrecht_cuttext($siteinfo['text']);
}
unset($siteinfo["keywords"]);
unset($siteinfo['keywords']);
}
function leistungsschutzrecht_cuttext($text) {
$text = str_replace(["\r", "\n"], [" ", " "], $text);
function leistungsschutzrecht_cuttext(string $text): string
{
$text = str_replace(["\r", "\n"], [' ', ' '], $text);
do {
$oldtext = $text;
$text = str_replace(" ", " ", $text);
$text = str_replace(' ', ' ', $text);
} while ($oldtext != $text);
$words = explode(" ", $text);
$words = explode(' ', $text);
$text = "";
$text = '';
$count = 0;
$limit = 7;
foreach ($words as $word) {
if ($text != "")
$text .= " ";
if ($text != '') {
$text .= ' ';
}
$text .= $word;
if (++$count >= $limit) {
if (sizeof($words) > $limit)
$text .= " ...";
if (sizeof($words) > $limit) {
$text .= ' ...';
}
break;
}
@ -71,7 +76,7 @@ function leistungsschutzrecht_cuttext($text) {
function leistungsschutzrecht_fetchsites()
{
// This list works - but question is how current it is
$url = "http://leistungsschutzrecht-stoppen.d-64.org/blacklist.txt";
$url = 'https://leistungsschutzrecht-stoppen.d-64.org/blacklist.txt';
$sitelist = DI::httpClient()->fetch($url);
$siteurls = explode(',', $sitelist);
@ -123,23 +128,27 @@ function leistungsschutzrecht_fetchsites()
}
}
function leistungsschutzrecht_is_member_site($url) {
function leistungsschutzrecht_is_member_site(string $url): bool
{
$sites = DI::config()->get('leistungsschutzrecht', 'sites');
if ($sites == "")
return(false);
if ($sites == '') {
return false;
}
if (sizeof($sites) == 0)
return(false);
if (sizeof($sites) == 0) {
return false;
}
$urldata = parse_url($url);
if (!isset($urldata["host"]))
return(false);
if (!isset($urldata['host'])) {
return false;
}
$cleanedurlpart = explode("%", $urldata["host"]);
$cleanedurlpart = explode('%', $urldata['host']);
$hostname = explode(".", $cleanedurlpart[0]);
$hostname = explode('.', $cleanedurlpart[0]);
if (empty($hostname)) {
return false;
}
@ -148,12 +157,13 @@ function leistungsschutzrecht_is_member_site($url) {
return false;
}
$site = $hostname[sizeof($hostname) - 2].".".$hostname[sizeof($hostname) - 1];
$site = $hostname[sizeof($hostname) - 2] . '.' . $hostname[sizeof($hostname) - 1];
return (isset($sites[$site]));
return isset($sites[$site]);
}
function leistungsschutzrecht_cron($a,$b) {
function leistungsschutzrecht_cron(App $a, $b)
{
$last = DI::config()->get('leistungsschutzrecht', 'last_poll');
if ($last) {
@ -166,4 +176,3 @@ function leistungsschutzrecht_cron($a,$b) {
leistungsschutzrecht_fetchsites();
DI::config()->set('leistungsschutzrecht', 'last_poll', time());
}
?>

View file

@ -37,13 +37,12 @@ function libertree_jot_nets(App &$a, array &$jotnets_fields)
'field' => [
'libertree_enable',
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)
{
if (!local_user()) {
@ -72,11 +71,9 @@ function libertree_settings(App $a, array &$data)
];
}
function libertree_settings_post(&$a,&$b) {
function libertree_settings_post(App $a, array &$b)
{
if (!empty($_POST['libertree-submit'])) {
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','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
@ -136,11 +134,8 @@ function libertree_post_local(&$a,&$b) {
$b['postopts'] .= 'libertree';
}
function libertree_send(&$a,&$b) {
function libertree_send(App $a, array &$b)
{
Logger::notice('libertree_send: invoked');
if ($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) {
@ -195,8 +190,9 @@ function libertree_send(&$a,&$b) {
$body = BBCode::toMarkdown($body, false);
// Adding the title
if(strlen($title))
$body = "## ".html_entity_decode($title)."\n\n".$body;
if (strlen($title)) {
$body = '## ' . html_entity_decode($title) . "\n\n" . $body;
}
$params = [

View file

@ -667,5 +667,3 @@ class Services_Libravatar
* c-hanging-comment-ender-p: nil
* End:
*/
?>

View file

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

View file

@ -20,13 +20,13 @@ use Friendica\Model\User;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\XML;
function ljpost_install() {
function ljpost_install()
{
Hook::register('post_local', 'addon/ljpost/ljpost.php', 'ljpost_post_local');
Hook::register('notifier_normal', 'addon/ljpost/ljpost.php', 'ljpost_send');
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_post', 'addon/ljpost/ljpost.php', 'ljpost_settings_post');
}
function ljpost_jot_nets(App &$a, array &$jotnets_fields)
@ -41,13 +41,12 @@ function ljpost_jot_nets(App &$a, array &$jotnets_fields)
'field' => [
'ljpost_enable',
DI::l10n()->t('Post to LiveJournal'),
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)
{
if (!local_user()) {
@ -75,61 +74,61 @@ function ljpost_settings(App &$a, array &$data)
];
}
function ljpost_settings_post(&$a,&$b) {
function ljpost_settings_post(App $a, array &$b)
{
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', '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
if($b['edit'])
if ($b['edit']) {
return;
}
if((! local_user()) || (local_user() != $b['uid']))
if ((!local_user()) || (local_user() != $b['uid'])) {
return;
}
if($b['private'] || $b['parent'])
if ($b['private'] || $b['parent']) {
return;
}
$lj_post = intval(DI::pConfig()->get(local_user(),'ljpost','post'));
$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;
}
if(! $lj_enable)
if (!$lj_enable) {
return;
}
if(strlen($b['postopts']))
if (strlen($b['postopts'])) {
$b['postopts'] .= ',';
}
$b['postopts'] .= 'ljpost';
}
function ljpost_send(&$a,&$b) {
if($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited']))
function ljpost_send(App $a, array &$b)
{
if ($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) {
return;
}
if(! strstr($b['postopts'],'ljpost'))
if (!strstr($b['postopts'],'ljpost')) {
return;
}
if($b['parent'] != $b['id'])
if ($b['parent'] != $b['id']) {
return;
}
$b['body'] = Post\Media::addAttachmentsToBody($b['uri-id'], $b['body']);
@ -147,8 +146,9 @@ function ljpost_send(&$a,&$b) {
// $lj_journal = $lj_username;
$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');
}
if ($lj_username && $lj_password && $lj_blog) {
$title = XML::escape($b['title']);
@ -168,7 +168,8 @@ function ljpost_send(&$a,&$b) {
<methodCall>
<methodName>LJ.XMLRPC.postevent</methodName>
<params>
<param><value>
<param>
<value>
<struct>
<member><name>username</name><value><string>$lj_username</string></value></member>
<member><name>password</name><value><string>$lj_password</string></value></member>
@ -197,10 +198,10 @@ function ljpost_send(&$a,&$b) {
</value>
</member>
</struct>
</value></param>
</value>
</param>
</params>
</methodCall>
EOT;
Logger::debug('ljpost: data: ' . $xml);
@ -208,6 +209,7 @@ EOT;
if ($lj_blog !== 'test') {
$x = DI::httpClient()->post($lj_blog, $xml, ['Content-Type' => 'text/xml'])->getBody();
}
Logger::info('posted to livejournal: ' . ($x) ? $x : '');
}
}

View file

@ -58,19 +58,19 @@ function mailstream_check_version()
}
/**
* This function indicates a module that can be wrapped in the LegacyModule class
* This is a statement rather than an actual function definition. The simple
* existence of this method is checked to figure out if the addon offers a
* module.
*/
function mailstream_module()
{
}
function mailstream_module() {}
/**
* Adds an item in "addon features" in the admin menu of the site
*
* @param Friendica\App $a App object (unused)
* @param App $a App object (unused)
* @param string $o HTML form data
*/
function mailstream_addon_admin(&$a, &$o)
function mailstream_addon_admin(App $a, string &$o)
{
$frommail = DI::config()->get('mailstream', 'frommail');
$template = Renderer::getMarkupTemplate('admin.tpl', 'addon/mailstream/');
@ -110,7 +110,7 @@ function mailstream_generate_id($uri)
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']);
$item = Post::selectFirst([], $criteria);
@ -138,10 +138,10 @@ function mailstream_send_hook(&$a, $data)
* mailstream is enabled and the necessary data is available, forks a
* workerqueue item to send the email.
*
* @param Friendica\App $a App object (unused)
* @param App $a App object (unused)
* @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();

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'])) {
return;

View file

@ -20,7 +20,7 @@ function mathjax_install()
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'])) {
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
// otherwise check the users settings.

View file

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

View file

@ -8,6 +8,7 @@
* Status: Deprecated
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\DI;
@ -18,7 +19,7 @@ function morechoice_install() {
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['Bear'] = DI::l10n()->t('Bear');
$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');
}
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['Millionaires'] = DI::l10n()->t('Millionaires');
$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');
}
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['Polygamist'] = DI::l10n()->t('Polygamist');
$b['Half married'] = DI::l10n()->t('Half married');

View file

@ -6,6 +6,8 @@
* Author: Thomas Willingham <https://kakste.com/profile/beardyunixer>
*
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\DI;
@ -14,7 +16,7 @@ function morepokes_install()
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['shag'] = ['shag', DI::l10n()->t('shag'), DI::l10n()->t('shagged')];

View file

@ -7,22 +7,31 @@
* Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
* Status: Unsupported
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\DI;
function namethingy_install() {
function namethingy_install()
{
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>';
}
/**
* This is a statement rather than an actual function definition. The simple
* existence of this method is checked to figure out if the addon offers a
* module.
*/
function namethingy_module() {}
function namethingy_content(&$a) {
function namethingy_content(App $a)
{
$baseurl = DI::baseUrl()->get() . '/addon/namethingy';
$o .= <<< EOT

View file

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

View file

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

View file

@ -6,6 +6,7 @@
* Author: Michael Vogel <https://pirati.ca/profile/heluecht>
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
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);
}
function nominatim_addon_admin(&$a, &$o)
function nominatim_addon_admin(App $a, &$o)
{
$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']) : '';
DI::config()->set('nominatim', 'language', $language);

View file

@ -15,6 +15,11 @@ use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\DI;
/**
* This is a statement rather than an actual function definition. The simple
* existence of this method is checked to figure out if the addon offers a
* module.
*/
function notifyall_module() {}
function notifyall_addon_admin(App $a, &$o)
@ -60,7 +65,7 @@ function notifyall_post(App $a)
DI::baseUrl()->redirect('admin');
}
function notifyall_content(&$a)
function notifyall_content(App $a)
{
if (!$a->isSiteAdmin()) {
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()) {
return;

View file

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

View file

@ -9,6 +9,7 @@
*
*/
use Friendica\App;
use Friendica\Core\Cache\Enum\Duration;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
@ -34,12 +35,12 @@ function openstreetmap_install()
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'));
}
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";
DI::page()['htmlhead'] .= $addScriptTag;
@ -54,7 +55,7 @@ function openstreetmap_alterheader($a, &$navHtml)
* @param mixed $a
* @param array& $item
*/
function openstreetmap_location($a, &$item)
function openstreetmap_location(App $a, &$item)
{
if (!(strlen($item['location']) || strlen($item['coord']))) {
return;
@ -104,7 +105,7 @@ function openstreetmap_location($a, &$item)
$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);
@ -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);
@ -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);
@ -177,7 +178,7 @@ function openstreetmap_generate_map(&$a, &$b)
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/");
$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;
$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'])) {
return;
}
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')){
$s = file_get_contents('pageheader.html');

View file

@ -31,6 +31,7 @@
* setting.
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
@ -44,13 +45,13 @@ function piwik_install() {
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'));
}
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
* associated CSS file. We just have to tell Friendica to get it
@ -90,7 +91,7 @@ function piwik_analytics($a,&$b) {
$b .= "</div>";
}
}
function piwik_addon_admin (&$a, &$o) {
function piwik_addon_admin (App $a, &$o) {
$t = Renderer::getMarkupTemplate( "admin.tpl", "addon/piwik/" );
$o = Renderer::replaceMacros( $t, [
'$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' ), ''],
]);
}
function piwik_addon_admin_post (&$a) {
function piwik_addon_admin_post (App $a) {
$url = trim($_POST['baseurl'] ?? '');
$id = trim($_POST['siteid'] ?? '');
$optout = trim($_POST['optout'] ?? '');

View file

@ -13,59 +13,56 @@ use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\DI;
function planets_install() {
function planets_install()
{
/**
*
* Our demo addon will attach in three places.
* The first is just prior to storing a local post.
*
*/
Hook::register('post_local', 'addon/planets/planets.php', 'planets_post_hook');
/**
*
* Then we'll attach into the addon settings page, and also the
* settings post hook so that we can create and update
* user preferences.
*
*/
Hook::register('addon_settings', 'addon/planets/planets.php', 'planets_settings');
Hook::register('addon_settings_post', 'addon/planets/planets.php', 'planets_settings_post');
Logger::notice("installed planets");
}
function planets_post_hook($a, &$item) {
/**
*
* An item was posted on the local system.
* We are going to look for specific items:
* - A status post by a profile owner
* - The profile owner must have allowed our addon
*
*/
function planets_post_hook(App $a, &$item)
{
Logger::notice('planets 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;
}
if(local_user() != $item['uid']) /* Does this person own the post? */
if (local_user() != $item['uid']) {
/* Does this person own the post? */
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;
}
/* Retrieve our personal config setting */
$active = DI::pConfig()->get(local_user(), 'planets', 'enable');
if(! $active)
if (!$active) {
return;
}
/**
*
@ -96,12 +93,15 @@ function planets_post_hook($a, &$item) {
*
*/
function planets_settings_post($a,$post) {
if(! local_user())
function planets_settings_post(App $a, $post)
{
if (!local_user()) {
return;
if($_POST['planets-submit'])
}
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'));
}
function public_server_register_account($a, $b)
function public_server_register_account(App $a, $b)
{
$uid = $b;
@ -46,7 +46,7 @@ function public_server_register_account($a, $b)
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");
@ -99,7 +99,7 @@ function public_server_cron($a, $b)
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
&& !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');
if (!$days) {
@ -122,7 +122,7 @@ function public_server_login($a, $b)
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');
$expiredays = trim($_POST['expiredays'] ?? '');
@ -139,7 +139,7 @@ function public_server_addon_admin_post(&$a)
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");
$t = Renderer::getMarkupTemplate("admin.tpl", "addon/public_server");

View file

@ -33,7 +33,7 @@ use Friendica\Util\XML;
require 'addon/pumpio/oauth/http.php';
require 'addon/pumpio/oauth/oauth_client.php';
require_once "mod/share.php";
require_once 'mod/share.php';
define('PUMPIO_DEFAULT_POLL_INTERVAL', 5); // given in minutes
@ -50,6 +50,11 @@ function pumpio_install()
Hook::register('check_item_notification', 'addon/pumpio/pumpio.php', 'pumpio_check_item_notification');
}
/**
* This is a statement rather than an actual function definition. The simple
* existence of this method is checked to figure out if the addon offers a
* module.
*/
function pumpio_module() {}
function pumpio_content(App $a)
@ -59,14 +64,15 @@ function pumpio_content(App $a)
return '';
}
require_once("mod/settings.php");
require_once 'mod/settings.php';
settings_init($a);
if (isset(DI::args()->getArgv()[1])) {
switch (DI::args()->getArgv()[1]) {
case "connect":
case 'connect':
$o = pumpio_connect($a);
break;
default:
$o = print_r(DI::args()->getArgv(), true);
break;
@ -77,53 +83,54 @@ function pumpio_content(App $a)
return $o;
}
function pumpio_check_item_notification($a, &$notification_data)
function pumpio_check_item_notification(App $a, array &$notification_data)
{
$hostname = DI::pConfig()->get($notification_data["uid"], 'pumpio', 'host');
$username = DI::pConfig()->get($notification_data["uid"], "pumpio", "user");
$hostname = DI::pConfig()->get($notification_data['uid'], 'pumpio', 'host');
$username = DI::pConfig()->get($notification_data['uid'], 'pumpio', 'user');
$notification_data["profiles"][] = "https://".$hostname."/".$username;
$notification_data['profiles'][] = 'https://' . $hostname . '/' . $username;
}
function pumpio_registerclient(App $a, $host)
{
$url = "https://".$host."/api/client/register";
$url = 'https://' . $host . '/api/client/register';
$params = [];
$application_name = DI::config()->get('pumpio', 'application_name');
if ($application_name == "") {
if ($application_name == '') {
$application_name = DI::baseUrl()->getHostname();
}
$adminlist = explode(",", str_replace(" ", "", DI::config()->get('config', 'admin_email')));
$adminlist = explode(',', str_replace(' ', '', DI::config()->get('config', 'admin_email')));
$params["type"] = "client_associate";
$params["contacts"] = $adminlist[0];
$params["application_type"] = "native";
$params["application_name"] = $application_name;
$params["logo_url"] = DI::baseUrl()->get()."/images/friendica-256.png";
$params["redirect_uris"] = DI::baseUrl()->get()."/pumpio/connect";
$params['type'] = 'client_associate';
$params['contacts'] = $adminlist[0];
$params['application_type'] = 'native';
$params['application_name'] = $application_name;
$params['logo_url'] = DI::baseUrl()->get() . '/images/friendica-256.png';
$params['redirect_uris'] = DI::baseUrl()->get() . '/pumpio/connect';
Logger::info("pumpio_registerclient: ".$url." parameters ".print_r($params, true));
Logger::info('pumpio_registerclient: ' . $url . ' parameters', $params);
// @TODO Rewrite this to our own HTTP client
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
curl_setopt($ch, CURLOPT_USERAGENT, "Friendica");
curl_setopt($ch, CURLOPT_USERAGENT, 'Friendica');
$s = curl_exec($ch);
$curl_info = curl_getinfo($ch);
if ($curl_info["http_code"] == "200") {
if ($curl_info['http_code'] == '200') {
$values = json_decode($s);
Logger::info("pumpio_registerclient: success ".print_r($values, true));
Logger::info('pumpio_registerclient: success ', $values);
return $values;
}
Logger::info("pumpio_registerclient: failed: ".print_r($curl_info, true));
Logger::info('pumpio_registerclient: failed: ', $curl_info);
return false;
}
@ -135,8 +142,8 @@ function pumpio_connect(App $a)
$consumer_secret = DI::pConfig()->get(local_user(), 'pumpio', 'consumer_secret');
$hostname = DI::pConfig()->get(local_user(), 'pumpio', 'host');
if ((($consumer_key == "") || ($consumer_secret == "")) && ($hostname != "")) {
Logger::notice("pumpio_connect: register client");
if ((($consumer_key == '') || ($consumer_secret == '')) && ($hostname != '')) {
Logger::notice('pumpio_connect: register client');
$clientdata = pumpio_registerclient($a, $hostname);
DI::pConfig()->set(local_user(), 'pumpio', 'consumer_key', $clientdata->client_id);
DI::pConfig()->set(local_user(), 'pumpio', 'consumer_secret', $clientdata->client_secret);
@ -144,17 +151,17 @@ function pumpio_connect(App $a)
$consumer_key = DI::pConfig()->get(local_user(), 'pumpio', 'consumer_key');
$consumer_secret = DI::pConfig()->get(local_user(), 'pumpio', 'consumer_secret');
Logger::info("pumpio_connect: ckey: ".$consumer_key." csecrect: ".$consumer_secret);
Logger::info('pumpio_connect: ckey: ' . $consumer_key . ' csecrect: ' . $consumer_secret);
}
if (($consumer_key == "") || ($consumer_secret == "")) {
Logger::notice("pumpio_connect: ".sprintf("Unable to register the client at the pump.io server '%s'.", $hostname));
if (($consumer_key == '') || ($consumer_secret == '')) {
Logger::notice('pumpio_connect: '.sprintf('Unable to register the client at the pump.io server "%s".', $hostname));
return DI::l10n()->t("Unable to register the client at the pump.io server '%s'.", $hostname);
}
// The callback URL is the script that gets called after the user authenticates with pumpio
$callback_url = DI::baseUrl()->get()."/pumpio/connect";
$callback_url = DI::baseUrl()->get() . '/pumpio/connect';
// Let's begin. First we need a Request Token. The request token is required to send the user
// to pumpio's login page.
@ -177,9 +184,9 @@ function pumpio_connect(App $a)
if (($success = $client->Initialize())) {
if (($success = $client->Process())) {
if (strlen($client->access_token)) {
Logger::info("pumpio_connect: otoken: ".$client->access_token." osecrect: ".$client->access_token_secret);
DI::pConfig()->set(local_user(), "pumpio", "oauth_token", $client->access_token);
DI::pConfig()->set(local_user(), "pumpio", "oauth_token_secret", $client->access_token_secret);
Logger::info('pumpio_connect: otoken: ' . $client->access_token . ', osecrect: ' . $client->access_token_secret);
DI::pConfig()->set(local_user(), 'pumpio', 'oauth_token', $client->access_token);
DI::pConfig()->set(local_user(), 'pumpio', 'oauth_token_secret', $client->access_token_secret);
}
}
$success = $client->Finalize($success);
@ -189,11 +196,11 @@ function pumpio_connect(App $a)
}
if ($success) {
Logger::notice("pumpio_connect: authenticated");
$o = DI::l10n()->t("You are now authenticated to pumpio.");
$o .= '<br /><a href="'.DI::baseUrl()->get().'/settings/connectors">'.DI::l10n()->t("return to the connector page").'</a>';
Logger::notice('pumpio_connect: authenticated');
$o = DI::l10n()->t('You are now authenticated to pumpio.');
$o .= '<br /><a href="' . DI::baseUrl()->get() . '/settings/connectors">' . DI::l10n()->t('return to the connector page') . '</a>';
} else {
Logger::notice("pumpio_connect: could not connect");
Logger::notice('pumpio_connect: could not connect');
$o = 'Could not connect to pumpio. Refresh the page or try again later.';
}
@ -288,8 +295,8 @@ function pumpio_settings_post(App $a, array &$b)
} elseif (!empty($_POST['pumpio-submit'])) {
// filtering the username if it is filled wrong
$user = $_POST['pumpio_user'];
if (strstr($user, "@")) {
$pos = strpos($user, "@");
if (strstr($user, '@')) {
$pos = strpos($user, '@');
if ($pos > 0) {
$user = substr($user, 0, $pos);
@ -299,7 +306,7 @@ function pumpio_settings_post(App $a, array &$b)
// Filtering the hostname if someone is entering it with "http"
$host = $_POST['pumpio_host'];
$host = trim($host);
$host = str_replace(["https://", "http://"], ["", ""], $host);
$host = str_replace(['https://', 'http://'], ['', ''], $host);
DI::pConfig()->set(local_user(), 'pumpio', 'post' , $_POST['pumpio'] ?? false);
DI::pConfig()->set(local_user(), 'pumpio', 'import' , $_POST['pumpio_import'] ?? false);
@ -335,7 +342,7 @@ function pumpio_hook_fork(App $a, array &$b)
}
// if post comes from pump.io don't send it back
if ($post['app'] == "pump.io") {
if ($post['app'] == 'pump.io') {
$b['execute'] = false;
return;
}
@ -383,11 +390,11 @@ function pumpio_post_local(App $a, array &$b)
function pumpio_send(App $a, array &$b)
{
if (!DI::pConfig()->get($b["uid"], 'pumpio', 'import') && ($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited']))) {
if (!DI::pConfig()->get($b['uid'], 'pumpio', 'import') && ($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited']))) {
return;
}
Logger::debug("pumpio_send: parameter ".print_r($b, true));
Logger::debug('pumpio_send: parameter ', $b);
$b['body'] = Post\Media::addAttachmentsToBody($b['uri-id'], $b['body']);
@ -397,7 +404,7 @@ function pumpio_send(App $a, array &$b)
$orig_post = Post::selectFirst([], $condition);
if (!DBA::isResult($orig_post)) {
Logger::notice("pumpio_send: no pumpio post ".$b["parent"]);
Logger::notice('pumpio_send: no pumpio post ' . $b['parent']);
return;
} else {
$iscomment = true;
@ -407,7 +414,7 @@ function pumpio_send(App $a, array &$b)
$receiver = pumpio_getreceiver($a, $b);
Logger::notice("pumpio_send: receiver ".print_r($receiver, true));
Logger::notice('pumpio_send: receiver ', $receiver);
if (!count($receiver) && ($b['private'] || !strstr($b['postopts'], 'pumpio'))) {
return;
@ -423,9 +430,9 @@ function pumpio_send(App $a, array &$b)
if ($b['verb'] == Activity::LIKE) {
if ($b['deleted']) {
pumpio_action($a, $b["uid"], $b["thr-parent"], "unlike");
pumpio_action($a, $b['uid'], $b['thr-parent'], 'unlike');
} else {
pumpio_action($a, $b["uid"], $b["thr-parent"], "like");
pumpio_action($a, $b['uid'], $b['thr-parent'], 'like');
}
return;
}
@ -435,11 +442,11 @@ function pumpio_send(App $a, array &$b)
}
if (($b['verb'] == Activity::POST) && ($b['created'] !== $b['edited']) && !$b['deleted']) {
pumpio_action($a, $b["uid"], $b["uri"], "update", $b["body"]);
pumpio_action($a, $b['uid'], $b['uri'], 'update', $b['body']);
}
if (($b['verb'] == Activity::POST) && $b['deleted']) {
pumpio_action($a, $b["uid"], $b["uri"], "delete");
pumpio_action($a, $b['uid'], $b['uri'], 'delete');
}
if ($b['deleted'] || ($b['created'] !== $b['edited'])) {
@ -447,7 +454,7 @@ function pumpio_send(App $a, array &$b)
}
// if post comes from pump.io don't send it back
if ($b['app'] == "pump.io") {
if ($b['app'] == 'pump.io') {
return;
}
@ -455,14 +462,14 @@ function pumpio_send(App $a, array &$b)
// Support for native shares
// http://<hostname>/api/<type>/shares?id=<the-object-id>
$oauth_token = DI::pConfig()->get($b['uid'], "pumpio", "oauth_token");
$oauth_token_secret = DI::pConfig()->get($b['uid'], "pumpio", "oauth_token_secret");
$consumer_key = DI::pConfig()->get($b['uid'], "pumpio","consumer_key");
$consumer_secret = DI::pConfig()->get($b['uid'], "pumpio","consumer_secret");
$oauth_token = DI::pConfig()->get($b['uid'], 'pumpio', 'oauth_token');
$oauth_token_secret = DI::pConfig()->get($b['uid'], 'pumpio', 'oauth_token_secret');
$consumer_key = DI::pConfig()->get($b['uid'], 'pumpio', 'consumer_key');
$consumer_secret = DI::pConfig()->get($b['uid'], 'pumpio', 'consumer_secret');
$host = DI::pConfig()->get($b['uid'], "pumpio", "host");
$user = DI::pConfig()->get($b['uid'], "pumpio", "user");
$public = DI::pConfig()->get($b['uid'], "pumpio", "public");
$host = DI::pConfig()->get($b['uid'], 'pumpio', 'host');
$user = DI::pConfig()->get($b['uid'], 'pumpio', 'user');
$public = DI::pConfig()->get($b['uid'], 'pumpio', 'public');
if ($oauth_token && $oauth_token_secret) {
$title = trim($b['title']);
@ -471,47 +478,49 @@ function pumpio_send(App $a, array &$b)
$params = [];
$params["verb"] = "post";
$params['verb'] = 'post';
if (!$iscomment) {
$params["object"] = [
'objectType' => "note",
$params['object'] = [
'objectType' => 'note',
'content' => $content];
if (!empty($title)) {
$params["object"]["displayName"] = $title;
$params['object']['displayName'] = $title;
}
if (!empty($receiver["to"])) {
$params["to"] = $receiver["to"];
if (!empty($receiver['to'])) {
$params['to'] = $receiver['to'];
}
if (!empty($receiver["bto"])) {
$params["bto"] = $receiver["bto"];
if (!empty($receiver['bto'])) {
$params['bto'] = $receiver['bto'];
}
if (!empty($receiver["cc"])) {
$params["cc"] = $receiver["cc"];
if (!empty($receiver['cc'])) {
$params['cc'] = $receiver['cc'];
}
if (!empty($receiver["bcc"])) {
$params["bcc"] = $receiver["bcc"];
if (!empty($receiver['bcc'])) {
$params['bcc'] = $receiver['bcc'];
}
} else {
$inReplyTo = ["id" => $orig_post["uri"],
"objectType" => "note"];
$inReplyTo = [
'id' => $orig_post['uri'],
'objectType' => 'note',
];
if (($orig_post["object-type"] != "") && (strstr($orig_post["object-type"], ActivityNamespace::ACTIVITY_SCHEMA))) {
$inReplyTo["objectType"] = str_replace(ActivityNamespace::ACTIVITY_SCHEMA, '', $orig_post["object-type"]);
if (($orig_post['object-type'] != '') && (strstr($orig_post['object-type'], ActivityNamespace::ACTIVITY_SCHEMA))) {
$inReplyTo['objectType'] = str_replace(ActivityNamespace::ACTIVITY_SCHEMA, '', $orig_post['object-type']);
}
$params["object"] = [
'objectType' => "comment",
$params['object'] = [
'objectType' => 'comment',
'content' => $content,
'inReplyTo' => $inReplyTo];
if ($title != "") {
$params["object"]["displayName"] = $title;
if ($title != '') {
$params['object']['displayName'] = $title;
}
}
@ -535,13 +544,13 @@ function pumpio_send(App $a, array &$b)
if ($success) {
if ($user->generator->displayName) {
DI::pConfig()->set($b["uid"], "pumpio", "application_name", $user->generator->displayName);
DI::pConfig()->set($b['uid'], 'pumpio', 'application_name', $user->generator->displayName);
}
$post_id = $user->object->id;
Logger::notice('pumpio_send ' . $username . ': success ' . $post_id);
if ($post_id && $iscomment) {
Logger::notice('pumpio_send '.$username.': Update extid '.$post_id." for post id ".$b['id']);
Logger::notice('pumpio_send ' . $username . ': Update extid ' . $post_id . ' for post id ' . $b['id']);
Item::update(['extid' => $post_id], ['id' => $b['id']]);
}
} else {
@ -551,7 +560,7 @@ function pumpio_send(App $a, array &$b)
}
}
function pumpio_action(App $a, $uid, $uri, $action, $content = "")
function pumpio_action(App $a, int $uid, string $uri, string $action, string $content = '')
{
// Don't do likes and other stuff if you don't import the timeline
if (!DI::pConfig()->get($uid, 'pumpio', 'import')) {
@ -563,7 +572,7 @@ function pumpio_action(App $a, $uid, $uri, $action, $content = "")
$otoken = DI::pConfig()->get($uid, 'pumpio', 'oauth_token');
$osecret = DI::pConfig()->get($uid, 'pumpio', 'oauth_token_secret');
$hostname = DI::pConfig()->get($uid, 'pumpio', 'host');
$username = DI::pConfig()->get($uid, "pumpio", "user");
$username = DI::pConfig()->get($uid, 'pumpio', 'user');
$orig_post = Post::selectFirst([], ['uri' => $uri, 'uid' => $uid]);
@ -571,26 +580,28 @@ function pumpio_action(App $a, $uid, $uri, $action, $content = "")
return;
}
if ($orig_post["extid"] && !strstr($orig_post["extid"], "/proxy/")) {
$uri = $orig_post["extid"];
if ($orig_post['extid'] && !strstr($orig_post['extid'], '/proxy/')) {
$uri = $orig_post['extid'];
} else {
$uri = $orig_post["uri"];
$uri = $orig_post['uri'];
}
if (($orig_post["object-type"] != "") && (strstr($orig_post["object-type"], ActivityNamespace::ACTIVITY_SCHEMA))) {
$objectType = str_replace(ActivityNamespace::ACTIVITY_SCHEMA, '', $orig_post["object-type"]);
} elseif (strstr($uri, "/api/comment/")) {
$objectType = "comment";
} elseif (strstr($uri, "/api/note/")) {
$objectType = "note";
} elseif (strstr($uri, "/api/image/")) {
$objectType = "image";
if (($orig_post['object-type'] != '') && (strstr($orig_post['object-type'], ActivityNamespace::ACTIVITY_SCHEMA))) {
$objectType = str_replace(ActivityNamespace::ACTIVITY_SCHEMA, '', $orig_post['object-type']);
} elseif (strstr($uri, '/api/comment/')) {
$objectType = 'comment';
} elseif (strstr($uri, '/api/note/')) {
$objectType = 'note';
} elseif (strstr($uri, '/api/image/')) {
$objectType = 'image';
}
$params["verb"] = $action;
$params["object"] = ['id' => $uri,
"objectType" => $objectType,
"content" => $content];
$params['verb'] = $action;
$params['object'] = [
'id' => $uri,
'objectType' => $objectType,
'content' => $content,
];
$client = new oauth_client_class;
$client->oauth_version = '1.0a';
@ -671,7 +682,7 @@ function pumpio_sync(App $a)
}
if ($next_contact_check <= time()) {
pumpio_getallusers($a, $rr["uid"]);
pumpio_getallusers($a, $rr['uid']);
DI::pConfig()->set($rr['uid'], 'pumpio', 'contact_check', time());
}
}
@ -683,10 +694,10 @@ function pumpio_sync(App $a)
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');
$csecret = DI::pConfig()->get($uid, 'pumpio', 'consumer_secret');
@ -694,20 +705,20 @@ function pumpio_fetchtimeline(App $a, $uid)
$osecret = DI::pConfig()->get($uid, 'pumpio', 'oauth_token_secret');
$lastdate = DI::pConfig()->get($uid, 'pumpio', 'lastdate');
$hostname = DI::pConfig()->get($uid, 'pumpio', 'host');
$username = DI::pConfig()->get($uid, "pumpio", "user");
$username = DI::pConfig()->get($uid, 'pumpio', 'user');
// get the application name for the pump.io app
// 1st try personal config, then system config and fallback to the
// hostname of the node if neither one is set.
$application_name = DI::pConfig()->get($uid, 'pumpio', 'application_name');
if ($application_name == "") {
if ($application_name == '') {
$application_name = DI::config()->get('pumpio', 'application_name');
}
if ($application_name == "") {
if ($application_name == '') {
$application_name = DI::baseUrl()->getHostname();
}
$first_time = ($lastdate == "");
$first_time = ($lastdate == '');
$client = new oauth_client_class;
$client->oauth_version = '1.0a';
@ -733,7 +744,7 @@ function pumpio_fetchtimeline(App $a, $uid)
}
if (!$success) {
Logger::notice('pumpio: error fetching posts for user '.$uid." ".$useraddr." ".print_r($user, true));
Logger::notice('pumpio: error fetching posts for user ' . $uid . ' ' . $useraddr . ' ', $user);
return;
}
@ -766,45 +777,45 @@ function pumpio_fetchtimeline(App $a, $uid)
}
$public = false;
foreach ($receiptians AS $receiver) {
if (is_string($receiver->objectType) && ($receiver->id == "http://activityschema.org/collection/public")) {
foreach ($receiptians as $receiver) {
if (is_string($receiver->objectType) && ($receiver->id == 'http://activityschema.org/collection/public')) {
$public = true;
}
}
if ($public && !stristr($post->generator->displayName, $application_name)) {
$_SESSION["authenticated"] = true;
$_SESSION["uid"] = $uid;
$_SESSION['authenticated'] = true;
$_SESSION['uid'] = $uid;
unset($_REQUEST);
$_REQUEST["api_source"] = true;
$_REQUEST["profile_uid"] = $uid;
$_REQUEST["source"] = "pump.io";
$_REQUEST['api_source'] = true;
$_REQUEST['profile_uid'] = $uid;
$_REQUEST['source'] = 'pump.io';
if (isset($post->object->id)) {
$_REQUEST['message_id'] = Protocol::PUMPIO.":".$post->object->id;
$_REQUEST['message_id'] = Protocol::PUMPIO . ':' . $post->object->id;
}
if ($post->object->displayName != "") {
$_REQUEST["title"] = HTML::toBBCode($post->object->displayName);
if ($post->object->displayName != '') {
$_REQUEST['title'] = HTML::toBBCode($post->object->displayName);
} else {
$_REQUEST["title"] = "";
$_REQUEST['title'] = '';
}
$_REQUEST["body"] = HTML::toBBCode($post->object->content);
$_REQUEST['body'] = HTML::toBBCode($post->object->content);
// To-Do: Picture has to be cached and stored locally
if ($post->object->fullImage->url != "") {
if ($post->object->fullImage->pump_io->proxyURL != "") {
$_REQUEST["body"] = "[url=".$post->object->fullImage->pump_io->proxyURL."][img]".$post->object->image->pump_io->proxyURL."[/img][/url]\n".$_REQUEST["body"];
if ($post->object->fullImage->url != '') {
if ($post->object->fullImage->pump_io->proxyURL != '') {
$_REQUEST['body'] = '[url=' . $post->object->fullImage->pump_io->proxyURL . '][img]' . $post->object->image->pump_io->proxyURL . "[/img][/url]\n" . $_REQUEST['body'];
} else {
$_REQUEST["body"] = "[url=".$post->object->fullImage->url."][img]".$post->object->image->url."[/img][/url]\n".$_REQUEST["body"];
$_REQUEST['body'] = '[url=' . $post->object->fullImage->url . '][img]' . $post->object->image->url . "[/img][/url]\n" . $_REQUEST['body'];
}
}
Logger::notice('pumpio: posting for user ' . $uid);
require_once('mod/item.php');
require_once 'mod/item.php';
item_post($a);
Logger::notice('pumpio: posting done - user ' . $uid);
@ -817,7 +828,7 @@ function pumpio_fetchtimeline(App $a, $uid)
}
}
function pumpio_dounlike(App $a, $uid, $self, $post, $own_id)
function pumpio_dounlike(App $a, int $uid, array $self, $post, string $own_id)
{
// Searching for the unliked post
// Two queries for speed issues
@ -847,13 +858,13 @@ function pumpio_dounlike(App $a, $uid, $self, $post, $own_id)
Item::markForDeletion(['verb' => Activity::LIKE, 'uid' => $uid, 'contact-id' => $contactid, 'thr-parent' => $orig_post['uri']]);
if (DBA::isResult($contact)) {
Logger::notice("pumpio_dounlike: unliked existing like. User ".$own_id." ".$uid." Contact: ".$contactid." Url ".$orig_post['uri']);
Logger::notice('pumpio_dounlike: unliked existing like. User ' . $own_id . ' ' . $uid . ' Contact: ' . $contactid . ' URI ' . $orig_post['uri']);
} else {
Logger::notice("pumpio_dounlike: not found. User ".$own_id." ".$uid." Contact: ".$contactid." Url ".$orig_post['uri']);
Logger::notice('pumpio_dounlike: not found. User ' . $own_id . ' ' . $uid . ' Contact: ' . $contactid . ' Url ' . $orig_post['uri']);
}
}
function pumpio_dolike(App $a, $uid, $self, $post, $own_id, $threadcompletion = true)
function pumpio_dolike(App $a, int $uid, array $self, $post, string $own_id, $threadcompletion = true)
{
if (empty($post->object->id)) {
Logger::info('Got empty like: '.print_r($post, true));
@ -893,9 +904,15 @@ function pumpio_dolike(App $a, $uid, $self, $post, $own_id, $threadcompletion =
}
}
$condition = ['verb' => Activity::LIKE, 'uid' => $uid, 'contact-id' => $contactid, 'thr-parent' => $orig_post['uri']];
$condition = [
'verb' => Activity::LIKE,
'uid' => $uid,
'contact-id' => $contactid,
'thr-parent' => $orig_post['uri'],
];
if (Post::exists($condition)) {
Logger::notice("pumpio_dolike: found existing like. User ".$own_id." ".$uid." Contact: ".$contactid." Url ".$orig_post['uri']);
Logger::notice('pumpio_dolike: found existing like. User ' . $own_id . ' ' . $uid . ' Contact: ' . $contactid . ' URI ' . $orig_post['uri']);
return;
}
@ -929,7 +946,7 @@ function pumpio_dolike(App $a, $uid, $self, $post, $own_id, $threadcompletion =
$ret = Item::insert($likedata);
Logger::notice("pumpio_dolike: ".$ret." User ".$own_id." ".$uid." Contact: ".$contactid." Url ".$orig_post['uri']);
Logger::notice('pumpio_dolike: ' . $ret . ' User ' . $own_id . ' ' . $uid . ' Contact: ' . $contactid . ' URI ' . $orig_post['uri']);
}
function pumpio_get_contact($uid, $contact, $no_insert = false)
@ -948,7 +965,7 @@ function pumpio_get_contact($uid, $contact, $no_insert = false)
'created' => DateTimeFormat::utcNow(),
'url' => $contact->url,
'nurl' => Strings::normaliseLink($contact->url),
'addr' => str_replace("acct:", "", $contact->id),
'addr' => str_replace('acct:', '', $contact->id),
'alias' => '',
'notify' => $contact->id,
'poll' => 'pump.io ' . $contact->id,
@ -975,7 +992,7 @@ function pumpio_get_contact($uid, $contact, $no_insert = false)
Group::addMember(User::getDefaultGroup($uid), $contact_id);
} else {
$contact_id = $r["id"];
$contact_id = $r['id'];
}
if (!empty($contact->image->url)) {
@ -985,7 +1002,7 @@ function pumpio_get_contact($uid, $contact, $no_insert = false)
return $contact_id;
}
function pumpio_dodelete(App $a, $uid, $self, $post, $own_id)
function pumpio_dodelete(App $a, int $uid, array $self, $post, string $own_id)
{
// Two queries for speed issues
$condition = ['uri' => $post->object->id, 'uid' => $uid];
@ -1002,21 +1019,21 @@ function pumpio_dodelete(App $a, $uid, $self, $post, $own_id)
return false;
}
function pumpio_dopost(App $a, $client, $uid, $self, $post, $own_id, $threadcompletion = true)
function pumpio_dopost(App $a, $client, int $uid, array $self, $post, string $own_id, bool $threadcompletion = true)
{
if (($post->verb == "like") || ($post->verb == "favorite")) {
if (($post->verb == 'like') || ($post->verb == 'favorite')) {
return pumpio_dolike($a, $uid, $self, $post, $own_id);
}
if (($post->verb == "unlike") || ($post->verb == "unfavorite")) {
if (($post->verb == 'unlike') || ($post->verb == 'unfavorite')) {
return pumpio_dounlike($a, $uid, $self, $post, $own_id);
}
if ($post->verb == "delete") {
if ($post->verb == 'delete') {
return pumpio_dodelete($a, $uid, $self, $post, $own_id);
}
if ($post->verb != "update") {
if ($post->verb != 'update') {
// Two queries for speed issues
if (Post::exists(['uri' => $post->object->id, 'uid' => $uid])) {
return false;
@ -1027,7 +1044,7 @@ function pumpio_dopost(App $a, $client, $uid, $self, $post, $own_id, $threadcomp
}
// Only handle these three types
if (!strstr("post|share|update", $post->verb)) {
if (!strstr('post|share|update', $post->verb)) {
return false;
}
@ -1042,8 +1059,8 @@ function pumpio_dopost(App $a, $client, $uid, $self, $post, $own_id, $threadcomp
$public = false;
foreach ($receiptians AS $receiver) {
if (is_string($receiver->objectType) && ($receiver->id == "http://activityschema.org/collection/public")) {
foreach ($receiptians as $receiver) {
if (is_string($receiver->objectType) && ($receiver->id == 'http://activityschema.org/collection/public')) {
$public = true;
}
}
@ -1055,7 +1072,7 @@ function pumpio_dopost(App $a, $client, $uid, $self, $post, $own_id, $threadcomp
$postarray['uri'] = $post->object->id;
$postarray['object-type'] = ActivityNamespace::ACTIVITY_SCHEMA . strtolower($post->object->objectType);
if ($post->object->objectType != "comment") {
if ($post->object->objectType != 'comment') {
$contact_id = pumpio_get_contact($uid, $post->actor);
if (!$contact_id) {
@ -1087,7 +1104,7 @@ function pumpio_dopost(App $a, $client, $uid, $self, $post, $own_id, $threadcomp
}
$reply = new stdClass;
$reply->verb = "note";
$reply->verb = 'note';
if (isset($post->cc)) {
$reply->cc = $post->cc;
@ -1104,7 +1121,7 @@ function pumpio_dopost(App $a, $client, $uid, $self, $post, $own_id, $threadcomp
$reply->actor = $post->object->inReplyTo->author;
$reply->url = $post->object->inReplyTo->url;
$reply->generator = new stdClass;
$reply->generator->displayName = "pumpio";
$reply->generator->displayName = 'pumpio';
$reply->published = $post->object->inReplyTo->published;
$reply->received = $post->object->inReplyTo->updated;
$reply->url = $post->object->inReplyTo->url;
@ -1139,7 +1156,7 @@ function pumpio_dopost(App $a, $client, $uid, $self, $post, $own_id, $threadcomp
$postarray['object'] = json_encode($post);
if (!empty($post->object->fullImage->url)) {
$postarray["body"] = "[url=".$post->object->fullImage->url."][img]".$post->object->image->url."[/img][/url]\n".$postarray["body"];
$postarray['body'] = '[url=' . $post->object->fullImage->url . '][img]' . $post->object->image->url . "[/img][/url]\n" . $postarray['body'];
}
if (!empty($post->object->displayName)) {
@ -1155,10 +1172,10 @@ function pumpio_dopost(App $a, $client, $uid, $self, $post, $own_id, $threadcomp
$postarray['edited'] = $postarray['created'];
}
if ($post->verb == "share") {
if (isset($post->object->author->displayName) && ($post->object->author->displayName != "")) {
if ($post->verb == 'share') {
if (isset($post->object->author->displayName) && ($post->object->author->displayName != '')) {
$share_author = $post->object->author->displayName;
} elseif (isset($post->object->author->preferredUsername) && ($post->object->author->preferredUsername != "")) {
} elseif (isset($post->object->author->preferredUsername) && ($post->object->author->preferredUsername != '')) {
$share_author = $post->object->author->preferredUsername;
} else {
$share_author = $post->object->author->url;
@ -1172,30 +1189,34 @@ function pumpio_dopost(App $a, $client, $uid, $self, $post, $own_id, $threadcomp
$postarray['body'] = Friendica\Content\Text\BBCode::getShareOpeningTag($share_author, $post->object->author->url,
$post->object->author->image->url, $post->links->self->href, $created) .
$postarray['body']."[/share]";
$postarray['body'] . '[/share]';
}
if (trim($postarray['body']) == "") {
if (trim($postarray['body']) == '') {
return false;
}
$top_item = Item::insert($postarray);
$postarray["id"] = $top_item;
$postarray['id'] = $top_item;
if (($top_item == 0) && ($post->verb == "update")) {
$fields = ['title' => $postarray["title"], 'body' => $postarray["body"], 'changed' => $postarray["edited"]];
$condition = ['uri' => $postarray["uri"], 'uid' => $uid];
if (($top_item == 0) && ($post->verb == 'update')) {
$fields = [
'title' => $postarray['title'],
'body' => $postarray['body'],
'changed' => $postarray['edited'],
];
$condition = ['uri' => $postarray['uri'], 'uid' => $uid];
Item::update($fields, $condition);
}
if (($post->object->objectType == "comment") && $threadcompletion) {
if (($post->object->objectType == 'comment') && $threadcompletion) {
pumpio_fetchallcomments($a, $uid, $postarray['thr-parent']);
}
return $top_item;
}
function pumpio_fetchinbox(App $a, $uid)
function pumpio_fetchinbox(App $a, int $uid)
{
$ckey= DI::pConfig()->get($uid, 'pumpio', 'consumer_key');
$csecret = DI::pConfig()->get($uid, 'pumpio', 'consumer_secret');
@ -1203,9 +1224,9 @@ function pumpio_fetchinbox(App $a, $uid)
$osecret = DI::pConfig()->get($uid, 'pumpio', 'oauth_token_secret');
$lastdate = DI::pConfig()->get($uid, 'pumpio', 'lastdate');
$hostname = DI::pConfig()->get($uid, 'pumpio', 'host');
$username = DI::pConfig()->get($uid, "pumpio", "user");
$username = DI::pConfig()->get($uid, 'pumpio', 'user');
$own_id = "https://".$hostname."/".$username;
$own_id = 'https://' . $hostname . '/' . $username;
$self = User::getOwnerDataById($uid);
@ -1214,7 +1235,7 @@ function pumpio_fetchinbox(App $a, $uid)
WHERE `post-thread-user`.`network` = ? AND `post-thread-user`.`uid` = ? AND `post-view`.`extid` != ''
ORDER BY `post-thread-user`.`commented` DESC LIMIT 10", Protocol::PUMPIO, $uid);
$client = new oauth_client_class;
$client = new oauth_client_class();
$client->oauth_version = '1.0a';
$client->authorization_header = true;
$client->url_parameters = false;
@ -1228,7 +1249,7 @@ function pumpio_fetchinbox(App $a, $uid)
$url = 'https://'.$hostname.'/api/user/'.$username.'/inbox';
if ($last_id != "") {
if ($last_id != '') {
$url .= '?since=' . urlencode($last_id);
}
@ -1254,21 +1275,21 @@ function pumpio_fetchinbox(App $a, $uid)
}
while ($item = DBA::fetch($lastitems)) {
pumpio_fetchallcomments($a, $uid, $item["uri"]);
pumpio_fetchallcomments($a, $uid, $item['uri']);
}
DBA::close($lastitems);
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');
$csecret = DI::pConfig()->get($uid, 'pumpio', 'consumer_secret');
$otoken = DI::pConfig()->get($uid, 'pumpio', 'oauth_token');
$osecret = DI::pConfig()->get($uid, 'pumpio', 'oauth_token_secret');
$hostname = DI::pConfig()->get($uid, 'pumpio', 'host');
$username = DI::pConfig()->get($uid, "pumpio", "user");
$username = DI::pConfig()->get($uid, 'pumpio', 'user');
$client = new oauth_client_class;
$client->oauth_version = '1.0a';
@ -1313,36 +1334,38 @@ function pumpio_getreceiver(App $a, array $b)
{
$receiver = [];
if (!$b["private"]) {
if (!$b['private']) {
if (!strstr($b['postopts'], 'pumpio')) {
return $receiver;
}
$public = DI::pConfig()->get($b['uid'], "pumpio", "public");
$public = DI::pConfig()->get($b['uid'], 'pumpio', 'public');
if ($public) {
$receiver["to"][] = [
"objectType" => "collection",
"id" => "http://activityschema.org/collection/public"];
$receiver['to'][] = [
'objectType' => 'collection',
'id' => 'http://activityschema.org/collection/public'
];
}
} else {
$cids = explode("><", $b["allow_cid"]);
$gids = explode("><", $b["allow_gid"]);
$cids = explode('><', $b['allow_cid']);
$gids = explode('><', $b['allow_gid']);
foreach ($cids AS $cid) {
$cid = trim($cid, " <>");
foreach ($cids as $cid) {
$cid = trim($cid, ' <>');
$contact = Contact::selectFirst(['name', 'nick', 'url'], ['id' => $cid, 'uid' => $b["uid"], 'network' => Protocol::PUMPIO, 'blocked' => false, 'readonly' => false]);
$contact = Contact::selectFirst(['name', 'nick', 'url'], ['id' => $cid, 'uid' => $b['uid'], 'network' => Protocol::PUMPIO, 'blocked' => false, 'readonly' => false]);
if (DBA::isResult($contact)) {
$receiver["bcc"][] = [
"displayName" => $contact["name"],
"objectType" => "person",
"preferredUsername" => $contact["nick"],
"url" => $contact["url"]];
$receiver['bcc'][] = [
'displayName' => $contact['name'],
'objectType' => 'person',
'preferredUsername' => $contact['nick'],
'url' => $contact['url'],
];
}
}
foreach ($gids AS $gid) {
$gid = trim($gid, " <>");
foreach ($gids as $gid) {
$gid = trim($gid, ' <>');
$contacts = DBA::p("SELECT `contact`.`name`, `contact`.`nick`, `contact`.`url`, `contact`.`network`
FROM `group_member`, `contact` WHERE `group_member`.`gid` = ?
@ -1350,33 +1373,35 @@ function pumpio_getreceiver(App $a, array $b)
$gid, Protocol::PUMPIO);
while ($row = DBA::fetch($contacts)) {
$receiver["bcc"][] = [
"displayName" => $row["name"],
"objectType" => "person",
"preferredUsername" => $row["nick"],
"url" => $row["url"]];
$receiver['bcc'][] = [
'displayName' => $row['name'],
'objectType' => 'person',
'preferredUsername' => $row['nick'],
'url' => $row['url'],
];
}
DBA::close($contacts);
}
}
if ($b["inform"] != "") {
$inform = explode(",", $b["inform"]);
if ($b['inform'] != '') {
$inform = explode(',', $b['inform']);
foreach ($inform AS $cid) {
if (substr($cid, 0, 4) != "cid:") {
foreach ($inform as $cid) {
if (substr($cid, 0, 4) != 'cid:') {
continue;
}
$cid = str_replace("cid:", "", $cid);
$cid = str_replace('cid:', '', $cid);
$contact = Contact::selectFirst(['name', 'nick', 'url'], ['id' => $cid, 'uid' => $b["uid"], 'network' => Protocol::PUMPIO, 'blocked' => false, 'readonly' => false]);
$contact = Contact::selectFirst(['name', 'nick', 'url'], ['id' => $cid, 'uid' => $b['uid'], 'network' => Protocol::PUMPIO, 'blocked' => false, 'readonly' => false]);
if (DBA::isResult($contact)) {
$receiver["to"][] = [
"displayName" => $contact["name"],
"objectType" => "person",
"preferredUsername" => $contact["nick"],
"url" => $contact["url"]];
$receiver['to'][] = [
'displayName' => $contact['name'],
'objectType' => 'person',
'preferredUsername' => $contact['nick'],
'url' => $contact['url'],
];
}
}
}
@ -1391,11 +1416,11 @@ function pumpio_fetchallcomments(App $a, $uid, $id)
$otoken = DI::pConfig()->get($uid, 'pumpio', 'oauth_token');
$osecret = DI::pConfig()->get($uid, 'pumpio', 'oauth_token_secret');
$hostname = DI::pConfig()->get($uid, 'pumpio', 'host');
$username = DI::pConfig()->get($uid, "pumpio", "user");
$username = DI::pConfig()->get($uid, 'pumpio', 'user');
Logger::notice("pumpio_fetchallcomments: completing comment for user ".$uid." post id ".$id);
Logger::notice('pumpio_fetchallcomments: completing comment for user ' . $uid . ' post id ' . $id);
$own_id = "https://".$hostname."/".$username;
$own_id = 'https://' . $hostname . '/' . $username;
$self = User::getOwnerDataById($uid);
@ -1406,7 +1431,7 @@ function pumpio_fetchallcomments(App $a, $uid, $id)
return false;
}
$url = $original["extid"];
$url = $original['extid'];
$client = new oauth_client_class;
$client->oauth_version = '1.0a';
@ -1418,7 +1443,7 @@ function pumpio_fetchallcomments(App $a, $uid, $id)
$client->access_token = $otoken;
$client->access_token_secret = $osecret;
Logger::notice("pumpio_fetchallcomments: fetching comment for user ".$uid." url ".$url);
Logger::notice('pumpio_fetchallcomments: fetching comment for user ' . $uid . ', URL ' . $url);
if (pumpio_reachable($url)) {
$success = $client->CallAPI($url, 'GET', [], ['FailOnAccessError' => true], $item);
@ -1431,7 +1456,7 @@ function pumpio_fetchallcomments(App $a, $uid, $id)
}
if ($item->likes->totalItems != 0) {
foreach ($item->likes->items AS $post) {
foreach ($item->likes->items as $post) {
$like = new stdClass;
$like->object = new stdClass;
$like->object->id = $item->id;
@ -1443,7 +1468,7 @@ function pumpio_fetchallcomments(App $a, $uid, $id)
//$like->actor->image = $item->image;
$like->actor->url = $item->url;
$like->generator = new stdClass;
$like->generator->displayName = "pumpio";
$like->generator->displayName = 'pumpio';
pumpio_dolike($a, $uid, $self, $post, $own_id, false);
}
}
@ -1452,7 +1477,7 @@ function pumpio_fetchallcomments(App $a, $uid, $id)
return;
}
foreach ($item->replies->items AS $item) {
foreach ($item->replies->items as $item) {
if ($item->id == $id) {
continue;
}
@ -1467,12 +1492,12 @@ function pumpio_fetchallcomments(App $a, $uid, $id)
}
$post = new stdClass;
$post->verb = "post";
$post->verb = 'post';
$post->actor = $item->author;
$post->published = $item->published;
$post->received = $item->updated;
$post->generator = new stdClass;
$post->generator->displayName = "pumpio";
$post->generator->displayName = 'pumpio';
// To-Do: Check for public post
unset($item->author);
@ -1481,12 +1506,12 @@ function pumpio_fetchallcomments(App $a, $uid, $id)
$post->object = $item;
Logger::notice("pumpio_fetchallcomments: posting comment ".$post->object->id." ".print_r($post, true));
Logger::notice('pumpio_fetchallcomments: posting comment ' . $post->object->id . ' ', $post);
pumpio_dopost($a, $client, $uid, $self, $post, $own_id, false);
}
}
function pumpio_reachable($url)
function pumpio_reachable(string $url): bool
{
return DI::httpClient()->get($url, HttpClientAccept::DEFAULT, [HttpClientOptions::TIMEOUT => 10])->isSuccess();
}

View file

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

View file

@ -31,7 +31,7 @@ function qcomment_install()
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');
}
@ -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()) {
return;

View file

@ -25,75 +25,67 @@ use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\DI;
function randplace_install() {
/**
*
function randplace_install()
{
/*
* Our demo addon will attach in three places.
* The first is just prior to storing a local post.
*
*/
Hook::register('post_local', 'addon/randplace/randplace.php', 'randplace_post_hook');
/**
*
/*
* Then we'll attach into the addon settings page, and also the
* settings post hook so that we can create and update
* user preferences.
*
*/
Hook::register('addon_settings', 'addon/randplace/randplace.php', 'randplace_settings');
Hook::register('addon_settings_post', 'addon/randplace/randplace.php', 'randplace_settings_post');
Logger::notice("installed randplace");
}
function randplace_uninstall() {
/**
*
function randplace_uninstall()
{
/*
* 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.
*
*/
Logger::notice("removed randplace");
}
function randplace_post_hook($a, &$item) {
/**
*
function randplace_post_hook(App $a, &$item)
{
/*
* An item was posted on the local system.
* We are going to look for specific items:
* - A status post by a profile owner
* - The profile owner must have allowed our addon
*
*/
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;
}
if(local_user() != $item['uid']) /* Does this person own the post? */
if (local_user() != $item['uid']) {
/* Does this person own the post? */
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;
}
/* Retrieve our personal config setting */
$active = DI::pConfig()->get(local_user(), 'randplace', 'enable');
if(! $active)
if (!$active) {
return;
}
/**
*
@ -107,47 +99,43 @@ function randplace_post_hook($a, &$item) {
$cities = [];
$zones = timezone_identifiers_list();
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));
}
}
if(! count($cities))
if (!count($cities)) {
return;
}
$city = array_rand($cities,1);
$item['location'] = $cities[$city];
return;
}
/**
*
* Callback from the settings post function.
* $post contains the $_POST array.
* We will make sure we've got a valid user account
* and if so set our configuration setting for this person.
*
*/
function randplace_settings_post($a,$post) {
if(! local_user())
function randplace_settings_post(App $a, $post)
{
if (!local_user()) {
return;
if($_POST['randplace-submit'])
}
if ($_POST['randplace-submit']) {
DI::pConfig()->set(local_user(), 'randplace', 'enable', intval($_POST['randplace']));
}
}
/**
*
* Called from the Addon Setting form.
* Add our own settings info to the page.
*
*/
function randplace_settings(App &$a, array &$data)
{
if(!local_user()) {

View file

@ -7,6 +7,7 @@
*
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\Core\Renderer;
use Friendica\DI;
@ -16,14 +17,17 @@ function rendertime_install() {
DI::config()->set('system', 'profiler', true);
}
function rendertime_uninstall() {
function rendertime_uninstall()
{
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/");
$o = Renderer::replaceMacros($t, [
@ -33,16 +37,17 @@ 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', 'minimal_time', $_POST['minimal_time'] ?? 0);
}
/**
* @param Friendica\App $a
* @param App $a
* @param string $o
*/
function rendertime_page_end(Friendica\App $a, &$o)
function rendertime_page_end(App $a, &$o)
{
$profiler = DI::profiler();

View file

@ -14,7 +14,7 @@ use Friendica\DI;
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_config' , __FILE__, 's3_storage_config');

View file

@ -5,6 +5,8 @@
* Version: 1.0
* Author: Ryan <https://friendica.verya.pe/profile/ryan>
*/
use Friendica\App;
use Friendica\Content\Text\BBCode;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
@ -14,6 +16,7 @@ use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\User;
use Friendica\Util\Strings;
use OneLogin\Saml2\Utils;
require_once(__DIR__ . '/vendor/autoload.php');
@ -77,12 +80,12 @@ function saml_install()
Hook::register('footer', __FILE__, 'saml_footer');
}
function saml_head(&$a, &$b)
function saml_head(App $a, array &$b)
{
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')));
$b .= <<<EOL
@ -106,7 +109,7 @@ function saml_is_configured()
DI::config()->get('saml', 'idp_cert');
}
function saml_sso_initiate(&$a, &$b)
function saml_sso_initiate(App $a, array &$b)
{
if (!saml_is_configured()) {
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);
}
if (isset($_POST['RelayState'])
&& \OneLogin\Saml2\Utils::getSelfURL() != $_POST['RelayState']) {
if (isset($_POST['RelayState']) && Utils::getSelfURL() != $_POST['RelayState']) {
$auth->redirectTo($_POST['RelayState']);
}
}
function saml_slo_initiate(&$a, &$b)
function saml_slo_initiate(App $a, array &$b)
{
if (!saml_is_configured()) {
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 =
saml_input(
@ -279,7 +281,7 @@ function saml_addon_admin(&$a, &$o)
$o = Renderer::replaceMacros($t, $form);
}
function saml_addon_admin_post(&$a)
function saml_addon_admin_post(App $a)
{
$set = function ($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()) {
return;

View file

@ -24,12 +24,12 @@ function showmore_dyn_install()
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');
}
function showmore_dyn_footer(App $a, &$b)
function showmore_dyn_footer(App $a, array &$b)
{
DI::page()->registerFooterScript(__DIR__ . '/showmore_dyn.js');
}

View file

@ -6,6 +6,8 @@
* Author: Thomas Willingham (based on Mike Macgirvin's Adult Smile template)
* All smileys from sites offering them as Public Domain
*/
use Friendica\App;
use Friendica\Core\Hook;
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');
}
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.

View file

@ -8,14 +8,18 @@
*
*
*/
use Friendica\App;
use Friendica\Core\Hook;
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');
}
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.
@ -400,5 +404,4 @@ function smiley_pack_fr_smilies(&$a,&$b) {
$b['texts'][] = ':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
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\DI;
@ -15,8 +16,8 @@ function smiley_pack_install() {
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.
#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['icons'][] = '<img class="smiley" src="' . DI::baseUrl()->get() . '/addon/smiley_pack/icons/commercial/twitch.gif' . '" alt="' . ':twitch:' . '" />';
}

View file

@ -7,6 +7,7 @@
* Maintainer: Hypolite Petovan <https://friendica.mrpetovan.com/profile/hypolite>
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\DI;
@ -16,7 +17,7 @@ function smileybutton_install()
Hook::register('jot_tool', 'addon/smileybutton/smileybutton.php', 'smileybutton_jot_tool');
}
function smileybutton_jot_tool(Friendica\App $a, &$b)
function smileybutton_jot_tool(App $a, string &$body)
{
// Disable if theme is quattro
// TODO add style for quattro
@ -113,7 +114,7 @@ function smileybutton_jot_tool(Friendica\App $a, &$b)
$image_url = DI::baseUrl()->get() . '/' . $image;
//Add the hmtl and script to the page
$b = <<< EOT
$body = <<< EOT
<div id="profile-smiley-wrapper">
<button type="button" class="btn btn-link smiley_button" onclick="toggle_smileybutton()"><img src="$image_url" alt="smiley"></button>
<div id="smileybutton">

View file

@ -8,6 +8,8 @@
* This is a template for how to extend the "smily" code.
*
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\DI;
@ -15,8 +17,8 @@ function smilies_adult_install() {
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['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['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');
}
function startpage_home_init($a, $b)
function startpage_home_init(App $a, $b)
{
if (!local_user()) {
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()) {
return;

View file

@ -1055,5 +1055,3 @@ class CodebirdSN
return $parsed;
}
}
?>

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']) {
return;
@ -430,7 +430,7 @@ function statusnet_action(App $a, $uid, $pid, $action)
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
@ -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) {
return;
@ -753,7 +753,7 @@ function statusnet_cron(App $a, $b)
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');
$csecret = DI::pConfig()->get($uid, 'statusnet', 'consumersecret');
@ -1011,7 +1011,7 @@ function statusnet_fetchuser(App $a, $uid, $screen_name = '', $user_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');
@ -1415,7 +1415,7 @@ function statusnet_convertmsg(App $a, $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');
$csecret = DI::pConfig()->get($uid, 'statusnet', 'consumersecret');
@ -1450,7 +1450,7 @@ function statusnet_fetch_own_contact(App $a, $uid)
return $contact_id;
}
function statusnet_is_retweet(App $a, $uid, $body)
function statusnet_is_retweet(App $a, int $uid, string $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()) {
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'])) {
return;
}
@ -78,6 +79,7 @@ function superblock_enotify_store(&$a,&$b) {
}
}
}
if ($found) {
// Empty out the fields
$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()) {
return;
@ -95,8 +97,8 @@ function superblock_conversation_start(&$a, &$b)
if ($words) {
$a->data['superblock'] = explode(',', $words);
}
DI::page()['htmlhead'] .= <<< EOT
DI::page()['htmlhead'] .= <<< EOT
<script>
function superblockBlock(author) {
$.get('superblock?block=' +author, function(data) {
@ -104,12 +106,11 @@ function superblockBlock(author) {
});
}
</script>
EOT;
}
function superblock_item_photo_menu(&$a, &$b)
function superblock_item_photo_menu(App $a, array &$b)
{
if (!local_user() || $b['item']['self']) {
return;
@ -129,10 +130,14 @@ function superblock_item_photo_menu(&$a, &$b)
$b['menu'][DI::l10n()->t('Block Completely')] = 'javascript:superblockBlock(\'' . $author . '\'); return false;';
}
/**
* This is a statement rather than an actual function definition. The simple
* existence of this method is checked to figure out if the addon offers a
* module.
*/
function superblock_module() {}
function superblock_init(&$a)
function superblock_init(App $a)
{
if (!local_user()) {
return;

View file

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

View file

@ -5,27 +5,29 @@
* Version: 1.0
* Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\DI;
function tictac_install() {
function tictac_install()
{
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>';
}
/**
* This is a statement rather than an actual function definition. The simple
* existence of this method is checked to figure out if the addon offers a
* module.
*/
function tictac_module() {}
function tictac_module() {
return;
}
function tictac_content(&$a) {
function tictac_content(App $a) {
$o = '';

View file

@ -29,9 +29,12 @@ function tumblr_install()
Hook::register('connector_settings_post', 'addon/tumblr/tumblr.php', 'tumblr_settings_post');
}
function tumblr_module()
{
}
/**
* This is a statement rather than an actual function definition. The simple
* existence of this method is checked to figure out if the addon offers a
* module.
*/
function tumblr_module() {}
function tumblr_content(App $a)
{
@ -257,7 +260,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') {
return;

View file

@ -1149,7 +1149,7 @@ function twitter_parse_link(App $a, array &$b)
*
* @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['extid'] = 'twitter::' . $post->id;
@ -1196,7 +1196,7 @@ function twitter_do_mirrorpost(App $a, $uid, $post)
return $datarray;
}
function twitter_fetchtimeline(App $a, $uid)
function twitter_fetchtimeline(App $a, int $uid)
{
$ckey = DI::config()->get('twitter', 'consumerkey');
$csecret = DI::config()->get('twitter', 'consumersecret');
@ -1592,16 +1592,16 @@ function twitter_expand_entities($body, stdClass $status)
/**
* Store entity attachments
*
* @param integer $uriid
* @param integer $uriId
* @param object $post Twitter object with the post
*/
function twitter_store_attachments(int $uriid, $post)
function twitter_store_attachments(int $uriId, $post)
{
if (!empty($post->extended_entities->media)) {
foreach ($post->extended_entities->media AS $medium) {
switch ($medium->type) {
case 'photo':
$attachment = ['uri-id' => $uriid, 'type' => Post\Media::IMAGE];
$attachment = ['uri-id' => $uriId, 'type' => Post\Media::IMAGE];
$attachment['url'] = $medium->media_url_https . '?name=large';
$attachment['width'] = $medium->sizes->large->w;
@ -1620,7 +1620,7 @@ function twitter_store_attachments(int $uriid, $post)
break;
case 'video':
case 'animated_gif':
$attachment = ['uri-id' => $uriid, 'type' => Post\Media::VIDEO];
$attachment = ['uri-id' => $uriId, 'type' => Post\Media::VIDEO];
if (is_array($medium->video_info->variants)) {
$bitrate = 0;
// We take the video with the highest bitrate
@ -1648,7 +1648,7 @@ function twitter_store_attachments(int $uriid, $post)
if (!empty($post->entities->urls)) {
foreach ($post->entities->urls as $url) {
$attachment = ['uri-id' => $uriid, 'type' => Post\Media::UNKNOWN, 'url' => $url->expanded_url, 'name' => $url->display_url];
$attachment = ['uri-id' => $uriId, 'type' => Post\Media::UNKNOWN, 'url' => $url->expanded_url, 'name' => $url->display_url];
Logger::debug('Attached link', ['attachment' => $attachment]);
Post\Media::insert($attachment);
}
@ -1660,9 +1660,9 @@ function twitter_store_attachments(int $uriid, $post)
*
* @param object $post Twitter object with the post
* @param array $postarray Array of the item that is about to be posted
* @param integer $uriid URI Id used to store tags. -1 = don't store tags for this post.
* @param integer $uriId URI Id used to store tags. -1 = don't store tags for this post.
*/
function twitter_media_entities($post, array &$postarray, int $uriid = -1)
function twitter_media_entities($post, array &$postarray, int $uriId = -1)
{
// There are no media entities? So we quit.
if (empty($post->extended_entities->media)) {
@ -1714,7 +1714,7 @@ function twitter_media_entities($post, array &$postarray, int $uriid = -1)
}
}
if ($uriid != -1) {
if ($uriId != -1) {
foreach ($media AS $key => $value) {
$postarray['body'] = str_replace($key, '', $postarray['body']);
}
@ -1737,10 +1737,10 @@ function twitter_media_entities($post, array &$postarray, int $uriid = -1)
* @param bool $create_user Should users be created?
* @param bool $only_existing_contact Only import existing contacts if set to "true"
* @param bool $noquote
* @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
*/
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, bool $noquote, int $uriId = 0): array
{
$postarray = [];
$postarray['network'] = Protocol::TWITTER;
@ -1751,8 +1751,8 @@ function twitter_createpost(App $a, $uid, $post, array $self, $create_user, $onl
$postarray['source'] = json_encode($post);
$postarray['direction'] = Conversation::PULL;
if (empty($uriid)) {
$uriid = $postarray['uri-id'] = ItemURI::insert(['uri' => $postarray['uri']]);
if (empty($uriId)) {
$uriId = $postarray['uri-id'] = ItemURI::insert(['uri' => $postarray['uri']]);
}
// Don't import our own comments
@ -1845,7 +1845,7 @@ function twitter_createpost(App $a, $uid, $post, array $self, $create_user, $onl
}
// Search for media links
twitter_media_entities($post, $postarray, $uriid);
twitter_media_entities($post, $postarray, $uriId);
$converted = twitter_expand_entities($postarray['body'], $post);
@ -1858,9 +1858,9 @@ function twitter_createpost(App $a, $uid, $post, array $self, $create_user, $onl
$postarray['created'] = DateTimeFormat::utc($post->created_at);
$postarray['edited'] = DateTimeFormat::utc($post->created_at);
if ($uriid > 0) {
twitter_store_tags($uriid, $converted['taglist']);
twitter_store_attachments($uriid, $post);
if ($uriId > 0) {
twitter_store_tags($uriId, $converted['taglist']);
twitter_store_attachments($uriId, $post);
}
if (!empty($post->place->name)) {
@ -1916,7 +1916,7 @@ function twitter_createpost(App $a, $uid, $post, array $self, $create_user, $onl
if (!empty($quoted['body'])) {
Item::insert($quoted);
$post = Post::selectFirst(['guid', 'uri-id'], ['uri' => $quoted['uri'], 'uid' => 0]);
Logger::info('Stored quoted post', ['uid' => $uid, 'uri-id' => $uriid, 'post' => $post]);
Logger::info('Stored quoted post', ['uid' => $uid, 'uri-id' => $uriId, 'post' => $post]);
$postarray['body'] .= "\n" . BBCode::getShareOpeningTag(
$quoted['author-name'],
@ -1941,17 +1941,18 @@ function twitter_createpost(App $a, $uid, $post, array $self, $create_user, $onl
/**
* Store tags and mentions
*
* @param integer $uriid
* @param integer $uriId
* @param array $taglist
* @return void
*/
function twitter_store_tags(int $uriid, array $taglist)
function twitter_store_tags(int $uriId, array $taglist)
{
foreach ($taglist as $tag) {
Tag::storeByHash($uriid, $tag[0], $tag[1], $tag[2]);
Tag::storeByHash($uriId, $tag[0], $tag[1], $tag[2]);
}
}
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]);
@ -2003,7 +2004,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');
$csecret = DI::config()->get('twitter', 'consumersecret');
@ -2192,7 +2193,7 @@ function twitter_fetchhometimeline(App $a, $uid)
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');
$csecret = DI::config()->get('twitter', 'consumersecret');
@ -2228,7 +2229,7 @@ function twitter_fetch_own_contact(App $a, $uid)
return $contact_id;
}
function twitter_is_retweet(App $a, $uid, $body)
function twitter_is_retweet(App $a, int $uid, string $body): bool
{
$body = trim($body);
@ -2267,7 +2268,7 @@ function twitter_is_retweet(App $a, $uid, $body)
return twitter_retweet($uid, $id);
}
function twitter_retweet(int $uid, int $id, int $item_id = 0)
function twitter_retweet(int $uid, int $id, int $item_id = 0): bool
{
Logger::info('Retweeting', ['user' => $uid, 'id' => $id]);
@ -2283,7 +2284,7 @@ function twitter_retweet(int $uid, int $id, int $item_id = 0)
return !isset($result->errors);
}
function twitter_update_mentions($body)
function twitter_update_mentions(string $body): string
{
$URLSearchString = '^\[\]';
$return = preg_replace_callback(
@ -2303,7 +2304,7 @@ function twitter_update_mentions($body)
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)) {
return $content . "\n\n" . $attributes['link'];

View file

@ -6,6 +6,8 @@
* Author: Michael Vogel <http://pirati.ca/profile/heluecht>
* Author: Matthias Ebers <https://loma.ml/profile/one>
*/
use Friendica\App;
use Friendica\Content\Smilies;
use Friendica\Core\Hook;
@ -13,7 +15,8 @@ function unicode_smilies_install() {
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, ':-(', '&#x1F641;');

View file

@ -6,6 +6,8 @@
* Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
*
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\DI;
@ -14,7 +16,7 @@ function viewsrc_install() {
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
<script>
$(function(){
@ -26,7 +28,7 @@ function viewsrc_page_end(&$a, &$o){
EOS;
}
function viewsrc_item_photo_menu(&$a, &$b)
function viewsrc_item_photo_menu(App $a, array &$b)
{
if (!local_user()) {
return;

View file

@ -6,6 +6,8 @@
* Author: Stephen Mahood <https://friends.mayfirst.org/profile/marxistvegan>
* Author: Tobias Diekershoff <https://f.diekershoff.de/profile/tobias>
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\Core\Renderer;
use Friendica\DI;
@ -14,27 +16,35 @@ function webrtc_install() {
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>';
}
function webrtc_addon_admin (&$a, &$o) {
function webrtc_addon_admin (App $a, &$o)
{
$t = Renderer::getMarkupTemplate( "admin.tpl", "addon/webrtc/" );
$o = Renderer::replaceMacros( $t, [
'$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 .')],
]);
}
function webrtc_addon_admin_post (&$a) {
function webrtc_addon_admin_post (App $a)
{
$url = trim($_POST['webrtcurl'] ?? '');
DI::config()->set('webrtc', 'webrtcurl', $url);
}
function webrtc_module() {
return;
}
/**
* This is a statement rather than an actual function definition. The simple
* existence of this method is checked to figure out if the addon offers a
* module.
*/
function webrtc_module() {}
function webrtc_content(&$a) {
function webrtc_content(App $a)
{
$o = '';
/* landingpage to create chatrooms */
@ -49,7 +59,5 @@ function webrtc_content(&$a) {
$o .= '<iframe src="'.$webrtcurl.'" width="600px" height="600px"></iframe>';
}
return $o;
}
?>

View file

@ -60,17 +60,19 @@ function windowsphonepush_install()
}
/* declare the windowsphonepush function so that /windowsphonepush url requests will land here */
function windowsphonepush_module()
{
}
/**
* This is a statement rather than an actual function definition. The simple
* existence of this method is checked to figure out if the addon offers a
* module.
*/
function windowsphonepush_module() {}
/* Callback from the settings post function.
* $post contains the $_POST array.
* We will make sure we've got a valid user account
* and if so set our configuration setting for this person.
*/
function windowsphonepush_settings_post($a, $post)
function windowsphonepush_settings_post(App $a, $post)
{
if (!local_user() || empty($_POST['windowsphonepush-submit'])) {
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'])) {
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') {
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
@ -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'])) {
return;