public function run($arguments) { $arguments = Ithemes_Sync_Functions::merge_defaults($arguments, $this->default_arguments); if (true !== backupbuddy_api::addSchedule($arguments['title'], $arguments['profile'], $arguments['interval'], $arguments['firstRun'], $arguments['destinations'], $arguments['deleteAfter'], $arguments['enabled'])) { return array('api' => '0', 'status' => 'error', 'message' => 'Error #378235: Creating schedule failed. A plugin may have blocked scheduling with WordPress. Details: ' . backupbuddy_api::$lastError); } else { return array('api' => '0', 'status' => 'ok', 'message' => 'Schedule added successfully.', 'scheduleID' => (int) (pb_backupbuddy::$options['next_schedule_index'] - 1)); } }
$error = true; } $remote_destinations = trim($submitted_schedule['data']['remote_destinations'], '|'); $remote_destinations = explode('|', $remote_destinations); if ('1' == $submitted_schedule['data']['delete_after']) { $delete_after = true; } else { $delete_after = false; } if ('1' == $submitted_schedule['data']['on_off']) { $enabled = true; } else { $enabled = false; } if ($error === false) { $add_response = backupbuddy_api::addSchedule($title = $submitted_schedule['data']['title'], $profile = $submitted_schedule['data']['profile'], $interval = $submitted_schedule['data']['interval'], $first_run = pb_backupbuddy::$format->unlocalize_time(strtotime($submitted_schedule['data']['first_run'])), $remote_destinations, $delete_after, $enabled); if (true !== $add_response) { pb_backupbuddy::alert('Error scheduling: ' . $add_response); } else { // Success pb_backupbuddy::save(); $schedule_form->clear_values(); pb_backupbuddy::alert('Added new schedule `' . htmlentities($submitted_schedule['data']['title']) . '`.'); } } } else { // EDIT SCHEDULE. Form handles saving; just need to update timestamp. $first_run = pb_backupbuddy::$format->unlocalize_time(strtotime($submitted_schedule['data']['first_run'])); if ($first_run == 0 || $first_run == 18000) { pb_backupbuddy::alert(sprintf(__('Invalid time format. Please use the specified format / example %s', 'it-l10n-backupbuddy'), $date_format_example)); $error = true;
$add_response = backupbuddy_api::addSchedule($title, $profile = '2', $interval = 'monthly', $first_run = time() + get_option('gmt_offset') * 3600 + 86400 + 18000, $remote_destinations = array($destination_id)); if (true !== $add_response) { $errors[] = $add_response; } } } // BLOGGER if ('blogger' == $form['schedule']) { $title = 'Daily Database (Quick Setup - Blogger)'; if (false === pb_backupbuddy_schedule_exist_by_title($title)) { $add_response = backupbuddy_api::addSchedule($title, $profile = '1', $interval = 'daily', $first_run = time() + get_option('gmt_offset') * 3600 + 86400, $remote_destinations = array($destination_id)); if (true !== $add_response) { $errors[] = $add_response; } } $title = 'Weekly Full (Quick Setup - Blogger)'; if (false === pb_backupbuddy_schedule_exist_by_title($title)) { $add_response = backupbuddy_api::addSchedule($title, $profile = '2', $interval = 'weekly', $first_run = time() + get_option('gmt_offset') * 3600 + 86400 + 18000, $remote_destinations = array($destination_id)); if (true !== $add_response) { $errors[] = $add_response; } } } } // end set schedule. if (0 == count($errors)) { pb_backupbuddy::save(); die('Success.'); } else { die(implode("\n", $errors)); }