Esempio n. 1
0
/**
 * Helper function which will be used extensively
 * @return	array	Array with information about the SCM
 */
function get_scm_data()
{
    global $PARAMS, $SOAP, $LOG;
    static $scm_data = null;
    if (!$scm_data) {
        $group_id = get_working_group($PARAMS);
        $res = $SOAP->call("getSCMData", array("group_id" => $group_id));
        if ($error = $SOAP->getError()) {
            $LOG->add($SOAP->responseData);
            exit_error($error, $SOAP->faultcode);
        }
        $scm_data = $res;
    }
    return $scm_data;
}
Esempio n. 2
0
function task_do_groups()
{
    global $PARAMS, $SOAP, $LOG;
    if (get_parameter($PARAMS, "help")) {
        return;
    }
    $group_id = get_working_group($PARAMS);
    $res = $SOAP->call("getProjectGroups", array("group_id" => $group_id));
    if ($error = $SOAP->getError()) {
        exit_error($error, $SOAP->faultcode);
    }
    show_output($res);
}
Esempio n. 3
0
/**
 * Get the variables for an artifact from the command line. This function is used when
 * adding/updating an artifact
 * 
 * @param bool	Specify that we're getting the variables for adding an artifact and not updating
 * @return array
 */
function get_artifact_params($adding = false)
{
    global $PARAMS, $SOAP, $LOG, $extra_fields;
    $group_id = get_working_group($PARAMS);
    $ret = array();
    $updating = !$adding;
    // we're updating if and only if we're not adding
    // Check the type ID
    if (!($group_artifact_id = get_parameter($PARAMS, "type", true))) {
        $group_artifact_id = get_user_input("Type ID of the artifact: ");
    }
    if (!$group_artifact_id || !is_numeric($group_artifact_id)) {
        exit_error("You must specify the type ID of the artifact as a valid number");
    }
    // Force the input of the artifact ID only if we're updating
    if ($updating) {
        if (!($artifact_id = get_parameter($PARAMS, "id", true))) {
            $artifact_id = get_user_input("ID of the artifact to modify: ");
        }
        if (!$artifact_id || !is_numeric($artifact_id)) {
            exit_error("You must specify the artifact ID as a valid number");
        }
        // check the artifact ID is valid
        $artifacts = $SOAP->call("getArtifacts", array("group_id" => $group_id, "group_artifact_id" => $group_artifact_id, "assigned_to" => "", "status" => ""));
        if ($error = $SOAP->getError()) {
            $LOG->add($SOAP->responseData);
            exit_error($error, $SOAP->faultcode);
        }
        $original_data = array();
        foreach ($artifacts as $artifact) {
            if ($artifact["artifact_id"] == $artifact_id) {
                $original_data = $artifact;
                $artifact_summary = $artifact["summary"];
            }
        }
        // The artifact wasn't found
        if (count($original_data) == 0) {
            exit_error("The artifact #" . $artifact_id . " doesn't belong to tracker #" . $group_artifact_id);
        }
    }
    // Check the priority
    if (!($priority = get_parameter($PARAMS, "priority", true)) && $adding) {
        // set a default value (only if adding)
        $priority = 3;
    }
    if ($priority && (!is_numeric($priority) || $priority < 1 || $priority > 5)) {
        exit_error("The priority must be a number between 1 and 5");
    }
    // ID of the user the artifact is assigned to
    if (!($assigned_to = get_parameter($PARAMS, "assigned_to", true)) && $adding) {
        $assigned_to = 100;
        // 100 = nobody
    }
    // Status ID (only for updating)
    if ($updating) {
        $status_id = get_parameter($PARAMS, "status", true);
    }
    // Check the summary
    if (!($summary = get_parameter($PARAMS, "summary")) && $adding) {
        $summary = get_user_input("Summary for this item: ");
    }
    $summary = trim($summary);
    if ($adding && !$summary) {
        // Summary is required only if adding an artifact
        exit_error("You must specify a summary for this item");
    }
    // Check the details
    if (!($details = get_parameter($PARAMS, "details")) && $adding) {
        $details = get_user_input("Details for this item: ");
    }
    $details = trim($details);
    if ($adding && !$details) {
        exit_error("You must specify a detail for this item");
    }
    // Check for invalid IDs
    // Get the group
    $group_res = $SOAP->call("getGroups", array("group_ids" => array($group_id)));
    if (count($group_res) == 0) {
        // Group doesn't exist
        exit_error("Group " . $group_id . " doesn't exist");
    }
    $group_name = $group_res[0]["group_name"];
    // Get the artifact type
    $artifact_type_res = $SOAP->call("getArtifactTypes", array("group_id" => $group_id));
    if (is_array($artifact_type_res) && count($artifact_type_res) > 0) {
        $found = false;
        // Search the name of the selected artifact type in the array of artifact types for the project
        for ($i = 0; $i < count($artifact_type_res); $i++) {
            if ($artifact_type_res[$i]["group_artifact_id"] == $group_artifact_id) {
                $found = true;
                $artifact_type_name = $artifact_type_res[$i]["name"];
                $artifact_index = $i;
                break;
            }
        }
        if (!$found) {
            exit_error("Type number " . $group_artifact_id . " doesn't belong to project " . $group_name);
        }
    } else {
        exit_error("Type number " . $group_artifact_id . " doesn't belong to project " . $group_name);
    }
    // Get the extra fields for this artifact and validate the input
    $extra_fields_tmp = $artifact_type_res[$artifact_index]["extra_fields"];
    $extra_fields = array();
    $extra_fields_data = array();
    $efd_index = 0;
    // rebuild the array in a more convenient way
    foreach ($extra_fields_tmp as $extra_field) {
        $alias = $extra_field["alias"];
        if (strlen($alias) == 0) {
            continue;
        }
        $extra_fields[$alias] = $extra_field;
        // Get the value specified for this extra field (if any)
        $value = get_parameter($PARAMS, $alias, true);
        // the extra field wasn't specified but it is required...
        if ($adding && strlen($value) == 0 && $extra_field["is_required"]) {
            exit_error("You must specify the parameter '" . $alias . "'");
        }
        if (strlen($value) > 0) {
            $value_ok = false;
            switch ($extra_field["field_type"]) {
                case ARTIFACT_EXTRAFIELDTYPE_TEXT:
                case ARTIFACT_EXTRAFIELDTYPE_TEXTAREA:
                    // this doesn't need validation
                    $value_ok = true;
                    break;
                case ARTIFACT_EXTRAFIELDTYPE_CHECKBOX:
                case ARTIFACT_EXTRAFIELDTYPE_MULTISELECT:
                    if (strtolower($value) == "none") {
                        $value = "100";
                        $value_ok = true;
                        break;
                    }
                    // in this case, $value is a list of comma-separated ids
                    $available_values_str = "";
                    // first get the list of the available values
                    foreach ($extra_field["available_values"] as $available_value) {
                        $available_values_str .= $available_value["element_id"] . " (" . $available_value["element_name"] . "), ";
                    }
                    // remove trailing ,
                    $available_values_str = preg_replace("/, \$/", "", $available_values_str);
                    $value_ok = true;
                    $values = split(",", $value);
                    $invalid_values = array();
                    // list of invalid values entered by the user
                    foreach ($values as $id) {
                        $found = false;
                        foreach ($extra_field["available_values"] as $available_value) {
                            // note we are comparing strings
                            if ("{$id}" == "" . $available_value["element_id"]) {
                                $found = true;
                                break;
                            }
                        }
                        if (!$found) {
                            $value_ok = false;
                            $invalid_values[] = $id;
                        }
                    }
                    if (!$value_ok) {
                        if (count($invalid_values) == 1) {
                            $error = "Value " . $invalid_values[0] . " is invalid for the field '" . $extra_field["field_name"] . "'. Available values are: " . $available_values_str;
                        } else {
                            $error = "Values " . implode(",", $invalid_values) . " are invalid for the field '" . $extra_field["field_name"] . "'. Available values are: " . $available_values_str;
                        }
                    }
                    break;
                case ARTIFACT_EXTRAFIELDTYPE_STATUS:
                case ARTIFACT_EXTRAFIELDTYPE_RADIO:
                case ARTIFACT_EXTRAFIELDTYPE_SELECT:
                    // Map the value entered by the user to an existing element_id
                    $available_values_str = "";
                    foreach ($extra_field["available_values"] as $available_value) {
                        $available_values_str .= $available_value["element_id"] . " (" . $available_value["element_name"] . "), ";
                        // note we are comparing strings
                        if ("" . $available_value["element_id"] == "{$value}") {
                            $value_ok = true;
                        }
                    }
                    // remove trailing ,
                    $available_values_str = preg_replace("/, \$/", "", $available_values_str);
                    if (!$value_ok) {
                        $error = "Value '{$value}' is invalid for the field '" . $extra_field["field_name"] . "'. Available values are: " . $available_values_str;
                    }
                    break;
            }
            if (!$value_ok) {
                exit_error($error);
            } else {
                $extra_fields_data[$efd_index] = array();
                $extra_fields_data[$efd_index]["extra_field_id"] = $extra_field["extra_field_id"];
                $extra_fields_data[$efd_index]["field_data"] = $value;
                $efd_index++;
            }
        }
    }
    // Get the user
    if ($assigned_to) {
        $users_res = $SOAP->call("getUsers", array("user_ids" => array($assigned_to)));
        if (!$SOAP->getError() && is_array($users_res) && count($users_res) > 0) {
            $assigned_to_name = $users_res[0]["firstname"] . " " . $users_res[0]["lastname"] . " (" . $users_res[0]["user_name"] . ")";
        } else {
            exit_error("Invalid user ID: " . $assigned_to);
        }
    } else {
        $assigned_to_name = "(nobody)";
    }
    // return the data to insert
    $ret["data"]["group_id"] = $group_id;
    $ret["data"]["group_artifact_id"] = $group_artifact_id;
    if ($updating) {
        $ret["data"]["artifact_id"] = $artifact_id;
        $ret["data"]["original_data"] = $original_data;
        if ($status_id) {
            $ret["data"]["status_id"] = $status_id;
        }
        if ($priority) {
            $ret["data"]["priority"] = $priority;
        }
        if ($assigned_to) {
            $ret["data"]["assigned_to"] = $assigned_to;
        }
        if ($summary) {
            $ret["data"]["summary"] = $summary;
        }
        if ($details) {
            $ret["data"]["details"] = $details;
        }
    } else {
        $ret["data"]["priority"] = $priority;
        $ret["data"]["assigned_to"] = $assigned_to;
        $ret["data"]["summary"] = $summary;
        $ret["data"]["details"] = $details;
    }
    $ret["data"]["extra_fields_data"] = $extra_fields_data;
    // also return the textual description of the data
    $ret["desc"]["group_name"] = $group_name;
    $ret["desc"]["artifact_type_name"] = $artifact_type_name;
    if ($updating) {
        $ret["desc"]["original_summary"] = $artifact_summary;
    }
    if ($priority) {
        $ret["desc"]["priority"] = $priority;
    }
    if ($summary) {
        $ret["desc"]["summary"] = $summary;
    }
    if ($details) {
        $ret["desc"]["details"] = $details;
    }
    if ($assigned_to) {
        $ret["desc"]["assigned_to_name"] = $assigned_to_name;
    }
    return $ret;
}
Esempio n. 4
0
function docman_do_delete()
{
    global $PARAMS, $SOAP, $LOG;
    $group_id = get_working_group($PARAMS);
    if (!($doc_id = get_parameter($PARAMS, "doc_id"))) {
        exit_error("You must specify a document id: (e.g.) --doc_id=17");
    }
    $params = array("group_id" => $group_id, "doc_id" => $doc_id);
    $res = $SOAP->call("documentDelete", $params);
    if ($error = $SOAP->getError()) {
        $LOG->add($SOAP->responseData);
        exit_error($error, $SOAP->faultcode);
    }
    show_output($res);
}
Esempio n. 5
0
					</div>
				</section>

				<section class="post_content" itemprop="articleBody">
					<?php 
the_content();
?>
				</section>

			</article>

		</div>
		<aside class="sidebar bg_tint_light sidebar_style_light [ padding--small ]" role="complementary">
			<h5 class="sc_title sc_title_regular sc_align_center [ no-margin ]">Working group</h5>
			<p><?php 
echo get_working_group($post->ID);
?>
</p>

			<h5 class="sc_title sc_title_regular sc_align_center [ no-margin ]">Language</h5>
			<p><?php 
echo get_language($post->ID);
?>
</p>

			<h5 class="sc_title sc_title_regular sc_align_center [ no-margin ]">Sector(s)</h5>
			<p><?php 
echo get_sector($post->ID);
?>
</p>
Esempio n. 6
0
function frs_do_addfile()
{
    global $PARAMS, $SOAP, $LOG;
    if (!($package_id = get_parameter($PARAMS, "package", true))) {
        exit_error("You must define a package with the --package parameter");
    }
    if (!($release_id = get_parameter($PARAMS, "release", true))) {
        exit_error("You must define a release with the --release parameter");
    }
    if (!($file = get_parameter($PARAMS, "file", true))) {
        exit_error("You must define a file with the --file parameter");
    } else {
        if (!file_exists($file)) {
            exit_error("File '{$file}' doesn't exist");
        } else {
            if (!($fh = fopen($file, "rb"))) {
                exit_error("Could not open '{$file}' for reading");
            }
        }
    }
    if (!($type_id = get_parameter($PARAMS, "type", true))) {
        $type_id = 9999;
        // 9999 = "other"
    }
    if (!($processor_id = get_parameter($PARAMS, "processor", true))) {
        $processor_id = 9999;
        // 9999 = "other"
    }
    $release_time = get_parameter($PARAMS, "date", true);
    if ($release_time) {
        if ($date_error = check_date($release_time)) {
            exit_error("The release date is invalid: " . $date_error);
        } else {
            $release_time = convert_date($release_time);
        }
    } else {
        $release_time = time();
    }
    $name = basename($file);
    $contents = fread($fh, filesize($file));
    $base64_contents = base64_encode($contents);
    fclose($fh);
    $group_id = get_working_group($PARAMS);
    $add_params = array("group_id" => $group_id, "package_id" => $package_id, "release_id" => $release_id, "name" => $name, "base64_contents" => $base64_contents, "type_id" => $type_id, "processor_id" => $processor_id, "release_time" => $release_time);
    $res = $SOAP->call("addFile", $add_params);
    if ($error = $SOAP->getError()) {
        $LOG->add($SOAP->responseData);
        exit_error($error, $SOAP->faultcode);
    }
    show_output($res);
}