Keyword

Checking if a user can alter state of article in category?

  • Darren Forster
  • Darren Forster's Avatar Topic Author
  • Offline
  • New Member
More
6 years 6 months ago #164483 by Darren Forster
Hi,

I'm just writing a bit of a template for K2. My plan is that I'm going to override the "category" layout, it's going to be a business directory for a community hub and the plan is that at first I'm going to ask the user for a postcode. Once I've got the postcode I then check through the database for any results that match. If results match the user is given the option to "claim" the listing as their own (which sends an e-mail to us so we can verify that the person trying to claim the business is genuinely the owner).

If the person does not have a business they can then proceed to an "Add business" form which allows them to add their business to our directory. Now I've got pretty much most of this working except the "Add business" section as at that stage I need to know whether or not the user has permission to publish to the "business directory" (and child categories) in K2 - if they do then they are shown a publish "Yes/No" button on the page and if they do not have permission then a hidden field is created called "publish" which is automatically set to 0.

Now of course I could just use the "itemform.php" to do this - but I have a big problem with "itemform.php" in the fact that when the user clicks on the itemform it opens up in either a separate window or a modal window and I don't want this as I want this to be like a progressive form on the site.

At present most of it works except I need to check whether or not the user can publish to the specific category.

I've used the following code
$publish = $this->user->authorise('core.edit.state', 'com_k2');
if ( $publish == 1 ) :	?>
	<div class="form-group row">
		<label class="form-label col-sm-2" for="published">
			Published:
		</label>
		<div class="col-sm-10">
			<label class="radio-inline"><input type="radio" name="published" value="1"/>Yes</label>
			<label class="radio-inline"><input type="radio" name="published" value="0" checked="checked"/>No</label>
		</div>
<?php else : ?>
	<div class="form-group row">
		<label class="form-label col-sm-2" for="published">
			Published:
		</label>
		<div class="col-sm-10">
			<input type="text" value="0" name="published" readonly />
		</div>
	</div>
<?php endif ; ?>

but this seems to only return if the user in Joomla ACL is set to be able to publish anywhere in K2 not if they are set in K2 to change state on specific categories. Is there an easy way to check this, or do I have to query the database to find this information out?

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
6 years 6 months ago #164494 by Krikor Boghossian
Replied by Krikor Boghossian on topic Checking if a user can alter state of article in category?
Hello there, you will have to query the database for this feature to work.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum