Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
twitter-clone/www/application/controllers/User_Tweets.php
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
49 lines (41 sloc)
1.52 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
defined('BASEPATH') OR exit('No direct script access allowed'); | |
class User_Tweets extends CI_Controller { | |
function __Construct(){ | |
parent::__Construct(); | |
$this->load->database(); // load database | |
$this->load->model('User_Tweets_Model'); // load model | |
$this->load->helper('url'); | |
} | |
public function index() { | |
// get posts based on user ID | |
$this->data['posts'] = $this->User_Tweets_Model->getPosts(); // calling Post model method getPosts() | |
$this->load->view('templates/header', NULL); | |
$this->load->view('templates/nav', 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); | |
} | |
public function create(){ | |
$this->load->helper(array('form', 'url')); | |
$this->load->library('form_validation'); | |
$this->form_validation->set_rules('tweet', 'Tweet', 'required'); | |
if ($this->form_validation->run() === FALSE) | |
{ | |
$this->data['posts'] = $this->User_Tweets_Model->getPosts(); // calling Post model method getPosts() | |
$this->load->view('templates/header', NULL); | |
$this->load->view('templates/nav'); | |
$this->load->view('user', $this->data); // load the view file , we are passing $data array to view file | |
$this->load->view('templates/footer', NULL); | |
} | |
else | |
{ | |
$this->User_Tweets_Model->addTweet(); | |
redirect("/User_Tweets"); | |
} | |
} | |
public function logout(){ | |
$this->load->helper('url'); | |
$this->session->sess_destroy(); | |
redirect("/login"); | |
} | |
} |