public static function registerModule($module, &$content) { PHPWS_Core::initModClass('controlpanel', 'Tab.php'); PHPWS_Core::initModClass('controlpanel', 'Link.php'); $cpFile = sprintf('%smod/%s/boost/controlpanel.php', PHPWS_SOURCE_DIR, $module); if (!is_file($cpFile)) { PHPWS_Boost::addLog($module, dgettext('controlpanel', 'Control Panel file not implemented.')); return false; } include $cpFile; // insure cp file does not change translation directory if (isset($tabs) && is_array($tabs)) { foreach ($tabs as $info) { $tab = new PHPWS_Panel_Tab(); if (!isset($info['id'])) { $tab->setId(strtolower(preg_replace('/\\W/', '_', $info['title']))); } else { $tab->setId($info['id']); } if (!isset($info['title'])) { $content[] = dgettext('controlpanel', 'Unable to create tab.') . ' ' . dgettext('controlpanel', 'Missing title.'); continue; } $tab->setTitle($info['title']); if (!isset($info['link'])) { $content[] = dgettext('controlpanel', 'Unable to create tab.') . ' ' . dgettext('controlpanel', 'Missing link.'); continue; } $tab->setLink($info['link']); if (isset($info['itemname'])) { $tab->setItemname($info['itemname']); } else { $tab->setItemname('controlpanel'); } $result = $tab->save(); if (PHPWS_Error::isError($result)) { $content[] = dgettext('controlpanel', 'An error occurred when trying to save a controlpanel tab.'); PHPWS_Error::log($result); return false; } } $content[] = sprintf(dgettext('controlpanel', 'Control Panel tabs created for %s.'), $module); } else { PHPWS_Boost::addLog($module, dgettext('controlpanel', 'Control Panel tabs not implemented.')); } if (isset($link) && is_array($link)) { $db = new PHPWS_DB('controlpanel_tab'); foreach ($link as $info) { $modlink = new PHPWS_Panel_Link(); if (isset($info['label'])) { $modlink->setLabel($info['label']); } if (isset($info['restricted'])) { $modlink->setRestricted($info['restricted']); } elseif (isset($info['admin'])) { $modlink->setRestricted($info['admin']); } $modlink->setUrl($info['url']); $modlink->setActive(1); if (isset($info['itemname'])) { $modlink->setItemName($info['itemname']); } else { $modlink->setItemName($module); } $modlink->setDescription($info['description']); if (is_string($info['image'])) { $modlink->setImage($info['image']); } elseif (is_array($info['image'])) { $modlink->setImage($info['image']['name']); } $db->addWhere('id', $info['tab']); $db->addColumn('id'); $result = $db->select('one'); if (PHPWS_Error::isError($result)) { PHPWS_Error::log($result); continue; } elseif (!isset($result)) { $tab_id = 'unsorted'; PHPWS_Boost::addLog($module, dgettext('controlpanel', 'Unable to load a link into a specified tab.')); } else { $tab_id = $info['tab']; } $modlink->setTab($tab_id); $result = $modlink->save(); if (PHPWS_Error::isError($result)) { PHPWS_Error::log($result); $content[] = dgettext('controlpanel', 'There was a problem trying to save a Control Panel link.'); return false; } $db->resetWhere(); } $content[] = sprintf(dgettext('controlpanel', 'Control Panel links created for %s.'), $module); } else { PHPWS_Boost::addLog($module, dgettext('controlpanel', 'No Control Panel links found.')); } PHPWS_ControlPanel::reset(); return true; }