*/
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...
";
}
$func = new functions();
$_SESSION["rediriger"]=false;
//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."'");
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'])
{
$_SESSION["popup_suite"] = true;
$_SESSION['diff'] = $_SESSION['liste_originale'];
?>
wash($_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($_SESSION['config']['show_only_elu_in_mailing_list'] == 'true')
$where .= "AND u.ELU = 'Y' ";
$db = new dbquery();
$db->connect();
if( !isset($_GET['what_users']) && !isset($_GET['what_services']) )
$where = " AND 1=0 ";
$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'".$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));
}
$id = "";
$desc ="";
if(isset($_GET['action']) && $_GET['action'] == "add" )
{
if(can_add_copy_list())
{
if(isset($_GET['id']) && !empty($_GET['id']))
{
$id = $_GET['id'];
$find = false;
for($i=0; $i < count($_SESSION['diff']); $i++)
{
if($id == $_SESSION['diff'][$i]['UserID'])
{
$find = true;
break;
}
}
if( $find == false)
{
$conn = new dbquery();
$conn->connect();
$conn->query("SELECT u.FIRSTNAME, u.LASTNAME, u.DEPARTMENT, u.MAIL, s.SERVICE 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['diff'], array( "UserID" => $id,
"FirstName" =>$line->FIRSTNAME,
"LastName"=>$line->LASTNAME,
"Service_id"=>$line->DEPARTMENT,
"Service"=>$line->SERVICE,
"Mail"=>$line->MAIL
));
}
}
}
}
else if(isset($_GET['action']) && $_GET['action'] == "remove" )
{
$rang = $_GET['rang'];
if( can_delete_copy_list($_SESSION['user']['UserId'],$_SESSION['detail_id'],$_SESSION['diff'][$rang]['UserID']) )
{
unset( $_SESSION['diff'][$rang] );
$_SESSION['diff'] = array_values($_SESSION['diff']);
}
}
else if(isset($_GET['action']) && $_GET['action'] == "up" )
{
$rang = $_GET['rang'];
$temp = $_SESSION['diff'][$rang];
$_SESSION['diff'][$rang] = $_SESSION['diff'][$rang-1];
$_SESSION['diff'][$rang-1] = $temp;
}
else if(isset($_GET['action']) && $_GET['action'] == "down" )
{
$rang = $_GET['rang'];
$temp = $_SESSION['diff'][$rang];
$_SESSION['diff'][$rang] = $_SESSION['diff'][$rang+1];
$_SESSION['diff'][$rang+1] = $temp;
}
$func = new functions();
$time = $func->get_session_time_expire();
?>
|