Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#16 2007-07-25 23:14:58

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: [plugin] [ORPHAN] upm_pending_notify: Pending article notification

v.0.1.2

Last edited by Mary (2013-01-24 17:24:07)

Offline

#17 2007-07-26 00:29:25

Richard
New Member
From: Ontario Canada
Registered: 2007-06-13
Posts: 5
Website

Re: [plugin] [ORPHAN] upm_pending_notify: Pending article notification

Mary

Thanks very much, have installed and as soon as one of my lazy buggers who call themselves writers get around to posting anything I’ll let you know if it solved our problem.

Richard


“Every artists strictly illimitable country is himself/the artist who has played that country false has comitted suicide” e.e. cummings

Offline

#18 2009-01-08 09:22:03

whocarez
Plugin Author
From: Germany/Ukraine
Registered: 2007-10-08
Posts: 305
Website GitHub Twitter

Re: [plugin] [ORPHAN] upm_pending_notify: Pending article notification

Hello,

since my upgrade to 4.07 this plugin stopped working. Has anyone a solution?

Update
I was a little bit to fast, three emails got lost, but it was not the fault of the plugin, I think.
It´s working in 4.0.7!

Last edited by whocarez (2009-01-15 11:17:19)

Offline

#19 2009-07-22 03:27:16

hicks
Member
From: Portland, OR, USA (ex-UK)
Registered: 2009-05-08
Posts: 106
Website

Re: [plugin] [ORPHAN] upm_pending_notify: Pending article notification

Hello,

How would I edit the plug-in to not inform the authors when their articles go live? (I’d rather tell them in a personal email.)

Thanks!

Offline

#20 2009-07-22 14:40:42

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: [plugin] [ORPHAN] upm_pending_notify: Pending article notification

You can take advantage of one of the plugin’s limitations: when you change the article status to live via the article list screen’s multi-edit functionality, rather than editing the individual article directly, author notifications are not sent.

Offline

#21 2009-07-22 15:45:51

hicks
Member
From: Portland, OR, USA (ex-UK)
Registered: 2009-05-08
Posts: 106
Website

Re: [plugin] [ORPHAN] upm_pending_notify: Pending article notification

Thanks Mary, good tip.
I was thinking it would be easy just to comment out or delete some lines in the plug in, if only I knew which ones would do the job without messing up the rest of it?

Offline

#22 2009-07-23 03:08:41

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: [plugin] [ORPHAN] upm_pending_notify: Pending article notification

Sure. Look for:

$GLOBALS['upm_pending_notify'] = 'author';

And comment it out.

And I’ll see about making author notification an option you can turn on and off. :)

Offline

#23 2009-07-23 04:20:29

hicks
Member
From: Portland, OR, USA (ex-UK)
Registered: 2009-05-08
Posts: 106
Website

Re: [plugin] [ORPHAN] upm_pending_notify: Pending article notification

Great, thank you.

Offline

#24 2010-07-11 00:13:49

Katalonian
Member
From: Baku, Azerbaijan
Registered: 2010-04-18
Posts: 219
Website

Re: [plugin] [ORPHAN] upm_pending_notify: Pending article notification

great!


<txp:txp_me />

Offline

#25 2014-01-27 11:35:19

whocarez
Plugin Author
From: Germany/Ukraine
Registered: 2007-10-08
Posts: 305
Website GitHub Twitter

Re: [plugin] [ORPHAN] upm_pending_notify: Pending article notification

Although this plugin is orphaned, but has someone a solution or an alternative with a function notifiing authors in case of setting an article to “Live” in textpattern 4.5.5?

When an article is changed from “Pending” to “Live” status, the article’s author receives a link to view their article on the live site. If the author happens to be a Publisher and set the article to “Live” herself, she does not receive the email.

Thanks!

Offline

#26 2014-01-29 21:27:15

whocarez
Plugin Author
From: Germany/Ukraine
Registered: 2007-10-08
Posts: 305
Website GitHub Twitter

Re: [plugin] [ORPHAN] upm_pending_notify: Pending article notification

no one?

Offline

#27 2014-01-29 23:10:15

GugUser
Member
From: Quito (Ecuador)
Registered: 2007-12-16
Posts: 1,477

Re: [plugin] [ORPHAN] upm_pending_notify: Pending article notification

I imagine that could do rah_post_versions.

Offline

#28 2014-01-30 15:16:46

whocarez
Plugin Author
From: Germany/Ukraine
Registered: 2007-10-08
Posts: 305
Website GitHub Twitter

Re: [plugin] [ORPHAN] upm_pending_notify: Pending article notification

ah, thanks, I’ll give it a try …

Offline

#29 2014-02-01 15:20:36

whocarez
Plugin Author
From: Germany/Ukraine
Registered: 2007-10-08
Posts: 305
Website GitHub Twitter

Re: [plugin] [ORPHAN] upm_pending_notify: Pending article notification

hm, somehow it doesn’t match my needs …
Maybe someone of the developers can take a look on this code and say, where changes have to be made. Publishers are still notified, when an author creates an article, but there should be also a notification for the authors, when the article is published by an editor.

	if (txpinterface == 'admin')
	{
		// i quite hate doing it this way, the write tab's setup is screwy

		add_privs('upm_pending_notify_created', '1,2,3,4,5');
		register_callback('upm_pending_notify_created', 'article', 'edit');

		add_privs('upm_pending_notify_updated_pre', '1,2,3,4,5');
		register_callback('upm_pending_notify_updated_pre', 'article', '', 1);

		add_privs('upm_pending_notify_updated_post', '1,2,3,4,5');
		register_callback('upm_pending_notify_updated_post', 'article', 'edit');
	}

//--------------------------------------------------------------

	function upm_pending_notify_created()
	{
		global $ID;

		// not trying to create a new article
		// begone!
		if (!gps('publish'))
		{
			return;
		}

		$Status = (int) ps('Status');

		if (!has_privs('article.publish') && $Status >= 4)
		{
			$Status = 3;
		}

		if ($Status == 3)
		{
			$ID	= (int) $ID;
			$Title = ps('Title');

			upm_pending_notify_publisher($ID, $Title);
		}
	}

//--------------------------------------------------------------

	function upm_pending_notify_updated_pre()
	{
		$GLOBALS['upm_pending_notify'] = false;

		// article updated
		if (gps('save'))
		{
			$ID = (int) ps('ID');

			$Status = (int) ps('Status');

			$old_status = (int) safe_field('Status', 'textpattern', "ID = $ID");

			// only notify if...

			// ...marked as pending
			// publishers are notified
			// see: upm_pending_notify_updated_post()
			if ($Status == 3)
			{
				$GLOBALS['upm_pending_notify'] = 'publishers';
			}

			// ...marked as live/sticky and was previously pending
			// author is notified
			// see: upm_pending_notify_updated_post()
			elseif ($Status > 3 and $old_status == 3)
			{
				$GLOBALS['upm_pending_notify'] = 'author';
			}
		}
	}

//--------------------------------------------------------------

	function upm_pending_notify_updated_post()
	{
		global $upm_pending_notify, $txp_user, $prefs;

		if (!$upm_pending_notify)
		{
			return;
		}

		$ID = (int) ps('ID');
		$Title = ps('Title');

		switch ($upm_pending_notify)
		{
			case 'publishers':
				upm_pending_notify_publisher($ID, $Title);
			break;

			case 'author':
				$AuthorID = ps('AuthorID');
				$LastModID = ps('LastModID');

				upm_pending_notify_author($ID, $Title, $AuthorID, $LastModID);
			break;
		}
	}

//--------------------------------------------------------------

	function upm_pending_notify_publisher($ID, $Title)
	{
		global $txp_user, $prefs;

		$publishers = safe_rows_start('RealName, email', 'txp_users', "privs = 1 and name != '".doSlash($txp_user)."'");

		if ($publishers)
		{
			$Title = ($Title) ? strip_tags($Title) : gTxt('untitled');
			$author = get_author_name($txp_user);

			$subject = upm_pending_notify_gTxt('email_subject_publisher', array(
				'{sitename}' => $prefs['sitename'],
				'{title}'		 => $Title,
			));

			while ($publisher = nextRow($publishers))
			{
				$body = upm_pending_notify_gTxt('email_message_publisher', array(
					'{article_url}' => hu.'textpattern/index.php?event=article&step=edit&ID='.$ID,
					'{author}'			=> $author,
					'{publisher}'		=> $publisher['RealName'],
					'{title}'				=> $Title,
				));

				upm_pending_notify_mail($publisher['RealName'], $publisher['email'], $subject, $body);
			}
		}
	}

//--------------------------------------------------------------

	function upm_pending_notify_author($ID, $Title, $AuthorID, $LastModID)
	{
		global $txp_user, $prefs;

		$author = safe_row('RealName, email', 'txp_users', "name = '".doSlash($AuthorID)."' and name != '".doSlash($txp_user)."'");

		if ($author)
		{
			include_once txpath.'/publish/taghandlers.php';

			$Title = ($Title) ? strip_tags($Title) : gTxt('untitled');
			$url = permlinkurl_id($ID);
			$publisher = get_author_name($txp_user);

			$subject = upm_pending_notify_gTxt('email_subject_author', array(
				'{sitename}' => $prefs['sitename'],
				'{title}'		 => $Title,
			));

			$body = upm_pending_notify_gTxt('email_message_author', array(
				'{article_url}' => $url,
				'{author}'			=> $author['RealName'],
				'{publisher}'		=> $publisher,
				'{title}'				=> $Title,
			));

			upm_pending_notify_mail($author['RealName'], $author['email'], $subject, $body);
		}
	}

//--------------------------------------------------------------

	function upm_pending_notify_mail($name, $email, $subject, $body)
	{
		global $prefs;

		if ($prefs['override_emailcharset'])
		{
			$charset = 'ISO-8859-1';

			if (is_callable('utf8_decode'))
			{
				$name		 = utf8_decode($name);
				$email	 = utf8_decode($email);

				$subject = utf8_decode($subject);
				$body		 = utf8_decode($body);
			}
		}

		else
		{
			$charset = 'UTF-8';
		}

		$name = encode_mailheader(strip_rn($name), 'phrase');
		$email = strip_rn($email);

		$subject = encode_mailheader(strip_rn($subject), 'text');

		$sep = !is_windows() ? "\n" : "\r\n";

		$body = str_replace("\r\n", "\n", $body);
		$body = str_replace("\r", "\n", $body);
		$body = str_replace("\n", $sep, $body);

		return mail("$name <$email>", $subject, $body,
			"From: $name <$email>".
			$sep.'X-Mailer: upm_pending_notify Textpattern plugin'.
			$sep.'Content-Transfer-Encoding: 8bit'.
			$sep.'Content-Type: text/plain; charset="'.$charset.'"'.
			$sep
		);
	}

//--------------------------------------------------------------

	function upm_pending_notify_gTxt($what, $vars = array())
	{
		$lang = array();

		$lang['email_subject_author']		 = '[{sitename}] Article published: {title}';
		$lang['email_message_author']		 = <<<eml
Dear {author},

{publisher} has published your article:

{title}
{article_url}
eml;

		$lang['email_subject_publisher'] = '[{sitename}] Article submitted: {title}';
		$lang['email_message_publisher'] = <<<eml
Dear {publisher},

{author} has submitted an article for review:

{title}
{article_url}
eml;

		return strtr($lang[$what], $vars);
	}

Offline

#30 2014-02-12 12:38:48

whocarez
Plugin Author
From: Germany/Ukraine
Registered: 2007-10-08
Posts: 305
Website GitHub Twitter

Re: [plugin] [ORPHAN] upm_pending_notify: Pending article notification

no one?

function upm_pending_notify_publisher($ID, $Title) works, but function upm_pending_notify_author($ID, $Title, $AuthorID, $LastModID) not, where I have to make changes?

Thanks!

Offline

Board footer

Powered by FluxBB