388 lines
15 KiB
PHP
388 lines
15 KiB
PHP
<?php
|
|
session_start();
|
|
require_once("config.php");
|
|
require_once("include_login.php");
|
|
|
|
if(!in_array("file_manager", $conf["page_menu"][$_SESSION["gruppo"]]))
|
|
header("Location: ".$conf["homepage_user"]);
|
|
|
|
$db2 = new Cms;
|
|
|
|
$id_file_focus = (isset($_GET["focus"])) ? $_GET["focus"] : "";
|
|
|
|
if(isset($_POST["act"]) && $_POST["act"]=="adduser"){
|
|
$file_id = $db->escape($_POST["fileid"]);
|
|
$to = $db->escape($_POST["e_mail"]);
|
|
$user_code = $db->escape($_POST["user_code"]);
|
|
$full_name = $db->escape($_POST["full_name"]);
|
|
$sql = "INSERT INTO wtb_user_file_policies (id, id_file, user_code) VALUES ( ISNULL((SELECT MAX(id) FROM wtb_user_file_policies), 0)+1, $file_id, '$user_code')";
|
|
$ret["result"] = ($db->query($sql)) ? "1" : "0";
|
|
|
|
if($ret["result"]=="1" && strlen($to)>0){ // INVIO MAIL DI NOTIFICA ALL'UTENTE
|
|
|
|
$sql = "SELECT filename, note FROM wtb_file_uploads WHERE id = '$file_id'";
|
|
$db->query($sql);
|
|
if($db->next_record()){
|
|
$filename = $db->f("filename");
|
|
$note = $db->f("note");
|
|
send_newfile_notify_user($to, $full_name, $filename, $note);
|
|
}
|
|
}
|
|
echo json_encode($ret);
|
|
return;
|
|
|
|
}
|
|
else if(isset($_POST["act"]) && $_POST["act"]=="srcuser"){
|
|
$file_id = $db->escape($_POST["fileid"]);
|
|
$q = $db->escape($_POST["q"]);
|
|
$ret = "";
|
|
if(strlen(trim($q))>0){
|
|
$sql = "SELECT User_code,
|
|
ISNULL(Full_name, User_name) AS Full_name,
|
|
wtb_user_groups.User_group,
|
|
e_mail
|
|
FROM wtb_users INNER JOIN wtb_user_groups ON wtb_users.key_group = wtb_user_groups.Key_group
|
|
WHERE User_code NOT IN (SELECT user_code FROM wtb_user_file_policies WHERE id_file = $file_id) AND
|
|
(Full_name LIKE '%$q%' OR User_name LIKE '%$q%') AND
|
|
ctrl_state = 'S'";
|
|
$db->query($sql);
|
|
while($db->next_record())
|
|
$ret[] = array( "user_code" => $db->f("User_code"),
|
|
"full_name" => firstLetterUpPhrase($db->f("Full_name")),
|
|
"user_group" => strtolower(str_replace(" ", "_", $db->f("User_group"))),
|
|
"e_mail" => extract_email_from($db->f("e_mail")));
|
|
}
|
|
echo json_encode($ret);
|
|
return;
|
|
|
|
}
|
|
else if(isset($_GET["act"]) && $_GET["act"]=="delfile"){
|
|
$file_id = $db->escape($_GET["fileid"]);
|
|
$sql = "SELECT filename FROM wtb_file_uploads WHERE id = $file_id";
|
|
$db->query($sql);
|
|
if($db->next_record()){
|
|
$filename = $db->f("filename");
|
|
try{
|
|
$endPoint = $db->getEndPoint();
|
|
$wsdl_url = "http://$endPoint/axis2/services/".$db->getWsdl()."?wsdl";
|
|
$client = new SOAPClient($wsdl_url);
|
|
$params = array("filename" => $filename);
|
|
$result = $client->exportFileToServer_delete($params);
|
|
$returnId = $result->return->returnId;
|
|
if($returnId==1){
|
|
$sql = "DELETE FROM wtb_user_file_policies WHERE id_file = '$file_id';
|
|
DELETE FROM wtb_file_uploads WHERE id = '$file_id'";
|
|
if($db2->query($sql)){
|
|
header("Location: file_manager.php");
|
|
}
|
|
} else{
|
|
echo $result->return->errorText;
|
|
}
|
|
} catch (SoapFault $e){
|
|
print_r($e);
|
|
}
|
|
} else{
|
|
echo "File non trovato";
|
|
}
|
|
}
|
|
else if(isset($_GET["act"]) && $_GET["act"]=="deluser"){
|
|
$user_code = $db->escape($_GET["usercode"]);
|
|
$file_id = $db->escape($_GET["fileid"]);
|
|
|
|
$sql = "DELETE FROM wtb_user_file_policies WHERE id_file = '$file_id' AND user_code = '$user_code'";
|
|
if($db->query($sql)){
|
|
header ("Location: file_manager.php?focus=$file_id");
|
|
}
|
|
}
|
|
|
|
require_once "top_html.php";
|
|
require_once "top_menu.php";
|
|
|
|
?>
|
|
<style>
|
|
.add_user{
|
|
font-size: 10px;
|
|
}
|
|
|
|
.box_username span{
|
|
background-color: #E0EAF1;
|
|
border: 1px solid #B3CEE1;
|
|
line-height: 1.4;
|
|
padding: 3px 4px;
|
|
margin-left: 3px;
|
|
margin-right: 3px;
|
|
color: #3E6D8E;
|
|
}
|
|
#order_list tr.focus td{
|
|
background-color: #F8D650;
|
|
}
|
|
#order_list td, #order_list th{
|
|
padding: 5px;
|
|
}
|
|
|
|
.box_user{
|
|
background: none repeat scroll 0 0 #eee;
|
|
border: 1px solid #ccc;
|
|
border-radius: 2px;
|
|
color: #1C2A47;
|
|
cursor: default;
|
|
display: block;
|
|
float: left;
|
|
height: 14px;
|
|
margin: 0 4px 4px 0;
|
|
padding: 0 3px;
|
|
position: relative;
|
|
white-space: nowrap;
|
|
}
|
|
.box_user .remove{
|
|
margin: 2px 0 -2px 1px;
|
|
outline: medium none;
|
|
background-image: url("images/structure/close.png");
|
|
background-repeat: no-repeat;
|
|
height: 13px;
|
|
margin-top: 1px;
|
|
width: 13px;
|
|
cursor: pointer;
|
|
display: inline-block;
|
|
padding: 0;
|
|
white-space: nowrap;
|
|
}
|
|
.box_user .remove:hover{
|
|
background-position: left -13px
|
|
}
|
|
.box_user.new{
|
|
display: none;
|
|
}
|
|
|
|
#order_list td{
|
|
min-width: 90px;
|
|
}
|
|
|
|
.userlist{
|
|
padding:5px;
|
|
}
|
|
|
|
.src_box{
|
|
float: left;
|
|
border: 1px solid #A5ACB2;
|
|
overflow-x: hidden;
|
|
overflow-y: auto;
|
|
}
|
|
.src_box .livesearch{
|
|
border: 1px solid #A5ACB2;
|
|
margin-top:1px;
|
|
position: absolute;
|
|
}
|
|
.src_box .row_res2{
|
|
width: 146px;
|
|
color: #1C2A47;
|
|
}
|
|
.src_box .row_res2:hover{
|
|
color: #fff;
|
|
}
|
|
.src_box .cancel_ico{
|
|
visibility: hidden;
|
|
cursor: pointer;
|
|
}
|
|
.livesearch{
|
|
max-height: 150px;
|
|
overflow-y: auto;
|
|
overflow-x: hidden;
|
|
visibility: hidden;
|
|
z-index: 10;
|
|
}
|
|
|
|
<?
|
|
// ASSEGNAZIONE COLORI X TIPOLOGIE UTENTI
|
|
$sql = "SELECT User_group FROM wtb_user_groups ORDER BY 1";
|
|
$db->query($sql);
|
|
$i = 0;
|
|
while($db->next_record()){
|
|
$userGroup = strtolower(str_replace(" ", "_", $db->f("User_group")));
|
|
$color_2 = dechex(hexdec($array_color_group[$i])- border_konstant);
|
|
?>
|
|
.box_user<?=".$userGroup"?>{
|
|
background-color: <?="#".$array_color_group[$i]?>;
|
|
border: 1px solid <?="#".$color_2?>;
|
|
}
|
|
|
|
.src_box .row_res2<?=".$userGroup"?>{
|
|
background-color: <?="#".$array_color_group[$i]?>;
|
|
}
|
|
.src_box .row_res2<?=".$userGroup"?>:hover{
|
|
background-color: <?="#".$color_2?>;
|
|
}<?
|
|
$i++;
|
|
}
|
|
?>
|
|
</style>
|
|
<script>
|
|
$().ready(function(){
|
|
$(".add_user").keyup(function(){
|
|
var fileid = $(this).parent().attr("paramid");
|
|
var q = $(this).val();
|
|
var livesearch = $(".livesearch", $(this).closest(".src_box"));
|
|
var cancelico = $(".cancel_ico", $(this).closest(".src_box"));
|
|
|
|
$.post("<?=$_SERVER["PHP_SELF"]?>", {act:"srcuser", fileid:fileid, q:q}, function(data){
|
|
var json = $.parseJSON(data);
|
|
try{
|
|
$(".livesearch").html("").css("visibility","hidden"); // tutti i livesearch
|
|
$.each(json, function(i, row){
|
|
var user_code = row.user_code;
|
|
var full_name = row.full_name;
|
|
var user_group = row.user_group;
|
|
var e_mail = row.e_mail;
|
|
livesearch
|
|
.append("<div class='row_res2 "+user_group+"' paramUserCode='"+user_code+"' paramUserGroup='"+user_group+"' paramEmail='"+e_mail+"'>"+full_name+"</div>")
|
|
.css("visibility","visible");
|
|
});
|
|
cancelico.css("visibility","visible");
|
|
}
|
|
catch(e){alert(e)}
|
|
});
|
|
});
|
|
/*
|
|
$(".userlist").closest("td").click(function(){
|
|
$(".add_user", $(this).closest("td")).focus();
|
|
});*/
|
|
|
|
$(".cancel_ico").click(function(){
|
|
var inputadd = $(".add_user", $(this).closest(".src_box"));
|
|
var livesearch = $(".livesearch", $(this).closest(".src_box"));
|
|
|
|
inputadd.val("");
|
|
livesearch.html('').css("visibility","hidden");
|
|
$(this).css("visibility","hidden");
|
|
});
|
|
|
|
$(".row_res2").live("click", function(){
|
|
try{
|
|
var user_code = $(this).attr("paramUserCode");
|
|
var full_name = $(this).html();
|
|
var fileid = $(this).closest(".src_box").attr("paramid");
|
|
var user_group = $(this).attr("paramUserGroup");
|
|
var e_mail = $(this).attr("paramEmail");
|
|
var userlist = $(".userlist", $(this).closest("#row_"+fileid));
|
|
var cancelico = $(".cancel_ico", $(this).closest(".src_box"));
|
|
var input = $(".add_user", $(this).closest(".src_box"));
|
|
|
|
$.post("<?=$_SERVER["PHP_SELF"]?>", {act:"adduser", fileid:fileid, user_code:user_code, e_mail:e_mail, full_name:full_name}, function(data){
|
|
var json = $.parseJSON(data);
|
|
if(json.result=="1"){
|
|
var content = "<span class='box_user "+user_group+" new' title='File non visualizzato dall'utente'>";
|
|
content += "<img src='images/structure/message_unread.png'/> ";
|
|
content += full_name;
|
|
content += " <a class='remove' href='<?=$_SERVER["PHP_SELF"]?>?act=deluser&usercode="+user_code+"&fileid="+fileid+"' title='Escludi'></a>";
|
|
content += "</span>";
|
|
userlist.append(content);
|
|
$("span.new").fadeIn(500);
|
|
}
|
|
else
|
|
alert("Errore di inserimento");
|
|
});
|
|
$(this).closest(".livesearch").html("").css("visibility", "hidden");
|
|
cancelico.css("visibility","hidden");
|
|
|
|
input.val("").focus();
|
|
}
|
|
catch(e){alert(e)}
|
|
});
|
|
<?
|
|
if(isset($_GET["focus"])){?>
|
|
$("td","#row_<?=$_GET["focus"]?>").animate({backgroundColor: "transparent"}, 2000);
|
|
$(".add_user","#row_<?=$_GET["focus"]?>").focus();<?
|
|
}
|
|
?>
|
|
});
|
|
|
|
</script>
|
|
<div class="molliche">Gestione dei file condivisi</div>
|
|
<div id="contenuto"><?
|
|
$sql = "SELECT * FROM wtb_file_uploads ORDER BY date_create DESC";
|
|
$db->query($sql);
|
|
if($db->num_rows()>0){?>
|
|
<table id="order_list" cellpadding="2" cellspacing="0" style="width:100%" align="center">
|
|
<tr style="background:#f1f1f1;">
|
|
<th>Nome file</th>
|
|
<th>Mittente</th>
|
|
<th>Data e ora di invio</th>
|
|
<th>Note</th>
|
|
<th style="width:40%">Inviato a</th>
|
|
<th>Azioni</th>
|
|
</tr><?
|
|
|
|
$i = 0;
|
|
while($db->next_record()){
|
|
$file_id = $db->f("id");
|
|
$filetype = strtolower(pathinfo($db->f("filename"), PATHINFO_EXTENSION));
|
|
|
|
if(file_exists("images/structure/filetype_icons/$filetype.png")){
|
|
$filename = getFilename($db->f("filename"), false);
|
|
$file_ico = "images/structure/filetype_icons/$filetype.png";
|
|
}
|
|
else{
|
|
$filename = $db->f("filename");
|
|
$file_ico = "images/structure/filetype_icons/file.png";
|
|
}
|
|
?>
|
|
<tr id="row_<?=$file_id?>" class="<?if($id_file_focus==$file_id)echo "focus"?>">
|
|
<td style="word-wrap:break-word;">
|
|
<a target="_blank" href="file_getFile.php?fileid=<?=$file_id?>" title="File <?=strtoupper($filetype)?>">
|
|
<img src="<?=$file_ico?>" style="width: 16px; height: 16px"/>
|
|
</a>
|
|
<br/>
|
|
<a target="_blank" href="file_getFile.php?fileid=<?=$file_id?>" title="Apri il file"><?=cutStringMiddle($filename, 40)?></a>
|
|
</td>
|
|
<td><?=ucfirst($db->f("creator"))?></td>
|
|
<td><?=formatDatetimeGeneral($db->f("date_create"), "%d/%m/%Y %H:%M")?></td>
|
|
<td><?=$db->f("note")?></td>
|
|
<td class="tduserlist">
|
|
<div class="userlist"><?
|
|
$sql = "SELECT Full_name, wtb_user_groups.User_group, date_read, wtb_users.User_code
|
|
FROM wtb_user_file_policies, wtb_users, wtb_user_groups
|
|
WHERE wtb_user_groups.Key_group = wtb_users.key_group AND
|
|
wtb_user_file_policies.id_file = {$file_id} AND
|
|
wtb_user_file_policies.user_code = wtb_users.User_code
|
|
ORDER BY wtb_user_groups.User_group";
|
|
$db2->query($sql);
|
|
while($db2->next_record()){
|
|
if(strlen($db2->f("date_read"))==0){
|
|
$title_mess = "File non visualizzato dall'utente";
|
|
$ico = "message_unread";
|
|
}
|
|
else{
|
|
$date_read = $db2->f("date_read");
|
|
$title_mess = "Visualizzato il ".formatDateDb($date_read, "%d/%m/%Y")." alle ".formatDateDb($date_read, "%H:%M");
|
|
$ico = "message_read";
|
|
}
|
|
$user_code = $db2->f("User_code");
|
|
$userGroup = strtolower(str_replace(" ", "_", $db2->f("User_group")));
|
|
$username = firstLetterUpPhrase($db2->f("Full_name"));
|
|
?>
|
|
<span class="box_user <?=$userGroup?>" title="<?=$title_mess?>">
|
|
<img src="images/structure/<?=$ico?>.png"/> <?
|
|
echo $username;
|
|
if(strlen($db2->f("date_read"))==0){?>
|
|
<a class="remove" href="<?=$_SERVER["PHP_SELF"]."?act=deluser&usercode=$user_code&fileid=$file_id"?>" title="Escludi"></a><?
|
|
}?>
|
|
</span><?
|
|
}?>
|
|
</div>
|
|
</td>
|
|
<td style="">
|
|
<a href="<?=$_SERVER["PHP_SELF"]?>?act=delfile&fileid=<?=$file_id?>">Elimina file</a><br/><br/>
|
|
<div class="src_box c" paramid="<?=$file_id?>" >
|
|
<input class="add_user" type="text" placeholder="Aggiungi utente" /><div class="ico cancel_ico"></div>
|
|
<div class="livesearch"></div>
|
|
</div>
|
|
</td>
|
|
</tr><?
|
|
$i++;
|
|
}?>
|
|
</table><?
|
|
} else{
|
|
echo "Nessun file inviato";
|
|
} ?>
|
|
</div><?
|
|
require_once "footer.php";
|