Remove Session::read('message'); use Display::addFlash

Flashes  now works when using Display::display_header
pull/2487/head
jmontoyaa 10 years ago
parent b5158a117b
commit 917ab67fdb
  1. 10
      main/admin/configure_plugin.php
  2. 15
      main/admin/skill_list.php
  3. 43
      main/calendar/agenda.php
  4. 5
      main/calendar/agenda_js.php
  5. 95
      main/exercise/hotpotatoes_exercise_report.php
  6. 2
      main/inc/lib/agenda.lib.php
  7. 1
      main/inc/lib/api.lib.php
  8. 3
      main/inc/lib/display.lib.php
  9. 3
      main/template/default/layout/show_header.tpl
  10. 8
      main/work/edit_work.php
  11. 5
      main/work/student_work.php
  12. 53
      main/work/work.php

@ -5,7 +5,6 @@
* @author Angel Fernando Quiroz Campos <angel.quiroz@beeznest.com>
* @package chamilo.admin
*/
use \ChamiloSession as Session;
$cidReset = true;
require_once '../inc/global.inc.php';
@ -24,10 +23,7 @@ if (!in_array($pluginName, $installedPlugins) || empty($pluginInfo)) {
}
global $_configuration;
$message = '';
$content = '';
$currentUrl = api_get_self() . "?name=$pluginName";
if (isset($pluginInfo['settings_form'])) {
@ -46,7 +42,9 @@ if (isset($pluginInfo['settings_form'])) {
$content .= $form->toHtml();
}
} else {
$message = Display::return_message(get_lang('NoConfigurationSettingsForThisPlugin'), 'warning');
Display::addFlash(
Display::return_message(get_lang('NoConfigurationSettingsForThisPlugin'), 'warning')
);
}
if (isset($form)) {
@ -108,8 +106,6 @@ $interbreadcrumb[] = array(
);
$tpl = new Template($pluginName, true, true, false, true, false);
$tpl->assign('message', '');
$tpl->assign('content', $content);
$tpl->display_one_col_template();
Session::erase('message');

@ -1,11 +1,13 @@
<?php
/* For licensing terms, see /license.txt */
use ChamiloSession as Session;
/**
* Skill list for management
* @author Angel Fernando Quiroz Campos <angel.quiroz@beeznest.com>
* @package chamilo.admin
*/
use ChamiloSession as Session;
$cidReset = true;
@ -27,7 +29,7 @@ $entityManager = Database::getManager();
switch ($action) {
case 'enable':
$skill = $entityManager->find('ChamiloCoreBundle:Skill', $skillId);
if (is_null($skill)) {
Display::addFlash(
Display::return_message(
@ -60,7 +62,7 @@ switch ($action) {
break;
case 'disable':
$skill = $entityManager->find('ChamiloCoreBundle:Skill', $skillId);
if (is_null($skill)) {
Display::addFlash(
Display::return_message(
@ -81,7 +83,7 @@ switch ($action) {
$skillObj = new Skill();
$childrens = $skillObj->get_children($skill->getId());
foreach ($childrens as $children) {
$skill = $entityManager->find(
'ChamiloCoreBundle:Skill',
@ -116,8 +118,6 @@ switch ($action) {
default:
$interbreadcrumb[] = array ("url" => 'index.php', "name" => get_lang('PlatformAdmin'));
$message = Session::has('message') ? Session::read('message') : null;
$toolbar = Display::toolbarButton(
get_lang('CreateSkill'),
api_get_path(WEB_CODE_PATH) . 'admin/skill_create.php',
@ -157,7 +157,6 @@ switch ($action) {
/* View */
$skill = new Skill();
$skillList = $skill->get_all();
$extraFieldSearchTagId = isset($_REQUEST['tag_id']) ? $_REQUEST['tag_id'] : 0;
if ($extraFieldSearchTagId) {
@ -173,7 +172,6 @@ switch ($action) {
}
$tpl = new Template(get_lang('ManageSkills'));
$tpl->assign('message', $message);
$tpl->assign('skills', $skillList);
$tpl->assign('current_tag_id', $extraFieldSearchTagId);
$tpl->assign('tags', $tags);
@ -184,6 +182,5 @@ switch ($action) {
$tpl->assign('content', $content);
$tpl->display_one_col_template();
Session::erase('message');
break;
}

@ -1,8 +1,6 @@
<?php
/* For licensing terms, see /license.txt */
use ChamiloSession as Session;
/**
* @package chamilo.calendar
*/
@ -53,8 +51,8 @@ function plus_repeated_event() {
$('#options2').show();
}
});
</script>
";
</script>";
$htmlHeadXtra[] = '<script>
var counter_image = 1;
@ -101,7 +99,7 @@ if ($type === 'fromjs') {
if (!api_is_allowed_to_edit(null, true) && $event_type === 'course') {
api_not_allowed(true);
}
if ($event_type == 'course') {
if ($event_type === 'course') {
$agendaUrl = api_get_path(WEB_CODE_PATH).'calendar/agenda_js.php?'.api_get_cidreq().'&type=course';
} else {
$agendaUrl = api_get_path(WEB_CODE_PATH).'calendar/agenda_js.php?&type='.$event_type;
@ -109,9 +107,7 @@ if ($event_type == 'course') {
$course_info = api_get_course_info();
$agenda->type = $event_type;
$message = null;
$content = null;
if (api_is_allowed_to_edit(false, true) ||
(api_get_course_setting('allow_user_edit_agenda') &&
!api_is_anonymous() &&
@ -166,7 +162,7 @@ if (api_is_allowed_to_edit(false, true) ||
if ($sendEmail) {
$message .= Display::return_message(get_lang('AdditionalMailWasSentToSelectedUsers'), 'confirmation');
}
Session::write('message', $message);
Display::addFlash($message);
header("Location: $agendaUrl");
exit;
} else {
@ -220,7 +216,7 @@ if (api_is_allowed_to_edit(false, true) ||
);
$message = Display::return_message(get_lang('Updated'), 'confirmation');
Session::write('message', $message);
Display::addFlash($message);
header("Location: $agendaUrl");
exit;
}
@ -264,7 +260,7 @@ if (api_is_allowed_to_edit(false, true) ||
}
$message = Display::return_message(get_lang('Updated'), 'confirmation');
Session::write('message', $message);
Display::addFlash($message);
header("Location: $agendaUrl");
exit;
} else {
@ -274,31 +270,23 @@ if (api_is_allowed_to_edit(false, true) ||
case 'importical':
$actionName = get_lang('Import');
$form = $agenda->getImportCalendarForm();
$content = $form->returnForm();
if ($form->validate()) {
$ical_name = $_FILES['ical_import']['name'];
$ical_type = $_FILES['ical_import']['type'];
$ext = substr($ical_name, (strrpos($ical_name, ".") + 1));
if ($ext === 'ics' || $ext === 'ical' || $ext === 'icalendar' || $ext === 'ifb') {
$result = $agenda->importEventFile($course_info, $_FILES['ical_import']);
$is_ical = true;
if (in_array($ext, ['ics', 'ical', 'icalendar', 'ifb'])) {
$content = $agenda->importEventFile($course_info, $_FILES['ical_import']);
$message = Display::return_message(get_lang('AddSuccess'));
} else {
$is_ical = false;
}
if (!$is_ical) {
$message = Display::return_message(get_lang('IsNotiCalFormatFile'), 'error');
$form = $agenda->getImportCalendarForm();
$content = $form->return_form();
break;
} else {
$message = Display::return_message(get_lang('AddSuccess'), 'error');
$content = $result;
}
Session::write('message', $message);
Display::addFlash($message);
$url = api_get_self().'?action=importical&type='.$agenda->type;
header("Location: $url");
exit;
}
$content = $form->returnForm();
break;
case "delete":
if (!(api_is_course_coach() && !api_is_element_in_the_session(TOOL_AGENDA, $eventId) )) {
@ -330,9 +318,6 @@ if (!empty($actionName)) {
// Tool introduction
$introduction = Display::return_introduction_section(TOOL_CALENDAR_EVENT);
$message = Session::read('message');
Session::erase('message');
$tpl = new Template($actionName);
$tpl->assign('content', $content);
$tpl->assign('actions', $actions);

@ -251,11 +251,6 @@ $tpl->assign('form_add', $form->returnForm());
// Loading Agenda template.
$content = $tpl->fetch('default/agenda/month.tpl');
$message = Session::read('message');
$tpl->assign('message', $message);
Session::erase('message');
$tpl->assign('content', $content);
// Loading main Chamilo 1 col template

@ -86,7 +86,7 @@ if ($is_allowedToEdit) {
case 'delete':
$fileToDelete = isset($_GET['id']) ? $_GET['id'] : null;
deleteAttempt($fileToDelete);
Session::write('message', Display::return_message(get_lang('ItemDeleted')));
Display::addFlash(Display::return_message(get_lang('ItemDeleted')));
$url = api_get_self().'?'.api_get_cidreq().'&path='.$hotpotatoes_path;
header("Location: $url");
exit;
@ -113,41 +113,39 @@ if ($is_allowedToEdit || $is_tutor) {
}
Display :: display_header($nameTools);
$actions = Display::div($actions, array('class'=> 'actions'));
$extra = '<script type="text/javascript">
$(document).ready(function() {
$extra = '<script>
$(document).ready(function() {
$( "#dialog:ui-dialog" ).dialog( "destroy" );
$( "#dialog:ui-dialog" ).dialog( "destroy" );
$( "#dialog-confirm" ).dialog({
autoOpen: false,
show: "blind",
resizable: false,
height:300,
modal: true
});
$("#export_opener").click(function() {
var targetUrl = $(this).attr("href");
$( "#dialog-confirm" ).dialog({
autoOpen: false,
show: "blind",
resizable: false,
height:300,
modal: true
});
$("#export_opener").click(function() {
var targetUrl = $(this).attr("href");
$( "#dialog-confirm" ).dialog({
width:400,
height:300,
buttons: {
"'.addslashes(get_lang('Download')).'": function() {
var export_format = $("input[name=export_format]:checked").val();
var extra_data = $("input[name=load_extra_data]:checked").val();
location.href = targetUrl+"&export_format="+export_format+"&extra_data="+extra_data;
$( this ).dialog( "close" );
}
width:400,
height:300,
buttons: {
"'.addslashes(get_lang('Download')).'": function() {
var export_format = $("input[name=export_format]:checked").val();
var extra_data = $("input[name=load_extra_data]:checked").val();
location.href = targetUrl+"&export_format="+export_format+"&extra_data="+extra_data;
$( this ).dialog( "close" );
}
});
$( "#dialog-confirm" ).dialog("open");
return false;
}
});
$( "#dialog-confirm" ).dialog("open");
return false;
});
</script>';
});
</script>';
$extra .= '<div id="dialog-confirm" title="'.get_lang("ConfirmYourChoice").'">';
$form = new FormValidator('report', 'post', null, null, array('class' => 'form-vertical'));
@ -193,14 +191,28 @@ if ($is_allowedToEdit || $is_tutor) {
// Column config
// @todo fix search firstname/lastname that doesn't work. rmove search for the moment
$column_model = array(
array('name'=>'firstname', 'index'=>'firstname', 'width'=>'50', 'align'=>'left', 'search' => 'false'),
array('name'=>'lastname', 'index'=>'lastname', 'width'=>'50', 'align'=>'left', 'formatter'=>'action_formatter', 'search' => 'false'),
array('name'=>'login', 'hidden'=>'true', 'index'=>'username', 'width'=>'40', 'align'=>'left', 'search' => 'false'),
array('name'=>'group_name', 'index'=>'group_id', 'width'=>'40', 'align'=>'left', 'search' => 'false'),
array('name'=>'exe_date', 'index'=>'exe_date', 'width'=>'60', 'align'=>'left', 'search' => 'false'),
array('name'=>'score', 'index'=>'exe_result', 'width'=>'50', 'align'=>'left', 'search' => 'false'),
array('name'=>'actions', 'index'=>'actions', 'width'=>'60', 'align'=>'left', 'search' => 'false')
$column_model = array(
array('name' => 'firstname', 'index' => 'firstname', 'width' => '50', 'align' => 'left', 'search' => 'false'),
array(
'name' => 'lastname',
'index' => 'lastname',
'width' => '50',
'align' => 'left',
'formatter' => 'action_formatter',
'search' => 'false',
),
array(
'name' => 'login',
'hidden' => 'true',
'index' => 'username',
'width' => '40',
'align' => 'left',
'search' => 'false',
),
array('name' => 'group_name', 'index' => 'group_id', 'width' => '40', 'align' => 'left', 'search' => 'false'),
array('name' => 'exe_date', 'index' => 'exe_date', 'width' => '60', 'align' => 'left', 'search' => 'false'),
array('name' => 'score', 'index' => 'exe_result', 'width' => '50', 'align' => 'left', 'search' => 'false'),
array('name' => 'actions', 'index' => 'actions', 'width' => '60', 'align' => 'left', 'search' => 'false'),
);
$action_links = '
@ -223,10 +235,10 @@ if ($is_allowedToEdit || $is_tutor) {
//Column config
// @todo fix search firstname/lastname that doesn't work. rmove search for the moment
$column_model = array(
array('name'=>'exe_date', 'index'=>'exe_date', 'width'=>'60', 'align'=>'left', 'search' => 'false'),
array('name'=>'score', 'index'=>'exe_result', 'width'=>'50', 'align'=>'left', 'search' => 'false'),
array('name'=>'actions', 'index'=>'actions', 'width'=>'60', 'align'=>'left', 'search' => 'false')
$column_model = array(
array('name' => 'exe_date', 'index' => 'exe_date', 'width' => '60', 'align' => 'left', 'search' => 'false'),
array('name' => 'score', 'index' => 'exe_result', 'width' => '50', 'align' => 'left', 'search' => 'false'),
array('name' => 'actions', 'index' => 'actions', 'width' => '60', 'align' => 'left', 'search' => 'false'),
);
}
@ -313,8 +325,5 @@ $(function() {
</form>
<?php
$showMessage = Session::read('message');
Session::erase('message');
echo isset($showMessage) ? $showMessage : null;
echo Display::grid_html('results');
Display :: display_footer();

@ -2687,7 +2687,7 @@ class Agenda
$form = new FormValidator(
'frm_import_ical',
'post',
api_get_self().'?action='.Security::remove_XSS($_GET['action']).'&type='.$this->type,
api_get_self().'?action=importical&type='.$this->type,
array('enctype' => 'multipart/form-data')
);
$form->addElement('header', get_lang('ICalFileImport'));

@ -2921,7 +2921,6 @@ function api_display_tool_view_option() {
$sourceurl = api_get_self().'?'.api_get_cidreq();
} else {
$sourceurl = $_SERVER['REQUEST_URI'];
//$sourceurl = str_replace('&', '&amp;', $sourceurl);
}
}

@ -66,6 +66,7 @@ class Display
self::$global_template = new Template($tool_name, $showHeader, $showHeader);
// Fixing tools with any help it takes xxx part of main/xxx/index.php
if (empty($help)) {
$currentURL = api_get_self();
@ -84,13 +85,13 @@ class Display
}
self::$global_template->setHelp($help);
if (!empty(self::$preview_style)) {
self::$global_template->preview_theme = self::$preview_style;
self::$global_template->setCssFiles();
self::$global_template->set_js_files();
self::$global_template->setCssCustomFiles();
}
if (!empty($page_header)) {
self::$global_template->assign('header', $page_header);
}

@ -12,7 +12,7 @@
<body dir="{{ text_direction }}" class="{{ section_name }} {{ login_class }}">
<noscript>{{ "NoJavascript"|get_lang }}</noscript>
{% if show_header == true %}
<div class="wrap">
<div class="wrap">
{% if displayCookieUsageWarning == true %}
<!-- Display Cookies validation -->
<div class="toolbar-cookie alert-warning">
@ -39,4 +39,5 @@
{% block breadcrumb %}
{{ breadcrumb }}
{% endblock %}
{{ flash_messages }}
{% endif %}

@ -114,21 +114,17 @@ if ($form->validate()) {
updateDirName($workData, $params['new_dir']);
$currentUrl = api_get_path(WEB_CODE_PATH).'work/edit_work.php?id='.$workId.'&'.api_get_cidreq();
Session::write('message', Display::return_message(get_lang('FolderEdited'), 'success'));
Display::addFlash(Display::return_message(get_lang('FolderEdited'), 'success'));
header('Location: '.$currentUrl);
exit;
} else {
Session::write('message', Display::return_message(get_lang('FileExists'), 'warning'));
Display::addFlash(Display::return_message(get_lang('FileExists'), 'warning'));
}
}
Display::display_header();
$message = Session::read('message');
echo $message;
Session::erase('message');
$form->display();
Display :: display_footer();

@ -82,7 +82,7 @@ switch ($action) {
$message .= $item['title'].'<br />';
}
$message = Display::return_message($message, 'info', false);
Session::write('message', $message);
Display::addFlash($message);
}
header('Location: '.api_get_self().'?studentId='.$studentId.'&'.api_get_cidreq());
exit;
@ -103,9 +103,6 @@ Display :: display_header(null);
$workPerUser = getWorkPerUser($studentId);
echo Session::read('message');
Session::erase('message');
echo '<div class="actions">';
echo '<a href="'.api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq().'">'.
Display::return_icon('back.png', get_lang('BackToWorksList'), '', ICON_SIZE_MEDIUM).'</a>';

@ -14,10 +14,11 @@ api_protect_course_script(true);
require_once 'work.lib.php';
$course_info = api_get_course_info();
$course_id = $course_info['real_id'];
$courseInfo = api_get_course_info();
$course_id = $courseInfo['real_id'];
$user_id = api_get_user_id();
$id_session = api_get_session_id();
$sessionId = api_get_session_id();
$groupId = api_get_group_id();
// Section (for the tabs)
$this_section = SECTION_COURSES;
@ -33,12 +34,10 @@ $_course = api_get_course_info();
/* Constants and variables */
$tool_name = get_lang('StudentPublications');
$session_id = api_get_session_id();
$group_id = api_get_group_id();
$item_id = isset($_REQUEST['item_id']) ? intval($_REQUEST['item_id']) : null;
$origin = isset($_REQUEST['origin']) ? Security::remove_XSS($_REQUEST['origin']) : '';
$course_dir = api_get_path(SYS_COURSE_PATH).$_course['path'];
$course_dir = api_get_path(SYS_COURSE_PATH).$courseInfo['path'];
$base_work_dir = $course_dir . '/work';
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'list';
@ -60,9 +59,9 @@ if (api_is_in_gradebook()) {
);
}
if (!empty($group_id)) {
if (!empty($groupId)) {
api_protect_course_group(GroupManager::GROUP_TOOL_WORK);
$group_properties = GroupManager::get_group_properties($group_id);
$group_properties = GroupManager::get_group_properties($groupId);
$interbreadcrumb[] = array(
'url' => api_get_path(WEB_CODE_PATH).'group/group.php?'.api_get_cidreq(),
@ -134,7 +133,6 @@ $student_can_edit_in_session = api_is_allowed_to_session_edit(false, true);
if (!in_array($action, array('add', 'create_dir'))) {
$token = Security::get_token();
}
$courseInfo = api_get_course_info();
$currentUrl = api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq();
$content = null;
@ -145,11 +143,11 @@ switch ($action) {
//if posts
if ($is_allowed_to_edit && !empty($_POST['changeProperties'])) {
updateSettings(
$course,
$courseInfo,
$_POST['show_score'],
$_POST['student_delete_own_publication']
);
Session::write('message', Display::return_message(get_lang('Saved'), 'success'));
Display::addFlash(Display::return_message(get_lang('Saved'), 'success'));
header('Location: '.$currentUrl);
exit;
}
@ -157,7 +155,7 @@ switch ($action) {
/* Display of tool options */
$content = settingsForm(
array(
'show_score' => $course_info['show_score'],
'show_score' => $courseInfo['show_score'],
'student_delete_own_publication' => $studentDeleteOwnPublication
)
);
@ -183,9 +181,9 @@ switch ($action) {
$result = addDir(
$_POST,
$user_id,
$_course,
$group_id,
$id_session
$courseInfo,
$groupId,
$sessionId
);
if ($result) {
@ -194,7 +192,7 @@ switch ($action) {
$message = Display::return_message(get_lang('CannotCreateDir'), 'error');
}
Session::write('message', $message);
Display::addFlash($message);
header('Location: '.$currentUrl);
exit;
} else {
@ -210,7 +208,7 @@ switch ($action) {
get_lang('DirDeleted') . ': ' . $work_to_delete['title'],
'success'
);
Session::write('message', $message);
Display::addFlash($message);
}
header('Location: '.$currentUrl);
exit;
@ -223,9 +221,9 @@ switch ($action) {
$content = generateMoveForm(
$item_id,
$curdirpath,
$course_info,
$group_id,
$session_id
$courseInfo,
$groupId,
$sessionId
);
}
}
@ -235,7 +233,7 @@ switch ($action) {
if ($is_allowed_to_edit) {
$move_to_path = get_work_path($_REQUEST['move_to_id']);
if ($move_to_path==-1) {
if ($move_to_path == -1) {
$move_to_path = '/';
} elseif (substr($move_to_path, -1, 1) != '/') {
$move_to_path = $move_to_path .'/';
@ -252,7 +250,7 @@ switch ($action) {
);
api_item_property_update(
$_course,
$courseInfo,
'work',
$_REQUEST['move_to_id'],
'FolderUpdated',
@ -286,8 +284,9 @@ switch ($action) {
null,
null,
null,
$session_id
$sessionId
);
Display::addFlash(
Display::return_message(
get_lang('VisibilityChanged'),
@ -314,7 +313,7 @@ switch ($action) {
null,
null,
null,
$session_id
$sessionId
);
Display::addFlash(
@ -357,15 +356,11 @@ switch ($action) {
Display :: display_header(null);
Display::display_introduction_section(TOOL_STUDENTPUBLICATION);
if ($origin == 'learnpath') {
if ($origin === 'learnpath') {
echo '<div style="height:15px">&nbsp;</div>';
}
display_action_links($work_id, $curdirpath, $action);
$message = Session::read('message');
echo $message;
Session::erase('message');
echo $content;
Display::display_footer();

Loading…
Cancel
Save