Fix missing extrafields inline edit handler in projet pages (element, contact, ganttview, tasks) (#38882)

* Fix missing extrafields inline edit handler in projet pages (element, contact, ganttview, tasks)

* Add  to ganttview.php

* Remove include and init for extrafield

* Fix phpstan

---------

Co-authored-by: Zakaria Boushaba <z.boushaba@vold.africa>
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
This commit is contained in:
Zakaria Boushaba 2026-06-29 09:42:15 +01:00 committed by GitHub
parent 1b91318272
commit 221f0a5a6b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 86 additions and 1 deletions

View file

@ -38,6 +38,7 @@ if (isModEnabled('category')) {
/**
* @var Conf $conf
* @var DoliDB $db
* @var ExtraFields $extrafields
* @var HookManager $hookmanager
* @var Translate $langs
* @var User $user
@ -66,6 +67,9 @@ if (getDolGlobalString('PROJECT_ALLOW_COMMENT_ON_PROJECT') && empty($object->com
$object->fetchComments();
}
$extrafields->fetch_name_optionals_label($object->table_element);
$object->fetch_optionals();
// Security check
$socid = 0;
@ -75,6 +79,10 @@ $hookmanager->initHooks(array('projectcontactcard', 'globalcard'));
$result = restrictedArea($user, 'projet', $id, 'projet&project');
$permissiontoadd = $user->hasRight('projet', 'creer');
$permissiontoeditextra = $permissiontoadd;
if (GETPOST('attribute', 'aZ09') && isset($extrafields->attributes[$object->table_element]['perms'][GETPOST('attribute', 'aZ09')])) {
$permissiontoeditextra = dol_eval((string) $extrafields->attributes[$object->table_element]['perms'][GETPOST('attribute', 'aZ09')]);
}
/*
@ -89,6 +97,25 @@ if ($reshook < 0) {
$formconfirmtoaddtasks = '';
if (empty($reshook)) {
if ($action == 'update_extras' && $permissiontoeditextra) {
$object->oldcopy = dol_clone($object, 2);
$attribute_name = GETPOST('attribute', 'aZ09');
$ret = $extrafields->setOptionalsFromPost(null, $object, $attribute_name);
if ($ret < 0) {
$error++;
}
if (!$error) {
$result = $object->updateExtraField($attribute_name, 'PROJECT_MODIFY');
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
$error++;
}
}
if ($error) {
$action = 'edit_extras';
}
}
// Test if we can add contact to the tasks at the same times, if not or not required, make a redirect
if ($action == 'addcontact' && $permissiontoadd) {
$form = new Form($db);

View file

@ -216,6 +216,9 @@ $othermessage = '';
$tmpprojtime = array();
$nbAttendees = 0;
$extrafields->fetch_name_optionals_label($object->table_element);
$object->fetch_optionals();
$permissiontoadd = $user->hasRight('projet', 'creer');
$permissiontodelete = $user->hasRight('projet', 'supprimer');
$permissiondellink = $user->hasRight('projet', 'creer'); // Used by the include of actions_dellink.inc.php

View file

@ -37,6 +37,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
/**
* @var Conf $conf
* @var DoliDB $db
* @var ExtraFields $extrafields
* @var HookManager $hookmanager
* @var Translate $langs
* @var User $user
@ -44,6 +45,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
$id = GETPOST('id', 'intcomma');
$ref = GETPOST('ref', 'alpha');
$action = GETPOST('action', 'aZ09');
$mode = GETPOST('mode', 'alpha');
$mine = ($mode == 'mine' ? 1 : 0);
@ -64,11 +66,38 @@ $result = restrictedArea($user, 'projet', $id, 'projet&project');
$langs->loadlangs(array('users', 'projects'));
$extrafields->fetch_name_optionals_label($object->table_element);
$object->fetch_optionals();
$permissiontoadd = ($user->hasRight('projet', 'all', 'creer') || $user->hasRight('projet', 'creer'));
$permissiontoeditextra = $permissiontoadd;
if (GETPOST('attribute', 'aZ09') && isset($extrafields->attributes[$object->table_element]['perms'][GETPOST('attribute', 'aZ09')])) {
$permissiontoeditextra = dol_eval((string) $extrafields->attributes[$object->table_element]['perms'][GETPOST('attribute', 'aZ09')]);
}
$error = 0;
/*
* Actions
*/
// None
if ($action == 'update_extras' && $permissiontoeditextra) {
$object->oldcopy = dol_clone($object, 2);
$attribute_name = GETPOST('attribute', 'aZ09');
$ret = $extrafields->setOptionalsFromPost(null, $object, $attribute_name);
if ($ret < 0) {
$error++;
}
if (!$error) {
$result = $object->updateExtraField($attribute_name, 'PROJECT_MODIFY');
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
$error++;
}
}
if ($error) {
$action = 'edit_extras';
}
}
/*

View file

@ -129,6 +129,7 @@ if (getDolGlobalString('PROJECT_ALLOW_COMMENT_ON_PROJECT') && method_exists($obj
if ($id > 0 || !empty($ref)) {
// fetch optionals attributes and labels
$extrafields->fetch_name_optionals_label($object->table_element);
$object->fetch_optionals();
}
$extrafields->fetch_name_optionals_label($taskstatic->table_element);
$search_array_options = $extrafields->getOptionalsFromPost($taskstatic->table_element, '', 'search_');
@ -155,6 +156,12 @@ $hookmanager->initHooks(array('projecttaskscard', 'globalcard'));
//if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignment.
$result = restrictedArea($user, 'projet', $id, 'projet&project');
$permissiontoadd = $user->hasRight('projet', 'creer');
$permissiontoeditextra = $permissiontoadd;
if (GETPOST('attribute', 'aZ09') && isset($extrafields->attributes[$object->table_element]['perms'][GETPOST('attribute', 'aZ09')])) {
$permissiontoeditextra = dol_eval((string) $extrafields->attributes[$object->table_element]['perms'][GETPOST('attribute', 'aZ09')]);
}
$diroutputmassaction = $conf->project->dir_output.'/tasks/temp/massgeneration/'.$user->id;
$progress = GETPOSTINT('progress');
@ -230,6 +237,25 @@ if ($reshook < 0) {
}
if (empty($reshook)) {
if ($action == 'update_extras' && ($id > 0 || !empty($ref)) && $permissiontoeditextra) {
$object->oldcopy = dol_clone($object, 2);
$attribute_name = GETPOST('attribute', 'aZ09');
$ret = $extrafields->setOptionalsFromPost(null, $object, $attribute_name);
if ($ret < 0) {
$error++;
}
if (!$error) {
$result = $object->updateExtraField($attribute_name, 'PROJECT_MODIFY');
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
$error++;
}
}
if ($error) {
$action = 'edit_extras';
}
}
// Selection of new fields
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';