当前位置: 首页>>代码示例>>PHP>>正文


PHP user_get_accessible_projects函数代码示例

本文整理汇总了PHP中user_get_accessible_projects函数的典型用法代码示例。如果您正苦于以下问题:PHP user_get_accessible_projects函数的具体用法?PHP user_get_accessible_projects怎么用?PHP user_get_accessible_projects使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了user_get_accessible_projects函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get

 public function get($request)
 {
     /**
      *      Returns the Response with a list of bug URIs.
      *
      *      @param $request - The Request we're responding to
      */
     $visible_project_ids = user_get_accessible_projects(auth_get_current_user_id(), TRUE);
     # Now we construct a query to figure out which of these bugs matches the conditions
     # we got from the query string, and order them correctly.
     $sql_to_add = $this->_build_sql_from_querystring($request->query);
     $bug_ids = array();
     $mantis_bug_table = config_get('mantis_bug_table');
     $query = "SELECT b.id, b.project_id FROM {$mantis_bug_table} b {$sql_to_add};";
     $result = db_query($query);
     # This loop takes care of both the filtering and the sorting.
     foreach ($result as $r) {
         if (in_array($r[1], $visible_project_ids)) {
             $bug_ids[] = $r[0];
         }
     }
     $this->rsrc_data['results'] = array();
     foreach ($bug_ids as $id) {
         $this->rsrc_data['results'][] = Bug::get_url_from_mantis_id($id);
     }
     $resp = new Response();
     $resp->status = 200;
     $resp->body = $this->_repr($request);
     return $resp;
 }
开发者ID:NetWielder,项目名称:mantis-rest,代码行数:30,代码来源:buglist.class.php

示例2: filter_get_bug_rows


//.........这里部分代码省略.........
        } else {
            $t_project_ids = array_map('intval', $t_filter[FILTER_PROPERTY_PROJECT_ID]);
        }
        $t_include_sub_projects = count($t_project_ids) == 1 && ($t_project_ids[0] == META_FILTER_CURRENT || $t_project_ids[0] == ALL_PROJECTS);
    }
    log_event(LOG_FILTERING, 'project_ids = @P' . implode(', @P', $t_project_ids));
    log_event(LOG_FILTERING, 'include sub-projects = ' . ($t_include_sub_projects ? '1' : '0'));
    # if the array has ALL_PROJECTS, then reset the array to only contain ALL_PROJECTS.
    # replace META_FILTER_CURRENT with the actualy current project id.
    $t_all_projects_found = false;
    $t_new_project_ids = array();
    foreach ($t_project_ids as $t_pid) {
        if ($t_pid == META_FILTER_CURRENT) {
            $t_pid = $t_project_id;
        }
        if ($t_pid == ALL_PROJECTS) {
            $t_all_projects_found = true;
            log_event(LOG_FILTERING, 'all projects selected');
            break;
        }
        # filter out inaccessible projects.
        if (!project_exists($t_pid) || !access_has_project_level(config_get('view_bug_threshold', null, $t_user_id, $t_pid), $t_pid, $t_user_id)) {
            log_event(LOG_FILTERING, 'Invalid or inaccessible project: ' . $t_pid);
            continue;
        }
        $t_new_project_ids[] = $t_pid;
    }
    $t_projects_query_required = true;
    if ($t_all_projects_found) {
        if (user_is_administrator($t_user_id)) {
            log_event(LOG_FILTERING, 'all projects + administrator, hence no project filter.');
            $t_projects_query_required = false;
        } else {
            $t_project_ids = user_get_accessible_projects($t_user_id);
        }
    } else {
        $t_project_ids = $t_new_project_ids;
    }
    if ($t_projects_query_required) {
        # expand project ids to include sub-projects
        if ($t_include_sub_projects) {
            $t_top_project_ids = $t_project_ids;
            foreach ($t_top_project_ids as $t_pid) {
                log_event(LOG_FILTERING, 'Getting sub-projects for project id @P' . $t_pid);
                $t_subproject_ids = user_get_all_accessible_subprojects($t_user_id, $t_pid);
                if (!$t_subproject_ids) {
                    continue;
                }
                $t_project_ids = array_merge($t_project_ids, $t_subproject_ids);
            }
            $t_project_ids = array_unique($t_project_ids);
        }
        # if no projects are accessible, then return an empty array.
        if (count($t_project_ids) == 0) {
            log_event(LOG_FILTERING, 'no accessible projects');
            return array();
        }
        log_event(LOG_FILTERING, 'project_ids after including sub-projects = @P' . implode(', @P', $t_project_ids));
        # this array is to be populated with project ids for which we only want to show public issues.  This is due to the limited
        # access of the current user.
        $t_public_only_project_ids = array();
        # this array is populated with project ids that the current user has full access to.
        $t_private_and_public_project_ids = array();
        $t_limited_projects = array();
        foreach ($t_project_ids as $t_pid) {
            # limit reporters to visible projects
开发者ID:vipjaven,项目名称:mantisbt,代码行数:67,代码来源:filter_api.php

示例3: helper_project_specific_where

function helper_project_specific_where($p_project_id, $p_user_id = null)
{
    if (null === $p_user_id) {
        $p_user_id = auth_get_current_user_id();
    }
    if (ALL_PROJECTS == $p_project_id) {
        $t_topprojects = $t_project_ids = user_get_accessible_projects($p_user_id);
        foreach ($t_topprojects as $t_project) {
            $t_project_ids = array_merge($t_project_ids, user_get_all_accessible_subprojects($p_user_id, $t_project));
        }
        $t_project_ids = array_unique($t_project_ids);
    } else {
        access_ensure_project_level(VIEWER, $p_project_id);
        $t_project_ids = user_get_all_accessible_subprojects($p_user_id, $p_project_id);
        array_unshift($t_project_ids, $p_project_id);
    }
    $t_project_ids = array_map('db_prepare_int', $t_project_ids);
    if (0 == count($t_project_ids)) {
        $t_project_filter = ' 1<>1';
    } elseif (1 == count($t_project_ids)) {
        $t_project_filter = ' project_id=' . $t_project_ids[0];
    } else {
        $t_project_filter = ' project_id IN (' . join(',', $t_project_ids) . ')';
    }
    return $t_project_filter;
}
开发者ID:amjadtbssm,项目名称:website,代码行数:26,代码来源:helper_api.php

示例4: print_project_option_list

/**
 * List projects that the current user has access to.
 *
 * @param integer        $p_project_id           The current project id or null to use cookie.
 * @param boolean        $p_include_all_projects True: include "All Projects", otherwise false.
 * @param integer|null   $p_filter_project_id    The id of a project to exclude or null.
 * @param string|boolean $p_trace                The current project trace, identifies the sub-project via a path from top to bottom.
 * @param boolean        $p_can_report_only      If true, disables projects in which user can't report issues; defaults to false (all projects enabled).
 * @return void
 */
function print_project_option_list($p_project_id = null, $p_include_all_projects = true, $p_filter_project_id = null, $p_trace = false, $p_can_report_only = false)
{
    $t_user_id = auth_get_current_user_id();
    $t_project_ids = user_get_accessible_projects($t_user_id);
    $t_can_report = true;
    project_cache_array_rows($t_project_ids);
    if ($p_include_all_projects && $p_filter_project_id !== ALL_PROJECTS) {
        echo '<option value="' . ALL_PROJECTS . '"';
        if ($p_project_id !== null) {
            check_selected($p_project_id, ALL_PROJECTS, false);
        }
        echo '>' . lang_get('all_projects') . '</option>' . "\n";
    }
    foreach ($t_project_ids as $t_id) {
        if ($p_can_report_only) {
            $t_report_bug_threshold = config_get('report_bug_threshold', null, $t_user_id, $t_id);
            $t_can_report = access_has_project_level($t_report_bug_threshold, $t_id, $t_user_id);
        }
        echo '<option value="' . $t_id . '"';
        check_selected($p_project_id, $t_id, false);
        check_disabled($t_id == $p_filter_project_id || !$t_can_report);
        echo '>' . string_attribute(project_get_field($t_id, 'name')) . '</option>' . "\n";
        print_subproject_option_list($t_id, $p_project_id, $p_filter_project_id, $p_trace, $p_can_report_only);
    }
}
开发者ID:gtn,项目名称:mantisbt,代码行数:35,代码来源:print_api.php

示例5: user_get_all_accessible_projects

/**
 * retun an array of sub-project IDs of all project to which the user has access
 * @param integer $p_user_id    A valid user identifier.
 * @param integer $p_project_id A valid project identifier.
 * @return array
 */
function user_get_all_accessible_projects($p_user_id, $p_project_id)
{
    if (ALL_PROJECTS == $p_project_id) {
        $t_topprojects = user_get_accessible_projects($p_user_id);
        # Cover the case for PHP < 5.4 where array_combine() returns
        # false and triggers warning if arrays are empty (see #16187)
        if (empty($t_topprojects)) {
            return array();
        }
        # Create a combined array where key = value
        $t_project_ids = array_combine($t_topprojects, $t_topprojects);
        # Add all subprojects user has access to
        foreach ($t_topprojects as $t_project) {
            $t_subprojects_ids = user_get_all_accessible_subprojects($p_user_id, $t_project);
            foreach ($t_subprojects_ids as $t_id) {
                $t_project_ids[$t_id] = $t_id;
            }
        }
    } else {
        access_ensure_project_level(VIEWER, $p_project_id);
        $t_project_ids = user_get_all_accessible_subprojects($p_user_id, $p_project_id);
        array_unshift($t_project_ids, $p_project_id);
    }
    return $t_project_ids;
}
开发者ID:pkdevboxy,项目名称:mantisbt,代码行数:31,代码来源:user_api.php

示例6: mc_project_get_attachments

/**
 * 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 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_project_file_table = db_get_table('project_file');
    $t_project_table = db_get_table('project');
    $t_project_user_list_table = db_get_table('project_user_list');
    $t_user_table = db_get_table('user');
    $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\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'] = timestamp_to_iso8601($row['date_added']);
        $t_attachment['download_url'] = mci_get_mantis_path() . 'file_download.php?file_id=' . $row['id'] . '&amp;type=doc';
        $t_result[] = $t_attachment;
    }
    return $t_result;
}
开发者ID:kaos,项目名称:mantisbt,代码行数:69,代码来源:mc_project_api.php

示例7: current_user_get_accessible_projects

/**
 * Returns an array of projects that are accessible to the current logged in
 * user.
 *
 * @param show_disabled	Include disabled projects.
 * @return an array of accessible project ids.
 * @access public
 */
function current_user_get_accessible_projects($p_show_disabled = false)
{
    return user_get_accessible_projects(auth_get_current_user_id(), $p_show_disabled);
}
开发者ID:fur81,项目名称:zofaxiopeu,代码行数:12,代码来源:current_user_api.php

示例8: foreach

    foreach ($rows as $t_row) {
        $t_categories[] = $t_row->category_id;
    }
    category_cache_array_rows(array_unique($t_categories));
}
// get all user set filters
$t_filter = current_user_get_bug_filter();
// if viewing all projects, allow to switch between combined and splitted view
// (all projects mixed together or separated into rows)
$f_default_pdisplay = "combined";
$pdisplay = gpc_get_string('pdisplay', $f_default_pdisplay);
// only one project to display?
if ($t_project_id || $pdisplay == "combined") {
    $all_project_ids = array($t_project_id);
} else {
    $all_project_ids = user_get_accessible_projects($t_current_user_id);
}
$rowcounts = array();
foreach ($all_project_ids as $curr_project_id) {
    ?>
    <tr>
        <td class="projectHeader" colspan="<?php 
    echo count($columns);
    ?>
">
            <h1><?php 
    echo project_get_name($curr_project_id);
    ?>
</h1>
        </td>
    </tr>
开发者ID:aberad,项目名称:MantisKanban,代码行数:31,代码来源:kanban_page.php

示例9: config_get

# along with Mantis.  If not, see <http://www.gnu.org/licenses/>.
# --------------------------------------------------------
# $Id: summary_page.php,v 1.54.2.1 2007-10-13 22:34:43 giallu Exp $
# --------------------------------------------------------
require_once 'core.php';
$t_core_path = config_get('core_path');
require_once $t_core_path . 'summary_api.php';
access_ensure_project_level(config_get('view_summary_threshold'));
$f_project_id = gpc_get_int('project_id', helper_get_current_project());
# Override the current page to make sure we get the appropriate project-specific configuration
$g_project_override = $f_project_id;
$t_user_id = auth_get_current_user_id();
# @@@ giallu: this block of code is duplicated from helper_project_specific_where
# the only diff is the commented line below: can we do better than this ?
if (ALL_PROJECTS == $f_project_id) {
    $t_topprojects = $t_project_ids = user_get_accessible_projects($t_user_id);
    foreach ($t_topprojects as $t_project) {
        $t_project_ids = array_merge($t_project_ids, user_get_all_accessible_subprojects($t_user_id, $t_project));
    }
    $t_project_ids = array_unique($t_project_ids);
} else {
    # access_ensure_project_level( VIEWER, $p_project_id );
    $t_project_ids = user_get_all_accessible_subprojects($t_user_id, $f_project_id);
    array_unshift($t_project_ids, $f_project_id);
}
$t_project_ids = array_map('db_prepare_int', $t_project_ids);
if (0 == count($t_project_ids)) {
    $specific_where = ' 1 <> 1';
} elseif (1 == count($t_project_ids)) {
    $specific_where = ' project_id=' . $t_project_ids[0];
} else {
开发者ID:jin255ff,项目名称:company_website,代码行数:31,代码来源:summary_page.php

示例10: mc_project_get_attachments

/**
 * 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;
}
开发者ID:derrickweaver,项目名称:mantisbt,代码行数:78,代码来源:mc_project_api.php

示例11: filter_get_bug_rows

function filter_get_bug_rows(&$p_page_number, &$p_per_page, &$p_page_count, &$p_bug_count, $p_custom_filter = null, $p_project_id = null, $p_user_id = null, $p_show_sticky = null)
{
    log_event(LOG_FILTERING, 'FILTERING: START NEW FILTER QUERY');
    $t_bug_table = config_get('mantis_bug_table');
    $t_bug_text_table = config_get('mantis_bug_text_table');
    $t_bugnote_table = config_get('mantis_bugnote_table');
    $t_custom_field_string_table = config_get('mantis_custom_field_string_table');
    $t_bugnote_text_table = config_get('mantis_bugnote_text_table');
    $t_project_table = config_get('mantis_project_table');
    $t_bug_monitor_table = config_get('mantis_bug_monitor_table');
    $t_limit_reporters = config_get('limit_reporters');
    $t_bug_relationship_table = config_get('mantis_bug_relationship_table');
    $t_report_bug_threshold = config_get('report_bug_threshold');
    $t_current_user_id = auth_get_current_user_id();
    if (null === $p_user_id) {
        $t_user_id = $t_current_user_id;
    } else {
        $t_user_id = $p_user_id;
    }
    $c_user_id = db_prepare_int($t_user_id);
    if (null === $p_project_id) {
        # @@@ If project_id is not specified, then use the project id(s) in the filter if set, otherwise, use current project.
        $t_project_id = helper_get_current_project();
    } else {
        $t_project_id = $p_project_id;
    }
    if ($p_custom_filter === null) {
        # Prefer current_user_get_bug_filter() over user_get_filter() when applicable since it supports
        # cookies set by previous version of the code.
        if ($t_user_id == $t_current_user_id) {
            $t_filter = current_user_get_bug_filter();
        } else {
            $t_filter = user_get_bug_filter($t_user_id, $t_project_id);
        }
    } else {
        $t_filter = $p_custom_filter;
    }
    $t_filter = filter_ensure_valid_filter($t_filter);
    if (false === $t_filter) {
        return false;
        # signify a need to create a cookie
        #@@@ error instead?
    }
    $t_view_type = $t_filter['_view_type'];
    $t_where_clauses = array("{$t_project_table}.enabled = 1", "{$t_project_table}.id = {$t_bug_table}.project_id");
    $t_select_clauses = array("{$t_bug_table}.*");
    $t_join_clauses = array();
    $t_from_clauses = array();
    // normalize the project filtering into an array $t_project_ids
    if ('simple' == $t_view_type) {
        log_event(LOG_FILTERING, 'FILTERING: Simple Filter');
        $t_project_ids = array($t_project_id);
        $t_include_sub_projects = true;
    } else {
        log_event(LOG_FILTERING, 'FILTERING: Advanced Filter');
        if (!is_array($t_filter['project_id'])) {
            $t_project_ids = array(db_prepare_int($t_filter['project_id']));
        } else {
            $t_project_ids = array_map('db_prepare_int', $t_filter['project_id']);
        }
        $t_include_sub_projects = count($t_project_ids) == 1 && $t_project_ids[0] == META_FILTER_CURRENT;
    }
    log_event(LOG_FILTERING, 'FILTERING: project_ids = ' . implode(',', $t_project_ids));
    log_event(LOG_FILTERING, 'FILTERING: include sub-projects = ' . ($t_include_sub_projects ? '1' : '0'));
    // if the array has ALL_PROJECTS, then reset the array to only contain ALL_PROJECTS.
    // replace META_FILTER_CURRENT with the actualy current project id.
    $t_all_projects_found = false;
    $t_new_project_ids = array();
    foreach ($t_project_ids as $t_pid) {
        if ($t_pid == META_FILTER_CURRENT) {
            $t_pid = $t_project_id;
        }
        if ($t_pid == ALL_PROJECTS) {
            $t_all_projects_found = true;
            log_event(LOG_FILTERING, 'FILTERING: all projects selected');
            break;
        }
        // filter out inaccessible projects.
        if (!access_has_project_level(VIEWER, $t_pid, $t_user_id)) {
            continue;
        }
        $t_new_project_ids[] = $t_pid;
    }
    $t_projects_query_required = true;
    if ($t_all_projects_found) {
        if (user_is_administrator($t_user_id)) {
            log_event(LOG_FILTERING, 'FILTERING: all projects + administrator, hence no project filter.');
            $t_projects_query_required = false;
        } else {
            $t_project_ids = user_get_accessible_projects($t_user_id);
        }
    } else {
        $t_project_ids = $t_new_project_ids;
    }
    if ($t_projects_query_required) {
        // expand project ids to include sub-projects
        if ($t_include_sub_projects) {
            $t_top_project_ids = $t_project_ids;
            foreach ($t_top_project_ids as $t_pid) {
                log_event(LOG_FILTERING, 'FILTERING: Getting sub-projects for project id ' . $t_pid);
//.........这里部分代码省略.........
开发者ID:amjadtbssm,项目名称:website,代码行数:101,代码来源:filter_api.php

示例12: access_denied

if (OFF == config_get('enable_project_documentation') || !file_is_uploading_enabled()) {
    access_denied();
}
# Override the current page to make sure we get the appropriate project-specific configuration
$g_project_override = $f_project_id;
$t_user_id = auth_get_current_user_id();
$t_project_file_table = db_get_table('project_file');
$t_project_table = db_get_table('project');
$t_project_user_list_table = db_get_table('project_user_list');
$t_user_table = db_get_table('user');
$t_pub = VS_PUBLIC;
$t_priv = VS_PRIVATE;
$t_admin = config_get_global('admin_site_threshold');
if ($f_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($f_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} ";
开发者ID:N0ctrnl,项目名称:mantisbt,代码行数:31,代码来源:proj_doc_page.php

示例13: filter_get_bug_rows


//.........这里部分代码省略.........
            $t_project_ids = array(db_prepare_int($t_filter[FILTER_PROPERTY_PROJECT_ID]));
        } else {
            $t_project_ids = array_map('db_prepare_int', $t_filter[FILTER_PROPERTY_PROJECT_ID]);
        }
        $t_include_sub_projects = count($t_project_ids) == 1 && ($t_project_ids[0] == META_FILTER_CURRENT || $t_project_ids[0] == ALL_PROJECTS);
    }
    log_event(LOG_FILTERING, 'project_ids = @P' . implode(', @P', $t_project_ids));
    log_event(LOG_FILTERING, 'include sub-projects = ' . ($t_include_sub_projects ? '1' : '0'));
    // if the array has ALL_PROJECTS, then reset the array to only contain ALL_PROJECTS.
    // replace META_FILTER_CURRENT with the actualy current project id.
    $t_all_projects_found = false;
    $t_new_project_ids = array();
    foreach ($t_project_ids as $t_pid) {
        if ($t_pid == META_FILTER_CURRENT) {
            $t_pid = $t_project_id;
        }
        if ($t_pid == ALL_PROJECTS) {
            $t_all_projects_found = true;
            log_event(LOG_FILTERING, 'all projects selected');
            break;
        }
        // filter out inaccessible projects.
        if (!access_has_project_level(VIEWER, $t_pid, $t_user_id)) {
            continue;
        }
        $t_new_project_ids[] = $t_pid;
    }
    $t_projects_query_required = true;
    if ($t_all_projects_found) {
        if (user_is_administrator($t_user_id)) {
            log_event(LOG_FILTERING, 'all projects + administrator, hence no project filter.');
            $t_projects_query_required = false;
        } else {
            $t_project_ids = user_get_accessible_projects($t_user_id);
        }
    } else {
        $t_project_ids = $t_new_project_ids;
    }
    if ($t_projects_query_required) {
        // expand project ids to include sub-projects
        if ($t_include_sub_projects) {
            $t_top_project_ids = $t_project_ids;
            foreach ($t_top_project_ids as $t_pid) {
                log_event(LOG_FILTERING, 'Getting sub-projects for project id @P' . $t_pid);
                $t_subproject_ids = user_get_all_accessible_subprojects($t_user_id, $t_pid);
                if (!$t_subproject_ids) {
                    continue;
                }
                $t_project_ids = array_merge($t_project_ids, $t_subproject_ids);
            }
            $t_project_ids = array_unique($t_project_ids);
        }
        // if no projects are accessible, then return an empty array.
        if (count($t_project_ids) == 0) {
            log_event(LOG_FILTERING, 'no accessible projects');
            return array();
        }
        log_event(LOG_FILTERING, 'project_ids after including sub-projects = @P' . implode(', @P', $t_project_ids));
        // this array is to be populated with project ids for which we only want to show public issues.  This is due to the limited
        // access of the current user.
        $t_public_only_project_ids = array();
        // this array is populated with project ids that the current user has full access to.
        $t_private_and_public_project_ids = array();
        foreach ($t_project_ids as $t_pid) {
            $t_access_required_to_view_private_bugs = config_get('private_bug_threshold', null, null, $t_pid);
            if (access_has_project_level($t_access_required_to_view_private_bugs, $t_pid, $t_user_id)) {
开发者ID:nourchene-benslimane,项目名称:mantisV0,代码行数:67,代码来源:filter_api.php

示例14: get_user_array

}
function get_user_array()
{
    class User
    {
        public $id;
        public $name;
    }
    $user_array = array();
    $p_project_id = null;
    if (null === $p_project_id) {
        $p_project_id = helper_get_current_project();
    }
    if ($p_project_id === ALL_PROJECTS) {
        $t_current_user = auth_get_current_user_id();
        $t_projects = user_get_accessible_projects($t_current_user);
        # Get list of users having access level for all accessible projects
        $t_users = array();
        foreach ($t_projects as $t_project_id) {
            $t_project_users_list = project_get_all_user_rows($t_project_id, DEVELOPER);
            # Do a 'smart' merge of the project's user list, into an
            # associative array (to remove duplicates)
            # Use a foreach loop for correctness
            foreach ($t_project_users_list as $t_key => $t_user) {
                $t_users[$t_user['id']] = $t_user;
            }
            unset($t_project_users_list);
        }
        unset($t_projects);
    } else {
        $t_users = project_get_all_user_rows($p_project_id, DEVELOPER);
开发者ID:AuthenticEshkinKot,项目名称:Taskodrome,代码行数:31,代码来源:main.php

示例15: filter_get_bug_rows

function filter_get_bug_rows(&$p_page_number, &$p_per_page, &$p_page_count, &$p_bug_count, $p_custom_filter = null, $p_project_id = null, $p_user_id = null, $p_show_sticky = null)
{
    $t_bug_table = config_get('mantis_bug_table');
    $t_bug_text_table = config_get('mantis_bug_text_table');
    $t_bugnote_table = config_get('mantis_bugnote_table');
    $t_custom_field_string_table = config_get('mantis_custom_field_string_table');
    $t_bugnote_text_table = config_get('mantis_bugnote_text_table');
    $t_project_table = config_get('mantis_project_table');
    $t_bug_monitor_table = config_get('mantis_bug_monitor_table');
    $t_limit_reporters = config_get('limit_reporters');
    $t_bug_relationship_table = config_get('mantis_bug_relationship_table');
    $t_report_bug_threshold = config_get('report_bug_threshold');
    $t_current_user_id = auth_get_current_user_id();
    if (null === $p_user_id) {
        $t_user_id = $t_current_user_id;
    } else {
        $t_user_id = $p_user_id;
    }
    $c_user_id = db_prepare_int($t_user_id);
    if (null === $p_project_id) {
        $t_project_id = helper_get_current_project();
    } else {
        $t_project_id = $p_project_id;
    }
    if ($p_custom_filter === null) {
        # Prefer current_user_get_bug_filter() over user_get_filter() when applicable since it supports
        # cookies set by previous version of the code.
        if ($t_user_id == $t_current_user_id) {
            $t_filter = current_user_get_bug_filter();
        } else {
            $t_filter = user_get_bug_filter($t_user_id, $t_project_id);
        }
    } else {
        $t_filter = $p_custom_filter;
    }
    $t_filter = filter_ensure_valid_filter($t_filter);
    if (false === $t_filter) {
        return false;
        # signify a need to create a cookie
        #@@@ error instead?
    }
    $t_where_clauses = array("{$t_project_table}.enabled = 1", "{$t_project_table}.id = {$t_bug_table}.project_id");
    $t_select_clauses = array("{$t_bug_table}.*");
    $t_join_clauses = array();
    $t_from_clauses = array();
    if (ALL_PROJECTS == $t_project_id) {
        if (!user_is_administrator($t_user_id)) {
            $t_topprojects = $t_projects = user_get_accessible_projects($t_user_id);
            foreach ($t_topprojects as $t_project) {
                $t_projects = array_merge($t_projects, user_get_all_accessible_subprojects($t_user_id, $t_project));
            }
            $t_projects = array_unique($t_projects);
            if (0 == count($t_projects)) {
                return array();
                # no accessible projects, return an empty array
            } else {
                if (1 == count($t_projects)) {
                    $t_project = $t_projects[0];
                    array_push($t_where_clauses, "( {$t_bug_table}.project_id={$t_project} )");
                } else {
                    array_push($t_where_clauses, "( {$t_bug_table}.project_id in (" . implode(', ', $t_projects) . ") )");
                }
            }
        }
    } else {
        access_ensure_project_level(VIEWER, $t_project_id, $t_user_id);
        $t_projects = user_get_all_accessible_subprojects($t_user_id, $t_project_id);
        $t_projects[] = $t_project_id;
        $t_projects = array_unique($t_projects);
        if (1 == count($t_projects)) {
            $t_project = $t_projects[0];
            array_push($t_where_clauses, "( {$t_bug_table}.project_id={$t_project} )");
        } else {
            array_push($t_where_clauses, "( {$t_bug_table}.project_id in (" . implode(', ', $t_projects) . ") )");
        }
    }
    # private bug selection
    if (!access_has_project_level(config_get('private_bug_threshold'), $t_project_id, $t_user_id)) {
        $t_public = VS_PUBLIC;
        $t_private = VS_PRIVATE;
        switch ($t_filter['view_state']) {
            case VS_PUBLIC:
                array_push($t_where_clauses, "({$t_bug_table}.view_state='{$t_public}')");
                break;
            case VS_PRIVATE:
                array_push($t_where_clauses, "({$t_bug_table}.view_state='{$t_private}' AND {$t_bug_table}.reporter_id='{$t_user_id}')");
                break;
            case META_FILTER_ANY:
            default:
                array_push($t_where_clauses, "({$t_bug_table}.view_state='{$t_public}' OR {$t_bug_table}.reporter_id='{$t_user_id}')");
                break;
        }
    } else {
        $t_view_state = db_prepare_int($t_filter['view_state']);
        if ($t_filter['view_state'] !== META_FILTER_ANY && !is_blank($t_filter['view_state'])) {
            array_push($t_where_clauses, "({$t_bug_table}.view_state='{$t_view_state}')");
        }
    }
    # reporter
    $t_any_found = false;
//.........这里部分代码省略.........
开发者ID:centaurustech,项目名称:BenFund,代码行数:101,代码来源:filter_api.php


注:本文中的user_get_accessible_projects函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。