Newer
Older
*
* Pop up used to create and modify diffusion lists instances
*
* @version 1.0
* @license GPL
* @author Claire Figueras <dev@maarch.org>
* @author Cyril Vazquez <dev@maarch.org>
require_once 'core/class/usergroups_controler.php';
require_once 'modules/entities/class/class_manage_listdiff.php';
require_once 'modules/entities/entities_tables.php';
require_once 'core/core_tables.php';
$core_tools = new core_tools();
$core_tools->load_lang();

Cyril Vazquez
committed
$difflist = new diffusion_list();
$usergroups_controler = new usergroups_controler();
// *****************************************************************************
// Manage request paramaters
// *****************************************************************************
// Origin
$origin = $_REQUEST['origin'];
// Action ?
$action = $_GET['action'];
$action = false;
// Id ?
$id = $_GET['id'];
$id = false;

Alex ORLUC
committed
// Category ?

Alex ORLUC
committed
$cat = $_GET['cat'];

Alex ORLUC
committed
$cat = false;

Alex ORLUC
committed
// Rank for remove/move ?
$rank = $_GET['rank'];
$rank = false;
// Mode (dest/copy or custom copy mode)
if (isset($_GET['role']) && !empty($_GET['role'])) {
$role_id = $_GET['role'];
$role_id = false;
$specific_role = $_GET['specific_role'];
$specific_role = false;
}
// *****************************************************************************
// Manage SESSION paramaters
// *****************************************************************************
/// Object/list type
//$objectType = $_SESSION[$origin]['diff_list']['difflist_type'];
$difflistType = $difflist->get_difflist_type($objectType);
$roles = $difflist->get_difflist_type_roles($difflistType);
$available_roles = $difflist->list_difflist_roles();
if ($difflistType->allow_entities == 'Y') {
$allow_entities = true;
$allow_entities = false;
if ($difflistType == '') {
$roles = array();
$difflistType = $difflist->get_difflist_type('entity_id');
$roles = $difflist->get_difflist_type_roles($difflistType);
$allow_entities = true;

Florian Azizian
committed
}
// Dest user
if (isset($_SESSION[$origin]['diff_list']['dest']['users'][0])
&& !empty($_SESSION[$origin]['diff_list']['dest']['users'][0])) {
$dest_is_set = true;
$dest_is_set = false;
// 1.4 create indexed array of existing diffusion to search for users/entities easily
$user_roles = array();
$entity_roles = array();
foreach ($roles as $role_id_local => $role_label) {
if (!empty($_SESSION[$origin]['diff_list'][$role_id_local]['users'])) {
for ($i = 0, $l = count($_SESSION[$origin]['diff_list'][$role_id_local]['users']); $i < $l; ++$i) {
$user_id = $_SESSION[$origin]['diff_list'][$role_id_local]['users'][$i]['user_id'];
$user_roles[$user_id][] = $role_id_local;
}
if (!empty($_SESSION[$origin]['diff_list'][$role_id_local]['entities'])) {
for ($i = 0, $l = count($_SESSION[$origin]['diff_list'][$role_id_local]['entities']); $i < $l; ++$i) {
$entity_id = $_SESSION[$origin]['diff_list'][$role_id_local]['entities'][$i]['entity_id'];
$entity_roles[$entity_id][] = $role_id_local;
}
}
// *****************************************************************************
// Search functions / filter users and entities avilable for list composition
// *****************************************************************************
if (isset($_POST['what_users']) && !empty($_POST['what_users'])) {
$_GET['what_users'] = $_POST['what_users'];
if (isset($_POST['what_services']) && !empty($_POST['what_services'])) {
$_GET['what_services'] = $_POST['what_services'];
// by default, if difflist for entities, load users and entity of the selectionned entity
if ($_GET['what_services'] == '' && $_GET['what_users'] == '') {
if ($_SESSION[$origin]['difflist_object']['object_label'] != null) {
$_GET['what_services'] = $_SESSION[$origin]['difflist_object']['object_label'];
$_SESSION['user']['primaryentity']['id'];
$_GET['what_services'] = $_SESSION['user']['primaryentity']['id'];
foreach ($_SESSION['user']['entities'] as $key => $value) {
if ($_SESSION['user']['entities'][$key]['ENTITY_ID'] == $_SESSION['user']['primaryentity']['id']) {
$primaryEntityLabel = $_SESSION['user']['entities'][$key]['ENTITY_LABEL'];
$_GET['what_services'] = $primaryEntityLabel;
if (isset($_REQUEST['no_filter'])) {
$_GET['what_users'] = '%';
$_GET['what_services'] = '%';
}
$whereUsers = '';
$whereEntities = '';
$orderByUsers = '';
$orderByEntities = '';
$whereEntitiesUsers = '';
$whatUsers = '';
$whatServices = '';
$onlyCc = false;

Cyril Vazquez
committed
$redirect_groupbasket = false;
if (isset($_SESSION['current_basket']) && count($_SESSION['current_basket']) > 0) {
if (is_array($_SESSION['user']['redirect_groupbasket_by_group'][$_SESSION['current_basket']['id']][$_SESSION['current_basket']['group_id']])) {
$redirect_groupbasket = current($_SESSION['user']['redirect_groupbasket_by_group'][$_SESSION['current_basket']['id']][$_SESSION['current_basket']['group_id']]);
if (empty($redirect_groupbasket['entities'])) {
$redirect_groupbasket['entities'] = '';
//$redirect_groupbasket['entities'] = $db->empty_list();
}
if (empty($redirect_groupbasket['users_entities'])) {
$redirect_groupbasket['users_entities'] = '';
//$redirect_groupbasket['users_entities'] = $db->empty_list();
}

Cyril Vazquez
committed
}
if (isset($_REQUEST['no_delete'])) {
$noDelete = true;
}
if (isset($_GET['what_users'])
&& !empty($_GET['what_users'])
$what_users = $func->wash($_GET['what_users'], 'no', '', 'no');
$user_expr =
' and ( '
.'lower(u.lastname) like lower(:whatUser) '
.' or lower(u.firstname) like lower(:whatUser) '
.' or lower(u.user_id) like lower(:whatUser)'
.')';
$PDOarray = array_merge($PDOarray, array(':whatUser' => '%'.$what_users.'%'));
if (isset($_GET['what_services'])
&& !empty($_GET['what_services'])
) {
$what_services = addslashes(
functions::wash($_GET['what_services'], 'no', '', 'no')
$entity_expr =
' and ('
.' lower(e.entity_label) like lower(:whatEntity) '
.' or lower(e.entity_id) like lower(:whatEntity)'
.')';
$PDOarray = array_merge($PDOarray, array(':whatEntity' => '%'.$what_services.'%'));
"select u.user_id, u.firstname, u.lastname, e.entity_id, e.entity_label "
. "FROM " . $_SESSION['tablename']['users'] . " u, " . ENT_ENTITIES . " e, "
. ENT_USERS_ENTITIES . " ue WHERE u.status <> 'DEL' and u.enabled = 'Y' and"
. " e.entity_id = ue.entity_id and u.user_id = ue.user_id and"
. " e.enabled = 'Y' and ue.primary_entity='Y' " . $user_expr . $entity_expr
. " order by u.lastname asc, u.firstname asc, u.user_id asc, e.entity_label asc limit 50";*/
$where = "u.status <> 'DEL' and u.status != 'SPD' and"
.' e.entity_id = ue.entity_id and u.user_id = ue.user_id and'
." e.enabled = 'Y' and ue.primary_entity='Y' ".$user_expr.$entity_expr;
$order = 'order by u.lastname asc, u.firstname asc, u.user_id asc, e.entity_label asc';
0,
50,
'u.user_id, u.firstname, u.lastname, e.entity_id, e.entity_label',
$_SESSION['tablename']['users'].' u, '.ENT_ENTITIES.' e, '.ENT_USERS_ENTITIES.' ue',
$where,
'',
'',
if ($user_expr == '' && $entity_expr == '') {
//no query
} else {
$stmt = $db->query($users_query, $PDOarray);
'ID' => functions::show_string($line->user_id),
'PRENOM' => functions::show_string($line->firstname),
'NOM' => functions::show_string($line->lastname),
'DEP_ID' => functions::show_string($line->entity_id),
'DEP' => functions::show_string($line->entity_label),
'select e.entity_id, e.entity_label FROM '
.$_SESSION['tablename']['users'].' u, '.ENT_ENTITIES.' e, '
.ENT_USERS_ENTITIES." ue WHERE u.status <> 'DEL' and u.enabled = 'Y'"
.'and e.entity_id = ue.entity_id and u.user_id = ue.user_id and '
."e.enabled = 'Y' ".$user_expr.$entity_expr
.' group by e.entity_id, e.entity_label order by e.entity_label asc limit 50';
$where = "u.status <> 'DEL' and u.status != 'SPD'".'and e.entity_id = ue.entity_id and u.user_id = ue.user_id and '
."e.enabled = 'Y' ".$user_expr.$entity_expr;
$order = 'ORDER by entity_label ASC';
0,
50,
'e.entity_id, e.entity_label',
$_SESSION['tablename']['users'].' u, '.ENT_ENTITIES.' e, '.ENT_USERS_ENTITIES.' ue',
'group by e.entity_id, e.entity_label',
if ($user_expr == '' && $entity_expr == '') {
//no query
} else {
$stmt = $db->query($entity_query, $PDOarray);
'ID' => functions::show_string($line->entity_id),
'DEP' => functions::show_string($line->entity_label),
//****************************************************************************************
// RELOAD PARENT ID VALIDATION OF LIST
//****************************************************************************************
//****************************************************************************************
// SWITCH ON ACTION REQUEST
//****************************************************************************************
switch ($action) {
// ADDS
//***************************************************************************************
// Add USER AS dest/copy/custom mode
'SELECT u.firstname, u.lastname, e.entity_id, e.entity_label '
.' FROM '.USERS_TABLE.' u '
.' LEFT JOIN '.ENT_USERS_ENTITIES.' ue ON u.user_id = ue.user_id '
.' LEFT JOIN '.ENT_ENTITIES.' e ON ue.entity_id = e.entity_id'
." WHERE u.user_id= ? and ue.primary_entity = 'Y'",
array($id)
$visible = 'Y';
if (!isset($_SESSION[$origin]['diff_list'][$role_id]['users'])) {
$_SESSION[$origin]['diff_list'][$role_id]['users'] = array();
if ($lastUser = end($_SESSION[$origin]['diff_list'][$role_id]['users'])) {
$visible = $lastUser['visible'];
// If dest is set && role is dest, move current dest to copy (legacy)
if ($role_id == 'dest' && $dest_is_set) {
if (!isset($_SESSION[$origin]['diff_list']['copy']['users'])) {
$_SESSION[$origin]['diff_list']['copy']['users'] = array();
$old_dest = $_SESSION[$origin]['diff_list']['dest']['users'][0]['user_id'];
if (!in_array('copy', $user_roles[$old_dest])) {
array_push(
$_SESSION[$origin]['diff_list']['copy']['users'],
array(
'user_id' => $_SESSION[$origin]['diff_list']['dest']['users'][0]['user_id'],
'firstname' => $_SESSION[$origin]['diff_list']['dest']['users'][0]['firstname'],
'lastname' => $_SESSION[$origin]['diff_list']['dest']['users'][0]['lastname'],
'entity_id' => $_SESSION[$origin]['diff_list']['dest']['users'][0]['entity_id'],
'entity_label' => $_SESSION[$origin]['diff_list']['dest']['users'][0]['entity_label'],
'visible' => 'Y',
)
);
}
unset($_SESSION[$origin]['diff_list']['dest']['users'][0]);
$_SESSION[$origin]['diff_list']['dest']['users'] = array_values(
$_SESSION[$origin]['diff_list']['dest']['users']
);
array_push(
$_SESSION[$origin]['diff_list'][$role_id]['users'],
array(
'user_id' => functions::show_string($id),
'firstname' => functions::show_string($line->firstname),
'lastname' => functions::show_string($line->lastname),
'entity_id' => functions::show_string($line->entity_id),
'entity_label' => functions::show_string($line->entity_label),
$_SESSION[$origin]['diff_list'][$role_id]['users'] = array_values(
);
break;
// ADD ENTITY AS copy/custom mode
case 'add_entity':
'SELECT entity_id, entity_label FROM '.ENT_ENTITIES
$visible = 'Y';
if (!isset($_SESSION[$origin]['diff_list'][$role_id]['entities'])) {
$_SESSION[$origin]['diff_list'][$role_id]['entities'] = array();
} else {
if ($lastEntity = end($_SESSION[$origin]['diff_list'][$role_id]['entities'])) {
$visible = $lastEntity['visible'];
$_SESSION[$origin]['diff_list'][$role_id]['entities'],
'entity_id' => functions::show_string($id),
'entity_label' => functions::show_string($line->entity_label),
'visible' => $visible,
// REMOVE
//***************************************************************************************
// Remove USER
case 'remove_user':
if ($rank !== false && $id && $role_id
&& $_SESSION[$origin]['diff_list'][$role_id]['users'][$rank]['user_id'] == $id
$visible = $_SESSION[$origin]['diff_list'][$role_id]['users'][$rank]['visible'];
unset($_SESSION[$origin]['diff_list'][$role_id]['users'][$rank]);
$_SESSION[$origin]['diff_list'][$role_id]['users'] = array_values(
$_SESSION[$origin]['diff_list'][$role_id]['users']
);
// Set next user (replacing removed one) visible
if (isset($_SESSION[$origin]['diff_list'][$role_id]['users'][$rank])) {
$_SESSION[$origin]['diff_list'][$role_id]['users'][$rank]['visible'] = $visible;
}
if ($role_id == 'dest') {
$dest_is_set = false;
}
break;
// Remove ENTITY
case 'remove_entity':
if ($rank !== false && $id && $role_id
&& $_SESSION[$origin]['diff_list'][$role_id]['entities'][$rank]['entity_id'] == $id
$visible = $_SESSION[$origin]['diff_list'][$role_id]['entities'][$rank]['visible'];
unset($_SESSION[$origin]['diff_list'][$role_id]['entities'][$rank]);
$_SESSION[$origin]['diff_list'][$role_id]['entities'] = array_values(
$_SESSION[$origin]['diff_list'][$role_id]['entities']
);
if (isset($_SESSION[$origin]['diff_list'][$role_id]['entities'][$rank])) {
$_SESSION[$origin]['diff_list'][$role_id]['entities'][$rank]['visible'] = $visible;
}
break;
// MOVE
//***************************************************************************************
if ($dest_is_set) {
if (!isset($_SESSION[$origin]['diff_list']['copy']['users'])) {
$_SESSION[$origin]['diff_list']['copy']['users'] = array();
$old_dest = $_SESSION[$origin]['diff_list']['dest']['users'][0]['user_id'];
if ($_SESSION['collection_id_choice'] != 'letterbox_coll') {
if (!in_array('copy', $user_roles[$old_dest])) {
array_push(
$_SESSION[$origin]['diff_list']['copy']['users'],
array(
'user_id' => $_SESSION[$origin]['diff_list']['dest']['users'][0]['user_id'],
'firstname' => $_SESSION[$origin]['diff_list']['dest']['users'][0]['firstname'],
'lastname' => $_SESSION[$origin]['diff_list']['dest']['users'][0]['lastname'],
'entity_id' => $_SESSION[$origin]['diff_list']['dest']['users'][0]['entity_id'],
'entity_label' => $_SESSION[$origin]['diff_list']['dest']['users'][0]['entity_label'],
}
unset($_SESSION[$origin]['diff_list']['dest']['users'][0]);
$_SESSION[$origin]['diff_list']['dest']['users'] = array_values(
$_SESSION[$origin]['diff_list']['dest']['users']
);
$old_dest_array = $_SESSION[$origin]['diff_list']['dest']['users'][0];
$old_copy_array = $_SESSION[$origin]['diff_list']['copy']['users'][0];
if (!in_array('copy', $user_roles[$old_dest])) {
$_SESSION[$origin]['diff_list']['copy']['users'][0]['user_id'] = $_SESSION[$origin]['diff_list']['dest']['users'][0]['user_id'];
$_SESSION[$origin]['diff_list']['copy']['users'][0]['firstname'] = $_SESSION[$origin]['diff_list']['dest']['users'][0]['firstname'];
$_SESSION[$origin]['diff_list']['copy']['users'][0]['lastname'] = $_SESSION[$origin]['diff_list']['dest']['users'][0]['lastname'];
$_SESSION[$origin]['diff_list']['copy']['users'][0]['entity_id'] = $_SESSION[$origin]['diff_list']['dest']['users'][0]['entity_id'];
$_SESSION[$origin]['diff_list']['copy']['users'][0]['entity_label'] = $_SESSION[$origin]['diff_list']['dest']['users'][0]['entity_label'];
$_SESSION[$origin]['diff_list']['copy']['users'][0]['visible'] = 'Y';
}
$_SESSION[$origin]['diff_list']['dest']['users'][0]['user_id'] = $old_copy_array['user_id'];
$_SESSION[$origin]['diff_list']['dest']['users'][0]['firstname'] = $old_copy_array['firstname'];
$_SESSION[$origin]['diff_list']['dest']['users'][0]['lastname'] = $old_copy_array['lastname'];
$_SESSION[$origin]['diff_list']['dest']['users'][0]['entity_id'] = $old_copy_array['entity_id'];
$_SESSION[$origin]['diff_list']['dest']['users'][0]['entity_label'] = $old_copy_array['entity_label'];
$_SESSION[$origin]['diff_list']['dest']['users'][0]['visible'] = 'Y';
break;
case 'copy_to_dest':
if ($dest_is_set) {
if (!isset($_SESSION[$origin]['diff_list'][$role_id]['users'])) {
$_SESSION[$origin]['diff_list'][$role_id]['users'] = array();
$old_dest = $_SESSION[$origin]['diff_list']['dest']['users'][0]['user_id'];
if (!in_array('copy', $user_roles[$old_dest])) {
array_push(
$_SESSION[$origin]['diff_list']['copy']['users'],
array(
'user_id' => $_SESSION[$origin]['diff_list']['dest']['users'][0]['user_id'],
'firstname' => $_SESSION[$origin]['diff_list']['dest']['users'][0]['firstname'],
'lastname' => $_SESSION[$origin]['diff_list']['dest']['users'][0]['lastname'],
'entity_id' => $_SESSION[$origin]['diff_list']['dest']['users'][0]['entity_id'],
'entity_label' => $_SESSION[$origin]['diff_list']['dest']['users'][0]['entity_label'],
unset($_SESSION[$origin]['diff_list']['dest']['users'][0]);
$_SESSION[$origin]['diff_list']['dest']['users'] = array_values(
$_SESSION[$origin]['diff_list']['dest']['users']
);
if (isset($_SESSION[$origin]['diff_list']['copy']['users'][$rank]['user_id'])
&& !empty($_SESSION[$origin]['diff_list']['copy']['users'][$rank]['user_id'])
$_SESSION[$origin]['diff_list']['dest']['users'][0]['user_id'] = $_SESSION[$origin]['diff_list']['copy']['users'][$rank]['user_id'];
$_SESSION[$origin]['diff_list']['dest']['users'][0]['firstname'] = $_SESSION[$origin]['diff_list']['copy']['users'][$rank]['firstname'];
$_SESSION[$origin]['diff_list']['dest']['users'][0]['lastname'] = $_SESSION[$origin]['diff_list']['copy']['users'][$rank]['lastname'];
$_SESSION[$origin]['diff_list']['dest']['users'][0]['entity_id'] = $_SESSION[$origin]['diff_list']['copy']['users'][$rank]['entity_id'];
$_SESSION[$origin]['diff_list']['dest']['users'][0]['entity_label'] = $_SESSION[$origin]['diff_list']['copy']['users'][$rank]['entity_label'];
$_SESSION[$origin]['diff_list']['dest']['users'][0]['visible'] = 'Y';
unset($_SESSION[$origin]['diff_list']['copy']['users'][$rank]);
$_SESSION[$origin]['diff_list']['copy']['users'] = array_values(
$_SESSION[$origin]['diff_list']['copy']['users']
case 'move_user_down':
$_SESSION[$origin]['diff_list'][$role_id]['users'],
$rank,
1,
$preserve_keys = true
);
$_SESSION[$origin]['diff_list'][$role_id]['users'],
$newRank,
1,
$preserve_keys = true
);
if ($upUser[0] && $downUser[0]) {
// Switch visible values
$downUserVisible = $downUser[0]['visible'];
$upUserVisible = $upUser[0]['visible'];
$upUser[0]['visible'] = $downUserVisible;
$downUser[0]['visible'] = $upUserVisible;
$_SESSION[$origin]['diff_list'][$role_id]['users'][$rank] = $upUser[0];
$_SESSION[$origin]['diff_list'][$role_id]['users'][$newRank] = $downUser[0];
}
break;
case 'move_entity_down':
$_SESSION[$origin]['diff_list'][$role_id]['entities'],
$rank,
1,
$preserve_keys = true
);
$newRank = $rank + 1;
$upEntity =
$_SESSION[$origin]['diff_list'][$role_id]['entities'],
$newRank,
1,
$preserve_keys = true
);
if ($upEntity[0] && $downEntity[0]) {
// Switch visible values
$downEntityVisible = $downEntity[0]['visible'];
$upEntityVisible = $upEntity[0]['visible'];
$upEntity[0]['visible'] = $downEntityVisible;
$downEntity[0]['visible'] = $upEntityVisible;
$_SESSION[$origin]['diff_list'][$role_id]['entities'][$rank] = $upEntity[0];
$_SESSION[$origin]['diff_list'][$role_id]['entities'][$newRank] = $downEntity[0];
}
$_SESSION[$origin]['diff_list'][$role_id]['users'],
$rank,
1,
$preserve_keys = true
);
$newRank = $rank - 1;
$downUser =
$_SESSION[$origin]['diff_list'][$role_id]['users'],
$newRank,
1,
$preserve_keys = true
);
if ($upUser[0] && $downUser[0]) {
// Switch visible values
$downUserVisible = $downUser[0]['visible'];
$upUserVisible = $upUser[0]['visible'];
$upUser[0]['visible'] = $downUserVisible;
$downUser[0]['visible'] = $upUserVisible;
// Switch positions
$_SESSION[$origin]['diff_list'][$role_id]['users'][$rank] = $downUser[0];
$_SESSION[$origin]['diff_list'][$role_id]['users'][$newRank] = $upUser[0];
}
break;
case 'move_entity_up':
$_SESSION[$origin]['diff_list'][$role_id]['entities'],
$rank,
1,
$preserve_keys = true
);
$newRank = $rank - 1;
$downEntity =
$_SESSION[$origin]['diff_list'][$role_id]['entities'],
$newRank,
1,
$preserve_keys = true
);
if ($upEntity[0] && $downEntity[0]) {
// Switch visible values
$downEntityVisible = $downEntity[0]['visible'];
$upEntityVisible = $upEntity[0]['visible'];
$upEntity[0]['visible'] = $downEntityVisible;
$downEntity[0]['visible'] = $upEntityVisible;
$_SESSION[$origin]['diff_list'][$role_id]['entities'][$rank] = $downEntity[0];
$_SESSION[$origin]['diff_list'][$role_id]['entities'][$newRank] = $upEntity[0];
}
//***************************************************************************************
case 'make_user_visible':
$_SESSION[$origin]['diff_list'][$role_id]['users'][$rank]['visible'] = 'Y';
case 'make_user_unvisible':
$_SESSION[$origin]['diff_list'][$role_id]['users'][$rank]['visible'] = 'N';
break;
case 'make_entity_visible':
$_SESSION[$origin]['diff_list'][$role_id]['entities'][$rank]['visible'] = 'Y';
case 'make_entity_unvisible':
$_SESSION[$origin]['diff_list'][$role_id]['entities'][$rank]['visible'] = 'N';
break;
// END SWITCH ACTION
// 1.4 create indexed array of existing diffusion to search for users/entities easily
$user_roles = array();
$entity_roles = array();
foreach ($roles as $role_id => $role_label) {
if (!empty($_SESSION[$origin]['diff_list'][$role_id]['users'])) {
for ($i = 0, $l = count($_SESSION[$origin]['diff_list'][$role_id]['users']); $i < $l; ++$i) {
$user_id = $_SESSION[$origin]['diff_list'][$role_id]['users'][$i]['user_id'];
$user_roles[$user_id][] = $role_id;
}
if (!empty($_SESSION[$origin]['diff_list'][$role_id]['entities'])) {
for ($i = 0, $l = count($_SESSION[$origin]['diff_list'][$role_id]['entities']); $i < $l; ++$i) {
$entity_id = $_SESSION[$origin]['diff_list'][$role_id]['entities'][$i]['entity_id'];
$entity_roles[$entity_id][] = $role_id;
}
$core_tools->load_html();
$core_tools->load_header(_USER_ENTITIES_TITLE);
$time = $core_tools->get_session_time_expire();
$displayValue = '';
$displayValue = ''.$displayValue.'';
$link = $_SESSION['config']['businessappurl'].'index.php?display=true&module=entities&page=manage_listinstance&origin='.$origin;
if ($onlyCc) {
$link .= '&only_cc';
}
if ($noDelete) {
$link .= '&no_delete';
}
if ($cat) {
$link .= '&cat='.$cat;
}
if ($specific_role) {
$link .= '&specific_role='.$specific_role;
}
$linkwithwhat =
$link
.'&what_users='.$whatUsers
.'&what_services='.$whatServices;
//******************************************************************************
// DISPLAY EXISTING LIST
//******************************************************************************
<body onload="setTimeout(window.close, <?php echo $time; ?>*60*1000);">
<script type="text/javascript">
function add_user(id) {
var user_id = $('user_id_' + id).value;
var role_select = $('user_role_' + id);
var role = role_select.options[role_select.selectedIndex].value;
goTo('<?php echo $linkwithwhat; ?>&action=add_user&id=' + user_id + '&role=' + role);
function add_entity(id) {
var entity_id = $('entity_id_' + id).value;
var role_select = $('entity_role_' + id);
var role = role_select.options[role_select.selectedIndex].value;
goTo('<?php echo $linkwithwhat; ?>&action=add_entity&id=' + entity_id + '&role=' + role);
/*if ((isset($_GET['what_users']) && ! empty($_GET['what_users']))
|| (isset($_GET['what_services']) && !empty($_GET['what_services']))
|| ( !empty($user_roles) || !empty($entity_roles))
<div id="diff_list" class="block" align="center">
<h2>
<?php
echo _DIFFUSION_LIST.' ';
if ($_SESSION[$origin]['difflist_object']['object_label'] != '') {
functions::xecho($_SESSION[$origin]['difflist_object']['object_label']);
/*if ($difflistType->difflist_type_label != '') {
echo "<br /><small><small><small> (" . $difflistType->difflist_type_label . ")</small></small></small>";
}*/
//**************************************************************************
// DEST USER
//**************************************************************************
if (1 == 2 && isset($_SESSION[$origin]['diff_list']['dest']['user_id'])
&& !empty($_SESSION[$origin]['diff_list']['dest']['user_id'])
&& !$onlyCc
) {
?>
<h3 class="sstit">
<?php echo _PRINCIPAL_RECIPIENT; ?>
</h3>
<table cellpadding="0" cellspacing="0" border="0" class="listing spec">
<tr>
<td style="width:5%;">
<i class="fa fa-user fa-2x" title="<?php echo _USER; ?>"></i>
</td>
<td style="width:5%;">
<?php
if ($_SESSION[$origin]['diff_list']['dest']['visible'] == 'Y') {
?>
<i class="fa fa-check fa-2x" title="<?php echo _VISIBLE; ?>"></i>
<?php
</td>
<td>
<?php functions::xecho($_SESSION[$origin]['diff_list']['dest']['lastname']).' '.$_SESSION[$origin]['diff_list']['dest']['firstname']; ?>
</td>
<td>
<?php functions::xecho($_SESSION[$origin]['diff_list']['dest']['entity_label']); ?>
</td>
<td class="action_entities" style="width:5%;">
<!-- Remove dest -->
<a href="<?php echo $linkwithwhat; ?>&action=remove_dest"><i
class="fa fa-times fa-2x"></i></a>
</td>
<td class="action_entities" style="width:15%;">
<!-- Move dest to copy -->
<a href="<?php echo $linkwithwhat; ?>&action=dest_to_copy&role=copy"><i
class="fa fa-arrow-down fa-2x"></i>
<?php echo _TO_CC; ?></a>
</td>
</tr>
</table>
<?php
//**************************************************************************
// OTHER ROLES
//**************************************************************************
foreach ($roles as $role_id => $role_label) {
if ($cat == 'outgoing' && $role_id == 'dest') {
$role_label = _REDACTOR;
} elseif ($cat != 'outgoing' && $role_id == 'dest') {
$role_label = _ASSIGNEE;

Alex ORLUC
committed
}
if (!empty($_SESSION[$origin]['diff_list']['dest']['users'][0]['entity_id'])) {
$entity_id_dest = $_SESSION[$origin]['diff_list']['dest']['users'][0]['entity_id'];
}
if ((!empty($_SESSION[$origin]['diff_list'][$role_id]['users']) && count($_SESSION[$origin]['diff_list'][$role_id]['users']) > 0) || (!empty($_SESSION[$origin]['diff_list'][$role_id]['entities']) && count($_SESSION[$origin]['diff_list'][$role_id]['entities']) > 0)) {
if (($specific_role == $role_id || $specific_role.'_copy' == $role_id || $specific_role.'_info' == $role_id) || !isset($_REQUEST['specific_role'])) {
?>
<h3 class="sstit" style="font-size:1.5em; text-align:left; margin-left:230px; margin-bottom: -10px">
<?php functions::xecho($role_label); ?>
</h3>
<table cellpadding="0" cellspacing="0" border="0" class="listing liste_diff spec">
<?php
//**************************************************************************
// OTHER ROLE USERS
//**************************************************************************
$color = ' class="col"';
if (!empty($_SESSION[$origin]['diff_list'][$role_id]['users'])) {
$nbDiffListUser = count($_SESSION[$origin]['diff_list'][$role_id]['users']);
} else {
$nbDiffListUser = 0;
}
$user = $_SESSION[$origin]['diff_list'][$role_id]['users'][$i];
if ($color == ' class="col"') {
$color = '';
} else {
$color = ' class="col"';
} ?>
<tr <?php echo $color; ?> >
<td style="width:5%;">
<i class="fa fa-user fa-2x" title="<?php echo _USER.' '.$role_label; ?>"></i>
</td>
<td style="width:5%;">
<?php
if ($user['visible'] == 'Y') {
?>
<a href="<?php echo $linkwithwhat; ?>&action=make_user_unvisible&role=<?php functions::xecho($role_id); ?>&rank=<?php functions::xecho($i); ?>">
<i class="fa fa-check fa-2x" title="<?php echo _VISIBLE; ?>"></i>
</a>
<?php
<a href="<?php echo $linkwithwhat; ?>&action=make_user_visible&role=<?php functions::xecho($role_id); ?>&rank=<?php functions::xecho($i); ?>">
<i class="fa fa-times fa-2x" title="<?php echo _NOT_VISIBLE; ?>"></i>
</a>
<?php
</td>
<td>
<?php functions::xecho($user['lastname'].' '.$user['firstname']); ?>
</td>
<td>
<?php functions::xecho($user['entity_label']); ?>
</td>
<td class="action_entities" style="width:5%;">
<?php
/*if (!$noDelete && ($role_id != 'dest' && !$onlyCc)) { */
if (!$noDelete && (!$onlyCc || ($onlyCc && $role_id != 'dest'))) {
?>
<a href="<?php echo $linkwithwhat; ?>&action=remove_user&role=<?php functions::xecho($role_id); ?>&rank=<?php functions::xecho($i); ?>&id=<?php functions::xecho($user['user_id']); ?>"><i
class="fa fa-times fa-lg" title="<?php echo _DEL_USER_LISTDIFF; ?>"></i></a>
<?php
</td>
<td class="action_entities" style="width:15%;">
<!-- Switch copy to dest -->
<?php
//if($role_id == 'dest' && isset($roles['copy']) && ($role_id != 'dest' && $onlyCc)) {
if ($role_id == 'dest' && isset($roles['copy']) && !$onlyCc && $_SESSION[$origin]['diff_list']['copy']['users'][0] != '') {
?>
<a href="<?php functions::xecho($linkwithwhat); ?>&action=dest_to_copy&role=copy"
title="<?php echo _GO_TO_CC; ?>"><i class="fa fa-arrow-down"></i>
<?php echo _TO_CC; ?></a>
<?php
} elseif ($role_id == 'copy' && !$onlyCc && isset($roles['dest'])) {
?>
<a href="<?php echo $linkwithwhat; ?>&action=copy_to_dest&role=copy&rank=<?php functions::xecho($i); ?>"
title="<?php echo _GO_TO_DEST; ?>"><i class="fa fa-arrow-up"></i>
<?php echo _TO_DEST; ?></a>
<?php
} else {
echo ' ';
} ?>
</td>
<td class="action_entities" style="width:5%;">
<!-- Move up in list -->
<?php
<a href="<?php echo $linkwithwhat; ?>&action=move_user_up&role=<?php functions::xecho($role_id); ?>&rank=<?php functions::xecho($i); ?>"><i
class="fa fa-arrow-up" title="<?php echo _UP_USER_ONE_ROW; ?>"></i></a>
<?php
</td>
<td class="action_entities" style="width:5%;">
<!-- Move down in list -->
<?php
<a href="<?php echo $linkwithwhat; ?>&action=move_user_down&role=<?php functions::xecho($role_id); ?>&rank=<?php functions::xecho($i); ?>"><i
class="fa fa-arrow-down" title="<?php echo _DOWN_USER_ONE_ROW; ?>"></i></a>
<?php
}
//**************************************************************************
// OTHER ROLE ENTITIES
//**************************************************************************
$nbEntitiesDiffList = 0;
if ($_SESSION[$origin]['diff_list'][$role_id]['entities']) {
$nbEntitiesDiffList = count($_SESSION[$origin]['diff_list'][$role_id]['entities']);
}
for ($i = 0, $l = $nbEntitiesDiffList; $i < $l; ++$i) {
$entity = $_SESSION[$origin]['diff_list'][$role_id]['entities'][$i];
if ($color == ' class="col"') {
$color = '';
} else {
$color = ' class="col"';
} ?>
<tr <?php echo $color; ?> >
<td style="width:5%;">
<i class="fa fa-sitemap fa-2x" title="<?php echo _ENTITY.' '.$role_label; ?>"></i>
</td>
<td style="width:5%;">
<?php
if ($entity['visible'] == 'Y') {
?>
<a href="<?php echo $linkwithwhat; ?>&action=make_entity_unvisible&role=<?php functions::xecho($role_id); ?>&rank=<?php functions::xecho($i); ?>">
<i class="fa fa-check fa-2x" title="<?php echo _VISIBLE; ?>"></i>
</a>
<?php
<a href="<?php echo $linkwithwhat; ?>&action=make_entity_visible&role=<?php functions::xecho($role_id); ?>&rank=<?php functions::xecho($i); ?>">
<i class="fa fa-times fa-2x" title="<?php echo _NOT_VISIBLE; ?>"></i>
</a>
<?php
</td>
<td>
<?php functions::xecho($entity['entity_id']); ?>
</td>
<td>
<?php functions::xecho($entity['entity_label']); ?>
</td>
<td class="action_entities" style="width:5%;">
<?php
<a href="<?php echo $linkwithwhat; ?>&action=remove_entity&role=<?php functions::xecho($role_id); ?>&rank=<?php functions::xecho($i); ?>&id=<?php functions::xecho($entity['entity_id']); ?>">
<i class="fa fa-times fa-lg" title="<?php echo _DEL_ENTITY_LISTDIFF; ?>"></i>
</a>
<?php
</td>
<td class="action_entities" style="width:15%;"> </td>
<td class="action_entities" style="width:5%;">
<!-- Move up in list -->
<?php
<a href="<?php echo $linkwithwhat; ?>&action=move_entity_up&role=<?php functions::xecho($role_id); ?>&rank=<?php functions::xecho($i); ?>"><i
class="fa fa-arrow-up" title="<?php echo _UP_ENTITY_ONE_ROW; ?>"></i></a>
<?php
</td>
<td class="action_entities" style="width:5%;">
<!-- Move down in list -->
<?php
<a href="<?php echo $linkwithwhat; ?>&action=move_entity_down&role=<?php functions::xecho($role_id); ?>&rank=<?php functions::xecho($i); ?>"><i
class="fa fa-arrow-down" title="<?php echo _DOWN_ENTITY_ONE_ROW; ?>"></i></a>
<?php
}
}
//******************************************************************************
// ACTIONS BUTTONS
//******************************************************************************?>
<form name="pop_diff" method="post" >
<div align="center">