Exemplo n.º 1
0
 /**
  * Process mentions in the current issue, for example, after the issue is created.
  * @return void
  * @access public
  */
 function process_mentions()
 {
     # Now that the issue is added process the @ mentions
     $t_all_mentioned_user_ids = array();
     $t_mentioned_user_ids = mention_get_users($this->summary);
     $t_all_mentioned_user_ids = array_merge($t_all_mentioned_user_ids, $t_mentioned_user_ids);
     $t_mentioned_user_ids = mention_get_users($this->description);
     $t_all_mentioned_user_ids = array_merge($t_all_mentioned_user_ids, $t_mentioned_user_ids);
     if (!is_blank($this->steps_to_reproduce)) {
         $t_mentioned_user_ids = mention_get_users($this->steps_to_reproduce);
         $t_all_mentioned_user_ids = array_merge($t_all_mentioned_user_ids, $t_mentioned_user_ids);
     }
     if (!is_blank($this->additional_information)) {
         $t_mentioned_user_ids = mention_get_users($this->additional_information);
         $t_all_mentioned_user_ids = array_merge($t_all_mentioned_user_ids, $t_mentioned_user_ids);
     }
     $t_filtered_mentioned_user_ids = access_has_bug_level_filter(config_get('view_bug_threshold'), $this->id, $t_all_mentioned_user_ids);
     $t_removed_mentions_user_ids = array_diff($t_all_mentioned_user_ids, $t_filtered_mentioned_user_ids);
     if (!empty($t_all_mentioned_user_ids)) {
         $t_mention_text = $this->description . "\n\n";
         if (!is_blank($this->steps_to_reproduce)) {
             $t_mention_text .= lang_get('email_steps_to_reproduce') . "\n\n";
             $t_mention_text .= $this->steps_to_reproduce . "\n\n";
         }
         if (!is_blank($this->additional_information)) {
             $t_mention_text .= lang_get('email_additional_information') . "\n\n";
             $t_mention_text .= $this->additional_information . "\n\n";
         }
         mention_process_user_mentions($this->id, $t_filtered_mentioned_user_ids, $t_mention_text, $t_removed_mentions_user_ids);
     }
 }
Exemplo n.º 2
0
/**
 * Format and hyperlink mentions
 *
 * @param string $p_text The text to process.
 * @param bool $p_html true for html, false otherwise.
 * @return string The processed text.
 */
function mention_format_text($p_text, $p_html = true)
{
    $t_mentioned_users = mention_get_users($p_text);
    if (empty($t_mentioned_users)) {
        return $p_text;
    }
    $t_mentions_tag = mentions_tag();
    $t_formatted_mentions = array();
    foreach ($t_mentioned_users as $t_username => $t_user_id) {
        $t_mention = $t_mentions_tag . $t_username;
        $t_mention_formatted = $t_mention;
        if ($p_html) {
            $t_mention_formatted = string_display_line($t_mention_formatted);
            $t_mention_formatted = '<a class="user" href="' . string_sanitize_url('view_user_page.php?id=' . $t_user_id, true) . '">' . $t_mention_formatted . '</a>';
            if (!user_is_enabled($t_user_id)) {
                $t_mention_formatted = '<s>' . $t_mention_formatted . '</s>';
            }
            $t_mention_formatted = '<span class="mention">' . $t_mention_formatted . '</span>';
        }
        $t_formatted_mentions[$t_mention] = $t_mention_formatted;
    }
    # Replace the mentions, ignoring existing anchor tags (otherwise
    # previously set mailto links would be processed as mentions,
    # corrupting the output
    $t_text = string_process_exclude_anchors($p_text, function ($p_string) use($t_formatted_mentions) {
        return str_replace(array_keys($t_formatted_mentions), array_values($t_formatted_mentions), $p_string);
    });
    return $t_text;
}
Exemplo n.º 3
0
/**
 * Process mentions in bugnote, typically after its added.
 *
 * @param  int $p_bug_id          The bug id
 * @param  int $p_bugnote_id      The bugnote id
 * @param  string $p_bugnote_text The bugnote text
 * @return void
 * @access public
 */
function bugnote_process_mentions($p_bug_id, $p_bugnote_id, $p_bugnote_text)
{
    # Process the mentions that have access to the issue note
    $t_mentioned_user_ids = mention_get_users($p_bugnote_text);
    $t_filtered_mentioned_user_ids = access_has_bugnote_level_filter(config_get('view_bug_threshold'), $p_bugnote_id, $t_mentioned_user_ids);
    $t_removed_mentions_user_ids = array_diff($t_mentioned_user_ids, $t_filtered_mentioned_user_ids);
    mention_process_user_mentions($p_bug_id, $t_filtered_mentioned_user_ids, $p_bugnote_text, $t_removed_mentions_user_ids);
}