Hi Tobias,
Your previous post about the update of Phundament I am still processing. But it is helpful already.
Another thing I came across is an conflict between certain Javascripts, one from the UserModule and one from the P3WidgetsModule. You can see what the problem is when you make a new ProfileField in the UserModule. Try to do this with an user-account with only enough rights to access the UserModule controller actions (NOT with access to the P3WidgetsModule controller actions).
When you choose a FieldType, certain params get an pre-defined value. Choosing VARCHAR sets the FieldSize to 255 e.g. and FieldType INTEGER gets a FieldSize of 10.
In the ProfileFieldController the public function registerScript() has the following JS which handles mentioned behaviour:
$js = "
var name = $('#name'),
value = $('#value'),
allFields = $([]).add(name).add(value),
tips = $('.validateTips');
var listWidgets = jQuery.parseJSON('".str_replace("'","\'",CJavaScript::jsonEncode($widgets[0]))."');
var widgets = jQuery.parseJSON('".str_replace("'","\'",CJavaScript::jsonEncode($widgets[1]))."');
var wgByType = jQuery.parseJSON('".str_replace("'","\'",CJavaScript::jsonEncode($wgByTypes))."');
var fieldType = {
'INTEGER':{
'hide':['match','other_validator','widgetparams'],
'val':{
'field_size':10,
'default':'0',
'range':'',
'widgetparams':''
}
},
'VARCHAR':{
'hide':['widgetparams'],
'val':{
'field_size':255,
'default':'',
'range':'',
'widgetparams':''
}
},
'TEXT':{
'hide':['range','widgetparams'],
'val':{
'field_size':1000,
'default':'',
'range':'',
'widgetparams':''
}
},
'DATE':{
'hide':['field_size','field_size_min','match','range','widgetparams'],
'val':{
'field_size':0,
'default':'0000-00-00',
'range':'',
'widgetparams':''
}
},
'FLOAT':{
'hide':['match','other_validator','widgetparams'],
'val':{
'field_size':'10.2',
'default':'0.00',
'range':'',
'widgetparams':''
}
},
'DECIMAL':{
'hide':['match','other_validator','widgetparams'],
'val':{
'field_size':'10,2',
'default':'0',
'range':'',
'widgetparams':''
}
},
'BOOL':{
'hide':['field_size','field_size_min','match','widgetparams'],
'val':{
'field_size':0,
'default':0,
'range':'1==".UserModule::t('Yes').";0==".UserModule::t('No')."',
'widgetparams':''
}
},
'BLOB':{
'hide':['field_size','field_size_min','match','widgetparams'],
'val':{
'field_size':0,
'default':'',
'range':'',
'widgetparams':''
}
},
'BINARY':{
'hide':['field_size','field_size_min','match','widgetparams'],
'val':{
'field_size':0,
'default':'',
'range':'',
'widgetparams':''
}
}
};
function showWidgetList(type) {
$('div.uwidget select').empty();
$('div.uwidget select').append('<option value=\"\">".UserModule::t('No')."</option>');
if (wgByType[type]) {
for (var k in wgByType[type]) {
$('div.uwidget select').append('<option value=\"'+wgByType[type][k]+'\">'+widgets[wgByType[type][k]]['label']+'</option>');
}
}
}
function setFields(type) {
if (fieldType[type]) {
if (".((isset($_GET['id']))?0:1).") {
showWidgetList(type);
$('#widgetlist option:first').attr('selected', 'selected');
}
$('div.formrow').addClass('toshow').removeClass('tohide');
if (fieldType[type].hide.length) $('div.'+fieldType[type].hide.join(', div.')).addClass('tohide').removeClass('toshow');
if ($('div.uwidget select').val()) {
$('div.widgetparams').removeClass('tohide');
}
$('div.toshow').show(500);
$('div.tohide').hide(500);
".((!isset($_GET['id']))?"
for (var k in fieldType[type].val) {
$('div.'+k+' input').val(fieldType[type].val[k]);
}":'')."
}
}
function isArray(obj) {
if (obj.constructor.toString().indexOf('Array') == -1)
return false;
else
return true;
}
$('#dialog-form').dialog({
autoOpen: false,
height: 400,
width: 400,
modal: true,
buttons: {
'".UserModule::t('Save')."': function() {
var wparam = {};
var fparam = {};
$('#dialog-form fieldset .wparam').each(function(){
if ($(this).val()) wparam[$(this).attr('name')] = $(this).val();
});
var tab = $('#tabs ul li.ui-tabs-selected').text();
fparam[tab] = {};
$('#dialog-form fieldset .tab-'+tab).each(function(){
if ($(this).val()) fparam[tab][$(this).attr('name')] = $(this).val();
});
if ($.JSON.encode(wparam)!='{}') $('div.widgetparams input').val($.JSON.encode(wparam));
if ($.JSON.encode(fparam[tab])!='{}') $('div.other_validator input').val($.JSON.encode(fparam));
$(this).dialog('close');
},
'".UserModule::t('Cancel')."': function() {
$(this).dialog('close');
}
},
close: function() {
}
});
$('#widgetparams').focus(function() {
var widget = widgets[$('#widgetlist').val()];
var html = '';
var wparam = ($('div.widgetparams input').val())?$.JSON.decode($('div.widgetparams input').val()):{};
var fparam = ($('div.other_validator input').val())?$.JSON.decode($('div.other_validator input').val()):{};
// Class params
for (var k in widget.params) {
html += '<label for=\"name\">'+((widget.paramsLabels[k])?widget.paramsLabels[k]:k)+'</label>';
html += '<input type=\"text\" name=\"'+k+'\" id=\"widget_'+k+'\" class=\"text wparam ui-widget-content ui-corner-all\" value=\"'+((wparam[k])?wparam[k]:widget.params[k])+'\" />';
}
// Validator params
if (widget.other_validator) {
var tabs = '';
var li = '';
for (var t in widget.other_validator) {
tabs += '<div id=\"tab-'+t+'\" class=\"tab\">';
li += '<li'+((fparam[t])?' class=\"ui-tabs-selected\"':'')+'><a href=\"#tab-'+t+'\">'+t+'</a></li>';
for (var k in widget.other_validator[t]) {
tabs += '<label for=\"name\">'+((widget.paramsLabels[k])?widget.paramsLabels[k]:k)+'</label>';
if (isArray(widget.other_validator[t][k])) {
tabs += '<select type=\"text\" name=\"'+k+'\" id=\"filter_'+k+'\" class=\"text fparam ui-widget-content ui-corner-all tab-'+t+'\">';
for (var i in widget.other_validator[t][k]) {
tabs += '<option value=\"'+widget.other_validator[t][k][i]+'\"'+((fparam[t]&&fparam[t][k])?' selected=\"selected\"':'')+'>'+widget.other_validator[t][k][i]+'</option>';
}
tabs += '</select>';
} else {
tabs += '<input type=\"text\" name=\"'+k+'\" id=\"filter_'+k+'\" class=\"text fparam ui-widget-content ui-corner-all tab-'+t+'\" value=\"'+((fparam[t]&&fparam[t][k])?fparam[t][k]:widget.other_validator[t][k])+'\" />';
}
}
tabs += '</div>';
}
html += '<div id=\"tabs\"><ul>'+li+'</ul>'+tabs+'</div>';
}
$('#dialog-form fieldset').html(html);
$('#tabs').tabs();
// Show form
$('#dialog-form').dialog('open');
});
$('#ufield_type').change(function() {
setFields($(this).val());
});
$('#widgetlist').change(function() {
if ($(this).val()) {
$('div.widgetparams').show(500);
} else {
$('div.widgetparams').hide(500);
}
});
// show all function
$('div.formrow p.note').append('<br/><a href=\"#\" id=\"showAll\">".UserModule::t('Show all')."</a>');
$('#showAll').click(function(){
$('div.row').show(500);
return false;
});
// init
setFields($('#ufield_type').val());
";
The problem occurs when the account has the rights to edit a P3 Widget (Translation) also. Another JavaScript handles the display of the buttons that appear when you hover over a P3Widget. Those buttons give access to edit the content etc.
I have not much knowledge of JS yet, so I don’t see why those two scripts don’t work together. But I notice that the pre-defined values for all kind of params of the ProfilField are not set automatically any-more.
Someone who sees the problem? Please enlighten us 
Greetings,
Ametad