How to allow editing after 30 minutes?

How to allow editing after 30 minutes?

by lester macrae -
Number of replies: 8

Hi there - I'm really enjoying Moddle right now, but need a little assistance (esp. since I've been asked to give a workshop on Moodle in 2 months!! :D )

I have 2 questions:

1) I am wondering if there is a way to bypass the 30 minute time restriction for editing posts

2) Is there a way to allow admins to edit anyone's post at any time (ties into the 30-minute thing I guess)

Thanks smile

Average of ratings: -
In reply to lester macrae

Re: How to allow editing after 30 minutes?

by Przemyslaw Stencel -
1) read this discussion

2) In the config.php file, uncomment the line which says:
$CFG->admineditalways = true;
In reply to Przemyslaw Stencel

Re: How to allow editing after 30 minutes?

by lester macrae -

Thanks so much, Przemyslaw!

I am wondering something about Darrell's hack found here: http://moodle.org/bugs/bug.php?op=show&bugid=849&pos=2

[Quote]

 _______
in moodle.mod/forum/lib.php - ensure that a maxeditingtime of 0 does not cause our cron method to fail or never execute.

function forum_cron () {
[...]                                 <-- what does this mean?
// edited by Daryl Hawes. <-- where does this start?
if($CFG->maxeditingtime == 0){
$cutofftime = time() - 1800; //if maxeditingtime is unlimited (0) then use 30 minutes;
}else{
$cutofftime = time() - $CFG->maxeditingtime;
}
_____

[End Quote]

Where do I put Darrell's hack in the function forum_cron? (ie. what does [...] mean?)

Thanks again! smile

In reply to lester macrae

Re: How to allow editing after 30 minutes?

by Daryl Hawes -
[...]                                 <-- what does this mean?
  *It means that stuff comes before it :)
// edited by Daryl Hawes. <-- where does this start?
  *See below:


function forum_cron () {
/// Function to be run periodically according to the moodle cron
/// Finds all posts that have yet to be mailed out, and mails them
/// out to all subscribers

    global $CFG, $USER;

    if (!empty($USER)) { // Remember real USER account if necessary
        $realuser = $USER;
    }
                             
    // edited by Daryl Hawes.
    if($CFG->maxeditingtime == 0){
        $cutofftime = time() - 1800; //if maxeditingtime is unlimited (0) then use 30 minutes;
    }else{
        $cutofftime = time() - $CFG->maxeditingtime;
    }
                       
    if ($posts = forum_get_unmailed_posts($cutofftime)) {
[...] (meaning the rest of the function follows normally)


(P.S. - I bet you know someone named Darrell. Localized into any language the spelling of my name is still Daryl though :)  Good luck and let me know if this works for you as it does for me.)
In reply to Daryl Hawes

Re: How to allow editing after 30 minutes?

by lester macrae -
Hi Daryl! .. sorry about that - I do know some Darrell's .. smile

This is my lib.php file:

[Quote]

function forum_cron () {
/// Function to be run periodically according to the moodle cron
/// Finds all posts that have yet to be mailed out, and mails them
/// out to all subscribers

    global $CFG, $USER, $THEME;
    static $strforums = NULL;

    if ($strforums === NULL) {
        $strforums = get_string('forums', 'forum');
    }

    if (!empty($USER->id)) { // Remember real USER account if necessary
        $realuser = $USER;
    }

    /// Posts older than 2 days will not be mailed.  This is to avoid the problem where
    /// cron has not been running for a long time, and then suddenly people are flooded
    /// with mail from the past few weeks or months

    $timenow   = time();
    $endtime   = $timenow - $CFG->maxeditingtime;
    $starttime = $endtime - 48 * 3600;   /// Two days earlier

    if ($posts = forum_get_unmailed_posts($starttime, $endtime)) {

[/Quote]

Do I replace the stuff in bold with your edits, or add them (above or below)?

Thanks again for helping such a n00b! :D
In reply to lester macrae

Re: How to allow editing after 30 minutes?

by lester macrae -
Sorry - still confused ..
In reply to lester macrae

Re: How to allow editing after 30 minutes?

by Daryl Hawes -
Did you try anything at all?
The version my suggestion is working from is still 1.2ish so this function has changed since then.
Try putting my changes ust before this line:
    /// Posts older than 2 days will not be mailed.  This is to avoid the problem where
In reply to Daryl Hawes

Re: How to allow editing after 30 minutes?

by lester macrae -
Hi again Daryl!

for the second part of the hack - here is my function forum_print_post section right after the if ($ownpost) { section:

QUOTE:

$age = time() - $post->created;
if ($ownpost) {
$output .= "".get_string("delete", "forum")."";
if ($reply) {
$output .= "".get_string("replyforum", "forum")."";
}
$output .= "  ";
} else {
if ($reply) {
$output .= "".get_string("replyforum", "forum")."  ";

}
}

END QUOTE

I've tried to slip in:

QUOTE

//edit by Daryl Hawes to allow editing if maxeditingtime is 0
if ( ($age < $CFG->maxeditingtime) || ($CFG->maxeditingtime == 0)) {
echo "".get_string("edit", "forum")." | ";
}
}

END QUOTE

in several places, but keep getting parse errors. Where would you suggest insert your edit - I should I replace some text?

Thanks again smile
In reply to lester macrae

Re: How to allow editing after 30 minutes?

by Daryl Hawes -
Hi Lester,
I've updated the bug report with instruction for moodle 1.4.5 (what version of moodle are you running now?)

http://moodle.org/bugs/bug.php?op=show&bugid=849

You could just email me your mod/forum/lib.php file and your lang file if you'd like me to try to edit them directly for you. My email is listed in my profile.