Quickmail - Groups / undefined function: array_chunk

Quickmail - Groups / undefined function: array_chunk

by Brian Schmidt -
Number of replies: 8
Hello,

When I try to use the groups mode for Quickmail, I get the following error:
Fatal error: Call to undefined function: array_chunk() in /home/httpdocs/mycourses/blocks/quickmail/email.html on line 221

Any ideas where to go from here?  Is this function supposed to be in one of the other files in the directory?  I'm only seeing it being called in email.html.

I have verified that I do have members of each group as well.

TIA,
Brian
Average of ratings: -
In reply to Brian Schmidt

Re: Quickmail - Groups / undefined function: array_chunk

by Mark Nielsen -
Looks like array_chunk() is supported by php 4.2 or greater.  Is your php version less than 4.2?

Cheers,
Mark
In reply to Mark Nielsen

Re: Quickmail - Groups / undefined function: array_chunk

by Brian Schmidt -
Hi Mark,

Yes, we're running php-4.1.2-2.3 on our server.  Any tips for getting around this?  Or are group modes for Quickmail not going to be possible for us?

Thanks,
Brian
In reply to Brian Schmidt

Re: Quickmail - Groups / undefined function: array_chunk

by Mark Nielsen -
Hi Brian,

Well, you could upgrade you php if you have the means to do that smile. Or you can use this little hack I just coded up for the latest version of Quickmail in CVS/contrib:

In /blocks/quickmail/email.php, find the first use of array_chunk which is:
        $table->data = array_chunk($cells, $cols);
Replace it with this:
        $index = 0;
$chunked = array();
foreach ($cells as $key => $cell) {
$chunked[$index][] = $cell;
if ($key != 0 and ($key+1)%$cols == 0) {
$index++;
}
}
$table->data = $chunked;
Find the second use of array_chunk which is:
                $rows = array_chunk($cells, $cols);
Replace it with this:
                $index = 0;
$chunked = array();
foreach ($cells as $key => $cell) {
$chunked[$index][] = $cell;
if ($key != 0 and ($key+1)%$cols == 0) {
$index++;
}
}
$rows = $chunked;

Hope it works well for you,
Mark
Average of ratings: Useful (1)
In reply to Mark Nielsen

Re: Quickmail - Groups / undefined function: array_chunk

by Brian Schmidt -
Hi Mark,

Thanks for all of your work!  Upgrading PHP on our server may not be much of an option for me at the moment.  smile

I think I must have an old-ish copy (email.html,v 1.9 2006/02/22 19:50:34 michaelpenne).  My email.php has no references to it in there, but my email.html does.  But it only has 1 reference.  I think I'll need to update to the latest in CVS before I can give this a whirl...

Thanks,
Brian
In reply to Brian Schmidt

Re: Quickmail - Groups / undefined function: array_chunk

by Mark Nielsen -
Yup, that is an older version.  The latest version pulls all that mumbo-jumbo up into email.php.

Cheers,
Mark
In reply to Mark Nielsen

Re: Quickmail - Groups / undefined function: array_chunk

by Brian Schmidt -
This works absolutely perfect, Mark - Thanks!!

Brian
In reply to Mark Nielsen

Re: Quickmail - Groups / undefined function: array_chunk

by Ellen Marie Murphy -
Mark,

We have 5.2.0-8+etch11 on our server, but are getting this error message:

Call to undefined function groups_get_groups() in /var/www/moodle/blocks/quickmail/email.php on line 231

We are running 1.9. Any ideas?

Ellen