PRinting the event mail template, fixing some jquery, adding security, still need more work see #4658
parent
ba2197b858
commit
0bc2807f73
@ -0,0 +1,91 @@ |
|||||||
|
<?php |
||||||
|
// name of the language file that needs to be included |
||||||
|
$language_file = array('admin', 'events'); |
||||||
|
$cidReset = true; |
||||||
|
|
||||||
|
require_once '../inc/global.inc.php'; |
||||||
|
|
||||||
|
//The event type is so mess that I'm giving me the freedom to try to do a "symfony controller" style |
||||||
|
class eventController { // extends Controller { |
||||||
|
public function showAction() |
||||||
|
{ |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public function newAction() |
||||||
|
{ |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public function addAction() |
||||||
|
{ |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public function listingAction() |
||||||
|
{ |
||||||
|
$event_email_template = new EventEmailTemplate(); |
||||||
|
return $event_email_template->display(); |
||||||
|
} |
||||||
|
|
||||||
|
public function deleteAction($id) { |
||||||
|
$event_email_template = new EventEmailTemplate(); |
||||||
|
return $event_email_template->delete($id); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
$event_controller = new eventController(); |
||||||
|
$action = isset($_GET['action']) ? $_GET['action'] : null; |
||||||
|
|
||||||
|
switch ($action) { |
||||||
|
case 'show': |
||||||
|
$event_controller->showAction(); |
||||||
|
break; |
||||||
|
case 'add': |
||||||
|
$event_controller->addAction(); |
||||||
|
break; |
||||||
|
case 'new': |
||||||
|
$event_controller->newAction(); |
||||||
|
break; |
||||||
|
case 'listing': |
||||||
|
$content = $event_controller->listingAction(); |
||||||
|
break; |
||||||
|
case 'delete' : |
||||||
|
$event_controller->deleteAction($_GET['id']); |
||||||
|
$content = $event_controller->listingAction(); |
||||||
|
break; |
||||||
|
} |
||||||
|
|
||||||
|
//jqgrid will use this URL to do the selects |
||||||
|
$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_event_email_template'; |
||||||
|
|
||||||
|
|
||||||
|
//The order is important you need to check the the $column variable in the model.ajax.php file |
||||||
|
$columns = array(get_lang('Subject'), get_lang('Message'), get_lang('EventTypeName'), get_lang('Language'), get_lang('Status'), get_lang('Actions')); |
||||||
|
|
||||||
|
//Column config |
||||||
|
$column_model = array( |
||||||
|
array('name'=>'subject', 'index'=>'subject', 'width'=>'80', 'align'=>'left'), |
||||||
|
array('name'=>'message', 'index'=>'message', 'width'=>'500', 'align'=>'left','sortable'=>'false'), |
||||||
|
array('name'=>'event_type_name', 'index'=>'event_type_name', 'width'=>'80', 'align'=>'left'), |
||||||
|
array('name'=>'language_id', 'index'=>'language_id', 'width'=>'80', 'align'=>'left'), |
||||||
|
array('name'=>'activated', 'index'=>'activated', 'width'=>'80', 'align'=>'left'), |
||||||
|
array('name'=>'actions', 'index'=>'actions', 'width'=>'100') |
||||||
|
); |
||||||
|
//Autowidth |
||||||
|
$extra_params['autowidth'] = 'true'; |
||||||
|
//height auto |
||||||
|
$extra_params['height'] = 'auto'; |
||||||
|
|
||||||
|
$htmlHeadXtra[] = api_get_jqgrid_js(); |
||||||
|
$htmlHeadXtra[] = '<script> |
||||||
|
$(function() { |
||||||
|
'.Display::grid_js('event_email_template', $url,$columns,$column_model,$extra_params, array(), $action_links,true).' |
||||||
|
}); |
||||||
|
</script>'; |
||||||
|
|
||||||
|
$tpl = new Template($tool_name); |
||||||
|
$tpl->assign('actions', $actions); |
||||||
|
$tpl->assign('message', $message); |
||||||
|
$tpl->assign('content', $content); |
||||||
|
$tpl->display_one_col_template(); |
||||||
@ -1,390 +1,362 @@ |
|||||||
<?php |
<?php |
||||||
|
|
||||||
// name of the language file that needs to be included |
// name of the language file that needs to be included |
||||||
$language_file = array('admin','events'); |
$language_file = array('admin', 'events'); |
||||||
$cidReset = true; |
$cidReset = true; |
||||||
|
|
||||||
require_once '../inc/global.inc.php'; |
require_once '../inc/global.inc.php'; |
||||||
require_once '../inc/conf/events.conf.php'; |
require_once '../inc/conf/events.conf.php'; |
||||||
$this_section = SECTION_PLATFORM_ADMIN; |
$this_section = SECTION_PLATFORM_ADMIN; |
||||||
|
|
||||||
api_protect_admin_script(); |
api_protect_admin_script(); |
||||||
|
|
||||||
$interbreadcrumb[] = array ('url' => 'index.php', 'name' => get_lang('PlatformAdmin')); |
$interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin')); |
||||||
$tool_name = get_lang('events_title'); |
$tool_name = get_lang('events_title'); |
||||||
|
|
||||||
$action = isset($_POST['action'])?$_POST['action']:null; |
$action = isset($_POST['action']) ? $_POST['action'] : null; |
||||||
//$eventId = isset($_POST['eventId'])?$_POST['eventId']:null; |
//$eventId = isset($_POST['eventId'])?$_POST['eventId']:null; |
||||||
$eventName = isset($_POST['eventList'])?$_POST['eventList']:null; |
$eventName = isset($_POST['eventList']) ? $_POST['eventList'] : null; |
||||||
$eventUsers = isset($_POST['eventUsers'])?$_POST['eventUsers']:null; |
$eventUsers = isset($_POST['eventUsers']) ? $_POST['eventUsers'] : null; |
||||||
$eventMessage = isset($_POST['eventMessage'])?$_POST['eventMessage']:null; |
$eventMessage = isset($_POST['eventMessage']) ? $_POST['eventMessage'] : null; |
||||||
$eventSubject = isset($_POST['eventSubject'])?$_POST['eventSubject']:null; |
$eventSubject = isset($_POST['eventSubject']) ? $_POST['eventSubject'] : null; |
||||||
$eventMessageLanguage = isset($_POST['languages'])?$_POST['languages']:null; |
$eventMessageLanguage = isset($_POST['languages']) ? $_POST['languages'] : null; |
||||||
$activated = isset($_POST['activated'])?$_POST['activated']:0; |
$activated = isset($_POST['activated']) ? $_POST['activated'] : 0; |
||||||
|
|
||||||
if($action == 'modEventType') { |
if ($action == 'modEventType') { |
||||||
if($eventUsers) { |
if ($eventUsers) { |
||||||
$users = explode(';',$eventUsers); |
$users = explode(';', $eventUsers); |
||||||
} |
} else { |
||||||
else { |
$users = array(); |
||||||
$users = array(); |
} |
||||||
} |
save_event_type_message($eventName, $users, $eventMessage, $eventSubject, $eventMessageLanguage, $activated); |
||||||
|
|
||||||
save_event_type_message($eventName,$users,$eventMessage,$eventSubject, $eventMessageLanguage, $activated); |
header('location: event_type.php'); |
||||||
|
exit; |
||||||
// echo mysql_error(); |
|
||||||
header('location: event_type.php'); |
|
||||||
exit; |
|
||||||
} |
} |
||||||
|
|
||||||
$ets = get_all_event_types(); |
$ets = get_all_event_types(); |
||||||
|
|
||||||
$languages = api_get_languages(); |
$languages = api_get_languages(); |
||||||
|
|
||||||
$ajaxPath = api_get_path(WEB_CODE_PATH).'inc/ajax/events.ajax.php'; |
$ajaxPath = api_get_path(WEB_CODE_PATH) . 'inc/ajax/events.ajax.php'; |
||||||
Display::display_header($tool_name); |
Display::display_header($tool_name); |
||||||
|
|
||||||
$key_lang = get_lang('unsaved_changes'); |
$action_array = array(array('url' =>'event_controller.php?action=listing' , 'content' => get_lang('List'))); |
||||||
|
|
||||||
|
echo Display::actions($action_array); |
||||||
|
$key_lang = get_lang('unsaved_changes'); |
||||||
$users = UserManager::get_user_list(); |
$users = UserManager::get_user_list(); |
||||||
|
|
||||||
?> |
?> |
||||||
|
|
||||||
<script language="javascript"> |
<script> |
||||||
var usersList = <?php print json_encode($users) ?>;
|
var usersList = <?php print json_encode($users) ?>;
|
||||||
var eventTypes = <?php print json_encode($ets) ?>;
|
var eventTypes = <?php print json_encode($ets) ?>;
|
||||||
var eventsConfig = <?php print json_encode($event_config) ?>;
|
var eventsConfig = <?php print json_encode($event_config) ?>;
|
||||||
var currentLanguage = <?php print json_encode(api_get_interface_language()) ?>;
|
var currentLanguage = <?php print json_encode(api_get_interface_language()) ?>;
|
||||||
var flagContentHasChanged = false; |
var flagContentHasChanged = false; |
||||||
|
var key_lang = "<?php print $key_lang ?>";
|
||||||
var key_lang = "<?php print $key_lang ?>";
|
|
||||||
|
function ajax(params,func) { |
||||||
|
$.ajax({ |
||||||
|
url: "<?php echo $ajaxPath ?>",
|
||||||
function ajax(params,func) { |
type: "POST", |
||||||
$.ajax({ |
data: params, |
||||||
url: "<?php echo $ajaxPath ?>",
|
success: func |
||||||
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 getCurrentEventTypeInd() { |
|
||||||
var ind=false; |
|
||||||
$.each(eventTypes,function(i,item) |
|
||||||
{ |
|
||||||
if(item.event_type_name == $('#eventList option:selected').first().attr('value')) { |
|
||||||
ind=i; |
|
||||||
return false; |
|
||||||
} |
|
||||||
} |
|
||||||
) |
|
||||||
|
|
||||||
return ind; |
|
||||||
} |
|
||||||
|
|
||||||
function getCurrentEventTypeName() |
|
||||||
{ |
|
||||||
var name = false; |
|
||||||
|
|
||||||
return $('#eventList option:selected').first().attr('value'); |
|
||||||
} |
} |
||||||
|
); |
||||||
function showEventType() { |
} |
||||||
cleanInput(); |
|
||||||
eInd = getCurrentEventTypeInd(); |
function refreshUsersList() { |
||||||
currentEventName = getCurrentEventTypeName(); |
removeAllOption($('#usersList')); |
||||||
|
$.each(usersList, function(ind,item) { |
||||||
$("span#activated_checkbox").css("display", "inline"); // make checkbox visible |
console.log(item.firstname); |
||||||
$('input[name=activated]').attr('checked', false); |
addOption($('#usersList'), item.user_id, item.firstname + ' '+item.lastname); |
||||||
|
}); |
||||||
|
} |
||||||
if(typeof(eventsConfig[currentEventName])!='undefined') |
|
||||||
{ |
function getCurrentEventTypeInd() { |
||||||
if(eventsConfig[currentEventName].self_sent == true) // if registration, only sent to self_user |
var ind=false; |
||||||
{ |
$.each(eventTypes,function(i,item) { |
||||||
$(".registration_case").css("display", "none"); |
if(item.event_type_name == $('#eventList option:selected').first().attr('value')) { |
||||||
} |
ind=i; |
||||||
else |
return false; |
||||||
{ |
|
||||||
$(".registration_case").css("display", "block"); |
|
||||||
} |
|
||||||
} |
|
||||||
else |
|
||||||
{ |
|
||||||
$(".registration_case").css("display", "block"); |
|
||||||
} |
} |
||||||
|
} |
||||||
|
) |
||||||
|
return ind; |
||||||
|
} |
||||||
|
|
||||||
|
function getCurrentEventTypeName() { |
||||||
|
var name = false; |
||||||
|
return $('#eventList option:selected').first().attr('value'); |
||||||
|
} |
||||||
|
|
||||||
|
function showEventType() { |
||||||
|
cleanInput(); |
||||||
|
eInd = getCurrentEventTypeInd(); |
||||||
|
currentEventName = getCurrentEventTypeName(); |
||||||
|
|
||||||
|
$("span#activated_checkbox").css("display", "inline"); // make checkbox visible |
||||||
|
$('input[name=activated]').attr('checked', false); |
||||||
|
|
||||||
|
if (typeof(eventsConfig[currentEventName])!='undefined') { |
||||||
|
// if registration, only sent to self_user |
||||||
|
if (eventsConfig[currentEventName].self_sent == true) { |
||||||
|
//hide |
||||||
|
$(".registration_case").show(); |
||||||
|
$("#usersList").attr('disabled', 'true'); |
||||||
|
$("#usersSubList").attr('disabled', 'true'); |
||||||
|
} else { |
||||||
|
$(".registration_case").show(); |
||||||
|
$("#usersList").removeAttr('disabled'); |
||||||
|
$("#usersSubList").removeAttr('disabled'); |
||||||
|
} |
||||||
|
} else { |
||||||
|
$(".registration_case").show(); |
||||||
|
$("#usersList").removeAttr('disabled'); |
||||||
|
$("#usersSubList").removeAttr('disabled'); |
||||||
|
} |
||||||
|
|
||||||
// List of events configuration |
// List of events configuration |
||||||
$('#eventName').attr('value', currentEventName); |
$('#eventName').attr('value', currentEventName); |
||||||
// $('#descLangVar').text(eventsConfig[currentEventName].desc_lang_var); |
// $('#descLangVar').text(eventsConfig[currentEventName].desc_lang_var); |
||||||
|
|
||||||
// set message and subject accoding to the current interface language |
// Set message and subject accoding to the current interface language |
||||||
$.each(eventTypes,function(key,value) |
$.each(eventTypes,function(key,value) { |
||||||
{ |
if (eventTypes[key]["event_type_name"] == currentEventName) { |
||||||
if(eventTypes[key]["event_type_name"] == currentEventName) |
$('#eventNameTitle').text(eventTypes[key]["nameLangVar"]); |
||||||
{ |
} |
||||||
$('#eventNameTitle').text(eventTypes[key]["nameLangVar"]); |
|
||||||
} |
|
||||||
|
|
||||||
if(eventTypes[key]["event_type_name"] == currentEventName && eventTypes[key]["activated"] == 1) |
if (eventTypes[key]["event_type_name"] == currentEventName && eventTypes[key]["activated"] == 1) { |
||||||
{ |
$('input[name=activated]').attr('checked', true); |
||||||
$('input[name=activated]').attr('checked', true); |
} |
||||||
} |
|
||||||
|
|
||||||
if(eventTypes[key]["event_type_name"] == currentEventName && eventTypes[key]["dokeos_folder"] == currentLanguage) |
if (eventTypes[key]["event_type_name"] == currentEventName && eventTypes[key]["dokeos_folder"] == currentLanguage) { |
||||||
{ |
$('#eventMessage').val(eventTypes[key]["message"]); |
||||||
|
$('#eventSubject').val(eventTypes[key]["subject"]); |
||||||
|
} |
||||||
|
}); |
||||||
|
|
||||||
$('#eventMessage').val(eventTypes[key]["message"]); |
// Displays the available keys for the mail template (related to an event name) |
||||||
$('#eventSubject').val(eventTypes[key]["subject"]); |
$('#keys').find('li').remove(); |
||||||
|
if(typeof(eventsConfig[currentEventName]["available_keyvars"])!='undefined') { |
||||||
|
$.each(eventsConfig[currentEventName]["available_keyvars"],function(key,value) { |
||||||
|
$('#keys').append('<li>'+key+'</li>'); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
} |
|
||||||
|
$.ajax({ |
||||||
|
url: '<?php echo $ajaxPath ?>?action=get_event_users&eventName=' +currentEventName,
|
||||||
|
dataType: 'json', |
||||||
|
success: function(data) { |
||||||
|
removeAllOption($('#usersSubList')); |
||||||
|
refreshUsersList(); |
||||||
|
usersIds = new Array(); |
||||||
|
var json = jQuery.parseJSON(data); |
||||||
|
$.each(json, 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(';')); |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
// displays the available keys for the mail template (related to an event name) |
function submitForm() { |
||||||
$('#keys').find('li').remove(); |
if($('#eventId')) { |
||||||
if(typeof(eventsConfig[currentEventName]["available_keyvars"])!='undefined') |
usersIds = new Array(); |
||||||
{ |
|
||||||
$.each(eventsConfig[currentEventName]["available_keyvars"],function(key,value) |
|
||||||
{ |
|
||||||
$('#keys').append('<li>'+key+'</li>'); |
|
||||||
}); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
ajax({action:"get_event_users", eventName:currentEventName},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); |
|
||||||
}); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
$('#usersSubList option').each(function(ind,item) { |
||||||
* Change the message of the mail according to the selected language |
usersIds[ind] = item.value; |
||||||
*/ |
|
||||||
function changeLanguage() |
|
||||||
{ |
|
||||||
cleanInput(); |
|
||||||
currentEventName = getCurrentEventTypeName(); |
|
||||||
$.each(eventTypes,function(key,value) |
|
||||||
{ |
|
||||||
if(eventTypes[key]["event_type_name"] == currentEventName && eventTypes[key]["dokeos_folder"] == $('#languages option:selected').first().attr('value')) |
|
||||||
{ |
|
||||||
$('#eventSubject').val(eventTypes[key]["subject"]); |
|
||||||
$('#eventMessage').val(eventTypes[key]["message"]); |
|
||||||
} |
|
||||||
}); |
}); |
||||||
|
|
||||||
|
$('#eventUsers').attr('value',usersIds.join(';')); |
||||||
|
return true; |
||||||
} |
} |
||||||
|
return false; |
||||||
/** |
} |
||||||
* Set flag at true if message and/or content was changed |
|
||||||
*/ |
function addOption(select,value,text) { |
||||||
function contentChanged() |
select.append('<option value="'+value+'">'+text+'</option>'); |
||||||
{ |
} |
||||||
flagContentHasChanged = true; |
|
||||||
} |
function removeOption(select,value) { |
||||||
|
select.find('option[value='+value+']').remove(); |
||||||
/** |
} |
||||||
* Asks if user want to abandon the changes he's done |
|
||||||
*/ |
function removeAllOption(select) { |
||||||
function confirmMessage(sender) |
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); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Change the message of the mail according to the selected language |
||||||
|
*/ |
||||||
|
function changeLanguage() |
||||||
|
{ |
||||||
|
cleanInput(); |
||||||
|
currentEventName = getCurrentEventTypeName(); |
||||||
|
$.each(eventTypes,function(key,value) |
||||||
{ |
{ |
||||||
if(flagContentHasChanged == true) |
if(eventTypes[key]["event_type_name"] == currentEventName && eventTypes[key]["dokeos_folder"] == $('#languages option:selected').first().attr('value')) |
||||||
{ |
{ |
||||||
if(confirm(key_lang)) |
$('#eventSubject').val(eventTypes[key]["subject"]); |
||||||
{ |
$('#eventMessage').val(eventTypes[key]["message"]); |
||||||
flagContentHasChanged = false; |
|
||||||
if(sender == "eventList") |
|
||||||
{ |
|
||||||
cleanInput(); |
|
||||||
showEventType(); |
|
||||||
} |
|
||||||
else if(sender == "languages") |
|
||||||
{ |
|
||||||
cleanInput(); |
|
||||||
changeLanguage(); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
} |
||||||
else |
}); |
||||||
{ |
|
||||||
if(sender == "eventList") |
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Set flag at true if message and/or content was changed |
||||||
|
*/ |
||||||
|
function contentChanged() |
||||||
|
{ |
||||||
|
flagContentHasChanged = true; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Asks if user want to abandon the changes he's done |
||||||
|
*/ |
||||||
|
function confirmMessage(sender) { |
||||||
|
console.log(sender); |
||||||
|
if(flagContentHasChanged == true) { |
||||||
|
if(confirm(key_lang)) { |
||||||
|
flagContentHasChanged = false; |
||||||
|
if(sender == "eventList") { |
||||||
|
cleanInput(); |
||||||
showEventType(); |
showEventType(); |
||||||
else if(sender == "languages") |
} else if(sender == "languages") { |
||||||
|
cleanInput(); |
||||||
changeLanguage(); |
changeLanguage(); |
||||||
|
} |
||||||
} |
} |
||||||
|
} else { |
||||||
|
if(sender == "eventList") |
||||||
|
showEventType(); |
||||||
|
else if(sender == "languages") |
||||||
|
changeLanguage(); |
||||||
} |
} |
||||||
|
} |
||||||
/** |
|
||||||
* Empty the input and the textarea |
/** |
||||||
*/ |
* Empty the input and the textarea |
||||||
function cleanInput() |
*/ |
||||||
{ |
function cleanInput() |
||||||
$('#eventMessage').val(""); |
{ |
||||||
$('#eventSubject').val(""); |
$('#eventMessage').val(""); |
||||||
} |
$('#eventSubject').val(""); |
||||||
|
} |
||||||
</script> |
</script> |
||||||
|
<div class="page-header"> |
||||||
<h3><?php print get_lang('events_title') ?></h3>
|
<h2><?php print get_lang('events_title') ?></h2>
|
||||||
|
</div> |
||||||
<form method="POST" onSubmit="return submitForm(); "> |
<form method="POST" onSubmit="return submitForm(); "> |
||||||
|
<table id="" width="90%"> |
||||||
<table id="" width="90%"> |
<tr> |
||||||
<tr> |
<td width="5%"> |
||||||
<td width="5%"> |
<h4><?php print get_lang('events_listTitle'); ?></h4>
|
||||||
<h4><?php print get_lang('events_listTitle'); ?></h4>
|
</td> |
||||||
</td> |
<td width="5%"> |
||||||
<td width="5%"> |
<h4><?php print get_lang('events_userListTile'); ?></h4>
|
||||||
<h4><?php print get_lang('events_userListTile'); ?></h4>
|
</td> |
||||||
</td> |
<td width="5%"> |
||||||
<td width="5%"> |
|
||||||
|
</td> |
||||||
</td> |
<td width="5%"> |
||||||
<td width="5%"> |
<h4><?php print get_lang('events_userSubListTile'); ?></h4>
|
||||||
<h4><?php print get_lang('events_userSubListTile'); ?></h4>
|
</td> |
||||||
</td> |
</tr> |
||||||
</tr> |
<tr> |
||||||
<tr> |
<td> |
||||||
<td> |
<select multiple="1" id="eventList" onchange="confirmMessage(this.name); return false;" name="eventList"> |
||||||
<select multiple="1" id="eventList" onchange="confirmMessage(this.name); return false;" name="eventList"> |
<?php |
||||||
<?php |
foreach ($event_config as $key => $config) { |
||||||
|
print '<option value="' . $key . '">' . get_lang($config['name_lang_var']) . '</option>'; |
||||||
foreach($event_config as $key => $config) { |
} |
||||||
print '<option value="'.$key.'">'.get_lang($config['name_lang_var']).'</option>'; |
?> |
||||||
} |
</select> |
||||||
|
</td> |
||||||
?> |
<td> |
||||||
</select> |
<select multiple="1" id="usersList" class="registration_case"></select> |
||||||
</td> |
</td> |
||||||
<td> |
<td valign="middle" class="registration_case"> |
||||||
<select multiple="1" id="usersList" class="registration_case"></select> |
<button class="arrowr" onclick='moveUsers($("#usersList"),$("#usersSubList")); return false;'></button> |
||||||
</td> |
<br /> |
||||||
<td valign="middle" class="registration_case"> |
<br /> |
||||||
<button class="arrowr" onclick='moveUsers($("#usersList"),$("#usersSubList")); return false;'></button> |
<button class="arrowl" onclick='moveUsers($("#usersSubList"),$("#usersList")); return false;'></button> |
||||||
<br /> |
</td> |
||||||
<button class="arrowl" onclick='moveUsers($("#usersSubList"),$("#usersList")); return false;'></button> |
<td> |
||||||
</td> |
<select multiple="1" id="usersSubList" class="registration_case"></select> |
||||||
<td> |
</td> |
||||||
<select multiple="1" id="usersSubList" class="registration_case"></select> |
</tr> |
||||||
</td> |
</table> |
||||||
</tr> |
|
||||||
</table> |
|
||||||
<br /> |
<br /> |
||||||
<span id="activated_checkbox"><label for="activated" style="display:inline;"><?php print get_lang('checkbox_activated'); ?></label><input type="checkbox" name="activated" value="1" /></span>
|
|
||||||
<br /> |
<span id="activated_checkbox"> |
||||||
|
<label for="activated" style="display:inline;"><?php print get_lang('checkbox_activated'); ?></label>
|
||||||
|
<input type="checkbox" name="activated" value="1" /> |
||||||
|
</span> |
||||||
|
|
||||||
|
<br /> |
||||||
|
<h2 id="eventNameTitle"></h2> |
||||||
|
|
||||||
<h2 id="eventNameTitle"></h2> |
<select id="languages" name="languages" style="margin-top:20px;" onclick='confirmMessage(this.name); return false;'> |
||||||
|
<?php foreach ($languages["name"] as $key => $value) { |
||||||
|
$english_name = $languages['folder'][$key]; ?> |
||||||
|
<option value="<?php echo $english_name; ?>" <?php echo ($english_name == api_get_interface_language()) ? "selected=selected" : ""; ?>><?php echo $value; ?></option>
|
||||||
|
<?php } ?> |
||||||
|
</select> |
||||||
|
|
||||||
|
<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" /> |
||||||
|
|
||||||
|
<br /> |
||||||
|
<!-- <div id="descLangVar"> |
||||||
|
</div>--> |
||||||
|
<br /> |
||||||
|
|
||||||
<select id="languages" name="languages" style="margin-top:20px;" onclick='confirmMessage(this.name); return false;'> |
<label for="eventSubject"> |
||||||
<?php foreach($languages["name"] as $key => $value){ $english_name = $languages['folder'][$key]; ?> |
<h4><?php print get_lang('events_labelSubject'); ?></h4>
|
||||||
<option value="<?php echo $english_name; ?>" <?php echo ($english_name == api_get_interface_language()) ? "selected=selected" : ""; ?>><?php echo $value; ?></option>
|
</label> |
||||||
<?php } ?> |
<input class="span6" type="text" id="eventSubject" name="eventSubject" onchange="contentChanged(); return false;" /> |
||||||
</select> |
<br /><br /> |
||||||
|
<table> |
||||||
<input type="hidden" name="action" value="modEventType" /> |
<tr> |
||||||
<input type="hidden" name="eventId" id="eventId" /> |
<td> |
||||||
<input type="hidden" name="eventUsers" id="eventUsers" /> |
<label for="eventMessage"><h4><?php print get_lang('events_labelMessage'); ?></h4></label>
|
||||||
<input type="hidden" id="eventName" /> |
</td> |
||||||
|
<td class="available_keys" style="padding-left: 30px;"> |
||||||
<br /> |
<h4><?php print get_lang('availables_keys'); ?></h4>
|
||||||
|
</td> |
||||||
<!-- <div id="descLangVar"> |
</tr> |
||||||
</div>--> |
<tr> |
||||||
<br /> |
<td> |
||||||
|
<textarea class="span6" rows="10" name="eventMessage" id="eventMessage" onchange="contentChanged(); return false;"> |
||||||
<label for="eventSubject"><h4><?php print get_lang('events_labelSubject'); ?></h4></label>
|
</textarea> |
||||||
<input type="text" id="eventSubject" name="eventSubject" onchange="contentChanged(); return false;" /> |
</td> |
||||||
<br /><br /> |
<td class="available_keys"> |
||||||
<table> |
<div id="keys" style="padding-left: 50px;"><ul></ul></div> |
||||||
<tr> |
</td> |
||||||
<td> |
</tr> |
||||||
<label for="eventMessage"><h4><?php print get_lang('events_labelMessage'); ?></h4></label>
|
</table> |
||||||
</td> |
|
||||||
<td class="available_keys" style="padding-left: 30px;"> |
<br /><br /> |
||||||
<h4><?php print get_lang('availables_keys'); ?></h4>
|
|
||||||
</td> |
<input type="submit" value="<?php print get_lang('events_btnMod'); ?>" />
|
||||||
</tr> |
|
||||||
<tr> |
|
||||||
<td> |
|
||||||
<textarea cols="100" rows="10" name="eventMessage" id="eventMessage" onchange="contentChanged(); return false;"></textarea> |
|
||||||
</td> |
|
||||||
<td class="available_keys"> |
|
||||||
<div id="keys" style="padding-left: 50px;"><ul></ul></div> |
|
||||||
</td> |
|
||||||
</tr> |
|
||||||
</table> |
|
||||||
|
|
||||||
<br /><br /> |
|
||||||
|
|
||||||
<input type="submit" value="<?php print get_lang('events_btnMod'); ?>" />
|
|
||||||
|
|
||||||
</form> |
</form> |
||||||
|
|
||||||
|
|
||||||
<?php |
<?php |
||||||
|
Display :: display_footer(); |
||||||
Display :: display_footer(); |
|
||||||
|
|
||||||
?> |
|
||||||
@ -0,0 +1,121 @@ |
|||||||
|
<?php |
||||||
|
/* For licensing terms, see /license.txt */ |
||||||
|
/** |
||||||
|
* This class provides methods for the notebook management. |
||||||
|
* Include/require it in your code to use its features. |
||||||
|
* @package chamilo.library |
||||||
|
*/ |
||||||
|
/** |
||||||
|
* Code |
||||||
|
*/ |
||||||
|
define ('EVENT_EMAIL_TEMPLATE_ACTIVE', 1); |
||||||
|
define ('EVENT_EMAIL_TEMPLATE_INACTIVE',0); |
||||||
|
|
||||||
|
/** |
||||||
|
* @package chamilo.library |
||||||
|
*/ |
||||||
|
class EventEmailTemplate extends Model { |
||||||
|
|
||||||
|
var $table; |
||||||
|
var $columns = array('id', 'message','subject','event_type_name','activated'); |
||||||
|
|
||||||
|
public function __construct() { |
||||||
|
$this->table = Database::get_main_table(TABLE_EVENT_EMAIL_TEMPLATE); |
||||||
|
} |
||||||
|
|
||||||
|
public function get_all($where_conditions = array()) { |
||||||
|
return Database::select('*',$this->table, array('where'=>$where_conditions,'order' =>'name ASC')); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* Displays the title + grid |
||||||
|
*/ |
||||||
|
public function display() { |
||||||
|
// action links |
||||||
|
$content = Display::actions(array(array('url' => 'event_type.php' , 'content' => get_lang('Add')))); |
||||||
|
$content .= Display::grid_html('event_email_template'); |
||||||
|
return $content; |
||||||
|
} |
||||||
|
|
||||||
|
public function get_status_list() { |
||||||
|
return array(EVENT_EMAIL_TEMPLATE_ACTIVE => get_lang('Enable'), EVENT_EMAIL_TEMPLATE_INACTIVE=> get_lang('Disable')); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Returns a Form validator Obj |
||||||
|
* @todo the form should be auto generated |
||||||
|
* @param string url |
||||||
|
* @param string action add, edit |
||||||
|
* @return obj form validator obj |
||||||
|
*/ |
||||||
|
public function return_form($url, $action) { |
||||||
|
|
||||||
|
$oFCKeditor = new FCKeditor('description') ; |
||||||
|
$oFCKeditor->ToolbarSet = 'careers'; |
||||||
|
$oFCKeditor->Width = '100%'; |
||||||
|
$oFCKeditor->Height = '200'; |
||||||
|
$oFCKeditor->Value = ''; |
||||||
|
$oFCKeditor->CreateHtml(); |
||||||
|
|
||||||
|
$form = new FormValidator('career', 'post', $url); |
||||||
|
// Settting the form elements |
||||||
|
$header = get_lang('Add'); |
||||||
|
if ($action == 'edit') { |
||||||
|
$header = get_lang('Modify'); |
||||||
|
} |
||||||
|
|
||||||
|
$form->addElement('header', $header); |
||||||
|
$id = isset($_GET['id']) ? intval($_GET['id']) : ''; |
||||||
|
$form->addElement('hidden', 'id', $id); |
||||||
|
|
||||||
|
$form->addElement('text', 'name', get_lang('Name'), array('size' => '70')); |
||||||
|
$form->add_html_editor('description', get_lang('Description'), false, false, array('ToolbarSet' => 'careers','Width' => '100%', 'Height' => '250')); |
||||||
|
$status_list = $this->get_status_list(); |
||||||
|
$form->addElement('select', 'status', get_lang('Status'), $status_list); |
||||||
|
if ($action == 'edit') { |
||||||
|
$form->addElement('text', 'created_at', get_lang('CreatedAt')); |
||||||
|
$form->freeze('created_at'); |
||||||
|
} |
||||||
|
|
||||||
|
if ($action == 'edit') { |
||||||
|
$form->addElement('style_submit_button', 'submit', get_lang('Modify'), 'class="save"'); |
||||||
|
} else { |
||||||
|
$form->addElement('style_submit_button', 'submit', get_lang('Add'), 'class="save"'); |
||||||
|
} |
||||||
|
|
||||||
|
// Setting the defaults |
||||||
|
$defaults = $this->get($id); |
||||||
|
|
||||||
|
if (!empty($defaults['created_at'])) { |
||||||
|
$defaults['created_at'] = api_convert_and_format_date($defaults['created_at']); |
||||||
|
} |
||||||
|
if (!empty($defaults['updated_at'])) { |
||||||
|
$defaults['updated_at'] = api_convert_and_format_date($defaults['updated_at']); |
||||||
|
} |
||||||
|
$form->setDefaults($defaults); |
||||||
|
|
||||||
|
// Setting the rules |
||||||
|
$form->addRule('name', get_lang('ThisFieldIsRequired'), 'required'); |
||||||
|
return $form; |
||||||
|
} |
||||||
|
|
||||||
|
public function get_count() { |
||||||
|
$row = Database::select('count(*) as count', $this->table, array(),'first'); |
||||||
|
return $row['count']; |
||||||
|
} |
||||||
|
|
||||||
|
/* |
||||||
|
public function save($params) { |
||||||
|
$id = parent::save($params); |
||||||
|
if (!empty($id)) { |
||||||
|
event_system(LOG_CAREER_CREATE, LOG_CAREER_ID, $id, api_get_utc_datetime(), api_get_user_id()); |
||||||
|
} |
||||||
|
return $id; |
||||||
|
} |
||||||
|
|
||||||
|
public function delete($id) { |
||||||
|
parent::delete($id); |
||||||
|
event_system(LOG_CAREER_DELETE, LOG_CAREER_ID, $id, api_get_utc_datetime(), api_get_user_id()); |
||||||
|
} */ |
||||||
|
} |
||||||
Loading…
Reference in new issue