Fix: When creating user on other entity, no way to read user

after creation.
This commit is contained in:
Laurent Destailleur 2013-02-16 21:06:15 +01:00
parent b1ee14ce60
commit 50decdd941
3 changed files with 52 additions and 45 deletions

View File

@ -689,7 +689,7 @@ class Form
{
//$minLength = (is_numeric($conf->global->COMPANY_USE_SEARCH_TO_SELECT)?$conf->global->COMPANY_USE_SEARCH_TO_SELECT:2);
$out.= ajax_combobox($htmlname, $event, $conf->global->COMPANY_USE_SEARCH_TO_SELECT);
/*
/*
if ($selected && empty($selected_input_value))
{
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
@ -876,7 +876,7 @@ class Form
if ($resql)
{
$num=$this->db->num_rows($resql);
if ($conf->use_javascript_ajax && $conf->global->CONTACT_USE_SEARCH_TO_SELECT && ! $forcecombo)
{
$out.= ajax_combobox($htmlname, $event);
@ -968,10 +968,10 @@ class Form
* @param int $disabled If select list must be disabled
* @param array $include Array list of users id to include
* @param int $enableonly Array list of users id to be enabled. All other must be disabled
* @param int $force_entity Possibility to force entity
* @param int $force_entity 0 or Id of environment to force
* @return void
*/
function select_users($selected='',$htmlname='userid',$show_empty=0,$exclude='',$disabled=0,$include='',$enableonly='',$force_entity=false)
function select_users($selected='',$htmlname='userid',$show_empty=0,$exclude='',$disabled=0,$include='',$enableonly='',$force_entity=0)
{
print $this->select_dolusers($selected,$htmlname,$show_empty,$exclude,$disabled,$include,$enableonly,$force_entity);
}
@ -986,10 +986,10 @@ class Form
* @param int $disabled If select list must be disabled
* @param array $include Array list of users id to include
* @param int $enableonly Array list of users id to be enabled. All other must be disabled
* @param int $force_entity Possibility to force entity
* @param int $force_entity 0 or Id of environment to force
* @return string HTML select string
*/
function select_dolusers($selected='',$htmlname='userid',$show_empty=0,$exclude='',$disabled=0,$include='',$enableonly='',$force_entity=false)
function select_dolusers($selected='',$htmlname='userid',$show_empty=0,$exclude='',$disabled=0,$include='',$enableonly='',$force_entity=0)
{
global $conf,$user,$langs;
@ -3946,17 +3946,17 @@ class Form
/**
* Return select list of groups
*
* @param string $selected Id group preselected
* @param string $htmlname Field name in form
* @param int $show_empty 0=liste sans valeur nulle, 1=ajoute valeur inconnue
* @param string $exclude Array list of groups id to exclude
* @param string $selected Id group preselected
* @param string $htmlname Field name in form
* @param int $show_empty 0=liste sans valeur nulle, 1=ajoute valeur inconnue
* @param string $exclude Array list of groups id to exclude
* @param int $disabled If select list must be disabled
* @param string $include Array list of groups id to include
* @param string $include Array list of groups id to include
* @param int $enableonly Array list of groups id to be enabled. All other must be disabled
* @param int $force_entity Possibility to force entity
* @param int $force_entity 0 or Id of environment to force
* @return void
*/
function select_dolgroups($selected='', $htmlname='groupid', $show_empty=0, $exclude='', $disabled=0, $include='', $enableonly='', $force_entity='')
function select_dolgroups($selected='', $htmlname='groupid', $show_empty=0, $exclude='', $disabled=0, $include='', $enableonly='', $force_entity=0)
{
global $conf,$user,$langs;

View File

@ -154,13 +154,13 @@ class User extends CommonObject
$sql.= " u.ref_int, u.ref_ext";
$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->multicompany->transverse_mode)) && (! empty($user->entity)))
{
$sql.= " WHERE u.entity IS NOT NULL";
$sql.= " WHERE u.entity IN (0,".$conf->entity.")";
}
else
{
$sql.= " WHERE u.entity IN (0,".$conf->entity.")";
$sql.= " WHERE u.entity IS NOT NULL";
}
if ($sid) // permet une recherche du user par son SID ActiveDirectory ou Samba

View File

@ -819,21 +819,6 @@ if (($action == 'create') || ($action == 'adduserldap'))
print "</td></tr>\n";
}
//Multicompany
if (! empty($conf->multicompany->enabled))
{
if (empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity)
{
print "<tr>".'<td valign="top">'.$langs->trans("Entity").'</td>';
print "<td>".$mc->select_entities($conf->entity);
print "</td></tr>\n";
}
else
{
print '<input type="hidden" name="entity" value="'.$conf->entity.'" />';
}
}
// Type
print '<tr><td valign="top">'.$langs->trans("Type").'</td>';
print '<td>';
@ -902,6 +887,28 @@ if (($action == 'create') || ($action == 'adduserldap'))
print '<textarea rows="'.ROWS_5.'" cols="90" name="signature">'.GETPOST('signature').'</textarea>';
print '</td></tr>';
// Multicompany
if (! empty($conf->multicompany->enabled))
{
if (empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity)
{
print "<tr>".'<td valign="top">'.$langs->trans("Entity").'</td>';
print "<td>".$mc->select_entities($conf->entity);
print "</td></tr>\n";
}
else
{
print '<input type="hidden" name="entity" value="'.$conf->entity.'" />';
}
}
// Hierarchy
print '<tr><td valign="top">'.$langs->trans("HierarchicalResponsible").'</td>';
print '<td>';
print $form->select_dolusers($object->fk_user,'fk_user',1,array($object->id),0,'',0,$conf->entity);
print '</td>';
print "</tr>\n";
// Note
print '<tr><td valign="top">';
print $langs->trans("Note");
@ -941,7 +948,7 @@ else
/* */
/* ************************************************************************** */
if ($id)
if ($id > 0)
{
$object->fetch($id);
if ($res < 0) { dol_print_error($db,$object->error); exit; }
@ -1051,7 +1058,7 @@ else
if ($action != 'edit')
{
$rowspan=16;
print '<table class="border" width="100%">';
// Ref
@ -1188,7 +1195,7 @@ else
print '<tr><td valign="top">'.$langs->trans('Signature').'</td><td>';
print dol_textishtml($object->signature)?$object->signature:dol_nl2br($object->signature,1,false);
print "</td></tr>\n";
// Hierarchy
print '<tr><td valign="top">'.$langs->trans("HierarchicalResponsible").'</td>';
print '<td>';
@ -1200,8 +1207,8 @@ else
}
print '</td>';
print "</tr>\n";
// Statut
// Status
print '<tr><td valign="top">'.$langs->trans("Status").'</td>';
print '<td>';
print $object->getLibStatut(4);
@ -1223,7 +1230,7 @@ else
print '<td>'.$object->openid.'</td>';
print "</tr>\n";
}
// Company / Contact
if (! empty($conf->societe->enabled))
{
@ -1287,7 +1294,7 @@ else
}
print "</td></tr>\n";
}
// 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
@ -1315,7 +1322,7 @@ else
print '<div class="tabsAction">';
if ($caneditfield && ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $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->multicompany->transverse_mode && $conf->entity == 1)))
{
if (! empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED))
{
@ -1327,7 +1334,7 @@ else
}
}
elseif ($caneditpassword && ! $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) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1)))
{
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=edit">'.$langs->trans("EditPassword").'</a>';
}
@ -1787,7 +1794,7 @@ else
print '<td>';
print '<textarea name="signature" rows="5" cols="90">'.dol_htmlentitiesbr_decode($object->signature).'</textarea>';
print '</td></tr>';
// openid
if (isset($conf->authmode) && preg_match('/myopenid/',$conf->authmode))
{
@ -1808,16 +1815,16 @@ else
// Hierarchy
print '<tr><td valign="top">'.$langs->trans("HierarchicalResponsible").'</td>';
print '<td>';
print $form->select_dolusers($object->fk_user,'fk_user',1,array($object->id));
print $form->select_dolusers($object->fk_user,'fk_user',1,array($object->id),0,'',0,$object->entity);
print '</td>';
print "</tr>\n";
// Statut
// Status
print '<tr><td valign="top">'.$langs->trans("Status").'</td>';
print '<td>';
print $object->getLibStatut(4);
print '</td></tr>';
// Multicompany
if (! empty($conf->multicompany->enabled))
{
@ -1832,7 +1839,7 @@ else
print '<input type="hidden" name="entity" value="'.$conf->entity.'" />';
}
}
// Company / Contact
if (! empty($conf->societe->enabled))
{