1
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
$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:
//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.