function print_status_option_list_plugin($p_select_label, $p_current_value = 0, $p_allow_close = false, $p_project_id = ALL_PROJECTS)
{
    $t_current_auth = access_get_project_level($p_project_id);
    #Changement de la fonction de récupération des statuts
    $t_enum_list = get_status_option_list_plugin($t_current_auth, $p_current_value, true, $p_allow_close, $p_project_id);
    if (count($t_enum_list) > 1) {
        # resort the list into ascending order
        ksort($t_enum_list);
        reset($t_enum_list);
        echo '<select ', helper_get_tab_index(), ' name="' . $p_select_label . '">';
        foreach ($t_enum_list as $key => $val) {
            #On ne veut pas afficher la valeur @0@
            if ($val == '@0@') {
                continue;
            }
            echo '<option value="' . $key . '"';
            check_selected($key, $p_current_value, false);
            #fix 1.3.0
            echo '>' . $val . '</option>';
        }
        echo '</select>';
    } else {
        if (count($t_enum_list) == 1) {
            echo array_pop($t_enum_list);
        } else {
            echo MantisEnum::getLabel(lang_get('status_enum_string'), $p_current_value);
        }
    }
}
Example #2
0
 /**
  * Gets the localized label corresponding to a value.  Note that this method
  * takes in the standard / localized enums so that if the value is in the localized
  * enum but not the standard one, then it returns not found.
  *
  * @param string $enumString The standard enum string.
  * @param string $localizedEnumString  The localized enum string.
  * @param integer $value  The value to lookup.
  *
  * @return the label or the decorated value to represent not found.
  */
 public static function getLocalizedLabel($enumString, $localizedEnumString, $value)
 {
     if (!MantisEnum::hasValue($enumString, $value)) {
         return MantisEnum::getLabelForUnknownValue($value);
     }
     return MantisEnum::getLabel($localizedEnumString, $value);
 }
Example #3
0
/**
 * Parse a workflow into a graph-like array of workflow transitions.
 * @param array The workflow enumeration to parse.
 * @return array The parsed workflow graph.
 */
function workflow_parse($p_enum_workflow)
{
    $t_status_arr = MantisEnum::getAssocArrayIndexedByValues(config_get('status_enum_string'));
    if (count($p_enum_workflow) == 0) {
        # workflow is not set, default it to all transitions
        foreach ($t_status_arr as $t_status => $t_label) {
            $t_temp_workflow = array();
            foreach ($t_status_arr as $t_next => $t_next_label) {
                if ($t_status != $t_next) {
                    $t_temp_workflow[] = $t_next . ':' . $t_next_label;
                }
            }
            $p_enum_workflow[$t_status] = implode(',', $t_temp_workflow);
        }
    }
    $t_entry = array();
    $t_exit = array();
    # prepopulate new bug state (bugs go from nothing to here)
    $t_submit_status_array = config_get('bug_submit_status');
    $t_new_label = MantisEnum::getLabel(lang_get('status_enum_string'), config_get('bug_submit_status'));
    if (is_array($t_submit_status_array)) {
        # @@@ (thraxisp) this is not implemented in bug_api.php
        foreach ($t_submit_status_array as $t_access => $t_status) {
            $t_entry[$t_status][0] = $t_new_label;
            $t_exit[0][$t_status] = $t_new_label;
        }
    } else {
        $t_status = $t_submit_status_array;
        $t_entry[$t_status][0] = $t_new_label;
        $t_exit[0][$t_status] = $t_new_label;
    }
    # add user defined arcs and implicit reopen arcs
    $t_reopen = config_get('bug_reopen_status');
    $t_reopen_label = MantisEnum::getLabel(lang_get('resolution_enum_string'), config_get('bug_reopen_resolution'));
    $t_resolved_status = config_get('bug_resolved_status_threshold');
    $t_default = array();
    foreach ($t_status_arr as $t_status => $t_status_label) {
        if (isset($p_enum_workflow[$t_status])) {
            $t_next_arr = MantisEnum::getAssocArrayIndexedByValues($p_enum_workflow[$t_status]);
            foreach ($t_next_arr as $t_next => $t_next_label) {
                if (!isset($t_default[$t_status])) {
                    $t_default[$t_status] = $t_next;
                }
                $t_exit[$t_status][$t_next] = '';
                $t_entry[$t_next][$t_status] = '';
            }
        } else {
            $t_exit[$t_status] = array();
        }
        if ($t_status >= $t_resolved_status) {
            $t_exit[$t_status][$t_reopen] = $t_reopen_label;
            $t_entry[$t_reopen][$t_status] = $t_reopen_label;
        }
        if (!isset($t_entry[$t_status])) {
            $t_entry[$t_status] = array();
        }
    }
    return array('entry' => $t_entry, 'exit' => $t_exit, 'default' => $t_default);
}
/**
 * get the color string for the given status, user and project
 * @param int $p_status
 * @param int|null $p_user user id, defaults to null (all users)
 * @param int|null $p_project project id, defaults to null (all projects)
 * @return string
 */
function get_status_color($p_status, $p_user = null, $p_project = null)
{
    $t_status_label = MantisEnum::getLabel(config_get('status_enum_string', null, $p_user, $p_project), $p_status);
    $t_status_colors = config_get('status_colors', null, $p_user, $p_project);
    $t_color = '#ffffff';
    if (isset($t_status_colors[$t_status_label])) {
        $t_color = $t_status_colors[$t_status_label];
    }
    return $t_color;
}
Example #5
0
/**
 * Parse a workflow into a graph-like array of workflow transitions.
 * @param array $p_enum_workflow The workflow enumeration to parse.
 * @return array The parsed workflow graph.
 */
function workflow_parse(array $p_enum_workflow)
{
    $t_status_arr = MantisEnum::getAssocArrayIndexedByValues(config_get('status_enum_string'));
    # If workflow is not set, defaults to array(), which means that all transitions are valid
    if (!is_array($p_enum_workflow)) {
        $p_enum_workflow = array();
    }
    # If any status row is missing, it defaults to all transitions
    foreach ($t_status_arr as $t_status => $t_label) {
        if (!isset($p_enum_workflow[$t_status])) {
            $t_temp_workflow = array();
            foreach ($t_status_arr as $t_next => $t_next_label) {
                if ($t_status != $t_next) {
                    $t_temp_workflow[] = $t_next . ':' . $t_next_label;
                }
            }
            $p_enum_workflow[$t_status] = implode(',', $t_temp_workflow);
        }
    }
    $t_entry = array();
    $t_exit = array();
    # prepopulate new bug state (bugs go from nothing to here)
    $t_submit_status_array = config_get('bug_submit_status');
    $t_new_label = MantisEnum::getLabel(lang_get('status_enum_string'), config_get('bug_submit_status'));
    if (is_array($t_submit_status_array)) {
        # @@@ (thraxisp) this is not implemented in bug_api.php
        foreach ($t_submit_status_array as $t_access => $t_status) {
            $t_entry[$t_status][0] = $t_new_label;
            $t_exit[0][$t_status] = $t_new_label;
        }
    } else {
        $t_status = $t_submit_status_array;
        $t_entry[$t_status][0] = $t_new_label;
        $t_exit[0][$t_status] = $t_new_label;
    }
    # add user defined arcs
    $t_default = array();
    foreach ($t_status_arr as $t_status => $t_status_label) {
        $t_exit[$t_status] = array();
        if (isset($p_enum_workflow[$t_status])) {
            $t_next_arr = MantisEnum::getAssocArrayIndexedByValues($p_enum_workflow[$t_status]);
            foreach ($t_next_arr as $t_next => $t_next_label) {
                if (!isset($t_default[$t_status])) {
                    $t_default[$t_status] = $t_next;
                }
                $t_exit[$t_status][$t_next] = '';
                $t_entry[$t_next][$t_status] = '';
            }
        }
        if (!isset($t_entry[$t_status])) {
            $t_entry[$t_status] = array();
        }
    }
    return array('entry' => $t_entry, 'exit' => $t_exit, 'default' => $t_default);
}
Example #6
0
 /**
  * Gets the localized label corresponding to a value.  Note that this method
  * takes in the standard / localized enums so that if the value is in the localized
  * enum but not the standard one, then it returns not found.
  *
  * @param string  $p_enum_string           The standard enum string.
  * @param string  $p_localized_enum_string The localized enum string.
  * @param integer $p_value                 The value to lookup.
  *
  * @return string the label or the decorated value to represent not found.
  */
 public static function getLocalizedLabel($p_enum_string, $p_localized_enum_string, $p_value)
 {
     if (!MantisEnum::hasValue($p_enum_string, $p_value)) {
         return MantisEnum::getLabelForUnknownValue($p_value);
     }
     $t_assoc_array = MantisEnum::getAssocArrayIndexedByValues($p_localized_enum_string);
     if (isset($t_assoc_array[(int) $p_value])) {
         return $t_assoc_array[(int) $p_value];
     }
     return MantisEnum::getLabel($p_enum_string, $p_value);
 }
function get_section_begin_apr($p_section_name)
{
    $t_access_levels = MantisEnum::getValues(config_get('access_levels_enum_string'));
    $t_output = '<table class="width100">';
    $t_output .= '<tr><td class="form-title-caps" colspan="' . (count($t_access_levels) + 1) . '">' . $p_section_name . '</td></tr>' . "\n";
    $t_output .= '<tr><td class="form-title" width="40%">' . lang_get('perm_rpt_capability') . '</td>';
    foreach ($t_access_levels as $t_access_level) {
        $t_output .= '<td class="form-title" style="text-align:center">&#160;' . MantisEnum::getLabel(lang_get('access_levels_enum_string'), $t_access_level) . '&#160;</td>';
    }
    $t_output .= '</tr>' . "\n";
    return $t_output;
}
/**
 * Get enumeration row
 * @param string  $p_caption           Caption.
 * @param string  $p_threshold         Threshold.
 * @param string  $p_enum              Enumeration.
 * @param boolean $p_all_projects_only All projects only.
 * @return void
 */
function get_capability_enum($p_caption, $p_threshold, $p_enum, $p_all_projects_only = false)
{
    global $g_user, $g_project_id, $t_show_submit, $g_access_levels;
    $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), $g_project_id, $g_user) && (ALL_PROJECTS == $g_project_id || !$p_all_projects_only);
    echo '<tr>' . "\n";
    echo "\t" . '<td>' . string_display($p_caption) . '</td>' . "\n";
    # Value
    $t_color = set_color($p_threshold, $t_file, $t_global, $t_project, $t_can_change);
    echo "\t" . '<td class="left" colspan="3"' . $t_color . '>';
    if ($t_can_change) {
        echo '<select name="flag_' . $p_threshold . '">';
        print_enum_string_option_list($p_enum, config_get($p_threshold));
        echo '</select>';
        $t_show_submit = true;
    } else {
        $t_value = MantisEnum::getLabel(lang_get($p_enum . '_enum_string'), config_get($p_threshold)) . '&#160;';
        echo $t_value;
    }
    echo '</td>' . "\n\t" . '<td colspan="' . (count($g_access_levels) - 3) . '"></td>' . "\n";
    print_who_can_change($p_threshold, $t_can_change);
    echo '</tr>' . "\n";
}
Example #9
0
/**
 * get the css class name for the given status, user and project
 * @param int $p_status
 * @return string
 */
function html_get_status_css_class($p_status, $p_user = null, $p_project = null)
{
    return string_attribute(MantisEnum::getLabel(config_get('status_enum_string', null, $p_user, $p_project), $p_status) . '-color');
}
$i = 1;
#row class selector
$t_time_sum = 0;
foreach ($t_all_projects as $t_all_project) {
    $t_query = "SELECT * FROM {$t_bug_table}\n\t\t\tWHERE project_id=" . db_param();
    $t_result = db_query_bound($t_query, array($t_all_project));
    while ($t_row = db_fetch_array($t_result)) {
        $t_timecard = TimecardBug::load($t_row['id']);
        $t_timecard->summary = $t_row['summary'];
        $t_timecard->assigned = user_get_name($t_row['handler_id']);
        $t_timecard->calculate();
        if ('user0' == $t_timecard->assigned) {
            # When bug not assigned don't print user0
            $t_timecard->assigned = '';
        }
        $t_timecard->status = MantisEnum::getLabel(config_get('status_enum_string'), $t_row['status']);
        $t_timecard->diff = time_get_diff($t_timecard->timestamp);
        if ($t_timecard->estimate < 0) {
            $t_timecard->estimate = plugin_lang_get('estimate_zero');
            $row_class = 'negative';
        } else {
            $t_time_sum += $t_timecard->estimate;
            $row_class = "row-{$i}";
        }
        echo "<tr class='{$row_class}'>\n\t\t\t\t<td>", print_bug_link($t_timecard->bug_id), '</td>' . '
				<td class="max_width">' . $t_timecard->summary . '</td>
				<td>' . $t_timecard->status . '</td>
				<td>' . $t_timecard->assigned . '</td>';
        if (plugin_config_get('use_timecard')) {
            echo '<td class="center">' . $t_timecard->timecard . '</td>';
        }
 /**
  * Update a bug from the given data structure
  *  If the third parameter is true, also update the longer strings table
  * @param bool p_update_extended
  * @param bool p_bypass_email Default false, set to true to avoid generating emails (if sending elsewhere)
  * @return bool (always true)
  * @access public
  */
 function update($p_update_extended = false, $p_bypass_mail = false)
 {
     self::validate($p_update_extended);
     $c_bug_id = $this->id;
     if (is_blank($this->due_date)) {
         $this->due_date = date_get_null();
     }
     $t_old_data = bug_get($this->id, true);
     $t_bug_table = db_get_table('mantis_bug_table');
     # Update all fields
     # Ignore date_submitted and last_updated since they are pulled out
     #  as unix timestamps which could confuse the history log and they
     #  shouldn't get updated like this anyway.  If you really need to change
     #  them use bug_set_field()
     $query = "UPDATE {$t_bug_table}\n\t\t\t\t\tSET project_id=" . db_param() . ', reporter_id=' . db_param() . ",\n\t\t\t\t\t\thandler_id=" . db_param() . ', duplicate_id=' . db_param() . ",\n\t\t\t\t\t\tpriority=" . db_param() . ', severity=' . db_param() . ",\n\t\t\t\t\t\treproducibility=" . db_param() . ', status=' . db_param() . ",\n\t\t\t\t\t\tresolution=" . db_param() . ', projection=' . db_param() . ",\n\t\t\t\t\t\tcategory_id=" . db_param() . ', eta=' . db_param() . ",\n\t\t\t\t\t\tos=" . db_param() . ', os_build=' . db_param() . ",\n\t\t\t\t\t\tplatform=" . db_param() . ', version=' . db_param() . ",\n\t\t\t\t\t\tbuild=" . db_param() . ', fixed_in_version=' . db_param() . ',';
     $t_fields = array($this->project_id, $this->reporter_id, $this->handler_id, $this->duplicate_id, $this->priority, $this->severity, $this->reproducibility, $this->status, $this->resolution, $this->projection, $this->category_id, $this->eta, $this->os, $this->os_build, $this->platform, $this->version, $this->build, $this->fixed_in_version);
     $t_roadmap_updated = false;
     if (access_has_project_level(config_get('roadmap_update_threshold'))) {
         $query .= "\n\t\t\t\t\t\ttarget_version=" . db_param() . ",";
         $t_fields[] = $this->target_version;
         $t_roadmap_updated = true;
     }
     $query .= "\n\t\t\t\t\t\tview_state=" . db_param() . ",\n\t\t\t\t\t\tsummary=" . db_param() . ",\n\t\t\t\t\t\tsponsorship_total=" . db_param() . ",\n\t\t\t\t\t\tsticky=" . db_param() . ",\n\t\t\t\t\t\tdue_date=" . db_param() . "\n\t\t\t\t\tWHERE id=" . db_param();
     $t_fields[] = $this->view_state;
     $t_fields[] = $this->summary;
     $t_fields[] = $this->sponsorship_total;
     $t_fields[] = (bool) $this->sticky;
     $t_fields[] = $this->due_date;
     $t_fields[] = $this->id;
     db_query_bound($query, $t_fields);
     bug_clear_cache($this->id);
     # log changes
     history_log_event_direct($c_bug_id, 'project_id', $t_old_data->project_id, $this->project_id);
     history_log_event_direct($c_bug_id, 'reporter_id', $t_old_data->reporter_id, $this->reporter_id);
     history_log_event_direct($c_bug_id, 'handler_id', $t_old_data->handler_id, $this->handler_id);
     history_log_event_direct($c_bug_id, 'priority', $t_old_data->priority, $this->priority);
     history_log_event_direct($c_bug_id, 'severity', $t_old_data->severity, $this->severity);
     history_log_event_direct($c_bug_id, 'reproducibility', $t_old_data->reproducibility, $this->reproducibility);
     history_log_event_direct($c_bug_id, 'status', $t_old_data->status, $this->status);
     history_log_event_direct($c_bug_id, 'resolution', $t_old_data->resolution, $this->resolution);
     history_log_event_direct($c_bug_id, 'projection', $t_old_data->projection, $this->projection);
     history_log_event_direct($c_bug_id, 'category', category_full_name($t_old_data->category_id, false), category_full_name($this->category_id, false));
     history_log_event_direct($c_bug_id, 'eta', $t_old_data->eta, $this->eta);
     history_log_event_direct($c_bug_id, 'os', $t_old_data->os, $this->os);
     history_log_event_direct($c_bug_id, 'os_build', $t_old_data->os_build, $this->os_build);
     history_log_event_direct($c_bug_id, 'platform', $t_old_data->platform, $this->platform);
     history_log_event_direct($c_bug_id, 'version', $t_old_data->version, $this->version);
     history_log_event_direct($c_bug_id, 'build', $t_old_data->build, $this->build);
     history_log_event_direct($c_bug_id, 'fixed_in_version', $t_old_data->fixed_in_version, $this->fixed_in_version);
     if ($t_roadmap_updated) {
         history_log_event_direct($c_bug_id, 'target_version', $t_old_data->target_version, $this->target_version);
     }
     history_log_event_direct($c_bug_id, 'view_state', $t_old_data->view_state, $this->view_state);
     history_log_event_direct($c_bug_id, 'summary', $t_old_data->summary, $this->summary);
     history_log_event_direct($c_bug_id, 'sponsorship_total', $t_old_data->sponsorship_total, $this->sponsorship_total);
     history_log_event_direct($c_bug_id, 'sticky', $t_old_data->sticky, $this->sticky);
     history_log_event_direct($c_bug_id, 'due_date', $t_old_data->due_date != date_get_null() ? $t_old_data->due_date : null, $this->due_date != date_get_null() ? $this->due_date : null);
     # Update extended info if requested
     if ($p_update_extended) {
         $t_bug_text_table = db_get_table('mantis_bug_text_table');
         $t_bug_text_id = bug_get_field($c_bug_id, 'bug_text_id');
         $query = "UPDATE {$t_bug_text_table}\n\t\t\t\t\t\t\tSET description=" . db_param() . ",\n\t\t\t\t\t\t\t\tsteps_to_reproduce=" . db_param() . ",\n\t\t\t\t\t\t\t\tadditional_information=" . db_param() . "\n\t\t\t\t\t\t\tWHERE id=" . db_param();
         db_query_bound($query, array($this->description, $this->steps_to_reproduce, $this->additional_information, $t_bug_text_id));
         bug_text_clear_cache($c_bug_id);
         $t_current_user = auth_get_current_user_id();
         if ($t_old_data->description != $this->description) {
             if (bug_revision_count($c_bug_id, REV_DESCRIPTION) < 1) {
                 $t_revision_id = bug_revision_add($c_bug_id, $t_old_data->reporter_id, REV_DESCRIPTION, $t_old_data->description, 0, $t_old_data->date_submitted);
             }
             $t_revision_id = bug_revision_add($c_bug_id, $t_current_user, REV_DESCRIPTION, $this->description);
             history_log_event_special($c_bug_id, DESCRIPTION_UPDATED, $t_revision_id);
         }
         if ($t_old_data->steps_to_reproduce != $this->steps_to_reproduce) {
             if (bug_revision_count($c_bug_id, REV_STEPS_TO_REPRODUCE) < 1) {
                 $t_revision_id = bug_revision_add($c_bug_id, $t_old_data->reporter_id, REV_STEPS_TO_REPRODUCE, $t_old_data->steps_to_reproduce, 0, $t_old_data->date_submitted);
             }
             $t_revision_id = bug_revision_add($c_bug_id, $t_current_user, REV_STEPS_TO_REPRODUCE, $this->steps_to_reproduce);
             history_log_event_special($c_bug_id, STEP_TO_REPRODUCE_UPDATED, $t_revision_id);
         }
         if ($t_old_data->additional_information != $this->additional_information) {
             if (bug_revision_count($c_bug_id, REV_ADDITIONAL_INFO) < 1) {
                 $t_revision_id = bug_revision_add($c_bug_id, $t_old_data->reporter_id, REV_ADDITIONAL_INFO, $t_old_data->additional_information, 0, $t_old_data->date_submitted);
             }
             $t_revision_id = bug_revision_add($c_bug_id, $t_current_user, REV_ADDITIONAL_INFO, $this->additional_information);
             history_log_event_special($c_bug_id, ADDITIONAL_INFO_UPDATED, $t_revision_id);
         }
     }
     # Update the last update date
     bug_update_date($c_bug_id);
     # allow bypass if user is sending mail separately
     if (false == $p_bypass_mail) {
         # bug assigned
         if ($t_old_data->handler_id != $this->handler_id) {
             email_generic($c_bug_id, 'owner', 'email_notification_title_for_action_bug_assigned');
             return true;
         }
         # status changed
         if ($t_old_data->status != $this->status) {
             $t_status = MantisEnum::getLabel(config_get('status_enum_string'), $this->status);
             $t_status = str_replace(' ', '_', $t_status);
             email_generic($c_bug_id, $t_status, 'email_notification_title_for_status_bug_' . $t_status);
             return true;
         }
         # @todo handle priority change if it requires special handling
         # generic update notification
         email_generic($c_bug_id, 'updated', 'email_notification_title_for_action_bug_updated');
     }
     return true;
 }
Example #12
0
if ($t_resolve_issue) {
    email_resolved($f_bug_id);
    email_relationship_child_resolved($f_bug_id);
} else {
    if ($t_close_issue) {
        email_close($f_bug_id);
        email_relationship_child_closed($f_bug_id);
    } else {
        if ($t_reopen_issue) {
            email_reopen($f_bug_id);
        } else {
            if ($t_existing_bug->handler_id === NO_USER && $t_updated_bug->handler_id !== NO_USER) {
                email_assign($f_bug_id);
            } else {
                if ($t_existing_bug->status !== $t_updated_bug->status) {
                    $t_new_status_label = MantisEnum::getLabel(config_get('status_enum_string'), $t_updated_bug->status);
                    $t_new_status_label = str_replace(' ', '_', $t_new_status_label);
                    email_generic($f_bug_id, $t_new_status_label, 'email_notification_title_for_status_bug_' . $t_new_status_label);
                } else {
                    email_generic($f_bug_id, 'updated', 'email_notification_title_for_action_bug_updated');
                }
            }
        }
    }
}
# Twitter notification of bug update.
if ($t_resolve_issue && $t_updated_bug->resolution >= config_get('bug_resolution_fixed_threshold') && $t_updated_bug->resolution < config_get('bug_resolution_not_fixed_threshold')) {
    twitter_issue_resolved($f_bug_id);
}
form_security_purge('bug_update');
print_successful_redirect_to_bug($f_bug_id);
Example #13
0
/**
 * get the css class name for the given status
 * @param int $p_status
 * @return string
 */
function html_get_status_css_class( $p_status ) {
	return string_attribute( MantisEnum::getLabel( config_get('status_enum_string' ), $p_status ) . '-color' );
}
Example #14
0
/**
 * get the color string for the given status
 * @param int $p_status
 * @return string
 */
function get_status_color($p_status)
{
    $t_status_label = MantisEnum::getLabel(config_get('status_enum_string'), $p_status);
    $t_status_colors = config_get('status_colors');
    $t_color = '#ffffff';
    if (isset($t_status_colors[$t_status_label])) {
        $t_color = $t_status_colors[$t_status_label];
    }
    return $t_color;
}
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";
}
function get_section_begin_for_email($p_section_name)
{
    global $t_project;
    $t_access_levels = MantisEnum::getValues(config_get('access_levels_enum_string'));
    echo '<table class="width100">';
    echo '<tr><td class="form-title-caps" colspan="' . (count($t_access_levels) + 7) . '">' . $p_section_name . '</td></tr>' . "\n";
    echo '<tr><td class="form-title" width="30%" rowspan="2">' . lang_get('message') . '</td>';
    echo '<td class="form-title" style="text-align:center" rowspan="2">&#160;' . lang_get('issue_reporter') . '&#160;</td>';
    echo '<td class="form-title" style="text-align:center" rowspan="2">&#160;' . lang_get('issue_handler') . '&#160;</td>';
    echo '<td class="form-title" style="text-align:center" rowspan="2">&#160;' . lang_get('users_monitoring_bug') . '&#160;</td>';
    echo '<td class="form-title" style="text-align:center" rowspan="2">&#160;' . lang_get('users_added_bugnote') . '&#160;</td>';
    echo '<td class="form-title" style="text-align:center" colspan="' . count($t_access_levels) . '">&#160;' . lang_get('access_levels') . '&#160;</td></tr><tr>';
    foreach ($t_access_levels as $t_access_level) {
        echo '<td class="form-title" style="text-align:center">&#160;' . MantisEnum::getLabel(lang_get('access_levels_enum_string'), $t_access_level) . '&#160;</td>';
    }
    echo '</tr>' . "\n";
}
Example #17
0
require_api('authentication_api.php');
require_api('compress_api.php');
require_api('config_api.php');
require_api('graphviz_api.php');
require_api('workflow_api.php');
auth_ensure_user_authenticated();
if (!config_get('relationship_graph_enable')) {
    access_denied();
}
compress_enable();
$t_status_arr = MantisEnum::getAssocArrayIndexedByValues(config_get('status_enum_string'));
$t_graph_fontname = config_get('relationship_graph_fontname');
$t_graph_fontsize = config_get('relationship_graph_fontsize');
$t_graph_fontpath = get_font_path();
$t_dot_tool = config_get('dot_tool');
$t_graph_attributes = array();
if (!empty($t_graph_fontpath)) {
    $t_graph_attributes['fontpath'] = $t_graph_fontpath;
}
$t_graph = new Graph('workflow', $t_graph_attributes, $t_dot_tool);
$t_graph->set_default_node_attr(array('fontname' => $t_graph_fontname, 'fontsize' => $t_graph_fontsize, 'shape' => 'record', 'style' => 'filled', 'height' => '0.2', 'width' => '0.4'));
$t_graph->set_default_edge_attr(array('style' => 'solid', 'color' => '#0000C0', 'dir' => 'forward'));
foreach ($t_status_arr as $t_from_status => $t_from_label) {
    $t_enum_status = MantisEnum::getAssocArrayIndexedByValues(config_get('status_enum_string'));
    foreach ($t_enum_status as $t_to_status_id => $t_to_status_label) {
        if (workflow_transition_edge_exists($t_from_status, $t_to_status_id)) {
            $t_graph->add_edge(string_no_break(MantisEnum::getLabel(lang_get('status_enum_string'), $t_from_status)), string_no_break(MantisEnum::getLabel(lang_get('status_enum_string'), $t_to_status_id)), array());
        }
    }
}
$t_graph->output('png', true);
Example #18
0
/**
 * Utility function for getting status text
 * @param type $status_id
 * @return type
 */
function kanban_get_status_text($status_id)
{
    return MantisEnum::getLabel(lang_get('status_enum_string'), $status_id);
}
Example #19
0
if( !empty( $t_graph_fontpath ) ) {
	$t_graph_attributes['fontpath'] = $t_graph_fontpath;
}

$t_graph = new Graph( 'workflow', $t_graph_attributes, $t_dot_tool );

$t_graph->set_default_node_attr( array ( 'fontname' => $t_graph_fontname,
                                         'fontsize' => $t_graph_fontsize,
                                         'shape'    => 'record',
                                         'style'    => 'filled',
                                         'height'   => '0.2',
                                         'width'    => '0.4' ) );

$t_graph->set_default_edge_attr( array ( 'style' => 'solid',
                                         'color' => '#0000C0',
                                         'dir'   => 'forward' ) );

foreach ( $t_status_arr as $t_from_status => $t_from_label) {
	$t_enum_status = MantisEnum::getAssocArrayIndexedByValues( config_get( 'status_enum_string' ) );
	foreach ( $t_enum_status as $t_to_status_id => $t_to_status_label ) {
		if ( workflow_transition_edge_exists( $t_from_status, $t_to_status_id ) ) {
			$t_graph->add_edge( string_no_break( MantisEnum::getLabel( lang_get( 'status_enum_string' ), $t_from_status ) ),
			                    string_no_break( MantisEnum::getLabel( lang_get( 'status_enum_string' ), $t_to_status_id ) ),
			                    array() );
		}
	}
}

$t_graph->output( 'png', true );
/**
 * access row
 * @return void
 */
function access_row()
{
    global $g_access, $g_can_change_flags;
    $t_enum_status = MantisEnum::getAssocArrayIndexedByValues(config_get('status_enum_string'));
    $t_file_new = config_get_global('report_bug_threshold');
    $t_global_new = config_get('report_bug_threshold', null, ALL_USERS, ALL_PROJECTS);
    $t_project_new = config_get('report_bug_threshold');
    $t_file_set = config_get_global('set_status_threshold');
    $t_global_set = config_get('set_status_threshold', null, ALL_USERS, ALL_PROJECTS);
    $t_project_set = config_get('set_status_threshold');
    $t_submit_status = config_get('bug_submit_status');
    # Print the table rows
    foreach ($t_enum_status as $t_status => $t_status_label) {
        echo "\t\t" . '<tr><td class="width30">' . string_no_break(MantisEnum::getLabel(lang_get('status_enum_string'), $t_status)) . '</td>' . "\n";
        if ($t_status == $t_submit_status) {
            # 'NEW' status
            $t_level_project = $t_project_new;
            $t_can_change = $g_access >= config_get_access('report_bug_threshold');
            $t_color = set_color_override($t_file_new, $t_global_new, $t_project_new);
            set_overrides('report_bug_threshold', $t_can_change, $t_color);
        } else {
            # Other statuses
            # File level: fallback if set_status_threshold is not defined
            if (isset($t_file_set[$t_status])) {
                $t_level_file = $t_file_set[$t_status];
            } else {
                $t_level_file = config_get_global('update_bug_status_threshold');
            }
            $t_level_global = isset($t_global_set[$t_status]) ? $t_global_set[$t_status] : $t_level_file;
            $t_level_project = isset($t_project_set[$t_status]) ? $t_project_set[$t_status] : $t_level_global;
            $t_can_change = $g_access >= config_get_access('set_status_threshold');
            $t_color = set_color_override($t_level_file, $t_level_global, $t_level_project);
            set_overrides('set_status_threshold', $t_can_change, $t_color);
        }
        if ($t_can_change) {
            echo '<td class="center ' . $t_color . '"><select name="access_change_' . $t_status . '">' . "\n";
            print_enum_string_option_list('access_levels', $t_level_project);
            echo '</select> </td>' . "\n";
            $g_can_change_flags = true;
        } else {
            echo '<td class="center ' . $t_color . '">' . MantisEnum::getLabel(lang_get('access_levels_enum_string'), $t_level_project) . '</td>' . "\n";
        }
        echo '</tr>' . "\n";
    }
}
function access_row()
{
    global $t_access, $t_can_change_flags, $t_colour_project, $t_colour_global;
    $t_enum_status = MantisEnum::getAssocArrayIndexedByValues(config_get('status_enum_string'));
    $t_file_new = config_get_global('report_bug_threshold');
    $t_global_new = config_get('report_bug_threshold', null, null, ALL_PROJECTS);
    $t_project_new = config_get('report_bug_threshold');
    $t_file_set = config_get_global('set_status_threshold');
    foreach ($t_enum_status as $t_status => $t_status_label) {
        if (!isset($t_file_set[$t_status])) {
            $t_file_set[$t_status] = config_get_global('update_bug_status_threshold');
        }
    }
    $t_global_set = config_get('set_status_threshold', null, null, ALL_PROJECTS);
    foreach ($t_enum_status as $t_status => $t_status_label) {
        if (!isset($t_file_set[$t_status])) {
            $t_file_set[$t_status] = config_get('update_bug_status_threshold', null, null, ALL_PROJECTS);
        }
    }
    $t_project_set = config_get('set_status_threshold');
    foreach ($t_enum_status as $t_status => $t_status_label) {
        if (!isset($t_file_set[$t_status])) {
            $t_file_set[$t_status] = config_get('update_bug_status_threshold');
        }
    }
    foreach ($t_enum_status as $t_status => $t_status_label) {
        echo '<tr ' . helper_alternate_class() . '><td width="30%">' . string_no_break(MantisEnum::getLabel(lang_get('status_enum_string'), $t_status)) . '</td>';
        if (config_get('bug_submit_status') == $t_status) {
            $t_level = $t_project_new;
            $t_can_change = $t_access >= config_get_access('report_bug_threshold');
            $t_colour = '';
            if ($t_global_new != $t_file_new) {
                $t_colour = ' bgcolor="' . $t_colour_global . '" ';
                # all projects override
                if ($t_can_change) {
                    set_overrides('report_bug_threshold');
                }
            }
            if ($t_project_new != $t_global_new) {
                $t_colour = ' bgcolor="' . $t_colour_project . '" ';
                # project overrides
                if ($t_can_change) {
                    set_overrides('report_bug_threshold');
                }
            }
        } else {
            $t_level = isset($t_project_set[$t_status]) ? $t_project_set[$t_status] : 0;
            $t_level_global = isset($t_global_set[$t_status]) ? $t_global_set[$t_status] : 0;
            $t_level_file = isset($t_file_set[$t_status]) ? $t_file_set[$t_status] : 0;
            $t_can_change = $t_access >= config_get_access('set_status_threshold');
            $t_colour = '';
            if ($t_level_global != $t_level_file) {
                $t_colour = ' bgcolor="' . $t_colour_global . '" ';
                # all projects override
                if ($t_can_change) {
                    set_overrides('set_status_threshold');
                }
            }
            if ($t_level != $t_level_global) {
                $t_colour = ' bgcolor="' . $t_colour_project . '" ';
                # project overrides
                if ($t_can_change) {
                    set_overrides('set_status_threshold');
                }
            }
        }
        if ($t_can_change) {
            echo '<td' . $t_colour . '><select name="access_change_' . $t_status . '">';
            print_enum_string_option_list('access_levels', $t_level);
            echo '</select> </td>';
            $t_can_change_flags = true;
        } else {
            echo '<td class="center"' . $t_colour . '>' . MantisEnum::getLabel(lang_get('access_levels_enum_string'), $t_level) . '</td>';
        }
        echo '</tr>' . "\n";
    }
}
/**
 * HTML for email section
 *
 * @param string $p_section_name Section name.
 * @return void
 */
function get_section_begin_for_email($p_section_name)
{
    $t_access_levels = MantisEnum::getValues(config_get('access_levels_enum_string'));
    echo '<div class="form-container">' . "\n";
    echo '<table>' . "\n";
    echo '  <thead>' . "\n";
    echo '    <tr>' . "\n";
    echo '      <td class="form-title-caps" colspan="' . (count($t_access_levels) + 5) . '">' . $p_section_name . '</td></tr>' . "\n";
    echo '    <tr class="row-category2">' . "\n";
    echo '      <th class="width30" rowspan="2">' . lang_get('message') . '</th>';
    echo '      <th class="form-title" style="text-align:center" rowspan="2">' . lang_get('issue_reporter') . '</th>' . "\n";
    echo '      <th class="form-title" style="text-align:center" rowspan="2">' . lang_get('issue_handler') . '</th>' . "\n";
    echo '      <th class="form-title" style="text-align:center" rowspan="2">' . lang_get('users_monitoring_bug') . '</th>' . "\n";
    echo '      <th class="form-title" style="text-align:center" rowspan="2">' . lang_get('users_added_bugnote') . '</th>' . "\n";
    echo '      <th class="form-title" style="text-align:center" rowspan="2">' . lang_get('category_assigned_to') . '</th>' . "\n";
    echo '      <th class="form-title" style="text-align:center" colspan="' . count($t_access_levels) . '">' . lang_get('access_levels') . '</th>' . "\n";
    echo '    </tr><tr class="row-category2">' . "\n";
    foreach ($t_access_levels as $t_access_level) {
        echo '      <th>&#160;' . MantisEnum::getLabel(lang_get('access_levels_enum_string'), $t_access_level) . '&#160;</th>' . "\n";
    }
    echo '    </tr>' . "\n";
    echo '  </thead>' . "\n";
    echo '<tbody>' . "\n";
}
Example #23
0
 /**
  * Tests enumerations that contain duplicate labels.
  */
 public function testNonTrimmedEnum()
 {
     $this->assertEquals('viewer', MantisEnum::getLabel(MantisEnumTest::NON_TRIMMED_ENUM, 10));
     $this->assertEquals('reporter', MantisEnum::getLabel(MantisEnumTest::NON_TRIMMED_ENUM, 20));
     $this->assertEquals('@100@', MantisEnum::getLabel(MantisEnumTest::NON_TRIMMED_ENUM, 100));
 }
Example #24
0
function print_status_option_list($p_select_label, $p_current_value = 0, $p_allow_close = false, $p_project_id = ALL_PROJECTS)
{
    $t_current_auth = access_get_project_level($p_project_id);
    $t_enum_list = get_status_option_list($t_current_auth, $p_current_value, true, $p_allow_close, $p_project_id);
    if (count($t_enum_list) > 1) {
        # resort the list into ascending order
        ksort($t_enum_list);
        reset($t_enum_list);
        echo '<select ' . helper_get_tab_index() . ' id="' . $p_select_label . '" name="' . $p_select_label . '">';
        foreach ($t_enum_list as $key => $val) {
            echo '<option value="' . $key . '"';
            check_selected($key, $p_current_value);
            echo '>' . string_html_specialchars($val) . '</option>';
        }
        echo '</select>';
    } else {
        if (count($t_enum_list) == 1) {
            echo array_pop($t_enum_list);
        } else {
            echo MantisEnum::getLabel(lang_get('status_enum_string'), $p_current_value);
        }
    }
}
Example #25
0
        if (!access_has_bug_level(config_get('assign_sponsored_bugs_threshold'), $f_bug_id)) {
            trigger_error(ERROR_SPONSORSHIP_ASSIGNER_ACCESS_LEVEL_TOO_LOW, ERROR);
        }
    }
    if ($f_handler_id != NO_USER) {
        if (!access_has_bug_level(config_get('handle_bug_threshold'), $f_bug_id, $f_handler_id)) {
            trigger_error(ERROR_HANDLER_ACCESS_TOO_LOW, ERROR);
        }
        if ($t_bug_sponsored) {
            if (!access_has_bug_level(config_get('handle_sponsored_bugs_threshold'), $f_bug_id, $f_handler_id)) {
                trigger_error(ERROR_SPONSORSHIP_HANDLER_ACCESS_LEVEL_TOO_LOW, ERROR);
            }
        }
    }
}
$t_status_label = str_replace(" ", "_", MantisEnum::getLabel(config_get('status_enum_string'), $f_new_status));
$t_resolved = config_get('bug_resolved_status_threshold');
$t_closed = config_get('bug_closed_status_threshold');
$t_bug = bug_get($f_bug_id);
html_page_top(bug_format_summary($f_bug_id, SUMMARY_CAPTION));
print_recently_visited();
?>

<br />
<div align="center">
<form id="bug-change-status-form" name="bug_change_status_form" method="post" action="bug_update.php">
<?php 
echo form_security_field('bug_update');
?>
<table class="width75" cellspacing="1">