[4734] Editing date on calendar item splits it from post

Started by Farjo, November 23, 2009, 02:21:47 AM

Previous topic - Next topic

Farjo

If someone posts an event to a forum where they do not have editing rights, then change the date on the calendar item, the post gets split from the item which no longer shows at the beginning of the post.

The best fix for this would be a new feature to allow admin to choose which boards calendar items can be posted into :)

H

-H
Former Support Team Lead
                              I recommend:
Namecheap (domains)
Fastmail (e-mail)
Linode (VPS)
                             

Farjo

Hi, just wondering what happened with this? It is still happening in RC5 and I cannot find it on the bug tracker (by searching 'calendar'). Was it not able to be reproduced or something else?

emanuele

Here it is a possible fix (the other one I can imagine requires more changes).
Most likely there is a better solution.

In Calendar.php:
Code (find) Select
// ... or just update it?
else
{
$eventOptions = array(
'title' => substr($_REQUEST['evtitle'], 0, 60),
'span' => empty($modSettings['cal_allowspan']) || empty($_POST['span']) || $_POST['span'] == 1 || empty($modSettings['cal_maxspan']) || $_POST['span'] > $modSettings['cal_maxspan'] ? 0 : min((int) $modSettings['cal_maxspan'], (int) $_POST['span'] - 1),
'start_date' => strftime('%Y-%m-%d', mktime(0, 0, 0, (int) $_REQUEST['month'], (int) $_REQUEST['day'], (int) $_REQUEST['year'])),
);

modifyEvent($_REQUEST['eventid'], $eventOptions);
}


Code (replace with) Select
// ... or just update it?
else
{
// There could be already a topic you are not allowed to modify
if(!allowedTo('post_new')){
$request = $smcFunc['db_query']('', '
SELECT id_board, id_topic
FROM {db_prefix}calendar
WHERE id_event = {int:id_event}
LIMIT 1
',
array(
'id_event' => $_REQUEST['eventid'],
));
list($id_board, $id_topic) = $smcFunc['db_fetch_row']($request);
$smcFunc['db_free_result']($request);
}
$eventOptions = array(
'title' => substr($_REQUEST['evtitle'], 0, 60),
'span' => empty($modSettings['cal_allowspan']) || empty($_POST['span']) || $_POST['span'] == 1 || empty($modSettings['cal_maxspan']) || $_POST['span'] > $modSettings['cal_maxspan'] ? 0 : min((int) $modSettings['cal_maxspan'], (int) $_POST['span'] - 1),
'start_date' => strftime('%Y-%m-%d', mktime(0, 0, 0, (int) $_REQUEST['month'], (int) $_REQUEST['day'], (int) $_REQUEST['year'])),
'board' => isset($id_board) ? (int) $id_board : 0,
'topic' => isset($id_topic) ? (int) $id_topic : 0,
);

modifyEvent($_REQUEST['eventid'], $eventOptions);
}


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

Farjo

Thank you emanuele. Yes that fixes it :)

I have a few other things on my plate now however when I have time I will give this a better test.

emanuele

Don't tell anyone, but I don't like this solution! :P
It's just the one with less edits I could imagine.


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

emanuele

BTW, I was checking this again and in the post event page only boards where the member is allowed to post are listed.

The problem, in fact arise if the permissions are changed before editing the event.
So the sequence is:
* post an event,
* change the board permissions for the user removing post new topic
* edit the event
that's the only case I was able to find where the event is split from the topic.


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

Farjo

Hi Emanuele, the problem arises if the event is posted to a board where they have the right to post but not to edit i.e. where 'Modify their own post' is off in Admin -> Members -> Permissions -> Edit Profiles :)

emanuele



Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.


Joshua Dickerson

Come work with me at Promenade Group



Need help? See the wiki. Want to help SMF? See the wiki!

Did you know you can help develop SMF? See us on Github.

How have you bettered the world today?

emanuele

It should, but honestly I'm not sure about side effects... ;)


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

Advertisement: