1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-10 08:44:46 +02:00

Update ProcessTemplate so that it lets you specify when fields user can edit in their profile, when editing the "user" template. Meaning, it's no longer necessary to jump back and forth between ProcessProfile and the ProcessProfile module config.

This commit is contained in:
Ryan Cramer
2017-11-16 10:53:16 -05:00
parent ac59da3427
commit 6c3eb6a460

View File

@@ -757,7 +757,20 @@ class ProcessTemplate extends Process {
$f->attr('id+name', '_fieldgroup_fields_changed');
$f->attr('value', '');
$t->add($f);
if($template->name != $template->fieldgroup->name || $this->config->advanced) $t->add($this->buildEditFormFieldgroup($template));
if(in_array($template->id, $this->wire('config')->userTemplateIDs)) {
/** @var ProcessProfile $profile */
$profile = $this->wire('modules')->get('ProcessProfile');
$profileInputs = $profile->getModuleConfigInputfields(array('profileFields' => $profile->profileFields));
$f = $profileInputs->getChildByName('profileFields');
$f->attr('id+name', '_user_profile_fields');
$f->description = $this->_('If you just added fields above, save first and then return here to select them.');
$t->add($f);
}
if($template->name != $template->fieldgroup->name || $this->config->advanced) {
$t->add($this->buildEditFormFieldgroup($template));
}
/** @var InputfieldText $f */
$f = $this->modules->get('InputfieldText');
@@ -945,10 +958,6 @@ class ProcessTemplate extends Process {
$select->setAsmSelectOption('editLink', $this->wire('config')->urls->admin . "setup/field/edit?id={value}&fieldgroup_id={$template->fieldgroup->id}&modal=1&process_template=1");
$select->setAsmSelectOption('hideDeleted', false);
if(in_array($template->id, $this->wire('config')->userTemplateIDs)) {
$select->notes = sprintf($this->_('To configure what fields a user can edit in their profile, see the [profile module settings](%s).'), $this->wire('config')->urls->admin . 'module/edit?name=ProcessProfile');
}
foreach($template->fieldgroup as $field) {
$field = $template->fieldgroup->getField($field->id, true); // get in context
$attrs = $this->getAsmListAttrs($field);
@@ -2298,6 +2307,16 @@ class ProcessTemplate extends Process {
return;
}
if(in_array($template->id, $this->wire('config')->userTemplateIDs)) {
$f = $form->getChildByName('_user_profile_fields');
$data = $this->wire('modules')->getConfig('ProcessProfile');
if($f && $data['profileFields'] != $f->val()) {
$data['profileFields'] = $f->val();
$this->wire('modules')->saveConfig('ProcessProfile', $data);
$this->message("Updated user profile fields", Notice::debug);
}
}
if($input->post('fieldgroup') && $input->post('fieldgroup') != $template->fieldgroup->id) {
$redirectUrl = "fieldgroup?id={$template->id}&fieldgroup=" . (int) $input->post('fieldgroup');
}