function getFrameworksByForm($fid) { static $cachedResults = array(); if (isset($cachedResults[$fid])) { return $cachedResults[$fid]; } $ret = array(); $sql = 'SELECT DISTINCT(fl_frame_id) FROM ' . $this->db->prefix("formulize_framework_links") . ' WHERE fl_form1_id=' . intval($fid) . ' OR fl_form2_id=' . intval($fid); $result = $this->db->query($sql); while ($myrow = $this->db->fetchArray($result)) { $framework = new formulizeFramework($myrow['fl_frame_id']); $ret[$framework->getVar('frid')] =& $framework; unset($framework); } $cachedResults[$fid] = $ret; return $ret; }
function getFormsByFramework($framework_Object_or_Frid) { if (is_object($framework_Object_or_Frid)) { if (get_class($framework_Object_or_Frid) == "formulizeFramework") { $frameworkObject = $framework_Object_or_Frid; } else { return false; } } elseif (is_numeric($framework_Object_or_Frid)) { include_once XOOPS_ROOT_PATH . "/modules/formulize/class/frameworks.php"; $frameworkObject = new formulizeFramework($frid); } else { return false; } $fids = array(); foreach ($frameworkObject->getVar('fids') as $thisFid) { $fids[] = $this->get($thisFid); } return $fids; }
function cloneEntry($entry, $frid, $fid, $copies, $callback = null) { global $xoopsDB, $xoopsUser; include_once XOOPS_ROOT_PATH . "/modules/formulize/class/forms.php"; $lsbpairs = array(); if ($frid) { include_once XOOPS_ROOT_PATH . "/modules/formulize/class/frameworks.php"; include_once XOOPS_ROOT_PATH . "/modules/formulize/include/extract.php"; $thisframe = new formulizeFramework($frid); $links = $thisframe->getVar('links'); // get the element ids of the elements that are linked selectboxes pointing to another form $lsbindexer = 0; foreach ($links as $link) { // not a common value link, and not a uid link (key is 0 for uid links) if (!$link->getVar('common') and $link->getVar('key1') and $link->getVar('relationship') > 1) { // 2 is one to many // 3 is many to one if ($link->getVar('relationship') == 2) { // key1 is the textbox, key2 is the lsb $lsbpairs[$link->getVar('key1')] = $link->getVar('key2'); } else { // key 1 is the lsb and key 2 is the textbox $lsbpairs[$link->getVar('key2')] = $link->getVar('key1'); } } } $entries_query = getData($frid, $fid, $entry); $ids = internalRecordIds($entries_query[0], "", "", true); // true causes the first key of the returned array to be the fids foreach ($ids as $fid => $entryids) { foreach ($entryids as $id) { $entries_to_clone[$fid][] = $id; } } } else { $entries_to_clone[$fid][] = $entry; } $dataHandlers = array(); $entryMap = array(); for ($copy_counter = 0; $copy_counter < $copies; $copy_counter++) { foreach ($entries_to_clone as $fid => $entries) { // never clone an entry in a form that is a single-entry form $thisform = new formulizeForm($fid); if ($thisform->getVar('single') != "off") { continue; } foreach ($entries as $thisentry) { if (!isset($dataHandlers[$fid])) { $dataHandlers[$fid] = new formulizeDataHandler($fid); } $clonedEntryId = $dataHandlers[$fid]->cloneEntry($thisentry, $callback); $dataHandlers[$fid]->setEntryOwnerGroups(getEntryOwner($clonedEntryId, $fid), $clonedEntryId); $entryMap[$fid][$thisentry][] = $clonedEntryId; } } } // all entries have been made. Now we need to fix up any linked selectboxes $element_handler = xoops_getmodulehandler('elements', 'formulize'); foreach ($lsbpairs as $source => $lsb) { $sourceElement = $element_handler->get($source); $lsbElement = $element_handler->get($lsb); $dataHandlers[$lsbElement->getVar('id_form')]->reassignLSB($sourceElement->getVar('id_form'), $lsbElement, $entryMap); } return $entryMap; }