Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: badman2nd on June 13, 2008, 09:55:53 AM

Title: unlimited edit time for single board only
Post by: badman2nd on June 13, 2008, 09:55:53 AM
I am hoping that it is possible to remove the editing time limit from a single board only while keeping all the rest at the forum standard. I run a tropical fish website and would like to create a board where the members can input their setups for other members to see. As these are always changing I would like the member to be able to change their post as they add or remove livestock. I do not want unlimited editing on any other section of the forum. Is this possible.

Thanks for your help and input.


Pat
Title: Re: unlimited edit time for single board only
Post by: badman2nd on June 16, 2008, 07:40:02 AM
Did, I word this wrong or is it something that cannot be done? I did a search but came up empty.

Thanks.
Title: Re: unlimited edit time for single board only
Post by: [SiNaN] on June 20, 2008, 03:37:54 AM
Let's try this:

Post.php

We have 3.

Find:

if (!empty($modSettings['edit_disable_time']) && $row['posterTime'] + ($modSettings['edit_disable_time'] + 5) * 60 < time())
Replace:

if (!empty($modSettings['edit_disable_time']) && $row['posterTime'] + ($modSettings['edit_disable_time'] + 5) * 60 < time() && $board != BOARD_ID)

Change the BOARD_ID as the board id.

Display.php

Find:

'can_modify' => (!$context['is_locked'] || allowedTo('moderate_board')) && (allowedTo('modify_any') || (allowedTo('modify_replies') && $context['user']['started']) || (allowedTo('modify_own') && $message['ID_MEMBER'] == $ID_MEMBER && (empty($modSettings['edit_disable_time']) || $message['posterTime'] + $modSettings['edit_disable_time'] * 60 > time()))),

Replace:

'can_modify' => (!$context['is_locked'] || allowedTo('moderate_board')) && (allowedTo('modify_any') || (allowedTo('modify_replies') && $context['user']['started']) || (allowedTo('modify_own') && $message['ID_MEMBER'] == $ID_MEMBER && (empty($modSettings['edit_disable_time']) || $message['posterTime'] + $modSettings['edit_disable_time'] * 60 > time())) && $board != BOARD_ID),

Change the BOARD_ID as the board id.
Title: Re: unlimited edit time for single board only
Post by: badman2nd on June 20, 2008, 02:42:02 PM
Great, I will give it a try and let you know. Thanks for the effort!

Pat
Title: Re: unlimited edit time for single board only
Post by: badman2nd on June 21, 2008, 07:30:55 AM
SiNan, I tried what you suggested and it did not work. the edit icon went away after the regular time period and I am getting this error in the log

Undefined variable: board
File: /home/badman/public_html/forum/Sources/Display.php

Heres how the code lookes after I did what you suggested in all areas
post.php
if (!empty($modSettings['edit_disable_time']) && $row['posterTime'] + ($modSettings['edit_disable_time'] + 5) * 60 < time() && $board != 92.0)

display.php
'can_modify' => (!$context['is_locked'] || allowedTo('moderate_board')) && (allowedTo('modify_any') || (allowedTo('modify_replies') && $context['user']['started']) || (allowedTo('modify_own') && $message['ID_MEMBER'] == $ID_MEMBER && (empty($modSettings['edit_disable_time']) || $message['posterTime'] + $modSettings['edit_disable_time'] * 60 > time())) && $board != 92.0),

Any thoughts or should I just abandon this?

Thanks

Pat
Title: Re: unlimited edit time for single board only
Post by: [SiNaN] on June 21, 2008, 08:09:40 AM
It seems that we don't have the board in globals. After doing the edit above, do:

Display.php

Find:

global $memberContext, $context, $messages_request, $topic, $ID_MEMBER, $attachments;

Replace:

global $memberContext, $context, $messages_request, $topic, $ID_MEMBER, $attachments, $board;

For the board ID, just enter 92 if your board is 92.0.
Title: Re: unlimited edit time for single board only
Post by: badman2nd on June 21, 2008, 09:12:00 AM
SiNaN, it still does not work, the edit option goes away after the ten minutes and I still get this error

8: Undefined variable: board
File: /home/badman/public_html/forum/Sources/Display.php

here is the display php now

global $memberContext, $context, $messages_request, $topic, $ID_MEMBER, $attachments, $board92;

and

   global $memberContext, $context, $messages_request, $topic, $ID_MEMBER, $attachments, $board92;

and the post.php, all three areas

if (!empty($modSettings['edit_disable_time']) && $row['posterTime'] + ($modSettings['edit_disable_time'] + 5) * 60 < time() && $board != 92)
Title: Re: unlimited edit time for single board only
Post by: [SiNaN] on June 21, 2008, 09:27:11 AM
The one in Display.php should be just $board, not $board92.
Title: Re: unlimited edit time for single board only
Post by: badman2nd on June 21, 2008, 09:36:35 AM
Ok, I will try again, And I want to thank you for taking your time with this.

Pat
Title: Re: unlimited edit time for single board only
Post by: badman2nd on June 21, 2008, 09:59:04 AM
Ok, the board error seems to be gone now, but now the edit (modify) icon does not show up at all this board is in local mode like you said.
Title: Re: unlimited edit time for single board only
Post by: [SiNaN] on June 21, 2008, 11:48:01 AM
After you do all the things above. Do this:

Display.php

Find:

      'can_modify' => (!$context['is_locked'] || allowedTo('moderate_board')) && (allowedTo('modify_any') || (allowedTo('modify_replies') && $context['user']['started']) || (allowedTo('modify_own') && $message['ID_MEMBER'] == $ID_MEMBER && (empty($modSettings['edit_disable_time']) || $message['posterTime'] + $modSettings['edit_disable_time'] * 60 > time())) && $board != 92),

Replace:

'can_modify' => (!$context['is_locked'] || allowedTo('moderate_board')) && (allowedTo('modify_any') || (allowedTo('modify_replies') && $context['user']['started']) || (allowedTo('modify_own') && $message['ID_MEMBER'] == $ID_MEMBER && (empty($modSettings['edit_disable_time']) || $board == 92 || $message['posterTime'] + $modSettings['edit_disable_time'] * 60 > time()))),

Just I missed a small point, sorry.
Title: Re: unlimited edit time for single board only
Post by: badman2nd on June 21, 2008, 12:54:39 PM
I'm testing it now, i'll let you know.

Pat
Title: Re: unlimited edit time for single board only
Post by: badman2nd on June 21, 2008, 01:18:54 PM
SiNaN, It seems to be working fine! Thank you!, I will test it a little more before marking it solved. It may be useful to other members.

Pat
Title: Re: unlimited edit time for single board only
Post by: badman2nd on June 22, 2008, 07:34:12 AM
One problem that now has come up is with the preview screen. When you hit preview the Fetching preview... just sits there and nothing happens. When I put the unmodified pages back it works fine.

Thanks SiNaN
Title: Re: unlimited edit time for single board only
Post by: [SiNaN] on June 22, 2008, 07:44:41 AM
Preview is also okay for me. Can you attach the edited files here? Maybe you've missed something.
Title: Re: unlimited edit time for single board only
Post by: badman2nd on June 22, 2008, 08:06:23 AM
I'm sure I did! here is the display

Title: Re: unlimited edit time for single board only
Post by: badman2nd on June 22, 2008, 08:07:11 AM
here is post
Title: Re: unlimited edit time for single board only
Post by: [SiNaN] on June 22, 2008, 08:48:24 AM
I've changed my files, with yours and still do not get any errors. Maybe I misunderstood. Can you provide a screenshot?
Title: Re: unlimited edit time for single board only
Post by: badman2nd on June 22, 2008, 09:05:20 AM
SiNaN, I am showing no errors in the error log, its just that the previwe never loads attached is a screen shot showing the "feetching preview" which it never gets past, I aso get I believe a javascript error showing in the IE browser and have attached what they say in a screen shot.
Title: Re: unlimited edit time for single board only
Post by: badman2nd on June 22, 2008, 09:10:59 AM
OK, some other info. When you reply with the quick reply it seems to be OK, if you use the modify or the regular reply link it will not go through the preview screen,  it just hangs.
Title: Re: unlimited edit time for single board only
Post by: badman2nd on June 23, 2008, 09:09:56 AM
SiNaN, did the shots help at all? I think I will just have to keep the board time limit.
Title: Re: unlimited edit time for single board only
Post by: [SiNaN] on June 23, 2008, 09:13:24 AM
I didn't look at it. Can you remind it to me tomorrow? I will check it tomorrow.
Title: Re: unlimited edit time for single board only
Post by: badman2nd on June 23, 2008, 09:35:35 AM
sure and thanks again!
Title: Re: unlimited edit time for single board only
Post by: [SiNaN] on June 24, 2008, 03:11:04 AM
I tested in both FF2 and IE7 but couldn't reproduce your error. Can you try it with the files attached? I set the board ID as 92.
Title: Re: unlimited edit time for single board only
Post by: badman2nd on June 24, 2008, 03:08:41 PM
Sinan, I see your post php was version 1.1.4 and mine is 1.1.5 and when compared using text pad there were a few differences. I also have a mod installed call "no spam by guest "which changes  this code

   $post_errors[] = 'bad_email';
         }
to this

$post_errors[] = 'bad_email';




                // by NoSpamByGuests mod
                     if (isset($_POST['message']))
                     {
                        $linkpos = strpos ($_POST['message'], "://"); // look for ://
                        if ($linkpos !== false) $post_errors[] = 'guest_no_link';
                        else {
                           $linkpos = strpos ($_POST['message'], "www."); // look for www.
                           if ($linkpos !== false) $post_errors[] = 'guest_no_link';
                        }
      }
         }

could this be the reason?

attached are the results of the differences
Title: Re: unlimited edit time for single board only
Post by: [SiNaN] on June 25, 2008, 06:43:48 AM
Sorry I'm still olldd, try this files then.

By the way, it can be because of that mod. Did you try editing a message without an url -http://-?
Title: Re: unlimited edit time for single board only
Post by: badman2nd on June 26, 2008, 07:39:46 AM
SiNaN, I downloaded your files and then copied you changes to my unedited files and everything seems to be working fine. I don't know if it was something I did or added when I was making your modifications but by using the code from  your files it works with my other modification intact! I am sorry for the delay I had a 24 hour bug and was not thinking straight for a day or so. I do want to thank you again for your help. I will test this for a day or so and hen mark it solved.


Pat
Title: Re: unlimited edit time for single board only
Post by: [SiNaN] on June 26, 2008, 12:32:24 PM
I think the problem is with the NoSpamByGuests. Because as I see, you have url in the message that you are trying to edit.
Title: Re: unlimited edit time for single board only
Post by: SpyDie on August 18, 2008, 05:10:29 PM
Reckon there is any way to make this work for a single membergroup, rather than a single board?
Title: Re: unlimited edit time for single board only
Post by: [SiNaN] on August 19, 2008, 12:36:00 PM
I'll try to write codes and post it into the Tips and Tricks board. Will inform you from this topic.
Title: Re: unlimited edit time for single board only
Post by: SpyDie on August 21, 2008, 11:51:55 AM
Thanks, appreciated.
Attempted myself to do it, didn't work.  :P
Title: Re: unlimited edit time for single board only
Post by: [SiNaN] on August 23, 2008, 12:24:43 PM
Both of them are added to the Tips and Tricks:

http://www.simplemachines.org/community/index.php?topic=257304.0

http://www.simplemachines.org/community/index.php?topic=257307.0
Title: Re: unlimited edit time for single board only
Post by: Simplemachines Cowboy on August 23, 2008, 10:17:29 PM
Thank you SiNan,
The unlimited edit time for a single board trick is just perfect for our "for sale" board.