public function saveCronPostSchedule() { if ($this->template->is_ajax()) { $failure_answer = ['success' => false, 'message' => lang('saving_error')]; $post = $post = $this->input->post(); if ($post) { $cron_post = Social_post_cron::inst($post['id']); if ($cron_post->exists()) { $cron_post->setTimeInUtc($post['cron_schedule_time'], $cron_post->timezone); $days = Cron_day::inst()->where_in('day', $post['cron_day'])->get(); $cron_post->delete($cron_post->cron_day->get()->all, 'cron_day'); if ($cron_post->save($days->all, 'cron_day')) { $answer = ['success' => true, 'message' => lang('saving_success')]; echo json_encode($answer); } else { echo json_encode($failure_answer); } } else { echo json_encode($failure_answer); } } else { echo json_encode($failure_answer); } } exit; }
public function add_cron_post($post) { if ($this->template->is_ajax()) { $post['post_to_groups'] = array($this->profile->id); $post['timezone'] = User_timezone::get_user_timezone($this->c_user->id); $post['user_id'] = $this->c_user->id; $errors = Social_post::validate_post($post); if (empty($errors)) { $errors = Social_post_cron::validate_cron($post); if (empty($errors)) { Social_post_cron::add_new_post($post, $this->c_user->id, $this->profile->id); $result['success'] = true; $result['message'] = lang('post_was_successfully_added'); } else { $result['success'] = false; $result['errors'] = $errors; } } else { $result['success'] = false; $result['errors'] = $errors; } echo json_encode($result); } exit; }