1
Mamba
Tip for Permissions Tab errors with $permform->render()
  • 2011/3/18 14:50

  • Mamba

  • Moderator

  • Posts: 11542

  • Since: 2004/4/23


In some modules we have a "Permissions" Tab to set Access/View/Other permissions for individual groups to, for example, Topics/Categories (like in xFAQ module).

But when we have Categories that we want to set the permissions for, and they are empty, then XOOPS generates on

le="color: #000000"><?php $permform->render();


errors similar to this:

Quote:
Warning: array_keys() expects parameter 1 to be array, null given in file /class/xoopsform/grouppermform.php line 129
Warning: Invalid argument supplied for foreach() in file /class/xoopsform/grouppermform.php line 129

I found a solution in another module, that resulted in this code in xFAQ:

le="color: #000000"><?php //check if topics exist before rendering the form and redirect, if there are no topics $result_view = $xoopsDB->query("SELECT topic_id, topic_title FROM " . $xoopsDB->prefix("xfaq_topic") . " "); if ($xoopsDB->getRowsNum($result_view)) { echo $permform->render(); } else { redirect_header("topic.php", 2, _AM_XFAQ_NOPERMSSET, false); }

I hope, it will help somebody.

As always, the goal is to have zero warnings/notices in our code

If somebody else has Tips or Best Practices that could be used in the "module refreshment" that we're doing, please share them with us.
Support XOOPS => DONATE
Use 2.7.x | Docs | Modules | Bugs

2
Tarik
Re: Tip for Permissions Tab errors with $permform->render()
  • 2011/3/18 15:08

  • Tarik

  • Not too shy to talk

  • Posts: 170

  • Since: 2010/2/3 1


or by using the object class

le="color: #000000"><?php //check if topics exist before rendering the form and redirect, if there are no topics if ($topicHandler->getCount()) { echo $permform->render(); } else { redirect_header("topic.php", 2, _AM_XFAQ_NOPERMSSET, false); }
Some people like what you do,
-- some people hate what you do,
---- but most people simply don’t give a damn.

3
Mamba
Re: Tip for Permissions Tab errors with $permform->render()
  • 2011/3/18 16:16

  • Mamba

  • Moderator

  • Posts: 11542

  • Since: 2004/4/23


Fantastic! Much better!

Thank you so much!

If you see anything in the code in those old modules that could be improved/simplified, please share with us, and help us making it better.

That's what the Blue Move was all about
Support XOOPS => DONATE
Use 2.7.x | Docs | Modules | Bugs