Re: CakeAdvent: Hacking the CakePHP Dispatch System

2013-12-03 Thread Reuben
Thanks for the heads up, Jose.

I'm always keen to read blogs of CakePHP core developers and contributors.

Regards
Reuben Helms

On Wednesday, 4 December 2013 02:54:08 UTC+10, Jose Diaz-Gonzalez wrote:
>
> Hi all!
>
> I'm Jose Diaz-Gonzalez (@savant on twitter and 
> irc, josegonzalez 
> on github ). I'm a core developer on 
> the CakePHP framework and a long-time open source contributor. I am not to 
> be confused with Jose Lorenzo (jose_zap), as I'm at least twice as handsome 
> with 3x the hair.
>
> I've been writing a series of posts for CakeAdvent, the CakePHP Advent 
> calendar. I'll be taking apart various bits of the CakePHP framework. 
> Sometimes it'll be for something useful, and sometimes you'll wish you 
> never knew this was possible. Hopefully it's useful information!
>
> I'm on post number three, Hacking the CakePHP Dispatch System. Please read 
> it if you are interested in micro-frameworks or in creating custom dispatch 
> filters.
>
> If anyone has any questions, feel free to comment on the posts on my blog. 
> Also feel free to respond to this email with suggestions for posts, as I am 
> more than happy to tear CakePHP to shreds in search of answers!
>
> Link to post: 
> http://josediazgonzalez.com/2013/12/03/hacking-the-cakephp-dispatch-system/
>
> - (little) Jose
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Strange console behavior

2013-12-03 Thread Ed Propsner
I'm not quite too sure what to make of it. 'debug(Debugger::trace())'
triggered the error that I could not re-declare class debugger. I removed
the Debugger::trace() but the error remained. Fairly confident that I
hadn't re-declared the class anywhere else I commented out
'Debugkit.Toolbar' and everything returned to normal however I'm now unable
to use Debugkit without the error returning. Perhaps I somehow managed to
corrupt my copy of Debugkit  I'll re-install and see what happens.


On Tue, Dec 3, 2013 at 6:32 AM, AD7six  wrote:

> Sounds like an early fatal error - if you put `debug(Debugger::trace())`
> in your `default.ctp` - it may give you more insight as to how/why it's
> doing that.
>
> AD
>
>
> On Tuesday, 3 December 2013 06:02:46 UTC+1, CrotchFrog wrote:
>>
>> Using Cake 2.4.3 on Ubuntu server 12.04 LTS
>>
>> A new unexpected behavior started recently in one of my projects ... when
>> I run 'cake bake' in the directory instead of the normal console output it
>> displays what seems to be the contents of my default.ctp or possibly
>> executing index.php. 'cake bake' works fine in the rest of my projects.
>> I've been doing a lot of work in this project so I'm sure I managed to
>> change something I'm just not sure what that would be. Any help is
>> appreciated.
>>
>  --
> 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 a topic in the
> Google Groups "CakePHP" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/cake-php/T2v0Qty3G5g/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> cake-php+unsubscr...@googlegroups.com.
> To post to this group, send email to cake-php@googlegroups.com.
> Visit this group at http://groups.google.com/group/cake-php.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.


CakeAdvent: Hacking the CakePHP Dispatch System

2013-12-03 Thread Jose Diaz-Gonzalez
 

Hi all!

I'm Jose Diaz-Gonzalez (@savant on twitter  and 
irc, josegonzalez on github ). I'm a core 
developer on the CakePHP framework and a long-time open source contributor. 
I am not to be confused with Jose Lorenzo (jose_zap), as I'm at least twice 
as handsome with 3x the hair.

I've been writing a series of posts for CakeAdvent, the CakePHP Advent 
calendar. I'll be taking apart various bits of the CakePHP framework. 
Sometimes it'll be for something useful, and sometimes you'll wish you 
never knew this was possible. Hopefully it's useful information!

I'm on post number three, Hacking the CakePHP Dispatch System. Please read 
it if you are interested in micro-frameworks or in creating custom dispatch 
filters.

If anyone has any questions, feel free to comment on the posts on my blog. 
Also feel free to respond to this email with suggestions for posts, as I am 
more than happy to tear CakePHP to shreds in search of answers!

Link to post: 
http://josediazgonzalez.com/2013/12/03/hacking-the-cakephp-dispatch-system/

- (little) Jose

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Posting to the top of the tree using the Tree Behavior

2013-12-03 Thread Justin Thomas
Of course, sorting it DESC makes perfect sense.  Just needed someone to get 
me out of the box.  Now I just need to reorder the data that's already 
there so when I do a DESC sort it stays the way it is now (only new records 
will be put at the top of the tree).  I think that's easily done.

Thanks.

On Tuesday, December 3, 2013 5:38:20 AM UTC-6, AD7six wrote:
>
>
>
> On Monday, 2 December 2013 19:22:14 UTC+1, Justin Thomas wrote:
>>
>> I'm using the Tree Behavior in one of my models.  When a new record is 
>> added by default it post the new record at the bottom of the tree.  What I 
>> need it to do is post the new record at the top of the tree.  
>>
>
> That will require updating every existing record in the table.
>  
>
>> I've looked at the documentation and I don't see anything to change that 
>> default behavior.  
>>
>  
>
>> I also looked at the reorder method, but I'm unsure how to use that to 
>> move a new record to the top of the tree.
>>
>
> Reorder is not the method you need - 
> moveUpis.
>
>
>> If I pass the lft and rght parameters as 1 and 2 will the other records 
>> update automatically?  
>>
>
> Nope
>  
>
>> Any ideas on how to achieve this?
>>
>
> Try something =). Alternatively treat the tree inverted - i.e. don't do 
> what you're asking but instead query the tree sorted by lft desc - the last 
> created record would be first.
>
> AD 
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.


RE: Production and Development Environment

2013-12-03 Thread Advantage+
Sorry no, in development I still need to authenticate hence the allowance of
api calls.

 

This is the problem. Everything now is in a password protected folder. So no
access. I need a way to allow API yet still have it in production so
controller kicsksin and denys all access but login.

 

 

Dave Maharaj

Freelance Designer | Developer
Description: header_logo
www.movepixels.com  |    d...@movepixels.com  |
709.800.0852

 

From: cake-php@googlegroups.com [mailto:cake-php@googlegroups.com] On Behalf
Of Reuben Helms
Sent: Monday, December 02, 2013 8:45 PM
To: cake-php@googlegroups.com
Subject: Re: Production and Development Environment

 

Trying one more time...

 

The requirement is that in production, you need to authenticate to get
access to the API, and that in development, no authentication is required.

 

The assumption is that the authentication will be session based, with a form
based login action.  There has been mention of a .htaccess file, but it
wasn't clearly stated if this was used to provide authentication via Basic
Authentication.

 

In the AppController, I would have:

 

public function beforeFilter() {

/* set up Authentication */

if (!Configure::read('developmentMode')) {

$this->Auth->deny(); /* a default deny for all actions, when not in
developmentMode */

}  else {

$this->Auth->allow(); /* a default allow for all actions, when in
development mode */

}

}

 

And then in any controller, I would have:

 

public function beforeFilter() {

   parent::beforeFilter();

   /* the remainder of your code, to allow actions, and lift authentication
restrictions for particular actions */

}

 

In production, this will ensure that all actions are denied by default, to
be overridden by specific controllers.

 

In development, this will set up a default allow for all actions.

 

It's been a while since I've actually played with the CakePHP 2.X Auth
stuff, but that's the general idea I was going for.

 

Best of luck finding a solution.

 

Regards

Reuben Helms

 

On Tue, Dec 3, 2013 at 8:39 AM, Advantage+  wrote:

I appolagize.

 

But if parent::before filter is called in the controller and reads
production or development anything called after that will be over-ridden no?

 

You cannot get an API called back to a password protected folder so you have
to remove the password protection, but if you want it to be a hidden folder
which is not accessible you need a way to hide it.

 

Dave Maharaj

Freelance Designer | Developer
Description: header_logo
  www.movepixels.com  |
 d...@movepixels.com  |  709.800.0852

 

From: cake-php@googlegroups.com [mailto:cake-php@googlegroups.com] On Behalf
Of AD7six
Sent: Saturday, November 30, 2013 11:08 AM


To: cake-php@googlegroups.com
Subject: Re: Production and Development Environment

 

 


On Friday, 29 November 2013 05:45:50 UTC+1, advantage+ wrote:

Hmm sounds like the exact thing I saidand if you do 

Beforefilter::parent () in the controller what was the point of asking if
there is an easy way to no go thur every controller!

 Example::

 

public function beforeFilter() {

  parent::beforeFilter();

  $this->Auth->deny();

  

  

  //Allow Security to allow ajax request for these actions

  $ajax_request = array('manage_add', 'manage_edit',
'manage_delete');

  if(in_array($this->params['action'], $ajax_request)){

 

 $this->Security->unlockedActions = $ajax_request;

 $this->Security->csrfCheck = false;

  }

   }

 

Since parent:: is called you have to go thru every controller no? 

 

If you see a correct way I happy to hear about it.

 

Thanks,

Dave.

-- 
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 a topic in the
Google Groups "CakePHP" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/cake-php/qY0yLORk4MM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
cake-php+unsubscr...@googlegroups.com
 .
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.

 

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
--- 
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For 

Re: Posting to the top of the tree using the Tree Behavior

2013-12-03 Thread AD7six


On Monday, 2 December 2013 19:22:14 UTC+1, Justin Thomas wrote:
>
> I'm using the Tree Behavior in one of my models.  When a new record is 
> added by default it post the new record at the bottom of the tree.  What I 
> need it to do is post the new record at the top of the tree.  
>

That will require updating every existing record in the table.
 

> I've looked at the documentation and I don't see anything to change that 
> default behavior.  
>
 

> I also looked at the reorder method, but I'm unsure how to use that to 
> move a new record to the top of the tree.
>

Reorder is not the method you need - 
moveUpis.


> If I pass the lft and rght parameters as 1 and 2 will the other records 
> update automatically?  
>

Nope
 

> Any ideas on how to achieve this?
>

Try something =). Alternatively treat the tree inverted - i.e. don't do 
what you're asking but instead query the tree sorted by lft desc - the last 
created record would be first.

AD 

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Strange console behavior

2013-12-03 Thread AD7six
Sounds like an early fatal error - if you put `debug(Debugger::trace())` in 
your `default.ctp` - it may give you more insight as to how/why it's doing 
that.

AD

On Tuesday, 3 December 2013 06:02:46 UTC+1, CrotchFrog wrote:
>
> Using Cake 2.4.3 on Ubuntu server 12.04 LTS
>
> A new unexpected behavior started recently in one of my projects ... when 
> I run 'cake bake' in the directory instead of the normal console output it 
> displays what seems to be the contents of my default.ctp or possibly 
> executing index.php. 'cake bake' works fine in the rest of my projects. 
> I've been doing a lot of work in this project so I'm sure I managed to 
> change something I'm just not sure what that would be. Any help is 
> appreciated.
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Production and Development Environment

2013-12-03 Thread Domingos Coelho
I do this to config database for each server, production or development, i 
put this code in database.php:

switch($_SERVER['HTTP_HOST']) {
case 'localhost':
case 'development':
$this->default = $this->development; // $development has the 
configuration for the development database
break;
case 'www.example.com':
case 'example.com':
case 'production':
 $this->default = $this->production; // $production has the 
configuration for the production database
 break;   
default:
$this->default = $this->development;
break;
}


-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Production and Development Environment

2013-12-03 Thread Reuben Helms
Trying one more time...

The requirement is that in production, you need to authenticate to get
access to the API, and that in development, no authentication is required.

The assumption is that the authentication will be session based, with a
form based login action.  There has been mention of a .htaccess file, but
it wasn't clearly stated if this was used to provide authentication via
Basic Authentication.

In the AppController, I would have:

public function beforeFilter() {
/* set up Authentication */
if (!Configure::read('developmentMode')) {
$this->Auth->deny(); /* a default deny for all actions, when not in
developmentMode */
}  else {
$this->Auth->allow(); /* a default allow for all actions, when in
development mode */
}
}

And then in any controller, I would have:

public function beforeFilter() {
   parent::beforeFilter();
   /* the remainder of your code, to allow actions, and lift authentication
restrictions for particular actions */
}

In production, this will ensure that all actions are denied by default, to
be overridden by specific controllers.

In development, this will set up a default allow for all actions.

It's been a while since I've actually played with the CakePHP 2.X Auth
stuff, but that's the general idea I was going for.

Best of luck finding a solution.

Regards
Reuben Helms


On Tue, Dec 3, 2013 at 8:39 AM, Advantage+  wrote:

> I appolagize.
>
>
>
> But if parent::before filter is called in the controller and reads
> production or development anything called after that will be over-ridden no?
>
>
>
> You cannot get an API called back to a password protected folder so you
> have to remove the password protection, but if you want it to be a hidden
> folder which is not accessible you need a way to hide it.
>
>
>
> *Dave Maharaj*
>
> *Freelance Designer | Developer*
> [image: Description: header_logo]
> www.movepixels.com  |  d...@movepixels.com  |  709.800.0852
>
>
>
> *From:* cake-php@googlegroups.com [mailto:cake-php@googlegroups.com] *On
> Behalf Of *AD7six
> *Sent:* Saturday, November 30, 2013 11:08 AM
>
> *To:* cake-php@googlegroups.com
> *Subject:* Re: Production and Development Environment
>
>
>
>
>
> On Friday, 29 November 2013 05:45:50 UTC+1, advantage+ wrote:
>
> Hmm sounds like the exact thing I said……..and if you do
>
> Beforefilter::parent () in the controller what was the point of asking if
> there is an easy way to no go thur every controller!
>
>  Example::
>
>
>
> public function beforeFilter() {
>
>   parent::beforeFilter();
>
>   $this->Auth->deny();
>
>
>
>
>
>   //Allow Security to allow ajax request for these actions
>
>   $ajax_request = array('manage_add', 'manage_edit', '
> manage_delete');
>
>   if(in_array($this->params['action'], $ajax_request)){
>
>
>
>  $this->Security->unlockedActions = $ajax_request;
>
>  $this->Security->csrfCheck = false;
>
>   }
>
>}
>
>
>
> Since parent:: is called you have to go thru every controller no?
>
>
>
> If you see a correct way I happy to hear about it.
>
>
>
> Thanks,
>
> Dave.
>
> --
> 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 a topic in the
> Google Groups "CakePHP" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/cake-php/qY0yLORk4MM/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> cake-php+unsubscr...@googlegroups.com.
> To post to this group, send email to cake-php@googlegroups.com.
> Visit this group at http://groups.google.com/group/cake-php.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.
<>

Posting to the top of the tree using the Tree Behavior

2013-12-03 Thread Justin Thomas
I'm using the Tree Behavior in one of my models.  When a new record is 
added by default it post the new record at the bottom of the tree.  What I 
need it to do is post the new record at the top of the tree.  I've looked 
at the documentation and I don't see anything to change that default 
behavior.  I also looked at the reorder method, but I'm unsure how to use 
that to move a new record to the top of the tree.

If I pass the lft and rght parameters as 1 and 2 will the other records 
update automatically?  Any ideas on how to achieve this?

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.