Re: CakePHP 1.2 Layout error

2013-01-02 Thread Marcus James
Found the error there was a file BOM encoded

-- 
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 post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Database Connection MS SQL 2012 With CakePHP 2.X

2013-01-02 Thread Mohamad Zulhelmi Redzwan
I try to make connection with my local ms sql db with this settings 
public $default = array(
'datasource' => 'Database/Sqlserver',
'persistent' => false,
'host' => 'localhost\SQLEXPRESS',
'login' => 'sa',
'password' => '123456',
'database' => 'ktmb',
'prefix' => '',
//'encoding' => 'utf8',
);

but it show error "Cake is NOT able to connect to the database.

Database connection "Sqlserver" is missing, or could not be created."

who can help me... 

-- 
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 post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Re: queries on HABTM relationships

2013-01-02 Thread Stefano Campanella
Yes I am sure. In my case id is not numeric, the permission name is already 
an identifier for the permission

On Wednesday, January 2, 2013 3:56:41 PM UTC+1, Maicon Pinto wrote:
>
> array('*id*'=>'can_access_admin') 
>
> Do you have sure is ID? Usually ID is numeric. 
>
> Em terça-feira, 1 de janeiro de 2013 19h23min58s UTC-3, Stefano Campanella 
> escreveu:
>>
>> Hello all,
>> this is my first time posting here. I recently started to study how to 
>> use CakePHP and I'm trying to develop a website.
>> In my website I am writing a custom authorize component where each user 
>> get one or more groups and each group has one or more permissions 
>> associated to it.
>> I have problems in using the find() method.
>> This is my structure:
>> User hasAndBelongsToMany Group
>> Group hasAndBelongsToMany Perm
>>
>> I have attached Containable to all the Models (in AppModel)
>>
>> now in my authorization component I need to check if a group has a 
>> specific permission, and for this I use find():
>>
>> if(!isset($this->controller()->Group)){
>>>   $this->controller()->loadModel('Group');
>>> }
>>> $n_perm=$this->controller()->Group->find('count',array(
>>>   'conditions'=>array('id'=>1),
>>>   'contain'=>array(
>>> 'Perm'=>array(
>>>   'conditions' => array('id'=>'can_access_admin')
>>> )
>>>   ) 
>>
>> ));
>>
>>
>> I would expect this to give me a result >=1 if group 1 has the 
>> 'can_access_admin' permission, and =0 if the group has no such permission.
>> This is not what actually happens, the only query that cakePHP shows is 
>> this:
>>
>> SELECT COUNT(*) AS `count` FROM `groups` AS `Group` WHERE `id` = 1
>>
>> And it is obviously not enough to find what I requested.
>>
>> Can anyone help me?
>>
>> Thanks
>>
>

-- 
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 post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Re: how to create a sample theme in cakephp 2.x

2013-01-02 Thread Passivhaus Experte

Am 02.01.2013 13:09, schrieb Siva Kumar:
i am beginner of cakephp. now only i learning it. plz if any one know 
it means help me to create a theme. --
CakePHP Cookbook 2.x Themes 
http://book.cakephp.org/2.0/en/views/themes.html


--
Grüße Sie freundlich.
Tim Bischoff (Indianer3c)
Blogautor Passivhaus Experte
http://www.passivhaus-experte.de/

--
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 post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




how to create a sample theme in cakephp 2.x

2013-01-02 Thread Siva Kumar
i am beginner of cakephp. now only i learning it. plz if any one know it 
means help me to create a theme.

-- 
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 post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Re: queries on HABTM relationships

2013-01-02 Thread Maicon Pinto
array('*id*'=>'can_access_admin') 

Do you have sure is ID? Usually ID is numeric. 

Em terça-feira, 1 de janeiro de 2013 19h23min58s UTC-3, Stefano Campanella 
escreveu:
>
> Hello all,
> this is my first time posting here. I recently started to study how to use 
> CakePHP and I'm trying to develop a website.
> In my website I am writing a custom authorize component where each user 
> get one or more groups and each group has one or more permissions 
> associated to it.
> I have problems in using the find() method.
> This is my structure:
> User hasAndBelongsToMany Group
> Group hasAndBelongsToMany Perm
>
> I have attached Containable to all the Models (in AppModel)
>
> now in my authorization component I need to check if a group has a 
> specific permission, and for this I use find():
>
> if(!isset($this->controller()->Group)){
>>   $this->controller()->loadModel('Group');
>> }
>> $n_perm=$this->controller()->Group->find('count',array(
>>   'conditions'=>array('id'=>1),
>>   'contain'=>array(
>> 'Perm'=>array(
>>   'conditions' => array('id'=>'can_access_admin')
>> )
>>   ) 
>
> ));
>
>
> I would expect this to give me a result >=1 if group 1 has the 
> 'can_access_admin' permission, and =0 if the group has no such permission.
> This is not what actually happens, the only query that cakePHP shows is 
> this:
>
> SELECT COUNT(*) AS `count` FROM `groups` AS `Group` WHERE `id` = 1
>
> And it is obviously not enough to find what I requested.
>
> Can anyone help me?
>
> Thanks
>

-- 
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 post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Best practices for general checks and redirects?

2013-01-02 Thread Jamie Krasnoo
Hey all,

I'm new to CakePHP and have a lot of experience with other frameworks. I'd 
like to know what the best practice is for doing checking for things before 
any controller is run? Does it belong in the AppController's beforeFilter 
callback, the afterFilter in UsersController, or is there a place to 
specifically put this sort of stuff? I just need to make sure that the 
RegisterController and login and logout and pages aren't impeded.

I need to check to see if a User with the role of merchants has their store 
set up after they log in. If they don't then they need to be redirected to 
the controller to set their store up.

Jamie

-- 
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 post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Re: CakePHP 1.2 Layout error

2013-01-02 Thread Maicon Pinto
Hello Marco,

Do you can to put of source code of your Layout?

;)

Em quarta-feira, 2 de janeiro de 2013 03h39min30s UTC-3, marco metal 
escreveu:
>
> Hi,
>
> I made a custom layout for admin panel. The problem is when i validated my 
> HTML i am getting an error 
>
> *"* *Non-space characters found without seeing a doctype first. Expected 
> .*" 
>
> On Firefox the layout renders perfectly when i inspect it but on google 
> chrome its showing an empty space inside body tag and all the html tag is 
> going inside body tag.
>
> Any idea what the problem is?
>
>
>

-- 
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 post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Re: queries on HABTM relationships

2013-01-02 Thread Stefano Campanella
Works like a charm! Thank you so much cricket!
Now to reply to your questions:
I am using a count because I don't need any content returned. With this 
query I just check if the record exists, if it does then I know the Group 
has the specified permission. The count will always return 0 if group 1 has 
no can_access permission or 1 if the group has the permission. I don't need 
any information, I only need to know if it exists.

I didn't find any note about CakePHP supporting only integer ids, is this 
true? Every permission has a unique name and it is not going to change, so 
I thought using an integer id and another name field is useless, I just use 
the permission name as primary key.

As for using ACL: reading CakePHP2.x Book I understood that ACL only 
supports trees structures, but it is a limitation for me because I need to 
be able to group my users in mode than one way. A user could be a Manager 
but also a Moderator, and these two groups are not one child of the other. 
I would need ACL to support more than just trees, it should support graphs. 
So I decided to make my Authorization component, which just uses flat 
groups (there is no group hierarchy) but allows one user to have more than 
one group. And it isn't even very big, the Authorize class is only 70 lines 
long, while ACL seems really too complex.

Anyway, I am done now. Thank you to everyone who tried to help me!!

On Wednesday, January 2, 2013 11:53:44 PM UTC+1, cricket wrote:
>
> I just realised that this also makes no sense. Why are you running a 
> COUNT(*) on Group when your condition is to select only the Group with 
> id = 1? 
>
> Perhaps you need to start from the beginning and explain what it is 
> you're looking for. 
>
> And I'll second the suggestion to use ACL. 
>
> On Wed, Jan 2, 2013 at 5:50 PM, lowpass > 
> wrote: 
> > I think that should be something like: 
> > 
> > $data = $this->controller()->Group->find( 
> > 'count', 
> > array( 
> > 'conditions' => array( 
> > 'Group.id' => 1 // hard-coded for testing? 
> > ), 
> > 'joins' => array( 
> > array( 
> > 'type' => 'INNER', 
> > 'table' => 'groups_perms', 
> > 'alias' => 'GroupPerm', 
> > 'conditions' => array( 
> > 'GroupPerm.group_id' => 
> 'Group.id' 
> > ) 
> > ), 
> > array( 
> > 'type' => 'INNER', 
> > 'table' => 'perms', 
> > 'alias' => 'Perm', 
> > 'conditions' => array( 
> > 'GroupPerm.perm_id' => 'Perm.id' 
> > ) 
> > ) 
> > ) 
> > ) 
> > ); 
> > 
> > However, I've left out the perm.id='can_access_admin' part because it 
> > makes no sense in the context of Cake. The id column should be an INT. 
> > I presume you mean something like 'Perm.type' => 'can_access_admin', 
> > in which case add it to the 2nd joins conditions array. 
> > 
> > On Wed, Jan 2, 2013 at 3:48 PM, Stefano Campanella 
> > > wrote: 
> >> mmh, ok. But the problem is that even if I change the find("count") 
> into a 
> >> find("all") it still loads data only from Group table. 
> >> 
> >> Yes I am using the AuthComponent for logged in users. But since I want 
> to 
> >> use my Authorize class also for managing what anonymous users can 
> access I 
> >> am calling $this->Auth->isAuthorized() in the beforeFilter of 
> AppController 
> >> with a $user parameter of array('id'=>0). Inside the authorize method I 
> >> recognize the empty user and make checks for permissions on an hard 
> coded 
> >> group id. I checked this would work correctly, if only I could make the 
> >> query in the right way. 
> >> 
> >> Let's change the question. Which code would you write to make CakePHP 
> >> execute this query: 
> >>> 
> >>> SELECT COUNT(*) AS count FROM groups INNER JOIN groups_perms ON 
> >>> groups.id=groups_perms.group_id INNER JOIN perm ON 
> >>> groups_perms.perm_id=perm.id WHERE group.id=1 AND 
> >>> perm.id='can_access_admin' 
>
> >> 
> >> given that you have access to $this->controller()->Group? 
> >> 
> >> Thanks 
> >> 
> >> On Wednesday, January 2, 2013 7:59:24 PM UTC+1, cricket wrote: 
> >>> 
> >>> When running a find('count') the contain param is useless. This is 
> >>> because the main query is fetching a sum, not a set of records from 
> >>> which to fetch the associated 'contain' records. 
> >>> 
> >>> Are you using AuthComponent? You can use that to fetch the User and 
> >>> associated records. However, I can't remember how deep it goes. To see 
> >>> what records it has, put this in your Users

Re: queries on HABTM relationships

2013-01-02 Thread lowpass
I just realised that this also makes no sense. Why are you running a
COUNT(*) on Group when your condition is to select only the Group with
id = 1?

Perhaps you need to start from the beginning and explain what it is
you're looking for.

And I'll second the suggestion to use ACL.

On Wed, Jan 2, 2013 at 5:50 PM, lowpass  wrote:
> I think that should be something like:
>
> $data = $this->controller()->Group->find(
> 'count',
> array(
> 'conditions' => array(
> 'Group.id' => 1 // hard-coded for testing?
> ),
> 'joins' => array(
> array(
> 'type' => 'INNER',
> 'table' => 'groups_perms',
> 'alias' => 'GroupPerm',
> 'conditions' => array(
> 'GroupPerm.group_id' => 'Group.id'
> )
> ),
> array(
> 'type' => 'INNER',
> 'table' => 'perms',
> 'alias' => 'Perm',
> 'conditions' => array(
> 'GroupPerm.perm_id' => 'Perm.id'
> )
> )
> )
> )
> );
>
> However, I've left out the perm.id='can_access_admin' part because it
> makes no sense in the context of Cake. The id column should be an INT.
> I presume you mean something like 'Perm.type' => 'can_access_admin',
> in which case add it to the 2nd joins conditions array.
>
> On Wed, Jan 2, 2013 at 3:48 PM, Stefano Campanella
>  wrote:
>> mmh, ok. But the problem is that even if I change the find("count") into a
>> find("all") it still loads data only from Group table.
>>
>> Yes I am using the AuthComponent for logged in users. But since I want to
>> use my Authorize class also for managing what anonymous users can access I
>> am calling $this->Auth->isAuthorized() in the beforeFilter of AppController
>> with a $user parameter of array('id'=>0). Inside the authorize method I
>> recognize the empty user and make checks for permissions on an hard coded
>> group id. I checked this would work correctly, if only I could make the
>> query in the right way.
>>
>> Let's change the question. Which code would you write to make CakePHP
>> execute this query:
>>>
>>> SELECT COUNT(*) AS count FROM groups INNER JOIN groups_perms ON
>>> groups.id=groups_perms.group_id INNER JOIN perm ON
>>> groups_perms.perm_id=perm.id WHERE group.id=1 AND perm.id='can_access_admin'
>>
>> given that you have access to $this->controller()->Group?
>>
>> Thanks
>>
>> On Wednesday, January 2, 2013 7:59:24 PM UTC+1, cricket wrote:
>>>
>>> When running a find('count') the contain param is useless. This is
>>> because the main query is fetching a sum, not a set of records from
>>> which to fetch the associated 'contain' records.
>>>
>>> Are you using AuthComponent? You can use that to fetch the User and
>>> associated records. However, I can't remember how deep it goes. To see
>>> what records it has, put this in your UsersController login method:
>>>
>>> die(debug($this->Auth->user()));
>>>
>>>
>>> http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html#accessing-the-logged-in-user
>>>
>>> On Tue, Jan 1, 2013 at 5:23 PM, Stefano Campanella
>>>  wrote:
>>> > Hello all,
>>> > this is my first time posting here. I recently started to study how to
>>> > use
>>> > CakePHP and I'm trying to develop a website.
>>> > In my website I am writing a custom authorize component where each user
>>> > get
>>> > one or more groups and each group has one or more permissions associated
>>> > to
>>> > it.
>>> > I have problems in using the find() method.
>>> > This is my structure:
>>> > User hasAndBelongsToMany Group
>>> > Group hasAndBelongsToMany Perm
>>> >
>>> > I have attached Containable to all the Models (in AppModel)
>>> >
>>> > now in my authorization component I need to check if a group has a
>>> > specific
>>> > permission, and for this I use find():
>>> >
>>> >> if(!isset($this->controller()->Group)){
>>> >>   $this->controller()->loadModel('Group');
>>> >> }
>>> >> $n_perm=$this->controller()->Group->find('count',array(
>>> >>   'conditions'=>array('id'=>1),
>>> >>   'contain'=>array(
>>> >> 'Perm'=>array(
>>> >>   'conditions' => array('id'=>'can_access_admin')
>>> >> )
>>> >>   )
>>> >>
>>> >> ));
>>> >
>>> >
>>> > I would expect this to give me a result >=1 if group 1 has the
>>> > 'can_access_admin' permission, and =0 if the group has no such
>>> > permission.
>>> > This is not what actually happens, the only query that cakePHP shows is
>>> > this:
>>> >
>>> > SELECT COUNT(*) AS `count` FROM `groups` AS `Group` WHERE `id` = 1
>>> >
>>> > And it is obviously not enough to find what I reques

Re: queries on HABTM relationships

2013-01-02 Thread lowpass
I think that should be something like:

$data = $this->controller()->Group->find(
'count',
array(
'conditions' => array(
'Group.id' => 1 // hard-coded for testing?
),
'joins' => array(
array(
'type' => 'INNER',
'table' => 'groups_perms',
'alias' => 'GroupPerm',
'conditions' => array(
'GroupPerm.group_id' => 'Group.id'
)
),
array(
'type' => 'INNER',
'table' => 'perms',
'alias' => 'Perm',
'conditions' => array(
'GroupPerm.perm_id' => 'Perm.id'
)
)
)
)
);

However, I've left out the perm.id='can_access_admin' part because it
makes no sense in the context of Cake. The id column should be an INT.
I presume you mean something like 'Perm.type' => 'can_access_admin',
in which case add it to the 2nd joins conditions array.

On Wed, Jan 2, 2013 at 3:48 PM, Stefano Campanella
 wrote:
> mmh, ok. But the problem is that even if I change the find("count") into a
> find("all") it still loads data only from Group table.
>
> Yes I am using the AuthComponent for logged in users. But since I want to
> use my Authorize class also for managing what anonymous users can access I
> am calling $this->Auth->isAuthorized() in the beforeFilter of AppController
> with a $user parameter of array('id'=>0). Inside the authorize method I
> recognize the empty user and make checks for permissions on an hard coded
> group id. I checked this would work correctly, if only I could make the
> query in the right way.
>
> Let's change the question. Which code would you write to make CakePHP
> execute this query:
>>
>> SELECT COUNT(*) AS count FROM groups INNER JOIN groups_perms ON
>> groups.id=groups_perms.group_id INNER JOIN perm ON
>> groups_perms.perm_id=perm.id WHERE group.id=1 AND perm.id='can_access_admin'
>
> given that you have access to $this->controller()->Group?
>
> Thanks
>
> On Wednesday, January 2, 2013 7:59:24 PM UTC+1, cricket wrote:
>>
>> When running a find('count') the contain param is useless. This is
>> because the main query is fetching a sum, not a set of records from
>> which to fetch the associated 'contain' records.
>>
>> Are you using AuthComponent? You can use that to fetch the User and
>> associated records. However, I can't remember how deep it goes. To see
>> what records it has, put this in your UsersController login method:
>>
>> die(debug($this->Auth->user()));
>>
>>
>> http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html#accessing-the-logged-in-user
>>
>> On Tue, Jan 1, 2013 at 5:23 PM, Stefano Campanella
>>  wrote:
>> > Hello all,
>> > this is my first time posting here. I recently started to study how to
>> > use
>> > CakePHP and I'm trying to develop a website.
>> > In my website I am writing a custom authorize component where each user
>> > get
>> > one or more groups and each group has one or more permissions associated
>> > to
>> > it.
>> > I have problems in using the find() method.
>> > This is my structure:
>> > User hasAndBelongsToMany Group
>> > Group hasAndBelongsToMany Perm
>> >
>> > I have attached Containable to all the Models (in AppModel)
>> >
>> > now in my authorization component I need to check if a group has a
>> > specific
>> > permission, and for this I use find():
>> >
>> >> if(!isset($this->controller()->Group)){
>> >>   $this->controller()->loadModel('Group');
>> >> }
>> >> $n_perm=$this->controller()->Group->find('count',array(
>> >>   'conditions'=>array('id'=>1),
>> >>   'contain'=>array(
>> >> 'Perm'=>array(
>> >>   'conditions' => array('id'=>'can_access_admin')
>> >> )
>> >>   )
>> >>
>> >> ));
>> >
>> >
>> > I would expect this to give me a result >=1 if group 1 has the
>> > 'can_access_admin' permission, and =0 if the group has no such
>> > permission.
>> > This is not what actually happens, the only query that cakePHP shows is
>> > this:
>> >
>> > SELECT COUNT(*) AS `count` FROM `groups` AS `Group` WHERE `id` = 1
>> >
>> > And it is obviously not enough to find what I requested.
>> >
>> > Can anyone help me?
>> >
>> > Thanks
>> >
>> > --
>> > 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 post to this group, send email to cake...@googlegroups.com.
>> > To unsubscribe from this group, send email to
>> > cake-php+u...@googlegroups.com.
>> > Visit this group at http:/

Re: queries on HABTM relationships

2013-01-02 Thread Leonardo

Excuse me Ivan,
but there is no reference to userScope attribute anywhere in the source 
code of cakePHP, I assume you mean $this->Auth->scope.


But it still doesn't help me, is was under the impression that that 
attribute is used to impose conditions for logging users in, this is not 
my case, I am working on the Authorization not on the Authentication. 
Furthermore, can_access_admin is not a field of User and the scope 
attribute is considered only by the Authentication component not by the 
Authorization one as far as I know.


Thank you anyway :)

Il 02/01/2013 21.56, Ivan Rimac ha scritto:

This simply is solvable with:

$this->Auth->userScope = array('User.can_access_admin' => 1);

Put that in you beforeFilter function inside AppController, and your 
problems are solved. If you want to redirect them, than you shoukd do 
something like this:


if ($this->Auth->user()) {
if(isset($this->params['admin']) && $this->Auth->user('admin') 
!= 1) {

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

Hope this helps.
Cheers



On Wed, Jan 2, 2013 at 7:59 PM, lowpass > wrote:


When running a find('count') the contain param is useless. This is
because the main query is fetching a sum, not a set of records from
which to fetch the associated 'contain' records.

Are you using AuthComponent? You can use that to fetch the User and
associated records. However, I can't remember how deep it goes. To see
what records it has, put this in your UsersController login method:

die(debug($this->Auth->user()));


http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html#accessing-the-logged-in-user

On Tue, Jan 1, 2013 at 5:23 PM, Stefano Campanella
mailto:leona...@guildofmessengers.com>> wrote:
> Hello all,
> this is my first time posting here. I recently started to study
how to use
> CakePHP and I'm trying to develop a website.
> In my website I am writing a custom authorize component where
each user get
> one or more groups and each group has one or more permissions
associated to
> it.
> I have problems in using the find() method.
> This is my structure:
> User hasAndBelongsToMany Group
> Group hasAndBelongsToMany Perm
>
> I have attached Containable to all the Models (in AppModel)
>
> now in my authorization component I need to check if a group has
a specific
> permission, and for this I use find():
>
>> if(!isset($this->controller()->Group)){
>>   $this->controller()->loadModel('Group');
>> }
>> $n_perm=$this->controller()->Group->find('count',array(
>>   'conditions'=>array('id'=>1),
>>   'contain'=>array(
>> 'Perm'=>array(
>>   'conditions' => array('id'=>'can_access_admin')
>> )
>>   )
>>
>> ));
>
>
> I would expect this to give me a result >=1 if group 1 has the
> 'can_access_admin' permission, and =0 if the group has no such
permission.
> This is not what actually happens, the only query that cakePHP
shows is
> this:
>
> SELECT COUNT(*) AS `count` FROM `groups` AS `Group` WHERE `id` = 1
>
> And it is obviously not enough to find what I requested.
>
> Can anyone help me?
>
> Thanks
>
> --
> 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 post to this group, send email to cake-php@googlegroups.com
.
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com
.
> Visit this group at http://groups.google.com/group/cake-php?hl=en.
>
>

--
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 post to this group, send email to cake-php@googlegroups.com
.
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com
.
Visit this group at http://groups.google.com/group/cake-php?hl=en.





--
*Ivan Rimac*
mail: ivn...@gmail.com 
/tel: +385 95 555 99 66/
/http://ivanrimac.com/
--
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 post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.

Visit this group at http://groups.google.com/group/cake-php?hl=en.

Re: CAKEPHP 2.1.x on Pagodabox | foreach multiple items for each slide (bootstrap carousel)

2013-01-02 Thread SpazzyV
Sven - 
 It's not super elegant but you could use a straight for loop and just 
do some simple calculations to determine when you have done the third loop. 
Since I am not doing anything like yours, and don't have the full code 
there is no way for me to test. However, I believe I have walked the logic 
in my head a couple of times. Please let me know if this works...









 0) {
// Reset the ad counter
$adCount = 0;
// Open the next item
?>



Thanks,
Vinnie

On Tuesday, January 1, 2013 3:32:41 PM UTC-5, SvenP wrote:
>
> Everything from the source is there, like I said, everything works as 
> expected. 
> If I remove the if($indexValue == 0) exception then I first get a blank 
> slide and then the other Ads in slides.
> Now I want to change the code to display 3 Ads in each slide.
>
> Op 1-jan.-2013, om 21:05 heeft lowpass > 
> het volgende geschreven:
>
> But are you only trusting what the browser displays? Are the other
> elements there in the source? What do you see when you disable
> javascript? What about when you remove the "active" class?
>
> On Tue, Jan 1, 2013 at 2:10 PM, Sven Pype > 
> wrote:
>
> Hi,
>
> The whole thing works perfectly and shows 1 ad for each slide.
> My goal is to have 3 ads from the db in 1 slide...
>
> I can't find a solution for it whit a foreach loop...
>
> Thanks anyway.
>
> Sven
>
>
> On Tue, Jan 1, 2013 at 8:05 PM, lowpass > 
> wrote:
>
>
> Is it possible that the other divs are being generated, but are
> hidden? What do the item & active class rules look like? Or maybe some
> JS is keeping the others from displaying? Try disabling the carousel
> activation code.
>
> On Sun, Dec 30, 2012 at 1:55 PM, SvenP > 
> wrote:
>
> Yes,
>
> Each ad relates to a sponsor... works perfect.
>
> array(
>  (int) 0 => array(
>  'Ad' => array(
>  'id' => '2',
>  'sponsor_id' => '0',
>  'title' => '...',
>  'body' => '...',
>  'link' => 'wwwcom'
>  ),
>  'Sponsor' => array(
>  'id' => '8',
>  'name' => ...,
>  'contact_first_name' => ...,
>  'contact_name' => ...,
>  'contact_tel' => ...,
>  'contact_email' => ...
>  )
>  ),
>
>
> On Sunday, December 30, 2012 7:20:54 PM UTC+1, cricket wrote:
>
>
> die(debug($ads));
>
> Are you certain of the array structure?
>
> On Sat, Dec 29, 2012 at 5:39 PM, SvenP  wrote:
>
> Hi,
>
> I'm looking for a way to show multiple 'Ads' / slide with a foreach
> loop
> from the db. ( each client has ads tied to them.)
>
> My code now works great but only shows one ad / slide.
>
> Thanks for your time!
>
> Sven
>
> Code:
> ___
>
> 
>  $ad):
> if($indexValue == 0){?>
> 
>  $ad['Ad']['title']?>
> 
>  $ad['Ad']['body']?> } else { ?>
> 
>  $ad['Ad']['title']?>
> 
> 
>   
>
> --
> 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 post to this group, send email to cake...@googlegroups.com.
> To unsubscribe from this group, send email to
> cake-php+u...@googlegroups.com.
> Visit this group at http://groups.google.com/group/cake-php?hl=en.
>
>
>
> --
> 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 post to this group, send email to cake...@googlegroups.com
> .
> To unsubscribe from this group, send email to
> cake-php+u...@googlegroups.com .
> Visit this group at http://groups.google.com/group/cake-php?hl=en.
>
>
>
> --
> 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 post to this group, send email to cake...@googlegroups.com
> .
> To unsubscribe from this group, send email to
> cake-php+u...@googlegroups.com .
> Visit this group at http://groups.google.com/group/cake-php?hl=en.
>
>
>
> --
> 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 post to this group, send email to cake...@googlegroups.com
> .
> To unsubscribe from this group, send email to
> cake-php+u...@googlegroups.com .
> Visit this group at http://groups.google.com/group/cake-php?hl=en.
>
>
>
> -- 
> 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 post to this group, send email to cake...@googl

Re: queries on HABTM relationships

2013-01-02 Thread Ivan Rimac
This simply is solvable with:

$this->Auth->userScope = array('User.can_access_admin' => 1);

Put that in you beforeFilter function inside AppController, and your
problems are solved. If you want to redirect them, than you shoukd do
something like this:

if ($this->Auth->user()) {
if(isset($this->params['admin']) && $this->Auth->user('admin') !=
1) {
  $this->redirect('/');
}
}

Hope this helps.
Cheers



On Wed, Jan 2, 2013 at 7:59 PM, lowpass  wrote:

> When running a find('count') the contain param is useless. This is
> because the main query is fetching a sum, not a set of records from
> which to fetch the associated 'contain' records.
>
> Are you using AuthComponent? You can use that to fetch the User and
> associated records. However, I can't remember how deep it goes. To see
> what records it has, put this in your UsersController login method:
>
> die(debug($this->Auth->user()));
>
>
> http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html#accessing-the-logged-in-user
>
> On Tue, Jan 1, 2013 at 5:23 PM, Stefano Campanella
>  wrote:
> > Hello all,
> > this is my first time posting here. I recently started to study how to
> use
> > CakePHP and I'm trying to develop a website.
> > In my website I am writing a custom authorize component where each user
> get
> > one or more groups and each group has one or more permissions associated
> to
> > it.
> > I have problems in using the find() method.
> > This is my structure:
> > User hasAndBelongsToMany Group
> > Group hasAndBelongsToMany Perm
> >
> > I have attached Containable to all the Models (in AppModel)
> >
> > now in my authorization component I need to check if a group has a
> specific
> > permission, and for this I use find():
> >
> >> if(!isset($this->controller()->Group)){
> >>   $this->controller()->loadModel('Group');
> >> }
> >> $n_perm=$this->controller()->Group->find('count',array(
> >>   'conditions'=>array('id'=>1),
> >>   'contain'=>array(
> >> 'Perm'=>array(
> >>   'conditions' => array('id'=>'can_access_admin')
> >> )
> >>   )
> >>
> >> ));
> >
> >
> > I would expect this to give me a result >=1 if group 1 has the
> > 'can_access_admin' permission, and =0 if the group has no such
> permission.
> > This is not what actually happens, the only query that cakePHP shows is
> > this:
> >
> > SELECT COUNT(*) AS `count` FROM `groups` AS `Group` WHERE `id` = 1
> >
> > And it is obviously not enough to find what I requested.
> >
> > Can anyone help me?
> >
> > Thanks
> >
> > --
> > 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 post to this group, send email to cake-php@googlegroups.com.
> > To unsubscribe from this group, send email to
> > cake-php+unsubscr...@googlegroups.com.
> > Visit this group at http://groups.google.com/group/cake-php?hl=en.
> >
> >
>
> --
> 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 post to this group, send email to cake-php@googlegroups.com.
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com.
> Visit this group at http://groups.google.com/group/cake-php?hl=en.
>
>
>


-- 
*Ivan Rimac***
mail: ivn...@gmail.com
*tel: +385 95 555 99 66*
*http://ivanrimac.com*

-- 
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 post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Re: queries on HABTM relationships

2013-01-02 Thread Stefano Campanella
mmh, ok. But the problem is that even if I change the find("count") into a 
find("all") it still loads data only from Group table.

Yes I am using the AuthComponent for logged in users. But since I want to 
use my Authorize class also for managing what anonymous users can access I 
am calling $this->Auth->isAuthorized() in the beforeFilter of AppController 
with a $user parameter of array('id'=>0). Inside the authorize method I 
recognize the empty user and make checks for permissions on an hard coded 
group id. I checked this would work correctly, if only I could make the 
query in the right way.

Let's change the question. Which code would you write to make CakePHP 
execute this query:

> SELECT COUNT(*) AS count FROM groups INNER JOIN groups_perms ON 
> groups.id=groups_perms.group_id INNER JOIN perm ON 
> groups_perms.perm_id=perm.id WHERE group.id=1 AND perm.id='can_access_admin'

given that you have access to $this->controller()->Group?

Thanks

On Wednesday, January 2, 2013 7:59:24 PM UTC+1, cricket wrote:
>
> When running a find('count') the contain param is useless. This is 
> because the main query is fetching a sum, not a set of records from 
> which to fetch the associated 'contain' records. 
>
> Are you using AuthComponent? You can use that to fetch the User and 
> associated records. However, I can't remember how deep it goes. To see 
> what records it has, put this in your UsersController login method: 
>
> die(debug($this->Auth->user())); 
>
>
> http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html#accessing-the-logged-in-user
>  
>
> On Tue, Jan 1, 2013 at 5:23 PM, Stefano Campanella 
> > wrote: 
> > Hello all, 
> > this is my first time posting here. I recently started to study how to 
> use 
> > CakePHP and I'm trying to develop a website. 
> > In my website I am writing a custom authorize component where each user 
> get 
> > one or more groups and each group has one or more permissions associated 
> to 
> > it. 
> > I have problems in using the find() method. 
> > This is my structure: 
> > User hasAndBelongsToMany Group 
> > Group hasAndBelongsToMany Perm 
> > 
> > I have attached Containable to all the Models (in AppModel) 
> > 
> > now in my authorization component I need to check if a group has a 
> specific 
> > permission, and for this I use find(): 
> > 
> >> if(!isset($this->controller()->Group)){ 
> >>   $this->controller()->loadModel('Group'); 
> >> } 
> >> $n_perm=$this->controller()->Group->find('count',array( 
> >>   'conditions'=>array('id'=>1), 
> >>   'contain'=>array( 
> >> 'Perm'=>array( 
> >>   'conditions' => array('id'=>'can_access_admin') 
> >> ) 
> >>   ) 
> >> 
> >> )); 
> > 
> > 
> > I would expect this to give me a result >=1 if group 1 has the 
> > 'can_access_admin' permission, and =0 if the group has no such 
> permission. 
> > This is not what actually happens, the only query that cakePHP shows is 
> > this: 
> > 
> > SELECT COUNT(*) AS `count` FROM `groups` AS `Group` WHERE `id` = 1 
> > 
> > And it is obviously not enough to find what I requested. 
> > 
> > Can anyone help me? 
> > 
> > Thanks 
> > 
> > -- 
> > 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 post to this group, send email to cake...@googlegroups.com. 
>
> > To unsubscribe from this group, send email to 
> > cake-php+u...@googlegroups.com . 
> > Visit this group at http://groups.google.com/group/cake-php?hl=en. 
> > 
> > 
>

-- 
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 post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Re: queries on HABTM relationships

2013-01-02 Thread lowpass
When running a find('count') the contain param is useless. This is
because the main query is fetching a sum, not a set of records from
which to fetch the associated 'contain' records.

Are you using AuthComponent? You can use that to fetch the User and
associated records. However, I can't remember how deep it goes. To see
what records it has, put this in your UsersController login method:

die(debug($this->Auth->user()));

http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html#accessing-the-logged-in-user

On Tue, Jan 1, 2013 at 5:23 PM, Stefano Campanella
 wrote:
> Hello all,
> this is my first time posting here. I recently started to study how to use
> CakePHP and I'm trying to develop a website.
> In my website I am writing a custom authorize component where each user get
> one or more groups and each group has one or more permissions associated to
> it.
> I have problems in using the find() method.
> This is my structure:
> User hasAndBelongsToMany Group
> Group hasAndBelongsToMany Perm
>
> I have attached Containable to all the Models (in AppModel)
>
> now in my authorization component I need to check if a group has a specific
> permission, and for this I use find():
>
>> if(!isset($this->controller()->Group)){
>>   $this->controller()->loadModel('Group');
>> }
>> $n_perm=$this->controller()->Group->find('count',array(
>>   'conditions'=>array('id'=>1),
>>   'contain'=>array(
>> 'Perm'=>array(
>>   'conditions' => array('id'=>'can_access_admin')
>> )
>>   )
>>
>> ));
>
>
> I would expect this to give me a result >=1 if group 1 has the
> 'can_access_admin' permission, and =0 if the group has no such permission.
> This is not what actually happens, the only query that cakePHP shows is
> this:
>
> SELECT COUNT(*) AS `count` FROM `groups` AS `Group` WHERE `id` = 1
>
> And it is obviously not enough to find what I requested.
>
> Can anyone help me?
>
> Thanks
>
> --
> 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 post to this group, send email to cake-php@googlegroups.com.
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com.
> Visit this group at http://groups.google.com/group/cake-php?hl=en.
>
>

-- 
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 post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Re: CakePHP 1.2 Layout error

2013-01-02 Thread lowpass
My guess is that one of your files contains a byte-order mark (BOM)
which you should remove. What editor are you using?

Be sure to check not only your layout template, but any view or
element templates as well.

On Wed, Jan 2, 2013 at 1:39 AM, Marcus James  wrote:
> Hi,
>
> I made a custom layout for admin panel. The problem is when i validated my
> HTML i am getting an error
>
> " Non-space characters found without seeing a doctype first. Expected
> ."
>
> On Firefox the layout renders perfectly when i inspect it but on google
> chrome its showing an empty space inside body tag and all the html tag is
> going inside body tag.
>
> Any idea what the problem is?
>
>
> --
> 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 post to this group, send email to cake-php@googlegroups.com.
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com.
> Visit this group at http://groups.google.com/group/cake-php?hl=en.
>
>

-- 
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 post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Re: I want to change password using cake php

2013-01-02 Thread Paulo Braga
Ok, you want to change a password in cake.

you have to have somthing like this:

old password: _
new password: 
confirm new password:

right??

so first you have to make a method in UsersController called 
changePassword(){}
and a view in foldes Users called change_password.ctp

in the change password you have to put:

  public function changePassword($id = null) { 
if ($this->data) { 
if ($this->User->save($this->data)) 
$this->Session->setFlash('Password changed successfully'); 
else
$this->Session->setFlash('The password was not changed'); 
} else { 
$this->data = $this->User->read(null, $id); 
} 
}

in change_password.ctp:

Form->create();?> 
Form->input('id');?> 
Form->input('current_password',array('type'=>'password'));?> 
Form->input('password',array('label'=>'New 
password','value'=>''));?> 
Form->input('password_confirmation',array('label'=>'confirm your 
password','type'=>'password', 'value'=>''));?> 
Form->end('change');?>

in User model put:

public $validate = array( 
 
'password' => array( 
'Not empty' => array( 
'rule' => 'notEmpty', 'message' => 'please enter your 
password' 
), 
'Match passwords' => array( 
'rule' => 'matchPasswords', 
'message' => 'your passwords do not match' 
) 
), 
'password_confirmation' => array( 
'Not empty' => array( 
'rule' => 'notEmpty', 'message' => 'please confirm your 
password' 
) 
), 
'current_password' => array( 
'notempty' => array('rule' => 'notEmpty', 'message' => 'please 
enter your old password'), 
'check password' => array('rule' => 'checkPassword', 
'message' => 'your password is not correct') 
)
);

public function matchPasswords($data) { 
if ($data['password'] == 
$this->data['User']['password_confirmation']) 
return true; 
$this->invalidate('password_confirmation', 'your passwords do not 
match'); 
return false; 
} 
 
public function checkPassword($data) { 
$user1=new User(); 
$user=$user1->read(null,  $this->data['User']['id']); 

$current_password=AuthComponent::password($data['current_password']); 
if($current_password==$user['User']['password']){ 
return true; 
 
} 
return false; 
 
}



On Tuesday, December 25, 2012 4:24:10 PM UTC+2, sweety wrote:
>
>
>

-- 
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 post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Re: Cake 2.2 Auth login failure

2013-01-02 Thread Paulo Braga
Post your AppController and UsersController(login method), and a screenshot 
of your users table.

On Monday, December 31, 2012 11:40:48 PM UTC+2, Martin Halla wrote:
>
> Hi,
>
> I have this app that uses the Auth component for login Everything works on 
> the local machine, but fails big time live at :
>
> http://ncln.halladesign.com
>
> Can you tell me why ?
>
> Here are more details :
>
> user : te...@test.com  
> password : password
> acl plugin by alexo
>
> Thanks!
>
>

-- 
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 post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Re: queries on HABTM relationships

2013-01-02 Thread Stefano Campanella
Yes I did, but it does not suit my needs or my organization structure. For 
me it's at the same time too complicated and too limited. I don't need a 
tree, I need a graph, where a user can have more than one group; because 
users can be categorized in more than one way.

Anyway, do you have any idea of why the query is not executed correctly? 
>From the CakePHP Book I got the impression that that was the correct way to 
make that kind of search.

-- 
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 post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Re: Different columns for different languages?

2013-01-02 Thread Salines
Hi, all you need is to use TranslateBehavior

http://book.cakephp.org/2.0/en/core-libraries/behaviors/translate.html

-- 
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 post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Different columns for different languages?

2013-01-02 Thread marcus33cz
Hi all,

I'm currently learning cakePHP and here's one thing I have no idea how to 
solve.

I have a table named "countries" (id, iso, name, iso3, numcode) which is 
also a Model (with a controller and some views).

This table contains 239 entries - all of them have their name (such as 
"Germany" etc). What if I wanted to translate the "name" column to other 
languages?
So that for example in French version of the app it would say "Allemagne", 
in English it would say "Germany"...

I've already checked i18n and I'm using the __() function elsewhere in my 
application. But I'm not really sure how should I do this.

If I copy the names from the database into some language files, every name 
will appear twice in the app - that's against the DRY principle.
And if some new country is formed and is added to the database, it would be 
missing in the language file.

What's the right way to do this?

THanks a lot!

-- 
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 post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.