Continued:

- added App (and imported it) as type-hint for $a
- also avoided & here as $a should not be modified within the function
- $b is 99.999% an array, let's add type-hint here

Signed-off-by: Roland Häder <roland@mxchange.org>
This commit is contained in:
Roland Häder 2018-05-10 15:13:30 +02:00
parent 81e57250e8
commit 5f02272cf9
No known key found for this signature in database
GPG key ID: B72F8185C6C7BD78
42 changed files with 261 additions and 167 deletions

View file

@ -6,6 +6,8 @@
* Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
*
*/
use Friendica\App;
use Friendica\Core\Addon;
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
@ -68,7 +70,7 @@ function blockem_addon_settings(&$a, &$s)
}
function blockem_addon_settings_post(&$a,&$b) {
function blockem_addon_settings_post(App $a, $b) {
if(! local_user())
return;
@ -79,7 +81,7 @@ function blockem_addon_settings_post(&$a,&$b) {
}
}
function blockem_enotify_store(&$a,&$b) {
function blockem_enotify_store(App $a, $b) {
$words = PConfig::get($b['uid'],'blockem','words');
if($words) {
@ -107,7 +109,7 @@ function blockem_enotify_store(&$a,&$b) {
}
}
function blockem_prepare_body_content_filter(\Friendica\App $a, &$hook_data)
function blockem_prepare_body_content_filter(App $a, array &$hook_data)
{
if (!local_user()) {
return;
@ -137,16 +139,17 @@ function blockem_prepare_body_content_filter(\Friendica\App $a, &$hook_data)
}
}
function blockem_display_item(&$a,&$b) {
function blockem_display_item(App $a, array &$b) {
if (empty($b['output']['body'])) {
return;
}
if(strstr($b['output']['body'],'id="blockem-wrap-'))
if (strstr($b['output']['body'],'id="blockem-wrap-')) {
$b['output']['thumb'] = $a->get_baseurl() . "/images/person-80.jpg";
}
}
function blockem_conversation_start(&$a,&$b) {
function blockem_conversation_start(App $a, $b) {
if(! local_user())
return;
@ -174,7 +177,7 @@ EOT;
}
function blockem_item_photo_menu(&$a,&$b) {
function blockem_item_photo_menu(App $a, $b) {
if((! local_user()) || ($b['item']['self']))
return;

View file

@ -6,6 +6,7 @@
*
*/
use Friencia\App;
use Friendica\Content\Text\BBCode;
use Friendica\Core\Addon;
use Friendica\Core\L10n;
@ -36,7 +37,7 @@ function blogger_uninstall()
}
function blogger_jot_nets(&$a, &$b)
function blogger_jot_nets(App $a, array &$b)
{
if (!local_user()) {
return;
@ -115,7 +116,7 @@ function blogger_settings(&$a, &$s)
}
function blogger_settings_post(&$a, &$b)
function blogger_settings_post(App $a, array &$b)
{
if (x($_POST, 'blogger-submit')) {
PConfig::set(local_user(), 'blogger', 'post', intval($_POST['blogger']));
@ -126,7 +127,7 @@ function blogger_settings_post(&$a, &$b)
}
}
function blogger_post_local(&$a, &$b)
function blogger_post_local(App $a, array &$b)
{
// This can probably be changed to allow editing by pointing to a different API endpoint
@ -164,7 +165,7 @@ function blogger_post_local(&$a, &$b)
function blogger_send(&$a, &$b)
function blogger_send(App $a, array &$b)
{
if ($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) {
return;

View file

@ -244,7 +244,7 @@ function buffer_post_local(&$a,&$b) {
$b['postopts'] .= 'buffer';
}
function buffer_send(App $a, &$b)
function buffer_send(App $a, array &$b)
{
if($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) {
return;

View file

@ -5,6 +5,8 @@
* Version: 1.0
* Author: Mike Macgirvin <mike@macgirvin.com>
*/
use Friencia\App;
use Friendica\Core\Addon;
use Friendica\Core\L10n;
@ -18,7 +20,7 @@ function buglink_uninstall()
Addon::unregisterHook('page_end', 'addon/buglink/buglink.php', 'buglink_active');
}
function buglink_active(&$a, &$b)
function buglink_active(App $a, array &$b)
{
$b .= '<div id="buglink_wrapper" style="position: fixed; bottom: 5px; left: 5px;"><a href="https://github.com/friendica/friendica/issues" target="_blank" title="' . L10n::t('Report Bug') . '"><img src="addon/buglink/bug-x.gif" alt="' . L10n::t('Report Bug') . '" /></a></div>';
}

View file

@ -8,6 +8,7 @@
* Author: Cat Gray <https://free-haven.org/profile/catness>
*/
use Friendica\App;
use Friendica\Content\Text\BBCode;
use Friendica\Core\Addon;
use Friendica\Core\L10n;
@ -33,7 +34,7 @@ function dwpost_uninstall() {
}
function dwpost_jot_nets(&$a,&$b) {
function dwpost_jot_nets(App $a, $b) {
if(! local_user())
return;
@ -47,7 +48,7 @@ function dwpost_jot_nets(&$a,&$b) {
}
function dwpost_settings(&$a,&$s) {
function dwpost_settings(App $a, $s) {
if(! local_user())
return;
@ -107,7 +108,7 @@ function dwpost_settings(&$a,&$s) {
}
function dwpost_settings_post(&$a,&$b) {
function dwpost_settings_post(App $a, $b) {
if(x($_POST,'dwpost-submit')) {
@ -120,7 +121,7 @@ function dwpost_settings_post(&$a,&$b) {
}
function dwpost_post_local(&$a,&$b) {
function dwpost_post_local(App $a, $b) {
// This can probably be changed to allow editing by pointing to a different API endpoint
@ -151,7 +152,7 @@ function dwpost_post_local(&$a,&$b) {
function dwpost_send(&$a,&$b) {
function dwpost_send(App $a, $b) {
if($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited']))
return;

View file

@ -6,6 +6,8 @@
* Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
* Status: Unsupported
*/
use Friencia\App;
use Friendica\Core\Addon;
use Friendica\Util\Network;
@ -27,7 +29,7 @@ function fortunate_uninstall()
}
function fortunate_fetch(&$a, &$b)
function fortunate_fetch(App $a, array &$b)
{
$a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="'
. $a->get_baseurl() . '/addon/fortunate/fortunate.css' . '" media="all" />' . "\r\n";

View file

@ -6,6 +6,7 @@
* Author: Thomas Willingham <https://beardyunixer.com/profile/beardyunixer>
*/
use Friencia\App;
use Friendica\Content\Nav;
use Friendica\Content\Widget;
use Friendica\Core\Addon;
@ -34,7 +35,7 @@ function forumdirectory_module()
return;
}
function forumdirectory_app_menu($a, &$b)
function forumdirectory_app_menu(App $a, array &$b)
{
$b['app_menu'][] = '<div class="app-title"><a href="forumdirectory">' . L10n::t('Forum Directory') . '</a></div>';
}

View file

@ -9,6 +9,7 @@
define('FROMGPLUS_DEFAULT_POLL_INTERVAL', 30); // given in minutes
use Friendica\App;
use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Core\L10n;
@ -38,7 +39,7 @@ function fromgplus_uninstall() {
Addon::unregisterHook('addon_settings_post', 'addon/fromgplus/fromgplus.php', 'fromgplus_addon_settings_post');
}
function fromgplus_addon_settings(&$a,&$s) {
function fromgplus_addon_settings(App $a, $s) {
if(! local_user())
return;
@ -79,7 +80,7 @@ class="settings-submit" value="' . L10n::t('Save Settings') . '" /></div>';
return;
}
function fromgplus_addon_settings_post(&$a,&$b) {
function fromgplus_addon_settings_post(App $a, $b) {
if(! local_user())
return;
@ -213,11 +214,10 @@ function fromgplus_html2bbcode($html) {
$bbcode = str_ireplace(["<br>"], ["\n"], $bbcode);
$bbcode = trim(strip_tags($bbcode));
return($bbcode);
return $bbcode;
}
function fromgplus_parse_query($var)
{
function fromgplus_parse_query($var) {
/**
* Use this function to parse out the query array element from
* the output of parse_url().
@ -246,38 +246,47 @@ function fromgplus_cleanupgoogleproxy($fullImage, $image) {
//$image = str_replace(array($preview, $preview2), array("/", "/"), $image->url);
$image = $image->url;
$cleaned = [];
$cleaned = [];
$queryvar = fromgplus_parse_query($fullImage);
if ($queryvar['url'] != "")
$cleaned["full"] = urldecode($queryvar['url']);
else
if ($queryvar['url'] != "") {
$cleaned["full"] = urldecode($queryvar['url']);
} else {
$cleaned["full"] = $fullImage;
if (@exif_imagetype($cleaned["full"]) == 0)
}
if (exif_imagetype($cleaned["full"]) == 0) {
$cleaned["full"] = "";
}
$queryvar = fromgplus_parse_query($image);
if ($queryvar['url'] != "")
$cleaned["preview"] = urldecode($queryvar['url']);
else
if ($queryvar['url'] != "") {
$cleaned["preview"] = urldecode($queryvar['url']);
} else {
$cleaned["preview"] = $image;
if (@exif_imagetype($cleaned["preview"]) == 0)
}
if (exif_imagetype($cleaned["preview"]) == 0) {
$cleaned["preview"] = "";
}
if ($cleaned["full"] == "") {
$cleaned["full"] = $cleaned["preview"];
$cleaned["preview"] = "";
}
if ($cleaned["full"] != "")
if ($cleaned["full"] != "") {
$infoFull = Image::getInfoFromURL($cleaned["full"]);
else
} else {
$infoFull = ["0" => 0, "1" => 0];
}
if ($cleaned["preview"] != "")
if ($cleaned["preview"] != "") {
$infoPreview = Image::getInfoFromURL($cleaned["preview"]);
else
} else {
$infoFull = ["0" => 0, "1" => 0];
}
if (($infoPreview[0] >= $infoFull[0]) && ($infoPreview[1] >= $infoFull[1])) {
$temp = $cleaned["full"];
@ -285,21 +294,22 @@ function fromgplus_cleanupgoogleproxy($fullImage, $image) {
$cleaned["preview"] = $temp;
}
if (($cleaned["full"] == $cleaned["preview"]) || (($infoPreview[0] == $infoFull[0]) && ($infoPreview[1] == $infoFull[1])))
if (($cleaned["full"] == $cleaned["preview"]) || (($infoPreview[0] == $infoFull[0]) && ($infoPreview[1] == $infoFull[1]))) {
$cleaned["preview"] = "";
}
if ($cleaned["full"] == "")
if (@exif_imagetype($fullImage) != 0)
$cleaned["full"] = $fullImage;
if ($cleaned["full"] == "" && exif_imagetype($fullImage) != 0) {
$cleaned["full"] = $fullImage;
}
if ($cleaned["full"] == "")
if (@exif_imagetype($image) != 0)
$cleaned["full"] = $image;
if ($cleaned["full"] == "" && exif_imagetype($image) != 0)
$cleaned["full"] = $image;
}
// Could be changed in the future to a link to the album
$cleaned["page"] = $cleaned["full"];
return($cleaned);
return $cleaned;
}
function fromgplus_cleantext($text) {
@ -311,7 +321,7 @@ function fromgplus_cleantext($text) {
$text = html_entity_decode($text, ENT_QUOTES);
$text = trim($text);
$text = str_replace(["\n", "\r", " ", $trash], ["", "", "", ""], $text);
return($text);
return $text;
}
function fromgplus_handleattachments($a, $uid, $item, $displaytext, $shared) {
@ -427,10 +437,11 @@ function fromgplus_handleattachments($a, $uid, $item, $displaytext, $shared) {
}
}
if ($pagedata["type"] != "")
return(add_page_info_data($pagedata));
if ($pagedata["type"] != "") {
return add_page_info_data($pagedata);
}
return($post.$quote);
return ($post . $quote);
}
function fromgplus_fetch($a, $uid) {

View file

@ -26,26 +26,32 @@ function geocoordinates_uninstall()
function geocoordinates_resolve_item(&$item)
{
if((!$item["coord"]) || ($item["location"]))
if((!x($item, 'coord')) || (x($item, 'location')))
return;
$key = Config::get("geocoordinates", "api_key");
if ($key == "")
if ($key == "") {
return;
}
$language = Config::get("geocoordinates", "language");
if ($language == "")
if ($language == "") {
$language = "de";
}
$coords = explode(' ',$item["coord"]);
if (count($coords) < 2)
if (count($coords) < 2) {
return;
}
$coords[0] = round($coords[0], 5);
$coords[1] = round($coords[1], 5);
$result = Cache::get("geocoordinates:".$language.":".$coords[0]."-".$coords[1]);
if (!is_null($result)) {
$item["location"] = $result;
return;
@ -53,7 +59,7 @@ function geocoordinates_resolve_item(&$item)
$s = Network::fetchUrl("https://api.opencagedata.com/geocode/v1/json?q=".$coords[0].",".$coords[1]."&key=".$key."&language=".$language);
if (!$s) {
if ($s === FALSE) {
logger("API could not be queried", LOGGER_DEBUG);
return;
}

View file

@ -21,6 +21,8 @@
* system will call the name_uninstall() function.
*
*/
use Friendica\App;
use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Core\L10n;
@ -166,7 +168,7 @@ function geonames_addon_admin_post($a,$post) {
function geonames_addon_admin(&$a,&$s) {
function geonames_addon_admin(App $a, $s) {
if(! local_user())
return;

View file

@ -6,6 +6,8 @@
* Author: Michael Vogel <https://pirati.ca/profile/heluecht>
*
*/
use Friencia\App;
use Friendica\Core\Addon;
use Friendica\Core\Cache;
@ -23,20 +25,20 @@ function googlemaps_uninstall()
logger("removed googlemaps");
}
function googlemaps_location($a, &$item)
function googlemaps_location(App $a, array &$item)
{
if(! (strlen($item['location']) || strlen($item['coord']))) {
if (! (strlen($item['location']) || strlen($item['coord']))) {
return;
}
if ($item['coord'] != ""){
if (x($item, 'coord')) {
$target = "http://maps.google.com/?q=".urlencode($item['coord']);
} else {
$target = "http://maps.google.com/?q=".urlencode($item['location']);
}
if ($item['location'] != "") {
if (x($item, 'location')) {
$title = $item['location'];
} else {
$title = $item['coord'];

View file

@ -5,6 +5,8 @@
* Version: 1.1
* Author: Klaus Weidenbach <http://friendica.dszdw.net/profile/klaus>
*/
use Friencia\App;
use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Core\L10n;
@ -40,7 +42,7 @@ function gravatar_load_config(\Friendica\App $a)
* @param $a array
* @param &$b array
*/
function gravatar_lookup($a, &$b) {
function gravatar_lookup(App $a, array &$b) {
$default_avatar = Config::get('gravatar', 'default_avatar');
$rating = Config::get('gravatar', 'rating');

View file

@ -5,6 +5,8 @@
* Version: 1.0
* Author: Thomas Willingham <https://kakste.com/profile/beardyunixer>
*/
use Friendica\App;
use Friendica\Core\Addon;
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
@ -56,7 +58,7 @@ function group_text_settings_post($a,$post) {
function group_text_settings(&$a,&$s) {
function group_text_settings(App $a, $s) {
if(! local_user())
return;

View file

@ -9,6 +9,7 @@
require_once 'mod/proxy.php';
use Friendica\App;
use Friendica\Content\Text\BBCode;
use Friendica\Core\Addon;
use Friendica\Core\Config;
@ -40,7 +41,7 @@ function obfuscate_email ($s) {
$s = str_replace('.','(dot)',$s);
return $s;
}
function impressum_footer($a, &$b) {
function impressum_footer(App $a, array &$b) {
$text = proxy_parse_html(BBCode::convert(Config::get('impressum','footer_text')));
if (! $text == '') {
$a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="'.$a->get_baseurl().'/addon/impressum/impressum.css" media="all" />';

View file

@ -5,6 +5,8 @@
* Version: 1.0
* Author: Thomas Willingham <https://kakste.com/profile/beardyunixer>
*/
use Friencia\App;
use Friendica\Core\Addon;
use Friendica\Core\L10n;
@ -18,7 +20,7 @@ function infiniteimprobabilitydrive_uninstall()
Addon::unregisterHook('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">' . L10n::t('Infinite Improbability Drive') . '</a></div>';
}

View file

@ -6,6 +6,8 @@
* Author: tony baldwin <https://free-haven.org/profile/tony>
* Author: Tobias Diekershoff <https://f.diekershoff.de/u/tobias>
*/
use Friendica\App;
use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Core\L10n;
@ -24,7 +26,7 @@ function irc_uninstall() {
}
function irc_addon_settings(&$a,&$s) {
function irc_addon_settings(App $a, $s) {
if(! local_user())
return;
@ -50,7 +52,7 @@ function irc_addon_settings(&$a,&$s) {
}
function irc_addon_settings_post(&$a,&$b) {
function irc_addon_settings_post(App $a, $b) {
if(! local_user())
return;

View file

@ -419,7 +419,7 @@ function jappixmini_settings(App $a, &$s)
</script>";
}
function jappixmini_settings_post(App $a, &$b)
function jappixmini_settings_post(App $a, array &$b)
{
// save addon settings for a user
if (!local_user()) {
@ -693,7 +693,7 @@ function jappixmini_cron(App $a, $d)
}
}
function jappixmini_download_source(App $a, &$b)
function jappixmini_download_source(App $a, array &$b)
{
// Jappix Mini source download link on About page
$b .= '<h1>Jappix Mini</h1>';

View file

@ -14,6 +14,8 @@
* Module Author: Chris Case
*
*/
use Friendica\App;
use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Core\L10n;
@ -34,7 +36,7 @@ function js_upload_uninstall() {
}
function js_upload_form(&$a,&$b) {
function js_upload_form(App $a, $b) {
$b['default_upload'] = false;
@ -134,7 +136,7 @@ EOT;
}
function js_upload_post_init(&$a,&$b) {
function js_upload_post_init(App $a, $b) {
// list of valid extensions, ex. array("jpeg", "xml", "bmp")
@ -162,7 +164,7 @@ function js_upload_post_init(&$a,&$b) {
}
function js_upload_post_file(&$a,&$b) {
function js_upload_post_file(App $a, $b) {
$result = $a->data['upload_result'];
@ -173,7 +175,7 @@ function js_upload_post_file(&$a,&$b) {
}
function js_upload_post_end(&$a,&$b) {
function js_upload_post_end(App $a, $b) {
logger('upload_post_end');
if(x($a->data,'upload_jsonresponse')) {

View file

@ -9,6 +9,8 @@
*
*"My body was my sacrifice... for my magic. This damage is permanent." - Raistlin Majere
*/
use Friendica\App;
use Friendica\Core\Addon;
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
@ -134,7 +136,7 @@ function krynn_settings_post($a,$post) {
function krynn_settings(&$a,&$s) {
function krynn_settings(App $a, $s) {
if(! local_user())
return;

View file

@ -70,7 +70,7 @@ function langfilter_addon_settings(App $a, &$s)
* 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;
@ -112,8 +112,7 @@ function langfilter_addon_settings_post(App $a, &$b)
* expand it again.
*/
function langfilter_prepare_body_content_filter(App $a, &$hook_data)
{
function langfilter_prepare_body_content_filter(App $a, &$hook_data) {
$logged_user = local_user();
if (!$logged_user) {
return;

View file

@ -53,6 +53,8 @@
*
* ...etc.
*/
use Friencia\App;
use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Model\User;
@ -69,12 +71,12 @@ function ldapauth_uninstall()
Addon::unregisterHook('authenticate', 'addon/ldapauth/ldapauth.php', 'ldapauth_hook_authenticate');
}
function ldapauth_load_config(\Friendica\App $a)
function ldapauth_load_config(App $a)
{
$a->loadConfigFile(__DIR__. '/config/ldapauth.ini.php');
}
function ldapauth_hook_authenticate($a, &$b)
function ldapauth_hook_authenticate(App $a, array &$b)
{
if (ldapauth_authenticate($b['username'], $b['password'])) {
$results = get_existing_account($b['username']);

View file

@ -5,6 +5,8 @@
* Version: 1.1
* Author: Klaus Weidenbach <http://friendica.dszdw.net/profile/klaus>
*/
use Friencia\App;
use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Core\L10n;
@ -40,7 +42,7 @@ function libravatar_load_config(\Friendica\App $a)
* @param $a array
* @param &$b array
*/
function libravatar_lookup($a, &$b)
function libravatar_lookup(App $a, array &$b)
{
$default_avatar = Config::get('libravatar', 'default_avatar');

View file

@ -6,6 +6,7 @@
* Author: Matthew Exon <http://mat.exon.name>
*/
use Friendica\App;
use Friendica\Content\Text\BBCode;
use Friendica\Core\Addon;
use Friendica\Core\Config;
@ -71,7 +72,7 @@ function mailstream_uninstall() {
function mailstream_module() {}
function mailstream_addon_admin(&$a,&$o) {
function mailstream_addon_admin(App $a, &$o) {
$frommail = Config::get('mailstream', 'frommail');
$template = get_markup_template('admin.tpl', 'addon/mailstream/');
$config = ['frommail',
@ -83,13 +84,13 @@ function mailstream_addon_admin(&$a,&$o) {
'$submit' => L10n::t('Save Settings')]);
}
function mailstream_addon_admin_post ($a) {
function mailstream_addon_admin_post (App $a) {
if (x($_POST, 'frommail')) {
Config::set('mailstream', 'frommail', $_POST['frommail']);
}
}
function mailstream_generate_id($a, $uri) {
function mailstream_generate_id(App $a, $uri) {
// http://www.jwz.org/doc/mid.html
$host = $a->get_hostname();
$resource = hash('md5', $uri);
@ -98,56 +99,58 @@ function mailstream_generate_id($a, $uri) {
return $message_id;
}
function mailstream_post_hook(&$a, &$item) {
function mailstream_post_hook(App $a, array &$item) {
if (!PConfig::get($item['uid'], 'mailstream', 'enabled')) {
return;
}
if (!$item['uid']) {
if (!x($item, 'uid') || !x($item, 'contact-id') || !x($item, 'uri')) {
return;
}
if (!$item['contact-id']) {
if (PConfig::get($item['uid'], 'mailstream', 'nolikes') && $item['verb'] == ACTIVITY_LIKE) {
return;
}
if (!$item['uri']) {
return;
}
if (PConfig::get($item['uid'], 'mailstream', 'nolikes')) {
if ($item['verb'] == ACTIVITY_LIKE) {
return;
}
}
$message_id = mailstream_generate_id($a, $item['uri']);
q("INSERT INTO `mailstream_item` (`uid`, `contact-id`, `uri`, `message-id`) " .
"VALUES (%d, '%s', '%s', '%s')", intval($item['uid']),
intval($item['contact-id']), dbesc($item['uri']), dbesc($message_id));
$r = q('SELECT * FROM `mailstream_item` WHERE `uid` = %d AND `contact-id` = %d AND `uri` = "%s"', intval($item['uid']), intval($item['contact-id']), dbesc($item['uri']));
if (count($r) != 1) {
if (!DBM::is_result($r)) {
logger('mailstream_post_remote_hook: Unexpected number of items returned from mailstream_item', LOGGER_NORMAL);
return;
}
$ms_item = $r[0];
logger('mailstream_post_remote_hook: created mailstream_item '
. $ms_item['id'] . ' for item ' . $item['uri'] . ' '
. $item['uid'] . ' ' . $item['contact-id'], LOGGER_DATA);
$user = mailstream_get_user($item['uid']);
if (!$user) {
logger('mailstream_post_remote_hook: no user ' . $item['uid'], LOGGER_NORMAL);
return;
}
mailstream_send($a, $ms_item['message-id'], $item, $user);
}
function mailstream_get_user($uid) {
$r = q('SELECT * FROM `user` WHERE `uid` = %d', intval($uid));
if (count($r) != 1) {
if (!DBM::is_result($r)) {
logger('mailstream_post_remote_hook: Unexpected number of users returned', LOGGER_NORMAL);
return;
}
return $r[0];
}
function mailstream_do_images($a, &$item, &$attachments) {
function mailstream_do_images(App $a, array &$item, &$attachments) {
if (!PConfig::get($item['uid'], 'mailstream', 'attachimg')) {
return;
}
@ -162,7 +165,9 @@ function mailstream_do_images($a, &$item, &$attachments) {
'data' => Network::fetchUrl($url, true, $redirects, 0, null, $cookiejar),
'guid' => hash("crc32", $url),
'filename' => basename($url),
'type' => $a->get_curl_content_type()];
'type' => $a->get_curl_content_type()
];
if (strlen($attachments[$url]['data'])) {
$item['body'] = str_replace($url, 'cid:' . $attachments[$url]['guid'], $item['body']);
continue;
@ -171,43 +176,54 @@ function mailstream_do_images($a, &$item, &$attachments) {
return $attachments;
}
function mailstream_sender($item) {
function mailstream_sender(array $item) {
$r = q('SELECT * FROM `contact` WHERE `id` = %d', $item['contact-id']);
if (DBM::is_result($r)) {
$contact = $r[0];
if ($contact['name'] != $item['author-name']) {
return $contact['name'] . ' - ' . $item['author-name'];
if ($r[0]['name'] != $item['author-name']) {
return $r[0]['name'] . ' - ' . $item['author-name'];
}
}
return $item['author-name'];
}
function mailstream_decode_subject($subject) {
$html = BBCode::convert($subject);
if (!$html) {
return $subject;
}
$notags = strip_tags($html);
if (!$notags) {
return $subject;
}
$noentity = html_entity_decode($notags);
if (!$noentity) {
return $notags;
}
$nocodes = preg_replace_callback("/(&#[0-9]+;)/", function($m) { return mb_convert_encoding($m[1], "UTF-8", "HTML-ENTITIES"); }, $noentity);
if (!$nocodes) {
return $noentity;
}
$trimmed = trim($nocodes);
if (!$trimmed) {
return $nocodes;
}
return $trimmed;
}
function mailstream_subject($item) {
if ($item['title']) {
function mailstream_subject(array $item) {
if (x($item, 'title')) {
return mailstream_decode_subject($item['title']);
}
$parent = $item['thr-parent'];
@ -250,8 +266,8 @@ function mailstream_subject($item) {
return L10n::t("Friendica Item");
}
function mailstream_send($a, $message_id, $item, $user) {
if (!$item['visible']) {
function mailstream_send(App $a, $message_id, array $item, $user) {
if (!x($item, 'visible')) {
return;
}
if (!$message_id) {
@ -350,7 +366,7 @@ function mailstream_cron($a, $b) {
mailstream_tidy();
}
function mailstream_addon_settings(&$a,&$s) {
function mailstream_addon_settings(App $a, &$s) {
$enabled = PConfig::get(local_user(), 'mailstream', 'enabled');
$address = PConfig::get(local_user(), 'mailstream', 'address');
$nolikes = PConfig::get(local_user(), 'mailstream', 'nolikes');
@ -380,37 +396,43 @@ function mailstream_addon_settings(&$a,&$s) {
'$submit' => L10n::t('Save Settings')]);
}
function mailstream_addon_settings_post($a,$post) {
function mailstream_addon_settings_post(App $a, $post) {
if ($_POST['mailstream_address'] != "") {
PConfig::set(local_user(), 'mailstream', 'address', $_POST['mailstream_address']);
}
else {
} else {
PConfig::delete(local_user(), 'mailstream', 'address');
}
if ($_POST['mailstream_nolikes']) {
PConfig::set(local_user(), 'mailstream', 'nolikes', $_POST['mailstream_enabled']);
}
else {
} else {
PConfig::delete(local_user(), 'mailstream', 'nolikes');
}
if ($_POST['mailstream_enabled']) {
PConfig::set(local_user(), 'mailstream', 'enabled', $_POST['mailstream_enabled']);
}
else {
} else {
PConfig::delete(local_user(), 'mailstream', 'enabled');
}
if ($_POST['mailstream_attachimg']) {
PConfig::set(local_user(), 'mailstream', 'attachimg', $_POST['mailstream_attachimg']);
}
else {
} else {
PConfig::delete(local_user(), 'mailstream', 'attachimg');
}
}
function mailstream_tidy() {
$r = q("SELECT id FROM mailstream_item WHERE completed IS NOT NULL AND completed < DATE_SUB(NOW(), INTERVAL 1 YEAR)");
if (!DBM::is_result($r)) {
logger('Cannot load records from mailstream_item or none are returned.', LOGGER_DEBUG);
return;
}
foreach ($r as $rr) {
q('DELETE FROM mailstream_item WHERE id = %d', intval($rr['id']));
}
logger('mailstream_tidy: deleted ' . count($r) . ' old items', LOGGER_DEBUG);
}

View file

@ -6,6 +6,7 @@
* Author: Tobias Diekershoff <https://social.diekershoff.de/profile/tobias>
* License: 3-clause BSD license
*/
use Friendica\App;
use Friendica\Core\Addon;
use Friendica\Core\Config;
@ -73,7 +74,7 @@ function mathjax_settings (&$a, &$s) {
/* we need to add one JavaScript include command to the html output
* note that you have to check the jsmath/easy/load.js too.
*/
function mathjax_page_header($a, &$b) {
function mathjax_page_header(App $a, array &$b) {
// if the visitor of the page is not a local_user, use MathJax
// otherwise check the users settings.
$url = Config::get ('mathjax','baseurl');

View file

@ -7,6 +7,7 @@
* Status: Unsupported
*/
use Friencia\App;
use Friendica\Core\Addon;
use Friendica\Core\L10n;
use Friendica\Util\DateTimeFormat;
@ -16,13 +17,11 @@ function membersince_install()
Addon::registerHook('profile_advanced', 'addon/membersince/membersince.php', 'membersince_display');
}
function membersince_uninstall()
{
function membersince_uninstall() {
Addon::unregisterHook('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.
$doc = new DOMDocument();

View file

@ -6,6 +6,8 @@
* Author: Thomas Willingham <https://kakste.com/profile/beardyunixer>
*
*/
use Friencia\App;
use Friendica\Core\Addon;
use Friendica\Core\L10n;
@ -19,7 +21,7 @@ function morepokes_uninstall()
Addon::unregisterHook('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', L10n::t('bitchslap'), L10n::t('bitchslapped')];
$b['shag'] = ['shag', L10n::t('shag'), L10n::t('shagged')];

View file

@ -7,6 +7,8 @@
* Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
*
*/
use Friencia\App;
use Friendica\Core\Addon;
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
@ -95,8 +97,7 @@ function nsfw_addon_settings(&$a, &$s)
return;
}
function nsfw_addon_settings_post(&$a, &$b)
{
function nsfw_addon_settings_post(App $a, array &$b) {
if (!local_user()) {
return;
}
@ -110,8 +111,7 @@ function nsfw_addon_settings_post(&$a, &$b)
}
}
function nsfw_prepare_body_content_filter(\Friendica\App $a, &$hook_data)
{
function nsfw_prepare_body_content_filter(App $a, &$hook_data) {
$words = null;
if (PConfig::get(local_user(), 'nsfw', 'disable')) {
return;

View file

@ -8,6 +8,8 @@
* Author: Klaus Weidenbach
*
*/
use Friencia\App;
use Friendica\Core\Addon;
use Friendica\Core\Cache;
use Friendica\Core\Config;
@ -88,7 +90,7 @@ function openstreetmap_location($a, &$item)
$nomserver = OSM_NOM;
}
if ($item['coord'] != "") {
if (x($item, 'coord')) {
$coords = explode(' ', $item['coord']);
if (count($coords) > 1) {
$lat = urlencode(round($coords[0], 5));
@ -105,7 +107,7 @@ function openstreetmap_location($a, &$item)
$target = $nomserver.'?q='.urlencode($item['location']);
}
if ($item['location'] != "") {
if (x($item, 'location')) {
$title = $item['location'];
} else {
$title = $item['coord'];
@ -114,7 +116,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 = Config::get('openstreetmap', 'nomserver', OSM_NOM);
@ -142,7 +144,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);
@ -151,7 +153,7 @@ function openstreetmap_generate_named_map(&$a, &$b)
}
}
function openstreetmap_generate_map(&$a, &$b)
function openstreetmap_generate_map(App $a, array &$b)
{
$tmsserver = Config::get('openstreetmap', 'tmsserver', OSM_TMS);

View file

@ -7,6 +7,8 @@
* Hauke Altmann <https://snarl.de/profile/tugelblend>
*
*/
use Friendica\App;
use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Core\L10n;
@ -33,7 +35,7 @@ function pageheader_uninstall() {
function pageheader_addon_settings(&$a,&$s) {
function pageheader_addon_settings(App $a, $s) {
if(! is_site_admin())
@ -59,7 +61,7 @@ function pageheader_addon_settings(&$a,&$s) {
}
function pageheader_addon_settings_post(&$a,&$b) {
function pageheader_addon_settings_post(App $a, $b) {
if(! is_site_admin())
return;

View file

@ -6,6 +6,7 @@
* Author: Keith Fernie <http://friendika.me4.it/profile/keith>
*/
use Friencia\App;
use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Core\L10n;
@ -118,7 +119,7 @@ function public_server_cron($a, $b)
logger("public_server: cron end");
}
function public_server_enotify(&$a, &$b)
function public_server_enotify(App $a, array &$b)
{
if (x($b, 'params') && $b['params']['type'] == NOTIFY_SYSTEM
&& x($b['params'], 'system_type') && $b['params']['system_type'] === 'public_server_expire') {

View file

@ -6,6 +6,7 @@
* Author: Michael Vogel <http://pirati.ca/profile/heluecht>
*/
use Friencia\App;
use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\HTML;
use Friendica\Core\Addon;
@ -375,12 +376,11 @@ function pumpio_settings_post(&$a, &$b)
}
}
function pumpio_load_config(\Friendica\App $a)
{
$a->loadConfigFile(__DIR__. '/config/pumpio.ini.php');
}
function pumpio_post_local(&$a, &$b)
function pumpio_post_local(App $a, array &$b)
{
if (!local_user() || (local_user() != $b['uid'])) {
return;

View file

@ -53,7 +53,7 @@ function securemail_uninstall() {
*
* @see App
*/
function securemail_settings(App &$a, &$s){
function securemail_settings(App $a, &$s){
if (!local_user()) {
return;
}
@ -82,7 +82,7 @@ function securemail_settings(App &$a, &$s){
*
* @see App
*/
function securemail_settings_post(App &$a, array &$b){
function securemail_settings_post(App $a, array &$b){
if (!local_user()) {
return;
@ -147,7 +147,7 @@ function securemail_settings_post(App &$a, array &$b){
*
* @see App
*/
function securemail_emailer_send_prepare(App &$a, array &$b) {
function securemail_emailer_send_prepare(App $a, array &$b) {
if (!x($b, 'uid')) {
return;
}

View file

@ -5,6 +5,8 @@
* Version: 0.2
* Author: Johannes Schwab <https://friendica.jschwab.org/profile/ddorian>
*/
use Friencia\App;
use Friendica\Core\Addon;
function smileybutton_install() {
@ -24,15 +26,17 @@ function smileybutton_uninstall() {
function show_button(Friendica\App $a, &$b) {
function show_button(App $a, &$b) {
// Disable if theme is quattro
// TODO add style for quattro
if ($a->getCurrentTheme() == 'quattro')
return;
}
// Disable for mobile because most mobiles have a smiley key for ther own
if ($a->is_mobile || $a->is_tablet)
if ($a->is_mobile || $a->is_tablet) {
return;
}
/**
*

View file

@ -8,6 +8,8 @@
* This is a template for how to extend the "smily" code.
*
*/
use Friendica\App;
use Friendica\Core\Addon;
function smilies_adult_install() {
@ -20,7 +22,7 @@ function smilies_adult_uninstall() {
function smilies_adult_smilies(&$a,&$b) {
function smilies_adult_smilies(App $a, $b) {
$b['texts'][] = '(o)(o)';
$b['icons'][] = '<img class="smiley" src="' . $a->get_baseurl() . '/addon/smilies_adult/icons/tits.gif' . '" alt="' . '(o)(o)' . '" />';

View file

@ -94,7 +94,7 @@ function statusnet_check_item_notification(App $a, &$notification_data)
$notification_data["profiles"][] = PConfig::get($notification_data["uid"], 'statusnet', 'own_url');
}
function statusnet_jot_nets(App $a, &$b)
function statusnet_jot_nets(App $a, array &$b)
{
if (!local_user()) {
return;
@ -385,7 +385,7 @@ function statusnet_settings(App $a, &$s)
$s .= '</div><div class="clear"></div>';
}
function statusnet_post_local(App $a, &$b)
function statusnet_post_local(App $a, array &$b)
{
if ($b['edit']) {
return;
@ -440,7 +440,7 @@ function statusnet_action(App $a, $uid, $pid, $action)
logger("statusnet_action '" . $action . "' send, result: " . print_r($result, true), LOGGER_DEBUG);
}
function statusnet_post_hook(App $a, &$b)
function statusnet_post_hook(App $a, array &$b)
{
/**
* Post to GNU Social
@ -669,7 +669,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"] != NETWORK_STATUSNET) {
return;

View file

@ -6,6 +6,7 @@
* Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
*/
use Friencia\App;
use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Core\L10n;
@ -64,7 +65,7 @@ function testdrive_cron($a,$b) {
$r = q("select * from user where account_expires_on < UTC_TIMESTAMP() + INTERVAL 5 DAY and
expire_notification_sent = '0000-00-00 00:00:00' ");
if(count($r)) {
if (DBM::is_result($r)) {
foreach($r as $rr) {
notification([
'uid' => $rr['uid'],
@ -87,14 +88,15 @@ function testdrive_cron($a,$b) {
}
$r = q("select * from user where account_expired = 1 and account_expires_on < UTC_TIMESTAMP() - INTERVAL 5 DAY ");
if(count($r)) {
if (DBM::is_result($r)) {
foreach($r as $rr) {
User::remove($rr['uid']);
}
}
}
function testdrive_enotify(&$a, &$b) {
function testdrive_enotify(App $a, array &$b) {
if (x($b, 'params') && $b['params']['type'] == NOTIFY_SYSTEM
&& x($b['params'], 'system_type') && $b['params']['system_type'] === 'testdrive_expire') {
$b['itemlink'] = $a->get_baseurl();

View file

@ -9,6 +9,7 @@
require_once __DIR__ . DIRECTORY_SEPARATOR . 'library' . DIRECTORY_SEPARATOR . 'tumblroauth.php';
use Friendica\App;
use Friendica\Content\Text\BBCode;
use Friendica\Core\Addon;
use Friendica\Core\Config;
@ -126,7 +127,7 @@ function tumblr_connect($a) {
// Give an error message
$o = 'Could not connect to Tumblr. Refresh the page or try again later.';
}
return($o);
return $o;
}
function tumblr_callback($a) {
@ -168,15 +169,17 @@ function tumblr_callback($a) {
$o = L10n::t("You are now authenticated to tumblr.");
$o .= '<br /><a href="'.$a->get_baseurl().'/settings/connectors">'.L10n::t("return to the connector page").'</a>';
return($o);
return $o;
}
function tumblr_jot_nets(&$a,&$b) {
if(! local_user())
function tumblr_jot_nets(App $a, $b) {
if (! local_user()) {
return;
}
$tmbl_post = PConfig::get(local_user(),'tumblr','post');
if(intval($tmbl_post) == 1) {
$tmbl_post = PConfig::get(local_user(), 'tumblr', 'post');
if (intval($tmbl_post) == 1) {
$tmbl_defpost = PConfig::get(local_user(),'tumblr','post_by_default');
$selected = ((intval($tmbl_defpost) == 1) ? ' checked="checked" ' : '');
$b .= '<div class="profile-jot-net"><input type="checkbox" name="tumblr_enable"' . $selected . ' value="1" /> '
@ -185,10 +188,11 @@ function tumblr_jot_nets(&$a,&$b) {
}
function tumblr_settings(&$a,&$s) {
function tumblr_settings(App $a, $s) {
if(! local_user())
if (! local_user()) {
return;
}
/* Add our stylesheet to the page so we can make our settings look nice */
@ -266,7 +270,7 @@ function tumblr_settings(&$a,&$s) {
}
function tumblr_settings_post(&$a,&$b) {
function tumblr_settings_post(App $a, $b) {
if(x($_POST,'tumblr-submit')) {
@ -278,7 +282,7 @@ function tumblr_settings_post(&$a,&$b) {
}
function tumblr_post_local(&$a, &$b) {
function tumblr_post_local(App $a, array &$b) {
// This can probably be changed to allow editing by pointing to a different API endpoint
@ -316,7 +320,7 @@ function tumblr_post_local(&$a, &$b) {
function tumblr_send(&$a,&$b) {
function tumblr_send(App $a, $b) {
if($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) {
return;

View file

@ -190,7 +190,7 @@ function twitter_follow(App $a, &$contact)
}
}
function twitter_jot_nets(App $a, &$b)
function twitter_jot_nets(App $a, array &$b)
{
if (!local_user()) {
return;
@ -386,7 +386,7 @@ function twitter_settings(App $a, &$s)
$s .= '</div><div class="clear"></div>';
}
function twitter_post_local(App $a, &$b)
function twitter_post_local(App $a, array &$b)
{
if ($b['edit']) {
return;
@ -446,7 +446,7 @@ function twitter_action(App $a, $uid, $pid, $action)
logger("twitter_action '" . $action . "' send, result: " . print_r($result, true), LOGGER_DEBUG);
}
function twitter_post_hook(App $a, &$b)
function twitter_post_hook(App $a, array &$b)
{
// Post to Twitter
if (!PConfig::get($b["uid"], 'twitter', 'import')
@ -761,7 +761,7 @@ function twitter_expire(App $a, $b)
logger('twitter_expire: expire_end');
}
function twitter_prepare_body(App $a, &$b)
function twitter_prepare_body(App $a, array &$b)
{
if ($b["item"]["network"] != NETWORK_TWITTER) {
return;
@ -920,7 +920,7 @@ function twitter_fetchtimeline(App $a, $uid)
PConfig::set($uid, 'twitter', 'lastid', $lastid);
}
function twitter_queue_hook(App $a, &$b)
function twitter_queue_hook(App $a, array &$b)
{
$qi = q("SELECT * FROM `queue` WHERE `network` = '%s'",
dbesc(NETWORK_TWITTER)

View file

@ -5,6 +5,8 @@
* Version: 1.0
* Author: Michael Vogel <http://pirati.ca/profile/heluecht>
*/
use Friendica\App;
use Friendica\Core\Addon;
use Friendica\Content\Smilies;
@ -16,7 +18,7 @@ function unicode_smilies_uninstall() {
Addon::unregisterHook('smilie', 'addon/unicode_smilies/unicode_smilies.php', 'unicode_smilies_smilies');
}
function unicode_smilies_smilies(&$a,&$b) {
function unicode_smilies_smilies(App $a, $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 Friencia\App;
use Friendica\Core\Addon;
use Friendica\Core\L10n;
use Friendica\Model\Item;
@ -35,7 +37,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,7 @@
* Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
*/
use Friencia\App;
use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\HTML;
use Friendica\Core\Addon;
@ -156,7 +157,7 @@ function wppost_settings_post(&$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

View file

@ -5,6 +5,7 @@
* Version: 0.1
* Author: Michael Vogel <https://pirati.ca/profile/heluecht>
*/
use Friendica\App;
use Friendica\Core\Addon;
use Friendica\Core\Config;