summaryrefslogtreecommitdiff
path: root/kolab.org/www/drupal-7.18/sites/all/modules/socialshareprivacy/socialshareprivacy.module
blob: f3c77fde8301c66984c173143352350a6ba6254e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
<?php

/**
 * @file
 * A social share (facebook, twitter, google+) privacy (two clicks) plugin for jQuery 1.3
 */

/**
 * The default path to the socialSharePrivacy directory.
 */
define('SOCIALSHAREPRIVACY_PATH', 'sites/all/libraries/socialshareprivacy');
define('SOCIALSHAREPRIVACY_FIELD_TYPE', variable_get('socialshareprivacy_field_type'));
define('SOCIALSHAREPRIVACY_FORMATTER', variable_get('socialshareprivacy_formatter'));
define('SOCIALSHAREPRIVACY_WIDGET', variable_get('socialshareprivacy_widget'));
define('SOCIALSHAREPRIVACY_DEFAULT_VALUE_SERVICES', serialize(array('facebook' => 'facebook', 'twitter' => 'twitter', 'gplus' => 'gplus')));

/**
 * Implements hook_help().
 */
function socialshareprivacy_help($path, $arg) {
  switch ($path) {
    case 'admin/config/user-interface/socialshareprivacy':
    case 'admin/help#socialshareprivacy':
      return '<p>' . t('Adds social network buttons to content types and provides a <a href="@urlBlock">block</a> with the 2-click-method “<a href="@urlHeise" target="_blank">socialSharePrivacy</a>“ by Heise Zeitschriften Verlag. So the networks won\'t receive data unless the visitor wants to.', array('@urlBlock' => url('admin/structure/block/manage/socialshareprivacy/socialshareprivacy_block/configure'), '@urlHeise' => 'http://www.heise.de/extras/socialshareprivacy/')) . '</p>';
  }
}


/**
 * Implements hook_permission().
 */
function socialshareprivacy_permission() {
  return array(
    'administer socialshareprivacy' => array(
      'title' => t('administer socialSharePrivacy'),
    ),
    'access socialshareprivacy' => array(
      'title' => t('access socialSharePrivacy'),
    ),
  );
}

/**
 * Implements hook_menu().
 */
function socialshareprivacy_menu() {
    $items = array();

    $items['admin/config/user-interface/socialshareprivacy'] = array(
        'title' => 'socialSharePrivacy',
        'description' => 'Configure settings for socialSharePrivacy',
        'page callback' => 'drupal_get_form',
        'page arguments' => array('socialshareprivacy_admin_settings'),
        'access arguments' => array('administer socialshareprivacy'),
        'weight' => -20,
        'file' => 'socialshareprivacy.admin.inc',
    );
    $items['admin/config/user-interface/socialshareprivacy/settings'] = array(
        'title' => 'Settings',
        'description' => 'Configure settings for socialSharePrivacy',
        'page callback' => 'drupal_get_form',
        'page arguments' => array('socialshareprivacy_admin_settings'),
        'access arguments' => array('administer socialshareprivacy'),
        'weight' => -20,
        'type' => MENU_DEFAULT_LOCAL_TASK,
        'file' => 'socialshareprivacy.admin.inc',
    );
    $items['admin/config/user-interface/socialshareprivacy/fieldmgmt'] = array(
        'title' => 'Field Management',
        'description' => 'Add socialSharePrivacy fields to your contenttypes',
        'page callback' => 'socialshareprivacy_admin_fieldmgmt',
        'access arguments' => array('administer socialshareprivacy'),
        'weight' => -19,
        'type' => MENU_LOCAL_TASK,
        'file' => 'socialshareprivacy.admin.inc',
    );
    $items['admin/config/user-interface/socialshareprivacy/bulkupdate'] = array(
        'title' => 'Bulk Update',
        'description' => 'Update existing nodes',
        'page callback' => 'socialshareprivacy_admin_bulkupdate',
        'access arguments' => array('administer socialshareprivacy'),
        'weight' => -18,
        'type' => MENU_LOCAL_TASK,
        'file' => 'socialshareprivacy.admin.inc',
    );

    return $items;
}

/**
 * Implement hook_field_info().
 */
function socialshareprivacy_field_info() {
  return array(
    SOCIALSHAREPRIVACY_FIELD_TYPE => array(
      'label' => t('Placeholder for socialSharePrivacy'),
      'description' => t('Move this field to the position you want the socialSharePrivacy to be displayed in.'),
      'default_widget' => SOCIALSHAREPRIVACY_WIDGET,
      'default_formatter' => SOCIALSHAREPRIVACY_FORMATTER,
    ),
  );
}

/**
 * Implement hook_field_widget_info().
 */
function socialshareprivacy_field_widget_info() {
  return array(
    SOCIALSHAREPRIVACY_WIDGET => array(
      'label' => t('SSP Widget'),
      'field types' => array(SOCIALSHAREPRIVACY_FIELD_TYPE),
    ),
  );
}

/**
 * Implement hook_field_widget().
 *
 */
function socialshareprivacy_field_widget_form(&$form, &$form_state, $field,
  $instance, $langcode, $items, $delta = 0) {

  $element = array(
    '#type' => 'checkbox',
    '#prefix' => '<br/><strong>socialSharePrivacy</strong>',
    /* '#description' => t('Placeholder for socialSharePrivacy'), */
    '#title' => t('Display socialSharePrivacy'),
    '#description' => t('If this box is checked then socialSharePrivacy will be displayed on the view of this node.'),
    '#default_value' => (isset($items[0]) && isset($items[0]['value'])) ? $items[0]['value'] : 1,
    '#suffix' => '<br/>',
  );

  return $element;
}

/**
 * Implements hook_field_formatter_info().
 */
function socialshareprivacy_field_formatter_info() {
  return array(
    SOCIALSHAREPRIVACY_FORMATTER => array(
      'label' => t('SSP Formatter'),
      'field types' => array(SOCIALSHAREPRIVACY_FIELD_TYPE),
      'module' => 'socialshareprivacy',
    ),
  );
}

/**
 * Implement hoo_field_is_empty().
 */
function socialshareprivacy_field_is_empty($item, $field) {
  return FALSE;
}

function socialshareprivacy_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items) {
  if ($field['type'] == SOCIALSHAREPRIVACY_FIELD_TYPE) {
    foreach ($items as $delta => $item) {
      if (!is_array($item)) {
        $items[$delta] = array('value' => $item);
      }
    }
  }
}

/**
 * Implements hook_field_formatter_view().
 */
function socialshareprivacy_field_formatter_view($object_type, $object, $field, $instance, $langcode, $items, $display) {

  if (!_socialshareprivacy_has_access()) {
    return NULL;
  }

  $element = array();
  if ($field['type']==SOCIALSHAREPRIVACY_FIELD_TYPE) {
    switch ($display['type']) {
      case SOCIALSHAREPRIVACY_FORMATTER:
        foreach ($items as $delta => $item) {
          if ($item['value'] == "1") {
            $element[$delta]['#type'] = 'markup';

            $htmlNodeId = $field['field_name'] . '-' . $object->nid;
            $javascript = _socialshareprivacy_write_javascript($htmlNodeId, url('node/' . $object->nid, array('absolute' => TRUE)));
            $markup = _socialshareprivacy_get_markup($htmlNodeId);
            if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && drupal_strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
              $markup =  $markup . '<script type="text/javascript">' . $javascript . '</script>';
            }

            $element[$delta]['#markup'] = $markup;
          }
        }
        break;
    }
  }

  return $element;
}

/**
 * Implements hook_block_info().
 */
function socialshareprivacy_block_info() {
  $blocks['socialshareprivacy_block'] = array(
    // info: The name of the block.
    'info' => t('socialSharePrivacy'),
    // Block caching options (per role, per user, etc.)
    'cache' => DRUPAL_NO_CACHE,
  );

  return $blocks;
}

/**
 * Implements hook_block_configure().
 */
function socialshareprivacy_block_configure($block_name = '') {
  if ($block_name == 'socialshareprivacy_block') {
    $form['help'] = array(
      '#markup' => t('Additional options can be set on the <a href="/admin/config/user-interface/socialshareprivacy">socialSharePrivacy configuration page</a>.'),
    );

    return $form;
  }
}

/**
 * Implements hook_block_view().
 */
function socialshareprivacy_block_view($delta = 0) {

  if (!_socialshareprivacy_has_access()) {
    return NULL;
  }

  return _socialshareprivacy_block($op='view');
}

/**
 * Gets the block.
 */
function _socialshareprivacy_block($op = 'list', $delta = 0, $edit = array()) {
  $block = array();

  if ($op == 'view') {
    $block['subject'] = t('socialSharePrivacy');
    $block['content'] = _socialshareprivacy_get_markup('socialshareprivacy-block');

    _socialshareprivacy_write_javascript('socialshareprivacy-block');
  }

  return $block;
}

/**
 * Return the path to the socialSharePrivacy plugin.
 */
function _socialshareprivacy_get_path() {
  static $library_path = NULL;

  // Try to locate the library path in any possible setup.
  if ($library_path == NULL) {
    // First check the default location.
    $path = variable_get('socialshareprivacy_path', SOCIALSHAREPRIVACY_PATH);
    if (is_dir($path . '/socialshareprivacy')) {
      $library_path = $path;
    }
    // Ask the libraries module as a fallback.
    elseif ($library_path == NULL && module_exists('libraries')) {
      if ($path = libraries_get_path('socialshareprivacy')) {
        $library_path = $path;
        variable_set('socialshareprivacy_path', $library_path);
      }
    }
    // HACK: If libraries api module is not installed but available, load it.
    elseif ($library_path == NULL && file_exists(dirname(__FILE__) . '/../libraries/libraries.module')) {
      require_once(dirname(__FILE__) . '/../libraries/libraries.module');
      if ($path = libraries_get_path('socialshareprivacy')) {
        $library_path = $path;
        variable_set('socialshareprivacy_path', $library_path);
      }
    }
    // If no path is found suggest the default one.
    elseif ($library_path == NULL) {
      $library_path = SOCIALSHAREPRIVACY_PATH;
    }
  }

  return $library_path;
}

/**
 * writes the javascript to the page
 */
function _socialshareprivacy_get_markup($nodeId = 'socialshareprivacy') {
  return '<div id="' . $nodeId . '" class="ssp_wrapper">&nbsp;</div>';
}

/**
 * writes the javascript to the page
 *
 *
 * @param $nodeId
 *   The unique javascript id.
 * @param $url
 *   The url to share.
 * @param $library_path
 *   The patch to SSP.
 */
function _socialshareprivacy_write_javascript($nodeId = 'socialshareprivacy', $url = '', $library_path = '') {

  $options = _socialshareprivacy_get_javascript_options($url, $library_path);

  $minFileNamePart = '.min';
  if (variable_get('socialshareprivacy_js_minified', 'true') == 'false') {
    $minFileNamePart = '';
  }

  if (variable_get('socialshareprivacy_reset_css', 'false') == 'true') {
    drupal_add_css(drupal_get_path('module', 'socialshareprivacy') . '/css/reset.css');
  }

  drupal_add_js(_socialshareprivacy_get_path() . '/jquery.socialshareprivacy' . $minFileNamePart . '.js', array('group' => JS_LIBRARY));
  drupal_add_js('(function ($) { jQuery(document).ready(function () { if(jQuery("#' . $nodeId . '").length > 0){ jQuery("#' . $nodeId . '").socialSharePrivacy(' . $options . ');' . _socialshareprivacy_external_link() . ' } }); })(jQuery);', 'inline');

  return '(function ($) { jQuery(document).ready(function () { if(jQuery("#' . $nodeId . '").length > 0){ jQuery("#' . $nodeId . '").socialSharePrivacy(' . $options . ');' . _socialshareprivacy_external_link() . ' } }); })(jQuery);';
}

/**
 * Return the javascript options
 *
 * @param $url
 *   The url to share.
 * @param $library_path
 *   The patch to SSP.
 */
function _socialshareprivacy_get_javascript_options($url = '', $library_path = '') {
  global $language;

  $path = $library_path;
  if ($path == '') {
    $path = _socialshareprivacy_get_path();
  }
  $facebook_dummy = base_path() . $path . '/socialshareprivacy/images/dummy_facebook_en.png';
  if (variable_get('socialshareprivacy_neutral_button', 'false') == 'true') {
    $facebook_dummy = base_path() . drupal_get_path('module', 'socialshareprivacy') . '/images/dummy_facebook.png';
  }
  elseif ($language->language == 'de' || variable_get('socialshareprivacy_force_german', 'false') == 'true') {
    $facebook_dummy = base_path() . $path . '/socialshareprivacy/images/dummy_facebook.png';
  }
  elseif ($language->language != 'en') {
    $facebook_dummy = base_path() . drupal_get_path('module', 'socialshareprivacy') . '/images/dummy_facebook.png';
  }

  /* use the german 'default' texts */
  if (variable_get('socialshareprivacy_force_german', 'true') == 'true') {
    $options = "{
          services : {
              facebook : {
                  'status' : '" . _socialshareprivacy_service_status("facebook") . "',
                  'dummy_img' : '" . $facebook_dummy . "',
                  'perma_option' : '" . _socialshareprivacy_service_permaoption_status("facebook") . "',
                  'referrer_track' : '" . _socialshareprivacy_get_referer_track() . "',
                  'action'         : '" . check_plain(variable_get('socialshareprivacy_facebook_action', 'recommend')) . "'
              },
              twitter : {
                  'status' : '" . _socialshareprivacy_service_status("twitter") . "',
                  'dummy_img' : '" . base_path() . $path . "/socialshareprivacy/images/dummy_twitter.png',
                  'perma_option' : '" . _socialshareprivacy_service_permaoption_status("twitter") . "',
                  'referrer_track' : '" . _socialshareprivacy_get_referer_track() . "'
              },
              gplus : {
                  'status' : '" . _socialshareprivacy_service_status("gplus") . "',
                  'dummy_img' : '" . base_path() . $path . "/socialshareprivacy/images/dummy_gplus.png',
                  'perma_option' : '" . _socialshareprivacy_service_permaoption_status("gplus") . "',
                  'referrer_track' : '" . _socialshareprivacy_get_referer_track() . "'
              }
          },
          'css_path': '" . base_path() . $path . "/socialshareprivacy/socialshareprivacy.css',
          'cookie_expires' : '" . variable_get('socialshareprivacy_cookie_expires', '365') . "',
          'info_link': '" . url(variable_get('socialshareprivacy_ext_link_target', 'http://www.heise.de/ct/artikel/2-Klicks-fuer-mehr-Datenschutz-1333879.html')) . "'";
  }
  else {
    $options = "{
          services : {
              facebook : {
                  'status' : '" . _socialshareprivacy_service_status("facebook") . "',
                  'dummy_img' : '" . $facebook_dummy . "',
                  'perma_option' : '" . _socialshareprivacy_service_permaoption_status("facebook") . "',
                  'language'       : '" . _socialshareprivacy_map_facebook_language($language->language) . "',
                  'txt_info'       : '" . _socialshareprivacy_escape_javascript(t('2 clicks for more privacy: Click here to activate the Facebook share button. Please note that activating the share button will already transfer data to Facebook. For more information please click on the <em>i</em>')) . "',
                  'referrer_track' : '" . _socialshareprivacy_get_referer_track() . "',
                  'action'         : '" . variable_get('socialshareprivacy_facebook_action', 'recommend') . "'
              },
              twitter : {
                  'status' : '" . _socialshareprivacy_service_status("twitter") . "',
                  'dummy_img' : '" . base_path() . $path . "/socialshareprivacy/images/dummy_twitter.png',
                  'perma_option' : '" . _socialshareprivacy_service_permaoption_status("twitter") . "',
                  'language'       : '" . $language->language . "',
                  'txt_info'       : '" . _socialshareprivacy_escape_javascript(t('2 clicks for more privacy: Click here to activate the Twitter share button. Please note that activating the share button will already transfer data to Twitter. For more information please click on the <em>i</em>')) . "',
                  'referrer_track' : '" . _socialshareprivacy_get_referer_track() . "'
              },
              gplus : {
                  'status' : '" . _socialshareprivacy_service_status("gplus") . "',
                  'dummy_img' : '" . base_path() . $path . "/socialshareprivacy/images/dummy_gplus.png',
                  'perma_option' : '" . _socialshareprivacy_service_permaoption_status("gplus") . "',
                  'language'       : '" . $language->language . "',
                  'txt_info'       : '" . _socialshareprivacy_escape_javascript(t('2 clicks for more privacy: Click here to activate the Google+ share button. Please note that activating the share button will already transfer data to Google. For more information please click on the <em>i</em>')) . "',
                  'referrer_track' : '" . _socialshareprivacy_get_referer_track() . "'
              }
          },
          'css_path': '" . base_path() . $path . "/socialshareprivacy/socialshareprivacy.css',
          'cookie_expires' : '" . (is_numeric(variable_get('socialshareprivacy_cookie_expires', '365')) ? variable_get('socialshareprivacy_cookie_expires', '365') : '365') . "',
          'txt_help'       : '" . _socialshareprivacy_escape_javascript(t('If you enable any of these options then the corresponding social network will receive and store data about your visit on this site. For more information please click on the <em>i</em>')) . "',
          'settings_perma' : '" . _socialshareprivacy_escape_javascript(t('Agree to permanent activation and thus data transfer:')) . "',
          'info_link': '" . url(variable_get('socialshareprivacy_ext_link_target', 'http://www.heise.de/ct/artikel/2-Klicks-fuer-mehr-Datenschutz-1333879.html')) . "'";
  }

  if ($url != '') {
    $options = $options . ",
    'uri' : '" . $url . "'";
  }

  $options = $options . "
          }";

  return $options;
}

/**
 * Checks if the directory in $form_element exists and contains a file named
 * 'jquery.socialshareprivacy.js'. If validation fails, the form element is flagged
 * with an error from within the file_check_directory function.
 *
 * @param $form_element
 *   The form element containing the name of the directory to check.
 */
function _socialshareprivacy_admin_settings_check_plugin_path($form_element) {
  $library_path = $form_element['#value'];
  if (!is_dir($library_path) || !(file_exists($library_path . '/jquery.socialshareprivacy.js') && file_exists($library_path . '/jquery.socialshareprivacy.min.js'))) {
    form_set_error($form_element['#parents'][0], t('You need to download the <a href="@urlSSP" target="_blank">socialSharePrivacy</a> and extract the entire contents of the archive into the %path folder of your server.', array('@urlSSP' => 'http://www.heise.de/extras/socialshareprivacy/', '%path' => $library_path)));
  }

  return $form_element;
}

/**
 * Get the status on/off for a service.
 */
function _socialshareprivacy_service_status($service) {
    $settings = variable_get('socialshareprivacy_services', unserialize(SOCIALSHAREPRIVACY_DEFAULT_VALUE_SERVICES));
    if (array_key_exists($service, $settings) && $settings[$service] !== 0) {
        return "on";
    }
    return "off";
}

/**
 * Get the status on/off for a perma option.
 */
function _socialshareprivacy_service_permaoption_status($service) {
    $settings = variable_get('socialshareprivacy_services_permaoption', unserialize(SOCIALSHAREPRIVACY_DEFAULT_VALUE_SERVICES));
    if (array_key_exists($service, $settings) && $settings[$service] !== 0) {
        return "on";
    }
    return "off";
}

/**
 * Translates and escapes '.
 */
function _socialshareprivacy_escape_javascript($text) {
    return addslashes(filter_xss($text));
}

/**
 * Gets the plain referer track string.
 */
function _socialshareprivacy_get_referer_track() {
    return check_plain(variable_get('socialshareprivacy_referrertrack', ''));
}

/**
 * Get the external link JS.
 */
function _socialshareprivacy_external_link() {
    $setting = variable_get('socialshareprivacy_ext_link', '');
    if ($setting == 'remove') {
        return " setTimeout('(function ($) { $(\'div.settings_info_menu > a\').click(function(){ return false; }); })(jQuery);', 300);";
    }
    elseif ($setting == 'blank') {
        return " setTimeout('(function ($) { $(\'div.settings_info_menu > a\').attr(\'target\', \'_blank\'); })(jQuery);', 300);";
    }
    return "";
}

/**
 * maps drupal language code to facebook langauge code
 */
function _socialshareprivacy_map_facebook_language($language) {
  $lang_map = array(
    'af' => 'af_ZA',
    'ar' => 'ar_AR',
    'ay' => 'ay_BO',
    'az' => 'az_AZ',
    'be' => 'be_BY',
    'bg' => 'bg_BG',
    'bn' => 'bn_IN',
    'bs' => 'bs_BA',
    'ca' => 'ca_ES',
    'ck' => 'ck_US',
    'cs' => 'cs_CZ',
    'cy' => 'cy_GB',
    'da' => 'da_DK',
    'de' => 'de_DE',
    'el' => 'el_GR',
    'en' => 'en_US',
    'eo' => 'eo_EO',
    'es' => 'es_ES',
    'et' => 'et_EE',
    'eu' => 'eu_ES',
    'fa' => 'fa_IR',
    'fb' => 'fb_FI',
    'fb' => 'fb_LT',
    'fi' => 'fi_FI',
    'fo' => 'fo_FO',
    'fr' => 'fr_CA',
    'fr' => 'fr_FR',
    'ga' => 'ga_IE',
    'gl' => 'gl_ES',
    'gn' => 'gn_PY',
    'gu' => 'gu_IN',
    'he' => 'he_IL',
    'hi' => 'hi_IN',
    'hr' => 'hr_HR',
    'hu' => 'hu_HU',
    'hy' => 'hy_AM',
    'id' => 'id_ID',
    'is' => 'is_IS',
    'it' => 'it_IT',
    'ja' => 'ja_JP',
    'jv' => 'jv_ID',
    'ka' => 'ka_GE',
    'kk' => 'kk_KZ',
    'km' => 'km_KH',
    'kn' => 'kn_IN',
    'ko' => 'ko_KR',
    'ku' => 'ku_TR',
    'la' => 'la_VA',
    'li' => 'li_NL',
    'lt' => 'lt_LT',
    'lv' => 'lv_LV',
    'mg' => 'mg_MG',
    'mk' => 'mk_MK',
    'ml' => 'ml_IN',
    'mn' => 'mn_MN',
    'mr' => 'mr_IN',
    'ms' => 'ms_MY',
    'mt' => 'mt_MT',
    'nb' => 'nb_NO',
    'ne' => 'ne_NP',
    'nl' => 'nl_BE',
    'nl' => 'nl_NL',
    'nn' => 'nn_NO',
    'pa' => 'pa_IN',
    'pl' => 'pl_PL',
    'ps' => 'ps_AF',
    'pt' => 'pt_PT',
    'qu' => 'qu_PE',
    'rm' => 'rm_CH',
    'ro' => 'ro_RO',
    'ru' => 'ru_RU',
    'sa' => 'sa_IN',
    'se' => 'se_NO',
    'sk' => 'sk_SK',
    'sl' => 'sl_SI',
    'so' => 'so_SO',
    'sq' => 'sq_AL',
    'sr' => 'sr_RS',
    'sv' => 'sv_SE',
    'sw' => 'sw_KE',
    'sy' => 'sy_SY',
    'ta' => 'ta_IN',
    'te' => 'te_IN',
    'tg' => 'tg_TJ',
    'th' => 'th_TH',
    'tl' => 'tl_PH',
    'tl' => 'tl_ST',
    'tr' => 'tr_TR',
    'tt' => 'tt_RU',
    'uk' => 'uk_UA',
    'ur' => 'ur_PK',
    'uz' => 'uz_UZ',
    'vi' => 'vi_VN',
    'xh' => 'xh_ZA',
    'yi' => 'yi_DE',
    'zh' => 'zh_CN',
    'zu' => 'zu_ZA',
  );
  $return = @$lang_map[$language];
  if (empty($return)) $return = 'en_US';
  return $return;
}

function _socialshareprivacy_has_access() {
  return user_access('access socialshareprivacy');
}