Re: Making Paginator first sort direction DESC

2008-05-20 Thread Tim W
of asc. On May 8, 12:35 am, Tim W [EMAIL PROTECTED] wrote: Thanks Marcin. I don't think i've been entirely clear. I can easily set the sort order programmatically, but when the user first clicks on a link to sort a column it automatically sorts ASC. I'd like to change that behavior to default

Re: Working 1.2 Auth with remember me feature

2008-05-14 Thread Tim W
Here's an updated function to support the good Dr Lecter's idea of resetting the cookie each time the user logs in. I'm fairly sure it works... function loginFromCookie() { $cookie = $this-Cookie-read('Auth.User'); if (!is_null($cookie)) { if ($this-Auth-login($cookie)) { //

Working 1.2 Auth with remember me feature

2008-05-13 Thread Tim W
Cake 1.2 Auth is still pretty badly documented, but between a half dozen articles I managed to get it all working. None tell the full story though, and I don't fully understand it, but I have working code I thought i'd share. I may post a bakery article if I get time. For now this should help

Re: Working 1.2 Auth with remember me feature

2008-05-13 Thread Tim W
functionality as yours (+ the extra continuous remembering), but I don't have a working example with all the views etc. HTH someone too ;-) On May 13, 12:42 pm, Tim W [EMAIL PROTECTED] wrote: Cake 1.2 Auth is still pretty badly documented, but between a half dozen articles I managed to get

Accessing views from Cake - problem with array nesting

2008-05-10 Thread Tim W
Hi all, I've just spent a hour or so tracking down an issue before realising it was caused by pointing cake at a view instead of a database table. In general views work with Cake, but in some seemingly random cases they fail. The problem i've run into was identified and a patch suggested in

Re: Accessing views from Cake - problem with array nesting (with workaround or solution)

2008-05-10 Thread Tim W
Once it's written out like this the problem and solution becomes obvious(my excuse is it's 2am) - change $image['ModelName'] to $image[0] Hope this helps someone out, and maybe someone will work out a patch one day. Cheers Tim On May 11, 2:02 am, Tim W [EMAIL PROTECTED] wrote: Hi all, I've

Re: Accessing views from Cake - problem with array nesting

2008-05-10 Thread Tim W
] wrote: Just make sure to alias the fields in your SELECT like cake DBO normally does SELECT Model.id AS Model.id I think - Configure::write('debug', 2); And check how cake does it :) -Original Message- From: cake-php@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Tim W

Re: Making Paginator first sort direction DESC

2008-05-07 Thread Tim W
Kende [EMAIL PROTECTED] wrote: Hello, try this in your controller: var $paginate = array('limit' = 100, 'page' = 1, 'order' = 'DESC'); Andras Kende http://www.kende.com -Original Message- From: cake-php@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Tim W Sent

Re: Making Paginator first sort direction DESC

2008-05-07 Thread Tim W
' = 'Model.column DESC' On Wed, May 7, 2008 at 11:26 AM, Tim W [EMAIL PROTECTED] wrote: Thanks for the suggestion, but unfortunately it didn't work for me. SQL Error: 1054: Unknown column 'DESC' in 'order clause' I'll spend some time to work this out at some point, i'll post when I do

Making Paginator first sort direction DESC

2008-05-06 Thread Tim W
Hi all, Paginator's great, like the rest of Cake, but there's one little thing I haven't been able to work out. By default when you click on a column to sort it will sort ASC (ascending), but i'd like the first sort to be DESC (descending). The options suggest this might be possible, but I

1.2 validation - may be blank, but if filled in must be a decimal

2008-03-28 Thread Tim W
Hi all, I have some data that's optional, but if it's filled in it must be a decimal. Is there an easy way to do this with 1.2 validation? My current though is that I might create a custom validation rule, and from their if the field isn't blank then send it through to the built in validation

Re: 1.2 validation - may be blank, but if filled in must be a decimal

2008-03-28 Thread Tim W
a better way to do this, if one exists :) Tim On Mar 28, 8:56 pm, Tim W [EMAIL PROTECTED] wrote: Hi all, I have some data that's optional, but if it's filled in it must be a decimal. Is there an easy way to do this with 1.2 validation? My current though is that I might create a custom validation

1.2 custom validation methods for multiple fields

2008-03-28 Thread Tim W
Hi all, Say I have a check box and a text field on a form. If the check box is checked the form has to have a number in it. If the check box isn't checked then it must be empty. Does anyone know how to do this validation in 1.2? I could write a custom validation method but I can't work out how

Re: 1.2 custom validation methods for multiple fields

2008-03-28 Thread Tim W
''; // Sample code to invalidate one field and make validation fail $this-invalidate('field_Name', 'messageKey'); // messageKey can be the error message or the key to the error message in the messages array (see 1.2 validation documentation) return false; } On Mar 28, 9:18 pm, Tim W

Re: 1.2 validation - may be blank, but if filled in must be a decimal

2008-03-28 Thread Tim W
on the fraction digits, or allow scientific notation as well. For example, if you wanted a positive number with maximum 2 digits after the decimal point then you'd use something like: '/^[0-9]+(\\.[0-9]{,2})?$/' On Mar 28, 8:12 am, Tim W [EMAIL PROTECTED] wrote: In case anyone else wants

Cake core code infinite loop/recursive rendering issue

2008-02-18 Thread Tim W
Hi all, I have an issue with rendering getting itself into an infinite loop. I've stepped through the code I can see what's going on, but I don't want to mess with the core given I don't have a good overview of how it all fits together. I can consistently reproduce this problem by doing one

Auth 1.2 - login only if user state = activated?

2008-02-15 Thread Tim W
Hi all, My user table/model has a state_id field. I'd like to configure Auth so that it only lets people login is the state is a certain value. Is there an easy way to do this? Two lines in auth.php suggest it should be possible 38: $conditions = $this-userScope; // (previously $conditions is

Re: Auth 1.2 - login only if user state = activated?

2008-02-15 Thread Tim W
That sound easy, i'll give it ago, thanks Grigri :) On Feb 15, 11:51 pm, grigri [EMAIL PROTECTED] wrote: Just set $this-Auth-userScope = array('User.state_id' = WHATEVER); in your controller's beforeFilter callback. On Feb 15, 10:43 am, Tim W [EMAIL PROTECTED] wrote: Hi all, My user

Re: Auth 1.2 - login only if user state = activated?

2008-02-15 Thread Tim W
I just tried it and it works perfectly, thank you Grigri. And wow, quick replies! :) On Feb 15, 11:51 pm, grigri [EMAIL PROTECTED] wrote: Just set $this-Auth-userScope = array('User.state_id' = WHATEVER); in your controller's beforeFilter callback. On Feb 15, 10:43 am, Tim W [EMAIL PROTECTED

AppModel retaining previous insert ID

2008-02-06 Thread Tim W
Hi all, I've got a piece of code that does an insert, then and update of the previous row inserted, then the code loops around and does the same thing again for a different data set. I've found an issue that the second time around the loop the AppModel is retaining the ID of the previous insert

Re: AppModel retaining previous insert ID

2008-02-06 Thread Tim W
Thanks Samuel, I didn't think to check if there was a create type method, cheers :) On Feb 7, 3:00 pm, Samuel DeVore [EMAIL PROTECTED] wrote: I usually use $this-ModelName-create(); On Feb 6, 2008 5:50 PM, Tim W [EMAIL PROTECTED] wrote: Hi all, I've got a piece of code that does

Re: Auth in 1.2 - get current user?

2008-02-05 Thread Tim W
Do you have sample vode for those Andy? I've also been banging my head against 1.2 Auth for about 3 days and i'm tempted to rip it out and write my own - which I expect to take about 2 hours. On Feb 5, 11:08 pm, AD7six [EMAIL PROTECTED] wrote: 2. When refresh a exprired auth page , it'll jump

Controller without model/table possible?

2008-02-05 Thread Tim W
Hi all, Is it possible to have a controller that doesn't map directly to a model or database table? I want an admin section for my website where I can edit users and other models, it'll hook into existing models rather than having its own. Thanks Tim

Re: Cake 1.2 Auth component redirecting to a weird path

2008-02-05 Thread Tim W
Can you post your AppController beforeFilter method? On Feb 6, 9:55 am, Arne-Kolja Bachstein [EMAIL PROTECTED] wrote: Hi there, I've got a slight problem with my Auth component atm. It always redirects me to a specific but really weird URL when successfully logging in. The URL is the path

Re: menu and css problem with path

2008-02-05 Thread Tim W
Can you post the exact source code that generates the section in question, as well as the code generated by Cake? In your web browser you'll have to choose view source and copy and paste it out. On Feb 6, 10:26 am, redcom [EMAIL PROTECTED] wrote: hello i have the following problem. i have

Re: Cake 1.2 Auth component redirecting to a weird path

2008-02-05 Thread Tim W
'); } } --- Best regards Arne On 5 Feb., 22:07, Tim W [EMAIL PROTECTED] wrote: Can you post your AppController beforeFilter method? On Feb 6, 9:55 am, Arne-Kolja Bachstein [EMAIL PROTECTED] wrote: Hi there, I've got a slight problem with my Auth component atm. It always

Re: Cake 1.2 Auth component redirecting to a weird path

2008-02-05 Thread Tim W
is the loginRedirect handled usually? Is it, like I assume, $this- redirect($this-Auth-loginRedirect()) within my login method? Arne On 5 Feb., 22:52, Tim W [EMAIL PROTECTED] wrote: The only thing that comes to mind is that you're missing a line I have in my beforeFilter action, your might

Auth in 1.2 - get current user?

2008-02-04 Thread Tim W
Hi all, Thanks mostly to the tutorial linked below I have basic auth working in my project. I can create a user in the database (that took a while to figure out), have users view public content without logging in, and make users log in before they go to a page that's for registered only. So far

Re: Auth in 1.2 - get current user?

2008-02-04 Thread Tim W
Thanks Amit. I think i've cracked auth in 1.2 and the remember me cookie issue. I'll go try and work out ACL now, if I can i'll put a fully working sample project up somewhere. On Feb 5, 12:59 am, Amit Badkas [EMAIL PROTECTED] wrote: On Feb 4, 2008 5:13 PM, Tim W [EMAIL PROTECTED] wrote

Re: HABTM - read only associations in Cake 1.2

2008-02-03 Thread Tim W
this? Or do I stop usingHABTMand do it with a plain old database call? Tim W wrote: Hi all, I have aHABTMrelationship that's working, but I want to tell it not to delete and create new rows in the many to many table - Ionlywant it to treat that table asreadonly. Using the following

HABTM - read only associations in Cake 1.2

2008-01-31 Thread Tim W
Hi all, I have a HABTM relationship that's working, but I want to tell it not to delete and create new rows in the many to many table - I only want it to treat that table as read only. Using the following unbindModel command doesn't seem to affect it.

Saving model without saving associated models

2008-01-17 Thread Tim W
Hi all, I'm doing a save of a model, it has an association and the key is being used in a join during the update, so that field isn't being saved. I need to disable the join for the save so I can update the field. Can anyone tell me how to do this? I think I can do this using the unbindModel()

best way to do calculated fields in afterFind

2008-01-15 Thread Tim W
Hi all, Is this the best way to create a calculated field in a model object? It works perfectly, but having to merge an array doesn't seem ideal, and it's not OO at all. function afterFind($results) { for ($i=0; $i count($results); $i++) { $lens = $results[$i]['Lens'];