diff options
author | friendica <info@friendica.com> | 2012-07-16 03:32:42 -0700 |
---|---|---|
committer | friendica <info@friendica.com> | 2012-07-16 03:32:42 -0700 |
commit | a047c5b1c38e601df051b1c6b0165f94d7d265ba (patch) | |
tree | 581c3f0189602a4b9c21fc2b132db48473ebf8ef /include | |
parent | 0dc9c66b170afdeefbfd3ae8873e97882a56db3e (diff) | |
download | volse-hubzilla-a047c5b1c38e601df051b1c6b0165f94d7d265ba.tar.gz volse-hubzilla-a047c5b1c38e601df051b1c6b0165f94d7d265ba.tar.bz2 volse-hubzilla-a047c5b1c38e601df051b1c6b0165f94d7d265ba.zip |
call item_translate hook if source language is not acceptable, ignore message if it cannot be translated.
Diffstat (limited to 'include')
-rwxr-xr-x | include/items.php | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/include/items.php b/include/items.php index b989891a6..6285e5da5 100755 --- a/include/items.php +++ b/include/items.php @@ -809,6 +809,13 @@ function item_store($arr,$force_parent = false) { unset($arr['dsprsig']); } + if(! $arr['uid']) { + logger('item_store: no uid'); + return 0; + } + + + if(x($arr, 'gravity')) $arr['gravity'] = intval($arr['gravity']); elseif($arr['parent-uri'] === $arr['uri']) @@ -827,9 +834,17 @@ function item_store($arr,$force_parent = false) { $arr['body'] = strip_tags($arr['body']); $arr['lang'] = detect_language($arr['body']); - - + $allowed_languages = get_pconfig($arr['uid'],'system','allowed_languages'); + + 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']) { + logger('item_store: language ' . $arr['lang'] . ' not accepted for uid ' . $arr['uid']); + return; + } + } $arr['wall'] = ((x($arr,'wall')) ? intval($arr['wall']) : 0); $arr['uri'] = ((x($arr,'uri')) ? notags(trim($arr['uri'])) : random_string()); |