Re: Making Paginator first sort direction DESC

2008-05-20 Thread Tim W
t direction to be desc instead 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 i

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)) { //

Re: Working 1.2 Auth with "remember me" feature

2008-05-13 Thread Tim W
-for-cakephp > > Basically the same 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: > &g

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 some

Re: Accessing views from Cake - problem with array nesting

2008-05-10 Thread Tim W
ssage- > From: cake-php@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Tim W > Sent: 10. maj 2008 16:03 > To: CakePHP > Subject: Accessing views from Cake - problem with array nesting > > Hi all, > > I've just spent a hour or so tracking down an issue befor

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

2008-05-10 Thread Tim W
[id] => 11 [added_by_user_id] => 1 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

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 this

Re: Making Paginator first sort direction DESC

2008-05-07 Thread Tim W
<[EMAIL PROTECTED]> wrote: > 'order' => '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: 10

Re: Making Paginator first sort direction DESC

2008-05-07 Thread Tim W
> > http://www.kende.com > > -Original Message- > From: cake-php@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf > > Of Tim W > Sent: Tuesday, May 06, 2008 9:26 AM > To: CakePHP > Subject: Making Paginator first sort direction DESC > > Hi all, > > Pa

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

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

2008-03-28 Thread Tim W
7;This must be blank or a positive decimal number' > ) > ); > > You could use a different regular expression to allow negative > numbers, enforce limits on the fraction digits, or allow scientific > notation as well. > > For example, if you wanted a positive number with maxi

Re: 1.2 custom validation methods for multiple fields

2008-03-28 Thread Tim W
echo ''; // 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) re

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 to

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

2008-03-28 Thread Tim W
t wrote my own since it was trivial and quicker. I'm still interested to hear 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 > dec

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 cod

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 thing

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. &g

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

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

2008-02-15 Thread Tim W
uot;Dardo Sordi Bogado" <[EMAIL PROTECTED]> wrote: > Use AuthComponent::$userScope = array() // accepts conditions in the > same way that Model::findAll() > > On Fri, Feb 15, 2008 at 8:43 AM, Tim W <[EMAIL PROTECTED]> wrote: > > > Hi all, > > > My use

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: 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: &g

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 a

Re: Cake 1.2 Auth component redirecting to a weird path

2008-02-05 Thread Tim W
doesnt change anything. Anyway, how 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 thin

Re: Cake 1.2 Auth component redirecting to a weird path

2008-02-05 Thread Tim W
ems', > $this->Session->read('profiles_menuitems')); > > $this->set('is_admin', $this->isAdmin()); > > $this->prepareSubmenu(); > } > else > { >

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 ha

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

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

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

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 I

Re: HABTM - read only associations in Cake 1.2

2008-02-03 Thread Tim W
hat keys are sent to the > model. > > Adam > > On Feb 2, 6:55 am, Tim Wild <[EMAIL PROTECTED]> wrote: > > > Does anyone have an idea about this? Or do I stop usingHABTMand do it > > with a plain old database call? > > > Tim W wrote: > > > Hi all,

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. $this->Lens->unbindModel(array('hasAndBelong

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() m

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'];