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


PHP enrol_is_enabled函数代码示例

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


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

示例1: user_loggedin

 /**
  * Triggered via the user_loggedin event, when a user logs in.
  *
  * @param stdClass $event
  */
 public static function user_loggedin($event)
 {
     global $DB;
     $eventdata = $event->get_data();
     if (!enrol_is_enabled('auto')) {
         return;
     }
     if (is_siteadmin($eventdata['userid'])) {
         // Don't enrol site admins
         return;
     }
     // Get all courses that have an auto enrol plugin, set to auto enrol on login, where the user isn't enrolled yet
     $sql = "SELECT e.courseid\n            FROM {enrol} e\n            LEFT JOIN {user_enrolments} ue ON e.id = ue.enrolid AND ue.userid = ?\n            WHERE e.enrol = 'auto'\n            AND e.status = ?\n            AND e.customint3 = ?\n            AND ue.id IS NULL";
     if (!($courses = $DB->get_records_sql($sql, array($eventdata['userid'], ENROL_INSTANCE_ENABLED, ENROL_AUTO_LOGIN)))) {
         return;
     }
     $autoplugin = enrol_get_plugin('auto');
     foreach ($courses as $course) {
         if (!($instance = $autoplugin->get_instance_for_course($course->courseid))) {
             continue;
         }
         $autoplugin->enrol_user($instance, $eventdata['userid'], $instance->roleid);
         // Send welcome message.
         if ($instance->customint2) {
             $autoplugin = enrol_get_plugin('auto');
             $autoplugin->email_welcome_message($instance, $DB->get_record('user', array('id' => $eventdata['userid'])));
         }
     }
 }
开发者ID:ninelanterns,项目名称:scaffold-enrol_auto,代码行数:34,代码来源:observer.php

示例2: member_added

 /**
  * Event processor - cohort member added
  * @param stdClass $ca
  * @return bool
  */
 public function member_added($ca)
 {
     global $DB;
     if (!enrol_is_enabled('cohort')) {
         return true;
     }
     // does any enabled cohort instance want to sync with this cohort?
     $sql = "SELECT e.*, r.id as roleexists\n                  FROM {enrol} e\n             LEFT JOIN {role} r ON (r.id = e.roleid)\n                 WHERE customint1 = :cohortid AND enrol = 'cohort'\n              ORDER BY id ASC";
     if (!($instances = $DB->get_records_sql($sql, array('cohortid' => $ca->cohortid)))) {
         return true;
     }
     $plugin = enrol_get_plugin('cohort');
     foreach ($instances as $instance) {
         if ($instance->status != ENROL_INSTANCE_ENABLED) {
             // no roles for disabled instances
             $instance->roleid = 0;
         } else {
             if ($instance->roleid and !$instance->roleexists) {
                 // invalid role - let's just enrol, they will have to create new sync and delete this one
                 $instance->roleid = 0;
             }
         }
         unset($instance->roleexists);
         // no problem if already enrolled
         $plugin->enrol_user($instance, $ca->userid, $instance->roleid, 0, 0, ENROL_USER_ACTIVE);
     }
     return true;
 }
开发者ID:raymondAntonio,项目名称:moodle,代码行数:33,代码来源:locallib.php

示例3: test_basics

 public function test_basics()
 {
     $this->assertFalse(enrol_is_enabled('paypal'));
     $plugin = enrol_get_plugin('paypal');
     $this->assertInstanceOf('enrol_paypal_plugin', $plugin);
     $this->assertEquals(ENROL_EXT_REMOVED_SUSPENDNOROLES, get_config('enrol_paypal', 'expiredaction'));
 }
开发者ID:pzhu2004,项目名称:moodle,代码行数:7,代码来源:paypal_test.php

示例4: test_basics

 public function test_basics()
 {
     $this->assertTrue(enrol_is_enabled('self'));
     $plugin = enrol_get_plugin('self');
     $this->assertInstanceOf('enrol_self_plugin', $plugin);
     $this->assertEquals(1, get_config('enrol_self', 'defaultenrol'));
     $this->assertEquals(ENROL_EXT_REMOVED_KEEP, get_config('enrol_self', 'expiredaction'));
 }
开发者ID:evltuma,项目名称:moodle,代码行数:8,代码来源:self_test.php

示例5: xmldb_enrol_elis_install

/**
 * Install function for this plugin
 *
 * @return  boolean  true  Returns true to satisfy install procedure
 */
function xmldb_enrol_elis_install()
{
    global $CFG;
    if (!enrol_is_enabled('elis')) {
        // force the elis plugin to be enabled
        set_config('enrol_plugins_enabled', $CFG->enrol_plugins_enabled . ',elis');
    }
    return true;
}
开发者ID:jamesmcq,项目名称:elis,代码行数:14,代码来源:install.php

示例6: course_updated

 /**
  * Called after updating/inserting course.
  *
  * @param bool $inserted true if course just inserted
  * @param stdClass $course
  * @param stdClass $data form data
  * @return void
  */
 public function course_updated($inserted, $course, $data)
 {
     global $CFG;
     if (!enrol_is_enabled('category')) {
         return;
     }
     // Sync category enrols.
     require_once "{$CFG->dirroot}/enrol/category/locallib.php";
     enrol_category_sync_course($course);
 }
开发者ID:ruddj,项目名称:moodle,代码行数:18,代码来源:lib.php

示例7: instance_deleteable

 /**
  * Is it possible to delete enrol instance via standard UI?
  *
  * @param stdClass $instance
  * @return bool
  */
 public function instance_deleteable($instance)
 {
     if (!enrol_is_enabled('database')) {
         return true;
     }
     if (!$this->get_config('dbtype') or !$this->get_config('dbhost') or !$this->get_config('remoteenroltable') or !$this->get_config('remotecoursefield') or !$this->get_config('remoteuserfield')) {
         return true;
     }
     //TODO: connect to external system and make sure no users are to be enrolled in this course
     return false;
 }
开发者ID:vinoth4891,项目名称:clinique,代码行数:17,代码来源:lib.php

示例8: execute

 /**
  * Do the job.
  * Throw exceptions on errors (the job will be retried).
  */
 public function execute()
 {
     global $CFG;
     require_once $CFG->dirroot . '/enrol/flatfile/lib.php';
     if (!enrol_is_enabled('flatfile')) {
         return;
     }
     // Instance of enrol_flatfile_plugin.
     $plugin = enrol_get_plugin('flatfile');
     $result = $plugin->sync(new \null_progress_trace());
     return $result;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:16,代码来源:flatfile_sync_task.php

示例9: enrol_jwc_sync

/**
 * Sync all jwc course links.
 * @param int $courseid one course, empty mean all
 * @return void
 */
function enrol_jwc_sync($courseid = NULL)
{
    global $CFG, $DB;
    // unfortunately this may take a long time
    @set_time_limit(0);
    //if this fails during upgrade we can continue from cron, no big deal
    $jwc = new jwc_helper();
    $jwc_enrol = enrol_get_plugin('jwc');
    if (enrol_is_enabled('jwc')) {
        $params = array();
        $onecourse = "";
        if ($courseid) {
            $params['courseid'] = $courseid;
            $onecourse = "AND courseid = :courseid";
        }
        $select = "enrol = :jwc AND status = :status {$onecourse}";
        $params['jwc'] = 'jwc';
        $params['status'] = ENROL_INSTANCE_ENABLED;
        $instances = $DB->get_records_select('enrol', $select, $params);
        foreach ($instances as $instance) {
            // 课程必须有cas认证的教师
            $teachers = enrol_jwc_get_cas_teachers($instance->courseid);
            if (empty($teachers)) {
                $DB->set_field('enrol', 'customchar2', '此课程没有使用HITID的教师', array('id' => $instance->id));
                continue;
            }
            // 从教务处获取所有选修该课程的学生
            $return_msg = '';
            $students = $jwc->get_students($instance->customchar1, $teachers, $jwc_enrol->get_config('semester'), $return_msg);
            $DB->set_field('enrol', 'customchar2', $return_msg, array('id' => $instance->id));
            if (!$students) {
                // 出错
                continue;
                // skip this instance. 就算出错,也别清理选课,以免意外。管理员更改学期名时再清理所有选课
            }
            // 开始同步
            // 选课
            foreach ($students as $userid) {
                $jwc_enrol->enrol_user($instance, $userid, $instance->roleid);
            }
            // 取消教务处删除的选课
            if (empty($students)) {
                $where = "enrolid = {$instance->id}";
            } else {
                $where = "enrolid = {$instance->id} AND userid NOT IN (" . implode(',', $students) . ')';
            }
            $ues = $DB->get_records_select('user_enrolments', $where);
            foreach ($ues as $ue) {
                $jwc_enrol->unenrol_user($instance, $ue->userid);
            }
        }
    }
}
开发者ID:hit-moodle,项目名称:moodle-enrol_jwc,代码行数:58,代码来源:locallib.php

示例10: __construct

 /**
  * Sets up the table.
  *
  * @param string $courseid The id of the course.
  */
 public function __construct($courseid)
 {
     parent::__construct('enrol_lti_manage_table');
     $this->define_columns(array('name', 'url', 'secret', 'edit'));
     $this->define_headers(array(get_string('name'), get_string('url'), get_string('secret', 'enrol_lti'), get_string('edit')));
     $this->collapsible(false);
     $this->sortable(false);
     // Set the variables we need access to.
     $this->ltiplugin = enrol_get_plugin('lti');
     $this->ltienabled = enrol_is_enabled('lti');
     $this->canconfig = has_capability('moodle/course:enrolconfig', \context_course::instance($courseid));
     $this->courseid = $courseid;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:18,代码来源:manage_table.php

示例11: test_basics

 public function test_basics()
 {
     # disabled by default
     $this->assertFalse(enrol_is_enabled('auto'));
     # correct enrol instance
     $plugin = enrol_get_plugin('auto');
     $this->assertInstanceOf('enrol_auto_plugin', $plugin);
     # default config checks
     $this->assertEquals('1', get_config('enrol_auto', 'defaultenrol'));
     $this->assertEquals('1', get_config('enrol_auto', 'status'));
     $this->assertEquals(ENROL_AUTO_COURSE_VIEWED, get_config('enrol_auto', 'enrolon'));
     $this->assertEquals('1', get_config('enrol_auto', 'sendcoursewelcomemessage'));
     $this->assertEquals('', get_config('enrol_auto', 'modviewmods'));
 }
开发者ID:ninelanterns,项目名称:scaffold-enrol_auto,代码行数:14,代码来源:auto_test.php

示例12: execute

 /**
  * Performs the synchronisation of members.
  */
 public function execute()
 {
     if (!is_enabled_auth('lti')) {
         mtrace('Skipping task - ' . get_string('pluginnotenabled', 'auth', get_string('pluginname', 'auth_lti')));
         return;
     }
     // Check if the enrolment plugin is disabled - isn't really necessary as the task should not run if
     // the plugin is disabled, but there is no harm in making sure core hasn't done something wrong.
     if (!enrol_is_enabled('lti')) {
         mtrace('Skipping task - ' . get_string('enrolisdisabled', 'enrol_lti'));
         return;
     }
     $this->dataconnector = new data_connector();
     // Get all the enabled tools.
     $tools = helper::get_lti_tools(array('status' => ENROL_INSTANCE_ENABLED, 'membersync' => 1));
     foreach ($tools as $tool) {
         mtrace("Starting - Member sync for published tool '{$tool->id}' for course '{$tool->courseid}'.");
         // Variables to keep track of information to display later.
         $usercount = 0;
         $enrolcount = 0;
         $unenrolcount = 0;
         // Fetch consumer records mapped to this tool.
         $consumers = $this->dataconnector->get_consumers_mapped_to_tool($tool->id);
         // Perform processing for each consumer.
         foreach ($consumers as $consumer) {
             mtrace("Requesting membership service for the tool consumer '{$consumer->getRecordId()}'");
             // Get members through this tool consumer.
             $members = $this->fetch_members_from_consumer($consumer);
             // Check if we were able to fetch the members.
             if ($members === false) {
                 mtrace("Skipping - Membership service request failed.\n");
                 continue;
             }
             // Fetched members count.
             $membercount = count($members);
             mtrace("{$membercount} members received.\n");
             // Process member information.
             list($usercount, $enrolcount) = $this->sync_member_information($tool, $consumer, $members);
         }
         // Now we check if we have to unenrol users who were not listed.
         if ($this->should_sync_unenrol($tool->membersyncmode)) {
             $unenrolcount = $this->sync_unenrol($tool);
         }
         mtrace("Completed - Synced members for tool '{$tool->id}' in the course '{$tool->courseid}'. " . "Processed {$usercount} users; enrolled {$enrolcount} members; unenrolled {$unenrolcount} members.\n");
     }
     // Sync the user profile photos.
     mtrace("Started - Syncing user profile images.");
     $countsyncedimages = $this->sync_profile_images();
     mtrace("Completed - Synced {$countsyncedimages} profile images.");
 }
开发者ID:lucaboesch,项目名称:moodle,代码行数:53,代码来源:sync_members.php

示例13: can_delete_instance

 /**
  * Is it possible to delete enrol instance via standard UI?
  *
  * @param stdClass $instance
  * @return bool
  */
 public function can_delete_instance($instance)
 {
     $context = context_course::instance($instance->courseid);
     if (!has_capability('enrol/database:config', $context)) {
         return false;
     }
     if (!enrol_is_enabled('database')) {
         return true;
     }
     if (!$this->get_config('dbtype') or !$this->get_config('remoteenroltable') or !$this->get_config('remotecoursefield') or !$this->get_config('remoteuserfield')) {
         return true;
     }
     //TODO: connect to external system and make sure no users are to be enrolled in this course
     return false;
 }
开发者ID:alanaipe2015,项目名称:moodle,代码行数:21,代码来源:lib.php

示例14: get_manual_enrol_link

 /**
  * Returns link to manual enrol UI if exists.
  * Does the access control tests automatically.
  *
  * @param object $instance
  * @return moodle_url
  */
 public function get_manual_enrol_link($instance)
 {
     $name = $this->get_name();
     if ($instance->enrol !== $name) {
         throw new coding_exception('invalid enrol instance!');
     }
     if (!enrol_is_enabled($name)) {
         return NULL;
     }
     $context = get_context_instance(CONTEXT_COURSE, $instance->courseid, MUST_EXIST);
     if (!has_capability('enrol/manual:manage', $context) or !has_capability('enrol/manual:enrol', $context) or !has_capability('enrol/manual:unenrol', $context)) {
         return NULL;
     }
     return new moodle_url('/enrol/manual/manage.php', array('enrolid' => $instance->id, 'id' => $instance->courseid));
 }
开发者ID:saurabh947,项目名称:MoodleLearning,代码行数:22,代码来源:lib.php

示例15: enrol_user

function enrol_user($userid, $courseid)
{
    global $DB;
    if (!enrol_is_enabled('manual')) {
        return false;
    }
    if (!($enrol = enrol_get_plugin('manual'))) {
        return false;
    }
    $params = array('enrol' => 'manual', 'courseid' => $courseid, 'status' => ENROL_INSTANCE_ENABLED);
    if (!($instances = $DB->get_records('enrol', $params, 'sortorder,id ASC'))) {
        return false;
    }
    $instance = reset($instances);
    $enrol->enrol_user($instance, $userid, $instance->roleid, time(), time() + 24 * 60 * 60 * 30);
}
开发者ID:advancingdesign,项目名称:moodle-quiz_papercopy,代码行数:16,代码来源:createuser.php


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