function displayCalendar($formframes, $mainforms = "", $viewHandles, $dateHandles, $filters, $viewPrefixes, $scopes, $hidden, $type = "month", $start = "", $multiPageData = "")
{
    global $xoopsDB, $xoopsUser;
    global $xoopsTpl;
    // Set some required variables
    $mid = getFormulizeModId();
    for ($i = 0; $i < count($formframes); $i++) {
        unset($fid);
        unset($frid);
        if ($mainforms[$i]) {
            list($fid, $frid) = getFormFramework($formframes[$i], $mainforms[$i]);
        } else {
            list($fid, $frid) = getFormFramework($formframes[$i]);
        }
        $fids[] = $fid;
        $frids[] = $frid;
    }
    $gperm_handler =& xoops_gethandler('groupperm');
    $member_handler =& xoops_gethandler('member');
    $groups = $xoopsUser ? $xoopsUser->getGroups() : array(0 => XOOPS_GROUP_ANONYMOUS);
    $uid = $xoopsUser ? $xoopsUser->getVar('uid') : 0;
    foreach ($fids as $thisFid) {
        // check that the user is allowed to see all the fids
        if (!($scheck = security_check($thisFid, "", $uid, "", $groups, $mid, $gperm_handler))) {
            print "<p>" . _NO_PERM . "</p>";
            return;
        }
    }
    $currentURL = getCurrentURL();
    // get the current view, ie: the month
    if ($_POST['calview']) {
        // if we're recieving a view from a form submission...
        $settings['calview'] = $_POST['calview'];
    } else {
        if (!$start) {
            // nothing passed from form, and no default value specified, so use current date
            $today = getDate();
            if ($today['mon'] < 10) {
                $today['mon'] = "0" . $today['mon'];
            }
            $settings['calview'] = $today['year'] . "-" . $today['mon'];
        } else {
            $settings['calview'] = $start;
        }
    }
    $settings['calfrid'] = $_POST['calfrid'];
    $settings['calfid'] = $_POST['calfid'];
    $settings['calhidden'] = $hidden;
    // check to see if a switch to a form has been requested
    $settings['ventry'] = $_POST['ventry'];
    if ($settings['ventry']) {
        if ($_POST['ventry'] == "addnew") {
            $this_ent = "";
            $dateOverride = $_POST['adddate'];
        } elseif ($_POST['ventry'] == "proxy") {
            // support for proxies not currently written
            $this_ent = "proxy";
        } else {
            $this_ent = $_POST['ventry'];
        }
        if ($_POST['calfrid']) {
            if (isset($multiPageData[$_POST['calfid']])) {
                if (is_numeric($multiPageData[$_POST['calfid']])) {
                    // numeric value indicates a screen id
                    $screenData = readScreenId($multiPageData[$_POST['calfid']], $_POST['calfid']);
                    if (is_array($screenData)) {
                        $multiPageData = $screenData;
                    }
                }
                include_once XOOPS_ROOT_PATH . "/modules/formulize/include/formdisplaypages.php";
                displayFormPages($_POST['calfrid'], $this_ent, $_POST['calfid'], $multiPageData[$_POST['calfid']]['pages'], $multiPageData[$_POST['calfid']]['conditions'], $multiPageData[$_POST['calfid']]['introtext'], $multiPageData[$_POST['calfid']]['thankstext'], $currentURL, _formulize_CAL_RETURNFROMMULTI, $settings, $dateOverride, $multiPageData[$_POST['calfid']]['printall']);
            } else {
                displayForm($_POST['calfrid'], $this_ent, $_POST['calfid'], $currentURL, "", $settings, "", $dateOverride, 1, 1);
                // first "" is the done text, second is the onetoonetitles, last two 1s are the overrides for multi form behaviour
            }
            return;
        } else {
            if (isset($multiPageData[$_POST['calfid']])) {
                if (is_numeric($multiPageData[$_POST['calfid']])) {
                    // numeric value indicates a screen id
                    $screenData = readScreenId($multiPageData[$_POST['calfid']], $_POST['calfid']);
                    if (is_array($screenData)) {
                        $multiPageData = $screenData;
                    }
                }
                include_once XOOPS_ROOT_PATH . "/modules/formulize/include/formdisplaypages.php";
                displayFormPages($_POST['calfid'], $this_ent, "", $multiPageData[$_POST['calfid']]['pages'], $multiPageData[$_POST['calfid']]['conditions'], $multiPageData[$_POST['calfid']]['introtext'], $multiPageData[$_POST['calfid']]['thankstext'], $currentURL, _formulize_CAL_RETURNFROMMULTI, $settings, $dateOverride, $multiPageData[$_POST['calfid']]['printall']);
            } else {
                displayForm($_POST['calfid'], $this_ent, "", $currentURL, "", $settings, "", $dateOverride, 1, 1);
                // "" is the done text
            }
            return;
        }
    }
    // handle deletion if requested, added sept 18 2005
    if ($_POST['delentry']) {
        deleteEntry($_POST['delentry'], $_POST['delfrid'], $_POST['delfid'], $gperm_handler, $member_handler, $mid);
    }
    // get the data for all the fids
    // 1. convert the scopes for each one
    // 2. do the extraction (filter by calview)
    include_once XOOPS_ROOT_PATH . "/modules/formulize/include/extract.php";
    for ($i = 0; $i < count($fids); $i++) {
        $scope = "";
        if ($scopes[$i]) {
            list($scope, $throwAwayCurrentView) = buildScope($scopes[$i], $member_handler, $gperm_handler, $uid, $groups, $fids[$i], $mid);
        }
        if (is_array($dateHandles[$i])) {
            $dateField = $dateHandles[$i][0];
            $dateField2 = $dateHandles[$i][1];
        } else {
            $dateField = $dateHandles[$i];
            $dateField2 = "";
        }
        if (!$frids[$i]) {
            $filterDH = $dateField;
            $filterDH2 = $dateField2;
        } else {
            $filterDH = $dateField;
            $filterDH2 = $dateField2;
        }
        // new, complex filter format is:
        // $filter[0][0] -- andor setting for filter 0
        // $filter[0][1] -- filter for filter 0
        $filter = array();
        $filter[0][0] = "OR";
        $filter[0][1] = $filterDH . "/**/" . $settings['calview'];
        if ($filterDH2) {
            $filter[0][1] .= "][" . $filterDH2 . "/**/" . $settings['calview'];
        }
        if ($filters[$i]) {
            $filter[1][0] = "AND";
            $filter[1][1] = $filters[$i];
        }
        $data[$i] = getData($frids[$i], $fids[$i], $filter, "AND", $scope);
        $data[$i] = resultSort($data[$i], $dateField);
    }
    // need the formatting magic to go here, to whip it all into a nice calendar
    // basic display of data is below
    // demonstrates linking to a form for updating/viewing that entry
    // demonstrates altering the calview setting to change months
    // need to do something a little more complex for adding a new entry, since we have to know for which fid/frid pair the add operation is being requested.
    // probably best to leave out adding for now and leave it as a future feature.  It can always be custom added within a pageworks page if necessary for a particular calendar
    $rights = $gperm_handler->checkRight("add_own_entry", $fid, $groups, $mid);
    // information to pass to the template
    global $calendarData;
    // initialize language constants
    global $arrayMonthNames;
    global $arrayWeekNames;
    global $dateMonthStartDay;
    $arrayMonthNames = array(_formulize_CAL_MONTH_01, _formulize_CAL_MONTH_02, _formulize_CAL_MONTH_03, _formulize_CAL_MONTH_04, _formulize_CAL_MONTH_05, _formulize_CAL_MONTH_06, _formulize_CAL_MONTH_07, _formulize_CAL_MONTH_08, _formulize_CAL_MONTH_09, _formulize_CAL_MONTH_10, _formulize_CAL_MONTH_11, _formulize_CAL_MONTH_12);
    if ($type == "mini_month") {
        $arrayWeekNames = array(_formulize_CAL_WEEK_1_3ABRV, _formulize_CAL_WEEK_2_3ABRV, _formulize_CAL_WEEK_3_3ABRV, _formulize_CAL_WEEK_4_3ABRV, _formulize_CAL_WEEK_5_3ABRV, _formulize_CAL_WEEK_6_3ABRV, _formulize_CAL_WEEK_7_3ABRV);
    } else {
        $arrayWeekNames = array(_formulize_CAL_WEEK_1, _formulize_CAL_WEEK_2, _formulize_CAL_WEEK_3, _formulize_CAL_WEEK_4, _formulize_CAL_WEEK_5, _formulize_CAL_WEEK_6, _formulize_CAL_WEEK_7);
    }
    // convert string date into parts
    $arrayDate = getdate(strtotime($settings['calview'] . "-01"));
    $dateMonth = $arrayDate["mon"];
    $dateDay = $arrayDate["mday"];
    $dateYear = $arrayDate["year"];
    // get the number of days in the month.
    $dateMonthDays = days_in_month($dateMonth, $dateYear);
    // get the month's first week start day.
    $dateMonthStartDay = $arrayDate["wday"];
    // get the number of weeks.
    $dateMonthWeeks = week_in_month($dateMonthDays) + 1;
    // intialize MONTH template information
    // each cell is an array:
    // [0] - is control information, where each entry is an array:
    //     [0] - day number
    //     [1] - send date
    // [1] - is an array containing all items, where each item is also an array:
    //     [0] - $ids[0]
    //     [1] - $frids[$i]
    //     [2] - $fids[$i]
    //     [3] - $textToDisplay
    //     [4] - true/false based on user's right to delete this item (based on either delete own, or delete others permission)
    if ($type == "month" || $type == "mini_month" || $type == "micro_month") {
        // initialize grid: convert the data set into a grid of 7 columns for
        //  days and a row for each week
        $displayDay = "";
        for ($intWeeks = 0; $intWeeks < $dateMonthWeeks; $intWeeks++) {
            $calendarData[$intWeeks] = array();
            for ($intDays = 0; $intDays < 7; $intDays++) {
                // check to see if the processing day is the start day.
                if ($intWeeks == 0 && $displayDay == "") {
                    if ($intDays == $dateMonthStartDay) {
                        $displayDay = 1;
                    }
                } else {
                    if ($displayDay != "") {
                        $displayDay++;
                        if ($displayDay > $dateMonthDays) {
                            $displayDay = "";
                        }
                    }
                }
                $calendarData[$intWeeks][$intDays] = array();
                $calendarData[$intWeeks][$intDays][0][0] = $displayDay;
                $calendarData[$intWeeks][$intDays][0][1] = $dateYear . "-" . $dateMonth . "-" . ($displayDay < 10 ? "0" . $displayDay : $displayDay);
                //$calendarData[$intWeeks][$intDays][1] = array();
            }
        }
        // Initialize template variables
        $xoopsTpl->assign('previousMonth', $dateMonth - 1 < 1 ? $dateYear - 1 . "-12" : $dateYear . "-" . ($dateMonth - 1 < 10 ? "0" . ($dateMonth - 1) : $dateMonth - 1));
        $xoopsTpl->assign('nextMonth', $dateMonth + 1 > 12 ? $dateYear + 1 . "-01" : $dateYear . "-" . ($dateMonth + 1 < 10 ? "0" . ($dateMonth + 1) : $dateMonth + 1));
        $monthSelector = array();
        $numberOfMonths = count($arrayMonthNames);
        for ($intMonth = 0; $intMonth < $numberOfMonths; $intMonth++) {
            $monthName = $arrayMonthNames[$intMonth];
            $monthSelector[$intMonth + 1 < 10 ? "0" . ($intMonth + 1) : $intMonth + 1] = $monthName;
        }
        $xoopsTpl->assign('monthSelector', $monthSelector);
        $yearSelector = array();
        $startYear = $dateYear - 4;
        $endYear = $dateYear + 3;
        for ($intYear = $startYear; $intYear <= $endYear; $intYear++) {
            $yearSelector[] = $intYear;
        }
        $xoopsTpl->assign('yearSelector', $yearSelector);
    }
    // process data set(s)
    for ($i = 0; $i < count($data); $i++) {
        foreach ($data[$i] as $id => $entry) {
            if (!$frids[$i]) {
                if (is_array($viewHandles[$i])) {
                    $formhandle = getFormHandleFromEntry($entry, $viewHandles[$i][0]);
                } else {
                    $formhandle = getFormHandleFromEntry($entry, $viewHandles[$i]);
                }
            } else {
                $formhandle = $mainforms[$i];
            }
            $ids = internalRecordIds($entry, $formhandle);
            if (is_array($viewHandles[$i])) {
                $needsep = 0;
                // make sure that no data is keep from previous processing
                $textToDisplay = "";
                foreach ($viewHandles[$i] as $thisVH) {
                    if ($needsep) {
                        $textToDisplay .= ", ";
                    }
                    $needsep = 1;
                    $textToDisplay .= display($entry, $thisVH);
                }
            } else {
                $textToDisplay = display($entry, $viewHandles[$i]);
            }
            if ($viewPrefixes[$i]) {
                $textToDisplay = $viewPrefixes[$i] . $textToDisplay;
            }
            $calendarDataItem = array();
            $calendarDataItem[0] = $ids[0];
            $calendarDataItem[1] = $frids[$i];
            $calendarDataItem[2] = $fids[$i];
            $calendarDataItem[3] = $textToDisplay;
            $calendarDataItem[4] = ($i == 0 and formulizePermHandler::user_can_delete_entry($fids[$i], display($entry, "uid"), $ids[0]));
            if ($type == "month" || $type == "mini_month" || $type == "micro_month") {
                if (is_array($dateHandles[$i])) {
                    $startValue = display($entry, $dateHandles[$i][0]);
                    $endValue = display($entry, $dateHandles[$i][1]);
                    if ($startValue && $endValue) {
                        $startDate = strtotime($startValue);
                        $endDate = strtotime($endValue);
                        for ($x = $startDate; $x <= $endDate; $x = $x + 86400) {
                            $arrayDate = getdate($x);
                            if ($arrayDate["mon"] == $dateMonth) {
                                $calendarData = assignItem($arrayDate, $calendarDataItem, $calendarData);
                            }
                        }
                    } else {
                        if ($startValue) {
                            $startDate = strtotime($startValue);
                            $arrayDate = getdate($startDate);
                            $calendarData = assignItem($arrayDate, $calendarDataItem, $calendarData);
                        } else {
                            $endDate = strtotime($endValue);
                            $arrayDate = getdate($endDate);
                            $calendarData = assignItem($arrayDate, $calendarDataItem, $calendarData);
                        }
                    }
                } else {
                    $currentDate = display($entry, $dateHandles[$i]);
                    $arrayDate = getdate(strtotime($currentDate));
                    $calendarData = assignItem($arrayDate, $calendarDataItem, $calendarData);
                }
            }
        }
    }
    // Initialize common template variables
    $xoopsTpl->assign('cal_type', $type);
    $xoopsTpl->assign('rights', $rights);
    $xoopsTpl->assign('frids', $frids[0]);
    $xoopsTpl->assign('fids', $fids[0]);
    $xoopsTpl->assign('addItem', _formulize_CAL_ADD_ITEM);
    $xoopsTpl->assign('rowStyleEven', true);
    $xoopsTpl->assign('MonthNames', $arrayMonthNames);
    $xoopsTpl->assign('WeekNames', $arrayWeekNames);
    $xoopsTpl->assign('dateMonthZeroIndex', $dateMonth - 1);
    $xoopsTpl->assign('dateMonth', $dateMonth);
    $xoopsTpl->assign('dateYear', $dateYear);
    $xoopsTpl->assign('currentURL', $currentURL);
    $xoopsTpl->assign('hidden', $hidden);
    $xoopsTpl->assign('calview', $settings['calview']);
    $xoopsTpl->assign('calendarData', $calendarData);
    $xoopsTpl->assign('delete', _formulize_DELETE);
    $xoopsTpl->assign('delconf', _formulize_DELCONF);
    // force template to be drawn
    $xoopsTpl->display("db:calendar_" . $type . ".html");
}
function drawEntries($fid, $cols, $searches = "", $frid = "", $scope, $standalone = "", $currentURL, $gperm_handler, $uid, $mid, $groups, $settings, $member_handler, $screen, $data, $wq, $regeneratePageNumbers, $hiddenQuickSearches, $cResults)
{
    // , $loadview="") { // -- loadview removed from this function sept 24 2005
    // determine if the query reached a limit in the number of entries to return
    $LOE_limit = 0;
    if (!is_array($data)) {
        $LOE_limit = is_numeric($data) ? $data : 0;
        $data = array();
    }
    global $xoopsDB;
    $useScrollBox = true;
    $useHeadings = true;
    $repeatHeaders = 5;
    $columnWidth = 0;
    $textWidth = 35;
    $useCheckboxes = 0;
    $useViewEntryLinks = 1;
    $useSearch = 1;
    $deColumns = array();
    $useSearchCalcMsgs = 1;
    $listTemplate = false;
    $inlineButtons = array();
    $hiddenColumns = array();
    $formulize_LOEPageSize = 10;
    if ($screen) {
        $useScrollBox = $screen->getVar('usescrollbox');
        $useHeadings = $screen->getVar('useheadings');
        $repeatHeaders = $screen->getVar('repeatheaders');
        $columnWidth = $screen->getVar('columnwidth');
        $textWidth = $screen->getVar('textwidth');
        if ($textWidth == 0) {
            $textWidth = 10000;
        }
        $useCheckboxes = $screen->getVar('usecheckboxes');
        $useViewEntryLinks = $screen->getVar('useviewentrylinks');
        $useSearch = $screen->getVar('usesearch');
        $hiddenColumns = $screen->getVar('hiddencolumns');
        $deColumns = $screen->getVar('decolumns');
        $deDisplay = $screen->getVar('dedisplay');
        $useSearchCalcMsgs = $screen->getVar('usesearchcalcmsgs');
        $listTemplate = $screen->getTemplate("listtemplate");
        foreach ($screen->getVar('customactions') as $caid => $thisCustomAction) {
            if ($thisCustomAction['appearinline'] == 1) {
                list($caCode) = processCustomButton($caid, $thisCustomAction);
                if ($caCode) {
                    $inlineButtons[$caid] = $thisCustomAction;
                }
            }
        }
        $formulize_LOEPageSize = $screen->getVar('entriesperpage');
    }
    $filename = "";
    // $settings['xport'] no longer set by a page load, except if called as part of the import process to create a template for updating
    if (!$settings['xport']) {
        $settings['xport'] = $settings['hlist'] ? "calcs" : "comma";
        $xportDivText1 = "<div id=exportlink style=\"display: none;\">";
        // export button turns this link on and off now
        $xportDivText2 = "</div>";
    } else {
        $xportDivText1 = "";
        $xportDivText2 = "";
    }
    if (@$_POST['advcalc_acid']) {
        if ($_POST['acid'] > 0) {
            $result = formulize_runAdvancedCalculation(intval($_POST['acid']));
            // result will be an array with two or three keys: 'text' and 'output', and possibly 'groupingMap'.  Text is for display on screen "raw" and Output is a variable that can be used by a dev.  The output variable will be an array if groupings are in effect.  The keys of the array will be the various grouping values in effect.  The groupingMap will be present if there's a set of groupings in effect.  It is an array that contains all the grouping choices, their text equivalents and their data values (which are the keys in the output array) -- groupingMap is still to be developed/added to the mix....will be necessary when we are integrating with Drupal or other API uses.
            print "<br/>" . $result['text'] . "<br/><br/>";
        }
    }
    // export of Data is moved out to a popup
    // Calculations still handled in the old way for now
    if ($settings['xport'] == "calcs") {
        $filename = prepExport($headers, $cols, $data, $settings['xport'], $settings['xport_cust'], $settings['title'], false, $fid, $groups);
        $linktext = $_POST['xport'] == "update" ? _formulize_DE_CLICKSAVE_TEMPLATE : _formulize_DE_CLICKSAVE;
        print "{$xportDivText1}<center><p><a href='{$filename}' target=\"_blank\">{$linktext}</a></p></center>";
        print "<br>{$xportDivText2}";
    }
    $scrollBoxWasSet = false;
    if ($useScrollBox and count($data) > 0) {
        print "<div class=scrollbox id=resbox>\n";
        $scrollBoxWasSet = true;
    }
    // perform calculations...
    // calc_cols is the columns requested (separated by / -- ele_id for each, also metadata is indicated with uid, proxyid, creation_date, mod_date)
    // calc_calcs is the calcs for each column, columns separated by / and calcs for a column separated by ,. possible calcs are sum, avg, min, max, count, per
    // calc_blanks is the blank setting for each calculation, setup the same way as the calcs, possible settings are all,  noblanks, onlyblanks
    // calc_grouping is the grouping option.  same format as calcs.  possible values are ele_ids or the uid, proxyid, creation_date and mod_date metadata terms
    // 1. extract data from four settings into arrays
    // 2. loop through the array and perform all the requested calculations
    if ($settings['calc_cols'] and !$settings['hcalc']) {
        //		print "<p><input type=button style=\"width: 140px;\" name=cancelcalcs1 value='" . _formulize_DE_CANCELCALCS . "' onclick=\"javascript:cancelCalcs();\"></input></p>\n";
        //		print "<div";
        //		if($totalcalcs>4) { print " class=scrollbox"; }
        //		print " id=calculations>
        $calc_cols = $settings['calc_cols'];
        $calc_calcs = $settings['calc_calcs'];
        $calc_blanks = $settings['calc_blanks'];
        $calc_grouping = $settings['calc_grouping'];
        print "<table class=outer>";
        if ($useHeadings) {
            $headers = getHeaders($cols, true);
            // second param indicates we're using element headers and not ids
            drawHeaders($headers, $cols, $useCheckboxes, $useViewEntryLinks, count($inlineButtons), $settings['lockedColumns']);
        }
        if ($useSearch) {
            drawSearches($searches, $cols, $useCheckboxes, $useViewEntryLinks, count($inlineButtons), false, $hiddenQuickSearches);
        }
        print "</table>";
        print "<table class=outer><tr><th colspan=2>" . _formulize_DE_CALCHEAD . "</th></tr>\n";
        if (!$settings['lockcontrols'] and ($useSearchCalcMsgs == 1 or $useSearchCalcMsgs == 3)) {
            // AND !$loadview) { // -- loadview removed from this function sept 24 2005
            print "<tr><td class=head colspan=2><input type=button style=\"width: 140px;\" name=mod_calculations value='" . _formulize_DE_MODCALCS . "' onclick=\"javascript:showPop('" . XOOPS_URL . "/modules/formulize/include/pickcalcs.php?fid={$fid}&frid={$frid}&calc_cols=" . urlencode($calc_cols) . "&calc_calcs=" . urlencode($calc_calcs) . "&calc_blanks=" . urlencode($calc_blanks) . "&calc_grouping=" . urlencode($calc_grouping) . "&cols=" . urlencode(implode(",", $cols)) . "');\"></input>&nbsp;&nbsp;" . "<input type=button style=\"width: 140px;\" name=cancelcalcs value='" . _formulize_DE_CANCELCALCS . "' onclick=\"javascript:cancelCalcs();\"></input>&nbsp;&nbsp" . "<input type=button style=\"width: 140px;\" name=showlist value='" . _formulize_DE_SHOWLIST . "' onclick=\"javascript:showList();\"></input></td></tr>";
        }
        $exportFilename = $settings['xport'] == "calcs" ? $filename : "";
        //formulize_benchmark("before printing results");
        // 0 is the masterresults, 1 is the blanksettings, 2 is grouping settings -- exportFilename is the name of the file that we need to create and into which we need to dump a copy of the calcs
        printResults($cResults[0], $cResults[1], $cResults[2], $cResults[3], $cResults[4], $exportFilename, $settings['title']);
        //formulize_benchmark("after printing results");
        print "</table>\n";
    }
    // MASTER HIDELIST CONDITIONAL...
    if (!$settings['hlist'] and !$listTemplate) {
        print "<div class=\"list-of-entries-container\"><table class=\"outer\">";
        $count_colspan = count($cols) + 1;
        if ($useViewEntryLinks or $useCheckboxes != 2) {
            $count_colspan_calcs = $count_colspan;
        } else {
            $count_colspan_calcs = $count_colspan - 1;
        }
        $count_colspan_calcs = $count_colspan_calcs + count($inlineButtons);
        // add to the column count for each inline custom button
        $count_colspan_calcs++;
        // add one more for the hidden floating column
        if (!$screen) {
            print "<tr><th colspan={$count_colspan_calcs}>" . _formulize_DE_DATAHEADING . "</th></tr>\n";
        }
        if ($settings['calc_cols'] and !$settings['lockcontrols'] and ($useSearchCalcMsgs == 1 or $useSearchCalcMsgs == 3)) {
            // AND !$loadview) { // -- loadview removed from this function sept 24 2005
            $calc_cols = $settings['calc_cols'];
            $calc_calcs = $settings['calc_calcs'];
            $calc_blanks = $settings['calc_blanks'];
            $calc_grouping = $settings['calc_grouping'];
            print "<tr><td class=head colspan={$count_colspan_calcs}><input type=button style=\"width: 140px;\" name=mod_calculations value='" . _formulize_DE_MODCALCS . "' onclick=\"javascript:showPop('" . XOOPS_URL . "/modules/formulize/include/pickcalcs.php?fid={$fid}&frid={$frid}&calc_cols={$calc_cols}&calc_calcs={$calc_calcs}&calc_blanks={$calc_blanks}&calc_grouping=" . urlencode($calc_grouping) . "&cols=" . urlencode(implode(",", $cols)) . "');\"></input>&nbsp;&nbsp;<input type=button style=\"width: 140px;\" name=cancelcalcs value='" . _formulize_DE_CANCELCALCS . "' onclick=\"javascript:cancelCalcs();\"></input>&nbsp;&nbsp;<input type=button style=\"width: 140px;\" name=hidelist value='" . _formulize_DE_HIDELIST . "' onclick=\"javascript:hideList();\"></input></td></tr>";
        }
        // draw advanced search notification
        if ($settings['as_0'] and ($useSearchCalcMsgs == 1 or $useSearchCalcMsgs == 2)) {
            $writable_q = writableQuery($wq);
            $minus1colspan = $count_colspan - 1 + count($inlineButtons);
            if (!$asearch_parse_error) {
                print "<tr>";
                if ($useViewEntryLinks or $useCheckboxes != 2) {
                    // only include this column if necessary
                    print "<td class=head></td>";
                }
                print "<td colspan={$minus1colspan} class=head>" . _formulize_DE_ADVSEARCH . ": {$writable_q}";
            } else {
                print "<tr>";
                if ($useViewEntryLinks or $useCheckboxes != 2) {
                    print "<td class=head></td>";
                }
                print "<td colspan={$minus1colspan} class=head><span style=\"font-weight: normal;\">" . _formulize_DE_ADVSEARCH_ERROR . "</span>";
            }
            if (!$settings['lockcontrols']) {
                // AND !$loadview) { // -- loadview removed from this function sept 24 2005
                print "<br><input type=button style=\"width: 140px;\" name=advsearch value='" . _formulize_DE_MOD_ADVSEARCH . "' onclick=\"javascript:showPop('" . XOOPS_URL . "/modules/formulize/include/advsearch.php?fid={$fid}&frid={$frid}";
                foreach ($settings as $k => $v) {
                    if (substr($k, 0, 3) == "as_") {
                        $v = str_replace("'", "&#39;", $v);
                        $v = stripslashes($v);
                        print "&{$k}=" . urlencode($v);
                    }
                }
                print "');\"></input>&nbsp;&nbsp;<input type=button style=\"width: 140px;\" name=cancelasearch value='" . _formulize_DE_CANCELASEARCH . "' onclick=\"javascript:killSearch();\"></input>";
            }
            print "</td></tr>\n";
        }
        if ($useHeadings) {
            $headers = getHeaders($cols, true);
            // second param indicates we're using element headers and not ids
            drawHeaders($headers, $cols, $useCheckboxes, $useViewEntryLinks, count($inlineButtons), $settings['lockedColumns']);
        }
        if ($useSearch) {
            drawSearches($searches, $cols, $useCheckboxes, $useViewEntryLinks, count($inlineButtons), false, $hiddenQuickSearches);
        }
        if (count($data) == 0) {
            // kill an empty dataset so there's no rows drawn
            unset($data);
        } else {
            // get form handles in use
            $mainFormHandle = key($data[key($data)]);
        }
        $headcounter = 0;
        $blankentries = 0;
        $GLOBALS['formulize_displayElement_LOE_Used'] = false;
        $formulize_LOEPageStart = (isset($_POST['formulize_LOEPageStart']) and !$regeneratePageNumbers) ? intval($_POST['formulize_LOEPageStart']) : 0;
        // adjust formulize_LOEPageSize if the actual count of entries is less than the page size
        $formulize_LOEPageSize = $GLOBALS['formulize_countMasterResultsForPageNumbers'] < $formulize_LOEPageSize ? $GLOBALS['formulize_countMasterResultsForPageNumbers'] : $formulize_LOEPageSize;
        $actualPageSize = $formulize_LOEPageSize ? $formulize_LOEPageStart + $formulize_LOEPageSize : $GLOBALS['formulize_countMasterResultsForPageNumbers'];
        if (isset($data)) {
            foreach ($data as $id => $entry) {
                formulize_benchmark("starting to draw one row of results");
                // check to make sure this isn't an unset entry (ie: one that was blanked by the extraction layer just prior to sending back results
                // Since the extraction layer is unsetting entries to blank them, this condition should never be met?
                // If this condition is ever met, it may very well screw up the paging of results!
                // NOTE: this condition is met on the last page of a paged set of results, unless the last page as exactly the same number of entries on it as the limit of entries per page
                if ($entry != "") {
                    if ($headcounter == $repeatHeaders and $repeatHeaders > 0) {
                        if ($useHeadings) {
                            drawHeaders($headers, $cols, $useCheckboxes, $useViewEntryLinks, count($inlineButtons));
                        }
                        $headcounter = 0;
                    }
                    $headcounter++;
                    print "<tr>\n";
                    if ($class == "even") {
                        $class = "odd";
                    } else {
                        $class = "even";
                    }
                    unset($linkids);
                    $linkids = internalRecordIds($entry, $mainFormHandle);
                    // draw in the margin column where the links and metadata goes
                    if ($useViewEntryLinks or $useCheckboxes != 2) {
                        print "<td class=\"head formulize-controls\">\n";
                    }
                    if (!$settings['lockcontrols']) {
                        //  AND !$loadview) { // -- loadview removed from this function sept 24 2005
                        // check to see if we should draw in the delete checkbox
                        // 2 is none, 1 is all
                        if ($useCheckboxes != 2 and ($useCheckboxes == 1 or formulizePermHandler::user_can_delete_entry($fid, $uid, $linkids[0]))) {
                            print "<input type=checkbox title='" . _formulize_DE_DELBOXDESC . "' class='formulize_selection_checkbox' name='delete_" . $linkids[0] . "' id='delete_" . $linkids[0] . "' value='delete_" . $linkids[0] . "'>";
                        }
                        if ($useViewEntryLinks) {
                            print "<a href='" . $currentURL;
                            if (strstr($currentURL, "?")) {
                                // if params are already part of the URL...
                                print "&";
                            } else {
                                print "?";
                            }
                            print "ve=" . $linkids[0] . "' onclick=\"javascript:goDetails('" . $linkids[0] . "');return false;\" " . " class=\"loe-edit-entry\" alt=\"" . _formulize_DE_VIEWDETAILS . "\" title=\"" . _formulize_DE_VIEWDETAILS . "\" >";
                            print "&nbsp;</a>";
                        }
                    }
                    // end of IF NO LOCKCONTROLS
                    if ($useViewEntryLinks or $useCheckboxes != 2) {
                        print "</td>\n";
                    }
                    $column_counter = 0;
                    if ($columnWidth) {
                        $columnWidthParam = "style=\"width: {$columnWidth}" . "px\"";
                    } else {
                        $columnWidthParam = "";
                    }
                    for ($i = 0; $i < count($cols); $i++) {
                        //formulize_benchmark("drawing one column");
                        $col = $cols[$i];
                        $colhandle = $settings['columnhandles'][$i];
                        $classToUse = $class . " column column" . $i;
                        $cellRowAddress = $id + 2;
                        if ($i == 0) {
                            print "<td {$columnWidthParam} class=\"{$class} floating-column\" id='floatingcelladdress_{$cellRowAddress}'>\n";
                        }
                        print "<td {$columnWidthParam} class=\"{$classToUse}\" id=\"celladdress_" . $cellRowAddress . "_" . $i . "\">\n";
                        if ($col == "creation_uid" or $col == "mod_uid") {
                            $userObject = $member_handler->getUser(display($entry, $col));
                            if ($userObject) {
                                $nameToDisplay = $userObject->getVar('name') ? $userObject->getVar('name') : $userObject->getVar('uname');
                            } else {
                                $nameToDisplay = _FORM_ANON_USER;
                            }
                            $value = "<a href=\"" . XOOPS_URL . "/userinfo.php?uid=" . display($entry, $col) . "\" target=_blank>" . $nameToDisplay . "</a>";
                        } else {
                            $value = display($entry, $col);
                        }
                        // set in the display function, corresponds to the entry id of the record in the form where the current value was retrieved from.  If there is more than one local entry id, because of a one to many framework, then this will be an array that corresponds to the order of the values returned by display.
                        $currentColumnLocalId = $GLOBALS['formulize_mostRecentLocalId'];
                        // if we're supposed to display this column as an element... (only show it if they have permission to update this entry)
                        if (in_array($colhandle, $deColumns) and formulizePermHandler::user_can_edit_entry($fid, $uid, $entry)) {
                            include_once XOOPS_ROOT_PATH . "/modules/formulize/include/elementdisplay.php";
                            if ($frid) {
                                // need to work out which form this column belongs to, and use that form's entry ID.  Need to loop through the entry to find all possible internal IDs, since a subform situation would lead to multiple values appearing in a single cell, so multiple displayElement calls would be made each with their own internal ID.
                                foreach ($entry as $entryFormHandle => $entryFormData) {
                                    foreach ($entryFormData as $internalID => $entryElements) {
                                        $deThisIntId = false;
                                        foreach ($entryElements as $entryHandle => $values) {
                                            if ($entryHandle == $col) {
                                                // we found the element that we're trying to display
                                                if ($deThisIntId) {
                                                    print "\n<br />\n";
                                                }
                                                // could be a subform so we'd display multiple values
                                                if ($deDisplay) {
                                                    print '<div id="deDiv_' . $colhandle . '_' . $internalID . '">';
                                                    print getHTMLForList($values, $colhandle, $internalID, $deDisplay, $textWidth, $currentColumnLocalId, $fid, $cellRowAddress, $i);
                                                    print "</div>";
                                                } else {
                                                    displayElement("", $colhandle, $internalID);
                                                }
                                                $deThisIntId = true;
                                            }
                                        }
                                    }
                                }
                            } else {
                                // display based on the mainform entry id
                                if ($deDisplay) {
                                    print '<div id="deDiv_' . $colhandle . '_' . $linkids[0] . '">';
                                    print getHTMLForList($value, $colhandle, $linkids[0], $deDisplay, $textWidth, $currentColumnLocalId, $fid, $cellRowAddress, $i);
                                    print "</div>";
                                } else {
                                    displayElement("", $colhandle, $linkids[0]);
                                    // works for mainform only!  To work on elements from a framework, we need to figure out the form the element is from, and the entry ID in that form, which is done above
                                }
                            }
                            $GLOBALS['formulize_displayElement_LOE_Used'] = true;
                        } elseif ($col != "creation_uid" and $col != "mod_uid" and $col != "entry_id") {
                            print getHTMLForList($value, $col, $linkids[0], 0, $textWidth, $currentColumnLocalId, $fid, $cellRowAddress, $i);
                        } else {
                            // no special formatting on the uid columns:
                            print $value;
                        }
                        print "</td>\n";
                        $column_counter++;
                    }
                    // handle inline custom buttons
                    foreach ($inlineButtons as $caid => $thisCustomAction) {
                        list($caCode) = processCustomButton($caid, $thisCustomAction, $linkids[0], $entry);
                        // only bother with the code, since we already processed any clicked button above
                        if ($caCode) {
                            print "<td {$columnWidthParam} class={$class}>\n";
                            print "<center>{$caCode}</center>\n";
                            print "</td>\n";
                        }
                    }
                    // handle hidden elements for passing back to custom buttons
                    foreach ($hiddenColumns as $thisHiddenCol) {
                        print "\n<input type=\"hidden\" name=\"hiddencolumn_" . $linkids[0] . "_{$thisHiddenCol}\" value=\"" . htmlspecialchars(display($entry, $thisHiddenCol)) . "\"></input>\n";
                    }
                    print "</tr>\n";
                } else {
                    // this is a blank entry
                    $blankentries++;
                }
                // end of not "" check
            }
            // end of foreach data as entry
        }
        // end of if there is any data to draw
        print "</table></div>";
    } elseif ($listTemplate and !$settings['hlist']) {
        // USING A CUSTOM LIST TEMPLATE SO DO EVERYTHING DIFFERENTLY
        // print str_replace("\n", "<br />", $listTemplate); // debug code
        $mainFormHandle = key($data[key($data)]);
        $formulize_LOEPageStart = (isset($_POST['formulize_LOEPageStart']) and !$regeneratePageNumbers) ? intval($_POST['formulize_LOEPageStart']) : 0;
        $actualPageSize = $formulize_LOEPageSize ? $formulize_LOEPageStart + $formulize_LOEPageSize : $GLOBALS['formulize_countMasterResultsForPageNumbers'];
        if (strstr($listTemplate, "displayElement")) {
            include_once XOOPS_ROOT_PATH . "/modules/formulize/include/elementdisplay.php";
        }
        if (isset($data)) {
            //for($entryCounter=$formulize_LOEPageStart;$entryCounter<$actualPageSize;$entryCounter++) {
            // setup the view name variables, with true only set for the last loaded view
            $viewNumber = 1;
            foreach ($settings['publishedviewnames'] as $id => $thisViewName) {
                $thisViewName = str_replace(" ", "_", $thisViewName);
                if ($id == $settings['lastloaded']) {
                    ${$thisViewName} = true;
                    ${'view' . $viewNumber} = true;
                } else {
                    ${$thisViewName} = false;
                    $view['view' . $viewNumber] = false;
                }
                $viewNumber++;
            }
            foreach ($data as $id => $entry) {
                //$entry = $data[$entryCounter];
                //$id=$entryCounter;
                // check to make sure this isn't an unset entry (ie: one that was blanked by the extraction layer just prior to sending back results
                // Since the extraction layer is unsetting entries to blank them, this condition should never be met?
                // If this condition is ever met, it may very well screw up the paging of results!
                // NOTE: this condition is met on the last page of a paged set of results, unless the last page as exactly the same number of entries on it as the limit of entries per page
                if ($entry != "") {
                    // Set up the variables for the link to the current entry, and the checkbox that can be used to select the current entry
                    $linkids = internalRecordIds($entry, $mainFormHandle);
                    $entry_id = $linkids[0];
                    // make a nice way of referring to this for in the eval'd code
                    $form_id = $fid;
                    // make a nice way of referring to this for in the eval'd code
                    if (!$settings['lockcontrols']) {
                        //  AND !$loadview) { // -- loadview removed from this function sept 24 2005
                        $viewEntryLinkCode = "<a href='" . $currentURL;
                        if (strstr($currentURL, "?")) {
                            // if params are already part of the URL...
                            $viewEntryLinkCode .= "&";
                        } else {
                            $viewEntryLinkCode .= "?";
                        }
                        $viewEntryLinkCode .= "ve=" . $entry_id . "' onclick=\"javascript:goDetails('" . $entry_id . "');return false;\">";
                        $GLOBALS['formulize_viewEntryId'] = $entry_id;
                        // put into global scope so the function 'viewEntryLink' can pick it up if necessary
                        $GLOBALS['formulize_viewEntryLinkCode'] = $viewEntryLinkCode;
                        // check to see if we should draw in the delete checkbox
                        // 2 is none, 1 is all
                        if ($useCheckboxes != 2 and ($useCheckboxes == 1 or formulizePermHandler::user_can_delete_entry($fid, $uid, $entry_id))) {
                            $selectionCheckbox = "<input type=checkbox title='" . _formulize_DE_DELBOXDESC . "' class='formulize_selection_checkbox' name='delete_" . $entry_id . "' id='delete_" . $entry_id . "' value='delete_" . $entry_id . "'>";
                        } else {
                            $selectionCheckbox = "";
                        }
                    }
                    // end of IF NO LOCKCONTROLS
                    $ids = internalRecordIds($entry, $mainFormHandle);
                    foreach ($inlineButtons as $caid => $thisCustomAction) {
                        list($caCode) = processCustomButton($caid, $thisCustomAction, $ids[0], $entry);
                        // only bother with the code, since we already processed any clicked button above
                        if ($caCode) {
                            ${$thisCustomAction['handle']} = $caCode;
                            // assign the button code that was returned
                        }
                    }
                    // handle hidden elements for passing back to custom buttons
                    foreach ($hiddenColumns as $thisHiddenCol) {
                        print "\n<input type=\"hidden\" name=\"hiddencolumn_" . $linkids[0] . "_{$thisHiddenCol}\" value=\"" . htmlspecialchars(display($entry, $thisHiddenCol)) . "\"></input>\n";
                    }
                    include XOOPS_ROOT_PATH . "/modules/formulize/templates/screens/default/" . $screen->getVar('sid') . "/listtemplate.php";
                }
            }
        }
    }
    // END OF MASTER HIDELIST CONDITIONAL
    if ((!isset($data) or count($data) == $blankentries) and !$LOE_limit) {
        // if no data was returned, or the dataset was empty...
        print "<p><b>" . _formulize_DE_NODATAFOUND . "</b></p>\n";
    } elseif ($LOE_limit) {
        print "<p>" . _formulize_DE_LOE_LIMIT_REACHED1 . " <b>" . $LOE_limit . "</b> " . _formulize_DE_LOE_LIMIT_REACHED2 . " <a href=\"\" onclick=\"javascript:forceQ();return false;\">" . _formulize_DE_LOE_LIMIT_REACHED3 . "</a></p>\n";
    }
    if ($scrollBoxWasSet) {
        print "</div>";
    }
    formulize_benchmark("We're done");
}
Esempio n. 3
0
function export_data($queryData, $frid, $fid, $groups, $columns, $include_metadata)
{
    global $xoopsDB;
    // generate the export filename, which the user will see
    $form_handler = xoops_getmodulehandler('forms', 'formulize');
    $formObject = $form_handler->get($fid);
    if (is_object($formObject)) {
        $formTitle = "'" . str_replace(array(" ", "-", "/", "'", "`", "\\", ".", "?", ",", ")", "(", "[", "]"), "_", trans($formObject->getVar('title'))) . "'";
    } else {
        $formTitle = "a_form";
    }
    $export_filename = _formulize_EXPORT_FILENAME_TEXT . "_" . $formTitle . "_" . date("M_j_Y_Hi") . ".csv";
    // output http headers
    header('Content-Description: File Transfer');
    header('Content-Type: text/csv; charset=' . _CHARSET);
    header('Content-Disposition: attachment; filename=' . $export_filename);
    header('Content-Transfer-Encoding: binary');
    header('Expires: 0');
    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    header('Pragma: public');
    // get a list of columns for export
    $headers = array();
    if ($include_metadata) {
        // include metadata columns if the user requested them
        $headers = array(_formulize_ENTRY_ID, _formulize_DE_CALC_CREATOR, _formulize_DE_CALC_MODIFIER, _formulize_DE_CALC_CREATEDATE, _formulize_DE_CALC_MODDATE);
    } else {
        if (in_array("entry_id", $columns)) {
            $headers[] = _formulize_ENTRY_ID;
        }
        if (in_array("uid", $columns) or in_array("creation_uid", $columns)) {
            $headers[] = _formulize_DE_CALC_CREATOR;
        }
        if (in_array("proxyid", $columns) or in_array("mod_uid", $columns)) {
            $headers[] = _formulize_DE_CALC_MODIFIER;
        }
        if (in_array("creation_date", $columns) or in_array("creation_datetime", $columns)) {
            $headers[] = _formulize_DE_CALC_CREATEDATE;
        }
        if (in_array("mod_date", $columns) or in_array("mod_datetime", $columns)) {
            $headers[] = _formulize_DE_CALC_MODDATE;
        }
    }
    foreach ($columns as $thiscol) {
        if ("creator_email" == $thiscol) {
            $headers[] = _formulize_DE_CALC_CREATOR_EMAIL;
        } else {
            $colMeta = formulize_getElementMetaData($thiscol, true);
            $headers[] = $colMeta['ele_colhead'] ? trans($colMeta['ele_colhead']) : trans($colMeta['ele_caption']);
        }
    }
    if ($include_metadata) {
        // include metadata columns if the user requested them
        $columns = array_merge(array("entry_id", "uid", "proxyid", "creation_date", "mod_date"), $columns);
    }
    if (strstr(strtolower(_CHARSET), 'utf') and $_POST['excel'] == 1) {
        echo "";
        // necessary to trigger certain versions of Excel to recognize the file as unicode
    }
    // output export header
    $output_handle = fopen('php://output', 'w');
    // open a file handle to stdout because fputcsv() needs it
    fputcsv($output_handle, $headers);
    // output export data
    $GLOBALS['formulize_doingExport'] = true;
    unset($queryData[0]);
    // get rid of the fid and userid lines
    unset($queryData[1]);
    $data_sql = implode(" ", $queryData);
    // merge all remaining lines into one string to send to getData
    $limitStart = 0;
    $limitSize = 50;
    // export in batches of 50 records at a time
    do {
        // load part of the data, since a very large dataset could exceed the PHP memory limit
        $data = getData($frid, $fid, $data_sql, "AND", null, $limitStart, $limitSize);
        if (is_array($data)) {
            foreach ($data as $entry) {
                $row = array();
                foreach ($columns as $column) {
                    switch ($column) {
                        case "entry_id":
                            $formhandle = getFormHandlesFromEntry($entry);
                            $ids = internalRecordIds($entry, $formhandle[0]);
                            $row[] = $ids[0];
                            break;
                        case "uid":
                            $c_uid = display($entry, 'creation_uid');
                            $c_name_q = q("SELECT name, uname FROM " . $xoopsDB->prefix("users") . " WHERE uid='{$c_uid}'");
                            $row[] = isset($c_name_q[0]['name']) ? $c_name_q[0]['name'] : $c_name_q[0]['uname'];
                            break;
                        case "proxyid":
                            $m_uid = display($entry, 'mod_uid');
                            if ($m_uid) {
                                $m_name_q = q("SELECT name, uname FROM " . $xoopsDB->prefix("users") . " WHERE uid='{$m_uid}'");
                                $row[] = isset($m_name_q[0]['name']) ? $m_name_q[0]['name'] : $m_name_q[0]['uname'];
                            } else {
                                $row[] = "";
                            }
                            break;
                        case "creation_date":
                            $row[] = display($entry, 'creation_datetime');
                            break;
                        case "mod_date":
                            $row[] = display($entry, 'mod_datetime');
                            break;
                        default:
                            $row[] = trans(html_entity_decode(displayTogether($entry, $column, ", "), ENT_QUOTES));
                    }
                }
                // output this row to the browser
                fputcsv($output_handle, $row);
            }
            // get the next set of data
            set_time_limit(90);
            $limitStart += $limitSize;
        }
    } while (is_array($data) and count($data) > 0);
    fclose($output_handle);
}
Esempio n. 4
0
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;
}