Re: Help please for ultra-beginner

2007-12-12 Thread Sanfly

No good im afraid, same error, except ugroup_id is now ugroupid


Notice: Undefined property: UsersController::$Ugroup in C:\server\www
\cake\basic_site\plugins\users\controllers\users_controller.php on
line 34

Fatal error: Call to a member function findByUgroupid() on a non-
object in C:\server\www\cake\basic_site\plugins\users\controllers
\users_controller.php on line 34


On Dec 12, 7:31 pm, chad [EMAIL PROTECTED] wrote:
 try findByUgroupId

 On Dec 11, 10:08 pm, Sanfly [EMAIL PROTECTED] wrote:

  Hi

  Ive only just started mucking around with CakePHP, and am having a
  little trouble getting my head around the controllers and models
  thingees.  YES - I have tried looking in the manual!!

  Im trying to make a cake website that will more or less mirror some
  normal-non-framework php sites I have done.

  There is a table called users where all normal user data is stored
  (see below for table structure).  The ugroup table contains a
  ugroup_name and a number of permissions that dictate what the user
  will be able to access on the site.  The ugroup_id field in users
  indicates which ugroup the user belongs to.

  When the person logs in, I first want it to check that the user_name
  and user_pass are valid, then access the ugroups table to set the
  ugroup data (permissions) as sessions, which can then be called when I
  like throughout the rest of the site.

  users_controller.php
  -
  ?php
  class UsersController extends AppController
  {

  function login()
  {
  $this-set('error', false);

  if (!empty($this-data))
  {
  $someone = $this-User-findByUser_name($this-data['User']
  ['user_name']);

  if(!empty($someone['User']['user_pass']) 
  $someone['User']['user_pass'] == md5($this-data['User']
  ['user_pass']))
  {
  $this-Session-write('User', $someone['User']);

  // Here is the code that is giving me 
  problems
  $perms = 
  $this-Ugroup-findByUgroup_id($someone['User']
  ['user_group']);

  if($perms['Ugroup']['perm_admin'] == 1){
  $this-redirect('/pages/admin/');
  }
  else{
  $this-redirect('/');
  }
  // End Problem code
  }
  else
  {
 $this-set('error', true);
  }
  }
  }

  function logout()
  {
 $this-Session-delete('User');

  $this-redirect('/');
  }}

  ?

  --
  However, this code gives me an error:

  --
  Notice: Undefined property: UsersController::$Ugroup in C:\server\www
  \cake\basic_site\plugins\users\controllers\users_controller.php on
  line 34

  Fatal error: Call to a member function findByUgroup_id() on a non-
  object in C:\server\www\cake\basic_site\plugins\users\controllers
  \users_controller.php on line 34
  --

  Can anyone point me in the right direction to solve this?  Sorry, but
  my cake knowledge is very limited and Im having trouble finding cake
  for dummies tutorials :s

  Thanks for any help :)

  --
  My tables:

  CREATE TABLE `users` (
`user_id` int(25) NOT NULL auto_increment,
`user_name` varchar(70) NOT NULL default '',
`user_pass` varchar(70) NOT NULL default '',
`ugroup_id` int(25) NOT NULL,
`user_email` varchar(50) NOT NULL default '',
`user_active` enum('0','1') NOT NULL default '0',
`user_logged` datetime NOT NULL default '-00-00 00:00:00',
`user_display` varchar(30) NOT NULL default '',
`user_joined` datetime NOT NULL default '-00-00 00:00:00',
`user_access` enum('0','1') NOT NULL default '0',
`user_bio` text NOT NULL,
`user_web` varchar(200) NOT NULL,
PRIMARY KEY  (`user_id`),
KEY `ugroup_id` (`ugroup_id`)
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;

  ALTER TABLE `users`
ADD CONSTRAINT `users_ibfk_1` FOREIGN KEY (`ugroup_id`) REFERENCES
  `ugroups` (`ugroup_id`);

  CREATE TABLE `ugroups` (
`ugroup_id` int(25) NOT NULL auto_increment,
`ugroup_name` varchar(70) NOT NULL default '',
`ugroup_rank` int(10) NOT NULL,
`perm_admin` enum('0','1') NOT NULL default '0',
`perm_configweb` enum('0','1') NOT NULL default '0',
`perm_setperm` enum('0','1') NOT NULL default '0',
`perm_adduser` enum('0','1') NOT NULL default '0',
`perm_edituser` enum('0','1') NOT 

Re: Help please for ultra-beginner

2007-12-12 Thread MrTufty

The error message you're getting tells you what the problem is... on
line 34, you're referring to $this-Ugroup-findByUgroupid().

This would be fine, except that you haven't told cake to give you
access to Ugroup in this way. I'm assuming you have a model for
Ugroup, and that it's associated with User in the correct way (which
would appear to be User belongsTo Ugroup, Ugroup hasMany User). This
would allow you to use... $this-User-Ugroup-findByUgroupid() to
achieve what you want.

Except by the magic of associations, you don't need to make the second
query, as Cake's magic will bring in the information you're looking
for with the first query, using a join.

This should give you an array in your $someone, something like this:

$someone = array(
   'User' = array( ... user details ...),
   'Ugroup' = array( ... usergroup details ...)
);

So you'll be able to refer to the Ugroup like this - $someone['Ugroup']
['perm_admin'].

Hope that helps!

On Dec 12, 7:37 am, Sanfly [EMAIL PROTECTED] wrote:
 No good im afraid, same error, except ugroup_id is now ugroupid

 
 Notice: Undefined property: UsersController::$Ugroup in C:\server\www
 \cake\basic_site\plugins\users\controllers\users_controller.php on
 line 34

 Fatal error: Call to a member function findByUgroupid() on a non-
 object in C:\server\www\cake\basic_site\plugins\users\controllers
 \users_controller.php on line 34
 

 On Dec 12, 7:31 pm, chad [EMAIL PROTECTED] wrote:

  try findByUgroupId

  On Dec 11, 10:08 pm, Sanfly [EMAIL PROTECTED] wrote:

   Hi

   Ive only just started mucking around with CakePHP, and am having a
   little trouble getting my head around the controllers and models
   thingees.  YES - I have tried looking in the manual!!

   Im trying to make a cake website that will more or less mirror some
   normal-non-framework php sites I have done.

   There is a table called users where all normal user data is stored
   (see below for table structure).  The ugroup table contains a
   ugroup_name and a number of permissions that dictate what the user
   will be able to access on the site.  The ugroup_id field in users
   indicates which ugroup the user belongs to.

   When the person logs in, I first want it to check that the user_name
   and user_pass are valid, then access the ugroups table to set the
   ugroup data (permissions) as sessions, which can then be called when I
   like throughout the rest of the site.

   users_controller.php
   -
   ?php
   class UsersController extends AppController
   {

   function login()
   {
   $this-set('error', false);

   if (!empty($this-data))
   {
   $someone = $this-User-findByUser_name($this-data['User']
   ['user_name']);

   if(!empty($someone['User']['user_pass']) 
   $someone['User']['user_pass'] == md5($this-data['User']
   ['user_pass']))
   {
   $this-Session-write('User', $someone['User']);

   // Here is the code that is giving me 
   problems
   $perms = 
   $this-Ugroup-findByUgroup_id($someone['User']
   ['user_group']);

   if($perms['Ugroup']['perm_admin'] == 1){
   $this-redirect('/pages/admin/');
   }
   else{
   $this-redirect('/');
   }
   // End Problem code
   }
   else
   {
  $this-set('error', true);
   }
   }
   }

   function logout()
   {
  $this-Session-delete('User');

   $this-redirect('/');
   }}

   ?

   --
   However, this code gives me an error:

   --
   Notice: Undefined property: UsersController::$Ugroup in C:\server\www
   \cake\basic_site\plugins\users\controllers\users_controller.php on
   line 34

   Fatal error: Call to a member function findByUgroup_id() on a non-
   object in C:\server\www\cake\basic_site\plugins\users\controllers
   \users_controller.php on line 34
   --

   Can anyone point me in the right direction to solve this?  Sorry, but
   my cake knowledge is very limited and Im having trouble finding cake
   for dummies tutorials :s

   Thanks for any help :)

   --
   My tables:

   CREATE TABLE `users` (
 `user_id` int(25) NOT NULL auto_increment,
 `user_name` varchar(70) NOT NULL default '',
 `user_pass` varchar(70) NOT NULL default '',
 `ugroup_id` 

Re: Help please for ultra-beginner

2007-12-12 Thread avairet

Hello,

My cake knowledge is limited too (2 months), but I think you must
specify your 2 models in your controller.

Something like that in PHP5 context:
?
class UsersController extends AppController
{
   public $uses = array('User','Ugroup');
}
?

And maybe you should specify the association in your 2 models...

Something like that:
?
class User extends AppModel
{
   public $belongsTo = array('Ugroup');
}
?

and for the associated model:

?
class Ugroup extends AppModel
{
   public $hasMany = array('User');
}
?

And finally, you must indicate to your models, the primary key you are
using, because by default Cake search for an id key to make
associations.
?
class Ugroup extends AppModel
{
   public $primaryKey = 'ugroup_id';
}
?

I hope this helps you...

BR

Avairet

On 12 déc, 08:37, Sanfly [EMAIL PROTECTED] wrote:
 No good im afraid, same error, except ugroup_id is now ugroupid

 
 Notice: Undefined property: UsersController::$Ugroup in C:\server\www
 \cake\basic_site\plugins\users\controllers\users_controller.php on
 line 34

 Fatal error: Call to a member function findByUgroupid() on a non-
 object in C:\server\www\cake\basic_site\plugins\users\controllers
 \users_controller.php on line 34
 

 On Dec 12, 7:31 pm, chad [EMAIL PROTECTED] wrote:

  try findByUgroupId

  On Dec 11, 10:08 pm, Sanfly [EMAIL PROTECTED] wrote:

   Hi

   Ive only just started mucking around with CakePHP, and am having a
   little trouble getting my head around the controllers and models
   thingees.  YES - I have tried looking in the manual!!

   Im trying to make a cake website that will more or less mirror some
   normal-non-framework php sites I have done.

   There is a table called users where all normal user data is stored
   (see below for table structure).  The ugroup table contains a
   ugroup_name and a number of permissions that dictate what the user
   will be able to access on the site.  The ugroup_id field in users
   indicates which ugroup the user belongs to.

   When the person logs in, I first want it to check that the user_name
   and user_pass are valid, then access the ugroups table to set the
   ugroup data (permissions) as sessions, which can then be called when I
   like throughout the rest of the site.

   users_controller.php
   -
   ?php
   class UsersController extends AppController
   {

   function login()
   {
   $this-set('error', false);

   if (!empty($this-data))
   {
   $someone = $this-User-findByUser_name($this-data['User']
   ['user_name']);

   if(!empty($someone['User']['user_pass']) 
   $someone['User']['user_pass'] == md5($this-data['User']
   ['user_pass']))
   {
   $this-Session-write('User', $someone['User']);

   // Here is the code that is giving me 
   problems
   $perms = 
   $this-Ugroup-findByUgroup_id($someone['User']
   ['user_group']);

   if($perms['Ugroup']['perm_admin'] == 1){
   $this-redirect('/pages/admin/');
   }
   else{
   $this-redirect('/');
   }
   // End Problem code
   }
   else
   {
  $this-set('error', true);
   }
   }
   }

   function logout()
   {
  $this-Session-delete('User');

   $this-redirect('/');
   }}

   ?

   --
   However, this code gives me an error:

   --
   Notice: Undefined property: UsersController::$Ugroup in C:\server\www
   \cake\basic_site\plugins\users\controllers\users_controller.php on
   line 34

   Fatal error: Call to a member function findByUgroup_id() on a non-
   object in C:\server\www\cake\basic_site\plugins\users\controllers
   \users_controller.php on line 34
   --

   Can anyone point me in the right direction to solve this?  Sorry, but
   my cake knowledge is very limited and Im having trouble finding cake
   for dummies tutorials :s

   Thanks for any help :)

   --
   My tables:

   CREATE TABLE `users` (
 `user_id` int(25) NOT NULL auto_increment,
 `user_name` varchar(70) NOT NULL default '',
 `user_pass` varchar(70) NOT NULL default '',
 `ugroup_id` int(25) NOT NULL,
 `user_email` varchar(50) NOT NULL default '',
 `user_active` enum('0','1') NOT NULL default '0',
 `user_logged` datetime NOT NULL default 

Re: Help please for ultra-beginner

2007-12-12 Thread avairet

Ok, that works! Very nice!

But in this case, some of my find() or save() calls become more
complex: $this-Model1-Model2-Model3-save();
And the resultsets of my find are now in the DESC order...

Avairet


On 12 déc, 15:54, avairet [EMAIL PROTECTED] wrote:
 Hi Mr Tufty,

 I didn't know that...
 It's very interesting.
 I will try it immediately because I've a doubt... that the associated
 models is known in my controller.

 I will reply after my test!

 Avairet

 On 12 déc, 13:56, MrTufty [EMAIL PROTECTED] wrote:

  Yes, you can do it that way too. But if you set up the associations,
  you don't NEED to change $uses to include Ugroup, as it will
  automatically be included based on it's association with the User
  model.

  On Dec 12, 9:22 am, avairet [EMAIL PROTECTED] wrote:

   Hello,

   My cake knowledge is limited too (2 months), but I think you must
   specify your 2 models in your controller.

   Something like that in PHP5 context:
   ?
   class UsersController extends AppController
   {
  public $uses = array('User','Ugroup');}

   ?

   And maybe you should specify the association in your 2 models...

   Something like that:
   ?
   class User extends AppModel
   {
  public $belongsTo = array('Ugroup');}

   ?

   and for the associated model:

   ?
   class Ugroup extends AppModel
   {
  public $hasMany = array('User');}

   ?

   And finally, you must indicate to your models, the primary key you are
   using, because by default Cake search for an id key to make
   associations.
   ?
   class Ugroup extends AppModel
   {
  public $primaryKey = 'ugroup_id';}

   ?

   I hope this helps you...

   BR

   Avairet

   On 12 déc, 08:37, Sanfly [EMAIL PROTECTED] wrote:

No good im afraid, same error, except ugroup_id is now ugroupid


Notice: Undefined property: UsersController::$Ugroup in C:\server\www
\cake\basic_site\plugins\users\controllers\users_controller.php on
line 34

Fatal error: Call to a member function findByUgroupid() on a non-
object in C:\server\www\cake\basic_site\plugins\users\controllers
\users_controller.php on line 34


On Dec 12, 7:31 pm, chad [EMAIL PROTECTED] wrote:

 try findByUgroupId

 On Dec 11, 10:08 pm, Sanfly [EMAIL PROTECTED] wrote:

  Hi

  Ive only just started mucking around with CakePHP, and am having a
  little trouble getting my head around the controllers and models
  thingees.  YES - I have tried looking in the manual!!

  Im trying to make a cake website that will more or less mirror some
  normal-non-framework php sites I have done.

  There is a table called users where all normal user data is stored
  (see below for table structure).  The ugroup table contains a
  ugroup_name and a number of permissions that dictate what the user
  will be able to access on the site.  The ugroup_id field in users
  indicates which ugroup the user belongs to.

  When the person logs in, I first want it to check that the user_name
  and user_pass are valid, then access the ugroups table to set the
  ugroup data (permissions) as sessions, which can then be called 
  when I
  like throughout the rest of the site.

  users_controller.php
  -
  ?php
  class UsersController extends AppController
  {

  function login()
  {
  $this-set('error', false);

  if (!empty($this-data))
  {
  $someone = 
  $this-User-findByUser_name($this-data['User']
  ['user_name']);

  if(!empty($someone['User']['user_pass']) 
  $someone['User']['user_pass'] == md5($this-data['User']
  ['user_pass']))
  {
  $this-Session-write('User', $someone['User']);

  // Here is the code that is giving 
  me problems
  $perms = 
  $this-Ugroup-findByUgroup_id($someone['User']
  ['user_group']);

  if($perms['Ugroup']['perm_admin'] 
  == 1){
  
  $this-redirect('/pages/admin/');
  }
  else{
  $this-redirect('/');
  }
  // End Problem code
  }
  else
  {
 $this-set('error', true);
  }
  }
  }

  function logout()
  {
 $this-Session-delete('User');

  $this-redirect('/');
  }}

  ?

  --
  

Re: Help please for ultra-beginner

2007-12-12 Thread avairet

I add another comment: if you are using Eclipse and PDT Eclipse, the
autocompletion for model's methods in controller doesn't work again.


On 12 déc, 16:07, avairet [EMAIL PROTECTED] wrote:
 Ok, that works! Very nice!

 But in this case, some of my find() or save() calls become more
 complex: $this-Model1-Model2-Model3-save();
 And the resultsets of my find are now in the DESC order...

 Avairet

 On 12 déc, 15:54, avairet [EMAIL PROTECTED] wrote:

  Hi Mr Tufty,

  I didn't know that...
  It's very interesting.
  I will try it immediately because I've a doubt... that the associated
  models is known in my controller.

  I will reply after my test!

  Avairet

  On 12 déc, 13:56, MrTufty [EMAIL PROTECTED] wrote:

   Yes, you can do it that way too. But if you set up the associations,
   you don't NEED to change $uses to include Ugroup, as it will
   automatically be included based on it's association with the User
   model.

   On Dec 12, 9:22 am, avairet [EMAIL PROTECTED] wrote:

Hello,

My cake knowledge is limited too (2 months), but I think you must
specify your 2 models in your controller.

Something like that in PHP5 context:
?
class UsersController extends AppController
{
   public $uses = array('User','Ugroup');}

?

And maybe you should specify the association in your 2 models...

Something like that:
?
class User extends AppModel
{
   public $belongsTo = array('Ugroup');}

?

and for the associated model:

?
class Ugroup extends AppModel
{
   public $hasMany = array('User');}

?

And finally, you must indicate to your models, the primary key you are
using, because by default Cake search for an id key to make
associations.
?
class Ugroup extends AppModel
{
   public $primaryKey = 'ugroup_id';}

?

I hope this helps you...

BR

Avairet

On 12 déc, 08:37, Sanfly [EMAIL PROTECTED] wrote:

 No good im afraid, same error, except ugroup_id is now ugroupid

 
 Notice: Undefined property: UsersController::$Ugroup in C:\server\www
 \cake\basic_site\plugins\users\controllers\users_controller.php on
 line 34

 Fatal error: Call to a member function findByUgroupid() on a non-
 object in C:\server\www\cake\basic_site\plugins\users\controllers
 \users_controller.php on line 34
 

 On Dec 12, 7:31 pm, chad [EMAIL PROTECTED] wrote:

  try findByUgroupId

  On Dec 11, 10:08 pm, Sanfly [EMAIL PROTECTED] wrote:

   Hi

   Ive only just started mucking around with CakePHP, and am having a
   little trouble getting my head around the controllers and models
   thingees.  YES - I have tried looking in the manual!!

   Im trying to make a cake website that will more or less mirror 
   some
   normal-non-framework php sites I have done.

   There is a table called users where all normal user data is stored
   (see below for table structure).  The ugroup table contains a
   ugroup_name and a number of permissions that dictate what the 
   user
   will be able to access on the site.  The ugroup_id field in users
   indicates which ugroup the user belongs to.

   When the person logs in, I first want it to check that the 
   user_name
   and user_pass are valid, then access the ugroups table to set the
   ugroup data (permissions) as sessions, which can then be called 
   when I
   like throughout the rest of the site.

   users_controller.php
   -
   ?php
   class UsersController extends AppController
   {

   function login()
   {
   $this-set('error', false);

   if (!empty($this-data))
   {
   $someone = 
   $this-User-findByUser_name($this-data['User']
   ['user_name']);

   if(!empty($someone['User']['user_pass']) 
   $someone['User']['user_pass'] == md5($this-data['User']
   ['user_pass']))
   {
   $this-Session-write('User', $someone['User']);

   // Here is the code that is 
   giving me problems
   $perms = 
   $this-Ugroup-findByUgroup_id($someone['User']
   ['user_group']);

   if($perms['Ugroup']['perm_admin'] 
   == 1){
   
   $this-redirect('/pages/admin/');
   }
   else{
   $this-redirect('/');
   }
   // End Problem code
   }
   else
   

Re: Help please for ultra-beginner

2007-12-12 Thread Sanfly

Hi

I had tried something similar to this before, using hasOne (ugroup)
in the users model, and belongsTo (users) in the ugroup model.

The code I had tried, and the one you suggested, both came up with a
SQL error.  Ive ended up solving this using Tuftys code, with the
addition of this from Avairet

 ?
class Ugroup extends AppModel
{
   public $primaryKey = 'ugroup_id';
}

?

Thanks both for your help :)

On Dec 12, 10:16 pm, MrTufty [EMAIL PROTECTED] wrote:
 The error message you're getting tells you what the problem is... on
 line 34, you're referring to $this-Ugroup-findByUgroupid().

 This would be fine, except that you haven't told cake to give you
 access to Ugroup in this way. I'm assuming you have a model for
 Ugroup, and that it's associated with User in the correct way (which
 would appear to be User belongsTo Ugroup, Ugroup hasMany User). This
 would allow you to use... $this-User-Ugroup-findByUgroupid() to
 achieve what you want.

 Except by the magic of associations, you don't need to make the second
 query, as Cake's magic will bring in the information you're looking
 for with the first query, using a join.

 This should give you an array in your $someone, something like this:

 $someone = array(
'User' = array( ... user details ...),
'Ugroup' = array( ... usergroup details ...)
 );

 So you'll be able to refer to the Ugroup like this - $someone['Ugroup']
 ['perm_admin'].

 Hope that helps!

 On Dec 12, 7:37 am, Sanfly [EMAIL PROTECTED] wrote:

  No good im afraid, same error, except ugroup_id is now ugroupid

  
  Notice: Undefined property: UsersController::$Ugroup in C:\server\www
  \cake\basic_site\plugins\users\controllers\users_controller.php on
  line 34

  Fatal error: Call to a member function findByUgroupid() on a non-
  object in C:\server\www\cake\basic_site\plugins\users\controllers
  \users_controller.php on line 34
  

  On Dec 12, 7:31 pm, chad [EMAIL PROTECTED] wrote:

   try findByUgroupId

   On Dec 11, 10:08 pm, Sanfly [EMAIL PROTECTED] wrote:

Hi

Ive only just started mucking around with CakePHP, and am having a
little trouble getting my head around the controllers and models
thingees.  YES - I have tried looking in the manual!!

Im trying to make a cake website that will more or less mirror some
normal-non-framework php sites I have done.

There is a table called users where all normal user data is stored
(see below for table structure).  The ugroup table contains a
ugroup_name and a number of permissions that dictate what the user
will be able to access on the site.  The ugroup_id field in users
indicates which ugroup the user belongs to.

When the person logs in, I first want it to check that the user_name
and user_pass are valid, then access the ugroups table to set the
ugroup data (permissions) as sessions, which can then be called when I
like throughout the rest of the site.

users_controller.php
-
?php
class UsersController extends AppController
{

function login()
{
$this-set('error', false);

if (!empty($this-data))
{
$someone = $this-User-findByUser_name($this-data['User']
['user_name']);

if(!empty($someone['User']['user_pass']) 
$someone['User']['user_pass'] == md5($this-data['User']
['user_pass']))
{
$this-Session-write('User', $someone['User']);

// Here is the code that is giving me 
problems
$perms = 
$this-Ugroup-findByUgroup_id($someone['User']
['user_group']);

if($perms['Ugroup']['perm_admin'] == 
1){

$this-redirect('/pages/admin/');
}
else{
$this-redirect('/');
}
// End Problem code
}
else
{
   $this-set('error', true);
}
}
}

function logout()
{
   $this-Session-delete('User');

$this-redirect('/');
}}

?

--
However, this code gives me an error:

--
Notice: Undefined property: UsersController::$Ugroup in C:\server\www
\cake\basic_site\plugins\users\controllers\users_controller.php on
line 34

Fatal error: Call to a member function findByUgroup_id() on a non-
object in 

Help please for ultra-beginner

2007-12-11 Thread Sanfly

Hi

Ive only just started mucking around with CakePHP, and am having a
little trouble getting my head around the controllers and models
thingees.  YES - I have tried looking in the manual!!

Im trying to make a cake website that will more or less mirror some
normal-non-framework php sites I have done.

There is a table called users where all normal user data is stored
(see below for table structure).  The ugroup table contains a
ugroup_name and a number of permissions that dictate what the user
will be able to access on the site.  The ugroup_id field in users
indicates which ugroup the user belongs to.

When the person logs in, I first want it to check that the user_name
and user_pass are valid, then access the ugroups table to set the
ugroup data (permissions) as sessions, which can then be called when I
like throughout the rest of the site.

users_controller.php
-
?php
class UsersController extends AppController
{

function login()
{
$this-set('error', false);

if (!empty($this-data))
{
$someone = $this-User-findByUser_name($this-data['User']
['user_name']);

if(!empty($someone['User']['user_pass']) 
$someone['User']['user_pass'] == md5($this-data['User']
['user_pass']))
{
$this-Session-write('User', $someone['User']);

// Here is the code that is giving me problems
$perms = 
$this-Ugroup-findByUgroup_id($someone['User']
['user_group']);

if($perms['Ugroup']['perm_admin'] == 1){
$this-redirect('/pages/admin/');
}
else{
$this-redirect('/');
}
// End Problem code
}
else
{
   $this-set('error', true);
}
}
}

function logout()
{
   $this-Session-delete('User');

$this-redirect('/');
}
}
?

--
However, this code gives me an error:

--
Notice: Undefined property: UsersController::$Ugroup in C:\server\www
\cake\basic_site\plugins\users\controllers\users_controller.php on
line 34

Fatal error: Call to a member function findByUgroup_id() on a non-
object in C:\server\www\cake\basic_site\plugins\users\controllers
\users_controller.php on line 34
--

Can anyone point me in the right direction to solve this?  Sorry, but
my cake knowledge is very limited and Im having trouble finding cake
for dummies tutorials :s

Thanks for any help :)

--
My tables:

CREATE TABLE `users` (
  `user_id` int(25) NOT NULL auto_increment,
  `user_name` varchar(70) NOT NULL default '',
  `user_pass` varchar(70) NOT NULL default '',
  `ugroup_id` int(25) NOT NULL,
  `user_email` varchar(50) NOT NULL default '',
  `user_active` enum('0','1') NOT NULL default '0',
  `user_logged` datetime NOT NULL default '-00-00 00:00:00',
  `user_display` varchar(30) NOT NULL default '',
  `user_joined` datetime NOT NULL default '-00-00 00:00:00',
  `user_access` enum('0','1') NOT NULL default '0',
  `user_bio` text NOT NULL,
  `user_web` varchar(200) NOT NULL,
  PRIMARY KEY  (`user_id`),
  KEY `ugroup_id` (`ugroup_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;

ALTER TABLE `users`
  ADD CONSTRAINT `users_ibfk_1` FOREIGN KEY (`ugroup_id`) REFERENCES
`ugroups` (`ugroup_id`);



CREATE TABLE `ugroups` (
  `ugroup_id` int(25) NOT NULL auto_increment,
  `ugroup_name` varchar(70) NOT NULL default '',
  `ugroup_rank` int(10) NOT NULL,
  `perm_admin` enum('0','1') NOT NULL default '0',
  `perm_configweb` enum('0','1') NOT NULL default '0',
  `perm_setperm` enum('0','1') NOT NULL default '0',
  `perm_adduser` enum('0','1') NOT NULL default '0',
  `perm_edituser` enum('0','1') NOT NULL default '0',
  `perm_viewuserhidden` enum('0','1') NOT NULL default '0',
  `perm_viewusers` enum('0','1') NOT NULL default '0',
  `perm_addgroup` enum('0','1') NOT NULL default '0',
  `perm_editgroup` enum('0','1') NOT NULL default '0',
  `perm_viewgroup` enum('0','1') NOT NULL default '0',
  PRIMARY KEY  (`ugroup_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---