Skip to content

Instantly share code, notes, and snippets.

@manifestuk
Created June 22, 2010 18:02
Show Gist options
  • Save manifestuk/448832 to your computer and use it in GitHub Desktop.
Save manifestuk/448832 to your computer and use it in GitHub Desktop.
/**
* Get Group Layout
*
* Gets layout information for member groups for the publish page
*
* @access public
* @param int Member group
* @param int Field group
* @return array
*/
function get_group_layout($member_group = '', $channel_id = '')
{
$this->db->select('field_layout');
$this->db->where("site_id", $this->config->item('site_id'));
$this->db->where("channel_id", $channel_id);
$this->db->where("member_group", $member_group);
$layout_data = $this->db->get('layout_publish');
if ($layout_data->num_rows() > 0)
{
$returned_data = unserialize($layout_data->row('field_layout'));
}
else
{
$returned_data = array();
}
/**
* Somewhere within this sprawling codebase there's a bug that saves fields
* with an empty 'ID' key. This in turns causes PHP errors in the view.
*
* Rather than dick about adding yet more logic to the view or controller,
* this cleans the data retrieved from the database, before passing it on.
* This may be the very definition of pissing in the wind.
*
* @author Stephen Lewis <ee2-bugfixes@experienceinternet.co.uk>
* @see http://expressionengine.com/bug_tracker/bug/12859/
*/
$clean_data = array();
foreach ($returned_data AS $tab => $fields)
{
$clean_data[$tab] = array();
foreach ($fields AS $field_id => $options)
{
if ($field_id)
{
$clean_data[$tab][$field_id] = $options;
}
}
}
return $clean_data;
}
@leevigraham
Copy link

What's this all about then?

@manifestuk
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment