Add "languages" field in filter-users to filter by most-used language
This commit is contained in:
parent
c398b2b1d6
commit
5eae25fec6
|
@ -291,11 +291,27 @@ $sile_file = 'silenced_accounts,'.$GLOBALS['ap_software'].','.$GLOBALS['ap_insta
|
|||
if (filedb_exists('cache', $sile_file))
|
||||
$silenced_users = unserialize(filedb_get('cache', $sile_file));
|
||||
|
||||
$nlanguages = [];
|
||||
$languages = arg('get.languages', null);
|
||||
if ($languages !== null) {
|
||||
$languages = explode(',', strtolower($languages));
|
||||
$nlanguages = [];
|
||||
foreach ($languages as $l)
|
||||
if (preg_match('/^[a-z]{2}$/', trim($l)))
|
||||
$nlanguages []= trim($l);
|
||||
}
|
||||
|
||||
$result_accounts = [];
|
||||
foreach ($filtered_accounts as $id) {
|
||||
$newacc = [];
|
||||
$account = $all_accounts[$filtered_accounts_index[$id]];
|
||||
|
||||
if (count($nlanguages) > 0) {
|
||||
$lang = $pg->fetch("SELECT language, COUNT(language) FROM statuses WHERE account_id = $id AND NOT language IS NULL GROUP BY language ORDER BY count DESC LIMIT 1");
|
||||
if ($lang === false || !in_array($lang['language'], $nlanguages))
|
||||
continue;
|
||||
}
|
||||
|
||||
$following = $pg->fetch('SELECT count(1) FROM follows WHERE account_id = \''.$id.'\'');
|
||||
$followers = $pg->fetch('SELECT count(1) FROM follows WHERE target_account_id = \''.$id.'\'');
|
||||
if (isset($_GET['no_follows']) && (intval($following['count']) > 0 || intval($followers['count']) > 0))
|
||||
|
|
|
@ -49,6 +49,12 @@
|
|||
<textarea name="instances" placeholder="instance1.org, server2.com"
|
||||
style="width: 100%; min-width: 24em; min-height: 4em"></textarea>
|
||||
</div>
|
||||
<div class="input">
|
||||
<label for="languages">Languages:</label>
|
||||
<br class="sep"/>
|
||||
<textarea name="languages" placeholder="es, en, de"
|
||||
style="width: 100%; min-width: 24em; min-height: 4em"></textarea>
|
||||
</div>
|
||||
<div class="input">
|
||||
<label for="user_filter">Account type:</label>
|
||||
<br class="sep"/>
|
||||
|
@ -185,7 +191,7 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="only mastodon disable-able">{mastodon:fields}</div>
|
||||
<div class="only mastodon">{mastodon:fields}</div>
|
||||
<div class="note">{note}</div>
|
||||
<div style="margin-top: 1em; text-align: right;">
|
||||
|
||||
|
|
|
@ -192,6 +192,9 @@ window.view.instance = {
|
|||
data.instances = instances;
|
||||
data.user_filter = 'remote';
|
||||
}
|
||||
var languages = E.element('#filters-current textarea[name=languages]').value.trim();
|
||||
if (languages !== '')
|
||||
data.languages = languages;
|
||||
const obj_noavatar = E.element('*[name=no_avatar]:checked');
|
||||
if (obj_noavatar !== null)
|
||||
data.no_avatar = '';
|
||||
|
@ -254,6 +257,7 @@ window.view.instance = {
|
|||
E.element("#filters-current textarea[name=profile]").value = d.profile;
|
||||
}
|
||||
E.element('#filters-current textarea[name=instances]').value = d.instances !== undefined ? d.instances : '';
|
||||
E.element('#filters-current textarea[name=languages]').value = d.languages !== undefined ? d.languages : '';
|
||||
E.elements('#filters-current input[type=checkbox]').forEach(function(it){ it.checked = false });
|
||||
if (d.no_avatar !== undefined) E.element('#filters-current input[name=no_avatar]').click();
|
||||
if (d.no_statuses !== undefined) E.element('#filters-current input[name=no_statuses]').click();
|
||||
|
|
Loading…
Reference in New Issue