$output=t('<p>This submodule of <strong>Anonymous Publishing</strong> lets users publish content without first registering an account at the site, but in a manner that affords some protection against spam.</p><p>Just enabling the module does nothing. You also need to enable anonymous publishing for at least one node type. If you want visitors to be able to create content without registering, you also need to grant the the anonymous user role the permission to “Create new content” for at least one node type . To do this, go to <a title="Set permissions for anonymous." <a href="@url">Administration » People » Permissions</a> for the node module.</p>',array('@url'=>Url::fromRoute('user.admin_permissions')->toString()));
$output=t('<p>This submodule of <strong>Anonymous Publishing</strong> lets users publish content without first registering an account at the site, but in a manner that affords some protection against spam.</p><p>Just enabling the module does nothing. You also need to enable anonymous publishing for at least one node type. If you want visitors to be able to create content without registering, you also need to grant the the anonymous user role the permission to “Create new content” for at least one node type . To do this, go to <a title="Set permissions for anonymous." <a href="@url">Administration » People » Permissions</a> for the node module.</p>',['@url'=>Url::fromRoute('user.admin_permissions')->toString()]);
$variables['submitted']=t('Submitted by @username on @datetime',array(
$variables['submitted']=t('Submitted by @username on @datetime',[
'@username'=>$variables['author'],
'@datetime'=>$variables['created']
));
'@datetime'=>$variables['created'],
]);
}
}
}
}
}
/**
* Entity form builder to add the anonymous publishing informations to the entity.
*/
@@ -190,36 +188,36 @@ function _anonymous_publishing_cl_alter_comment_or_node_form(&$form, FormStateIn
// Create the anonymous publishing options.
// Node author information for administrators.
$form['anonymous_publishing']=array(
$form['anonymous_publishing']=[
'#type'=>'details',
'#title'=>t('Anonymous Publishing'),
'#group'=>'advanced',
'#open'=>TRUE,
'#attributes'=>array(
'class'=>array('form-anonymous-publishing'),
),
'#attached'=>array(
'library'=>array('node/drupal.node'),
),
'#attributes'=>[
'class'=>['form-anonymous-publishing'],
],
'#attached'=>[
'library'=>['node/drupal.node'],
],
'#optional'=>FALSE,
);
];
$options=$settings->get('general_options');
$aliasopt=$settings->get('user_alias');
$selfactmsg=$options['sactivate']?'':' '.t('and the content is approved by by an administrator');
$verifymsg=t('Your content will not appear on this site until your email is verified@selfactmsg.',array('@selfactmsg'=>$selfactmsg));
$verifymsg=t('Your content will not appear on this site until your email is verified@selfactmsg.',['@selfactmsg'=>$selfactmsg]);
$verifymsg.=' <b>'.t('Your email address will not be shown publicly.').'</b>';
$form['anonymous_publishing']['email']=array(
$form['anonymous_publishing']['email']=[
'#type'=>'email',
'#title'=>t('Verification email address:'),
'#description'=>$verifymsg,
'#size'=>60,
'#maxlength'=>Email::EMAIL_MAX_LENGTH,
'#required'=>TRUE,
'#parents'=>array('anonymous_publishing_email'),
);
'#parents'=>['anonymous_publishing_email'],
];
// If user can choose an alias, give him UI for this config.
if($aliasopt=='byline'){
@@ -227,14 +225,14 @@ function _anonymous_publishing_cl_alter_comment_or_node_form(&$form, FormStateIn
if(!empty($bylineguide)){
$bylineguide.=' ';
}
$form['anonymous_publishing']['alias']=array(
$form['anonymous_publishing']['alias']=[
'#type'=>'textfield',
'#title'=>t('Byline:'),
'#description'=>t('@bylineguide<em>All</em> posts associated with this email address will carry this byline. Leave blank if you want to keep the byline already associated with this email address.',array('@bylineguide'=>$bylineguide)),
'#description'=>t('@bylineguide<em>All</em> posts associated with this email address will carry this byline. Leave blank if you want to keep the byline already associated with this email address.',['@bylineguide'=>$bylineguide]),
'#size'=>30,
'#maxlength'=>Email::EMAIL_MAX_LENGTH,
'#parents'=>array('anonymous_publishing_alias'),
);
'#parents'=>['anonymous_publishing_alias'],
];
}
// Set default_value non-empty to simulate 'bot.
@@ -242,15 +240,15 @@ function _anonymous_publishing_cl_alter_comment_or_node_form(&$form, FormStateIn
// It shall never be seen by humans. 'Bots look for English words like
// "email", so it is better to leave this untranslated to make sure the
// 'bot bites the bait.
$form['email_confirm_field']=array(
$form['email_confirm_field']=[
'#type'=>'email',
'#title'=>'Enter your email address (not!):',
'#default_value'=>'',
'#size'=>20,
'#description'=>t('This field should not even be visible to humans.'),
\Drupal::messenger()->addMessage(t('Thank you for posting here. You must also confirm that @email belongs to you.',array('@email'=>$comment->anonymous_publishing_email)));
\Drupal::messenger()->addMessage(t('Thank you for posting here. You must also confirm that @email belongs to you.',['@email'=>$comment->anonymous_publishing_email]));
}
}
}
@@ -571,11 +565,11 @@ function anonymous_publishing_cl_node_presave(NodeInterface $node) {
@@ -593,7 +587,7 @@ function anonymous_publishing_cl_node_presave(NodeInterface $node) {
if($needs_confirmation){
$node->set('status',NODE_NOT_PUBLISHED);
\Drupal::messenger()->addMessage(t('Thank you for posting here. You must also confirm that @email belongs to you.',array('@email'=>$node->anonymous_publishing_email)));
\Drupal::messenger()->addMessage(t('Thank you for posting here. You must also confirm that @email belongs to you.',['@email'=>$node->anonymous_publishing_email]));
}
}
}
@@ -605,7 +599,7 @@ function anonymous_publishing_cl_entity_delete(EntityInterface $entity) {