本文整理汇总了PHP中Display::display_error_message方法的典型用法代码示例。如果您正苦于以下问题:PHP Display::display_error_message方法的具体用法?PHP Display::display_error_message怎么用?PHP Display::display_error_message使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Display
的用法示例。
在下文中一共展示了Display::display_error_message方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: check_download_survey
/**
* @package chamilo.survey
* @author Arnaud Ligot <arnaud@cblue.be>
* @version $Id: $
*
* A small peace of code to enable user to access images included into survey
* which are accessible by non authenticated users. This file is included
* by document/download.php
*/
function check_download_survey($course, $invitation, $doc_url)
{
require_once 'survey.lib.php';
// Getting all the course information
$_course = CourseManager::get_course_information($course);
$course_id = $_course['real_id'];
// Database table definitions
$table_survey = Database::get_course_table(TABLE_SURVEY);
$table_survey_question = Database::get_course_table(TABLE_SURVEY_QUESTION);
$table_survey_question_option = Database::get_course_table(TABLE_SURVEY_QUESTION_OPTION);
$table_survey_invitation = Database::get_course_table(TABLE_SURVEY_INVITATION);
// Now we check if the invitationcode is valid
$sql = "SELECT * FROM {$table_survey_invitation}\n\t WHERE\n\t c_id = {$course_id} AND\n\t invitation_code = '" . Database::escape_string($invitation) . "'";
$result = Database::query($sql);
if (Database::num_rows($result) < 1) {
Display::display_error_message(get_lang('WrongInvitationCode'), false);
Display::display_footer();
exit;
}
$survey_invitation = Database::fetch_assoc($result);
// Now we check if the user already filled the survey
if ($survey_invitation['answered'] == 1) {
Display::display_error_message(get_lang('YouAlreadyFilledThisSurvey'), false);
Display::display_footer();
exit;
}
// Very basic security check: check if a text field from a survey/answer/option contains the name of the document requested
// Fetch survey ID
// If this is the case there will be a language choice
$sql = "SELECT * FROM {$table_survey}\n\t WHERE\n\t c_id = {$course_id} AND\n\t code='" . Database::escape_string($survey_invitation['survey_code']) . "'";
$result = Database::query($sql);
if (Database::num_rows($result) > 1) {
if ($_POST['language']) {
$survey_invitation['survey_id'] = $_POST['language'];
} else {
echo '<form id="language" name="language" method="POST" action="' . api_get_self() . '?course=' . $_GET['course'] . '&invitationcode=' . $_GET['invitationcode'] . '">';
echo ' <select name="language">';
while ($row = Database::fetch_assoc($result)) {
echo '<option value="' . $row['survey_id'] . '">' . $row['lang'] . '</option>';
}
echo '</select>';
echo ' <input type="submit" name="Submit" value="' . get_lang('Ok') . '" />';
echo '</form>';
display::display_footer();
exit;
}
} else {
$row = Database::fetch_assoc($result);
$survey_invitation['survey_id'] = $row['survey_id'];
}
$sql = "SELECT count(*)\n\t FROM {$table_survey}\n\t WHERE\n\t c_id = {$course_id} AND\n\t survey_id = " . $survey_invitation['survey_id'] . " AND (\n title LIKE '%{$doc_url}%'\n or subtitle LIKE '%{$doc_url}%'\n or intro LIKE '%{$doc_url}%'\n or surveythanks LIKE '%{$doc_url}%'\n )\n\t\t UNION\n\t\t SELECT count(*)\n\t\t FROM {$table_survey_question}\n\t\t WHERE\n\t\t c_id = {$course_id} AND\n\t\t survey_id = " . $survey_invitation['survey_id'] . " AND (\n survey_question LIKE '%{$doc_url}%'\n or survey_question_comment LIKE '%{$doc_url}%'\n )\n\t\t UNION\n\t\t SELECT count(*)\n\t\t FROM {$table_survey_question_option}\n\t\t WHERE\n\t\t c_id = {$course_id} AND\n\t\t survey_id = " . $survey_invitation['survey_id'] . " AND (\n option_text LIKE '%{$doc_url}%'\n )";
$result = Database::query($sql);
if (Database::num_rows($result) == 0) {
Display::display_error_message(get_lang('WrongInvitationCode'), false);
Display::display_footer();
exit;
}
return $_course;
}
示例2: send_invitation
public function send_invitation($username, $password, $userfriend_id, $content_message = '')
{
global $charset;
if ($this->verifyUserPass($username, $password) == "valid") {
$user_id = UserManager::get_user_id_from_username($username);
$message_title = get_lang('Invitation');
$count_is_true = SocialManager::send_invitation_friend($user_id, $userfriend_id, $message_title, $content_message);
if ($count_is_true) {
return Display::display_normal_message(api_htmlentities(get_lang('InvitationHasBeenSent'), ENT_QUOTES, $charset), false);
} else {
return Display::display_error_message(api_htmlentities(get_lang('YouAlreadySentAnInvitation'), ENT_QUOTES, $charset), false);
}
}
return get_lang('InvalidId');
}
示例3: action_subscribe_user
/**
* Handle the subscribe action.
*
* @return bool
*/
function action_subscribe_user()
{
$action = self::get('action');
if ($action != self::ACTION_SUBSCRIBE) {
return false;
}
$course_code = self::post(self::PARAM_SUBSCRIBE);
if (empty($course_code)) {
return false;
}
$registration_code = self::post(self::PARAM_PASSCODE);
if ($this->subscribe_user($course_code, $registration_code)) {
Display::display_confirmation_message(get_lang('EnrollToCourseSuccessful'));
return;
}
if (!empty($registration_code)) {
Display::display_error_message(get_lang('CourseRegistrationCodeIncorrect'));
}
$this->display_form($course_code);
return true;
}
示例4: ch_qti2_import_file
/**
* This function will import the zip file with the respective qti2
* @param array $uploaded_file ($_FILES)
*/
function ch_qti2_import_file($array_file)
{
$unzip = 0;
$lib_path = api_get_path(LIBRARY_PATH);
$process = FileManager::process_uploaded_file($array_file);
if (preg_match('/\\.zip$/i', $array_file['name'])) {
// if it's a zip, allow zip upload
$unzip = 1;
}
if ($process && $unzip == 1) {
$main_path = api_get_path(SYS_CODE_PATH);
require_once $main_path . 'exercice/export/exercise_import.inc.php';
require_once $main_path . 'exercice/export/qti2/qti2_classes.php';
$imported = import_exercise($array_file['name']);
if ($imported) {
header('Location: exercice.php?' . api_get_cidreq());
} else {
Display::display_error_message(get_lang('UplNoFileUploaded'));
return false;
}
}
}
示例5: get_lang
// temporary configuration of in which folder to upload the file in each course.
// Should default to '', and start with a '/' and end without it, if defined
$subDir = '';
$tool_name = get_lang('ImportPDFIntroToCourses');
$interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
set_time_limit(0);
Display::display_header($tool_name);
if ($_POST['formSent']) {
if (empty($_FILES['import_file']['tmp_name'])) {
$error_message = get_lang('UplUploadFailed');
Display::display_error_message($error_message, false);
} else {
$allowed_file_mimetype = array('zip');
$ext_import_file = substr($_FILES['import_file']['name'], strrpos($_FILES['import_file']['name'], '.') + 1);
if (!in_array($ext_import_file, $allowed_file_mimetype)) {
Display::display_error_message(get_lang('YouMustImportAZipFile'));
} else {
$errors = import_pdfs($courses, $subDir);
if (count($errors) == 0) {
error_log('Course intros imported successfully in ' . __FILE__ . ', line ' . __LINE__);
}
}
}
}
if (count($errors) != 0) {
$error_message = '<ul>';
foreach ($errors as $index => $error_course) {
$error_message .= '<li>' . get_lang('Course') . ': ' . $error_course['Title'] . ' (' . $error_course['Code'] . ')</li>';
}
$error_message .= '</ul>';
Display::display_normal_message($error_message, false);
示例6: ldap_add_user
/**
* Adds a user to the Dokeos database or updates its data
* @param string username (and uid inside LDAP)
* @author Mustapha Alouani
*/
function ldap_add_user($login)
{
global $ldap_basedn, $ldap_host, $ldap_port, $ldap_rdn, $ldap_pass;
$ds = ldap_connect($ldap_host, $ldap_port);
ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($ds, LDAP_OPT_REFERRALS, 0);
if ($ds) {
$str_query = "(uid=" . $login . ")";
$r = false;
$res = ldap_handle_bind($ds, $r);
$sr = ldap_search($ds, $ldap_basedn, $str_query);
//echo "Le nombre de resultats est : ".ldap_count_entries($ds,$sr)."<p>";
$info = ldap_get_entries($ds, $sr);
for ($key = 0; $key < $info['count']; $key++) {
$lastname = api_convert_encoding($info[$key]['sn'][0], api_get_system_encoding(), 'UTF-8');
$firstname = api_convert_encoding($info[$key]['givenname'][0], api_get_system_encoding(), 'UTF-8');
$email = $info[$key]['mail'][0];
// Get uid from dn
$dn_array = ldap_explode_dn($info[$key]['dn'], 1);
$username = $dn_array[0];
// uid is first key
$outab[] = $info[$key]['edupersonprimaryaffiliation'][0];
// Ici "student"
//$val = ldap_get_values_len($ds, $entry, "userPassword");
//$val = ldap_get_values_len($ds, $info[$key], "userPassword");
//$password = $val[0];
// TODO the password, if encrypted at the source, will be encrypted twice, which makes it useless. Try to fix that.
$password = $info[$key]['userPassword'][0];
$structure = $info[$key]['edupersonprimaryorgunitdn'][0];
$array_structure = explode(",", $structure);
$array_val = explode("=", $array_structure[0]);
$etape = $array_val[1];
$array_val = explode("=", $array_structure[1]);
$annee = $array_val[1];
// Pour faciliter la gestion on ajoute le code "etape-annee"
$official_code = $etape . "-" . $annee;
$auth_source = 'ldap';
// Pas de date d'expiration d'etudiant (a recuperer par rapport au shadow expire LDAP)
$expiration_date = '0000-00-00 00:00:00';
$active = 1;
if (empty($status)) {
$status = 5;
}
if (empty($phone)) {
$phone = '';
}
if (empty($picture_uri)) {
$picture_uri = '';
}
// Ajout de l'utilisateur
if (UserManager::is_username_available($username)) {
$user_id = UserManager::create_user($firstname, $lastname, $status, $email, $username, $password, $official_code, api_get_setting('platformLanguage'), $phone, $picture_uri, $auth_source, $expiration_date, $active);
} else {
$user = UserManager::get_user_info($username);
$user_id = $user['user_id'];
UserManager::update_user($user_id, $firstname, $lastname, $username, null, null, $email, $status, $official_code, $phone, $picture_uri, $expiration_date, $active);
}
}
} else {
Display::display_error_message(get_lang('LDAPConnectionError'));
}
return $user_id;
}
示例7: header
$df = DocumentManager::get_default_certificate_id($_course['code']);
if (!isset($df)) {
DocumentManager::attach_gradebook_certificate($_course['code'], $document_id);
}
$certificate_condition = '&certificate=true';
}
header('Location: document.php?' . api_get_cidreq() . '&id=' . $folder_id . $selectcat . $certificate_condition);
exit;
} else {
Display::display_header($nameTools, 'Doc');
Display::display_error_message(get_lang('Impossible'));
Display::display_footer();
}
} else {
Display::display_header($nameTools, 'Doc');
Display::display_error_message(get_lang('Impossible'));
Display::display_footer();
}
} else {
// Interbreadcrumb for the current directory root path
// Copied from document.php
$dir_array = explode('/', $dir);
$array_len = count($dir_array);
// Interbreadcrumb for the current directory root path
if (empty($document_data['parents'])) {
$interbreadcrumb[] = array('url' => '#', 'name' => $document_data['title']);
} else {
foreach ($document_data['parents'] as $document_sub_data) {
$interbreadcrumb[] = array('url' => $document_sub_data['document_url'], 'name' => $document_sub_data['title']);
}
}
示例8: replace_document
/**
* Replace a document in the actual db
*
* @param XapianDocument $doc xapian document to push into the db
* @param Xapian::docid $did xapian document id of the document to replace
*/
function replace_document($doc, $did)
{
if (!is_a($doc, 'XapianDocument')) {
return false;
}
if ($this->db == null) {
$this->connectDb();
}
try {
$this->getDb()->replace_document((int) $did, $doc);
$this->getDb()->flush();
} catch (Exception $e) {
Display::display_error_message($e->getMessage());
return 1;
}
}
示例9: isset
Session::erase('error_message');
}
if (!empty($my_folder_data['description'])) {
echo '<p><div><strong>'.get_lang('Description').':</strong><p>'.Security::remove_XSS($my_folder_data['description']).'</p></div></p>';
}
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null;
$item_id = isset($_REQUEST['item_id']) ? intval($_REQUEST['item_id']) : null;
switch ($action) {
case 'delete':
$fileDeleted = deleteWorkItem($item_id, $courseInfo);
if (!$fileDeleted) {
Display::display_error_message(get_lang('YouAreNotAllowedToDeleteThisDocument'));
} else {
Display::display_confirmation_message(get_lang('TheDocumentHasBeenDeleted'));
}
break;
}
$result = getWorkDateValidationStatus($work_data);
echo $result['message'];
$check_qualification = intval($my_folder_data['qualification']);
if (!empty($work_data['enable_qualification']) && !empty($check_qualification)) {
$type = 'simple';
$columns = array(
get_lang('Type'),
示例10: array
$classes = array();
$tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
$tbl_class = Database::get_main_table(TABLE_MAIN_CLASS);
$tool_name = get_lang('AddClassesToACourse');
$interbreadcrumb[] = array("url" => 'index.php', "name" => get_lang('PlatformAdmin'));
Display::display_header($tool_name);
//api_display_tool_title($tool_name);
if ($_POST['formSent']) {
$form_sent = $_POST['formSent'];
$classes = is_array($_POST['ClassList']) ? $_POST['ClassList'] : array();
$courses = is_array($_POST['CourseList']) ? $_POST['CourseList'] : array();
$first_letter_class = $_POST['firstLetterClass'];
$first_letter_course = $_POST['firstLetterCourse'];
if ($form_sent == 1) {
if (count($classes) == 0 || count($courses) == 0) {
Display::display_error_message(get_lang('AtLeastOneClassAndOneCourse'));
} elseif (api_substr($_POST['formSubmit'], -2) == '>>') {
foreach ($courses as $course_code) {
foreach ($classes as $class_id) {
ClassManager::subscribe_to_course($class_id, $course_code);
}
}
Display::display_normal_message(get_lang('ClassesSubscribed'));
} else {
// remove classes from courses
foreach ($courses as $course_code) {
foreach ($classes as $class_id) {
ClassManager::unsubscribe_from_course($class_id, $course_code);
}
}
Display::display_normal_message(get_lang('ClassesUnSubscribed'));
示例11: foreach
Display::display_error_message(get_lang("CannotDeleteGlossary") . ':' . $term['id']);
}
}
}
//$data = Import::csv_to_array($_FILES['file']['tmp_name']);
$data = Import::csv_reader($_FILES['file']['tmp_name']);
$good = 0;
$bad = 0;
foreach ($data as $item) {
if (GlossaryManager::save_glossary(array('glossary_title' => $item['term'], 'glossary_comment' => $item['definition']), false)) {
$good++;
} else {
$bad++;
}
}
Display::display_confirmation_message(get_lang("TermsImported") . ':' . $good);
if ($bad) {
Display::display_error_message(get_lang("TermsNotImported") . ':' . $bad);
}
GlossaryManager::display_glossary();
}
break;
default:
GlossaryManager::display_glossary();
break;
}
} else {
GlossaryManager::display_glossary();
}
// Footer
Display::display_footer();
示例12: create_comment
/**
* Creates a comment on a post in a given blog
* @author Toon Keppens
* @param String $title
* @param String $full_text
* @param Integer $blog_id
* @param Integer $post_id
* @param Integer $parent_id
*/
public static function create_comment($title, $full_text, $file_comment, $blog_id, $post_id, $parent_id, $task_id = 'NULL')
{
$_user = api_get_user_info();
$_course = api_get_course_info();
$blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT);
$upload_ok = true;
$has_attachment = false;
$current_date = date('Y-m-d H:i:s', time());
$course_id = api_get_course_int_id();
if (!empty($_FILES['user_upload']['name'])) {
$upload_ok = process_uploaded_file($_FILES['user_upload']);
$has_attachment = true;
}
if ($upload_ok) {
// Table Definition
$tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS);
// Create the comment
$sql = "INSERT INTO {$tbl_blogs_comments} (c_id, title, comment, author_id, date_creation, blog_id, post_id, parent_comment_id, task_id )\n\t\t\t\t\tVALUES ({$course_id}, '" . Database::escape_string($title) . "', '" . Database::escape_string($full_text) . "', '" . (int) $_user['user_id'] . "','" . $current_date . "', '" . (int) $blog_id . "', '" . (int) $post_id . "', '" . (int) $parent_id . "', '" . (int) $task_id . "')";
Database::query($sql);
// Empty post values, or they are shown on the page again
$last_id = Database::insert_id();
if ($last_id) {
$sql = "UPDATE {$tbl_blogs_comments} SET comment_id = iid WHERE iid = {$last_id}";
Database::query($sql);
}
if ($has_attachment) {
$courseDir = $_course['path'] . '/upload/blog';
$sys_course_path = api_get_path(SYS_COURSE_PATH);
$updir = $sys_course_path . $courseDir;
// Try to add an extension to the file if it hasn't one
$new_file_name = add_ext_on_mime(stripslashes($_FILES['user_upload']['name']), $_FILES['user_upload']['type']);
// user's file name
$file_name = $_FILES['user_upload']['name'];
if (!filter_extension($new_file_name)) {
Display::display_error_message(get_lang('UplUnableToSaveFileFilteredExtension'));
} else {
$new_file_name = uniqid('');
$new_path = $updir . '/' . $new_file_name;
$result = @move_uploaded_file($_FILES['user_upload']['tmp_name'], $new_path);
$comment = Database::escape_string($file_comment);
// Storing the attachments if any
if ($result) {
$sql = 'INSERT INTO ' . $blog_table_attachment . '(c_id, filename,comment, path, post_id,size,blog_id,comment_id) ' . "VALUES ({$course_id}, '" . Database::escape_string($file_name) . "', '" . $comment . "', '" . Database::escape_string($new_file_name) . "' , '" . $post_id . "', '" . $_FILES['user_upload']['size'] . "', '" . $blog_id . "', '" . $last_id . "' )";
Database::query($sql);
$id = Database::insert_id();
if ($id) {
$sql = "UPDATE {$blog_table_attachment} SET id = iid WHERE iid = {$id}";
Database::query($sql);
}
}
}
}
}
}
示例13: api_get_language_isocode
$langsvgedit = api_get_language_isocode();
$langsvgedit = isset($svgedit_code_translation_table[$langsvgedit]) ? $svgedit_code_translation_table[$langsvgedit] : $langsvgedit;
$langsvgedit = file_exists(api_get_path(LIBRARY_PATH) . 'svg-edit/locale/lang.' . $langsvgedit . '.js') ? $langsvgedit : 'en';
$svg_url = api_get_path(WEB_LIBRARY_PATH) . 'svg-edit/svg-editor.php?lang=' . $langsvgedit;
?>
<script>
document.write ('<iframe id="frame" frameborder="0" scrolling="no" src="<?php
echo $svg_url;
?>
" width="100%" height="100%"><noframes><p>Sorry, your browser does not handle frames</p></noframes></iframe>');
function resizeIframe() {
var height = window.innerHeight -50;
//max lower size
if (height<550) {
height=550;
}
document.getElementById('frame').style.height = height +"px";
}
document.getElementById('frame').onload = resizeIframe;
window.onresize = resizeIframe;
</script>
<?php
echo '<noscript>';
echo '<iframe style="height: 550px; width: 100%;" scrolling="no" frameborder="0" src="' . $svg_url . '"><noframes><p>Sorry, your browser does not handle frames</p></noframes></iframe>';
echo '</noscript>';
} else {
Display::display_error_message(get_lang('BrowserDontSupportsSVG'));
}
Display::display_footer();
示例14: save_message_attachment_file
/**
* Saves a message attachment files
* @param array $file_attach $_FILES['name']
* @param string a comment about the uploaded file
* @param int message id
* @param int receiver user id (optional)
* @param int sender user id (optional)
* @param int group id (optional)
* @return void
*/
public static function save_message_attachment_file($file_attach, $file_comment, $message_id, $receiver_user_id = 0, $sender_user_id = 0, $group_id = 0)
{
$tbl_message_attach = Database::get_main_table(TABLE_MESSAGE_ATTACHMENT);
// Try to add an extension to the file if it hasn't one
$new_file_name = add_ext_on_mime(stripslashes($file_attach['name']), $file_attach['type']);
// user's file name
$file_name = $file_attach['name'];
if (!filter_extension($new_file_name)) {
Display::display_error_message(get_lang('UplUnableToSaveFileFilteredExtension'));
} else {
$new_file_name = uniqid('');
if (!empty($receiver_user_id)) {
$message_user_id = $receiver_user_id;
} else {
$message_user_id = $sender_user_id;
}
// User-reserved directory where photos have to be placed.*
$userGroup = new UserGroup();
if (!empty($group_id)) {
$path_user_info = $userGroup->get_group_picture_path_by_id($group_id, 'system', true);
} else {
$path_user_info['dir'] = UserManager::getUserPathById($message_user_id, 'system');
}
$path_message_attach = $path_user_info['dir'] . 'message_attachments/';
// If this directory does not exist - we create it.
if (!file_exists($path_message_attach)) {
@mkdir($path_message_attach, api_get_permissions_for_new_directories(), true);
}
$new_path = $path_message_attach . $new_file_name;
if (is_uploaded_file($file_attach['tmp_name'])) {
@copy($file_attach['tmp_name'], $new_path);
}
// Storing the attachments if any
$params = ['filename' => $file_name, 'comment' => $file_comment, 'path' => $new_file_name, 'message_id' => $message_id, 'size' => $file_attach['size']];
Database::insert($tbl_message_attach, $params);
}
}
示例15: intval
$table_survey_question_option = Database::get_course_table(TABLE_SURVEY_QUESTION_OPTION);
$table_survey_question_group = Database::get_course_table(TABLE_SURVEY_QUESTION_GROUP);
$table_course = Database::get_main_table(TABLE_MAIN_COURSE);
$table_user = Database::get_main_table(TABLE_MAIN_USER);
$survey_id = intval($_GET['survey_id']);
$course_id = api_get_course_int_id();
// Breadcrumbs
$interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH) . 'survey/survey_list.php', 'name' => get_lang('SurveyList'));
// Getting the survey information
if (isset($_GET['survey_id'])) {
$course_code = api_get_course_id();
if ($course_code != -1) {
$survey_data = survey_manager::get_survey($survey_id);
} else {
Display::display_header(get_lang('ToolSurvey'));
Display::display_error_message(get_lang('NotAllowed'), false);
Display::display_footer();
exit;
}
}
$tool_name = strip_tags($survey_data['title']);
$is_survey_type_1 = $survey_data['survey_type'] == 1;
if (api_strlen(strip_tags($survey_data['title'])) > 40) {
$tool_name .= '...';
}
if ($is_survey_type_1 && isset($_GET['action']) && ($_GET['action'] == 'addgroup' || $_GET['action'] == 'deletegroup')) {
$_POST['name'] = trim($_POST['name']);
if ($_GET['action'] == 'addgroup') {
if (!empty($_POST['group_id'])) {
Database::query('UPDATE ' . $table_survey_question_group . ' SET description = \'' . Database::escape_string($_POST['description']) . '\'
WHERE c_id = ' . $course_id . ' AND id = \'' . Database::escape_string($_POST['group_id']) . '\'');