示例#1
0
/**
 * This function used to handle updating the configuration.
 *@return boolean
 */
function UpdatePostieConfig($data)
{
    UpdatePostiePermissions($data["role_access"]);
    // We also update the cron settings
    if ($data['interval'] != '') {
        postie_decron();
        if ($data['interval'] != 'manual') {
            postie_cron($interval = $data['interval']);
        }
    }
    return 1;
}
/**
 * This function handles updating the configuration 
 *@return boolean
 */
function UpdatePostieConfig($data)
{
    SetupConfiguration();
    $key_arrays = GetListOfArrayConfig();
    $config = GetDBConfig();
    foreach ($config as $key => $value) {
        if (isset($data[$key])) {
            if (in_array($key, $key_arrays)) {
                //This is stored as an array
                $data[$key] = trim($data[$key]);
                if (strstr($data[$key], "\n")) {
                    $delim = "\n";
                } else {
                    $delim = ',';
                }
                $config[$key] = array();
                $values = explode($delim, $data[$key]);
                foreach ($values as $item) {
                    if (trim($item)) {
                        $config[$key][] = trim($item);
                    }
                }
            } else {
                $config[$key] = FilterNewLines($data[$key]);
            }
        }
    }
    WriteConfig($config);
    UpdatePostiePermissions($data["ROLE_ACCESS"]);
    // If we are using cronless, we also update the cronless events
    if ($config['CRONLESS'] != '') {
        postie_decron();
        postie_cron();
    }
    return 1;
}
示例#3
0
function postie_cron($interval = false)
{
    //Do not echo output in filters, it seems to break some installs
    //error_log("postie_cron: setting up cron task: $interval");
    //$schedules = wp_get_schedules();
    //error_log("postie_cron\n" . print_r($schedules, true));
    if (!$interval) {
        $config = config_Read();
        $interval = $config['interval'];
        //error_log("postie_cron: setting up cron task from config: $interval");
    }
    if (!$interval || $interval == '') {
        $interval = 'hourly';
        //error_log("Postie: setting up cron task: defaulting to hourly");
    }
    if ($interval == 'manual') {
        postie_decron();
        //error_log("postie_cron: clearing cron (manual)");
    } else {
        if ($interval != wp_get_schedule('check_postie_hook')) {
            postie_decron();
            //remove existing
            //try to create the new schedule with the first run in 5 minutes
            if (false === wp_schedule_event(time() + 5 * 60, $interval, 'check_postie_hook')) {
                //error_log("postie_cron: Failed to set up cron task: $interval");
            } else {
                //error_log("postie_cron: Set up cron task: $interval");
            }
        } else {
            //error_log("postie_cron: OK: $interval");
            //don't need to do anything, cron already scheduled
        }
    }
}