Skip to content

Instantly share code, notes, and snippets.

@luisliz
Created January 12, 2013 19:45
Show Gist options
  • Save luisliz/4520168 to your computer and use it in GitHub Desktop.
Save luisliz/4520168 to your computer and use it in GitHub Desktop.
Notice controller to notice model
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Notice extends CI_Model {
function view($page) {
21 $array = array();
$this->load->library('parser');
if($this->session->flashdata('tankauth_allow_notice')) {
// Check for $data
if($this->session->flashdata('tankauth_notice_data')) extract($this->session->flashdata('tankauth_notice_data'));
switch($page){
// Registration
case 'registration-success':
$data['page_title'] = 'Successful Registration';
$array['title'] = 'Successful Registration';
break;
case 'registration-disabled':
$data['page_title'] = 'Registration Disabled';
$array['title'] = 'Registration Disabled';
break;
// Activation
case 'activation-sent':
$data['email'] = $email;
$data['page_title'] = 'Activation Email Sent';
$array['title'] = 'Activation Email Sent';
break;
case 'activation-complete':
$data['login_link'] = base_url('auth/login');
$data['page_title'] = 'Activation Complete';
$array['title'] = 'Activation Complete';
break;
case 'activation-failed':
$data['page_title'] = 'Activation Failed';
$array['title'] = 'Activation Failed';
break;
// Password
case 'password-changed':
$data['page_title'] = 'Password Changed';
$array['title'] = 'Password Changed';
break;
case 'password-sent':
$data['page_title'] = 'New Password Sent';
$array['title'] = 'New Password Sent';
break;
case 'password-reset':
$data['page_title'] = 'Password Reset';
$array['title'] = 'Password Reset';
break;
case 'password-failed':
$data['page_title'] = 'Password Failed';
$array['title'] = 'Password Failed';
break;
// Email
case 'email-sent':
$data['email'] = $new_email;
$data['page_title'] = 'Confirmation Email Sent';
$array['title'] = 'Confirmation Email Sent';
break;
case 'email-activated':
$data['login_link'] = base_url('/login');
$data['page_title'] = 'Your Email has been Activated';
$array['title'] = 'Your Email has been Activated';
break;
case 'email-failed':
$data['page_title'] = 'Email Sending Failed';
$array['title'] = 'Email Sending Failed';
break;
// User + Account
case 'user-banned':
$data['page_title'] = 'You have been Banned.';
$data['ban_reason'] = $ban_reason;
$array['title'] = 'You have been Banned.';
break;
case 'user-deleted':
$data['page_title'] = 'Your account has been Deleted.';
$array['title'] = 'Your account has been Deleted.';
break;
case 'acct-unapproved':
$data['logout_link'] = base_url('auth/logout');
$data['page_title'] = 'Account not yet Approved';
$array['title'] = 'Account not yet Approved';
break;
case 'logout-success':
$data['page_title'] = 'Logged Out';
$array['title'] = 'Logged Out';
break;
default:
show_404();
}
if($this->session->flashdata('is_logged_out')) $this->tank_auth->logout();
$data['body_class'] = $page;
$array['parse'] = $this->parser->parse('landing/'.$page, $data, TRUE);
return $array;
} else {
redirect('/');
}
}
}
/* End of file notice.php */
/* Location: ./application/models/notice.php */
<!--the view that just shows the data-->
<?= $data ?>
<?php
//function in the Controller that handles notices
function notice() {
$page = $this->uri->segment(3);
$this->load->model('notice');
$view = $this->notice->view($page);21
$data['title'] = $view['title'];
$data['data'] = $view['parse'];
$this->load->view('view_notice');
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment