skala
Mallory Dessaintes 14 years ago
commit 9fc7b0a1b9
  1. 229
      main/admin/event_type.php
  2. 1
      main/admin/index.php
  3. 34
      main/inc/ajax/events.ajax.php
  4. 7
      main/inc/lib/database.lib.php
  5. 55
      main/inc/lib/events.lib.inc.php
  6. 2
      main/lang/french/admin.inc.php
  7. 10
      main/lang/french/events.inc.php

@ -0,0 +1,229 @@
<?php // $Id: course_list.php 21855 2009-07-07 18:26:10Z juliomontoya $
/* For licensing terms, see /license.txt */
/**
* This script shows a list of courses and allows searching for courses codes
* and names
* @package chamilo.admin
*/
/* INIT SECTION */
// name of the language file that needs to be included
$language_file = array('admin','events');
$cidReset = true;
require_once '../inc/global.inc.php';
$this_section = SECTION_PLATFORM_ADMIN;
api_protect_admin_script();
$action = isset($_POST['action'])?$_POST['action']:null;
$eventId = isset($_POST['eventId'])?$_POST['eventId']:null;
$eventUsers = isset($_POST['eventUsers'])?$_POST['eventUsers']:null;
$eventMessage = isset($_POST['eventMessage'])?$_POST['eventMessage']:null;
if($action == 'modEventType') {
if($eventUsers) {
$users = explode(';',$eventUsers);
}
else {
$users = array();
}
eventType_mod($eventId,$users,$eventMessage);
// echo mysql_error();
header('location: event_type.php');
exit;
}
$tool_name = get_lang('events_title');
$ajaxPath = api_get_path(WEB_CODE_PATH).'inc/ajax/events.ajax.php';
$htmlHeadXtra[] = '<script src="../inc/lib/javascript/jquery.js" type="text/javascript" language="javascript"></script>';
Display::display_header($tool_name);
?>
<script language="javascript">
var usersList;
var eventTypes;
$(document).ready(function(){
ajax({action:"getUsers"},function(data) {
usersList = data;
}
);
ajax({action:"getEventTypes"},function(data) {
eventTypes = data;
showEventTypes(data);
}
);
});
function ajax(params,func) {
$.ajax({
url: "<?php echo $ajaxPath ?>",
type: "POST",
data: params,
success: func
}
);
}
function refreshUsersList() {
removeAllOption($('#usersList'));
$.each(usersList,function(ind,item) {
addOption($('#usersList'),item.user_id,item.firstname + ' '+item.lastname);
}
);
}
function showEventTypes(data) {
$.each(data,function(ind,item) {
addOption($('#eventList'),item.id,item.name);
}
);
}
function getCurrentEventTypeInd() {
var ind = false;
$.each(eventTypes,function(i,data)
{
if(data.id == $('#eventList option:selected').first().attr('value')) {
ind = i;
return false;
}
}
)
return ind;
}
function showEventType() {
eInd = getCurrentEventTypeInd();
$('#eventId').attr('value',eventTypes[eInd].id);
$('#eventName').attr('value',eventTypes[eInd].name);
$('#eventNameTitle').text(eventTypes[eInd].name);
$('#eventMessage').text(eventTypes[eInd].message);
ajax({action:"getEventTypeUsers","id":eventTypes[eInd].id},function(data) {
removeAllOption($('#usersSubList'));
refreshUsersList();
usersIds = new Array();
$.each(data,function(ind,item) {
addOption($('#usersSubList'),item.user_id,item.firstname + ' '+item.lastname);
usersIds[ind] = item.value;
removeOption($('#usersList'),item.user_id);
});
$('#eventUsers').attr('value',usersIds.join(';'));
}
);
}
function submitForm() {
if($('#eventId')) {
usersIds = new Array();
$('#usersSubList option').each(function(ind,item)
{
usersIds[ind] = item.value;
}
);
$('#eventUsers').attr('value',usersIds.join(';'));
return true;
}
return false;
}
function addOption(select,value,text) {
select.append('<option value="'+value+'">'+text+'</option>');
}
function removeOption(select,value) {
select.find('option[value='+value+']').remove();
}
function removeAllOption(select) {
select.find('option').remove();
}
function moveUsers(src,dest) {
src.find('option:selected').each(function(index,opt) {
text = opt.text;
val = opt.value;
addOption(dest,val,text);
removeOption(src,val);
});
}
</script>
<h3><?php print get_lang('events_title') ?></h3>
<table id="" width="90%">
<tr>
<td width="5%">
<h4><?php print get_lang('events_listTitle'); ?></h4>
</td>
<td width="5%">
<h4><?php print get_lang('events_userListTile'); ?></h4>
</td>
<td width="5%">
&nbsp;
</td>
<td width="5%">
<h4><?php print get_lang('events_userSubListTile'); ?></h4>
</td>
</tr>
<tr>
<td>
<select multiple="1" id="eventList" onChange="showEventType()"></select>
</td>
<td>
<select multiple="1" id="usersList"></select>
</td>
<td valign="middle">
<button class="arrowr" onclick='moveUsers($("#usersList"),$("#usersSubList")); return false;'></button>
<br />
<button class="arrowl" onclick='moveUsers($("#usersSubList"),$("#usersList")); return false;'></button>
</td>
<td>
<select multiple="1" id="usersSubList"></select>
</td>
</tr>
</table>
<br />
<h2 id="eventNameTitle"></h2>
<form method="POST" onSubmit="return submitForm(); ">
<input type="hidden" name="action" value="modEventType" />
<input type="hidden" name="eventId" id="eventId" />
<input type="hidden" name="eventUsers" id="eventUsers" />
<input type="hidden" id="eventName" />
<textarea cols="100" rows="10" name="eventMessage" id="eventMessage">
</textarea>
<br /><br />
<input type="submit" value="<?php print get_lang('events_btnMod'); ?>" />
</form>
<?php
Display :: display_footer();
?>

@ -176,6 +176,7 @@ if(api_is_platform_admin()) {
echo '<li><a href="filler.php">'.get_lang('DataFiller').'</a></li>';
}
?>
<li><a href="event_type.php"><?php print get_lang('events_title') ?></a></li>
</ul>
</div>

@ -0,0 +1,34 @@
<?php
error_reporting(E_ERROR);
ob_start();
require_once '../global.inc.php';
require_once '../lib/usermanager.lib.php';
$id = isset($_REQUEST['id'])?$_REQUEST['id']:null;
$action = isset($_REQUEST['action'])?$_REQUEST['action']:null;
api_protect_admin_script();
ob_end_clean();
header('content-type: text/json');
if($action == 'getEventTypes') {
$events = eventType_getAll();
print json_encode($events);
}
elseif($action == 'getUsers') {
$users = UserManager::get_user_list();
print json_encode($users);
}
elseif($action == 'getEventTypeUsers') {
$users = eventType_getUsers($id);
print json_encode($users);
}

@ -110,6 +110,10 @@ define('TABLE_MAIN_LEGAL', 'legal');
// Dashboard blocks plugin
define('TABLE_MAIN_BLOCK', 'block');
define('TABLE_MAIN_EVENT_TYPE','event_type');
define('TABLE_MAIN_EVENT_TYPE_MESSAGE','event_type_message');
define('TABLE_MAIN_EVENT_TYPE_REL_USER','user_rel_event_type');
// Statistic database tables
define('TABLE_STATISTIC_TRACK_E_LASTACCESS', 'track_e_lastaccess');
define('TABLE_STATISTIC_TRACK_E_ACCESS', 'track_e_access');
@ -992,6 +996,9 @@ class Database {
echo $info;
}
}
if(mysql_error()) {
error_log($query."\n".mysql_error());
}error_log($query);
return $result;
}

@ -674,4 +674,59 @@ function event_system($event_type, $event_value_type, $event_value, $timestamp =
$res = Database::query($sql);
return true;
}
function eventType_getAll($etId) {
$etId = intval($etId);
$sql = 'SELECT * FROM '.Database::get_main_table(TABLE_MAIN_EVENT_TYPE).' et
LEFT JOIN '.Database::get_main_table(TABLE_MAIN_EVENT_TYPE_MESSAGE).' em ON em.event_type_id = et.id
WHERE em.language_id = 18
';
$eventsTypes = Database::store_result(Database::query($sql));
// echo $sql;
return $eventsTypes;
}
function eventType_getUsers($etId) {
$etId = intval($etId);
$sql = 'SELECT user.* FROM '.Database::get_main_table(TABLE_MAIN_USER).' user
JOIN '.Database::get_main_table(TABLE_MAIN_EVENT_TYPE_REL_USER).' relUser ON relUser.user_id = user.user_id
JOIN '.Database::get_main_table(TABLE_MAIN_EVENT_TYPE).' et ON relUser.event_type_id = et.id
WHERE et.id = '.$etId.'
';
$eventsTypes = Database::store_result(Database::query($sql));
return $eventsTypes;
}
function eventType_mod($etId,$users,$message) {
$etId = intval($etId);
$sql = 'DELETE FROM '.Database::get_main_table(TABLE_MAIN_EVENT_TYPE_REL_USER).'
WHERE event_type_id = '.$etId.'
';
Database::query($sql);
foreach($users as $user) {
$sql = 'INSERT INTO '.Database::get_main_table(TABLE_MAIN_EVENT_TYPE_REL_USER).'
(user_id,event_type_id)
VALUES('.intval($user).','.$etId.')
';
Database::query($sql);
}
$sql = 'UPDATE '.Database::get_main_table(TABLE_MAIN_EVENT_TYPE_MESSAGE).'
SET message = "'.Database::escape_string($message).'"
WHERE event_type_id = '.$etId.'
';
Database::query($sql);
}
?>

@ -1280,4 +1280,6 @@ $DRHPageAfterLoginTitle = "Page à montrer pour les DRH une fois authentifiés"
$DRHPageAfterLoginComment = "Laisser vide pour le comportement normal de chamilo.";
$SessionAdminPageAfterLoginTitle = "Page à montrer pour les adminsitrateurs de sessions une fois authentifiés";
$SessionAdminPageAfterLoginComment = "Laisser vide pour le comportement normal de chamilo.";
$events_title = 'Gestion des évenements';
?>

@ -0,0 +1,10 @@
<?php
$events_title = 'Gestion des évenements';
$events_listTitle = 'Liste des évenements';
$events_userListTile = 'Liste des utilisateurs';
$events_userSubListTile = 'Liste des utilisateurs inscrits';
$events_btnMod = 'Modifier l\'évenement';
?>
Loading…
Cancel
Save