Exemplo n.º 1
0
 /**
  * bit.ly module's settings
  * @todo Show default tweet value after resetting it!
  */
 public function index()
 {
     $form = twitter::get_configure_form();
     if (request::method() == "post") {
         access::verify_csrf();
         if ($form->validate()) {
             $consumer_key = $form->twitter_oauth->consumer_key->value;
             $consumer_secret = $form->twitter_oauth->consumer_secret->value;
             $reset_tweet = $form->twitter_message->reset_tweet->value;
             if ($reset_tweet) {
                 $default_tweet = twitter::reset_default_tweet();
             } else {
                 $default_tweet = $form->twitter_message->default_tweet->value;
             }
             $shorten_urls = $form->urls->shorten_urls->value;
             module::set_var("twitter", "consumer_key", $consumer_key);
             module::set_var("twitter", "consumer_secret", $consumer_secret);
             module::set_var("twitter", "default_tweet", $default_tweet);
             module::set_var("twitter", "shorten_urls", $shorten_urls);
             message::success("Twitter settings saved");
             url::redirect("admin/twitter");
         }
     }
     $is_registered = twitter::is_registered();
     $v = new Admin_View("admin.html");
     $v->page_title = t("Twitter");
     $v->content = new View("admin_twitter.html");
     $v->content->form = $form;
     $v->content->is_registered = $is_registered;
     print $v;
 }