To enable content to be submitted anonymously, a mixin "org.ametys.plugins.ugc.Mixin" has been added. It provides contact information: name and mail of the person submitting the content.
This information is no longer automatically calculated, but is required in the ad submission form.
In the default rendering of the "Content proposal" service :
on an authenticated page: the name + mail fields are hidden and pre-filled with the logged-in user. on a non-authenticated page: the name + mail fields are visible and pre-filled if a user is logged in. Be careful if you have overloaded the part below in the service rendering:
Oops! Copy to clipboard failed. Open the code and copy it manually.<xsl:call-template name="contenttype-form">
<xsl:with-param name="className">ugc-form</xsl:with-param>
<xsl:with-param name="actionUrl" select="$ugc-form-url"/>
<xsl:with-param name="submitJsClass" select="concat('submit_', $uniqueId, '()')"/>
<xsl:with-param name="uniqueId" select="$uniqueId"/>
<xsl:with-param name="formId" select="concat('ugc-form-', $uniqueId)"/>
<xsl:with-param name="items" select="/ugc/mixin/metadataSet/*|/ugc/content-type/metadataSet/*[local-name() != 'dc']"/>
<xsl:with-param name="submitI18nKey" select="'plugin.ugc:PLUGINS_UGC_SERVICE_FORM_SUBMIT'"></xsl:with-param>
<xsl:with-param name="contentValues" select="/ugc/items"></xsl:with-param>
<xsl:with-param name="withCaptcha" select="/ugc/has-captcha = 'true'"/>
</xsl:call-template>
<script type="text/javascript">
$j(document).ready(function() {
var _getAmetysUserCb = function(user)
{
if (user)
{
$j('.ugc-form').find('input[name="ugc-contact.name"]').val(user.fullname);
$j('.ugc-form').find('input[name="ugc-contact.mail"]').val(user.email);
$j('.ugc-form').find('input[name="ugc-contact.name"]').closest('fieldset').hide();
}
}
getAmetysUser(_getAmetysUserCb);
});
</script> <xsl:call-template name="contenttype-form">
<xsl:with-param name="className">ugc-form</xsl:with-param>
<xsl:with-param name="actionUrl" select="$ugc-form-url"/>
<xsl:with-param name="submitJsClass" select="concat('submit_', $uniqueId, '()')"/>
<xsl:with-param name="uniqueId" select="$uniqueId"/>
<xsl:with-param name="formId" select="concat('ugc-form-', $uniqueId)"/>
<xsl:with-param name="items" select="/ugc/mixin/metadataSet/*|/ugc/content-type/metadataSet/*[local-name() != 'dc']"/>
<xsl:with-param name="submitI18nKey" select="'plugin.ugc:PLUGINS_UGC_SERVICE_FORM_SUBMIT'"></xsl:with-param>
<xsl:with-param name="contentValues" select="/ugc/items"></xsl:with-param>
<xsl:with-param name="withCaptcha" select="/ugc/has-captcha = 'true'"/>
</xsl:call-template>
<script type="text/javascript">
$j(document).ready(function() {
var _getAmetysUserCb = function(user)
{
if (user)
{
$j('.ugc-form').find('input[name="ugc-contact.name"]').val(user.fullname);
$j('.ugc-form').find('input[name="ugc-contact.mail"]').val(user.email);
$j('.ugc-form').find('input[name="ugc-contact.name"]').closest('fieldset').hide();
}
}
getAmetysUser(_getAmetysUserCb);
});
</script> Voir le code
<xsl:call-template name="contenttype-form">
<xsl:with-param name="className">ugc-form</xsl:with-param>
<xsl:with-param name="actionUrl" select="$ugc-form-url"/>
<xsl:with-param name="submitJsClass" select="concat('submit_', $uniqueId, '()')"/>
<xsl:with-param name="uniqueId" select="$uniqueId"/>
<xsl:with-param name="formId" select="concat('ugc-form-', $uniqueId)"/>
<xsl:with-param name="items" select="/ugc/mixin/metadataSet/*|/ugc/content-type/metadataSet/*[local-name() != 'dc']"/>
<xsl:with-param name="submitI18nKey" select="'plugin.ugc:PLUGINS_UGC_SERVICE_FORM_SUBMIT'"></xsl:with-param>
<xsl:with-param name="contentValues" select="/ugc/items"></xsl:with-param>
<xsl:with-param name="withCaptcha" select="/ugc/has-captcha = 'true'"/>
</xsl:call-template>
<script type="text/javascript">
$j(document).ready(function() {
var _getAmetysUserCb = function(user)
{
if (user)
{
$j('.ugc-form').find('input[name="ugc-contact.name"]').val(user.fullname);
$j('.ugc-form').find('input[name="ugc-contact.mail"]').val(user.email);
$j('.ugc-form').find('input[name="ugc-contact.name"]').closest('fieldset').hide();
}
}
getAmetysUser(_getAmetysUserCb);
});
</script> The logic described above is provided by this piece of code.
In particular, it's important to add the UGC mixin fields to the form "items":
Oops! Copy to clipboard failed. Open the code and copy it manually.<xsl:with-param name="items" select="/ugc/mixin/metadataSet/*|/ugc/content-type/metadataSet/*[local-name() != 'dc']"/> <xsl:with-param name="items" select="/ugc/mixin/metadataSet/*|/ugc/content-type/metadataSet/*[local-name() != 'dc']"/>
<xsl:with-param name="items" select="/ugc/mixin/metadataSet/*|/ugc/content-type/metadataSet/*[local-name() != 'dc']"/>