Browse Source

Merge remote-tracking branch 'upstream/develop' into 1701-curl-range

Conflicts:
	mod/oexchange.php
	mod/uimport.php
pull/3080/head
Michael 4 years ago
parent
commit
e67133ef56
162 changed files with 798 additions and 757 deletions
  1. +1
    -1
      LICENSE
  2. +4
    -4
      boot.php
  3. +5
    -5
      doc/Plugins.md
  4. +23
    -23
      doc/autoloader.md
  5. +5
    -5
      doc/de/Plugins.md
  6. +3
    -3
      doc/themes.md
  7. +2
    -2
      include/Contact.php
  8. +2
    -2
      include/Photo.php
  9. +4
    -4
      include/acl_selectors.php
  10. +15
    -15
      include/api.php
  11. +1
    -1
      include/conversation.php
  12. +4
    -3
      include/cron.php
  13. +72
    -48
      include/delivery.php
  14. +3
    -2
      include/diaspora.php
  15. +22
    -22
      include/event.php
  16. +18
    -18
      include/identity.php
  17. +1
    -1
      include/nav.php
  18. +0
    -1
      include/network.php
  19. +126
    -107
      include/notifier.php
  20. +1
    -1
      include/ostatus.php
  21. +1
    -1
      include/plaintext.php
  22. +4
    -4
      include/redir.php
  23. +27
    -27
      include/security.php
  24. +3
    -3
      include/text.php
  25. +1
    -1
      include/uimport.php
  26. +2
    -2
      mod/_well_known.php
  27. +1
    -1
      mod/acctlink.php
  28. +1
    -1
      mod/acl.php
  29. +37
    -37
      mod/admin.php
  30. +1
    -1
      mod/allfriends.php
  31. +1
    -1
      mod/amcd.php
  32. +2
    -2
      mod/api.php
  33. +2
    -2
      mod/apps.php
  34. +1
    -1
      mod/attach.php
  35. +23
    -23
      mod/babel.php
  36. +2
    -2
      mod/bookmarklet.php
  37. +2
    -2
      mod/cal.php
  38. +4
    -4
      mod/cb.php
  39. +1
    -1
      mod/common.php
  40. +2
    -2
      mod/community.php
  41. +1
    -1
      mod/contactgroup.php
  42. +10
    -10
      mod/contacts.php
  43. +20
    -20
      mod/content.php
  44. +1
    -1
      mod/credits.php
  45. +3
    -3
      mod/crepair.php
  46. +4
    -4
      mod/delegate.php
  47. +1
    -1
      mod/dfrn_confirm.php
  48. +2
    -2
      mod/dfrn_notify.php
  49. +5
    -5
      mod/dfrn_poll.php
  50. +3
    -3
      mod/dfrn_request.php
  51. +5
    -5
      mod/directory.php
  52. +2
    -2
      mod/dirfind.php
  53. +2
    -2
      mod/display.php
  54. +1
    -1
      mod/editpost.php
  55. +3
    -3
      mod/events.php
  56. +1
    -1
      mod/fbrowser.php
  57. +1
    -3
      mod/fetch.php
  58. +2
    -2
      mod/filer.php
  59. +1
    -1
      mod/filerm.php
  60. +2
    -2
      mod/follow.php
  61. +4
    -4
      mod/friendica.php
  62. +8
    -8
      mod/fsuggest.php
  63. +3
    -3
      mod/group.php
  64. +1
    -1
      mod/hcard.php
  65. +1
    -1
      mod/help.php
  66. +2
    -2
      mod/home.php
  67. +1
    -1
      mod/hostxrd.php
  68. +3
    -3
      mod/hovercard.php
  69. +1
    -1
      mod/ignored.php
  70. +4
    -4
      mod/install.php
  71. +5
    -5
      mod/invite.php
  72. +2
    -2
      mod/item.php
  73. +1
    -1
      mod/like.php
  74. +3
    -3
      mod/localtime.php
  75. +9
    -9
      mod/lockview.php
  76. +1
    -1
      mod/login.php
  77. +2
    -2
      mod/lostpass.php
  78. +1
    -1
      mod/maintenance.php
  79. +2
    -2
      mod/manage.php
  80. +2
    -2
      mod/match.php
  81. +3
    -3
      mod/message.php
  82. +1
    -1
      mod/modexp.php
  83. +3
    -3
      mod/mood.php
  84. +3
    -3
      mod/msearch.php
  85. +1
    -1
      mod/navigation.php
  86. +8
    -8
      mod/network.php
  87. +5
    -5
      mod/newmember.php
  88. +3
    -3
      mod/nodeinfo.php
  89. +2
    -2
      mod/nogroup.php
  90. +1
    -1
      mod/noscrape.php
  91. +2
    -2
      mod/notes.php
  92. +2
    -2
      mod/notice.php
  93. +2
    -2
      mod/notifications.php
  94. +4
    -4
      mod/notify.php
  95. +1
    -1
      mod/oembed.php
  96. +2
    -3
      mod/oexchange.php
  97. +2
    -2
      mod/openid.php
  98. +7
    -7
      mod/opensearch.php
  99. +1
    -1
      mod/ostatus_subscribe.php
  100. +10
    -10
      mod/parse_url.php

+ 1
- 1
LICENSE View File

@ -1,5 +1,5 @@
Friendica Communications Server
Copyright (c) 2010-2016 the Friendica Project
Copyright (c) 2010-2017 the Friendica Project
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by


+ 4
- 4
boot.php View File

@ -1540,7 +1540,7 @@ function check_db() {
* Sets the base url for use in cmdline programs which don't have
* $_SERVER variables
*/
function check_url(App &$a) {
function check_url(App $a) {
$url = get_config('system','url');
@ -1562,7 +1562,7 @@ function check_url(App &$a) {
/**
* @brief Automatic database updates
*/
function update_db(App &$a) {
function update_db(App $a) {
$build = get_config('system','build');
if(! x($build))
$build = set_config('system','build',DB_UPDATE_VERSION);
@ -1678,7 +1678,7 @@ function run_update_function($x) {
* @param App $a
*
*/
function check_plugins(App &$a) {
function check_plugins(App $a) {
$r = q("SELECT * FROM `addon` WHERE `installed` = 1");
if (dbm::is_result($r))
@ -2414,7 +2414,7 @@ function get_temppath() {
}
/// @deprecated
function set_template_engine(App &$a, $engine = 'internal') {
function set_template_engine(App $a, $engine = 'internal') {
/// @note This function is no longer necessary, but keep it as a wrapper to the class method
/// to avoid breaking themes again unnecessarily


+ 5
- 5
doc/Plugins.md View File

@ -40,7 +40,7 @@ Arguments
---
Your hook callback functions will be called with at least one and possibly two arguments
function myhook_function(&$a, &$b) {
function myhook_function(App $a, &$b) {
}
@ -77,9 +77,9 @@ This will include:
$a->argc = 3
$a->argv = array(0 => 'plugin', 1 => 'arg1', 2 => 'arg2');
Your module functions will often contain the function plugin_name_content(App &$a), which defines and returns the page body content.
They may also contain plugin_name_post(App &$a) which is called before the _content function and typically handles the results of POST forms.
You may also have plugin_name_init(App &$a) which is called very early on and often does module initialisation.
Your module functions will often contain the function plugin_name_content(App $a), which defines and returns the page body content.
They may also contain plugin_name_post(App $a) which is called before the _content function and typically handles the results of POST forms.
You may also have plugin_name_init(App $a) which is called very early on and often does module initialisation.
Templates
---
@ -285,7 +285,7 @@ $b is an array with:
is called after the other queries have passed.
The registered function can add, change or remove the acl_lookup() variables.
'results' => array of the acl_lookup() vars
'results' => array of the acl_lookup() vars
Complete list of hook callbacks


+ 23
- 23
doc/autoloader.md View File

@ -32,7 +32,7 @@ Let's say you have a php file in "include/" that define a very useful class:
file: include/ItemsManager.php
<?php
namespace \Friendica;
class ItemsManager {
public function getAll() { ... }
public function getByID($id) { ... }
@ -67,11 +67,11 @@ The code will be something like:
```
file: mod/network.php
<?php
function network_content(App &$a) {
function network_content(App $a) {
$itemsmanager = new \Friendica\ItemsManager();
$items = $itemsmanager->getAll();
// pass $items to template
// return result
}
@ -86,7 +86,7 @@ Going further: now we have a bunch of "*Manager" classes that cause some code du
file: include/BaseManager.php
<?php
namespace \Friendica;
class BaseManager {
public function thatFunctionEveryManagerUses() { ... }
}
@ -98,7 +98,7 @@ and then let's change the ItemsManager class to use this code
file: include/ItemsManager.php
<?php
namespace \Friendica;
class ItemsManager extends BaseManager {
public function getAll() { ... }
public function getByID($id) { ... }
@ -110,9 +110,9 @@ It works with the "BaseManager" example here, it works when we need to call stat
```
file: include/dfrn.php
<?php
<?php
namespace \Friendica;
class dfrn {
public static function mail($item, $owner) { ... }
}
@ -121,7 +121,7 @@ It works with the "BaseManager" example here, it works when we need to call stat
```
file: mod/mail.php
<?php
mail_post($a){
...
\Friendica\dfrn::mail($item, $owner);
@ -134,15 +134,15 @@ If your code is in same namespace as the class you need, you don't need to prepe
```
file: include/delivery.php
<?php
namespace \Friendica;
// this is the same content of current include/delivery.php,
// this is the same content of current include/delivery.php,
// but has been declared to be in "Friendica" namespace
[...]
switch($contact['network']) {
case NETWORK_DFRN:
if ($mail) {
$item['body'] = ...
@ -160,11 +160,11 @@ But if you want to use classes from another library, you need to use the full na
```
<?php
namespace \Frienidca;
namespace \Friendica;
class Diaspora {
public function md2bbcode() {
$html = \Michelf\MarkdownExtra::defaultTransform($text);
$html = \Michelf\MarkdownExtra::defaultTransform($text);
}
}
```
@ -173,13 +173,13 @@ if you use that class in many places of the code and you don't want to write the
```
<?php
namespace \Frienidca;
namespace \Friendica;
use \Michelf\MarkdownExtra;
class Diaspora {
public function md2bbcode() {
$html = MarkdownExtra::defaultTransform($text);
$html = MarkdownExtra::defaultTransform($text);
}
}
```
@ -190,7 +190,7 @@ You can go more deep if you want to, like:
```
<?php
namespace \Friendica\Network;
class DFRN {
}
```
@ -200,7 +200,7 @@ or
```
<?php
namespace \Friendica\DBA;
class MySQL {
}
```


+ 5
- 5
doc/de/Plugins.md View File

@ -40,7 +40,7 @@ Argumente
Deine Hook-Callback-Funktion wird mit mindestens einem und bis zu zwei Argumenten aufgerufen
function myhook_function(&$a, &$b) {
function myhook_function(App $a, &$b) {
}
@ -67,9 +67,9 @@ So würde http://example.com/plugin/arg1/arg2 nach einem Modul "plugin" suchen u
$a->argc = 3
$a->argv = array(0 => 'plugin', 1 => 'arg1', 2 => 'arg2');
Deine Modulfunktionen umfassen oft die Funktion plugin_name_content(App &$a), welche den Seiteninhalt definiert und zurückgibt.
Sie können auch plugin_name_post(App &$a) umfassen, welches vor der content-Funktion aufgerufen wird und normalerweise die Resultate der POST-Formulare handhabt.
Du kannst ebenso plugin_name_init(App &$a) nutzen, was oft frühzeitig aufgerufen wird und das Modul initialisert.
Deine Modulfunktionen umfassen oft die Funktion plugin_name_content(App $a), welche den Seiteninhalt definiert und zurückgibt.
Sie können auch plugin_name_post(App $a) umfassen, welches vor der content-Funktion aufgerufen wird und normalerweise die Resultate der POST-Formulare handhabt.
Du kannst ebenso plugin_name_init(App $a) nutzen, was oft frühzeitig aufgerufen wird und das Modul initialisert.
Derzeitige Hooks
@ -311,7 +311,7 @@ mod/photos.php: call_hooks('photo_post_end',intval($item_id));
mod/photos.php: call_hooks('photo_upload_form',$ret);
mod/friendica.php: call_hooks('about_hook', $o);
mod/friendica.php: call_hooks('about_hook', $o);
mod/editpost.php: call_hooks('jot_tool', $jotplugins);


+ 3
- 3
doc/themes.md View File

@ -122,7 +122,7 @@ the 1st part of the line is the name of the CSS file (without the .css) the 2nd
Calling the t() function with the common name makes the string translateable.
The selected 1st part will be saved in the database by the theme_post function.
function theme_post(App &$a){
function theme_post(App $a){
// non local users shall not pass
if (! local_user()) {
return;
@ -168,7 +168,7 @@ The content of this file should be something like
<?php
/* meta informations for the theme, see below */
function duepuntozero_lr_init(App &$a) {
function duepuntozero_lr_init(App $a) {
$a-> theme_info = array(
'extends' => 'duepuntozero'.
);
@ -251,7 +251,7 @@ Next crucial part of the theme.php file is a definition of an init function.
The name of the function is <theme-name>_init.
So in the case of quattro it is
function quattro_init(App &$a) {
function quattro_init(App $a) {
$a->theme_info = array();
set_template_engine($a, 'smarty3');
}


+ 2
- 2
include/Contact.php View File

@ -612,7 +612,7 @@ function get_contact($url, $uid = 0, $no_update = false) {
*
* @return string posts in HTML
*/
function posts_from_gcontact($a, $gcontact_id) {
function posts_from_gcontact(App $a, $gcontact_id) {
require_once('include/conversation.php');
@ -664,7 +664,7 @@ function posts_from_gcontact($a, $gcontact_id) {
*
* @return string posts in HTML
*/
function posts_from_contact_url($a, $contact_url) {
function posts_from_contact_url(App $a, $contact_url) {
require_once('include/conversation.php');


+ 2
- 2
include/Photo.php View File

@ -283,7 +283,7 @@ class Photo {
do {
// FIXME - implement horizantal bias for scaling as in followin GD functions
// to allow very tall images to be constrained only horizontally.
// to allow very tall images to be constrained only horizontally.
$this->image->scaleImage($dest_width, $dest_height);
} while ($this->image->nextImage());
@ -943,7 +943,7 @@ function scale_image($width, $height, $max) {
return array("width" => $dest_width, "height" => $dest_height);
}
function store_photo($a, $uid, $imagedata = "", $url = "") {
function store_photo(App $a, $uid, $imagedata = "", $url = "") {
$r = q("SELECT `user`.`nickname`, `user`.`page-flags`, `contact`.`id` FROM `user` INNER JOIN `contact` on `user`.`uid` = `contact`.`uid`
WHERE `user`.`uid` = %d AND `user`.`blocked` = 0 AND `contact`.`self` = 1 LIMIT 1",
intval($uid));


+ 4
- 4
include/acl_selectors.php View File

@ -372,7 +372,7 @@ function populate_acl($user = null, $show_jotnets = false) {
}
function construct_acl_data(&$a, $user) {
function construct_acl_data(App $a, $user) {
// Get group and contact information for html ACL selector
$acl_data = acl_lookup($a, 'html');
@ -404,7 +404,7 @@ function construct_acl_data(&$a, $user) {
}
function acl_lookup(&$a, $out_type = 'json') {
function acl_lookup(App $a, $out_type = 'json') {
if (!local_user()) {
return '';
@ -687,11 +687,11 @@ function acl_lookup(&$a, $out_type = 'json') {
}
/**
* @brief Searching for global contacts for autocompletion
*
*
* @param App $a
* @return array with the search results
*/
function navbar_complete(App &$a) {
function navbar_complete(App $a) {
// logger('navbar_complete');


+ 15
- 15
include/api.php View File

@ -133,7 +133,7 @@
* @hook 'logged_in'
* array $user logged user record
*/
function api_login(App &$a){
function api_login(App $a){
// login with oauth
try{
$oauth = new FKOAuth1();
@ -251,7 +251,7 @@
* @param App $a
* @return string API call result
*/
function api_call(App &$a){
function api_call(App $a){
global $API, $called_api;
$type="json";
@ -404,7 +404,7 @@
* @param array $user_info
* @return array
*/
function api_rss_extra(&$a, $arr, $user_info){
function api_rss_extra(App $a, $arr, $user_info){
if (is_null($user_info)) $user_info = api_get_user($a);
$arr['$user'] = $user_info;
$arr['$rss'] = array(
@ -444,7 +444,7 @@
* @param int|string $contact_id Contact ID or URL
* @param string $type Return type (for errors)
*/
function api_get_user(&$a, $contact_id = Null, $type = "json"){
function api_get_user(App $a, $contact_id = Null, $type = "json"){
global $called_api;
$user = null;
$extra_query = "";
@ -712,7 +712,7 @@
* @param array $item : item from db
* @return array(array:author, array:owner)
*/
function api_item_get_user(&$a, $item) {
function api_item_get_user(App $a, $item) {
$status_user = api_get_user($a, $item["author-link"]);
@ -2451,7 +2451,7 @@
'homepage' => $profile['homepage'],
'users' => null);
return $profile;
}
}
}
/**
@ -2874,14 +2874,14 @@
// BadRequestException if no id specified (for clients using Twitter API)
if ($id == 0) throw new BadRequestException('Message id not specified');
// add parent-uri to sql command if specified by calling app
// add parent-uri to sql command if specified by calling app
$sql_extra = ($parenturi != "" ? " AND `parent-uri` = '" . dbesc($parenturi) . "'" : "");
// get data of the specified message id
$r = q("SELECT `id` FROM `mail` WHERE `uid` = %d AND `id` = %d" . $sql_extra,
intval($uid),
intval($uid),
intval($id));
// error message if specified id is not in database
if (!dbm::is_result($r)) {
if ($verbose == "true") {
@ -2893,8 +2893,8 @@
}
// delete message
$result = q("DELETE FROM `mail` WHERE `uid` = %d AND `id` = %d" . $sql_extra,
intval($uid),
$result = q("DELETE FROM `mail` WHERE `uid` = %d AND `id` = %d" . $sql_extra,
intval($uid),
intval($id));
if ($verbose == "true") {
@ -3860,7 +3860,7 @@
// get data of the specified message id
$r = q("SELECT `id` FROM `mail` WHERE `id` = %d AND `uid` = %d",
intval($id),
intval($id),
intval($uid));
// error message if specified id is not in database
if (!dbm::is_result($r)) {
@ -3869,8 +3869,8 @@
}
// update seen indicator
$result = q("UPDATE `mail` SET `seen` = 1 WHERE `id` = %d AND `uid` = %d",
intval($id),
$result = q("UPDATE `mail` SET `seen` = 1 WHERE `id` = %d AND `uid` = %d",
intval($id),
intval($uid));
if ($result) {
@ -3921,7 +3921,7 @@
// message if nothing was found
if (!dbm::is_result($r))
$success = array('success' => false, 'search_results' => 'problem with query');
else if (count($r) == 0)
else if (count($r) == 0)
$success = array('success' => false, 'search_results' => 'nothing found');
else {
$ret = Array();


+ 1
- 1
include/conversation.php View File

@ -466,7 +466,7 @@ function item_condition() {
*/
if(!function_exists('conversation')) {
function conversation(&$a, $items, $mode, $update, $preview = false) {
function conversation(App $a, $items, $mode, $update, $preview = false) {
require_once('include/bbcode.php');
require_once('include/Contact.php');


+ 4
- 3
include/cron.php View File

@ -264,8 +264,9 @@ function cron_poll_contacts($argc, $argv) {
intval($c['id'])
);
if (dbm::is_result($res))
if (!dbm::is_result($res)) {
continue;
}
foreach($res as $contact) {
@ -343,7 +344,7 @@ function cron_poll_contacts($argc, $argv) {
*
* @param App $a
*/
function cron_clear_cache(App &$a) {
function cron_clear_cache(App $a) {
$last = get_config('system','cache_last_cleared');
@ -430,7 +431,7 @@ function cron_clear_cache(App &$a) {
*
* @param App $a
*/
function cron_repair_diaspora(App &$a) {
function cron_repair_diaspora(App $a) {
$r = q("SELECT `id`, `url` FROM `contact`
WHERE `network` = '%s' AND (`batch` = '' OR `notify` = '' OR `poll` = '' OR pubkey = '')
ORDER BY RAND() LIMIT 50", dbesc(NETWORK_DIASPORA));


+ 72
- 48
include/delivery.php View File

@ -10,7 +10,7 @@ require_once("include/dfrn.php");
function delivery_run(&$argv, &$argc){
global $a, $db;
if (is_null($a)){
if (is_null($a)) {
$a = new App;
}
@ -32,8 +32,9 @@ function delivery_run(&$argv, &$argc){
load_hooks();
if ($argc < 3)
if ($argc < 3) {
return;
}
$a->set_baseurl(get_config('system','url'));
@ -42,10 +43,11 @@ function delivery_run(&$argv, &$argc){
$cmd = $argv[1];
$item_id = intval($argv[2]);
for($x = 3; $x < $argc; $x ++) {
for ($x = 3; $x < $argc; $x ++) {
$contact_id = intval($argv[$x]);
/// @todo When switching completely to the worker we won't need this anymore
// Some other process may have delivered this item already.
$r = q("SELECT * FROM `deliverq` WHERE `cmd` = '%s' AND `item` = %d AND `contact` = %d LIMIT 1",
@ -57,8 +59,9 @@ function delivery_run(&$argv, &$argc){
continue;
}
if ($a->maxload_reached())
if ($a->maxload_reached()) {
return;
}
// It's ours to deliver. Remove it from the queue.
@ -68,8 +71,9 @@ function delivery_run(&$argv, &$argc){
dbesc($contact_id)
);
if (!$item_id || !$contact_id)
if (!$item_id || !$contact_id) {
continue;
}
$expire = false;
$mail = false;
@ -90,14 +94,13 @@ function delivery_run(&$argv, &$argc){
$message = q("SELECT * FROM `mail` WHERE `id` = %d LIMIT 1",
intval($item_id)
);
if (!count($message)){
if (!count($message)) {
return;
}
$uid = $message[0]['uid'];
$recipients[] = $message[0]['contact-id'];
$item = $message[0];
}
elseif ($cmd === 'expire') {
} elseif ($cmd === 'expire') {
$normal_mode = false;
$expire = true;
$items = q("SELECT * FROM `item` WHERE `uid` = %d AND `wall` = 1
@ -106,18 +109,19 @@ function delivery_run(&$argv, &$argc){
);
$uid = $item_id;
$item_id = 0;
if (!count($items))
if (!count($items)) {
continue;
}
elseif ($cmd === 'suggest') {
}
} elseif ($cmd === 'suggest') {
$normal_mode = false;
$fsuggest = true;
$suggest = q("SELECT * FROM `fsuggest` WHERE `id` = %d LIMIT 1",
intval($item_id)
);
if (!count($suggest))
if (!count($suggest)) {
return;
}
$uid = $suggest[0]['uid'];
$recipients[] = $suggest[0]['cid'];
$item = $suggest[0];
@ -151,26 +155,33 @@ function delivery_run(&$argv, &$argc){
$icontacts = null;
$contacts_arr = array();
foreach($items as $item)
if (!in_array($item['contact-id'],$contacts_arr))
foreach ($items as $item) {
if (!in_array($item['contact-id'],$contacts_arr)) {
$contacts_arr[] = intval($item['contact-id']);
}
}
if (count($contacts_arr)) {
$str_contacts = implode(',',$contacts_arr);
$icontacts = q("SELECT * FROM `contact`
WHERE `id` IN ( $str_contacts ) "
);
}
if ( !($icontacts && count($icontacts)))
if ( !($icontacts && count($icontacts))) {
continue;
}
// avoid race condition with deleting entries
if ($items[0]['deleted']) {
foreach($items as $item)
foreach ($items as $item) {
$item['deleted'] = 1;
}
}
if ((count($items) == 1) && ($items[0]['uri'] === $items[0]['parent-uri'])) {
// When commenting too fast after delivery, a post wasn't recognized as top level post.
// The count then showed more than one entry. The additional check should help.
// The check for the "count" should be superfluous, but I'm not totally sure by now, so we keep it.
if ((($items[0]['id'] == $item_id) || (count($items) == 1)) && ($items[0]['uri'] === $items[0]['parent-uri'])) {
logger('delivery: top level post');
$top_level = true;
}
@ -184,8 +195,9 @@ function delivery_run(&$argv, &$argc){
intval($uid)
);
if (!dbm::is_result($r))
if (!dbm::is_result($r)) {
continue;
}
$owner = $r[0];
@ -217,9 +229,9 @@ function delivery_run(&$argv, &$argc){
$localhost = $a->get_hostname();
if (strpos($localhost,':'))
if (strpos($localhost,':')) {
$localhost = substr($localhost,0,strpos($localhost,':'));
}
/**
*
* Be VERY CAREFUL if you make any changes to the following line. Seemingly innocuous changes
@ -254,12 +266,12 @@ function delivery_run(&$argv, &$argc){
intval($contact_id)
);
if (dbm::is_result($r))
if (dbm::is_result($r)) {
$contact = $r[0];
if ($contact['self'])
}
if ($contact['self']) {
continue;
}
$deliver_status = 0;
logger("main delivery by delivery: followup=$followup mail=$mail fsuggest=$fsuggest relocate=$relocate - network ".$contact['network']);
@ -275,13 +287,14 @@ function delivery_run(&$argv, &$argc){
} elseif ($fsuggest) {
$atom = dfrn::fsuggest($item, $owner);
q("DELETE FROM `fsuggest` WHERE `id` = %d LIMIT 1", intval($item['id']));
} elseif ($relocate)
} elseif ($relocate) {
$atom = dfrn::relocate($owner, $uid);
elseif ($followup) {
} elseif ($followup) {
$msgitems = array();
foreach($items as $item) { // there is only one item
if (!$item['parent'])
foreach ($items as $item) { // there is only one item
if (!$item['parent']) {
continue;
}
if ($item['id'] == $item_id) {
logger('followup: item: '. print_r($item,true), LOGGER_DATA);
$msgitems[] = $item;
@ -290,17 +303,20 @@ function delivery_run(&$argv, &$argc){
$atom = dfrn::entries($msgitems,$owner);
} else {
$msgitems = array();
foreach($items as $item) {
if (!$item['parent'])
foreach ($items as $item) {
if (!$item['parent']) {
continue;
}
// private emails may be in included in public conversations. Filter them.
if ($public_message && $item['private'])
if ($public_message && $item['private']) {
continue;
}
$item_contact = get_item_contact($item,$icontacts);
if (!$item_contact)
if (!$item_contact) {
continue;
}
if ($normal_mode) {
if ($item_id == $item['id'] || $item['id'] == $item['parent']) {
@ -326,10 +342,11 @@ function delivery_run(&$argv, &$argc){
if (link_compare($basepath,App::get_baseurl())) {
$nickname = basename($contact['url']);
if ($contact['issued-id'])
if ($contact['issued-id']) {
$sql_extra = sprintf(" AND `dfrn-id` = '%s' ", dbesc($contact['issued-id']));
else
} else {
$sql_extra = sprintf(" AND `issued-id` = '%s' ", dbesc($contact['dfrn-id']));
}
$x = q("SELECT `contact`.*, `contact`.`uid` AS `importer_uid`,
`contact`.`pubkey` AS `cpubkey`,
@ -362,19 +379,20 @@ function delivery_run(&$argv, &$argc){
// If we are setup as a soapbox we aren't accepting top level posts from this person
if (($x[0]['page-flags'] == PAGE_SOAPBOX) AND $top_level)
if (($x[0]['page-flags'] == PAGE_SOAPBOX) AND $top_level) {
break;
}
logger('mod-delivery: local delivery');
dfrn::import($atom, $x[0]);
break;
}
}
if (!was_recently_delayed($contact['id']))
if (!was_recently_delayed($contact['id'])) {
$deliver_status = dfrn::deliver($owner,$contact,$atom);
else
} else {
$deliver_status = (-1);
}
logger('notifier: dfrn_delivery to '.$contact["url"].' with guid '.$target_item["guid"].' returns '.$deliver_status);
@ -393,10 +411,12 @@ function delivery_run(&$argv, &$argc){
case NETWORK_OSTATUS:
// Do not send to otatus if we are not configured to send to public networks
if ($owner['prvnets'])
if ($owner['prvnets']) {
break;
if (get_config('system','ostatus_disabled') || get_config('system','dfrn_only'))
}
if (get_config('system','ostatus_disabled') || get_config('system','dfrn_only')) {
break;
}
// There is currently no code here to distribute anything to OStatus.
// This is done in "notifier.php" (See "url_recipients" and "push_notify")
@ -405,20 +425,22 @@ function delivery_run(&$argv, &$argc){
case NETWORK_MAIL:
case NETWORK_MAIL2:
if (get_config('system','dfrn_only'))
if (get_config('system','dfrn_only')) {
break;
}
// WARNING: does not currently convert to RFC2047 header encodings, etc.
$addr = $contact['addr'];
if (!strlen($addr))
if (!strlen($addr)) {
break;
}
if ($cmd === 'wall-new' || $cmd === 'comment-new') {
$it = null;
if ($cmd === 'wall-new')
if ($cmd === 'wall-new') {
$it = $items[0];
else {
} else {
$r = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($argv[2]),
intval($uid)
@ -451,10 +473,12 @@ function delivery_run(&$argv, &$argc){
if ($reply_to) {
$headers = 'From: '.email_header_encode($local_user[0]['username'],'UTF-8').' <'.$reply_to.'>'."\n";
$headers .= 'Sender: '.$local_user[0]['email']."\n";
} else
} else {
$headers = 'From: '.email_header_encode($local_user[0]['username'],'UTF-8').' <'.$local_user[0]['email'].'>'."\n";
} else
}
} else {
$headers = 'From: '. email_header_encode($local_user[0]['username'],'UTF-8') .' <'. t('noreply') .'@'.$a->get_hostname() .'>'. "\n";
}
//if ($reply_to)
// $headers .= 'Reply-to: '.$reply_to . "\n";
@ -478,9 +502,9 @@ function delivery_run(&$argv, &$argc){
dbesc($it['parent-uri']),
intval($uid));
if (dbm::is_result($r) AND ($r[0]['title'] != ''))
if (dbm::is_result($r) AND ($r[0]['title'] != '')) {
$subject = $r[0]['title'];
else {
} else {
$r = q("SELECT `title` FROM `item` WHERE `parent-uri` = '%s' AND `uid` = %d LIMIT 1",
dbesc($it['parent-uri']),
intval($uid));


+ 3
- 2
include/diaspora.php View File

@ -325,8 +325,9 @@ class Diaspora {
logger("delivering to: ".$rr["username"]);
self::dispatch($rr,$msg);
}
} else
logger("No subscribers for ".$msg["author"]." ".print_r($msg, true));
} else {
logger("No subscribers for ".$msg["author"]." ".print_r($msg, true), LOGGER_DEBUG);
}
return $message_id;
}


+ 22
- 22
include/event.php View File

@ -206,7 +206,7 @@ function bbtoevent($s) {
}
function sort_by_date(App &$a) {
function sort_by_date(App $a) {
usort($a,'ev_compare');
return $a;
@ -495,7 +495,7 @@ function get_event_strings() {
/**
* @brief Get an event by its event ID
*
*
* @param type $owner_uid The User ID of the owner of the event
* @param type $event_params An assoziative array with
* int 'event_id' => The ID of the event in the event table
@ -523,15 +523,15 @@ function event_by_id($owner_uid = 0, $event_params, $sql_extra = '') {
/**
* @brief Get all events in a specific timeframe
*
*
* @param int $owner_uid The User ID of the owner of the events
* @param array $event_params An assoziative array with
* int 'ignored' =>
* int 'ignored' =>
* string 'start' => Start time of the timeframe
* string 'finish' => Finish time of the timeframe
* string 'adjust_start' =>
* string 'adjust_start' =>
*
* string 'adjust_start' =>
*
* @param string $sql_extra Additional sql conditions (e.g. permission request)
* @return array Query results
*/
@ -564,7 +564,7 @@ function events_by_date($owner_uid = 0, $event_params, $sql_extra = '') {
/**
* @brief Convert an array query results in an arry which could be used by the events template
*
*
* @param array $arr Event query array
* @return array Event array for the template
*/
@ -623,11 +623,11 @@ function process_events ($arr) {
/**
* @brief Format event to export format (ical/csv)
*
*
* @param array $events Query result for events
* @param string $format The output format (ical/csv)
* @param string $timezone The timezone of the user (not implemented yet)
*
*
* @return string Content according to selected export format
*/
function event_format_export ($events, $format = 'ical', $timezone) {
@ -641,7 +641,7 @@ function event_format_export ($events, $format = 'ical', $timezone) {
$o = '"Subject", "Start Date", "Start Time", "Description", "End Date", "End Time", "Location"' . PHP_EOL;
foreach ($events as $event) {
/// @todo the time / date entries don't include any information about the
/// @todo the time / date entries don't include any information about the
// timezone the event is scheduled in :-/
$tmp1 = strtotime($event['start']);
$tmp2 = strtotime($event['finish']);
@ -650,7 +650,7 @@ function event_format_export ($events, $format = 'ical', $timezone) {
$o .= '"'.$event['summary'].'", "'.strftime($date_format, $tmp1) .
'", "'.strftime($time_format, $tmp1).'", "'.$event['desc'] .
'", "'.strftime($date_format, $tmp2) .
'", "'.strftime($time_format, $tmp2) .
'", "'.strftime($time_format, $tmp2) .
'", "'.$event['location'].'"' . PHP_EOL;
}
break;
@ -672,7 +672,7 @@ function event_format_export ($events, $format = 'ical', $timezone) {
foreach ($events as $event) {
if ($event['adjust'] == 1) {
$UTC = 'Z';
} else {
} else {
$UTC = '';
}
$o .= 'BEGIN:VEVENT' . PHP_EOL;
@ -716,16 +716,16 @@ function event_format_export ($events, $format = 'ical', $timezone) {
/**
* @brief Get all events for a user ID
*
*
* The query for events is done permission sensitive
* If the user is the owner of the calendar he/she
* will get all of his/her available events.
* If the user is only a visitor only the public events will
* be available
*
*
* @param int $uid The user ID
* @param int $sql_extra Additional sql conditions for permission
*
*
* @return array Query results
*/
function events_by_uid($uid = 0, $sql_extra = '') {
@ -736,8 +736,8 @@ function events_by_uid($uid = 0, $sql_extra = '') {
if($sql_extra == '')
$sql_extra = " AND `allow_cid` = '' AND `allow_gid` = '' ";
// does the user who requests happen to be the owner of the events
// requested? then show all of your events, otherwise only those that
// does the user who requests happen to be the owner of the events
// requested? then show all of your events, otherwise only those that
// don't have limitations set in allow_cid and allow_gid
if (local_user() == $uid) {
$r = q("SELECT `start`, `finish`, `adjust`, `summary`, `desc`, `location`, `nofinish`
@ -756,7 +756,7 @@ function events_by_uid($uid = 0, $sql_extra = '') {
}
/**
*
*
* @param int $uid The user ID
* @param string $format Output format (ical/csv)
* @return array With the results
@ -764,7 +764,7 @@ function events_by_uid($uid = 0, $sql_extra = '') {
* string 'format' => The output format
* string 'extension' => The file extension of the output format
* string 'content' => The formatted output content
*
*
* @todo Respect authenticated users with events_by_uid()
*/
function event_export($uid, $format = 'ical') {
@ -815,7 +815,7 @@ function event_export($uid, $format = 'ical') {
/**
* @brief Get the events widget
*
*
* @return string Formated html of the evens widget
*/
function widget_events() {
@ -835,11 +835,11 @@ function widget_events() {
// Cal logged in user (test permission at foreign profile page)
// If the $owner uid is available we know it is part of one of the profile pages (like /cal)
// So we have to test if if it's the own profile page of the logged in user
// So we have to test if if it's the own profile page of the logged in user
// or a foreign one. For foreign profile pages we need to check if the feature
// for exporting the cal is enabled (otherwise the widget would appear for logged in users
// on foreigen profile pages even if the widget is disabled)
if(intval($owner_uid) && local_user() !== $owner_uid && ! feature_enabled($owner_uid, "export_calendar"))
if(intval($owner_uid) && local_user() !== $owner_uid && ! feature_enabled($owner_uid, "export_calendar"))
return;
// If it's a kind of profile page (intval($owner_uid)) return if the user not logged in and


+ 18
- 18
include/identity.php View File

@ -31,7 +31,7 @@ require_once("mod/proxy.php");
* @param int $profile
* @param array $profiledata
*/
function profile_load(&$a, $nickname, $profile = 0, $profiledata = array()) {
function profile_load(App $a, $nickname, $profile = 0, $profiledata = array()) {
$user = q("SELECT `uid` FROM `user` WHERE `nickname` = '%s' LIMIT 1",
dbesc($nickname)
@ -118,12 +118,12 @@ function profile_load(&$a, $nickname, $profile = 0, $profiledata = array()) {
/**
* @brief Get all profil data of a local user
*
*
* If the viewer is an authenticated remote viewer, the profile displayed is the
* one that has been configured for his/her viewing in the Contact manager.
* Passing a non-zero profile ID can also allow a preview of a selected profile
* by the owner
*
*
* @param string $nickname
* @param int $uid
* @param int $profile
@ -177,17 +177,17 @@ function get_profiledata_by_nick($nickname, $uid = 0, $profile = 0) {
/**
* @brief Formats a profile for display in the sidebar.
*
*
* It is very difficult to templatise the HTML completely
* because of all the conditional logic.
*
*
* @param array $profile
* @param int $block
*
*
* @return HTML string stuitable for sidebar inclusion
*
*
* @note Returns empty string if passed $profile is wrong type or not populated
*
*
* @hooks 'profile_sidebar_enter'
* array $profile - profile data
* @hooks 'profile_sidebar'
@ -598,7 +598,7 @@ function get_events() {
));
}
function advanced_profile(App &$a) {
function advanced_profile(App $a) {
$o = '';
$uid = $a->profile['uid'];
@ -755,7 +755,7 @@ function profile_tabs($a, $is_owner=False, $nickname=Null){
array(
'label'=>t('Status'),
'url' => $url,
'sel' => ((!isset($tab)&&$a->argv[0]=='profile')?'active':''),
'sel' => ((!isset($tab) && $a->argv[0]=='profile')?'active':''),
'title' => t('Status Messages and Posts'),
'id' => 'status-tab',
'accesskey' => 'm',
@ -771,7 +771,7 @@ function profile_tabs($a, $is_owner=False, $nickname=Null){
array(
'label' => t('Photos'),
'url' => App::get_baseurl() . '/photos/' . $nickname,
'sel' => ((!isset($tab)&&$a->argv[0]=='photos')?'active':''),
'sel' => ((!isset($tab) && $a->argv[0]=='photos')?'active':''),
'title' => t('Photo Albums'),
'id' => 'photo-tab',
'accesskey' => 'h',
@ -779,7 +779,7 @@ function profile_tabs($a, $is_owner=False, $nickname=Null){
array(
'label' => t('Videos'),
'url' => App::get_baseurl() . '/videos/' . $nickname,
'sel' => ((!isset($tab)&&$a->argv[0]=='videos')?'active':''),
'sel' => ((!isset($tab) && $a->argv[0]=='videos')?'active':''),
'title' => t('Videos'),
'id' => 'video-tab',
'accesskey' => 'v',
@ -791,7 +791,7 @@ function profile_tabs($a, $is_owner=False, $nickname=Null){
$tabs[] = array(
'label' => t('Events'),
'url' => App::get_baseurl() . '/events',
'sel' =>((!isset($tab)&&$a->argv[0]=='events')?'active':''),
'sel' =>((!isset($tab) && $a->argv[0]=='events')?'active':''),
'title' => t('Events and Calendar'),
'id' => 'events-tab',
'accesskey' => 'e',
@ -802,7 +802,7 @@ function profile_tabs($a, $is_owner=False, $nickname=Null){
$tabs[] = array(
'label' => t('Events'),
'url' => App::get_baseurl() . '/cal/' . $nickname,
'sel' =>((!isset($tab)&&$a->argv[0]=='cal')?'active':''),
'sel' =>((!isset($tab) && $a->argv[0]=='cal')?'active':''),
'title' => t('Events and Calendar'),
'id' => 'events-tab',
'accesskey' => 'e',
@ -813,7 +813,7 @@ function profile_tabs($a, $is_owner=False, $nickname=Null){
$tabs[] = array(
'label' => t('Personal Notes'),
'url' => App::get_baseurl() . '/notes',
'sel' =>((!isset($tab)&&$a->argv[0]=='notes')?'active':''),
'sel' =>((!isset($tab) && $a->argv[0]=='notes')?'active':''),
'title' => t('Only You Can See This'),
'id' => 'notes-tab',
'accesskey' => 't',
@ -824,7 +824,7 @@ function profile_tabs($a, $is_owner=False, $nickname=Null){
$tabs[] = array(
'label' => t('Contacts'),
'url' => App::get_baseurl() . '/viewcontacts/' . $nickname,
'sel' => ((!isset($tab)&&$a->argv[0]=='viewcontacts')?'active':''),
'sel' => ((!isset($tab) && $a->argv[0]=='viewcontacts')?'active':''),
'title' => t('Contacts'),
'id' => 'viewcontacts-tab',
'accesskey' => 'k',
@ -845,7 +845,7 @@ function get_my_url() {
return false;
}
function zrl_init(App &$a) {
function zrl_init(App $a) {
$tmp_str = get_my_url();
if(validate_url($tmp_str)) {
@ -891,7 +891,7 @@ function zrl($s,$force = false) {
* settings except their own while on this site.
*
* @return int user ID
*
*
* @note Returns local_user instead of user ID if "always_my_theme"
* is set to true
*/


+ 1
- 1
include/nav.php View File

@ -1,6 +1,6 @@
<?php
function nav(App &$a) {
function nav(App $a) {
/*
*


+ 0
- 1
include/network.php View File

@ -5,7 +5,6 @@
*/
use \Friendica\Core\Config;
use \Friendica\Core\PConfig;
require_once("include/xml.php");
require_once('include/Probe.php');


+ 126
- 107
include/notifier.php View File

@ -43,11 +43,11 @@ require_once('include/salmon.php');
function notifier_run(&$argv, &$argc){
global $a, $db;
if(is_null($a)){
if (is_null($a)) {
$a = new App;
}
if(is_null($db)) {
if (is_null($db)) {
@include(".htconfig.php");
require_once("include/dba.php");
$db = new dba($db_host, $db_user, $db_pass, $db_data);
@ -64,8 +64,9 @@ function notifier_run(&$argv, &$argc){
load_hooks();
if($argc < 3)
if ($argc < 3) {
return;
}
$a->set_baseurl(get_config('system','url'));
@ -77,7 +78,7 @@ function notifier_run(&$argv, &$argc){
case 'mail':
default:
$item_id = intval($argv[2]);
if(! $item_id){
if (! $item_id) {
return;
}
break;
@ -93,21 +94,20 @@ function notifier_run(&$argv, &$argc){
$normal_mode = true;
if($cmd === 'mail') {
if ($cmd === 'mail') {
$normal_mode = false;
$mail = true;
$message = q("SELECT * FROM `mail` WHERE `id` = %d LIMIT 1",
intval($item_id)
);
if(! count($message)){
if (! count($message)) {
return;
}
$uid = $message[0]['uid'];
$recipients[] = $message[0]['contact-id'];
$item = $message[0];
}
elseif($cmd === 'expire') {
} elseif ($cmd === 'expire') {
$normal_mode = false;
$expire = true;
$items = q("SELECT * FROM `item` WHERE `uid` = %d AND `wall` = 1
@ -116,22 +116,23 @@ function notifier_run(&$argv, &$argc){
);
$uid = $item_id;
$item_id = 0;
if(! count($items))
if (! count($items)) {
return;
}
elseif($cmd === 'suggest') {
}
} elseif ($cmd === 'suggest') {
$normal_mode = false;
$fsuggest = true;
$suggest = q("SELECT * FROM `fsuggest` WHERE `id` = %d LIMIT 1",
intval($item_id)
);
if(! count($suggest))
if (! count($suggest)) {
return;
}
$uid = $suggest[0]['uid'];
$recipients[] = $suggest[0]['cid'];
$item = $suggest[0];
} elseif($cmd === 'removeme') {
} elseif ($cmd === 'removeme') {
$r = q("SELECT `contact`.*, `user`.`pubkey` AS `upubkey`, `user`.`prvkey` AS `uprvkey`,
`user`.`timezone`, `user`.`nickname`, `user`.`sprvkey`, `user`.`spubkey`,
`user`.`page-flags`, `user`.`prvnets`, `user`.`account-type`, `user`.`guid`
@ -150,15 +151,15 @@ function notifier_run(&$argv, &$argc){
$self = $r[0];
$r = q("SELECT * FROM `contact` WHERE NOT `self` AND `uid` = %d", intval($item_id));
if(!$r)
if (!$r) {
return;
}
require_once('include/Contact.php');
foreach($r as $contact) {
foreach ($r as $contact) {
terminate_friendship($user, $self, $contact);
}
return;
} elseif($cmd === 'relocate') {
} elseif ($cmd === 'relocate') {
$normal_mode = false;
$relocate = true;
$uid = $item_id;
@ -170,7 +171,7 @@ function notifier_run(&$argv, &$argc){
intval($item_id)
);
if((! dbm::is_result($r)) || (! intval($r[0]['parent']))) {
if ((! dbm::is_result($r)) || (! intval($r[0]['parent']))) {
return;
}
@ -184,18 +185,19 @@ function notifier_run(&$argv, &$argc){
intval($parent_id)
);
if(! count($items)) {
if (! count($items)) {
return;
}
// avoid race condition with deleting entries
if($items[0]['deleted']) {
foreach($items as $item)
if ($items[0]['deleted']) {
foreach ($items as $item) {
$item['deleted'] = 1;
}
}
if((count($items) == 1) && ($items[0]['id'] === $target_item['id']) && ($items[0]['uri'] === $items[0]['parent-uri'])) {
if ((count($items) == 1) && ($items[0]['id'] === $target_item['id']) && ($items[0]['uri'] === $items[0]['parent-uri'])) {
logger('notifier: top level post');
$top_level = true;
}
@ -220,6 +222,9 @@ function notifier_run(&$argv, &$argc){
$hub = get_config('system','huburl');
// Should the post be transmitted to Diaspora?
$diaspora_delivery = true;
// If this is a public conversation, notify the feed hub
$public_message = true;