Format code, use Session class, use Display::addFlash function.

1.10.x
jmontoya 9 years ago
parent a88556a10e
commit 93cae24e1d
  1. 44
      main/admin/access_urls.php
  2. 18
      main/admin/careers.php
  3. 14
      main/admin/group_list.php
  4. 17
      main/admin/skills_import.php
  5. 15
      main/admin/user_import.php
  6. 30
      main/admin/user_list.php
  7. 12
      main/admin/user_update_import.php
  8. 19
      main/course_progress/index.php
  9. 5
      main/group/group.php
  10. 2
      main/group/group_space.php
  11. 2
      main/inc/lib/career.lib.php
  12. 4
      main/inc/lib/display.lib.php

@ -6,6 +6,7 @@
* @author Julio Montoya <gugli100@gmail.com>
* @author Yannick Warnier <yannick.warnier@beeznest.com>
*/
$cidReset = true;
require_once '../inc/global.inc.php';
$this_section = SECTION_PLATFORM_ADMIN;
@ -32,8 +33,6 @@ if (isset ($_GET['action'])) {
Display :: display_normal_message(Security::remove_XSS(stripslashes($_GET['message'])));
}
$check = Security::check_token('get');
if ($check) {
$url_id = intval($_GET['url_id']);
switch ($_GET['action']) {
@ -64,19 +63,20 @@ if (isset ($_GET['action'])) {
$url_str.=$my_url['url'].' <br />';
}
}
Display :: display_normal_message(get_lang('AdminUserRegisteredToThisURL').': '.$url_str.'<br />',false);
Display:: display_normal_message(
get_lang('AdminUserRegisteredToThisURL').': '.$url_str.'<br />',
false
);
}
}
break;
}
}
Security::clear_token();
}
$parameters['sec_token'] = Security::get_token();
// checking if the admin is registered in all sites
// Checking if the admin is registered in all sites
$url_string = '';
$my_user_url_list = api_get_access_url_from_user(api_get_user_id());
foreach ($url_list as $my_url) {
@ -94,16 +94,27 @@ if ($current_access_url_id==-1) {
} elseif(api_is_platform_admin()) {
$quant= UrlManager::relation_url_user_exist(api_get_user_id(),$current_access_url_id);
if ($quant==0) {
Display :: display_warning_message('<a href="'.api_get_self().'?action=register&sec_token='.$parameters['sec_token'].'">'.get_lang('ClickToRegisterAdmin').'</a>',false);
Display:: display_warning_message(
'<a href="'.api_get_self().'?action=register&sec_token='.$parameters['sec_token'].'">'.get_lang('ClickToRegisterAdmin').'</a>',
false
);
}
}
// action menu
echo '<div class="actions">';
echo Display::url(Display::return_icon('new_link.png', get_lang('AddUrl'), array(), ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH).'admin/access_url_edit.php');
echo Display::url(Display::return_icon('user.png', get_lang('ManageUsers'), array(), ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH).'admin/access_url_edit_users_to_url.php');
echo Display::url(Display::return_icon('course.png', get_lang('ManageCourses'), array(), ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH).'admin/access_url_edit_courses_to_url.php');
//echo Display::url(Display::return_icon('session.png', get_lang('ManageSessions'), array(), ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH).'admin/access_url_edit_sessions_to_url.php');
echo Display::url(
Display::return_icon('new_link.png', get_lang('AddUrl'), array(), ICON_SIZE_MEDIUM),
api_get_path(WEB_CODE_PATH).'admin/access_url_edit.php'
);
echo Display::url(
Display::return_icon('user.png', get_lang('ManageUsers'), array(), ICON_SIZE_MEDIUM),
api_get_path(WEB_CODE_PATH).'admin/access_url_edit_users_to_url.php'
);
echo Display::url(
Display::return_icon('course.png', get_lang('ManageCourses'), array(), ICON_SIZE_MEDIUM),
api_get_path(WEB_CODE_PATH).'admin/access_url_edit_courses_to_url.php'
);
$userGroup = new UserGroup();
if ($userGroup->getUseMultipleUrl()) {
@ -122,7 +133,6 @@ if (isMultipleUrlSupport()) {
echo '</div>';
//$table = new SortableTable('urls', 'url_count_mask', 'get_url_data_mask',2);
$sortable_data = UrlManager::get_url_data();
$urls = array();
foreach ($sortable_data as $row) {
@ -144,21 +154,21 @@ foreach ($sortable_data as $row) {
if ($row['id']=='1') {
$status = Display::return_icon($image.'.gif', get_lang(ucfirst($action)));
} else {
$status = '<a href="access_urls.php?action='.$action.'&amp;url_id='.$row['id'].'&amp;sec_token='.$_SESSION['sec_token'].'">'.Display::return_icon($image.'.gif', get_lang(ucfirst($action))).'</a>';
$status = '<a href="access_urls.php?action='.$action.'&amp;url_id='.$row['id'].'">'.
Display::return_icon($image.'.gif', get_lang(ucfirst($action))).'</a>';
}
// Actions
$url_id = $row['id'];
$actions = Display::url(Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL), "access_url_edit.php?url_id=$url_id");
if ($url_id != '1') {
$actions .= '<a href="access_urls.php?action=delete_url&amp;url_id='.$url_id.'&amp;sec_token='.$_SESSION['sec_token'].'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset))."'".')) return false;">'.Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL).'</a>';
$actions .= '<a href="access_urls.php?action=delete_url&amp;url_id='.$url_id.'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset))."'".')) return false;">'.
Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL).'</a>';
}
$urls[] = array($url, $description, $status, $actions);
}
$table = new SortableTableFromArrayConfig($urls, 2, 50, 'urls');
$table->set_additional_parameters($parameters);
//$table->set_header(0, '');
$table->set_header(0, 'URL');
$table->set_header(1, get_lang('Description'));
$table->set_header(2, get_lang('Active'));

@ -1,6 +1,8 @@
<?php
/* For licensing terms, see /license.txt */
use ChamiloSession as Session;
/**
* @package chamilo.admin
*/
@ -104,10 +106,10 @@ switch ($action) {
if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
api_not_allowed();
}
$_SESSION['notebook_view'] = 'creation_date';
Session::write('notebook_view', 'creation_date');
$url = api_get_self().'?action='.Security::remove_XSS($_GET['action']);
$form = $career->returnForm($url, 'add');
$form = $career->return_form($url, 'add');
// The validation or display
if ($form->validate()) {
@ -132,7 +134,7 @@ switch ($action) {
case 'edit':
// Action handling: Editing
$url = api_get_self().'?action='.Security::remove_XSS($_GET['action']).'&id='.intval($_GET['id']);
$form = $career->returnForm($url, 'edit');
$form = $career->return_form($url, 'edit');
// The validation or display
if ($form->validate()) {
@ -144,9 +146,15 @@ switch ($action) {
if ($res) {
Display::display_confirmation_message(get_lang('CareerUpdated'));
if ($values['status'] && !$old_status) {
Display::display_confirmation_message(sprintf(get_lang('CareerXUnarchived'), $values['name']), false);
Display::display_confirmation_message(
sprintf(get_lang('CareerXUnarchived'), $values['name']),
false
);
} elseif (!$values['status'] && $old_status) {
Display::display_confirmation_message(sprintf(get_lang('CareerXArchived'), $values['name']), false);
Display::display_confirmation_message(
sprintf(get_lang('CareerXArchived'), $values['name']),
false
);
}
}
}

@ -315,18 +315,6 @@ if (isset($_GET['search']) && $_GET['search'] == 'advanced') {
$check = Security::check_token('get');
if ($check) {
switch ($_GET['action']) {
case 'show_message' :
if (!empty($_GET['warn'])) {
// to prevent too long messages
if ($_GET['warn'] == 'session_message') {
$_GET['warn'] = $_SESSION['session_message_import_users'];
}
Display::display_warning_message(urldecode($_GET['warn']), false);
}
if (!empty($_GET['message'])) {
Display :: display_confirmation_message(stripslashes($_GET['message']));
}
break;
case 'delete_group':
if (api_is_platform_admin()) {
if (GroupPortalManager :: delete($_GET['group_id'])) {
@ -340,7 +328,7 @@ if (isset($_GET['search']) && $_GET['search'] == 'advanced') {
$message = lock_unlock_user('lock', $_GET['user_id']);
Display :: display_normal_message($message);
break;
case 'unlock';
case 'unlock':
$message = lock_unlock_user('unlock', $_GET['user_id']);
Display :: display_normal_message($message);
break;

@ -7,9 +7,8 @@
* section here: http://en.wikipedia.org/wiki/Personal_knowledge_management
*/
$cidReset = true;
require '../inc/global.inc.php';
require_once '../inc/global.inc.php';
/**
* Validate the imported data.
@ -19,7 +18,6 @@ require '../inc/global.inc.php';
function validate_data($skills)
{
$errors = array();
$skills = array();
// 1. Check if mandatory fields are set.
$mandatory_fields = array('id', 'parent_id', 'name');
foreach ($skills as $index => $skill) {
@ -87,6 +85,7 @@ function parse_csv_data($file)
foreach ($skills as $index => $skill) {
$skills[$index] = $skill;
}
return $skills;
}
@ -195,7 +194,7 @@ if (!empty($_POST['formSent']) && $_FILES['import_file']['size'] !== 0) {
$error_kind_file = true;
}
// List skill id whith error.
// List skill id with error.
$skills_to_insert = $skill_id_error = array();
if (is_array($errors)) {
foreach ($errors as $my_errors) {
@ -234,19 +233,9 @@ if (!empty($_POST['formSent']) && $_FILES['import_file']['size'] !== 0) {
$warning_message .= '</ul>';
}
// if the warning message is too long then we display the warning message trough a session
if (!empty($warning_message) && api_strlen($warning_message) > 150) {
$_SESSION['session_message_import_skills'] = $warning_message;
$warning_message = 'session_message';
}
if ($error_kind_file) {
$error_message = get_lang('YouMustImportAFileAccordingToSelectedOption');
} else {
//header('Location: '.api_get_path(WEB_CODE_PATH).'admin/skills_import.php?action=show_message&warn='.urlencode($warning_message).'&message='.urlencode($see_message_import).'&sec_token='.$tok);
//exit;
}
}
Display :: display_header($tool_name);

@ -405,6 +405,7 @@ if (isset($_POST['formSent']) && $_POST['formSent'] AND
$see_message_import = get_lang('FileImported');
}
$warning_message = '';
if (count($errors) != 0) {
$warning_message = '<ul>';
foreach ($errors as $index => $error_user) {
@ -422,25 +423,21 @@ if (isset($_POST['formSent']) && $_POST['formSent'] AND
}
// if the warning message is too long then we display the warning message trough a session
Display::addFlash(Display::return_message($warning_message, 'warning', false));
$_SESSION['session_message_import_users'] = $warning_message;
$warning_message = 'session_message';
Display::addFlash(Display::return_message($see_message_import, 'confirmation', false));
if ($error_kind_file) {
$error_message = get_lang('YouMustImportAFileAccordingToSelectedOption');
Display::addFlash(Display::return_message(get_lang('YouMustImportAFileAccordingToSelectedOption'), 'error', false));
} else {
header('Location: '.api_get_path(WEB_CODE_PATH).'admin/user_list.php?action=show_message&warn='.urlencode($warning_message).'&message='.urlencode($see_message_import).'&sec_token='.$tok);
header('Location: '.api_get_path(WEB_CODE_PATH).'admin/user_list.php?sec_token='.$tok);
exit;
}
}
Display :: display_header($tool_name);
if (!empty($error_message)) {
Display::display_error_message($error_message);
}
$form = new FormValidator('user_import','post','user_import.php');
$form = new FormValidator('user_import', 'post', api_get_self());
$form->addElement('header', '', $tool_name);
$form->addElement('hidden', 'formSent');
$form->addElement('file', 'import_file', get_lang('ImportFileLocation'));

@ -2,8 +2,8 @@
/* For licensing terms, see /license.txt */
/**
@author Bart Mollet
@author Julio Montoya <gugli100@gmail.com> BeezNest 2011
* @author Bart Mollet
* @author Julio Montoya <gugli100@gmail.com> BeezNest 2011
* @package chamilo.admin
*/
@ -41,6 +41,7 @@ function load_course_list (div_course,my_user_id) {
}
});
}
function load_session_list(div_session, my_user_id) {
$.ajax({
contentType: "application/x-www-form-urlencoded",
@ -156,7 +157,8 @@ api_protect_admin_script(true);
* @param boolean $is_count Whether to count, or get data
* @return string SQL query
*/
function prepare_user_sql_query($is_count) {
function prepare_user_sql_query($is_count)
{
$sql = "";
$user_table = Database::get_main_table(TABLE_MAIN_USER);
$admin_table = Database::get_main_table(TABLE_MAIN_ADMIN);
@ -354,7 +356,8 @@ function loginUser($userId)
* Get the total number of users on the platform
* @see SortableTable#get_total_number_of_items()
*/
function get_number_of_users() {
function get_number_of_users()
{
$sql = prepare_user_sql_query(true);
$res = Database::query($sql);
@ -662,25 +665,6 @@ if (!empty($action)) {
$message = get_lang('UserAdded').' '.$user_info['firstname'].' '.$user_info['lastname'].' ('.$user_info['username'].')';
$message = Display::return_message($message, 'confirmation');
}
break;
case 'show_message' :
if (!empty($_GET['warn'])) {
// to prevent too long messages
if ($_GET['warn'] == 'session_message') {
$_GET['warn'] = $_SESSION['session_message_import_users'];
}
if (isset($_GET['warn']) && !empty($_GET['warn'])) {
$message .= Display::return_message(
Security::remove_XSS($_GET['warn']),
'warning',
false
);
}
}
if (!empty($_GET['message'])) {
$message .= Display::return_message(stripslashes($_GET['message']), 'confirmation');
}
break;
case 'delete_user':
if (api_is_platform_admin()) {

@ -406,14 +406,12 @@ if (isset($_POST['formSent']) && $_POST['formSent'] AND $_FILES['import_file']['
}
// if the warning message is too long then we display the warning message trough a session
$_SESSION['session_message_import_users'] = $warning_message;
$warning_message = 'session_message';
Display::addFlash(Display::return_message($warning_message, 'warning', false));
if ($error_kind_file) {
$error_message = get_lang('YouMustImportAFileAccordingToSelectedOption');
Display::addFlash(Display::return_message(get_lang('YouMustImportAFileAccordingToSelectedOption'), 'error', false));
} else {
header('Location: '.api_get_path(WEB_CODE_PATH).'admin/user_list.php?action=show_message&warn='.urlencode($warning_message).'&message='.urlencode($see_message_import).'&sec_token='.$tok);
header('Location: '.api_get_path(WEB_CODE_PATH).'admin/user_list.php?sec_token='.$tok);
exit;
}
@ -424,8 +422,8 @@ if (!empty($error_message)) {
Display::display_error_message($error_message);
}
$form = new FormValidator('user_update_import','post','user_update_import.php');
$form->addElement('header', '', $tool_name);
$form = new FormValidator('user_update_import', 'post', api_get_self());
$form->addElement('header', $tool_name);
$form->addElement('hidden', 'formSent');
$form->addElement('file', 'import_file', get_lang('ImportFileLocation'));

@ -1,5 +1,8 @@
<?php
/* For licensing terms, see /license.txt */
use ChamiloSession as Session;
/**
* Template (front controller in MVC pattern) used for distpaching to the controllers depend on the current action
* @author Christian Fasanando <christian1827@gmail.com>
@ -60,7 +63,7 @@ if (isset($_GET['isStudentView']) && $_GET['isStudentView'] == 'true') {
}
if ($action == 'thematic_details' || $action == 'thematic_list') {
$_SESSION['thematic_control'] = $action;
Session::write('thematic_control', $action);
}
// get thematic id
@ -181,22 +184,24 @@ function check_per_custom_date(obj) {
}
</script>';
$thematicControl = Session::read('thematic_control');
if ($action == 'thematic_list') {
$interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('ThematicControl'));
}
if ($action == 'thematic_add') {
$interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action='.$_SESSION['thematic_control'], 'name' => get_lang('ThematicControl'));
$interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action='.$thematicControl, 'name' => get_lang('ThematicControl'));
$interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('NewThematicSection'));
}
if ($action == 'thematic_edit') {
$interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action='.$_SESSION['thematic_control'], 'name' => get_lang('ThematicControl'));
$interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action='.$thematicControl, 'name' => get_lang('ThematicControl'));
$interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('EditThematicSection'));
}
if ($action == 'thematic_details') {
$interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('ThematicControl'));
}
if ($action == 'thematic_plan_list' || $action == 'thematic_plan_delete') {
$interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action='.$_SESSION['thematic_control'], 'name' => get_lang('ThematicControl'));
$interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action='.$thematicControl, 'name' => get_lang('ThematicControl'));
if (!empty($thematic_data)) {
$interbreadcrumb[] = array(
'url' => '#',
@ -205,7 +210,7 @@ if ($action == 'thematic_plan_list' || $action == 'thematic_plan_delete') {
}
}
if ($action == 'thematic_plan_add' || $action == 'thematic_plan_edit') {
$interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action='.$_SESSION['thematic_control'], 'name' => get_lang('ThematicControl'));
$interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action='.$thematicControl, 'name' => get_lang('ThematicControl'));
$interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action=thematic_plan_list&thematic_id='.$thematic_id, 'name' => get_lang('ThematicPlan').' ('.$thematic_data['title'].')');
if ($description_type >= ADD_THEMATIC_PLAN) {
$interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('NewBloc'));
@ -214,11 +219,11 @@ if ($action == 'thematic_plan_add' || $action == 'thematic_plan_edit') {
}
}
if ($action == 'thematic_advance_list' || $action == 'thematic_advance_delete') {
$interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action='.$_SESSION['thematic_control'], 'name' => get_lang('ThematicControl'));
$interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action='.$thematicControl, 'name' => get_lang('ThematicControl'));
$interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('ThematicAdvance').' ('.$thematic_data['title'].')');
}
if ($action == 'thematic_advance_add' || $action == 'thematic_advance_edit') {
$interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action='.$_SESSION['thematic_control'], 'name' => get_lang('ThematicControl'));
$interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action='.$thematicControl, 'name' => get_lang('ThematicControl'));
$interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action=thematic_advance_list&thematic_id='.$thematic_id, 'name' => get_lang('ThematicAdvance').' ('.$thematic_data['title'].')');
$interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('NewThematicAdvance'));
}

@ -1,6 +1,8 @@
<?php
/* For licensing terms, see /license.txt */
use ChamiloSession as Session;
/**
* Main page for the group module.
* This script displays the general group settings,
@ -262,4 +264,5 @@ if (api_get_setting('allow_group_categories') == 'true') {
if (!isset($_GET['origin']) || $_GET['origin'] != 'learnpath') {
Display::display_footer();
}
$_SESSION['_gid'] = 0;
Session::write('_gid', 0);

@ -269,7 +269,7 @@ if (api_is_allowed_to_edit(false, true) ||
// Link to the chat area of this group
if (api_get_course_setting('allow_open_chat_window')) {
$actions_array[] = array(
'url' => "javascript: void(0);\" onclick=\"window.open('../chat/chat.php?".api_get_cidreq()."&toolgroup=".$current_group['id']."','window_chat_group_".$_SESSION['_cid']."_".$_SESSION['_gid']."','height=380, width=625, left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no') \"",
'url' => "javascript: void(0);\" onclick=\"window.open('../chat/chat.php?".api_get_cidreq()."&toolgroup=".$current_group['id']."','window_chat_group_".api_get_course_id()."_".api_get_group_id()."','height=380, width=625, left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no') \"",
'content' => Display::return_icon('chat.png', get_lang('Chat'), array(), 32)
);
} else {

@ -96,7 +96,7 @@ class Career extends Model
* @todo the form should be auto generated
* @param string $url
* @param string $action add, edit
* @return obj form validator obj
* @return FormValidator
*/
public function return_form($url, $action)
{

@ -523,6 +523,10 @@ class Display
*/
public static function return_message($message, $type = 'normal', $filter = true)
{
if (empty($message)) {
return '';
}
if ($filter) {
$message = api_htmlentities($message, ENT_QUOTES, api_is_xml_http_request() ? 'UTF-8' : api_get_system_encoding());
}

Loading…
Cancel
Save