/**
* Converts a module's category information to the new database.
*
* @author Eloi George <eloi@NOSPAM.bygeorgeware.com>
* @utility Convert
* @param string $module  : Module that's being converted.
* @param string $item_id : Id of the current module item.
* @param string $key_id  : Key_id assigned to the current module item.
* @return success or failure
*/
function convertCategories($module, $item_id, $key_id)
{
    $cat_db = Convert::getSourceDB('mod_fatcat_elements');
    $cat_db->addWhere('module_title', $module);
    $cat_db->addWhere('module_id', $item_id);
    $category_list = $cat_db->select();
    $cat_db->disconnect();
    Convert::siteDB();
    if (empty($category_list)) {
    	return false;
    }
    $item_db = & new PHPWS_DB('category_items');
    foreach ($category_list as $item) {
        // ignores 0 id category
        if (!$item['cat_id']) {
            continue;
        }
        $item_db->addValue('key_id', $key_id);
        $item_db->addValue('cat_id', $item['cat_id']);
        $item_db->addValue('module', $module);
        $result = $item_db->insert();
        if (PEAR::isError($result)) {
        	exit(PHPWS_Error::printError($result));
        }
        $item_db->reset();
    }
    return true;
}
