Possible security risk when saving data in forms - adding fields

2008-07-04 Thread phpjoy

When getting a form from a user, it should be double checked in the
user's action logic.
A user could easily manipulate a form field to submit a new field to
the server, like id="4294967294", and stuck the users table. The user
could guess, of course, other field names, or see other forms/views
and get the field names from there.
It has unlimited possibilities, like change the field "created"
"modified" "lastvisit" "user.id" and a lot more.
I tested it out on a company's blogging system, and I could easily
modify the "created" field to 2007.

Throughout the examples in the manual (1.2 and 1.1), I haven't noticed
any reminder of that possible risk, though I noticed the bad
programming habits shown in the blog example and old 1.1 manual.

function add() {
  if (!empty($this->data)) {
if ($this->Post->save($this->data)) {
  $this->flash('Your post has been saved.','/posts');
}
  }
}

Is there a function that I'm unaware of, that locks the fields from
the form?
Like: Controller->ExpectFields = array('Post.name', 'Post.title');

I checked the bakery's code, and found out that after adding a comment
[the add form is secured], you could edit the comment to belong to
another user by sending Comment.user_id from a form. I assume getting
them isn't too hard, for it's probably found in the generated HTML
code of the profiles.

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



Re: Strict or Pretty? We're looking for a few good opinions

2008-06-08 Thread phpjoy

Point your heads up towards PHP6, leave standards but not too far.
Sometimes very stupid things can be done in the quest for standards..

On Jun 7, 5:14 am, Nate <[EMAIL PROTECTED]> wrote:
> So, we all love the simplicity and magic that Cake gives us.  It's
> wonderful that we've even been able to deliver these things with
> relative consistency and transparency across both major versions (and
> many minor versions) of PHP.  It's these things that make Cake what it
> is.  In order to get these things to work the way they do, we've had
> to pull quite a few tricks and it wasn't all very easy.
>
> As we all know, the next major version of CakePHP will only have to
> worry about supporting one PHP version.  This is going to open up new
> worlds of possibility for streamlining your code and development
> processes, and creating simple, pretty syntax constructs.
>
> We're currently in the exploratory phases of figuring out what some of
> the API constructs for Cake 2.0 might look like, and have come to
> somewhat of an empasse in several key areas.  In these areas (and
> undoubtedly other similar ones down the road) taking advantage of
> certain functionality that would help us keep Cake simple while taking
> advantage of more advanced object oriented features means breaking
> strict mode compatibility.
>
> Now, rather than give specifics and turn this into a discussion about
> semantics, I've decided to pose this as a general question, which we
> can use as a guideline moving forward: assuming we follow the "spirit
> of the law" in all other areas (i.e. using proper visibility modifiers
> in classes, cleaning up object handling to comply with PHP5, etc.),
> would you consider it acceptable to break strict mode in a few key
> (forward-compatible) areas if it meant significantly simplifying code
> and/or eliminating extra work you would otherwise have to do?  As a
> "feature", how important is absolute compliance with strict-mode
> standards?
>
> We may at some point set up a polling system and put the issue to an
> actual vote, but for now, we're just looking for opinions one way or
> the other, so let us know what you think.
--~--~-~--~~~---~--~~
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: Different performance between 1.1 and 1.2

2008-05-31 Thread phpjoy

"Fear is the path to the dark side. Fear leads to anger. Anger leads
to hate. Hate leads to suffering."

Not that I'm hinting anything :D


On May 30, 12:13 am, "Chris Hartjes" <[EMAIL PROTECTED]> wrote:
> On Thu, May 29, 2008 at 4:56 PM, [EMAIL PROTECTED]
>
> <[EMAIL PROTECTED]> wrote:
>
> > The problem is that it's the same even if debug is off .
> > The difference is smaller but Cake 1.1 seems faster than Cake 1.2
>
> Ah, you crazy kids and your concerns about the speed of Cake.  Back in
> my day, we looked at all factors of an application before we started
> blaming the code, since the database would inevitably be the
> bottleneck unless we had written really shitty code or were actually
> doing computationally-intensive work.
>
> I think the additional features of 1.2 are what make it worth
> upgrading from 1.1, and I hate to burst anyone's ego but I doubt your
> application will get so much traffic that any alleged speed decrease
> from Cake 1.2 will make a difference.  Good coding practices go a long
> way towards ensuring application speed.
>
> Performance testing and benchmarking is an art in itself and unless
> you use tools specifically dedicated towards those  ends (like Xdebug
> or Apache Benchmark or Siege ) you are just making shit up.
>
> Have I used these tools on Cake?  No.  Why? Because I don't care about
> CakePHP's speed.  For 99.999% of those who use CakePHP, it is
> MTFEIYFTR (More Than Fast Enough If You Follow The Rules).  For the
> other .001%, either change your code or go with a non-Cake solution.
>
> This is the "Twitter sucks because of Rails" fallacy.  Twitter sucks
> because they built a messaging system using tools for building a
> content management system.
>
> So, to get back to your initial question from the beginning of the thread:
>
> Upgrade to 1.2 because it is light-years ahead of 1.1 in available features.
>
> Now get off my lawn!
>
> --
> Chris Hartjes
> Internet Loudmouth
> Motto for 2008: "Moving from herding elephants to handling snakes..."
> @TheKeyBoard:http://www.littlehart.net/atthekeyboard
--~--~-~--~~~---~--~~
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: looking for a hosting company

2008-03-28 Thread phpjoy

any experience with godaddy anyone?
i had some, wonder what was yours.

On Mar 26, 3:53 pm, Zoltan <[EMAIL PROTECTED]> wrote:
> Just wondering if anyone has a hosting company they'd recommend.
> I've personally hosted a few sites on DreamHost, speed is ok, but
> getting Cake sites up and running is problem-free. On the other hand,
> I've used Rackspace, which is faster, but keep on running into
> problems.
>
> If anybody has a hosting company they'd recommend, I'd appreciate it.
>
> Thanks,
> Zoltanwww.yyztech.ca
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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: Suppressing UTF-8 BOM output

2008-03-25 Thread phpjoy

Use a normal editor..
http://www.scintilla.org is a good one.

There's an encoding called "UTF-Cookie", which doesn't save the BOM.


On Mar 24, 4:37 pm, MonkeyGirl <[EMAIL PROTECTED]> wrote:
> Hi.
>
> I'm probably missing something simple here, but a few weeks ago, my
> Cake app seemed to spontaneously start outputting the hex values "EF
> BB BF" at the beginning of all its pages. Static files such as CSS
> files, and non-Cake PHP files in /app/webroot, don't do this. It's
> just files generated with CakePHP.
>
> This is causing me some grief as it means the XLS writer has stopped
> working, because OpenOffice.org (and presumably Excel) really doesn't
> like seeing EF BB BF at the beginning of a file.
>
> After looking into this, I've discovered that the string in question
> is the UTF-8 byte-order mark, as explained 
> inhttp://en.wikipedia.org/wiki/Byte-order_mark
> .
>
> I can't remember what I must have done to get CakePHP to start
> outputting this string, but I need to get it to stop. I'm guessing
> there's something simple that I can set, but I can't work out what it
> is.
>
> The only place I thought I mentioned UTF-8 is the HTML metadata, which
> the XLS generator obviously isn't outputting.
>
> Any ideas, anyone?
>
> Thank you very much,
> Zoe.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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: CakePHP guide

2008-02-06 Thread phpjoy

That attitude is the exact difference between ExtJS which is more
community-driven and Zend, which is cold and company-driven.
ExtJS succeeds because the community-force behind it drives it
forward, because people make tons of plugins. Because they don't need
a "bakery", they have a simple forum with a WORKING SEARCH.
You should check how people are turning into staff/core contributers
there and get a job if they're good enough. I didn't see anyone of the
core-staff in there bitch about how stupid people are, how questions
are being asked over and over again. Those messages made by users are
either deleted or ignored.

I think that only an idiot would be happy to contribute to anything
after such a stupid comment.

I like CakePHP as a product (otherwise I wouldn't be here), but nate,
you should work on your human skills.

On Feb 4, 6:48 pm, nate <[EMAIL PROTECTED]> wrote:
> The only comment or criticism I have is that it's a shame that such
> efforts aren't put towards the official documentation.  John gets
> little to no help from outside contributors, and the only way the
> community has seen fit to contribute is with scattered, one-off
> tutorials at various levels of currency, completeness and accuracy.  I
> don't mean to denigrate your efforts here, but I really think that
> efforts like these often serve to scatter and spread the pool of
> useful information thinner, which just makes it harder to find, which
> makes people more frustrated.
>
> On Feb 3, 1:01 pm, MonkeyGirl <[EMAIL PROTECTED]> wrote:
>
> > Hi!
>
> > Just to let you all know, I've finally written enough of the CakePHP
> > guide that I'm working on to warrant putting it online at last. It's
> > available here:
>
> >http://cakephp.bytenoise.co.uk/
>
> > It's only the first three chapters so far, but hopefully I should have
> > a lot more there over the next few weeks.
>
> > Any comments and constructive criticism are both welcomed.
>
> > Thanks,
> > Zoe.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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: Simple binding question.

2008-01-22 Thread phpjoy

That's a very good idea. silly me.
I don't know why I was stubborn using the ticket model.


On Jan 21, 12:57 pm, "Dardo Sordi Bogado" <[EMAIL PROTECTED]>
wrote:
> Do bind in the model you will execute the findAll!
>
> As you say:
>
> A deal has many tickets, and
> belongs to one item.
>
> do bind: Deal hasMany Ticket, Deal belongsTo Item.
>
> HTH,
> - Dardo Sordi.
>
> On Jan 21, 2008 7:16 AM, phpjoy <[EMAIL PROTECTED]> wrote:
>
>
>
> > for some kind of reason, this didn't work:
> > $this->Ticket->bindModel(array('belongsTo' => array('Deal'
> > =>array('foreignKey' => 'deal_id';
> > $this->Ticket->Deal->bindModel(array('belongsTo' => array('Item'
> > =>array('foreignKey' => 'item_id';
>
> > On the query, it searched for:
> > Item.id = Ticket.item_id (and item_id doesn't exist)
>
> > On Jan 20, 11:17 pm, "Dardo Sordi Bogado" <[EMAIL PROTECTED]>
> > wrote:
> > > If "A deal has many tickets, and belongs to one item.", then why you bind:
>
> > > $this->Ticket->bindModel(array('belongsTo' => array('Deal'
> > > =>array('foreignKey' => 'deal_id';
> > > $this->Ticket->bindModel(array('belongsTo' => array('Item'
> > > =>array('foreignKey' => 'deal_id';
>
> > > Ticket belongsTo Deal, Ticket belongsTo Item ?
>
> > > On Jan 19, 2008 6:43 PM, phpjoy <[EMAIL PROTECTED]> wrote:
>
> > > > No, there isn't such a key Ticket.item_id
> > > > Warning (512): SQL Error: 1054: Unknown column 'Ticket.item_id' in 'on
> > > > clause' [CORE\cake\libs\model\datasources\dbo_source.php, line 440]
>
> > > > There's Deal.item_id
> > > > Basically a ticket belongs to a deal. A deal has many tickets, and
> > > > belongs to one item.
>
> > > > It should be:
> > > > Ticket->Deal->Item
>
> > > > I need to get Item.title for every ticket that I have.
> > > > So my custom SQL query is correct, but I wonder how I could use binds
> > > > to do that.
>
> > > > That's the custom query I came up with:
> > > > SELECT `Ticket`.`id`, `Deal`.`file`, `Item`.`title` FROM `tickets` AS
> > > > `Ticket` LEFT JOIN `deals` AS `Deal` ON (`Ticket`.`deal_id` =
> > > > `Deal`.`id`) LEFT JOIN `items` AS `Item` ON (`Deal`.`item_id` =
> > > > `Item`.`id`) WHERE `Ticket`.`user_id` = 1
> > > > When I left join 'items' to deal.item_id, it works.
>
> > > > On Jan 19, 6:40 pm, "Dardo Sordi Bogado" <[EMAIL PROTECTED]> wrote:
> > > > > You are putting:
>
> > > > > $this->Ticket->bindModel(array('belongsTo' => array('Item' =>
> > > > > array('foreignKey' => 'deal_id';
>
> > > > > instead of :
>
> > > > > $this->Ticket->bindModel(array('belongsTo' => array('Item' =>
> > > > > array('foreignKey' => 'item_id';
>
> > > > > it's a copy and paste error.
>
> > > > > HTH,
> > > > > - Dardo Sordi.
>
> > > > > On Jan 18, 2008 9:39 PM, phpjoy <[EMAIL PROTECTED]> wrote:
>
> > > > > > I wonder how I could make asimplequery to work through bind(), and
> > > > > > not use a custom query.
>
> > > > > > I'm binding two models for a model:
> > > > > > $this->Ticket->bindModel(array('belongsTo' => array('Deal' =>
> > > > > > array('foreignKey' => 'deal_id';
> > > > > > $this->Ticket->bindModel(array('belongsTo' => array('Item' =>
> > > > > > array('foreignKey' => 'deal_id';
>
> > > > > > The resulting query I get is this:
> > > > > > SELECT `Ticket`.`id`, `Deal`.`file`, `Item`.`title` FROM `tickets` 
> > > > > > AS
> > > > > > `Ticket` LEFT JOIN `deals` AS `Deal` ON (`Ticket`.`deal_id` =
> > > > > > `Deal`.`id`) LEFT JOIN `items` AS `Item` ON (`Ticket`.`deal_id` =
> > > > > > `Item`.`id`) WHERE `Ticket`.`user_id` = 1
>
> > > > > > Now, instead of:
> > > > > > `Item` ON (`Ticket`.`deal_id` = `Item`.`id`)
> > > > > > I need:
> > > > > > `Item` ON (`Deal`.`item_id` = `Item`.`id`)
>
> > > > > > Which gives this query:
> > > > > > SELECT `Ticket`.`id`, `Deal`.`file`, `Item`.`title` FROM `tickets` 
> > > > > > AS
> > > > > > `Ticket` LEFT JOIN `deals` AS `Deal` ON (`Ticket`.`deal_id` =
> > > > > > `Deal`.`id`) LEFT JOIN `items` AS `Item` ON (`Deal`.`item_id` =
> > > > > > `Item`.`id`) WHERE `Ticket`.`user_id` = 1
>
> > > > > > I tried binding item to deal, and CakePHP made 200 queries instead.
> > > > > > That didn't work too well.
> > > > > > Any ideas how I could make a slim query with CakePHP, without using
> > > > > > query()?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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: Simple binding question.

2008-01-21 Thread phpjoy

for some kind of reason, this didn't work:
$this->Ticket->bindModel(array('belongsTo' => array('Deal'
=>array('foreignKey' => 'deal_id';
$this->Ticket->Deal->bindModel(array('belongsTo' => array('Item'
=>array('foreignKey' => 'item_id';

On the query, it searched for:
Item.id = Ticket.item_id (and item_id doesn't exist)

On Jan 20, 11:17 pm, "Dardo Sordi Bogado" <[EMAIL PROTECTED]>
wrote:
> If "A deal has many tickets, and belongs to one item.", then why you bind:
>
> $this->Ticket->bindModel(array('belongsTo' => array('Deal'
> =>array('foreignKey' => 'deal_id';
> $this->Ticket->bindModel(array('belongsTo' => array('Item'
> =>array('foreignKey' => 'deal_id';
>
> Ticket belongsTo Deal, Ticket belongsTo Item ?
>
> On Jan 19, 2008 6:43 PM, phpjoy <[EMAIL PROTECTED]> wrote:
>
>
>
> > No, there isn't such a key Ticket.item_id
> > Warning (512): SQL Error: 1054: Unknown column 'Ticket.item_id' in 'on
> > clause' [CORE\cake\libs\model\datasources\dbo_source.php, line 440]
>
> > There's Deal.item_id
> > Basically a ticket belongs to a deal. A deal has many tickets, and
> > belongs to one item.
>
> > It should be:
> > Ticket->Deal->Item
>
> > I need to get Item.title for every ticket that I have.
> > So my custom SQL query is correct, but I wonder how I could use binds
> > to do that.
>
> > That's the custom query I came up with:
> > SELECT `Ticket`.`id`, `Deal`.`file`, `Item`.`title` FROM `tickets` AS
> > `Ticket` LEFT JOIN `deals` AS `Deal` ON (`Ticket`.`deal_id` =
> > `Deal`.`id`) LEFT JOIN `items` AS `Item` ON (`Deal`.`item_id` =
> > `Item`.`id`) WHERE `Ticket`.`user_id` = 1
> > When I left join 'items' to deal.item_id, it works.
>
> > On Jan 19, 6:40 pm, "Dardo Sordi Bogado" <[EMAIL PROTECTED]> wrote:
> > > You are putting:
>
> > > $this->Ticket->bindModel(array('belongsTo' => array('Item' =>
> > > array('foreignKey' => 'deal_id';
>
> > > instead of :
>
> > > $this->Ticket->bindModel(array('belongsTo' => array('Item' =>
> > > array('foreignKey' => 'item_id';
>
> > > it's a copy and paste error.
>
> > > HTH,
> > > - Dardo Sordi.
>
> > > On Jan 18, 2008 9:39 PM, phpjoy <[EMAIL PROTECTED]> wrote:
>
> > > > I wonder how I could make a simple query to work through bind(), and
> > > > not use a custom query.
>
> > > > I'm binding two models for a model:
> > > > $this->Ticket->bindModel(array('belongsTo' => array('Deal' =>
> > > > array('foreignKey' => 'deal_id';
> > > > $this->Ticket->bindModel(array('belongsTo' => array('Item' =>
> > > > array('foreignKey' => 'deal_id';
>
> > > > The resulting query I get is this:
> > > > SELECT `Ticket`.`id`, `Deal`.`file`, `Item`.`title` FROM `tickets` AS
> > > > `Ticket` LEFT JOIN `deals` AS `Deal` ON (`Ticket`.`deal_id` =
> > > > `Deal`.`id`) LEFT JOIN `items` AS `Item` ON (`Ticket`.`deal_id` =
> > > > `Item`.`id`) WHERE `Ticket`.`user_id` = 1
>
> > > > Now, instead of:
> > > > `Item` ON (`Ticket`.`deal_id` = `Item`.`id`)
> > > > I need:
> > > > `Item` ON (`Deal`.`item_id` = `Item`.`id`)
>
> > > > Which gives this query:
> > > > SELECT `Ticket`.`id`, `Deal`.`file`, `Item`.`title` FROM `tickets` AS
> > > > `Ticket` LEFT JOIN `deals` AS `Deal` ON (`Ticket`.`deal_id` =
> > > > `Deal`.`id`) LEFT JOIN `items` AS `Item` ON (`Deal`.`item_id` =
> > > > `Item`.`id`) WHERE `Ticket`.`user_id` = 1
>
> > > > I tried binding item to deal, and CakePHP made 200 queries instead.
> > > > That didn't work too well.
> > > > Any ideas how I could make a slim query with CakePHP, without using
> > > > query()?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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: Simple binding question.

2008-01-19 Thread phpjoy

No, there isn't such a key Ticket.item_id
Warning (512): SQL Error: 1054: Unknown column 'Ticket.item_id' in 'on
clause' [CORE\cake\libs\model\datasources\dbo_source.php, line 440]

There's Deal.item_id
Basically a ticket belongs to a deal. A deal has many tickets, and
belongs to one item.

It should be:
Ticket->Deal->Item

I need to get Item.title for every ticket that I have.
So my custom SQL query is correct, but I wonder how I could use binds
to do that.

That's the custom query I came up with:
SELECT `Ticket`.`id`, `Deal`.`file`, `Item`.`title` FROM `tickets` AS
`Ticket` LEFT JOIN `deals` AS `Deal` ON (`Ticket`.`deal_id` =
`Deal`.`id`) LEFT JOIN `items` AS `Item` ON (`Deal`.`item_id` =
`Item`.`id`) WHERE `Ticket`.`user_id` = 1
When I left join 'items' to deal.item_id, it works.

On Jan 19, 6:40 pm, "Dardo Sordi Bogado" <[EMAIL PROTECTED]> wrote:
> You are putting:
>
> $this->Ticket->bindModel(array('belongsTo' => array('Item' =>
> array('foreignKey' => 'deal_id';
>
> instead of :
>
> $this->Ticket->bindModel(array('belongsTo' => array('Item' =>
> array('foreignKey' => 'item_id';
>
> it's a copy and paste error.
>
> HTH,
> - Dardo Sordi.
>
> On Jan 18, 2008 9:39 PM, phpjoy <[EMAIL PROTECTED]> wrote:
>
>
>
> > I wonder how I could make a simple query to work through bind(), and
> > not use a custom query.
>
> > I'm binding two models for a model:
> > $this->Ticket->bindModel(array('belongsTo' => array('Deal' =>
> > array('foreignKey' => 'deal_id';
> > $this->Ticket->bindModel(array('belongsTo' => array('Item' =>
> > array('foreignKey' => 'deal_id';
>
> > The resulting query I get is this:
> > SELECT `Ticket`.`id`, `Deal`.`file`, `Item`.`title` FROM `tickets` AS
> > `Ticket` LEFT JOIN `deals` AS `Deal` ON (`Ticket`.`deal_id` =
> > `Deal`.`id`) LEFT JOIN `items` AS `Item` ON (`Ticket`.`deal_id` =
> > `Item`.`id`) WHERE `Ticket`.`user_id` = 1
>
> > Now, instead of:
> > `Item` ON (`Ticket`.`deal_id` = `Item`.`id`)
> > I need:
> > `Item` ON (`Deal`.`item_id` = `Item`.`id`)
>
> > Which gives this query:
> > SELECT `Ticket`.`id`, `Deal`.`file`, `Item`.`title` FROM `tickets` AS
> > `Ticket` LEFT JOIN `deals` AS `Deal` ON (`Ticket`.`deal_id` =
> > `Deal`.`id`) LEFT JOIN `items` AS `Item` ON (`Deal`.`item_id` =
> > `Item`.`id`) WHERE `Ticket`.`user_id` = 1
>
> > I tried binding item to deal, and CakePHP made 200 queries instead.
> > That didn't work too well.
> > Any ideas how I could make a slim query with CakePHP, without using
> > query()?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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
-~--~~~~--~~--~--~---



Simple binding question.

2008-01-18 Thread phpjoy

I wonder how I could make a simple query to work through bind(), and
not use a custom query.

I'm binding two models for a model:
$this->Ticket->bindModel(array('belongsTo' => array('Deal' =>
array('foreignKey' => 'deal_id';
$this->Ticket->bindModel(array('belongsTo' => array('Item' =>
array('foreignKey' => 'deal_id';

The resulting query I get is this:
SELECT `Ticket`.`id`, `Deal`.`file`, `Item`.`title` FROM `tickets` AS
`Ticket` LEFT JOIN `deals` AS `Deal` ON (`Ticket`.`deal_id` =
`Deal`.`id`) LEFT JOIN `items` AS `Item` ON (`Ticket`.`deal_id` =
`Item`.`id`) WHERE `Ticket`.`user_id` = 1

Now, instead of:
`Item` ON (`Ticket`.`deal_id` = `Item`.`id`)
I need:
`Item` ON (`Deal`.`item_id` = `Item`.`id`)

Which gives this query:
SELECT `Ticket`.`id`, `Deal`.`file`, `Item`.`title` FROM `tickets` AS
`Ticket` LEFT JOIN `deals` AS `Deal` ON (`Ticket`.`deal_id` =
`Deal`.`id`) LEFT JOIN `items` AS `Item` ON (`Deal`.`item_id` =
`Item`.`id`) WHERE `Ticket`.`user_id` = 1

I tried binding item to deal, and CakePHP made 200 queries instead.
That didn't work too well.
Any ideas how I could make a slim query with CakePHP, without using
query()?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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 Component encrypting password before validation.

2008-01-18 Thread phpjoy

nate, someone could want to use other hashing methods and not the
default one.
i vote for enabling :)

and adding the last crypt component to cake :D

On Jan 18, 6:18 am, nate <[EMAIL PROTECTED]> wrote:
> No.  Disabling password hashing is Evil with a capital "E".  That's
> why I don't let you do it.
>
> On Jan 17, 11:03 am, dizz <[EMAIL PROTECTED]> wrote:
>
> > Thanks to both of you, I thought of this, but I thought it would be
> > easier to disable the AuthComponent::hashPasswords and then do what
> > Baz did above.
>
> > Anyways thanks again for the help.
>
> > -Andrew
>
> > On Jan 17, 10:45 pm, Baz <[EMAIL PROTECTED]> wrote:
>
> > > Yep,
>
> > > Use a different field, eg. new_password or something. (I'm assuming
> > > you're validating when creating a password. No need for login)
>
> > > Here's assuming you have a model called User:
>
> > > // needed for validation for some reason
> > > $this->User->set($this->data);
> > > if ($this->validates($this->data))
> > > {
> > > $this->data['User']['passwd'] =
> > > $this->Auth->password($this->data['User']['new_passwd'] )
>
> > > // all we did was hash passwords, no need to revalidate.
> > > if ($this->save($this->data, false))
> > > {
> > > //do stuff
> > > } else
> > > {
> > > // invalid
> > > }
>
> > > }
>
> > > Would be nice to stick this is beforeSave in the model, but you can't
> > > [easily] access the Auth component from the model.
>
> > > Hope this helps.
>
> > > On Jan 17, 2008 9:31 AM, dizz <[EMAIL PROTECTED]> wrote:
>
> > > > Hello,
>
> > > > I am using the auth component and before my model can validate the
> > > > password the auth component already encrypts the password so making it
> > > > impossible to use the between built in valid method.
>
> > > > Is there any work around for this?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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
-~--~~~~--~~--~--~---



Ok, I nailed it.. It's a unicode problem!

2008-01-15 Thread phpjoy
http://groups.google.com/group/cake-php/browse_thread/thread/610bc62336c1cb4b/2724fab26d98b9af?lnk=gst&q=validation+between#2724fab26d98b9af

working on a solution :)

phpjoy wrote:
> Hey all,
>
> I'm having some (probably stupid) validation error. The 'address'
> field always invalidates, regardless of the number of chars.
> I ought to add that it happens *only* on "update" (edit), the adding
> works perfectly!
>
>   var $validate = array(
>   'firstname' => array('rule' => array('between', 2, 
> 20),'message' =>
> 'יש להזין לפחות 2 תווים'),
>   'lastname' => array('rule' => array('between', 2, 20),'message' 
> =>
> 'יש להזין לפחות 2 תווים'),
>   'ssc' => array(
>   'number' => array('rule' => array('numeric'),'message' 
> => 'יש להזין
> תעודת זהות תקינה'),
>   'between'=> array('rule' => array('between', 5, 
> 12),'message' =>
> 'יש להזין תעודת זהות תקינה')),
>   'address' => array('rule' => array('between', 4, 20),'message' 
> =>
> 'יש להזין לפחות 4 תווים'),
>   'city' => array('rule' => array('between', 2, 20),'message' => 
> 'יש
> להזין לפחות 2 תווים'),
>   'zipcode' => array('rule' => array('numeric'),'allowEmpty' =>
> true,'message' => 'יש להזין מספרים בלבד'),
>   'pobox' => array('rule' => array('numeric'),'allowEmpty' =>
> true,'message' => 'יש להזין מספרים בלבד'),
>   'homephone_num' => array('rule' => array('between', 9, 
> 20),'message'
> => 'יש להזין מספר טלפון עם קידומת'),
>   'cellphone_num' => array('rule' => array('between', 10,
> 20),'message' => 'יש להזין לפחות 10 תווים')
>   );
>
> I might have messed up the validation somewhere.
>
> edit_profile.ctp has this line in it:
>
>   input('UserStaticProfile.address',
> array('maxlength'=>20, 'class' => 'inputbox', 'label' => 'כתובת'));?>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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
-~--~~~~--~~--~--~---



Validation error, what am I missing?

2008-01-14 Thread phpjoy
Hey all,

I'm having some (probably stupid) validation error. The 'address'
field always invalidates, regardless of the number of chars.
I ought to add that it happens *only* on "update" (edit), the adding
works perfectly!

var $validate = array(
'firstname' => array('rule' => array('between', 2, 
20),'message' =>
'יש להזין לפחות 2 תווים'),
'lastname' => array('rule' => array('between', 2, 20),'message' 
=>
'יש להזין לפחות 2 תווים'),
'ssc' => array(
'number' => array('rule' => array('numeric'),'message' 
=> 'יש להזין
תעודת זהות תקינה'),
'between'=> array('rule' => array('between', 5, 
12),'message' =>
'יש להזין תעודת זהות תקינה')),
'address' => array('rule' => array('between', 4, 20),'message' 
=>
'יש להזין לפחות 4 תווים'),
'city' => array('rule' => array('between', 2, 20),'message' => 
'יש
להזין לפחות 2 תווים'),
'zipcode' => array('rule' => array('numeric'),'allowEmpty' =>
true,'message' => 'יש להזין מספרים בלבד'),
'pobox' => array('rule' => array('numeric'),'allowEmpty' =>
true,'message' => 'יש להזין מספרים בלבד'),
'homephone_num' => array('rule' => array('between', 9, 
20),'message'
=> 'יש להזין מספר טלפון עם קידומת'),
'cellphone_num' => array('rule' => array('between', 10,
20),'message' => 'יש להזין לפחות 10 תווים')
);

I might have messed up the validation somewhere.

edit_profile.ctp has this line in it:

  input('UserStaticProfile.address',
array('maxlength'=>20, 'class' => 'inputbox', 'label' => 'כתובת'));?>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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: XHR calls and an Auth problem - [security risk?]

2007-11-30 Thread phpjoy

I checked my application, and I found the origin + fix. In the file
routes.php:
Router::connect('/pages/*', array('controller' => 'pages', 'action'
=> 'display'));
Router::connect('/sections/', array('controller' => 'sections',
'action' => 'index', 'prefix' => Configure::read('Routing.admin')));

My old file was without the 'prefix' key. That fixed the problem. Any
ideas why?

On Nov 30, 12:59 pm, AD7six <[EMAIL PROTECTED]> wrote:
> On Nov 30, 11:46 am, phpjoy <[EMAIL PROTECTED]> wrote:
>
>
>
> > I'm experiencing a VERY weird auth problem, which is a very big
> > security risk for my application.
>
> > When I try to access a page in the admin section directly, I'm being
> > redirected to the login page.
> > When I try to do the same via an XHR call, the page is loaded!
>
> > Example:
> > When I try to access the URLhttp://localhost/admin/sections/edit/1294
> > I get redirected tohttp://localhost/admin/login
>
> > When the program accesses the same URL, it loads the page.
> > Any ideas why it happens?
>
> > Here's my auth setup:
> > function auth() {
> > $this->controller->Auth->userScope = array( 
> > 'AdminUser.active' =>
> > '1' );
> > $this->controller->Auth->userModel = 'AdminUser';
> > $this->controller->Auth->loginAction='/' 
> > .Configure::read('Routing.admin') .'/login/';
>
> > $this->controller->Auth->loginRedirect='/' 
> > .Configure::read('Routing.admin') .'/';
>
> > $this->controller->Auth->authorize = false;
> > $this->controller->Auth->sessionKey = 'AdminUser';
> > }
>
> > Here are the headers, checked by FireBug:
>
> > Response Headers
> > ==
> > DateFri, 30 Nov 2007 10:30:54 GMT
> > Server  Apache/2.2.4 (Win32) DAV/2 mod_ssl/2.2.4 OpenSSL/0.9.8e
> > mod_autoindex_color PHP/5.2.3
> > X-Powered-ByPHP/5.2.3
> > P3P CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"
> > Pragma  no-cache
> > Cache-Control   no-store, no-cache, max-age=0, must-revalidate
> > Content-Length  719
> > Keep-Alive  timeout=5, max=97
> > Connection  Keep-Alive
> > Content-Typetext/html
>
> > Request Headers
> > =
> > Hostlocalhost
> > User-Agent  Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:
> > 1.8.1.10) Gecko/20071115 Firefox/2.0.0.10
> > Accept  text/xml,application/xml,application/xhtml+xml,text/
> > html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
> > Accept-Language en-us,en;q=0.7,he;q=0.3
> > Accept-Encoding gzip,deflate
> > Accept-Charset  ISO-8859-1,utf-8;q=0.7,*;q=0.7
> > Keep-Alive  300
> > Connection  keep-alive
> > X-Requested-WithXMLHttpRequest
> > Refererhttp://localhost/admin/
> > Cookie  ProgramName=77254f4fb7cf56b71b28f6708f9a
> > Pragma  no-cache
> > Cache-Control   no-cache
>
> > If I request it through an HTTP data proxy, it doesn't load. Here are
> > the headers:
> > Response Headers
> > ==
> > DateFri, 30 Nov 2007 10:43:57 GMT
> > Server  Apache/2.2.4 (Win32) DAV/2 mod_ssl/2.2.4 OpenSSL/0.9.8e
> > mod_autoindex_color PHP/5.2.3
> > X-Powered-ByPHP/5.2.3
> > P3P CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"
> > Pragma  no-cache
> > Cache-Control   no-store, no-cache, max-age=0, must-revalidate
> > Locationhttp://localhost/admin/login/
> > Content-Length  0
> > Keep-Alive  timeout=5, max=95
> > Connection  Keep-Alive
> > Content-Typetext/html
>
> > Request Headers
> > 
> > Hostlocalhost
> > User-Agent  Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:
> > 1.8.1.10) Gecko/20071115 Firefox/2.0.0.10
> > Accept  */*
> > Accept-Language en-us,en;q=0.7,he;q=0.3
> > Accept-Encoding gzip,deflate
> > Accept-Charset  ISO-8859-1,utf-8;q=0.7,*;q=0.7
> > Keep-Alive  300
> > Connection  keep-alive
> > Refererhttp://localhost/admin/
> > Cookie  ProgramName=bc904aec5ff06a2d12bb6f334fde97ab
>
> > How can I make Auth check XHR calls?
>
> I doubt the Auth component cares how it receives a call, it's probably
> an app specific problem (if not provide a sample application which
> demonstrates the problem). Try having a look and investigatively debug
> the auth class, or stick some calls to $this-log($aVar); in your code
> to see if it´s bypassing the Auth class, or calling it and succeeding
> etc.
>
> hth,
>
> AD
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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
-~--~~~~--~~--~--~---



XHR calls and an Auth problem - [security risk?]

2007-11-30 Thread phpjoy

I'm experiencing a VERY weird auth problem, which is a very big
security risk for my application.

When I try to access a page in the admin section directly, I'm being
redirected to the login page.
When I try to do the same via an XHR call, the page is loaded!

Example:
When I try to access the URL
http://localhost/admin/sections/edit/1294
I get redirected to
http://localhost/admin/login

When the program accesses the same URL, it loads the page.
Any ideas why it happens?

Here's my auth setup:
function auth() {
$this->controller->Auth->userScope = array( 'AdminUser.active' 
=>
'1' );
$this->controller->Auth->userModel = 'AdminUser';
$this->controller->Auth-
>loginAction='/' .Configure::read('Routing.admin') .'/login/';
$this->controller->Auth-
>loginRedirect='/' .Configure::read('Routing.admin') .'/';
$this->controller->Auth->authorize = false;
$this->controller->Auth->sessionKey = 'AdminUser';
}


Here are the headers, checked by FireBug:

Response Headers
==
DateFri, 30 Nov 2007 10:30:54 GMT
Server  Apache/2.2.4 (Win32) DAV/2 mod_ssl/2.2.4 OpenSSL/0.9.8e
mod_autoindex_color PHP/5.2.3
X-Powered-ByPHP/5.2.3
P3P CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"
Pragma  no-cache
Cache-Control   no-store, no-cache, max-age=0, must-revalidate
Content-Length  719
Keep-Alive  timeout=5, max=97
Connection  Keep-Alive
Content-Typetext/html


Request Headers
=
Hostlocalhost
User-Agent  Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:
1.8.1.10) Gecko/20071115 Firefox/2.0.0.10
Accept  text/xml,application/xml,application/xhtml+xml,text/
html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language en-us,en;q=0.7,he;q=0.3
Accept-Encoding gzip,deflate
Accept-Charset  ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive  300
Connection  keep-alive
X-Requested-WithXMLHttpRequest
Referer http://localhost/admin/
Cookie  ProgramName=77254f4fb7cf56b71b28f6708f9a
Pragma  no-cache
Cache-Control   no-cache



If I request it through an HTTP data proxy, it doesn't load. Here are
the headers:
Response Headers
==
DateFri, 30 Nov 2007 10:43:57 GMT
Server  Apache/2.2.4 (Win32) DAV/2 mod_ssl/2.2.4 OpenSSL/0.9.8e
mod_autoindex_color PHP/5.2.3
X-Powered-ByPHP/5.2.3
P3P CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"
Pragma  no-cache
Cache-Control   no-store, no-cache, max-age=0, must-revalidate
Locationhttp://localhost/admin/login/
Content-Length  0
Keep-Alive  timeout=5, max=95
Connection  Keep-Alive
Content-Typetext/html

Request Headers

Hostlocalhost
User-Agent  Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:
1.8.1.10) Gecko/20071115 Firefox/2.0.0.10
Accept  */*
Accept-Language en-us,en;q=0.7,he;q=0.3
Accept-Encoding gzip,deflate
Accept-Charset  ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive  300
Connection  keep-alive
Referer http://localhost/admin/
Cookie  ProgramName=bc904aec5ff06a2d12bb6f334fde97ab


How can I make Auth check XHR calls?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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: Admin Routing, problem upgrading (using )

2007-11-09 Thread phpjoy

i overlooked that one, thank you


On Nov 9, 1:20 pm, AD7six <[EMAIL PROTECTED]> wrote:
> On Nov 9, 9:46 am, phpjoy <[EMAIL PROTECTED]> wrote:
>
>
>
> > Hey,
>
> > I upgraded from CakePHP 1.2alpha to 1.2pre-beta 1.
>
> > My admin routing stopped working:
> > My old routing is: (in routes.php)
> > Router::connect('/admin/', array('controller' => 'backend_home',
> > 'action'=> 'home', 'admin'=>1));
>
> > core.php:
> > Configure::write('Routing.admin', 'admin');
>
> > inside the controller:
> > function admin_home() {
> > $this->set('title', 'Main');
> > }
>
> see the release announcements and/or the router testcase. you need to
> add 'prefix' => 'admin'
>
> hth,
>
> AD


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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
-~--~~~~--~~--~--~---



Admin Routing, problem upgrading (using )

2007-11-09 Thread phpjoy

Hey,

I upgraded from CakePHP 1.2alpha to 1.2pre-beta 1.

My admin routing stopped working:
My old routing is: (in routes.php)
Router::connect('/admin/', array('controller' => 'backend_home',
'action'=> 'home', 'admin'=>1));

core.php:
Configure::write('Routing.admin', 'admin');

inside the controller:
function admin_home() {
$this->set('title', 'Main');
}


The Error:
Missing Method in BackendHomeController
You are seeing this error because the action home is not defined in
controller BackendHomeController


I think it's a problem in routing.php:
Router::connect('/admin/', array('controller' => 'backend_home',
'action'=> 'home', 'admin'=>1));
What should it be?

Thanks in advanced


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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
-~--~~~~--~~--~--~---



Using the Paginator helper with 2 models in a view.

2007-09-02 Thread phpjoy

in my index.ctp I have the following code:
sort('Title', 'title');?>
sort('Layout Name', 'LayoutWidget.name');?
>

When I try to sort the table in the column 'title' it works like a
charm.
When I try to sort the Layout Name column, it works just for 'asc'.
When I want to click it again, the direction stays on 'asc' instead of
'desc'.

Any ideas how I can fix this?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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
-~--~~~~--~~--~--~---



Weird slowness problem.

2007-08-31 Thread phpjoy

Hey,

I have a weird slowness problem on my machine.
I use MySQL 5, PHP 5.2x. It's the xampp server installation.

I have a very weird problem, my cake page loads up super-slow.
I have a new computer, E6750 2g mem. 1 page takes about 3 seconds to
load.

On my old machine (2 ghz p4), everytime I loaded a page, it took 3
seconds for the page to load. There is no difference between the
machines.
On my remote host, it also takes 3 seconds for the site to load.
Sometimes less.

On the remote/my machine, if I load 1 page or 8 at the same time, it
doesn't matter. It's still the same time.

I have plenty of memory, and the CPU power isn't maxed out at all.

How come it runs so slow?
Can I make it run faster?

There is no difference between debug 0 and debug 1.

Happy weekend!


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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: Advanced pagination problem. (Calling another controller by request handler)

2007-08-23 Thread phpjoy

Resolved:
In the new controller, I added these line to the index function:

function admin_index() {
$this->paginate = array('limit' => 20);
if(!isset($this->params['pass']['sort'])) $this->paginate['options']
['sort'] = 'created';
else $this->paginate['options']['sort'] = $this->params['pass']
['sort'];
if(isset($this->params['pass']['direction'])) $this-
>paginate['options']['direction'] = $this->params['pass']
['direction'];

$this->paginate['options']['controller']='sections';
$this->paginate['options']['action']='view';
$this->paginate['options'][]=$this->params['pass']['section'];
}


On Aug 24, 6:12 am, phpjoy <[EMAIL PROTECTED]> wrote:
> I have a URL calling a controller, and that controller is calling
> ANOTHER controller by requestAction.
>
> This is the URL I 
> have:http://localhost/admin/sections/view/175/page:1/sort:file/direction:asc
>
> I send the parameters to the new controller, and everything but the
> direction works fine.
>
> When I click on the paginated link, it keeps putting "ASC" for the
> options and not "DESC".
>
> If I change the URL to desc *manually*, it works.
> URL:http://localhost/admin/sections/view/175/page:1/sort:file/direction:desc
>
> However, if it queries the DB for ASC, I'll still get 'ASC' on the
> options [which isn't what's desired].
>
> Any ideas?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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
-~--~~~~--~~--~--~---



Advanced pagination problem. (Calling another controller by request handler)

2007-08-23 Thread phpjoy

I have a URL calling a controller, and that controller is calling
ANOTHER controller by requestAction.

This is the URL I have:
http://localhost/admin/sections/view/175/page:1/sort:file/direction:asc

I send the parameters to the new controller, and everything but the
direction works fine.

When I click on the paginated link, it keeps putting "ASC" for the
options and not "DESC".

If I change the URL to desc *manually*, it works.
URL: http://localhost/admin/sections/view/175/page:1/sort:file/direction:desc


However, if it queries the DB for ASC, I'll still get 'ASC' on the
options [which isn't what's desired].

Any ideas?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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
-~--~~~~--~~--~--~---



Removing the auto-loaded helpers.

2007-08-20 Thread phpjoy

I remember I read somewhere that the HTML helper (and maybe pagination
one) are automatically loaded when CakePHP starts unless it's being
specifically told not to.

How can I remove the auto-loaded helpers?
Are there more stuff that are auto-loaded I should know about? :+)


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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: wrong find usage, or a bug when binding a model to a model?

2007-08-14 Thread phpjoy

Alrights, here are my errors:
1) I tried associating two models instead of 1.
2) Your remark on building web applications fast really helped me. I
waste about 5-10% of my time now optimizing these things, and now I
realize I shouldn't [maybe far later].

Again optimization..:
LoadModel takes more time than a bind, doesn't it?

http://bin.cakephp.org/view/1965044820
Here's the code I use. This is the most complex query I have in my
software.
It's a component, calling a model through a controller.

The end result:
field Section.section_id gets the fields TemplateLayout.style and
Template.directory


On Aug 13, 3:28 pm, Grant Cox <[EMAIL PROTECTED]> wrote:
> This is not a bug.  Unless the query generated includes a join to the
> TemplateLayout model's table, then you cannot include those fields.
> What associations are there between the three models?  Since Cake's
> JOINS will only join a single association, it may be possible for you
> to query the Layout model (with the Layout's section_id, if it has
> one), and so in one query bring in the TemplateLayout.style.
>
> But realistically, don't worry if your query also gets a few extra
> fields.  I am sure that it will not be the performance bottleneck in
> your application - and Cake is about building applications quickly (ie
> code everything the simple / straightforward way - don't try to
> "optimize" things that don't need to).
>
> Since you say it works in recursive 2 these points probably just
> relate to your poor posting style.
>
> 1.  What is with $this->controller->$model->Section ?  You should be
> using just $this->Section in your controller
> 2.  If you want to bind Section to Layout, either do it in the
> Section's inline associations, or if you must use bindModel, do it
> properly:
> $this->Section->bindModel( array(
>   'hasMany'=>array(
> 'Layout'=>array( 'className' => 'Layout' )
>   )
> ) );


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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
-~--~~~~--~~--~--~---



wrong find usage, or a bug when binding a model to a model?

2007-08-13 Thread phpjoy

I call for a model with bindmodel. Then I bind another model to that
model.
$this->controller->$model->Section->Layout->bindModel

Section binds Layout, and Layout binds TemplateLayout.
With recursive is set to 2 on the model Section, I get all the results
I need. The problem Is that I get extra fields.

Here's my find request:
$this->controller->$model->Section->find(array('`Section`.`id`'=>
$section));

When I change the find request to include only the fields I want, I
get an error:
$this->controller->$model->Section->find(array('`Section`.`id`'=>
$section), array('TemplateLayout.style'));
Query: SELECT `TemplateLayout`.`style` FROM `0_sections` AS `Section`
LEFT JOIN `0_layouts` AS `Layout` ON (`Section`.`layout_id` =
`Layout`.`id`) WHERE `Section`.`id` = 255 LIMIT 1
SQL Error: 1054: Unknown column 'TemplateLayout.style' in 'field list'

Am I using it wrong?
Should I report a bug?

Using 1.2 lastest release (not nightly build)


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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
-~--~~~~--~~--~--~---



Security on high/medium

2007-08-11 Thread phpjoy

Where can I find the differences between medium/high security in 1.2?

Auth started acting crazy with external links until I set the security
to medium instead of high..


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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: host free for cake

2007-08-10 Thread phpjoy

i'd go for a 4$ host (CHEAP) or install mysql/apache on your own
computer with the "xampp" server.
free hosts i saw are crap..

On Aug 10, 4:24 pm, tuiBR <[EMAIL PROTECTED]> wrote:
> Please,
>
> somebody knows webserver free that run cakephp ?
>
> tranks!


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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: CAKE_SESSION_STRING - what it's behavior?

2007-08-10 Thread phpjoy

Just making sure.. :-)
Thank you.

By the way, I really enjoy your blog. It's a great piece of work.

On Aug 10, 2:05 pm, "Geoff Ford" <[EMAIL PROTECTED]> wrote:
> Nope size is not an issue here :)
>
> Geoff
>
> On 8/10/07, phpjoy <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > so it's size doesn't matter.. means each install i can put a random 10
> > letters number, sha256 it and wrap it up?
>
> > On Aug 10, 8:23 am, Geoff Ford <[EMAIL PROTECTED]> wrote:
> > > It is a random string that should be (near enough to) unique for your
> > > application.  It is used to salt hashes, seed rnd() and the like to
> > > improve security.
>
> > > Geoff
> > > --http://lemoncake.wordpress.com
>
> > > On Aug 10, 2:39 pm, phpjoy <[EMAIL PROTECTED]> wrote:
>
> > > > After messing around a bit with the Auth component, I got to
> > > > "CAKE_SESSION_STRING" for security usages.
>
> > > > I wonder which value it should hold.
> > > > I just put in random chars? is it an md5 value? other type of hashed
> > > > value? Should it have a number of chars?
>
> --http://lemoncake.wordpress.com


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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: Auth1.2 component not showing methods.

2007-08-10 Thread phpjoy

Ok I checked some more:

The Auth isAuthorized fails here:

function isAuthorized($type = null, $user = null, $object = null) {
if (empty($user) && !$this->user()) {//THIS IS CALLED, FAILS 
HERE.
return false;
}
}

So I went and checked the Auth->user() function and this was the
result:
function user($key = null) {
$this->__setDefaults();
if (!$this->Session->check($this->sessionKey)) {//THIS IS CALLED,
FAILS HERE.
return null;
}
}
Which means it doesn't recognize the user.

Then I noticed that no sessionKey was set.. So I set the session's
key.
$this->Auth->sessionKey = 'AdminUser';

Now it works. I thought Cake does that for me. :-)
thanks a lot for your precious help!

On Aug 10, 1:53 pm, "Dr. Tarique Sani" <[EMAIL PROTECTED]> wrote:
> On 8/10/07, phpjoy <[EMAIL PROTECTED]> wrote:
>
>
>
> > everything.
> > i tried:
> > $this->Auth->authorize = '*';
>
> This is not a valid option
>
> > and:
> > $this->Auth->authorize = 'controller';
>
> Ummm this typically goes in your app_controller beforeFilter -
> there are several ways you can use the auth component
>
> try -
>
> http://www.ogrn.com/andy/2007/07/10/auth-changes-in-cakephp-12-and-ho...
>
> or
>
> http://www.littlehart.net/atthekeyboard/2007/07/28/two-headed-applica...
>
> Also do note that the Auth component is bit of a moving target right now...
>
> HTH
> Tarique
>
> --
> =
> Cheesecake-Photoblog:http://cheesecake-photoblog.org
> PHP for E-Biz:http://sanisoft.com
> =


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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: Auth1.2 component not showing methods.

2007-08-10 Thread phpjoy

everything.
i tried:
$this->Auth->authorize = '*';
and:
$this->Auth->authorize = 'controller';

both in the users controller and in the "production controller".


On Aug 10, 7:18 am, "Dr. Tarique Sani" <[EMAIL PROTECTED]> wrote:
> On 8/10/07, phpjoy <[EMAIL PROTECTED]> wrote:
>
> > $this->Auth->userModel = 'AdminUser';
> > $this->Auth->loginAction='/' .CAKE_ADMIN .'/login/';
>
> What is the value for $this->Auth->authorize
>
> IOW - what are you using to authorize your actions?
>
> Possible values are actions, model, controller
>
> Tarique
>
> --
> =
> Cheesecake-Photoblog:http://cheesecake-photoblog.org
> PHP for E-Biz:http://sanisoft.com
> =


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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: CAKE_SESSION_STRING - what it's behavior?

2007-08-10 Thread phpjoy

so it's size doesn't matter.. means each install i can put a random 10
letters number, sha256 it and wrap it up?


On Aug 10, 8:23 am, Geoff Ford <[EMAIL PROTECTED]> wrote:
> It is a random string that should be (near enough to) unique for your
> application.  It is used to salt hashes, seed rnd() and the like to
> improve security.
>
> Geoff
> --http://lemoncake.wordpress.com
>
> On Aug 10, 2:39 pm, phpjoy <[EMAIL PROTECTED]> wrote:
>
> > After messing around a bit with the Auth component, I got to
> > "CAKE_SESSION_STRING" for security usages.
>
> > I wonder which value it should hold.
> > I just put in random chars? is it an md5 value? other type of hashed
> > value? Should it have a number of chars?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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
-~--~~~~--~~--~--~---



Auth1.2 component not showing methods.

2007-08-09 Thread phpjoy

I setup the Auth component, and it's working great for the validation
stage.
If no session is found, it redirects to /admin/login/ just as it
should.

$this->Auth->userModel = 'AdminUser';
$this->Auth->loginAction='/' .CAKE_ADMIN .'/login/';

After I get validated (Goes to Users controller and Login method) ->
It redirects to the last page (as it should).

Then, after the beforeFilter it sends me BACK to the Auth component ->
Even though it is validated and there's a session!

Here's a part of my session [trimmed]:
array(4) {
  ["AdminUser"]=>
  array(2) {
["id"]=>
string(1) "1"
["username"]=>
string(5) "yossi"
  }
  ["Auth"]=>
  array(1) {
["redirect"]=>
string(13) "admin/images/"
  }
}


How come the controller keeps redirecting me to the Auth component? Am
I doing something wrong/missing something?
* Using lastest Cake 1.2 Release

thanks,
yossi


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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
-~--~~~~--~~--~--~---



CAKE_SESSION_STRING - what it's behavior?

2007-08-09 Thread phpjoy

After messing around a bit with the Auth component, I got to
"CAKE_SESSION_STRING" for security usages.

I wonder which value it should hold.
I just put in random chars? is it an md5 value? other type of hashed
value? Should it have a number of chars?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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
-~--~~~~--~~--~--~---



Error Handling for big sites.

2007-08-08 Thread phpjoy

Let's say I have a big site application, should I do these kind of
error checking after component/model loading:

loadComponent('AdminSiteTree');
if(!class_exists('AdminSiteTreeComponent'))
$this->cakeError('internalError', null);

What do you say? What do you do in your projects?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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: edit skipping to add if no id is sent.

2007-08-07 Thread phpjoy

it's just one row in a table, i don't need an increase.. it's always
id=1.
the problem i had was that cakephp wanted an id, and wouldn't send to
"edit". if no id is found, it sends to the "add" method automatically,
so i bypassed it by changing the table.

--
yossi

On Aug 7, 3:47 pm, "Pablo Viojo" <[EMAIL PROTECTED]> wrote:
> Dear phpjoy,
>
> What do you mean with id=1? better use an autoincrement field.
>
> And please sign your messages (at least a nickname)
>
> --
> Pablo Viojo
> [EMAIL PROTECTED]://pviojo.net
>
> On 8/7/07, phpjoy <[EMAIL PROTECTED]> wrote:
>
>
>
> > well, figuring out how it works, i decided to say..
> > "fuck it, i'll just add an "id=1" to the table.
>
> > by the way, where does it happen, this redirection?
> > it didn't even get to the method, as if a before filter exists or
> > something else in the core of cakephp.
>
> > On Aug 7, 11:21 am, Geoff Ford <[EMAIL PROTECTED]> wrote:
> > > Put an id in - cake needs it to write the update statement.  It
> > > doesn't have to be 'id', just use var $primaryKey = 'some field';
>
> > > Geoff
> > > --http://lemoncake.wordpress.com
>
> > > On Aug 7, 12:21 am, phpjoy <[EMAIL PROTECTED]> wrote:
>
> > > > i also wonder, where does this redirect happen in cake?
> > > > dispatcher? before?
> > > > class/method would be great :)
>
> > > > On Aug 7, 8:51 am, phpjoy <[EMAIL PROTECTED]> wrote:
>
> > > > > i have a table in my database that doesn't need an id, it's only 1 row
> > > > > stored in the DB.
>
> > > > > i want to edit that row, and whenever i try to edit it -> i get thrown
> > > > > to add.http://localhost/admin/config/edit
> > > > > redirects tohttp://localhost/admin/config/add
> > > > > and gives me this error:
> > > > > Missing Method in ConfigController
> > > > > You are seeing this error because the action admin_add is not defined
> > > > > in controller ConfigController
>
> > > > > how can i bypass this?
> > > > > it doesn't even reach the edit method at the second time, it tries to
> > > > > search even before it got to the function.
>
> > > > > do you guys have other good techniques out there?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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: edit skipping to add if no id is sent.

2007-08-07 Thread phpjoy

well, figuring out how it works, i decided to say..
"fuck it, i'll just add an "id=1" to the table.

by the way, where does it happen, this redirection?
it didn't even get to the method, as if a before filter exists or
something else in the core of cakephp.

On Aug 7, 11:21 am, Geoff Ford <[EMAIL PROTECTED]> wrote:
> Put an id in - cake needs it to write the update statement.  It
> doesn't have to be 'id', just use var $primaryKey = 'some field';
>
> Geoff
> --http://lemoncake.wordpress.com
>
> On Aug 7, 12:21 am, phpjoy <[EMAIL PROTECTED]> wrote:
>
> > i also wonder, where does this redirect happen in cake?
> > dispatcher? before?
> > class/method would be great :)
>
> > On Aug 7, 8:51 am, phpjoy <[EMAIL PROTECTED]> wrote:
>
> > > i have a table in my database that doesn't need an id, it's only 1 row
> > > stored in the DB.
>
> > > i want to edit that row, and whenever i try to edit it -> i get thrown
> > > to add.http://localhost/admin/config/edit
> > > redirects tohttp://localhost/admin/config/add
> > > and gives me this error:
> > > Missing Method in ConfigController
> > > You are seeing this error because the action admin_add is not defined
> > > in controller ConfigController
>
> > > how can i bypass this?
> > > it doesn't even reach the edit method at the second time, it tries to
> > > search even before it got to the function.
>
> > > do you guys have other good techniques out there?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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: edit skipping to add if no id is sent.

2007-08-07 Thread phpjoy

i also wonder, where does this redirect happen in cake?
dispatcher? before?
class/method would be great :)

On Aug 7, 8:51 am, phpjoy <[EMAIL PROTECTED]> wrote:
> i have a table in my database that doesn't need an id, it's only 1 row
> stored in the DB.
>
> i want to edit that row, and whenever i try to edit it -> i get thrown
> to add.http://localhost/admin/config/edit
> redirects tohttp://localhost/admin/config/add
> and gives me this error:
> Missing Method in ConfigController
> You are seeing this error because the action admin_add is not defined
> in controller ConfigController
>
> how can i bypass this?
> it doesn't even reach the edit method at the second time, it tries to
> search even before it got to the function.
>
> do you guys have other good techniques out there?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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
-~--~~~~--~~--~--~---



edit skipping to add if no id is sent.

2007-08-06 Thread phpjoy

i have a table in my database that doesn't need an id, it's only 1 row
stored in the DB.

i want to edit that row, and whenever i try to edit it -> i get thrown
to add.
http://localhost/admin/config/edit
redirects to
http://localhost/admin/config/add
and gives me this error:
Missing Method in ConfigController
You are seeing this error because the action admin_add is not defined
in controller ConfigController

how can i bypass this?
it doesn't even reach the edit method at the second time, it tries to
search even before it got to the function.


do you guys have other good techniques out there?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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: Check mod_rewite through programming

2007-08-03 Thread phpjoy

no need to work hard:
google.com: php.net modules apache
http://il.php.net/apache [this was the first sub-result] (PHP: Apache-
specific Functions - Manual)
http://il.php.net/manual/en/function.apache-get-modules.php (after
reading the page..)



On Aug 2, 5:00 pm, "Sascha Fröhlich" <[EMAIL PROTECTED]>
wrote:
> Damn...
> phpinfo() spits out some information about apache2handler, take a look at
> "loaded modules"...
> perhaps you can parse the output, see this page:http://de3.php.net/phpinfo
>
> Regards,
> Sascha
>
> 2007/8/2, Sascha Fröhlich <[EMAIL PROTECTED]>:
>
>
>
> > Hi there,


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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: Cake PHP Book

2007-08-02 Thread phpjoy

Are you sure summer 2008 is good for 1.2?
I assume that in summer 2008 there will be 2.0 alpha.. Which leads to
a beta soon after!
Which means you might want to release a the book for the 2.0 beta?

Not that I have any idea of the CakePHP timeline dates.. but you might
wanna consult the foundation.

On Aug 1, 12:10 pm, Sarat Pediredla <[EMAIL PROTECTED]> wrote:
> Just a shout out to the community that I will be writing a book for
> CakePHP 1.2 which will be due out Summer 2008. Our company has been
> working with CakePHP from 1.1 and after building many apps and writing
> custom hacks to the frameworks for ages (which are thankfully resolved
> in 1.2), we decided to make sure the community gets the documentation
> it deserves.
>
> I doubt it would be as good as a book coming from the CakePHP creators
> but it is better their focus remains on the actual code and API.
> Hopefully, the book effort can complement this. And hopefully a nice
> share to the foundation from the book revenue when it hits the
> shelves.
>
> If anyone wants to discuss this or has any comments/feedback, please
> drop me a line.
>
> Sarat Pediredlahttp://hedgehoglab.com


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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: Cake PHP running dead slow

2007-07-30 Thread phpjoy

i think that he ment to use the bindmodel() instead of loading a new
model..

user->profile->func();
instead of
loadModel('user');
loadModel('profile');

i wondered what's the performance difference.

On Jul 30, 1:30 am, Grant Cox <[EMAIL PROTECTED]> wrote:
> On Jul 29, 4:45 pm, housebolt <[EMAIL PROTECTED]> wrote:
>
> > $uses is evil and should be sparsely used.
>
> Do you have any benchmarks to back this up, or any comments from the
> core Cake developers (ie PHPNut or Nate) to this effect?  I have not
> heard this before, and it sounds like FUD.  I use loadModel heavily in
> my code and do not notice any particular performance hit (and afaik
> loadModel is basically the same as $uses).  Cake model instances are
> cached in the ClassRegistry, and I was under the impression these
> existing instances were used for associations and $uses where
> possible.
>
> Certainly there is some performance hit to loading in Model classes
> (and it shouldn't be done unnecessarily), but unless you have some
> further proof I don't believe this is any worse whether they are
> loaded through associations, through $uses, or through loadModel.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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: Cake PHP running dead slow

2007-07-29 Thread phpjoy

housebolt, how slow is $uses?

i should treat 'loadModel()' with the same care ['stay away as much as
you can']?
how slow does it make the production software?

On Jul 29, 8:45 am, housebolt <[EMAIL PROTECTED]> wrote:
> It probably is your server. I ran a couple of apps on a godaddy shared
> server (with CGI) and the load on the server was already so high that
> adding a large app load on top of all of it made the thing slow, but
> not nearly as slow as what you've got going. I used to have an app
> with about 30 tables running clean and smooth on a shared server, it's
> just a matter of how efficient your code is and how fast your mysql
> server is responding to requests.
>
> Also, you'll want to check that you're not using var $uses heavily in
> your controllers. For example you'll want to use 
> $this->Users->Profile->read() instead of using var $uses = array('Users', 
> 'Profile'); (and
>
> $this->Profile->read()). $uses is evil and should be sparsely used.
>
> Last but not least, try setting debug to '0' in /app/config/core.php.
> Cake will do some automagical caching to speed things up a bit.
>
> But all in all, I'd recommend getting a new server. I run pretty much
> everything these days on mediatemple (mediatemple.com). Check them
> out, they've got a great setup.
>
> On Jul 28, 7:47 pm, "AzGhanv/." <[EMAIL PROTECTED]> wrote:
>
> > Just need to confirm... is there some known issue of cake with
> > Apache1.3/CGI .
> > i have also asked server hosting company to check load.
> > sometimes it takes 2-3s and sometimes 20-60s for php exec.
>
> > plz reply if someone have any idea ...
>
> > On Jul 28, 11:44 pm, "AzGhanv/." <[EMAIL PROTECTED]> wrote:
>
> > > Hi,
>
> > > Cake PHP is running dead slow on production server, plz check it
> > > yourself ...http://www.voiceofkhanqah.com, On load, at bottom of page it 
> > > shows ...
> > > 
>
> > > For phpinfo() ...http://www.voiceofkhanqah.com/afnan.php
>
> > > For debug level 3 logs of main page ...
> > > -
> > > 3 queries took 57 ms
> > > Nr Query Error Affected Num. rows Took (ms)
> > > 1 DESCRIBE `majalis`  6 6 18
> > > 2 DESCRIBE `users`  5 5 29
> > > 3 SELECT `Majlis`.`id`, `Majlis`.`title`, `Majlis`.`start_time`,
> > > `Majlis`.`end_time`, `Majlis`.`status`, `Majlis`.`weekdays` FROM
> > > `majalis` AS `Majlis` WHERE status=1   5 5 10
>
> > > other static content (htm) on same server runs comparatively faster 
> > > ..http://www.voiceofkhanqah.com/old/
>
> > > please reply what i m missing, thanks in advance.
>
> > > Afnan.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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: bindmodel and the paginator not working / trac ticket 2201

2007-07-26 Thread phpjoy

slap me and call me silly!

i actually left this and got back to the ticket a few days ago. my
mind DELETED the "=true".. i actually looked at the API before, twice.
silly me :)

thanks for pointing me!

On Jul 25, 4:29 pm, AD7six <[EMAIL PROTECTED]> wrote:
> On Jul 25, 12:21 pm, phpjoy <[EMAIL PROTECTED]> wrote:
>
> > you mean:
> > $this->WidgetMenu->bindModel(
> > array('hasOne' => array(
> > 'ModelName' => array(
> > 'className' => 'ModelName',
> > )
> > ),
> >   ), true);
> > i tried that, it doesn't work..
>
> So in a week, you didn't look at the core code or api? I don't mean to
> sound accusative, but why not?
>
> https://trac.cakephp.org/browser/branches/1.2.x.x/cake/libs/model/mod...
>
> AD


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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: bindmodel and the paginator not working / trac ticket 2201

2007-07-25 Thread phpjoy

you mean:
$this->WidgetMenu->bindModel(
array('hasOne' => array(
'ModelName' => array(
'className' => 'ModelName',
)
),
  ), true);
i tried that, it doesn't work.. i didn't get what's the second
parameter (unless it's the 'true' after the array..).

On Jul 19, 8:29 am, AD7six <[EMAIL PROTECTED]> wrote:
> On Jul 19, 6:17 am, phpjoy <[EMAIL PROTECTED]> wrote:
>
> > nobody has an idea how to make the pagination work with bindmodel
> > instead of static models?
>
> You use the second parameter in bindModel to make the new association
> persist. Like what gwoo and phpNut said in the ticket comments.
>
> AD


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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: bindmodel and the paginator not working / trac ticket 2201

2007-07-18 Thread phpjoy

nobody has an idea how to make the pagination work with bindmodel
instead of static models?

On Jul 18, 12:06 am, phpjoy <[EMAIL PROTECTED]> wrote:
> https://trac.cakephp.org/ticket/2201
>
> regarding this trac ticket:
> Controller::paginate() bug with un/binding [patch included]
>
> it's not a bug, so how can i get the paginator to work with bindmodel
> (or that's not possible?)
> it works great if i use var $belongsTo in the model instead of
> bindmodel.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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
-~--~~~~--~~--~--~---



bindmodel and the paginator not working / trac ticket 2201

2007-07-17 Thread phpjoy

https://trac.cakephp.org/ticket/2201

regarding this trac ticket:
Controller::paginate() bug with un/binding [patch included]

it's not a bug, so how can i get the paginator to work with bindmodel
(or that's not possible?)
it works great if i use var $belongsTo in the model instead of
bindmodel.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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: $this->cakeError refuses to load a custom layout.

2007-07-17 Thread phpjoy

that's great to know, "errors always use the default layouts". :)
didn't see it in the manual..

thanks a tons for the solution.


On Jul 16, 7:52 pm, rtconner <[EMAIL PROTECTED]> wrote:
> Ah.. phpjoy, I had the same problem. There is no easy solution so far
> as I could find. No good solution that I liked anyways. Errors always
> use the default layout, and there is nothing you can do to change
> that.
>
> .. So.. the best solution as I could figure is this..
>
> Create /app/error.php and copy and paste ErrorHandler into it. Then
> modify it to read "class AppError extends ErrorHandler"
>
> The modify the file to handle dynamic layouts. Here I'll make it easy
> and just copy and past my (Cake 1.2) error.php file for you. Hope this
> helps.
>
> 
> 
> /**
>  * Override defaults cake error behavior
>  */
> class AppError extends ErrorHandler {
>
> var $layout = 'error';
>
> /**
>  * Displays an error page (e.g. 404 Not found).
>  *
>  * @param array $params Parameters for controller
>  * @access public
>  */
> function error($params) {
> extract($params);
> $this->controller->base = $base;
> $this->controller->webroot = $this->_webroot();
> $this->controller->viewPath='errors';
> $this->controller->set(array('code' => $code,
>   
>   'name' => $name,
>   
>   'message' => $message,
>   
>   'title' => $code . ' ' . $name));
> $this->controller->render('error404', $this->layout);
> exit();
> }
> /**
>  * Convenience method to display a 404 page.
>  *
>  * @param array $params Parameters for controller
>  * @access public
>  */
> function error404($params) {
> extract($params);
>
> if (!isset($url)) {
> $url = $action;
> }
> if (!isset($message)) {
> $message = '';
> }
> if (!isset($base)) {
> $base = '';
> }
>
> header("HTTP/1.0 404 Not Found");
> $this->error(array('code' => '404',
> 'name' => 'Not found',
> 'message' => 
> sprintf(__("The requested address %s was not found
> on this server.", true), $url, $message),
> 'base' => $base));
> exit();
> }
> /**
>  * Renders the Missing Controller web page.
>  *
>  * @param array $params Parameters for controller
>  * @access public
>  */
> function missingController($params) {
> extract(Router::getPaths());
> extract($params, EXTR_OVERWRITE);
>
> $this->controller->base = $base;
> $this->controller->webroot = $webroot;
> $this->controller->viewPath ='errors';
> $controllerName = str_replace('Controller', '', $className);
> $this->controller->set(array('controller' => $className,
>   
>   'controllerName' => $controllerName,
>   
>   'title' => __('Missing Controller', true)));
> $this->controller->render('missingController', $this->layout);
> exit();
> }
> /**
>  * Renders the Missing Action web page.
>  *
>  * @param array $params Parameters for controller
>  * @access public
>  */
> function missingAction($params) {
> extract(Router::getPaths());
> extract($params, EXTR_OVERWRITE);
>
> $this->controller->base = $base;
> $this->controller->webroot = $webroot;
> $this->controller->viewPath = 'errors';
>  

Re: $this->cakeError refuses to load a custom layout.

2007-07-16 Thread phpjoy

no ideas?
it's a bug? the normal behavior is loading a default layout?


On Jul 14, 6:32 pm, phpjoy <[EMAIL PROTECTED]> wrote:
> it seems like it won't load a custom layout for me.
>
> at first, i didn't have in app/views/layouts the file "default.ctp",
> and it loaded the default cakephp layout.
> so i added default.ctp to my layouts directory, and it loaded it.
>
> however i want a custom layout for my errors [from default.ctp], and i
> wonder how to do that.
> this is the code:
>
> //$this->layout='wetsummer10/default';
> //$this->layout='default/default';
> $this->layout='spark';
> $this->cakeError('error', array(array('name' => 'Page Was Not Found',
> 'code'=>'404', 'message'=>'Error Message', 'base'=>$this->base)));
>
> none worked, even if a layout IS set, it uses 'default.ctp'.
>
> any ideas?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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
-~--~~~~--~~--~--~---



$this->cakeError refuses to load a custom layout.

2007-07-14 Thread phpjoy

it seems like it won't load a custom layout for me.

at first, i didn't have in app/views/layouts the file "default.ctp",
and it loaded the default cakephp layout.
so i added default.ctp to my layouts directory, and it loaded it.

however i want a custom layout for my errors [from default.ctp], and i
wonder how to do that.
this is the code:

//$this->layout='wetsummer10/default';
//$this->layout='default/default';
$this->layout='spark';
$this->cakeError('error', array(array('name' => 'Page Was Not Found',
'code'=>'404', 'message'=>'Error Message', 'base'=>$this->base)));

none worked, even if a layout IS set, it uses 'default.ctp'.

any ideas?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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: Corrupted Image [file stored in filesystem, thumbnail ok!]

2007-07-07 Thread phpjoy

i figured out it's either apache or cakephp.. so wanted to make sure
it's not cake.

i'll setup a DB on a linux machine in the next few days to test it
out..
thanks

On Jul 7, 2:18 am, Grant Cox <[EMAIL PROTECTED]> wrote:
> Felix had a similar issue last year
>
> http://www.thinkingphp.org/2006/11/02/being-trapped-in-programmers-hell/http://www.thinkingphp.org/2006/11/03/windows-xp-apache-php-output-pr...
>
> But this was using php readfile() to pass the data, whereas yours is
> just apache.  In which case, try a different version of apache, try
> different files, try removing your .htaccess file (to see if
> mod_rewrite is causing something funky).  But from what you have
> mentioned, there is nothing about Cake that could be causing the
> problem.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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
-~--~~~~--~~--~--~---



Corrupted Image [file stored in filesystem, thumbnail ok!]

2007-07-06 Thread phpjoy

i have a problem with an image i use.
i upload the image, and it's alright on the file system. perfect.

when i load up the image from the server, it's corrupted.


the file on the DISK is perfectly fine.
it's just displayed wrong through apache.. it's completely weird!

for example, after the upload, this file shows correctly:
C:\xampp\htdocs\app\webroot\media\1\1\1\1\quan.jpg

while this url (which is the same file!) doesn't:
http://localhost/media/1/1/1/1/quan.jpg

moreover, the generated THUMBNAIL shows correctly!
and only the last part of the file shows corruptedly..

i assume it might be a caching problem/loading i'm unaware of.
any ideas?

[i use apache xampp server for windows]


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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: Paginate define columns to use (1.2)

2007-07-02 Thread phpjoy

did you try:
$this->ModelName->recursive = 0;
in the model?

On Jul 1, 5:13 pm, Mech7 <[EMAIL PROTECTED]> wrote:
> UnbindModel does also not seem to work :(
>
> // Remove HABTM on tags and categories
> $this->Article->unbindModel(array('hasAndBelongsToMany' =>
> array('Tag', 'Category')));
> // Find all articles
> $this->set('articles',  $this->paginate('Article'));


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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
-~--~~~~--~~--~--~---



Validation in 1.2 when field isn't in database.

2007-07-02 Thread phpjoy

when i try to validate a form's field that doesn't exist in the
database i get this error.
the validation works for fields that are in the database.

var $validate = array(
'imagedata' => array('No image uploaded.' => VALID_NOT_EMPTY),
);

that's the validation line. 'imagedata' is only in the form, and moved
later to the database.
then again, models should work with databases.. so is it the
controller's job to check it out?


Warning (2): preg_match() expects parameter 2 to be string, array
given [CORE\cake\libs\model\model.php, line 1744]

$this   =   Image object
$data   =   array("media_category_id" => "", "filename" => "", "name" =>
"", "description" => "", "imagedata" => array, "cuser" => 1)
$Validation =   Validation object
$ruleSet=   array("No image uploaded." => "/.+/")
$fieldName  =   "imagedata"
$validator  =   array("allowEmpty" => null, "required" => null, "rule" 
=>
"/.+/", "last" => false, "on" => null)
$index  =   "No image uploaded."
$default=   array("allowEmpty" => null, "required" => null, "rule" 
=>
"blank", "last" => false, "on" => null)
$message=   "This field cannot be left blank"
$rule   =   "/.+/"
$ruleParams =   array(0 => array)
$valid  =   true
$msg=   null
} elseif (method_exists($Validation, $rule)) {
$valid = call_user_func_array(array(&
$Validation, $rule), $ruleParams);
} elseif (!is_array($validator['rule'])) {
$valid = preg_match($rule,
$data[$fieldName]);
}

preg_match - [internal], line ??
Model::invalidFields() - CORE\cake\libs\model\model.php, line 1744
Model::validates() - CORE\cake\libs\model\model.php, line 1660
ImagesController::admin_add() - CORE\app\controllers
\images_controller.php, line 46
Dispatcher::_invoke() - CORE\cake\dispatcher.php, line 341
Dispatcher::dispatch() - CORE\cake\dispatcher.php, line 323
[main] - CORE\app\webroot\index.php, line 83


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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: cakeError - using international chars

2007-06-29 Thread phpjoy

digging up the code a bit..:
from the constructor of ErrorHandler (libs/error.php):
$allow = array('.', '/', '_', ' ', '-', '~');
if(substr(PHP_OS,0,3) == "WIN") {
$allow = array_merge($allow, array('\\', ':') );
}
$clean = new Sanitize();
$messages = $clean->paranoid($messages, $allow);

that means no international chars can be put inside a message..


On Jun 29, 10:56 am, phpjoy <[EMAIL PROTECTED]> wrote:
> hey,
>
> if i try to use cakeError with an international char, it simply
> ignores the information.
>
> for example:
> $this->cakeError('error', array(array('name' => 'PageNotFound',
> 'code'=>'404', 'message'=>'displayedmessage', 'base'=>$this->base)));
> works like a charm..
>
> while..
>
> $this->cakeError('error', array(array('name' => 'PageNotFound',
> 'code'=>'404', 'message'=>'הודעה', 'base'=>$this->base)));
> erases the data in the varible "message" and doesn't display anything.
>
> any ideas anyone?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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
-~--~~~~--~~--~--~---



cakeError - using international chars

2007-06-29 Thread phpjoy

hey,

if i try to use cakeError with an international char, it simply
ignores the information.

for example:
$this->cakeError('error', array(array('name' => 'PageNotFound',
'code'=>'404', 'message'=>'displayedmessage', 'base'=>$this->base)));
works like a charm..

while..

$this->cakeError('error', array(array('name' => 'PageNotFound',
'code'=>'404', 'message'=>'הודעה', 'base'=>$this->base)));
erases the data in the varible "message" and doesn't display anything.

any ideas anyone?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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: cake1.2 model validation

2007-06-27 Thread phpjoy

works like a charm.. here's the final code:

 var $validate = array(
'directory' => array('rule' => 'ValidFunc')
);

function ValidFunc($value) {
$this->data['ModelName']['fieldname']='new' .$value;
case 1: $this->invalidate('fieldname', 'message1'); return true;
case 2: $this->invalidate('fieldname', 'message2'); return true;
}

now here's the magic trick, in order to make it visible in the form in
the view i should..:
$this->data = $this->ModelName->data;
otherwise it doesn't get changed in the controller and then displayed
in the view.

is there a way to change it from the model itself?

On Jun 28, 1:05 am, francky06l <[EMAIL PROTECTED]> wrote:
> Yes, nice hack somehow :-)
> Thanks Geoff
>
> On Jun 28, 12:56 am, Geoff Ford <[EMAIL PROTECTED]> wrote:
>
> > Just took at look at the code and your right franky, after you return
> > false from your custom function invalidFields() then calls $this-
>
> > >invalidate() itself overwriting the message you just wrote.
>
> > However this is not the case if you return true.
>
> > This may be a bit "wrong" but you can get around this like so
>
> > function ValidFun($ruleParams){
> >   $fieldName = array_keys($ruleParams);
> >   $fieldName = $fieldName[0];
> >   if ($conditions){
> > // all validation passed
> >   } else {
> >// validation failed
> >$this->invalidate($fieldName, 'Your Error Message');
> >   }
>
> >   return true;
>
> > }
>
> > By always returning true invalidFields() will not set the error
> > message itself, but the Model::validationErrors will still contain the
> > invalid field with your error message and and so Model::validates()
> > will return the correct value of false.
>
> > On Jun 28, 8:45 am, francky06l <[EMAIL PROTECTED]> wrote:
>
> > > I am not sure that will work (I might be wrong) but it seems to me
> > > that the model->invalidate is called after your validFunc returning
> > > false (this call will oerwrite your message). I haven't tested,
> > > neither check the code deeply enough to know if the call to invalidate
> > > (into the validateField method) checks for an existing messages prior
> > > to call invalidate..
>
> > > Let me know :-)
> > > Thanks
>
> > > On Jun 28, 12:30 am, Geoff Ford <[EMAIL PROTECTED]> wrote:
>
> > > > Oops just reread the question.
>
> > > > To set the error message from within the ValidFunc you can use the
> > > > Model::invalidate($field, $value = null);
>
> > > > On Jun 28, 8:26 am, Geoff Ford <[EMAIL PROTECTED]> wrote:
>
> > > > > if believe that you can change the error message with
> > > > > var $validate = array(
> > > > > 'directory' => array('error_mesasage' =>
> > > > > array(array('rule' => 'ValidFunc', 'message'=>'message'))
> > > > > );
>
> > > > > On Jun 28, 5:32 am, francky06l <[EMAIL PROTECTED]> wrote:
>
> > > > > > I guess you can't do this using the model validation, but if your
> > > > > > validation function is in the current model, you could replace the
> > > > > > value $this->data['Model']['field'] and return true (in this way, 
> > > > > > this
> > > > > > will not be considered as an error).
> > > > > > If your goal is to correct the value, show it with a message, the
> > > > > > above is still valid (for the value) but I have no idea how to 
> > > > > > change
> > > > > > the message. You can have a look to the bakery (multiple 
> > > > > > validation),
> > > > > > Mariano has done work about validation messages into the view-side,
> > > > > > maybe there you could interact with it.
>
> > > > > > On Jun 27, 9:11 pm, phpjoy <[EMAIL PROTECTED]> wrote:
>
> > > > > > > ahoy,
>
> > > > > > > i have the following validation in a model:
> > > > > > > var $validate = array(
> > > > > > > 'directory' => array('rule' => 'ValidFunc', 
> > > > > > > 'message'=>'message')
> > > > > > > );
>
> > > > > > > function ValidFunc($value) {
> > > > > > > $newvalue = 'new' .$value;
> > > > > > > $value = $newvalue;
> > > > > > > case 1: /*message=1*/ return false;
> > > > > > > case 2: /*message=2*/ return false;
> > > > > > > }
>
> > > > > > > there are 2 things i'm struggling to do:
> > > > > > > 1) change the validation message from the ValidFunc,
> > > > > > > 2) change $value for the form to $newvalue.
>
> > > > > > > anyone knows how i can do that?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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
-~--~~~~--~~--~--~---



cake1.2 model validation

2007-06-27 Thread phpjoy

ahoy,

i have the following validation in a model:
var $validate = array(
'directory' => array('rule' => 'ValidFunc', 
'message'=>'message')
);

function ValidFunc($value) {
$newvalue = 'new' .$value;
$value = $newvalue;
case 1: /*message=1*/ return false;
case 2: /*message=2*/ return false;
}

there are 2 things i'm struggling to do:
1) change the validation message from the ValidFunc,
2) change $value for the form to $newvalue.

anyone knows how i can do that?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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: checking if a controller exists

2007-06-21 Thread phpjoy

but it will only check *after* the controller is loaded, i wanted to
check before it's loaded..
there's also a registryclass in the cake 1.2 i didn't really get into,
it might be better than class_exists if it holds all the classes index
there.

loading a controller straight through the code is faster than loading
a function through requestAction?


On Jun 19, 12:03 pm, kabturek <[EMAIL PROTECTED]> wrote:
> yo can always try class_exists() ;)http://php.net/class_exists
>
> greets,
>
> On Jun 19, 11:22 am, phpjoy <[EMAIL PROTECTED]> wrote:
>
> > thanks a lot, that pretty much sums it up..
> > i see the right way is to loadController. i might send a suggestion
> > about that.. there should be existsController or something like
> > that :)
>
> > On Jun 18, 4:56 pm, "Mariano Iglesias" <[EMAIL PROTECTED]>
> > wrote:
>
> > > function reachable($url) {
> > > $params = Router::parse($url);
>
> > > if (!empty($params['controller'])) {
> > > $ctrlName = Inflector::camelize($params['controller']);
>
> > > if (!loadController($ctrlName)) {
> > > $pluginName =
> > > Inflector::camelize($params['action']);
> > > if (loadController($ctrlName . '.' . 
> > > $pluginName)) {
> > > return true;
> > > }
> > > } else {
> > > return true;
> > > }
> > > }
>
> > > return false;
>
> > > }
>
> > > -MI
>
> > > -------
>
> > > Remember, smart coders answer ten questions for every question they ask.
> > > So be smart, be cool, and share your knowledge.
>
> > > BAKE ON!
>
> > > blog:http://www.MarianoIglesias.com.ar
>
> > > -Mensaje original-
> > > De: cake-php@googlegroups.com [mailto:[EMAIL PROTECTED] En nombre
> > > de phpjoy
> > > Enviado el: Lunes, 18 de Junio de 2007 11:06 a.m.
> > > Para: Cake PHP
> > > Asunto: Re: checking if a controller exists
>
> > > you gave an intresting idea.. maybe i'll simply loadcontroller and
> > > then run the action and then call the view render myself from the
> > > function.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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: getting 2 rows from a table with 2 foreign keys

2007-06-19 Thread phpjoy

yep, that's exactly what i was asking.
thanks a lot!
so easy that i missed that. :-)

On Jun 19, 12:55 pm, Grant Cox <[EMAIL PROTECTED]> wrote:
> Are you asking how you can have multiple assocations to the same
> foreign model?  In that case just use unique association keys, ie:
>
> var $belongsTo = array(
> 'ModifiedUser' => array('className' => 'User',
> 'foreignKey'=>'muser'),
> 'CreatedUser' => array('className' => 'User', 'foreignKey'=>'cuser'),
> );


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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
-~--~~~~--~~--~--~---



getting 2 rows from a table with 2 foreign keys

2007-06-19 Thread phpjoy

hey,

i have a table with 2 fields in it: muser and cuser.
cuser is the user that created the object, and muser is the user that
modified the object in the last time.
both should be loaded for the same object, for example:
$object['mAdminUser']['username']
$object['cAdminUser']['username']
or
$object[m'username']
$object['cusername']

i wonder what's the best cakephp way to load these fields.

thanks for your time!


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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: checking if a controller exists

2007-06-19 Thread phpjoy

thanks a lot, that pretty much sums it up..
i see the right way is to loadController. i might send a suggestion
about that.. there should be existsController or something like
that :)



On Jun 18, 4:56 pm, "Mariano Iglesias" <[EMAIL PROTECTED]>
wrote:
> function reachable($url) {
> $params = Router::parse($url);
>
> if (!empty($params['controller'])) {
> $ctrlName = Inflector::camelize($params['controller']);
>
> if (!loadController($ctrlName)) {
> $pluginName =
> Inflector::camelize($params['action']);
> if (loadController($ctrlName . '.' . $pluginName)) {
> return true;
> }
> } else {
> return true;
> }
> }
>
> return false;
>
> }
>
> -MI
>
> ---
>
> Remember, smart coders answer ten questions for every question they ask.
> So be smart, be cool, and share your knowledge.
>
> BAKE ON!
>
> blog:http://www.MarianoIglesias.com.ar
>
> -Mensaje original-
> De: cake-php@googlegroups.com [mailto:[EMAIL PROTECTED] En nombre
> de phpjoy
> Enviado el: Lunes, 18 de Junio de 2007 11:06 a.m.
> Para: Cake PHP
> Asunto: Re: checking if a controller exists
>
> you gave an intresting idea.. maybe i'll simply loadcontroller and
> then run the action and then call the view render myself from the
> function.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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: checking if a controller exists

2007-06-18 Thread phpjoy

you gave an intresting idea.. maybe i'll simply loadcontroller and
then run the action and then call the view render myself from the
function.

i'll try and report back!
if that doesn't work i'll goto the router itself [something i try
avoid doing].

On Jun 18, 1:51 pm, Grant Cox <[EMAIL PROTECTED]> wrote:
> If you know the actual controller name you can use loadController()
> which will return a boolean of whether the controller could be
> loaded.  However, your example above is difficult because a
> requestAction (and normal requests) go through your application routes
> - which could have any kind of mapping from request url to
> controller.  Perhaps you could look into how the Router works, and
> find something that identifies the controller that would be used for a
> particular request url?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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
-~--~~~~--~~--~--~---



checking if a controller exists

2007-06-18 Thread phpjoy

what's the cakephp way to check whether a controller exists or not?


$this->set('product', $this->requestAction('/admin/product/',
array('return')));
if the controller isn't there, it shows an error message.
i haven't tried taking it to debug 0, i thought of using a function to
check.

thanks


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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: cake1.2: form options

2007-06-15 Thread phpjoy

yeah, that's obvious. i read the api and setup the select to work, i
just wonder why the bake didn't do that on his own..

thanks for youur answer.

On Jun 15, 4:12 pm, "Dr. Tarique Sani" <[EMAIL PROTECTED]> wrote:
> You have to set the $s from your controller
>
> T
>
> On 6/15/07, phpjoy <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > hey,
>
> > i recently migrated to cake1.2, and i baked a project.
>
> > in the edit form, i had the following line:
> > $form->input('published', array('options' => $s));
>
> > the problem is that it doesn't work. it doesn't recognize $s.
> > Notice (8): Undefined variable: s [CORE\app\views\sections
> > \admin_edit.ctp, line 6
>
> > any ideas how i can fix this?
>
> --
> =
> Cheesecake-Photoblog:http://cheesecake-photoblog.org
> PHP for E-Biz:http://sanisoft.com
> =


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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
-~--~~~~--~~--~--~---



cake1.2: form options

2007-06-15 Thread phpjoy

hey,

i recently migrated to cake1.2, and i baked a project.

in the edit form, i had the following line:
$form->input('published', array('options' => $s));

the problem is that it doesn't work. it doesn't recognize $s.
Notice (8): Undefined variable: s [CORE\app\views\sections
\admin_edit.ctp, line 6

any ideas how i can fix this?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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: bakery GUI suggestion

2007-06-03 Thread phpjoy

great to hear! i'd love to see a better gui for the bakery.. slimmer
gui, that is.
what's a "mock up"? :)

On Jun 3, 7:42 pm, gwoo <[EMAIL PROTECTED]> wrote:
> Suggestions are more than welcome. If you have an idea for better gui,
> put together a mock up and submit it as an enhancement to 
> trac.https://trac.cakephp.org


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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
-~--~~~~--~~--~--~---



bakery GUI suggestion

2007-06-03 Thread phpjoy

hey all!

i have a little bakery GUI suggestion. for months i enter the bakery
and think "gee! that's quite annoying finding everything in the
bakery!", so i decided to share that now.

i really liked the old wiki gui, it was quite simple and easy to
access all of the tutorials there.
now when i want to access a tutorial, i have to see the name in BIG,
then have quite a few lines of description, and now i can see only 2-3
tutorials/code snippets per page.

personally, i'd prefer it to be title - short description near it, and
one line or max 3 lines under it another tutorial. get around 8-18
items per page. it makes my search faster and easier.

generally speaking, the cake sites (bakery, cake itself, cakeforge)
don't feel too user-friendly when you think of the gui design [how
colors blend, where links/items are put, etc].


i'm not complaining or anything, just sending a suggestion based on my
own experience.
and yes, i prefer a better cakephp software than a better gui for the
website. :-)

is that the place to post this?

yossi.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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: accessing a controller from a component.

2007-01-10 Thread phpjoy

i'm working with php5.

and nope, it still doesn't work..

function startup(&$controller) {
$this->controller = &$controller;
}

and in the component's function:
var_dump($this->controller);
either shows a bool TRUE if i set it up, or a null if i don't set it
up.

if it's not defined at all at the start, i get an error too.

[EMAIL PROTECTED] wrote:
> what you do works on php5, not php4
> to make it work on both, you have to write the assignment like this:
>
> function startup(&$controller)
> {
> $this->controller = &$controller;
> }


--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
"Cake PHP" 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
-~--~~~~--~~--~--~---



accessing a controller from a component.

2007-01-10 Thread phpjoy

i think i'm missing something in my component, .. i can't seem to
access the controller from the component.

here's the component's code:

class PlacesComponent extends Object {
var $controller = true;

function startup(&$controller) {
$this->controller = $controller;
}

function Do() {
$this->controller->redirect('/admin/center/');
}
}

in the controller I use the following code:
loadComponent('Places');

the error I'm getting in the browser:
Fatal error: Call to a member function redirect() on a non-object in
{filename}

it seems as if it giveme access to $this->controller from the startup
function. I tried it without the startup function, and couldn't find
anything about it in the API.
i'd be happy to know how come it doesn't work, and where i could find
it in the API itself.. .. 


I use cake 1.12.


--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
"Cake PHP" 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
-~--~~~~--~~--~--~---



MySQL export and import

2007-01-08 Thread phpjoy


hey all,

is there a class in CakePHP for exporting/importing SQL calls?
backing up a server, etc?
exporting SQL to XML and XML to SQL?

thanks


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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: Table associations the CakePHP way

2006-12-26 Thread phpjoy


hey adrian,

the table names are right, and work great with scuffold. it works
without scuffold too, i just want to make it more efficient.
on some of the models i used hasmany, belongsto, and hasone. i get the
table category and layout dumped, the problem is that i get all of the
information from the fields => and not just category.name, or
layout.name.

there are a few ways to handle this. there are two ways I know:
1) do a mysql query
2) ask for specific fields in the hasone/belongsto/hasmany, ..


i just wanna hear what else you guys are doing.. the cakephp way. :)

yossi


Adrian Godong wrote:

First you'll have to create correct associations for your Models (if you
don't know how or too lazy to read the manual, ask again).

Second, try dumping the whole thing you got from the Model->findAll or
findBy... using debug($[modelname]->[functionname]);

You'll see that accessing category.name and layout.name is just an array
away from the main result.

Still having problem? Print out to us the result of the steps above...


On 12/26/06, phpjoy <[EMAIL PROTECTED]> wrote:
>
>
> I have a controller, and I want to fetch information from tables.
> With scaffold, it works wonderfully.. However I wanna load the
> information smartly for my app.
>
> These are my tables:
> section:
> id
> name
> field1
> field2
> layout_id
> category_id
>
> category:
> id
> name
> field3
> field4
> field5
> field6
>
> layout:
> id
> name
> field7
> field8
>
> I want to put the information from the section table in the view.
> the category_id and layout_id should have category.name and layout.name
> instead of the id of the category.
> I could build a MySQL query for this, but I wonder what's the CakePHP
> way.
> (The more ways, the marrier it is ;))
>
>
> >
>


--
Adrian Godong
[EMAIL PROTECTED]

Microsoft Student Ambassador



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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
-~--~~~~--~~--~--~---



Table associations the CakePHP way

2006-12-26 Thread phpjoy


I have a controller, and I want to fetch information from tables.
With scaffold, it works wonderfully.. However I wanna load the
information smartly for my app.

These are my tables:
section:
id
name
field1
field2
layout_id
category_id

category:
id
name
field3
field4
field5
field6

layout:
id
name
field7
field8

I want to put the information from the section table in the view.
the category_id and layout_id should have category.name and layout.name
instead of the id of the category.
I could build a MySQL query for this, but I wonder what's the CakePHP
way.
(The more ways, the marrier it is ;))


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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: Reusable code, components and controllers.

2006-12-26 Thread phpjoy


great, gonna use this one!

for some kinda reason, i didn't take into consideration that you can
use var $components = array( 'Session' ); in a component..

sigh! :)


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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: The right way to check a field in of another model in a controller.

2006-12-25 Thread phpjoy


the echo was for fast-debugging,

usually i use the $_GET, i should switch to
$this->params['url']['section'] for standarization.. right?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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
-~--~~~~--~~--~--~---



Reusable code, components and controllers.

2006-12-25 Thread phpjoy


I have this code for my app, and I need to put it in a few controllers.
I wonder where I can put it, so I could call it from the controllers.

loadModel('Section');
$Section =& new Section;
$this->Section =& new Section;

$this->Section->id = $this->params['url']['section'];
$section = $this->Section->read();

if($section==FALSE) {
$this->Session->setFlash('Section doesn\'t exist, displaying sections
index.');
$this->redirect('/admin/sections/');
}

I tried putting it in a component, but I couldn't access
$this->Session->..


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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
-~--~~~~--~~--~--~---



The right way to check a field in of another model in a controller.

2006-12-25 Thread phpjoy


hey guys,

i need to check whether an ID exists in another model or not.

i wonder which is the correct way to do that:
1) calling a request action, or
2) loading the model itself and making the operation.

1)
if($this->requestAction('/admin/sections/exists/' .$_GET['section'])) {
echo 'Exists..';
}
else echo 'Doesnt Exist..';

2)
loadModel('Section');
$Section =& new Section;
$this->Section =& new Section;
$Section->id = $_GET['section'];
if($Section->exists()==TRUE) echo $_GET['section'] .':Exists';
else echo $_GET['section'] .':Doesnt Exist';


i assume 2 is the better way to go, but i wanna hear your opinions!

marry xmas :)


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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: Updating a date field after form submission

2006-12-22 Thread phpjoy


if i have a created field and a modified field, will both of them be
updated everytime?

for example:
add()/edit() - DB fields modified and created will be changed.

or:
add() - only the field "created" will be changed.
edit() - only the field "modified" will be changed.

and can you control it somehow?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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: Textarea limit

2006-12-16 Thread phpjoy

i know you have to use something in addition for the native HTML, but i
wondered whether cakephp provides that or not..

i thought of adding an onclick, and javascript at the start of the file
- as i normally do.


--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
"Cake PHP" 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
-~--~~~~--~~--~--~---



Textarea limit

2006-12-15 Thread phpjoy

hey guys,

how do you limit and check the textareas?
do you make javascripts for that?

kinda new to cakephp.

yossi


--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
"Cake PHP" 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
-~--~~~~--~~--~--~---