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


PHP stdClass::get_parent_context_ids方法代码示例

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


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

示例1: get_other_users

 /**
  * Gets and array of other users.
  *
  * Other users are users who have been assigned roles or inherited roles
  * within this course but who have not been enrolled in the course
  *
  * @global moodle_database $DB
  * @param string $sort
  * @param string $direction
  * @param int $page
  * @param int $perpage
  * @return array
  */
 public function get_other_users($sort, $direction='ASC', $page=0, $perpage=25) {
     global $DB;
     if ($direction !== 'ASC') {
         $direction = 'DESC';
     }
     $key = md5("$sort-$direction-$page-$perpage");
     if (!array_key_exists($key, $this->otherusers)) {
         list($ctxcondition, $params) = $DB->get_in_or_equal($this->context->get_parent_context_ids(true), SQL_PARAMS_NAMED, 'ctx');
         $params['courseid'] = $this->course->id;
         $params['cid'] = $this->course->id;
         $sql = "SELECT ra.id as raid, ra.contextid, ra.component, ctx.contextlevel, ra.roleid, u.*, ue.lastseen
                 FROM {role_assignments} ra
                 JOIN {user} u ON u.id = ra.userid
                 JOIN {context} ctx ON ra.contextid = ctx.id
            LEFT JOIN (
                    SELECT ue.id, ue.userid, ul.timeaccess AS lastseen
                      FROM {user_enrolments} ue
                 LEFT JOIN {enrol} e ON e.id=ue.enrolid
                 LEFT JOIN {user_lastaccess} ul ON (ul.courseid = e.courseid AND ul.userid = ue.userid)
                     WHERE e.courseid = :courseid
                    ) ue ON ue.userid=u.id
                WHERE ctx.id $ctxcondition AND
                      ue.id IS NULL
             ORDER BY u.$sort $direction, ctx.depth DESC";
         $this->otherusers[$key] = $DB->get_records_sql($sql, $params, $page*$perpage, $perpage);
     }
     return $this->otherusers[$key];
 }
开发者ID:narasimhaeabyas,项目名称:tataaiapro,代码行数:41,代码来源:locallib_12_01_2016bk.php

示例2: get_other_users

 /**
  * Gets and array of other users.
  *
  * Other users are users who have been assigned roles or inherited roles
  * within this course but who have not been enrolled in the course
  *
  * @global moodle_database $DB
  * @param string $sort
  * @param string $direction
  * @param int $page
  * @param int $perpage
  * @return array
  */
 public function get_other_users($sort, $direction = 'ASC', $page = 0, $perpage = 25)
 {
     global $DB;
     if ($direction !== 'ASC') {
         $direction = 'DESC';
     }
     $key = md5("{$sort}-{$direction}-{$page}-{$perpage}");
     if (!array_key_exists($key, $this->otherusers)) {
         list($ctxcondition, $params) = $DB->get_in_or_equal($this->context->get_parent_context_ids(true), SQL_PARAMS_NAMED, 'ctx');
         $params['courseid'] = $this->course->id;
         $params['cid'] = $this->course->id;
         $extrafields = get_extra_user_fields($this->get_context());
         $ufields = user_picture::fields('u', $extrafields);
         $sql = "SELECT ra.id as raid, ra.contextid, ra.component, ctx.contextlevel, ra.roleid, {$ufields},\n                        coalesce(u.lastaccess,0) AS lastaccess\n                    FROM {role_assignments} ra\n                    JOIN {user} u ON u.id = ra.userid\n                    JOIN {context} ctx ON ra.contextid = ctx.id\n               LEFT JOIN (\n                       SELECT ue.id, ue.userid\n                         FROM {user_enrolments} ue\n                         JOIN {enrol} e ON e.id = ue.enrolid\n                        WHERE e.courseid = :courseid\n                       ) ue ON ue.userid=u.id\n                   WHERE ctx.id {$ctxcondition} AND\n                         ue.id IS NULL\n                ORDER BY {$sort} {$direction}, ctx.depth DESC";
         $this->otherusers[$key] = $DB->get_records_sql($sql, $params, $page * $perpage, $perpage);
     }
     return $this->otherusers[$key];
 }
开发者ID:uniedpa,项目名称:moodle,代码行数:31,代码来源:locallib.php

示例3: get_filter_sql

 /**
  * Obtains WHERE clause to filter results by defined search and role filter
  * (instance filter is handled separately in JOIN clause, see
  * get_instance_sql).
  *
  * @return array Two-element array with SQL and params for WHERE clause
  */
 protected function get_filter_sql()
 {
     global $DB;
     // Search condition.
     $extrafields = get_extra_user_fields($this->get_context());
     list($sql, $params) = users_search_sql($this->searchfilter, 'u', true, $extrafields);
     // Role condition.
     if ($this->rolefilter) {
         // Get context SQL.
         $contextids = $this->context->get_parent_context_ids();
         $contextids[] = $this->context->id;
         list($contextsql, $contextparams) = $DB->get_in_or_equal($contextids, SQL_PARAMS_NAMED);
         $params += $contextparams;
         // Role check condition.
         $sql .= " AND (SELECT COUNT(1) FROM {role_assignments} ra WHERE ra.userid = u.id " . "AND ra.roleid = :roleid AND ra.contextid {$contextsql}) > 0";
         $params['roleid'] = $this->rolefilter;
     }
     return array($sql, $params);
 }
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:26,代码来源:locallib.php

示例4: get_roles_with_capability

/**
 * Get the roles that have a given capability assigned to it
 *
 * This function does not resolve the actual permission of the capability.
 * It just checks for permissions and overrides.
 * Use get_roles_with_cap_in_context() if resolution is required.
 *
 * @param string $capability capability name (string)
 * @param string $permission optional, the permission defined for this capability
 *                      either CAP_ALLOW, CAP_PREVENT or CAP_PROHIBIT. Defaults to null which means any.
 * @param stdClass $context null means any
 * @return array of role records
 */
function get_roles_with_capability($capability, $permission = null, $context = null) {
    global $DB;

    if ($context) {
        $contexts = $context->get_parent_context_ids(true);
        list($insql, $params) = $DB->get_in_or_equal($contexts, SQL_PARAMS_NAMED, 'ctx');
        $contextsql = "AND rc.contextid $insql";
    } else {
        $params = array();
        $contextsql = '';
    }

    if ($permission) {
        $permissionsql = " AND rc.permission = :permission";
        $params['permission'] = $permission;
    } else {
        $permissionsql = '';
    }

    $sql = "SELECT r.*
              FROM {role} r
             WHERE r.id IN (SELECT rc.roleid
                              FROM {role_capabilities} rc
                             WHERE rc.capability = :capname
                                   $contextsql
                                   $permissionsql)";
    $params['capname'] = $capability;


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

示例5: validate_context

 /**
  * Makes sure user may execute functions in this context.
  *
  * @param stdClass $context
  * @since Moodle 2.0
  */
 public static function validate_context($context)
 {
     global $CFG, $PAGE;
     if (empty($context)) {
         throw new invalid_parameter_exception('Context does not exist');
     }
     if (empty(self::$contextrestriction)) {
         self::$contextrestriction = context_system::instance();
     }
     $rcontext = self::$contextrestriction;
     if ($rcontext->contextlevel == $context->contextlevel) {
         if ($rcontext->id != $context->id) {
             throw new restricted_context_exception();
         }
     } else {
         if ($rcontext->contextlevel > $context->contextlevel) {
             throw new restricted_context_exception();
         } else {
             $parents = $context->get_parent_context_ids();
             if (!in_array($rcontext->id, $parents)) {
                 throw new restricted_context_exception();
             }
         }
     }
     $PAGE->reset_theme_and_output();
     list($unused, $course, $cm) = get_context_info_array($context->id);
     require_login($course, false, $cm, false, true);
     $PAGE->set_context($context);
 }
开发者ID:jackdaniels79,项目名称:moodle,代码行数:35,代码来源:externallib.php

示例6: validate_context

 /**
  * Makes sure user may execute functions in this context.
  *
  * @param stdClass $context
  * @since Moodle 2.0
  */
 protected static function validate_context($context)
 {
     global $CFG;
     if (empty($context)) {
         throw new invalid_parameter_exception('Context does not exist');
     }
     if (empty(self::$contextrestriction)) {
         self::$contextrestriction = context_system::instance();
     }
     $rcontext = self::$contextrestriction;
     if ($rcontext->contextlevel == $context->contextlevel) {
         if ($rcontext->id != $context->id) {
             throw new restricted_context_exception();
         }
     } else {
         if ($rcontext->contextlevel > $context->contextlevel) {
             throw new restricted_context_exception();
         } else {
             $parents = $context->get_parent_context_ids();
             if (!in_array($rcontext->id, $parents)) {
                 throw new restricted_context_exception();
             }
         }
     }
     if ($context->contextlevel >= CONTEXT_COURSE) {
         list($context, $course, $cm) = get_context_info_array($context->id);
         require_login($course, false, $cm, false, true);
     }
 }
开发者ID:tyleung,项目名称:CMPUT401MoodleExams,代码行数:35,代码来源:externallib.php


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