Re: Send Email problem with multiple receivers

2011-12-02 Thread MetZ
Hi again all!

I have still not found a solution to this problem!
Cake 1.3.13, unable to send email to multiple recipients.

Please help me!

Any suggestions on how I can debug this problem? I get no info
whatsoever in any logs, have debugging to 2 in core.

Thank you for all your help!

-Tom

On 1 Des, 17:49, MetZ  wrote:
> ooh.. sorry... Cake 1.3.13 ;)
>
> Thanks for your time this far!
>
> -Tom
>
> On 1 Des, 10:19, euromark  wrote:
>
>
>
>
>
>
>
> > if you are using the new EmailLib in 2.0 you should be using the
> > setter methods:
> > $this->Email->to()
> > etc
>
> > On 1 Dez., 06:36, Graham Weldon  wrote:
>
> > > What CakePHP version are you on?
>
> > > Cheers,
> > > Graham Weldonhttp://grahamweldon.com
> > > e. gra...@grahamweldon.com
> > > p. (+61) 0407 017 293
> > > Skype: grahamweldon
>
> > > On Thursday, 1 December 2011 at 4:20 PM, MetZ wrote:
> > > > Hi..
> > > > Tried it, did not work either, only the first email in array get the
> > > > email.
>
> > > > Any other suggestions??
>
> > > > -Tom
>
> > > > On 1 Des, 06:03, Graham Weldon  > > > (http://gmail.com)> wrote:
> > > > > Have you tried an array of email address?
>
> > > > > $this->Email->to = array('du...@rmail.com (http://rmail.com)', 
> > > > > 'du...@email.com (http://email.com)');
>
> > > > > Cheers,
> > > > > Graham Weldonhttp://grahamweldon.com
> > > > > e. gra...@grahamweldon.com (http://grahamweldon.com)
> > > > > p. (+61) 0407 017 293
> > > > > Skype: grahamweldon
>
> > > > > On Thursday, 1 December 2011 at 4:02 PM, MetZ wrote:
> > > > > > Hi all!
>
> > > > > > I am having a problem, when sending email with multiple reveivers in
> > > > > > $this->Email->to
>
> > > > > > It will only send to one adress (the first one =>
> > > > > > email_numb...@gmail.com (mailto:email_numb...@gmail.com 
> > > > > > (http://gmail.com))), why is that? any suggestions!?!
>
> > > > > > $this->Email->to = 'email_numb...@gmail.com 
> > > > > > (mailto:email_numb...@gmail.com), email_numb...@gmail.com 
> > > > > > (mailto:email_numb...@gmail.com (http://gmail.com))';
> > > > > > $this->Email->subject = 'Ma Subject!';
> > > > > > $this->Email->from = Configure::read('App.noreply');
> > > > > > $this->Email->template = 'new_notify';
> > > > > > $this->Email->sendAs = 'both';
> > > > > > $this->Email->send();
> > > > > > $this->Email->reset();
>
> > > > > > --
> > > > > > Our newest site for the community: CakePHP Video 
> > > > > > Tutorialshttp://tv.cakephp.org
> > > > > > Check out the new CakePHP Questions 
> > > > > > sitehttp://ask.cakephp.organdhelpotherswith their CakePHP related 
> > > > > > questions.
>
> > > > > > To unsubscribe from this group, send email to
> > > > > > cake-php+unsubscr...@googlegroups.com 
> > > > > > (mailto: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 
> > > > Tutorialshttp://tv.cakephp.org
> > > > Check out the new CakePHP Questions 
> > > > sitehttp://ask.cakephp.organdhelpothers 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: Write unit test for a controller that uses AuthComponent in CakePHP 2.0.3

2011-12-02 Thread José Lorenzo
You also need to mock the models:

 $this->controller = $this->generate('Users', array(
'components' => array('Auth' => array('user')),
'models' => array('User' => array('save')) // We mock the User 
Model's save method
));

-- 
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: 2.04 vs 1.3

2011-12-02 Thread Miloš Vučinić
Thank you for response. You are most kind.

All the best,
Milos

On Dec 2, 9:49 am, AD7six  wrote:
> On Friday, 2 December 2011 01:23:13 UTC+1, Miloš Vučinić wrote:
>
> > Also one more question. Am I right to assume that cheat sheet from 2.*
> > is the same as the one provided on
> >http://cakephp.org/files/Resources/CakePHP-1.2-Cheatsheet.pdf
>
> 2.0 is faster, easier to use and more functional - I'd use that as our main
> choice criteria.
>
> The concepts haven't changed, but 2.0 is not 100% bc compatible with 1.3 so
> that cheatsheet is likely to be only 80% relevant/accurate.
>
> AD
>
>
>
>
>
>
>
>

-- 
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


Cakephp and AJAX

2011-12-02 Thread Miloš Vučinić
Hello,

I haven't used AJAX so far because I never needed it. I read the
manuals regarding it, now I am wondering how to do it in cake. My task
is following:
I have a list of users. Next to each user I have a button which says
archive. On click I have to archive the user. Now, I don want to
reload the whole page so I want to use AJAX.
The way I see it, I would create a regular AJAX call to my url which
is function just like any other in cake, like /users/archive/57 where
number 57 is id in the database (it will be generated for each
button).
On server side I would perform the function, but how do I return
response. Do I just echo it ? And how does the cake knows it was an
AJAX call and that it needs to send a response to a client. And is it
ok, for the response to be just a simple ok , or notok string , and
then if ok, I just change the archive sting into yes from no in the
user list.

Can you please give me like quick steps of how would you do it with a
quick syntax example.

Like : 1) Create a client call to the server
 2) Execute function on server the normal way you wold
 3) Send response to client (please explain how)

Thank you in advance,

All the best
Milos Vucinic

-- 
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: Is it possible to access AuthComponent from a Helper ?

2011-12-02 Thread Sam Sherlock
I found an acl tutorial that has an access helper and comp.

The access helper checks acl permissions before outputing links.

All works fairly well, though I do have reservations about the way it
crosses the view and controller streams

This is the link
http://net.tutsplus.com/tutorials/php/how-to-use-cakephps-access-control-lists/

- S
On 2 Dec 2011 10:29, "euromark"  wrote:

> i think it is possible but would create quite some overhead...
> and yes, it would probably break MVC
>
> On 2 Dez., 10:16, Dan  wrote:
> > I would like to write a Helper which would check if a given link is
> > authorized for the current user.
> >
> > I'm using CakePHP 2.0. I'm using the AuthComponent with controller
> > authorization. So my authorization logic goes into isAuthorized
> callbacks.
> >
> > The idea would be to have a helper used in this manner :
> > $this->MyAuthHelper->link(__('Edit'), array('action' => 'edit',
> > $user['User']['id']));
> >
> > The MyAuthHelper would check if the current controller action edit with
> the
> > passed parameter is accessible for the current user. If that's the case,
> it
> > returns the link, otherwise it returns nothing.
> >
> > I manage to parse the url this way : $parsedUrl =
> > Router::parse(Router::normalize(Router::url($url)));
> > But then I would like to call the AuthComponent::isAuthorized method,
> > passing the requested url.
> >
> > I see in AuthComponent the method : public function isAuthorized($user =
> > null, $request = null)
> > So I could write something like : isAuthorized(null, new
> > CakeRequest($parsedUrl, false))   // false parameter to prevent to parse
> > the environment ie. GET, POST, FILES
> >
> > But how could I access the AuthComponent from my helper ?? It seems to
> > break the MVC. Any great ideas out there ?
> >
> > Thanks for reading.
>
> --
> 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: Cakephp 2.0.3: Troubles with Sessions...

2011-12-02 Thread ava
SOLVED: removing the ?>  at the end of the controller solved the
problem. Weird.

On Nov 27, 7:30 pm, ava  wrote:
> @euromark
>
> how is the test case set up? Well, I call it several times by clicking
> on the link in the view.  I don't know if this answers your
> question...
>
> Anyway, I tried to get aSessionID, but this doesn't return a value:
>
> function testsession() {
>       if ($scounter = $this->Session->read('scounter')) {
>           $scounter++;
>       } else {
>           $scounter = 1;
>       }
>       $this->Session->write('scounter', $scounter);
>       $this->set('scounter', $scounter);
>
>       $this->log('SessionID: ' . $this->Session->id());      // no
> SessionID is outputed...
>
> }
>
> On Nov 27, 1:57 pm, euromark  wrote:
>
>
>
>
>
>
>
> > you can simplify the condition to
> > if ($scounter = $this->Session->read('scounter')) {}
>
> > but besides that
> > how is the test case set up?
> > because it is possible that it resets itself after each run
> > therefore thesessionwould always be emptied afterwards...
>
> > On 27 Nov., 11:38,ava wrote:
>
> > > Hi
>
> > > I'm struggling with sessions in cakephp 2.0.3.
>
> > > In this testcase the counter should be incremented with each click on
> > > the link.  The counter always remains 1.
>
> > > // CONTROLLER
> > >  > > class Test01sController extends AppController {
>
> > >    public $components = array('Session');
>
> > >    function testsession() {
> > >       $scounter = 1;
> > >       if ($this->Session->check('scounter')) {
> > >           $scounter = $this->Session->read('scounter');
> > >           $scounter++;
> > >       }
> > >       $this->Session->write('scounter', $scounter);
> > >       $this->set('scounter', $scounter);
> > >     }
>
> > > }
>
> > > //MODEL
> > >  > > class Test01 extends AppModel {
> > >    var $name = 'Test01';
> > >    var $useTable = false;}
>
> > > ?>
>
> > > // VIEW
> > >  > > echo $scounter;
> > > ?>
> > > testsession
>
> > > // CORE
> > > Configure::write('Session', array(
> > >     'defaults' => 'php',
> > >     'cookie' => 'vportal',
> > >     'ini' => array('session.gc_divisor' =>
> > > 1000,'session.cookie_httponly' => true),
> > >     'timeout' => 4320  //3 days
> > > ));
>
> > > I also dumped the $_SESSION array. This array is always empty.
>
> > > Any help or hints are appreciated.
>
> > > -- Andre

-- 
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 to add a fixture to a plugin test?

2011-12-02 Thread euromark
thats because it wont be the real model but an app model instance :)
i figured that out the hard way, too


On 2 Dez., 15:47, Roland  wrote:
> Ah, of course^^
>
> Thx, now it works :)
>
> best regards,
> Roland
>
> On 30 Nov., 04:46, euromark  wrote:
>
>
>
>
>
>
>
> > i think you just have to use
> > ClassRegistry::init('ModelName);
> > here
>
> > On 29 Nov., 22:38, Roland  wrote:
>
> > > None, that's the problem. I got non error or tips what is not
> > > working... but when I do $article->find('all') I get an empty
> > > result...
>
> > > thanks
> > > Roland
>
> > > On 29 Nov., 04:44, José Lorenzo  wrote:
>
> > > > this should just work, what error are you getting?

-- 
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 to add a fixture to a plugin test?

2011-12-02 Thread Roland
Ah, of course^^

Thx, now it works :)

best regards,
Roland

On 30 Nov., 04:46, euromark  wrote:
> i think you just have to use
> ClassRegistry::init('ModelName);
> here
>
> On 29 Nov., 22:38, Roland  wrote:
>
>
>
>
>
>
>
> > None, that's the problem. I got non error or tips what is not
> > working... but when I do $article->find('all') I get an empty
> > result...
>
> > thanks
> > Roland
>
> > On 29 Nov., 04:44, José Lorenzo  wrote:
>
> > > this should just work, what error are you getting?

-- 
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 can I debug an ajax login call?

2011-12-02 Thread Roland
Read this for AJAX debugging:
http://bakery.cakephp.org/articles/HeathNail/2010/08/20/debugging-with-firephp

best regards
Roland

On 2 Dez., 11:29, heohni  wrote:
> Hi,
>
> I cannot login into my users area and I am using a ajax form:
>
> function login() {
>
>         Configure::write('debug', 2);
>         $this->layout = 'ajax';
>
>         $this->RequestHandler->isAjax()) {
>             if($this->Auth->user()){ <
>
> This is always wrong and I don't see a way to debug this...?
> How can I make the sql query visible?
> I am using a ajax form as I said...
> Via Jquery I catch the submit and send a post to
> $.post('/users/login', $(this).serializeArray(), afterValidate,
> 'json');
>
> I could send the sql statement debug info to the json output if I
> would know how to make the query visible?
> Any ideas?

-- 
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: HTML Tidy Component

2011-12-02 Thread AD7six


On Friday, 2 December 2011 12:57:41 UTC+1, euromark wrote:
>
> personally I would find it more interesting to know what has to be
> "fixed" (missing closing p tag etc)
> because one should ask himself why the output has to be fixed in the
> first place.
> after all its the own code which should have been valid from the start
> (if its your layout/template stuff and not user input, of course).
> if there is a closing tag missing you should add it in the code - and
> not by some helper callback before outputting.
>
> so alerting the developer about invalid content in his templates would
> probably be more helpful in the long run than
> just fixing it at runtime all the time.
> but then I dont know if tidy supports such debug information.
>

Yes it does. I used it in this debug kit panel-helper 
https://github.com/AD7six/mi_development/blob/master/views/helpers/tidy.php

AD

>

-- 
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: HTML Tidy Component

2011-12-02 Thread euromark
personally I would find it more interesting to know what has to be
"fixed" (missing closing p tag etc)
because one should ask himself why the output has to be fixed in the
first place.
after all its the own code which should have been valid from the start
(if its your layout/template stuff and not user input, of course).
if there is a closing tag missing you should add it in the code - and
not by some helper callback before outputting.

so alerting the developer about invalid content in his templates would
probably be more helpful in the long run than
just fixing it at runtime all the time.
but then I dont know if tidy supports such debug information.


On 2 Dez., 11:37, Thiago Belem  wrote:
> Andy,
>
> Really thank you for your reply, it will surely help me to improve the code.
>
> I've created Issues
> with your
> suggestions and I will analyse and deal with each issue
> separately.
>
> I know there's a few Tidy CakePHP helpers out there, even that one of them
> is mine but all of them are designed to version 1.2 or 1.3.
>
> About the "should be a helper" advice, I created it as a Component since it
> interacts with the request+respose somehow, but you have your point since
> is HTML manipulation.
>
> Maybe I shuld convert the whole idea into a plugin, and put the *
> repairString* core on a Lib inside it... So as you said, I can call it from
> from a Helper to clear the whole output (when specificied on helper's
> configuration) or to just use a method to clean some HTML snipped inside a
> view/element.
>
> Plus, would be a good idea to create a Behavior where you do something like
> this?
>
> $actsAs = array('HtmlTidy' => array('fields' => array('body')));
>
> And automatically cleanup the fields value inside behavior's
> beforeValidate()?
>
> Regards,
> --
> ***Thiago Belem*
> Desenvolvedor
> Rio de Janeiro - RJ - Brasil
>
> +55 (21) 8865.9250
> thiagobelem.net
> cont...@thiagobelem.net
>
> *Skype / gTalk **»* thiago.belem.web
> *LinkedIn* *»* br.linkedin.com/in/thiagobelem/pt*
> Assando Sites*, curso de CakePHP *»* assando-sites.com.br
>
> 2011/12/2 AD7six 
>
>
>
>
>
>
>
>
>
> > On Friday, 2 December 2011 06:19:22 UTC+1, Thiago Belem wrote:
>
> >> Folks,
>
> >> I've just finished the HTML Tidy 
> >> Component,
> >> it helps you to sanitize, clean and solve several HTML markup issues
> >> automatically.
>
> >> Just include it in your list of components you'll get a clean and valid
> >> output.
>
> > First point that jumps up is: What is a class that is 100% focussed on the
> > V of MVC doing in the C?
>
> >> I would like to hear from everyone, including suggestions for improvement
> >> in the component and unit tests.
>
> > Positive: generally it's useful
>
> > Neutral: Googling you'll find that you are not the only person to have
> > written something to automatically call tidy for you (there's at least one
> > helper already out there on the bakery)
>
> > Suggestions:
>
> > Should be a helper, or a lib (so that you can, if you really want, call it
> > from anywhere in your app, e.g. before save in a model,  from a helper when
> > rendering) and a helper. The helper is just an after layout callback to
> > auto call repairString if _configured_ to do so.
>
> > Throwing exceptions (again, in the constructor) means it doesn't degrade
> > gracefully. It works as designed or if flat out kills your application -
> > that's not good. What happens to your application when you deploy or
> > upgrade to your production server and tidy isn't/is-no-longer available?
>
> > Instanciating Tidy in the constructor means you're loading a class on all
> > requests which potentially you're not going to use just by including the
> > component. However implemented it should lazy-load wherever possible (that
> > means new Tidy() is called the first time you actually try to use the class
> > - not optimistically loading it early). In practical terms that means only
> > check settings in constructor/setup functions - do as little as possible.
>
> > Using shutdown means if you wanted to use the class to repair some random
> > string that you aren't sending to the browser - you get as a 'bonus'
> > whatever html you render being corrected - with no obvious configurable way
> > to turn that off (except removing the component or disabling the component
> > before the request finishes)
>
> > Throw exceptions when you try to use code and it won't work without
> > addressing "the problem". Trigger errors when you try to use code and some
> > recoverable problem occurs - That doesn't break your app but it does put
> > "Tidy is configured to clean up your shitty html - but the extension isn't
> > available" into the error log which devs (should) read.
>
> > hth,
>
> > AD
>
> >>  --
> > Our newest site for the community: CakePHP Video Tutorials
> >http://tv.cakephp.org
> > Check out the new CakePHP Questions sitehttp://ask.cakephp.organd 

Re: How use .htaccess to redirect these urls

2011-12-02 Thread Điển vũ
Thank you very much for help me this matter.

-- 
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: Best image resize and crop helper

2011-12-02 Thread Alex Bovey
On Fri, Dec 2, 2011 at 9:34 AM, AD7six  wrote:

>
> That's quite a common way of thinking about upload processing.
>
> Why would you run logic each time you want to point at an image - instead
> of once when you upload it such that your helper/image logic is only "the
> $size thumbnail for that file is here: "$domain/$path.$size.$ext"?
>


That's logical - thanks Andy.

-- 
Alex Bovey
Web Developer | Alex Bovey Consultancy Ltd
Registered in England & Wales no. 6471391 | VAT no. 934 8959 65

-- 
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: HTML Tidy Component

2011-12-02 Thread Thiago Belem
Andy,

Really thank you for your reply, it will surely help me to improve the code.

I've created Issues
with your
suggestions and I will analyse and deal with each issue
separately.

I know there's a few Tidy CakePHP helpers out there, even that one of them
is mine but all of them are designed to version 1.2 or 1.3.

About the "should be a helper" advice, I created it as a Component since it
interacts with the request+respose somehow, but you have your point since
is HTML manipulation.

Maybe I shuld convert the whole idea into a plugin, and put the *
repairString* core on a Lib inside it... So as you said, I can call it from
from a Helper to clear the whole output (when specificied on helper's
configuration) or to just use a method to clean some HTML snipped inside a
view/element.

Plus, would be a good idea to create a Behavior where you do something like
this?

$actsAs = array('HtmlTidy' => array('fields' => array('body')));

And automatically cleanup the fields value inside behavior's
beforeValidate()?

Regards,
--
***Thiago Belem*
Desenvolvedor
Rio de Janeiro - RJ - Brasil

+55 (21) 8865.9250
thiagobelem.net
cont...@thiagobelem.net

*Skype / gTalk **»* thiago.belem.web
*LinkedIn* *»* br.linkedin.com/in/thiagobelem/pt*
Assando Sites*, curso de CakePHP *»* assando-sites.com.br


2011/12/2 AD7six 

>
>
> On Friday, 2 December 2011 06:19:22 UTC+1, Thiago Belem wrote:
>>
>> Folks,
>>
>> I've just finished the HTML Tidy 
>> Component,
>> it helps you to sanitize, clean and solve several HTML markup issues
>> automatically.
>>
>> Just include it in your list of components you'll get a clean and valid
>> output.
>>
>
> First point that jumps up is: What is a class that is 100% focussed on the
> V of MVC doing in the C?
>
>>
>> I would like to hear from everyone, including suggestions for improvement
>> in the component and unit tests.
>>
>
> Positive: generally it's useful
>
> Neutral: Googling you'll find that you are not the only person to have
> written something to automatically call tidy for you (there's at least one
> helper already out there on the bakery)
>
> Suggestions:
>
> Should be a helper, or a lib (so that you can, if you really want, call it
> from anywhere in your app, e.g. before save in a model,  from a helper when
> rendering) and a helper. The helper is just an after layout callback to
> auto call repairString if _configured_ to do so.
>
> Throwing exceptions (again, in the constructor) means it doesn't degrade
> gracefully. It works as designed or if flat out kills your application -
> that's not good. What happens to your application when you deploy or
> upgrade to your production server and tidy isn't/is-no-longer available?
>
> Instanciating Tidy in the constructor means you're loading a class on all
> requests which potentially you're not going to use just by including the
> component. However implemented it should lazy-load wherever possible (that
> means new Tidy() is called the first time you actually try to use the class
> - not optimistically loading it early). In practical terms that means only
> check settings in constructor/setup functions - do as little as possible.
>
> Using shutdown means if you wanted to use the class to repair some random
> string that you aren't sending to the browser - you get as a 'bonus'
> whatever html you render being corrected - with no obvious configurable way
> to turn that off (except removing the component or disabling the component
> before the request finishes)
>
> Throw exceptions when you try to use code and it won't work without
> addressing "the problem". Trigger errors when you try to use code and some
> recoverable problem occurs - That doesn't break your app but it does put
> "Tidy is configured to clean up your shitty html - but the extension isn't
> available" into the error log which devs (should) read.
>
> hth,
>
> AD
>
>>
>>  --
> 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: Validation problems

2011-12-02 Thread Toby G
Hmmm... My earlier reply appears to have got lost.

Thanks for the advice.  I worked it out.  It was because the
relationship was a hasMany & I'd forgot to add the .0. into the field
name.

T

On Dec 2, 8:43 am, AD7six  wrote:
> On Thursday, 1 December 2011 18:05:57 UTC+1, Toby G wrote:
>
> > Hi there,
>
> > Version: 1.3.12
>
> > I seem to be having a problem with the 'numeric' validation rule on an
> > associated Model's fields.  For some reason it is not validating '10'
> > as a valid numeric value.
>
> > Here are the validation rules for the (PhysicalTicket) no_of_tickets
> > field in question...
>
> > 'no_of_tickets' => array(
> > 'numeric' => array(
> > 'rule' => array('numeric'),
> > 'message' => 'Please provide the number of tickets you require',
> > 'allowEmpty' => false,
> > //'required' => false,
> > //'last' => false, // Stop validation after this rule
> > //'on' => 'create', // Limit validation to 'create' or 'update'
> > operations
> > ),
> > 'between' => array(
> > 'rule' => array('between', 1, 9),
>
> the between rule is checking number of characters, not numeric value
>
>
>
>
>
>
>
>
>
> > 'message' => 'Please provide the number of tickets you require
> > (between 1 & 9 can be booked at a time)',
> > 'allowEmpty' => false,
> > //'required' => false,
> > //'last' => false, // Stop validation after this rule
> > //'on' => 'create', // Limit validation to 'create' or 'update'
> > operations
> > ),
> > ),
>
> > And here is the data being validated (using saveAll)...
>
> > Array
> > (
> >     [Booking] => Array
> >         (
> >             [event_id] => 17
> >             [booking_type] => is_physical_tickets
> >             [post_to_wall] => 1
> >         )
>
> >     [PhysicalTicket] => Array
> >         (
> >             [name] => Toby Griffiths
> >             [phone_no] =>
> >             [no_of_tickets] => 10
> >         )
>
> >     [submit] => Request tickets
> >     [add_more_text] => SOMETHING RANDOM
> > )
>
> > The validation error show is "Please provide the number of tickets you
> > require" rather than the expected "'Please provide the number of
> > tickets you require (between 1 & 9 can be booked at a time)"
>
> There's probably something else at play here, like e.g. the value of
> no_of_tickets not actually being in the data that's being validated and
> therefore !notEmpty - I'd suggest sticking debug($something) in cake
> somewhere. e.g. in function numeric, in Validation, or in Model's validate
> logic.
>
> AD
>
>
>
>
>
>
>
>

-- 
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


How can I debug an ajax login call?

2011-12-02 Thread heohni
Hi,

I cannot login into my users area and I am using a ajax form:

function login() {

Configure::write('debug', 2);
$this->layout = 'ajax';

$this->RequestHandler->isAjax()) {
if($this->Auth->user()){ <

This is always wrong and I don't see a way to debug this...?
How can I make the sql query visible?
I am using a ajax form as I said...
Via Jquery I catch the submit and send a post to
$.post('/users/login', $(this).serializeArray(), afterValidate,
'json');

I could send the sql statement debug info to the json output if I
would know how to make the query visible?
Any ideas?

-- 
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: Is it possible to access AuthComponent from a Helper ?

2011-12-02 Thread euromark
i think it is possible but would create quite some overhead...
and yes, it would probably break MVC

On 2 Dez., 10:16, Dan  wrote:
> I would like to write a Helper which would check if a given link is
> authorized for the current user.
>
> I'm using CakePHP 2.0. I'm using the AuthComponent with controller
> authorization. So my authorization logic goes into isAuthorized callbacks.
>
> The idea would be to have a helper used in this manner :
> $this->MyAuthHelper->link(__('Edit'), array('action' => 'edit',
> $user['User']['id']));
>
> The MyAuthHelper would check if the current controller action edit with the
> passed parameter is accessible for the current user. If that's the case, it
> returns the link, otherwise it returns nothing.
>
> I manage to parse the url this way : $parsedUrl =
> Router::parse(Router::normalize(Router::url($url)));
> But then I would like to call the AuthComponent::isAuthorized method,
> passing the requested url.
>
> I see in AuthComponent the method : public function isAuthorized($user =
> null, $request = null)
> So I could write something like : isAuthorized(null, new
> CakeRequest($parsedUrl, false))   // false parameter to prevent to parse
> the environment ie. GET, POST, FILES
>
> But how could I access the AuthComponent from my helper ?? It seems to
> break the MVC. Any great ideas out there ?
>
> Thanks for reading.

-- 
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 use .htaccess to redirect these urls

2011-12-02 Thread AD7six


On Friday, 2 December 2011 11:00:03 UTC+1, Điển vũ wrote:
>
> I post at here , because if i use RewriteCond %{REQUEST_URI} in htaccess. 
> It seems any urls in cakephp contain webroot.
>

They will, if you're using a development install. webroot should be your 
webserver root - not app.
 

>
> And I followed your suggestion redirect urls in routes.php:
>
> if (preg_match('/webroot/', Router::url(null, false))) {
> header("Location: " . str_replace('/webroot', '', 
> Router::url(null, true)) . "/", true, 301);
> exit();
> }
>

Remember DRY - you're calling Router::url twice. You're also using 
preg_match where a simple strpos would do. Though relatively cheap, that 
code is a lot more expensive than it needs to be. You don't need cake for 
that either - infact - here you go https://gist.github.com/1422680

AD 

-- 
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 use .htaccess to redirect these urls

2011-12-02 Thread Điển vũ
I post at here , because if i use RewriteCond %{REQUEST_URI} in htaccess. 
It seems any urls in cakephp contain webroot. 

And I followed your suggestion redirect urls in routes.php:

if (preg_match('/webroot/', Router::url(null, false))) {
header("Location: " . str_replace('/webroot', '', 
Router::url(null, true)) . "/", true, 301);
exit();
}

-- 
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: Best image resize and crop helper

2011-12-02 Thread AD7six


On Friday, 2 December 2011 10:10:33 UTC+1, Alex Bovey wrote:
>
> On Thu, Dec 1, 2011 at 6:41 PM, Miles J  wrote:
> > This should be done when the image is uploaded.
>
> Thanks for the responses all.
>
> Miles - I'm interested to know your rationale for that approach, which
> I always used to follow, but find a helper so much more convenient
> when you want to make a minor adjustment to the image size.
>

That's quite a common way of thinking about upload processing.

Why would you run logic each time you want to point at an image - instead 
of once when you upload it such that your helper/image logic is only "the 
$size thumbnail for that file is here: "$domain/$path.$size.$ext"?

What happens when you find you need a different size for whatever
> reason?  Do you simply have a function that lets you regenerate all
> images to a certain size, presuming you keep the originally uploaded
> image?
>

Personally, I would always maintain a pristine, or largest-used-size 
image/file to be able to regenerate versions at any time.

AD

>

-- 
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: HTML Tidy Component

2011-12-02 Thread AD7six


On Friday, 2 December 2011 06:19:22 UTC+1, Thiago Belem wrote:
>
> Folks,
>
> I've just finished the HTML Tidy 
> Component, 
> it helps you to sanitize, clean and solve several HTML markup issues 
> automatically.
>
> Just include it in your list of components you'll get a clean and valid 
> output.
>

First point that jumps up is: What is a class that is 100% focussed on the 
V of MVC doing in the C? 

>
> I would like to hear from everyone, including suggestions for improvement 
> in the component and unit tests.
>

Positive: generally it's useful

Neutral: Googling you'll find that you are not the only person to have 
written something to automatically call tidy for you (there's at least one 
helper already out there on the bakery) 

Suggestions:

Should be a helper, or a lib (so that you can, if you really want, call it 
from anywhere in your app, e.g. before save in a model,  from a helper when 
rendering) and a helper. The helper is just an after layout callback to 
auto call repairString if _configured_ to do so.

Throwing exceptions (again, in the constructor) means it doesn't degrade 
gracefully. It works as designed or if flat out kills your application - 
that's not good. What happens to your application when you deploy or 
upgrade to your production server and tidy isn't/is-no-longer available?
 
Instanciating Tidy in the constructor means you're loading a class on all 
requests which potentially you're not going to use just by including the 
component. However implemented it should lazy-load wherever possible (that 
means new Tidy() is called the first time you actually try to use the class 
- not optimistically loading it early). In practical terms that means only 
check settings in constructor/setup functions - do as little as possible. 

Using shutdown means if you wanted to use the class to repair some random 
string that you aren't sending to the browser - you get as a 'bonus' 
whatever html you render being corrected - with no obvious configurable way 
to turn that off (except removing the component or disabling the component 
before the request finishes)

Throw exceptions when you try to use code and it won't work without 
addressing "the problem". Trigger errors when you try to use code and some 
recoverable problem occurs - That doesn't break your app but it does put 
"Tidy is configured to clean up your shitty html - but the extension isn't 
available" into the error log which devs (should) read.

hth,

AD

>
>

-- 
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


Is it possible to access AuthComponent from a Helper ?

2011-12-02 Thread Dan
I would like to write a Helper which would check if a given link is 
authorized for the current user.

I'm using CakePHP 2.0. I'm using the AuthComponent with controller 
authorization. So my authorization logic goes into isAuthorized callbacks.

The idea would be to have a helper used in this manner :
$this->MyAuthHelper->link(__('Edit'), array('action' => 'edit', 
$user['User']['id']));

The MyAuthHelper would check if the current controller action edit with the 
passed parameter is accessible for the current user. If that's the case, it 
returns the link, otherwise it returns nothing. 

I manage to parse the url this way : $parsedUrl = 
Router::parse(Router::normalize(Router::url($url)));
But then I would like to call the AuthComponent::isAuthorized method, 
passing the requested url.

I see in AuthComponent the method : public function isAuthorized($user = 
null, $request = null)
So I could write something like : isAuthorized(null, new 
CakeRequest($parsedUrl, false))   // false parameter to prevent to parse 
the environment ie. GET, POST, FILES

But how could I access the AuthComponent from my helper ?? It seems to 
break the MVC. Any great ideas out there ?

Thanks for reading.

-- 
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: Best image resize and crop helper

2011-12-02 Thread Alex Bovey
On Thu, Dec 1, 2011 at 6:41 PM, Miles J  wrote:
> This should be done when the image is uploaded.

Thanks for the responses all.

Miles - I'm interested to know your rationale for that approach, which
I always used to follow, but find a helper so much more convenient
when you want to make a minor adjustment to the image size.

What happens when you find you need a different size for whatever
reason?  Do you simply have a function that lets you regenerate all
images to a certain size, presuming you keep the originally uploaded
image?

Thanks, Alex

-- 
Alex Bovey
Web Developer | Alex Bovey Consultancy Ltd
Registered in England & Wales no. 6471391 | VAT no. 934 8959 65

-- 
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: Same Old?

2011-12-02 Thread AD7six


On Wednesday, 30 November 2011 07:05:21 UTC+1, Krissy Masters wrote:
>
>  Wondering why you look at Krop /  Craigslist/ Authentic Jobs no one 
> wants Cake? 
>
> 1 in 1000 jobs looks for Cake? Wonder why? Cake board with Cake or what 
> ever it is has zero new job offers?
>
>  
>
> Is there a reason? Same as before im going to get banned fron the Cake 
> Board fine, open a new account because you need people like me to support 
> but just don’t question right! 
>
> Drupal has 100 job offers, WordPress Developers / Designers…. Where is 
> Cake?
>
> Why does no one want Cake?
>
>  
>
> There are zero companies looking for Cake developers if I am wrong show me 
> 1 who is hiring!
>

Can I ask if you're actually interested in answers or simply have a 
misguided axe to grind with the framework? Bearing in mind CakePHP is a 
tool you can use to solve almost any PHP task and is not a law degree or 
something else you paid for to receive a piece of paper.

AD

> 

-- 
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: 2.04 vs 1.3

2011-12-02 Thread AD7six


On Friday, 2 December 2011 01:23:13 UTC+1, Miloš Vučinić wrote:
>
> Also one more question. Am I right to assume that cheat sheet from 2.*
> is the same as the one provided on 
> http://cakephp.org/files/Resources/CakePHP-1.2-Cheatsheet.pdf


2.0 is faster, easier to use and more functional - I'd use that as our main 
choice criteria.

The concepts haven't changed, but 2.0 is not 100% bc compatible with 1.3 so 
that cheatsheet is likely to be only 80% relevant/accurate.

AD

>

-- 
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 use .htaccess to redirect these urls

2011-12-02 Thread AD7six


On Thursday, 1 December 2011 23:51:56 UTC+1, Điển vũ wrote:
>
> How can i redirect these urls ( use Htaccess):
>
> http://example.com/webroot/posts/1/post_slug
> to 
> http://example.com/posts/1/post_slug
>
> i read and do a lot but can't . Please help me solve this matter.
>
>
If you want to do it with .htaccess - perhaps by looking/asking in a 
.htaccessy kind of place. Since you're using cake though why don't you 
simply do it in your app (I hope you're not using a dev install on 
production btw..)

AD 

-- 
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: Validation problems

2011-12-02 Thread AD7six


On Thursday, 1 December 2011 18:05:57 UTC+1, Toby G wrote:
>
> Hi there,
>
> Version: 1.3.12
>
> I seem to be having a problem with the 'numeric' validation rule on an
> associated Model's fields.  For some reason it is not validating '10'
> as a valid numeric value.
>
> Here are the validation rules for the (PhysicalTicket) no_of_tickets
> field in question...
>
> 'no_of_tickets' => array(
> 'numeric' => array(
> 'rule' => array('numeric'),
> 'message' => 'Please provide the number of tickets you require',
> 'allowEmpty' => false,
> //'required' => false,
> //'last' => false, // Stop validation after this rule
> //'on' => 'create', // Limit validation to 'create' or 'update'
> operations
> ),
> 'between' => array(
> 'rule' => array('between', 1, 9),
>

the between rule is checking number of characters, not numeric value
 

> 'message' => 'Please provide the number of tickets you require
> (between 1 & 9 can be booked at a time)',
> 'allowEmpty' => false,
> //'required' => false,
> //'last' => false, // Stop validation after this rule
> //'on' => 'create', // Limit validation to 'create' or 'update'
> operations
> ),
> ),
>
> And here is the data being validated (using saveAll)...
>
> Array
> (
> [Booking] => Array
> (
> [event_id] => 17
> [booking_type] => is_physical_tickets
> [post_to_wall] => 1
> )
>
> [PhysicalTicket] => Array
> (
> [name] => Toby Griffiths
> [phone_no] =>
> [no_of_tickets] => 10
> )
>
> [submit] => Request tickets
> [add_more_text] => SOMETHING RANDOM
> )
>
> The validation error show is "Please provide the number of tickets you
> require" rather than the expected "'Please provide the number of
> tickets you require (between 1 & 9 can be booked at a time)"
>

There's probably something else at play here, like e.g. the value of 
no_of_tickets not actually being in the data that's being validated and 
therefore !notEmpty - I'd suggest sticking debug($something) in cake 
somewhere. e.g. in function numeric, in Validation, or in Model's validate 
logic.

AD

>

-- 
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