本文整理汇总了PHP中Chamilo\CoreBundle\Framework\Container::getCourseSettingsManager方法的典型用法代码示例。如果您正苦于以下问题:PHP Container::getCourseSettingsManager方法的具体用法?PHP Container::getCourseSettingsManager怎么用?PHP Container::getCourseSettingsManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Chamilo\CoreBundle\Framework\Container
的用法示例。
在下文中一共展示了Container::getCourseSettingsManager方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isset
//.........这里部分代码省略.........
$course_id = 0;
if ($ok_to_register_course) {
/** @var Course $course */
$course = self::getCourseManager()->create();
$course->setCode($code)->setDirectory($directory)->setCourseLanguage($course_language)->setTitle($title)->setDescription(get_lang('CourseDescription'))->setCategoryCode($category_code)->setVisibility($visibility)->setShowScore(1)->setDiskQuota($disk_quota)->setCreationDate(new \DateTime())->setExpirationDate(new \DateTime($expiration_date))->setDepartmentName($department_name)->setDepartmentUrl($department_url)->setSubscribe($subscribe)->setUnsubscribe($unsubscribe)->setVisualCode($visual_code);
self::getCourseManager()->save($course, true);
$course_id = $course->getId();
/*// Here we must add 2 fields.
$sql = "INSERT INTO ".$TABLECOURSE . " SET
code = '".Database :: escape_string($code) . "',
directory = '".Database :: escape_string($directory) . "',
course_language = '".Database :: escape_string($course_language) . "',
title = '".Database :: escape_string($title) . "',
description = '".Database::escape_string(get_lang('CourseDescription')) . "',
category_code = '".Database :: escape_string($category_code) . "',
visibility = '".$visibility . "',
show_score = '1',
disk_quota = '".intval($disk_quota) . "',
creation_date = '$time',
expiration_date = '".$expiration_date . "',
last_edit = '$time',
last_visit = NULL,
tutor_name = '".Database :: escape_string($tutor_name) . "',
department_name = '".Database :: escape_string($department_name) . "',
department_url = '".Database :: escape_string($department_url) . "',
subscribe = '".intval($subscribe) . "',
unsubscribe = '".intval($unsubscribe) . "',
visual_code = '".Database :: escape_string($visual_code) . "'";
Database::query($sql);
$course_id = Database::insert_id();*/
//$course->addUsers()
if ($course_id) {
$settingsManager = Container::getCourseSettingsManager();
$schemas = $settingsManager->getSchemas();
$schemas = array_keys($schemas);
/**
* @var string $key
* @var \Sylius\Bundle\SettingsBundle\Schema\SchemaInterface $schema
*/
foreach ($schemas as $schema) {
$settings = $settingsManager->loadSettings($schema);
$settingsManager->setCourse($course);
$settingsManager->saveSettings($schema, $settings);
}
$sort = api_max_sort_value('0', api_get_user_id());
$i_course_sort = CourseManager::userCourseSort($user_id, $code);
if (!empty($user_id)) {
$sql = "INSERT INTO " . $TABLECOURSUSER . " SET\n c_id = '" . Database::escape_string($course_id) . "',\n user_id = '" . intval($user_id) . "',\n status = '1',\n tutor_id = '0',\n sort = '" . $i_course_sort . "',\n user_course_cat = '0'";
Database::query($sql);
}
if (!empty($teachers)) {
if (!is_array($teachers)) {
$teachers = array($teachers);
}
foreach ($teachers as $key) {
//just in case
if ($key == $user_id) {
continue;
}
if (empty($key)) {
continue;
}
$sql = "INSERT INTO " . $TABLECOURSUSER . " SET\n c_id = '" . Database::escape_string($course_id) . "',\n user_id = '" . Database::escape_string($key) . "',\n status = '1',\n role = '',\n tutor_id = '0',\n sort = '" . ($sort + 1) . "',\n user_course_cat = '0'";
Database::query($sql);
}