Sorry, I meant the HowtosController, not AppController.
On Tue, May 21, 2013 at 8:25 AM, Larry Lutz <lutzle@swbell.net> wrote:
Thanks for the response, cricket. Yes, I do call beforeFilter in AppController (extensively) and it beings with parent::beforeFilter. Keep in mind that all controllers except for one correctly inherit from this AppController. The code for AppController goes on forever because of Cake-Menu, but here goes:
<?php
/**
* Application level Controller
*
* This file is application-wide controller file. You can put all
* application-wide controller-related methods here.
*
* PHP 5
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @package app.Controller
* @since CakePHP(tm) v 0.2.9
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('Controller', 'Controller');
/**
* Application Controller
*
* Add your application-wide methods in the class below, your controllers
* will inherit them.
*
* @package app.Controller
* @link http://book.cakephp.org/2.0/en/controllers.html#the-app-controller
*/
class AppController extends Controller {
public $uses = array();
public $helpers = array('Html', 'Form', 'Session', 'Js' => array('jquery'), 'Menu.MenuBuilder' => array('noLinkFormat' => '<h3>%s</h3>', 'authField' => 'group_id', 'authVar' => 'user', 'authModel' => 'Users.User'),);
public $components = array('Acl', 'Auth', 'Session', 'DebugKit.Toolbar', 'RequestHandler');
function beforeFilter() {
parent::beforeFilter();
$this->layout = 'lel';
// Auth stuff
$this->Auth->authenticate = array('Form' => array('fields' => array('username' => 'email', 'password' => 'passwd'), 'userModel' => 'User', 'scope' => array('User.active' => 1)));
$this->Auth->authorize = 'controller';
$this->Auth->loginAction = array('plugin' => 'users', 'controller' => 'users', 'action' => 'login', 'admin' => FALSE);
$this->Auth->loginRedirect = '/';
$this->Auth->logoutRedirect = '/';
$this->Auth->authError = __('Sorry, but you need to login to access this location.');
$this->Auth->loginError = __('Invalid e-mail / password combination. Please try again');
$this->Auth->autoRedirect = TRUE;
if ($this->Auth->user()) {
$this->set('user', $this->Auth->user());
$this->set('isAuthorized', ($this->Auth->user('id') != ''));
}
$this->set( 'loggedIn', $this->Auth->loggedIn() );
// $this->Auth->allow('reset', 'verify', 'logout', 'reset_password', 'login', 'home');
// $this->Auth->allow('*');
// End of Auth stuff
$menu = array(
'main-menu' => array(
array(
'title' => 'Home',
'url' => array(
'plugin' => FALSE,
'admin' => FALSE,
'controller' => 'posts',
'action' => 'home',
),
),
array(
'title' => 'Blog',
'url' => array(
'plugin' => FALSE,
'admin' => FALSE,
'controller' => 'articles',
'action' => 'index',
),
),
array(
'title' => 'Crochet',
'url' => array(
'plugin' => FALSE,
'admin' => FALSE,
'controller' => 'crochet_patterns',
'action' => 'index',
),
),
array(
'title' => 'How To\'s',
'url' => array(
'plugin' => FALSE,
'admin' => FALSE,
'controller' => 'howtos',
'action' => 'index',
),
),
array(
'title' => 'Learning Resources',
'url' => array(
'plugin' => FALSE,
'admin' => FALSE,
'controller' => 'pages',
'action' => 'learning_resources',
),
),
array(
'title' => 'Recipes',
'url' => array(
'plugin' => FALSE,
'admin' => FALSE,
'controller' => 'recipes',
'action' => 'index',
),
),
),
'left-menu' => array(
array(
'title' => 'Home',
'url' => array(
'plugin' => FALSE,
'admin' => FALSE,
'controller' => 'posts',
'action' => 'home',
),
),
array(
'title' => 'Blog',
'url' => array(
'plugin' => FALSE,
'admin' => FALSE,
'controller' => 'posts',
'action' => 'index',
),
),
array(
'title' => 'Crochet',
'url' => array(
'plugin' => FALSE,
'controller' => 'crochet_patterns',
'action' => 'index',
'admin' => FALSE,
),
),
array(
'title' => 'How To\'s',
'url' => array(
'plugin' => FALSE,
'controller' => 'howtos',
'action' => 'index',
'admin' => TRUE,
),
),
array(
'title' => 'Learning Resources',
'url' => '#',
'children' => array(
array(
'title' => 'Collections',
'url' => array(
'plugin' => FALSE,
'admin' => FALSE,
'controller' => 'collections',
'action' => 'index',
),
),
array(
'title' => 'Resources',
'url' => array(
'plugin' => FALSE,
'admin' => FALSE,
'controller' => 'resources',
'action' => 'index',
),
),
),
),
array(
'title' => 'Recipes',
'url' => array(
'plugin' => FALSE,
'admin' => FALSE,
'controller' => 'recipes',
'action' => 'index',
),
),
),
'admin-menu' => array(
array(
'title' => 'Articles',
'url' => '#',
// 'permissions' => array('512b9492-097c-462d-9c34-08b058f5bb4b'),
'children' => array(
array(
'title' => 'Manage Articles',
'url' => array(
'plugin' => FALSE,
'admin' => TRUE,
'controller' => 'posts',
'action' => 'index'
),
), array(
'title' => 'Add Article',
'url' => array(
'plugin' => FALSE,
'admin' => TRUE,
'controller' => 'posts',
'action' => 'add'
),
),
),
), array(
'title' => 'Crochet',
'url' => '#',
'children' => array(
array(
'title' => 'Patterns',
'url' => '#',
'children' => array(
array(
'title' => 'Manage Patterns',
'url' => array(
'plugin' => FALSE,
'admin' => TRUE,
'controller' => 'crochet_patterns',
'action' => 'index',
),
),
array(
'title' => 'Add Pattern',
'url' => array(
'plugin' => FALSE,
'admin' => TRUE,
'controller' => 'crochet_patterns',
'action' => 'add',
),
),
),
),
array(
'title' => 'Difficulty Levels',
'url' => '#',
'children' => array(
array(
'title' => 'Manage Levels',
'url' => array(
'plugin' => FALSE,
'admin' => TRUE,
'controller' => 'crochet_difficulties',
'action' => 'index',
),
),
array(
'title' => 'Add Level',
'url' => array(
'plugin' => FALSE,
'admin' => TRUE,
'controller' => 'crochet_difficulties',
'action' => 'add',
),
),
),
),
array(
'title' => 'Shapes',
'url' => '#',
'children' => array(
array(
'title' => 'Manage Shapes',
'url' => array(
'plugin' => FALSE,
'admin' => TRUE,
'controller' => 'crochet_shapes',
'action' => 'index',
),
),
array(
'title' => 'Add Shape',
'url' => array(
'plugin' => FALSE,
'admin' => TRUE,
'controller' => 'crochet_shapes',
'action' => 'add',
),
),
),
),
array(
'title' => 'Threads',
'url' => '#',
'children' => array(
array(
'title' => 'Manage Threads',
'url' => array(
'plugin' => FALSE,
'admin' => TRUE,
'controller' => 'crochet_threads',
'action' => 'index',
),
),
array(
'title' => 'Add Thread',
'url' => array(
'plugin' => FALSE,
'admin' => TRUE,
'controller' => 'crochet_threads',
'action' => 'add',
),
),
),
),
),
),
array(
'title' => 'Herbs',
'url' => '#',
'children' => array(
array(
'title' => 'Herbal Actions',
'url' => '#',
'children' => array(
array(
'title' => 'Manage Actions',
'url' => array(
'plugin' => FALSE,
'admin' => TRUE,
'controller' => 'herbal_actions',
'action' => 'index',
),
),
array(
'title' => 'Add Action',
'url' => array(
'plugin' => FALSE,
'admin' => TRUE,
'controller' => 'herbal_actions',
'action' => 'add',
),
),
),
),
array(
'title' => 'Herbal Medical Conditions',
'url' => '#',
'children' => array(
array(
'title' => 'Manage Medical Conditions',
'url' => array(
'plugin' => FALSE,
'admin' => TRUE,
'controller' => 'herbal_medical_conditions',
'action' => 'index',
),
),
array(
'title' => 'Add Medical Condition',
'url' => array(
'plugin' => FALSE,
'admin' => TRUE,
'controller' => 'herbal_medical_conditions',
'action' => 'add',
),
),
),
),
),
),
array(
'title' => 'Home Inventory',
'url' => '#',
'children' => array(
array(
'title' => 'Apartment Addresses',
'url' => '#',
'children' => array(
array(
'title' => 'Manage Addresses',
'url' => array(
'plugin' => FALSE,
'admin' => FALSE,
'controller' => 'hinv_addresses',
'action' => 'index',
),
),
array(
'title' => 'Add Address',
'url' => array(
'plugin' => FALSE,
'admin' => FALSE,
'controller' => 'hinv_addresses',
'action' => 'add',
),
),
),
),
array(
'title' => 'Apartment Rooms',
'url' => '#',
'children' => array(
array(
'title' => 'Manage Apartment Rooms',
'url' => array(
'plugin' => FALSE,
'admin' => FALSE,
'controller' => 'hinv_rooms',
'action' => 'index',
),
),
array(
'title' => 'Add Apartment Room',
'url' => array(
'plugin' => FALSE,
'admin' => FALSE,
'controller' => 'hinv_rooms',
'action' => 'add',
),
),
),
),
array(
'title' => 'Inventory Items',
'url' => '#',
'children' => array(
array(
'title' => 'Manage Items',
'url' => array(
'plugin' => FALSE,
'admin' => FALSE,
'controller' => 'hinv_items',
'action' => 'index',
),
),
array(
'title' => 'Add Item',
'url' => array(
'plugin' => FALSE,
'admin' => FALSE,
'controller' => 'hinv_items',
'action' => 'add',
),
),
),
),
array(
'title' => 'Inventory Attachments',
'url' => '#',
'children' => array(
array(
'title' => 'Manage Attachments',
'url' => array(
'plugin' => FALSE,
'admin' => FALSE,
'controller' => 'hinv_attachments',
'action' => 'index',
),
),
array(
'title' => 'Add Attachment',
'url' => array(
'plugin' => FALSE,
'admin' => FALSE,
'controller' => 'hinv_attachments',
'action' => 'add',
),
),
),
),
),
),
array(
'title' => 'How To\'s',
'url' => '#',
'children' => array(
array(
'title' => 'Manage How To\'s',
'url' => array(
'plugin' => FALSE,
'admin' => TRUE,
'controller' => 'howtos',
'action' => 'index',
),
),
array(
'title' => 'Add How To',
'url' => array(
'plugin' => FALSE,
'admin' => TRUE,
'controller' => 'howtos',
'action' => 'add',
),
),
),
),
array(
'title' => 'Job Search',
'url' => '#',
'children' => array(
array(
'title' => 'Search Activities',
'url' => '#',
'children' => array(
array(
'title' => 'Manage Search Activities',
'url' => array(
'plugin' => FALSE,
'admin' => TRUE,
'controller' => 'jobsearchactivities',
'action' => 'index',
),
),
array(
'title' => 'Add Search Activity',
'url' => array(
'plugin' => FALSE,
'admin' => TRUE,
'controller' => 'jobsearchactivities',
'action' => 'add',
),
),
),
), array(
'title' => 'Organizations',
'url' => '#',
'children' => array(
array(
'title' => 'Manage Organizations',
'url' => array(
'plugin' => FALSE,
'admin' => TRUE,
'controller' => 'organizations',
'action' => 'index',
),
),
array(
'title' => 'Add Organization',
'url' => array(
'plugin' => FALSE,
'admin' => TRUE,
'controller' => 'organizations',
'action' => 'add',
),
),
),
),
array(
'title' => 'People',
'url' => '#',
'children' => array(
array(
'title' => 'Manage People',
'url' => array(
'plugin' => FALSE,
'admin' => TRUE,
'controller' => 'people',
'action' => 'index',
),
),
array(
'title' => 'Add Person',
'url' => array(
'plugin' => FALSE,
'admin' => TRUE,
'controller' => 'people',
'action' => 'add',
),
),
),
),
array(
'title' => 'Person Types',
'url' => '#',
'children' => array(
array(
'title' => 'Manage Person Types',
'url' => array(
'plugin' => FALSE,
'admin' => TRUE,
'controller' => 'persontypes',
'action' => 'index',
),
),
array(
'title' => 'Add Person Type',
'url' => array(
'plugin' => FALSE,
'admin' => TRUE,
'controller' => 'persontypes',
'action' => 'add',
),
),
),
),
array(
'title' => 'General Resumes',
'url' => '#',
'children' => array(
array(
'title' => 'Manage Resumes',
'url' => array(
'plugin' => FALSE,
'admin' => TRUE,
'controller' => 'generalresumes',
'action' => 'index',
),
),
array(
'title' => 'Add Resume',
'url' => array(
'plugin' => FALSE,
'admin' => TRUE,
'controller' => 'generalresumes',
'action' => 'add',
),
),
),
),
array(
'title' => 'Jobs',
'url' => '#',
'children' => array(
array(
'title' => 'Manage Jobs',
'url' => array(
'plugin' => FALSE,
'admin' => TRUE,
'controller' => 'resumejobs',
'action' => 'index',
),
),
array(
'title' => 'Add Job',
'url' => array(
'plugin' => FALSE,
'admin' => TRUE,
'controller' => 'resumejobs',
'action' => 'add',
),
),
),
),
array(
'title' => 'Education',
'url' => '#',
'children' => array(
array(
'title' => 'Manage Education',
'url' => array(
'plugin' => FALSE,
'admin' => TRUE,
'controller' => 'educations',
'action' => 'index',
),
),
array(
'title' => 'Add Education',
'url' => array(
'plugin' => FALSE,
'admin' => TRUE,
'controller' => 'educations',
'action' => 'add',
),
),
),
),
),
), array(
'title' => 'Learning Resources',
'url' => '#',
'children' => array(
array(
'title' => 'Collections',
'url' => '#',
'children' => array(
array(
'title' => 'Manage Collections',
'url' => array(
'plugin' => FALSE,
'admin' => TRUE,
'controller' => 'collections',
'action' => 'index',
),
),
array(
'title' => 'Add Collection',
'url' => array(
'plugin' => FALSE,
'admin' => TRUE,
'controller' => 'collections',
'action' => 'add',
),
),
),
),
array(
'title' => 'Resources',
'url' => '#',
'children' => array(
array(
'title' => 'Manage Resources',
'url' => array(
'plugin' => FALSE,
'admin' => TRUE,
'controller' => 'resources',
'action' => 'index',
),
),
array(
'title' => 'Add Resource',
'url' => array(
'plugin' => FALSE,
'admin' => TRUE,
'controller' => 'resources',
'action' => 'add',
),
),
),
),
array(
'title' => 'Resource Types',
'url' => '#',
'children' => array(
array(
'title' => 'Manage Types',
'url' => array(
'plugin' => FALSE,
'admin' => TRUE,
'controller' => 'types',
'action' => 'index',
),
),
array(
'title' => 'Add Type',
'url' => array(
'plugin' => FALSE,
'admin' => TRUE,
'controller' => 'types',
'action' => 'add',
),
),
),
),
array(
'title' => 'Levels',
'url' => '#',
'children' => array(
array(
'title' => 'Manage Levels',
'url' => array(
'plugin' => FALSE,
'admin' => TRUE,
'controller' => 'levels',
'action' => 'index',
),
),
array(
'title' => 'Add Level',
'url' => array(
'plugin' => FALSE,
'admin' => TRUE,
'controller' => 'levels',
'action' => 'add',
),
),
),
),
),
),
array(
'title' => 'Quotations',
'url' => '#',
'children' => array(
array(
'title' => 'Manage Quotations',
'url' => array(
'plugin' => FALSE,
'admin' => TRUE,
'controller' => 'quotations',
'action' => 'index',
),
),
array(
'title' => 'Add Quotation',
'url' => array(
'plugin' => FALSE,
'admin' => TRUE,
'controller' => 'quotations',
'action' => 'add',
),
),
),
),
array(
'title' => 'Recipes',
'url' => '#',
'children' => array(
array(
'title' => 'Recipes',
'url' => '#',
'children' => array(
array(
'title' => 'Manage Recipes',
'url' => array(
'plugin' => FALSE,
'admin' => TRUE,
'controller' => 'recipes',
'action' => 'index',
),
),
array(
'title' => 'Add Recipe',
'url' => array(
'plugin' => FALSE,
'admin' => TRUE,
'controller' => 'recipes',
'action' => 'add',
),
),
),
),
array(
'title' => 'Ingredient Units',
'url' => '#',
'children' => array(
array(
'title' => 'Manage Units',
'url' => array(
'plugin' => FALSE,
'admin' => TRUE,
'controller' => 'ingredient_units',
'action' => 'index',
),
),
array(
'title' => 'Add Unit',
'url' => array(
'plugin' => FALSE,
'admin' => TRUE,
'controller' => 'ingredient_units',
'action' => 'add',
),
),
),
),
),
), array(
'title' => 'Site Management',
'url' => '#',
'children' => array(
array(
'title' => 'ACL',
'url' => array(
'plugin' => 'acl',
'admin' => TRUE,
'controller' => 'acl',
'action' => 'index',
),
),
array(
'title' => 'Categories',
'url' => '#',
'children' => array(
array(
'title' => 'Flat List',
'url' => array(
'plugin' => 'categories',
'admin' => TRUE,
'controller' => 'categories',
'action' => 'index',
),
),
array(
'title' => 'Tree List',
'url' => array(
'plugin' => 'categories',
'admin' => TRUE,
'controller' => 'categories',
'action' => 'tree',
),
),
array(
'title' => 'Add Category',
'url' => array(
'plugin' => 'categories',
'admin' => TRUE,
'controller' => 'categories',
'action' => 'add',
),
),
),
),
array(
'title' => 'Configuration',
'url' => '#',
'children' => array(
array(
'title' => 'Manage Configuration',
'url' => array(
'plugin' => 'configuration',
'admin' => TRUE,
'controller' => 'configurations',
'action' => 'index',
),
),
array(
'title' => 'Add Config Variable',
'url' => array(
'plugin' => 'configuration',
'admin' => TRUE,
'controller' => 'configurations',
'action' => 'add',
),
),
),
),
array(
'title' => 'Tags',
'url' => '#',
'children' => array(
array(
'title' => 'Manage Tags',
'url' => array(
'plugin' => 'tags',
'admin' => TRUE,
'controller' => 'tags',
'action' => 'index',
),
),
array(
'title' => 'Add Tag',
'url' => array(
'plugin' => 'tags',
'admin' => TRUE,
'controller' => 'tags',
'action' => 'add',
),
),
),
),
),
), array(
'title' => 'User Management',
'url' => '#',
'children' => array(
array(
'title' => 'Users',
'url' => '#',
'children' => array(
array(
'title' => 'Manage Users',
'url' => array(
'plugin' => 'users',
'admin' => TRUE,
'controller' => 'users',
'action' => 'index',
),
),
array(
'title' => 'Add User',
'url' => array(
'plugin' => 'users',
'admin' => TRUE,
'controller' => 'users',
'action' => 'add',
),
),
),
),
array(
'title' => 'Groups',
'url' => '#',
'children' => array(
array(
'title' => 'Manage Groups',
'url' => array(
'plugin' => FALSE,
'admin' => TRUE,
'controller' => 'groups',
'action' => 'index',
),
),
array(
'title' => 'Add Group',
'url' => array(
'plugin' => FALSE,
'admin' => TRUE,
'controller' => 'groups',
'action' => 'add',
),
),
),
),
),
),
),
);
$this->set(compact('menu'));
}
public function isAuthorized() {
return TRUE;
}
public function isRequestedAction() {
return array_key_exists('requested', $this->params);
}
public function getUser($request) {
$username = env('PHP_AUTH_USER');
$pass = env('PHP_AUTH_PW');
if (empty($username) || empty($pass)) {
return FALSE;
}
return $this->_findUser($username, $pass);
}
public function restoreLoginFromCookie() {
$this->Cookie->name = 'Users';
$cookie = $this->Cookie->read('rememberMe');
if (!empty($cookie) && !$this->Auth->user()) {
$data['User'][$this->Auth->fields['username']] = $cookie[$this->Auth->fields['username']];
$data['User'][$this->Auth->fields['password']] = $cookie[$this->Auth->fields['password']];
$this->Auth->login($data);
}
}
}
On Monday, May 20, 2013 5:57:41 PM UTC-5, cricket wrote:--Do you call beforeFilter in this controller? If so, does it in turn call parent::beforefilter()? Does the controller have its own constructor?Can you post the code?On Thu, May 16, 2013 at 3:33 PM, Larry Lutz <lut...@swbell.net> wrote:I'm hoping that someone can give me some troubleshooting ideas. I have a CakePHP 2.2.7 application/site with 31 controllers in addition to AppController. Thirty of those controllers correctly import (actually use) AppController so that variables set in it are available in the other controllers and so forth. One controller doesn't seem to inherit anything from AppController. Just like all the other controllers, I have this on the first line:App::uses('AppController', 'Controller');The class declaration looks like this:class HowtosController extends AppController {For the life of me, I can't figure out why the HowtosController is failing to inherit everything from AppController, while all the other controllers do. I've looked at everything that I can think of, and nothing seems to fix it. Basically, I'm using the Cake-Menu plugin which sets a $menu variable in AppController, and the HowtosController isn't receiving that. I also display the user name (if one is logged in) using $user['username'] which results in an "Undefined variable: user" in all the views deriving from HowtosController. (So it's not limited to just one plugin or the Auth component. It's across the board.) Looking at the available variables in the Debug Toolkit, none of the variables that one would expect to see are in the Howtos views.Can anyone give me any suggestions on how to continue troubleshooting?--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+u...@googlegroups.com.
To post to this group, send email to cake...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment