diff --git a/htdocs/projet/contact.php b/htdocs/projet/contact.php index 6672e16dfab..e81215050c0 100644 --- a/htdocs/projet/contact.php +++ b/htdocs/projet/contact.php @@ -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); diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 29c26b01096..89de95b7624 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -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 diff --git a/htdocs/projet/ganttview.php b/htdocs/projet/ganttview.php index 47b1936ecda..80dc43be10a 100644 --- a/htdocs/projet/ganttview.php +++ b/htdocs/projet/ganttview.php @@ -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'; + } +} /* diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index 53eba5e3f43..b1d44df6b24 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -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';