183 lines
6.1 KiB
PHP
183 lines
6.1 KiB
PHP
<?php
|
|
|
|
|
|
use Glpi\Event;
|
|
|
|
include ('../inc/includes.php');
|
|
include ('../front/publications_fonctions.php');
|
|
|
|
Session::checkLoginUser();
|
|
|
|
if (Session::getCurrentInterface() == "helpdesk") {
|
|
Html::helpHeader("Publication", '', $_SESSION["glpiname"]);
|
|
} else {
|
|
Html::header("Publication", '', "", "");
|
|
}
|
|
|
|
echo'<link rel="stylesheet" href="'.$CFG_GLPI["root_doc"].'/css/publication.css">';
|
|
|
|
//gestion des droits
|
|
$userId = getUserIdByPublication($_GET['id']);
|
|
if($userId != $_SESSION["glpiID"] ){
|
|
Html::redirect($CFG_GLPI["root_doc"]."/front/publications.php");
|
|
}
|
|
|
|
|
|
|
|
$Publication = getPublication($_GET['id']);
|
|
$PublicationFiles = getPublicationsFiles($_GET['id']);
|
|
|
|
if($Publication != null ){
|
|
echo'
|
|
<div id="messageBar" style="display: none;">
|
|
<div style="text-align:center;position:fixed;top:50%;left:40%;">
|
|
<img src="../file_upload/loading.gif">
|
|
</div>
|
|
</div>
|
|
|
|
<div class="grid-container" id="creepublication">
|
|
<span style=" font-size: 1rem; color: #606770;font-weight: 600;display: block;text-align: center;">Modifier la publication</span>
|
|
</div>
|
|
<form class="form" method="post" action="'.$CFG_GLPI["root_doc"].'/ajax/publication.php" enctype="multipart/form-data">
|
|
|
|
<div class="grid-container" >
|
|
|
|
<div id="block">
|
|
<div class="flex-container">
|
|
<input type="hidden" name="function" value="publication">
|
|
<input type="hidden" name="action" value="update">
|
|
<input type="hidden" name="id_publication" value="'.$Publication['id_publication'].'">';
|
|
$is_arabic = preg_match('/\p{Arabic}/u', nl2br($Publication['titre']));
|
|
if($is_arabic == true ){
|
|
echo'<textarea id="titre" name="titre" style="background-color: #ffffff; direction: rtl;" placeholder="Que voulez-vous dire">'.$Publication['titre'].'</textarea>';
|
|
}else{
|
|
echo'<textarea id="titre" name="titre" style="background-color: #ffffff; " placeholder="Que voulez-vous dire">'.$Publication['titre'].'</textarea>';
|
|
}
|
|
|
|
echo' </div>
|
|
<div>
|
|
<div class="fileupload draghoverable">
|
|
<div id="fileupload_info_ticket1" class="fileupload_info">';
|
|
if(count($PublicationFiles) > 0)
|
|
foreach ($PublicationFiles as $PublicationFile) {
|
|
echo'<p id="idFile'.$PublicationFile['id_file'].'"><img src="'.$CFG_GLPI["root_doc"].'/pics/icones/jpg-dist.png"> <b>'.$PublicationFile['filename'].'</b> <span data-id-file="'.$PublicationFile['id_file'].'" class="fa fa-times-circle pointer delete"></span></p>';
|
|
}
|
|
echo' </div>
|
|
<div id="fileupload_info_ticket" class="fileupload_info"> </div>
|
|
<div id="dropdoc">
|
|
<span class="b">d茅posez votre fichier ici, ou</span><br>
|
|
<input id="fileToUpload" type="file" name="files[]" multiple="multiple" accept=".jpg, .jpeg, .png">
|
|
</div>
|
|
<div class="flex-container" style="margin-top: 5px;">
|
|
<div style ="width:50%; text-align: right;"><div id="deletePublication" class="BUTTON_BDX" style="background: #cecece;border: solid #999 1px;color: #4a4a4a;" >Supprimer</div></div>
|
|
<div style ="width:50%; text-align: left;"><div id="update" onclick="submitForm()" class="BUTTON_BDX">Enregistrer</div></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</form>';
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$root = $CFG_GLPI["root_doc"];
|
|
$fullname = $_SESSION["glpifriendlyname"];
|
|
|
|
if (Session::getCurrentInterface() == "helpdesk") {
|
|
Html::helpFooter();
|
|
} else {
|
|
Html::footer();
|
|
}
|
|
|
|
|
|
?>
|
|
<script>
|
|
|
|
var root = <?php echo json_encode($root); ?>;
|
|
var fullname =<?php echo json_encode($fullname); ?>;
|
|
|
|
|
|
|
|
|
|
//textarea detect language
|
|
function checkRTL(s){
|
|
var ltrChars = 'A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02B8\u0300-\u0590\u0800-\u1FFF'+'\u2C00-\uFB1C\uFDFE-\uFE6F\uFEFD-\uFFFF',
|
|
rtlChars = '\u0591-\u07FF\uFB1D-\uFDFD\uFE70-\uFEFC',
|
|
rtlDirCheck = new RegExp('^[^'+ltrChars+']*['+rtlChars+']');
|
|
|
|
return rtlDirCheck.test(s);
|
|
};
|
|
|
|
var input = $('#titre').on('keypress', keypress)[0];
|
|
|
|
function keypress(e){
|
|
|
|
setTimeout(function(){
|
|
var text = $('#titre').val().split(/\s/).join('');
|
|
if( text.length == 1 ){
|
|
var isRTL = checkRTL( String.fromCharCode(e.charCode) );
|
|
var dir = isRTL ? 'RTL' : 'LTR';
|
|
$('#titre').css('direction', dir);
|
|
}
|
|
},100);
|
|
}
|
|
//textarea detect language
|
|
|
|
|
|
|
|
function submitForm() {
|
|
jQuery("#update").attr("disabled","disabled");
|
|
jQuery("#update").css("border","solid #c7585c 1px");
|
|
jQuery("#messageBar").css("display","block");
|
|
$( ".form" ).submit();
|
|
};
|
|
|
|
// delete Publication
|
|
$( "#deletePublication" ).click(function() {
|
|
var t = confirm("Etes-vous s没r de vouloir supprimer cette Publication ?");
|
|
if (t == true) {
|
|
jQuery("#messageBar").css("display","block");
|
|
$.ajax({
|
|
method: "POST",
|
|
url: root+"/ajax/publication.php",
|
|
data: { "id_publication": $("input[name='id_publication']").val() ,"function" : 'publication' , "action" : 'delete'}
|
|
})
|
|
.done(function( msg ) {
|
|
window.location.replace(root+"/front/publications.php");
|
|
})
|
|
.fail(function(msg) {
|
|
jQuery("#messageBar").css("display","none");
|
|
});
|
|
}
|
|
});
|
|
|
|
|
|
$("#fileToUpload").on("change", function(e) {
|
|
|
|
var files = e.target.files,
|
|
filesLength = files.length;
|
|
$('#fileupload_info_ticket').empty();
|
|
|
|
for(var up=0 ; up < filesLength ; up++){
|
|
if(files[up].type == "image/jpeg" || files[up].type == "image/jpg" || files[up].type == "image/png" )
|
|
$('#fileupload_info_ticket').append('<p id=""><img src="'+root+'/pics/icones/jpg-dist.png" title="jpg"> <b>'+files[up].name+'</b> </p>');
|
|
}
|
|
});
|
|
|
|
|
|
$( ".delete" ).click(function() {
|
|
var idFile = $(this).attr('data-id-file');
|
|
$("#idFile"+idFile).remove( ).hide("slow",function(){
|
|
$(".fileupload.draghoverable").append('<input type="hidden" name="id_file_delete[]" value="'+idFile+'">');
|
|
});
|
|
});
|
|
|
|
|
|
|
|
</script>
|