You are here

function dlike_append in Drupal like (Flag counter) 7

Same name and namespace in other branches
  1. 7.3 dlike.inc \dlike_append()
  2. 7.2 dlike.inc \dlike_append()
2 calls to dlike_append()
dlike_create_link in ./dlike.module
dlike_flag_link in ./dlike.module
This function is part of flag.module file. This function is overridden here.
1 string reference to 'dlike_append'
dlike_menu in ./dlike.module
Implementation of hook_menu().

File

./dlike.inc, line 44
This files contains all the include functions.

Code

function dlike_append($flag_type, $content_id, $flag_name) {

  // Variables added for appending facebook like like string
  // Check if facebook like likes is enabled for a flag
  $dlike_status_value = variable_get('dlike-' . $flag_name . '_option', 0);

  //add a condition for disabled flags
  if ($dlike_status_value == 0) {
    $dlike_append_link = '';
  }
  else {

    // Get the list of all the users those flagged current content
    // $dlike_append_names = dlike_user_list($type, $flag->get_content_id($object), $flag->name);
    // Get the flag counts for a piece of content
    $dlike_append_count = flag_get_counts($flag_type, $content_id);
    if ($dlike_append_count && $dlike_append_count[$flag_name] > 0) {

      // Get the text string set by the user
      $dlike_text_value_singular = variable_get('dlike-' . $flag_name . '_text_value_singular', NULL);
      $dlike_text_value = variable_get('dlike-' . $flag_name . '_text_value', NULL);

      // Pass the string through t().
      $dlike_sanitize_string = t('@text', array(
        '@text' => $dlike_text_value,
      ));

      // If set, replace the token for count by actual count.
      $dlike_append_string = format_plural($dlike_append_count[$flag_name], $dlike_text_value_singular, $dlike_text_value);

      // Check if user has the right permissions
      if (user_access('dlike access list')) {

        // format link address.
        $dlike_link_address = 'dlike/' . $flag_type . '/' . $content_id . '/' . $flag_name;

        // format the attributed for l() function.
        $dlike_link_arrtibutes = array();
        $dlike_link_arrtibutes = array(
          'html' => TRUE,
          'attributes' => array(
            'rel' => 'lightmodal[|width:400px; height:300px; scrolling: auto;]',
          ),
        );

        // format the link to the list of users who flagged the content.
        $dlike_append_link = '<span class="dlike-' . $flag_type . '-append-' . $content_id . '">' . l($dlike_append_string, $dlike_link_address, $dlike_link_arrtibutes) . '</span>';
      }
      else {
        $dlike_append_link = $dlike_append_string;
      }
    }
    else {
      $dlike_append_link = '<span class="dlike-' . $flag_type . '-append-' . $content_id . '"></span>';
    }
  }
  if (isset($_POST['method']) && $_POST['method'] == 'ajax') {
    print $dlike_append_link;
    die;
  }
  return $dlike_append_link;
}