Added Cookie login. Seems to work OK
This commit is contained in:
parent
d7a76d9c53
commit
1d6aba8d90
|
|
@ -4,27 +4,39 @@
|
|||
|
||||
class AppController extends Controller {
|
||||
|
||||
var $components = array('Auth', 'RequestHandler');
|
||||
var $components = array('Auth', 'RequestHandler');
|
||||
|
||||
var $helpers = array('Javascript', 'Time', 'Html', 'Form', 'Ajax');
|
||||
function beforeFilter() {
|
||||
$this->set('currentuser', $this->Auth->user());
|
||||
var $helpers = array('Javascript', 'Time', 'Html', 'Form', 'Ajax');
|
||||
function beforeFilter() {
|
||||
$this->set('currentuser', $this->Auth->user());
|
||||
|
||||
/**
|
||||
* Define the scheme for issue Types.
|
||||
*/
|
||||
$this->set('issueTypes', array(1=>"Bug Report", 2=>"Feature Request", 3=>"Other IT Help"));
|
||||
|
||||
$priorities = array(1 => 'Low',2=>"Medium",3=>"High", 4=>"Critical");
|
||||
$this->set('issuePriorities', $priorities);
|
||||
$this->Auth->loginAction = array('controller' => 'users', 'action' => 'login');
|
||||
$this->Auth->loginRedirect = array('controller' => 'enquiries', 'action' => 'index');
|
||||
$this->Auth->allow('display');
|
||||
$this->Auth->authorize = 'controller';
|
||||
|
||||
|
||||
/**
|
||||
* Define the scheme for issue Types.
|
||||
*/
|
||||
$this->set('issueTypes', array(1=>"Bug Report", 2=>"Feature Request", 3=>"Other IT Help"));
|
||||
|
||||
$priorities = array(1 => 'Low',2=>"Medium",3=>"High", 4=>"Critical");
|
||||
$this->set('issuePriorities', $priorities);
|
||||
|
||||
|
||||
|
||||
if($this->RequestHandler->isAjax()) {
|
||||
Configure::write('debug', 0);
|
||||
}
|
||||
if($this->RequestHandler->isAjax()) {
|
||||
Configure::write('debug', 0);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function isAuthorized() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,123 +1,155 @@
|
|||
<?php
|
||||
class UsersController extends AppController {
|
||||
|
||||
var $name = 'Users';
|
||||
var $helpers = array('Html', 'Form');
|
||||
var $components = array('Acl','Auth');
|
||||
var $paginate = array(
|
||||
'Users' => array('order' => array('User.name' => 'asc'),
|
||||
'limit' => 20
|
||||
),
|
||||
'Enquiry' => array('order' => array('Enquiry.id' => 'desc'), 'limit' => 250)
|
||||
);
|
||||
var $name = 'Users';
|
||||
var $helpers = array('Html', 'Form');
|
||||
var $components = array('Acl','Auth', 'Cookie');
|
||||
var $paginate = array(
|
||||
'Users' => array('order' => array('User.name' => 'asc'),
|
||||
'limit' => 20
|
||||
),
|
||||
'Enquiry' => array('order' => array('Enquiry.id' => 'desc'), 'limit' => 250)
|
||||
);
|
||||
|
||||
function beforeFilter() {
|
||||
$this->Auth->allow('add');
|
||||
$this->set('currentuser', $this->Auth->user());
|
||||
}
|
||||
function beforeFilter() {
|
||||
$this->Auth->allow('add');
|
||||
$this->set('currentuser', $this->Auth->user());
|
||||
}
|
||||
|
||||
function login() { //Provided by the authComponent
|
||||
$this->pageTitle = ': Login';
|
||||
$this->Session->setFlash(__('Please enter your Username and Password to continue', true));
|
||||
}
|
||||
function login() { //Provided by the authComponent
|
||||
$this->pageTitle = ': Login';
|
||||
$this->Session->setFlash(__('Please enter your Username and Password to continue', true));
|
||||
|
||||
|
||||
function logout() {
|
||||
$this->redirect($this->Auth->logout());
|
||||
}
|
||||
/* Auth Cookie code from http://www.webdevelopment2.com/cakephp-auth-component-tutorial-3/ */
|
||||
//– code inside this function will execute only when autoRedirect was set to false (i.e. in a beforeFilter).
|
||||
if ($this->Auth->user()) {
|
||||
if (!empty($this->data) && $this->data['User']['remember_me']) {
|
||||
$cookie = array();
|
||||
$cookie['username'] = $this->data['User']['username'];
|
||||
$cookie['password'] = $this->data['User']['password'];
|
||||
$this->Cookie->write('Auth.User', $cookie, true, '+2 weeks');
|
||||
unset($this->data['User']['remember_me']);
|
||||
}
|
||||
$this->redirect($this->Auth->redirect());
|
||||
}
|
||||
if (empty($this->data)) {
|
||||
$cookie = $this->Cookie->read('Auth.User');
|
||||
if (!is_null($cookie)) {
|
||||
if ($this->Auth->login($cookie)) {
|
||||
// Clear auth message, just in case we use it.
|
||||
|
||||
function index() {
|
||||
$this->User->recursive = 0;
|
||||
$this->set('users', $this->paginate());
|
||||
}
|
||||
$this->Session->setFlash(__('Welcome back '.$cookie['username']), true);
|
||||
$this->Session->del('Message.auth');
|
||||
$this->redirect($this->Auth->redirect());
|
||||
} else { // Delete invalid Cookie
|
||||
$this->Cookie->del('Auth.User');
|
||||
}
|
||||
|
||||
function view($id = null) {
|
||||
if (!$id) {
|
||||
$this->Session->setFlash(__('Invalid User.', true));
|
||||
$this->redirect(array('action'=>'index'));
|
||||
}
|
||||
$this->set('user', $this->User->read(null, $id));
|
||||
$this->set('enquiries', $this->paginate('Enquiry', array('Enquiry.user_id' => $id)));
|
||||
|
||||
$statuses = $this->User->Enquiry->Status->find('all');
|
||||
$status_list = array();
|
||||
foreach ($statuses as $status) {
|
||||
$status_list[] = array($status['Status']['id'], $status['Status']['name']);
|
||||
}
|
||||
$this->set('status_list', $status_list);
|
||||
|
||||
}
|
||||
|
||||
function add() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->set('groups', $this->User->Group->find('list'));
|
||||
if (!empty($this->data)) {
|
||||
$this->User->create();
|
||||
if ($this->User->save($this->data)) {
|
||||
$this->Session->setFlash(__('The User has been saved', true));
|
||||
$this->redirect(array('action'=>'index'));
|
||||
} else {
|
||||
$this->Session->setFlash(__('The User could not be saved. Please, try again.', true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function edit($id = null) {
|
||||
if (!$id && empty($this->data)) {
|
||||
$this->Session->setFlash(__('Invalid User', true));
|
||||
$this->redirect(array('action'=>'index'));
|
||||
}
|
||||
if (!empty($this->data)) {
|
||||
if ($this->User->save($this->data)) {
|
||||
$this->Session->setFlash(__('The User has been saved', true));
|
||||
$this->redirect(array('action'=>'index'));
|
||||
} else {
|
||||
$this->Session->setFlash(__('The User could not be saved. Please, try again.', true));
|
||||
}
|
||||
}
|
||||
if (empty($this->data)) {
|
||||
$this->data = $this->User->read(null, $id);
|
||||
$this->set('groups', $this->User->Group->find('list'));
|
||||
}
|
||||
}
|
||||
function logout() {
|
||||
$this->redirect($this->Auth->logout());
|
||||
}
|
||||
|
||||
function delete($id = null) {
|
||||
if (!$id) {
|
||||
$this->Session->setFlash(__('Invalid id for User', true));
|
||||
$this->redirect(array('action'=>'index'));
|
||||
}
|
||||
if ($this->User->del($id)) {
|
||||
$this->Session->setFlash(__('User deleted', true));
|
||||
$this->redirect(array('action'=>'index'));
|
||||
}
|
||||
}
|
||||
function index() {
|
||||
$this->User->recursive = 0;
|
||||
$this->set('users', $this->paginate());
|
||||
}
|
||||
|
||||
function initpermissions() {
|
||||
function view($id = null) {
|
||||
if (!$id) {
|
||||
$this->Session->setFlash(__('Invalid User.', true));
|
||||
$this->redirect(array('action'=>'index'));
|
||||
}
|
||||
$this->set('user', $this->User->read(null, $id));
|
||||
$this->set('enquiries', $this->paginate('Enquiry', array('Enquiry.user_id' => $id)));
|
||||
|
||||
$group = $this->User->Group;
|
||||
//Allow admins to everything
|
||||
$group->id = 6;
|
||||
$this->Acl->allow($group, 'controllers');
|
||||
$statuses = $this->User->Enquiry->Status->find('all');
|
||||
$status_list = array();
|
||||
foreach ($statuses as $status) {
|
||||
$status_list[] = array($status['Status']['id'], $status['Status']['name']);
|
||||
}
|
||||
$this->set('status_list', $status_list);
|
||||
|
||||
//Manager Permission
|
||||
$group->id = 5;
|
||||
$this->Acl->allow($group, 'controllers');
|
||||
}
|
||||
|
||||
//User Permission
|
||||
$group->id = 4;
|
||||
$this->Acl->deny($group, 'controllers');
|
||||
$this->Acl->allow($group, 'controllers/Enquires/add');
|
||||
$this->Acl->allow($group, 'controllers/Enquires/edit');
|
||||
$this->Acl->allow($group, 'controllers/Enquires/view');
|
||||
$this->Acl->allow($group, 'controllers/Quotes/add');
|
||||
$this->Acl->allow($group, 'controllers/Quotes/edit');
|
||||
$this->Acl->allow($group, 'controllers/Quotes/view');
|
||||
$this->Acl->allow($group, 'controllers/QuoteProducts/add');
|
||||
function add() {
|
||||
|
||||
$this->Acl->allow($group, 'controllers/QuoteProducts/edit');
|
||||
$this->Acl->allow($group, 'controllers/QuoteProducts/view');
|
||||
$this->set('groups', $this->User->Group->find('list'));
|
||||
if (!empty($this->data)) {
|
||||
$this->User->create();
|
||||
if ($this->User->save($this->data)) {
|
||||
$this->Session->setFlash(__('The User has been saved', true));
|
||||
$this->redirect(array('action'=>'index'));
|
||||
} else {
|
||||
$this->Session->setFlash(__('The User could not be saved. Please, try again.', true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
function edit($id = null) {
|
||||
if (!$id && empty($this->data)) {
|
||||
$this->Session->setFlash(__('Invalid User', true));
|
||||
$this->redirect(array('action'=>'index'));
|
||||
}
|
||||
if (!empty($this->data)) {
|
||||
if ($this->User->save($this->data)) {
|
||||
$this->Session->setFlash(__('The User has been saved', true));
|
||||
$this->redirect(array('action'=>'index'));
|
||||
} else {
|
||||
$this->Session->setFlash(__('The User could not be saved. Please, try again.', true));
|
||||
}
|
||||
}
|
||||
if (empty($this->data)) {
|
||||
$this->data = $this->User->read(null, $id);
|
||||
$this->set('groups', $this->User->Group->find('list'));
|
||||
}
|
||||
}
|
||||
|
||||
function delete($id = null) {
|
||||
if (!$id) {
|
||||
$this->Session->setFlash(__('Invalid id for User', true));
|
||||
$this->redirect(array('action'=>'index'));
|
||||
}
|
||||
if ($this->User->del($id)) {
|
||||
$this->Session->setFlash(__('User deleted', true));
|
||||
$this->redirect(array('action'=>'index'));
|
||||
}
|
||||
}
|
||||
|
||||
function initpermissions() {
|
||||
|
||||
$group = $this->User->Group;
|
||||
//Allow admins to everything
|
||||
$group->id = 6;
|
||||
$this->Acl->allow($group, 'controllers');
|
||||
|
||||
//Manager Permission
|
||||
$group->id = 5;
|
||||
$this->Acl->allow($group, 'controllers');
|
||||
|
||||
//User Permission
|
||||
$group->id = 4;
|
||||
$this->Acl->deny($group, 'controllers');
|
||||
$this->Acl->allow($group, 'controllers/Enquires/add');
|
||||
$this->Acl->allow($group, 'controllers/Enquires/edit');
|
||||
$this->Acl->allow($group, 'controllers/Enquires/view');
|
||||
$this->Acl->allow($group, 'controllers/Quotes/add');
|
||||
$this->Acl->allow($group, 'controllers/Quotes/edit');
|
||||
$this->Acl->allow($group, 'controllers/Quotes/view');
|
||||
$this->Acl->allow($group, 'controllers/QuoteProducts/add');
|
||||
|
||||
$this->Acl->allow($group, 'controllers/QuoteProducts/edit');
|
||||
$this->Acl->allow($group, 'controllers/QuoteProducts/view');
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
9
vendors/xtcpdf.php
vendored
9
vendors/xtcpdf.php
vendored
|
|
@ -90,7 +90,7 @@ class XTCPDF extends TCPDF {
|
|||
$fourthColWidth = -10;
|
||||
|
||||
$pageNo = $this->PageNoFormatted();
|
||||
//$pageOf = $this->getAliasNbPages();
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -98,13 +98,11 @@ class XTCPDF extends TCPDF {
|
|||
$this->SetXY($boxXstart, 55);
|
||||
|
||||
$heightNeeded = $this->getNumLines($companyName, $secondColWidth);
|
||||
//echo "Height needed: $heightNeeded";
|
||||
|
||||
|
||||
$lineHeight = 6.40997; //Size of a single line of text. If the company name is more, multiply this by the number of lines it needs.
|
||||
|
||||
// $lineHeight = 0;
|
||||
|
||||
// $this->MultiCell($w, $h, $txt, $border, $align, $fill, $ln, $x, $y, $reseth, $stretch, $ishtml);
|
||||
|
||||
|
||||
$this->MultiCell($firstColWidth, $lineHeight*$heightNeeded, "QUOTATION TO:", 'LTR', 'L', 0, 0);
|
||||
|
|
@ -112,7 +110,7 @@ class XTCPDF extends TCPDF {
|
|||
|
||||
$this->MultiCell($thirdColWidth, $lineHeight*$heightNeeded, "FROM:", 'LT', 'L', 0, 0);
|
||||
$this->MultiCell($fourthColWidth, $lineHeight*$heightNeeded, "<a href=\"mailto:$fromEmail\">$fromName</a>", 'TR', 'L', 0, 1, null,null, true,0,true); //Start a new line after this.
|
||||
// echo "Last height: ".$this->getLastH();
|
||||
|
||||
|
||||
$this->MultiCell($firstColWidth, 0, "EMAIL TO:", 'LR', 'L', 0, 0);
|
||||
$this->MultiCell($secondColWidth, 0, "<a href=\"mailto:$emailTo\">$emailTo</a>", 'LR','L', 0, 0, null, null, true, 0, true);
|
||||
|
|
@ -249,7 +247,6 @@ class XTCPDF extends TCPDF {
|
|||
$pageNo = $this->PageNoFormatted();
|
||||
$this->MultiCell(0, 0, "PAGE $pageNo OF {nb}", 0, "R", 0, 1);
|
||||
$this->MultiCell(0, 0, "PRICING & SPECIFICATIONS", 0, "C", 0, 1);
|
||||
$this->Ln();
|
||||
|
||||
$this->MultiCell($itemColwidth, 0, "ITEM\nNO.", 1, "C", 1, 0);
|
||||
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ foreach ($quote['QuotePage'] as $quotePage):
|
|||
|
||||
|
||||
|
||||
<div class="related">
|
||||
<div class="quoteproducts">
|
||||
<h3><?php __('Products in this Quote');?></h3>
|
||||
<?php if (!empty($quoteProducts)):?>
|
||||
<table cellpadding = "0" cellspacing = "0" class="quoteproducts">
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
*
|
||||
* Quotenik - Working CSS file based on the CakePHP default CSS.
|
||||
* Modified by Karl Cordes 2008/2009
|
||||
* Modified by Karl Cordes 2008/2009/2010
|
||||
*
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
|
|
@ -340,6 +340,13 @@ div.enquiriesindex {
|
|||
}
|
||||
|
||||
|
||||
div.quoteproducts {
|
||||
clear: both;
|
||||
display: block;
|
||||
padding-top: 3%;
|
||||
}
|
||||
|
||||
|
||||
/* Tables */
|
||||
table {
|
||||
background: #fff;
|
||||
|
|
@ -555,7 +562,7 @@ table.productoptions tr.defaultoption {
|
|||
}
|
||||
|
||||
table.quoteproducts {
|
||||
width: 70%;
|
||||
width: 60%;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue