Merge pull request #6954 from hregis/develop_transverse
New: big refactorization of multicompany transverse mode
This commit is contained in:
commit
50769f2f41
@ -6,6 +6,7 @@ English Dolibarr ChangeLog
|
||||
|
||||
For developers:
|
||||
NEW: Add a lot of API REST: dictionaryevents, memberstypes, ...
|
||||
NEW: Big refactorization of multicompany transverse mode
|
||||
NEW: getEntity function use true $shared value by default
|
||||
|
||||
WARNING:
|
||||
@ -22,6 +23,7 @@ Following changes may create regression for some external modules, but were nece
|
||||
* Removed Societe::set_commnucation_level (was deprecated in 4.0). Was not used.
|
||||
* Removed the trigger file of PAYPAL module that stored data that was not used by Dolibarr. The trigger event still
|
||||
exists, but if an external module need action on it, it must provides itself its trigger file.
|
||||
* Use $conf->global->MULTICOMPANY_TRANSVERSE_MODE instead $conf->multicompany->transverse_mode
|
||||
* Use getEntity('xxx') instead getEntity('xxx', 1) and use getEntity('xxx', 0) instead getEntity('xxx')
|
||||
|
||||
***** ChangeLog for 5.0.3 compared to 5.0.2 *****
|
||||
|
||||
@ -235,7 +235,7 @@ $sql = "SELECT b.rowid, b.box_id, b.position, b.box_order,";
|
||||
$sql.= " bd.rowid as boxid";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."boxes as b, ".MAIN_DB_PREFIX."boxes_def as bd";
|
||||
$sql.= " WHERE b.box_id = bd.rowid";
|
||||
$sql.= " AND b.entity IN (0,".(! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)?"1,":"").$conf->entity.")";
|
||||
$sql.= " AND b.entity IN (0,".$conf->entity.")";
|
||||
$sql.= " AND b.fk_user=0";
|
||||
$sql.= " ORDER by b.position, b.box_order";
|
||||
|
||||
@ -342,7 +342,7 @@ print "</tr>\n";
|
||||
$var=true;
|
||||
foreach($boxtoadd as $box)
|
||||
{
|
||||
|
||||
|
||||
|
||||
if (preg_match('/^([^@]+)@([^@]+)$/i',$box->boximg))
|
||||
{
|
||||
@ -479,7 +479,7 @@ print '</tr>';
|
||||
|
||||
// Activate FileCache - Developement
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL == 2 || ! empty($conf->global->MAIN_ACTIVATE_FILECACHE)) {
|
||||
|
||||
|
||||
print '<tr class="oddeven"><td width="35%">'.$langs->trans("EnableFileCache").'</td><td>';
|
||||
print $form->selectyesno('MAIN_ACTIVATE_FILECACHE',$conf->global->MAIN_ACTIVATE_FILECACHE,1);
|
||||
print '</td>';
|
||||
|
||||
@ -131,7 +131,7 @@ print '<table class="noborder" width="100%">';
|
||||
$sql = "SELECT r.id, r.libelle, r.module, r.perms, r.subperms, r.bydefault";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."rights_def as r";
|
||||
$sql.= " WHERE r.libelle NOT LIKE 'tou%'"; // On ignore droits "tous"
|
||||
$sql.= " AND entity IN (".(! empty($conf->multicompany->transverse_mode)?"1,":"").$conf->entity.")";
|
||||
$sql.= " AND entity = ".$conf->entity;
|
||||
if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) $sql.= " AND r.perms NOT LIKE '%_advance'"; // Hide advanced perms if option is not enabled
|
||||
$sql.= " ORDER BY r.module, r.id";
|
||||
|
||||
@ -185,7 +185,7 @@ if ($result)
|
||||
print "</tr>\n";
|
||||
}
|
||||
|
||||
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.img_object('',$picto).' '.$objMod->getName();
|
||||
print '<a name="'.$objMod->getName().'"> </a>';
|
||||
|
||||
@ -324,14 +324,4 @@ $dolibarr_nocsrfcheck='0';
|
||||
// External module
|
||||
//##############################
|
||||
|
||||
// multicompany_transverse_mode
|
||||
// Prerequisite: Need external module "multicompany"
|
||||
// Pyramidal (0): The rights and groups are managed in each entity. Each user belongs to the entity he was created into.
|
||||
// Transversal (1): The user is created and managed only into master entity but can login to all entities if he is admmin
|
||||
// of entity or belongs to at least one user group created into entity.
|
||||
|
||||
// Default value: 0 (pyramidal)
|
||||
// Examples:
|
||||
// $multicompany_transverse_mode='1';
|
||||
|
||||
|
||||
|
||||
@ -132,14 +132,7 @@ class Conf
|
||||
$sql = "SELECT ".$db->decrypt('name')." as name,";
|
||||
$sql.= " ".$db->decrypt('value')." as value, entity";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."const";
|
||||
if (! empty($this->multicompany->transverse_mode))
|
||||
{
|
||||
$sql.= " WHERE entity IN (0,1,".$this->entity.")";
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql.= " WHERE entity IN (0,".$this->entity.")";
|
||||
}
|
||||
$sql.= " WHERE entity IN (0,".$this->entity.")";
|
||||
$sql.= " ORDER BY entity"; // This is to have entity 0 first, then entity 1 that overwrite.
|
||||
|
||||
$resql = $db->query($sql);
|
||||
|
||||
@ -1468,7 +1468,7 @@ class Form
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! empty($conf->multicompany->transverse_mode))
|
||||
if (! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
|
||||
{
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ug";
|
||||
$sql.= " ON ug.fk_user = u.rowid";
|
||||
@ -1565,7 +1565,7 @@ class Form
|
||||
$moreinfo++;
|
||||
}
|
||||
}
|
||||
if (! empty($conf->multicompany->enabled) && empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity)
|
||||
if (! empty($conf->multicompany->enabled) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity)
|
||||
{
|
||||
if ($obj->admin && ! $obj->entity)
|
||||
{
|
||||
@ -6196,7 +6196,7 @@ class Form
|
||||
$out.= '>';
|
||||
|
||||
$out.= $obj->name;
|
||||
if (! empty($conf->multicompany->enabled) && empty($conf->multicompany->transverse_mode) && $conf->entity == 1)
|
||||
if (! empty($conf->multicompany->enabled) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1)
|
||||
{
|
||||
$out.= " (".$obj->label.")";
|
||||
}
|
||||
|
||||
@ -60,7 +60,7 @@ class InfoBox
|
||||
$sql.= " d.rowid as box_id, d.file, d.note, d.tms";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."boxes as b, ".MAIN_DB_PREFIX."boxes_def as d";
|
||||
$sql.= " WHERE b.box_id = d.rowid";
|
||||
$sql.= " AND b.entity IN (0,".(! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)?"1,":"").$conf->entity.")";
|
||||
$sql.= " AND b.entity IN (0,".$conf->entity.")";
|
||||
if ($zone >= 0) $sql.= " AND b.position = ".$zone;
|
||||
if (is_object($user)) $sql.= " AND b.fk_user IN (0,".$user->id.")";
|
||||
else $sql.= " AND b.fk_user = 0";
|
||||
@ -70,9 +70,9 @@ class InfoBox
|
||||
{
|
||||
$sql = "SELECT d.rowid as box_id, d.file, d.note, d.tms";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."boxes_def as d";
|
||||
$sql.= " WHERE d.entity IN (0,".(! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)?"1,":"").$conf->entity.")";
|
||||
$sql.= " WHERE d.entity IN (0,".$conf->entity.")";
|
||||
}
|
||||
|
||||
|
||||
dol_syslog(get_class()."::listBoxes get default box list for mode=".$mode." userid=".(is_object($user)?$user->id:'')."", LOG_DEBUG);
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
|
||||
@ -508,7 +508,7 @@ class Menubase
|
||||
|
||||
$sql = "SELECT m.rowid, m.type, m.module, m.fk_menu, m.fk_mainmenu, m.fk_leftmenu, m.url, m.titre, m.langs, m.perms, m.enabled, m.target, m.mainmenu, m.leftmenu, m.position";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."menu as m";
|
||||
$sql.= " WHERE m.entity IN (0,".(! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)?"1,":"").$conf->entity.")";
|
||||
$sql.= " WHERE m.entity IN (0,".$conf->entity.")";
|
||||
$sql.= " AND m.menu_handler IN ('".$menu_handler."','all')";
|
||||
if ($type_user == 0) $sql.= " AND m.usertype IN (0,2)";
|
||||
if ($type_user == 1) $sql.= " AND m.usertype IN (1,2)";
|
||||
|
||||
@ -98,7 +98,7 @@ function dolGetModulesDirs($subdir='')
|
||||
while (($file = readdir($handle))!==false)
|
||||
{
|
||||
if (preg_match('/disabled/',$file)) continue; // We discard module if it contains disabled into name.
|
||||
|
||||
|
||||
if (is_dir($dirroot.'/'.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS' && $file != 'includes')
|
||||
{
|
||||
if (is_dir($dirroot . '/' . $file . '/core/modules'.$subdir.'/'))
|
||||
@ -207,7 +207,7 @@ function dol_print_object_info($object, $usetable=0)
|
||||
//print "x".$deltadateforserver." - ".$deltadateforclient." - ".$deltadateforuser;
|
||||
|
||||
if ($usetable) print '<table class="border centpercent">';
|
||||
|
||||
|
||||
// Import key
|
||||
if (! empty($object->import_key))
|
||||
{
|
||||
@ -378,7 +378,7 @@ function dol_print_object_info($object, $usetable=0)
|
||||
if ($usetable) print '</td></tr>';
|
||||
else print '<br>';
|
||||
}
|
||||
|
||||
|
||||
// Date approve
|
||||
if (! empty($object->date_approve2))
|
||||
{
|
||||
@ -391,7 +391,7 @@ function dol_print_object_info($object, $usetable=0)
|
||||
if ($usetable) print '</td></tr>';
|
||||
else print '<br>';
|
||||
}
|
||||
|
||||
|
||||
// User close
|
||||
if (! empty($object->user_cloture))
|
||||
{
|
||||
@ -476,7 +476,7 @@ function dol_print_object_info($object, $usetable=0)
|
||||
if ($usetable) print '</td></tr>';
|
||||
else print '<br>';
|
||||
}
|
||||
|
||||
|
||||
if ($usetable) print '</table>';
|
||||
}
|
||||
|
||||
@ -799,7 +799,7 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m
|
||||
if(!empty($user->array_options['options_'.$extra])){
|
||||
$mask = preg_replace('#('.$start.')(.*?)('.$end.')#si', $user->array_options['options_'.$extra], $mask);
|
||||
}
|
||||
}
|
||||
}
|
||||
$maskwithonlyymcode=$mask;
|
||||
$maskwithonlyymcode=preg_replace('/\{(0+)([@\+][0-9\-\+\=]+)?([@\+][0-9\-\+\=]+)?\}/i',$maskcounter,$maskwithonlyymcode);
|
||||
$maskwithonlyymcode=preg_replace('/\{dd\}/i','dd',$maskwithonlyymcode);
|
||||
@ -928,11 +928,11 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m
|
||||
//print "masktri=".$masktri." maskcounter=".$maskcounter." maskraz=".$maskraz." maskoffset=".$maskoffset."<br>\n";
|
||||
|
||||
// Define $sqlstring
|
||||
if (function_exists('mb_strrpos'))
|
||||
if (function_exists('mb_strrpos'))
|
||||
{
|
||||
$posnumstart=mb_strrpos($maskwithnocode,$maskcounter, 'UTF-8');
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
$posnumstart=strrpos($maskwithnocode,$maskcounter);
|
||||
} // Pos of counter in final string (from 0 to ...)
|
||||
@ -1123,7 +1123,7 @@ function get_string_between($string, $start, $end){
|
||||
$string = " ".$string;
|
||||
$ini = strpos($string,$start);
|
||||
if ($ini == 0) return "";
|
||||
$ini += strlen($start);
|
||||
$ini += strlen($start);
|
||||
$len = strpos($string,$end,$ini) - $ini;
|
||||
return substr($string,$ini,$len);
|
||||
}
|
||||
@ -1539,9 +1539,9 @@ function getListOfModels($db,$type,$maxfilenamelength=0)
|
||||
$sql = "SELECT nom as id, nom as lib, libelle as label, description as description";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."document_model";
|
||||
$sql.= " WHERE type = '".$type."'";
|
||||
$sql.= " AND entity IN (0,".(! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)?"1,":"").$conf->entity.")";
|
||||
$sql.= " AND entity IN (0,".$conf->entity.")";
|
||||
$sql.= " ORDER BY description DESC";
|
||||
|
||||
|
||||
dol_syslog('/core/lib/function2.lib.php::getListOfModels', LOG_DEBUG);
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
@ -1625,7 +1625,7 @@ function getListOfModels($db,$type,$maxfilenamelength=0)
|
||||
/**
|
||||
* This function evaluates a string that should be a valid IPv4
|
||||
* Note: For ip 169.254.0.0, it returns 0 with some PHP (5.6.24) and 2 with some minor patchs of PHP (5.6.25). See https://github.com/php/php-src/pull/1954.
|
||||
*
|
||||
*
|
||||
* @param string $ip IP Address
|
||||
* @return int 0 if not valid or reserved range, 1 if valid and public IP, 2 if valid and private range IP
|
||||
*/
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2006-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2010-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2010-2017 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -76,7 +76,7 @@ function user_prepare_head($object)
|
||||
{
|
||||
if (empty($conf->global->AGENDA_EXT_NB)) $conf->global->AGENDA_EXT_NB=5;
|
||||
$MAXAGENDA=$conf->global->AGENDA_EXT_NB;
|
||||
|
||||
|
||||
$i=1;
|
||||
$nbagenda = 0;
|
||||
while ($i <= $MAXAGENDA)
|
||||
@ -87,10 +87,10 @@ function user_prepare_head($object)
|
||||
$offsettz='AGENDA_EXT_OFFSETTZ_'.$object->id.'_'.$key;
|
||||
$color='AGENDA_EXT_COLOR_'.$object->id.'_'.$key;
|
||||
$i++;
|
||||
|
||||
|
||||
if (! empty($object->conf->$name)) $nbagenda++;
|
||||
}
|
||||
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/user/agenda_extsites.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans("ExtSites").($nbagenda ? ' <span class="badge">'.$nbagenda.'</span>' : '');
|
||||
$head[$h][2] = 'extsites';
|
||||
@ -238,8 +238,6 @@ function group_prepare_head($object)
|
||||
return $head;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Prepare array with list of tabs
|
||||
*
|
||||
@ -283,32 +281,6 @@ function user_admin_prepare_head()
|
||||
return $head;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Prepare array with list of tabs
|
||||
*
|
||||
* @param Object $object Object related to tabs
|
||||
* @param array $aEntities Entities array
|
||||
* @return array Array of tabs
|
||||
*/
|
||||
function entity_prepare_head($object, $aEntities)
|
||||
{
|
||||
global $mc;
|
||||
|
||||
$head = array();
|
||||
|
||||
foreach($aEntities as $entity)
|
||||
{
|
||||
$mc->getInfo($entity);
|
||||
$head[$entity][0] = $_SERVER['PHP_SELF'].'?id='.$object->id.'&entity='.$entity;
|
||||
$head[$entity][1] = $mc->label;
|
||||
$head[$entity][2] = $entity;
|
||||
}
|
||||
|
||||
return $head;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show list of themes. Show all thumbs of themes
|
||||
*
|
||||
@ -485,7 +457,7 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
|
||||
print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
|
||||
// Background color THEME_ELDY_BACKBODY
|
||||
if ($foruserprofile)
|
||||
{
|
||||
@ -508,7 +480,7 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
|
||||
else print '';
|
||||
}
|
||||
if ($edit) print '<br>('.$langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis").')';
|
||||
print '</td>';*/
|
||||
print '</td>';*/
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -530,7 +502,7 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
|
||||
print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
|
||||
// TopMenuBackgroundColor
|
||||
if ($foruserprofile)
|
||||
{
|
||||
@ -553,13 +525,13 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
|
||||
else print '';
|
||||
}
|
||||
if ($edit) print '<br>('.$langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis").')';
|
||||
print '</td>';*/
|
||||
print '</td>';*/
|
||||
}
|
||||
else
|
||||
{
|
||||
$default='5a6482';
|
||||
if ($conf->theme == 'md') $default='5a3278';
|
||||
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.$langs->trans("TopMenuBackgroundColor").'</td>';
|
||||
print '<td colspan="'.($colspan-1).'">';
|
||||
@ -577,15 +549,15 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
|
||||
print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
|
||||
// BackgroundTableTitleColor
|
||||
if ($foruserprofile)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.$langs->trans("BackgroundTableTitleColor").'</td>';
|
||||
print '<td colspan="'.($colspan-1).'">';
|
||||
@ -613,7 +585,7 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
|
||||
{
|
||||
$default='ffffff';
|
||||
if ($conf->theme == 'md') $default='ffffff';
|
||||
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.$langs->trans("BackgroundTableLineOddColor").'</td>';
|
||||
print '<td colspan="'.($colspan-1).'">';
|
||||
@ -631,17 +603,17 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
|
||||
print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
|
||||
// BackgroundTableLineEvenColor
|
||||
if ($foruserprofile)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$default='f8f8f8';
|
||||
if ($conf->theme == 'md') $default='f8f8f8';
|
||||
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.$langs->trans("BackgroundTableLineEvenColor").'</td>';
|
||||
print '<td colspan="'.($colspan-1).'">';
|
||||
@ -659,12 +631,12 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
|
||||
print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
|
||||
// TextTitleColor
|
||||
if ($foruserprofile)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -681,12 +653,12 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
|
||||
}
|
||||
print ' ('.$langs->trans("Default").': <strong><span style="color: #3c3c14">3c3c14</span></strong>) ';
|
||||
print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
|
||||
|
||||
|
||||
print '</td>';
|
||||
|
||||
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
|
||||
// Text LinkColor
|
||||
if ($foruserprofile)
|
||||
{
|
||||
@ -724,7 +696,7 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
|
||||
{
|
||||
$color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TEXTLINK,array()),'');
|
||||
if ($color) print '<input type="text" class="colorthumb" disabled="disabled" style="padding: 1px; margin-top: 0; margin-bottom: 0; background-color: #'.$color.'" value="'.$color.'">';
|
||||
else
|
||||
else
|
||||
{
|
||||
//print '<input type="text" class="colorthumb" disabled="disabled" style="padding: 1px; margin-top: 0; margin-bottom: 0; background-color: #'.$defaultcolor.'" value="'.$langs->trans("Default").'">';
|
||||
//print '<span style="color: #000078">'.$langs->trans("Default").'</span>';
|
||||
@ -735,7 +707,7 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
|
||||
print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
|
||||
// Use Hover
|
||||
if ($foruserprofile)
|
||||
{
|
||||
@ -767,7 +739,7 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
|
||||
{
|
||||
if ($conf->global->THEME_ELDY_USE_HOVER == '1') $color='edf4fb';
|
||||
else $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_USE_HOVER,array()),'');
|
||||
if ($color)
|
||||
if ($color)
|
||||
{
|
||||
if ($color != 'edf4fb') print '<input type="text" class="colorthumb" disabled="disabled" style="padding: 1px; margin-top: 0; margin-bottom: 0; background-color: #'.$color.'" value="'.$color.'">';
|
||||
else print $langs->trans("Default");
|
||||
@ -779,7 +751,6 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
|
||||
print '</table>';
|
||||
}
|
||||
|
||||
|
||||
@ -39,7 +39,7 @@ function check_user_password_dolibarr($usertotest,$passwordtotest,$entitytotest=
|
||||
|
||||
// Force master entity in transversal mode
|
||||
$entity=$entitytotest;
|
||||
if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)) $entity=1;
|
||||
if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) $entity=1;
|
||||
|
||||
$login='';
|
||||
|
||||
|
||||
@ -45,7 +45,7 @@ function check_user_password_ldap($usertotest,$passwordtotest,$entitytotest)
|
||||
|
||||
// Force master entity in transversal mode
|
||||
$entity=$entitytotest;
|
||||
if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)) $entity=1;
|
||||
if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) $entity=1;
|
||||
|
||||
$login='';
|
||||
$resultFetchUser='';
|
||||
|
||||
@ -63,9 +63,9 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left
|
||||
-- Home - Menu users and groups
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '1', __HANDLER__, 'left', 400__+MAX_llx_menu__, 'home', 'users', 1__+MAX_llx_menu__, '/user/home.php?leftmenu=users', 'MenuUsersAndGroups', 0, 'users', '', '', 2, 4, __ENTITY__);
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$leftmenu=="users"', __HANDLER__, 'left', 401__+MAX_llx_menu__, 'home', '', 400__+MAX_llx_menu__, '/user/index.php?leftmenu=users', 'Users', 1, 'users', '$user->rights->user->user->lire || $user->admin', '', 2, 0, __ENTITY__);
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$leftmenu=="users"', __HANDLER__, 'left', 402__+MAX_llx_menu__, 'home', '', 401__+MAX_llx_menu__, '/user/card.php?leftmenu=users&action=create', 'NewUser', 2, 'users', '$user->rights->user->user->creer || $user->admin', '', 2, 0, __ENTITY__);
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$leftmenu=="users"', __HANDLER__, 'left', 403__+MAX_llx_menu__, 'home', '', 400__+MAX_llx_menu__, '/user/group/index.php?leftmenu=users', 'Groups', 1, 'users', '($conf->global->MAIN_USE_ADVANCED_PERMS?$user->rights->user->group_advance->read:$user->rights->user->user->lire) || $user->admin', '', 2, 1, __ENTITY__);
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$leftmenu=="users"', __HANDLER__, 'left', 404__+MAX_llx_menu__, 'home', '', 403__+MAX_llx_menu__, '/user/group/card.php?leftmenu=users&action=create', 'NewGroup', 2, 'users', '($conf->global->MAIN_USE_ADVANCED_PERMS?$user->rights->user->group_advance->write:$user->rights->user->user->creer) || $user->admin', '', 2, 0, __ENTITY__);
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$leftmenu=="users"', __HANDLER__, 'left', 402__+MAX_llx_menu__, 'home', '', 401__+MAX_llx_menu__, '/user/card.php?leftmenu=users&action=create', 'NewUser', 2, 'users', '($user->rights->user->user->creer || $user->admin) && !(! empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE)', '', 2, 0, __ENTITY__);
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$leftmenu=="users"', __HANDLER__, 'left', 403__+MAX_llx_menu__, 'home', '', 400__+MAX_llx_menu__, '/user/group/index.php?leftmenu=users', 'Groups', 1, 'users', '(($conf->global->MAIN_USE_ADVANCED_PERMS?$user->rights->user->group_advance->read:$user->rights->user->user->lire) || $user->admin) && !(! empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE)', '', 2, 1, __ENTITY__);
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$leftmenu=="users"', __HANDLER__, 'left', 404__+MAX_llx_menu__, 'home', '', 403__+MAX_llx_menu__, '/user/group/card.php?leftmenu=users&action=create', 'NewGroup', 2, 'users', '(($conf->global->MAIN_USE_ADVANCED_PERMS?$user->rights->user->group_advance->write:$user->rights->user->user->creer) || $user->admin) && !(! empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE)', '', 2, 0, __ENTITY__);
|
||||
-- Third parties
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->societe->enabled', __HANDLER__, 'left', 500__+MAX_llx_menu__, 'companies', 'thirdparties', 2__+MAX_llx_menu__, '/societe/index.php?leftmenu=thirdparties', 'ThirdParty', 0, 'companies', '$user->rights->societe->lire', '', 2, 0, __ENTITY__);
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->societe->enabled', __HANDLER__, 'left', 501__+MAX_llx_menu__, 'companies', '', 500__+MAX_llx_menu__, '/societe/card.php?action=create', 'MenuNewThirdParty', 1, 'companies', '$user->rights->societe->lire', '', 2, 0, __ENTITY__);
|
||||
@ -211,7 +211,7 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2400__+MAX_llx_menu__, 'accountancy', 'accounting', 6__+MAX_llx_menu__, '/accountancy/index.php?leftmenu=accountancy', 'MenuAccountancy', 0, 'accountancy', '! empty($conf->accounting->enabled) || $user->rights->accounting->bind->write || $user->rights->accounting->bind->write || $user->rights->compta->resultat->lire', '', 0, 7, __ENTITY__);
|
||||
-- Setup
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2451__+MAX_llx_menu__, 'accountancy', 'accountancy_admin', 2400__+MAX_llx_menu__, '/accountancy/index.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'Setup', 1, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 1, __ENTITY__);
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2457__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_journal', 2451__+MAX_llx_menu__, '/accountancy/admin/journals_list.php?id=35&mainmenu=accountancy&leftmenu=accountancy_admin', 'AccountingJournals', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 10, __ENTITY__);
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2454__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_journal', 2451__+MAX_llx_menu__, '/accountancy/admin/journals_list.php?id=35&mainmenu=accountancy&leftmenu=accountancy_admin', 'AccountingJournals', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 10, __ENTITY__);
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2455__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_chartmodel', 2451__+MAX_llx_menu__, '/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'Pcg_version', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 20, __ENTITY__);
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2456__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_chart', 2451__+MAX_llx_menu__, '/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'Chartofaccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 30, __ENTITY__);
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2457__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_chart_group', 2451__+MAX_llx_menu__, '/accountancy/admin/categories_list.php?id=32&mainmenu=accountancy&leftmenu=accountancy_admin', 'AccountingCategory', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 40, __ENTITY__);
|
||||
|
||||
@ -597,12 +597,12 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu
|
||||
if ($usemenuhider || empty($leftmenu) || $leftmenu=="users")
|
||||
{
|
||||
$newmenu->add("", $langs->trans("Users"), 1, $user->rights->user->user->lire || $user->admin);
|
||||
$newmenu->add("/user/card.php?leftmenu=users&action=create", $langs->trans("NewUser"),2, $user->rights->user->user->creer || $user->admin, '', 'home');
|
||||
$newmenu->add("/user/card.php?leftmenu=users&action=create", $langs->trans("NewUser"),2, ($user->rights->user->user->creer || $user->admin) && !(! empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE), '', 'home');
|
||||
$newmenu->add("/user/index.php?leftmenu=users", $langs->trans("ListOfUsers"), 2, $user->rights->user->user->lire || $user->admin);
|
||||
$newmenu->add("/user/hierarchy.php?leftmenu=users", $langs->trans("HierarchicView"), 2, $user->rights->user->user->lire || $user->admin);
|
||||
$newmenu->add("", $langs->trans("Groups"), 1, $user->rights->user->user->lire || $user->admin);
|
||||
$newmenu->add("/user/group/card.php?leftmenu=users&action=create", $langs->trans("NewGroup"), 2, ($conf->global->MAIN_USE_ADVANCED_PERMS?$user->rights->user->group_advance->write:$user->rights->user->user->creer) || $user->admin);
|
||||
$newmenu->add("/user/group/index.php?leftmenu=users", $langs->trans("ListOfGroups"), 2, ($conf->global->MAIN_USE_ADVANCED_PERMS?$user->rights->user->group_advance->read:$user->rights->user->user->lire) || $user->admin);
|
||||
$newmenu->add("", $langs->trans("Groups"), 1, ($user->rights->user->user->lire || $user->admin) && !(! empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE));
|
||||
$newmenu->add("/user/group/card.php?leftmenu=users&action=create", $langs->trans("NewGroup"), 2, (($conf->global->MAIN_USE_ADVANCED_PERMS?$user->rights->user->group_advance->write:$user->rights->user->user->creer) || $user->admin) && !(! empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE));
|
||||
$newmenu->add("/user/group/index.php?leftmenu=users", $langs->trans("ListOfGroups"), 2, (($conf->global->MAIN_USE_ADVANCED_PERMS?$user->rights->user->group_advance->read:$user->rights->user->user->lire) || $user->admin) && !(! empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -156,9 +156,6 @@ if (empty($dolibarr_main_limit_users)) $dolibarr_main_limit_users=0;
|
||||
if (empty($dolibarr_mailing_limit_sendbyweb)) $dolibarr_mailing_limit_sendbyweb=0;
|
||||
if (empty($dolibarr_mailing_limit_sendbycli)) $dolibarr_mailing_limit_sendbycli=0;
|
||||
if (empty($dolibarr_strict_mode)) $dolibarr_strict_mode=0; // For debug in php strict mode
|
||||
// TODO Multicompany Remove this. Useless.
|
||||
if (empty($multicompany_transverse_mode)) $multicompany_transverse_mode=0;
|
||||
if (empty($multicompany_force_entity)) $multicompany_force_entity=0; // To force entity in login page
|
||||
|
||||
// Security: CSRF protection
|
||||
// This test check if referrer ($_SERVER['HTTP_REFERER']) is same web site than Dolibarr ($_SERVER['HTTP_HOST'])
|
||||
|
||||
@ -1209,7 +1209,7 @@ class Holiday extends CommonObject
|
||||
$sql = "SELECT u.rowid";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."user as u";
|
||||
|
||||
if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode))
|
||||
if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
|
||||
{
|
||||
$sql.= ", ".MAIN_DB_PREFIX."usergroup_user as ug";
|
||||
$sql.= " WHERE (ug.fk_user = u.rowid";
|
||||
@ -1305,7 +1305,7 @@ class Holiday extends CommonObject
|
||||
$sql = "SELECT u.rowid, u.lastname, u.firstname, u.gender, u.photo, u.employee, u.statut";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."user as u";
|
||||
|
||||
if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode))
|
||||
if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
|
||||
{
|
||||
$sql.= ", ".MAIN_DB_PREFIX."usergroup_user as ug";
|
||||
$sql.= " WHERE (ug.fk_user = u.rowid";
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
<?php
|
||||
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2015 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
|
||||
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2017 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -165,7 +165,7 @@ if (empty($user->societe_id))
|
||||
DOL_DOCUMENT_ROOT."/contact/class/contact.class.php",
|
||||
DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php",
|
||||
DOL_DOCUMENT_ROOT."/product/class/product.class.php",
|
||||
DOL_DOCUMENT_ROOT."/product/class/service.class.php",
|
||||
DOL_DOCUMENT_ROOT."/product/class/product.class.php",
|
||||
DOL_DOCUMENT_ROOT."/comm/propal/class/propal.class.php",
|
||||
DOL_DOCUMENT_ROOT."/commande/class/commande.class.php",
|
||||
DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php",
|
||||
|
||||
@ -380,4 +380,18 @@ create table llx_loan_schedule
|
||||
fk_user_modif integer
|
||||
)ENGINE=innodb;
|
||||
|
||||
ALTER TABLE llx_tva ADD COLUMN datec date AFTER tms;
|
||||
ALTER TABLE llx_tva ADD COLUMN datec date AFTER tms;
|
||||
|
||||
ALTER TABLE llx_user_rights ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER rowid;
|
||||
ALTER TABLE llx_user_rights DROP FOREIGN KEY fk_user_rights_fk_user_user;
|
||||
ALTER TABLE llx_user_rights DROP INDEX uk_user_rights;
|
||||
ALTER TABLE llx_user_rights DROP INDEX fk_user;
|
||||
ALTER TABLE llx_user_rights ADD UNIQUE INDEX uk_user_rights (entity, fk_user, fk_id);
|
||||
ALTER TABLE llx_user_rights ADD CONSTRAINT fk_user_rights_fk_user_user FOREIGN KEY (fk_user) REFERENCES llx_user (rowid);
|
||||
|
||||
ALTER TABLE llx_usergroup_rights ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER rowid;
|
||||
ALTER TABLE llx_usergroup_rights DROP FOREIGN KEY fk_usergroup_rights_fk_usergroup;
|
||||
ALTER TABLE llx_usergroup_rights DROP INDEX fk_usergroup;
|
||||
ALTER TABLE llx_usergroup_rights ADD UNIQUE INDEX uk_usergroup_rights (entity, fk_usergroup, fk_id);
|
||||
ALTER TABLE llx_usergroup_rights ADD CONSTRAINT fk_usergroup_rights_fk_usergroup FOREIGN KEY (fk_usergroup) REFERENCES llx_usergroup (rowid);
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
-- ============================================================================
|
||||
-- Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
-- Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
-- Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
-- Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
-- Copyright (C) 2017 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
--
|
||||
-- This program is free software; you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
@ -21,7 +22,6 @@
|
||||
-- Delete orphans
|
||||
-- V4 DELETE llx_user_rights FROM llx_user_rights LEFT JOIN llx_user ON llx_user_rights.fk_user = llx_user.rowid WHERE llx_user.rowid IS NULL;
|
||||
|
||||
ALTER TABLE llx_user_rights ADD UNIQUE INDEX uk_user_rights (entity, fk_user, fk_id);
|
||||
|
||||
ALTER TABLE llx_user_rights ADD CONSTRAINT fk_user_rights_fk_user_user FOREIGN KEY (fk_user) REFERENCES llx_user (rowid);
|
||||
|
||||
ALTER TABLE llx_user_rights ADD UNIQUE INDEX uk_user_rights (fk_user, fk_id);
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
-- ============================================================================
|
||||
-- Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
-- Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
-- Copyright (C) 2017 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
--
|
||||
-- This program is free software; you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
@ -18,8 +19,9 @@
|
||||
|
||||
create table llx_user_rights
|
||||
(
|
||||
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||
fk_user integer NOT NULL,
|
||||
fk_id integer NOT NULL
|
||||
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||
entity integer DEFAULT 1 NOT NULL, -- multi company id
|
||||
fk_user integer NOT NULL,
|
||||
fk_id integer NOT NULL
|
||||
)ENGINE=innodb;
|
||||
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
-- ============================================================================
|
||||
-- Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
-- Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
-- Copyright (C) 2017 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
--
|
||||
-- This program is free software; you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
@ -20,5 +21,6 @@
|
||||
-- Supprime orhpelins pour permettre montee de la cle
|
||||
-- V4 DELETE llx_usergroup_rights FROM llx_usergroup_rights LEFT JOIN llx_usergroup ON llx_usergroup_rights.fk_usergroup = llx_usergroup.rowid WHERE llx_usergroup.rowid IS NULL;
|
||||
|
||||
ALTER TABLE llx_usergroup_rights ADD UNIQUE INDEX uk_usergroup_rights (entity, fk_usergroup, fk_id);
|
||||
|
||||
ALTER TABLE llx_usergroup_rights ADD CONSTRAINT fk_usergroup_rights_fk_usergroup FOREIGN KEY (fk_usergroup) REFERENCES llx_usergroup (rowid);
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
-- ============================================================================
|
||||
-- Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
-- Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
-- Copyright (C) 2017 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
--
|
||||
-- This program is free software; you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
@ -18,10 +19,10 @@
|
||||
|
||||
create table llx_usergroup_rights
|
||||
(
|
||||
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||
fk_usergroup integer NOT NULL,
|
||||
fk_id integer NOT NULL,
|
||||
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||
entity integer DEFAULT 1 NOT NULL, -- multi company id
|
||||
fk_usergroup integer NOT NULL,
|
||||
fk_id integer NOT NULL
|
||||
|
||||
UNIQUE(fk_usergroup,fk_id)
|
||||
)ENGINE=innodb;
|
||||
|
||||
|
||||
@ -1,14 +1,14 @@
|
||||
<?php
|
||||
/* Copyright (C) 2002-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2003 Xavier Dutoit <doli@sydesy.com>
|
||||
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
|
||||
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2005 Simon Tosser <simon@kornog-computing.com>
|
||||
* Copyright (C) 2006 Andre Cianfarani <andre.cianfarani@acdeveloppement.net>
|
||||
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2011 Philippe Grand <philippe.grand@atoo-net.com>
|
||||
/* Copyright (C) 2002-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2003 Xavier Dutoit <doli@sydesy.com>
|
||||
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
|
||||
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
|
||||
* Copyright (C) 2005-2017 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2005 Simon Tosser <simon@kornog-computing.com>
|
||||
* Copyright (C) 2006 Andre Cianfarani <andre.cianfarani@acdeveloppement.net>
|
||||
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2011 Philippe Grand <philippe.grand@atoo-net.com>
|
||||
* Copyright (C) 2014 Teddy Andreotti <125155@supinfo.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -98,11 +98,6 @@ if (! empty($dolibarr_main_document_root_alt))
|
||||
}
|
||||
}
|
||||
|
||||
// Set properties specific to multicompany
|
||||
// TODO Multicompany Remove this. Useless. Var should be read when required.
|
||||
$conf->multicompany->transverse_mode = empty($multicompany_transverse_mode)?'':$multicompany_transverse_mode; // Force Multi-Company transverse mode
|
||||
$conf->multicompany->force_entity = empty($multicompany_force_entity)?'':(int) $multicompany_force_entity; // Force entity in login page
|
||||
|
||||
// Chargement des includes principaux de librairies communes
|
||||
if (! defined('NOREQUIREUSER')) require_once DOL_DOCUMENT_ROOT .'/user/class/user.class.php'; // Need 500ko memory
|
||||
if (! defined('NOREQUIRETRAN')) require_once DOL_DOCUMENT_ROOT .'/core/class/translate.class.php';
|
||||
@ -170,10 +165,6 @@ if (! defined('NOREQUIREDB'))
|
||||
{
|
||||
$conf->entity = $_COOKIE['DOLENTITY'];
|
||||
}
|
||||
else if (! empty($conf->multicompany->force_entity) && is_numeric($conf->multicompany->force_entity)) // To force entity in login page
|
||||
{
|
||||
$conf->entity = $conf->multicompany->force_entity;
|
||||
}
|
||||
|
||||
// Sanitize entity
|
||||
if (! is_numeric($conf->entity)) $conf->entity=1;
|
||||
|
||||
@ -109,7 +109,7 @@ if (empty($user->socid)) $fieldstosearchall["t.note_private"]="NotePrivate";
|
||||
$arrayfields=array(
|
||||
't.field1'=>array('label'=>"Field1", 'checked'=>1),
|
||||
't.field2'=>array('label'=>"Field2", 'checked'=>1),
|
||||
//'t.entity'=>array('label'=>"Entity", 'checked'=>1, 'enabled'=>(! empty($conf->multicompany->enabled) && empty($conf->multicompany->transverse_mode))),
|
||||
//'t.entity'=>array('label'=>"Entity", 'checked'=>1, 'enabled'=>(! empty($conf->multicompany->enabled) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))),
|
||||
't.datec'=>array('label'=>"DateCreationShort", 'checked'=>0, 'position'=>500),
|
||||
't.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500),
|
||||
//'t.statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000),
|
||||
|
||||
@ -102,7 +102,7 @@ $arrayfields=array(
|
||||
't.eatby'=>array('label'=>$langs->trans("EatByDate"), 'checked'=>1),
|
||||
't.sellby'=>array('label'=>$langs->trans("SellByDate"), 'checked'=>1),
|
||||
//'t.import_key'=>array('label'=>$langs->trans("ImportKey"), 'checked'=>1),
|
||||
//'t.entity'=>array('label'=>$langs->trans("Entity"), 'checked'=>1, 'enabled'=>(! empty($conf->multicompany->enabled) && empty($conf->multicompany->transverse_mode))),
|
||||
//'t.entity'=>array('label'=>$langs->trans("Entity"), 'checked'=>1, 'enabled'=>(! empty($conf->multicompany->enabled) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))),
|
||||
//'t.fk_user_creat'=>array('label'=>$langs->trans("UserCreationShort"), 'checked'=>0, 'position'=>500),
|
||||
//'t.fk_user_modif'=>array('label'=>$langs->trans("UserModificationShort"), 'checked'=>0, 'position'=>500),
|
||||
't.datec'=>array('label'=>$langs->trans("DateCreationShort"), 'checked'=>0, 'position'=>500),
|
||||
|
||||
@ -1690,7 +1690,7 @@ class Societe extends CommonObject
|
||||
|
||||
$sql = "SELECT DISTINCT u.rowid, u.login, u.lastname, u.firstname, u.email, u.statut, u.entity, u.photo";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc, ".MAIN_DB_PREFIX."user as u";
|
||||
if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode))
|
||||
if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
|
||||
{
|
||||
$sql.= ", ".MAIN_DB_PREFIX."usergroup_user as ug";
|
||||
$sql.= " WHERE ((ug.fk_user = sc.fk_user";
|
||||
|
||||
@ -142,13 +142,13 @@ if (! empty($socid))
|
||||
$sql = "SELECT DISTINCT u.rowid, u.login, u.fk_soc, u.lastname, u.firstname, u.statut, u.entity, u.photo";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."user as u";
|
||||
$sql .= " , ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode))
|
||||
if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
|
||||
{
|
||||
$sql.= ", ".MAIN_DB_PREFIX."usergroup_user as ug";
|
||||
}
|
||||
$sql .= " WHERE sc.fk_soc =".$object->id;
|
||||
$sql .= " AND sc.fk_user = u.rowid";
|
||||
if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode))
|
||||
if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
|
||||
{
|
||||
$sql.= " AND ((ug.fk_user = sc.fk_user";
|
||||
$sql.= " AND ug.entity = ".$conf->entity.")";
|
||||
@ -229,7 +229,7 @@ if (! empty($socid))
|
||||
|
||||
$sql = "SELECT DISTINCT u.rowid, u.lastname, u.firstname, u.login, u.email, u.statut, u.fk_soc, u.photo";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."user as u";
|
||||
if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode))
|
||||
if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
|
||||
{
|
||||
$sql.= ", ".MAIN_DB_PREFIX."usergroup_user as ug";
|
||||
$sql.= " WHERE ((ug.fk_user = u.rowid";
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
* Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org>
|
||||
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
|
||||
* Copyright (C) 2005-2016 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2005-2017 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2005 Lionel Cousteix <etm_ltd@tiscali.co.uk>
|
||||
* Copyright (C) 2011 Herve Prot <herve.prot@symeos.com>
|
||||
* Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
|
||||
@ -57,6 +57,12 @@ $subaction = GETPOST('subaction','alpha');
|
||||
$group = GETPOST("group","int",3);
|
||||
$cancel = GETPOST('cancel');
|
||||
|
||||
// Users/Groups management only in master entity if transverse mode
|
||||
if (($action == 'create' || $action == 'adduserldap') && ! empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE)
|
||||
{
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
// Define value to know what current user can do on users
|
||||
$canadduser=(! empty($user->admin) || $user->rights->user->user->creer);
|
||||
$canreaduser=(! empty($user->admin) || $user->rights->user->user->lire);
|
||||
@ -228,11 +234,11 @@ if (empty($reshook)) {
|
||||
|
||||
// Set entity property
|
||||
$entity = GETPOST('entity', 'int');
|
||||
if (!empty($conf->multicompany->enabled)) {
|
||||
if (!empty($_POST["superadmin"])) {
|
||||
if (! empty($conf->multicompany->enabled)) {
|
||||
if (GETPOST('superadmin', 'int')) {
|
||||
$object->entity = 0;
|
||||
} else {
|
||||
if ($conf->multicompany->transverse_mode) {
|
||||
if (! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
|
||||
$object->entity = 1; // all users are forced into master entity
|
||||
} else {
|
||||
$object->entity = ($entity == '' ? 1 : $entity);
|
||||
@ -249,8 +255,8 @@ if (empty($reshook)) {
|
||||
|
||||
$id = $object->create($user);
|
||||
if ($id > 0) {
|
||||
if (isset($_POST['password']) && trim($_POST['password'])) {
|
||||
$object->setPassword($user, trim($_POST['password']));
|
||||
if (GETPOST('password')) {
|
||||
$object->setPassword($user, GETPOST('password'));
|
||||
}
|
||||
if (! empty($conf->categorie->enabled)) {
|
||||
// Categories association
|
||||
@ -283,10 +289,10 @@ if (empty($reshook)) {
|
||||
|
||||
$object->fetch($id);
|
||||
if ($action == 'addgroup') {
|
||||
$object->SetInGroup($group, ($conf->multicompany->transverse_mode ? GETPOST("entity") : $editgroup->entity));
|
||||
$object->SetInGroup($group, (! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) ? GETPOST('entity', 'int') : $editgroup->entity));
|
||||
}
|
||||
if ($action == 'removegroup') {
|
||||
$object->RemoveFromGroup($group, ($conf->multicompany->transverse_mode ? GETPOST("entity") : $editgroup->entity));
|
||||
$object->RemoveFromGroup($group, (! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) ? GETPOST('entity', 'int') : $editgroup->entity));
|
||||
}
|
||||
|
||||
if ($result > 0) {
|
||||
@ -367,7 +373,7 @@ if (empty($reshook)) {
|
||||
{
|
||||
$object->entity = 0;
|
||||
}
|
||||
else if ($conf->multicompany->transverse_mode)
|
||||
else if (! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
|
||||
{
|
||||
$object->entity = 1; // all users in master entity
|
||||
}
|
||||
@ -409,7 +415,7 @@ if (empty($reshook)) {
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error && isset($_POST['contactid'])) {
|
||||
if (!$error && GETPOST('contactid', 'int')) {
|
||||
$contactid = GETPOST('contactid', 'int');
|
||||
|
||||
if ($contactid > 0) {
|
||||
@ -617,7 +623,7 @@ $formfile = new FormFile($db);
|
||||
|
||||
llxHeader('',$langs->trans("UserCard"));
|
||||
|
||||
if (($action == 'create') || ($action == 'adduserldap'))
|
||||
if ($action == 'create' || $action == 'adduserldap')
|
||||
{
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
@ -858,7 +864,7 @@ if (($action == 'create') || ($action == 'adduserldap'))
|
||||
print '<td>';
|
||||
print $form->selectyesno('admin',GETPOST('admin'),1);
|
||||
|
||||
if (! empty($conf->multicompany->enabled) && ! $user->entity && empty($conf->multicompany->transverse_mode))
|
||||
if (! empty($conf->multicompany->enabled) && ! $user->entity && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
|
||||
{
|
||||
if (! empty($conf->use_javascript_ajax))
|
||||
{
|
||||
@ -888,8 +894,8 @@ if (($action == 'create') || ($action == 'adduserldap'))
|
||||
});
|
||||
</script>';
|
||||
}
|
||||
$checked=($_POST["superadmin"]?' checked':'');
|
||||
$disabled=($_POST["superadmin"]?'':' disabled');
|
||||
$checked=(GETPOST('superadmin', 'int')?' checked':'');
|
||||
$disabled=(GETPOST('superadmin', 'int')?'':' disabled');
|
||||
print '<input type="checkbox" name="superadmin" value="1"'.$checked.$disabled.' /> '.$langs->trans("SuperAdministrator");
|
||||
}
|
||||
print "</td></tr>\n";
|
||||
@ -1005,9 +1011,9 @@ if (($action == 'create') || ($action == 'adduserldap'))
|
||||
print '</td></tr>';
|
||||
|
||||
// Multicompany
|
||||
if (! empty($conf->multicompany->enabled))
|
||||
if (! empty($conf->multicompany->enabled) && is_object($mc))
|
||||
{
|
||||
if (empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity && is_object($mc))
|
||||
if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity)
|
||||
{
|
||||
print "<tr>".'<td>'.$langs->trans("Entity").'</td>';
|
||||
print "<td>".$mc->select_entities($conf->entity);
|
||||
@ -1226,7 +1232,7 @@ else
|
||||
*/
|
||||
if ($action == 'password')
|
||||
{
|
||||
print $form->formconfirm("card.php?id=$object->id",$langs->trans("ReinitPassword"),$langs->trans("ConfirmReinitPassword",$object->login),"confirm_password", '', 0, 1);
|
||||
print $form->formconfirm($_SERVER['PHP_SELF']."?id=$object->id",$langs->trans("ReinitPassword"),$langs->trans("ConfirmReinitPassword",$object->login),"confirm_password", '', 0, 1);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1234,7 +1240,7 @@ else
|
||||
*/
|
||||
if ($action == 'passwordsend')
|
||||
{
|
||||
print $form->formconfirm("card.php?id=$object->id",$langs->trans("SendNewPassword"),$langs->trans("ConfirmSendNewPassword",$object->login),"confirm_passwordsend", '', 0, 1);
|
||||
print $form->formconfirm($_SERVER['PHP_SELF']."?id=$object->id",$langs->trans("SendNewPassword"),$langs->trans("ConfirmSendNewPassword",$object->login),"confirm_passwordsend", '', 0, 1);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1242,7 +1248,7 @@ else
|
||||
*/
|
||||
if ($action == 'disable')
|
||||
{
|
||||
print $form->formconfirm("card.php?id=$object->id",$langs->trans("DisableAUser"),$langs->trans("ConfirmDisableUser",$object->login),"confirm_disable", '', 0, 1);
|
||||
print $form->formconfirm($_SERVER['PHP_SELF']."?id=$object->id",$langs->trans("DisableAUser"),$langs->trans("ConfirmDisableUser",$object->login),"confirm_disable", '', 0, 1);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1250,7 +1256,7 @@ else
|
||||
*/
|
||||
if ($action == 'enable')
|
||||
{
|
||||
print $form->formconfirm("card.php?id=$object->id",$langs->trans("EnableAUser"),$langs->trans("ConfirmEnableUser",$object->login),"confirm_enable", '', 0, 1);
|
||||
print $form->formconfirm($_SERVER['PHP_SELF']."?id=$object->id",$langs->trans("EnableAUser"),$langs->trans("ConfirmEnableUser",$object->login),"confirm_enable", '', 0, 1);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1258,7 +1264,7 @@ else
|
||||
*/
|
||||
if ($action == 'delete')
|
||||
{
|
||||
print $form->formconfirm("card.php?id=$object->id",$langs->trans("DeleteAUser"),$langs->trans("ConfirmDeleteUser",$object->login),"confirm_delete", '', 0, 1);
|
||||
print $form->formconfirm($_SERVER['PHP_SELF']."?id=$object->id",$langs->trans("DeleteAUser"),$langs->trans("ConfirmDeleteUser",$object->login),"confirm_delete", '', 0, 1);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1476,26 +1482,6 @@ else
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// Multicompany
|
||||
// TODO This should be done with hook formObjectOption
|
||||
if (is_object($mc))
|
||||
{
|
||||
if (! empty($conf->multicompany->enabled) && empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity)
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("Entity").'</td><td>';
|
||||
if (empty($object->entity))
|
||||
{
|
||||
print $langs->trans("AllEntities");
|
||||
}
|
||||
else
|
||||
{
|
||||
$mc->getInfo($object->entity);
|
||||
print $mc->label;
|
||||
}
|
||||
print "</td></tr>\n";
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($conf->file->main_authentication) && preg_match('/openid/',$conf->file->main_authentication) && ! empty($conf->global->MAIN_OPENIDURL_PERUSER))
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("OpenIDURL").'</td>';
|
||||
@ -1519,23 +1505,23 @@ else
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("LinkToCompanyContact").'</td>';
|
||||
print '<td>';
|
||||
if (isset($object->societe_id) && $object->societe_id > 0)
|
||||
if (isset($object->socid) && $object->socid > 0)
|
||||
{
|
||||
$societe = new Societe($db);
|
||||
$societe->fetch($object->societe_id);
|
||||
$societe->fetch($object->socid);
|
||||
print $societe->getNomUrl(1,'');
|
||||
}
|
||||
else
|
||||
{
|
||||
print $langs->trans("ThisUserIsNot");
|
||||
}
|
||||
if (! empty($object->contact_id))
|
||||
if (! empty($object->contactid))
|
||||
{
|
||||
$contact = new Contact($db);
|
||||
$contact->fetch($object->contact_id);
|
||||
if ($object->societe_id > 0) print ' / ';
|
||||
$contact->fetch($object->contactid);
|
||||
if ($object->socid > 0) print ' / ';
|
||||
else print '<br>';
|
||||
print '<a href="'.DOL_URL_ROOT.'/contact/card.php?id='.$object->contact_id.'">'.img_object($langs->trans("ShowContact"),'contact').' '.dol_trunc($contact->getFullName($langs),32).'</a>';
|
||||
print '<a href="'.DOL_URL_ROOT.'/contact/card.php?id='.$object->contactid.'">'.img_object($langs->trans("ShowContact"),'contact').' '.dol_trunc($contact->getFullName($langs),32).'</a>';
|
||||
}
|
||||
print '</td>';
|
||||
print '</tr>'."\n";
|
||||
@ -1594,7 +1580,7 @@ else
|
||||
print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NoEMail")).'">'.$langs->trans('SendMail').'</a></div>';
|
||||
}
|
||||
|
||||
if ($caneditfield && (empty($conf->multicompany->enabled) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1)))
|
||||
if ($caneditfield && (empty($conf->multicompany->enabled) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1)))
|
||||
{
|
||||
if (! empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED))
|
||||
{
|
||||
@ -1606,7 +1592,7 @@ else
|
||||
}
|
||||
}
|
||||
elseif ($caneditpassword && ! $object->ldap_sid &&
|
||||
(empty($conf->multicompany->enabled) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1)))
|
||||
(empty($conf->multicompany->enabled) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1)))
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=edit">'.$langs->trans("EditPassword").'</a></div>';
|
||||
}
|
||||
@ -1619,7 +1605,7 @@ else
|
||||
print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("UserDisabled")).'">'.$langs->trans("ReinitPassword").'</a></div>';
|
||||
}
|
||||
elseif (($user->id != $id && $caneditpassword) && $object->login && !$object->ldap_sid &&
|
||||
((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1)))
|
||||
((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1)))
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=password">'.$langs->trans("ReinitPassword").'</a></div>';
|
||||
}
|
||||
@ -1629,7 +1615,7 @@ else
|
||||
print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("UserDisabled")).'">'.$langs->trans("SendNewPassword").'</a></div>';
|
||||
}
|
||||
else if (($user->id != $id && $caneditpassword) && $object->login && !$object->ldap_sid &&
|
||||
((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1)))
|
||||
((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1)))
|
||||
{
|
||||
if ($object->email) print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=passwordsend">'.$langs->trans("SendNewPassword").'</a></div>';
|
||||
else print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NoEMail")).'">'.$langs->trans("SendNewPassword").'</a></div>';
|
||||
@ -1638,19 +1624,19 @@ else
|
||||
|
||||
// Activer
|
||||
if ($user->id <> $id && $candisableuser && $object->statut == 0 &&
|
||||
((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1)))
|
||||
((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1)))
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=enable">'.$langs->trans("Reactivate").'</a></div>';
|
||||
}
|
||||
// Desactiver
|
||||
if ($user->id <> $id && $candisableuser && $object->statut == 1 &&
|
||||
((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1)))
|
||||
((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1)))
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?action=disable&id='.$object->id.'">'.$langs->trans("DisableUser").'</a></div>';
|
||||
}
|
||||
// Delete
|
||||
if ($user->id <> $id && $candisableuser &&
|
||||
((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1)))
|
||||
((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1)))
|
||||
{
|
||||
if ($user->admin || ! $object->admin) // If user edited is admin, delete is possible on for an admin
|
||||
{
|
||||
@ -1791,7 +1777,7 @@ else
|
||||
|
||||
if (! empty($groupslist))
|
||||
{
|
||||
if (! (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)))
|
||||
if (! (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)))
|
||||
{
|
||||
foreach($groupslist as $groupforuser)
|
||||
{
|
||||
@ -1809,33 +1795,41 @@ else
|
||||
|
||||
print '<table class="noborder" width="100%">'."\n";
|
||||
print '<tr class="liste_titre"><th class="liste_titre" width="25%">'.$langs->trans("Groups").'</th>'."\n";
|
||||
if(! empty($conf->multicompany->enabled) && !empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity)
|
||||
if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity)
|
||||
{
|
||||
print '<td class="liste_titre" width="25%">'.$langs->trans("Entity").'</td>';
|
||||
}
|
||||
print '<th align="right">';
|
||||
if ($caneditgroup)
|
||||
{
|
||||
print $form->select_dolgroups('', 'group', 1, $exclude, 0, '', '', $object->entity);
|
||||
print ' ';
|
||||
// Multicompany
|
||||
if (! empty($conf->multicompany->enabled))
|
||||
{
|
||||
if ($conf->entity == 1 && $conf->multicompany->transverse_mode)
|
||||
{
|
||||
print '</td><td>'.$langs->trans("Entity").'</td>';
|
||||
print "<td>".$mc->select_entities($conf->entity);
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<input type="hidden" name="entity" value="'.$conf->entity.'" />';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<input type="hidden" name="entity" value="'.$conf->entity.'" />';
|
||||
}
|
||||
print '<input type="submit" class="button" value="'.$langs->trans("Add").'" />';
|
||||
// Users/Groups management only in master entity if transverse mode
|
||||
if (! empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE)
|
||||
{
|
||||
// nothing
|
||||
}
|
||||
else
|
||||
{
|
||||
print $form->select_dolgroups('', 'group', 1, $exclude, 0, '', '', $object->entity);
|
||||
print ' ';
|
||||
// Multicompany
|
||||
if (! empty($conf->multicompany->enabled))
|
||||
{
|
||||
if ($conf->entity == 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE)
|
||||
{
|
||||
print '</td><td>'.$langs->trans("Entity").'</td>';
|
||||
print "<td>".$mc->select_entities($conf->entity);
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<input type="hidden" name="entity" value="'.$conf->entity.'" />';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<input type="hidden" name="entity" value="'.$conf->entity.'" />';
|
||||
}
|
||||
print '<input type="submit" class="button" value="'.$langs->trans("Add").'" />';
|
||||
}
|
||||
}
|
||||
print '</th></tr>'."\n";
|
||||
|
||||
@ -1859,7 +1853,7 @@ else
|
||||
print img_object($langs->trans("ShowGroup"),"group").' '.$group->name;
|
||||
}
|
||||
print '</td>';
|
||||
if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity)
|
||||
if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity)
|
||||
{
|
||||
print '<td class="valeur">';
|
||||
if (! empty($group->usergroup_entity))
|
||||
@ -1877,7 +1871,7 @@ else
|
||||
}
|
||||
}
|
||||
print '<td align="right">';
|
||||
if ($caneditgroup && empty($conf->multicompany->transverse_mode))
|
||||
if ($caneditgroup && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
|
||||
{
|
||||
print '<a href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=removegroup&group='.$group->id.'">';
|
||||
print img_delete($langs->trans("RemoveFromGroup"));
|
||||
@ -2037,7 +2031,7 @@ else
|
||||
|
||||
// Administrator
|
||||
print '<tr><td>'.$langs->trans("Administrator").'</td>';
|
||||
if ($object->societe_id > 0)
|
||||
if ($object->socid > 0)
|
||||
{
|
||||
$langs->load("admin");
|
||||
print '<td>';
|
||||
@ -2062,7 +2056,7 @@ else
|
||||
{
|
||||
print $form->selectyesno('admin',$object->admin,1);
|
||||
|
||||
if (! empty($conf->multicompany->enabled) && ! $user->entity && empty($conf->multicompany->transverse_mode))
|
||||
if (! empty($conf->multicompany->enabled) && ! $user->entity && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
|
||||
{
|
||||
if ($conf->use_javascript_ajax)
|
||||
{
|
||||
@ -2124,7 +2118,7 @@ else
|
||||
if ($user->id == $object->id || ! $user->admin)
|
||||
{
|
||||
$type=$langs->trans("Internal");
|
||||
if ($object->societe_id) $type=$langs->trans("External");
|
||||
if ($object->socid) $type=$langs->trans("External");
|
||||
print $form->textwithpicto($type,$langs->trans("InternalExternalDesc"));
|
||||
if ($object->ldap_sid) print ' ('.$langs->trans("DomainUser").')';
|
||||
}
|
||||
@ -2385,16 +2379,16 @@ else
|
||||
{
|
||||
print '<tr><td width="25%">'.$langs->trans("LinkToCompanyContact").'</td>';
|
||||
print '<td>';
|
||||
if ($object->societe_id > 0)
|
||||
if ($object->socid > 0)
|
||||
{
|
||||
$societe = new Societe($db);
|
||||
$societe->fetch($object->societe_id);
|
||||
$societe->fetch($object->socid);
|
||||
print $societe->getNomUrl(1,'');
|
||||
if ($object->contact_id)
|
||||
if ($object->contactid)
|
||||
{
|
||||
$contact = new Contact($db);
|
||||
$contact->fetch($object->contact_id);
|
||||
print ' / <a href="'.DOL_URL_ROOT.'/contact/card.php?id='.$object->contact_id.'">'.img_object($langs->trans("ShowContact"),'contact').' '.dol_trunc($contact->getFullName($langs),32).'</a>';
|
||||
$contact->fetch($object->contactid);
|
||||
print ' / <a href="'.DOL_URL_ROOT.'/contact/card.php?id='.$object->contactid.'">'.img_object($langs->trans("ShowContact"),'contact').' '.dol_trunc($contact->getFullName($langs),32).'</a>';
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -2427,25 +2421,10 @@ else
|
||||
print "</tr>\n";
|
||||
}
|
||||
|
||||
// Multicompany
|
||||
// TODO check if user not linked with the current entity before change entity (thirdparty, invoice, etc.) !!
|
||||
if (! empty($conf->multicompany->enabled) && is_object($mc))
|
||||
{
|
||||
if (empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity)
|
||||
{
|
||||
print "<tr>".'<td>'.$langs->trans("Entity").'</td>';
|
||||
print "<td>".$mc->select_entities($object->entity, 'entity', '', 0, 1); // last parameter 1 means, show also a choice 0=>'all entities'
|
||||
print "</td></tr>\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<input type="hidden" name="entity" value="'.$conf->entity.'" />';
|
||||
}
|
||||
}
|
||||
|
||||
// Other attributes
|
||||
$parameters=array('colspan' => ' colspan="2"');
|
||||
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
||||
print $hookmanager->resPrint;
|
||||
if (empty($reshook) && ! empty($extrafields->attribute_label))
|
||||
{
|
||||
print $object->showOptionals($extrafields,'edit');
|
||||
@ -2491,7 +2470,8 @@ else
|
||||
$genallowed = $user->rights->user->user->creer;
|
||||
$delallowed = $user->rights->user->user->supprimer;
|
||||
|
||||
$somethingshown = $formfile->show_documents('user', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', 0, '', $soc->default_lang);
|
||||
print $formfile->showdocuments('user', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', 0, '', $soc->default_lang);
|
||||
$somethingshown = $formfile->numoffiles;
|
||||
|
||||
// Show links to link elements
|
||||
$linktoelem = $form->showLinkToObjectBlock($object, null, null);
|
||||
|
||||
@ -107,16 +107,16 @@ class User extends CommonObject
|
||||
public $all_permissions_are_loaded; // All permission are loaded
|
||||
public $nb_rights; // Number of rights granted to the user
|
||||
private $_tab_loaded=array(); // Cache array of already loaded permissions
|
||||
|
||||
|
||||
public $conf; // To store personal config
|
||||
public $default_values; // To store default values for user
|
||||
public $lastsearch_values_tmp; // To store current search criterias for user
|
||||
public $lastsearch_values; // To store last saved search criterias for user
|
||||
|
||||
|
||||
public $users; // To store all tree of users hierarchy
|
||||
public $parentof; // To store an array of all parents for all ids.
|
||||
private $cache_childids;
|
||||
|
||||
|
||||
public $accountancy_code; // Accountancy code in prevision of the complete accountancy module
|
||||
|
||||
public $thm; // Average cost of employee - Used for valuation of time spent
|
||||
@ -207,7 +207,7 @@ class User extends CommonObject
|
||||
|
||||
if ($entity < 0)
|
||||
{
|
||||
if ((empty($conf->multicompany->enabled) || empty($conf->multicompany->transverse_mode)) && (! empty($user->entity)))
|
||||
if ((empty($conf->multicompany->enabled) || empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) && (! empty($user->entity)))
|
||||
{
|
||||
$sql.= " WHERE u.entity IN (0,".$conf->entity.")";
|
||||
}
|
||||
@ -218,7 +218,7 @@ class User extends CommonObject
|
||||
}
|
||||
else // The fetch was forced on an entity
|
||||
{
|
||||
if (!empty($conf->multicompany->enabled) && !empty($conf->multicompany->transverse_mode))
|
||||
if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
|
||||
$sql.= " WHERE u.entity IS NOT NULL"; // multicompany is on in transverse mode or user making fetch is on entity 0, so user is allowed to fetch anywhere into database
|
||||
else
|
||||
$sql.= " WHERE u.entity IN (0, ".$conf->entity.")";
|
||||
@ -365,7 +365,7 @@ class User extends CommonObject
|
||||
$this->error=$this->db->lasterror();
|
||||
return -2;
|
||||
}
|
||||
|
||||
|
||||
// Load user->default_values for user. TODO Save this in memcached ?
|
||||
$sql = "SELECT rowid, entity, type, page, param, value";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."default_values";
|
||||
@ -376,7 +376,7 @@ class User extends CommonObject
|
||||
{
|
||||
while ($obj = $this->db->fetch_object($resql))
|
||||
{
|
||||
if (! empty($obj->page) && ! empty($obj->type) && ! empty($obj->param))
|
||||
if (! empty($obj->page) && ! empty($obj->type) && ! empty($obj->param))
|
||||
{
|
||||
$this->default_values[$obj->page][$obj->type][$obj->param]=$obj->value;
|
||||
}
|
||||
@ -389,7 +389,7 @@ class User extends CommonObject
|
||||
return -3;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -469,9 +469,9 @@ class User extends CommonObject
|
||||
$obj = $this->db->fetch_object($result);
|
||||
$nid = $obj->id;
|
||||
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."user_rights WHERE fk_user = ".$this->id." AND fk_id=".$nid;
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."user_rights WHERE fk_user = ".$this->id." AND fk_id=".$nid." AND entity = ".$entity;
|
||||
if (! $this->db->query($sql)) $error++;
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."user_rights (fk_user, fk_id) VALUES (".$this->id.", ".$nid.")";
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."user_rights (entity, fk_user, fk_id) VALUES (".$entity.", ".$this->id.", ".$nid.")";
|
||||
if (! $this->db->query($sql)) $error++;
|
||||
|
||||
$i++;
|
||||
@ -581,6 +581,7 @@ class User extends CommonObject
|
||||
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."user_rights";
|
||||
$sql.= " WHERE fk_user = ".$this->id." AND fk_id=".$nid;
|
||||
$sql.= " AND entity = ".$entity;
|
||||
if (! $this->db->query($sql)) $error++;
|
||||
|
||||
$i++;
|
||||
@ -660,7 +661,7 @@ class User extends CommonObject
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."user_rights as ur";
|
||||
$sql.= ", ".MAIN_DB_PREFIX."rights_def as r";
|
||||
$sql.= " WHERE r.id = ur.fk_id";
|
||||
$sql.= " AND r.entity IN (0,".(! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)?"1,":"").$conf->entity.")";
|
||||
$sql.= " AND ur.entity = ".$conf->entity;
|
||||
$sql.= " AND ur.fk_user= ".$this->id;
|
||||
$sql.= " AND r.perms IS NOT NULL";
|
||||
if ($moduletag) $sql.= " AND r.module = '".$this->db->escape($moduletag)."'";
|
||||
@ -706,11 +707,8 @@ class User extends CommonObject
|
||||
$sql.= " ".MAIN_DB_PREFIX."usergroup_user as gu,";
|
||||
$sql.= " ".MAIN_DB_PREFIX."rights_def as r";
|
||||
$sql.= " WHERE r.id = gr.fk_id";
|
||||
if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)) {
|
||||
$sql.= " AND gu.entity IN (0,".$conf->entity.")";
|
||||
} else {
|
||||
$sql.= " AND r.entity = ".$conf->entity;
|
||||
}
|
||||
$sql.= " AND gr.entity = ".$conf->entity;
|
||||
$sql.= " AND r.entity = ".$conf->entity;
|
||||
$sql.= " AND gr.fk_usergroup = gu.fk_usergroup";
|
||||
$sql.= " AND gu.fk_user = ".$this->id;
|
||||
$sql.= " AND r.perms IS NOT NULL";
|
||||
@ -2014,14 +2012,14 @@ class User extends CommonObject
|
||||
|
||||
$result=''; $label='';
|
||||
$link=''; $linkstart=''; $linkend='';
|
||||
|
||||
|
||||
if (! empty($this->photo))
|
||||
{
|
||||
$label.= '<div class="photointooltip">';
|
||||
$label.= Form::showphoto('userphoto', $this, 80, 0, 0, 'photowithmargin photologintooltip', 'small', 0, 1);
|
||||
$label.= '</div><div style="clear: both;"></div>';
|
||||
}
|
||||
|
||||
|
||||
$label.= '<div class="centpercent">';
|
||||
$label.= '<u>' . $langs->trans("User") . '</u><br>';
|
||||
$label.= '<b>' . $langs->trans('Name') . ':</b> ' . $this->getFullName($langs,'','');
|
||||
@ -2112,9 +2110,9 @@ class User extends CommonObject
|
||||
}
|
||||
$result.=$linkend;
|
||||
//if ($withpictoimg == -1) $result.='</div>';
|
||||
|
||||
|
||||
$result.=$companylink;
|
||||
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@ -2573,7 +2571,7 @@ class User extends CommonObject
|
||||
// Init $this->users array
|
||||
$sql = "SELECT DISTINCT u.rowid, u.firstname, u.lastname, u.fk_user, u.fk_soc, u.login, u.email, u.gender, u.admin, u.statut, u.photo, u.entity"; // Distinct reduce pb with old tables with duplicates
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."user as u";
|
||||
if(! empty($conf->multicompany->enabled) && $conf->entity == 1 && (! empty($conf->multicompany->transverse_mode) || (! empty($user->admin) && empty($user->entity))))
|
||||
if(! empty($conf->multicompany->enabled) && $conf->entity == 1 && (! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) || (! empty($user->admin) && empty($user->entity))))
|
||||
{
|
||||
$sql.= " WHERE u.entity IS NOT NULL";
|
||||
}
|
||||
|
||||
@ -39,7 +39,7 @@ class UserGroup extends CommonObject
|
||||
protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
|
||||
public $picto='group';
|
||||
public $entity; // Entity of group
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @see name
|
||||
@ -252,16 +252,19 @@ class UserGroup extends CommonObject
|
||||
/**
|
||||
* Add a permission to a group
|
||||
*
|
||||
* @param int $rid id du droit a ajouter
|
||||
* @param string $allmodule Ajouter tous les droits du module allmodule
|
||||
* @param string $allperms Ajouter tous les droits du module allmodule, perms allperms
|
||||
* @return int > 0 if OK, < 0 if KO
|
||||
* @param int $rid id du droit a ajouter
|
||||
* @param string $allmodule Ajouter tous les droits du module allmodule
|
||||
* @param string $allperms Ajouter tous les droits du module allmodule, perms allperms
|
||||
* @param int $entity Entity to use
|
||||
* @return int > 0 if OK, < 0 if KO
|
||||
*/
|
||||
function addrights($rid,$allmodule='',$allperms='')
|
||||
function addrights($rid, $allmodule='', $allperms='', $entity=0)
|
||||
{
|
||||
global $conf, $user, $langs;
|
||||
|
||||
dol_syslog(get_class($this)."::addrights $rid, $allmodule, $allperms");
|
||||
$entity = (! empty($entity)?$entity:$conf->entity);
|
||||
|
||||
dol_syslog(get_class($this)."::addrights $rid, $allmodule, $allperms, $entity");
|
||||
$error=0;
|
||||
$whereforadd='';
|
||||
|
||||
@ -274,7 +277,7 @@ class UserGroup extends CommonObject
|
||||
$sql = "SELECT module, perms, subperms";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."rights_def";
|
||||
$sql.= " WHERE id = '".$this->db->escape($rid)."'";
|
||||
$sql.= " AND entity = ".$conf->entity;
|
||||
$sql.= " AND entity = ".$entity;
|
||||
|
||||
$result=$this->db->query($sql);
|
||||
if ($result) {
|
||||
@ -311,7 +314,7 @@ class UserGroup extends CommonObject
|
||||
$sql = "SELECT id";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."rights_def";
|
||||
$sql.= " WHERE $whereforadd";
|
||||
$sql.= " AND entity = ".$conf->entity;
|
||||
$sql.= " AND entity = ".$entity;
|
||||
|
||||
$result=$this->db->query($sql);
|
||||
if ($result)
|
||||
@ -323,9 +326,9 @@ class UserGroup extends CommonObject
|
||||
$obj = $this->db->fetch_object($result);
|
||||
$nid = $obj->id;
|
||||
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."usergroup_rights WHERE fk_usergroup = $this->id AND fk_id=".$nid;
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."usergroup_rights WHERE fk_usergroup = $this->id AND fk_id=".$nid." AND entity = ".$entity;
|
||||
if (! $this->db->query($sql)) $error++;
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."usergroup_rights (fk_usergroup, fk_id) VALUES ($this->id, $nid)";
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."usergroup_rights (entity, fk_usergroup, fk_id) VALUES (".$entity.", ".$this->id.", ".$nid.")";
|
||||
if (! $this->db->query($sql)) $error++;
|
||||
|
||||
$i++;
|
||||
@ -363,18 +366,21 @@ class UserGroup extends CommonObject
|
||||
/**
|
||||
* Remove a permission from group
|
||||
*
|
||||
* @param int $rid id du droit a retirer
|
||||
* @param string $allmodule Retirer tous les droits du module allmodule
|
||||
* @param string $allperms Retirer tous les droits du module allmodule, perms allperms
|
||||
* @return int > 0 if OK, < 0 if OK
|
||||
* @param int $rid id du droit a retirer
|
||||
* @param string $allmodule Retirer tous les droits du module allmodule
|
||||
* @param string $allperms Retirer tous les droits du module allmodule, perms allperms
|
||||
* @param int $entity Entity to use
|
||||
* @return int > 0 if OK, < 0 if OK
|
||||
*/
|
||||
function delrights($rid,$allmodule='',$allperms='')
|
||||
function delrights($rid, $allmodule='', $allperms='', $entity=0)
|
||||
{
|
||||
global $conf, $user, $langs;
|
||||
|
||||
$error=0;
|
||||
$wherefordel='';
|
||||
|
||||
$entity = (! empty($entity)?$entity:$conf->entity);
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
if (! empty($rid))
|
||||
@ -384,7 +390,7 @@ class UserGroup extends CommonObject
|
||||
$sql = "SELECT module, perms, subperms";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."rights_def";
|
||||
$sql.= " WHERE id = '".$this->db->escape($rid)."'";
|
||||
$sql.= " AND entity = ".$conf->entity;
|
||||
$sql.= " AND entity = ".$entity;
|
||||
|
||||
$result=$this->db->query($sql);
|
||||
if ($result) {
|
||||
@ -421,7 +427,7 @@ class UserGroup extends CommonObject
|
||||
$sql = "SELECT id";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."rights_def";
|
||||
$sql.= " WHERE $wherefordel";
|
||||
$sql.= " AND entity = ".$conf->entity;
|
||||
$sql.= " AND entity = ".$entity;
|
||||
|
||||
$result=$this->db->query($sql);
|
||||
if ($result)
|
||||
@ -435,6 +441,7 @@ class UserGroup extends CommonObject
|
||||
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."usergroup_rights";
|
||||
$sql.= " WHERE fk_usergroup = $this->id AND fk_id=".$nid;
|
||||
$sql.= " AND entity = ".$entity;
|
||||
if (! $this->db->query($sql)) $error++;
|
||||
|
||||
$i++;
|
||||
@ -498,6 +505,7 @@ class UserGroup extends CommonObject
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."usergroup_rights as u, ".MAIN_DB_PREFIX."rights_def as r";
|
||||
$sql.= " WHERE r.id = u.fk_id";
|
||||
$sql.= " AND r.entity = ".$conf->entity;
|
||||
$sql.= " AND u.entity = ".$conf->entity;
|
||||
$sql.= " AND u.fk_usergroup = ".$this->id;
|
||||
$sql.= " AND r.perms IS NOT NULL";
|
||||
if ($moduletag) $sql.= " AND r.module = '".$this->db->escape($moduletag)."'";
|
||||
@ -755,7 +763,7 @@ class UserGroup extends CommonObject
|
||||
{
|
||||
return $this->LibStatut(0,$mode);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Renvoi le libelle d'un statut donne
|
||||
*
|
||||
@ -769,7 +777,7 @@ class UserGroup extends CommonObject
|
||||
$langs->load('users');
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retourne chaine DN complete dans l'annuaire LDAP pour l'objet
|
||||
*
|
||||
@ -849,7 +857,7 @@ class UserGroup extends CommonObject
|
||||
$user->id => $user
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a document onto disk according to template module.
|
||||
*
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2005-2015 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2015 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2005-2017 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2011 Herve Prot <herve.prot@symeos.com>
|
||||
* Copyright (C) 2012 Florian Henry <florian.henry@open-concept.pro>
|
||||
*
|
||||
@ -54,7 +54,8 @@ $userid=GETPOST('user', 'int');
|
||||
// Security check
|
||||
$result = restrictedArea($user, 'user', $id, 'usergroup&usergroup', 'user');
|
||||
|
||||
if (! empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->multicompany->transverse_mode)
|
||||
// Users/Groups management only in master entity if transverse mode
|
||||
if (! empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE)
|
||||
{
|
||||
accessforbidden();
|
||||
}
|
||||
@ -105,7 +106,7 @@ if ($action == 'add')
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
|
||||
if ($ret < 0) $error++;
|
||||
|
||||
if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)) $object->entity = 0;
|
||||
if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) $object->entity = 0;
|
||||
else $object->entity = $_POST["entity"];
|
||||
|
||||
$db->begin();
|
||||
@ -148,8 +149,8 @@ if ($action == 'adduser' || $action =='removeuser')
|
||||
|
||||
$edituser = new User($db);
|
||||
$edituser->fetch($userid);
|
||||
if ($action == 'adduser') $result=$edituser->SetInGroup($object->id,(! empty($conf->multicompany->transverse_mode)?GETPOST('entity','int'):$object->entity));
|
||||
if ($action == 'removeuser') $result=$edituser->RemoveFromGroup($object->id,(! empty($conf->multicompany->transverse_mode)?GETPOST('entity','int'):$object->entity));
|
||||
if ($action == 'adduser') $result=$edituser->SetInGroup($object->id,(! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)?GETPOST('entity','int'):$object->entity));
|
||||
if ($action == 'removeuser') $result=$edituser->RemoveFromGroup($object->id,(! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)?GETPOST('entity','int'):$object->entity));
|
||||
|
||||
if ($result > 0)
|
||||
{
|
||||
@ -188,7 +189,7 @@ if ($action == 'update')
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
|
||||
if ($ret < 0) $error++;
|
||||
|
||||
if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)) $object->entity = 0;
|
||||
if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) $object->entity = 0;
|
||||
else $object->entity = $_POST["entity"];
|
||||
|
||||
$ret=$object->update();
|
||||
@ -250,7 +251,7 @@ if ($action == 'create')
|
||||
// Multicompany
|
||||
if (! empty($conf->multicompany->enabled) && is_object($mc))
|
||||
{
|
||||
if (empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity)
|
||||
if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity)
|
||||
{
|
||||
print "<tr>".'<td class="tdtop">'.$langs->trans("Entity").'</td>';
|
||||
print "<td>".$mc->select_entities($conf->entity);
|
||||
@ -333,7 +334,7 @@ else
|
||||
print "</td></tr>\n";
|
||||
|
||||
// Multicompany
|
||||
if (! empty($conf->multicompany->enabled) && is_object($mc) && empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity)
|
||||
if (! empty($conf->multicompany->enabled) && is_object($mc) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity)
|
||||
{
|
||||
$mc->getInfo($object->entity);
|
||||
print "<tr>".'<td class="tdtop">'.$langs->trans("Entity").'</td>';
|
||||
@ -382,7 +383,7 @@ else
|
||||
|
||||
if (! empty($object->members))
|
||||
{
|
||||
if (! (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)))
|
||||
if (! (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)))
|
||||
{
|
||||
foreach($object->members as $useringroup)
|
||||
{
|
||||
@ -404,7 +405,7 @@ else
|
||||
// Multicompany
|
||||
if (! empty($conf->multicompany->enabled) && is_object($mc))
|
||||
{
|
||||
if ($conf->entity == 1 && $conf->multicompany->transverse_mode)
|
||||
if ($conf->entity == 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE)
|
||||
{
|
||||
print '</td><td class="tdtop">'.$langs->trans("Entity").'</td>';
|
||||
print "<td>".$mc->select_entities($conf->entity);
|
||||
@ -454,7 +455,7 @@ else
|
||||
print '</td>';
|
||||
print '<td>'.$useringroup->lastname.'</td>';
|
||||
print '<td>'.$useringroup->firstname.'</td>';
|
||||
if (! empty($conf->multicompany->enabled) && is_object($mc) && ! empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity)
|
||||
if (! empty($conf->multicompany->enabled) && is_object($mc) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity)
|
||||
{
|
||||
print '<td class="valeur">';
|
||||
if (! empty($useringroup->usergroup_entity))
|
||||
@ -539,7 +540,7 @@ else
|
||||
// Multicompany
|
||||
if (! empty($conf->multicompany->enabled) && is_object($mc))
|
||||
{
|
||||
if (empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity)
|
||||
if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity)
|
||||
{
|
||||
print "<tr>".'<td class="tdtop">'.$langs->trans("Entity").'</td>';
|
||||
print "<td>".$mc->select_entities($object->entity);
|
||||
|
||||
@ -32,6 +32,12 @@ if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS))
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
// Users/Groups management only in master entity if transverse mode
|
||||
if (! empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE)
|
||||
{
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
$langs->load("users");
|
||||
|
||||
$sall=GETPOST('sall', 'alphanohtml');
|
||||
@ -95,7 +101,7 @@ llxHeader();
|
||||
$sql = "SELECT g.rowid, g.nom as name, g.entity, g.datec, COUNT(DISTINCT ugu.fk_user) as nb";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."usergroup as g";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_usergroup = g.rowid";
|
||||
if (! empty($conf->multicompany->enabled) && $conf->entity == 1 && ($conf->multicompany->transverse_mode || ($user->admin && ! $user->entity)))
|
||||
if (! empty($conf->multicompany->enabled) && $conf->entity == 1 && ($conf->global->MULTICOMPANY_TRANSVERSE_MODE || ($user->admin && ! $user->entity)))
|
||||
{
|
||||
$sql.= " WHERE g.entity IS NOT NULL";
|
||||
}
|
||||
@ -160,7 +166,7 @@ if ($resql)
|
||||
print '<tr class="liste_titre">';
|
||||
print_liste_field_titre($langs->trans("Group"),$_SERVER["PHP_SELF"],"g.nom",$param,"","",$sortfield,$sortorder);
|
||||
//multicompany
|
||||
if(! empty($conf->multicompany->enabled) && empty($conf->multicompany->transverse_mode) && $conf->entity == 1)
|
||||
if(! empty($conf->multicompany->enabled) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1)
|
||||
{
|
||||
print_liste_field_titre($langs->trans("Entity"),$_SERVER["PHP_SELF"],"g.entity",$param,"",'align="center"',$sortfield,$sortorder);
|
||||
}
|
||||
@ -172,7 +178,7 @@ if ($resql)
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
|
||||
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td><a href="card.php?id='.$obj->rowid.'">'.img_object($langs->trans("ShowGroup"),"group").' '.$obj->name.'</a>';
|
||||
@ -182,7 +188,7 @@ if ($resql)
|
||||
}
|
||||
print "</td>";
|
||||
//multicompany
|
||||
if (! empty($conf->multicompany->enabled) && is_object($mc) && empty($conf->multicompany->transverse_mode) && $conf->entity == 1)
|
||||
if (! empty($conf->multicompany->enabled) && is_object($mc) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1)
|
||||
{
|
||||
$mc->getInfo($obj->entity);
|
||||
print '<td align="center">'.$mc->label.'</td>';
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2006-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2006-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2006-2017 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -33,6 +33,12 @@ $langs->load("companies");
|
||||
$langs->load("ldap");
|
||||
$langs->load("users");
|
||||
|
||||
// Users/Groups management only in master entity if transverse mode
|
||||
if (! empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE)
|
||||
{
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
$canreadperms=true;
|
||||
if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS))
|
||||
{
|
||||
@ -98,7 +104,7 @@ $head = group_prepare_head($object);
|
||||
dol_fiche_head($head, 'ldap', $langs->trans("Group"), -1, 'group');
|
||||
|
||||
dol_banner_tab($object,'id','',$user->rights->user->user->lire || $user->admin);
|
||||
|
||||
|
||||
print '<div class="fichecenter">';
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
* Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org>
|
||||
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2005-2017 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -38,6 +38,12 @@ $confirm=GETPOST('confirm', 'alpha');
|
||||
$module=GETPOST('module', 'alpha');
|
||||
$rights=GETPOST('rights', 'int');
|
||||
|
||||
// Users/Groups management only in master entity if transverse mode
|
||||
if (! empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE)
|
||||
{
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
// Defini si peux lire les permissions
|
||||
$canreadperms=($user->admin || $user->rights->user->user->lire);
|
||||
// Defini si peux modifier les permissions
|
||||
@ -53,22 +59,44 @@ if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS))
|
||||
|
||||
if (! $canreadperms) accessforbidden();
|
||||
|
||||
$object = new Usergroup($db);
|
||||
$object->fetch($id);
|
||||
$object->getrights();
|
||||
|
||||
$entity=$conf->entity;
|
||||
if (! empty($conf->multicompany->enabled))
|
||||
{
|
||||
if (! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
|
||||
$entity=(GETPOST('entity','int') ? GETPOST('entity','int') : $conf->entity);
|
||||
else
|
||||
$entity=(! empty($object->entity) ? $object->entity : $conf->entity);
|
||||
}
|
||||
|
||||
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
|
||||
$hookmanager->initHooks(array('groupcard','globalcard'));
|
||||
|
||||
|
||||
/**
|
||||
* Actions
|
||||
*/
|
||||
if ($action == 'addrights' && $caneditperms)
|
||||
{
|
||||
$editgroup = new Usergroup($db);
|
||||
$result=$editgroup->fetch($id);
|
||||
if ($result > 0) $editgroup->addrights($rights, $module);
|
||||
}
|
||||
$parameters=array();
|
||||
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
|
||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
|
||||
if ($action == 'delrights' && $caneditperms)
|
||||
{
|
||||
$editgroup = new Usergroup($db);
|
||||
$result=$editgroup->fetch($id);
|
||||
if ($result > 0) $editgroup->delrights($rights, $module);
|
||||
if (empty($reshook)) {
|
||||
if ($action == 'addrights' && $caneditperms)
|
||||
{
|
||||
$editgroup = new Usergroup($db);
|
||||
$result=$editgroup->fetch($id);
|
||||
if ($result > 0) $editgroup->addrights($rights, $module, '', $entity);
|
||||
}
|
||||
|
||||
if ($action == 'delrights' && $caneditperms)
|
||||
{
|
||||
$editgroup = new Usergroup($db);
|
||||
$result=$editgroup->fetch($id);
|
||||
if ($result > 0) $editgroup->delrights($rights, $module, '', $entity);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -80,12 +108,8 @@ $form = new Form($db);
|
||||
|
||||
llxHeader('',$langs->trans("Permissions"));
|
||||
|
||||
if ($id)
|
||||
if ($object->id)
|
||||
{
|
||||
$object = new Usergroup($db);
|
||||
$object->fetch($id);
|
||||
$object->getrights();
|
||||
|
||||
/*
|
||||
* Affichage onglets
|
||||
*/
|
||||
@ -127,7 +151,6 @@ if ($id)
|
||||
// Load all permissions
|
||||
if ($objMod->rights_class)
|
||||
{
|
||||
$entity=((! empty($conf->multicompany->enabled) && ! empty($object->entity)) ? $object->entity : null);
|
||||
$ret=$objMod->insert_permissions(0, $entity);
|
||||
$modules[$objMod->rights_class]=$objMod;
|
||||
}
|
||||
@ -140,56 +163,42 @@ if ($id)
|
||||
$db->commit();
|
||||
|
||||
// Lecture des droits groupes
|
||||
$permsgroup = array();
|
||||
$permsgroupbyentity = array();
|
||||
|
||||
$sql = "SELECT r.id, r.libelle, r.module ";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."rights_def as r";
|
||||
$sql.= ", ".MAIN_DB_PREFIX."usergroup_rights as ugr";
|
||||
$sql.= " WHERE ugr.fk_id = r.id";
|
||||
if(! empty($conf->multicompany->enabled))
|
||||
{
|
||||
if (empty($conf->multicompany->transverse_mode))
|
||||
{
|
||||
$sql.= " AND r.entity = ".$object->entity;
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql.= " AND r.entity IN (0,1)";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql.= " AND r.entity IN (0,".$conf->entity.")";
|
||||
}
|
||||
|
||||
$sql.= " AND ugr.fk_usergroup = ".$object->id;
|
||||
$sql = "SELECT DISTINCT r.id, r.libelle, r.module, gr.entity";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."rights_def as r,";
|
||||
$sql.= " ".MAIN_DB_PREFIX."usergroup_rights as gr";
|
||||
$sql.= " WHERE gr.fk_id = r.id";
|
||||
$sql.= " AND gr.entity = ".$entity;
|
||||
$sql.= " AND gr.fk_usergroup = ".$object->id;
|
||||
|
||||
dol_syslog("get user perms", LOG_DEBUG);
|
||||
$result=$db->query($sql);
|
||||
|
||||
if ($result)
|
||||
{
|
||||
$num = $db->num_rows($result);
|
||||
$i = 0;
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $db->fetch_object($result);
|
||||
array_push($permsgroup,$obj->id);
|
||||
$i++;
|
||||
}
|
||||
$db->free($result);
|
||||
$num = $db->num_rows($result);
|
||||
$i = 0;
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $db->fetch_object($result);
|
||||
if (! isset($permsgroupbyentity[$obj->entity]))
|
||||
$permsgroupbyentity[$obj->entity] = array();
|
||||
array_push($permsgroupbyentity[$obj->entity], $obj->id);
|
||||
$i++;
|
||||
}
|
||||
$db->free($result);
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($db);
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
dol_banner_tab($object,'id','',$user->rights->user->user->lire || $user->admin);
|
||||
|
||||
|
||||
print '<div class="fichecenter">';
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
|
||||
|
||||
/*
|
||||
* Ecran ajout/suppression permission
|
||||
*/
|
||||
@ -214,6 +223,10 @@ if ($id)
|
||||
|
||||
if ($user->admin) print info_admin($langs->trans("WarningOnlyPermissionOfActivatedModules"));
|
||||
|
||||
$parameters=array();
|
||||
$reshook=$hookmanager->executeHooks('insertExtraHeader',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
|
||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
|
||||
print '<table width="100%" class="noborder">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("Module").'</td>';
|
||||
@ -225,22 +238,7 @@ if ($id)
|
||||
$sql = "SELECT r.id, r.libelle, r.module";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."rights_def as r";
|
||||
$sql.= " WHERE r.libelle NOT LIKE 'tou%'"; // On ignore droits "tous"
|
||||
if(! empty($conf->multicompany->enabled))
|
||||
{
|
||||
if (empty($conf->multicompany->transverse_mode))
|
||||
{
|
||||
$sql.= " AND r.entity = ".$object->entity;
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql.= " AND r.entity IN (0,1)";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql.= " AND r.entity = ".$conf->entity;
|
||||
}
|
||||
|
||||
$sql.= " AND r.entity = " . $entity;
|
||||
if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) $sql.= " AND r.perms NOT LIKE '%_advance'"; // Hide advanced perms if option is disable
|
||||
$sql.= " ORDER BY r.module, r.id";
|
||||
|
||||
@ -279,9 +277,9 @@ if ($id)
|
||||
print '<td class="nowrap">'.img_object('',$picto).' '.$objMod->getName();
|
||||
print '<a name="'.$objMod->getName().'"> </a></td>';
|
||||
print '<td align="center" class="nowrap">';
|
||||
print '<a title='.$langs->trans("All").' alt='.$langs->trans("All").' href="perms.php?id='.$object->id.'&action=addrights&module='.$obj->module.'#'.$objMod->getName().'">'.$langs->trans("All")."</a>";
|
||||
print '<a title='.$langs->trans("All").' alt='.$langs->trans("All").' href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=addrights&entity='.$entity.'&module='.$obj->module.'#'.$objMod->getName().'">'.$langs->trans("All")."</a>";
|
||||
print '/';
|
||||
print '<a title='.$langs->trans("None").' alt='.$langs->trans("None").' href="perms.php?id='.$object->id.'&action=delrights&module='.$obj->module.'#'.$objMod->getName().'">'.$langs->trans("None")."</a>";
|
||||
print '<a title='.$langs->trans("None").' alt='.$langs->trans("None").' href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delrights&entity='.$entity.'&module='.$obj->module.'#'.$objMod->getName().'">'.$langs->trans("None")."</a>";
|
||||
print '</td>';
|
||||
print '<td colspan="2"> </td>';
|
||||
print '</tr>';
|
||||
@ -293,25 +291,37 @@ if ($id)
|
||||
// Module
|
||||
print '<td class="nowrap">'.img_object('',$picto).' '.$objMod->getName().'</td>';
|
||||
|
||||
if (in_array($obj->id, $permsgroup))
|
||||
if (is_array($permsgroupbyentity[$entity]))
|
||||
{
|
||||
// Own permission by group
|
||||
if ($caneditperms)
|
||||
{
|
||||
print '<td align="center"><a class="reposition" href="perms.php?id='.$object->id.'&action=delrights&rights='.$obj->id.'">'.img_edit_remove($langs->trans("Remove")).'</a></td>';
|
||||
}
|
||||
print '<td align="center">';
|
||||
print img_picto($langs->trans("Active"),'tick');
|
||||
print '</td>';
|
||||
if (in_array($obj->id, $permsgroupbyentity[$entity]))
|
||||
{
|
||||
// Own permission by group
|
||||
if ($caneditperms)
|
||||
{
|
||||
print '<td align="center"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delrights&entity='.$entity.'&rights='.$obj->id.'">'.img_edit_remove($langs->trans("Remove")).'</a></td>';
|
||||
}
|
||||
print '<td align="center">';
|
||||
print img_picto($langs->trans("Active"),'tick');
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
// Do not own permission
|
||||
if ($caneditperms)
|
||||
{
|
||||
print '<td align="center"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=addrights&entity='.$entity.'&rights='.$obj->id.'">'.img_edit_add($langs->trans("Add")).'</a></td>';
|
||||
}
|
||||
print '<td> </td>';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Do not own permission
|
||||
if ($caneditperms)
|
||||
{
|
||||
print '<td align="center"><a class="reposition" href="perms.php?id='.$object->id.'&action=addrights&rights='.$obj->id.'">'.img_edit_add($langs->trans("Add")).'</a></td>';
|
||||
}
|
||||
print '<td> </td>';
|
||||
// Do not own permission
|
||||
if ($caneditperms)
|
||||
{
|
||||
print '<td align="center"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=addrights&entity='.$entity.'&rights='.$obj->id.'">'.img_edit_add($langs->trans("Add")).'</a></td>';
|
||||
}
|
||||
print '<td> </td>';
|
||||
}
|
||||
|
||||
$perm_libelle=($conf->global->MAIN_USE_ADVANCED_PERMS && ($langs->trans("PermissionAdvanced".$obj->id)!=("PermissionAdvanced".$obj->id))?$langs->trans("PermissionAdvanced".$obj->id):(($langs->trans("Permission".$obj->id)!=("Permission".$obj->id))?$langs->trans("Permission".$obj->id):$langs->trans($obj->libelle)));
|
||||
@ -323,9 +333,13 @@ if ($id)
|
||||
}
|
||||
}
|
||||
print '</table>';
|
||||
|
||||
|
||||
print '</div>';
|
||||
|
||||
|
||||
$parameters=array();
|
||||
$reshook=$hookmanager->executeHooks('insertExtraFooter',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
|
||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
|
||||
dol_fiche_end();
|
||||
}
|
||||
|
||||
|
||||
@ -73,7 +73,7 @@ $user_arbo = $userstatic->get_full_tree(0, ($search_statut != '' && $search_stat
|
||||
|
||||
if (! is_array($user_arbo) && $user_arbo < 0)
|
||||
{
|
||||
setEventMessages($userstatic->error, $userstatic->errors, 'warnings');
|
||||
setEventMessages($userstatic->error, $userstatic->errors, 'warnings');
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -97,24 +97,21 @@ foreach($fulltree as $key => $val)
|
||||
$userstatic->admin=$val['admin'];
|
||||
$userstatic->entity=$val['entity'];
|
||||
$userstatic->photo=$val['photo'];
|
||||
|
||||
|
||||
$entity=$val['entity'];
|
||||
$entitystring='';
|
||||
|
||||
// TODO Set of entitystring should be done with a hook
|
||||
if (is_object($mc))
|
||||
if (! empty($conf->multicompany->enabled) && is_object($mc))
|
||||
{
|
||||
if (! empty($conf->multicompany->enabled))
|
||||
if (empty($entity))
|
||||
{
|
||||
if (empty($entity))
|
||||
{
|
||||
$entitystring=$langs->trans("AllEntities");
|
||||
}
|
||||
else
|
||||
{
|
||||
$mc->getInfo($entity);
|
||||
$entitystring=$mc->label;
|
||||
}
|
||||
$entitystring=$langs->trans("AllEntities");
|
||||
}
|
||||
else
|
||||
{
|
||||
$mc->getInfo($entity);
|
||||
$entitystring=$mc->label;
|
||||
}
|
||||
}
|
||||
|
||||
@ -128,7 +125,7 @@ foreach($fulltree as $key => $val)
|
||||
$li.=img_picto($langs->trans("Administrator"),'star');
|
||||
}
|
||||
$li.=' ('.$val['login'].($entitystring?' - '.$entitystring:'').')';
|
||||
|
||||
|
||||
$data[] = array(
|
||||
'rowid'=>$val['rowid'],
|
||||
'fk_menu'=>$val['fk_user'],
|
||||
|
||||
@ -100,7 +100,7 @@ $sql.= ", s.code_client";
|
||||
$sql.= ", s.canvas";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."user as u";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON u.fk_soc = s.rowid";
|
||||
if (! empty($conf->multicompany->enabled) && $conf->entity == 1 && ($conf->multicompany->transverse_mode || ($user->admin && ! $user->entity)))
|
||||
if (! empty($conf->multicompany->enabled) && $conf->entity == 1 && ($conf->global->MULTICOMPANY_TRANSVERSE_MODE || ($user->admin && ! $user->entity)))
|
||||
{
|
||||
$sql.= " WHERE u.entity IS NOT NULL";
|
||||
}
|
||||
@ -212,7 +212,7 @@ if ($canreadperms)
|
||||
|
||||
$sql = "SELECT g.rowid, g.nom as name, g.note, g.entity, g.datec";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."usergroup as g";
|
||||
if(! empty($conf->multicompany->enabled) && $conf->entity == 1 && ($conf->multicompany->transverse_mode || ($user->admin && ! $user->entity)))
|
||||
if(! empty($conf->multicompany->enabled) && $conf->entity == 1 && ($conf->global->MULTICOMPANY_TRANSVERSE_MODE || ($user->admin && ! $user->entity)))
|
||||
{
|
||||
$sql.= " WHERE g.entity IS NOT NULL";
|
||||
}
|
||||
|
||||
@ -92,7 +92,7 @@ $arrayfields=array(
|
||||
'u.accountancy_code'=>array('label'=>$langs->trans("AccountancyCode"), 'checked'=>0),
|
||||
'u.email'=>array('label'=>$langs->trans("EMail"), 'checked'=>1),
|
||||
'u.fk_soc'=>array('label'=>$langs->trans("Company"), 'checked'=>1),
|
||||
'u.entity'=>array('label'=>$langs->trans("Entity"), 'checked'=>1, 'enabled'=>(! empty($conf->multicompany->enabled) && empty($conf->multicompany->transverse_mode))),
|
||||
'u.entity'=>array('label'=>$langs->trans("Entity"), 'checked'=>1, 'enabled'=>(! empty($conf->multicompany->enabled) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))),
|
||||
'u.fk_user'=>array('label'=>$langs->trans("HierarchicalResponsible"), 'checked'=>1),
|
||||
'u.datelastlogin'=>array('label'=>$langs->trans("LastConnexion"), 'checked'=>1, 'position'=>100),
|
||||
'u.datepreviouslogin'=>array('label'=>$langs->trans("PreviousConnexion"), 'checked'=>0, 'position'=>110),
|
||||
@ -194,7 +194,7 @@ $sql.= " FROM ".MAIN_DB_PREFIX."user as u";
|
||||
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user_extrafields as ef on (u.rowid = ef.fk_object)";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON u.fk_soc = s.rowid";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u2 ON u.fk_user = u2.rowid";
|
||||
if(! empty($conf->multicompany->enabled) && $conf->entity == 1 && (! empty($conf->multicompany->transverse_mode) || (! empty($user->admin) && empty($user->entity))))
|
||||
if(! empty($conf->multicompany->enabled) && $conf->entity == 1 && (! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) || (! empty($user->admin) && empty($user->entity))))
|
||||
{
|
||||
$sql.= " WHERE u.entity IS NOT NULL";
|
||||
}
|
||||
@ -545,7 +545,7 @@ while ($i < min($num,$limit))
|
||||
print '</td>';
|
||||
}
|
||||
// Multicompany enabled
|
||||
if (! empty($conf->multicompany->enabled) && empty($conf->multicompany->transverse_mode))
|
||||
if (! empty($conf->multicompany->enabled) && is_object($mc) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
|
||||
{
|
||||
if (! empty($arrayfields['u.entity']['checked']))
|
||||
{
|
||||
@ -556,12 +556,8 @@ while ($i < min($num,$limit))
|
||||
}
|
||||
else
|
||||
{
|
||||
// $mc is defined in conf.class.php if multicompany enabled.
|
||||
if (is_object($mc))
|
||||
{
|
||||
$mc->getInfo($obj->entity);
|
||||
print $mc->label;
|
||||
}
|
||||
$mc->getInfo($obj->entity);
|
||||
print $mc->label;
|
||||
}
|
||||
print '</td>';
|
||||
}
|
||||
@ -581,7 +577,7 @@ while ($i < min($num,$limit))
|
||||
$user2->photo=$obj->photo2;
|
||||
$user2->admin=$obj->admin2;
|
||||
$user2->email=$obj->email2;
|
||||
$user2->societe_id=$obj->fk_soc2;
|
||||
$user2->socid=$obj->fk_soc2;
|
||||
print $user2->getNomUrl(-1,'',0,0,24,0,'');
|
||||
if (! empty($conf->multicompany->enabled) && $obj->admin2 && ! $obj->entity2)
|
||||
{
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
* Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org>
|
||||
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
|
||||
* Copyright (C) 2005-2015 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2005-2017 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -38,7 +38,6 @@ $action=GETPOST('action', 'alpha');
|
||||
$confirm=GETPOST('confirm', 'alpha');
|
||||
$module=GETPOST('module', 'alpha');
|
||||
$rights=GETPOST('rights', 'int');
|
||||
$entity=(GETPOST('entity','int')?GETPOST('entity','int'):$conf->entity);
|
||||
|
||||
if (! isset($id) || empty($id)) accessforbidden();
|
||||
|
||||
@ -71,6 +70,15 @@ $object = new User($db);
|
||||
$object->fetch($id, '', '', 1);
|
||||
$object->getrights();
|
||||
|
||||
$entity=$conf->entity;
|
||||
if (! empty($conf->multicompany->enabled))
|
||||
{
|
||||
if (! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
|
||||
$entity=(GETPOST('entity','int') ? GETPOST('entity','int') : $conf->entity);
|
||||
else
|
||||
$entity=(! empty($object->entity) ? $object->entity : $conf->entity);
|
||||
}
|
||||
|
||||
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
|
||||
$hookmanager->initHooks(array('usercard','globalcard'));
|
||||
|
||||
@ -86,12 +94,11 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e
|
||||
if (empty($reshook)) {
|
||||
if ($action == 'addrights' && $caneditperms) {
|
||||
$edituser = new User($db);
|
||||
$edituser->fetch($id);
|
||||
//$edituser->addrights($rights, $module, '', $entity); // TODO unused for the moment
|
||||
$edituser->addrights($rights, $module);
|
||||
$edituser->fetch($object->id);
|
||||
$edituser->addrights($rights, $module, '', $entity);
|
||||
|
||||
// Si on a touche a ses propres droits, on recharge
|
||||
if ($id == $user->id) {
|
||||
if ($object->id == $user->id) {
|
||||
$user->clearrights();
|
||||
$user->getrights();
|
||||
$menumanager->loadMenu();
|
||||
@ -100,12 +107,11 @@ if (empty($reshook)) {
|
||||
|
||||
if ($action == 'delrights' && $caneditperms) {
|
||||
$edituser = new User($db);
|
||||
$edituser->fetch($id);
|
||||
//$edituser->delrights($rights, $module, '', $entity); // TODO unused for the moment
|
||||
$edituser->delrights($rights, $module);
|
||||
$edituser->fetch($object->id);
|
||||
$edituser->delrights($rights, $module, '', $entity);
|
||||
|
||||
// Si on a touche a ses propres droits, on recharge
|
||||
if ($id == $user->id) {
|
||||
if ($object->id == $user->id) {
|
||||
$user->clearrights();
|
||||
$user->getrights();
|
||||
$menumanager->loadMenu();
|
||||
@ -161,8 +167,7 @@ foreach($modulesdir as $dir)
|
||||
// Load all permissions
|
||||
if ($objMod->rights_class)
|
||||
{
|
||||
$forceEntity=((! empty($conf->multicompany->enabled) && ! empty($object->entity)) ? $object->entity : null);
|
||||
$ret=$objMod->insert_permissions(0, $forceEntity);
|
||||
$ret=$objMod->insert_permissions(0, $entity);
|
||||
$modules[$objMod->rights_class]=$objMod;
|
||||
//print "modules[".$objMod->rights_class."]=$objMod;";
|
||||
}
|
||||
@ -177,22 +182,11 @@ $db->commit();
|
||||
// Lecture des droits utilisateurs
|
||||
$permsuser = array();
|
||||
|
||||
$sql = "SELECT r.id, r.libelle, r.module";
|
||||
$sql = "SELECT DISTINCT r.id, r.libelle, r.module";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."rights_def as r,";
|
||||
$sql.= " ".MAIN_DB_PREFIX."user_rights as ur";
|
||||
$sql.= " WHERE ur.fk_id = r.id";
|
||||
if (! empty($conf->multicompany->enabled))
|
||||
{
|
||||
if (1==2 && ! empty($conf->multicompany->transverse_mode)) {
|
||||
$sql.= " AND r.entity = ".(GETPOST('entity','int')?GETPOST('entity','int'):$conf->entity); // TODO unused for the moment
|
||||
} else {
|
||||
$sql.= " AND r.entity = ".(! empty($object->entity) ? $object->entity : $conf->entity);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql.= " AND r.entity = ".$conf->entity;
|
||||
}
|
||||
$sql.= " AND ur.entity = ".$entity;
|
||||
$sql.= " AND ur.fk_user = ".$object->id;
|
||||
|
||||
dol_syslog("get user perms", LOG_DEBUG);
|
||||
@ -216,18 +210,13 @@ else
|
||||
|
||||
// Lecture des droits groupes
|
||||
$permsgroupbyentity = array();
|
||||
$aEntities = array();
|
||||
|
||||
$sql = "SELECT r.id, r.libelle, r.module, gu.entity";
|
||||
$sql = "SELECT DISTINCT r.id, r.libelle, r.module, gu.entity";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."rights_def as r,";
|
||||
$sql.= " ".MAIN_DB_PREFIX."usergroup_rights as gr,";
|
||||
$sql.= " ".MAIN_DB_PREFIX."usergroup_user as gu";
|
||||
$sql.= " WHERE gr.fk_id = r.id";
|
||||
if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)) {
|
||||
$sql.= " AND gu.entity IS NOT NULL";
|
||||
} else {
|
||||
$sql.= " AND r.entity = ".((! empty($conf->multicompany->enabled) && ! empty($object->entity)) ? $object->entity : $conf->entity);
|
||||
}
|
||||
$sql.= " AND gr.entity = ".$entity;
|
||||
$sql.= " AND gr.fk_usergroup = gu.fk_usergroup";
|
||||
$sql.= " AND gu.fk_user = ".$object->id;
|
||||
|
||||
@ -272,17 +261,10 @@ if ($user->admin) print info_admin($langs->trans("WarningOnlyPermissionOfActivat
|
||||
// Show warning about external users
|
||||
if (empty($user->societe_id)) print info_admin(showModulesExludedForExternal($modules))."\n";
|
||||
|
||||
// For multicompany transversal mode
|
||||
// TODO Place a hook here
|
||||
if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode))
|
||||
{
|
||||
$aEntities=array_keys($permsgroupbyentity);
|
||||
sort($aEntities);
|
||||
$entity = (GETPOST('entity', 'int')?GETPOST('entity', 'int'):$aEntities[0]);
|
||||
$head = entity_prepare_head($object, $aEntities);
|
||||
$title = $langs->trans("Entities");
|
||||
dol_fiche_head($head, $entity, $title, 1, 'multicompany@multicompany');
|
||||
}
|
||||
$parameters=array('permsgroupbyentity'=>$permsgroupbyentity);
|
||||
$reshook=$hookmanager->executeHooks('insertExtraHeader',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
|
||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
|
||||
|
||||
print "\n";
|
||||
print '<table width="100%" class="noborder">';
|
||||
@ -297,7 +279,7 @@ print '</tr>'."\n";
|
||||
$sql = "SELECT r.id, r.libelle, r.module";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."rights_def as r";
|
||||
$sql.= " WHERE r.libelle NOT LIKE 'tou%'"; // On ignore droits "tous"
|
||||
$sql.= " AND r.entity = ".((! empty($conf->multicompany->enabled) && ! empty($object->entity)) ? $object->entity : $conf->entity);
|
||||
$sql.= " AND r.entity = " . $entity;
|
||||
if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) $sql.= " AND r.perms NOT LIKE '%_advance'"; // Hide advanced perms if option is disable
|
||||
$sql.= " ORDER BY r.module, r.id";
|
||||
|
||||
@ -336,9 +318,9 @@ if ($result)
|
||||
print '<td class="maxwidthonsmartphone tdoverflowonsmartphone">'.img_object('',$picto).' '.$objMod->getName();
|
||||
print '<a name="'.$objMod->getName().'"></a></td>';
|
||||
print '<td align="center" class="nowrap">';
|
||||
print '<a class="reposition" title="'.dol_escape_htmltag($langs->trans("All")).'" alt="'.dol_escape_htmltag($langs->trans("All")).'" href="perms.php?id='.$object->id.'&action=addrights&entity='.$entity.'&module='.$obj->module.'">'.$langs->trans("All")."</a>";
|
||||
print '<a class="reposition" title="'.dol_escape_htmltag($langs->trans("All")).'" alt="'.dol_escape_htmltag($langs->trans("All")).'" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=addrights&entity='.$entity.'&module='.$obj->module.'">'.$langs->trans("All")."</a>";
|
||||
print '/';
|
||||
print '<a class="reposition" title="'.dol_escape_htmltag($langs->trans("None")).'" alt="'.dol_escape_htmltag($langs->trans("None")).'" href="perms.php?id='.$object->id.'&action=delrights&entity='.$entity.'&module='.$obj->module.'">'.$langs->trans("None")."</a>";
|
||||
print '<a class="reposition" title="'.dol_escape_htmltag($langs->trans("None")).'" alt="'.dol_escape_htmltag($langs->trans("None")).'" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delrights&entity='.$entity.'&module='.$obj->module.'">'.$langs->trans("None")."</a>";
|
||||
print '</td>';
|
||||
print '<td colspan="2"> </td>';
|
||||
print '</tr>'."\n";
|
||||
@ -365,7 +347,7 @@ if ($result)
|
||||
{
|
||||
if ($caneditperms)
|
||||
{
|
||||
print '<td align="center"><a class="reposition" href="perms.php?id='.$object->id.'&action=delrights&rights='.$obj->id.'">'.img_edit_remove($langs->trans("Remove")).'</a></td>';
|
||||
print '<td align="center"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delrights&entity='.$entity.'&rights='.$obj->id.'">'.img_edit_remove($langs->trans("Remove")).'</a></td>';
|
||||
}
|
||||
print '<td align="center" class="nowrap">';
|
||||
print img_picto($langs->trans("Active"),'tick');
|
||||
@ -391,7 +373,7 @@ if ($result)
|
||||
// Do not own permission
|
||||
if ($caneditperms)
|
||||
{
|
||||
print '<td align="center"><a class="reposition" href="perms.php?id='.$object->id.'&action=addrights&entity='.$entity.'&rights='.$obj->id.'">'.img_edit_add($langs->trans("Add")).'</a></td>';
|
||||
print '<td align="center"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=addrights&entity='.$entity.'&rights='.$obj->id.'">'.img_edit_add($langs->trans("Add")).'</a></td>';
|
||||
}
|
||||
print '<td> </td>';
|
||||
}
|
||||
@ -401,7 +383,7 @@ if ($result)
|
||||
// Do not own permission
|
||||
if ($caneditperms)
|
||||
{
|
||||
print '<td align="center"><a class="reposition" href="perms.php?id='.$object->id.'&action=addrights&entity='.$entity.'&rights='.$obj->id.'">'.img_edit_add($langs->trans("Add")).'</a></td>';
|
||||
print '<td align="center"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=addrights&entity='.$entity.'&rights='.$obj->id.'">'.img_edit_add($langs->trans("Add")).'</a></td>';
|
||||
}
|
||||
print '<td> </td>';
|
||||
}
|
||||
@ -417,13 +399,10 @@ if ($result)
|
||||
else dol_print_error($db);
|
||||
print '</table>';
|
||||
|
||||
$parameters=array();
|
||||
$reshook=$hookmanager->executeHooks('insertExtraFooter',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
|
||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
|
||||
// For multicompany transversal mode
|
||||
// TODO Place a hook here
|
||||
if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode))
|
||||
{
|
||||
dol_fiche_end();
|
||||
}
|
||||
|
||||
dol_fiche_end();
|
||||
|
||||
|
||||
@ -416,7 +416,7 @@ function getListOfGroups($authentication)
|
||||
$sql = "SELECT g.rowid, g.nom as name, g.entity, g.datec, COUNT(DISTINCT ugu.fk_user) as nb";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."usergroup as g";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_usergroup = g.rowid";
|
||||
if (! empty($conf->multicompany->enabled) && $conf->entity == 1 && ($conf->multicompany->transverse_mode || ($user->admin && ! $user->entity)))
|
||||
if (! empty($conf->multicompany->enabled) && $conf->entity == 1 && ($conf->global->MULTICOMPANY_TRANSVERSE_MODE || ($user->admin && ! $user->entity)))
|
||||
{
|
||||
$sql.= " WHERE g.entity IS NOT NULL";
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user