コード例 #1
0
ファイル: mc_tag_api.php プロジェクト: fur81/zofaxiopeu
/**
 * Retrieves all tags, unless the users 
 *
 * @param string   $p_username    The user's username
 * @param string   $p_password    The user's password
 * @param int      $p_page_number The page number to return data for
 * @param string   $p_per_page    The number of issues to return per page
 * @return array The tag data
 */
function mc_tag_get_all($p_username, $p_password, $p_page_number, $p_per_page)
{
    $t_user_id = mci_check_login($p_username, $p_password);
    if ($t_user_id === false) {
        return mci_soap_fault_login_failed();
    }
    if (!access_has_global_level(config_get('tag_view_threshold'))) {
        return mci_soap_fault_access_denied($t_user_id, 'No rights to view tags');
    }
    if ($p_per_page == 0) {
        $p_per_page = 1;
    }
    $t_results = array();
    $t_total_results = tag_count('');
    foreach (tag_get_all('', $p_per_page, $p_per_page * ($p_page_number - 1)) as $t_tag_row) {
        $t_results[] = array('id' => $t_tag_row['id'], 'name' => $t_tag_row['name'], 'description' => $t_tag_row['description'], 'user_id' => mci_account_get_array_by_id($t_tag_row['user_id']), 'date_created' => SoapObjectsFactory::newDateTimeVar($t_tag_row['date_created']), 'date_updated' => SoapObjectsFactory::newDateTimeVar($t_tag_row['date_updated']));
    }
    return array('results' => $t_results, 'total_results' => $t_total_results);
}
コード例 #2
0
ファイル: mc_tag_api.php プロジェクト: N0ctrnl/mantisbt
/**
 * Retrieves all tags, unless the users
 *
 * @param string   $p_username    The user's username
 * @param string   $p_password    The user's password
 * @param int      $p_page_number The page number to return data for
 * @param string   $p_per_page    The number of issues to return per page
 * @return array The tag data
 */
function mc_tag_get_all($p_username, $p_password, $p_page_number, $p_per_page)
{
    $t_user_id = mci_check_login($p_username, $p_password);
    if ($t_user_id === false) {
        return mci_soap_fault_login_failed();
    }
    if (!access_has_global_level(config_get('tag_view_threshold'))) {
        return mci_soap_fault_access_denied($t_user_id, 'No rights to view tags');
    }
    if ($p_per_page == 0) {
        $p_per_page = 1;
    }
    $t_results = array();
    $t_total_results = tag_count('');
    $t_tags = tag_get_all('', $p_per_page, $p_per_page * ($p_page_number - 1));
    while ($t_tag = db_fetch_array($t_tags)) {
        $t_tag['user_id'] = mci_account_get_array_by_id($t_tag['user_id']);
        $t_tag['date_created'] = SoapObjectsFactory::newDateTimeVar($t_tag['date_created']);
        $t_tag['date_updated'] = SoapObjectsFactory::newDateTimeVar($t_tag['date_updated']);
        $t_results[] = $t_tag;
    }
    log_event(LOG_WEBSERVICE, "retrieved " . count($t_results) . "/{$t_total_results} tags (page #{$p_page_number})");
    return array('results' => $t_results, 'total_results' => $t_total_results);
}
コード例 #3
0
ファイル: mc_api.php プロジェクト: elmarculino/mantisbt
/**
 * Transforms a version array into an array suitable for marshalling into ProjectVersionData
 *
 * @param array $p_version Version array.
 * @return array
 */
function mci_project_version_as_array(array $p_version)
{
    return array('id' => $p_version['id'], 'name' => $p_version['version'], 'project_id' => $p_version['project_id'], 'date_order' => SoapObjectsFactory::newDateTimeVar($p_version['date_order']), 'description' => mci_null_if_empty($p_version['description']), 'released' => $p_version['released'], 'obsolete' => $p_version['obsolete']);
}
コード例 #4
0
ファイル: mc_issue_api.php プロジェクト: elmarculino/mantisbt
/**
 * Returns an array for SOAP encoding from a BugData object
 *
 * @param BugData $p_issue_data A BugData object to process.
 * @return array The issue header data as an array
 */
function mci_issue_data_as_header_array(BugData $p_issue_data)
{
    $t_issue = array();
    $t_id = $p_issue_data->id;
    $t_issue['id'] = $t_id;
    $t_issue['view_state'] = $p_issue_data->view_state;
    $t_issue['last_updated'] = SoapObjectsFactory::newDateTimeVar($p_issue_data->last_updated);
    $t_issue['project'] = $p_issue_data->project_id;
    $t_issue['category'] = mci_get_category($p_issue_data->category_id);
    $t_issue['priority'] = $p_issue_data->priority;
    $t_issue['severity'] = $p_issue_data->severity;
    $t_issue['status'] = $p_issue_data->status;
    $t_issue['reporter'] = $p_issue_data->reporter_id;
    $t_issue['summary'] = mci_sanitize_xml_string($p_issue_data->summary);
    if (!empty($p_issue_data->handler_id)) {
        $t_issue['handler'] = $p_issue_data->handler_id;
    } else {
        $t_issue['handler'] = null;
    }
    $t_issue['resolution'] = $p_issue_data->resolution;
    $t_issue['attachments_count'] = count(mci_issue_get_attachments($p_issue_data->id));
    $t_issue['notes_count'] = count(mci_issue_get_notes($p_issue_data->id));
    return $t_issue;
}
コード例 #5
0
/**
 * Get the attachments 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 attachments for.
 * @return array  representing a ProjectAttachmentDataArray structure.
 */
function mc_project_get_attachments($p_username, $p_password, $p_project_id)
{
    global $g_project_override;
    $t_user_id = mci_check_login($p_username, $p_password);
    if ($t_user_id === false) {
        return mci_soap_fault_login_failed();
    }
    $g_project_override = $p_project_id;
    # Check if project documentation feature is enabled.
    if (OFF == config_get('enable_project_documentation') || !file_is_uploading_enabled()) {
        return mci_soap_fault_access_denied($t_user_id);
    }
    if (!project_exists($p_project_id)) {
        return SoapObjectsFactory::newSoapFault('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_pub = VS_PUBLIC;
    $t_priv = VS_PRIVATE;
    $t_admin = config_get_global('admin_site_threshold');
    if ($p_project_id == ALL_PROJECTS) {
        # Select all the projects that the user has access to
        $t_projects = user_get_accessible_projects($t_user_id);
    } else {
        # Select the specific project
        $t_projects = array($p_project_id);
    }
    $t_projects[] = ALL_PROJECTS;
    # add ALL_PROJECTS to the list of projects to fetch
    $t_reqd_access = config_get('view_proj_doc_threshold');
    if (is_array($t_reqd_access)) {
        if (1 == count($t_reqd_access)) {
            $t_access_clause = '= ' . array_shift($t_reqd_access) . ' ';
        } else {
            $t_access_clause = 'IN (' . implode(',', $t_reqd_access) . ')';
        }
    } else {
        $t_access_clause = '>= ' . $t_reqd_access;
    }
    $t_query = 'SELECT pft.id, pft.project_id, pft.filename, pft.file_type, pft.filesize, pft.title, pft.description, pft.date_added, pft.user_id
		FROM {project_file} pft
		LEFT JOIN {project} pt ON pft.project_id = pt.id
		LEFT JOIN {project_user_list} pult
		ON pft.project_id = pult.project_id AND pult.user_id = ' . db_param() . '
		LEFT JOIN {user} ut ON ut.id = ' . db_param() . '
		WHERE pft.project_id in (' . implode(',', $t_projects) . ') AND
		( ( ( pt.view_state = ' . db_param() . ' OR pt.view_state is null ) AND pult.user_id is null AND ut.access_level ' . $t_access_clause . ' ) OR
		( ( pult.user_id = ' . db_param() . ' ) AND ( pult.access_level ' . $t_access_clause . ' ) ) OR
		( ut.access_level = ' . db_param() . ' ) )
		ORDER BY pt.name ASC, pft.title ASC';
    $t_result = db_query($t_query, array($t_user_id, $t_user_id, $t_pub, $t_user_id, $t_admin));
    $t_num_files = db_num_rows($t_result);
    $t_attachments = array();
    for ($i = 0; $i < $t_num_files; $i++) {
        $t_row = db_fetch_array($t_result);
        $t_attachment = array();
        $t_attachment['id'] = $t_row['id'];
        $t_attachment['filename'] = $t_row['filename'];
        $t_attachment['title'] = $t_row['title'];
        $t_attachment['description'] = $t_row['description'];
        $t_attachment['size'] = $t_row['filesize'];
        $t_attachment['content_type'] = $t_row['file_type'];
        $t_attachment['date_submitted'] = SoapObjectsFactory::newDateTimeVar($t_row['date_added']);
        $t_attachment['download_url'] = mci_get_mantis_path() . 'file_download.php?file_id=' . $t_row['id'] . '&amp;type=doc';
        $t_attachment['user_id'] = $t_row['user_id'];
        $t_attachments[] = $t_attachment;
    }
    return $t_attachments;
}
コード例 #6
0
ファイル: mc_project_api.php プロジェクト: fur81/zofaxiopeu
/**
 * Get the attachments 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 attachments for.
 * @return Array  representing a ProjectAttachmentDataArray structure.
 */
function mc_project_get_attachments($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();
    }
    # Check if project documentation feature is enabled.
    if (OFF == config_get('enable_project_documentation') || !file_is_uploading_enabled()) {
        return mci_soap_fault_access_denied($t_user_id);
    }
    if (!project_exists($p_project_id)) {
        return SoapObjectsFactory::newSoapFault('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_project_file_table = db_get_table('mantis_project_file_table');
    $t_project_table = db_get_table('mantis_project_table');
    $t_project_user_list_table = db_get_table('mantis_project_user_list_table');
    $t_user_table = db_get_table('mantis_user_table');
    $t_pub = VS_PUBLIC;
    $t_priv = VS_PRIVATE;
    $t_admin = config_get_global('admin_site_threshold');
    if ($p_project_id == ALL_PROJECTS) {
        # Select all the projects that the user has access to
        $t_projects = user_get_accessible_projects($t_user_id);
    } else {
        # Select the specific project
        $t_projects = array($p_project_id);
    }
    $t_projects[] = ALL_PROJECTS;
    # add ALL_PROJECTS to the list of projects to fetch
    $t_reqd_access = config_get('view_proj_doc_threshold');
    if (is_array($t_reqd_access)) {
        if (1 == count($t_reqd_access)) {
            $t_access_clause = "= " . array_shift($t_reqd_access) . " ";
        } else {
            $t_access_clause = "IN (" . implode(',', $t_reqd_access) . ")";
        }
    } else {
        $t_access_clause = ">= {$t_reqd_access} ";
    }
    $query = "SELECT pft.id, pft.project_id, pft.filename, pft.file_type, pft.filesize, pft.title, pft.description, pft.date_added, pft.user_id\n\t\tFROM {$t_project_file_table} pft\n\t\tLEFT JOIN {$t_project_table} pt ON pft.project_id = pt.id\n\t\tLEFT JOIN {$t_project_user_list_table} pult\n\t\tON pft.project_id = pult.project_id AND pult.user_id = {$t_user_id}\n\t\tLEFT JOIN {$t_user_table} ut ON ut.id = {$t_user_id}\n\t\tWHERE pft.project_id in (" . implode(',', $t_projects) . ") AND\n\t\t( ( ( pt.view_state = {$t_pub} OR pt.view_state is null ) AND pult.user_id is null AND ut.access_level {$t_access_clause} ) OR\n\t\t( ( pult.user_id = {$t_user_id} ) AND ( pult.access_level {$t_access_clause} ) ) OR\n\t\t( ut.access_level = {$t_admin} ) )\n\t\tORDER BY pt.name ASC, pft.title ASC";
    $result = db_query($query);
    $num_files = db_num_rows($result);
    $t_result = array();
    for ($i = 0; $i < $num_files; $i++) {
        $row = db_fetch_array($result);
        $t_attachment = array();
        $t_attachment['id'] = $row['id'];
        $t_attachment['filename'] = $row['filename'];
        $t_attachment['title'] = $row['title'];
        $t_attachment['description'] = $row['description'];
        $t_attachment['size'] = $row['filesize'];
        $t_attachment['content_type'] = $row['file_type'];
        $t_attachment['date_submitted'] = SoapObjectsFactory::newDateTimeVar($row['date_added']);
        $t_attachment['download_url'] = mci_get_mantis_path() . 'file_download.php?file_id=' . $row['id'] . '&amp;type=doc';
        $t_attachment['user_id'] = $row['user_id'];
        $t_result[] = $t_attachment;
    }
    return $t_result;
}