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


PHP Session\manager类代码示例

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


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

示例1: reset_all_data

 /**
  * Reset contents of all database tables to initial values, reset caches, etc.
  *
  * Note: this is relatively slow (cca 2 seconds for pg and 7 for mysql) - please use with care!
  *
  * @static
  * @param bool $detectchanges
  *      true  - changes in global state and database are reported as errors
  *      false - no errors reported
  *      null  - only critical problems are reported as errors
  * @return void
  */
 public static function reset_all_data($detectchanges = false)
 {
     global $DB, $CFG, $USER, $SITE, $COURSE, $PAGE, $OUTPUT, $SESSION;
     // Stop any message redirection.
     phpunit_util::stop_message_redirection();
     // Stop any message redirection.
     phpunit_util::stop_phpmailer_redirection();
     // Stop any message redirection.
     phpunit_util::stop_event_redirection();
     // We used to call gc_collect_cycles here to ensure desctructors were called between tests.
     // This accounted for 25% of the total time running phpunit - so we removed it.
     // Show any unhandled debugging messages, the runbare() could already reset it.
     self::display_debugging_messages();
     self::reset_debugging();
     // reset global $DB in case somebody mocked it
     $DB = self::get_global_backup('DB');
     if ($DB->is_transaction_started()) {
         // we can not reset inside transaction
         $DB->force_transaction_rollback();
     }
     $resetdb = self::reset_database();
     $warnings = array();
     if ($detectchanges === true) {
         if ($resetdb) {
             $warnings[] = 'Warning: unexpected database modification, resetting DB state';
         }
         $oldcfg = self::get_global_backup('CFG');
         $oldsite = self::get_global_backup('SITE');
         foreach ($CFG as $k => $v) {
             if (!property_exists($oldcfg, $k)) {
                 $warnings[] = 'Warning: unexpected new $CFG->' . $k . ' value';
             } else {
                 if ($oldcfg->{$k} !== $CFG->{$k}) {
                     $warnings[] = 'Warning: unexpected change of $CFG->' . $k . ' value';
                 }
             }
             unset($oldcfg->{$k});
         }
         if ($oldcfg) {
             foreach ($oldcfg as $k => $v) {
                 $warnings[] = 'Warning: unexpected removal of $CFG->' . $k;
             }
         }
         if ($USER->id != 0) {
             $warnings[] = 'Warning: unexpected change of $USER';
         }
         if ($COURSE->id != $oldsite->id) {
             $warnings[] = 'Warning: unexpected change of $COURSE';
         }
     }
     if (ini_get('max_execution_time') != 0) {
         // This is special warning for all resets because we do not want any
         // libraries to mess with timeouts unintentionally.
         // Our PHPUnit integration is not supposed to change it either.
         if ($detectchanges !== false) {
             $warnings[] = 'Warning: max_execution_time was changed to ' . ini_get('max_execution_time');
         }
         set_time_limit(0);
     }
     // restore original globals
     $_SERVER = self::get_global_backup('_SERVER');
     $CFG = self::get_global_backup('CFG');
     $SITE = self::get_global_backup('SITE');
     $_GET = array();
     $_POST = array();
     $_FILES = array();
     $_REQUEST = array();
     $COURSE = $SITE;
     // reinitialise following globals
     $OUTPUT = new bootstrap_renderer();
     $PAGE = new moodle_page();
     $FULLME = null;
     $ME = null;
     $SCRIPT = null;
     // Empty sessison and set fresh new not-logged-in user.
     \core\session\manager::init_empty_session();
     // reset all static caches
     \core\event\manager::phpunit_reset();
     accesslib_clear_all_caches(true);
     get_string_manager()->reset_caches(true);
     reset_text_filters_cache(true);
     events_get_handlers('reset');
     core_text::reset_caches();
     get_message_processors(false, true);
     filter_manager::reset_caches();
     // Reset internal users.
     core_user::reset_internal_users();
     //TODO MDL-25290: add more resets here and probably refactor them to new core function
//.........这里部分代码省略.........
开发者ID:sumitnegi933,项目名称:Moodle_lms_New,代码行数:101,代码来源:util.php

示例2: local_loginas_extends_settings_navigation

/**
 * Adds module specific settings to the settings block.
 *
 * @param settings_navigation $settings The settings navigation object
 * @param stdClass $context The node context
 */
function local_loginas_extends_settings_navigation(settings_navigation $settings, $context)
{
    global $DB, $CFG, $PAGE, $USER;
    // Course id and context.
    $courseid = !empty($PAGE->course->id) ? $PAGE->course->id : SITEID;
    $coursecontext = context_course::instance($courseid);
    // Must have the loginas capability.
    if (!has_capability('moodle/user:loginas', $coursecontext)) {
        return;
    }
    // Set the settings category.
    $loginas = $settings->add(get_string('loginas'));
    // Login as list by admin setting.
    if (is_siteadmin($USER)) {
        // Admin settings page.
        $url = new moodle_url('/admin/settings.php', array('section' => 'localsettingloginas'));
        $loginas->add(get_string('settings'), $url, $settings::TYPE_SETTING);
        // Users list.
        $loginasusers = array();
        // Since 2.6, use all the required fields.
        $ufields = 'id, ' . get_all_user_name_fields(true);
        // Get users by id.
        if ($configuserids = get_config('local_loginas', 'loginasusers')) {
            $userids = explode(',', $configuserids);
            if ($users = $DB->get_records_list('user', 'id', $userids, '', $ufields)) {
                $loginasusers = $users;
            }
        }
        // Get users by username.
        if ($configusernames = get_config('local_loginas', 'loginasusernames')) {
            $usernames = explode(',', $configusernames);
            if ($users = $DB->get_records_list('user', 'username', $usernames, '', $ufields)) {
                $loginasusers = $loginasusers + $users;
            }
        }
        // Add action links for specified users.
        if ($loginasusers) {
            $params = array('id' => $courseid, 'sesskey' => sesskey());
            foreach ($loginasusers as $userid => $lauser) {
                $url = new moodle_url('/course/loginas.php', $params);
                $url->param('user', $userid);
                $loginas->add(fullname($lauser, true), $url, $settings::TYPE_SETTING);
            }
        }
    }
    // Course users login as.
    if (!($configcourseusers = get_config('local_loginas', 'courseusers'))) {
        return;
    }
    $loggedinas = \core\session\manager::is_loggedinas();
    if (!$loggedinas) {
        // Ajax link.
        $node = $loginas->add(get_string('courseusers', 'local_loginas'), 'javascript:void();', $settings::TYPE_SETTING);
        $node->add_class('local_loginas_setting_link');
        local_loginas_require_js($PAGE);
    }
}
开发者ID:keliix06,项目名称:moodle-local_loginas,代码行数:63,代码来源:lib.php

示例3: download_as_dataformat

/**
 * Sends a formated data file to the browser
 *
 * @package    core
 * @subpackage dataformat
 *
 * @param string $filename The base filename without an extension
 * @param string $dataformat A dataformat name
 * @param array $columns An ordered map of column keys and labels
 * @param Iterator $iterator An iterator over the records, usually a RecordSet
 * @param function $callback An option function applied to each record before writing
 * @param mixed $extra An optional value which is passed into the callback function
 */
function download_as_dataformat($filename, $dataformat, $columns, $iterator, $callback = null)
{
    if (ob_get_length()) {
        throw new coding_exception("Output can not be buffered before calling download_as_dataformat");
    }
    $classname = 'dataformat_' . $dataformat . '\\writer';
    if (!class_exists($classname)) {
        throw new coding_exception("Unable to locate dataformat/{$type}/classes/writer.php");
    }
    $format = new $classname();
    // The data format export could take a while to generate...
    set_time_limit(0);
    // Close the session so that the users other tabs in the same session are not blocked.
    \core\session\manager::write_close();
    $format->set_filename($filename);
    $format->send_http_headers();
    $format->write_header($columns);
    $c = 0;
    foreach ($iterator as $row) {
        if ($callback) {
            $row = $callback($row);
        }
        if ($row === null) {
            continue;
        }
        $format->write_record($row, $c++);
    }
    $format->write_footer($columns);
}
开发者ID:gabrielrosset,项目名称:moodle,代码行数:42,代码来源:dataformatlib.php

示例4: test_set_user

 public function test_set_user()
 {
     global $USER, $DB;
     $this->assertEquals(0, $USER->id);
     $this->assertSame($_SESSION['USER'], $USER);
     $user = $DB->get_record('user', array('id' => 2));
     $this->assertNotEmpty($user);
     $this->setUser($user);
     $this->assertEquals(2, $USER->id);
     $this->assertEquals(2, $_SESSION['USER']->id);
     $this->assertSame($_SESSION['USER'], $USER);
     $USER->id = 3;
     $this->assertEquals(3, $USER->id);
     $this->assertEquals(3, $_SESSION['USER']->id);
     $this->assertSame($_SESSION['USER'], $USER);
     \core\session\manager::set_user($user);
     $this->assertEquals(2, $USER->id);
     $this->assertEquals(2, $_SESSION['USER']->id);
     $this->assertSame($_SESSION['USER'], $USER);
     $USER = $DB->get_record('user', array('id' => 1));
     $this->assertNotEmpty($USER);
     $this->assertEquals(1, $USER->id);
     $this->assertEquals(1, $_SESSION['USER']->id);
     $this->assertSame($_SESSION['USER'], $USER);
     $this->setUser(null);
     $this->assertEquals(0, $USER->id);
     $this->assertSame($_SESSION['USER'], $USER);
 }
开发者ID:tyleung,项目名称:CMPUT401MoodleExams,代码行数:28,代码来源:advanced_test.php

示例5: tool_dbtransfer_transfer_database

/**
 * Initiate database transfer.
 * @param moodle_database $sourcedb
 * @param moodle_database $targetdb
 * @param progress_trace $feedback
 * @return void
 */
function tool_dbtransfer_transfer_database(moodle_database $sourcedb, moodle_database $targetdb, progress_trace $feedback = null)
{
    core_php_time_limit::raise();
    \core\session\manager::write_close();
    // Release session.
    $var = new database_mover($sourcedb, $targetdb, true, $feedback);
    $var->export_database(null);
    tool_dbtransfer_rebuild_target_log_actions($targetdb, $feedback);
}
开发者ID:evltuma,项目名称:moodle,代码行数:16,代码来源:locallib.php

示例6: execute

 /**
  * Do the job.
  * Throw exceptions on errors (the job will be retried).
  */
 public function execute()
 {
     global $DB;
     $timenow = time();
     \core\session\manager::gc();
     // Cleanup old session linked tokens.
     // Deletes the session linked tokens that are over a day old.
     $DB->delete_records_select('external_tokens', 'lastaccess < :onedayago AND tokentype = :tokentype', array('onedayago' => $timenow - DAYSECS, 'tokentype' => EXTERNAL_TOKEN_EMBEDDED));
 }
开发者ID:evltuma,项目名称:moodle,代码行数:13,代码来源:session_cleanup_task.php

示例7: report_usersessions_kill_session

/**
 * Kill user session.
 *
 * @param int $id
 * @return void
 */
function report_usersessions_kill_session($id)
{
    global $DB, $USER;
    $session = $DB->get_record('sessions', array('id' => $id, 'userid' => $USER->id), 'id, sid');
    if (!$session or $session->sid === session_id()) {
        // Do not delete the current session!
        return;
    }
    \core\session\manager::kill_session($session->sid);
}
开发者ID:evltuma,项目名称:moodle,代码行数:16,代码来源:locallib.php

示例8: block_informationspot_pluginfile

/**
 * Form for editing Information Spot  block instances.
 *
 * @copyright 2014 Roberto Pinna
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 * @package   block_informationspot
 * @category  files
 * @param stdClass $course course object
 * @param stdClass $birecord_or_cm block instance record
 * @param stdClass $context context object
 * @param string $filearea file area
 * @param array $args extra arguments
 * @param bool $forcedownload whether or not force download
 * @param array $options additional options affecting the file serving
 * @return bool
 */
function block_informationspot_pluginfile($course, $birecord_or_cm, $context, $filearea, $args, $forcedownload, array $options = array())
{
    global $DB, $CFG, $USER;
    if ($context->contextlevel != CONTEXT_BLOCK) {
        send_file_not_found();
    }
    // If block is in course context, then check if user has capability to access course.
    if ($context->get_course_context(false)) {
        require_course_login($course);
    } else {
        if ($CFG->forcelogin) {
            require_login();
        } else {
            // Get parent context and see if user have proper permission.
            $parentcontext = $context->get_parent_context();
            if ($parentcontext->contextlevel === CONTEXT_COURSECAT) {
                // Check if category is visible and user can view this category.
                $category = $DB->get_record('course_categories', array('id' => $parentcontext->instanceid), '*', MUST_EXIST);
                if (!$category->visible) {
                    require_capability('moodle/category:viewhiddencategories', $parentcontext);
                }
            } else {
                if ($parentcontext->contextlevel === CONTEXT_USER && $parentcontext->instanceid != $USER->id) {
                    // The block is in the context of a user, it is only visible to the user who it belongs to.
                    send_file_not_found();
                }
            }
            // At this point there is no way to check SYSTEM context, so ignoring it.
        }
    }
    if ($filearea != 'image') {
        send_file_not_found();
    }
    $fs = get_file_storage();
    $imageid = array_shift($args);
    $filename = array_pop($args);
    $filepath = $args ? '/' . implode('/', $args) . '/' : '/';
    if (!($file = $fs->get_file($context->id, 'block_informationspot', $filearea, $imageid, $filepath, $filename)) or $file->is_directory()) {
        send_file_not_found();
    }
    if ($parentcontext = context::instance_by_id($birecord_or_cm->parentcontextid, IGNORE_MISSING)) {
        if ($parentcontext->contextlevel == CONTEXT_USER) {
            // force download on all personal pages including /my/
            //because we do not have reliable way to find out from where this is used
            $forcedownload = true;
        }
    } else {
        // weird, there should be parent context, better force dowload then
        $forcedownload = true;
    }
    // NOTE: it woudl be nice to have file revisions here, for now rely on standard file lifetime,
    //       do not lower it because the files are dispalyed very often.
    \core\session\manager::write_close();
    send_stored_file($file, null, 0, $forcedownload, $options);
}
开发者ID:bobopinna,项目名称:moodle-blocks_informationspot,代码行数:71,代码来源:lib.php

示例9: execute

 public function execute()
 {
     global $CFG, $DB;
     require_once $CFG->dirroot . "/mod/turnitintooltwo/lib.php";
     require_once $CFG->dirroot . "/mod/turnitintooltwo/turnitintooltwo_view.class.php";
     $data = (array) $this->get_custom_data();
     // Make sure we are still wanted.
     $submission = $DB->get_record('turnitintooltwo_submissions', array('id' => $data['submissionid']));
     if (!$submission) {
         return true;
     }
     cli_writeln("Processing Turnitintooltwo submission: " . $data['submissionid']);
     $user = $DB->get_record('user', array('id' => $data['userid']));
     \core\session\manager::set_user($user);
     $turnitintooltwo = $DB->get_record('turnitintooltwo', array('id' => $data['tiiid']));
     list($course, $cm) = get_course_and_cm_from_instance($turnitintooltwo, 'turnitintooltwo');
     try {
         $turnitintooltwoassignment = new \turnitintooltwo_assignment($turnitintooltwo->id, $turnitintooltwo);
         $turnitintooltwosubmission = new \turnitintooltwo_submission($data['submissionid'], "moodle", $turnitintooltwoassignment);
         $parts = $turnitintooltwoassignment->get_parts();
         $tiisubmission = $turnitintooltwosubmission->do_tii_submission($cm, $turnitintooltwoassignment);
         // Update submission.
         $DB->update_record('turnitintooltwo_submissions', array('id' => $data['submissionid'], 'submission_modified' => $data['subtime']));
     } catch (\Exception $e) {
         $tiisubmission = array('success' => false, 'message' => $e->getMessage());
         cli_writeln($e->getMessage());
     }
     $digitalreceipt = $tiisubmission;
     $digitalreceipt['is_manual'] = 0;
     $digitalreceipt = json_encode($digitalreceipt);
     $this->update_sub_status($data['submissionid'], $tiisubmission['success'], $digitalreceipt);
     if ($tiisubmission['success'] === true) {
         $lockedassignment = new \stdClass();
         $lockedassignment->id = $turnitintooltwoassignment->turnitintooltwo->id;
         $lockedassignment->submitted = 1;
         $DB->update_record('turnitintooltwo', $lockedassignment);
         $lockedpart = new \stdClass();
         $lockedpart->id = $data['submissionpart'];
         $lockedpart->submitted = 1;
         // Disable anonymous marking if post date has passed.
         if ($parts[$data['submissionpart']]->dtpost <= time()) {
             $lockedpart->unanon = 1;
         }
         $DB->update_record('turnitintooltwo_parts', $lockedpart);
         cli_writeln("Finished processing successful submission: " . $data['submissionid']);
     } else {
         turnitintooltwo_add_to_log($course->id, "errored submission", 'view.php?id=' . $cm->id, "Failed to submit '" . $turnitintooltwosubmission->submission_title . "'", $cm->id, $user->id, array('submissionid' => $data['submissionid']));
         cli_writeln("Finished processing unsuccessful submission: " . $data['submissionid']);
     }
     \core\session\manager::set_user(get_admin());
     return $tiisubmission['success'];
 }
开发者ID:SkylarKelty,项目名称:moodle-mod_turnitintooltwo,代码行数:52,代码来源:submit_assignment.php

示例10: setUp

 /**
  * Test set up.
  *
  * This is executed before running any tests in this file.
  */
 public function setUp()
 {
     global $SESSION;
     $this->resetAfterTest();
     manager::init_empty_session();
     // Set this user as the admin.
     $this->setAdminUser();
     $data = new stdClass();
     $data->enrolstartdate = time();
     $data->secret = 'secret';
     $toolrecord = $this->getDataGenerator()->create_lti_tool($data);
     $this->tool = helper::get_lti_tool($toolrecord->id);
     $SESSION->notifications = [];
 }
开发者ID:dg711,项目名称:moodle,代码行数:19,代码来源:tool_provider_test.php

示例11: report_usersessions_extend_navigation_user

/**
 * This function extends the course navigation with the report items
 *
 * @param navigation_node $navigation The navigation node to extend
 * @param stdClass $user
 * @param stdClass $course The course to object for the report
 */
function report_usersessions_extend_navigation_user($navigation, $user, $course)
{
    global $USER;
    if (isguestuser() or !isloggedin()) {
        return;
    }
    if (\core\session\manager::is_loggedinas() or $USER->id != $user->id) {
        // No peeking at somebody else's sessions!
        return;
    }
    $context = context_user::instance($USER->id);
    if (has_capability('report/usersessions:manageownsessions', $context)) {
        $navigation->add(get_string('navigationlink', 'report_usersessions'), new moodle_url('/report/usersessions/user.php'), $navigation::TYPE_SETTING);
    }
}
开发者ID:nikitskynikita,项目名称:moodle,代码行数:22,代码来源:lib.php

示例12: tool_generator_pluginfile

/**
 * Files support.
 *
 * Exits if the required permissions are not satisfied.
 *
 * @param stdClass $course course object
 * @param stdClass $cm
 * @param stdClass $context context object
 * @param string $filearea file area
 * @param array $args extra arguments
 * @param bool $forcedownload whether or not force download
 * @param array $options additional options affecting the file serving
 * @return void The file is sent along with it's headers
 */
function tool_generator_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options = array())
{
    // Only for admins or CLI.
    if (!defined('CLI_SCRIPT') && !is_siteadmin()) {
        die;
    }
    if ($context->contextlevel != CONTEXT_SYSTEM) {
        send_file_not_found();
    }
    $fs = get_file_storage();
    $file = $fs->get_file($context->id, 'tool_generator', $filearea, $args[0], '/', $args[1]);
    // Send the file, always forcing download, we don't want options.
    \core\session\manager::write_close();
    send_stored_file($file, 0, 0, true);
}
开发者ID:evltuma,项目名称:moodle,代码行数:29,代码来源:lib.php

示例13: block_slideshow_pluginfile

/**
 * Slideshow block
 *
 * This is a simple block that allows a user to embed a slideshow just below the 
 * header of either the frontpage of a site or a coursepage.  The slideshow is based
 * on jquery cycle.
 *
 * @package    block_slideshow
 * @category   blocks
 * @copyright  2013 Paul Prenis
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
function block_slideshow_pluginfile($course, $birecord_or_cm, $context, $filearea, $args, $forcedownload, array $options = array())
{
    global $DB, $CFG;
    if ($context->contextlevel != CONTEXT_BLOCK) {
        send_file_not_found();
    }
    // If block is in course context, then check if user has capability to access course.
    if ($context->get_course_context(false)) {
        require_course_login($course);
    } else {
        if ($CFG->forcelogin) {
            require_login();
        } else {
            // Get parent context and see if user have proper permission.
            $parentcontext = $context->get_parent_context();
            if ($parentcontext->contextlevel === CONTEXT_COURSECAT) {
                // Check if category is visible and user can view this category.
                $category = $DB->get_record('course_categories', array('id' => $parentcontext->instanceid), '*', MUST_EXIST);
                if (!$category->visible) {
                    require_capability('moodle/category:viewhiddencategories', $parentcontext);
                }
            }
            // At this point there is no way to check SYSTEM or USER context, so ignoring it.
        }
    }
    if ($filearea !== 'content') {
        send_file_not_found();
    }
    $fs = get_file_storage();
    $filename = array_pop($args);
    $filepath = $args ? '/' . implode('/', $args) . '/' : '/';
    if (!($file = $fs->get_file($context->id, 'block_slideshow', 'content', 0, $filepath, $filename)) or $file->is_directory()) {
        send_file_not_found();
    }
    if ($parentcontext = context::instance_by_id($birecord_or_cm->parentcontextid, IGNORE_MISSING)) {
        if ($parentcontext->contextlevel == CONTEXT_USER) {
            // force download on all personal pages including /my/
            //because we do not have reliable way to find out from where this is used
            $forcedownload = true;
        }
    } else {
        // weird, there should be parent context, better force dowload then
        $forcedownload = true;
    }
    \core\session\manager::write_close();
    send_stored_file($file, 60 * 60, 0, $forcedownload, $options);
}
开发者ID:ptabak,项目名称:moodle-block_slideshow,代码行数:59,代码来源:lib.php

示例14: report_usersessions_myprofile_navigation

/**
 * Add nodes to myprofile page.
 *
 * @param \core_user\output\myprofile\tree $tree Tree object
 * @param stdClass $user user object
 * @param bool $iscurrentuser
 * @param stdClass $course Course object
 *
 * @return bool
 */
function report_usersessions_myprofile_navigation(core_user\output\myprofile\tree $tree, $user, $iscurrentuser, $course)
{
    global $USER;
    if (isguestuser() or !isloggedin()) {
        return;
    }
    if (\core\session\manager::is_loggedinas() or $USER->id != $user->id) {
        // No peeking at somebody else's sessions!
        return;
    }
    $context = context_user::instance($USER->id);
    if (has_capability('report/usersessions:manageownsessions', $context)) {
        $node = new core_user\output\myprofile\node('reports', 'usersessions', get_string('navigationlink', 'report_usersessions'), null, new moodle_url('/report/usersessions/user.php'));
        $tree->add_node($node);
    }
    return true;
}
开发者ID:evltuma,项目名称:moodle,代码行数:27,代码来源:lib.php

示例15: execute

 /**
  * Run the deletion task.
  *
  * @throws \coding_exception if the module could not be removed.
  */
 public function execute()
 {
     global $CFG;
     require_once $CFG->dirroot . '/course/lib.php';
     // Set the proper user.
     if ($this->get_custom_data()->userid !== $this->get_custom_data()->realuserid) {
         $realuser = \core_user::get_user($this->get_custom_data()->realuserid, '*', MUST_EXIST);
         cron_setup_user($realuser);
         \core\session\manager::loginas($this->get_custom_data()->userid, \context_system::instance(), false);
     } else {
         $user = \core_user::get_user($this->get_custom_data()->userid, '*', MUST_EXIST);
         cron_setup_user($user);
     }
     $cms = $this->get_custom_data()->cms;
     foreach ($cms as $cm) {
         try {
             course_delete_module($cm->id);
         } catch (\Exception $e) {
             throw new \coding_exception("The course module {$cm->id} could not be deleted. {$e->getTraceAsString()}");
         }
     }
 }
开发者ID:lucaboesch,项目名称:moodle,代码行数:27,代码来源:course_delete_modules.php


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