//G::LoadClass('configuration');
G::LoadSystem('inputfilter');
$filter = new InputFilter();
$G_MAIN_MENU = 'processmaker';
$G_SUB_MENU = 'processes';
$G_ID_MENU_SELECTED = 'PROCESSES';
$G_ID_SUB_MENU_SELECTED = 'FIELDS';
$dbc = new DBConnection();
$ses = new DBSession($dbc);
//Hardcode: UID of the library by default
$PRO_UID = isset($_POST['PRO_UID']) ? $_POST['PRO_UID'] : '746B734DC23311';
$process = new Process($dbc);
$process->Load($PRO_UID);
$dynaform = new dynaform($dbc);
$dynaform->Fields['DYN_UID'] = isset($_POST['DYN_UID']) ? urldecode($_POST['DYN_UID']) : '0';
$dynaform->Load($dynaform->Fields['DYN_UID']);
if (isset($_POST['DYN_UID']) && $_POST['DYN_UID'] !== '') {
    $file = $dynaform->Fields['DYN_FILENAME'];
} else {
    //Hardcode: Sample of xmlform.
    $file = $PRO_UID . '/' . 'myInfo';
}
/* Start Comment: If file doesn't exist, it is created */
if (!file_exists(PATH_DYNAFORM . $file . '.xml')) {
    $newDoc = new Xml_Document();
    $newDoc->addChildNode(new Xml_Node('dynaForm', 'open', '', array('type' => 'xmlform', 'name' => $file)));
    $newDoc->children[0]->addChildNode(new Xml_Node('', 'cdata', "\n"));
    G::verifyPath(dirname(PATH_DYNAFORM . $file . '.xml'), true);
    $newDoc->save(PATH_DYNAFORM . $file . '.xml');
    unset($newDoc);
}