function show_revision($t_revision)
{
    static $s_can_drop = null;
    static $s_drop_token = null;
    static $s_user_access = null;
    if (is_null($s_can_drop)) {
        $s_can_drop = access_has_bug_level(config_get('bug_revision_drop_threshold'), $t_revision['bug_id']);
        $s_drop_token = form_security_param('bug_revision_drop');
    }
    switch ($t_revision['type']) {
        case REV_DESCRIPTION:
            $t_label = lang_get('description');
            break;
        case REV_STEPS_TO_REPRODUCE:
            $t_label = lang_get('steps_to_reproduce');
            break;
        case REV_ADDITIONAL_INFO:
            $t_label = lang_get('additional_information');
            break;
        case REV_BUGNOTE:
            if (is_null($s_user_access)) {
                $s_user_access = access_has_bug_level(config_get('private_bugnote_threshold'), $t_revision['bug_id']);
            }
            if (!$s_user_access) {
                return null;
            }
            $t_label = lang_get('bugnote');
            break;
        default:
            $t_label = '';
    }
    $t_by_string = sprintf(lang_get('revision_by'), string_display_line(date(config_get('normal_date_format'), $t_revision['timestamp'])), string_display_line(user_get_name($t_revision['user_id'])));
    ?>
<tr class="spacer"><td><a id="revision-<?php 
    echo $t_revision['id'];
    ?>
"></a></td></tr>

<tr <?php 
    echo helper_alternate_class();
    ?>
>
<th class="category"><?php 
    echo lang_get('revision');
    ?>
</th>
<td colspan="2"><?php 
    echo $t_by_string;
    ?>
</td>
<td class="center" width="5%">
<?php 
    if ($s_can_drop) {
        print_bracket_link('bug_revision_drop.php?id=' . $t_revision['id'] . $s_drop_token, lang_get('revision_drop'));
    }
    ?>
</tr>

<tr <?php 
    echo helper_alternate_class();
    ?>
>
<th class="category"><?php 
    echo $t_label;
    ?>
</th>
<td colspan="3"><?php 
    echo string_display_links($t_revision['value']);
    ?>
</td>
</tr>

	<?php 
}
/**
 * return formatted string with all the details on the requested relationship
 * @param integer             $p_bug_id       A bug identifier.
 * @param BugRelationshipData $p_relationship A bug relationship object.
 * @param boolean             $p_html         Whether to return html or text output.
 * @param boolean             $p_html_preview Whether to include style/hyperlinks - if preview is false, we prettify the output.
 * @param boolean             $p_show_project Show Project details.
 * @return string
 */
function relationship_get_details($p_bug_id, BugRelationshipData $p_relationship, $p_html = false, $p_html_preview = false, $p_show_project = false)
{
    $t_summary_wrap_at = utf8_strlen(config_get('email_separator2')) - 28;
    $t_icon_path = config_get('icon_path');
    if ($p_bug_id == $p_relationship->src_bug_id) {
        # root bug is in the source side, related bug in the destination side
        $t_related_bug_id = $p_relationship->dest_bug_id;
        $t_related_project_name = project_get_name($p_relationship->dest_project_id);
        $t_relationship_descr = relationship_get_description_src_side($p_relationship->type);
    } else {
        # root bug is in the dest side, related bug in the source side
        $t_related_bug_id = $p_relationship->src_bug_id;
        $t_related_project_name = project_get_name($p_relationship->src_project_id);
        $t_relationship_descr = relationship_get_description_dest_side($p_relationship->type);
    }
    # related bug not existing...
    if (!bug_exists($t_related_bug_id)) {
        return '';
    }
    # user can access to the related bug at least as a viewer
    if (!access_has_bug_level(VIEWER, $t_related_bug_id)) {
        return '';
    }
    if ($p_html_preview == false) {
        $t_td = '<td>';
    } else {
        $t_td = '<td class="print">';
    }
    # get the information from the related bug and prepare the link
    $t_bug = bug_get($t_related_bug_id, false);
    $t_status_string = get_enum_element('status', $t_bug->status, auth_get_current_user_id(), $t_bug->project_id);
    $t_resolution_string = get_enum_element('resolution', $t_bug->resolution, auth_get_current_user_id(), $t_bug->project_id);
    $t_relationship_info_html = $t_td . string_no_break($t_relationship_descr) . '&#160;</td>';
    if ($p_html_preview == false) {
        $t_relationship_info_html .= '<td><a href="' . string_get_bug_view_url($t_related_bug_id) . '">' . string_display_line(bug_format_id($t_related_bug_id)) . '</a></td>';
        $t_relationship_info_html .= '<td><span class="issue-status" title="' . string_attribute($t_resolution_string) . '">' . string_display_line($t_status_string) . '</span></td>';
    } else {
        $t_relationship_info_html .= $t_td . string_display_line(bug_format_id($t_related_bug_id)) . '</td>';
        $t_relationship_info_html .= $t_td . string_display_line($t_status_string) . '&#160;</td>';
    }
    $t_relationship_info_text = utf8_str_pad($t_relationship_descr, 20);
    $t_relationship_info_text .= utf8_str_pad(bug_format_id($t_related_bug_id), 8);
    # get the handler name of the related bug
    $t_relationship_info_html .= $t_td;
    if ($t_bug->handler_id > 0) {
        $t_relationship_info_html .= string_no_break(prepare_user_name($t_bug->handler_id));
    }
    $t_relationship_info_html .= '&#160;</td>';
    # add project name
    if ($p_show_project) {
        $t_relationship_info_html .= $t_td . string_display_line($t_related_project_name) . '&#160;</td>';
    }
    # add summary
    if ($p_html == true) {
        $t_relationship_info_html .= $t_td . string_display_line_links($t_bug->summary);
        if (VS_PRIVATE == $t_bug->view_state) {
            $t_relationship_info_html .= sprintf(' <img src="%s" alt="(%s)" title="%s" />', $t_icon_path . 'protected.gif', lang_get('private'), lang_get('private'));
        }
    } else {
        if (utf8_strlen($t_bug->summary) <= $t_summary_wrap_at) {
            $t_relationship_info_text .= string_email_links($t_bug->summary);
        } else {
            $t_relationship_info_text .= utf8_substr(string_email_links($t_bug->summary), 0, $t_summary_wrap_at - 3) . '...';
        }
    }
    # add delete link if bug not read only and user has access level
    if (!bug_is_readonly($p_bug_id) && !current_user_is_anonymous() && $p_html_preview == false) {
        if (access_has_bug_level(config_get('update_bug_threshold'), $p_bug_id)) {
            $t_relationship_info_html .= ' [<a class="small" href="bug_relationship_delete.php?bug_id=' . $p_bug_id . '&amp;rel_id=' . $p_relationship->id . htmlspecialchars(form_security_param('bug_relationship_delete')) . '">' . lang_get('delete_link') . '</a>]';
        }
    }
    $t_relationship_info_html .= '&#160;</td>';
    $t_relationship_info_text .= "\n";
    if ($p_html_preview == false) {
        # choose color based on status
        $t_status_label = html_get_status_css_class($t_bug->status, auth_get_current_user_id(), $t_bug->project_id);
        $t_relationship_info_html = '<tr class="' . $t_status_label . '">' . $t_relationship_info_html . '</tr>' . "\n";
    } else {
        $t_relationship_info_html = '<tr>' . $t_relationship_info_html . '</tr>';
    }
    if ($p_html == true) {
        return $t_relationship_info_html;
    } else {
        return $t_relationship_info_text;
    }
}
                    }
                }
            }
        }
        if (0 < count($t_depends)) {
            $t_depends = implode($t_depends, '<br />');
        } else {
            $t_depends = '<span class="small dependency_met">' . lang_get('plugin_no_depends') . '</span>';
        }
        echo '<tr ', helper_alternate_class(), '>';
        echo '<td class="small center">', $t_name, '</td>';
        echo '<td class="small">', $t_description, $t_author, $t_url, '</td>';
        echo '<td class="center">', $t_depends, '</td>';
        echo '<td class="center">';
        if ($t_ready) {
            print_bracket_link('manage_plugin_install.php?name=' . $t_basename . form_security_param('manage_plugin_install'), lang_get('plugin_install'));
        }
        echo '</td></tr>';
    }
    ?>

</table>
<?php 
}
?>

<br /><?php 
echo lang_get('plugin_key');
?>
:
<span class='dependency_met'><?php 
Example #4
0
 />
	</td>
	<td class="center">
		<?php 
        echo get_enum_element('project_view_state', $t_subproject['view_state']);
        ?>
	</td>
	<td>
		<?php 
        echo string_display_links($t_subproject['description']);
        ?>
	</td>
	<td class="center">
		<?php 
        print_bracket_link('manage_proj_edit_page.php?project_id=' . $t_subproject['id'], lang_get('edit_link'));
        print_bracket_link("manage_proj_subproj_delete.php?project_id={$f_project_id}&subproject_id=" . $t_subproject['id'] . form_security_param('manage_proj_subproj_delete'), lang_get('unlink_link'));
        ?>
	</td>
</tr>
<?php 
    }
    # End of foreach loop over subprojects
}
# End of hiding subproject listing if there are no subprojects
?>

<tr>
	<td colspan="6">
	<input type="submit" value="<?php 
echo lang_get('update_subproject_inheritance');
?>
Example #5
0
/**
 * Display a tag hyperlink.
 * If a bug ID is passed, the tag link will include a detach link if the
 * user has appropriate privileges.
 * @param array Tag row
 * @param integer Bug ID
 */
function tag_display_link($p_tag_row, $p_bug_id = 0)
{
    static $t_security_token = null;
    if (is_null($t_security_token)) {
        $t_security_token = htmlspecialchars(form_security_param('tag_detach'));
    }
    if (auth_get_current_user_id() == $p_tag_row['user_attached'] || auth_get_current_user_id() == $p_tag_row['user_id']) {
        $t_detach = config_get('tag_detach_own_threshold');
    } else {
        $t_detach = config_get('tag_detach_threshold');
    }
    $t_name = string_display_line($p_tag_row['name']);
    $t_description = string_display_line($p_tag_row['description']);
    echo "<a href='tag_view_page.php?tag_id={$p_tag_row['id']}' title='{$t_description}'>{$t_name}</a>";
    if ($p_bug_id > 0 && access_has_bug_level($t_detach, $p_bug_id)) {
        $t_tooltip = string_html_specialchars(sprintf(lang_get('tag_detach'), $t_name));
        echo " <a href='tag_detach.php?bug_id={$p_bug_id}&amp;tag_id={$p_tag_row['id']}{$t_security_token}'><img src='images/delete.png' class='delete-icon' title=\"{$t_tooltip}\" alt=\"X\"/></a>";
    }
    return true;
}
	<td class="category" width="15%">
		<?php 
    echo lang_get('monitoring_user_list');
    ?>
	</td>
	<td>
<?php 
    if (0 == $num_users) {
        echo lang_get('no_users_monitoring_bug');
    } else {
        $t_can_delete_others = access_has_bug_level(config_get('monitor_delete_others_bug_threshold'), $f_bug_id);
        for ($i = 0; $i < $num_users; $i++) {
            echo $i > 0 ? ', ' : '';
            echo print_user($t_users[$i]);
            if ($t_can_delete_others) {
                echo ' [<a class="small" href="' . helper_mantis_url('bug_monitor_delete.php') . '?bug_id=' . $f_bug_id . '&user_id=' . $t_users[$i] . form_security_param('bug_monitor_delete') . '">' . lang_get('delete_link') . '</a>]';
            }
        }
    }
    if (access_has_bug_level(config_get('monitor_add_others_bug_threshold'), $f_bug_id)) {
        echo '<br /><br />', lang_get('username');
        ?>
		<form method="get" action="bug_monitor_add.php">
		<?php 
        echo form_security_field('bug_monitor_add');
        ?>
			<input type="hidden" name="bug_id" value="<?php 
        echo (int) $f_bug_id;
        ?>
" />
			<input type="text" name="username" />
/**
 * @author Lennard Bredenkamp, BFE
 * provide link for deletion, trigger delete process
 * 
 */
function print_delete_from_testlink($tts_tproject_id, $tts_exec_id, $p_bug_id)
{
    //uses form security function from mantis
    echo '[<a class="small" href="' . plugin_page('tts_relationship_delete') . '&amp;bug_id=' . $p_bug_id . '&amp;exec_id=' . $tts_exec_id . '&amp;tproject_id=' . $tts_tproject_id . htmlspecialchars(form_security_param('tts_relationship_delete')) . '">' . lang_get('delete_link') . '</a>]';
}
Example #8
0
function print_custom_field_projects_list($p_field_id)
{
    $c_field_id = (int) $p_field_id;
    $t_project_ids = custom_field_get_project_ids($p_field_id);
    $t_security_token = form_security_param('manage_proj_custom_field_remove');
    foreach ($t_project_ids as $t_project_id) {
        $t_project_name = project_get_field($t_project_id, 'name');
        $t_sequence = custom_field_get_sequence($p_field_id, $t_project_id);
        echo '<b>', $t_project_name, '</b>: ';
        print_bracket_link("manage_proj_custom_field_remove.php?field_id={$c_field_id}&amp;project_id={$t_project_id}&amp;return=custom_field{$t_security_token}", lang_get('remove_link'));
        echo '<br />- ';
        $t_linked_field_ids = custom_field_get_linked_ids($t_project_id);
        $t_current_project_fields = array();
        $t_first = true;
        foreach ($t_linked_field_ids as $t_current_field_id) {
            if ($t_first) {
                $t_first = false;
            } else {
                echo ', ';
            }
            if ($t_current_field_id == $p_field_id) {
                echo '<em>';
            }
            echo string_display(custom_field_get_field($t_current_field_id, 'name'));
            echo ' (', custom_field_get_sequence($t_current_field_id, $t_project_id), ')';
            if ($t_current_field_id == $p_field_id) {
                echo '</em>';
            }
        }
        echo '<br /><br />';
    }
}
Example #9
0
/**
 * Display a tag hyperlink.
 * If a bug ID is passed, the tag link will include a detach link if the
 * user has appropriate privileges.
 * @param array   $p_tag_row Tag row.
 * @param integer $p_bug_id  The bug ID to display.
 * @return boolean
 */
function tag_display_link(array $p_tag_row, $p_bug_id = 0)
{
    static $s_security_token = null;
    if (is_null($s_security_token)) {
        $s_security_token = htmlspecialchars(form_security_param('tag_detach'));
    }
    echo tag_get_link($p_tag_row);
    if (isset($p_tag_row['user_attached']) && auth_get_current_user_id() == $p_tag_row['user_attached'] || auth_get_current_user_id() == $p_tag_row['user_id']) {
        $t_detach = config_get('tag_detach_own_threshold');
    } else {
        $t_detach = config_get('tag_detach_threshold');
    }
    if ($p_bug_id > 0 && access_has_bug_level($t_detach, $p_bug_id)) {
        $t_tooltip = string_html_specialchars(sprintf(lang_get('tag_detach'), string_display_line($p_tag_row['name'])));
        echo '<a href="tag_detach.php?bug_id=' . $p_bug_id . '&amp;tag_id=' . $p_tag_row['id'] . $s_security_token . '"><img src="images/delete.png" class="delete-icon" title="' . $t_tooltip . '" alt="X"/></a>';
    }
    return true;
}
function GetRelationshipContent($p_bug_id, $p_html = false, $p_html_preview = false, $p_summary = false, $p_icons = false)
{
    $t_summary = '';
    $t_icons = '';
    $t_show_project = false;
    $t_summary_wrap_at = utf8_strlen(config_get('email_separator2')) - 10;
    $t_relationship_all = relationship_get_all($p_bug_id, $t_show_project);
    $t_relationship_all_count = count($t_relationship_all);
    if ($p_summary) {
        for ($i = 0; $i < $t_relationship_all_count; $i++) {
            $p_relationship = $t_relationship_all[$i];
            if ($p_bug_id == $p_relationship->src_bug_id) {
                # root bug is in the src side, related bug in the dest side
                $t_related_bug_id = $p_relationship->dest_bug_id;
                $t_relationship_descr = relationship_get_description_src_side($p_relationship->type);
            } else {
                # root bug is in the dest side, related bug in the src side
                $t_related_bug_id = $p_relationship->src_bug_id;
                $t_relationship_descr = relationship_get_description_dest_side($p_relationship->type);
            }
            # get the information from the related bug and prepare the link
            $t_bug = bug_get($t_related_bug_id, false);
            $t_text = trim(utf8_str_pad($t_relationship_descr, 20)) . ' ';
            if ($p_html_preview == true) {
                $t_text .= '<a href="' . string_get_bug_view_url($t_related_bug_id) . '"';
                $t_text .= ' class="rcv_tooltip"';
                //$t_text .= ' title="' . utf8_str_pad (bug_format_id ($t_related_bug_id), 8) . "\n" . string_attribute ($t_bug->summary) . '"';
                $t_text .= '>';
            }
            $t_text .= string_display_line(bug_format_id($t_related_bug_id));
            if ($p_html_preview == true) {
                $t_text .= '<span class="rcv_tooltip_box">';
                $t_text .= '<span class="rcv_tooltip_title">' . bug_format_id($t_related_bug_id) . '</span>';
                $t_text .= '<span class="rcv_tooltip_content">' . utf8_substr(string_email_links($t_bug->summary), 0, MAX_TOOLTIP_CONTENT_LENGTH);
                $t_text .= MAX_TOOLTIP_CONTENT_LENGTH < strlen($t_bug->summary) ? '...' : '';
                $t_text .= '</span>';
                $t_text .= '</span>';
                $t_text .= '</a>';
            }
            if (plugin_config_get('ShowRelationshipsControl') && !bug_is_readonly($p_bug_id) && !current_user_is_anonymous() && true == $p_html_preview) {
                // bug not read only
                if (access_has_bug_level(config_get('update_bug_threshold'), $p_bug_id)) {
                    // user has access level
                    // add a delete link
                    $t_text .= ' [';
                    $t_text .= '<a class="small" href="bug_relationship_delete.php?bug_id=' . $p_bug_id;
                    $t_text .= '&amp;rel_id=' . $p_relationship->id;
                    $t_text .= '&amp;redirect_url=view_all_bug_page.php';
                    $t_text .= htmlspecialchars(form_security_param('bug_relationship_delete'));
                    $t_text .= '">' . lang_get('delete_link') . '</a>';
                    $t_text .= ']';
                }
            }
            // $t_text = relationship_get_details ($p_bug_id, $t_relationship_all[$i], true, false, $t_show_project);
            if (false == $p_html) {
                // p_html == No
                if ($i != 0) {
                    if ($p_html_preview == true) {
                        $t_summary .= ",<br/>";
                    } else {
                        $t_summary .= ", ";
                    }
                }
                $t_summary .= $t_text;
            } else {
                // p_html == Yes
                if ($p_html_preview == true) {
                    $t_summary .= '<tr bgcolor="' . get_status_color($t_bug->status, auth_get_current_user_id(), $t_bug->project_id) . '">';
                    $t_summary .= '<td>' . $t_text . '</td>';
                    $t_summary .= '</tr>' . "\n";
                } else {
                    if ($i != 0) {
                        $t_summary .= ", ";
                    }
                    $t_summary .= $t_text;
                }
            }
        }
    }
    if (plugin_config_get('ShowRelationshipIcons') && !current_user_is_anonymous() && true == $p_html_preview) {
        $t_text = RelationshipsUtils::GetBugSmybols($p_bug_id, !is_blank($t_summary));
        if (!is_blank($t_text)) {
            if (false == $p_html) {
                // p_html == No
                $t_icons .= $t_text;
            } else {
                // p_html == Yes
                if ($p_html_preview == true) {
                    $t_icons .= '<tr><td>' . $t_text . '</td></tr>' . "\n";
                } else {
                    $t_icons .= $t_text;
                }
            }
        }
    }
    if ($p_html_preview == true) {
        $t_icons_table = '';
        $t_summary_table = '';
        if (!is_blank($t_icons)) {
            $t_icons_table = '<table border="0" width="100%" cellpadding="0" cellspacing="1">' . $t_icons . '</table>';
        }
        if (!is_blank($t_summary)) {
            $t_summary_table = '<table border="0" width="100%" cellpadding="0" cellspacing="1">' . $t_summary . '</table>';
        }
        if (!is_blank($t_icons_table) && !is_blank($t_summary_table)) {
            return '<table border="0" width="100%" cellpadding="0" cellspacing="0">' . '<tr><td valign="top" style="padding:0px;">' . $t_summary_table . '</td><td valign="top" style="padding:0px;">' . $t_icons_table . '</td></tr>' . '</table>';
        } else {
            return $t_summary_table . $t_icons_table;
        }
    } else {
        $t_result = $t_icons;
        if (!is_blank($t_icons) && !is_blank($t_summary)) {
            $t_result .= '<br/>';
        }
        $t_result .= $t_summary;
        return $t_result;
    }
}
Example #11
0
$t_first = true;
foreach ($t_bug_rows as $t_bug_id => $t_bug_row) {
    echo $t_first ? '' : '<tr ' . helper_alternate_class() . '>';
    ?>
<td colspan="<?php 
    echo $t_columns - ($t_can_update ? 2 : 1);
    ?>
"><?php 
    echo '<a href="view.php?id=', $t_bug_id, '">', bug_format_id($t_bug_id), '</a>: ', string_display_line($t_bug_row['summary']);
    ?>
</td>
<?php 
    if ($t_can_update) {
        ?>
<td class="center"><span class="small-links"><?php 
        print_bracket_link(plugin_page('detach') . '&id=' . $t_changeset->id . '&bug_id=' . $t_bug_id . form_security_param('plugin_Source_detach'), plugin_lang_get('detach'));
        ?>
</span>
<?php 
    }
    ?>
</tr>

<?php 
    $t_first = false;
}
if ($t_can_update) {
    if (!$t_first) {
        ?>
<tr <?php 
        echo helper_alternate_class();
function print_delete_from_testlink($tts_tproject_id, $tts_exec_id, $p_bug_id)
{
    //form using hidden fields in order to pass on data to TestLink
    // echo "Sende L&ouml;schanfrage an TestLink";
    // print_bracket_link( "onclick:bfeDeleteaction()", "L&ouml;schen" );
    echo '[<a class="small" href="' . plugin_page('tts_relationship_delete') . '&amp;bug_id=' . $p_bug_id . '&amp;exec_id=' . $tts_exec_id . '&amp;tproject_id=' . $tts_tproject_id . htmlspecialchars(form_security_param('tts_relationship_delete')) . '">' . lang_get('delete_link') . '</a>]';
    /*
    $t_tts_info_html = ' [<a class="small" href="bug_relationship_delete.php?bug_id=' . $p_bug_id . '&amp;rel_id=' . $p_relationship->id . htmlspecialchars( form_security_param( 'bug_relationship_delete' ) ) . '">' . lang_get( 'delete_link' ) . '</a>]';
    echo $t_tts_info_html;
    
    [ <a href='javascript:void(0)' onclick='bfeDeleteaction()'>L&ouml;schen</a> ]
    
    <form name="bfe_tts_delete_form" action="http://localhost/testlink/lib/execute/bugAddOrDeleteBFE.php" method="POST"> <!--  opens TestLink php file which then stores data in TestLink DB and redirects to Mantis  -->
    	<input type="hidden" name="tproject_id" id="tproject_id" value="<?php echo $tts_tproject_id; ?>">
    	<input type="hidden" name="exec_id" id="exec_id" value="<?php echo $tts_exec_id; ?>" >
    	<input type="hidden" name="bug_id" id="bug_id" value="<?php echo $p_bug_id; ?>" >
    	<input type="hidden" name="bug_delete" id="bug_delete" value="true" >
    </form>
    <script>
    function bfeDeleteaction()
    {
    	document.bfe_tts_delete_form.submit(); //send form (after click on bracketlink)
    }
    </script>
    */
}
Example #13
0
        echo $t_stats['files'];
        ?>
</td>
<td class="right"><?php 
        echo $t_stats['bugs'];
        ?>
</td>
<?php 
    }
    ?>
<td class="center">
<?php 
    print_bracket_link(plugin_page('list') . '&id=' . $t_repo->id, plugin_lang_get('changesets'));
    if ($t_can_manage) {
        if (preg_match('/^Import \\d+-\\d+\\d+/', $t_repo->name)) {
            print_bracket_link(plugin_page('repo_delete') . '&id=' . $t_repo->id . form_security_param('plugin_Source_repo_delete'), plugin_lang_get('delete'));
        }
        print_bracket_link(plugin_page('repo_manage_page') . '&id=' . $t_repo->id, plugin_lang_get('manage'));
    }
    ?>
</td>
</tr>
<?php 
}
?>

</table>

<?php 
if ($t_can_manage) {
    ?>
Example #14
0
function print_bug_attachments_list($p_bug_id)
{
    $t_attachments = file_get_visible_attachments($p_bug_id);
    $t_attachments_count = count($t_attachments);
    $i = 0;
    $image_previewed = false;
    foreach ($t_attachments as $t_attachment) {
        $t_file_display_name = string_display_line($t_attachment['display_name']);
        $t_filesize = number_format($t_attachment['size']);
        $t_date_added = date(config_get('normal_date_format'), $t_attachment['date_added']);
        if ($image_previewed) {
            $image_previewed = false;
            echo '<br />';
        }
        if ($t_attachment['can_download']) {
            $t_href_start = '<a href="' . string_attribute($t_attachment['download_url']) . '">';
            $t_href_end = '</a>';
            $t_href_clicket = " [<a href=\"file_download.php?file_id={$t_attachment['id']}&amp;type=bug\" target=\"_blank\">^</a>]";
        } else {
            $t_href_start = '';
            $t_href_end = '';
            $t_href_clicket = '';
        }
        if (!$t_attachment['exists']) {
            print_file_icon($t_file_display_name);
            echo '&#160;<span class="strike">' . $t_file_display_name . '</span>' . lang_get('word_separator') . '(' . lang_get('attachment_missing') . ')';
        } else {
            echo $t_href_start;
            print_file_icon($t_file_display_name);
            echo $t_href_end . '&#160;' . $t_href_start . $t_file_display_name . $t_href_end . $t_href_clicket . ' (' . $t_filesize . ' ' . lang_get('bytes') . ') ' . '<span class="italic">' . $t_date_added . '</span>';
        }
        if ($t_attachment['can_delete']) {
            echo '&#160;[';
            print_link('bug_file_delete.php?file_id=' . $t_attachment['id'] . form_security_param('bug_file_delete'), lang_get('delete_link'), false, 'small');
            echo ']';
        }
        if ($t_attachment['exists']) {
            if (FTP == config_get('file_upload_method') && $t_attachment['exists']) {
                echo ' (' . lang_get('cached') . ')';
            }
            if ($t_attachment['preview'] && $t_attachment['type'] == 'text') {
                $c_id = db_prepare_int($t_attachment['id']);
                $t_bug_file_table = db_get_table('mantis_bug_file_table');
                echo "<script type=\"text/javascript\" language=\"JavaScript\">\n<!--\nfunction swap_content( span ) {\ndisplayType = ( document.getElementById( span ).style.display == 'none' ) ? '' : 'none';\ndocument.getElementById( span ).style.display = displayType;\n}\n\n -->\n </script>";
                echo " <span id=\"hideSection_{$c_id}\">[<a class=\"small\" href='#' id='attmlink_" . $c_id . "' onclick='swap_content(\"hideSection_" . $c_id . "\");swap_content(\"showSection_" . $c_id . "\");return false;'>" . lang_get('show_content') . "</a>]</span>";
                echo " <span style='display:none' id=\"showSection_{$c_id}\">[<a class=\"small\" href='#' id='attmlink_" . $c_id . "' onclick='swap_content(\"hideSection_" . $c_id . "\");swap_content(\"showSection_" . $c_id . "\");return false;'>" . lang_get('hide_content') . "</a>]";
                echo "<pre>";
                /** @todo Refactor into a method that gets contents for download / preview. */
                switch (config_get('file_upload_method')) {
                    case DISK:
                        if ($t_attachment['exists']) {
                            $v_content = file_get_contents($t_attachment['diskfile']);
                        }
                        break;
                    case FTP:
                        if (file_exists($t_attachment['exists'])) {
                            file_get_contents($t_attachment['diskfile']);
                        } else {
                            $ftp = file_ftp_connect();
                            file_ftp_get($ftp, $t_attachment['diskfile'], $t_attachment['diskfile']);
                            file_ftp_disconnect($ftp);
                            $v_content = file_get_contents($t_attachment['diskfile']);
                        }
                        break;
                    default:
                        $query = "SELECT *\n\t                  \t\t\t\t\tFROM {$t_bug_file_table}\n\t\t\t\t            \t\t\tWHERE id=" . db_param();
                        $result = db_query_bound($query, array($c_id));
                        $row = db_fetch_array($result);
                        $v_content = $row['content'];
                }
                echo htmlspecialchars($v_content);
                echo "</pre></span>\n";
            }
            if ($t_attachment['can_download'] && $t_attachment['preview'] && $t_attachment['type'] == 'image') {
                $t_preview_style = 'border: 0;';
                $t_max_width = config_get('preview_max_width');
                if ($t_max_width > 0) {
                    $t_preview_style .= ' max-width:' . $t_max_width . 'px;';
                }
                $t_max_height = config_get('preview_max_height');
                if ($t_max_height > 0) {
                    $t_preview_style .= ' max-height:' . $t_max_height . 'px;';
                }
                $t_preview_style = 'style="' . $t_preview_style . '"';
                $t_title = file_get_field($t_attachment['id'], 'title');
                $t_image_url = $t_attachment['download_url'] . '&amp;show_inline=1' . form_security_param('file_show_inline');
                echo "\n<br />{$t_href_start}<img alt=\"{$t_title}\" {$t_preview_style} src=\"{$t_image_url}\" />{$t_href_end}";
                $image_previewed = true;
            }
        }
        if ($i != $t_attachments_count - 1) {
            echo "<br />\n";
            $i++;
        }
    }
}
    if (isset($t_user['realname']) && $t_user['realname'] > "" && ON == config_get('show_realname')) {
        $t_user_name = string_attribute($t_user['realname']) . " (" . $t_user_name . ")";
        if (ON == config_get('sort_by_last_name')) {
            $t_sort_name_bits = split(' ', strtolower($t_user_name), 2);
            $t_sort_name = $t_sort_name_bits[1] . ', ' . $t_sort_name_bits[1];
        } else {
            $t_sort_name = strtolower($t_user_name);
        }
    }
    $t_display[] = $t_user_name;
    $t_sort[] = $t_sort_name;
}
array_multisort($t_sort, SORT_ASC, SORT_STRING, $t_users, $t_display);
# reset the class counter
helper_alternate_class(0);
$t_user_remove_security = form_security_param('manage_proj_user_remove');
for ($i = 0; $i < count($t_sort); $i++) {
    $t_user = $t_users[$i];
    ?>
		<tr <?php 
    echo helper_alternate_class();
    ?>
>
			<td>
				<?php 
    echo $t_display[$i];
    ?>
			</td>
			<td>
			<?php 
    $t_email = user_get_email($t_user['id']);
Example #16
0
/**
 * Prints the preview of an image file attachment.
 * @param array $p_attachment An attachment arrray from within the array returned by the file_get_visible_attachments() function
 */
function print_bug_attachment_preview_image($p_attachment)
{
    $t_preview_style = 'border: 0;';
    $t_max_width = config_get('preview_max_width');
    if ($t_max_width > 0) {
        $t_preview_style .= ' max-width:' . $t_max_width . 'px;';
    }
    $t_max_height = config_get('preview_max_height');
    if ($t_max_height > 0) {
        $t_preview_style .= ' max-height:' . $t_max_height . 'px;';
    }
    $t_title = file_get_field($p_attachment['id'], 'title');
    $t_image_url = $p_attachment['download_url'] . '&show_inline=1' . form_security_param('file_show_inline');
    echo "\n<div class=\"bug-attachment-preview-image\">";
    echo '<a href="' . string_attribute($p_attachment['download_url']) . '">';
    echo '<img src="' . string_attribute($t_image_url) . '" alt="' . string_attribute($t_title) . '" style="' . string_attribute($t_preview_style) . '" />';
    echo '</a></div>';
}
Example #17
0
    /**
     * Show TimeTracking information when viewing bugs.
     * @param string Event name
     * @param int Bug ID
     */
    function view_bug_time($p_event, $p_bug_id)
    {
        $table = plugin_table('data');
        $t_user_id = auth_get_current_user_id();
        # Pull all Time-Record entries for the current Bug
        if (access_has_bug_level(plugin_config_get('view_others_threshold'), $p_bug_id)) {
            $query_pull_timerecords = "SELECT * FROM {$table} WHERE bug_id = {$p_bug_id} ORDER BY timestamp DESC";
        } else {
            if (access_has_bug_level(plugin_config_get('admin_own_threshold'), $p_bug_id)) {
                $query_pull_timerecords = "SELECT * FROM {$table} WHERE bug_id = {$p_bug_id} and user = {$t_user_id} ORDER BY timestamp DESC";
            } else {
                // User has no access
                return;
            }
        }
        $result_pull_timerecords = db_query($query_pull_timerecords);
        $num_timerecords = db_num_rows($result_pull_timerecords);
        # Get Sum for this bug
        $query_pull_hours = "SELECT SUM(hours) as hours FROM {$table} WHERE bug_id = {$p_bug_id}";
        $result_pull_hours = db_query($query_pull_hours);
        $row_pull_hours = db_fetch_array($result_pull_hours);
        ?>


   <a name="timerecord" id="timerecord" /><br />

<?php 
        collapse_open('timerecord');
        ?>
   <table class="width100" cellspacing="1">
   <tr>
      <td colspan="6" class="form-title">
<?php 
        collapse_icon('timerecord');
        echo plugin_lang_get('title');
        ?>
      </td>
   </tr>
   <tr class="row-category">
      <td><div align="center"><?php 
        echo plugin_lang_get('user');
        ?>
</div></td>
      <td><div align="center"><?php 
        echo plugin_lang_get('expenditure_date');
        ?>
</div></td>
      <td><div align="center"><?php 
        echo plugin_lang_get('hours');
        ?>
</div></td>
      <td><div align="center"><?php 
        echo plugin_lang_get('information');
        ?>
</div></td>
      <td><div align="center"><?php 
        echo plugin_lang_get('entry_date');
        ?>
</div></td>
      <td>&nbsp;</td>
   </tr>


<?php 
        if (access_has_bug_level(plugin_config_get('admin_own_threshold'), $p_bug_id)) {
            $current_date = explode("-", date("Y-m-d"));
            ?>


   <form name="time_tracking" method="post" action="<?php 
            echo plugin_page('add_record');
            ?>
" >
      <?php 
            echo form_security_field('plugin_TimeTracking_add_record');
            ?>

      <input type="hidden" name="bug_id" value="<?php 
            echo $p_bug_id;
            ?>
">

   <tr <?php 
            echo helper_alternate_class();
            ?>
>
     <td><?php 
            echo user_get_name(auth_get_current_user_id());
            ?>
</td>
     <td nowrap>
        <div align="center">
           <select tabindex="5" name="day"><?php 
            print_day_option_list($current_date[2]);
            ?>
</select>
           <select tabindex="6" name="month"><?php 
            print_month_option_list($current_date[1]);
            ?>
</select>
           <select tabindex="7" name="year"><?php 
            print_year_option_list($current_date[0]);
            ?>
</select>
        </div>
     </td>
     <td><div align="right"><input type="text" name="time_value" value="00:00" size="5"></div></td>
     <td><div align="center"><input type="text" name="time_info"></div></td>
     <td>&nbsp;</td>
     <td><input name="<?php 
            echo plugin_lang_get('submit');
            ?>
" type="submit" value="<?php 
            echo plugin_lang_get('submit');
            ?>
"></td>
   </tr>
</form>

<?php 
        }
        # END Access Control
        for ($i = 0; $i < $num_timerecords; $i++) {
            $row = db_fetch_array($result_pull_timerecords);
            ?>


   <tr <?php 
            echo helper_alternate_class();
            ?>
>
      <td><?php 
            echo user_get_name($row["user"]);
            ?>
</td>
      <td><div align="center"><?php 
            echo date(config_get("short_date_format"), strtotime($row["expenditure_date"]));
            ?>
 </div></td>
      <td><div align="right"><?php 
            echo db_minutes_to_hhmm($row["hours"] * 60);
            ?>
 </div></td>
      <td><div align="center"><?php 
            echo string_display_links($row["info"]);
            ?>
</div></td>
      <td><div align="center"><?php 
            echo date(config_get("complete_date_format"), strtotime($row["timestamp"]));
            ?>
 </div></td>

<?php 
            $user = auth_get_current_user_id();
            if ($user == $row["user"] && access_has_bug_level(plugin_config_get('admin_own_threshold'), $p_bug_id) || access_has_bug_level(plugin_config_get('admin_threshold'), $p_bug_id)) {
                ?>


      <td><a href="<?php 
                echo plugin_page('delete_record');
                ?>
&bug_id=<?php 
                echo $p_bug_id;
                ?>
&delete_id=<?php 
                echo $row["id"];
                echo form_security_param('plugin_TimeTracking_delete_record');
                ?>
"><?php 
                echo plugin_lang_get('delete');
                ?>
</a></td>

<?php 
            } else {
                ?>
      <td>&nbsp;</td>

<?php 
            }
            ?>
   </tr>


<?php 
        }
        # End for loop
        ?>


   <tr class="row-category">
      <td><?php 
        echo plugin_lang_get('sum');
        ?>
</td>
      <td>&nbsp;</td>
      <td><div align="right"><b><?php 
        echo db_minutes_to_hhmm($row_pull_hours['hours'] * 60);
        ?>
</b></div></td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
   </tr>
</table>

<?php 
        collapse_closed('timerecord');
        ?>

<table class="width100" cellspacing="1">
<tr>
   <td class="form-title" colspan="2">
          <?php 
        collapse_icon('timerecord');
        ?>
          <?php 
        echo plugin_lang_get('title');
        ?>
	</td>
</tr>
</table>

<?php 
        collapse_end('timerecord');
    }