function push_notifications_used_languages in Push Notifications 7
Determine any languages used in the push notifications table.
2 calls to push_notifications_used_languages()
- push_notifications_admin_overview_form in includes/
push_notifications.admin.inc - Overview form for Push Notification Settings.
- push_notifications_mass_push_form in includes/
push_notifications.admin.inc - Form callback for sending a mass-push notification.
File
- ./
push_notifications.module, line 1223 - Push Notifications functionality.
Code
function push_notifications_used_languages() {
$query = db_select('push_notifications_tokens', 'pnt');
$query
->fields('pnt', array(
'language',
));
$query
->distinct();
$result = $query
->execute();
// Convert the records into an array with
// full language code available.
include_once DRUPAL_ROOT . '/includes/iso.inc';
$languages = _locale_get_predefined_list();
$used_languages = array();
foreach ($result as $record) {
$used_languages[$record->language] = $languages[$record->language][0];
}
if (!empty($used_languages)) {
// Sort the languages alphabetically.
$used_langauges = asort($used_languages);
// Add an "All" option.
array_unshift($used_languages, 'All Recipients');
}
return $used_languages;
}