public function post_tweets() { $tweets = Tweets_Model::find('all', array('status' => Tweets_Model::STATUS_NOT_SENDED, 'type' => Tweets_Model::TYPE_TIME)); foreach ($tweets as $tweet) { if (time() + $tweet->offset * 60 > $tweet->date && $tweet->status == Tweets_Model::STATUS_NOT_SENDED) { $status = $this->post_to($tweet); if (isset($status->id) && $status->id > 0) { $tweet->status = Tweets_Model::STATUS_SENDED; $tweet->save(); } else { $current_user = $tweet->user; if ($current_user) { $recipients = array(); $email_config = get_config('swiftmailer'); if (filter_var($current_user->email, FILTER_VALIDATE_EMAIL) !== FALSE) { $recipients[] = $current_user->email; } $recipients[] = $email_config['support']; $mailer = new Swiftmailer(); $mailer->send('Warbble notification', array('email' => '*****@*****.**', 'title' => 'Support'), $recipients, $mailer->get_html_tweet_message($tweet, $this->path)); $tweet->status = Tweets_Model::STATUS_FILED; $tweet->save(); } } } } }
public function edit_tweet() { if ($this->is_ajax() && isset($_POST['id'])) { $current_user = Users_Model::get_current_user(); $tweet = Tweets_Model::first(array('id' => $_POST['id'])); if ($tweet && $tweet->user_id == $current_user->user_id) { echo json_encode(array('status' => true, 'tweet' => $tweet->attributes())); } else { echo json_encode(array('status' => false)); } } exit; }