Re: Wordpress is CakePHP

2009-02-18 Thread Chris M
I'm by NO MEANS an expert in this area, but it sounds like your router is 
working properly but the WP install is looking at the absolute path to the WP 
install.  Hopefully, there is a WP config to control this setting and that will 
fix it for you.

Remember, I'm a newbie to Cake and to WP.  I'm not telling you the definitive 
answer, only my 'gut feel' and what I would look for.

HIH ... 





From: kaushik 
To: CakePHP 
Sent: Thursday, 19 February, 2009 5:28:53 PM
Subject: Re: Wordpress is CakePHP


I have installed Wordpress in "app\webroot\wordpress". it is working
properly when I am firing URL: "www.mysite.com/wordpress". But all the
link are showing in wordpress section like "www.mysite.com/app/webroot/
wordpress/?cat=1", although I am working with "www.mysite.com/
wordpress". even if I open "www.mysite.com/wordpress/wp-login.php", it
is redirected me to "www.mysite.com/wordpress/app/webroot/wordpress/wp-
admin/" after login.

What is fix for this problem so that it always use "www.mysite.com/wp-
admin/..." and "www.mysite.com/wordpress"?


On Feb 19, 11:05 am, Andras Kende  wrote:
> You could put the wordpress directory inside the webroot folder
>
> domain.com/wordpress
>
> On Feb 19, 2009, at 12:26 AM, kaushik wrote:
>
>
>
> > I have developed a site in cake. Now the client to integrate Wordpress
> > blog in this site. Is it possible to install Wordpress in any sub
> > directory and operate it from there.
>
> Andras Kendehttp://kende.com


  Make Yahoo!7 your homepage and win a trip to the Quiksilver Pro. Find out 
more
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Submitting a form with ajax using a diffrent controller

2009-02-18 Thread yankeyhotel


you rock. thanks that did it. :)


Mathias Furevik wrote:
> 
> 
> Try specify the url directly:
> 
> "url" => "/comments/add"
> 
> You should also specify what model you are submitting to:
> 
> "model" => "Comment"
> 
> //mathias
> 
> 2009/2/19 yankeyhotel :
>>
>>
>> has anyone figured out this problem. I am also reading through Apress
>> Beginning CakePHP and having the same problem. any help on the example in
>> the book would be awesome.
>>
>> thanks
>> --
>> View this message in context:
>> http://www.nabble.com/Submitting-a-form-with-ajax-using-a-diffrent-controller-tp20957512p22094274.html
>> Sent from the CakePHP mailing list archive at Nabble.com.
>>
>>
>> >
>>
> 
> > 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Submitting-a-form-with-ajax-using-a-diffrent-controller-tp20957512p22094695.html
Sent from the CakePHP mailing list archive at Nabble.com.


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



Re: Wordpress is CakePHP

2009-02-18 Thread kaushik

I have installed Wordpress in "app\webroot\wordpress". it is working
properly when I am firing URL: "www.mysite.com/wordpress". But all the
link are showing in wordpress section like "www.mysite.com/app/webroot/
wordpress/?cat=1", although I am working with "www.mysite.com/
wordpress". even if I open "www.mysite.com/wordpress/wp-login.php", it
is redirected me to "www.mysite.com/wordpress/app/webroot/wordpress/wp-
admin/" after login.

What is fix for this problem so that it always use "www.mysite.com/wp-
admin/..." and "www.mysite.com/wordpress"?


On Feb 19, 11:05 am, Andras Kende  wrote:
> You could put the wordpress directory inside the webroot folder
>
> domain.com/wordpress
>
> On Feb 19, 2009, at 12:26 AM, kaushik wrote:
>
>
>
> > I have developed a site in cake. Now the client to integrate Wordpress
> > blog in this site. Is it possible to install Wordpress in any sub
> > directory and operate it from there.
>
> Andras Kendehttp://kende.com
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Wordpress is CakePHP

2009-02-18 Thread Andras Kende

You could put the wordpress directory inside the webroot folder

domain.com/wordpress



On Feb 19, 2009, at 12:26 AM, kaushik wrote:

>
> I have developed a site in cake. Now the client to integrate Wordpress
> blog in this site. Is it possible to install Wordpress in any sub
> directory and operate it from there.
> >

Andras Kende
http://kende.com




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



Re: Submitting a form with ajax using a diffrent controller

2009-02-18 Thread Mathias Hunskår Furevik

Try specify the url directly:

"url" => "/comments/add"

You should also specify what model you are submitting to:

"model" => "Comment"

//mathias

2009/2/19 yankeyhotel :
>
>
> has anyone figured out this problem. I am also reading through Apress
> Beginning CakePHP and having the same problem. any help on the example in
> the book would be awesome.
>
> thanks
> --
> View this message in context: 
> http://www.nabble.com/Submitting-a-form-with-ajax-using-a-diffrent-controller-tp20957512p22094274.html
> Sent from the CakePHP mailing list archive at Nabble.com.
>
>
> >
>

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



Re: Submitting a form with ajax using a diffrent controller

2009-02-18 Thread yankeyhotel


has anyone figured out this problem. I am also reading through Apress
Beginning CakePHP and having the same problem. any help on the example in
the book would be awesome.

thanks
-- 
View this message in context: 
http://www.nabble.com/Submitting-a-form-with-ajax-using-a-diffrent-controller-tp20957512p22094274.html
Sent from the CakePHP mailing list archive at Nabble.com.


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



Wordpress is CakePHP

2009-02-18 Thread kaushik

I have developed a site in cake. Now the client to integrate Wordpress
blog in this site. Is it possible to install Wordpress in any sub
directory and operate it from there.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Problem with SMTP and EmailComponent

2009-02-18 Thread Miles J

I also dont see you creating/setting the body of the email anywhere in
the code you gave.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: isn't a form in the view supposed to find the correct action?

2009-02-18 Thread brian

I believe that FormHelper will default to add action unless
$this->data[ModelName]['id'] is set, in which case it will create an
edit form.

Personally, I think it's best to just specify the action. It's only a
few letters to type. Why make things difficult to understand at a
glance when you (or, worse, someone else) come back 6 months later?

On Wed, Feb 18, 2009 at 10:07 PM, Marcelo Andrade  wrote:
>
> On Wed, Feb 18, 2009 at 8:58 PM, Sidney  wrote:
>> (..)
>
> @Sydney
>
> You are right.  But I don't know if I was clear.  If we have a
> mycontrollers/dosomething.ctp view with a code like
>
> echo $form->create('Mycontroller');
>
> we get a form for the add (or even the edit) action and not for a
> dosomething action.  I've asked if it couldn't make more sense if the
> default action (when not specified in the $form->create) be the action
> with the same name as the view instead of the add/edit action.
>
> In other words: isn't the form helper supposed to follow the Cake's
> convention about the view name is the same as the action name
> (at least by default)?
>
> Best regards.
>
> --
> MARCELO DE F. ANDRADE (aka "eleKtron")
> Belem, PA, Amazonia, Brazil
> Linux User #221105
>
> >
>

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



Re: Problem with SMTP and EmailComponent

2009-02-18 Thread Dr. Loboto
Use templates and put email content there.
http://book.cakephp.org/view/269/Sending-a-basic-message

On Feb 19, 4:27 am, sal  wrote:
> Hey all,
>
> I am currently running a cake site off a home server. Because of this,
> when I use the EmailComponent within cake, I have to use SMTP. I was
> able to get my page up and running sending out emails with SMTP,
> however I noticed that when using SMTP I cannot pass any arguments
> (the body of the email) to the send() method. If I try to I will still
> get a confirmation that the email has been sent, but I never receive
> it. If I do not pass any arguments to the send() method I get the same
> confirmation and will receive the email almost instantly. My question
> is how would I go about including the body of the email being sent and
> still get the email to actually send using SMTP? I have included the
> "contacts_controller.php" used in my app. Any help is greatly
> appreciated as I am stuck : /
>
> 
>         class ContactsController extends AppController {
>
>                 var $name = 'Contacts';
>                 var $components = array('RequestHandler', 'Email');
>
>                 function index() {
>
>                         if ($this->RequestHandler->isPost()) {
>
>                                 $this->Contact->set($this->data);
>
>                                 if ($this->Contact->validates()) {
>
>                                         //send email using the Email component
>                                         $this->Email->smtpOptions = array(
>                                                                               
>                           'port'          => '25',
>                                                                               
>                           'timeout'       => '30',
>                                                                               
>                           'host'          => 'smtp.xx.xxx'
>                                                                               
>                           );
>                                         $this->Email->delivery = 'smtp';
>                                         $this->Email->to = 
> 'n...@yourdomain.com';
>                                         $this->Email->subject = 'Contact 
> message from ' . $this->data
> ['Contact']['name'];
>                                         $this->Email->from = 
> $this->data['Contact']['email'];
>
>                                         if ($this->Email->send()) {
>
>                                                 $this->flash('Your email has 
> been sent.', '/contacts');
>
>                                         } else {
>
>                                                 $this->flash('Your email has 
> NOT been sent.', '/contacts');
>                                         }
>
>                                 }
>
>                         }
>
>                 }
>
>         }
>
> ?>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Trouble With Saving Data In View

2009-02-18 Thread brian

This should work

  function view($id = null) {
   if (!$id) {
   $this->Session->setFlash(__('Invalid Item.', true));
   $this->redirect(array('action'=>'index'));
   }

   $this->Item->recursive = 2;
   $item = $this->Item->read(null, $id)
   $this->Item->saveField('views', $item['Item']['views']
+ 1, false);
   $this->set(compact('item'));
   }

On Wed, Feb 18, 2009 at 8:34 PM, NineBlindEyes  wrote:
>
> Ok so here is my problem. I have to have a record of how many times a
> user views a page. I simply want to add 1 to the view every time the
> view page for the item is loaded. It seems to be updating the views
> correctly, but it also adds to new rows in the database.
>
> Here is my code:
>
>   function view($id = null) {
>if (!$id) {
>$this->Session->setFlash(__('Invalid Item.', true));
>$this->redirect(array('action'=>'index'));
>}
>
>//Add 1 to view
>$this->Item->recursive = -1;
>$item =  $this->Item->read(null, $id);
>$viewnum = $item['Item']['views']+1;
>$this->data['Item'] = array('id'=>$id,'views'=>$viewnum);
>
>//Save new view #s
>$this->Item->save($this->data,false,array('views'));
>
>$this->Item->recursive = 2;
>$this->set('item', $this->Item->read(null, $id));
>}
>
> >
>

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



Re: isn't a form in the view supposed to find the correct action?

2009-02-18 Thread Marcelo Andrade

On Thu, Feb 19, 2009 at 12:07 AM, Marcelo Andrade  wrote:
> On Wed, Feb 18, 2009 at 8:58 PM, Sidney  wrote:
>> (..)

@Sidney,

Sorry, man.  I've misspelled your name! :-P

--
MARCELO DE F. ANDRADE (aka "eleKtron")
Belem, PA, Amazonia, Brazil
Linux User #221105

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



Re: isn't a form in the view supposed to find the correct action?

2009-02-18 Thread Marcelo Andrade

On Wed, Feb 18, 2009 at 8:58 PM, Sidney  wrote:
> (..)

@Sydney

You are right.  But I don't know if I was clear.  If we have a
mycontrollers/dosomething.ctp view with a code like

echo $form->create('Mycontroller');

we get a form for the add (or even the edit) action and not for a
dosomething action.  I've asked if it couldn't make more sense if the
default action (when not specified in the $form->create) be the action
with the same name as the view instead of the add/edit action.

In other words: isn't the form helper supposed to follow the Cake's
convention about the view name is the same as the action name
(at least by default)?

Best regards.

--
MARCELO DE F. ANDRADE (aka "eleKtron")
Belem, PA, Amazonia, Brazil
Linux User #221105

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



Trouble With Saving Data In View

2009-02-18 Thread NineBlindEyes

Ok so here is my problem. I have to have a record of how many times a
user views a page. I simply want to add 1 to the view every time the
view page for the item is loaded. It seems to be updating the views
correctly, but it also adds to new rows in the database.

Here is my code:

   function view($id = null) {
if (!$id) {
$this->Session->setFlash(__('Invalid Item.', true));
$this->redirect(array('action'=>'index'));
}

//Add 1 to view
$this->Item->recursive = -1;
$item =  $this->Item->read(null, $id);
$viewnum = $item['Item']['views']+1;
$this->data['Item'] = array('id'=>$id,'views'=>$viewnum);

//Save new view #s
$this->Item->save($this->data,false,array('views'));

$this->Item->recursive = 2;
$this->set('item', $this->Item->read(null, $id));
}

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



Re: Search db with find & conditions

2009-02-18 Thread rb


I knew it was that simple..

In fact, it's what I was trying to do, but I couldn't get the syntax
down right.  I hadn't fully grasped how to append to an array.

Anyway, i'll give this a try tomorrow. and thanks for the pointers on
the better use of find().  I'll dig into the doc's some more.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Calling a (empty!) model-method causes SQL Error: 1064

2009-02-18 Thread AD7six



On Feb 18, 11:40 pm, Mr Speaker  wrote:
> Perhaps I have a plural typo, but I'm not sure - because the call from
> the model's own controller works - only if you call from a DIFFERENT
> controller does it not work. Here's a test I did:
>
> class Message extends AppModel {
>     var $name = 'Message';
>     function get_message() {
>         $message = $this->find('first');
>         return $message['Message']['title'];
>     }
>
> }
>
> class MessagesController extends AppController {
>     var $name = "Messages";
>     function get_message() {
>         $this->set( 'message', $this->Message->get_message() );
>     }
>
> }
>
> And the view get_message.ctp is just: . If I
> then go to /cake/messages/get_message then it works as expected: "TEST
> MESSAGE! W00T!"
>
> But if I then add another model:
> class Test extends AppModel
> {
>     var $name = 'Test';
>         var $useTable = false;
>
> }
>
> class TestsController extends AppController {
>     var $name = "Tests";
>     var $uses = array( 'Messages' );

$uses is for models, and models are singular - see the conventions
page in the book.

hth,

AD
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: isn't a form in the view supposed to find the correct action?

2009-02-18 Thread Sidney

An example might clarify (note this isn't syntactically perfect, I'm
writing this by hand):

In my ADD view:
$form->create('Game');
   $form->input(blahblah); // your input fields
$form->end('Add');

outputs -->

The input fields here


In my EDIT view:
$form->create('Game');
   $form->input(blahblah);
$form->end('Update');

outputs -->

The input fields here


Notice that the code to generate the forms is the same. The model name
is specified on the form->create. Cake has decided that the form
should self post, so the action is derived from the controller/view
that created it.

If the input fields contain a field (normally hidden) which is the
model's key (id='GameId' name='data['Game']['id'] in this example)
then, when the controller saves the data, that record would be
updated. If this field is not in the form then an insert would be
performed. Basically the EDIT and ADD action code in the controller is
the same.

Sorry if I have this wrong. I will be mortally embarrased for causing
confusion. I have only been using Cake for about 8 weeks (loving it)
but I'm quite confident.

Sid. (the nervous)


On Feb 18, 7:50 pm, Aivaras  wrote:
> Unless you create a form with Model.id that is filled by edit() function.
> You don't need to specify an action then.
>
> Aivaras
>
> On Wed, Feb 18, 2009 at 10:35, RichardAtHome wrote:
>
>
>
> > Sindey, Marcelo is right. The default action for a form is to post to
> > the $controller->add() method. You have to override it for other
> > actions
>
> > On Feb 18, 12:00 am, Sidney  wrote:
> > > I think the default action is to self-post i.e. the form post/get goes
> > > to the same controller/action that served the view with the form on
> > > it. This is a normal design convention and seems logical to me
> > > (although quite a noob myself). Perhaps I misunderstand your question?
>
> > > On Feb 17, 8:01 am, Marcelo Andrade  wrote:
>
> > > > Hi there,
>
> > > > By the CakePHP conventions, the view's name must be the same
> > > > as an action in a controller.  A common mistake for the newbies is
> > > > when creating a form in the view is that the
>
> > > > echo $form->create('MyModel');
>
> > > > defaults to generate a form for the "add" action.  But I think that
> > > > should be more intuitive that it's defaults to the action with the
> > > > same name as the view.  Isn' it?
>
> > > > Best regards.
>
> > > > --
> > > > MARCELO DE F. ANDRADE (aka "eleKtron")
> > > > Belem, PA, Amazonia, Brazil
> > > > Linux User #221105
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Calling a (empty!) model-method causes SQL Error: 1064

2009-02-18 Thread Mr Speaker

Ahhh... the line I had in test_controller:
var $uses = array( 'Messages' );

just imports the Messages CONTROLLER, not the MODEL (is that right?!).
To get it to work I had to change it to
var $uses = array( 'Message' ); // Message, not Messages
and then change my index function to:

function index() {
$message = new Message(); // need to add this constructor!
$this->set( 'message', $message->get_welcome_message() );
}

Which looks a bit more messy than I'd like - but I think it's just
because i haven't set up my associations correctly yet.


On Feb 19, 9:40 am, Mr Speaker  wrote:
> Perhaps I have a plural typo, but I'm not sure - because the call from
> the model's own controller works - only if you call from a DIFFERENT
> controller does it not work. Here's a test I did:
>
> class Message extends AppModel {
>     var $name = 'Message';
>     function get_message() {
>         $message = $this->find('first');
>         return $message['Message']['title'];
>     }
>
> }
>
> class MessagesController extends AppController {
>     var $name = "Messages";
>     function get_message() {
>         $this->set( 'message', $this->Message->get_message() );
>     }
>
> }
>
> And the view get_message.ctp is just: . If I
> then go to /cake/messages/get_message then it works as expected: "TEST
> MESSAGE! W00T!"
>
> But if I then add another model:
> class Test extends AppModel
> {
>     var $name = 'Test';
>         var $useTable = false;
>
> }
>
> class TestsController extends AppController {
>     var $name = "Tests";
>     var $uses = array( 'Messages' );
>
>     function get_message() {
>         // Original way - works lovely.
>         $message = $this->Messages->find('first');
>         $this->set( 'fromFind', $message['Messages']['title'] );
>
>         // "Fat Model" way - receives an exception.
>         $this->set( 'fromModel', $this->Messages->get_message() );
>     }}
>
> With the view: 
>
> If I then go to /cake/tests/get_message then it outputs the $fromFind
> variable, but crashes when trying to load the get_message() from the
> Messages model:
> "Warning (512): SQL Error: 1064: You have an error in your SQL syntax;
> etc... (as original exception)"
>
> It's like cake can't see the custom method on the Message class from
> outside it's own controller. Or I'm doing something stupid.
>
> On Feb 19, 9:06 am, Adam Royle  wrote:
>
> > Sounds like you have a typo somewhere (maybe you've got plural instead
> > of singular?). Cake automatically creates models if they don't exist.
> > Therefore it is creating a model (an instance of AppModel) and your
> > method is not defined in AppModel.
>
> > Make sense?
>
> > Adam
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: CakePHP + Ajax/JS(Prototype/JQuery) creating fields on the fly and Multiple Picture Uploader

2009-02-18 Thread netors

exo_duz,

I have something similar that may be useful to you,
its not the best way to do it but it gets the job done.

First, you need prototype and scriptaculous on your webroot/js/ folder

on your Controller:

class EventsController extends AppController {
var $name='Events';
var $uses=array('Event', 'EventDetails');

function add() {
$totalEventDetails = 1; // unless i have already posted some
content...
if (!empty($this->data)) {
$this->Event->set($this->data['Event']);
if ($this->Event->validates()) {
// data for Event model has been validated
$error_in_details = false;
foreach ($this->data['EventDetails'] as 
$key=>$detail) {

$this->Event->EventDetail->set($detail['EventDetail']);
if 
(!$this->Event->EventDetail->validates()) {
$error_in_details = true;
$error_in_detail[$key] = true;
} else {
$error_in_detail[$key] = false;
}
}
// if there are no errors, save Event and 
EventDetails
if (!$error_in_details) {
// set user id
$this->Event->create();

$this->Event->save($this->data['Event'], false);
foreach ($this->data['EventDetails'] as 
$key=>$detail) {

$detail['EventDetail']['event_id'] = $this->Event->id;

$this->Event->EventDetail->create();

$this->Event->EventDetail->save($detail, false);
}
$this->Session->setFlash(__('The Event 
and EventDetails have been
saved', true));

$this->redirect(array('action'=>'index'));
} else {
$this->Session->setFlash(__('The 
EventDetail could not be saved.
Please, try again.', true));
}
} else {
$this->Session->setFlash(__('The Event could 
not be saved. Please,
try again.', true));
}
$totalEventDetails = count($this->data['EventDetails']);
}
$this->set('totalEventDetails',$totalEventDetails);
}

function ajaxAddDetail($total_details) {
$details = $this->data['EventDetails'];
$this->set(compact('details'));
$this->set('totalEventDetails',$total_details+1);
$this->render('add','ajax');
}
}

on your View:

link('prototype'); ?>
link('scriptaculous'); ?>



click to add details field

div('ajax_detail_updater', array
('class'=>'last')); ?>

//',

{

asynchronous:true,

evalScripts:true,

parameters: Form.serialize($('EventAddForm')),

requestHeaders:['X-Update', 'ajax_detail_updater']})
},
false
);
//]]>

text('EventDetails.'.
$c.'.EventDetail.description',array('id'=>'detail_'.$c,'value'=>@
$details[$c]['description'])); ?>
divEnd('ajax_detail_updater'); ?>

end(array('label'=>__
('Submit',true),'class'=>'submit button'));?>

This code may contain errors, I copied it and modified it from a
working example

locally hosted Git and bug tracking?

2009-02-18 Thread cds

For those of you that use Git to keep track of your projects how do
you log bugs? Do you use the Trac + Git plugins? Basically I'm looking
for a locally hosted tracking system similar to SVN + Trac.

Thanks,
CDS

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



Problem with SMTP and EmailComponent

2009-02-18 Thread sal

Hey all,

I am currently running a cake site off a home server. Because of this,
when I use the EmailComponent within cake, I have to use SMTP. I was
able to get my page up and running sending out emails with SMTP,
however I noticed that when using SMTP I cannot pass any arguments
(the body of the email) to the send() method. If I try to I will still
get a confirmation that the email has been sent, but I never receive
it. If I do not pass any arguments to the send() method I get the same
confirmation and will receive the email almost instantly. My question
is how would I go about including the body of the email being sent and
still get the email to actually send using SMTP? I have included the
"contacts_controller.php" used in my app. Any help is greatly
appreciated as I am stuck : /

RequestHandler->isPost()) {

$this->Contact->set($this->data);

if ($this->Contact->validates()) {

//send email using the Email component
$this->Email->smtpOptions = array(

'port'  => '25',

'timeout'   => '30',

'host'  => 'smtp.xx.xxx'

);
$this->Email->delivery = 'smtp';
$this->Email->to = 
'n...@yourdomain.com';
$this->Email->subject = 'Contact 
message from ' . $this->data
['Contact']['name'];
$this->Email->from = 
$this->data['Contact']['email'];

if ($this->Email->send()) {

$this->flash('Your email has 
been sent.', '/contacts');

} else {

$this->flash('Your email has 
NOT been sent.', '/contacts');
}

}

}

}

}

?>

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



Re: Search db with find & conditions

2009-02-18 Thread mscdex

On Feb 18, 2:24 pm, rb  wrote:
> However the problem lies in that that name input field is *not*
> required.  So if I submit a form with zip = 1 and name = [empty
> string]
>
> the SQL equivalent is obviously,
>         SELECT *
>         FROM schools
>         WHERE zip_mail = 1
>         AND name = ''
>
> This is obviously wrong because I only want the last AND condition if
> name is not empty.  So i'm not sure where to go from here...

Just check to see if the name is empty. If it isn't empty, include it
in the find conditions. One possible solution:

$formSchools = $this->data['schools'];

$conditions = array(
'School.zip_mail' => $formSchools['zip_mail']
);

if (!empty($formSchools['name']))
$conditions['School.name'] = $formSchools['name'];

$this->set('querySearchSchools', $this->School->find('all', array
('conditions' => $conditions)));

Note that you should use the newer form of the find() method. In other
words, specify as the first parameter to find(): 'all' if you have the
possibility of finding multiple records, 'first' if you want the first
record found, or any of the other valid find methods defined in the
online manual. The second parameter should be an array containing
arrays for each of the query options you wish to have. Additional
examples:

$fields = array('School.city', 'School.start_date');
$this->set('querySearchSchools', $this->School->find('all', array
('conditions' => $conditions, 'fields' => $fields, 'recursive' =>
-1)));

In the example above, the city and date the school came into existance
would be retrieved for any school that met the specified conditions.
Also, the 'recursive' => -1 part tells Cake to do no joins with other
models/tables and to just retrieve data strictly from the School model/
table.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: translate behavior

2009-02-18 Thread jitka (poLK)

In doubts how to use something, read test cases - they're not only
proving that old bugs are away, but also showing how are things
supposed to be used.
https://trac.cakephp.org/browser/branches/1.2.x.x/cake/tests/cases/libs/model/behaviors/translate.test.php#L305
Read this method - it deletes few translations first, and then reads
translated db content using array $locale.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Calling a (empty!) model-method causes SQL Error: 1064

2009-02-18 Thread Mr Speaker

Perhaps I have a plural typo, but I'm not sure - because the call from
the model's own controller works - only if you call from a DIFFERENT
controller does it not work. Here's a test I did:

class Message extends AppModel {
var $name = 'Message';
function get_message() {
$message = $this->find('first');
return $message['Message']['title'];
}
}

class MessagesController extends AppController {
var $name = "Messages";
function get_message() {
$this->set( 'message', $this->Message->get_message() );
}
}

And the view get_message.ctp is just: . If I
then go to /cake/messages/get_message then it works as expected: "TEST
MESSAGE! W00T!"

But if I then add another model:
class Test extends AppModel
{
var $name = 'Test';
var $useTable = false;
}

class TestsController extends AppController {
var $name = "Tests";
var $uses = array( 'Messages' );

function get_message() {
// Original way - works lovely.
$message = $this->Messages->find('first');
$this->set( 'fromFind', $message['Messages']['title'] );

// "Fat Model" way - receives an exception.
$this->set( 'fromModel', $this->Messages->get_message() );
}
}
With the view: 

If I then go to /cake/tests/get_message then it outputs the $fromFind
variable, but crashes when trying to load the get_message() from the
Messages model:
"Warning (512): SQL Error: 1064: You have an error in your SQL syntax;
etc... (as original exception)"

It's like cake can't see the custom method on the Message class from
outside it's own controller. Or I'm doing something stupid.


On Feb 19, 9:06 am, Adam Royle  wrote:
> Sounds like you have a typo somewhere (maybe you've got plural instead
> of singular?). Cake automatically creates models if they don't exist.
> Therefore it is creating a model (an instance of AppModel) and your
> method is not defined in AppModel.
>
> Make sense?
>
> Adam
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Calling a (empty!) model-method causes SQL Error: 1064

2009-02-18 Thread Adam Royle
Sounds like you have a typo somewhere (maybe you've got plural instead 
of singular?). Cake automatically creates models if they don't exist. 
Therefore it is creating a model (an instance of AppModel) and your 
method is not defined in AppModel.

Make sense?

Adam

Mr Speaker wrote:
> I think I must have some kind of scoping issue - the problem only
> occurs when I try to call a method from a Model from a different
> controller. So from the original example below, if I do:
>
>  function index() {
>  $this->Abc->doTest();
>  }
>
> inside AbcController, then it works as expected and returns null.
> If I call it from StartController, then it gives the error below (and
> as you pointed out, looks like it tries to call AppModel::doTest not
> AbcModel::doTest)
>
> By the way, the reason I am trying to call the method from the model
> not the controller is that I was trying to follow this advice:
> http://weblog.jamisbuck.org/2006/10/18/skinny-controller-fat-model
> which is from a Ruby on Rails guy - so perhaps I'm just going about it
> in the wrong manner!
>
> Thanks!
>
> On Feb 18, 11:14 pm, AD7six  wrote:
>
>> On Feb 18, 1:01 pm, Mr Speaker  wrote:
>>
>>  
>>> I have this same issue (exactly)... what am i doing wrong?
>>>
>> You are (both) calling a method on a (model) object that doesn't exist
>> - probably because of a misnamed file.
>>
>> "AppModel::doTest() - [internal], line ?? "<- it's an instance of
>> AppModel, not your model.
>>
>> Check the conventions page regarding filenames.
>>
>> hth,
>>
>> AD
>>  
> >
>
>

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



Re: Calling a (empty!) model-method causes SQL Error: 1064

2009-02-18 Thread Mr Speaker

I think I must have some kind of scoping issue - the problem only
occurs when I try to call a method from a Model from a different
controller. So from the original example below, if I do:

function index() {
$this->Abc->doTest();
}

inside AbcController, then it works as expected and returns null.
If I call it from StartController, then it gives the error below (and
as you pointed out, looks like it tries to call AppModel::doTest not
AbcModel::doTest)

By the way, the reason I am trying to call the method from the model
not the controller is that I was trying to follow this advice:
http://weblog.jamisbuck.org/2006/10/18/skinny-controller-fat-model
which is from a Ruby on Rails guy - so perhaps I'm just going about it
in the wrong manner!

Thanks!

On Feb 18, 11:14 pm, AD7six  wrote:
> On Feb 18, 1:01 pm, Mr Speaker  wrote:
>
> > I have this same issue (exactly)... what am i doing wrong?
>
> You are (both) calling a method on a (model) object that doesn't exist
> - probably because of a misnamed file.
>
> "AppModel::doTest() - [internal], line ?? " <- it's an instance of
> AppModel, not your model.
>
> Check the conventions page regarding filenames.
>
> hth,
>
> AD
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Auth/ACL and redirect to home

2009-02-18 Thread Timothy Western

I am coming back to CakePHP after having given it a rest for a few
months, and am really enjoying the new features in 1.2.   I've gone
through and used Mark Story's fabulous auth and ACL tutorial, and have
it working pretty well, but there is one thing I'm not sure about.  I
know if you are on another page (you clicked somewhere that required
permissions and you were not authenticated or logged in), that it
redirects you to the login then back.  That's fine, but what I'm not
sure is how to handle the redirect when a user is coming from the
'home' page

I think I've got it figured out by setting my login redirect in
AppController to:

$this->Auth->loginRedirect = array('controller' => 'pages', 'action'
=> 'display', 'home');

However, I've noticed that sometimes I have to login twice before it
redirects.   Has anyone else experienced similar behavior?  Before I
made this change it seemed to work fine, and does on any page that
requires a login to get you ACL permissions.


Tim

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



Re: how to display message "no record found"

2009-02-18 Thread Aivaras

Thank you for a correction.

Faifas


On Wed, Feb 18, 2009 at 18:34, Mark (Germany)
 wrote:
>
> if(!empty($data) {}
> is enough
> as it does not contain anything if there haven not been any found
> records
>
>
> On 18 Feb., 17:06, vikas  wrote:
> > Ya you are right.. my problem is solved..
> > thanx
> >

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



Search db with find & conditions

2009-02-18 Thread rb

I'm pretty new to cakephp, so theres a good chance this is a dumb
question, but I haven't been successful in finding my answer in any of
the docs.

I'm searching a table using "find" and my params are being submitted
from an html form.  This is working just fine (kinda) using this code:


$formSchools = $this->data['schools'];

$conditions = array(
'School.zip_mail' => $formSchools['zip_mail']
,'School.name' => $formSchools['name']
);

$this->set('querySearchSchools', $this->School->find($conditions));



However the problem lies in that that name input field is *not*
required.  So if I submit a form with zip = 1 and name = [empty
string]

the SQL equivalent is obviously,
SELECT *
FROM schools
WHERE zip_mail = 1
AND name = ''

This is obviously wrong because I only want the last AND condition if
name is not empty.  So i'm not sure where to go from here...

Any pointers would be *greatly* appreciated.. even a "dude, you're way
off" would be helpful ;)

Thanks

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



Re: translate behavior

2009-02-18 Thread kicaj

Hmm.

I'm new in cakephp...

Maybe give somebody a hint of code :)

jitka (poLK) napisał(a):
> For 'fallback' translations, set model's $locale property to array of
> locales instead of string - if translation for field(s) and 1st locale
> in array will not be found, other ones will be tried.
> As of notice that returned data are using fallback locale (means - not
> first one in $locale array), there is currently no way how you can
> determine this fact (except for asking model for data with string
> $locale first and if it fails, try it again with array $locale), but
> we will probably remove this limitation in future.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



How to Redirect After Session Has Expired

2009-02-18 Thread Alfredo Quiroga-Villamil

I am sure there is a way to get this done, just not sure if I am
missing something. Further details below:

Issue:
=

Need to re-direct after session has expired or cleared.

Description:
=

I am currently only using the Auth component to handle my
authentication. No ACL for now. In my AppController I have:

=
public function beforeFilter() {
parent::beforeFilter();
$this->Auth->loginAction = array('controller' => 'portal', 
'action'
=> 'login');
$this->Auth->loginRedirect = array('controller' => 'portal',
'action' => 'main');
$this->Auth->logoutRedirect = array('controller' => 'portal',
'action' => 'index');
$this->Auth->autoRedirect = false;
} // End of beforeFilter()
=

Everything works great. The only issue I currently have is the following:

After the session expire, I am not being re-directed or kicked out of
the main view.

I am only using cakephp as my backend engine. All my front end is
built using something else and all I do is send ajax requets. I've
also looked at the property ajaxLogin under Auth; but after further
inspection of the code to try to understand what it does I found the
part in auth.php where I think it's being called. See below:

auth.php from cakephp

=
} else {
if (!$this->user()) {
if (!$this->RequestHandler->isAjax()) {

$this->Session->setFlash($this->authError, 'default', array(), 'auth');
$this->Session->write('Auth.redirect', 
$url);
$controller->redirect($loginAction, 
null, true);
return false;
} elseif (!empty($this->ajaxLogin)) {
$controller->viewPath = 'elements';
echo 
$controller->render($this->ajaxLogin, 'ajax');
$this->_stop();
return false;
}
}
}
=

There are no re-directs there, it's rendering as the property
documentation describes.

How can I ensure that after I am logged in if the session expires the
user is re-directed back to the login page for any request coming in.?

Thanks in advance,

Alfredo

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



Saving HABTM records when not all join table columns are foreign keys

2009-02-18 Thread RyOnLife


I am trying to update tables with a HABTM relationship.

When my join table looked like this:

CREATE TABLE IF NOT EXISTS `items_labels` (
  `item_id` int(11) NOT NULL,
  `label_id` int(11) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

... I could update the tables with $this->Item->save($data) where $data was:

Array
(
[Item] => Array
(
[id] => 1
)
[Label] => Array
(
[Label] => Array
(
[0] => 4
[1] => 5
[2] => 7
[3] => 8
)
)
)

I've added a column to my join table, so it now looks like:

CREATE TABLE IF NOT EXISTS `items_labels` (
  `item_id` int(11) NOT NULL,
  `label_id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

When I am saving $data, I also want to save a user_id. The user_id will be
the same for all records in a single save operation.

Can someone show me what the $data array needs to look like in order to
incorporate the user_id? Thanks.

-- 
View this message in context: 
http://n2.nabble.com/Saving-HABTM-records-when-not-all-join-table-columns-are-foreign-keys-tp2348416p2348416.html
Sent from the CakePHP mailing list archive at Nabble.com.


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



Re: List of all Controllers and Actions

2009-02-18 Thread GetIT


> I use this as a dev/fallback 
> menu:http://trac.assembla.com/mi/browser/branches/base/views/elements/admi...

Thanks a lot.
Configure::listObjects() is exactly what I was looking for.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Problems with Routes

2009-02-18 Thread Eber Freitas Dias
Please, take a look at this ::: http://pastie.org/392952 ::: as you can see,
it inserts '/painel/' in front of the controller and action... how to avoid
that? realise that I have 'prefix' => null, 'painel' => false on the
$form->create() options array...

Thanks in advanced! :)

-- 
Éber Freitas Dias

www.acoruja.com
www.tu-dus.com
www.eberfdias.com

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



Re: how to display message "no record found"

2009-02-18 Thread Mark (Germany)

if(!empty($data) {}
is enough
as it does not contain anything if there haven not been any found
records


On 18 Feb., 17:06, vikas  wrote:
> Ya you are right.. my problem is solved..
> thanx
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: HTML not escaped in baked views - is this a bug?

2009-02-18 Thread Mark (Germany)

i agree
already did this with all my view templates


i even tried to exclude the "id" and "foreign_id" fields (as they are
keys and therefore no threats:


foreach ($fields as $field) {
$isKey = false;
if(!empty($associations['belongsTo'])) {
foreach ($associations['belongsTo'] as $alias 
=> $details) {
if($field === $details['foreignKey']) {
$isKey = true;
echo "\t\t\n\t\t\tlink(\${$singularVar}
['{$alias}']['{$details['displayField']}'], array('controller'=>
'{$details['controller']}', 'action'=>'view', \${$singularVar}
['{$alias}']['{$details['primaryKey']}'])); ?>\n\t\t\n";
break;
}
}
}
if($isKey !== true) {
/** CORE-EDIT (protection against js injection 
by using h()
function)**/
$h_b = "h(";
$h_e = ")";
if ($field=='id' || (strlen($field) > 3 && 
substr($field, -3, 3)
=='_id')) {
$h_b = "";
$h_e = "";
}

echo "\t\t\n\t\t\t\n\t\t\n";
/** CORE-EDIT end **/
}
}
TODO: exclude primaryKeys if they are called other than "id"




maybe there is a nicer cleaner way - but it works^^




On 18 Feb., 16:58, mark_story  wrote:
> Well you can make your own bake templates, and include html escaping
> there.  The assumption is that you will 'harden' your app after
> baking. I could see it being an enhancement.  But like I said you can
> make your own hardened bake files.
>
> -Mark
>
> On Feb 18, 9:37 am, Jonathan  wrote:
>
> > Hi,
>
> > If you use the console to bake views like index.ctp and view.ctp, data
> > is echo'ed directly like:
> >   
>
> > - I think that all output should by default be HTML-escaped to avoid
> > security flaws, so the baked code should rather be something like:
> >   
>
> > What are your opinions - should this be considered a bug?
>
> >   Regards
>
> >     Jonathan
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: how to display message "no record found"

2009-02-18 Thread vikas

Ya you are right.. my problem is solved..
thanx
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: HTML not escaped in baked views - is this a bug?

2009-02-18 Thread mark_story

Well you can make your own bake templates, and include html escaping
there.  The assumption is that you will 'harden' your app after
baking. I could see it being an enhancement.  But like I said you can
make your own hardened bake files.

-Mark

On Feb 18, 9:37 am, Jonathan  wrote:
> Hi,
>
> If you use the console to bake views like index.ctp and view.ctp, data
> is echo'ed directly like:
>   
>
> - I think that all output should by default be HTML-escaped to avoid
> security flaws, so the baked code should rather be something like:
>   
>
> What are your opinions - should this be considered a bug?
>
>   Regards
>
>     Jonathan
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Problem with email component after upgrade to 1.2 final

2009-02-18 Thread Martin Westin

Hello LunarDraco, devils advocate here.
Exactly how much faster would all that be compared to requestAction()?
Unless you see some serious performance gain why bother? (it is only
one cron request every hour? every 5 min?)




On Feb 18, 4:04 pm, LunarDraco  wrote:
> > If you use 1.2.1 stable it should work as expected without any extra
> > calls.
>
> For me, I'm using the email component from the console shell. The
> console shell doesn't load up hardly anything automagically, so in my
> case it is required to make the call.
> This shell is then in turn called by a cron job to periodically check
> our ftp site for updated files and send out notifications. The logic
> for this check is done within a controller. So my shell loads the
> controller, then creates and loads the email component. Associates the
> email component and controller and then I call my action in the
> controller.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: how to display message "no record found"

2009-02-18 Thread Aivaras
Hello, why not trying this:

if(!empty($data) && isset($data[0])) {
  echo "yay";
}
else {
  echo "No records found, we are really sorry :(";
}

if there are no records then $data should be empty and $data[0] should not
be set, that is how you check if there are any records, or I misunderstood
your question?

Have a nice day,
Faifas


On Wed, Feb 18, 2009 at 17:10, vikas  wrote:

>
> I have UsersController. In that I have a index() action.
>
> In that action, the code is:
>
> $data = $this->paginate('User');
> $this->set(compact('data'));
>
> Now I want to check that is there data available or not. Means if
> there is no record then I will get no record in array.
> But how to check this thing in view because I use $data variable in my
> index view.. So if there is no record then want to disply message that
> "no record found". but by default it display paginator string:
> Page 1 of 1, showing 0 records out of 0 total, starting on record 0,
> ending on 0
>
>
> >
>

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



how to display message "no record found"

2009-02-18 Thread vikas

I have UsersController. In that I have a index() action.

In that action, the code is:

$data = $this->paginate('User');
$this->set(compact('data'));

Now I want to check that is there data available or not. Means if
there is no record then I will get no record in array.
But how to check this thing in view because I use $data variable in my
index view.. So if there is no record then want to disply message that
"no record found". but by default it display paginator string:
Page 1 of 1, showing 0 records out of 0 total, starting on record 0,
ending on 0


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



Re: Problem with email component after upgrade to 1.2 final

2009-02-18 Thread LunarDraco

> If you use 1.2.1 stable it should work as expected without any extra
> calls.

For me, I'm using the email component from the console shell. The
console shell doesn't load up hardly anything automagically, so in my
case it is required to make the call.
This shell is then in turn called by a cron job to periodically check
our ftp site for updated files and send out notifications. The logic
for this check is done within a controller. So my shell loads the
controller, then creates and loads the email component. Associates the
email component and controller and then I call my action in the
controller.


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



Re: translate behavior

2009-02-18 Thread jitka (poLK)

For 'fallback' translations, set model's $locale property to array of
locales instead of string - if translation for field(s) and 1st locale
in array will not be found, other ones will be tried.
As of notice that returned data are using fallback locale (means - not
first one in $locale array), there is currently no way how you can
determine this fact (except for asking model for data with string
$locale first and if it fails, try it again with array $locale), but
we will probably remove this limitation in future.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



HTML not escaped in baked views - is this a bug?

2009-02-18 Thread Jonathan

Hi,

If you use the console to bake views like index.ctp and view.ctp, data
is echo'ed directly like:
  

- I think that all output should by default be HTML-escaped to avoid
security flaws, so the baked code should rather be something like:
  

What are your opinions - should this be considered a bug?

  Regards

Jonathan

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



Re: Validate rule: multiple (CookBook -> 4.1.4.17 Multiple)

2009-02-18 Thread WebbedIT

The question I guess I now need answered is why doesn't
Modell::saveAll validate HABTM data before saving it?

By digging into the core I found that Model::saveAll does not have a
switch case for hasAndBelongsToMany, but by my limited logical
reasoning that would mean the data would not get saved either, yet it
does.

I amended lines #1511 to #1525 to the following which results in my
HABTM model getting validated as required and my data is being saved
as expected, but I don't fully follow the code so there's a high
chance this is not a sensible solution:

  if (isset($associations[$association])) {
switch ($associations[$association]) {
  case 'belongsTo':
  case 'hasAndBelongsToMany': // added
if ($this->__save($this->{$association}, $values, $options)) {
  $data[$this->alias][$this->{$associations[$association]}
[$association]['foreignKey']] = $this->{$association}->id; // edited
} else {
  $validationErrors[$association] = $this->{$association}-
>validationErrors;
  $validates = false;
}
if (!$options['atomic']) {
  $return[$association][] = $validates;
}
  break;
}
  }
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Are we using the slowest PHP framework there is?

2009-02-18 Thread mark_story

On Feb 17, 8:35 pm, Motin  wrote:
> CakePHP does have some issues with aggressive loading, and have
> terrible performance in a lot of areas, but that benchmark, doesn't
> really measure anything regarding to Yii. Because of Yii's lazy
> loading, practically none of the commonly used objects/classes are
> loaded in the test application. This makes it practically the same as
> barebones PHP. However, in a real application, when the helpers and
> models are actually used (and thus loaded), I think the results would
> look much different.
>
> Also, CakePHP is meant to be run with a non-file-based cache engine +
> a php accelerator.
>
> Still, I believe that Yii is much faster for slimmed down
> applications, and I really hope that CakePHP can learn something from
> the lazy loading parts (why on earth does Cake load _all_ models in
> $uses on each request - instead of when they are actually used? for
> instance).
>


Well PHP4 is one reason.  Lazy loading doesn't work so well in PHP4,
also using $uses is known to cause performance issues as you end up
loading far too many models.  You ask about why cake doesn't lazy
load, but by using $uses you are doing the opposite of lazy loading.
$uses is probably the most aggressive loading strategy you can
implement.  Using Controller::loadModel() or ClassRegistry::init() is
a more _lazy_ approach.

-Mark
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Define TMP where?

2009-02-18 Thread Martin Westin

Catchy subject, no? At least it is to the point. :)

So, I want to (re)define where the temp-files go. I would prefer to do
this without modifying the core, but I can't see where. My first true
entry-point into the request-cycle is in bootstrap.php, too late to
define the constant TMP.

Now, before you can say index.php, let me point out that shell access
disregards any setting I have changed or added to index.php. So, while
index.php will let me define the temp-folder, it will only be 99%
true. And unfortunately those few shell requests (cron calling
regularly) are rather important to me. For example I keep a few lock-
files in the temp folder without which things could get messy.

The annoying bit is how close Cake seems to be to supporting this. In
paths.php Cake checks if TMP is already defined and all... but for a
shell task there is no way I know of that can get me in front of
paths. It looks like there should be but I can't find it. It looks
like this has been thought out for web access but so far forgotten for
shell access, unless I have missed it.

If there is no place (in my application) to define TMP for shell
access, my question is if the least invasive method would be to modify
paths.php in the core. Or is there some better place?

/Martin
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Validate rule: multiple (CookBook -> 4.1.4.17 Multiple)

2009-02-18 Thread WebbedIT

Thanks Abrar,

Unfortunately you have not have read my post properly ... this is not
multiple rules per field, it's the built-in cake 'multiple' rule
clearly indicated by the subject of this thread.

Paul.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Validate rule: multiple (CookBook -> 4.1.4.17 Multiple)

2009-02-18 Thread Abrar Arshad
Hi,
 No need to force something in the controller to make working multiple
rules on one field, you can do it this way.
It means the value of rule key can have array of parameters with itself
repeating in the array.

 var $validate = array(
'email'=> array(
'email'=>
array('rule'=>'email','message'=>'Email is invalid'),

'isUnique'=>array('rule'=>'isUnique','message'=>'This email is already
registered')));


}

i hope it will help you.

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



translate behavior

2009-02-18 Thread kicaj

How to use Translate Behavior when some fields there are no translated
and I want display default version?

..and setFlash with message 'There is no translated version (french),
and we was display default version (english)!":)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Validate rule: multiple (CookBook -> 4.1.4.17 Multiple)

2009-02-18 Thread WebbedIT

Update: I managed to get the 'multiple' rule working, but I am having
to force it in my controller action as follows

Role Model:
validate = array(
  'Role' => array(
'rule' => array('multiple', array('min'=>1)),
'message' => 'If approved, select one or more roles'
  )
);

Staff Controller:
function edit($id = null) {
  if (!empty($this->data)) {
$this->Staff->Role->set($this->data); // pass data to Role model,
doesn't check rule without this
$this->data['Staff']['modifier_id'] = $this->authUser['User']
['id'];
$this->data['Person']['modifier_id'] = $this->authUser['User']
['id'];
if ($this->Staff->saveAll($this->data, array('validate'=>'first'))
&& $this->Staff->Role->validates()) {
  $this->Session->setFlash('Staff updated');
  $this->redirect('view/'.$this->Staff->id);
} else {
  $this->Session->setFlash('Staff not updated, correct errors and
resubmit');
}
  } else {
$this->data = $this->Staff->find('first', array(
  'conditions' => array('Staff.id'=>$id),
  'contain' => array('Person'=>array('Organisation'),'Role')
));
$this->data['Scheme']['id'] = $this->data['Person']['Organisation']
['scheme_id'];
  }
  $this->__formData();
}

Problem with this is it's running validation for the Staff->saveAll()
separately from Role->validates() generating independent $this-
>validationErrors arrays so I get either the errors from one check OR
the other, not both.

Can anyone advise how I can run this so all errors are properly added
to $this->validationErrors?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Calling a (empty!) model-method causes SQL Error: 1064

2009-02-18 Thread AD7six



On Feb 18, 1:01 pm, Mr Speaker  wrote:
> I have this same issue (exactly)... what am i doing wrong?

You are (both) calling a method on a (model) object that doesn't exist
- probably because of a misnamed file.

"AppModel::doTest() - [internal], line ?? " <- it's an instance of
AppModel, not your model.

Check the conventions page regarding filenames.

hth,

AD
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Calling a (empty!) model-method causes SQL Error: 1064

2009-02-18 Thread Mr Speaker

I have this same issue (exactly)... what am i doing wrong?

On Dec 31 2008, 11:28 pm, asteel  wrote:
> Hi,
>
> when I call a method of a model out of a controller, I get the
> following sql-exception:
>
> EXCEPTION ->
>
> Warning (512): SQL Error: 1064: You have an error in your SQL syntax;
> check the manual that corresponds to your MySQL server version for the
> right syntax to use near 'doTest' at line 1 [CORE/cake/libs/model/
> datasources/dbo_source.php, line 514]
>

> <- EXCEPTION
>
> CODE >
>
> class StartController extends AppController {
>         var $name = 'Start';
>         var $uses = array('Abc');
>
>         function index() {
>                 // call that causes the exception
>                 $this->Abc->doTest();
>         }
>
> }
>
> class Abc extends AppModel {
>         // ** ORM **
>         var $name = 'Abc';
>         var $table = 'abc';
>         var $displayField = 'titel';
>
>         // ** Methods **
>         function doTest() {
>                 return null;
>         }
>
> }
>
> < CODE
>
> I am using the latest version (1.2 / nightlybuild 31.12.2008).
>
> Any ideas?
>
> Thanks.

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



Re: List of all Controllers and Actions

2009-02-18 Thread Günther Theilen

Hi,

I use these two methods:
http://bin.cakephp.org/view/835272537

Regards
Guenther

GetIT wrote:
> Hi,
> 
> I want to build a navigation out of all available Controllers/Actions.
> 
> Is there a way to get a list of all Controllers/Actions with the help
> of cakephp or php?
> How?
> > 


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



Re: List of all Controllers and Actions

2009-02-18 Thread AD7six



On Feb 18, 10:15 am, GetIT  wrote:
> Hi,
>
> I want to build a navigation out of all available Controllers/Actions.
>
> Is there a way to get a list of all Controllers/Actions with the help
> of cakephp or php?
> How?

I use this as a dev/fallback menu:
http://trac.assembla.com/mi/browser/branches/base/views/elements/admin/menu/auto.ctp

Trying to automate linking to actions isn't going to be easy or a good
idea (IMO). e,g, which of these should appear in the menu?
admin_index($type)
admin_recent($type)
admin_edit($id)
admin_delete($id)
admin_add()
admin_approve($id)
admin_pending()
etc.

AD
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: List of all Controllers and Actions

2009-02-18 Thread Martin Westin

I haven't done this sort of menu and I am not sure I would want to.

You might need to do the following:
Get all controllers by listing the folder (app/controllers) and
pasring the filenames. Dito for any plugins.
You would then have to instantiate each one and call get_ class_
methods() to get all methods and parsing out names like _actionname
and admin_actionname

The above is automatic but quite costly (processing and RAM) so you
would definitely want to cache the results. I go a step further
myself, though.

I have a menu-system that is similar but I have a table containing top-
level menuitems (controllers). This way I have a table of data to
point permissions to. I can link different ones to different users so
that each one sees a slightly different menu... but best of all, I can
completely exclude controllers I don't want a navigation for (such as
an API or some utility-controller). You get a whole lot more control
when you put the data into a table since you can add any meta-data (as
extra fields) you want.

You can do the same using a tree-structure in the database
representing controllers and actions to get the menu you need.

/Martin


On Feb 18, 10:15 am, GetIT  wrote:
> Hi,
>
> I want to build a navigation out of all available Controllers/Actions.
>
> Is there a way to get a list of all Controllers/Actions with the help
> of cakephp or php?
> How?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Validate rule: multiple (CookBook -> 4.1.4.17 Multiple)

2009-02-18 Thread WebbedIT

There doesn't seem to be much online about the use of this rule and I
am having problems using it to make sure one checkbox is selected
(searches for 'validate multiple' bring up loads about multiple rules
per field).

I first applied it as in the CookBook ...

var $validate = array(
'multiple' => array(
'rule' => array('multiple', array('min' => 1)),
'message' => 'Please select at least one option'
)
);

But thought this probably wasn't working as it was not assigned to any
field, but which field to I apply it to.  Looking at teknoid's custom
HABTM validation blog entry (http://teknoid.wordpress.com/2008/10/16/
how-to-validate-habtm-data/) I figured I needed to apply it to the
name of the array in $this->data so ended up with this.

var $validate = array(
'Role' => array(
'rule' => array('multiple', array('min' => 1)),
'message' => 'Please select at least one role'
)
);

Still no joy though .. anyone else got this rule working yet?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Odd pagination possible using paginator?

2009-02-18 Thread Martin Westin

Hi brian,
Thanks, but unfortunately that does not really answer my question.
Using find I can get "all" relevant "instances". I was instead looking
for a way for paginate() to work on those instances belonging to one
Person. The problem being that I only get it to paginate instances
relative to each Series.

In English I'd write: Paginate instances belonging to any Series
belonging to any Study belonging to Person 2.

If a "page" contained the last 5 instances from a Series, paginator
should, if possible, "jump" and include the first 5 from the next
Series. It might be possible to try some custom joining and pass that
to paginator, but before spending unknown hours "stabbing in the dark"
I was hoping that someone had some experience with a similar case and
was confident that it is doable.

/Martin


On Feb 17, 4:49 pm, brian  wrote:
> Just a hunch: try adding a fields array, for each model, that contains
> either its ID/PK and/or FK to the child model. I've recently noticed
> that this sometimes is necessary to get belongsTo associations
> contained. Start from the top (Person) and work down.
>
> $this->data = $this->Person->find('first',array(
>    'conditions' => array(
>        'Person.pk' => $id
>    ),
>    fields => array('Person.pk'),
>    'contain' => array(
>        'Study' => array(
>            'fields => array('Study.pk'),
>            'Series' => array(
>                'Instance' => array(
>                    'File'
>                )
>            )
>        )
>    )
> ))
>
> I haven't had time to dig further than that so, for now, it's been a
> bit of a stab in the dark.
>
> On Tue, Feb 17, 2009 at 6:55 AM, Martin Westin
>
>  wrote:
>
> > Hi,
> > This is a bit of an odd case. I have a deep association and want to
> > paginate the "farthest" model ignoring its relation to the
> > intermediate model... As a straight find using containable might
> > explain the hierarchy:
>
> > $this->data = $this->Person->find('first',array(
> >    'conditions' => array(
> >        'Person.pk' => $id
> >    ),
> >    'contain' => array(
> >        'Study' => array(
> >            'Series' => array(
> >                'Instance' => array(
> >                    'File'
> >                )
> >            )
> >        )
> >    )
> > ));
> > As anyone can clearly see, this is a "legacy" database that I can't
> > alter. (pk is a bit of a tip-off)
>
> > This is a series of hasMany (and returning belongsTo)
> > Person->Study->Series->Instance->File
>
> > I want to paginate the Instances returned no matter if they belongTo
> > one of 5 series to fill the "page".
> > I want to paginate Files that eventually belongTo Person $id, ignoring
> > the intermediate models.
> > (I hope that explains it)
>
> > I was wondering if there was some , to me, unknown trick to get this
> > kind of pagination or if I should just accept a custom query (or some
> > hack of my own)?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: logout not authorized to access

2009-02-18 Thread Chris

I found the same thing.  I moved my login and logout functions to a
security controller which handles other security based actions.

You answered your own question as unfortunately even though Auth has a
loginAction() method it does not have a logoutAction() method so it
needs to be excluded manually.

You can add a beforeFilter to the controller containing the logout
function like so:

function beforeFilter() {
parent::beforeFilter();
$this->Auth->allow('logout');
}

That will ensure that logout is ignored for all users.

On Feb 10, 12:25 pm, yisn  wrote:
> I followed the "Simple Acl controlled Application" in the Cookbook of
> CakePHP, and got the message "You arenotauthorizedto access that
> location" when try tologout. I logged in as a user who isnotallowed
> to access the UsersController actions.
>
> Do i need to grant the access to "logout" function for this user to
> fix this problem? But the "login" function doesnotneed to be
> granted, does the "auth" componentnotgrant access to "logout"
> function itself?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



List of all Controllers and Actions

2009-02-18 Thread GetIT

Hi,

I want to build a navigation out of all available Controllers/Actions.

Is there a way to get a list of all Controllers/Actions with the help
of cakephp or php?
How?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: create an input with $form->input() and disable it?

2009-02-18 Thread CraigFisher

I got caught by the phantom data loss:  the $data array after POSTing
doesn't contain the all the fields from the Model->read; only those
that aren't disabled - so if you fail validation, and the form is
redisplayed, the data which was originally populated via the Model-
>read will have lost the fields which were disabled.

Readonly and css was the way that I used... otherwise you can't use
the 'Input' styling for consistent looks & view code.

-C
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: isn't a form in the view supposed to find the correct action?

2009-02-18 Thread Aivaras
Unless you create a form with Model.id that is filled by edit() function.
You don't need to specify an action then.

Aivaras


On Wed, Feb 18, 2009 at 10:35, RichardAtHome wrote:

>
> Sindey, Marcelo is right. The default action for a form is to post to
> the $controller->add() method. You have to override it for other
> actions
>
> On Feb 18, 12:00 am, Sidney  wrote:
> > I think the default action is to self-post i.e. the form post/get goes
> > to the same controller/action that served the view with the form on
> > it. This is a normal design convention and seems logical to me
> > (although quite a noob myself). Perhaps I misunderstand your question?
> >
> > On Feb 17, 8:01 am, Marcelo Andrade  wrote:
> >
> > > Hi there,
> >
> > > By the CakePHP conventions, the view's name must be the same
> > > as an action in a controller.  A common mistake for the newbies is
> > > when creating a form in the view is that the
> >
> > > echo $form->create('MyModel');
> >
> > > defaults to generate a form for the "add" action.  But I think that
> > > should be more intuitive that it's defaults to the action with the
> > > same name as the view.  Isn' it?
> >
> > > Best regards.
> >
> > > --
> > > MARCELO DE F. ANDRADE (aka "eleKtron")
> > > Belem, PA, Amazonia, Brazil
> > > Linux User #221105
> >
>

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



Understanding Acl with Auth

2009-02-18 Thread rinda

Hi,

I spent days understanding this acl stuff. I made progress but
still

I have groups:
id:1, name:administrators
id:2, name:managers
id:3, name:users

I have users:
id:1, name:admin, group_id:1
id:2, name:mana, group_id:2
id:3, name:user, group_id:3

I have aros:
id:1, parent_id:null, model:Group, foreign_key:1,
alias:administrators, lft:1, rght:4
id:2, parent_id:null, model:Group, foreign_key:2, alias:managers, lft:
5, rght:8
id:3, parent_id:null, model:Group, foreign_key:3, alias:users, lft:9,
rght:12
id:4, parent_id:1, model:User, foreign_key:1, alias:admin, lft:2, rght:
3
id:5, parent_id:2, model:User, foreign_key:2, alias:mana, lft:6, rght:
7
id:6, parent_id:3, model:User, foreign_key:3, alias:user, lft:10, rght:
11

I have acos:
id:1, parent_id:null, alias:controllers, lft:1, rght:6
id:2, parent_id:1, alias:bla, lft:2, rght:3
id:3, parent_id:1, alias:she, lft:4, rght:5

I have aros_acos:
id:1, aro_id:2, aco_id:2, _read,_create,_update,_delete: 1
id:2, aro_id:2, aco_id:3, _read,_create,_update,_delete: 1
id:3, aro_id:3, aco_id:3, _read,_create,_update,_delete: 1

These are bla and she controller:
class [Bla/She]Controller extends AppController
{
  var $uses = array();
  function testing()
  {
echo "Acl makes me crazy.";
$this->autoRender = false;
  }
}

This is User model:
class User extends AppModel
{
  var $name = 'User';
  var $belongsTo = array('Group');
  var $actsAs = array('Acl' => array('requester'));

  function parentNode()
  {
if (!$this->id && empty($this->data))
{
  return null;
}
$data = $this->data;
if (empty($this->data))
{
  $data = $this->read();
}
if (!$data['User']['group_id'])
{
  return null;
}
else
{
  return array('Group' => array('id' => $data['User']
['group_id']));
}
  }
}

This is Group model:
class Group extends AppModel
{
  var $name = 'Group';
  var $actsAs = array('Acl' => array('requester'));

  function parentNode()
  {
return null;
  }
}

This is my app_controller file:
class AppController extends Controller
{
  var $components = array('Acl', 'Auth');

  function beforeFilter()
  {
$this->Auth->authorize = 'actions';
$this->Auth->loginAction = array('controller' => 'users', 'action'
=> 'login');
$this->Auth->logoutRedirect = array('controller' => 'users',
'action' => 'login');
$this->Auth->loginRedirect = array('controller' => 'users',
'action' => 'login');
$this->Auth->actionPath = 'controllers/';
  }
}

If I log in with user 'mana' (group = 'managers') then go to this
page: /bla/testing, I get this error:
DbAcl::check() - Failed ARO/ACO node lookup in permissions check.
Node references:

Aco: controllers/Bla/testing

But if I put another aco node with alias 'testing' and parent node
points to 'bla', I can access it.
id:4, parent_id:2, alias:testing, lft:3, rght:4

I am very confused. How should you name the aco (controller stuff)?
How do I use _read, _create, etc field effectively? Why do I get
failed node lookup rather than denied access?

Thank you.

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



Re: l10n and Auth

2009-02-18 Thread LuigiZ

Thanks Miles.
I have placed my code in a beforeFilter() controller (not
AppController) and works fine now !

On 17 Feb, 22:05, Miles J  wrote:
> Is it in your beforeFilter()? Try placing it in your AppController
> beforeFilter(). Thats where I place mine and it works smoothly.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Link to Image using Helpers

2009-02-18 Thread Adrian Marte

Worked! Thanks a lot.

Quite obvious when I think about it ;)

On 12 Feb., 11:35, grigri  wrote:
> Assuming you meant `app/webroot/img`,
>
> // This is a text link to an image:
> echo $html->link('This is an image', '/img/some-image.png');
>
> // This is an image link to another image:
> echo $html->image('small-image.png', array('url' => '/img/big-
> image.png'));
>
> // So is this:
> echo $html->link(
>   $html->image('small-image.png'),
>   '/img/big-image.png',
>   array('escape' => false)
> );
>
> If you didn't mean `app/webroot/img`, and you're actually storing
> images in `app/img`, then let me be the first to say UR DOIN IT RONG!
> If you want a file to be directly web-accessible then it belongs in
> the webroot folder. Anything not in the webroot folder cannot be
> accessed directly through a url.
>
> If you really really want to keep images outside of the webroot then
> you'll have to serve them with a MediaView or some other method - not
> a great idea for static images since it creates quite a bit of server
> overhead. If you're going for dynamic images, on the other hand, then
> it makes perfect sense [though I'd invest in some cacheing].
>
> hth
> grigri
>
> On Feb 12, 9:08 am, Adrian Marte  wrote:
>
> > Hi,
>
> > How can I create a link to an image (in the app/img directory) using
> > the HTML helper? I only find solutions for image links, but not links
> > to images.
>
> > Thank,
> > Adrian
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: isn't a form in the view supposed to find the correct action?

2009-02-18 Thread RichardAtHome

Sindey, Marcelo is right. The default action for a form is to post to
the $controller->add() method. You have to override it for other
actions

On Feb 18, 12:00 am, Sidney  wrote:
> I think the default action is to self-post i.e. the form post/get goes
> to the same controller/action that served the view with the form on
> it. This is a normal design convention and seems logical to me
> (although quite a noob myself). Perhaps I misunderstand your question?
>
> On Feb 17, 8:01 am, Marcelo Andrade  wrote:
>
> > Hi there,
>
> > By the CakePHP conventions, the view's name must be the same
> > as an action in a controller.  A common mistake for the newbies is
> > when creating a form in the view is that the
>
> > echo $form->create('MyModel');
>
> > defaults to generate a form for the "add" action.  But I think that
> > should be more intuitive that it's defaults to the action with the
> > same name as the view.  Isn' it?
>
> > Best regards.
>
> > --
> > MARCELO DE F. ANDRADE (aka "eleKtron")
> > Belem, PA, Amazonia, Brazil
> > Linux User #221105
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Get parent id of threaded

2009-02-18 Thread igorf

Hi
I have an array getted with :
$categories = $this->CatalogCategory->find('threaded');

Now I have the id of a children CatalogCategory and I need to get the
"path" from $categories to this children, how can I do?

Example:
Array
(
[0] => Array
([CatalogCategory] => Array
([id] => 1
[parent_id] =>
[name_it] => name it 1)

[children] => Array
(
[0] => Array
([CatalogCategory] => Array
([id] => 2
[parent_id] => 1
[name_it] => name it 1.1)

[children] => Array
(
)

)

[1] => Array
(
[CatalogCategory] => Array
(
[id] => 3
[parent_id] => 1
[name_it] => name it 1.2
)

[children] => Array
(
)

)

)

)

[1] => Array
(
[CatalogCategory] => Array
(
[id] => 4
[parent_id] =>
[name_it] => name it 2
)

[children] => Array
(
[0] => Array
(
[CatalogCategory] => Array
(
[id] => 5
[parent_id] => 4
[name_it] => name it 2.1
)

[children] => Array
(
)

)

[1] => Array
(
[CatalogCategory] => Array
(
[id] => 6
[parent_id] => 4
[name_it] => name it 2.2
)

[children] => Array
(
)
)
)
)
)


I have id = 6 and I need an array similar (4,6)

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



Re: Are we using the slowest PHP framework there is?

2009-02-18 Thread Ned Lukies

As someone who has written/writing a CMS using CakePHP, even this is
not of concern. A bit of mod_rewrite trickery has allowed us to write
custom code for very fast viewing content pages, while the
administration interface is kept within Cake's MVC. Who cares if the
administration interface is a little slow, its unlikely to be getting
more than 1500 page views a day.

Ned


> Also the benchmarks measure heavy traffic. That is less important for
> an Application framework than it is for a CMS. That type of benchmark
> can never really measure the efficiency of the ORM or any other
> "internal" part of Cake.

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