static function install() { Database::instance()->query("CREATE TABLE {twitter_tweets} (\n `id` int(9) NOT NULL AUTO_INCREMENT,\n `item_id` int(9) NOT NULL,\n `sent` int(9) NULL,\n `twitter_id` decimal(20,0) NULL,\n `tweet` varchar(255) NOT NULL,\n `user_id` int(9) NOT NULL,\n PRIMARY KEY (`id`))\n DEFAULT CHARSET=utf8;"); Database::instance()->query("CREATE TABLE {twitter_users} (\n `id` int(9) NOT NULL AUTO_INCREMENT,\n `oauth_token` varchar(64) NOT NULL,\n `oauth_token_secret` varchar(64) NOT NULL,\n `screen_name` varchar(16) NOT NULL,\n `twitter_user_id` int(9) NOT NULL,\n `user_id` int(9) NOT NULL,\n PRIMARY KEY (`id`))\n DEFAULT CHARSET=utf8;"); module::set_version("twitter", 1); twitter::reset_default_tweet(); }
/** * 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; }