Esempio n. 1
0
 /**
  * Export Issues Menu
  * @return array
  */
 function export_issues_menu()
 {
     if (!access_has_project_level(plugin_config_get('export_threshold'))) {
         return array();
     }
     return array('<a href="' . plugin_page('export') . '">' . plugin_lang_get('export') . '</a>');
 }
/**
 * Prints the field within the custom action form.  This has an entry for
 * every field the user need to supply + the submit button.  The fields are
 * added as rows in a table that is already created by the calling code.
 * A row has two columns.
 */
function action_add_note_print_fields()
{
    echo '<tr class="row-1" valign="top"><td class="category">', lang_get('add_bugnote_title'), '</td><td><textarea name="bugnote_text" cols="80" rows="10"></textarea></td></tr>';
    ?>
	<!-- View Status -->
	<tr class="row-2">
	<td class="category">
		<?php 
    echo lang_get('view_status');
    ?>
	</td>
	<td>
<?php 
    $t_default_state = config_get('default_bugnote_view_status');
    if (access_has_project_level(config_get('set_view_status_threshold'))) {
        ?>
			<select name="view_state">
				<?php 
        print_enum_string_option_list('view_state', $t_default_state);
        ?>
			</select>
<?php 
    } else {
        echo get_enum_element('view_state', $t_default_state);
        echo '<input type="hidden" name="view_state" value="', $t_default_state, '" />';
    }
    ?>
	</td>
	</tr>
	<?php 
    echo '<tr><td colspan="2"><center><input type="submit" class="button" value="' . lang_get('add_bugnote_button') . ' " /></center></td></tr>';
}
Esempio n. 3
0
/**
 * Get username, realname and email from for a given user id
 * @param integer $p_user_id A valid user identifier.
 * @return array
 */
function mci_account_get_array_by_id($p_user_id)
{
    $t_result = array();
    $t_result['id'] = $p_user_id;
    if (user_exists($p_user_id)) {
        $t_current_user_id = auth_get_current_user_id();
        $t_access_level = user_get_field($t_current_user_id, 'access_level');
        $t_can_manage = access_has_global_level(config_get('manage_user_threshold')) && access_has_global_level($t_access_level);
        # this deviates from the behaviour of view_user_page.php, but it is more intuitive
        $t_is_same_user = $t_current_user_id === $p_user_id;
        $t_can_see_realname = access_has_project_level(config_get('show_user_realname_threshold'));
        $t_can_see_email = access_has_project_level(config_get('show_user_email_threshold'));
        $t_result['name'] = user_get_field($p_user_id, 'username');
        if ($t_is_same_user || $t_can_manage || $t_can_see_realname) {
            $t_realname = user_get_realname($p_user_id);
            if (!empty($t_realname)) {
                $t_result['real_name'] = $t_realname;
            }
        }
        if ($t_is_same_user || $t_can_manage || $t_can_see_email) {
            $t_email = user_get_email($p_user_id);
            if (!empty($t_email)) {
                $t_result['email'] = $t_email;
            }
        }
    }
    return $t_result;
}
Esempio n. 4
0
 function menu_main()
 {
     $t_links = array();
     if (plugin_config_get('show_gantt_roadmap_link') && access_has_project_level(config_get('view_summary_threshold'))) {
         $t_page = plugin_page('summary_gantt_chart_page', false, 'GanttChart');
         $t_lang = plugin_lang_get('menu', 'GanttChart');
         $t_links[] = "<a href=\"{$t_page}\">{$t_lang}</a>";
     }
     return $t_links;
 }
 /**
  * When reporting a bug, show appropriate form elements to the user.
  * @param string Event name
  * @param int Project ID
  */
 function report_bug_form($p_event, $p_project_id)
 {
     if (plugin_config_get('use_estimates') && access_has_project_level(plugin_config_get('estimate_threshold'), $p_project_id)) {
         echo '<tr ', helper_alternate_class(), '><td class="category">', plugin_lang_get('estimate'), '<input type="hidden" name="plugin_timecard" value="1"/>', '</td><td><input name="plugin_timecard_estimate" size="8" maxlength="64"/>', plugin_lang_get('hours'), '</td></tr>';
     }
     if (plugin_config_get('use_timecard')) {
         $t_project = TimecardProject::load($p_project_id);
         echo '<tr ', helper_alternate_class(), '><td class="category">', plugin_lang_get('timecard'), '</td><td><input name="plugin_timecard_string" value="', $t_project->timecard, '" size="15" maxlength="64"/></td></tr>';
     }
 }
/**
 * Delete a project attachment given its id.
 *
 * @param string $p_username  The name of the user trying to add an attachment to an issue.
 * @param string $p_password  The password of the user.
 * @param integer $p_project_attachment_id  The id of the attachment to be deleted.
 * @return true: success, false: failure
 */
function mc_project_attachment_delete( $p_username, $p_password, $p_project_attachment_id ) {
	$t_user_id = mci_check_login( $p_username, $p_password );
	if( $t_user_id === false ) {
		return mci_soap_fault_login_failed();
	}
	$t_project_id = file_get_field( $p_project_attachment_id, 'project_id', 'project' );
	if( !access_has_project_level( config_get( 'upload_project_file_threshold' ), $t_project_id, $t_user_id ) ) {
		return mci_soap_fault_access_denied( $t_user_id );
	}
	return file_delete( $p_project_attachment_id, 'project' );
}
Esempio n. 7
0
function prepare_email_link($p_email, $p_text)
{
    if (!access_has_project_level(config_get('show_user_email_threshold'))) {
        return $p_text;
    }
    # If we apply string_url() to the whole mailto: link then the @
    #  gets turned into a %40 and you can't right click in browsers to
    #  do Copy Email Address.
    $t_mailto = string_attribute("mailto:{$p_email}");
    $p_text = string_display($p_text);
    return "<a href=\"{$t_mailto}\">{$p_text}</a>";
}
/**
 * A function that prepares the version string for outputting to the user on view / print issue pages.
 * This function would add the version date, if appropriate.
 *
 * @param integer $p_project_id  The project id.
 * @param integer $p_version_id  The version id.  If false then this method will return an empty string.
 * @return The formatted version string.
 */
function prepare_version_string($p_project_id, $p_version_id)
{
    if ($p_version_id === false) {
        return '';
    }
    $t_version_text = version_full_name($p_version_id, null, $p_project_id);
    if (access_has_project_level(config_get('show_version_dates_threshold'), $p_project_id)) {
        $t_short_date_format = config_get('short_date_format');
        $t_version = version_get($p_version_id);
        $t_version_text .= ' (' . date($t_short_date_format, $t_version->date_order) . ')';
    }
    return $t_version_text;
}
Esempio n. 9
0
 /**
  * Gets the avatar information for the user.  The avatars are provided by
  * plugins that can integrate with a variety of services like gravatar.com,
  * LDAP, Social Identities, etc.
  *
  * If logged in user doesn't have access to view avatars or not avatar is found,
  * then a default avatar will be used.
  *
  * Note that the provided user id may no longer has a corresponding user in the
  * system, if the user was deleted.
  *
  * @param integer $p_user_id  The user id.
  * @param integer $p_size     The desired width/height of the avatar.
  *
  * @return array The array with avatar information.
  */
 public static function get($p_user_id, $p_size = 80)
 {
     $t_enabled = config_get('show_avatar') !== OFF;
     $t_avatar = null;
     if ($t_enabled) {
         $t_user_exists = user_exists($p_user_id);
         if ($t_user_exists && access_has_project_level(config_get('show_avatar_threshold'), null, $p_user_id)) {
             $t_avatar = event_signal('EVENT_USER_AVATAR', array($p_user_id, $p_size));
         }
         if ($t_avatar === null) {
             $t_avatar = new Avatar();
         }
         $t_avatar->normalize($p_user_id, $t_user_exists);
     }
     return $t_avatar;
 }
    function display_bug($p_event, $p_bug_id)
    {
        require_once 'Source.ViewAPI.php';
        $t_project_id = bug_get_field($p_bug_id, 'project_id');
        $t_view_threshold = config_get('plugin_Source_view_threshold');
        if (!access_has_project_level($t_view_threshold, $t_project_id)) {
            return;
        }
        $t_changesets = $this->changesets;
        if (count($t_changesets) < 1) {
            return;
        }
        collapse_open('Source');
        ?>
<br/>
<a name="changesets"/>
<table class="width100" cellspacing="1">

<tr>
	<td class="form-title"><?php 
        collapse_icon('Source');
        echo plugin_lang_get('related_changesets', 'Source');
        ?>
</td>
</tr>
		<?php 
        Source_View_Changesets($t_changesets);
        ?>
</table>
<?php 
        collapse_closed('Source');
        ?>
<br/>
<table class="width100" cellspacing="1">

<tr>
	<td class="form-title"><?php 
        collapse_icon('Source');
        echo plugin_lang_get('related_changesets', 'Source');
        ?>
</td>
</tr>

</table>
<?php 
        collapse_end('Source');
    }
Esempio n. 11
0
        collapse_icon('profile');
        echo lang_get('or_fill_in');
        ?>
			<?php 
        collapse_end('profile');
        ?>
		<?php 
    }
    ?>
		</td>
	</tr>
<?php 
}
if ($t_show_product_version) {
    $t_product_version_released_mask = VERSION_RELEASED;
    if (access_has_project_level(config_get('report_issues_for_unreleased_versions_threshold'))) {
        $t_product_version_released_mask = VERSION_ALL;
    }
    ?>
	<tr>
		<th class="category">
			<label for="product_version"><?php 
    echo lang_get('product_version');
    ?>
</label>
		</th>
		<td>
			<select <?php 
    echo helper_get_tab_index();
    ?>
 id="product_version" name="product_version">
Esempio n. 12
0
function helper_get_columns_to_view($p_columns_target = COLUMNS_TARGET_VIEW_PAGE)
{
    $t_columns = helper_call_custom_function('get_columns_to_view', array($p_columns_target));
    $t_enable_sponsorship = config_get('enable_sponsorship');
    if (OFF == $t_enable_sponsorship) {
        $t_keys = array_keys($t_columns, 'sponsorship_total');
        foreach ($t_keys as $t_key) {
            unset($t_columns[$t_key]);
        }
    }
    $t_show_attachments = config_get('show_attachment_indicator');
    if (OFF == $t_show_attachments) {
        $t_keys = array_keys($t_columns, 'attachment');
        foreach ($t_keys as $t_key) {
            unset($t_columns[$t_key]);
        }
    }
    if (OFF == config_get('enable_relationship')) {
        $t_keys = array_keys($t_columns, 'duplicate_id');
        foreach ($t_keys as $t_key) {
            unset($t_columns[$t_key]);
        }
    }
    $t_current_project_id = helper_get_current_project();
    if ($t_current_project_id != ALL_PROJECTS && !access_has_project_level(config_get('roadmap_view_threshold'), $t_current_project_id)) {
        $t_keys = array_keys($t_columns, 'target_version');
        foreach ($t_keys as $t_key) {
            unset($t_columns[$t_key]);
        }
    }
    # get the array values to remove gaps in the array which causes issue
    # if the array is accessed using an index.
    return array_values($t_columns);
}
Esempio n. 13
0
/**
 * Note: any changes made in this function should be reflected in
 * mci_filter_db_get_available_queries())
 * @param integer $p_project_id A valid project identifier.
 * @param integer $p_user_id    A valid user identifier.
 * @return mixed
 */
function filter_db_get_available_queries($p_project_id = null, $p_user_id = null)
{
    $t_overall_query_arr = array();
    if (null === $p_project_id) {
        $t_project_id = helper_get_current_project();
    } else {
        $t_project_id = (int) $p_project_id;
    }
    if (null === $p_user_id) {
        $t_user_id = auth_get_current_user_id();
    } else {
        $t_user_id = (int) $p_user_id;
    }
    # If the user doesn't have access rights to stored queries, just return
    if (!access_has_project_level(config_get('stored_query_use_threshold'))) {
        return $t_overall_query_arr;
    }
    # Get the list of available queries. By sorting such that public queries are
    # first, we can override any query that has the same name as a private query
    # with that private one
    $t_query = 'SELECT * FROM {filters}
					WHERE (project_id=' . db_param() . '
						OR project_id=0)
					AND name!=\'\'
					AND (is_public = ' . db_param() . '
						OR user_id = ' . db_param() . ')
					ORDER BY is_public DESC, name ASC';
    $t_result = db_query($t_query, array($t_project_id, true, $t_user_id));
    while ($t_row = db_fetch_array($t_result)) {
        $t_overall_query_arr[$t_row['id']] = $t_row['name'];
    }
    $t_overall_query_arr = array_unique($t_overall_query_arr);
    asort($t_overall_query_arr);
    return $t_overall_query_arr;
}
function get_capability_enum($p_caption, $p_threshold, $p_enum, $p_all_projects_only = false)
{
    global $t_user, $t_project_id, $t_show_submit, $t_access_levels, $t_colour_project, $t_colour_global;
    $t_file = config_get_global($p_threshold);
    $t_global = config_get($p_threshold, null, null, ALL_PROJECTS);
    $t_project = config_get($p_threshold);
    $t_can_change = access_has_project_level(config_get_access($p_threshold), $t_project_id, $t_user) && (ALL_PROJECTS == $t_project_id || !$p_all_projects_only);
    $t_colour = '';
    if ($t_global != $t_file) {
        $t_colour = ' bgcolor="' . $t_colour_global . '" ';
        # all projects override
        if ($t_can_change) {
            set_overrides($p_threshold);
        }
    }
    if ($t_project != $t_global) {
        $t_colour = ' bgcolor="' . $t_colour_project . '" ';
        # project overrides
        if ($t_can_change) {
            set_overrides($p_threshold);
        }
    }
    echo '<tr ' . helper_alternate_class() . '><td>' . string_display($p_caption) . '</td>';
    if ($t_can_change) {
        echo '<td class="left" colspan="3"' . $t_colour . '><select name="flag_' . $p_threshold . '">';
        print_enum_string_option_list($p_enum, config_get($p_threshold));
        echo '</select></td><td colspan="' . (count($t_access_levels) - 3) . '"></td>';
        $t_show_submit = true;
    } else {
        $t_value = MantisEnum::getLabel(lang_get($p_enum . '_enum_string'), config_get($p_threshold)) . '&nbsp;';
        echo '<td class="left" colspan="3"' . $t_colour . '>' . $t_value . '</td><td colspan="' . (count($t_access_levels) - 3) . '"></td>';
    }
    if ($t_can_change) {
        echo '<td><select name="access_' . $p_threshold . '">';
        print_enum_string_option_list('access_levels', config_get_access($p_threshold));
        echo '</select> </td>';
    } else {
        echo '<td>' . MantisEnum::getLabel(lang_get('access_levels_enum_string'), config_get_access($p_threshold)) . '&nbsp;</td>';
    }
    echo '</tr>' . "\n";
}
Esempio n. 15
0
?>


<!-- View Status -->
<tr <?php 
echo helper_alternate_class();
?>
>
	<td class="category">
		<?php 
echo lang_get('view_status');
?>
	</td>
	<td>
<?php 
if (access_has_project_level(config_get('set_view_status_threshold'))) {
    ?>
		<input <?php 
    echo helper_get_tab_index();
    ?>
 type="radio" name="view_state" value="<?php 
    echo VS_PUBLIC;
    ?>
" <?php 
    check_checked($f_view_state, VS_PUBLIC);
    ?>
 /> <?php 
    echo lang_get('public');
    ?>
		<input <?php 
    echo helper_get_tab_index();
Esempio n. 16
0
<tr>
	<td class="worklog-content">
<?php 
    echo $v_content;
    ?>
	</td>
</tr>
</table>
</div>
<?php 
}
# end for loop
?>

<p>
<div align="center">
	<?php 
if (access_has_project_level(DEVELOPER)) {
    global $g_worklog_edit_page, $g_worklog_delete_page;
    print_bracket_link($g_worklog_edit_page . "&f_id={$v_id}", lang_get('bugnote_edit_link'));
    print_bracket_link($g_worklog_delete_page . "&f_id={$v_id}", lang_get('delete_link'));
}
global $g_worklog_menu_page;
if (OFF == plugin_config_get('worklog_view_window')) {
    print_bracket_link($g_worklog_menu_page, lang_get('back_link'));
}
?>
</div>

<?php 
html_page_bottom1();
Esempio n. 17
0
/**
 * Returns the attachment contents
 *
 * @param int $p_file_id
 * @param string $p_type The file type, bug or doc
 * @param int $p_user_id
 * @return string|soap_fault the string contents, or a soap_fault
 */
function mci_file_get($p_file_id, $p_type, $p_user_id)
{
    # we handle the case where the file is attached to a bug
    # or attached to a project as a project doc.
    $query = '';
    switch ($p_type) {
        case 'bug':
            $t_bug_file_table = db_get_table('bug_file');
            $query = "SELECT *\n\t\t\t\tFROM {$t_bug_file_table}\n\t\t\t\tWHERE id='{$p_file_id}'";
            break;
        case 'doc':
            $t_project_file_table = db_get_table('project_file');
            $query = "SELECT *\n\t\t\t\tFROM {$t_project_file_table}\n\t\t\t\tWHERE id='{$p_file_id}'";
            break;
        default:
            return new soap_fault('Server', '', 'Invalid file type ' . $p_type . ' .');
    }
    $result = db_query($query);
    if ($result->EOF) {
        return new soap_fault('Client', '', 'Unable to find an attachment with type ' . $p_type . ' and id ' . $p_file_id . ' .');
    }
    $row = db_fetch_array($result);
    if ($p_type == 'doc') {
        $t_project_id = $row['project_id'];
    } else {
        if ($p_type == 'bug') {
            $t_bug_id = $row['bug_id'];
            $t_project_id = bug_get_field($t_bug_id, 'project_id');
        }
    }
    $t_diskfile = file_normalize_attachment_path($row['diskfile'], $t_project_id);
    $t_content = $row['content'];
    # Check access rights
    switch ($p_type) {
        case 'bug':
            if (!mci_file_can_download_bug_attachments($t_bug_id, $p_user_id)) {
                return mci_soap_fault_access_denied($p_user_id);
            }
            break;
        case 'doc':
            # Check if project documentation feature is enabled.
            if (OFF == config_get('enable_project_documentation')) {
                return mci_soap_fault_access_denied($p_user_id);
            }
            if (!access_has_project_level(config_get('view_proj_doc_threshold'), $t_project_id, $p_user_id)) {
                return mci_soap_fault_access_denied($p_user_id);
            }
            break;
    }
    # dump file content to the connection.
    switch (config_get('file_upload_method')) {
        case DISK:
            if (file_exists($t_diskfile)) {
                return mci_file_read_local($t_diskfile);
            } else {
                return new soap_fault('Client', '', 'Unable to find an attachment with type ' . $p_type . ' and id ' . $p_file_id . ' .');
            }
        case FTP:
            if (file_exists($t_diskfile)) {
                return mci_file_read_local($t_diskfile);
            } else {
                $ftp = file_ftp_connect();
                file_ftp_get($ftp, $t_diskfile, $t_diskfile);
                file_ftp_disconnect($ftp);
                return mci_file_read_local($t_diskfile);
            }
        default:
            return $t_content;
    }
}
Esempio n. 18
0
access_ensure_project_level(VIEWER);
html_page_top();
?>

<br />
<?php 
# Select the news posts
$rows = news_get_rows(helper_get_current_project());
$t_count = count($rows);
if ($t_count > 0) {
    ?>
	<ul><?php 
    # Loop through results
    for ($i = 0; $i < $t_count; $i++) {
        extract($rows[$i], EXTR_PREFIX_ALL, 'v');
        if (VS_PRIVATE == $v_view_state && !access_has_project_level(config_get('private_news_threshold'), $v_project_id)) {
            continue;
        }
        $v_headline = string_display($v_headline);
        $v_date_posted = date(config_get('complete_date_format'), $v_date_posted);
        ?>
		<li>
			<span class="news-date-posted"><?php 
        echo $v_date_posted;
        ?>
</span>
			<span class="news-headline"><a href="news_view_page.php?news_id=<?php 
        echo $v_id;
        ?>
"><?php 
        echo $v_headline;
Esempio n. 19
0
function get_email_link_with_subject($p_email, $p_text, $p_summary)
{
    if (!access_has_project_level(config_get('show_user_email_threshold'))) {
        return $p_text;
    }
    # If we apply string_url() to the whole mailto: link then the @
    #  gets turned into a %40 and you can't right click in browsers to
    #  do Copy Email Address.  If we don't apply string_url() to the
    #  summary text then an ampersand (for example) will truncate the text
    $t_summary = string_url($p_summary);
    $t_email = string_url($p_email);
    $t_mailto = string_attribute("mailto:{$t_email}?subject={$t_summary}");
    $t_text = string_display($p_text);
    return "<a href=\"{$t_mailto}\">{$t_text}</a>";
}
Esempio n. 20
0
/**
 * Print column content for column target version
 *
 * @param BugData $p_bug bug object
 * @param int $p_columns_target see COLUMNS_TARGET_* in constant_inc.php
 * @return null
 * @access public
 */
function print_column_target_version($p_bug, $p_columns_target = COLUMNS_TARGET_VIEW_PAGE)
{
    echo '<td class="column-target-version">';
    # In case of a specific project, if the current user has no access to the field, then it would have been excluded from the
    # list of columns to view.  In case of ALL_PROJECTS, then we need to check the access per row.
    if (helper_get_current_project() != ALL_PROJECTS || access_has_project_level(config_get('roadmap_view_threshold'), $p_bug->project_id)) {
        echo string_display_line($p_bug->target_version);
    }
    echo '</td>';
}
Esempio n. 21
0
$t_bug_data->resolution = gpc_get_string('resolution', config_get('default_bug_resolution'));
$t_bug_data->status = gpc_get_string('status', config_get('bug_submit_status'));
$t_bug_data->summary = trim(gpc_get_string('summary'));
$t_bug_data->description = gpc_get_string('description');
$t_bug_data->steps_to_reproduce = gpc_get_string('steps_to_reproduce', config_get('default_bug_steps_to_reproduce'));
$t_bug_data->additional_information = gpc_get_string('additional_info', config_get('default_bug_additional_info'));
$t_bug_data->due_date = gpc_get_string('due_date', '');
if (is_blank($t_bug_data->due_date)) {
    $t_bug_data->due_date = date_get_null();
}
$f_files = gpc_get_file('ufile', null);
/** @todo (thraxisp) Note that this always returns a structure */
$f_report_stay = gpc_get_bool('report_stay', false);
$f_copy_notes_from_parent = gpc_get_bool('copy_notes_from_parent', false);
$f_copy_attachments_from_parent = gpc_get_bool('copy_attachments_from_parent', false);
if (access_has_project_level(config_get('roadmap_update_threshold'), $t_bug_data->project_id)) {
    $t_bug_data->target_version = gpc_get_string('target_version', '');
}
# if a profile was selected then let's use that information
if (0 != $t_bug_data->profile_id) {
    if (profile_is_global($t_bug_data->profile_id)) {
        $row = user_get_profile_row(ALL_USERS, $t_bug_data->profile_id);
    } else {
        $row = user_get_profile_row($t_bug_data->reporter_id, $t_bug_data->profile_id);
    }
    if (is_blank($t_bug_data->platform)) {
        $t_bug_data->platform = $row['platform'];
    }
    if (is_blank($t_bug_data->os)) {
        $t_bug_data->os = $row['os'];
    }
Esempio n. 22
0
/**
 * Get the custom fields that belong to the specified project.
 *
 * @param string $p_username  The name of the user trying to access the versions.
 * @param string $p_password  The password of the user.
 * @param integer $p_project_id  The id of the project to retrieve the custom fields for.
 * @return Array  representing a CustomFieldDefinitionDataArray structure.
 */
function mc_project_get_custom_fields($p_username, $p_password, $p_project_id)
{
    $t_user_id = mci_check_login($p_username, $p_password);
    if ($t_user_id === false) {
        return mci_soap_fault_login_failed();
    }
    if (!project_exists($p_project_id)) {
        return new soap_fault('Client', '', "Project '{$p_project_id}' does not exist.");
    }
    if (!mci_has_readonly_access($t_user_id, $p_project_id)) {
        return mci_soap_fault_access_denied($t_user_id);
    }
    $t_result = array();
    $t_related_custom_field_ids = custom_field_get_linked_ids($p_project_id);
    foreach (custom_field_get_linked_ids($p_project_id) as $t_id) {
        $t_def = custom_field_get_definition($t_id);
        if (access_has_project_level($t_def['access_level_r'], $p_project_id)) {
            $t_result[] = array('field' => array('id' => $t_def['id'], 'name' => $t_def['name']), 'type' => $t_def['type'], 'default_value' => $t_def['default_value'], 'possible_values' => $t_def['possible_values'], 'valid_regexp' => $t_def['valid_regexp'], 'access_level_r' => $t_def['access_level_r'], 'access_level_rw' => $t_def['access_level_rw'], 'length_min' => $t_def['length_min'], 'length_max' => $t_def['length_max'], 'display_report' => $t_def['display_report'], 'display_update' => $t_def['display_update'], 'display_resolved' => $t_def['display_resolved'], 'display_closed' => $t_def['display_closed'], 'require_report' => $t_def['require_report'], 'require_update' => $t_def['require_update'], 'require_resolved' => $t_def['require_resolved'], 'require_closed' => $t_def['require_closed']);
        }
    }
    return $t_result;
}
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# Mantis is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Mantis.  If not, see <http://www.gnu.org/licenses/>.
# --------------------------------------------------------
# $Id: manage_custom_field_proj_add.php,v 1.2.2.1 2007-10-13 22:33:29 giallu Exp $
# --------------------------------------------------------
require_once 'core.php';
form_security_validate('manage_custom_field_proj_add');
auth_reauthenticate();
$f_field_id = gpc_get_int('field_id');
$f_project_id = gpc_get_int_array('project_id', array());
$f_sequence = gpc_get_int('sequence');
$t_manage_project_threshold = config_get('manage_project_threshold');
foreach ($f_project_id as $t_proj_id) {
    if (access_has_project_level($t_manage_project_threshold, $t_proj_id)) {
        if (!custom_field_is_linked($f_field_id, $t_proj_id)) {
            custom_field_link($f_field_id, $t_proj_id);
        }
        custom_field_set_sequence($f_field_id, $t_proj_id, $f_sequence);
    }
}
form_security_purge('manage_custom_field_proj_add');
print_header_redirect('manage_custom_field_edit_page.php?field_id=' . $f_field_id);
/**
 * Get a list of bug group actions available to the current user for one or
 * more projects.
 * @param array $p_project_ids An array containing one or more project IDs.
 * @return array
 */
function bug_group_action_get_commands(array $p_project_ids = null)
{
    if ($p_project_ids === null || count($p_project_ids) == 0) {
        $p_project_ids = array(ALL_PROJECTS);
    }
    $t_commands = array();
    foreach ($p_project_ids as $t_project_id) {
        if (!isset($t_commands['MOVE']) && access_has_project_level(config_get('move_bug_threshold', null, null, $t_project_id), $t_project_id)) {
            $t_commands['MOVE'] = lang_get('actiongroup_menu_move');
        }
        if (!isset($t_commands['COPY']) && access_has_any_project(config_get('report_bug_threshold', null, null, $t_project_id))) {
            $t_commands['COPY'] = lang_get('actiongroup_menu_copy');
        }
        if (!isset($t_commands['ASSIGN']) && access_has_project_level(config_get('update_bug_assign_threshold', null, null, $t_project_id), $t_project_id)) {
            if (ON == config_get('auto_set_status_to_assigned', null, null, $t_project_id) && access_has_project_level(access_get_status_threshold(config_get('bug_assigned_status', null, null, $t_project_id), $t_project_id), $t_project_id)) {
                $t_commands['ASSIGN'] = lang_get('actiongroup_menu_assign');
            } else {
                $t_commands['ASSIGN'] = lang_get('actiongroup_menu_assign');
            }
        }
        if (!isset($t_commands['CLOSE']) && access_has_project_level(config_get('update_bug_status_threshold', null, null, $t_project_id), $t_project_id) && (access_has_project_level(access_get_status_threshold(config_get('bug_closed_status_threshold', null, null, $t_project_id), $t_project_id), $t_project_id) || access_has_project_level(config_get('allow_reporter_close', null, null, $t_project_id), $t_project_id))) {
            $t_commands['CLOSE'] = lang_get('actiongroup_menu_close');
        }
        if (!isset($t_commands['DELETE']) && access_has_project_level(config_get('delete_bug_threshold', null, null, $t_project_id), $t_project_id)) {
            $t_commands['DELETE'] = lang_get('actiongroup_menu_delete');
        }
        if (!isset($t_commands['RESOLVE']) && access_has_project_level(config_get('update_bug_status_threshold', null, null, $t_project_id), $t_project_id) && access_has_project_level(access_get_status_threshold(config_get('bug_resolved_status_threshold', null, null, $t_project_id), $t_project_id), $t_project_id)) {
            $t_commands['RESOLVE'] = lang_get('actiongroup_menu_resolve');
        }
        if (!isset($t_commands['SET_STICKY']) && access_has_project_level(config_get('set_bug_sticky_threshold', null, null, $t_project_id), $t_project_id)) {
            $t_commands['SET_STICKY'] = lang_get('actiongroup_menu_set_sticky');
        }
        if (!isset($t_commands['UP_PRIOR']) && access_has_project_level(config_get('update_bug_threshold', null, null, $t_project_id), $t_project_id)) {
            $t_commands['UP_PRIOR'] = lang_get('actiongroup_menu_update_priority');
        }
        if (!isset($t_commands['EXT_UPDATE_SEVERITY']) && access_has_project_level(config_get('update_bug_threshold', null, null, $t_project_id), $t_project_id)) {
            $t_commands['EXT_UPDATE_SEVERITY'] = lang_get('actiongroup_menu_update_severity');
        }
        if (!isset($t_commands['UP_STATUS']) && access_has_project_level(config_get('update_bug_status_threshold', null, null, $t_project_id), $t_project_id)) {
            $t_commands['UP_STATUS'] = lang_get('actiongroup_menu_update_status');
        }
        if (!isset($t_commands['UP_CATEGORY']) && access_has_project_level(config_get('update_bug_threshold', null, null, $t_project_id), $t_project_id)) {
            $t_commands['UP_CATEGORY'] = lang_get('actiongroup_menu_update_category');
        }
        if (!isset($t_commands['VIEW_STATUS']) && access_has_project_level(config_get('change_view_status_threshold', null, null, $t_project_id), $t_project_id)) {
            $t_commands['VIEW_STATUS'] = lang_get('actiongroup_menu_update_view_status');
        }
        if (!isset($t_commands['EXT_UPDATE_PRODUCT_BUILD']) && config_get('enable_product_build', null, null, $t_project_id) == ON && access_has_project_level(config_get('update_bug_threshold', null, null, $t_project_id), $t_project_id)) {
            $t_commands['EXT_UPDATE_PRODUCT_BUILD'] = lang_get('actiongroup_menu_update_product_build');
        }
        if (!isset($t_commands['EXT_ADD_NOTE']) && access_has_project_level(config_get('add_bugnote_threshold', null, null, $t_project_id), $t_project_id)) {
            $t_commands['EXT_ADD_NOTE'] = lang_get('actiongroup_menu_add_note');
        }
        if (!isset($t_commands['EXT_ATTACH_TAGS']) && access_has_project_level(config_get('tag_attach_threshold', null, null, $t_project_id), $t_project_id)) {
            $t_commands['EXT_ATTACH_TAGS'] = lang_get('actiongroup_menu_attach_tags');
        }
        if (!isset($t_commands['UP_FIXED_IN_VERSION']) && version_should_show_product_version($t_project_id) && access_has_project_level(config_get('update_bug_threshold', null, null, $t_project_id), $t_project_id)) {
            $t_commands['UP_FIXED_IN_VERSION'] = lang_get('actiongroup_menu_update_fixed_in_version');
        }
        if (!isset($t_commands['UP_TARGET_VERSION']) && version_should_show_product_version($t_project_id) && access_has_project_level(config_get('roadmap_update_threshold', null, null, $t_project_id), $t_project_id)) {
            $t_commands['UP_TARGET_VERSION'] = lang_get('actiongroup_menu_update_target_version');
        }
        $t_custom_field_ids = custom_field_get_linked_ids($t_project_id);
        foreach ($t_custom_field_ids as $t_custom_field_id) {
            if (!custom_field_has_write_access_to_project($t_custom_field_id, $t_project_id)) {
                continue;
            }
            $t_custom_field_def = custom_field_get_definition($t_custom_field_id);
            $t_command_id = 'custom_field_' . $t_custom_field_id;
            $t_command_caption = sprintf(lang_get('actiongroup_menu_update_field'), lang_get_defaulted($t_custom_field_def['name']));
            $t_commands[$t_command_id] = string_display($t_command_caption);
        }
    }
    $t_custom_group_actions = config_get('custom_group_actions');
    foreach ($t_custom_group_actions as $t_custom_group_action) {
        # use label if provided to get the localized text, otherwise fallback to action name.
        if (isset($t_custom_group_action['label'])) {
            $t_commands[$t_custom_group_action['action']] = lang_get_defaulted($t_custom_group_action['label']);
        } else {
            $t_commands[$t_custom_group_action['action']] = lang_get_defaulted($t_custom_group_action['action']);
        }
    }
    return $t_commands;
}
Esempio n. 25
0
/**
 * Check if the specified bug can be reopened
 * @param BugData $p_bug Bug to check access against
 * @param int|null $p_user_id integer representing user id, defaults to null to use current user
 * @return bool whether user has access to reopen bugs
 * @access public
 */
function access_can_reopen_bug($p_bug, $p_user_id = null)
{
    if (!bug_is_resolved($p_bug->id)) {
        # Can't reopen a bug that's not resolved
        return false;
    }
    if ($p_user_id === null) {
        $p_user_id = auth_get_current_user_id();
    }
    # If allow_reporter_reopen is enabled, then reporters can always reopen
    # their own bugs as long as their access level is reporter or above
    if (ON == config_get('allow_reporter_reopen', null, null, $p_bug->project_id) && bug_is_user_reporter($p_bug->id, $p_user_id) && access_has_project_level(config_get('report_bug_threshold', null, $p_user_id, $p_bug->project_id), $p_bug->project_id, $p_user_id)) {
        return true;
    }
    # Other users's access level must allow them to reopen bugs
    $t_reopen_bug_threshold = config_get('reopen_bug_threshold', null, null, $p_bug->project_id);
    if (access_has_bug_level($t_reopen_bug_threshold, $p_bug->id, $p_user_id)) {
        $t_reopen_status = config_get('bug_reopen_status', null, null, $p_bug->project_id);
        # User must be allowed to change status to reopen status
        $t_reopen_status_threshold = access_get_status_threshold($t_reopen_status, $p_bug->project_id);
        return access_has_bug_level($t_reopen_status_threshold, $p_bug->id, $p_user_id);
    }
    return false;
}
Esempio n. 26
0
         $t_failed_ids[$t_bug_id] = lang_get('bug_actiongroup_access');
     }
     break;
 case 'MOVE':
     $f_project_id = gpc_get_int('project_id');
     if (access_has_bug_level(config_get('move_bug_threshold'), $t_bug_id) && access_has_project_level(config_get('report_bug_threshold', null, null, $f_project_id), $f_project_id)) {
         # @todo we need to issue a helper_call_custom_function( 'issue_update_validate', array( $t_bug_id, $t_bug_data, $f_bugnote_text ) );
         bug_move($t_bug_id, $f_project_id);
         helper_call_custom_function('issue_update_notify', array($t_bug_id));
     } else {
         $t_failed_ids[$t_bug_id] = lang_get('bug_actiongroup_access');
     }
     break;
 case 'COPY':
     $f_project_id = gpc_get_int('project_id');
     if (access_has_project_level(config_get('report_bug_threshold'), $f_project_id)) {
         # Copy everything except history
         bug_copy($t_bug_id, $f_project_id, true, true, false, true, true, true);
     } else {
         $t_failed_ids[$t_bug_id] = lang_get('bug_actiongroup_access');
     }
     break;
 case 'ASSIGN':
     $f_assign = gpc_get_int('assign');
     if (ON == config_get('auto_set_status_to_assigned')) {
         $t_assign_status = config_get('bug_assigned_status');
     } else {
         $t_assign_status = $t_status;
     }
     # check that new handler has rights to handle the issue, and
     #  that current user has rights to assign the issue
Esempio n. 27
0
    }
}
# Check for an error
$t_error_msg = strip_tags(gpc_get_string('error_msg', null));
if ($t_error_msg != null) {
    print "<br />{$t_error_msg}<br /><br />";
}
print lang_get('query_name_label') . lang_get('word_separator');
?>
<form method="post" action="query_store.php">
<?php 
echo form_security_field('query_store');
?>
<input type="text" name="query_name" /><br />
<?php 
if (access_has_project_level(config_get('stored_query_create_shared_threshold'))) {
    print '<input type="checkbox" name="is_public" value="on" /> ';
    print lang_get('make_public');
    print '<br />';
}
?>
<input type="checkbox" name="all_projects" value="on" <?php 
check_checked(ALL_PROJECTS == helper_get_current_project());
?>
 >
<?php 
print lang_get('all_projects');
?>
<br /><br />
<input type="submit" class="button" value="<?php 
print lang_get('save_query');
Esempio n. 28
0
/**
 * print a mailto: href link with subject
 *
 * @param string $p_email  Email Address.
 * @param string $p_text   Link text to display to user.
 * @param string $p_bug_id The bug identifier.
 * @return void
 */
function print_email_link_with_subject($p_email, $p_text, $p_bug_id)
{
    $t_bug = bug_get($p_bug_id, true);
    if (!access_has_project_level(config_get('show_user_email_threshold', null, null, $t_bug->project_id), $t_bug->project_id)) {
        echo $p_text;
        return;
    }
    $t_subject = email_build_subject($p_bug_id);
    echo get_email_link_with_subject($p_email, $p_text, $t_subject);
}
Esempio n. 29
0
$t_full_projects = array();
foreach ($t_projects as $t_project_id) {
    $t_full_projects[] = project_get_row($t_project_id);
}
$t_projects = multi_sort($t_full_projects, $f_sort, $t_direction);
$t_stack = array($t_projects);
while (0 < count($t_stack)) {
    $t_projects = array_shift($t_stack);
    if (0 == count($t_projects)) {
        continue;
    }
    $t_project = array_shift($t_projects);
    $t_project_id = $t_project['id'];
    $t_level = count($t_stack);
    # only print row if user has project management privileges
    if (access_has_project_level($t_manage_project_threshold, $t_project_id, auth_get_current_user_id())) {
        ?>
<tr <?php 
        echo helper_alternate_class();
        ?>
>
	<td>
		<a href="manage_proj_edit_page.php?project_id=<?php 
        echo $t_project['id'];
        ?>
"><?php 
        echo str_repeat("&raquo; ", $t_level) . string_display($t_project['name']);
        ?>
</a>
	</td>
	<td>
Esempio n. 30
0
			<td>
			<?php 
    $t_email = user_get_email($t_user['id']);
    print_email_link($t_email, $t_email);
    ?>
			</td>
			<td>
				<?php 
    echo get_enum_element('access_levels', $t_user['access_level']);
    ?>
			</td>
			<td class="center">
			<?php 
    # You need global or project-specific permissions to remove users
    #  from this project
    if ($t_can_manage_users && access_has_project_level($t_user['access_level'], $f_project_id)) {
        if (project_includes_user($f_project_id, $t_user['id'])) {
            print_button("manage_proj_user_remove.php?project_id={$f_project_id}&user_id=" . $t_user['id'], lang_get('remove_link'));
            $t_removable_users_exist = true;
        }
    }
    ?>
			</td>
		</tr>
<?php 
}
# end for
?>
	<tr>
	<td>&nbsp;  </td>
	<td>&nbsp;  </td>