Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2018-01-30 09:35:17

jpdupont
Member
From: Virton (BE)
Registered: 2004-10-01
Posts: 752
Website

Reserve the edition of a section to a user

Is it possible, natively or through a plugin to only allow editing of articles of a particular section to a specific user?

If it is not possible now, can we consider this later?

Offline

#2 2018-01-30 12:21:48

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 9,786
Website

Re: Reserve the edition of a section to a user

It’s possible with a plugin. The lengths to which you enforce it are down to you.

For instance, you could just alter the List panel to only show articles that a particular user has authored and/or use the Write panel callbacks for the ‘section’ dropdown to restrict the list of sections to a preset list based on user name or group.

Lots of ways to do it. Few lines of code in a plugin.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#3 2018-01-30 12:33:44

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,232

Re: Reserve the edition of a section to a user

While Stef answered I searched my plugin surprise bag and found see_restrict


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#4 2018-01-30 12:44:59

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,232

Re: Reserve the edition of a section to a user

The link in the old topic that Stef’s 2012 post started with, led to code.google.com (now redirects to the wrong location on Github Stef edited that post now) and – if I’m not mistaken (no further notes in my tip-file) – should have contained the following code:

// Hook the plugin into the admin side in the right place
register_callback('mrd_for_your_eyes_only', 'admin_criteria');

function mrd_for_your_eyes_only($evt, $stp, $crit) {
	// Grab the logged-in user name and make sure it's 'safe' (no weird characters that would break MySQL)
	global $txp_user;
	$user = doSlash($txp_user);

	// Fetch the logged-in user's privilege level
	$privs = safe_field('privs', 'txp_users', "name='$user'");

	// Publishers get to see everything: drop out of the plugin without doing anything
	if ($privs === '1') {
		return;
	}

	// Anyone other than Publisher ends up here
	if ($stp === 'list_list') {
		// We are on the 'articles' page so alter the criteria to only include those articles
		// with AuthorID that matches the logged-in user 
		return " AND AuthorID = '$user'";
	} else if (in_array($stp, array('link_list', 'file_list', 'image_list'))) {
		// We are on the Links, Files or Images panel so only include those items where
		// the author matches the logged-in user
		return " AND author = '$user'";
	}
}

In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#5 2018-01-30 12:51:51

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 9,786
Website

Re: Reserve the edition of a section to a user

uli wrote #308964:

The link in the old topic that Stef’s 2012 post started with, led to code.google.com

Yes, it was a link to the specific commit that I made which added the feature. The redirect doesn’t follow to the exact commit so it defaults to Github’s main project page unfortunately. The code in the forum post was just an example of how to use it. The one you posted was an alternative version with more functionality, thanks! Perhaps we should add that example to the post as well. I updated the google code link to point to the relevant commits in GitHub.

Good find about see_restrict too. Didn’t know about that one.

Last edited by Bloke (2018-01-30 12:56:51)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#6 2018-01-31 10:11:27

jpdupont
Member
From: Virton (BE)
Registered: 2004-10-01
Posts: 752
Website

Re: Reserve the edition of a section to a user

Thank you very much Uli and Stef, I will test in the coming days!

Offline

#7 2018-01-31 12:09:51

etc
Developer
Registered: 2010-11-11
Posts: 3,940
Website

Re: Reserve the edition of a section to a user

Note that both plugins act only on the interface atm. It’s still possible to circumvent the restriction via a suitable POST request.

I had a project too where users were constrained to publish only one article per custom user group in a given section within a fixed time period. It would be great if we could imagine a way to manage this kind of flexible restrictions in core.

Offline

#8 2018-01-31 12:21:38

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 9,786
Website

Re: Reserve the edition of a section to a user

etc wrote #309006:

I had a project too where users were constrained to publish only one article per custom user group in a given section within a fixed time period. It would be great if we could imagine a way to manage this kind of flexible restrictions in core.

+1. Thinking caps on when we do unlimited custom fields, as we could potentially introduce custom workflows somehow… or at least make it easy for plugins to do so. This might tie in with the status-mods branch.

Last edited by Bloke (2018-01-31 12:22:28)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#9 2018-01-31 21:29:03

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,265
Website

Re: Reserve the edition of a section to a user

I had a requirement a little while ago to provide a basic blog facility for kids at school. Using a combination of user permissions, bot_privs and an adi plugin I stripped everything out to give only a bare minimum.

The logic being – to not confuse the little sausages, and also to prevent them being nosey (or breaking things).

What they got (from memory):
  • two tabs – Write and List
  • on the Write tab – title, body and Save/Publish button
  • on the List tab – article list only, no multi select

No tag builder, no categories, no status. Restricted to one section. I even went as far as taking the Textpattern CMS link out of the footer.

All a bit extreme, but in the real world it’d still be nice to provide a minimal interface – i.e. hiding features/fields etc that are not required for a particular website/client/user.

Offline

Board footer

Powered by FluxBB