Rewrites/type-hints App and array #600

Closed
Quix0r wants to merge 29 commits from rewrites/type-hints-app into develop
59 changed files with 566 additions and 394 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, array &$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, array &$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,24 +139,25 @@ function blockem_prepare_body_content_filter(\Friendica\App $a, &$hook_data)
}
}
function blockem_display_item(&$a,&$b) {
if (empty($b['output']['body'])) {
return;
}
if(strstr($b['output']['body'],'id="blockem-wrap-'))
function blockem_display_item(App $a, array &$b)
{
if (isset($b['output']) && 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, array &$b) {
if(! local_user())
if (! local_user()) {
return;
$words = PConfig::get(local_user(),'blockem','words');
if($words) {
$a->data['blockem'] = explode(',',$words);
}
$words = PConfig::get(local_user(), 'blockem', 'words');
if ($words) {
$a->data['blockem'] = explode(',', $words);
}
$a->page['htmlhead'] .= <<< EOT
<script>
@ -174,7 +177,7 @@ EOT;
}
function blockem_item_photo_menu(&$a,&$b) {
function blockem_item_photo_menu(App $a, array &$b) {
if((! local_user()) || ($b['item']['self']))
return;

View file

@ -6,6 +6,7 @@
*
*/
use Friendica\App;
use Friendica\Content\Text\BBCode;
use Friendica\Core\Addon;
use Friendica\Core\L10n;
@ -36,8 +37,7 @@ function blogger_uninstall()
}
function blogger_jot_nets(&$a, &$b)
{
function blogger_jot_nets(App $a, &$b) {
if (!local_user()) {
return;
}
@ -115,7 +115,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 +126,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 +164,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

@ -109,7 +109,7 @@ function buffer_connect(&$a) {
return($o);
}
function buffer_jot_nets(&$a,&$b) {
function buffer_jot_nets(App $a, &$b) {
if(! local_user())
return;
@ -122,7 +122,7 @@ function buffer_jot_nets(&$a,&$b) {
}
}
function buffer_settings(&$a,&$s) {
function buffer_settings(App $a, &$s) {
if(! local_user())
return;
@ -205,7 +205,7 @@ function buffer_settings(&$a,&$s) {
}
function buffer_settings_post(&$a,&$b) {
function buffer_settings_post(App $a, array &$b) {
if(x($_POST,'buffer-submit')) {
if(x($_POST,'buffer_delete')) {
@ -219,7 +219,7 @@ function buffer_settings_post(&$a,&$b) {
}
}
function buffer_post_local(&$a,&$b) {
function buffer_post_local(App $a, array &$b) {
if (!local_user() || (local_user() != $b['uid'])) {
return;
@ -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 Friendica\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, &$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

@ -9,6 +9,7 @@
require_once 'addon/diaspora/Diaspora_Connection.php';
use Friendica\App;
use Friendica\Content\Text\BBCode;
use Friendica\Core\Addon;
use Friendica\Core\L10n;
@ -35,7 +36,7 @@ function diaspora_uninstall() {
}
function diaspora_jot_nets(&$a,&$b) {
function diaspora_jot_nets(App $a, &$b) {
if(! local_user())
return;
@ -48,7 +49,7 @@ function diaspora_jot_nets(&$a,&$b) {
}
}
function diaspora_queue_hook(&$a,&$b) {
function diaspora_queue_hook(App $a, array &$b) {
$hostname = $a->get_hostname();
$qi = q("SELECT * FROM `queue` WHERE `network` = '%s'",
@ -225,7 +226,7 @@ function diaspora_settings(&$a,&$s) {
}
function diaspora_settings_post(&$a,&$b) {
function diaspora_settings_post(App $a, array &$b) {
if(x($_POST,'diaspora-submit')) {
@ -238,7 +239,7 @@ function diaspora_settings_post(&$a,&$b) {
}
function diaspora_post_local(&$a,&$b) {
function diaspora_post_local(App $a, array &$b) {
if ($b['edit']) {
return;
@ -274,7 +275,7 @@ function diaspora_post_local(&$a,&$b) {
function diaspora_send(&$a,&$b) {
function diaspora_send(App $a, array &$b) {
$hostname = $a->get_hostname();
logger('diaspora_send: invoked');

View file

@ -8,10 +8,12 @@
* 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;
use Friendica\Core\PConfig;
use Friendica\Database\DBM;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network;
@ -33,12 +35,13 @@ function dwpost_uninstall() {
}
function dwpost_jot_nets(&$a,&$b) {
if(! local_user())
function dwpost_jot_nets(App $a, &$b) {
if (! local_user()) {
return;
}
$dw_post = PConfig::get(local_user(),'dwpost','post');
if(intval($dw_post) == 1) {
if (intval($dw_post) == 1) {
$dw_defpost = PConfig::get(local_user(),'dwpost','post_by_default');
$selected = ((intval($dw_defpost) == 1) ? ' checked="checked" ' : '');
$b .= '<div class="profile-jot-net"><input type="checkbox" name="dwpost_enable" ' . $selected . ' value="1" /> '
@ -47,7 +50,7 @@ function dwpost_jot_nets(&$a,&$b) {
}
function dwpost_settings(&$a,&$s) {
function dwpost_settings(App $a, &$s) {
if(! local_user())
return;
@ -107,7 +110,7 @@ function dwpost_settings(&$a,&$s) {
}
function dwpost_settings_post(&$a,&$b) {
function dwpost_settings_post(App $a, array &$b) {
if(x($_POST,'dwpost-submit')) {
@ -120,7 +123,7 @@ function dwpost_settings_post(&$a,&$b) {
}
function dwpost_post_local(&$a,&$b) {
function dwpost_post_local(App $a, array &$b) {
// This can probably be changed to allow editing by pointing to a different API endpoint
@ -151,7 +154,7 @@ function dwpost_post_local(&$a,&$b) {
function dwpost_send(&$a,&$b) {
function dwpost_send(App $a, array &$b) {
if($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited']))
return;
@ -168,17 +171,19 @@ function dwpost_send(&$a,&$b) {
$tz = 'UTC';
$x = q("select timezone from user where uid = %d limit 1",
$x = q("SELECT `timezone` FROM `user` WHERE `uid` = %d LIMIT 1",
intval($b['uid'])
);
if($x && strlen($x[0]['timezone']))
if (!empty($x[0]['timezone'])) {
$tz = $x[0]['timezone'];
}
$dw_username = PConfig::get($b['uid'],'dwpost','dw_username');
$dw_password = PConfig::get($b['uid'],'dwpost','dw_password');
$dw_blog = 'http://www.dreamwidth.org/interface/xmlrpc';
if($dw_username && $dw_password && $dw_blog) {
if ($dw_username && $dw_password && $dw_blog) {
$title = $b['title'];
$post = BBCode::convert($b['body']);
$post = xmlify($post);

View file

@ -6,6 +6,8 @@
* Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
* Status: Unsupported
*/
use Friendica\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, &$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 Friendica\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,8 +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 +79,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, array &$b) {
if(! local_user())
return;
@ -213,11 +213,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 +245,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 +293,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 +320,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 +436,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

@ -5,6 +5,8 @@
* Version: 0.1
* Author: Michael Vogel <https://pirati.ca/profile/heluecht>
*/
use Friendica\App;
use Friendica\Core\Addon;
use Friendica\Core\Cache;
use Friendica\Core\Config;
@ -24,28 +26,31 @@ function geocoordinates_uninstall()
Addon::unregisterHook('post_remote', 'addon/geocoordinates/geocoordinates.php', 'geocoordinates_post_hook');
}
function geocoordinates_resolve_item(&$item)
function geocoordinates_resolve_item(array &$item)
{
if((!$item["coord"]) || ($item["location"]))
if (empty($item['coord']) || !empty($item['location'])) {
return;
}
$key = Config::get("geocoordinates", "api_key");
if ($key == "")
if ($key == "") {
return;
}
$language = Config::get("geocoordinates", "language");
if ($language == "")
$language = "de";
$language = Config::get("geocoordinates", "language", "de");
$coords = explode(' ',$item["coord"]);
$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 +58,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 empty($s)) {
logger("API could not be queried", LOGGER_DEBUG);
return;
}
@ -74,18 +79,18 @@ function geocoordinates_resolve_item(&$item)
logger("Got location for coordinates ".$coords[0]."-".$coords[1].": ".$item["location"], LOGGER_DEBUG);
if ($item["location"] != "")
if ($item["location"] != "") {
Cache::set("geocoordinates:".$language.":".$coords[0]."-".$coords[1], $item["location"]);
}
}
function geocoordinates_post_hook($a, &$item)
function geocoordinates_post_hook(App $a, array &$item)
{
geocoordinates_resolve_item($item);
}
function geocoordinates_addon_admin(&$a, &$o)
function geocoordinates_addon_admin(App $a, &$o)
{
$t = get_markup_template("admin.tpl", "addon/geocoordinates/");
$o = replace_macros($t, [
@ -95,7 +100,7 @@ function geocoordinates_addon_admin(&$a, &$o)
]);
}
function geocoordinates_addon_admin_post(&$a)
function geocoordinates_addon_admin_post(App $a)
{
$api_key = ((x($_POST, 'api_key')) ? notags(trim($_POST['api_key'])) : '');
Config::set('geocoordinates', 'api_key', $api_key);

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

@ -4,9 +4,9 @@
* Description: Thread email comment notifications on Gmail and anonymise them
* Version: 1.0
* Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
*
*
*/
use Friendica\App;
use Friendica\Core\Addon;
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
@ -92,7 +92,7 @@ function gnot_settings(&$a,&$s) {
}
function gnot_enotify_mail(&$a,&$b) {
function gnot_enotify_mail(App $a, array &$b) {
if((! $b['uid']) || (! intval(PConfig::get($b['uid'], 'gnot','enable'))))
return;
if($b['type'] == NOTIFY_COMMENT)

View file

@ -6,6 +6,8 @@
* Author: Michael Vogel <https://pirati.ca/profile/heluecht>
*
*/
use Friendica\App;
use Friendica\Core\Addon;
use Friendica\Core\Cache;
@ -23,20 +25,19 @@ 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 (isset($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 (isset($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 Friendica\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

@ -6,12 +6,15 @@
* Author: Tony Baldwin <https://free-haven.org/profile/tony>
* Author: Michael Johnston
* Author: Cat Gray <https://free-haven.org/profile/catness>
* @TODO A lot spaces here needs converted to tab
*/
use Friendica\App;
use Friendica\Content\Text\BBCode;
use Friendica\Core\Addon;
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
use Friendica\Database\DBM;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network;
@ -23,6 +26,7 @@ function ijpost_install() {
Addon::registerHook('connector_settings_post', 'addon/ijpost/ijpost.php', 'ijpost_settings_post');
}
function ijpost_uninstall() {
Addon::unregisterHook('post_local', 'addon/ijpost/ijpost.php', 'ijpost_post_local');
Addon::unregisterHook('notifier_normal', 'addon/ijpost/ijpost.php', 'ijpost_send');
@ -32,8 +36,7 @@ function ijpost_uninstall() {
}
function ijpost_jot_nets(&$a,&$b) {
function ijpost_jot_nets(App $a, &$b) {
if(! local_user())
return;
@ -106,7 +109,7 @@ function ijpost_settings(&$a,&$s) {
}
function ijpost_settings_post(&$a,&$b) {
function ijpost_settings_post(App $a, array &$b) {
if(x($_POST,'ijpost-submit')) {
@ -119,8 +122,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
if($b['edit'])
@ -150,7 +152,7 @@ function ijpost_post_local(&$a,&$b) {
function ijpost_send(&$a,&$b) {
function ijpost_send(App $a, array &$b) {
if($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited']))
return;
@ -167,17 +169,20 @@ function ijpost_send(&$a,&$b) {
$tz = 'UTC';
$x = q("select timezone from user where uid = %d limit 1",
$x = q("SELECT `timezone` FROM `user` WHERE `uid` = %d LIMIT 1",
intval($b['uid'])
);
if($x && strlen($x[0]['timezone']))
if (DBM::is_result($x) && !empty($x[0]['timezone'])) {
$tz = $x[0]['timezone'];
}
$ij_username = PConfig::get($b['uid'],'ijpost','ij_username');
$ij_password = PConfig::get($b['uid'],'ijpost','ij_password');
$ij_blog = 'http://www.insanejournal.com/interface/xmlrpc';
if($ij_username && $ij_password && $ij_blog) {
if ($ij_username && $ij_password && $ij_blog) {
$title = $b['title'];
$post = BBCode::convert($b['body']);
$post = xmlify($post);
@ -222,6 +227,7 @@ EOT;
if($ij_blog !== 'test') {
$x = Network::post($ij_blog, $xml, ["Content-Type: text/xml"]);
}
logger('posted to insanejournal: ' . ($x) ? $x : '', LOGGER_DEBUG);
}

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, &$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" />';
@ -49,12 +50,12 @@ function impressum_footer($a, &$b) {
}
}
function impressum_load_config(\Friendica\App $a)
function impressum_load_config(App $a)
{
$a->loadConfigFile(__DIR__. '/config/impressum.ini.php');
$a->loadConfigFile(__DIR__. '/config/impressum.ini.php');
}
function impressum_show($a,&$b) {
function impressum_show(App $a,&$b) {
$b .= '<h3>'.L10n::t('Impressum').'</h3>';
$owner = Config::get('impressum', 'owner');
$owner_profile = Config::get('impressum','ownerprofile');

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;
@ -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, array &$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()) {

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, array &$b) {
$b['default_upload'] = false;
@ -134,7 +136,7 @@ EOT;
}
function js_upload_post_init(&$a,&$b) {
function js_upload_post_init(App $a, array &$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, array &$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, array &$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;

View file

@ -53,6 +53,8 @@
*
* ...etc.
*/
use Friendica\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

@ -6,6 +6,7 @@
* Author: Tony Baldwin <https://free-haven.org/u/tony>
*/
use Friendica\App;
use Friendica\Content\Text\BBCode;
use Friendica\Core\Addon;
use Friendica\Core\L10n;
@ -30,7 +31,7 @@ function libertree_uninstall() {
}
function libertree_jot_nets(&$a,&$b) {
function libertree_jot_nets(App $a, &$b) {
if(! local_user())
return;
@ -44,7 +45,7 @@ function libertree_jot_nets(&$a,&$b) {
}
function libertree_settings(&$a,&$s) {
function libertree_settings(App $a, &$s) {
if(! local_user())
return;
@ -104,7 +105,7 @@ function libertree_settings(&$a,&$s) {
}
function libertree_settings_post(&$a,&$b) {
function libertree_settings_post(App $a, array &$b) {
if(x($_POST,'libertree-submit')) {
@ -117,7 +118,7 @@ function libertree_settings_post(&$a,&$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
@ -155,7 +156,7 @@ function libertree_post_local(&$a,&$b) {
function libertree_send(&$a,&$b) {
function libertree_send(App $a, array &$b) {
logger('libertree_send: invoked');

View file

@ -5,6 +5,8 @@
* Version: 1.1
* Author: Klaus Weidenbach <http://friendica.dszdw.net/profile/klaus>
*/
use Friendica\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

@ -8,10 +8,12 @@
* 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;
use Friendica\Core\PConfig;
use Friendica\Database\DBM;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network;
@ -33,7 +35,7 @@ function ljpost_uninstall() {
}
function ljpost_jot_nets(&$a,&$b) {
function ljpost_jot_nets(App $a, &$b) {
if(! local_user())
return;
@ -101,7 +103,7 @@ function ljpost_settings(&$a,&$s) {
}
function ljpost_settings_post(&$a,&$b) {
function ljpost_settings_post(App $a, array &$b) {
if(x($_POST,'ljpost-submit')) {
@ -114,7 +116,7 @@ function ljpost_settings_post(&$a,&$b) {
}
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
@ -145,7 +147,7 @@ function ljpost_post_local(&$a,&$b) {
function ljpost_send(&$a,&$b) {
function ljpost_send(App $a, array &$b) {
if($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited']))
return;
@ -162,11 +164,13 @@ function ljpost_send(&$a,&$b) {
$tz = 'UTC';
$x = q("select timezone from user where uid = %d limit 1",
$x = q("SELECT `timezone` FROM `user` WHERE `uid` = %d LIMIT 1",
intval($b['uid'])
);
if($x && strlen($x[0]['timezone']))
if (!empty($x[0]['timezone'])) {
$tz = $x[0]['timezone'];
}
$lj_username = xmlify(PConfig::get($b['uid'],'ljpost','lj_username'));
$lj_password = xmlify(PConfig::get($b['uid'],'ljpost','lj_password'));
@ -175,10 +179,11 @@ function ljpost_send(&$a,&$b) {
// $lj_journal = $lj_username;
$lj_blog = xmlify(PConfig::get($b['uid'],'ljpost','lj_blog'));
if(! strlen($lj_blog))
if (! strlen($lj_blog)) {
$lj_blog = xmlify('http://www.livejournal.com/interface/xmlrpc');
}
if($lj_username && $lj_password && $lj_blog) {
if ($lj_username && $lj_password && $lj_blog) {
$title = xmlify($b['title']);
$post = BBCode::convert($b['body']);
$post = xmlify($post);

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 (!isset($item['uid']) || !isset($item['contact-id']) || !isset($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,105 +176,141 @@ 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 (!empty($item['title'])) {
return mailstream_decode_subject($item['title']);
}
$parent = $item['thr-parent'];
// Don't look more than 100 levels deep for a subject, in case of loops
for ($i = 0; ($i < 100) && $parent; $i++) {
$parent_item = Item::selectFirst(['thr-parent', 'title'], ['uri' => $parent]);
if (!DBM::is_result($parent_item)) {
break;
}
if ($parent_item['thr-parent'] === $parent) {
break;
}
if ($parent_item['title']) {
return L10n::t('Re:') . ' ' . mailstream_decode_subject($parent_item['title']);
}
$parent = $parent_item['thr-parent'];
}
$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d",
intval($item['contact-id']), intval($item['uid']));
/// @TODO If above statement fails, this will cause E_NOTICE-s
/// @TODO Also maybe directly use $r[0] instead of variable copy?
$contact = $r[0];
if ($contact['network'] === 'dfrn') {
return L10n::t("Friendica post");
}
if ($contact['network'] === 'dspr') {
return L10n::t("Diaspora post");
}
if ($contact['network'] === 'face') {
$text = mailstream_decode_subject($item['body']);
// For some reason these do show up in Facebook
$text = preg_replace('/\xA0$/', '', $text);
$subject = (strlen($text) > 150) ? (substr($text, 0, 140) . '...') : $text;
return preg_replace('/\\s+/', ' ', $subject);
}
if ($contact['network'] === 'feed') {
return L10n::t("Feed item");
}
if ($contact['network'] === 'mail') {
return L10n::t("Email");
}
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 (empty($item['visible'])) {
return;
}
if (!$message_id) {
return;
}
require_once(dirname(__file__).'/phpmailer/class.phpmailer.php');
/// @TODO Maybe properly use Composer
require_once dirname(__FILE__) . '/phpmailer/class.phpmailer.php';
$attachments = [];
mailstream_do_images($a, $item, $attachments);
$frommail = Config::get('mailstream', 'frommail');
if ($frommail == "") {
$frommail = 'friendica@localhost.local';
}
$address = PConfig::get($item['uid'], 'mailstream', 'address');
if (!$address) {
$address = $user['email'];
}
$mail = new PHPmailer;
try {
$mail->XMailer = 'Friendica Mailstream Addon';
$mail->SetFrom($frommail, mailstream_sender($item));
@ -350,7 +391,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 +421,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, &$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 Friendica\App;
use Friendica\Core\Addon;
use Friendica\Core\L10n;
use Friendica\Util\DateTimeFormat;
@ -21,7 +22,7 @@ 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.

View file

@ -6,6 +6,8 @@
* Author: Thomas Willingham <https://kakste.com/profile/beardyunixer>
*
*/
use Friendica\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 Friendica\App;
use Friendica\Core\Addon;
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
@ -95,7 +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,9 +112,10 @@ 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;
}
@ -128,16 +131,19 @@ function nsfw_prepare_body_content_filter(\Friendica\App $a, &$hook_data)
}
$found = false;
if (count($word_list)) {
$body = $hook_data['item']['title'] . "\n" . nsfw_extract_photos($hook_data['item']['body']);
foreach ($word_list as $word) {
$word = trim($word);
if (!strlen($word)) {
continue;
}
$tag_search = false;
switch ($word[0]) {
case '/'; // Regular expression
$found = preg_match($word, $body);

View file

@ -8,6 +8,8 @@
* Author: Klaus Weidenbach
*
*/
use Friendica\App;
use Friendica\Core\Addon;
use Friendica\Core\Cache;
use Friendica\Core\Config;
@ -88,15 +90,18 @@ function openstreetmap_location($a, &$item)
$nomserver = OSM_NOM;
}
if ($item['coord'] != "") {
if (!empty($item['coord'])) {
$coords = explode(' ', $item['coord']);
if (count($coords) > 1) {
$lat = urlencode(round($coords[0], 5));
$lon = urlencode(round($coords[1], 5));
$target = $tmsserver;
if ($marker > 0) {
$target .= '?mlat=' . $lat . '&mlon=' . $lon;
}
$target .= '#map='.intval($zoom).'/'.$lat.'/'.$lon;
}
}
@ -105,7 +110,7 @@ function openstreetmap_location($a, &$item)
$target = $nomserver.'?q='.urlencode($item['location']);
}
if ($item['location'] != "") {
if (!empty($item['location'])) {
$title = $item['location'];
} else {
$title = $item['coord'];
@ -114,7 +119,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 +147,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 +156,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, array &$b) {
if(! is_site_admin())
return;
@ -70,7 +72,7 @@ function pageheader_addon_settings_post(&$a,&$b) {
}
}
function pageheader_fetch($a,&$b) {
function pageheader_fetch(App $a, &$b) {
if(file_exists('pageheader.html')){
$s = file_get_contents('pageheader.html');

View file

@ -30,6 +30,8 @@
* about http/https but beware to put the trailing / at the end of your
* setting.
*/
use Friendica\App;
use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Core\L10n;
@ -48,12 +50,12 @@ function piwik_uninstall() {
logger("uninstalled piwik addon");
}
function piwik_load_config(\Friendica\App $a)
function piwik_load_config(App $a)
{
$a->loadConfigFile(__DIR__. '/config/piwik.ini.php');
}
function piwik_analytics($a,&$b) {
function piwik_analytics(App $a, &$b) {
/*
* styling of every HTML block added by this addon is done in the

View file

@ -5,25 +5,29 @@
* Version: 1.1
* Author: tony baldwin <tony@free-haven.org>
* Hauke Altmann <https://snarl.de/profile/tugelblend>
*
*/
use Friendica\App;
use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Core\L10n;
function pledgie_install() {
function pledgie_install()
{
Addon::registerHook('page_end', 'addon/pledgie/pledgie.php', 'pledgie_active');
Addon::registerHook('addon_settings', 'addon/pledgie/pledgie.php', 'pledgie_addon_settings');
Addon::registerHook('addon_settings_post', 'addon/pledgie/pledgie.php', 'pledgie_addon_settings_post');
}
function pledgie_uninstall() {
function pledgie_uninstall()
{
Addon::unregisterHook('page_end', 'addon/pledgie/pledgie.php', 'pledgie_active');
Addon::unregisterHook('addon_settings', 'addon/pledgie/pledgie.php', 'pledgie_addon_settings');
Addon::unregisterHook('addon_settings_post', 'addon/pledgie/pledgie.php', 'pledgie_addon_settings_post');
}
function pledgie_addon_settings(&$a,&$s) {
function pledgie_addon_settings(App $a, &$s)
{
if(! is_site_admin())
return;
@ -58,8 +62,8 @@ function pledgie_addon_settings(&$a,&$s) {
return;
}
function pledgie_addon_settings_post(&$a,&$b) {
function pledgie_addon_settings_post(App $a, array &$b)
{
if(! is_site_admin())
return;
@ -70,9 +74,11 @@ function pledgie_addon_settings_post(&$a,&$b) {
}
}
function pledgie_active(&$a,&$b) {
function pledgie_active(App $a, &$b)
{
$campaign = Config::get('pledgie-campaign','text');
$describe = Config::get('pledgie-describe','text');
$b .= '<div style="position: fixed; padding:5px; border-style:dotted; border-width:1px; background-color: white; line-height: 1; bottom: 5px; left: 20px; z-index: 1000; width: 150px; font-size: 12px;">';
$b .= $describe . '<br/><a href="https://pledgie.com/campaigns/';
$b .= $campaign;

View file

@ -6,6 +6,7 @@
* Author: Keith Fernie <http://friendika.me4.it/profile/keith>
*/
use Friendica\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 Friendica\App;
use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\HTML;
use Friendica\Core\Addon;
@ -211,9 +212,9 @@ function pumpio_connect(&$a)
return $o;
}
function pumpio_jot_nets(&$a, &$b)
function pumpio_jot_nets(App $a, &$b)
{
if (!local_user()) {
if(! local_user())
return;
}
@ -326,10 +327,10 @@ function pumpio_settings(&$a, &$s)
$s .= '<div class="settings-submit-wrapper" ><input type="submit" id="pumpio-submit" name="pumpio-submit" class="settings-submit" value="' . L10n::t('Save Settings') . '" /></div></div>';
}
function pumpio_settings_post(&$a, &$b)
{
if (x($_POST, 'pumpio-submit')) {
if (x($_POST, 'pumpio_delete')) {
function pumpio_settings_post(App $a, array &$b) {
if (x($_POST,'pumpio-submit')) {
if (x($_POST,'pumpio_delete')) {
PConfig::set(local_user(), 'pumpio', 'consumer_key', '');
PConfig::set(local_user(), 'pumpio', 'consumer_secret', '');
PConfig::set(local_user(), 'pumpio', 'oauth_token', '');
@ -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;
@ -405,7 +405,7 @@ function pumpio_post_local(&$a, &$b)
$b['postopts'] .= 'pumpio';
}
function pumpio_send(&$a, &$b)
function pumpio_send(App $a, array &$b)
{
if (!PConfig::get($b["uid"], 'pumpio', 'import')) {
if ($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) {
@ -1398,11 +1398,12 @@ function pumpio_getallusers(&$a, $uid)
}
}
function pumpio_queue_hook(&$a, &$b)
function pumpio_queue_hook(App $a, array &$b)
{
$qi = q("SELECT * FROM `queue` WHERE `network` = '%s'",
dbesc(NETWORK_PUMPIO)
);
if (!DBM::is_result($qi)) {
return;
}

View file

@ -15,8 +15,9 @@
* you wish to use them. On some themes they may be visible.
* Wave the mouse around near the comment input box and the qcomments will show up. Click on any of
* them to open the comment window fully and insert the qcomment. Then "Submit" will submit it.
*
*/
use Friendica\App;
use Friendica\Core\Addon;
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
@ -59,7 +60,7 @@ function qcomment_addon_settings(&$a, &$s)
return;
}
function qcomment_addon_settings_post(&$a,&$b) {
function qcomment_addon_settings_post(App $a, array &$b) {
if(! local_user())
return;

View file

@ -25,7 +25,8 @@ require_once 'openpgp.php';
require_once 'openpgp_crypt_symmetric.php';
function securemail_install() {
function securemail_install()
{
Addon::registerHook('addon_settings', 'addon/securemail/securemail.php', 'securemail_settings');
Addon::registerHook('addon_settings_post', 'addon/securemail/securemail.php', 'securemail_settings_post');
@ -53,7 +54,8 @@ function securemail_uninstall() {
*
* @see App
*/
function securemail_settings(App &$a, &$s){
function securemail_settings(App $a, &$s)
{
if (!local_user()) {
return;
}
@ -82,8 +84,8 @@ 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;
}
@ -146,8 +148,10 @@ function securemail_settings_post(App &$a, array &$b){
* @param array $b hook data
*
* @see App
* @todo x() is deprecated, next PR
*/
function securemail_emailer_send_prepare(App &$a, array &$b) {
function securemail_emailer_send_prepare(App $a, array &$b)
{
if (!x($b, 'uid')) {
return;
}
@ -183,7 +187,7 @@ function securemail_emailer_send_prepare(App &$a, array &$b) {
$b['htmlVersion'] = null;
}
/// @TODO Old lost code? Next PR!
/**
* add addon composer autoloader maps to system autoloader

View file

@ -5,8 +5,9 @@
* Version: 1.0
* Author: Michael Vogel <ike@piratenpartei.de>
* based upon NSFW from Mike Macgirvin <http://macgirvin.com/profile/mike>
*
*/
use Friendica\App;
use Friendica\Core\Addon;
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
@ -61,7 +62,7 @@ function showmore_addon_settings(&$a,&$s) {
return;
}
function showmore_addon_settings_post(&$a,&$b) {
function showmore_addon_settings_post(App $a, array &$b) {
if(! local_user())
return;

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\Addon;
function smiley_pack_es_install() {
@ -18,7 +20,7 @@ function smiley_pack_es_uninstall() {
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

@ -5,9 +5,9 @@
* Version: 1.01
* 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\Addon;
function smiley_pack_fr_install() {
@ -20,7 +20,7 @@ function smiley_pack_fr_uninstall() {
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.

View file

@ -7,6 +7,7 @@
* All smileys from sites offering them as Public Domain
*/
use Friendica\App;
use Friendica\Core\Addon;
function smiley_pack_install() {
@ -19,7 +20,7 @@ function smiley_pack_uninstall() {
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.

View file

@ -5,6 +5,8 @@
* Version: 0.2
* Author: Johannes Schwab <https://friendica.jschwab.org/profile/ddorian>
*/
use Friendica\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')
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, array &$b) {
$b['texts'][] = '(o)(o)';
$b['icons'][] = '<img class="smiley" src="' . $a->get_baseurl() . '/addon/smilies_adult/icons/tits.gif' . '" alt="' . '(o)(o)' . '" />';
@ -40,4 +42,4 @@ function smilies_adult_smilies(&$a,&$b) {
$b['texts'][] = ':finger';
$b['icons'][] = '<img class="smiley" src="' . $a->get_baseurl() . '/addon/smilies_adult/icons/finger.gif' . '" alt="' . ':finger' . '" />';
}
}

View file

@ -317,7 +317,7 @@ class CodebirdSN
*
* @return string The OAuth authenticate URL
*/
public function oauth_authenticate($force_login = NULL, $screen_name = NULL)
public function oauth_authenticate($force_login = null, $screen_name = null)
{
if ($this->_oauth_token == null) {
throw new \Exception('To get the authenticate URL, the OAuth token must be set.');
@ -337,7 +337,7 @@ class CodebirdSN
*
* @return string The OAuth authorize URL
*/
public function oauth_authorize($force_login = NULL, $screen_name = NULL)
public function oauth_authorize($force_login = null, $screen_name = null)
{
if ($this->_oauth_token == null) {
throw new \Exception('To get the authorize URL, the OAuth token must be set.');

View file

@ -1,104 +1,104 @@
<?php
use Friendica\Core\Config;
require_once __DIR__ . DIRECTORY_SEPARATOR . 'twitteroauth.php';
/*
* We have to alter the TwitterOAuth class a little bit to work with any GNU Social
* installation abroad. Basically it's only make the API path variable and be happy.
*
* Thank you guys for the Twitter compatible API!
*/
class StatusNetOAuth extends TwitterOAuth
{
function get_maxlength()
{
$config = $this->get($this->host . 'statusnet/config.json');
return $config->site->textlimit;
}
function accessTokenURL()
{
return $this->host . 'oauth/access_token';
}
function authenticateURL()
{
return $this->host . 'oauth/authenticate';
}
function authorizeURL()
{
return $this->host . 'oauth/authorize';
}
function requestTokenURL()
{
return $this->host . 'oauth/request_token';
}
function __construct($apipath, $consumer_key, $consumer_secret, $oauth_token = NULL, $oauth_token_secret = NULL)
{
parent::__construct($consumer_key, $consumer_secret, $oauth_token, $oauth_token_secret);
$this->host = $apipath;
}
/**
* Make an HTTP request
*
* Copied here from the TwitterOAuth library and complemented by applying the proxy settings of Friendica
*
* @param string $method
* @param string $host
* @param string $path
* @param array $parameters
*
* @return array|object API results
*/
function http($url, $method, $postfields = NULL)
{
$this->http_info = [];
$ci = curl_init();
/* Curl settings */
$prx = Config::get('system', 'proxy');
if (strlen($prx)) {
curl_setopt($ci, CURLOPT_HTTPPROXYTUNNEL, 1);
curl_setopt($ci, CURLOPT_PROXY, $prx);
$prxusr = Config::get('system', 'proxyuser');
if (strlen($prxusr)) {
curl_setopt($ci, CURLOPT_PROXYUSERPWD, $prxusr);
}
}
curl_setopt($ci, CURLOPT_USERAGENT, $this->useragent);
curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, $this->connecttimeout);
curl_setopt($ci, CURLOPT_TIMEOUT, $this->timeout);
curl_setopt($ci, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ci, CURLOPT_HTTPHEADER, ['Expect:']);
curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, $this->ssl_verifypeer);
curl_setopt($ci, CURLOPT_HEADERFUNCTION, [$this, 'getHeader']);
curl_setopt($ci, CURLOPT_HEADER, FALSE);
switch ($method) {
case 'POST':
curl_setopt($ci, CURLOPT_POST, TRUE);
if (!empty($postfields)) {
curl_setopt($ci, CURLOPT_POSTFIELDS, $postfields);
}
break;
case 'DELETE':
curl_setopt($ci, CURLOPT_CUSTOMREQUEST, 'DELETE');
if (!empty($postfields)) {
$url = "{$url}?{$postfields}";
}
}
curl_setopt($ci, CURLOPT_URL, $url);
$response = curl_exec($ci);
$this->http_code = curl_getinfo($ci, CURLINFO_HTTP_CODE);
$this->http_info = array_merge($this->http_info, curl_getinfo($ci));
$this->url = $url;
curl_close($ci);
return $response;
}
}
<?php
use Friendica\Core\Config;
require_once __DIR__ . DIRECTORY_SEPARATOR . 'twitteroauth.php';
/*
* We have to alter the TwitterOAuth class a little bit to work with any GNU Social
* installation abroad. Basically it's only make the API path variable and be happy.
*
* Thank you guys for the Twitter compatible API!
*/
class StatusNetOAuth extends TwitterOAuth
{
function get_maxlength()
{
$config = $this->get($this->host . 'statusnet/config.json');
return $config->site->textlimit;
}
function accessTokenURL()
{
return $this->host . 'oauth/access_token';
}
function authenticateURL()
{
return $this->host . 'oauth/authenticate';
}
function authorizeURL()
{
return $this->host . 'oauth/authorize';
}
function requestTokenURL()
{
return $this->host . 'oauth/request_token';
}
function __construct($apipath, $consumer_key, $consumer_secret, $oauth_token = null, $oauth_token_secret = null)
{
parent::__construct($consumer_key, $consumer_secret, $oauth_token, $oauth_token_secret);
$this->host = $apipath;
}
/**
* Make an HTTP request
*
* Copied here from the TwitterOAuth library and complemented by applying the proxy settings of Friendica
*
* @param string $method
* @param string $host
* @param string $path
* @param array $parameters
*
* @return array|object API results
*/
function http($url, $method, $postfields = null)
{
$this->http_info = [];
$ci = curl_init();
/* Curl settings */
$prx = Config::get('system', 'proxy');
if (strlen($prx)) {
curl_setopt($ci, CURLOPT_HTTPPROXYTUNNEL, 1);
curl_setopt($ci, CURLOPT_PROXY, $prx);
$prxusr = Config::get('system', 'proxyuser');
if (strlen($prxusr)) {
curl_setopt($ci, CURLOPT_PROXYUSERPWD, $prxusr);
}
}
curl_setopt($ci, CURLOPT_USERAGENT, $this->useragent);
curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, $this->connecttimeout);
curl_setopt($ci, CURLOPT_TIMEOUT, $this->timeout);
curl_setopt($ci, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ci, CURLOPT_HTTPHEADER, ['Expect:']);
curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, $this->ssl_verifypeer);
curl_setopt($ci, CURLOPT_HEADERFUNCTION, [$this, 'getHeader']);
curl_setopt($ci, CURLOPT_HEADER, FALSE);
switch ($method) {
case 'POST':
curl_setopt($ci, CURLOPT_POST, TRUE);
if (!empty($postfields)) {
curl_setopt($ci, CURLOPT_POSTFIELDS, $postfields);
}
break;
case 'DELETE':
curl_setopt($ci, CURLOPT_CUSTOMREQUEST, 'DELETE');
if (!empty($postfields)) {
$url = "{$url}?{$postfields}";
}
}
curl_setopt($ci, CURLOPT_URL, $url);
$response = curl_exec($ci);
$this->http_code = curl_getinfo($ci, CURLINFO_HTTP_CODE);
$this->http_info = array_merge($this->http_info, curl_getinfo($ci));
$this->url = $url;
curl_close($ci);
return $response;
}
}

View file

@ -76,14 +76,14 @@ class TwitterOAuth
/**
* construct TwitterOAuth object
*/
function __construct($consumer_key, $consumer_secret, $oauth_token = NULL, $oauth_token_secret = NULL)
function __construct($consumer_key, $consumer_secret, $oauth_token = null, $oauth_token_secret = null)
{
$this->sha1_method = new OAuthSignatureMethod_HMAC_SHA1();
$this->consumer = new OAuthConsumer($consumer_key, $consumer_secret);
if (!empty($oauth_token) && !empty($oauth_token_secret)) {
$this->token = new OAuthConsumer($oauth_token, $oauth_token_secret);
} else {
$this->token = NULL;
$this->token = null;
}
}
@ -92,7 +92,7 @@ class TwitterOAuth
*
* @returns a key/value array containing oauth_token and oauth_token_secret
*/
function getRequestToken($oauth_callback = NULL)
function getRequestToken($oauth_callback = null)
{
$parameters = array();
if (!empty($oauth_callback)) {
@ -224,7 +224,7 @@ class TwitterOAuth
*
* @return API results
*/
function http($url, $method, $postfields = NULL)
function http($url, $method, $postfields = null)
{
$this->http_info = array();
$ci = curl_init();

View file

@ -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;
@ -712,7 +712,7 @@ function statusnet_prepare_body(App $a, &$b)
}
}
function statusnet_cron(App $a, $b)
function statusnet_cron(App $a)
{
$last = Config::get('statusnet', 'last_poll');
@ -731,6 +731,7 @@ function statusnet_cron(App $a, $b)
logger('statusnet: cron_start');
$r = q("SELECT * FROM `pconfig` WHERE `cat` = 'statusnet' AND `k` = 'mirror_posts' AND `v` = '1' ORDER BY RAND() ");
if (DBM::is_result($r)) {
foreach ($r as $rr) {
logger('statusnet: fetching for user ' . $rr['uid']);
@ -746,10 +747,12 @@ function statusnet_cron(App $a, $b)
$abandon_limit = date(DateTimeFormat::MYSQL, time() - $abandon_days * 86400);
$r = q("SELECT * FROM `pconfig` WHERE `cat` = 'statusnet' AND `k` = 'import' AND `v` ORDER BY RAND()");
if (DBM::is_result($r)) {
foreach ($r as $rr) {
if ($abandon_days != 0) {
$user = q("SELECT `login_date` FROM `user` WHERE uid=%d AND `login_date` >= '%s'", $rr['uid'], $abandon_limit);
if (!DBM::is_result($user)) {
logger('abandoned account: timeline from user ' . $rr['uid'] . ' will not be imported');
continue;

View file

@ -1,6 +1,4 @@
<?php
/**
* Name: superblock
* Description: block people
@ -8,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;
@ -69,7 +69,7 @@ function superblock_addon_settings(&$a,&$s) {
return;
}
function superblock_addon_settings_post(&$a,&$b) {
function superblock_addon_settings_post(App $a, array &$b) {
if(! local_user())
return;
@ -80,7 +80,7 @@ function superblock_addon_settings_post(&$a,&$b) {
}
}
function superblock_enotify_store(&$a,&$b) {
function superblock_enotify_store(App $a, array &$b) {
$words = PConfig::get($b['uid'],'system','blocked');
if($words) {
@ -109,7 +109,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;
@ -132,7 +132,7 @@ EOT;
}
function superblock_item_photo_menu(&$a,&$b) {
function superblock_item_photo_menu(App $a, array &$b) {
if((! local_user()) || ($b['item']['self']))
return;

View file

@ -6,9 +6,11 @@
* Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
*/
use Friendica\App;
use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Database\DBM;
use Friendica\Model\User;
use Friendica\Util\DateTimeFormat;
@ -33,16 +35,17 @@ function testdrive_uninstall() {
}
function testdrive_load_config(\Friendica\App $a)
function testdrive_load_config(App $a)
{
$a->loadConfigFile(__DIR__. '/config/testdrive.ini.php');
}
function testdrive_globaldir_update($a,&$b) {
function testdrive_globaldir_update(App $a, &$b)
{
$b['url'] = '';
}
function testdrive_register_account($a,$b) {
function testdrive_register_account(App $a, $b) {
$uid = $b;
@ -58,13 +61,13 @@ function testdrive_register_account($a,$b) {
};
function testdrive_cron($a,$b) {
function testdrive_cron(App $a) {
require_once('include/enotify.php');
$r = q("select * from user where account_expires_on < UTC_TIMESTAMP() + INTERVAL 5 DAY and
expire_notification_sent = '0000-00-00 00:00:00' ");
$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'],
@ -78,23 +81,23 @@ function testdrive_cron($a,$b) {
'source_photo' => $a->get_baseurl() . '/images/person-80.jpg',
]);
q("update user set expire_notification_sent = '%s' where uid = %d",
q("UPDATE `user` SET `expire_notification_sent`='%s' WHERE `uid`=%d",
dbesc(DateTimeFormat::utcNow()),
intval($rr['uid'])
);
}
}
$r = q("select * from user where account_expired = 1 and account_expires_on < UTC_TIMESTAMP() - INTERVAL 5 DAY ");
if(count($r)) {
$r = q("SELECT * FROM `user` WHERE `account_expired`=1 AND `account_expires_on` < UTC_TIMESTAMP() - INTERVAL 5 DAY");
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

@ -53,13 +53,13 @@ class TumblrOAuth {
/**
* construct TumblrOAuth object
*/
function __construct($consumer_key, $consumer_secret, $oauth_token = NULL, $oauth_token_secret = NULL) {
function __construct($consumer_key, $consumer_secret, $oauth_token = null, $oauth_token_secret = null) {
$this->sha1_method = new OAuthSignatureMethod_HMAC_SHA1();
$this->consumer = new OAuthConsumer($consumer_key, $consumer_secret);
if (!empty($oauth_token) && !empty($oauth_token_secret)) {
$this->token = new OAuthConsumer($oauth_token, $oauth_token_secret);
} else {
$this->token = NULL;
$this->token = null;
}
}
@ -69,7 +69,7 @@ class TumblrOAuth {
*
* @returns a key/value array containing oauth_token and oauth_token_secret
*/
function getRequestToken($oauth_callback = NULL) {
function getRequestToken($oauth_callback = null) {
$parameters = array();
if (!empty($oauth_callback)) {
$parameters['oauth_callback'] = $oauth_callback;
@ -191,7 +191,7 @@ class TumblrOAuth {
*
* @return API results
*/
function http($url, $method, $postfields = NULL) {
function http($url, $method, $postfields = null) {
$this->http_info = array();
$ci = curl_init();
/* Curl settings */

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, array &$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, array &$b) {
if($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) {
return;

View file

@ -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')
@ -658,7 +658,7 @@ function twitter_addon_admin(App $a, &$o)
]);
}
function twitter_cron(App $a, $b)
function twitter_cron(App $a)
{
$last = Config::get('twitter', 'last_poll');
@ -726,7 +726,7 @@ function twitter_cron(App $a, $b)
Config::set('twitter', 'last_poll', time());
}
function twitter_expire(App $a, $b)
function twitter_expire(App $a)
{
$days = Config::get('twitter', 'expire');
@ -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, 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\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 Friendica\App;
use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\HTML;
use Friendica\Core\Addon;
@ -14,7 +15,8 @@ use Friendica\Core\PConfig;
use Friendica\Database\DBA;
use Friendica\Util\Network;
function wppost_install() {
function wppost_install()
{
Addon::registerHook('post_local', 'addon/wppost/wppost.php', 'wppost_post_local');
Addon::registerHook('notifier_normal', 'addon/wppost/wppost.php', 'wppost_send');
Addon::registerHook('jot_networks', 'addon/wppost/wppost.php', 'wppost_jot_nets');
@ -22,7 +24,9 @@ function wppost_install() {
Addon::registerHook('connector_settings_post', 'addon/wppost/wppost.php', 'wppost_settings_post');
}
function wppost_uninstall() {
function wppost_uninstall()
{
Addon::unregisterHook('post_local', 'addon/wppost/wppost.php', 'wppost_post_local');
Addon::unregisterHook('notifier_normal', 'addon/wppost/wppost.php', 'wppost_send');
Addon::unregisterHook('jot_networks', 'addon/wppost/wppost.php', 'wppost_jot_nets');
@ -37,11 +41,13 @@ function wppost_uninstall() {
}
function wppost_jot_nets(&$a,&$b) {
function wppost_jot_nets(App $a, &$b)
{
if(! local_user())
return;
$wp_post = PConfig::get(local_user(),'wppost','post');
if(intval($wp_post) == 1) {
$wp_defpost = PConfig::get(local_user(),'wppost','post_by_default');
$selected = ((intval($wp_defpost) == 1) ? ' checked="checked" ' : '');
@ -51,7 +57,8 @@ function wppost_jot_nets(&$a,&$b) {
}
function wppost_settings(&$a,&$s) {
function wppost_settings(App &$a, &$s)
{
if(! local_user())
return;
@ -136,8 +143,8 @@ function wppost_settings(&$a,&$s) {
}
function wppost_settings_post(&$a,&$b) {
function wppost_settings_post(App $a, array &$b)
{
if(x($_POST,'wppost-submit')) {
PConfig::set(local_user(),'wppost','post',intval($_POST['wppost']));
@ -156,8 +163,8 @@ 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
if ($b['edit']) {
@ -194,8 +201,8 @@ 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;
}

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;