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
$getcols = $_GET['cols'];
$loadOnlyView = $_GET['loadonlyview'];
$cols = explode(",", $_GET['cols']);
// what is this for?
$currentview = $_GET['currentview'];
$view_groupscope = $gperm_handler->checkRight("view_groupscope", $fid, $groups, $mid);
$view_globalscope = $gperm_handler->checkRight("view_globalscope", $fid, $groups, $mid);
$publish_reports = $gperm_handler->checkRight("publish_reports", $fid, $groups, $mid);
$publish_globalscope = $gperm_handler->checkRight("publish_globalscope", $fid, $groups, $mid);
if (strstr($_GET['currentview'], ",")) {
    $specificgroups = explode(",", trim($_GET['currentview'], ","));
    if ($publish_reports or $publish_globalscope) {
        $groupNames = groupNameList(trim($_GET['currentview'], ","), false);
        // false forces all groups to be got even if the "onlymembergroups" flag is present
    } else {
        $groupNames = groupNameList(trim($_GET['currentview'], ","));
    }
}
// main body of page goes here...
include_once XOOPS_ROOT_PATH . "/class/xoopsformloader.php";
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>";