When you clone a simplenews node that has been sent (emailed), the clone node also has the status of being sent and so it cannot be sent again. I have a client who wanted to able to clone a newsletter so it could be sent to different newsletter groups. To solve this problem I have written a small custom module that resets the status and count of emails sent, could this be included as a feature in a future release

extract of code...


function module_form_alter(&$form, &$form_state, $form_id) {

  switch ($form_id) {
	
  case 'simplenews_node_form':
  
     if (stripos($form['#action'],"/clone") !== false) {
	
        $pnode = $form['#parameters'][2];
        $pnode->simplenews['sent_subscriber_count']=0;
        $pnode->simplenews['s_status']=0;
        $form['#parameters'][2]=$pnode;
		
        $node = $form['#node'];
        $node->simplenews['sent_subscriber_count']=0;
        $node->simplenews['s_status']=0;
        $form['#node']=$node;
     }
    break;
	
  default:
       break;
	
 }//switch

} //module_form_alter

CommentFileSizeAuthor
#2 simplenews_936982_clone.patch1.08 KBmiro_dietiker

Comments

miro_dietiker’s picture

Referring to discussion about resending newsletter
#936982: Clone of simplenews node that has been sent

miro_dietiker’s picture

Status: Active » Fixed
StatusFileSize
new1.08 KB

If you look at clone.pages.inc you can find:

function clone_node_save($nid) {
...
  drupal_alter("clone_node", $node, $original_node, "save-edit");

This means simplenews can react on the clone_node hook.
Attached patch was committed to cvs (1.220.2.59 and .60 - needed 2 commits). If something broken, please tell.
There won't be any backport to 6.x-1.x.

giorgosk’s picture

works as described

but
"save" and "preview" buttons have moved just below "More information about formatting options"
like their weight was changed

could it be related ?

miro_dietiker’s picture

Nope ;-)
We didn't do anything to the buttons with this patch. I don't see any possibility this could change something on the buttons...

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

anybody’s picture

Issue summary: View changes

This also makes sense for 7.x versions. Is this patch contained there?

goose2000’s picture

This issue still exists for the latest version Simplenews. Not sure if form_alter() is the right way to correct this in Drupal 10.

dev-4.x 344532a
dev-4.x 91c4849