Forums | Mahara Community

Developers /
My Forum posts plugin


Gregor Anželj's profile picture
Posts: 349

19 December 2011, 11:49

i think log_debug function will solve most of your problms. Usage, e.g.:

$arr = array('on','two','three');
log_debug($arr);

But mostly you'll need to refresh the page (F5). I don't know why print_r wouldn't work...

c) Setting the default value - I think it should look something like this (not sure about arrays, but I think it should work for them also...):

'groupids' => array(
'type' => 'select',
...
'defaultvalue' => $group_array_ids,
)
,

Where $group_array_ids should be array, containig all the IDs...

HTH,
Gregor

anonymous profile picture
Account deleted
Posts: 214

20 December 2011, 2:52

You'll probably find you're unable to use var_dump() and print_r() in various places and will have to use:

  • log_debug()
  • log_info()
  • log_message()
  • log_warn()
  • log_environ()

There is some documentation for these is in htdocs/lib/errors.php.

I suspect that the reason that print_r() won't work in a pieform is because of the way that pieforms redirect. From what I recall, when you submit a pieform it performs the validation phase, then the submit phase, and then redirects. If you print_r before the redirect it should complain about headers being sent already, but may not depending on your debug levels.

The log_foo functions use the session message stack to temporarily store the messages during the redirect. In my opinion, log_foo are better than print_r because they'll also tell you if a variable is null or empty (much as var_dump does but in a friendlier fashion). log_environ is also useful as it'll give you a stack trace.

When developing Mahara, I'd recommend that you have the following settings in your config.php (copied from lib/config-dist.php):

// Developer settings
$cfg->developermode = DEVMODE_DEBUGJS | DEVMODE_DEBUGCSS | DEVMODE_UNPACKEDJS;
$cfg->log_dbg_targets = LOG_TARGET_SCREEN | LOG_TARGET_ERRORLOG;
$cfg->log_info_targets = LOG_TARGET_SCREEN | LOG_TARGET_ERRORLOG;
$cfg->log_warn_targets = LOG_TARGET_SCREEN | LOG_TARGET_ERRORLOG;
$cfg->log_environ_targets = LOG_TARGET_SCREEN | LOG_TARGET_ERRORLOG;
$cfg->sendallemailto = '[email protected]';
$cfg->emaillog = '/var/log/apache2/maharamail.log';
$cfg->perftofoot = true;
$cfg->perftolog = true;

Hope that this helps,

Andrew

Wullie's profile picture
Posts: 252

20 December 2011, 7:41

Thanks Gregor/Andrew,

I got there from both of your posts (the config.php was good to know and after you mentioned it, it was something I remembered seeing at some point, but couldn't find it again.

So, now that (I think) I have a working plugin, what do I do now (I've no knowledge of where/how to manage uploads/plugins, so any help would be appreciated - I've seen github mentioned, but no idea what to do with it - or is there preferred ones) and would anyone like to do some more testing for me?

Thanks

13 results