Merge remote-tracking branch 'refs/remotes/friendica/develop' into develop

This commit is contained in:
Hypolite Petovan 2017-02-17 20:44:57 -05:00
commit e61301a403
16 changed files with 218 additions and 134 deletions

View File

@ -430,6 +430,17 @@ define('PRIORITY_LOW', 40);
define('PRIORITY_NEGLIGIBLE',50);
/* @}*/
/**
* @name Social Relay settings
*
* See here: https://github.com/jaywink/social-relay
* and here: https://wiki.diasporafoundation.org/Relay_servers_for_public_posts
* @{
*/
define('SR_SCOPE_NONE', '');
define('SR_SCOPE_ALL', 'all');
define('SR_SCOPE_TAGS', 'tags');
/* @}*/
// Normally this constant is defined - but not if "pcntl" isn't installed
if (!defined("SIGTERM"))
@ -1404,6 +1415,53 @@ class App {
proc_close(proc_open($cmdline." &",array(),$foo,dirname(__FILE__)));
}
/**
* @brief Returns the system user that is executing the script
*
* This mostly returns something like "www-data".
*
* @return string system username
*/
static function systemuser() {
if (!function_exists('posix_getpwuid') OR !function_exists('posix_geteuid')) {
return '';
}
$processUser = posix_getpwuid(posix_geteuid());
return $processUser['name'];
}
/**
* @brief Checks if a given directory is usable for the system
*
* @return boolean the directory is usable
*/
static function directory_usable($directory) {
if ($directory == '') {
logger("Directory is empty. This shouldn't happen.", LOGGER_DEBUG);
return false;
}
if (!file_exists($directory)) {
logger('Path "'.$directory.'" does not exist for user '.self::systemuser(), LOGGER_DEBUG);
return false;
}
if (is_file($directory)) {
logger('Path "'.$directory.'" is a file for user '.self::systemuser(), LOGGER_DEBUG);
return false;
}
if (!is_dir($directory)) {
logger('Path "'.$directory.'" is not a directory for user '.self::systemuser(), LOGGER_DEBUG);
return false;
}
if (!is_writable($directory)) {
logger('Path "'.$temppath.'" is not writable for user '.self::systemuser(), LOGGER_DEBUG);
return false;
}
return true;
}
}
/**
@ -2308,8 +2366,9 @@ function get_itemcachepath() {
return "";
$itemcache = get_config('system','itemcache');
if (($itemcache != "") AND is_dir($itemcache) AND is_writable($itemcache))
if (($itemcache != "") AND App::directory_usable($itemcache)) {
return($itemcache);
}
$temppath = get_temppath();
@ -2319,7 +2378,7 @@ function get_itemcachepath() {
mkdir($itemcache);
}
if (is_dir($itemcache) AND is_writable($itemcache)) {
if (App::directory_usable($itemcache)) {
set_config("system", "itemcache", $itemcache);
return($itemcache);
}
@ -2329,20 +2388,22 @@ function get_itemcachepath() {
function get_lockpath() {
$lockpath = get_config('system','lockpath');
if (($lockpath != "") AND is_dir($lockpath) AND is_writable($lockpath))
if (($lockpath != "") AND App::directory_usable($lockpath)) {
return($lockpath);
}
$temppath = get_temppath();
if ($temppath != "") {
$lockpath = $temppath."/lock";
if (!is_dir($lockpath))
if (!is_dir($lockpath)) {
mkdir($lockpath);
elseif (!is_writable($lockpath))
} elseif (!App::directory_usable($lockpath)) {
$lockpath = $temppath;
}
if (is_dir($lockpath) AND is_writable($lockpath)) {
if (App::directory_usable($lockpath)) {
set_config("system", "lockpath", $lockpath);
return($lockpath);
}
@ -2357,7 +2418,7 @@ function get_lockpath() {
*/
function get_spoolpath() {
$spoolpath = get_config('system','spoolpath');
if (($spoolpath != "") AND is_dir($spoolpath) AND is_writable($spoolpath)) {
if (($spoolpath != "") AND App::directory_usable($spoolpath)) {
return($spoolpath);
}
@ -2368,11 +2429,11 @@ function get_spoolpath() {
if (!is_dir($spoolpath)) {
mkdir($spoolpath);
} elseif (!is_writable($spoolpath)) {
} elseif (!App::directory_usable($spoolpath)) {
$spoolpath = $temppath;
}
if (is_dir($spoolpath) AND is_writable($spoolpath)) {
if (App::directory_usable($spoolpath)) {
set_config("system", "spoolpath", $spoolpath);
return($spoolpath);
}
@ -2384,16 +2445,18 @@ function get_temppath() {
$a = get_app();
$temppath = get_config("system","temppath");
if (($temppath != "") AND is_dir($temppath) AND is_writable($temppath))
if (($temppath != "") AND App::directory_usable($temppath)) {
return($temppath);
}
$temppath = sys_get_temp_dir();
if (($temppath != "") AND is_dir($temppath) AND is_writable($temppath)) {
if (($temppath != "") AND App::directory_usable($temppath)) {
$temppath .= "/".$a->get_hostname();
if (!is_dir($temppath))
mkdir($temppath);
if (is_dir($temppath) AND is_writable($temppath)) {
if (App::directory_usable($temppath)) {
set_config("system", "temppath", $temppath);
return($temppath);
}

View File

@ -730,6 +730,10 @@ function posts_from_contact_url(App $a, $contact_url) {
$sql = "`item`.`uid` = %d";
}
if (!dbm::is_result($r)) {
return '';
}
$author_id = intval($r[0]["author-id"]);
if (get_config('system', 'old_pager')) {

View File

@ -626,7 +626,7 @@ use \Friendica\Core\Config;
// count friends
$r = q("SELECT count(*) as `count` FROM `contact`
WHERE `uid` = %d AND `rel` IN ( %d, %d )
AND `self`=0 AND NOT `blocked` AND `hidden`=0",
AND `self`=0 AND NOT `blocked` AND NOT `pending` AND `hidden`=0",
intval($uinfo[0]['uid']),
intval(CONTACT_IS_SHARING),
intval(CONTACT_IS_FRIEND)
@ -635,7 +635,7 @@ use \Friendica\Core\Config;
$r = q("SELECT count(*) as `count` FROM `contact`
WHERE `uid` = %d AND `rel` IN ( %d, %d )
AND `self`=0 AND NOT `blocked` AND `hidden`=0",
AND `self`=0 AND NOT `blocked` AND NOT `pending` AND `hidden`=0",
intval($uinfo[0]['uid']),
intval(CONTACT_IS_FOLLOWER),
intval(CONTACT_IS_FRIEND)

View File

@ -8,6 +8,8 @@
* This will change in the future.
*/
use \Friendica\Core\Config;
require_once("include/items.php");
require_once("include/bb2diaspora.php");
require_once("include/Scrape.php");
@ -309,10 +311,6 @@ class Diaspora {
return false;
}
// Use a dummy importer to import the data for the public copy
$importer = array("uid" => 0, "page-flags" => PAGE_FREELOVE);
$message_id = self::dispatch($importer,$msg);
// Now distribute it to the followers
$r = q("SELECT `user`.* FROM `user` WHERE `user`.`uid` IN
(SELECT `contact`.`uid` FROM `contact` WHERE `contact`.`network` = '%s' AND `contact`.`addr` = '%s')
@ -320,13 +318,22 @@ class Diaspora {
dbesc(NETWORK_DIASPORA),
dbesc($msg["author"])
);
if ($r) {
if (dbm::is_result($r)) {
foreach ($r as $rr) {
logger("delivering to: ".$rr["username"]);
self::dispatch($rr,$msg);
}
} else {
logger("No subscribers for ".$msg["author"]." ".print_r($msg, true), LOGGER_DEBUG);
$social_relay = (bool)Config::get('system', 'relay_subscribe', false);
// Use a dummy importer to import the data for the public copy
if ($social_relay) {
$importer = array("uid" => 0, "page-flags" => PAGE_FREELOVE);
$message_id = self::dispatch($importer,$msg);
} else {
logger("Unwanted message from ".$msg["author"]." send by ".$_SERVER["REMOTE_ADDR"]." with ".$_SERVER["HTTP_USER_AGENT"].": ".print_r($msg, true), LOGGER_DEBUG);
}
}
return $message_id;

View File

@ -374,7 +374,10 @@ function profile_sidebar($profile, $block = 0) {
if (dbm::is_result($r))
$updated = date("c", strtotime($r[0]['updated']));
$r = q("SELECT COUNT(*) AS `total` FROM `contact` WHERE `uid` = %d AND NOT `self` AND NOT `blocked` AND NOT `hidden` AND NOT `archive`
$r = q("SELECT COUNT(*) AS `total` FROM `contact`
WHERE `uid` = %d
AND NOT `self` AND NOT `blocked` AND NOT `pending`
AND NOT `hidden` AND NOT `archive`
AND `network` IN ('%s', '%s', '%s', '')",
intval($profile['uid']),
dbesc(NETWORK_DFRN),

View File

@ -35,7 +35,19 @@ function spool_post_run($argv, $argc) {
continue;
}
$arr = json_decode(file_get_contents($fullfile), true);
// If it isn't an array then it is no spool file
if (!is_array($arr)) {
continue;
}
// Skip if it doesn't seem to be an item array
if (!isset($arr['uid']) AND !isset($arr['uri']) AND !isset($arr['network'])) {
continue;
}
$result = item_store($arr);
logger("Spool file ".$file." stored: ".$result, LOGGER_DEBUG);
unlink($fullfile);
}

View File

@ -875,7 +875,7 @@ function contact_block() {
return $o;
$r = q("SELECT COUNT(*) AS `total` FROM `contact`
WHERE `uid` = %d AND NOT `self` AND NOT `blocked`
AND NOT `hidden` AND NOT `archive`
AND NOT `pending` AND NOT `hidden` AND NOT `archive`
AND `network` IN ('%s', '%s', '%s')",
intval($a->profile['uid']),
dbesc(NETWORK_DFRN),
@ -893,8 +893,9 @@ function contact_block() {
// Splitting the query in two parts makes it much faster
$r = q("SELECT `id` FROM `contact`
WHERE `uid` = %d AND NOT `self` AND NOT `blocked`
AND NOT `hidden` AND NOT `archive`
AND `network` IN ('%s', '%s', '%s') ORDER BY RAND() LIMIT %d",
AND NOT `pending` AND NOT `hidden` AND NOT `archive`
AND `network` IN ('%s', '%s', '%s')
ORDER BY RAND() LIMIT %d",
intval($a->profile['uid']),
dbesc(NETWORK_DFRN),
dbesc(NETWORK_OSTATUS),

View File

@ -1,5 +1,7 @@
<?php
/// @TODO This file has DOS line endings!
use \Friendica\Core\Config;
require_once("mod/hostxrd.php");
require_once("mod/nodeinfo.php");
@ -23,27 +25,25 @@ function _well_known_init(App $a) {
function wk_social_relay(App $a) {
define('SR_SCOPE_ALL', 'all');
define('SR_SCOPE_TAGS', 'tags');
$subscribe = (bool)Config::get('system', 'relay_subscribe', false);
$subscribe = (bool)get_config('system', 'relay_subscribe');
if ($subscribe)
$scope = get_config('system', 'relay_scope');
else
$scope = "";
if ($subscribe) {
$scope = Config::get('system', 'relay_scope', SR_SCOPE_ALL);
} else {
$scope = SR_SCOPE_NONE;
}
$tags = array();
if ($scope == SR_SCOPE_TAGS) {
$server_tags = get_config('system', 'relay_server_tags');
$server_tags = Config::get('system', 'relay_server_tags');
$tagitems = explode(",", $server_tags);
foreach($tagitems AS $tag)
foreach($tagitems AS $tag) {
$tags[trim($tag, "# ")] = trim($tag, "# ");
}
if (get_config('system', 'relay_user_tags')) {
if (Config::get('system', 'relay_user_tags')) {
$terms = q("SELECT DISTINCT(`term`) FROM `search`");
foreach($terms AS $term) {
@ -54,8 +54,9 @@ function wk_social_relay(App $a) {
}
$taglist = array();
foreach($tags AS $tag)
foreach($tags AS $tag) {
$taglist[] = $tag;
}
$relay = array("subscribe" => $subscribe,
"scope" => $scope,

View File

@ -48,7 +48,8 @@ function viewcontacts_content(App $a) {
}
$r = q("SELECT COUNT(*) AS `total` FROM `contact`
WHERE `uid` = %d AND (NOT `blocked` OR `pending`) AND NOT `hidden` AND NOT `archive`
WHERE `uid` = %d AND NOT `blocked` AND NOT `pending`
AND NOT `hidden` AND NOT `archive`
AND `network` IN ('%s', '%s', '%s')",
intval($a->profile['uid']),
dbesc(NETWORK_DFRN),
@ -59,7 +60,8 @@ function viewcontacts_content(App $a) {
$a->set_pager_total($r[0]['total']);
$r = q("SELECT * FROM `contact`
WHERE `uid` = %d AND (NOT `blocked` OR `pending`) AND NOT `hidden` AND NOT `archive`
WHERE `uid` = %d AND NOT `blocked` AND NOT `pending`
AND NOT `hidden` AND NOT `archive`
AND `network` IN ('%s', '%s', '%s')
ORDER BY `name` ASC LIMIT %d, %d",
intval($a->profile['uid']),

View File

@ -3,14 +3,15 @@
# This file is distributed under the same license as the Friendica package.
#
# Translators:
# Jonatan Nyberg <jonatan@autistici.org>, 2017
# Mike Macgirvin, 2010
msgid ""
msgstr ""
"Project-Id-Version: friendica\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-12-19 07:46+0100\n"
"PO-Revision-Date: 2016-12-19 10:01+0000\n"
"Last-Translator: fabrixxm <fabrix.xm@gmail.com>\n"
"PO-Revision-Date: 2017-02-13 20:15+0000\n"
"Last-Translator: Jonatan Nyberg <jonatan@autistici.org>\n"
"Language-Team: Swedish (http://www.transifex.com/Friendica/friendica/language/sv/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
@ -20,7 +21,7 @@ msgstr ""
#: include/contact_widgets.php:6
msgid "Add New Contact"
msgstr ""
msgstr "Lägg till kontakt"
#: include/contact_widgets.php:7
msgid "Enter address or web location"

View File

@ -5,7 +5,7 @@ function string_plural_select_sv($n){
return ($n != 1);;
}}
;
$a->strings["Add New Contact"] = "";
$a->strings["Add New Contact"] = "Lägg till kontakt";
$a->strings["Enter address or web location"] = "";
$a->strings["Example: bob@example.com, http://example.com/barbara"] = "Exempel: adam@exempel.com, http://exempel.com/bertil";
$a->strings["Connect"] = "Skicka kontaktf&ouml;rfr&aring;gan";

View File

@ -256,40 +256,30 @@ $(document).ready(function(){
input.val(val);
});
// Set the padding for input elements with inline buttons
//
// In Frio we use some input elements where the submit button is visually
// inside the the input field (through css). We need to set a padding-right
// to the input element where the padding value would be at least the width
// of the button. Otherwise long user input would be invisible because it is
// behind the button.
$("body").on('click', '.form-group-search > input', function() {
// Get the width of the button (if the button isn't available
// buttonWidth will be null
var buttonWidth = $(this).next('.form-button-search').outerWidth();
if (buttonWidth) {
// Take the width of the button and ad 5px
var newWidth = buttonWidth + 5;
// Set the padding of the input element according
// to the width of the button
$(this).css('padding-right', newWidth);
}
});
});
//function commentOpenUI(obj, id) {
// $(document).unbind( "click.commentOpen", handler );
//
// var handler = function() {
// if(obj.value == '{{$comment}}') {
// obj.value = '';
// $("#comment-edit-text-" + id).addClass("comment-edit-text-full").removeClass("comment-edit-text-empty");
// // Choose an arbitrary tab index that's greater than what we're using in jot (3 of them)
// // The submit button gets tabindex + 1
// $("#comment-edit-text-" + id).attr('tabindex','9');
// $("#comment-edit-submit-" + id).attr('tabindex','10');
// $("#comment-edit-submit-wrapper-" + id).show();
// }
// };
//
// $(document).bind( "click.commentOpen", handler );
//}
//
//function commentCloseUI(obj, id) {
// $(document).unbind( "click.commentClose", handler );
//
// var handler = function() {
// if(obj.value === '') {
// obj.value = '{{$comment}}';
// $("#comment-edit-text-" + id).removeClass("comment-edit-text-full").addClass("comment-edit-text-empty");
// $("#comment-edit-text-" + id).removeAttr('tabindex');
// $("#comment-edit-submit-" + id).removeAttr('tabindex');
// $("#comment-edit-submit-wrapper-" + id).hide();
// }
// };
//
// $(document).bind( "click.commentClose", handler );
//}
function openClose(theID) {
var elem = document.getElementById(theID);

View File

@ -1210,7 +1210,7 @@ section {
.wall-item-container .wall-item-actions-social a {
margin-right: 3em;
}
.wall-item-container .wall-item-actions-social a .active {
.wall-item-container .wall-item-actions-social a.active {
font-weight: bold;
}
.wall-item-container .wall-item-actions-tools {

View File

@ -1210,7 +1210,7 @@ section {
.wall-item-container .wall-item-actions-social a {
margin-right: 3em;
}
.wall-item-container .wall-item-actions-social a .active {
.wall-item-container .wall-item-actions-social a.active {
font-weight: bold;
}
.wall-item-container .wall-item-actions-tools {

View File

@ -1210,7 +1210,7 @@ section {
.wall-item-container .wall-item-actions-social a {
margin-right: 3em;
}
.wall-item-container .wall-item-actions-social a .active {
.wall-item-container .wall-item-actions-social a.active {
font-weight: bold;
}
.wall-item-container .wall-item-actions-tools {

View File

@ -576,7 +576,7 @@ section {
}
.wall-item-actions-social { float: left; margin-top: 0.5em;
a { margin-right: 3em;
.active { font-weight: bold;}
&.active { font-weight: bold;}
}
}
.wall-item-actions-tools { float: right; width: 15%;