Re: Redirect After Using render('action')

2009-09-25 Thread Tony Thomas

Thanks Brian,

I thought that might be the case.

On Sep 24, 7:30 pm, brian bally.z...@gmail.com wrote:
 Whether Cake spits out a CSV file or redirects to another
 controller/action, headers need to be sent to the client, but you
 can't send headers for both simultaneously.

 If you really want the form to disappear, use JS to submit the form
 using AJAX and hide/change certain elements of the page.

 On Thu, Sep 24, 2009 at 3:17 PM, Tony Thomas truet...@gmail.com wrote:

  I have a controller function that's using $this-render('action') to
  render a view that creates a CSV file after submitting some info in a
  form.

  What I want to do is redirect the user after the CSV file is
  downloaded. So the steps would be:

  1. User submits data.
  2. Queries are run and a CSV file is rendered and saved by the user.
  3. Controller redirects to another view.

  If I do a simple redirect using $this-redirect('controller/action'),
  the CSV file is not rendered, even though render() is called first. If
  I don't redirect, the CSV is successfully rendered, but the user is
  left with a form that is still filled-in. I'd like to redirect to
  another view and display a Success flash message once the CSV is
  rendered.

  Any tips?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Redirect After Using render('action')

2009-09-24 Thread Tony Thomas

I have a controller function that's using $this-render('action') to
render a view that creates a CSV file after submitting some info in a
form.

What I want to do is redirect the user after the CSV file is
downloaded. So the steps would be:

1. User submits data.
2. Queries are run and a CSV file is rendered and saved by the user.
3. Controller redirects to another view.

If I do a simple redirect using $this-redirect('controller/action'),
the CSV file is not rendered, even though render() is called first. If
I don't redirect, the CSV is successfully rendered, but the user is
left with a form that is still filled-in. I'd like to redirect to
another view and display a Success flash message once the CSV is
rendered.

Any tips?
--~--~-~--~~~---~--~~
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: Ajax Errors

2009-08-11 Thread Tony Thomas

I actually ending up using this:

http://deadlytechnology.com/scripts/javascript/ajax-failure-callback/

It sends a 403 server error back if the transaction doesn't validate
which triggers my error message in the view.

On Aug 11, 2:50 am, Saliem than.sal...@gmail.com wrote:
 I am not quite sure what you are missing but you might want to double
 check a couple of things including:

 the name of your aliquot model file,
 the validate variable in your aliquot model file and
 try using the validationErrors method available for each of the models
 created and returning any errors as json

 please see :

 http://book.cakephp.org/view/410/Validating-Data-from-the-Controller

 On Aug 10, 3:42 pm, Tony Thomas truet...@gmail.com wrote:

  This is something that's so simple, I'm embarrassed to ask. But after
  a few dozen Google searches, I'm going to swallow my pride and post my
  question here.

  I have a simple ajax function in my controller and I want it to return
  an error is the request is not successful. For example:

  function ajax_update_box($boxId, $aliquotIds){
          if ($this-RequestHandler-isAjax()) { // if the request is AJAX
                  if($aliquots = $this-Aliquot-validateMove($aliquotIds, 
  $boxId))
  { // make sure a slot is open in the box
                          foreach($aliquots as $aliquot_id = $position ) { 
  // validateMove
  returns an array
                                  if 
  ($this-Aliquot-save($this-data['Aliquot'] =! true)) {
                                          Configure::write('debug', 0);
                                          $this-autoRender = false;
                                          exit('There was an error and some 
  of the aliquots were not
  moved.');
                                  }
                          }

                          echo $this-unstored();

                  } else { // this is where I want it to return an error.
                          Configure::write('debug', 0);
                          $this-autoRender = false;
                          exit('The move did not work. Check to see if the 
  box is full.');

                  }
                  Configure::write('debug', 0);
                          $this-autoRender = false;
                          exit(0);
          }

  }

  If the request doesn't pass validation in my model, I want to display
  an error message, but I can't seem to get that to work. Everything is
  treated as success. What am I missing?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Ajax Errors

2009-08-10 Thread Tony Thomas

This is something that's so simple, I'm embarrassed to ask. But after
a few dozen Google searches, I'm going to swallow my pride and post my
question here.

I have a simple ajax function in my controller and I want it to return
an error is the request is not successful. For example:

function ajax_update_box($boxId, $aliquotIds){
if ($this-RequestHandler-isAjax()) { // if the request is AJAX
if($aliquots = $this-Aliquot-validateMove($aliquotIds, 
$boxId))
{ // make sure a slot is open in the box
foreach($aliquots as $aliquot_id = $position ) { // 
validateMove
returns an array
if ($this-Aliquot-save($this-data['Aliquot'] 
=! true)) {
Configure::write('debug', 0);
$this-autoRender = false;
exit('There was an error and some of 
the aliquots were not
moved.');
}
}

echo $this-unstored();

} else { // this is where I want it to return an error.
Configure::write('debug', 0);
$this-autoRender = false;
exit('The move did not work. Check to see if the box is 
full.');

}
Configure::write('debug', 0);
$this-autoRender = false;
exit(0);
}
}

If the request doesn't pass validation in my model, I want to display
an error message, but I can't seem to get that to work. Everything is
treated as success. What am I missing?
--~--~-~--~~~---~--~~
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 Dynamic Navigation Based On Tree Behavior

2009-07-29 Thread Tony Thomas

Thanks for this tip. It was exactly what I needed!

On Jul 26, 7:51 pm, brian bally.z...@gmail.com wrote:
 I used this:

 http://bakery.cakephp.org/articles/view/tree-helper-1

 My nav is an element with:

 div id=nav
 ?php
 echo $tree-generate(
         $section_nodes,
         array(
                 'element' = 'sections/nav_node',
                 'model' = 'Section'
         )
 );
 ?
 /div

 And nav_node.ctp looks like:

 $tree-addItemAttribute('id', 'section_'.$data['Section']['id']);

 if ($depth == 0)
 {
         $tree-addItemAttribute('class', 'Section HideMe');

 }

 if ($hasChildren)
 {
         $tree-addItemAttribute('class', 'NavParent');

 }

 $is_current = (isset($section_node_id)  $section_node_id ==
 $data['Section']['id'])
         ? ' class=Current'
         : null;

 echo 'a href='.$data['Section']['path'].' title=
 rel='.$data['Section']['id'].''.$is_current.''.$data['Section']['name'].'/a';

 On Sun, Jul 26, 2009 at 3:57 PM, Tony Thomastruet...@gmail.com wrote:

  I have a Pages table in my app with the following fields:

  id
  parent_id
  lft
  rght
  title
  body
  created
  modified

  My model uses $actsAs = array('Tree')

  All the data associations are correct and generatetreelist() returns
  the appropriate values. What I'm looking for is a way to turn the tree
  information into a nested list for dynamically built navigation. I
  want new pages to appear in the menu when they are created, but I want
  them to appear in the hierarchy according to where they fall in the
  tree.

  Does anyone have any tips for me?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Create Dynamic Navigation Based On Tree Behavior

2009-07-26 Thread Tony Thomas

I have a Pages table in my app with the following fields:

id
parent_id
lft
rght
title
body
created
modified

My model uses $actsAs = array('Tree')

All the data associations are correct and generatetreelist() returns
the appropriate values. What I'm looking for is a way to turn the tree
information into a nested list for dynamically built navigation. I
want new pages to appear in the menu when they are created, but I want
them to appear in the hierarchy according to where they fall in the
tree.

Does anyone have any tips for me?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Building a helper; Fatal error cake/libs/view/view.php on line 702

2009-03-24 Thread Tony Thomas

I want to build some options for use across several views, so a custom
HTML helper seems like the best option. However, I'm running into
problems. Here's the helper:

class PositionHelper extends AppHelper {
var $helpers = array('Html');
function getPositions() {
$yaxes = array('A','B','C','D','E','F','G','H','I');
$xaxes = array
('001','002','003','004','005','006','007','008','009');
$options = array();
foreach($yaxes as $y){
foreach($xaxes as $x) {
$options = array_pad($options,1, $y . ',' . $x);
}
}
return $this-output($form-input('position', array('options' =
$options)));
}
}

This is an attempt to build a select list of options. Right now I get
this error when I try to use it:

Fatal error: [] operator not supported for strings in /path/cake/libs/
view/view.php on line 702

As you can see, I just want to build a list of options that can be
used in more than one view and not coded into each one. Am I just
approaching this the wrong way?
--~--~-~--~~~---~--~~
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: Mod_rewrite not working

2009-03-21 Thread Tony Thomas

mod_rewrite is enabled. Like I mentioned, I can run another CakePHP
app already using mod_rewrite with my current setup. It's only this
brand new one that's behaving bizarrely.

On Mar 20, 5:22 pm, Miles J mileswjohn...@gmail.com wrote:
 Id first check your apache config files anyways, to make sure
 mod_rewrite is enabled. If you are using vhosts, check those settings
 also.
--~--~-~--~~~---~--~~
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: Mod_rewrite not working

2009-03-21 Thread Tony Thomas

I still don't know exactly what the problem was, but I downloaded a
new copy of cake and moved my models and controllers over and it
worked right away. Something must have happened when copying the files
over originally.

On Mar 21, 11:10 am, Tony Thomas truet...@gmail.com wrote:
 mod_rewrite is enabled. Like I mentioned, I can run another CakePHP
 app already using mod_rewrite with my current setup. It's only this
 brand new one that's behaving bizarrely.

 On Mar 20, 5:22 pm, Miles J mileswjohn...@gmail.com wrote:

  Id first check your apache config files anyways, to make sure
  mod_rewrite is enabled. If you are using vhosts, check those settings
  also.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Mod_rewrite not working

2009-03-20 Thread Tony Thomas

I'm starting up a fresh project in Cake, so I downloaded the latest
version, built my models and controllers using $scaffold, but the app
is acting like mod_rewrite is not working. The .htaccess files are all
there.

I'm running a local setup using MAMP on OS X.

The odd thing is that I have another CakePHP setup on this same
computer that functions just fine.

Here's what happens:

If I go to http://localhost:/project/pages I get an Apache 404
error.

If I go to http://localhost:/project/index.php/pages I get the
expected output but the paths to the css files in the head are all
wrong.

It's exactly like the .htaccess files aren't there or mod_rewrite
isn't on, except that my other local CakePHP project works just as
expected.

Can anyone else think of what might be causing this?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Retrieve Associated Count

2009-03-17 Thread Tony Thomas

I have a simple hasMany relationship set up with CakePHP and I want to
retrieve a couple of fields from the parent table based on the count
of the child.

The scenario: I have boxes that hold 81 aliquots each. (Each box is
9X9.) I want to retrieve the id and description from the boxes table
of boxes that have fewer than 81 aliquots to generate a list. In other
words, I want a list of boxes that are not full.

My models:

class Box extends AppModel {
var $name = 'Box';
var $hasMany = array('Aliquot');
var $belongsTo = 'Freezer';
}

class Aliquot extends AppModel
{
var $name = 'Aliquot';
var $belongsTo = array('Box','Specimen');
}

I can't seem to work out the best way to get a count of the aliquots
for each box. I haven't been working with CakePHP all that long, so
I'm hoping there's a relatively simple way to do this that I'm
missing. It doesn't seem like a very complicated thing to do, yet I've
spent the better part of my morning working on it with not success.
This seems like it would work:

http://book.cakephp.org/view/75/Saving-Your-Data#counterCache-Cache-your-count-490

Except that my tables are already populated, so creating the
aliquot_count field in my boxes table just leaves me with a bunch of
empty fields. Does anyone have some advice that will point me in the
right direction?
--~--~-~--~~~---~--~~
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: Redirect Loop

2009-03-14 Thread Tony Thomas

Since someone emailed me off the list to inquire about this, I thought
I'd post my fix for the problem for those who find this in the future.
Here's what I wrote in my email:

It turned out that I had moved some code in the layout that was trying
to check against Auth. I have this code in my app_controller.php file:

function beforeFilter(){
if ($role = $this-Auth-user('role')) {
$this-set('user_info', $this-Auth-user());
}
}

I check for that $user_info variable in the layout. I'm not sure
exactly what caused the problem but I'm pretty sure that was the root
of it. Here's what the layout has:

if (isset($user_info)) {

// display the username and some other info

}

I was modifying the layout and put that part of the code at the very
beginning. The effect was that the code was run before the page could
be rendered so that even when I went to log in, it was being checked,
thus trying to redirect me toward the login page. I think it went
something like this:

   1. I tried to access a page that was protected by Auth.
   2. I was redirected to the login page
   3. The login page tried to check for $user_info which wasn't set
because I hadn't logged in. Since it was checking before the page
rendered, it kept redirecting without ever rendering the page until
Firefox decided that it was an infinite loop (it was) and stopped
trying.


At least I think that's what was happening. As soon as I moved that
section down into a part of the page that would be run after the page
started to render, it solved my problem. It was bizarre. You wouldn't
think that modifying a layout would send the application into an
infinite loop. In retrospect it makes sense if my understanding of the
problem is correct. In any case, the problem was solved.

On Mar 11, 4:07 pm, Tony Thomas truet...@gmail.com wrote:
 I've been working on a local copy of my CakePHP app that runs on a my
 computer. Today I've only been working on a layout and the style
 sheet. I took a break and went back to it which prompted a new login.
 Suddenly I'm getting aredirectloop. Firefox gives me this following
 message:

 RedirectLoop

 Firefox has detected that the server is redirecting the request for
 this address in a way that will never complete.

 The browser has stopped trying to retrieve the requested item. The
 site is redirecting the request in a way that will never complete.

     * Have you disabled or blocked cookies required by this site?
     * NOTE: If accepting the site's cookies does not resolve the
 problem, it is likely a server configuration issue and not your
 computer.

 Any thoughts on what might cause that if I wasn't working in the a
 controller? More importantly, how do I fix it?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Best Way to Nest Lists w/ nestedList()

2009-03-11 Thread Tony Thomas

I'm trying to create navigation in CakePHP that uses this method with
CSS drop-downs:

http://www.webmonkey.com/tutorial/Add_CSS_Drop-Down_Menus

So, of course I want to leverage nestedList(), but since I have two
levels of nested lists, I'm getting unexpected results.

Here's what I want:

Main List Item 1
Secondary List Item 1
Secondary List Item 2
Tertiary List Item 1
Main List Item 2

Here's what I have set up at the moment:

$nav = $html-nestedList(
array(
$html-link('Main List Item 1', '#') = array(
$html-link('Secondary List Item 1', '/url/'),
array($html-link('Secondary List Item 2', '/url/') =
array($html-link('Tertiary List Item 1', '/
url'))),
$html-link('Secondary List Item 2', '/url/'),
$html-link('Secondary List Item 3', '/visits/'),
),
$html-link('Main List Item 2', '#'),
$html-link('Main List Item 3', '#'))
This gets me close, but the result is this:

Main List Item 1
Secondary List Item 1
1
Secondary List Item 2 (winds up in the tertiary list)
Tertiary List Item 1
Secondary List Item 2
Secondary List Item 3
Main List Item 2
Main List Item 3

How can I set this up using nestedList so that the list is formatted
without the 1 above and with the secondary list item 2 in the proper
place? Or am I approaching this from the wrong angle altogether?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Redirect Loop

2009-03-11 Thread Tony Thomas

I've been working on a local copy of my CakePHP app that runs on a my
computer. Today I've only been working on a layout and the style
sheet. I took a break and went back to it which prompted a new login.
Suddenly I'm getting a redirect loop. Firefox gives me this following
message:

Redirect Loop

Firefox has detected that the server is redirecting the request for
this address in a way that will never complete.

The browser has stopped trying to retrieve the requested item. The
site is redirecting the request in a way that will never complete.

* Have you disabled or blocked cookies required by this site?
* NOTE: If accepting the site's cookies does not resolve the
problem, it is likely a server configuration issue and not your
computer.

Any thoughts on what might cause that if I wasn't working in the a
controller? More importantly, how do I fix it?
--~--~-~--~~~---~--~~
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: Undefined variable: javascript when Javascript is absolutely loaded

2009-02-27 Thread Tony Thomas

This problem just cropped up out of the blue for me. I made no changes
to the AppController where the helpers are defined. I can't figure it
out. The JavaScript file in question is clearly in the HTML, but
everything is broken.

I had made a simple change to a different controller that seemed to
precipitate the error, but commenting out the function in question has
no effect. Does anyone have any idea why this would seem to happen
spontaneously?

On Feb 4, 11:29 am, Stonk eric.rei...@gmail.com wrote:
 Maybe it will help someone in the future.

 Undefinedvariable:javascript[APP\views\layouts\default.ctp, line 8]
  Fatal error: Call to a member function link() on a non-object in 
  xy\default.ctp on line Y

 If one helper can't be loaded (typo), no helper will be loaded. So if
 it says javascriptisundefined, it can be a typo anywhere in the
 $helpers var.
--~--~-~--~~~---~--~~
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: Undefined variable: javascript when Javascript is absolutely loaded

2009-02-27 Thread Tony Thomas

I forgot to add that if I remove 'echo $javascript-link('js.js');'
nothing is rendered at all. Even if I hand code the link to the
JavaScript. It's truly bizarre and has broken my entire application.
On Friday afternoon no less. :-(

On Feb 27, 1:42 pm, Tony Thomas truet...@gmail.com wrote:
 This problem just cropped up out of the blue for me. I made no changes
 to the AppController where the helpers are defined. I can't figure it
 out. TheJavaScriptfile in question is clearly in the HTML, but
 everything is broken.

 I had made a simple change to a different controller that seemed to
 precipitate the error, but commenting out the function in question has
 no effect. Does anyone have any idea why this would seem to happen
 spontaneously?

 On Feb 4, 11:29 am, Stonk eric.rei...@gmail.com wrote:

  Maybe it will help someone in the future.

  Undefinedvariable:javascript[APP\views\layouts\default.ctp, line 8]
   Fatal error: Call to a member function link() on a non-object in 
   xy\default.ctp on line Y

  If one helper can't be loaded (typo), no helper will be loaded. So if
  it says javascriptisundefined, it can be a typo anywhere in the
  $helpers var.
--~--~-~--~~~---~--~~
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: Undefined variable: javascript when Javascript is absolutely loaded

2009-02-27 Thread Tony Thomas

This must be something unrelated to CakePHP. My local version
functions perfectly and now the production server doesn't give me the
non-object fatal error, but doesn't include my JavaScript either.
(BUT, at least the information is displayed, which is a start.)
There's something bizarre happening with the server.

On Feb 27, 1:51 pm, brian bally.z...@gmail.com wrote:
 On Fri, Feb 27, 2009 at 2:42 PM, Tony Thomas truet...@gmail.com wrote:

  This problem just cropped up out of the blue for me. I made no changes
  to the AppController where the helpers are defined. I can't figure it
  out. TheJavaScriptfile in question is clearly in the HTML, but
  everything is broken.

 What's broken? You're seeing the non-object fatal error?

 But, if thejavascriptlink is present (and the path is correct) are
 you just having JS issues?

  I had made a simple change to a different controller that seemed to
  precipitate the error, but commenting out the function in question has
  no effect. Does anyone have any idea why this would seem to happen
  spontaneously?

 Have you emptied your cache?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Odd Behavior with allow()

2009-02-13 Thread Tony Thomas

I moved my CakePHP app to a new server and everything is working fine
except the one area where I have to allow public access.

The controller I want to allow is 'report', so in the pertinent
controller, I have this:

function beforeFilter() {
$this-Auth-allow('report');
}
}

This worked fine on the previous server. However, on the new server,
when I try to access the URL in question, I'm sent to the login page.

Let's say my url is 'example.com/controller_name/report'

I'm immediately redirected to 'example.com/users/login'

But, if I go to 'example.com/Controller_Name/report', it works fine.
The only problem is that since the form on the page is built using
$form-create('ControllerName', array('action' = 'report')), the form
action winds up reverting to the CakePHP convention of
'controller_name/action' rather than 'Controller_Name/action' and I'm
once again kicked out.

I'm sure there's probably something simple I'm missing that will
correct this, but I don't know where to start. Has anyone run into
this behavior before?
--~--~-~--~~~---~--~~
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 Behavior with allow()

2009-02-13 Thread Tony Thomas

It was a routing issue. I managed to piece it together when the 'edit'
function of the same controller was acting bizarrely. Once I fixed the
routing, everything worked as expected.

On Feb 13, 1:13 pm, brian bally.z...@gmail.com wrote:
 This seems like a routing issue. What's the route you're using for this?

 And, are you certain that the both servers have an identical routes.php?

 On Fri, Feb 13, 2009 at 1:07 PM, Tony Thomas truet...@gmail.com wrote:

  I moved my CakePHP app to a new server and everything is working fine
  except the one area where I have to allow public access.

  The controller I want to allow is 'report', so in the pertinent
  controller, I have this:

  function beforeFilter() {
                 $this-Auth-allow('report');
         }
  }

  This worked fine on the previous server. However, on the new server,
  when I try to access the URL in question, I'm sent to the login page.

  Let's say my url is 'example.com/controller_name/report'

  I'm immediately redirected to 'example.com/users/login'

  But, if I go to 'example.com/Controller_Name/report', it works fine.
  The only problem is that since the form on the page is built using
  $form-create('ControllerName', array('action' = 'report')), the form
  action winds up reverting to the CakePHP convention of
  'controller_name/action' rather than 'Controller_Name/action' and I'm
  once again kicked out.

  I'm sure there's probably something simple I'm missing that will
  correct this, but I don't know where to start. Has anyone run into
  this behavior before?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Migrating to Media Temple DV Server - Path problem

2009-01-22 Thread Tony Thomas

I'm moving my CakePHP app onto to a Media Temple Dedicated Virtual
server and my paths are all wrong.

There seem to be two issues, one more severe than the other:

First, the paths to webroot don't work, so the head of my document
links my stylesheet like so:

link rel=stylesheet type=text/css href=/index.php/users/css/
style.css media=screen, projection /

Notice that first, index.php is inserted into the beginning of the
link and second that the path is completely wrong. When I access the
base url, I get the Apache 404 error. If I insert index.php in the the
url, it works fine so that https://example.com/index.php/users/login
works (but with incorrect links to style sheets and layout as noted
above), but https://example.com/users/login produces an Apache 404
error.

It seems the problem is a mod_rewrite one perhaps. The default
CakePHP .htaccess files are on the server. Any thoughts? There seem to
be a lot of forum posts that are somehow related, but don't quite fit
my scenario.

--~--~-~--~~~---~--~~
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: Migrating to Media Temple DV Server - Path problem

2009-01-22 Thread Tony Thomas

Aha! After further investigation, the .htaccess from cake's root was
missing. Once I created that, all was fixed.

On Jan 22, 10:20 am, Tony Thomas truet...@gmail.com wrote:
 I'm moving my CakePHP app onto to a Media Temple Dedicated Virtual
 server and my paths are all wrong.

 There seem to be two issues, one more severe than the other:

 First, the paths to webroot don't work, so the head of my document
 links my stylesheet like so:

 link rel=stylesheet type=text/css href=/index.php/users/css/
 style.css media=screen, projection /

 Notice that first, index.php is inserted into the beginning of the
 link and second that the path is completely wrong. When I access the
 base url, I get the Apache 404 error. If I insert index.php in the the
 url, it works fine so thathttps://example.com/index.php/users/login
 works (but with incorrect links to style sheets and layout as noted
 above), buthttps://example.com/users/loginproduces an Apache 404
 error.

 It seems the problem is a mod_rewrite one perhaps. The default
 CakePHP .htaccess files are on the server. Any thoughts? There seem to
 be a lot of forum posts that are somehow related, but don't quite fit
 my scenario.
--~--~-~--~~~---~--~~
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: Label information for Multiple Checkboxes

2009-01-20 Thread Tony Thomas

On Jan 16, 12:22 am, brian bally.z...@gmail.com wrote:
 I think you could probably easily build the structure you want using
 Set in afterFind() (if not in the find itself). Can you post an
 example  of the sort of array you would need if you were, say,
 displaying each option in an html table? Like if you did a straight
 find('all', $your_conditions).

Just to keep it simple, I've only got two fields in my 'find' until I
work out the logic. Once I have that worked out, I should be able to
open it up to however many fields I want.

$aliquots = $this-Aliquot-find(
'all',
array('fields' = array(
'Aliquot.id',
'Specimen.type'),
'conditions' = 
'Aliquot.box_id IS NULL', 'limit' = '0, 100',
'recursive' = 2
)
);
$this-set('aliquots', $aliquots);

Then in the view:

echo $form-input('Aliquot', array( 'label' = false,
'type' 
= 'select',

'multiple' = 'checkbox',

'options' = $aliquots));

The problem is that 'options' above doesn't seem to display a nested
array correctly. It's fine if I only define a single field in my find,
but since it uses the array for the labels as well as the value for
each checkbox, I can't define more information there to be displayed
only in the label. At least I haven't figured out how.

I could loop through and define each checkbox separately, but making a
multiple selection is difficult in that scenario unless I abandon the
form helpers altogether and just hand code the form.

 On Thu, Jan 15, 2009 at 5:02 PM, Tony Thomas truet...@gmail.com wrote:

  I follow you up to this bit:

  ?php

  echo $form-input(
        'Category',
        array(
              'type'='select',
              'multiple'='checkbox',
              'options'=$ids,
              'label'=false
              )
        );
  ?

  This doesn't seem to solve the problem of getting the other
  information into my label. In fact, it's the exact method I'm using
  now. I understand using $this-find('all', $options) and extract() to
  separate the ids from the rest of the information, but how do I get
  the other information displayed in my form? This method still leaves
  me with checkboxes and ids, but no other info.
--~--~-~--~~~---~--~~
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: Label information for Multiple Checkboxes

2009-01-20 Thread Tony Thomas

That worked! Thanks!

On Jan 20, 8:54 am, grigri j...@hendersonwebdesign.com wrote:
 // controller
 $aliquots = $this-Aliquot-find('all', array(
   'conditions' = whatever,
   'fields' = array(
     'Aliquot.id',
     'Aliquot.additive',
     'Specimen.type',
     'Specimen.draw_date'
   ),
   'recursive' = 0
 ));
 $this-set('aliquots', Set::combine($aliquots,
   '{n}.Aliquot.id',
   array(
     '{0} [{1} / {2}]', // Format
     '{n}.Aliquot.additive', // Field #0
     '{n}.Specimen.type', // Field #1
     '{n}.Specimen.draw_date' // Field #2
   )
 ));
 // view
 echo $form-input('Aliquot', array('options' = 'aliquots', 'multiple'
 = 'checkbox'));

 Alternatively, if you want the checkboxes grouped - say by specimen
 type, then use this:

 $this-set('aliquots', Set::combine($aliquots,
   '{n}.Aliquot.id',
   array(
     '{0} [{1} / {2}]', // Format
     '{n}.Aliquot.additive', // Field #0
     '{n}.Specimen.type', // Field #1
     '{n}.Specimen.draw_date' // Field #2
   ),
   '{n}.Specimen.type'
 ));
 // view
 echo $form-input('Aliquot', array('options' = 'aliquots', 'multiple'
 = 'checkbox'));

 hth
 grigri

 On Jan 20, 2:32 pm, Tony Thomas truet...@gmail.com wrote:

  On Jan 16, 12:22 am, brian bally.z...@gmail.com wrote:

   I think you could probably easily build the structure you want using
   Set in afterFind() (if not in the find itself). Can you post an
   example  of the sort of array you would need if you were, say,
   displaying each option in an html table? Like if you did a straight
   find('all', $your_conditions).

  Just to keep it simple, I've only got two fields in my 'find' until I
  work out the logic. Once I have that worked out, I should be able to
  open it up to however many fields I want.

  $aliquots = $this-Aliquot-find(
                                                  'all',
                                                  array('fields' = array(
                                                          'Aliquot.id',
                                                          'Specimen.type'),
                                                          'conditions' = 
  'Aliquot.box_id IS NULL', 'limit' = '0, 100',
  'recursive' = 2
                                                          )
                                                  );
  $this-set('aliquots', $aliquots);

  Then in the view:

  echo $form-input('Aliquot', array( 'label' = false,
                                                                          
  'type' = 'select',
                                                                          
  'multiple' = 'checkbox',
                                                                          
  'options' = $aliquots));

  The problem is that 'options' above doesn't seem to display a nested
  array correctly. It's fine if I only define a single field in my find,
  but since it uses the array for the labels as well as the value for
  each checkbox, I can't define more information there to be displayed
  only in the label. At least I haven't figured out how.

  I could loop through and define each checkbox separately, but making a
  multiple selection is difficult in that scenario unless I abandon the
  form helpers altogether and just hand code the form.

   On Thu, Jan 15, 2009 at 5:02 PM, Tony Thomas truet...@gmail.com wrote:

I follow you up to this bit:

?php

echo $form-input(
      'Category',
      array(
            'type'='select',
            'multiple'='checkbox',
            'options'=$ids,
            'label'=false
            )
      );
?

This doesn't seem to solve the problem of getting the other
information into my label. In fact, it's the exact method I'm using
now. I understand using $this-find('all', $options) and extract() to
separate the ids from the rest of the information, but how do I get
the other information displayed in my form? This method still leaves
me with checkboxes and ids, but no other info.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Label information for Multiple Checkboxes

2009-01-15 Thread Tony Thomas

I'm building a list of checkboxes like so:

echo $form-input('Aliquot.id', array( 'label' = FALSE,

'type' = 'select',

'multiple' = 'checkbox',

'options' = $aliquots));
echo $form-input('box_id', array('options' = $boxes));

$aliquots above is built from $this-Aliquot-find('list', $options);
which finds all the ids of the pertinent records. The problem I have
this this only generates a list of ids. Is there good way to load an
array for 'label' so that I can display more than just the list of ids?
--~--~-~--~~~---~--~~
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: Label information for Multiple Checkboxes

2009-01-15 Thread Tony Thomas

The complicating factor here is that Aliquot belongs to Specimen in my
model and I want to display some information from both tables:
Specimen.type, Specimen.draw_date, Aliquot.additive  etc. It looks
more and more like I'm going to have to put that information in an
array and loop through it, building each checkbox one at a time
instead of my example below. Or am I missing something?

On Jan 15, 11:01 am, grigri j...@hendersonwebdesign.com wrote:
 You need to set the $displayField property inside your `Aliquot` model
 to whatever field you want for the label.

 On Jan 15, 4:47 pm, Tony Thomas truet...@gmail.com wrote:

  I'm building a list of checkboxes like so:

  echo $form-input('Aliquot.id', array( 'label' = FALSE,
                                                                              
      'type' = 'select',
                                                                              
      'multiple' = 'checkbox',
                                                                              
      'options' = $aliquots));
  echo $form-input('box_id', array('options' = $boxes));

  $aliquots above is built from $this-Aliquot-find('list', $options);
  which finds all the ids of the pertinent records. The problem I have
  this this only generates a list of ids. Is there good way to load an
  array for 'label' so that I can display more than just the list of ids?
--~--~-~--~~~---~--~~
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: Label information for Multiple Checkboxes

2009-01-15 Thread Tony Thomas

On Jan 15, 1:03 pm, David Coleman david.cole...@connaxis.com
wrote:
 Do you need checkboxes from multiple tables?  

No. The checkboxes in this case only pertain to my aliquots table so
that users can assign them to a box, which is in turn assigned to a
freezer. But in order to identify where the aliquots go, there are a
few fields from my specimens table (blood comes in as a specimen and
is then divided into aliquots) that I'd like to display in the label.

If so you need to use the
 trick I posted earlier today to make the hidden elements not be duplicated.
 Overload your form.php in your app/views/helpers folder.

 What you are doing is similar to a recent application that I wrote, in which
 I developed this extention to the form-input method to accomplish just this
 effect.

 See the message re: Ticket #5577 (new Enhancement)  If this is what you
 need.

 -Original Message-
 From: cake-php@googlegroups.com [mailto:cake-...@googlegroups.com] On Behalf

 Of Tony Thomas
 Sent: Thursday, January 15, 2009 4:52 PM
 To: CakePHP
 Subject: Re: Label information for Multiple Checkboxes

 The complicating factor here is that Aliquot belongs to Specimen in my
 model and I want to display some information from both tables:
 Specimen.type, Specimen.draw_date, Aliquot.additive  etc. It looks
 more and more like I'm going to have to put that information in an
 array and loop through it, building each checkbox one at a time
 instead of my example below. Or am I missing something?

 On Jan 15, 11:01 am, grigri j...@hendersonwebdesign.com wrote:
  You need to set the $displayField property inside your `Aliquot` model
  to whatever field you want for the label.

  On Jan 15, 4:47 pm, Tony Thomas truet...@gmail.com wrote:

   I'm building a list of checkboxes like so:

   echo $form-input('Aliquot.id', array( 'label' = FALSE,
                                                                          
         'type' = 'select',
                                                                          
         'multiple' = 'checkbox',
                                                                          
         'options' = $aliquots));
   echo $form-input('box_id', array('options' = $boxes));

   $aliquots above is built from $this-Aliquot-find('list', $options);
   which finds all the ids of the pertinent records. The problem I have
   this this only generates a list of ids. Is there good way to load an
   array for 'label' so that I can display more than just the list of ids?
--~--~-~--~~~---~--~~
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: Label information for Multiple Checkboxes

2009-01-15 Thread Tony Thomas

I tried that very thing, but it didn't produce the expected results.
Maybe find('list', $options) isn't meant to accommodate more than a
single field. I'm not sure.

On Jan 15, 11:34 am, David Coleman david.cole...@connaxis.com
wrote:
 You could also do something like this in your controller:

             $aliquots = $this-Aliquot-find(

                   'list',

                   array(

                         'fields'=array(

                               'Aliquot.id',

                               'Aliquot.name'

                               ),

                         'conditions'=array(

                               // some conditions if necessary.

                               )

                         )

                   );

 And then pass this to your view with

 $this-set(‘aliquotes’, $aliquots);

--~--~-~--~~~---~--~~
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: Label information for Multiple Checkboxes

2009-01-15 Thread Tony Thomas

I follow you up to this bit:

 ?php

 echo $form-input(
   'Category',
   array(
 'type'='select',
 'multiple'='checkbox',
 'options'=$ids,
 'label'=false
 )
   );
 ?

This doesn't seem to solve the problem of getting the other
information into my label. In fact, it's the exact method I'm using
now. I understand using $this-find('all', $options) and extract() to
separate the ids from the rest of the information, but how do I get
the other information displayed in my form? This method still leaves
me with checkboxes and ids, but no other info.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Where Does This Fall in the MVC Architecture?

2008-12-09 Thread Tony Thomas

I'm working on an application to store information on lab specimens.
The lab receive specimens which are divided into aliquots which are
then put into boxes and in turn stored in freezers.

I want to create a function to find all unstored aliquots and display
a message on every page to alert the lab users that there are aliquots
that haven't been assigned to boxes yet. It's a simple query:

SELECT COUNT(aliquot.id)
FROM aliquots
WHERE aliquots.box_id IS NULL

The problem is that I can't quite decide where it belongs in the MVC
architecture. It seems like a helper since the alert message would
appear in the left column of every page. But it runs a query, so does
it belong in a model? The problem is that I want to retrieve the
information no matter which model is currently in use.

What's the best way to preserve the MCV structure and DRY philosophy
while including a function like this in my application?
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: using Google Visualization

2008-12-09 Thread Tony Thomas

http://www.google.com/jsapi; doesn't appear to be a valid URL for the
library you're trying to use.

On Dec 9, 7:30 am, Juan [EMAIL PROTECTED] wrote:
 I'm trying to use the Google Visualization API with my CakePHP app.
 The two first obstacles are:

 - how to link an external JS library?

 I try this in my view:
 $javascript-link('http://www.google.com/jsapi', false);

 but it's not working. I see in the CakePHP source code that it doesn't
 seem possible to do 
 this:http://api.cakephp.org/javascript_8php-source.html#l00258

 I solve this by just adding the script src ... by hand without using
 the javascript helper, but I liked the helper because then I can
 include this script in the layout $scripts_for_layout.

 - Why it doesn't work when the view is rendered using AJAX?

 I'm running the chart sample 
 at:http://code.google.com/apis/visualization/documentation/using_overvie...
 in my view, it works fine, but if I render the view in a div using
 AJAX then the script stops executing after google.load (...)

 any ideas would be  appreciated. 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Where Does This Fall in the MVC Architecture?

2008-12-09 Thread Tony Thomas

Fantastic. That worked!

On Dec 9, 9:30 am, Jon Bennett [EMAIL PROTECTED] wrote:
  I would:

   * create a method in your model to fetch the data
   * create a method in your controller to access this data
   * create an element that calls via 'requestAction' the data from the 
  controller
   * insert this element into your layout and add array('cache'='1 hour');

 take a look 
 athttp://bakery.cakephp.org/articles/view/creating-reusable-elements-wi...
 for ideas.

 jon

 --

 jon bennett
 w:http://www.jben.net/
 iChat (AIM): jbendotnet Skype: jon-bennett
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



updateAll Syntax question

2008-12-05 Thread Tony Thomas

I have a scenario where I want to update multiple records
simultaneously. In this case, I have a form with check boxes next to
ids from the table I want to update. These are aliquots stored in a
lab.

updateAll seems like a natural solution, except I can't quite get my
head around defining the proper conditions. In my case the controller
receives an array of aliquot ids and one box id where they will all be
store.

$this-data['Aliquot']['id'][] // an array of selected ids sent from
my form
$this-data['Aliquot']['box_id'] // the id of the box we're going to
store the aliquots in

How would you define the conditions in updateAll() so that all of the
sent aliquot ids get the same box id?

$this-Aliquot-updateAll(array('Aliquot.box_id' = $this-data
['Aliquot']['box_id']));

Will the above syntax automagically update all of the aliquot records
with the same box id if I don't define conditions?
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Manual Search Not Working?

2008-10-01 Thread Tony Thomas

Has something changed with the CakePHP Cookbook's search
(book.cakephp.org)? Over the last few days every search turns up no
results. I just tried a search for model and it returned no results.
Anyone who works on that know anything?
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Auth Redirect Problems

2008-09-30 Thread Tony Thomas

I don't know why. Are you you using 1.2 or 1.1? I'm using 1.2.

This:

$this-Auth-autoRedirect = FALSE;

Gives me:

unexpected T_VARIABLE

I haven't had a chance to investigate.

On Sep 30, 2:06 am, Okto Silaban [EMAIL PROTECTED] wrote:
 How come? I get no problem with the syntax.. It works fine for me..

 This is the full code in app/app_controller.php (I just copy paste it)

 beforeFilter()
 {
         $this-Auth-loginAction = array('controller' = 'users', 'action'
 = 'login');
         $this-Auth-logoutRedirect = '/';
         $this-Auth-loginRedirect = array('controller' = 'users', 'action'
 = 'login');
         $this-Auth-autoRedirect = FALSE;

 }

 Okto.Silaban.Net

 On Fri, Sep 26, 2008 at 10:00 PM, Tony Thomas [EMAIL PROTECTED] wrote:

  This gives me an unexpected T_VARIABLE error on the line with $this-
  Auth-autoRedirect = FALSE;

  I think the algorithm might be right, but the syntax is wrong.

  On Sep 17, 12:20 pm, Okto Silaban [EMAIL PROTECTED] wrote:
   I'm not really sure, but I think :
   $this-Auth-loginRedirect

   doesn't tell we're we gonna go after logging in..

   But, if we're acessing an area which not allowed by Auth, we will sent to
   that page.. (if you're not login yet..).

   So I set that in beforeFilter :

   function beforeFilter() {
     $this-Auth-loginRedirect = array('controller' = 'controller_name',
   'action' = 'index');
      $this-Auth-autoRedirect = FALSE; // so after logging in we're not
  auto
   redirected

   }

   then manually set

   function login() {
       $this-redirect('somewhere');
       exit();

   }
   On Tue, Sep 9, 2008 at 10:12 PM, Tony Thomas [EMAIL PROTECTED] wrote:

If someone is familiar with a post to this group or blog entry that
addresses this issue, please let me know. I've spent the morning
scouring both with no satisfactory results.

I have a cakePHP app on a shared server. In local testing, everything
worked fine. But mod_rewrite did not function properly on the shared
server, so I'm using CakePHP pretty URLS instead. Also caching (at
least temporarily) is off. I've uncommented the pertinent lines of
code in core.php and I've dutifully deleted the .htaccess files.

The problem I have is that after logging in, the redirect is
inconsistent. About 2/3 of the time I get redirected to
   https://[base_url]/https:/[domain]. I just can't seem to find away
around this problem.

My login function looks like this:

function login() {
                       $this-Auth-loginRedirect = array('controller'
  =
'controller_name', 'action' = 'index');
   }

I still get inconsistent results with the redirect going to a URL like
the former example the majority of the time. Any insight, links, etc.
would be appreciated.
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Auth Redirect Problems

2008-09-26 Thread Tony Thomas

This gives me an unexpected T_VARIABLE error on the line with $this-
Auth-autoRedirect = FALSE;

I think the algorithm might be right, but the syntax is wrong.

On Sep 17, 12:20 pm, Okto Silaban [EMAIL PROTECTED] wrote:
 I'm not really sure, but I think :
 $this-Auth-loginRedirect

 doesn't tell we're we gonna go after logging in..

 But, if we're acessing an area which not allowed by Auth, we will sent to
 that page.. (if you're not login yet..).

 So I set that in beforeFilter :

 function beforeFilter() {
   $this-Auth-loginRedirect = array('controller' = 'controller_name',
 'action' = 'index');
    $this-Auth-autoRedirect = FALSE; // so after logging in we're not auto
 redirected

 }

 then manually set

 function login() {
     $this-redirect('somewhere');
     exit();

 }
 On Tue, Sep 9, 2008 at 10:12 PM, Tony Thomas [EMAIL PROTECTED] wrote:

  If someone is familiar with a post to this group or blog entry that
  addresses this issue, please let me know. I've spent the morning
  scouring both with no satisfactory results.

  I have a cakePHP app on a shared server. In local testing, everything
  worked fine. But mod_rewrite did not function properly on the shared
  server, so I'm using CakePHP pretty URLS instead. Also caching (at
  least temporarily) is off. I've uncommented the pertinent lines of
  code in core.php and I've dutifully deleted the .htaccess files.

  The problem I have is that after logging in, the redirect is
  inconsistent. About 2/3 of the time I get redirected to
 https://[base_url]/https:/[domain]. I just can't seem to find away
  around this problem.

  My login function looks like this:

  function login() {
                         $this-Auth-loginRedirect = array('controller' =
  'controller_name', 'action' = 'index');
     }

  I still get inconsistent results with the redirect going to a URL like
  the former example the majority of the time. Any insight, links, etc.
  would be appreciated.


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Best way to validate dates to prevent future dating

2008-09-25 Thread Tony Thomas

The problem I had was that each new record that was being added, would
then go to a step to add several related records in a different table.
So even though I could check the datestamps against each other, the
flash messages were getting lost because the application immediately
redirects and starts using another model. In my case these are lab
specimens that are divided into aliquots.

The user begins by creating a new record for a specimen. There are
three date fields. The draw date, the receive date and the storage
date. The record is added and the user is prompted for how many
aliquots will be created from the specimen. They enter a number and a
corresponding number of aliquot records are created. In leaving the
specimen model and going to the aliquot model, I was losing flash
messages before anyone saw the specimen record again.

I decided (for now) to check the dates in the view, so I created a
simple helper to format any dates that are before the 'created' date
in red text. (I should add that all of my dates are being stored as
Unix timestamps.) I created this helper:

?php
/* /app/views/helpers/date.php */

class DateHelper extends AppHelper {

function future($datestamp, $created, $format) {

if ($datestamp  0) {

if ($datestamp  $created) {

$thedate = 'span class=redtext' . date($format,
$datestamp) . ' This record was created on ' . date('m/d/Y',
$created) . ' at ' . date('G:i', $created) . '. Specimens cannot be
future dated. /span';

} else {

$thedate = date($format, $datestamp);

}

return $this-output($thedate);

} else {

$thedate = '';
return $this-output($thedate);

}

}
}

?

Since my helper is called 'DateHelper', add 'Date' to the helper var
in the AppController.

Then I can just send any date as:

$date-future($date, $created, $format)

and the date is sent back formatted like $format (the same as the php
date() function). If the date in question is later than the date the
record was created, it's formatted with the class 'redtext' so it
stands out.

There's probably a better way to do all of this utilizing AJAX, but
I'm not there yet.

For now, my helper is handy and I can reuse it in the other views that
use dates.

One big reason I did it this was as that I wanted the record to be
saved, but send also send a message to the user that something is
wrong with the date. I'll refine this as I develop the application
further, but for now this works.

On Sep 16, 12:36 pm, LunarDraco [EMAIL PROTECTED] wrote:
 Here is a sample that I use, Its not exactly what your looking for,
 but a little tweaking will get you where you need to be:

 var $validate = array(
    'expires' =
 array('rule'=array('date','mdy'),'rule'=array('validateFutureDate'),'on'='create')
 );

         function validateFutureDate($value) {
         $valid = false;

         $timestamp = strtotime(str_replace('-','/',
 $value['expires']));
                 $t = time()+(86400*34);
                 if($timestamp = $t)
                         $valid = true;

         return $valid;
     }

 On Sep 16, 3:08 am, RichardAtHome [EMAIL PROTECTED] wrote:

   I was afraid that might be the case

  It's really not difficult :-)

  And its a very powerful solution once you understand how it works.

  On Sep 16, 1:46 am, Tony Thomas [EMAIL PROTECTED] wrote:

   Thanks. I was afraid that might be the case.

   On Sep 15, 7:42 pm, Dardo Sordi Bogado [EMAIL PROTECTED] wrote:

You can't use functions i.e date() at class definitions, create a
custom method in the model and use that as a validation rule.

On Mon, Sep 15, 2008 at 9:34 PM, Tony Thomas [EMAIL PROTECTED] wrote:

 According to the documentation that's the proper way to define the
 array.

http://book.cakephp.org/view/139/comparison

 It just amounts to defining an array without defining the keys if I'm
 not mistaken. I'll take a closer look at the syntax in the morning
 when my mind is a little fresher. I'll post something here if
 something jumps out at me.

 On Sep 15, 4:20 pm, 703designs [EMAIL PROTECTED] wrote:
 I noticed that the way you coded your array would definitely throw a
 syntax error.

 How about
 'rule' = array(
     'comparison' = date()
 ),

 I'll try this on my Cake installation later to check, as I haven't
 used the 'comparison' validator. I just know that your array looks
 botched.

 On Sep 15, 5:14 pm, 703designs [EMAIL PROTECTED] wrote:

  date() should just return the formatted date string. What sort of
  errors are you seeing?

  On Sep 15, 3:51 pm, Tony Thomas [EMAIL PROTECTED] wrote:

   Anyone have a proven method for validating submitted dates to 
   make
   sure they're not in the future?

   The closest I can get is:

   'date_field' = array('rule' = array

Re: Auth login redirect unreliable?

2008-09-09 Thread Tony Thomas

Plus, the problem I ran into with this solution is that the logout
function goes into an infinite loop.

I will note that I didn't have problems with redirect until I started
using database sessions  stopped using mod_rewrite because of
restrictions on the shared server I'm using.

On Jul 15, 8:50 am, jhicks [EMAIL PROTECTED] wrote:
 That will only work as long as the browser supports HTTP_REFERER.

 On Jul 6, 2:52 pm, Chez17 [EMAIL PROTECTED] wrote:

  Using Eric's post, I created a very simple way to get the Auth
  component toredirectto the referring page no matter what. I think
  its userful:

  ?php
  class UsersController extends AppController
  {
      var $name = Users;

      var $components = array(Auth);

      function beforeFilter()
      {
          $this-Auth-autoRedirect = false;
      }

      function login()
      {
          $this-redirect($_SERVER['HTTP_REFERER']);
      }

  }

  On Jul 2, 1:56 pm, Rich [EMAIL PROTECTED] wrote:

   that worked perfectly for me. thanks Eric!

   On Jul 2, 12:32 pm, Eric [EMAIL PROTECTED] wrote:

I had a similar problem and here is what I did.

1. Change your setupAuth function like this
function setupAuth(  )
{
...
$this-Auth-loginRedirect = '/users/loginRedirect';
$this-Auth-autoRedirect = false; // -- handle redirecting yourself

}

2. create a loginRedirect action which determines where to go after a
login has succeeded

function loginRedirect()
{
 $this-log('users/LoginRedirect()', LOG_DEBUG);
 if (parent::getAuthGroup() ===  ADMIN)
 {
  $this-log('--redirecting to admin', LOG_DEBUG);
  $this-redirect('/admin/myCtrl/index');
 }
 else
 {
  $this-log('--redirecting to normal', LOG_DEBUG);
  $this-redirect('/myCtrl/index');

}

3. Your login action is pretty simple then

function login()
{
 if ($this-Auth-login())
 {
   $this-loginRedirect();
 }
 else
 {
  if (!empty($this-data))
    $this-Session-setFlash($this-Auth-loginError);
 }

}

I think you can get the page that the user was trying to access via
the session, andredirectthere, but taking them to the front page
works for me
.
Hopefully this helps.

-Eric

On Jul 2, 10:44 am, leo [EMAIL PROTECTED] wrote:

 On 2 Jul, 17:27, dr. Hannibal Lecter [EMAIL PROTECTED] wrote:

  I see what you mean, but I'm not sure that you can put 'action' = 
  '/'
  or 'controller' = '/'.

 Sorry, I missed that. Nope, I wouldn't want to be doing that even if
 it was valid.

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Auth Redirect Problems

2008-09-09 Thread Tony Thomas

If someone is familiar with a post to this group or blog entry that
addresses this issue, please let me know. I've spent the morning
scouring both with no satisfactory results.

I have a cakePHP app on a shared server. In local testing, everything
worked fine. But mod_rewrite did not function properly on the shared
server, so I'm using CakePHP pretty URLS instead. Also caching (at
least temporarily) is off. I've uncommented the pertinent lines of
code in core.php and I've dutifully deleted the .htaccess files.

The problem I have is that after logging in, the redirect is
inconsistent. About 2/3 of the time I get redirected to
https://[base_url]/https:/[domain]. I just can't seem to find away
around this problem.

My login function looks like this:

function login() {
$this-Auth-loginRedirect = array('controller' =
'controller_name', 'action' = 'index');
}

I still get inconsistent results with the redirect going to a URL like
the former example the majority of the time. Any insight, links, etc.
would be appreciated.

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Retrieving User Information with Auth/Acl

2008-07-03 Thread Tony Thomas

On Jul 3, 6:23 pm, francky06l [EMAIL PROTECTED] wrote:
 I do not understand the on the fly there ..

Meaning I don't want to have to statically define who can do what.
Instead of something like:

if ($this-Auth-user('username') == 'User1') {

// allow them to do stuff

} else {

// kick them out

}

I want to get user information after they've gone through the login
process in Auth, look at the Acl and determine whether or not they
have permission to do what they want to do. In other words, I don't
want static rules in the controller. I want to load up some variables
from the session and check it against Acl.

You are wanted to check
 a permission on an action regarding a user, but is this User logged-
 in ? I mean a member of a User model or something similar ??

In this case I'm certain the user (me) is logged in. Auth is working
as expected. I just can't get my head around checking Acl.

For now I've abandoned the built in Acl in lieu of a simple system
using roles in the user table. The Acl component is more flexible,
so I'd still like to use it if anyone has advice.

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Firefox 3 Cookies Auth

2008-06-30 Thread Tony Thomas

I spent a long time on this so I thought I'd share it with the
community. I was wracking my brain trying to get Auth to work properly
on a site I'm testing locally in Firefox 3. No matter what I did, the
application locked me out with a message stating You are not
authorized I read several blog posts about Auth and the entry in
the manual over and over.

Then on a whim I tested the same site in Safari and got totally
different results. Today I looked at my Firefox cookies and noticed
that there were two CakePHP cookies. One current (presumably from just
having logged in) and one expired. I deleted the expired cookie and
the application worked.

Here are the specifics:

Cake 1.2.0.7125 RC1
Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10.4; en-US; rv:1.9) Gecko/
2008061004 Firefox/3.0

I'm not sure if this is a fluke, a Firefox bug or a CakePHP bug. I
just thought I'd share what I found in case anyone else is
troubleshooting Auth and is having trouble.

The upside to this story is that I learned an awful lot about CakePHP
Auth in the process.

Here a list of articles I found helpful:

http://www.webdevelopment2.com/cakephp-auth-component-tutorial-1/
http://www.littlehart.net/atthekeyboard/2007/09/11/a-hopefully-useful-tutorial-for-using-cakephps-auth-component/
http://bakery.cakephp.org/articles/view/simple-form-authentication-in-1-2-x-x
http://lemoncake.wordpress.com/2007/07/19/using-authcomponent-and-acl-in-cakephp-12/
http://realm3.com/articles/setting_up_users_groups_withacl_and_auth_in_cake_1.2.php

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Defining more than one hasMany relationship

2008-05-19 Thread Tony Thomas

I tried resetting the array as you describe but the problem persisted.
The only thing that worked was to stop using foreach. I don't get it,
but I stopped trying once I found a solution.

On May 16, 10:58 pm, David Christopher Zentgraf [EMAIL PROTECTED]
wrote:
 foreach() does neither modify nor unset the original array unless
 explicitly told to.
 Maybe you're having issues with the array pointer?

 http://jp2.php.net/foreach

  foreach has some side effects on the array pointer. Don't rely on
  the array pointer during or after the foreach without resetting it.

 http://jp2.php.net/manual/en/function.reset.php

 $numbers = array(1, 2, 3, 4);

 foreach ($numbers as $number) {
 $number = null; // does nothing to $numbers

 }

 print_r(current($numbers)); // prints nothing

 reset($numbers);
 print_r(current($numbers)); // prints '1'

 print_r($numbers);  // prints 'array([0] = 1, [1] = 2 
 ...)'

 On 16 May 2008, at 22:26, Tony Thomas wrote:



  No. It's simply looping through and echoing the array, but once it
  does, the contents of the array are no longer available. As soon as I
  looped through using while(list($key, $value) = each($array) instead
  of a foreach loop, I was able to loop through it twice to create the
  second table. Please correct me if I'm wrong, but I presume it's
  because foreach() operates from a copy of the array, which is then
  unset after looping through the data. At least, that's what my results
  suggest. As soon as I switched methods as noted above, the data
  remained available to loop through again to create a second table from
  separate data in the array.

  On May 15, 4:20 pm, Dovdimus Prime [EMAIL PROTECTED] wrote:
  Are you saying that this foreach loop is modifying the contents of
  the
  array?

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Defining more than one hasMany relationship

2008-05-15 Thread Tony Thomas

Hi All,

I'm building a CakePHP app for tracking clinic patients, their visits,
their symptoms and questionnaire answers. The barrier I've encountered
is that each patient has many visits AND many symptoms. I want to view
the patient record and their aggregate visits and symptoms.

I've defined a hasMany relationship in the patient model as such:

var $hasMany = array(
'Visit' = array(
'order'= 'Visit.id DESC',
'limit'= '10'
),
'M5Symptom' = array(
'className' = 'M5Symptom',
'order' = 'M5Symptom.modified DESC',
'limit' = '25'
)
);

In the patient view I get the relevant patient data, and the
corresponding list of visits, but I get the message, Undefined
index:  M5Symptom for listing the symptoms. As far as I can tell the
model is correct, because the query for the patient view finds and
retrieves a list of 25 symptom records exactly as specified in the
model. From that I take that the model and controller must be working
as expected. Otherwise the query wouldn't be right and/or it wouldn't
retrieve the pertinent records. The query that results is EXACTLY what
I want.

That leads me to believe the problem must be in the view.

Here's the view function in the patient controller:

function view($id = null) {

$this-Patient-id = $id;
$this-set('patient', $this-Patient-read());

}

Everything works right up until I try to list the symptoms. Here's the
code for listing symptoms in the view:

echo $html-tableHeaders(array('Symptom','Start Date','End Date',
'Severity'));

foreach ($patient['M5Symptom'] as $symptom) {

echo $html-tableCells(

array($symptom['symptom'],
  $symptom['start_date'],
  $symptom['end_date'],
  $symptom['severity'],
)
);

}

I've looked at all of this over and over and I just can't find out why
'M5Symptom' is undefined. Just above this, 'Visit' lists recent visit
dates for me with the exact same logic in place.

Am I wrong in assuming I can define more than one hasMany? If so, why
is the correct query generated? I'm hoping another set of eyes will
find what I'm missing. Sleeping on it didn't help.

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Defining more than one hasMany relationship

2008-05-15 Thread Tony Thomas

print_r($patient['M5Symptom']) results in the expected list of
symptoms:

Array
(
[0] = Array
(
[id] = 19
[patient_id] = 5007
[symptom] = Stuffy Nose
[start_date] = 12/18/2006
[end_date] = 12/21/2006
[severity] =
[exported] =
[date_reported] =
[created] =
[modified] =
)

//etc. for the full list of 25 most recent symptoms

)


On May 15, 12:00 pm, Dovdimus Prime [EMAIL PROTECTED] wrote:
 Yep: 'undefined index' definitely means you're not referencing your
 part of the patients array properly. The problem may well be nothing
 to do with the associations in your model.

 Use print_r to look at the array you're passing into the view.

 David

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Defining more than one hasMany relationship

2008-05-15 Thread Tony Thomas

debug($patient) produces:

Array
(
[Patient] = Array
(
[id] = 5007
[med_hist_id] = 0
[gender] = M
[st_of_birth] = [redacted]
[st_of_res] = [redacted]
[res_length] = 11 yrs
[cntry_of_origin] = U.S.
[dob] = [redacted]
[siblings] = 2
[birth_order] = 1
[mono_before] = N
[ethnicity] = [redacted]
[race] = [redacted]
[contact_by] = email
[withdrawn] = N
[kdas] = NKDA
[mono_dx] = N
)

[Visit] = Array
(
[0] = Array
(
[id] = 2060
[quest_id] =
[patient_id] = 5007
[protocol] = Mono 5
[vdate] = 4/22/2008
[vtmstmp] = 1208840400
[week] =
[yr] = 2
[number] = 8
[notes] = [redacted]
[kit] = 0
[sev_p] = 0
[sev_scr] = 0
[sev_pain] =
[modified] = 4/22/2008 2:25:47 PM
[created] = 4/22/2008 2:11:39 PM
)
//truncated here, but shows the last ten visits as expected

)

[M5Symptom] = Array
(
[0] = Array
(
[id] = 19
[patient_id] = 5007
[symptom] = Stuffy Nose
[start_date] = 12/18/2006
[end_date] = 12/21/2006
[severity] =
[exported] =
[date_reported] =
[created] =
[modified] =
)
// again truncated by me, but the list of 25 shows up in the array

)

)

On May 15, 12:23 pm, [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote:
 Hi Tony,
 What do you have in the $patient variable when you debug it?
 debug($patient)

 /Martin

 On May 15, 5:37 pm, Tony Thomas [EMAIL PROTECTED] wrote:

  Hi All,

  I'm building a CakePHP app for tracking clinic patients, their visits,
  their symptoms and questionnaire answers. The barrier I've encountered
  is that each patient has many visits AND many symptoms. I want to view
  the patient record and their aggregate visits and symptoms.

  I've defined a hasMany relationship in the patient model as such:

  var $hasMany = array(
  'Visit' = array(
  'order'= 'Visit.id DESC',
  'limit'= '10'
  ),
  'M5Symptom' = array(
  'className' = 'M5Symptom',
  'order' = 'M5Symptom.modified DESC',
  'limit' = '25'
  )
  );

  In the patient view I get the relevant patient data, and the
  corresponding list of visits, but I get the message, Undefined
  index:  M5Symptom for listing the symptoms. As far as I can tell the
  model is correct, because the query for the patient view finds and
  retrieves a list of 25 symptom records exactly as specified in the
  model. From that I take that the model and controller must be working
  as expected. Otherwise the query wouldn't be right and/or it wouldn't
  retrieve the pertinent records. The query that results is EXACTLY what
  I want.

  That leads me to believe the problem must be in the view.

  Here's the view function in the patient controller:

  function view($id = null) {

  $this-Patient-id = $id;
  $this-set('patient', $this-Patient-read());

  }

  Everything works right up until I try to list the symptoms. Here's the
  code for listing symptoms in the view:

  echo $html-tableHeaders(array('Symptom','Start Date','End Date',
  'Severity'));

  foreach ($patient['M5Symptom'] as $symptom) {

  echo $html-tableCells(

  array($symptom['symptom'],
$symptom['start_date'],
$symptom['end_date'],
$symptom['severity'],
  )
  );

  }

  I've looked at all of this over and over and I just can't find out why
  'M5Symptom' is undefined. Just above this, 'Visit' lists recent visit
  dates for me with the exact same logic in place.

  Am I wrong in assuming I can define more than one hasMany? If so, why
  is the correct query generated? I'm hoping another set of eyes will
  find what I'm missing. Sleeping on it didn't help.

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Defining more than one hasMany relationship

2008-05-15 Thread Tony Thomas

OK, some additional information. (I apologize, because I think this is
getting into PHP territory and may not be specifically related to
CakePHP.)

If I place debug($patient) before the first foreach loop (for
'Visit'), I get the arrays as below. If I place it after the foreach
loop I get the same Undefined index message. How can I preserve that
array to reuse it to make a second table?

On May 15, 12:35 pm, Tony Thomas [EMAIL PROTECTED] wrote:
 debug($patient) produces:

 Array
 (
 [Patient] = Array
 (
 [id] = 5007
 [med_hist_id] = 0
 [gender] = M
 [st_of_birth] = [redacted]
 [st_of_res] = [redacted]
 [res_length] = 11 yrs
 [cntry_of_origin] = U.S.
 [dob] = [redacted]
 [siblings] = 2
 [birth_order] = 1
 [mono_before] = N
 [ethnicity] = [redacted]
 [race] = [redacted]
 [contact_by] = email
 [withdrawn] = N
 [kdas] = NKDA
 [mono_dx] = N
 )

 [Visit] = Array
 (
 [0] = Array
 (
 [id] = 2060
 [quest_id] =
 [patient_id] = 5007
 [protocol] = Mono 5
 [vdate] = 4/22/2008
 [vtmstmp] = 1208840400
 [week] =
 [yr] = 2
 [number] = 8
 [notes] = [redacted]
 [kit] = 0
 [sev_p] = 0
 [sev_scr] = 0
 [sev_pain] =
 [modified] = 4/22/2008 2:25:47 PM
 [created] = 4/22/2008 2:11:39 PM
 )
 //truncated here, but shows the last ten visits as expected

 )

 [M5Symptom] = Array
 (
 [0] = Array
 (
 [id] = 19
 [patient_id] = 5007
 [symptom] = Stuffy Nose
 [start_date] = 12/18/2006
 [end_date] = 12/21/2006
 [severity] =
 [exported] =
 [date_reported] =
 [created] =
 [modified] =
 )
 // again truncated by me, but the list of 25 shows up in the array

 )

 )

 On May 15, 12:23 pm, [EMAIL PROTECTED]

 [EMAIL PROTECTED] wrote:
  Hi Tony,
  What do you have in the $patient variable when you debug it?
  debug($patient)

  /Martin

  On May 15, 5:37 pm, Tony Thomas [EMAIL PROTECTED] wrote:

   Hi All,

   I'm building a CakePHP app for tracking clinic patients, their visits,
   their symptoms and questionnaire answers. The barrier I've encountered
   is that each patient has many visits AND many symptoms. I want to view
   the patient record and their aggregate visits and symptoms.

   I've defined a hasMany relationship in the patient model as such:

   var $hasMany = array(
   'Visit' = array(
   'order'= 'Visit.id DESC',
   'limit'= '10'
   ),
   'M5Symptom' = array(
   'className' = 'M5Symptom',
   'order' = 'M5Symptom.modified DESC',
   'limit' = '25'
   )
   );

   In the patient view I get the relevant patient data, and the
   corresponding list of visits, but I get the message, Undefined
   index:  M5Symptom for listing the symptoms. As far as I can tell the
   model is correct, because the query for the patient view finds and
   retrieves a list of 25 symptom records exactly as specified in the
   model. From that I take that the model and controller must be working
   as expected. Otherwise the query wouldn't be right and/or it wouldn't
   retrieve the pertinent records. The query that results is EXACTLY what
   I want.

   That leads me to believe the problem must be in the view.

   Here's the view function in the patient controller:

   function view($id = null) {

   $this-Patient-id = $id;
   $this-set('patient', $this-Patient-read());

   }

   Everything works right up until I try to list the symptoms. Here's the
   code for listing symptoms in the view:

   echo $html-tableHeaders(array('Symptom','Start Date','End Date',
   'Severity'));

   foreach ($patient['M5Symptom'] as $symptom) {

   echo $html-tableCells(

   array($symptom['symptom'],
 $symptom['start_date'],
 $symptom['end_date'],
 $symptom['severity'],
   )
   );

   }

   I've looked at all of this over and over and I just can't find out why
   'M5Symptom' is undefined. Just above this, 'Visit' lists recent visit
   dates for me with the exact same logic in place.

   Am I wrong in assuming I can define more than one hasMany? If so, why
   is the correct query generated

Re: Defining more than one hasMany relationship

2008-05-15 Thread Tony Thomas

Thanks for all of the help. The tips I got pointed me in the right
direction. Once I changed my foreach loops to while (list($key,
$value) = each($patient['Visit'])) and while (list($key, $value) =
each($patient['M5Symptoms'])) respectively, my data appeared. I
figured this out once I realized the foreach() operates on a copy of
the array and list($key, $value) = each($array) doesn't.

http://us2.php.net/foreach
http://us2.php.net/manual/en/function.list.php

(Links for reference to those who might come upon this in the future.
Hello from the past.)

On May 15, 2:26 pm, Tony Thomas [EMAIL PROTECTED] wrote:
 OK, some additional information. (I apologize, because I think this is
 getting into PHP territory and may not be specifically related to
 CakePHP.)

 If I place debug($patient) before the first foreach loop (for
 'Visit'), I get the arrays as below. If I place it after the foreach
 loop I get the same Undefined index message. How can I preserve that
 array to reuse it to make a second table?

 On May 15, 12:35 pm, Tony Thomas [EMAIL PROTECTED] wrote:

  debug($patient) produces:

  Array
  (
  [Patient] = Array
  (
  [id] = 5007
  [med_hist_id] = 0
  [gender] = M
  [st_of_birth] = [redacted]
  [st_of_res] = [redacted]
  [res_length] = 11 yrs
  [cntry_of_origin] = U.S.
  [dob] = [redacted]
  [siblings] = 2
  [birth_order] = 1
  [mono_before] = N
  [ethnicity] = [redacted]
  [race] = [redacted]
  [contact_by] = email
  [withdrawn] = N
  [kdas] = NKDA
  [mono_dx] = N
  )

  [Visit] = Array
  (
  [0] = Array
  (
  [id] = 2060
  [quest_id] =
  [patient_id] = 5007
  [protocol] = Mono 5
  [vdate] = 4/22/2008
  [vtmstmp] = 1208840400
  [week] =
  [yr] = 2
  [number] = 8
  [notes] = [redacted]
  [kit] = 0
  [sev_p] = 0
  [sev_scr] = 0
  [sev_pain] =
  [modified] = 4/22/2008 2:25:47 PM
  [created] = 4/22/2008 2:11:39 PM
  )
  //truncated here, but shows the last ten visits as expected

  )

  [M5Symptom] = Array
  (
  [0] = Array
  (
  [id] = 19
  [patient_id] = 5007
  [symptom] = Stuffy Nose
  [start_date] = 12/18/2006
  [end_date] = 12/21/2006
  [severity] =
  [exported] =
  [date_reported] =
  [created] =
  [modified] =
  )
  // again truncated by me, but the list of 25 shows up in the array

  )

  )

  On May 15, 12:23 pm, [EMAIL PROTECTED]

  [EMAIL PROTECTED] wrote:
   Hi Tony,
   What do you have in the $patient variable when you debug it?
   debug($patient)

   /Martin

   On May 15, 5:37 pm, Tony Thomas [EMAIL PROTECTED] wrote:

Hi All,

I'm building a CakePHP app for tracking clinic patients, their visits,
their symptoms and questionnaire answers. The barrier I've encountered
is that each patient has many visits AND many symptoms. I want to view
the patient record and their aggregate visits and symptoms.

I've defined a hasMany relationship in the patient model as such:

var $hasMany = array(
'Visit' = array(
'order'= 'Visit.id DESC',
'limit'= '10'
),
'M5Symptom' = array(
'className' = 'M5Symptom',
'order' = 'M5Symptom.modified DESC',
'limit' = '25'
)
);

In the patient view I get the relevant patient data, and the
corresponding list of visits, but I get the message, Undefined
index:  M5Symptom for listing the symptoms. As far as I can tell the
model is correct, because the query for the patient view finds and
retrieves a list of 25 symptom records exactly as specified in the
model. From that I take that the model and controller must be working
as expected. Otherwise the query wouldn't be right and/or it wouldn't
retrieve the pertinent records. The query that results is EXACTLY what
I want.

That leads me to believe the problem must be in the view.

Here's the view function in the patient controller:

function view($id = null) {

$this-Patient-id = $id;
$this-set('patient', $this-Patient-read());

}

Everything works right up until I try to list the symptoms