*/
include("session.php");
require_once("class_functions.php");
require_once("class_db.php");
if(file_exists($_SESSION['config']['lang'].'.php'))
{
include($_SESSION['config']['lang'].'.php');
}
else
{
$_SESSION['error'] = "Language file missing...
";
}
$funct= new functions();
$res_id = $_SESSION['courrier']['res_id'];
$func = new functions();
$_SESSION["rediriger"]=false;
if( count($_GET) == 0 && count($_POST) == 0)
{
//Load the original listinstance
$_SESSION['new_diff'] = array();
$_SESSION['new_diff'] = $_SESSION['diff'];
}
//Can delete copy in listinstance
function can_delete_copy_list($this_user_id,$res_id = null,$user_id)
{
if($_SESSION['user']['delete_copy_rights'] == 'true')
{
return true;
}
else if( $res_id == null )
{
return true;
}
else
{
$con = new dbquery();
$con->connect();
$con->query("SELECT BY_USER_ID
FROM ".$_SESSION['tablename']['listinstance']."
WHERE res_id = ".$res_id." AND user_id = '".$user_id."'
AND SEQUENCE > 1");
if($result = $con->fetch_object())
{
if($result->BY_USER_ID == $this_user_id || $result->BY_USER_ID == "" )
return true;
else
return false;
}
else
return true;
}
}
//Can modify copy list
function can_add_copy_list()
{
return ($_SESSION['config']['modifycopylist'] == 'true');
}
if($_GET['cancel'])
{
?>
0)
{
$user_access = "and department in (";
for($t=0; $twash($_GET['what_users'], "no", "", "no"));
$where .= " AND (u.LASTNAME like '%".strtolower($what_users)."%'
OR u.LASTNAME like '%".strtoupper($what_users)."%'
OR u.FIRSTNAME like '%".strtolower($what_users)."%'
OR u.FIRSTNAME like '%".strtoupper($what_users)."%') ";
$orderby = " ORDER BY u.LASTNAME asc, u.FIRSTNAME asc,s.SERVICE asc";
}
if(isset($_GET['what_services']) && !empty($_GET['what_services']) )
{
$what_services = addslashes($func->wash($_GET['what_services'], "no", "", "no"));
$where .= " AND (s.SERVICE like '%".strtolower($what_services)."%'
OR s.SERVICE like '%".strtoupper($what_services)."%')";
$orderby = " ORDER BY s.SERVICE asc, u.LASTNAME asc, u.FIRSTNAME asc";
}
if(!empty($where))
{
if($_SESSION['config']['show_only_elu_in_mailing_list'] == 'true')
$where .= "AND u.ELU = 'Y' ";
$db = new dbquery();
$db->connect();
$db->query("select u.USER_ID, u.FIRSTNAME, u.LASTNAME, u.DEPARTMENT, u.MAIL, s.SERVICE
FROM ".$_SESSION['tablename']['users']." u, ".$_SESSION['tablename']['services']." s
WHERE u.DEPARTMENT = s.ID and STATUS <> 'DEL' AND u.ENABLED = 'Y' ".$user_access." ".$where.$orderby);
//$db->show();
//$i=0;
while($line = $db->fetch_object())
{
array_push($users, array("ID" => $line->USER_ID, "PRENOM" => $line->FIRSTNAME, "NOM" => $line->LASTNAME, "DEP_ID" => $line->DEPARTMENT, "MAIL" => $line->MAIL, "DEP" =>$line->SERVICE));
}
}
else
$users = array();
$id = "";
$desc ="";
//print_r($users);
if(isset($_GET['action']) && $_GET['action'] == "add" )
{
if(can_add_copy_list())
{
if(isset($_GET['id']) && !empty($_GET['id']))
{
$id = $_GET['id'];
$find = false;
//Check if the "new" user is not in the copy_diff_list
for($i=0;$iconnect();
$conn->query("SELECT u.firstname, u.lastname, u.department, u.mail, s.id from ".$_SESSION['tablename']['users']." u, ".$_SESSION['tablename']['services']." s WHERE s.id = u.department and user_id='".$id."'");
$line = $conn->fetch_object();
array_push($_SESSION['new_diff'], array("UserID" => $id,
"FirstName" =>$line->firstname,
"LastName"=>$line->lastname,
"Service"=>$line->id,
"Mail"=>$line->mail
));
}
}
}
}
else if(isset($_GET['action']) && $_GET['action'] == "remove" )
{
$rang = $_GET['rang'];
if( can_delete_copy_list($_SESSION['user']['UserId'],$_SESSION['courrier']['res_id'],$_SESSION['new_diff'][$rang]['UserID']) )
{
unset( $_SESSION['new_diff'][$rang] );
$_SESSION['new_diff'] = array_values($_SESSION['new_diff']);
}
}
$func = new functions();
$time = $func->get_session_time_expire();
?>