diff --git a/www/README.md b/www/README.md index 6a36455..bbd921e 100644 --- a/www/README.md +++ b/www/README.md @@ -7,8 +7,7 @@ For your final project you will work in teams of 2 to build a fully-functioning 2. Login (session management) 3. User profile page with the users’ tweets. 4. View tweets from all users. -5. Ability to “Like” tweets when logged-in -6. Ability to search all tweets. +5. Ability to search all tweets. ### Optional Features 1. DMs diff --git a/www/application/config/database.php b/www/application/config/database.php index 6c634b5..4d3bb20 100755 --- a/www/application/config/database.php +++ b/www/application/config/database.php @@ -70,7 +70,10 @@ | The $query_builder variables lets you determine whether or not to load | the query builder class. */ -$active_group = 'default'; +if ($_SERVER['HTTP_HOST'] == 'web.digitalmediauconn.org') + $active_group = 'production'; +else $active_group = 'default'; + $query_builder = TRUE; $db['default'] = array( diff --git a/www/application/controllers/Register.php b/www/application/controllers/Register.php index 7ff25a4..a9f7707 100644 --- a/www/application/controllers/Register.php +++ b/www/application/controllers/Register.php @@ -1,18 +1,25 @@ load->database(); // load database + $this->load->model('User_Info_Model'); // load model + $this->output->enable_profiler(TRUE); + } + public function index(){ $this->load->helper(array('form', 'url')); $this->load->library('form_validation'); - $this->form_validation->set_rules('name', 'Name', 'required'); + $this->form_validation->set_rules('firstname', 'First Name', 'required'); + $this->form_validation->set_rules('lastname', 'Last Name', 'required'); + $this->form_validation->set_rules('location', 'Location', 'required'); $this->form_validation->set_rules('email', 'Email', 'required'); $this->form_validation->set_rules('username', 'Username', 'required'); $this->form_validation->set_rules('password', 'Password', 'required', array('required' => 'You must provide a %s.')); - $this->form_validation->set_rules('email', 'Email', 'required'); - $this->form_validation->set_rules('email', 'Email', 'required|valid_email'); if ($this->form_validation->run() == FALSE) @@ -21,6 +28,7 @@ public function index(){ // load the homepage once properly submitted // https://www.codeigniter.com/user_guide/libraries/form_validation.html#callbacks-your-own-validation-methods else { + $this->User_Info_Model->addUser(); $this->load->view('formsuccess'); } } diff --git a/www/application/controllers/User_Tweets.php b/www/application/controllers/User_Tweets.php index 3f202b6..e5b6fb6 100644 --- a/www/application/controllers/User_Tweets.php +++ b/www/application/controllers/User_Tweets.php @@ -1,15 +1,21 @@ -load->database(); - $this->load->model('User_Tweets_Model'); - $this->output->enable_profiler(TRUE); - } +class User_Tweets extends CI_Controller { - public function index(){ - $this->data['posts'] = $this->User_Tweets_Model->getPosts(); - $this->load->view('user', $this->data); - } + function __Construct(){ + parent::__Construct(); + //$this->load->library('session'); + $this->load->database(); // load database + $this->load->model('User_Tweets_Model'); // load model + $this->output->enable_profiler(TRUE); } + + public function index() { + $this->data['posts'] = $this->User_Tweets_Model->getPosts(); // calling Post model method getPosts() + $this->load->view('templates/header', NULL); + $this->load->view('user', $this->data); // load the view file , we are passing $data array to view file + $this->load->view('templates/footer', NULL); + } + +} diff --git a/www/application/models/User_Tweets_Model.php b/www/application/models/User_Tweets_Model.php index 81f7858..6292bf0 100644 --- a/www/application/models/User_Tweets_Model.php +++ b/www/application/models/User_Tweets_Model.php @@ -1,19 +1,36 @@ db->select("first_name, last_name, username, tweet, date_time"); + $this->db->from('Users, Tweets'); + $this->db->where('Users.id = Tweets.user_id'); + $this->db->order_by('date_time', 'DESC'); + $query = $this->db->get(); + return $query->result_array(); + } - function getPosts(){ + function addTweet(){ + $this->load->helper('url'); - //$this->load->library('session'); - //session_start(); - $user_id = 1; //$this->session->userdata('session_id'); + $slug = url_title($this->input->post('title'), 'dash', TRUE); - $this->db->select("first_name, last_name, username, tweet, date_time, location"); - $this->db->from("Users, Tweets"); - $this->db->where("Users.id = Tweets.user_id and Users.id = $user_id"); - $this->db->order_by('date_time', 'DESC'); - $query = $this->db->get(); - return $query->result_array(); - } + $data = array( + 'tweet' => $this->input->post('tweet'), + 'date_time' => 10, + 'user_id' => 1 + ); + + return $this->db->insert('Tweets', $data); + /* + $this->load->helper('url'); + $data = array( + 'tweet' => $this->input->post('tweet') + ); + + return $this->db->insert('tweets', $data); + */ + } } diff --git a/www/application/views/formsuccess.php b/www/application/views/formsuccess.php index eb2f877..ac1472b 100644 --- a/www/application/views/formsuccess.php +++ b/www/application/views/formsuccess.php @@ -1,3 +1 @@

Your form was successfully submitted!

- -

diff --git a/www/application/views/register.php b/www/application/views/register.php index 82111bb..cb638b4 100644 --- a/www/application/views/register.php +++ b/www/application/views/register.php @@ -3,14 +3,22 @@ echo validation_errors(); echo form_open('register'); ?> -
Name
- - +
First Name
+ + + +
Last Name
+ +
Email Address
+
Location
+ + +
Username
diff --git a/www/application/views/user.php b/www/application/views/user.php index b066d4f..1accc25 100644 --- a/www/application/views/user.php +++ b/www/application/views/user.php @@ -1,34 +1,5 @@ - - - - - User Tweets - - - - +

Tweets Feed

- load->library('form_validation'); - echo validation_errors(); - echo form_open('user_tweets'); ?> - -
-
-
-
Tweet
- - - -
- - - -
@@ -44,6 +15,3 @@
- - -