Need to allow editing event status only for owner

  • Szilard Gajer
  • Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 11 months ago #82325 by Szilard Gajer
Hi,

First of all, Events Booking is a very useful component :)
But I have a problem:
I made a group to handle event booking events for specially registered users, who can add and edit events. This gorup members can change the status of the events (published/unpublished) as well, but my problem is that all of these users can edit the status of all of events.
How can I make that only events owner can modify this status?
Edit Own option is allowed but it does not allow to change status of events.

HELP! :)

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

More
7 years 11 months ago #82331 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Need to allow editing event status only for owner
So basically, you only want that only user who create the event can change status (publish / unpublish) that event? Other users won't be allowed to do that?

Please let me know so that I can assist you further

Regards,

Tuan

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

  • Szilard Gajer
  • Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 11 months ago #82332 by Szilard Gajer
Replied by Szilard Gajer on topic Need to allow editing event status only for owner
Exactly that's what I want! :)

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

More
7 years 11 months ago #82351 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Need to allow editing event status only for owner
Hi

This will require small modifications to the code. Please follow the instructions below to get it work:

1. Open the file components/com_eventbooking/helper/helper.php

2. Find the method canChangeEventStatus

3. Change the code of that whole method to:
Code:
public static function canChangeEventStatus($eventId) { $user = JFactory::getUser(); $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('created_by') ->from('#__eb_events') ->where('id = ' . (int) $eventId); $db->setQuery($query); $createdBy = (int) $db->loadResult(); return $createdBy > 0 && $createdBy == $user->id; }

After that, it should work as expected

Regards,

Tuan
The following user(s) said Thank You: Szilard Gajer

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

  • Szilard Gajer
  • Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 11 months ago #82365 by Szilard Gajer
Replied by Szilard Gajer on topic Need to allow editing event status only for owner
Hi Tuan,

Works as I imagined!
Thanks a lot, you're great!

Regards,

Szilárd

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

More
7 years 11 months ago #82375 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Need to allow editing event status only for owner
Great. Thanks for confirming

Regards,

Tuan

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

Moderators: Tuan Pham Ngoc