aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2012-07-16 03:53:11 -0700
committerfriendica <info@friendica.com>2012-07-16 03:53:11 -0700
commit5902e0983d8a17e34674855bee36b75a82bff8cb (patch)
treef7a1e76e36e55e950222d7ab02e8700f9c40e885
parenta047c5b1c38e601df051b1c6b0165f94d7d265ba (diff)
downloadvolse-hubzilla-5902e0983d8a17e34674855bee36b75a82bff8cb.tar.gz
volse-hubzilla-5902e0983d8a17e34674855bee36b75a82bff8cb.tar.bz2
volse-hubzilla-5902e0983d8a17e34674855bee36b75a82bff8cb.zip
language filtering infrastructure, check owner's language prefs and either translate it or dump it depending on those prefs and the availability of translation plugins.
-rwxr-xr-xinclude/items.php13
-rw-r--r--mod/item.php20
2 files changed, 28 insertions, 5 deletions
diff --git a/include/items.php b/include/items.php
index 6285e5da5..b66a325a5 100755
--- a/include/items.php
+++ b/include/items.php
@@ -828,10 +828,6 @@ function item_store($arr,$force_parent = false) {
if(! x($arr,'type'))
$arr['type'] = 'remote';
- // Shouldn't happen but we want to make absolutely sure it doesn't leak from a plugin.
-
- if((strpos($arr['body'],'<') !== false) || (strpos($arr['body'],'>') !== false))
- $arr['body'] = strip_tags($arr['body']);
$arr['lang'] = detect_language($arr['body']);
@@ -840,12 +836,19 @@ function item_store($arr,$force_parent = false) {
if((is_array($allowed_languages)) && ($arr['lang']) && (! array_key_exists($arr['lang'],$allowed_languages))) {
$translate = array('item' => $arr, 'from' => $arr['lang'], 'to' => $allowed_languages, 'translated' => false);
call_hooks('item_translate', $translate);
- if(! $translate['translated']) {
+ if((! $translate['translated']) && (intval(get_pconfig($arr['uid'],'system','reject_disallowed_languages')))) {
logger('item_store: language ' . $arr['lang'] . ' not accepted for uid ' . $arr['uid']);
return;
}
+ $arr = $translate['item'];
}
+ // Shouldn't happen but we want to make absolutely sure it doesn't leak from a plugin.
+
+ if((strpos($arr['body'],'<') !== false) || (strpos($arr['body'],'>') !== false))
+ $arr['body'] = strip_tags($arr['body']);
+
+
$arr['wall'] = ((x($arr,'wall')) ? intval($arr['wall']) : 0);
$arr['uri'] = ((x($arr,'uri')) ? notags(trim($arr['uri'])) : random_string());
$arr['extid'] = ((x($arr,'extid')) ? notags(trim($arr['extid'])) : '');
diff --git a/mod/item.php b/mod/item.php
index 1593d179b..2a34f7d82 100644
--- a/mod/item.php
+++ b/mod/item.php
@@ -221,6 +221,11 @@ function item_post(&$a) {
logger('detected language: ' . $language);
+
+
+
+
+
$private = ((strlen($str_group_allow) || strlen($str_contact_allow) || strlen($str_group_deny) || strlen($str_contact_deny)) ? 1 : 0);
// If this is a comment, set the permissions from the parent.
@@ -601,6 +606,21 @@ function item_post(&$a) {
killme();
}
+ // post owner can post in any language they wish; others however are subject to the owner's whims about language acceptance
+
+ if($profile_uid != local_user()) {
+ $allowed_languages = get_pconfig($profile_uid,'system','allowed_languages');
+
+ if((is_array($allowed_languages)) && ($datarray['lang']) && (! array_key_exists($datarray['lang'],$allowed_languages))) {
+ $translate = array('item' => $datarray, 'from' => $datarray['lang'], 'to' => $allowed_languages, 'translated' => false);
+ call_hooks('item_translate', $translate);
+ if((! $translate['translated']) && (intval(get_pconfig($profile_uid,'system','reject_disallowed_languages')))) {
+ logger('item_store: language ' . $datarray['lang'] . ' not accepted for uid ' . $datarray['uid']);
+ return;
+ }
+ $datarray = $translate['item'];
+ }
+ }
call_hooks('post_local',$datarray);