Merge remote-tracking branch 'upstream/develop' into comment-public

This commit is contained in:
Michael 2017-12-26 23:59:32 +00:00
commit d707c5afcd
10 changed files with 844 additions and 1902 deletions

View File

@ -37,7 +37,6 @@ require_once 'include/datetime.php';
require_once 'include/pgettext.php';
require_once 'include/nav.php';
require_once 'include/identity.php';
require_once 'update.php';
define('FRIENDICA_PLATFORM', 'Friendica');
define('FRIENDICA_CODENAME', 'Asparagus');
@ -619,10 +618,17 @@ function is_ajax()
function check_db($via_worker)
{
$build = Config::get('system', 'build');
if (!x($build)) {
if (empty($build)) {
Config::set('system', 'build', DB_UPDATE_VERSION);
$build = DB_UPDATE_VERSION;
}
// We don't support upgrading from very old versions anymore
if ($build < NEW_UPDATE_ROUTINE_VERSION) {
die('You try to update from a version prior to database version 1170. The direct upgrade path is not supported. Please update to version 3.5.4 before updating to this version.');
}
if ($build != DB_UPDATE_VERSION) {
// When we cannot execute the database update via the worker, we will do it directly
if (!Worker::add(PRIORITY_CRITICAL, 'DBUpdate') && $via_worker) {
@ -647,7 +653,7 @@ function check_url(App $a)
// and www.example.com vs example.com.
// We will only change the url to an ip address if there is no existing setting
if (!x($url)) {
if (empty($url)) {
$url = Config::set('system', 'url', System::baseUrl());
}
if ((!link_compare($url, System::baseUrl())) && (!preg_match("/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/", $a->get_hostname))) {
@ -664,25 +670,21 @@ function check_url(App $a)
function update_db(App $a)
{
$build = Config::get('system', 'build');
if (!x($build)) {
$build = Config::set('system', 'build', DB_UPDATE_VERSION);
if (empty($build)) {
Config::set('system', 'build', DB_UPDATE_VERSION);
$build = DB_UPDATE_VERSION;
}
if ($build != DB_UPDATE_VERSION) {
require_once 'update.php';
$stored = intval($build);
$current = intval(DB_UPDATE_VERSION);
if ($stored < $current) {
Config::load('database');
// We're reporting a different version than what is currently installed.
// Run any existing update scripts to bring the database up to current.
// make sure that boot.php and update.php are the same release, we might be
// updating right this very second and the correct version of the update.php
// file may not be here yet. This can happen on a very busy site.
if (DB_UPDATE_VERSION == UPDATE_VERSION) {
// Compare the current structure with the defined structure
$t = Config::get('database', 'dbupdate_' . DB_UPDATE_VERSION);
if (!is_null($t)) {
return;
@ -690,19 +692,7 @@ function update_db(App $a)
Config::set('database', 'dbupdate_' . DB_UPDATE_VERSION, time());
// run old update routine (wich could modify the schema and
// conflits with new routine)
for ($x = $stored; $x < NEW_UPDATE_ROUTINE_VERSION; $x++) {
$r = run_update_function($x);
if (!$r) {
break;
}
}
if ($stored < NEW_UPDATE_ROUTINE_VERSION) {
$stored = NEW_UPDATE_ROUTINE_VERSION;
}
// run new update routine
// run update routine
// it update the structure in one call
$retval = DBStructure::update(false, true);
if ($retval) {
@ -716,7 +706,7 @@ function update_db(App $a)
}
// run any left update_nnnn functions in update.php
for ($x = $stored; $x < $current; $x ++) {
for ($x = $stored + 1; $x <= $current; $x++) {
$r = run_update_function($x);
if (!$r) {
break;
@ -724,7 +714,6 @@ function update_db(App $a)
}
}
}
}
return;
}
@ -996,7 +985,7 @@ function remote_user()
if (local_user()) {
return false;
}
if ((x($_SESSION, 'authenticated')) && (x($_SESSION, 'visitor_id'))) {
if (x($_SESSION, 'authenticated') && x($_SESSION, 'visitor_id')) {
return intval($_SESSION['visitor_id']);
}
return false;
@ -1051,7 +1040,7 @@ function info($s)
function get_max_import_size()
{
$a = get_app();
return ((x($a->config, 'max_import_size')) ? $a->config['max_import_size'] : 0 );
return (x($a->config, 'max_import_size') ? $a->config['max_import_size'] : 0);
}

View File

@ -1,5 +1,6 @@
Where to get started to help improve Friendica?
===============================================
# Where to get started to help improve Friendica
<!-- markdownlint-disable MD010 MD013 -->
* [Home](help)
@ -10,29 +11,25 @@ A project like Friendica is the sum of many different contributions.
We are looking for helpers in all areas, whether you write text or code, whether you spread the word to convince people or design new icons.
Whether you feel like an expert or like a newbie - join us with your ideas!
Contact us
---
## Contact us
The discussion of Friendica development takes place in the following Friendica forums:
* The main [forum for Friendica development](https://forum.friendi.ca/profile/developers)
* The [forum for Friendica theme development](https://friendica.eu/profile/ftdevs)
Help other users
---
## Help other users
Remember the questions you had when you first tried Friendica?
A good place to start can be to help new people find their way around Friendica in the [general support forum](https://forum.friendi.ca/prufile/helpers).
Welcome them, answer their questions, point them to documentation or ping other helpers directly if you can't help but think you know who can.
Translation
---
## Translation
The documentation contains help on how to translate Friendica [at Transifex](/help/translations) where the UI is translated.
If you don't want to translate the UI, or it is already done to your satisfaction, you might want to work on the translation of the /help files?
Design
---
## Design
Are you good at designing things?
If you have seen Friendica you probably have ideas to improve it, haven't you?
@ -43,8 +40,7 @@ If you have seen Friendica you probably have ideas to improve it, haven't you?
We can't promise we have the right skills in the group but we'll try.
* Choose a thing to start with, e.g. work on the icon set of your favorite theme
Programming
---
## Programming
### Composer
@ -60,6 +56,7 @@ It's a command-line tool that downloads required libraries into the `vendor` fol
For the sake of consistency between contribution and general code readability, Friendica follows the widespread [PSR-2 coding standards](http://www.php-fig.org/psr/psr-2/) to the exception of a few rules.
Here's a few primers if you are new to Friendica or to the PSR-2 coding standards:
* Indentation is tabs, period (not PSR-2).
* By default, strings are enclosed in single quotes, but feel free to use double quotes if it makes more sense (SQL queries, adding tabs and line feeds).
* Operators are wrapped by spaces, e.g. `$var === true`, `$var = 1 + 2` and `'string' . $concat . 'enation'`

View File

@ -615,6 +615,12 @@ This is an alias for `search`.
---
### saved_searches/list (*; AUTH)
This call does not have any parameter.
---
### users/search (*)
#### Parameters
@ -686,6 +692,23 @@ On error:
---
### account/update_profile (POST; AUTH)
#### Parameters
* name (optional): full name of the user
* description (optional): a description of the user
#### Unsupported parameters
* url
* location
* profile_link_color
* include_entities
* skip_status
---
### friendships/incoming (*; AUTH)
#### Unsupported parameters
@ -1199,8 +1222,6 @@ The following API calls from the Twitter API are not implemented in either Frien
* friendships/lookup
* account/settings
* account/update_delivery_device
* account/update_profile
* account/update_profile_background_image
* blocks/ids
* users/show
* users/search
@ -1234,7 +1255,6 @@ The following API calls from the Twitter API are not implemented in either Frien
* lists/subscriptions
* lists/members/destroy_all
* lists/ownerships
* saved_searches/list
* saved_searches/show/:id
* saved_searches/create
* saved_searches/destroy/:id

File diff suppressed because it is too large Load Diff

View File

@ -13,6 +13,7 @@ use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Protocol\Diaspora;
require_once 'include/bbcode.php';
require_once 'mod/proxy.php';
@ -374,9 +375,9 @@ function profile_sidebar($profile, $block = 0)
$location = $pdesc = $gender = $marital = $homepage = $about = false;
}
$firstname = ((strpos($profile['name'], ' '))
? trim(substr($profile['name'], 0, strpos($profile['name'], ' '))) : $profile['name']);
$lastname = (($firstname === $profile['name']) ? '' : trim(substr($profile['name'], strlen($firstname))));
$split_name = Diaspora::splitName($profile['name']);
$firstname = $split_name['first'];
$lastname = $split_name['last'];
if ($profile['guid'] != "") {
$diaspora = array(

View File

@ -534,7 +534,7 @@ function admin_page_federation(App $a)
// off one % two of them are needed in the query
// Add more platforms if you like, when one returns 0 known nodes it is not
// displayed on the stats page.
$platforms = array('Friendi%%a', 'Diaspora', '%%red%%', 'Hubzilla', 'BlaBlaNet', 'GNU Social', 'StatusNet', 'Mastodon', 'Pleroma');
$platforms = array('Friendi%%a', 'Diaspora', '%%red%%', 'Hubzilla', 'BlaBlaNet', 'GNU Social', 'StatusNet', 'Mastodon', 'Pleroma', 'socialhome');
$colors = array(
'Friendi%%a' => '#ffc018', // orange from the logo
'Diaspora' => '#a1a1a1', // logo is black and white, makes a gray
@ -544,7 +544,8 @@ function admin_page_federation(App $a)
'GNU Social' => '#a22430', // dark red from the logo
'StatusNet' => '#789240', // the green from the logo (red and blue have already others
'Mastodon' => '#1a9df9', // blue from the Mastodon logo
'Pleroma' => '#E46F0F' // Orange from the text that is used on Pleroma instances
'Pleroma' => '#E46F0F', // Orange from the text that is used on Pleroma instances
'socialhome' => '#52056b' // lilac from the Django Image used at the Socialhome homepage
);
$counts = array();
$total = 0;

View File

@ -3963,6 +3963,62 @@ class Diaspora
return self::buildAndTransmit($owner, $contact, $type, $message, false, $item["guid"]);
}
/**
* @brief Split a name into first name and last name
*
* @param string $name The name
*
* @return array The array with "first" and "last"
*/
public static function splitName($name) {
$name = trim($name);
// Is the name longer than 64 characters? Then cut the rest of it.
if (strlen($name) > 64) {
if ((strpos($name, ' ') <= 64) && (strpos($name, ' ') !== false)) {
$name = trim(substr($name, 0, strrpos(substr($name, 0, 65), ' ')));
} else {
$name = substr($name, 0, 64);
}
}
// Take the first word as first name
$first = ((strpos($name, ' ') ? trim(substr($name, 0, strpos($name, ' '))) : $name));
$last = (($first === $name) ? '' : trim(substr($name, strlen($first))));
if ((strlen($first) < 32) && (strlen($last) < 32)) {
return ['first' => $first, 'last' => $last];
}
// Take the last word as last name
$first = ((strrpos($name, ' ') ? trim(substr($name, 0, strrpos($name, ' '))) : $name));
$last = (($first === $name) ? '' : trim(substr($name, strlen($first))));
if ((strlen($first) < 32) && (strlen($last) < 32)) {
return ['first' => $first, 'last' => $last];
}
// Take the first 32 characters if there is no space in the first 32 characters
if ((strpos($name, ' ') > 32) || (strpos($name, ' ') === false)) {
$first = substr($name, 0, 32);
$last = substr($name, 32);
return ['first' => $first, 'last' => $last];
}
$first = trim(substr($name, 0, strrpos(substr($name, 0, 33), ' ')));
$last = (($first === $name) ? '' : trim(substr($name, strlen($first))));
// Check if the last name is longer than 32 characters
if (strlen($last) > 32) {
if (strpos($last, ' ') <= 32) {
$last = trim(substr($last, 0, strrpos(substr($last, 0, 33), ' ')));
} else {
$last = substr($last, 0, 32);
}
}
return ['first' => $first, 'last' => $last];
}
/**
* @brief Create profile data
*
@ -3986,11 +4042,12 @@ class Diaspora
}
$profile = $r[0];
$handle = $profile["addr"];
$first = ((strpos($profile['name'], ' ')
? trim(substr($profile['name'], 0, strpos($profile['name'], ' '))) : $profile['name']));
$last = (($first === $profile['name']) ? '' : trim(substr($profile['name'], strlen($first))));
$split_name = self::splitName($profile['name']);
$first = $split_name['first'];
$last = $split_name['last'];
$large = System::baseUrl().'/photo/custom/300/'.$profile['uid'].'.jpg';
$medium = System::baseUrl().'/photo/custom/100/'.$profile['uid'].'.jpg';
$small = System::baseUrl().'/photo/custom/50/' .$profile['uid'].'.jpg';

View File

@ -575,7 +575,7 @@ class PortableContact
return true;
}
public static function toBoolean($val)
private static function toBoolean($val)
{
if (($val == "true") || ($val == 1)) {
return true;
@ -592,7 +592,7 @@ class PortableContact
* @param object $data POCO data
* @return array Server data
*/
public static function detectPocoData($data)
private static function detectPocoData($data)
{
$server = false;
@ -629,7 +629,7 @@ class PortableContact
* @param string $server_url address of the server
* @return array Server data
*/
public static function fetchNodeinfo($server_url)
private static function fetchNodeinfo($server_url)
{
$serverret = z_fetch_url($server_url."/.well-known/nodeinfo");
if (!$serverret["success"]) {
@ -746,7 +746,7 @@ class PortableContact
* @param string $body Front page of the server
* @return array Server data
*/
public static function detectServerType($body)
private static function detectServerType($body)
{
$server = false;
@ -1292,7 +1292,7 @@ class PortableContact
*
* @param string $poco URL to the POCO endpoint
*/
public static function fetchServerlist($poco)
private static function fetchServerlist($poco)
{
$serverret = z_fetch_url($poco."/@server");
if (!$serverret["success"]) {
@ -1315,7 +1315,7 @@ class PortableContact
}
}
public static function discoverFederation()
private static function discoverFederation()
{
$last = Config::get('poco', 'last_federation_discovery');
@ -1470,7 +1470,7 @@ class PortableContact
}
}
public static function discoverServerUsers($data, $server)
private static function discoverServerUsers($data, $server)
{
if (!isset($data->entry)) {
return;
@ -1501,7 +1501,7 @@ class PortableContact
}
}
public static function discoverServer($data, $default_generation = 0)
private static function discoverServer($data, $default_generation = 0)
{
if (!isset($data->entry) || !count($data->entry)) {
return false;

View File

@ -310,6 +310,7 @@ class ExAuth
$lockpath = Config::get('jabber', 'lockpath');
if (is_null($lockpath)) {
$this->writeLog(LOG_INFO, 'No lockpath defined.');
return;
}
@ -325,6 +326,9 @@ class ExAuth
// Now it is safe to create the pid file
PidFile::create($file);
if (!file_exists($file)) {
$this->writeLog(LOG_WARNING, 'Logfile ' . $file . " couldn't be created.");
}
}
/**

1621
update.php

File diff suppressed because it is too large Load Diff