Re: What is the proper way of testing controllers in CakePHP 2.0

2011-08-24 Thread Christophe Roblin
No, $this->headers seems to always return an empty array

On 25 Aug, 06:02, jeremyharris  wrote:
> When you debug the $this->headers var, what do you get back? Anything
> at all?
>
> If you're not getting anything back then it might be a problem with
> testAction, although there are tests that show it works.
>
> On Aug 21, 1:48 am, Christophe Roblin  wrote:
>
>
>
>
>
>
>
> > Hi,
>
> > I've tried searching the new docs about testing with the new PHPUnit
> > for CakePHP 2.0 Beta, without any success
> > Below is my code for testing the admin action of controller posts with
> > method add.
>
> > My issue is that I expected from the docs I received that headers were
> > set when using testAction, it is always blank
>
> >         public function testAdminAdd() {
> >             $Posts = $this->generate('Posts', array(
> >                 'components' => array(
> >                     'Session'
> >                     )
> >                 )
> >             );
>
> >             $Posts->Session->expects($this->once())-
>
> > >method('setFlash');
>
> >             $this->testAction('/admin/posts/add', array(
> >                 'data' => array(
> >                     'Post' => array('name' => 'New Post')
> >                     )
> >                 )
> >             );
> >            // debug($this);
> >             $this->assertEquals($this->headers['Location'], '/admin/
> > posts/index');
> >             $this->assertEquals($this->vars['post']['Post']['name'],
> > 'New Post');
>
> >             $this->assertPattern('/contents);
> >             $this->assertPattern('/view);

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: What is the proper way of testing controllers in CakePHP 2.0

2011-08-24 Thread jeremyharris
When you debug the $this->headers var, what do you get back? Anything
at all?

If you're not getting anything back then it might be a problem with
testAction, although there are tests that show it works.

On Aug 21, 1:48 am, Christophe Roblin  wrote:
> Hi,
>
> I've tried searching the new docs about testing with the new PHPUnit
> for CakePHP 2.0 Beta, without any success
> Below is my code for testing the admin action of controller posts with
> method add.
>
> My issue is that I expected from the docs I received that headers were
> set when using testAction, it is always blank
>
>         public function testAdminAdd() {
>             $Posts = $this->generate('Posts', array(
>                 'components' => array(
>                     'Session'
>                     )
>                 )
>             );
>
>             $Posts->Session->expects($this->once())-
>
> >method('setFlash');
>
>             $this->testAction('/admin/posts/add', array(
>                 'data' => array(
>                     'Post' => array('name' => 'New Post')
>                     )
>                 )
>             );
>            // debug($this);
>             $this->assertEquals($this->headers['Location'], '/admin/
> posts/index');
>             $this->assertEquals($this->vars['post']['Post']['name'],
> 'New Post');
>
>             $this->assertPattern('/contents);
>             $this->assertPattern('/view);

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: multiple controller in one model

2011-08-24 Thread Mohd Hasnol
ok thanks.solved already.

On Thu, Aug 25, 2011 at 1:37 AM, Ryan Schmidt wrote:

>
> On Aug 24, 2011, at 07:59, Mohd Hasnol wrote:
>
> > Let me explain. i have 2 roles which are admin and members.it can be
> many admin and members. For admin i can add new admin using add function in
> users controller and using users table. For member i would like using add
> function in members controller and members table since members have many
> attributes(username, password,name,etc..) compare to users table(only
> username and password).
> >
> > Then, the login function need username and password in users table. How
> could i use username and password in members table to login?
> >
> > In this situation, admin will set the username and password for the
> member. But then member can change it after they login.
>
> Put *all* users -- whether admins or members -- into a single "users"
> table. You could add a "role" field to it to distinguish admins from
> members.
>
> It probably doesn't matter if the admins have extra fields in the table
> that don't get filled in.
>
>
> --
> Our newest site for the community: CakePHP Video Tutorials
> http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help
> others with their CakePHP related questions.
>
>
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group
> at http://groups.google.com/group/cake-php
>

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: multiple controller in one model

2011-08-24 Thread Ryan Schmidt

On Aug 24, 2011, at 07:59, Mohd Hasnol wrote:

> Let me explain. i have 2 roles which are admin and members.it can be many 
> admin and members. For admin i can add new admin using add function in users 
> controller and using users table. For member i would like using add function 
> in members controller and members table since members have many 
> attributes(username, password,name,etc..) compare to users table(only 
> username and password).
> 
> Then, the login function need username and password in users table. How could 
> i use username and password in members table to login?
> 
> In this situation, admin will set the username and password for the member. 
> But then member can change it after they login.

Put *all* users -- whether admins or members -- into a single "users" table. 
You could add a "role" field to it to distinguish admins from members.

It probably doesn't matter if the admins have extra fields in the table that 
don't get filled in.


-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: odd problem for reading session

2011-08-24 Thread euromark
either way you should omit the trailing ?> anyway - in all php files


On 24 Aug., 17:34, Teddy Zeenny  wrote:
> Are there any spaces or new line characters after the " ?> "  ?
>
>
>
>
>
>
>
> On Wed, Aug 24, 2011 at 6:22 PM, pang  wrote:
> > Hi,
>
> > I met a very odd problem, I create a new controller which request user
> > session to access. the session name is called "User".
>
> > When I have ?> at the end of the controller file, I can't read session
> > data, $this->Session->read('User') is empty,
>
> > But when I delete the trail signs  ?> in the controller file, the
> > session can be read successfully.
>
> > I am wondering what's the root cause of this problem?
>
> > --
> > Our newest site for the community: CakePHP Video Tutorials
> >http://tv.cakephp.org
> > Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help
> > others with their CakePHP related questions.
>
> > To unsubscribe from this group, send email to
> > cake-php+unsubscr...@googlegroups.com For more options, visit this group
> > athttp://groups.google.com/group/cake-php

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: How come this isn't a safe way to store username and passwords

2011-08-24 Thread crazysarahtemple...@aol.com
Wow. That was the most comprehensive answer I have ever had to any
question ever! Thanks for all that.

I think I'm going to have to go off and do some learning to achieve
all that but clearly the first step is get the sensitive stuff into
the database. Thanks for explaining everything so clearly.

:)



On Aug 24, 4:12 pm, Ben McClure  wrote:
> Sarah,
>
> Regarding point 1, if they got into your web server via FTP, they would have
> no way of initiating a database connection to get at the data. If they
> actually broke into your web server directly, then it is true that they
> could look up your database connection details and run MySQL queries against
> it.
>
> However, if they broke into your web server as such, They would have access
> to a lot more information than that.
>
> Regarding point 2, you're absolutely right--if the file is outside of the
> webroot, then only point 1 applies to it. If the file were in the webroot
> and the web server were misconfigured, then all PHP code in the files in the
> webroot would be displayed exactly as it was typed by the
> developer--obviously not a good situation when sensitive information is at
> stake :)
>
> I think the database is the way to go. You have the option of getting a bit
> clever with how you store the information... you could use a two-way
> encryption method to encrypt the key for storage in the database, and
> encrypt/decrypt it using a random hash value that you set in your config
> file. The obvious hole in this setup is that the web server HAS to know how
> to decrypt and view the API key, so someone who has access to your web
> server has the ability to perform those same actions if they know how.
>
> One possible way around this is creating a complex algorithm for modifying
> the hash based on some other value(s) and encrypting and decrypting the
> information, and then obfuscating the PHP code so that it's not obvious what
> it is doing. You could use a freely available PHP obfuscator for this.
>
> In this scenario, to get access to your API key, someone would have to:
>
>    1. Break into your web server (FTP wouldn't work)
>    2. Get your database connection details and encryption/decryption hash
>    3. Find the obfuscated code which performs the decryption
>    4. De-obfuscate the code so they can figure out the procedure
>    5. Query the database for the encrypted key
>    6. Decrypt the key
>
> So while not 100% secure, everything you do to secure the key adds another
> layer of protection that makes it more likely to be safe.
>
> Unfortunately, there is no way to 100% securely store secure information
> that your web server knows how to read automatically. You can keep making it
> more and more secure, but someone will always be able to trace those steps
> back to your secure information if they know how.
>
> Either way, the key is to add some additional layers between the API key and
> your application--the database is one layer that goes a long way toward that
> goal.
>
> I hope that was of some assistance, and let me know if I can try to help any
> further. Thanks,
>
> Ben

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: debug level on ajax request

2011-08-24 Thread Ben McClure
Fixing warnings and notices is not the answer to his question--With debug 
mode off, he should not be getting such messages displayed. At worse, he 
should be seeing formatted Cake errors or simply a blank page if something 
is wrong.

Perhaps the warnings/notices/errors are being thrown before you call 
Configure::write('debug', 
0); ? If so, try calling it earlier in your code.

Or perhaps something else is changing the value of debug back to 1 or 
greater?

You could echo something from inside that if() block to make sure it is 
actually hitting the code which sets the debug value to 0.

Beyond that, I don't know what else to have you try :)

Ben

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: odd problem for reading session

2011-08-24 Thread Teddy Zeenny
Are there any spaces or new line characters after the " ?> "  ?

On Wed, Aug 24, 2011 at 6:22 PM, pang  wrote:

> Hi,
>
> I met a very odd problem, I create a new controller which request user
> session to access. the session name is called "User".
>
> When I have ?> at the end of the controller file, I can't read session
> data, $this->Session->read('User') is empty,
>
> But when I delete the trail signs  ?> in the controller file, the
> session can be read successfully.
>
>
> I am wondering what's the root cause of this problem?
>
> --
> Our newest site for the community: CakePHP Video Tutorials
> http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help
> others with their CakePHP related questions.
>
>
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group
> at http://groups.google.com/group/cake-php
>

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: How come this isn't a safe way to store username and passwords

2011-08-24 Thread Ben McClure
Sarah,

Regarding point 1, if they got into your web server via FTP, they would have 
no way of initiating a database connection to get at the data. If they 
actually broke into your web server directly, then it is true that they 
could look up your database connection details and run MySQL queries against 
it.

However, if they broke into your web server as such, They would have access 
to a lot more information than that.

Regarding point 2, you're absolutely right--if the file is outside of the 
webroot, then only point 1 applies to it. If the file were in the webroot 
and the web server were misconfigured, then all PHP code in the files in the 
webroot would be displayed exactly as it was typed by the 
developer--obviously not a good situation when sensitive information is at 
stake :)

I think the database is the way to go. You have the option of getting a bit 
clever with how you store the information... you could use a two-way 
encryption method to encrypt the key for storage in the database, and 
encrypt/decrypt it using a random hash value that you set in your config 
file. The obvious hole in this setup is that the web server HAS to know how 
to decrypt and view the API key, so someone who has access to your web 
server has the ability to perform those same actions if they know how.

One possible way around this is creating a complex algorithm for modifying 
the hash based on some other value(s) and encrypting and decrypting the 
information, and then obfuscating the PHP code so that it's not obvious what 
it is doing. You could use a freely available PHP obfuscator for this.

In this scenario, to get access to your API key, someone would have to:

   1. Break into your web server (FTP wouldn't work)
   2. Get your database connection details and encryption/decryption hash
   3. Find the obfuscated code which performs the decryption
   4. De-obfuscate the code so they can figure out the procedure
   5. Query the database for the encrypted key
   6. Decrypt the key

So while not 100% secure, everything you do to secure the key adds another 
layer of protection that makes it more likely to be safe.

Unfortunately, there is no way to 100% securely store secure information 
that your web server knows how to read automatically. You can keep making it 
more and more secure, but someone will always be able to trace those steps 
back to your secure information if they know how.

Either way, the key is to add some additional layers between the API key and 
your application--the database is one layer that goes a long way toward that 
goal.

I hope that was of some assistance, and let me know if I can try to help any 
further. Thanks,

Ben

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


odd problem for reading session

2011-08-24 Thread pang
Hi,

I met a very odd problem, I create a new controller which request user
session to access. the session name is called "User".

When I have ?> at the end of the controller file, I can't read session
data, $this->Session->read('User') is empty,

But when I delete the trail signs  ?> in the controller file, the
session can be read successfully.


I am wondering what's the root cause of this problem?

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Media Plugin Tutorial

2011-08-24 Thread Ben McClure
Here's a simple tutorial to help get you started:

http://sopix.wordpress.com/2010/12/28/media-plugin-of-cakephp-tutorial/

Ben

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: debug level on ajax request

2011-08-24 Thread p r
yes you're right. but the debug mode is for developing purposes and my
question belongs to control the debug mode in app controller.


On 22 Aug., 10:28, "Dr. Loboto"  wrote:
> The best way is to fix that warnings and notices. Good app never
> throws this kind of shit.
>
> On 18 авг, 20:18, p r  wrote:
>
>
>
>
>
>
>
> > yes the Requesthandler is in use and the debug level is set correctly
> > to 0 but errors and notices doesn't care.
> > It seems the backtrace is added before the debug level is set in
> > AppController? When i set the debug level in core.php it works as i
> > desired.
>
> > On 18 Aug., 15:06, mi...@brightstorm.co.uk wrote:
>
> > > > Hello,
>
> > > > could anybody explain this behavior? i set in my app controller
>
> > > > if($this->RequestHandler->isAjax()) {
> > > >                    $this->layout = 'ajax';
> > > >                    $this->autoRender = false;
> > > >                    Configure::write('debug', 0);
> > > > }
>
> > > > but notices and errors are even so sent. only when i set in core.php
> > > > the debug level to 0, no notices etc. occures.
>
> > > if requesthandler is working, you can do
>
> > >  if($this->params['isAjax']==1) {
> > >                         $this->layout = 'ajax';
> > >                         $this->autoRender = false;
> > >                         Configure::write('debug', 0);
> > >  }
>
> > > > greetings
>
> > > > --
> > > > Our newest site for the community: CakePHP Video Tutorials
> > > >http://tv.cakephp.org
> > > > Check out the new CakePHP Questions sitehttp://ask.cakephp.organdhelp
> > > > others with their CakePHP related questions.
>
> > > > To unsubscribe from this group, send email to
> > > > cake-php+unsubscr...@googlegroups.com For more options, visit this group
> > > > athttp://groups.google.com/group/cake-php

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: multiple controller in one model

2011-08-24 Thread Mohd Hasnol
is it using joint table? But im not clear about it. Sorry, im newbie.

On Wed, Aug 24, 2011 at 8:59 PM, Mohd Hasnol  wrote:

> Hi,
>  Sorry :).
>
> Let me explain. i have 2 roles which are admin and members.it can be many
> admin and members. For admin i can add new admin using add function in users
> controller and using users table. For member i would like using add function
> in members controller and members table since members have many
> attributes(username, password,name,etc..) compare to users table(only
> username and password).
>
> Then, the login function need username and password in users table. How
> could i use username and password in members table to login?
>
> In this situation, admin will set the username and password for the member.
> But then member can change it after they login.
>
> Thanks.
>
> On Wed, Aug 24, 2011 at 8:17 PM, euromark wrote:
>
>> maybe its just me - but i really can't follow you.
>> after reading it three times :)
>>
>> also the headline does not seem to make sense to me..
>> please clarify (with live example code etc)
>>
>>
>>
>> On 24 Aug., 11:18, nOLL  wrote:
>> > Hi,
>> >
>> > Is it possible to add in attributes from multiple controller into one
>> > model?
>> >
>> > I would like to use certain attributes from other model(username and
>> > password only in members table) into users table.
>> > therefore, members could login to the website based on username and
>> > password that fill in by the admin from the add member function in
>> > members controller.(not using add function in users controller).
>> >
>> > Thanks.
>>
>> --
>> Our newest site for the community: CakePHP Video Tutorials
>> http://tv.cakephp.org
>> Check out the new CakePHP Questions site http://ask.cakephp.org and help
>> others with their CakePHP related questions.
>>
>>
>> To unsubscribe from this group, send email to
>> cake-php+unsubscr...@googlegroups.com For more options, visit this group
>> at http://groups.google.com/group/cake-php
>>
>
>

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: multiple controller in one model

2011-08-24 Thread Mohd Hasnol
Hi,
 Sorry :).

Let me explain. i have 2 roles which are admin and members.it can be many
admin and members. For admin i can add new admin using add function in users
controller and using users table. For member i would like using add function
in members controller and members table since members have many
attributes(username, password,name,etc..) compare to users table(only
username and password).

Then, the login function need username and password in users table. How
could i use username and password in members table to login?

In this situation, admin will set the username and password for the member.
But then member can change it after they login.

Thanks.

On Wed, Aug 24, 2011 at 8:17 PM, euromark wrote:

> maybe its just me - but i really can't follow you.
> after reading it three times :)
>
> also the headline does not seem to make sense to me..
> please clarify (with live example code etc)
>
>
>
> On 24 Aug., 11:18, nOLL  wrote:
> > Hi,
> >
> > Is it possible to add in attributes from multiple controller into one
> > model?
> >
> > I would like to use certain attributes from other model(username and
> > password only in members table) into users table.
> > therefore, members could login to the website based on username and
> > password that fill in by the admin from the add member function in
> > members controller.(not using add function in users controller).
> >
> > Thanks.
>
> --
> Our newest site for the community: CakePHP Video Tutorials
> http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help
> others with their CakePHP related questions.
>
>
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group
> at http://groups.google.com/group/cake-php
>

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: How come this isn't a safe way to store username and passwords

2011-08-24 Thread crazysarahtemple...@aol.com
Hey there Ben, thanks for the reply, I understand what you're saying
but have a couple of questions:

With regards you point 1 - if someone got access to your web server
would they not be able to get onto your database and get at the paypal
info anyway?

Re point 2 - crikey, database is the way to go then! But also, the way
that tutorial stores the password it's in an included file and the
included file is not located in the webroot. I had read somewhere that
if you do that and the php code was shown then they'd only be able to
see the variable $password rather than the contents of that variable.
Is that right?

It's all very confusing! I really appreciate your knowledge

Sarah





On Aug 24, 6:22 am, Ben McClure  wrote:
> You have to store your API key somewhere, and your site needs to know how to
> retrieve it.
>
> There are two main issues with storing it directly in the file:
>
>    1. As already stated, if someone gets access to your web server or FTP
>    information, they'll have your PayPal API information as well.
>    2. If your web server ever gets misconfigured and displays the actual PHP
>    code on the browser (not uncommon), your API key will be shown to anyone 
> who
>    views that URL.
>
> It might make more sense to store those details in your application's
> database, which, as also mentioned previously, should not be accessible from
> anywhere but your web server.
>
> Ben

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: multiple controller in one model

2011-08-24 Thread euromark
maybe its just me - but i really can't follow you.
after reading it three times :)

also the headline does not seem to make sense to me..
please clarify (with live example code etc)



On 24 Aug., 11:18, nOLL  wrote:
> Hi,
>
> Is it possible to add in attributes from multiple controller into one
> model?
>
> I would like to use certain attributes from other model(username and
> password only in members table) into users table.
> therefore, members could login to the website based on username and
> password that fill in by the admin from the add member function in
> members controller.(not using add function in users controller).
>
> Thanks.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Subquery or something else?

2011-08-24 Thread Jens Dittrich
There is a cake way for creating subqueries!

See: http://book.cakephp.org/view/1030/Complex-Find-Conditions and scroll 
down to the section Sub-queries.

There is an example how to build subqueries the cake way and get efficient 
calls to the database.
I would suggest that you are trying to hit the database as little as 
possible to avoid upcoming bottlenecks.

regards,
Jens

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: development best practices

2011-08-24 Thread luca capra

Hi, I'm trying to do the same with latest Cake2.0

/app/Controller/AppController.php/

App::uses('Controller', 'MyAppController');

class AppController extends MyAppController {
function test(){ die("boo"); }

}


but cake can't find the Controller/MyAppController.php file ("Fatal 
error: Class 'MyAppController' not found")

I've tryed /Lib, /app/Lib, app/Controller without success..

Thanks in advance.
Luca

On 16/08/2011 10:08, euromark wrote:

I use a plugin "tools" where I have my "own" AppController, .. etc as
Libs:
/libs/my_app_controller.php
MyAppController extends Controller {}

now I can use in all projects:
AppController extends MyAppController {}

same for all other classes



--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.



To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


multiple controller in one model

2011-08-24 Thread nOLL
Hi,

Is it possible to add in attributes from multiple controller into one
model?

I would like to use certain attributes from other model(username and
password only in members table) into users table.
therefore, members could login to the website based on username and
password that fill in by the admin from the add member function in
members controller.(not using add function in users controller).

Thanks.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Component causing AppController to fail in 2.0 beta

2011-08-24 Thread Ben McClure
Debug was already set to the highest level listed (2). I get errors for 
everything else, but apparently in CakePHP 2.0 Beta, there is some strange 
behavior if you don't enable a plugin but try to use it:

1. Component added to AppController for a non-enabled plugin made the entire 
AppController not run, but did not display any error messages. It simply 
acted as if I did not have a custom AppController defined.

2. Helper added to AppController for a non-enabled plugin was less 
catastrophic--it simply didn't work until I enabled the plugin.

I find it odd that if you try to use a model from a disabled plugin, you get 
a nice exception in CakePHP, but if you try to use a component or helper 
from a disabled plugin, it silently fails.

Ben

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: CakePHP 2.0 beta - AppController issue

2011-08-24 Thread Ben McClure
That was the first thing I changed--the problem turned out to be that I 
wasn't enabling the module in bootstrap.php. Whoops!

Thanks,

Ben

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: accessing field of paginate array in my view

2011-08-24 Thread Tomfox Wiranata
and to differ between one attribute "visible=true" and "visible=false"
i wanted to make two paginates with the same model in the same view.
but that wont work in cake...

On Aug 24, 10:03 am, Tomfox Wiranata 
wrote:
> i wouldnt be surprised if i did :).
> but i am using the same action "profile" because the index of the
> books is shown on that profile... or to be more specific, in the view
> "profile.ctp" i included an
> "$this->element" that shows all books, that each user is following.
>
> that is, why i am using one paginator. it happens all in one
> controller, in my view/action "profile"
>
> On Aug 24, 9:04 am, WebbedIT  wrote:
>
>
>
> > Tomfox,
>
> > I think you're approaching this from the wrong angle.
>
> > When a user is viewing their profile you're running a different action
> > to when viewing the index of books. In each of these actions you would
> > run different paginates/finds on the book model to find what you're
> > after.
>
> > /users/profile/$username: Book.user_id=>$user_id
>
> > /books/index: Book.is_visible=>1
>
> > HTH, Paul
>
> > On Aug 23, 10:01 pm, Tomfox Wiranata 
> > wrote:
>
> > > hi everyone,
>
> > > i have the object book with its attribute visible as boolean. i wanna
> > > use pagination and it works except for one thing.
>
> > > first i did two "this->paginate" in my controller. one with visible
> > > condition true and the other with false. but cake doesnt like two
> > > paginations in one controller.
>
> > > so i just returned any book, that a user "follows", no matter if it is
> > > set to visible true or false.
>
> > > controller:
> > >         public $paginate = array('Book' => array('limit' => 1, 'joins' =>
> > > array(
> > >         array(
> > >             'table' => 'books_users',
> > >             'alias' => 'BookUser',
> > >             'conditions'=> array('BookUser.fk_book_id = Book.id AND
> > > Book.locked = false')
> > >         )
> > >     )));
>
> > > NOW in my view, i want to make the distinction. when the user is
> > > visiting his own profile, non visible books are listed, since these
> > > are his own. if someone visits a another profile, the non visible
> > > books shall not appear.
>
> > > view:
>
> > > if ($user['User']['username'] == $this->Session->read('User.username'))
> > > {
>
> > >      if ($private_books['BookUser']['BooksUser']['visible'] = 'true')
> > >      ...show
>
> > >      else
> > >      ...dont show
>
> > > Problem: i cant access the visible field from the pagination array,
> > > that looks like that
>
> > > [BookUser] => Array
> > >         (
> > >             [0] => Array
> > >                 (
> > >             [firstname] => test
> > >             [lastname] => user
> > >             [username] => testuser
>
> > >             [BooksUser] => Array
> > >                 (
>
> > >                     >>     [visible] => 1
> > > <<
> > >                 )
>
> > >         )
>
> > > )
>
> > > }
>
> > > so how can i access the visible here? I tried
>
> > >   if ($private_books['BookUser']['BooksUser']['visible'] = 1)
>
> > > but it didnt work
>
> > > thanks :)- Hide quoted text -
>
> > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Component causing AppController to fail in 2.0 beta

2011-08-24 Thread Ceeram
Turn on debug, it should,have shown an error message about the plugin not 
being loaded

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: accessing field of paginate array in my view

2011-08-24 Thread Tomfox Wiranata
i wouldnt be surprised if i did :).
but i am using the same action "profile" because the index of the
books is shown on that profile... or to be more specific, in the view
"profile.ctp" i included an
"$this->element" that shows all books, that each user is following.

that is, why i am using one paginator. it happens all in one
controller, in my view/action "profile"




On Aug 24, 9:04 am, WebbedIT  wrote:
> Tomfox,
>
> I think you're approaching this from the wrong angle.
>
> When a user is viewing their profile you're running a different action
> to when viewing the index of books. In each of these actions you would
> run different paginates/finds on the book model to find what you're
> after.
>
> /users/profile/$username: Book.user_id=>$user_id
>
> /books/index: Book.is_visible=>1
>
> HTH, Paul
>
> On Aug 23, 10:01 pm, Tomfox Wiranata 
> wrote:
>
>
>
> > hi everyone,
>
> > i have the object book with its attribute visible as boolean. i wanna
> > use pagination and it works except for one thing.
>
> > first i did two "this->paginate" in my controller. one with visible
> > condition true and the other with false. but cake doesnt like two
> > paginations in one controller.
>
> > so i just returned any book, that a user "follows", no matter if it is
> > set to visible true or false.
>
> > controller:
> >         public $paginate = array('Book' => array('limit' => 1, 'joins' =>
> > array(
> >         array(
> >             'table' => 'books_users',
> >             'alias' => 'BookUser',
> >             'conditions'=> array('BookUser.fk_book_id = Book.id AND
> > Book.locked = false')
> >         )
> >     )));
>
> > NOW in my view, i want to make the distinction. when the user is
> > visiting his own profile, non visible books are listed, since these
> > are his own. if someone visits a another profile, the non visible
> > books shall not appear.
>
> > view:
>
> > if ($user['User']['username'] == $this->Session->read('User.username'))
> > {
>
> >      if ($private_books['BookUser']['BooksUser']['visible'] = 'true')
> >      ...show
>
> >      else
> >      ...dont show
>
> > Problem: i cant access the visible field from the pagination array,
> > that looks like that
>
> > [BookUser] => Array
> >         (
> >             [0] => Array
> >                 (
> >             [firstname] => test
> >             [lastname] => user
> >             [username] => testuser
>
> >             [BooksUser] => Array
> >                 (
>
> >                     >>     [visible] => 1
> > <<
> >                 )
>
> >         )
>
> > )
>
> > }
>
> > so how can i access the visible here? I tried
>
> >   if ($private_books['BookUser']['BooksUser']['visible'] = 1)
>
> > but it didnt work
>
> > thanks :)- Hide quoted text -
>
> - Show quoted text -

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: CakePHP 2.0 beta - AppController issue

2011-08-24 Thread Teddy Zeenny
Make sure your components extend Component and not Object.

On Wed, Aug 24, 2011 at 6:48 AM, Ben McClure  wrote:

> Hmm... actually I guess it is called but I have some sort of problem with
> one of my components that was preventing AppController from being used
> apparently (although no errors were output). I will try disabling my custom
> components and troubleshooting them one by one to see which one's doing it.
>
> Ben
>
> --
> Our newest site for the community: CakePHP Video Tutorials
> http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help
> others with their CakePHP related questions.
>
>
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group
> at http://groups.google.com/group/cake-php
>

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Subquery or something else?

2011-08-24 Thread Jeremy Burns | Class Outfit
I agree that there are better single query methods in pure SQL, but my 
recommendation keeps it in a Cake stylee (rather than using $model->query). I'd 
be happy to be put right, but even if you did it using joins in a Cake find, I 
think it'd still execute two queries.

Jeremy Burns
Class Outfit

http://www.classoutfit.com

On 23 Aug 2011, at 19:25, Robert Maiolo wrote:

> I'd try an outer join
> 
> 
> On Tue, Aug 23, 2011 at 11:23 AM, euromark  wrote:
> although this will get quite slow with more and more ids and might
> consume a lot of memory some day
> depending on the size a subquery might some day be more suitable. but
> until then this 2-query will work fine.
> 
> 
> On 23 Aug., 13:44, Dwayne Hanekamp  wrote:
> > That worked, awesome!
> >
> > Thanks so much Jeremy!
> >
> > Dwayne
> >
> > On 23 aug, 12:48, Jeremy Burns | Class Outfit
> >
> >
> >
> >
> >
> >
> >
> >  wrote:
> > > Do a find to get all the ids of the badges in the users_badges table. 
> > > Then do $this->Badge->find('all', array('conditions' => array('NOT' 
> > > array('Badge.id' => $badgeIds;
> >
> > > Seehttp://book.cakephp.org/view/1030/Complex-Find-Conditionsandsearch for 
> > > 'NOT IN' on the page.
> >
> > > Jeremy Burns
> > > Class Outfit
> >
> > >http://www.classoutfit.com
> >
> > > On 23 Aug 2011, at 11:43, Dwayne Hanekamp wrote:
> >
> > > > Hello everyone,
> > > > I've been trying to work this out for the last couple of hours but it
> > > > isn't working.
> > > > I'm building an achievement system. So i have two tables:
> >
> > > > Users_Badges and Badges (and ofc much more but they don't matter)
> >
> > > > What i want is to make a find condition which only selects the badges
> > > > that don't
> > > > exist in the Users_Badges table.
> >
> > > > I hope you all can help me.
> >
> > > > Thanks in advance,
> >
> > > > Dwayne
> >
> > > > --
> > > > Our newest site for the community: CakePHP Video 
> > > > Tutorialshttp://tv.cakephp.org
> > > > Check out the new CakePHP Questions sitehttp://ask.cakephp.organdhelp 
> > > > others with their CakePHP related questions.
> >
> > > > To unsubscribe from this group, send email to
> > > > cake-php+unsubscr...@googlegroups.com For more options, visit this 
> > > > group athttp://groups.google.com/group/cake-php
> 
> --
> Our newest site for the community: CakePHP Video Tutorials 
> http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help 
> others with their CakePHP related questions.
> 
> 
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php
> 
> 
> -- 
> Our newest site for the community: CakePHP Video Tutorials 
> http://tv.cakephp.org 
> Check out the new CakePHP Questions site http://ask.cakephp.org and help 
> others with their CakePHP related questions.
>  
>  
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: accessing field of paginate array in my view

2011-08-24 Thread WebbedIT
Tomfox,

I think you're approaching this from the wrong angle.

When a user is viewing their profile you're running a different action
to when viewing the index of books. In each of these actions you would
run different paginates/finds on the book model to find what you're
after.

/users/profile/$username: Book.user_id=>$user_id

/books/index: Book.is_visible=>1

HTH, Paul

On Aug 23, 10:01 pm, Tomfox Wiranata 
wrote:
> hi everyone,
>
> i have the object book with its attribute visible as boolean. i wanna
> use pagination and it works except for one thing.
>
> first i did two "this->paginate" in my controller. one with visible
> condition true and the other with false. but cake doesnt like two
> paginations in one controller.
>
> so i just returned any book, that a user "follows", no matter if it is
> set to visible true or false.
>
> controller:
>         public $paginate = array('Book' => array('limit' => 1, 'joins' =>
> array(
>         array(
>             'table' => 'books_users',
>             'alias' => 'BookUser',
>             'conditions'=> array('BookUser.fk_book_id = Book.id AND
> Book.locked = false')
>         )
>     )));
>
> NOW in my view, i want to make the distinction. when the user is
> visiting his own profile, non visible books are listed, since these
> are his own. if someone visits a another profile, the non visible
> books shall not appear.
>
> view:
>
> if ($user['User']['username'] == $this->Session->read('User.username'))
> {
>
>      if ($private_books['BookUser']['BooksUser']['visible'] = 'true')
>      ...show
>
>      else
>      ...dont show
>
> Problem: i cant access the visible field from the pagination array,
> that looks like that
>
> [BookUser] => Array
>         (
>             [0] => Array
>                 (
>             [firstname] => test
>             [lastname] => user
>             [username] => testuser
>
>             [BooksUser] => Array
>                 (
>
>                     >>     [visible] => 1
> <<
>                 )
>
>         )
>
> )
>
> }
>
> so how can i access the visible here? I tried
>
>   if ($private_books['BookUser']['BooksUser']['visible'] = 1)
>
> but it didnt work
>
> thanks :)

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php