Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2014-12-29 09:10:38

raminrahimi
Member
From: India
Registered: 2013-03-19
Posts: 278

user access level: allow one category to post

Hi TXP team,
Is it possible in textpattern: Allow a specific user to post articles and images in a specific category ?
It mean i need to have a user to allow just managing articles and images with specific category, no other permission allowed.

Last edited by raminrahimi (2014-12-29 09:43:01)

Offline

#2 2014-12-29 16:05:13

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

Re: user access level: allow one category to post

Hi Ramin,

this can only be done via CSS, as far as I know, which can of course be sidestepped by clever users.
You need the plugin bot_admin_body_class and then set up a selector similar to this one:

#page-article.restricted-user #categories_group select#category-1 option:not([value="meaningful-labor"])  {display:none;}

Note the class .restricted-user which later has to be replaced by the user name class.

See also caniuse.com/ for the applicability of the :not() selector.

Last edited by uli (2014-12-29 16:08:25)


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

Offline

#3 2014-12-29 16:23:27

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,171
Website GitHub Mastodon Twitter

Re: user access level: allow one category to post

It is worth warning that somebody with disabled js would be able to reach the whole content.


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#4 2014-12-29 16:57:14

raminrahimi
Member
From: India
Registered: 2013-03-19
Posts: 278

Re: user access level: allow one category to post

it mean CSS will hide the classes, if some one know firebug or any other tools easily they can enable that by CSS display, am I true ?

Offline

#5 2014-12-29 17:57:27

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

Re: user access level: allow one category to post

In FF, View > Website Style > No Style is sufficient, not even Firebug is necessary, yes.


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

Offline

#6 2014-12-29 18:01:54

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

Re: user access level: allow one category to post

uli wrote #286928:

this can only be done via CSS, as far as I know

Here I meant “with existing plugins”, no plugin I know of that’d remove categories from the cat dropdown on a by user base and server side.


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

Offline

#7 2014-12-30 20:58:23

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,915
Website GitHub

Re: user access level: allow one category to post

If you’re able and willing to experiment, you should be able to write a plugin that replaces the category drop-down and outputs just a single category if that user is logged in:

You could use rah_status_dropdown as a starting point. That provides a replacement UI for the status radio buttons using a dropdown menu, and uses the following plugin pluggable_ui hook: article_ui / status. Another of jukka’s plugins, rah_section_titles, uses the same principle to replace the section drop-down.

For the category drop-down you need article_ui / categories. You can see how the existing category drop-down is made in the source of /textpattern/include/txp_article.php

You’ll probably need to replicate it with a modified function that returns only the category you want if $txp_user matches a certain AuthorID or list of IDs, or alternatively, if you’re limiting access to a certain user privilege type to return your designated category if the privs of that user match a certain kind of user, e.g. here’s an example function to determine if the currently logged-in user is a staff writer:

function is_staffwriter()
	{
		global $txp_user;

		if (safe_field('privs', 'txp_users', "name = '".doSlash($txp_user)."'") == 4)
		{
			return true;
		}

		return false;
	}

and here’s how it’s used in principle (code from an older manually-modified version of txp from before the days of pluggable_ui) to replace the standard category drop-down.

if (is_staffwriter() and ( ($pull == false) or ($AuthorID == $txp_user) ))
		{
			… code for designated category …
		}
		else
		{
			… code for usual category drop-down …
		}

Sorry that these are only pieces of the puzzle but maybe some of that helps…


TXP Builders – finely-crafted code, design and txp

Offline

Board footer

Powered by FluxBB