function generateViews($fid, $uid, $groups, $frid = "0", $currentView, $loadedView = "", $view_groupscope, $view_globalscope, $prevview = "", $loadOnlyView = 0, $screen, $lastLoaded)
{
    global $xoopsDB;
    $limitViews = false;
    $screenLimitViews = array();
    $forceLastLoaded = false;
    if ($screen) {
        $screenLimitViews = $screen->getVar('limitviews');
        if (!in_array("allviews", $screenLimitViews)) {
            $limitViews = true;
            // IF LIMIT VIEWS IS IN EFFECT, THEN CHECK FOR BASIC VIEWS BEING ENABLED, AND IF THEY ARE NOT, THEN WE NEED TO SET THE CURRENT VIEW LIST TO THE LASTLOADED
            // Excuses....This is a future todo item.  Very complex UI issues, in that user could change options, then switch to other view, then switch back and their options are missing now
            // Right now, without basic views enabled, the first view in the list comes up if an option is changed (since the basic scope cannot be reflected in the available views), so that's just confusing
            // Could have 'custom' option show up at top of list instead, just to indicate to the user that things are not the options originally loaded from that view
            if (!in_array("mine", $screenLimitViews) and !in_array("group", $screenLimitViews) and !in_array("all", $screenLimitViews) and !$_POST['loadreport']) {
                // if the basic views are not present, and the user hasn't specifically changed the current view list
                $forceLastLoaded = true;
            } else {
                $forceLastLoaded = false;
            }
        }
    }
    $options = !$limitViews ? "<option value=\"\">" . _formulize_DE_STANDARD_VIEWS . "</option>\n" : "";
    $vcounter = 0;
    if ($loadOnlyView and $loadedView and !$limitViews) {
        $vcounter++;
        $options .= "<option value=\"\">&nbsp;&nbsp;" . _formulize_DE_NO_STANDARD_VIEWS . "</option>\n";
    }
    if ($currentView == "mine" and !$loadOnlyView and (!$limitViews or in_array("mine", $screenLimitViews))) {
        $options .= "<option value=mine selected>&nbsp;&nbsp;" . _formulize_DE_MINE . "</option>\n";
        $vcounter++;
    } elseif (!$loadOnlyView and (!$limitViews or in_array("mine", $screenLimitViews))) {
        $vcounter++;
        $options .= "<option value=mine>&nbsp;&nbsp;" . _formulize_DE_MINE . "</option>\n";
    }
    if ($currentView == "group" and $view_groupscope and !$loadOnlyView and (!$limitViews or in_array("group", $screenLimitViews))) {
        $options .= "<option value=group selected>&nbsp;&nbsp;" . _formulize_DE_GROUP . "</option>\n";
        $vcounter++;
    } elseif ($view_groupscope and !$loadOnlyView and (!$limitViews or in_array("group", $screenLimitViews))) {
        $vcounter++;
        $options .= "<option value=group>&nbsp;&nbsp;" . _formulize_DE_GROUP . "</option>\n";
    }
    if ($currentView == "all" and $view_globalscope and !$loadOnlyView and (!$limitViews or in_array("all", $screenLimitViews))) {
        $options .= "<option value=all selected>&nbsp;&nbsp;" . _formulize_DE_ALL . "</option>\n";
        $vcounter++;
    } elseif ($view_globalscope and !$loadOnlyView and (!$limitViews or in_array("all", $screenLimitViews))) {
        $vcounter++;
        $options .= "<option value=all>&nbsp;&nbsp;" . _formulize_DE_ALL . "</option>\n";
    }
    // check for pressence of advanced scope
    if (strstr($currentView, ",") and !$loadedView and !$limitViews) {
        $vcounter++;
        $groupNames = groupNameList(trim($currentView, ","));
        $options .= "<option value={$currentView} selected>&nbsp;&nbsp;" . _formulize_DE_AS_ENTRIESBY . printSmart($groupNames) . "</option>\n";
    } elseif (($view_globalscope or $view_groupscope) and !$loadOnlyView and !$limitViews) {
        $vcounter++;
        $pickgroups = $vcounter;
        $options .= "<option value=\"\">&nbsp;&nbsp;" . _formulize_DE_AS_PICKGROUPS . "</option>\n";
    }
    // check for available reports/views
    list($s_reports, $p_reports, $ns_reports, $np_reports) = availReports($uid, $groups, $fid, $frid);
    $lastStandardView = $vcounter;
    if (!$limitViews) {
        // cannot pick saved views in the screen UI so these will never be available if views are being limited
        if ((count($s_reports) > 0 or count($ns_reports) > 0) and !$limitViews) {
            // we have saved reports...
            $options .= "<option value=\"\">" . _formulize_DE_SAVED_VIEWS . "</option>\n";
            $vcounter++;
        }
        for ($i = 0; $i < count($s_reports); $i++) {
            if ($loadedView == "sold_" . $s_reports[$i]['report_id'] or $prevview == "sold_" . $s_reports[$i]['report_id']) {
                $vcounter++;
                $options .= "<option value={$currentView} selected>&nbsp;&nbsp;" . stripslashes($s_reports[$i]['report_name']) . "</option>\n";
                // " (id: " . $s_reports[$i]['report_id'] . ")</option>\n";
                $loadviewname = $s_reports[$i]['report_name'];
                $curviewid = "sold_" . $s_reports[$i]['report_id'];
            } else {
                $vcounter++;
                $options .= "<option value=sold_" . $s_reports[$i]['report_id'] . ">&nbsp;&nbsp;" . stripslashes($s_reports[$i]['report_name']) . "</option>\n";
                // " (id: " . $s_reports[$i]['report_id'] . ")</option>\n";
            }
        }
        for ($i = 0; $i < count($ns_reports); $i++) {
            if ($loadedView == "s" . $ns_reports[$i]['sv_id'] or $prevview == "s" . $ns_reports[$i]['sv_id']) {
                $vcounter++;
                $options .= "<option value={$currentView} selected>&nbsp;&nbsp;" . stripslashes($ns_reports[$i]['sv_name']) . "</option>\n";
                // " (id: " . $ns_reports[$i]['sv_id'] . ")</option>\n";
                $loadviewname = $ns_reports[$i]['sv_name'];
                $curviewid = "s" . $ns_reports[$i]['sv_id'];
            } else {
                $vcounter++;
                $options .= "<option value=s" . $ns_reports[$i]['sv_id'] . ">&nbsp;&nbsp;" . stripslashes($ns_reports[$i]['sv_name']) . "</option>\n";
                // " (id: " . $ns_reports[$i]['sv_id'] . ")</option>\n";
            }
        }
    }
    if ((count($p_reports) > 0 or count($np_reports) > 0) and !$limitViews) {
        // we have saved reports...
        $options .= "<option value=\"\">" . _formulize_DE_PUB_VIEWS . "</option>\n";
        $vcounter++;
    }
    $firstPublishedView = $vcounter + 1;
    if (!$limitViews) {
        // old reports are not selectable in the screen UI so will never be in the limit list
        for ($i = 0; $i < count($p_reports); $i++) {
            if ($loadedView == "pold_" . $p_reports[$i]['report_id'] or $prevview == "pold_" . $p_reports[$i]['report_id']) {
                $vcounter++;
                $options .= "<option value={$currentView} selected>&nbsp;&nbsp;" . stripslashes($p_reports[$i]['report_name']) . "</option>\n";
                // " (id: " . $p_reports[$i]['report_id'] . ")</option>\n";
                $loadviewname = $p_reports[$i]['report_name'];
                $curviewid = "pold_" . $p_reports[$i]['report_id'];
            } else {
                $vcounter++;
                $options .= "<option value=pold_" . $p_reports[$i]['report_id'] . ">&nbsp;&nbsp;" . stripslashes($p_reports[$i]['report_name']) . "</option>\n";
                // " (id: " . $p_reports[$i]['report_id'] . ")</option>\n";
            }
        }
    }
    $publishedViewNames = array();
    for ($i = 0; $i < count($np_reports); $i++) {
        if (!$limitViews or in_array($np_reports[$i]['sv_id'], $screenLimitViews)) {
            if ($loadedView == "p" . $np_reports[$i]['sv_id'] or $prevview == "p" . $np_reports[$i]['sv_id'] or $forceLastLoaded and $lastLoaded == "p" . $np_reports[$i]['sv_id']) {
                $vcounter++;
                $options .= "<option value={$currentView} selected>&nbsp;&nbsp;" . stripslashes($np_reports[$i]['sv_name']) . "</option>\n";
                // " (id: " . $np_reports[$i]['sv_id'] . ")</option>\n";
                $loadviewname = $np_reports[$i]['sv_name'];
                $curviewid = "p" . $np_reports[$i]['sv_id'];
            } else {
                $vcounter++;
                $options .= "<option value=p" . $np_reports[$i]['sv_id'] . ">&nbsp;&nbsp;" . stripslashes($np_reports[$i]['sv_name']) . "</option>\n";
                // " (id: " . $np_reports[$i]['sv_id'] . ")</option>\n";
            }
            $publishedViewNames["p" . $np_reports[$i]['sv_id']] = stripslashes($np_reports[$i]['sv_name']);
            // used by the screen system to create a variable for each view name, and only the last loaded view is set to true.
        }
    }
    $to_return[0] = $options;
    $to_return[1] = $firstPublishedView;
    $to_return[2] = $lastStandardView;
    $to_return[3] = $pickgroups;
    $to_return[4] = $loadviewname;
    $to_return[5] = $curviewid;
    $to_return[6] = $publishedViewNames;
    return $to_return;
}
Example #2
0
print "<HTML>";
print "<head>";
print "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=" . _CHARSET . "\" />";
print "<title>" . _formulize_DE_SAVEVIEW . "</title>\n";
print "<link rel=\"stylesheet\" type=\"text/css\" media=\"screen\" href=\"" . XOOPS_URL . "/xoops.css\" />\n";
$themecss = xoops_getcss();
//$themecss = substr($themecss, 0, -6);
//$themecss .= ".css";
print "<link rel=\"stylesheet\" type=\"text/css\" media=\"screen\" href=\"{$themecss}\" />\n";
print "</head>";
print "<body style=\"background: white; margin-top:20px;\"><center>";
print "<table width=100%><tr><td width=5%></td><td width=90%>";
$saveform = new xoopsThemeForm(_formulize_DE_SAVEVIEW, 'saveoptions', XOOPS_URL . "/modules/formulize/include/save.php?fid={$fid}&frid={$frid}&lastloaded={$lastloaded}&cols={$getcols}&currentview={$currentview}");
// need to build the list of available reports that can be saved.
// available are all their own saved reports, plus all published IF they have can update others turned on.
list($s_reports, $p_reports, $ns_reports, $np_reports) = availReports($uid, $groups, $fid, $frid);
// we are ignoring update_own_reports permission for now -- everyone can update their own reports
if ($update_other_reports = $gperm_handler->checkRight("update_other_reports", $fid, $groups, $mid)) {
    // figure out which published reports belong to others, and include them in the list of reports we can update
    foreach ($p_reports as $details) {
        if ($details['report_uid'] != $uid) {
            $other_p_reports[] = $details;
        }
    }
    foreach ($np_reports as $details) {
        if ($details['sv_uid'] != $uid) {
            $other_np_reports[] = $details;
        }
    }
}
list($saveoptions, $defaultSave) = makeSaveList($s_reports, $ns_reports, $other_p_reports, $other_np_reports, $lastloaded, $viewselection);