Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NEW funclionality to Clone user with permissions and categories #29773

Merged
merged 18 commits into from
Nov 13, 2024

Conversation

lamrani002
Copy link
Contributor

NEW|New functionality to clone user

$sql .= " SELECT 1";
$sql .= " FROM ".$this->db->prefix()."user_rights dest";
$sql .= " WHERE dest.entity = src.entity";
$sql .= " AND dest.fk_user = ".$this->db->escape($toId);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is an int so must use
$sql .= " AND dest.fk_user = ".((int) $toId);


// Construction de la requête d'insertion
$sql = "INSERT INTO ".$this->db->prefix()."user_rights (entity, fk_user, fk_id)";
$sql .= " SELECT entity, ".$this->db->escape($toId).", fk_id";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is an int so must use
$sql .= " SELECT entity, ".((int) $toId).", fk_id";

$categorystatic = new Categorie($this->db);

$sql = "INSERT INTO ".$this->db->prefix()."categorie_".(empty($categorystatic->MAP_CAT_TABLE[$type]) ? $type : $categorystatic->MAP_CAT_TABLE[$type])." (fk_categorie, fk_user)";
$sql .= " SELECT fk_categorie, $toId FROM ".$this->db->prefix()."categorie_".(empty($categorystatic->MAP_CAT_TABLE[$type]) ? $type : $categorystatic->MAP_CAT_TABLE[$type]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$toId must be sanitized with (int)

@eldy eldy added the PR to fix - See feedback in comments PR needs to be fixed to be integrated (some comments should describes the fix to do) label Jun 4, 2024
@eldy eldy added PR postponed PR is postponed (will be processed later). Ie: feature pushed during a beta or need transition steps and removed PR to fix - See feedback in comments PR needs to be fixed to be integrated (some comments should describes the fix to do) labels Jun 6, 2024
@hregis
Copy link
Contributor

hregis commented Oct 28, 2024

@lamrani002 it will probably be necessary to adapt the cloning functions when Multicompany uses user centralization on the main entity!

@eldy
Copy link
Member

eldy commented Nov 13, 2024

@lamrani002 it will probably be necessary to adapt the cloning functions when Multicompany uses user centralization on the main entity!

An easy to do first step can be to show the clone feature only if user is in same entity than current entity. So cloning is kept always in same entity.

@eldy eldy changed the title New funclionality to Clone user with permissions and categories NEW funclionality to Clone user with permissions and categories Nov 13, 2024
@eldy eldy merged commit 7e283c2 into Dolibarr:develop Nov 13, 2024
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR postponed PR is postponed (will be processed later). Ie: feature pushed during a beta or need transition steps
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants