Skip to content

Commit

Permalink
merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
Shemona Singh authored and Shemona Singh committed Dec 4, 2017
2 parents 3c30c51 + 14377c9 commit a892989
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 67 deletions.
3 changes: 1 addition & 2 deletions www/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion www/application/config/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
14 changes: 11 additions & 3 deletions www/application/controllers/Register.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
<?php

class Register extends CI_Controller {
function __Construct(){
parent::__Construct();
$this->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)
Expand All @@ -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');
}
}
Expand Down
30 changes: 18 additions & 12 deletions www/application/controllers/User_Tweets.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
<?php defined('BASEPATH') OR exit('No direct script access allowed');
class User_Tweets extends CI_Controller {
function __Construct(){
parent::__Construct ();
<?php
defined('BASEPATH') OR exit('No direct script access allowed');

$this->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);
}

}
39 changes: 28 additions & 11 deletions www/application/models/User_Tweets_Model.php
Original file line number Diff line number Diff line change
@@ -1,19 +1,36 @@
<?php
class User_Tweets_Model extends CI_Model {
function getPosts(){
//$_SESSION['user_id'] = $id;
$this->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);
*/
}

}
2 changes: 0 additions & 2 deletions www/application/views/formsuccess.php
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
<h3>Your form was successfully submitted!</h3>

<p><?php echo anchor('form', 'Try it again!'); ?></p>
14 changes: 11 additions & 3 deletions www/application/views/register.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,22 @@
echo validation_errors();
echo form_open('register'); ?>

<h5>Name</h5>
<input type="text" name="name" value="<?php echo set_value('name'); ?>" size="50" />
<?php echo form_error('name'); ?>
<h5>First Name</h5>
<input type="text" name="firstname" value="<?php echo set_value('firstname'); ?>" size="50" />
<?php echo form_error('firstname'); ?>

<h5>Last Name</h5>
<input type="text" name="lastname" value="<?php echo set_value('lastname'); ?>" size="50" />
<?php echo form_error('lastname'); ?>

<h5>Email Address</h5>
<input type="text" name="email" value="<?php echo set_value('email'); ?>" size="50" />
<?php echo form_error('email'); ?>

<h5>Location</h5>
<input type="text" name="location" value="<?php echo set_value('location'); ?>" size="50" />
<?php echo form_error('location'); ?>

<h5>Username</h5>
<input type="text" name="username" value="<?php echo set_value('username'); ?>" size="50" />
<?php echo form_error('username'); ?>
Expand Down
34 changes: 1 addition & 33 deletions www/application/views/user.php
Original file line number Diff line number Diff line change
@@ -1,34 +1,5 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
?><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>User Tweets</title>
<style type="text/css">

</style>
</head>
<body>

<?php defined('BASEPATH') OR exit('No direct script access allowed'); ?>
<h1>Tweets Feed</h1>
<?php
$this->load->library('form_validation');
echo validation_errors();
echo form_open('user_tweets'); ?>

<div class="container">
<div class="row">
<div class="col-md-2 col-md-offset-5">
<h5>Tweet</h5>
<input type="text" name="tweet" value="<?php echo set_value('tweet'); ?>" size="50" />
<?php echo form_error('tweet'); ?>
<input type="hidden" name="user_id" value="<?php echo 'id' // USER ID HERE for tweet creation ?>">
<div><input class="btn" type="submit" value="Submit"/></div>
</form>



<div class="container">
<div class="row">
<?php foreach($posts as $post){?>
Expand All @@ -44,6 +15,3 @@
<?php }?>
</div>
</div>

</body>
</html>

0 comments on commit a892989

Please sign in to comment.