forked from Wavyzz/dolibarr
Fix: refactoring elements sharing management between entities
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2011 Regis Houssin <regis@dolibarr.fr>
|
/* Copyright (C) 2011-2012 Regis Houssin <regis@dolibarr.fr>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -51,11 +51,11 @@ if((isset($_GET['action']) && ! empty($_GET['action'])) && (isset($_GET['name'])
|
|||||||
{
|
{
|
||||||
if ($_GET['action'] == 'set')
|
if ($_GET['action'] == 'set')
|
||||||
{
|
{
|
||||||
dolibarr_set_const($db, $_GET['name'], 1, 'chaine', 0, '', $conf->entity);
|
dolibarr_set_const($db, GETPOST('name','alpha'), 1, 'chaine', 0, '', GETPOST('entity','int'));
|
||||||
}
|
}
|
||||||
else if ($_GET['action'] == 'del')
|
else if ($_GET['action'] == 'del')
|
||||||
{
|
{
|
||||||
dolibarr_del_const($db, $_GET['name'], $conf->entity);
|
dolibarr_del_const($db, GETPOST('name','alpha'), GETPOST('entity','int'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -191,28 +191,19 @@ class Conf
|
|||||||
$this->modules[]=$module;
|
$this->modules[]=$module;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Sharings between entities
|
|
||||||
else if ($value && preg_match('/^MULTICOMPANY_([A-Z_]+)_SHARING$/',$key,$reg))
|
|
||||||
{
|
|
||||||
$module=strtolower($reg[1]);
|
|
||||||
$multicompany_sharing[$module]=$value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sharings between entities
|
// Load shared elements between entities
|
||||||
if (! empty($this->multicompany->enabled) && ! empty($multicompany_sharing))
|
if (! empty($this->multicompany->enabled))
|
||||||
{
|
{
|
||||||
$ret = @dol_include_once('/multicompany/class/actions_multicompany.class.php');
|
$ret = @dol_include_once('/multicompany/class/actions_multicompany.class.php');
|
||||||
if ($ret)
|
if ($ret)
|
||||||
{
|
{
|
||||||
$mc = new ActionsMulticompany($db);
|
$mc = new ActionsMulticompany($db);
|
||||||
|
$this->multicompany->entity = $mc->loadEntity();
|
||||||
foreach($multicompany_sharing as $key => $value)
|
$this->entities = $mc->loadSharedElements();
|
||||||
{
|
|
||||||
$this->entities[$key]=$mc->check_entity($value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -463,7 +463,7 @@ function dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $not
|
|||||||
|
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."const";
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."const";
|
||||||
$sql.= " WHERE name = ".$db->encrypt($name,1);
|
$sql.= " WHERE name = ".$db->encrypt($name,1);
|
||||||
if ($entity > 0) $sql.= " AND entity = ".$entity;
|
if ($entity >= 0) $sql.= " AND entity = ".$entity;
|
||||||
|
|
||||||
dol_syslog("admin.lib::dolibarr_set_const sql=".$sql, LOG_DEBUG);
|
dol_syslog("admin.lib::dolibarr_set_const sql=".$sql, LOG_DEBUG);
|
||||||
$resql=$db->query($sql);
|
$resql=$db->query($sql);
|
||||||
|
|||||||
@@ -218,14 +218,17 @@ function ajax_combobox($htmlname)
|
|||||||
/**
|
/**
|
||||||
* On/off button for constant
|
* On/off button for constant
|
||||||
*
|
*
|
||||||
* @param code Name of constant
|
* @param string $code Name of constant
|
||||||
* @param input Input element
|
* @param array $input Input element
|
||||||
|
* @param int $entity Entity to set
|
||||||
* TODO add different method for other input (show/hide, disable, ..)
|
* TODO add different method for other input (show/hide, disable, ..)
|
||||||
*/
|
*/
|
||||||
function ajax_constantonoff($code,$input=array())
|
function ajax_constantonoff($code,$input=array(),$entity=false)
|
||||||
{
|
{
|
||||||
global $conf, $langs;
|
global $conf, $langs;
|
||||||
|
|
||||||
|
$entity = ((! empty($entity) && is_numeric($entity) && $entity > 0) || $entity == 0 ? $entity : $conf->entity);
|
||||||
|
|
||||||
$out= '<script type="text/javascript">
|
$out= '<script type="text/javascript">
|
||||||
$(function() {
|
$(function() {
|
||||||
var input='.json_encode($input).';
|
var input='.json_encode($input).';
|
||||||
@@ -234,7 +237,8 @@ function ajax_constantonoff($code,$input=array())
|
|||||||
$( "#set_'.$code.'" ).click(function() {
|
$( "#set_'.$code.'" ).click(function() {
|
||||||
$.get( "'.DOL_URL_ROOT.'/core/ajax/constantonoff.php", {
|
$.get( "'.DOL_URL_ROOT.'/core/ajax/constantonoff.php", {
|
||||||
action: \'set\',
|
action: \'set\',
|
||||||
name: \''.$code.'\'
|
name: \''.$code.'\',
|
||||||
|
entity: \''.$entity.'\'
|
||||||
},
|
},
|
||||||
function() {
|
function() {
|
||||||
$("#set_'.$code.'" ).hide();
|
$("#set_'.$code.'" ).hide();
|
||||||
@@ -256,7 +260,8 @@ function ajax_constantonoff($code,$input=array())
|
|||||||
$( "#del_'.$code.'" ).click(function() {
|
$( "#del_'.$code.'" ).click(function() {
|
||||||
$.get( "'.DOL_URL_ROOT.'/core/ajax/constantonoff.php", {
|
$.get( "'.DOL_URL_ROOT.'/core/ajax/constantonoff.php", {
|
||||||
action: \'del\',
|
action: \'del\',
|
||||||
name: \''.$code.'\'
|
name: \''.$code.'\',
|
||||||
|
entity: \''.$entity.'\'
|
||||||
},
|
},
|
||||||
function() {
|
function() {
|
||||||
$("#del_'.$code.'" ).hide();
|
$("#del_'.$code.'" ).hide();
|
||||||
|
|||||||
Reference in New Issue
Block a user