本文整理汇总了PHP中CourseManager::course_code_exists方法的典型用法代码示例。如果您正苦于以下问题:PHP CourseManager::course_code_exists方法的具体用法?PHP CourseManager::course_code_exists怎么用?PHP CourseManager::course_code_exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CourseManager
的用法示例。
在下文中一共展示了CourseManager::course_code_exists方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: course_code_exists
/**
* Checks whether a given course code has been already occupied.
* @param string $wanted_course_code The code to be checked.
* @return string
* Returns TRUE if there is created:
* - a course with the same code OR visual_code (visualcode).
* - a course request with the same code as the given one, or
* Othewise returns FALSE.
*/
public static function course_code_exists($wanted_course_code)
{
if ($code_exists = CourseManager::course_code_exists($wanted_course_code)) {
return $code_exists;
}
$table_course_request = Database::get_main_table(TABLE_MAIN_COURSE_REQUEST);
$wanted_course_code = Database::escape_string($wanted_course_code);
$sql = sprintf('SELECT COUNT(id) AS number FROM %s WHERE visual_code = "%s"', $table_course_request, $wanted_course_code);
$result = Database::fetch_array(Database::query($sql));
return $result['number'] > 0;
}
示例2: array
$wanted_code = $course_values['wanted_code'];
$category_code = $course_values['category_code'];
$title = $course_values['title'];
$course_language = $course_values['course_language'];
$exemplary_content = !empty($course_values['exemplary_content']);
if ($course_validation_feature) {
$description = $course_values['description'];
$objetives = $course_values['objetives'];
$target_audience = $course_values['target_audience'];
}
if ($wanted_code == '') {
$wanted_code = CourseManager::generate_course_code(api_substr($title, 0, CourseManager::MAX_COURSE_LENGTH_CODE));
}
// Check whether the requested course code has already been occupied.
if (!$course_validation_feature) {
$course_code_ok = !CourseManager::course_code_exists($wanted_code);
} else {
$course_code_ok = !CourseRequestManager::course_code_exists($wanted_code);
}
if ($course_code_ok) {
if (!$course_validation_feature) {
$params = array();
$params['title'] = $title;
$params['exemplary_content'] = $exemplary_content;
$params['wanted_code'] = $wanted_code;
$params['course_category'] = $category_code;
$params['course_language'] = $course_language;
$params['gradebook_model_id'] = isset($course_values['gradebook_model_id']) ? $course_values['gradebook_model_id'] : null;
$course_info = CourseManager::create_course($params);
if (!empty($course_info)) {
/*
示例3: accept_course_request
/**
* Accepts a given by its id course request. The requested course gets created immediately after the request acceptance.
* @param int/string $id The id (an integer number) of the corresponding database record.
* @return string/bool Returns the code of the newly created course or FALSE on failure.
*/
public static function accept_course_request($id)
{
$id = (int) $id;
// Retrieve request's data
$course_request_info = self::get_course_request_info($id);
if (!is_array($course_request_info)) {
return false;
}
// Make all the checks again before the new course creation.
if (CourseManager::course_code_exists($wanted_code)) {
return false;
}
$user_id = (int) $course_request_info['user_id'];
if ($user_id <= 0) {
return false;
}
$user_info = api_get_user_info($user_id);
if (!is_array($user_info)) {
return false;
}
// Create the requested course
$params = array();
$params['title'] = $course_request_info['title'];
$params['category_code'] = $course_request_info['category_code'];
$params['course_language'] = $course_request_info['course_language'];
$params['exemplary_content'] = intval($course_request_info['exemplary_content']) > 0;
$params['wanted_code'] = $course_request_info['code'];
$params['user_id'] = $course_request_info['user_id'];
$params['tutor_name'] = api_get_person_name($user_info['firstname'], $user_info['lastname'], null, null, $course_language);
$course_info = CourseManager::create_course($params);
if (!empty($course_info)) {
// Mark the request as accepted.
$sql = "UPDATE " . Database::get_main_table(TABLE_MAIN_COURSE_REQUEST) . " SET status = " . COURSE_REQUEST_ACCEPTED . " WHERE id = " . $id;
Database::query($sql);
// E-mail notification.
// E-mail language: The platform language seems to be the best choice
$email_language = api_get_setting('platformLanguage');
$email_subject = sprintf(get_lang('CourseRequestAcceptedEmailSubject', null, $email_language), '[' . api_get_setting('platform.site_name') . ']', $course_info['code']);
$email_body = get_lang('Dear', null, $email_language) . ' ';
$email_body .= api_get_person_name($user_info['firstname'], $user_info['lastname'], null, null, $email_language) . ",\n\n";
$email_body .= sprintf(get_lang('CourseRequestAcceptedEmailText', null, $email_language), $wanted_code, $course_info['code'], api_get_path(WEB_COURSE_PATH) . $course_info['directory'] . '/') . "\n";
$email_body .= "\n" . get_lang('Formula', null, $email_language) . "\n";
$email_body .= api_get_person_name(api_get_setting('platform.administrator_name'), api_get_setting('platform.administrator_surname'), null, null, $email_language) . "\n";
$email_body .= get_lang('Manager', null, $email_language) . ' ' . api_get_setting('platform.site_name') . "\n";
$email_body .= get_lang('Phone', null, $email_language) . ': ' . api_get_setting('administratorTelephone') . "\n";
$email_body .= get_lang('Email', null, $email_language) . ': ' . api_get_setting('emailAdministrator', null, $email_language) . "\n";
$email_body .= "\n" . get_lang('CourseRequestLegalNote', null, $email_language) . "\n";
$sender_name = api_get_person_name(api_get_setting('platform.administrator_name'), api_get_setting('platform.administrator_surname'), null, PERSON_NAME_EMAIL_ADDRESS);
$sender_email = api_get_setting('platform.administrator_email');
$recipient_name = api_get_person_name($user_info['firstname'], $user_info['lastname'], null, PERSON_NAME_EMAIL_ADDRESS);
$recipient_email = $user_info['mail'];
$extra_headers = 'Bcc: ' . $sender_email;
@api_mail($recipient_name, $recipient_email, $email_subject, $email_body, $sender_name, $sender_email);
return $course_info['code'];
}
return false;
}
示例4: addCourseAction
//.........这里部分代码省略.........
$form->addRule('legal', get_lang('YouHaveToAcceptTermsAndConditions'), 'required');
// Link to terms and conditions.
$link_terms_and_conditions = '
<script>
function MM_openBrWindow(theURL, winName, features) { //v2.0
window.open(theURL,winName,features);
}
</script>
';
$link_terms_and_conditions .= \Display::url(get_lang('ReadTermsAndConditions'), '#', ['onclick' => "javascript:MM_openBrWindow('{$terms_and_conditions_url}', 'Conditions', 'scrollbars=yes, width=800');"]);
$form->addElement('label', null, $link_terms_and_conditions);
}
}
$obj = new \GradeModel();
$obj->fill_grade_model_select_in_form($form);
$form->addElement('html', '</div>');
// Submit button.
$form->addButtonCreate($courseValidation ? get_lang('CreateThisCourseRequest') : get_lang('CreateCourseArea'));
// Set default values.
if (isset($_user['language']) && $_user['language'] != '') {
$values['course_language'] = $_user['language'];
} else {
$values['course_language'] = api_get_setting('language.platform_language');
}
$form->setDefaults($values);
$message = null;
$content = null;
// Validate the form.
if ($form->validate()) {
$course_values = $form->exportValues();
$wanted_code = $course_values['wanted_code'];
//$category_code = $course_values['category_code'];
$category_code = '';
$title = $course_values['title'];
$course_language = $course_values['course_language'];
$exemplary_content = !empty($course_values['exemplary_content']);
if ($courseValidation) {
$description = $course_values['description'];
$objetives = $course_values['objetives'];
$target_audience = $course_values['target_audience'];
}
if ($wanted_code == '') {
$wanted_code = \CourseManager::generate_course_code(api_substr($title, 0, \CourseManager::MAX_COURSE_LENGTH_CODE));
}
// Check whether the requested course code has already been occupied.
if (!$courseValidation) {
$course_code_ok = !\CourseManager::course_code_exists($wanted_code);
} else {
$course_code_ok = !\CourseRequestManager::course_code_exists($wanted_code);
}
if ($course_code_ok) {
if (!$courseValidation) {
$params = array();
$params['title'] = $title;
$params['exemplary_content'] = $exemplary_content;
$params['wanted_code'] = $wanted_code;
$params['course_category'] = $category_code;
$params['course_language'] = $course_language;
$params['gradebook_model_id'] = isset($course_values['gradebook_model_id']) ? $course_values['gradebook_model_id'] : null;
$course_info = \CourseManager::create_course($params);
if (!empty($course_info)) {
$url = api_get_path(WEB_CODE_PATH);
$url .= 'course_info/start.php?cidReq=';
$url .= $course_info['code'];
$url .= '&first=1';
header('Location: ' . $url);
exit;
} else {
$this->addFlash('error', $this->trans('CourseCreationFailed'));
// Display the form.
$content = $form->returnForm();
}
} else {
// Create a request for a new course.
$request_id = \CourseRequestManager::create_course_request($wanted_code, $title, $description, $category_code, $course_language, $objetives, $target_audience, api_get_user_id(), $exemplary_content);
if ($request_id) {
$course_request_info = \CourseRequestManager::get_course_request_info($request_id);
$message = (is_array($course_request_info) ? '<strong>' . $course_request_info['code'] . '</strong> : ' : '') . get_lang('CourseRequestCreated');
\Display::return_message($message, 'confirmation', false);
\Display::return_message('div', \Display::url(get_lang('Enter'), api_get_path(WEB_PATH) . 'user_portal.php', ['class' => 'btn btn-default']), ['style' => 'float: left; margin:0px; padding: 0px;']);
} else {
\Display::return_message(get_lang('CourseRequestCreationFailed'), 'error', false);
// Display the form.
$content = $form->returnForm();
}
}
} else {
\Display::return_message(get_lang('CourseCodeAlreadyExists'), 'error', false);
// Display the form.
$content = $form->returnForm();
}
} else {
if (!$courseValidation) {
$this->addFlash('warning', get_lang('Explanation'));
}
// Display the form.
$content = $form->returnForm();
}
return $this->render('ChamiloCoreBundle:Index:userportal.html.twig', array('content' => $content));
}