diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 0eaa3efff8f..b5e7174f9b0 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -1001,13 +1001,7 @@ else } // Other attributes - $parameters=array(); - $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - if (empty($reshook) && ! empty($extrafields->attribute_label)) - { - print $object->showOptionals($extrafields,'edit'); - } + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; print ''; print "\n"; @@ -1277,13 +1271,7 @@ else print ''; // Other attributes - $parameters=array(); - $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - if (empty($reshook) && ! empty($extrafields->attribute_label)) - { - print $object->showOptionals($extrafields,'edit',$parameters); - } + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; print ''; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 88ef341cb04..25fa78b1067 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -5938,8 +5938,16 @@ abstract class CommonObject $e = 0; foreach($extrafields->attribute_label as $key=>$label) { - if (empty($extrafields->attribute_list[$key])) continue; // 0 = Never visible field - if (($mode == 'create' || $mode == 'edit') && abs($extrafields->attribute_list[$key]) != 1 && abs($extrafields->attribute_list[$key]) != 3) continue; // <> -1 and <> 1 and <> 3 = not visible on forms, only on list + $enabled = $extrafields->attribute_list[$key]; + if (empty($enabled)) continue; // 0 = Never visible field + if (! is_numeric($enabled)) + { + $enabled=dol_eval($enabled, 1); + if (empty($enabled)) continue; + else $enabled = 1; + } + + if (($mode == 'create' || $mode == 'edit') && abs($enabled) != 1 && abs($enabled) != 3) continue; // <> -1 and <> 1 and <> 3 = not visible on forms, only on list // Load language if required if (! empty($extrafields->attributes[$this->table_element]['langfile'][$key])) $langs->load($extrafields->attributes[$this->table_element]['langfile'][$key]); diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index bf9bcf587f8..0905223c4fe 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -144,7 +144,7 @@ class ExtraFields * @param array|string $param Params for field (ex for select list : array('options' => array(value'=>'label of option')) ) * @param int $alwayseditable Is attribute always editable regardless of the document status * @param string $perms Permission to check - * @param int $list Visibilty (0=never visible, 1=visible on list+forms, 2=list onyl, 3=form only) + * @param string $list Visibilty ('0'=never visible, '1'=visible on list+forms, '2'=list only, '3'=form only or 'eval string') * @param int $notused Deprecated. * @param string $computed Computed value * @param string $entity Entity of extrafields (for multicompany modules) @@ -152,7 +152,7 @@ class ExtraFields * @param string $enabled Condition to have the field enabled or not * @return int <=0 if KO, >0 if OK */ - function addExtraField($attrname, $label, $type, $pos, $size, $elementtype, $unique=0, $required=0, $default_value='', $param='', $alwayseditable=0, $perms='', $list=-1, $notused=0, $computed='', $entity='', $langfile='', $enabled='1') + function addExtraField($attrname, $label, $type, $pos, $size, $elementtype, $unique=0, $required=0, $default_value='', $param='', $alwayseditable=0, $perms='', $list='-1', $notused=0, $computed='', $entity='', $langfile='', $enabled='1') { if (empty($attrname)) return -1; if (empty($label)) return -1; @@ -198,11 +198,11 @@ class ExtraFields * @param string $default_value Default value for field (in database) * @param array $param Params for field (ex for select list : array('options'=>array('value'=>'label of option')) * @param string $perms Permission - * @param int $list Into list view by default + * @param string $list Into list view by default * @param string $computed Computed value * @return int <=0 if KO, >0 if OK */ - private function create($attrname, $type='varchar', $length=255, $elementtype='member', $unique=0, $required=0, $default_value='',$param='', $perms='', $list=0, $computed='') + private function create($attrname, $type='varchar', $length=255, $elementtype='member', $unique=0, $required=0, $default_value='',$param='', $perms='', $list='0', $computed='') { if ($elementtype == 'thirdparty') $elementtype='societe'; if ($elementtype == 'contact') $elementtype='socpeople'; @@ -288,7 +288,7 @@ class ExtraFields * @param array|string $param Params for field (ex for select list : array('options' => array(value'=>'label of option')) ) * @param int $alwayseditable Is attribute always editable regardless of the document status * @param string $perms Permission to check - * @param int $list Visibily + * @param string $list Visibily * @param int $notused Deprecated. * @param string $default Default value (in database. use the default_value feature for default value on screen). * @param string $computed Computed value @@ -297,7 +297,7 @@ class ExtraFields * @param string $enabled Condition to have the field enabled or not * @return int <=0 if KO, >0 if OK */ - private function create_label($attrname, $label='', $type='', $pos=0, $size=0, $elementtype='member', $unique=0, $required=0, $param='', $alwayseditable=0, $perms='', $list=-1, $notused=0, $default='', $computed='',$entity='', $langfile='', $enabled='1') + private function create_label($attrname, $label='', $type='', $pos=0, $size=0, $elementtype='member', $unique=0, $required=0, $param='', $alwayseditable=0, $perms='', $list='-1', $notused=0, $default='', $computed='',$entity='', $langfile='', $enabled='1') { global $conf,$user; @@ -306,7 +306,7 @@ class ExtraFields // Clean parameters if (empty($pos)) $pos=0; - if (empty($list)) $list=0; + if (empty($list)) $list='0'; if (empty($required)) $required=0; if (empty($unique)) $unique=0; if (empty($alwayseditable)) $alwayseditable=0; @@ -361,7 +361,7 @@ class ExtraFields $sql.= " ".$alwayseditable.","; $sql.= " ".($perms?"'".$this->db->escape($perms)."'":"null").","; $sql.= " ".($langfile?"'".$this->db->escape($langfile)."'":"null").","; - $sql.= " ".$list.","; + $sql.= " '".$this->db->escape($list)."',"; $sql.= " ".($default?"'".$this->db->escape($default)."'":"null").","; $sql.= " ".($computed?"'".$this->db->escape($computed)."'":"null").","; $sql .= " " . $user->id . ","; @@ -496,7 +496,7 @@ class ExtraFields * @param array $param Params for field (ex for select list : array('options' => array(value'=>'label of option')) ) * @param int $alwayseditable Is attribute always editable regardless of the document status * @param string $perms Permission to check - * @param int $list Visibility + * @param string $list Visibility * @param int $notused Deprecated. * @param string $default Default value (in database. use the default_value feature for default value on screen). * @param string $computed Computed value @@ -605,7 +605,7 @@ class ExtraFields * @param array $param Params for field (ex for select list : array('options' => array(value'=>'label of option')) ) * @param int $alwayseditable Is attribute always editable regardless of the document status * @param string $perms Permission to check - * @param int $list Visiblity + * @param string $list Visiblity * @param int $notused Deprecated. * @param string $default Default value (in database. use the default_value feature for default value on screen). * @param string $computed Computed value @@ -614,7 +614,7 @@ class ExtraFields * @param string $enabled Condition to have the field enabled or not * @return int <=0 if KO, >0 if OK */ - private function update_label($attrname,$label,$type,$size,$elementtype,$unique=0,$required=0,$pos=0,$param='',$alwayseditable=0,$perms='',$list=0,$notused=0,$default='',$computed='',$entity='',$langfile='',$enabled='1') + private function update_label($attrname,$label,$type,$size,$elementtype,$unique=0,$required=0,$pos=0,$param='',$alwayseditable=0,$perms='',$list='0',$notused=0,$default='',$computed='',$entity='',$langfile='',$enabled='1') { global $conf, $user; dol_syslog(get_class($this)."::update_label ".$attrname.", ".$label.", ".$type.", ".$size.", ".$elementtype.", ".$unique.", ".$required.", ".$pos.", ".$alwayseditable.", ".$perms.", ".$list.", ".$notused.", ".$default.", ".$computed.", ".$entity.", ".$langfile.", ".$enabled); @@ -624,7 +624,7 @@ class ExtraFields if ($elementtype == 'contact') $elementtype='socpeople'; if (empty($pos)) $pos=0; - if (empty($list)) $list=0; + if (empty($list)) $list='0'; if (empty($required)) $required=0; if (empty($unique)) $unique=0; if (empty($alwayseditable)) $alwayseditable=0; @@ -688,7 +688,7 @@ class ExtraFields $sql.= " ".$pos.","; $sql.= " '".$this->db->escape($alwayseditable)."',"; $sql.= " '".$this->db->escape($params)."',"; - $sql.= " ".$list.", "; + $sql.= " '".$this->db->escape($list)."', "; $sql.= " ".(($default!='')?"'".$this->db->escape($default)."'":"null").","; $sql.= " ".($computed?"'".$this->db->escape($computed)."'":"null").","; $sql .= " " . $user->id . ","; diff --git a/htdocs/core/tpl/admin_extrafields_edit.tpl.php b/htdocs/core/tpl/admin_extrafields_edit.tpl.php index e08983f9e10..5ecf859f603 100644 --- a/htdocs/core/tpl/admin_extrafields_edit.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_edit.tpl.php @@ -252,7 +252,7 @@ else textwithpicto($langs->trans("Visibility"), $langs->trans("VisibleDesc")); ?> - + diff --git a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql index 880bd4e7ca2..2a088118119 100644 --- a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql +++ b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql @@ -411,3 +411,5 @@ UPDATE llx_accounting_account set account_parent = 0 WHERE account_parent = '' O ALTER TABLE llx_accounting_account MODIFY COLUMN account_parent integer DEFAULT 0; ALTER TABLE llx_accounting_account ADD INDEX idx_accounting_account_account_parent (account_parent); +ALTER TABLE llx_extrafields MODIFY COLUMN list VARCHAR(128); + diff --git a/htdocs/install/mysql/tables/llx_extrafields.sql b/htdocs/install/mysql/tables/llx_extrafields.sql index 5c3a318b796..9acf239ee64 100644 --- a/htdocs/install/mysql/tables/llx_extrafields.sql +++ b/htdocs/install/mysql/tables/llx_extrafields.sql @@ -35,7 +35,7 @@ create table llx_extrafields pos integer DEFAULT 0, alwayseditable integer DEFAULT 0, -- 1 if field can be edited whatever is element status param text, -- extra parameters to define possible values of field - list integer DEFAULT 1, -- visibility of field. 0=Never visible, 1=Visible on list and forms, 2=Visible on list only. Using a negative value means field is not shown by default on list but can be selected for viewing + list varchar(255) DEFAULT '1', -- visibility of field. 0=Never visible, 1=Visible on list and forms, 2=Visible on list only. Using a negative value means field is not shown by default on list but can be selected for viewing langs varchar(64), -- example: fileofmymodule@mymodule fk_user_author integer, -- user making creation fk_user_modif integer, -- user making last change diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index 1ba869796ed..b6d87ce9ac2 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -59,11 +59,7 @@ $backtopage=GETPOST('backtopage','alpha'); $action=GETPOST('action','alpha'); // Load translation files -$langs->load("main"); -$langs->load("members"); -$langs->load("companies"); -$langs->load("install"); -$langs->load("other"); +$langs->loadLangs(array("main","members","companies","install","other")); // Security check if (empty($conf->adherent->enabled)) accessforbidden('',0,0,1); @@ -76,6 +72,8 @@ if (empty($conf->global->MEMBER_ENABLE_PUBLIC)) $extrafields = new ExtraFields($db); +$object = new Adherent($db); + /** * Show header for new member @@ -487,17 +485,17 @@ llxHeaderVierge($langs->trans("NewSubscription")); print load_fiche_titre($langs->trans("NewSubscription"), '', '', 0, 0, 'center'); -print '
'; + +print '
'; +print '
'; + +print '
'; if (! empty($conf->global->MEMBER_NEWFORM_TEXT)) print $langs->trans($conf->global->MEMBER_NEWFORM_TEXT)."
\n"; else print $langs->trans("NewSubscriptionDesc",$conf->global->MAIN_INFO_SOCIETE_MAIL)."
\n"; print '
'; dol_htmloutput_errors($errmsg); -print '
'; -print '
'; - - // Print form print '
'."\n"; print ''; @@ -631,13 +629,8 @@ print ''."\n"; print ''.$langs->trans("URLPhoto").''."\n"; // Public print ''.$langs->trans("Public").''."\n"; -// Extrafields -foreach($extrafields->attribute_label as $key=>$value) -{ - print "".$value.""; - print $extrafields->showInputField($key,GETPOST('options_'.$key)); - print "\n"; -} +// Other attributes +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; // Comments print ''; print ''.$langs->trans("Comments").'';