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


PHP context::get_parent_context_ids方法代码示例

本文整理汇总了PHP中context::get_parent_context_ids方法的典型用法代码示例。如果您正苦于以下问题:PHP context::get_parent_context_ids方法的具体用法?PHP context::get_parent_context_ids怎么用?PHP context::get_parent_context_ids使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在context的用法示例。


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

示例1: get_related_contexts_string

/**
 * Gets a string for sql calls, searching for stuff in this context or above
 *
 * NOTE: use $DB->get_in_or_equal($context->get_parent_context_ids()...
 *
 * @deprecated since 2.2, $context->use get_parent_context_ids() instead
 * @param context $context
 * @return string
 */
function get_related_contexts_string(context $context)
{
    if ($parents = $context->get_parent_context_ids()) {
        return ' IN (' . $context->id . ',' . implode(',', $parents) . ')';
    } else {
        return ' =' . $context->id;
    }
}
开发者ID:rolandovanegas,项目名称:moodle,代码行数:17,代码来源:accesslib.php

示例2: get_related_contexts_string

/**
 * Gets a string for sql calls, searching for stuff in this context or above.
 *
 * @deprecated since 2.2
 * @see context::get_parent_context_ids()
 * @param context $context
 * @return string
 */
function get_related_contexts_string(context $context)
{
    debugging('get_related_contexts_string() is deprecated, please use $context->get_parent_context_ids(true) instead.', DEBUG_DEVELOPER);
    if ($parents = $context->get_parent_context_ids()) {
        return ' IN (' . $context->id . ',' . implode(',', $parents) . ')';
    } else {
        return ' =' . $context->id;
    }
}
开发者ID:Hirenvaghasiya,项目名称:moodle,代码行数:17,代码来源:deprecatedlib.php

示例3: count_role_users

/**
 * Counts all the users assigned this role in this context or higher
 *
 * @param int|array $roleid either int or an array of ints
 * @param context $context
 * @param bool $parent if true, get list of users assigned in higher context too
 * @return int Returns the result count
 */
function count_role_users($roleid, context $context, $parent = false) {
    global $DB;

    if ($parent) {
        if ($contexts = $context->get_parent_context_ids()) {
            $parentcontexts = ' OR r.contextid IN ('.implode(',', $contexts).')';
        } else {
            $parentcontexts = '';
        }
    } else {
        $parentcontexts = '';
    }

    if ($roleid) {
        list($rids, $params) = $DB->get_in_or_equal($roleid, SQL_PARAMS_QM);
        $roleselect = "AND r.roleid $rids";
    } else {
        $params = array();
        $roleselect = '';
    }

    array_unshift($params, $context->id);

    $sql = "SELECT COUNT(u.id)
              FROM {role_assignments} r
              JOIN {user} u ON u.id = r.userid
             WHERE (r.contextid = ? $parentcontexts)
                   $roleselect
                   AND u.deleted = 0";

    return $DB->count_records_sql($sql, $params);
}
开发者ID:rwijaya,项目名称:moodle,代码行数:40,代码来源:accesslib.php

示例4: meditraxcohort_can_view_cohort

/**
 * Check if cohort exists and user is allowed to access it from the given context.
 *
 * @param stdClass|int $cohortorid cohort object or id
 * @param context $currentcontext current context (course) where visibility is checked
 * @return boolean
 */
function meditraxcohort_can_view_cohort($cohortorid, $currentcontext)
{
    global $DB;
    if (is_numeric($cohortorid)) {
        $cohort = $DB->get_record('cohort', array('id' => $cohortorid), 'id, contextid, visible');
    } else {
        $cohort = $cohortorid;
    }
    if ($cohort && in_array($cohort->contextid, $currentcontext->get_parent_context_ids())) {
        if ($cohort->visible) {
            return true;
        }
        $cohortcontext = context::instance_by_id($cohort->contextid);
        if (has_capability('moodle/cohort:view', $cohortcontext)) {
            return true;
        }
    }
    return false;
}
开发者ID:posttechguy,项目名称:moodle-meditrax-local_meditraxcohort,代码行数:26,代码来源:lib.php


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