Ejemplo n.º 1
17
function ReadPostData($ReportID, $Prefs)
{
    global $db;
    // check for page setup form entry to look at check boxes and save as new defaults, return
    if (isset($_POST['PageForm'])) {
        $success = SavePrefs($ReportID);
        // values saved, read them back in to update $Prefs array
        $sql = "SELECT *\tFROM " . DBReports . " WHERE id = '" . $ReportID . "'";
        $Result = DB_query($sql, $db, '', '', false, true);
        $myrow = DB_fetch_assoc($Result);
        foreach ($myrow as $key => $value) {
            $Prefs[$key] = $value;
        }
        return $Prefs;
    }
    // Since we are not at the page setup form, we read from the filter form, fetch user selections
    $Prefs['DateListings']['params'] = $_POST['DefDate'];
    if ($_POST['DefDate'] == 'b') {
        // then it's a range selection, save dates, else discard
        $Prefs['DateListings']['params'] .= ':' . $_POST['DefDateFrom'] . ':' . $_POST['DefDateTo'];
    }
    $Prefs['defgroup'] = $_POST['DefGroup'];
    $Prefs['defsort'] = $_POST['DefSort'];
    $Prefs['TruncListings']['params'] = $_POST['DefTrunc'];
    if (!$Prefs['defaultreport']) {
        // Then save the filter settings because it's a custom report and we save them
        $success = SaveFilters($ReportID, 'dateselect', $Prefs['DateListings']['params']);
        $success = SaveFilters($ReportID, 'trunclong', $Prefs['TruncListings']['params']);
        if (isset($Prefs['defgroup'])) {
            $success = SaveDefSettings($ReportID, 'grouplist', $Prefs['defgroup']);
        }
        if (isset($Prefs['defsort'])) {
            $success = SaveDefSettings($ReportID, 'sortlist', $Prefs['defsort']);
        }
    }
    // update Prefs with current user selections
    if (isset($Prefs['defgroup'])) {
        // First clear all defaults and reset the user's choice
        for ($i = 0; $i < count($Prefs['GroupListings']); $i++) {
            $Prefs['GroupListings'][$i]['params'] = 0;
        }
        if ($Prefs['defgroup'] != 0) {
            $Prefs['GroupListings'][$Prefs['defgroup'] - 1]['params'] = '1';
        }
    }
    if (isset($Prefs['defsort'])) {
        // First clear all defaults and reset the user's choice
        for ($i = 0; $i < count($Prefs['SortListings']); $i++) {
            $Prefs['SortListings'][$i]['params'] = 0;
        }
        if ($Prefs['defsort'] != 0) {
            $Prefs['SortListings'][$Prefs['defsort'] - 1]['params'] = '1';
        }
    }
    // Criteria Field Selection
    $i = 1;
    while (isset($_POST['defcritsel' . $i])) {
        // then there is at least one criteria
        // Build the criteria default string
        $Prefs['CritListings'][$i - 1]['params'] = mb_substr($Prefs['CritListings'][$i - 1]['params'], 0, 1);
        $Prefs['CritListings'][$i - 1]['params'] .= ':' . $_POST['defcritsel' . $i];
        $Prefs['CritListings'][$i - 1]['params'] .= ':' . $_POST['fromvalue' . $i];
        if ($_POST['tovalue' . $i] == '') {
            $_POST['tovalue' . $i] = $_POST['fromvalue' . $i];
        }
        $Prefs['CritListings'][$i - 1]['params'] .= ':' . $_POST['tovalue' . $i];
        if (!$Prefs['defaultreport']) {
            // save it since it's a custom report
            $sql = "UPDATE " . DBRptFields . " SET params='" . $Prefs['CritListings'][$i - 1]['params'] . "'\n\t\t\t\tWHERE reportid ='" . $ReportID . "' AND entrytype='critlist' AND seqnum='" . $i . "'";
            $Result = DB_query($sql, $db, '', '', false, true);
        }
        $i++;
    }
    // If it's a default report, we're done, return
    if ($Prefs['defaultreport']) {
        return $Prefs;
    }
    // Read in the display field form selections
    $i = 1;
    while (isset($_POST['DataField' . $i])) {
        // read in the field choices
        if ($_POST['show' . $i] == '1') {
            $Prefs['FieldListings'][$i - 1]['visible'] = '1';
        } else {
            $Prefs['FieldListings'][$i - 1]['visible'] = '0';
        }
        if ($_POST['break' . $i] == '1') {
            $Prefs['FieldListings'][$i - 1]['columnbreak'] = '1';
        } else {
            $Prefs['FieldListings'][$i - 1]['columnbreak'] = '0';
        }
        $sql = "UPDATE " . DBRptFields . " SET\n\t\t\t\tvisible='" . $Prefs['FieldListings'][$i - 1]['visible'] . "',\n\t\t\t\tcolumnbreak='" . $Prefs['FieldListings'][$i - 1]['columnbreak'] . "'\n\t\t\tWHERE reportid ='" . $ReportID . "' AND entrytype='fieldlist' AND seqnum='" . $i . "'";
        $Result = DB_query($sql, $db, '', '', false, true);
        $i++;
    }
    return $Prefs;
}
Ejemplo n.º 2
0
// STEP FIVE: convert all [datadir] refs to $fbcmdBaseDir
foreach ($fbcmdPrefs as $key => $value) {
    $fbcmdPrefs[$key] = str_replace('[datadir]', $fbcmdBaseDir, $value);
}
if ($fbcmdCommand == 'BC_PREFERENCES') {
    foreach (array_keys($fbcmdPrefs) as $pref) {
        $pref = strtolower($pref);
        print "-{$pref} ";
    }
    return;
}
////////////////////////////////////////////////////////////////////////////////
if ($fbcmdCommand == 'SAVEPREF') {
    ValidateParamCount(0, 1);
    SetDefaultParam(1, "{$fbcmdBaseDir}prefs.php");
    SavePrefs($fbcmdParams[1]);
    return;
}
////////////////////////////////////////////////////////////////////////////////
$GLOBALS['facebook_config']['debug'] = $fbcmdPrefs['facebook_debug'];
////////////////////////////////////////////////////////////////////////////////
$fbcmdCommandList = array();
AddCommand('ADDALBUM', 'title [description] [location] [privacy]~Create a new photo album');
AddCommand('ADDPIC', 'filename [album_id|latest] [caption]~Upload (add) a photo to an album');
AddCommand('ADDPICD', 'dirname [album_id|latest]~Upload (add) all *.jpg files in a directory to an album');
AddCommand('ALBUMS', '[flist]~List all photo albums for friend(s)');
AddCommand('ALLINFO', 'flist~List all available profile information for friend(s)');
AddCommand('APICS', 'album_id [savedir]~List [and optionally save] all photos from an album');
AddCommand('AUTH', 'authcode~Sets your facebook authorization code');
AddCommand('COMMENT', 'post_id text~Add a comment to a story that appears in the stream');
AddCommand('DELPOST', 'post_id~Deletes a post from your stream');