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


PHP course_modinfo::get_user_id方法代码示例

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


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

示例1: get_uservisible

 /**
  * Works out whether activity is visible *for current user* - if this is false, they
  * aren't allowed to access it.
  *
  * @return bool
  */
 private function get_uservisible() {
     $userid = $this->modinfo->get_user_id();
     if ($this->_uservisible !== null || $userid == -1) {
         // Has already been calculated or does not need calculation.
         return $this->_uservisible;
     }
     $this->_uservisible = true;
     if (!$this->_visible || !$this->get_available()) {
         $coursecontext = context_course::instance($this->get_course());
         if (!has_capability('moodle/course:viewhiddensections', $coursecontext, $userid)) {
             $this->_uservisible = false;
         }
     }
     return $this->_uservisible;
 }
开发者ID:rwijaya,项目名称:moodle,代码行数:21,代码来源:modinfolib.php

示例2: is_user_access_restricted_by_conditional_access

 /**
  * Checks whether the module's conditional access settings mean that the user cannot see the activity at all
  *
  * @return bool True if the user cannot see the module. False if the activity is either available or should be greyed out.
  */
 public function is_user_access_restricted_by_conditional_access()
 {
     global $CFG, $USER;
     if (empty($CFG->enableavailability)) {
         return false;
     }
     // If module will always be visible anyway (but greyed out), don't bother checking anything else
     if ($this->showavailability == CONDITION_STUDENTVIEW_SHOW) {
         return false;
     }
     // Can the user see hidden modules?
     $modcontext = context_module::instance($this->id);
     $userid = $this->modinfo->get_user_id();
     if (has_capability('moodle/course:viewhiddenactivities', $modcontext, $userid)) {
         return false;
     }
     // Is the module hidden due to unmet conditions?
     if (!$this->available) {
         return true;
     }
     return false;
 }
开发者ID:vinoth4891,项目名称:clinique,代码行数:27,代码来源:modinfolib.php

示例3: update_user_visible

 /**
  * Works out whether activity is visible *for current user* - if this is false, they
  * aren't allowed to access it.
  * @return void
  */
 private function update_user_visible()
 {
     global $CFG;
     $modcontext = get_context_instance(CONTEXT_MODULE, $this->id);
     $userid = $this->modinfo->get_user_id();
     $this->uservisible = true;
     if ((!$this->visible or !$this->available) and !has_capability('moodle/course:viewhiddenactivities', $modcontext, $userid)) {
         // If the activity is hidden or unavailable, and you don't have viewhiddenactivities,
         // set it so that user can't see or access it
         $this->uservisible = false;
     } else {
         if (!empty($CFG->enablegroupmembersonly) and !empty($this->groupmembersonly) and !has_capability('moodle/site:accessallgroups', $modcontext, $userid)) {
             // If the activity has 'group members only' and you don't have accessallgroups...
             $groups = $this->modinfo->get_groups($this->groupingid);
             if (empty($groups)) {
                 // ...and you don't belong to a group, then set it so you can't see/access it
                 $this->uservisible = false;
             }
         }
     }
 }
开发者ID:nigeldaley,项目名称:moodle,代码行数:26,代码来源:modinfolib.php

示例4: update_user_visible

 /**
  * Works out whether activity is visible *for current user* - if this is false, they
  * aren't allowed to access it.
  * @return void
  */
 private function update_user_visible()
 {
     global $CFG;
     $modcontext = get_context_instance(CONTEXT_MODULE, $this->id);
     $userid = $this->modinfo->get_user_id();
     $this->uservisible = true;
     // Check visibility/availability conditions.
     if ((!$this->visible or !$this->available) and !has_capability('moodle/course:viewhiddenactivities', $modcontext, $userid)) {
         // If the activity is hidden or unavailable, and you don't have viewhiddenactivities,
         // set it so that user can't see or access it.
         $this->uservisible = false;
     }
     // Check group membership. The grouping option makes the activity
     // completely invisible as it does not apply to the user at all.
     if (!empty($CFG->enablegroupmembersonly) and !empty($this->groupmembersonly) and !has_capability('moodle/site:accessallgroups', $modcontext, $userid)) {
         // If the activity has 'group members only' and you don't have accessallgroups...
         $groups = $this->modinfo->get_groups($this->groupingid);
         if (empty($groups)) {
             // ...and you don't belong to a group, then set it so you can't see/access it
             $this->uservisible = false;
             // Ensure activity is completely hidden from user.
             $this->showavailability = 0;
         }
     }
 }
开发者ID:esyacelga,项目名称:sisadmaca,代码行数:30,代码来源:modinfolib.php


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