Re: Best way to accomplish acl for database records owned by a user

2009-09-24 Thread rOger

Thanks for your answers!!

@brian: It looks rather complex to accomplish such a "easy" task so I
think there must be an easier way to get the same result...

@Rick: Your solution is the one I used before but I thought that there
must be a solution that is integrated into the ACO/ACL concept...

It's always the same problem with every framework; simple tasks are
easy; real world scenarios are big challenges. It would be interesting
to know how the developers of cakePHP/ACL-system would accomplish this
task...

regards,
rOger


On 24 Sep., 16:09, Rick  wrote:
> I know that globals are bad but...
>
> I just set a global $gblCurrentUser when the user logs in.  Then
> accessing that in models, I can add a select condition for that user
> in the beforeFind etc..
>
> You get the idea?
>
> Rick
>
> On Sep 24, 12:20 am, brian  wrote:
>
> > I did something similar to this. However, I was so overwhelmed by the
> > contradictory and/or incomplete information I found about Cake's ACL
> > (mostly because it was quite dated) that I really don't know for sure
> > that I did it the best way.
>
> > My app is an extranet that has several different Groups. The
> > navigation consists of many Sections that are stored as a tree (MPTT).
> > Some Sections may not be seen by certain Groups. So, to display this
> > navigation tree, I called this method in my SectionsController:
>
> > public function nav($group_id = null)
> > {
> >         if (is_null($group_id))
> >         {
> >                 if (!$this->params['admin'])
> >                 {
> >                         $group_id = $this->Auth->user('group_id');
> >                 }
> >         }
> >         $this->Session->write('group_id_for_nav', $group_id);
>
> >         /* try getting the nodes from the cache
> >          */
> >         $sections = Cache::read("group_sections_${group_id}", 'default');
>
> >         if (!$sections)
> >         {
> >                 /* fetch the permissions for this group
> >                  */
> >                 $perms = $this->Acl->Aco->find(
> >                         'all',
> >                         array(
> >                                 'fields' => array('Aco.foreign_key'),
> >                                 'conditions' => array(
> >                                         'Aco.model' => 'Section',
> >                                         'Aco.id = Permission.aco_id'
> >                                 ),
> >                                 'recursive' => -1,
> >                                 'joins' => array(
> >                                         array(
> >                                                 'table' => 'aros',
> >                                                 'alias' => 'Aro',
> >                                                 'type' => 'INNER',
> >                                                 'conditions'=> array(
> >                                                         'Aro.model' => 
> > 'Group',
> >                                                         "Aro.foreign_key = 
> > ${group_id}"
> >                                                 )
> >                                         ),
> >                                         array(
> >                                                 'table' => 'aros_acos',
> >                                                 'alias' => 'Permission',
> >                                                 'type' => 'INNER',
> >                                                 'conditions'=> array(
> >                                                         'Permission.aro_id 
> > = Aro.id',
> >                                                         'Permission._read 
> > >= 0'
> >                                                 )
> >                                         )
> >                                 )                                      
> >                         )
> >                 );
>
> >                 $section_ids = Set::extract($perms, '{n}.Aco.foreign_key');
>
> >                 /* we don't want to see the root node
> >                  */
> >                 unset($section_ids[0]);
>
> >                 /* now grab the sections these permissions allow
> >                  */
> >                 $sections = $this->Section->threaded($section_ids);
>
> >                 /* save this group's allowed sections
> >                  */
> >                 Cache::write("group_sections_${group_id}", $sections, 
> > 'default');
> >         }
> >         return $sections;
>
> > }
>
> > So, the Aco.foreign_key fields I'm after correspond to Section.ids.
> > Once i have those, I fetch the relevant Sections as a threaded list.
> > Obviously, you'd just be interested in the record IDs.
>
> > What I'm storing in the cache is the Sections themselves. For your
> > case, you'd likely want to save the record IDs in the session instead
> > of caching them.
>
> > Anyway, the important thing is the joins used to get at the model IDs
> > for your reco

Re: Trouble with installation

2009-09-24 Thread Cristian Cassina

Nigel,

could it be a permission related issue? Did you check file and folders 
permissions of this new Cake installation?
Regards

Cristian

Nigel ha scritto:
> I use Ubuntu 9.04 and I installed apache, mysql, and php5.  I did the
> blog tutorial successfully with everything working.  After that I
> deleted the folder cake and installed it again for the next tutorial.
> I cleared the database.  Now, the Cake page is not displaying properly
> as though there is some trouble with apache mod_rewrite, but I checked
> it out and its fine.  What am I missing here?
>
> >
>   


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



Re: Doubt in cake php

2009-09-24 Thread John Andersen

Look into the controllers method "requestAction", which allows you to
retrieve the list of clubs in a view!
Enjoy,
   John

On Sep 24, 11:59 am, hunny  wrote:
> Hi Guys,
>
> I am new to cakephp. I am having the following issue:
>
> I am displaying list of checkbox containing clubs to a login user. The
> list of clubs I am passing through the models via controllers in the
> traditional way.
>
> Now the logged in user should see his list of clubs automatically
> ticked. This list is present in another database.
>
> One solution is to get the list of user clubs in the controller itself
> and pass it to the view.
>
> But is there any alternative way, where I can access the user clubs in
> the view itself without loading in the controller.
>
> Basically i am looking for something similar like View Helpers in
> Zend. We can access the model data in views using view Helpers. Is
> there something similar in cakephp.
>
> P.S: I have asked this question to a few people who knew cake php and
> their first reaction is that you shouldn't access model data in views
> as it is against MVC. But let me assure you we can access model data
> in view as long as it is read only. At least that is what we are used
> to follow in Zend Framework. :)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: How can I build a navigation menu in cakephp?

2009-09-24 Thread Barney

thanks, what's caching result? can you give me more tips please



On Sep 24, 8:33 pm, brian  wrote:
> Remove the single quotes. $category['Category']['name'] is already a
> string so you don't need them. What you'd done is passed the literal
> string, '$category['Category']['name']'.
>
> As for creating a menu, once you have something working, you might
> want to look at caching the result so you're not hitting the database
> on every page view.
>
>
>
> On Thu, Sep 24, 2009 at 10:20 PM, Barney  wrote:
>
> > first, I am very new to cakephp.
>
> > I have 2 tables "categories" and "products"
>
> > I want to make a menu like category->product tree
>
> > in the view,  i use those code to display the categories:
>
> > 
> > 
> > 
> > 
> > 
>
> > 
> > 
>
> > But if I want to add links to these categories
>
> > how can I use $html->link to achieve it?
>
> > $html->link('$category['Category']['name']',array
> > ('controller'=>'Products','action'=>'view', $category['Products']
> > ['id']));
>
> > but this line code goes error,
>
> > I know $html->link first parameter should be a string value, how can I
> > assign a variable ?
>
> > please help,thank you
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: How can I build a navigation menu in cakephp?

2009-09-24 Thread brian

Remove the single quotes. $category['Category']['name'] is already a
string so you don't need them. What you'd done is passed the literal
string, '$category['Category']['name']'.

As for creating a menu, once you have something working, you might
want to look at caching the result so you're not hitting the database
on every page view.

On Thu, Sep 24, 2009 at 10:20 PM, Barney  wrote:
>
> first, I am very new to cakephp.
>
> I have 2 tables "categories" and "products"
>
> I want to make a menu like category->product tree
>
> in the view,  i use those code to display the categories:
>
> 
> 
> 
> 
> 
>
> 
> 
>
> But if I want to add links to these categories
>
> how can I use $html->link to achieve it?
>
>
> $html->link('$category['Category']['name']',array
> ('controller'=>'Products','action'=>'view', $category['Products']
> ['id']));
>
>
> but this line code goes error,
>
> I know $html->link first parameter should be a string value, how can I
> assign a variable ?
>
>
> please help,thank you
> >
>

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



Re: changing $session->flash('auth'); layout

2009-09-24 Thread brian

Gotcha. Auth uses 'default' layout when calling
$this->Session->setFlash(). Have a look at SessionHelper::flash() to
see how it handles that.

http://api.cakephp.org/view_source/session-helper/#line-129

In any case, if you want to style/move it/whatever, create a CSS rule
for the #authMessage selector. You can even use javascript to do a
little more with it. (simple with jQuery).

On Thu, Sep 24, 2009 at 8:54 PM, adam  wrote:
>
> Sorry.  When calling $session->flash('auth'); in my layout, it outputs
> the message like this:
>
> MESSAGE HERE
>
> I would like it to be whatever I want it to be.  When calling $this-
>>setFlash(), the second or third parameter allows you to set the flash
> layout.  And then $session->flash(); will output the message in that
> layout.  However, this functionality is missing from auth flash
> messages.
>
> Or is it?  That's what I'm asking.
>
> On Sep 24, 7:13 pm, brian  wrote:
>> I read that 3 times and still have no idea what you want to do.
>>
>> On Thu, Sep 24, 2009 at 2:37 PM, adam  wrote:
>>
>> > i am implementing a layout and am sad that i can not change the auth
>> > flash layout, instead i am having to use session->check(), then
>> > session->read(), and then to remove the message, session->flash() into
>> > an area of the layout where it will not be displayed.
>>
>> > is there a way to chagne the flash layout for auth messages (like with
>> > setFlash layouts?) without having to extend the session helper, or
>> > maybe be able to delete the message with the session helper from the
>> > layout without using flash() which displays the message?
> >
>

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



Re: Private Messaging mysql

2009-09-24 Thread brian

Ah, I thought the "(inbox, sent, trash)" referred to an enum.

On Thu, Sep 24, 2009 at 8:31 PM, Miles J  wrote:
>
> Nah it wouldn't require enum fields, you just give a static int value
> to all the folder/status types.
>
> But yes, would be better to maybe do a "messages_body" table if you
> want to send to multiple users.
>
> On Sep 24, 5:24 pm, brian  wrote:
>> Ugh! That relies upon enum columns, for one thing. But it also makes
>> it more than a bit awkward to send a msg to more than one user.
>>
>> DB tables are cheap. Plan for the future.
>>
>> On Thu, Sep 24, 2009 at 3:20 PM, Miles J  wrote:
>>
>> > You dont need that many tables like brian suggested. All you need is
>> > two, users and messages.
>>
>> > messages:
>> > - id
>> > - user_id (sender)
>> > - recipient_id (receiver)
>> > - subject
>> > - content
>> > - status (read, unread, etc)
>> > - userFolder (inbox, sent, trash)
>> > - recipientFolder (inbox, sent, trash)
>> > - created
>> > - modified
>>
>> > On Sep 24, 12:14 pm, John Andersen  wrote:
>> >> It is late (here in Latvia) and I am not sure that I remember
>> >> correctly what I saw while playing around with saving HABTM associated
>> >> data.
>>
>> >> If correctly, then providing the associated model as:
>>
>> >> $data[associatedModel][associatedModel] = array();
>>
>> >> deletes all the associations between the main model and the associated
>> >> model.
>>
>> >> But this is from memory (soft tissue, may fail to retrieve
>> >> correctly) :D so may somewhat be wrong!
>> >> Enjoy,
>> >>    John
>>
>> >> On Sep 24, 7:35 pm, brian  wrote:
>> >> [snip]
>>
>> >> > That's a good question. I'm actually not sure how best to unlink a
>> >> > pair of records. You could always add an id column to the join table
>> >> > and do $this->Message->InboxMessage->del($id). But you'd need to
>> >> > determine the $id first.
>>
>> >> > The other way would be to use a plain SQL:
>> >> > $this->Message->query('DELETE FROM inboxes_messages WHERE message_id =
>> >> > '.$message_id);
>>
>> >> > There's a Model::_deleteLinks() method that does just this but it's
>> >> > protected. Maybe someone else knows the proper Cake way to do this.
>>
>> >> > You might also find Mariano's SoftDeletableBehavior of 
>> >> > use:http://bakery.cakephp.org/articles/view/soft-delete-behavior
>>
>> >> > Just be aware that it's a few years old and may require some syntax
>> >> > adjustments. I don't know if it's been kept up to date. Read the
>> >> > comments in the article.
> >
>

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



How can I build a navigation menu in cakephp?

2009-09-24 Thread Barney

first, I am very new to cakephp.

I have 2 tables "categories" and "products"

I want to make a menu like category->product tree

in the view,  i use those code to display the categories:










But if I want to add links to these categories

how can I use $html->link to achieve it?


$html->link('$category['Category']['name']',array
('controller'=>'Products','action'=>'view', $category['Products']
['id']));


but this line code goes error,

I know $html->link first parameter should be a string value, how can I
assign a variable ?


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



Re: changing $session->flash('auth'); layout

2009-09-24 Thread adam

Sorry.  When calling $session->flash('auth'); in my layout, it outputs
the message like this:

MESSAGE HERE

I would like it to be whatever I want it to be.  When calling $this-
>setFlash(), the second or third parameter allows you to set the flash
layout.  And then $session->flash(); will output the message in that
layout.  However, this functionality is missing from auth flash
messages.

Or is it?  That's what I'm asking.

On Sep 24, 7:13 pm, brian  wrote:
> I read that 3 times and still have no idea what you want to do.
>
> On Thu, Sep 24, 2009 at 2:37 PM, adam  wrote:
>
> > i am implementing a layout and am sad that i can not change the auth
> > flash layout, instead i am having to use session->check(), then
> > session->read(), and then to remove the message, session->flash() into
> > an area of the layout where it will not be displayed.
>
> > is there a way to chagne the flash layout for auth messages (like with
> > setFlash layouts?) without having to extend the session helper, or
> > maybe be able to delete the message with the session helper from the
> > layout without using flash() which displays the message?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Private Messaging mysql

2009-09-24 Thread Miles J

Nah it wouldn't require enum fields, you just give a static int value
to all the folder/status types.

But yes, would be better to maybe do a "messages_body" table if you
want to send to multiple users.

On Sep 24, 5:24 pm, brian  wrote:
> Ugh! That relies upon enum columns, for one thing. But it also makes
> it more than a bit awkward to send a msg to more than one user.
>
> DB tables are cheap. Plan for the future.
>
> On Thu, Sep 24, 2009 at 3:20 PM, Miles J  wrote:
>
> > You dont need that many tables like brian suggested. All you need is
> > two, users and messages.
>
> > messages:
> > - id
> > - user_id (sender)
> > - recipient_id (receiver)
> > - subject
> > - content
> > - status (read, unread, etc)
> > - userFolder (inbox, sent, trash)
> > - recipientFolder (inbox, sent, trash)
> > - created
> > - modified
>
> > On Sep 24, 12:14 pm, John Andersen  wrote:
> >> It is late (here in Latvia) and I am not sure that I remember
> >> correctly what I saw while playing around with saving HABTM associated
> >> data.
>
> >> If correctly, then providing the associated model as:
>
> >> $data[associatedModel][associatedModel] = array();
>
> >> deletes all the associations between the main model and the associated
> >> model.
>
> >> But this is from memory (soft tissue, may fail to retrieve
> >> correctly) :D so may somewhat be wrong!
> >> Enjoy,
> >>    John
>
> >> On Sep 24, 7:35 pm, brian  wrote:
> >> [snip]
>
> >> > That's a good question. I'm actually not sure how best to unlink a
> >> > pair of records. You could always add an id column to the join table
> >> > and do $this->Message->InboxMessage->del($id). But you'd need to
> >> > determine the $id first.
>
> >> > The other way would be to use a plain SQL:
> >> > $this->Message->query('DELETE FROM inboxes_messages WHERE message_id =
> >> > '.$message_id);
>
> >> > There's a Model::_deleteLinks() method that does just this but it's
> >> > protected. Maybe someone else knows the proper Cake way to do this.
>
> >> > You might also find Mariano's SoftDeletableBehavior of 
> >> > use:http://bakery.cakephp.org/articles/view/soft-delete-behavior
>
> >> > Just be aware that it's a few years old and may require some syntax
> >> > adjustments. I don't know if it's been kept up to date. Read the
> >> > comments in the article.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Redirect After Using render('action')

2009-09-24 Thread brian

Whether Cake spits out a CSV file or redirects to another
controller/action, headers need to be sent to the client, but you
can't send headers for both simultaneously.

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

On Thu, Sep 24, 2009 at 3:17 PM, Tony Thomas  wrote:
>
> I have a controller function that's using $this->render('action') to
> render a view that creates a CSV file after submitting some info in a
> form.
>
> What I want to do is redirect the user after the CSV file is
> downloaded. So the steps would be:
>
> 1. User submits data.
> 2. Queries are run and a CSV file is rendered and saved by the user.
> 3. Controller redirects to another view.
>
> If I do a simple redirect using $this->redirect('controller/action'),
> the CSV file is not rendered, even though render() is called first. If
> I don't redirect, the CSV is successfully rendered, but the user is
> left with a form that is still filled-in. I'd like to redirect to
> another view and display a "Success" flash message once the CSV is
> rendered.
>
> Any tips?
> >
>

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



Re: Private Messaging mysql

2009-09-24 Thread brian

Ugh! That relies upon enum columns, for one thing. But it also makes
it more than a bit awkward to send a msg to more than one user.

DB tables are cheap. Plan for the future.

On Thu, Sep 24, 2009 at 3:20 PM, Miles J  wrote:
>
> You dont need that many tables like brian suggested. All you need is
> two, users and messages.
>
> messages:
> - id
> - user_id (sender)
> - recipient_id (receiver)
> - subject
> - content
> - status (read, unread, etc)
> - userFolder (inbox, sent, trash)
> - recipientFolder (inbox, sent, trash)
> - created
> - modified
>
> On Sep 24, 12:14 pm, John Andersen  wrote:
>> It is late (here in Latvia) and I am not sure that I remember
>> correctly what I saw while playing around with saving HABTM associated
>> data.
>>
>> If correctly, then providing the associated model as:
>>
>> $data[associatedModel][associatedModel] = array();
>>
>> deletes all the associations between the main model and the associated
>> model.
>>
>> But this is from memory (soft tissue, may fail to retrieve
>> correctly) :D so may somewhat be wrong!
>> Enjoy,
>>    John
>>
>> On Sep 24, 7:35 pm, brian  wrote:
>> [snip]
>>
>> > That's a good question. I'm actually not sure how best to unlink a
>> > pair of records. You could always add an id column to the join table
>> > and do $this->Message->InboxMessage->del($id). But you'd need to
>> > determine the $id first.
>>
>> > The other way would be to use a plain SQL:
>> > $this->Message->query('DELETE FROM inboxes_messages WHERE message_id =
>> > '.$message_id);
>>
>> > There's a Model::_deleteLinks() method that does just this but it's
>> > protected. Maybe someone else knows the proper Cake way to do this.
>>
>> > You might also find Mariano's SoftDeletableBehavior of 
>> > use:http://bakery.cakephp.org/articles/view/soft-delete-behavior
>>
>> > Just be aware that it's a few years old and may require some syntax
>> > adjustments. I don't know if it's been kept up to date. Read the
>> > comments in the article.
> >
>

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



Re: Trouble with installation

2009-09-24 Thread brian

We could guess what "not displaying properly" means but that could go
on for a while.

On Thu, Sep 24, 2009 at 12:45 PM, Nigel  wrote:
>
> I use Ubuntu 9.04 and I installed apache, mysql, and php5.  I did the
> blog tutorial successfully with everything working.  After that I
> deleted the folder cake and installed it again for the next tutorial.
> I cleared the database.  Now, the Cake page is not displaying properly
> as though there is some trouble with apache mod_rewrite, but I checked
> it out and its fine.  What am I missing here?
>
> >
>

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



Re: Translate field names

2009-09-24 Thread brian

__('field_name')

http://book.cakephp.org/view/161/Internationalization-Localization

On Thu, Sep 24, 2009 at 4:05 PM, emmexx  wrote:
>
> I searched the bakery and here but couldn't find an answer.
>
> I'd like to translate all field names in a simple way.
> The Translate behaviour is useful to translate field values but I want
> to translate the field name, that is use another label for the name of
> one or more fields in a table.
>
> I can't believe cakephp has not a mechanism to translate field names:
> they're used in forms and views by cake...
>
> Thank you
>   maxx
>
> >
>

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



Re: changing $session->flash('auth'); layout

2009-09-24 Thread brian

I read that 3 times and still have no idea what you want to do.

On Thu, Sep 24, 2009 at 2:37 PM, adam  wrote:
>
> i am implementing a layout and am sad that i can not change the auth
> flash layout, instead i am having to use session->check(), then
> session->read(), and then to remove the message, session->flash() into
> an area of the layout where it will not be displayed.
>
> is there a way to chagne the flash layout for auth messages (like with
> setFlash layouts?) without having to extend the session helper, or
> maybe be able to delete the message with the session helper from the
> layout without using flash() which displays the message?
> >
>

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



Including non-plugin element from within plugin

2009-09-24 Thread michaelc

I'm experiencing an interesting problem wherein I include from within
a view in a plugin an element which contains a form (the users login
form, that is).  However, I can't seem to see a way free to not having
it prepend the plugin name onto the action.  The offending code is
line 156 of form.php, knowing as we do that Form::plugin is set when
it is initialized from View::_loadHelpers (see line 755).

My essential problem is that there appears to be no way to change the
plugin context once inside of a plugin's view, to reflect the
inclusion of non-plugin content.  I am using plugins like photoshop,
to extend the functionality of a base site, and the usecase seems
awkward when compared with the design for a plugin (extending a
generic site - they therefore must be self contained).  Given how easy
it is to load a base element, it would appear however that either was
planned for.

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



MAMP + CakePHP issues

2009-09-24 Thread fahd

Hey fellow Cakers,

I've been developing on CakePHP for a bit and decided to have a
localhost version on MAMP so that I could demo my app to people
without being dependent on an Internet connection.

Ran into a few issues ofcourse and hoping someone can give some
insight:

1) I have several sites under the /Sites/ folder and I pointed MAMP's
Apache document root there. For example /Sites/project1/ is where the
Cake app sites.  It finds the /project1/ site fine (after some
htaccess mods) but there are issues with relative links. Any link that
is manually coded and not using $html->link uses /Sites/ instead of /
Sites/project1/ as the base. This is for images and any Ajax calls
from jQuery. (css and js files are fine). The images I can bare, but
the site is unusable without Ajax.

Temp solution: changed the document root to /Sites/project1/. This is
not ideal, but I'd like to know if you guys have a fix so I don't have
to change the document root all the time for previewing different
projects.

2) We have a lot of complex MySQL queries being made, using $this-
>query('SELECT...'). We've placed these in the appropriate models
within a function. Hence from the Controller we'll have something like
$this->Users->getMeSomething($variable), that goes to the user.php
model and runs that function. This works fine on our live and dev
sites, but for some reason on MAMP I'm getting the error:

Warning (512): SQL Error: 1064: You have an error in your SQL syntax;
check the manual that corresponds to your MySQL server version for the
right syntax to use near '__getUsersForUsers' at line 1 [CORE/cake/
libs/model/datasources/dbo_source.php, line 525]

The context:
==
DboSource::showQuery() - CORE/cake/libs/model/datasources/
dbo_source.php, line 525
DboSource::execute() - CORE/cake/libs/model/datasources/
dbo_source.php, line 201
DboSource::fetchAll() - CORE/cake/libs/model/datasources/
dbo_source.php, line 336
DboSource::query() - CORE/cake/libs/model/datasources/dbo_source.php,
line 297
Model::call__() - CORE/cake/libs/model/model.php, line 441
Overloadable::__call() - CORE/cake/libs/overloadable_php5.php, line 52
AppModel::__getUsersForUsers() - [internal], line ??
UsersController::view() - APP/controllers/users_controller.php, line
401
Object::dispatchMethod() - CORE/cake/libs/object.php, line 118
Dispatcher::_invoke() - CORE/cake/dispatcher.php, line 227
Dispatcher::dispatch() - CORE/cake/dispatcher.php, line 194
[main] - APP/webroot/index.php, line 88
==
Line 88 on webroot is this: $Dispatcher->dispatch($url);

Thanks for any help

Fahd

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



Enumerating ACL settings

2009-09-24 Thread Stuart

What's the easiest way to enumerate the who has what ACL settings for
a specific ACO entry? I have the appropriate aco_id but there doesn't
appear to be an easy way to link this though the aros_acos table back
to the aros?

BTW:
I'm reasonably new to Cake.

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



Getting started with Ajax

2009-09-24 Thread Jürgen

Hi,

I've just been getting started with Ajax and I've been able to set up
a simple website using the pagesController that comes with cake. As
for now I'm not yet using any databases.

Today I started to try integrating some Ajax in my site. It's quite
simple: I want to load the pages into the 'content' div without
reloading the entire layout. So what I tried was the following: I
edited the pagesController by copying the display function and naming
it display_ajax(); Then all I changed was in the last line in the
render() function I added 'ajax'.

Now when I press an ajax link that loads the new display_ajax function
it displays in the 'content' div an error message saying that it can't
find the $javascript variable in my default.ctp layout file. That's on
the line where I load the javascript files ajax needs.

Now maybe I don't really understand how cake works yet, but I think
this is weird. First off, I thought by setting the 'ajax' value in the
render function, the layout shouldn't be loaded at all. And even if it
should (apparently so, can someone explain?) then why does it return
this error, when it doesn't return any errors if I use the standard
display() function. The functions are the same!

I hope someone can help me with this! Thanks.

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



Re: No Listbox for HABTM Relationship using Scaffold

2009-09-24 Thread Choopong Choosamer

I have the same problem.

I must downgrade it to 1.2.3.

1.2.5, 1.2.4, and 1.2.x.x nightly build also have the same problem.

Cheers.

On Sep 21, 7:59 am, josephusbrown  wrote:
> The issue appears to be with the current version of cakephp 1.2.5. I
> went back to previous version and HABTM list boxes appear.

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



Trouble with installation

2009-09-24 Thread Nigel

I use Ubuntu 9.04 and I installed apache, mysql, and php5.  I did the
blog tutorial successfully with everything working.  After that I
deleted the folder cake and installed it again for the next tutorial.
I cleared the database.  Now, the Cake page is not displaying properly
as though there is some trouble with apache mod_rewrite, but I checked
it out and its fine.  What am I missing here?

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



Re: executing queries from a .sql file in the console

2009-09-24 Thread Jorge Horacio Cué Cantú
Hello,

I had a similar problem. I have an Install controller that executes a SQL
script in ordert to create the database.
What I have done is somethjing similar to:

uses('model'.DS.'connection_manager');
$db = ConnectionManager::getInstance();
$dataSource = $db->getDataSource('default');

// The to execute each SQL statement do:

$result = $dataSource->_execute($sql_statement');
if ($result) {
// success
} else {
// failure
}


I hope this helps you. Regards


2009/9/24 Stinkbug 

>
> I'm somewhat familiar with the schema stuff.  However, the .sql file
> is a file that's going to be provided to us and not a file that will
> be generated by cake.  Our .sql file isn't just about the schema, it
> could be large amounts of data manipulation using sql.  So unless the
> schema stuff will execute a .sql file (rather than just generate it).
> I don't think it will work for us.  That's why I was trying to get the
> code above to work.
>
> Any other thoughts?
>
> On Sep 23, 4:39 pm, Sam Sherlock  wrote:
> > I think you want to create a schemahttp://
> book.cakephp.org/view/735/Generating-and-using-Schema-files
> > - S
> >
> > 2009/9/23 Stinkbug 
> >
> >
> >
> > > I'm trying to execute a bunch of sql from a .sql file from the
> > > console.  I was trying to use the query method inside the Model class,
> > > but I keep getting the following error.
> >
> > > Error: Missing database table 'models' for model 'Model'
> >
> > > Below is my code:
> >
> > >  > > App::import('Core', array('Model'));
> > > class UpgradeShell extends Shell {
> > >var $uses = array();
> >
> > >function main() {
> > >$filename = APP . 'config/sql/upgrade.sql';
> > >if (file_exists($filename)) {
> > >$handle = fopen($filename, "r");
> > >$sql = fread($handle, filesize($filename));
> > >fclose($handle);
> > >echo $sql;
> > >if ($sql) {
> > >//Model::query($sql);
> > >$model = new Model();
> > >//$model->query($sql);
> > >}
> > >}
> > >}
> >
> > > }
> > > ?>
> >
> > > When I try Model::query($sql);
> >
> > > I get the following error:
> > > Notice: Undefined property: UpgradeShell::$Model in C:\wamp\www\rx.com
> > > \app\vendors\shells\upgrade.php on line 13
> >
> > > Fatal error: Call to a member function query() on a non-object in C:
> > > \wamp\www\rx.com\app\vendors\shells\upgrade.php on line 13
> >
> > > I don't really need to specify models, I just want to execute the
> > > queries inside the .sql file.
> >
> >
> >
>

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



Re: Enterprise Level App using cakephp

2009-09-24 Thread gabrielr

Thanks for answer (Y)

On 24 sep, 16:20, "Larry E. Masters aka PhpNut" 
wrote:
> Serious though,http://book.cakephp.org/view/510/Sites-in-the-wild
> --
> /**
> * @author Larry E. Masters
> * @var string $userName
> * @param string $realName
> * @returns string aka PhpNut
> * @access  public
> */
>
> On Thu, Sep 24, 2009 at 4:17 PM, Larry E. Masters aka PhpNut <
>
> php...@gmail.com> wrote:
> > Is anybody use cakephp for developing an Enterprise Level
> >> Application?
>
> > Yes.
>
> >> and What Kind of App was developed?
>
> > A big one.
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: How to send data from controller to controller?

2009-09-24 Thread LPaulino

I've found another way

$this->setAction('action_name', array('key1' => 'value1', 'key2' =>
'value2'))

and...

function action_name($info = null)
{
  $info1 = $info['key1'];
  $info2 = $info['key2'];
}

Cya guys


On Sep 24, 6:08 pm, LPaulino  wrote:
> I've just found it... func_get_args()
> thx
>
> On Sep 24, 3:33 pm, LPaulino  wrote:
>
>
>
> > Thx man. I found the method (setAction (action, [param, param,
> > param])) here:http://cakephp.org/files/Resources/CakePHP-1.2-Cheatsheet.pdf
>
> > 1 last question: How can I can get those params in the other action?
>
> > Thx
>
> > On Sep 24, 2:51 pm, brian  wrote:
>
> > > Use $this->setAction('action_name'), then.
>
> > >http://api.cakephp.org/class/controller#method-ControllersetAction
>
> > > On Thu, Sep 24, 2009 at 1:20 PM, LPaulino  wrote:
>
> > > > ups I said it wrong, I mean from action to action
>
> > > > On 24 set, 13:56, brian  wrote:
> > > >> Those redirects are pointing to the same controller.
>
> > > >> Why not simply point the form at the 2nd controller?
>
> > > >> On Thu, Sep 24, 2009 at 9:16 AM, LPaulino  wrote:
>
> > > >> > Hi guys,
>
> > > >> > I would like to know how can I send data from 1 controller to another
> > > >> > one. Let me explain better why I need that.
>
> > > >> > I have in my view 1 form with a select:
> > > >> > 
> > > >> > 
> > > >> >   Test1 
> > > >> >   Test2 
> > > >> >   Test3 
> > > >> > 
> > > >> > 
> > > >> > 
>
> > > >> > When it is send to controller "test", the action index will check
> > > >> > which test was select and will send the data to another controller,
> > > >> > something like a redirect but I dont wanna pass the selectTest value
> > > >> > in the URL. Something like that:
>
> > > >> > function index()
> > > >> > {
> > > >> >   if($this->data['Test']['selectTest'] == 'Test1')
> > > >> >   {
> > > >> >      $this->redirect(array('controller' => 'test', 'action' =>
> > > >> > 'test1', 'data' => $this->data));
> > > >> >   }
> > > >> >   if($this->data['Test']['selectTest'] == 'Test2')
> > > >> >   {
> > > >> >      $this->redirect(array('controller' => 'test', 'action' =>
> > > >> > 'test2', 'data' => $this->data));
> > > >> >   }
> > > >> >   if($this->data['Test']['selectTest'] == 'Test3')
> > > >> >   {
> > > >> >      $this->redirect(array('controller' => 'test', 'action' =>
> > > >> > 'test3', 'data' => $this->data));
> > > >> >   }
> > > >> > }
>
> > > >> > Changing redirect to send, I dont know...
> > > >> > Is that possible? How can I do that?
>
> > > >> > Thx
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Enterprise Level App using cakephp

2009-09-24 Thread Larry E. Masters aka PhpNut
Serious though, http://book.cakephp.org/view/510/Sites-in-the-wild
-- 
/**
* @author Larry E. Masters
* @var string $userName
* @param string $realName
* @returns string aka PhpNut
* @access  public
*/

On Thu, Sep 24, 2009 at 4:17 PM, Larry E. Masters aka PhpNut <
php...@gmail.com> wrote:

> Is anybody use cakephp for developing an Enterprise Level
>> Application?
>
>
> Yes.
>
>
>> and What Kind of App was developed?
>>
>
> A big one.
>
>

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



Re: Enterprise Level App using cakephp

2009-09-24 Thread Larry E. Masters aka PhpNut
>
> Is anybody use cakephp for developing an Enterprise Level
> Application?


Yes.


> and What Kind of App was developed?
>

A big one.

-- 
/**
* @author Larry E. Masters
* @var string $userName
* @param string $realName
* @returns string aka PhpNut
* @access  public
*/

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



Re: Enterprise Level App using cakephp

2009-09-24 Thread gabrielr

someone for answer thoose questions 

On 24 sep, 10:03, gabrielr  wrote:
> Hi everybody,
> First of all, congratulations for this Framework, it mak programmer's
> life easier.
> Well, I have 2 Questions to this group.
>
> Is anybody use cakephp for developing an Enterprise Level
> Application?, and What Kind of App was developed?
>
> I  have Developed an aplication for Human Resources, and it Works
> perfectly.
>
> Thanks for Your future answers !
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: How to send data from controller to controller?

2009-09-24 Thread LPaulino

I've just found it... func_get_args()
thx

On Sep 24, 3:33 pm, LPaulino  wrote:
> Thx man. I found the method (setAction (action, [param, param,
> param])) here:http://cakephp.org/files/Resources/CakePHP-1.2-Cheatsheet.pdf
>
> 1 last question: How can I can get those params in the other action?
>
> Thx
>
> On Sep 24, 2:51 pm, brian  wrote:
>
>
>
> > Use $this->setAction('action_name'), then.
>
> >http://api.cakephp.org/class/controller#method-ControllersetAction
>
> > On Thu, Sep 24, 2009 at 1:20 PM, LPaulino  wrote:
>
> > > ups I said it wrong, I mean from action to action
>
> > > On 24 set, 13:56, brian  wrote:
> > >> Those redirects are pointing to the same controller.
>
> > >> Why not simply point the form at the 2nd controller?
>
> > >> On Thu, Sep 24, 2009 at 9:16 AM, LPaulino  wrote:
>
> > >> > Hi guys,
>
> > >> > I would like to know how can I send data from 1 controller to another
> > >> > one. Let me explain better why I need that.
>
> > >> > I have in my view 1 form with a select:
> > >> > 
> > >> > 
> > >> >   Test1 
> > >> >   Test2 
> > >> >   Test3 
> > >> > 
> > >> > 
> > >> > 
>
> > >> > When it is send to controller "test", the action index will check
> > >> > which test was select and will send the data to another controller,
> > >> > something like a redirect but I dont wanna pass the selectTest value
> > >> > in the URL. Something like that:
>
> > >> > function index()
> > >> > {
> > >> >   if($this->data['Test']['selectTest'] == 'Test1')
> > >> >   {
> > >> >      $this->redirect(array('controller' => 'test', 'action' =>
> > >> > 'test1', 'data' => $this->data));
> > >> >   }
> > >> >   if($this->data['Test']['selectTest'] == 'Test2')
> > >> >   {
> > >> >      $this->redirect(array('controller' => 'test', 'action' =>
> > >> > 'test2', 'data' => $this->data));
> > >> >   }
> > >> >   if($this->data['Test']['selectTest'] == 'Test3')
> > >> >   {
> > >> >      $this->redirect(array('controller' => 'test', 'action' =>
> > >> > 'test3', 'data' => $this->data));
> > >> >   }
> > >> > }
>
> > >> > Changing redirect to send, I dont know...
> > >> > Is that possible? How can I do that?
>
> > >> > Thx
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Translate field names

2009-09-24 Thread emmexx

I searched the bakery and here but couldn't find an answer.

I'd like to translate all field names in a simple way.
The Translate behaviour is useful to translate field values but I want
to translate the field name, that is use another label for the name of
one or more fields in a table.

I can't believe cakephp has not a mechanism to translate field names:
they're used in forms and views by cake...

Thank you
   maxx

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



Re: Doubt in cake php

2009-09-24 Thread Martin Westin

Ever heard of a can of worms :)
(The whole "-This is MVC. -No, this is MVC" thing can turn nasty at
times.)

Cake allows no direct access to Models from Views. That is how the MVC
pattern has been implemented in Cake even though there are other
interpretations in other Frameworks. If everyone had the same
preference there wouldn't be such an abundance of frameworks doing
more or less the same things but is slightly different ways.

I have never found cakes strict partitioning to be a problem in any
particular situation I can recall. This is likely to be because the
web is request based. Every time you will ever see a view rendered
that has to have been as the result of a request. And all requests go
through a Controller so you will always have access to Model data in
every request and the ability to pass that data to the view. Things
can be very different in a desktop application or something like a
Flash application in which the code runs continuously throughout the
"session". In these types of applications the MVC works a bit
differently.

I get the feeling from your question that you may be thinking too
strict in another way (as may seem to do). You are not limited to
locking the User model to the Users controller and the users views
only. I tend to think of the models on the one side and the controller
and view as a pair on the other. That is, the controller and view(s)
are tightly linked but the models can be utilised a bit more freely.

I would never render the Posts/index view from the Users controller
for example. But I would, and often do, access the Post model from the
Users controller and pass the data to the users views. To finally get
to some kind of point: Why would it be a problem to "get the list of
user clubs in the controller and pass it to the view" as you put it?
That is the primary purpose of the controller. It is essentially there
to interpret the request, access the model(s) and present that data to
the view. If you accessed the Models from the Views, the Controller
would not do much more than request routing.

I hope you are not offended by this accidental lecture on MVC. A topic
I am not an expert in by any stretch of the imagination. I was trying
to explain my limited knowledge of the reasoning behind the design of
CakePHP and to explain that there is more than one way to design an
MVC framework. You already mentioned yourself that you knew of a way
to access your data. I am afraid the "better" way you are looking for
is not "allowed". You could of-course probably set the whole Model
instance as a view variable but I have never tried that.




On Sep 24, 10:59 am, hunny  wrote:
> Hi Guys,
>
> I am new to cakephp. I am having the following issue:
>
> I am displaying list of checkbox containing clubs to a login user. The
> list of clubs I am passing through the models via controllers in the
> traditional way.
>
> Now the logged in user should see his list of clubs automatically
> ticked. This list is present in another database.
>
> One solution is to get the list of user clubs in the controller itself
> and pass it to the view.
>
> But is there any alternative way, where I can access the user clubs in
> the view itself without loading in the controller.
>
> Basically i am looking for something similar like View Helpers in
> Zend. We can access the model data in views using view Helpers. Is
> there something similar in cakephp.
>
> P.S: I have asked this question to a few people who knew cake php and
> their first reaction is that you shouldn't access model data in views
> as it is against MVC. But let me assure you we can access model data
> in view as long as it is read only. At least that is what we are used
> to follow in Zend Framework. :)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Doubt in cake php

2009-09-24 Thread Jon Bennett

Hi,

> Basically i am looking for something similar like View Helpers in
> Zend. We can access the model data in views using view Helpers. Is
> there something similar in cakephp.

Short answer: you can't.

Longer answer: as the current version of cake is both php4 and 5
compatible, it uses arrays for data, not objects because objects are v
slow and limited in php4. This is why you pass the data from the model
to the controller to the view, and can't access models directly, even
read only, from the view.

Cake 1.3 I believe will use objects, certainly the future cakephp 2 and 3 will.

hth

Jon
ps: A more descriptive subject would probably have led to an answer
sooner - I only looked because I was curious, not because I knew I
could help

-- 

jon bennett
w: http://www.jben.net/
iChat (AIM): jbendotnet Skype: jon-bennett

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



Re: Redirect After Using render('action')

2009-09-24 Thread Miles J

I dont believe you have any control at all regarding "downloads".

On Sep 24, 12:17 pm, Tony Thomas  wrote:
> I have a controller function that's using $this->render('action') to
> render a view that creates a CSV file after submitting some info in a
> form.
>
> What I want to do is redirect the user after the CSV file is
> downloaded. So the steps would be:
>
> 1. User submits data.
> 2. Queries are run and a CSV file is rendered and saved by the user.
> 3. Controller redirects to another view.
>
> If I do a simple redirect using $this->redirect('controller/action'),
> the CSV file is not rendered, even though render() is called first. If
> I don't redirect, the CSV is successfully rendered, but the user is
> left with a form that is still filled-in. I'd like to redirect to
> another view and display a "Success" flash message once the CSV is
> rendered.
>
> Any tips?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: No Listbox for HABTM Relationship using Scaffold

2009-09-24 Thread mark_story

I don't have any issues with the habtm generation on either the git
head of 1.2 or the 1.2.5 package.  In fact there was an issue with
habtm selectbox generation with 1.2.4 and earlier.  See

http://code.cakephp.org/cakephp/commits/view/2c9fd2a4
http://code.cakephp.org/tickets/view/48

-Mark

On Sep 20, 8:59 pm, josephusbrown  wrote:
> The issue appears to be with the current version of cakephp 1.2.5. I
> went back to previous version and HABTM list boxes appear.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Private Messaging mysql

2009-09-24 Thread Miles J

You dont need that many tables like brian suggested. All you need is
two, users and messages.

messages:
- id
- user_id (sender)
- recipient_id (receiver)
- subject
- content
- status (read, unread, etc)
- userFolder (inbox, sent, trash)
- recipientFolder (inbox, sent, trash)
- created
- modified

On Sep 24, 12:14 pm, John Andersen  wrote:
> It is late (here in Latvia) and I am not sure that I remember
> correctly what I saw while playing around with saving HABTM associated
> data.
>
> If correctly, then providing the associated model as:
>
> $data[associatedModel][associatedModel] = array();
>
> deletes all the associations between the main model and the associated
> model.
>
> But this is from memory (soft tissue, may fail to retrieve
> correctly) :D so may somewhat be wrong!
> Enjoy,
>    John
>
> On Sep 24, 7:35 pm, brian  wrote:
> [snip]
>
> > That's a good question. I'm actually not sure how best to unlink a
> > pair of records. You could always add an id column to the join table
> > and do $this->Message->InboxMessage->del($id). But you'd need to
> > determine the $id first.
>
> > The other way would be to use a plain SQL:
> > $this->Message->query('DELETE FROM inboxes_messages WHERE message_id =
> > '.$message_id);
>
> > There's a Model::_deleteLinks() method that does just this but it's
> > protected. Maybe someone else knows the proper Cake way to do this.
>
> > You might also find Mariano's SoftDeletableBehavior of 
> > use:http://bakery.cakephp.org/articles/view/soft-delete-behavior
>
> > Just be aware that it's a few years old and may require some syntax
> > adjustments. I don't know if it's been kept up to date. Read the
> > comments in the article.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Redirect After Using render('action')

2009-09-24 Thread Tony Thomas

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

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

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

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

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



Re: Private Messaging mysql

2009-09-24 Thread John Andersen

It is late (here in Latvia) and I am not sure that I remember
correctly what I saw while playing around with saving HABTM associated
data.

If correctly, then providing the associated model as:

$data[associatedModel][associatedModel] = array();

deletes all the associations between the main model and the associated
model.

But this is from memory (soft tissue, may fail to retrieve
correctly) :D so may somewhat be wrong!
Enjoy,
   John


On Sep 24, 7:35 pm, brian  wrote:
[snip]
> That's a good question. I'm actually not sure how best to unlink a
> pair of records. You could always add an id column to the join table
> and do $this->Message->InboxMessage->del($id). But you'd need to
> determine the $id first.
>
> The other way would be to use a plain SQL:
> $this->Message->query('DELETE FROM inboxes_messages WHERE message_id =
> '.$message_id);
>
> There's a Model::_deleteLinks() method that does just this but it's
> protected. Maybe someone else knows the proper Cake way to do this.
>
> You might also find Mariano's SoftDeletableBehavior of 
> use:http://bakery.cakephp.org/articles/view/soft-delete-behavior
>
> Just be aware that it's a few years old and may require some syntax
> adjustments. I don't know if it's been kept up to date. Read the
> comments in the article.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



changing $session->flash('auth'); layout

2009-09-24 Thread adam

i am implementing a layout and am sad that i can not change the auth
flash layout, instead i am having to use session->check(), then
session->read(), and then to remove the message, session->flash() into
an area of the layout where it will not be displayed.

is there a way to chagne the flash layout for auth messages (like with
setFlash layouts?) without having to extend the session helper, or
maybe be able to delete the message with the session helper from the
layout without using flash() which displays the message?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: How to send data from controller to controller?

2009-09-24 Thread LPaulino

Thx man. I found the method (setAction (action, [param, param,
param])) here: http://cakephp.org/files/Resources/CakePHP-1.2-Cheatsheet.pdf

1 last question: How can I can get those params in the other action?

Thx

On Sep 24, 2:51 pm, brian  wrote:
> Use $this->setAction('action_name'), then.
>
> http://api.cakephp.org/class/controller#method-ControllersetAction
>
>
>
> On Thu, Sep 24, 2009 at 1:20 PM, LPaulino  wrote:
>
> > ups I said it wrong, I mean from action to action
>
> > On 24 set, 13:56, brian  wrote:
> >> Those redirects are pointing to the same controller.
>
> >> Why not simply point the form at the 2nd controller?
>
> >> On Thu, Sep 24, 2009 at 9:16 AM, LPaulino  wrote:
>
> >> > Hi guys,
>
> >> > I would like to know how can I send data from 1 controller to another
> >> > one. Let me explain better why I need that.
>
> >> > I have in my view 1 form with a select:
> >> > 
> >> > 
> >> >   Test1 
> >> >   Test2 
> >> >   Test3 
> >> > 
> >> > 
> >> > 
>
> >> > When it is send to controller "test", the action index will check
> >> > which test was select and will send the data to another controller,
> >> > something like a redirect but I dont wanna pass the selectTest value
> >> > in the URL. Something like that:
>
> >> > function index()
> >> > {
> >> >   if($this->data['Test']['selectTest'] == 'Test1')
> >> >   {
> >> >      $this->redirect(array('controller' => 'test', 'action' =>
> >> > 'test1', 'data' => $this->data));
> >> >   }
> >> >   if($this->data['Test']['selectTest'] == 'Test2')
> >> >   {
> >> >      $this->redirect(array('controller' => 'test', 'action' =>
> >> > 'test2', 'data' => $this->data));
> >> >   }
> >> >   if($this->data['Test']['selectTest'] == 'Test3')
> >> >   {
> >> >      $this->redirect(array('controller' => 'test', 'action' =>
> >> > 'test3', 'data' => $this->data));
> >> >   }
> >> > }
>
> >> > Changing redirect to send, I dont know...
> >> > Is that possible? How can I do that?
>
> >> > Thx
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Problem viewing data...

2009-09-24 Thread brian

Put debug("id: ${id}") in your controller. Maybe it's not what you
think it is. Do you have a route for this action?

On Thu, Sep 24, 2009 at 1:38 PM, mig_akira  wrote:
>
>
> Ops, sorry, here's the code for views/users/view.ctp
> [code]
> 
> 
> 
>        
>                > ?>
>                >
>                        
>
>                
>                > ?>
>                >
>                        
>
> (and son on)..
> [/code]
>
> the contents are not the same, because it happens for every user...doesn't
> matter if it's user number 7 or 123...=(
>
> I don't get, because all other views for other controllers, such as for
> groups, are correct and are pretty much similar to the users view!
>
>
>
> brian-263 wrote:
>>
>>
>> On Mon, Sep 21, 2009 at 4:47 PM, mig_akira  wrote:
>>>
>>>
>>> hello everyone!
>>>
>>> I'm building a simple web page, with Auth/ACL and a few members.
>>>
>>> Problem is, I baked the admin part of the site, and everything works fine
>>> except for one thing! In my users admin page, I click in "view", but it
>>> insists in showing the view for the first user (in this case, the admin).
>>>
>>> In my url, it shows /users/view/7 (number of the user's ID), but it shows
>>> the data for the user with ID == 1.
>>>
>>> Funny thing is, if I click EDIT instead of VIEW, it shows the correct
>>> user!
>>> (and the URL is /users/edit/7)
>>>
>>> Here are the codes for the VIEWS/USERS/INDEX.CTP :
>>> [code]
>>> >> $i = 0;
>>> foreach ($users as $user):
>>>        $class = null;
>>>        if ($i++ % 2 == 0) {
>>>                $class = ' class="altrow"';
>>>        }
>>> ?>
>>>        >
>>>                
>>>                        
>>>                
>>>                
>>>                        
>>>                
>>>                
>>>                        
>>>                
>>>                
>>>                        link(__('View', true),
>>> array('action'=>'view',
>>> $user['User']['id'])); ?>
>>>                        link(__('Edit', true),
>>> array('action'=>'edit',
>>> $user['User']['id'])); ?>
>>>                        link(__('Delete', true),
>>> array('action'=>'delete',
>>> $user['User']['id']), null, sprintf(__('Are you sure you want to delete #
>>> %s?', true), $user['User']['id'])); ?>
>>>                
>>>        
>>> 
>>> [/code]
>>
>>
>> That's the view for index(), not view(). The latter would not have a
>> foreach loop, as you should only have a single User in your array.
>>
>>> And here's for the action view in the users_Controller.php:
>>> [code]
>>> function view($id = null) {
>>>                if (!$id) {
>>>                        $this->Session->setFlash(__('Invalid User.',
>>> true));
>>>                        $this->redirect(array('action'=>'index'));
>>>                }
>>>                $this->set('user', $this->User->read(null, $id));
>>>        }
>>> [/code]
>>>
>>> What could be the problem?
>>>
>>
>> Check that you're looking at the proper view file. Then, add
>> debug($user). It's possible that the record in the database is the
>> same for User 1 & 7.
>>
>> >
>>
>>
>
> --
> View this message in context: 
> http://www.nabble.com/Problem-viewing-data...-tp25530475p25578012.html
> Sent from the CakePHP mailing list archive at Nabble.com.
>
>
> >
>

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



Re: How to send data from controller to controller?

2009-09-24 Thread brian

Use $this->setAction('action_name'), then.

http://api.cakephp.org/class/controller#method-ControllersetAction

On Thu, Sep 24, 2009 at 1:20 PM, LPaulino  wrote:
>
> ups I said it wrong, I mean from action to action
>
> On 24 set, 13:56, brian  wrote:
>> Those redirects are pointing to the same controller.
>>
>> Why not simply point the form at the 2nd controller?
>>
>>
>>
>> On Thu, Sep 24, 2009 at 9:16 AM, LPaulino  wrote:
>>
>> > Hi guys,
>>
>> > I would like to know how can I send data from 1 controller to another
>> > one. Let me explain better why I need that.
>>
>> > I have in my view 1 form with a select:
>> > 
>> > 
>> >   Test1 
>> >   Test2 
>> >   Test3 
>> > 
>> > 
>> > 
>>
>> > When it is send to controller "test", the action index will check
>> > which test was select and will send the data to another controller,
>> > something like a redirect but I dont wanna pass the selectTest value
>> > in the URL. Something like that:
>>
>> > function index()
>> > {
>> >   if($this->data['Test']['selectTest'] == 'Test1')
>> >   {
>> >      $this->redirect(array('controller' => 'test', 'action' =>
>> > 'test1', 'data' => $this->data));
>> >   }
>> >   if($this->data['Test']['selectTest'] == 'Test2')
>> >   {
>> >      $this->redirect(array('controller' => 'test', 'action' =>
>> > 'test2', 'data' => $this->data));
>> >   }
>> >   if($this->data['Test']['selectTest'] == 'Test3')
>> >   {
>> >      $this->redirect(array('controller' => 'test', 'action' =>
>> > 'test3', 'data' => $this->data));
>> >   }
>> > }
>>
>> > Changing redirect to send, I dont know...
>> > Is that possible? How can I do that?
>>
>> > Thx
> >
>

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



Re: Problem viewing data...

2009-09-24 Thread mig_akira


Ops, sorry, here's the code for views/users/view.ctp
[code]




>
>

 

>
>

 
(and son on)..
[/code]

the contents are not the same, because it happens for every user...doesn't
matter if it's user number 7 or 123...=(

I don't get, because all other views for other controllers, such as for
groups, are correct and are pretty much similar to the users view!



brian-263 wrote:
> 
> 
> On Mon, Sep 21, 2009 at 4:47 PM, mig_akira  wrote:
>>
>>
>> hello everyone!
>>
>> I'm building a simple web page, with Auth/ACL and a few members.
>>
>> Problem is, I baked the admin part of the site, and everything works fine
>> except for one thing! In my users admin page, I click in "view", but it
>> insists in showing the view for the first user (in this case, the admin).
>>
>> In my url, it shows /users/view/7 (number of the user's ID), but it shows
>> the data for the user with ID == 1.
>>
>> Funny thing is, if I click EDIT instead of VIEW, it shows the correct
>> user!
>> (and the URL is /users/edit/7)
>>
>> Here are the codes for the VIEWS/USERS/INDEX.CTP :
>> [code]
>> > $i = 0;
>> foreach ($users as $user):
>>        $class = null;
>>        if ($i++ % 2 == 0) {
>>                $class = ' class="altrow"';
>>        }
>> ?>
>>        >
>>                
>>                        
>>                
>>                
>>                        
>>                
>>                
>>                        
>>                
>>                
>>                        link(__('View', true),
>> array('action'=>'view',
>> $user['User']['id'])); ?>
>>                        link(__('Edit', true),
>> array('action'=>'edit',
>> $user['User']['id'])); ?>
>>                        link(__('Delete', true),
>> array('action'=>'delete',
>> $user['User']['id']), null, sprintf(__('Are you sure you want to delete #
>> %s?', true), $user['User']['id'])); ?>
>>                
>>        
>> 
>> [/code]
> 
> 
> That's the view for index(), not view(). The latter would not have a
> foreach loop, as you should only have a single User in your array.
> 
>> And here's for the action view in the users_Controller.php:
>> [code]
>> function view($id = null) {
>>                if (!$id) {
>>                        $this->Session->setFlash(__('Invalid User.',
>> true));
>>                        $this->redirect(array('action'=>'index'));
>>                }
>>                $this->set('user', $this->User->read(null, $id));
>>        }
>> [/code]
>>
>> What could be the problem?
>>
> 
> Check that you're looking at the proper view file. Then, add
> debug($user). It's possible that the record in the database is the
> same for User 1 & 7.
> 
> > 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Problem-viewing-data...-tp25530475p25578012.html
Sent from the CakePHP mailing list archive at Nabble.com.


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



Re: How to send data from controller to controller?

2009-09-24 Thread LPaulino

ups I said it wrong, I mean from action to action

On 24 set, 13:56, brian  wrote:
> Those redirects are pointing to the same controller.
>
> Why not simply point the form at the 2nd controller?
>
>
>
> On Thu, Sep 24, 2009 at 9:16 AM, LPaulino  wrote:
>
> > Hi guys,
>
> > I would like to know how can I send data from 1 controller to another
> > one. Let me explain better why I need that.
>
> > I have in my view 1 form with a select:
> > 
> > 
> >   Test1 
> >   Test2 
> >   Test3 
> > 
> > 
> > 
>
> > When it is send to controller "test", the action index will check
> > which test was select and will send the data to another controller,
> > something like a redirect but I dont wanna pass the selectTest value
> > in the URL. Something like that:
>
> > function index()
> > {
> >   if($this->data['Test']['selectTest'] == 'Test1')
> >   {
> >      $this->redirect(array('controller' => 'test', 'action' =>
> > 'test1', 'data' => $this->data));
> >   }
> >   if($this->data['Test']['selectTest'] == 'Test2')
> >   {
> >      $this->redirect(array('controller' => 'test', 'action' =>
> > 'test2', 'data' => $this->data));
> >   }
> >   if($this->data['Test']['selectTest'] == 'Test3')
> >   {
> >      $this->redirect(array('controller' => 'test', 'action' =>
> > 'test3', 'data' => $this->data));
> >   }
> > }
>
> > Changing redirect to send, I dont know...
> > Is that possible? How can I do that?
>
> > Thx
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: How to send data from controller to controller?

2009-09-24 Thread brian

Those redirects are pointing to the same controller.

Why not simply point the form at the 2nd controller?

On Thu, Sep 24, 2009 at 9:16 AM, LPaulino  wrote:
>
> Hi guys,
>
> I would like to know how can I send data from 1 controller to another
> one. Let me explain better why I need that.
>
> I have in my view 1 form with a select:
> 
> 
>   Test1 
>   Test2 
>   Test3 
> 
> 
> 
>
> When it is send to controller "test", the action index will check
> which test was select and will send the data to another controller,
> something like a redirect but I dont wanna pass the selectTest value
> in the URL. Something like that:
>
> function index()
> {
>   if($this->data['Test']['selectTest'] == 'Test1')
>   {
>      $this->redirect(array('controller' => 'test', 'action' =>
> 'test1', 'data' => $this->data));
>   }
>   if($this->data['Test']['selectTest'] == 'Test2')
>   {
>      $this->redirect(array('controller' => 'test', 'action' =>
> 'test2', 'data' => $this->data));
>   }
>   if($this->data['Test']['selectTest'] == 'Test3')
>   {
>      $this->redirect(array('controller' => 'test', 'action' =>
> 'test3', 'data' => $this->data));
>   }
> }
>
> Changing redirect to send, I dont know...
> Is that possible? How can I do that?
>
> Thx
> >
>

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



Re: Choose which database to usa, on the fly

2009-09-24 Thread Cristian Cassina

Thank you and thank to WebbedIT fro your kid replies and suggestions. 
I'm going to read the article you posted and I'll decide which path to 
follow.

Cristian

Jorge Horacio Cué Cantú ha scritto:
> Hello,
>
> One approach I take with an application is: Each different "customer" 
> (I am developping a SaaS site) o "company" in Your case, can have an 
> specific domain (  www.company1.com , 
> www.company2.com , ...)   then based on 
> domain the application can select an specific database.
>
> Check following artile in the backery;
>
> 
> http://bakery.cakephp.org/articles/view/one-core-one-app-multiple-domains
>
> That way you can select even more things, such as: "themes", 
> "database", "AC/ACO", modules..."
>
> I hope this can help You. Regards.
>
>
> 2009/9/23 WebbedIT mailto:p...@webbedit.co.uk>>
>
>
> Your query is off topic so really needs it's own topic.
>
> I'm sure you could probably do this, but not sure if it is the right
> way to go.
>
> Why would you separate different companies into different databases?
> I would imagine each database would have duplicate tables/models etc.
> so simply having a company_id foreignKey within each model would allow
> you to pull the relevant data without having to maintain multiple
> databases and their connections.
>
> I have done this with a centrally hosted CMS which drives around 20
> completely different websites from one database, and I am currently
> working on a portal/community website for the third sector where any
> number of non-profit organisations can manage their own sub-sites.
>
> Paul.
>
>
>
> >


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



Re: Making Databases Optional in CakePHP

2009-09-24 Thread mark_story

Databases are optional.  Set $uses = array() in your controller, to
prevent it from loading any of the model classes.

-Mark

On Sep 24, 7:31 am, Erik Kristensen  wrote:
> Good Morning Everyone!
>
> I am a long time user and I absolutely love CakePHP, however there is
> one problem that I have run into lately that I think deserves some
> attention, though I am sure there are those that will disagree with
> me.
>
> For the most part most of the applications I have written have all had
> databases and so it has never been a problem, however recently, I have
> an pre-existing open source application that I am a developer on that
> doesn't use a database, and I find that CakePHP doesn't exactly play
> nice without a database. I found a few articles on the internet that
> talk about creating a dummy dbo source, etc etc to get CakePHP to work
> without a database, but I feel that a better solution might be
> warrented.
>
> Why not add an option to the config.php file to disable database use?
> Or at least add an option to make a database optional?
>
> Other frameworks handle this by just allowing to include the use of
> models or to not include them.
>
> Now I am not suggesting we change to be like other frameworks, but
> allow one to not use them and have the entire framework understand
> that it doesn't need to expect a database connection I think only
> makes sense, especially to open the doors to people that don't want to
> use the framework because of the database requirements.
>
> I am big on UI in my applications, and I found that CakePHP View and
> Theming capabilities dwarf those of other frameworks, IMHO, that is
> one of the biggest reasons I want to use CakePHP for this project that
> doesn't use a database (but might in the future, thats why being
> optional would be nice)
>
> Thoughts on this?
> -Erik
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Using same Auth component in admin and client

2009-09-24 Thread brian

$admin = Configure::read('Routing.admin');

if (isset($this->params[$admin]) && $this->params[$admin])

But I've no idea if Auth can handle having 2 models like this.

On Thu, Sep 24, 2009 at 7:06 AM, vinodkalpaka  wrote:
>
> How can I use same Auth component in admin and client properly? What
> is the use of $this->Auth->userModel ="modelname" . I am using users
> table in admin side and customers table in client side
>
> I have used the following code in beforeFilter() function of
> AppController
>
> here is the code
> $this->pos = strpos($_SERVER['REQUEST_URI'], "admin");
> if ($this->pos != true)
> $this->Auth->userModel = 'Customer';
> else
> $this->Auth->userModel = 'User';
>
> But this do not work properly.
> I can login to the client panel if Use the line $this->Auth->userModel
> = 'Customer';, but admin panel validation fails.
> Please advice me.
>
> >
>

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



Re: Private Messaging mysql

2009-09-24 Thread schneimi

Hi,

I use some similar setup as you thought about:

messages table
  user_id
  sender_id
  receiver_id
  ...

MessageModel
  var $belongsTo = array('User' =>
 array('className'  => 'User',
   'foreignKey' => 'user_id'
 ),
 'Sender' =>
 array('className'  => 'User',
   'foreignKey' => 'sender_id'
 ),
 'Receiver' =>
 array('className'  => 'User',
   'foreignKey' => 'receiver_id'
 )
   );

Outbox is where sender_id=user_id and Inbox is where
user_id=receiver_id and it should be no problem to add a folder
model.

You really have to copy the message on send, definitly if you enable
to send one message to multiple other users.

hope this helps,

Michael

On 23 Sep., 10:58, invisibleman  wrote:
> I need some help in creating the right tables for a private messaging
> system for cakephp. Can anyone help.
>
> Basically at the moment i have the following tables
>
> Users
> - id
> - name
> - email
>
> Messages
> - id
> - subject
> - body
> - datesent
>
> MessageFolders
> - id
> - foldername
> - status
>
> The messagefolders table contains inbox and outbox i need to link the
> users, messages and messagesfolders tables together but what i need
> practically is for a message to be stored in the sending users outbox
> and in the receiving users inbox but both users are able to delete
> their messages but it should not effect the other user.
>
> E.g if i sent a message to a user and i delete it from my outbox the
> recipient user should still have the message in their inbox.
>
> I'm not sure if there should be 2 copies of the message or some status
> field as to whether a user can see it or not.
>
> I'm just looking for some guidance, Any help much appreciated
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Private Messaging mysql

2009-09-24 Thread brian

On Thu, Sep 24, 2009 at 7:56 AM, invisibleman  wrote:
>
> Ah Thank you that makes alot of sense, for some reason i couldn't wrap
> my head around the best way to do this.
> I guess my next questions is how do i only delete from the join table
> in cakephp?
>
> Usually to delete from a table like the inbox or message i would use
> $this->NameofModel->delete(), do i need to setup a model file for the
> jointable too or something to delete specifically from that?
>

That's a good question. I'm actually not sure how best to unlink a
pair of records. You could always add an id column to the join table
and do $this->Message->InboxMessage->del($id). But you'd need to
determine the $id first.

The other way would be to use a plain SQL:
$this->Message->query('DELETE FROM inboxes_messages WHERE message_id =
'.$message_id);

There's a Model::_deleteLinks() method that does just this but it's
protected. Maybe someone else knows the proper Cake way to do this.

You might also find Mariano's SoftDeletableBehavior of use:
http://bakery.cakephp.org/articles/view/soft-delete-behavior

Just be aware that it's a few years old and may require some syntax
adjustments. I don't know if it's been kept up to date. Read the
comments in the article.

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



Re: Best way to accomplish acl for database records owned by a user

2009-09-24 Thread brian
You could also just use $this->Auth->user('id') which gets the info
from the session.

On Thu, Sep 24, 2009 at 10:09 AM, Rick  wrote:
>
> I know that globals are bad but...
>
> I just set a global $gblCurrentUser when the user logs in.  Then
> accessing that in models, I can add a select condition for that user
> in the beforeFind etc..
>
> You get the idea?
>
> Rick
>
>
>
>
> On Sep 24, 12:20 am, brian  wrote:
>> I did something similar to this. However, I was so overwhelmed by the
>> contradictory and/or incomplete information I found about Cake's ACL
>> (mostly because it was quite dated) that I really don't know for sure
>> that I did it the best way.
>>
>> My app is an extranet that has several different Groups. The
>> navigation consists of many Sections that are stored as a tree (MPTT).
>> Some Sections may not be seen by certain Groups. So, to display this
>> navigation tree, I called this method in my SectionsController:
>>
>> public function nav($group_id = null)
>> {
>>         if (is_null($group_id))
>>         {
>>                 if (!$this->params['admin'])
>>                 {
>>                         $group_id = $this->Auth->user('group_id');
>>                 }
>>         }
>>         $this->Session->write('group_id_for_nav', $group_id);
>>
>>         /* try getting the nodes from the cache
>>          */
>>         $sections = Cache::read("group_sections_${group_id}", 'default');
>>
>>         if (!$sections)
>>         {
>>                 /* fetch the permissions for this group
>>                  */
>>                 $perms = $this->Acl->Aco->find(
>>                         'all',
>>                         array(
>>                                 'fields' => array('Aco.foreign_key'),
>>                                 'conditions' => array(
>>                                         'Aco.model' => 'Section',
>>                                         'Aco.id = Permission.aco_id'
>>                                 ),
>>                                 'recursive' => -1,
>>                                 'joins' => array(
>>                                         array(
>>                                                 'table' => 'aros',
>>                                                 'alias' => 'Aro',
>>                                                 'type' => 'INNER',
>>                                                 'conditions'=> array(
>>                                                         'Aro.model' => 
>> 'Group',
>>                                                         "Aro.foreign_key = 
>> ${group_id}"
>>                                                 )
>>                                         ),
>>                                         array(
>>                                                 'table' => 'aros_acos',
>>                                                 'alias' => 'Permission',
>>                                                 'type' => 'INNER',
>>                                                 'conditions'=> array(
>>                                                         'Permission.aro_id = 
>> Aro.id',
>>                                                         'Permission._read >= 
>> 0'
>>                                                 )
>>                                         )
>>                                 )
>>                         )
>>                 );
>>
>>                 $section_ids = Set::extract($perms, '{n}.Aco.foreign_key');
>>
>>                 /* we don't want to see the root node
>>                  */
>>                 unset($section_ids[0]);
>>
>>                 /* now grab the sections these permissions allow
>>                  */
>>                 $sections = $this->Section->threaded($section_ids);
>>
>>                 /* save this group's allowed sections
>>                  */
>>                 Cache::write("group_sections_${group_id}", $sections, 
>> 'default');
>>         }
>>         return $sections;
>>
>> }
>>
>> So, the Aco.foreign_key fields I'm after correspond to Section.ids.
>> Once i have those, I fetch the relevant Sections as a threaded list.
>> Obviously, you'd just be interested in the record IDs.
>>
>> What I'm storing in the cache is the Sections themselves. For your
>> case, you'd likely want to save the record IDs in the session instead
>> of caching them.
>>
>> Anyway, the important thing is the joins used to get at the model IDs
>> for your record-level ACL through the ACO.foreign_key.
>>
>> Let me know if you want more info.
>>
>> On Wed, Sep 23, 2009 at 5:19 PM, rOger  wrote:
>>
>> > Hi @all,
>>
>> > I'm really new to CakePHP and I read about the ACL modell of CakePHP.
>> > As usual also the examples seems to be simple so it is easy to
>> > understand the system. I'm evaluating cakePHP for a new project where
>> > I have records which belongs to a given user = that is the owner of
>> > the record. Now I want to have a ACL system which enables some groups
>> > (like 

Re: jQuery support in cake

2009-09-24 Thread brian

The 1.3 release will include libs to allow or using jQuery instead of
Prototype. For now, though, just don't use the helper.

On Thu, Sep 24, 2009 at 4:37 AM, Intunet  wrote:
>
> I'm just looking at CakePHP as a viable solution to building
> applications and am a big fan of jQuery. For me and a lot of my
> collegues, jQuery is a cut above the likes of Prototype which it looks
> like CakePHP supports more strictly.
>
> Do you think that CakePHP is likely to ever switch its attention from
> Prototype to jQuery as its native js framework for its AJAX functions?
>
> >
>

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



Doubt in cake php

2009-09-24 Thread hunny

Hi Guys,

I am new to cakephp. I am having the following issue:

I am displaying list of checkbox containing clubs to a login user. The
list of clubs I am passing through the models via controllers in the
traditional way.

Now the logged in user should see his list of clubs automatically
ticked. This list is present in another database.

One solution is to get the list of user clubs in the controller itself
and pass it to the view.

But is there any alternative way, where I can access the user clubs in
the view itself without loading in the controller.

Basically i am looking for something similar like View Helpers in
Zend. We can access the model data in views using view Helpers. Is
there something similar in cakephp.

P.S: I have asked this question to a few people who knew cake php and
their first reaction is that you shouldn't access model data in views
as it is against MVC. But let me assure you we can access model data
in view as long as it is read only. At least that is what we are used
to follow in Zend Framework. :)

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



Enterprise Level App using cakephp

2009-09-24 Thread gabrielr

Hi everybody,
First of all, congratulations for this Framework, it mak programmer's
life easier.
Well, I have 2 Questions to this group.

Is anybody use cakephp for developing an Enterprise Level
Application?, and What Kind of App was developed?


I  have Developed an aplication for Human Resources, and it Works
perfectly.


Thanks for Your future answers !

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



i can't get data from table in Autocompletion

2009-09-24 Thread Jiru

In my autocomplete_controller()   i use the function

function getData(){

$this->layout = 'ajax';

$this->set("typed",$this->data['Autocomplete']['AutocompleteName']);


for($i=0;$i<10;$i++){
$items[] = rand(1,100);
}

$this->set("items",$items);
}

it will show the random numbers 1 to 100 in autocompletion text field
when i type any letter.  Anybody can give me the code to access the
data from a table. I expect the query. Help me plz.!

I add the related files here!
// get_data.ctp








//index.ctp

charset("UTF-8");
$javascript->link("prototype",false);
$javascript->link("scriptaculous",false);
$html->css("cake.ajax");
?>


create('Autocomplete');?>


autocomplete('AutocompleteName',"getData",array());
?>


end('Submit');?>



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



how to migrate old system to cakephp?

2009-09-24 Thread gchen89

We have a website which is running on LAMP. The initial version was
developed in early this century. Till today, lots of programmers have
worked on it and lots of changes have been made. Lots of patches can
be found here and there in the program. Recently, we need to add some
new stuff. This will be lots of code changes again like we used to.
The code of current system is not readable and maintainable and we are
going to re-write the whole thing using php. We found lots of php
frameworks available on web we chose cakephp after comparisons with
others and doing tests ourselves. We already have tables and data
there and fortunately our tables already conform to cakephp’s
conventions. I am here looking for some good suggestions how to
migrate old system to cakephp? Since all the functions were written
and are working very well right now we don’t want to re-write
everything from scratch. We just want to do copy and paste and make as
little modification as possible. Any suggestions? For example, we
defined lots of constants in our system, the constants are stored in
one php file, where to put the file in cakephp? We already have some
homepages, we don’t want to change their looks. I know we can put
those homepages in the view folder in cakephp but those homepages are
mixed with html and php code, is there a good way to keep the homepage
design but move the php code to somewhere in cakephp? And we have new
homepages designed in dreamweaver, is there any suggestion when
designing the homepages in dreamweaver when later on we are going to
put them in cakephp framework for out projcets?
Thank you !

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



Re: eCommerce question

2009-09-24 Thread Serverdog

I usually use 2 methods depending on the requirements:

1. Stock = actual stock - cart contents for all users (cart expires
after 30 min activity)
2. Stock availability is checked on produc search/display and double
checked when the user clicks Confirm Checkout. (Obivously this one has
usability implications).

It all depends on what your supplies are like at the end of the day.
If you can get extra stock in the next day and ship it straight away -
no issues overselling.

Andy

On Sep 24, 11:44 am, cakeFreak  wrote:
> Hey guys,
>
> my question is about developing an eCommerce solution in PHP, and it
> about dealing with stock quantities.
>
> When you have real products (not services or e-books, for example, but
> real books instead) how do you deal with the following situation:
>
> 1) you have 10 copies of Book "Learning CakePHP"  in stock
> 2) you have 20 customers in the eCommerce website at the same time
> 3) 15 customers add a copy of the Book "Learning CakePHP" to their
> shopping chart
> 4) only 5 customers finally biught the book
>
> At this point my question is: how do you work with your stock values?
> Decreasing the stock every time a customer adds to chart, is a bit
> risky.
> Maybe using a kinda average purchasing rate (say only 50% of those
> that added to chart bought the book) it would be less risky to manage
> stock values?
>
> Dunno if I'm overcomplicating the problem. Just Curious about your
> opinion and solutions to this issue.
>
> Daniel

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



Registration with Country---State/Region---City

2009-09-24 Thread nameless

When a users wants to register on my site, he must select Country,
State/Region and City.

How could I do that ?
I have bought Ip2location but it's incomplete for some cities.


Ip2Location is like this ( latitude and longitude is unnecessary ):

"UNITED STATES","MASSACHUSETTS","BEVERLY","42.5685","-70.8619"
"UNITED STATES","CONNECTICUT","FAIRFIELD","41.1862","-73.2613"
"UNITED STATES","NEW JERSEY","LEBANON","40.6482","-74.817"
"SPAIN","CASTILLA Y LEON","VALLADOLID","41.65","-4.717"
"SPAIN","CASTILLA Y LEON","SALAMANCA","40.967","-5.65"
"SPAIN","CASTILLA Y LEON","VALLADOLID","41.65","-4.717"
"SPAIN","CASTILLA Y LEON","VALLADOLID","41.65","-4.717"
"ITALY","LAZIO","ROME","41.9","12.483"
"ITALY","LAZIO","ROME","41.9","12.483"
"ITALY","LAZIO","ROME","41.9","12.483"
"ITALY","LAZIO","ROME","41.9","12.483"


If there is an alternative solution tell me ( also without database
because ip2location database is 500MB !! ).
Thank you !!

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



Using same Auth component in admin and client

2009-09-24 Thread vinodkalpaka

How can I use same Auth component in admin and client properly? What
is the use of $this->Auth->userModel ="modelname" . I am using users
table in admin side and customers table in client side

I have used the following code in beforeFilter() function of
AppController

here is the code
$this->pos = strpos($_SERVER['REQUEST_URI'], "admin");
if ($this->pos != true)
$this->Auth->userModel = 'Customer';
else
$this->Auth->userModel = 'User';

But this do not work properly.
I can login to the client panel if Use the line $this->Auth->userModel
= 'Customer';, but admin panel validation fails.
Please advice me.

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



jQuery support in cake

2009-09-24 Thread Intunet

I'm just looking at CakePHP as a viable solution to building
applications and am a big fan of jQuery. For me and a lot of my
collegues, jQuery is a cut above the likes of Prototype which it looks
like CakePHP supports more strictly.

Do you think that CakePHP is likely to ever switch its attention from
Prototype to jQuery as its native js framework for its AJAX functions?

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



Re: Private Messaging mysql

2009-09-24 Thread invisibleman

Ah Thank you that makes alot of sense, for some reason i couldn't wrap
my head around the best way to do this.
I guess my next questions is how do i only delete from the join table
in cakephp?

Usually to delete from a table like the inbox or message i would use
$this->NameofModel->delete(), do i need to setup a model file for the
jointable too or something to delete specifically from that?

Thanks for you help

On Sep 23, 5:30 pm, brian  wrote:
> Off the top of my head ...
>
> users
> - id
> - name
> - email
>
> messages
> - id
> - created
> - subject
> - content
>
> inboxes
> - id
> - user_id
>
> outboxes
> - id
> - user_id
>
> inboxes_messages
> - inbox_id
> - message_id
>
> messages_outboxes
> - message_id
> - outbox_id
>
> User hasOne Inbox, Outbox
>
> Better might be to have several for each user:
> User hasMany Inbox, Outbox
>
> Inbox HABTM Message HABTM Inbox
> Outbox HABTM Message HABTM Outbox
>
> So, to "delete" a message, you simply remove the appropriate record in
> the join table. The Message, itself, is left in place and there's just
> one copy in the DB.
>
> On Wed, Sep 23, 2009 at 4:58 AM, invisibleman  wrote:
>
> > I need some help in creating the right tables for a private messaging
> > system for cakephp. Can anyone help.
>
> > Basically at the moment i have the following tables
>
> > Users
> > - id
> > - name
> > - email
>
> > Messages
> > - id
> > - subject
> > - body
> > - datesent
>
> > MessageFolders
> > - id
> > - foldername
> > - status
>
> > The messagefolders table contains inbox and outbox i need to link the
> > users, messages and messagesfolders tables together but what i need
> > practically is for a message to be stored in the sending users outbox
> > and in the receiving users inbox but both users are able to delete
> > their messages but it should not effect the other user.
>
> > E.g if i sent a message to a user and i delete it from my outbox the
> > recipient user should still have the message in their inbox.
>
> > I'm not sure if there should be 2 copies of the message or some status
> > field as to whether a user can see it or not.
>
> > I'm just looking for some guidance, Any help much appreciated

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



Validation for client and admin panel

2009-09-24 Thread vinodkalpaka


How can I use same Auth component in admin and client properly? What is the
use of $this->Auth->userModel ="modelname" . I am using users table in admin
side and customers table in client side

I have used the following code in beforeFilter() function of AppController

here is the code
$this->pos = strpos($_SERVER['REQUEST_URI'], "admin");
if ($this->pos != true)
$this->Auth->userModel = 'Customer';
else
$this->Auth->userModel = 'User';

But this do not work properly.  
I can login to the client panel if Use the line $this->Auth->userModel =
'Customer';, but admin panel validation fails.
Please advice me.
-- 
View this message in context: 
http://www.nabble.com/Validation-for-client-and-admin-panel-tp25556513p25556513.html
Sent from the CakePHP mailing list archive at Nabble.com.


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



Re: Choose which database to usa, on the fly

2009-09-24 Thread Jorge Horacio Cué Cantú
Hello,

One approach I take with an application is: Each different "customer" (I am
developping a SaaS site) o "company" in Your case, can have an specific
domain (  www.company1.com, www.company2.com, ...)   then based on domain
the application can select an specific database.

Check following artile in the backery;


http://bakery.cakephp.org/articles/view/one-core-one-app-multiple-domains

That way you can select even more things, such as: "themes", "database",
"AC/ACO", modules..."

I hope this can help You. Regards.


2009/9/23 WebbedIT 

>
> Your query is off topic so really needs it's own topic.
>
> I'm sure you could probably do this, but not sure if it is the right
> way to go.
>
> Why would you separate different companies into different databases?
> I would imagine each database would have duplicate tables/models etc.
> so simply having a company_id foreignKey within each model would allow
> you to pull the relevant data without having to maintain multiple
> databases and their connections.
>
> I have done this with a centrally hosted CMS which drives around 20
> completely different websites from one database, and I am currently
> working on a portal/community website for the third sector where any
> number of non-profit organisations can manage their own sub-sites.
>
> Paul.
> >
>

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



RE: Search and Find all

2009-09-24 Thread Dave Maharaj :: WidePixels.com

No problem. If you have more questions you know what to do.

Dave 

-Original Message-
From: Simon [mailto:simon_d...@hotmail.com] 
Sent: September-24-09 12:21 PM
To: CakePHP
Subject: Re: Search and Find all


thank you Dave And Brian

i got it i'm knida blonde  haha

here is what i did

function search($item = null) {
$item = $this->params['url']['q'];
$params = array('conditions' => array(
'AND' => array(
'OR' =>array(
'Post.name LIKE'  => '%' . $item . '%',
'Post.date LIKE'  => '%' . $item . '%',
'Post.poster LIKE' => '%' . $item . '%'),
'NOT'=>array('Post.active'=> '0'))),
 'order' => 'Post.name',
 'recursive' => 1));


if (!$item) {
$this->Session->setFlash(__('No Search Items Found',
true));
$this->redirect(array('action'=>'index'));
}

$this->set('results', $this->Post->find('all' , $params));


}




On Sep 24, 7:18 am, Simon  wrote:
> you ment like this correct me if i worng
>
> function search($item = null) {
>     $item = $this->params['url']['q'];
>     $post = $this->Post->find('all', $params =>
>         array('conditions' => array(
>             'AND' => array(
>                 'OR' =>array(
>                     'Post.name LIKE'      => '%' . $item . '%',
>                     'Post.date LIKE'  => '%' . $item . '%',
>                     'Post.poster LIKE' => '%' . $item . '%'),
>             'NOT'=>array('Post.active'=> '0'))),
>              'order' => 'Post.name',
>              'recursive' => 1));
>
>                 if (!$item) {
>                         $this->Session->setFlash(__('No Search Items 
> Found', true));
>                         $this->redirect(array('action'=>'index'));
>                 }
>
>                 $this->set('search', $posts);
>                 $this->set('results', $this->Post->find('all' , 
> $params));
>
>         }
>
> On Sep 24, 6:56 am, "Dave Maharaj :: WidePixels.com"
>
>
>
>  wrote:
> > Your telling it to find nothing.
>
> > You need to tell it what to find.
>
> > Like you had before
>
> >  $params => array('conditions' => array(
> >             'AND' => array(
> >                 'OR' =>array(
> >                     'Post.name LIKE'      => '%' . $item . '%',
> >                    'Post.date LIKE'  => '%' . $item . '%',
> >                     'Post.poster LIKE' => '%' . $item . '%'),
> >             'NOT'=>array('Post.active'=> '0'))),
> >             'order' => 'Post.name',
> >              'recursive' => 1));
>
> > $this->set('results', $this->Post->find('all' , $params));
>
> > It will find ALL Posts that meet these PARAMS and whatever you 
> > define in the PARAMS
>
> > Dave
>
> >     
>
> > -Original Message-
> > From: Simon [mailto:simon_d...@hotmail.com]
> > Sent: September-24-09 11:09 AM
> > To: CakePHP
> > Subject: Re: Search and Find all
>
> > hi
> > thanks for you time i get  parse erorr when i  do this
>
> > $this->set('results', $this->find(...));
>
> > i tried it without the dots
>
> > $this->set('results', $this->find());
>
> > then i get
> > Call to undefined method PostsController::find()
>
> > thank you
>
> > On Sep 23, 5:45 pm, brian  wrote:
> > > You're testing for $item but your controller setting a variable
$search.
>
> > > lthough, on 2nd look, you have a problem there, also. You're 
> > > assigning the result of your find() to $post but, further down, refer
to $posts.
>
> > > Maybe you should simply do:
>
> > > $this->set('results', $this->find(...));
>
> > > view:
>
> > > if (empty($results)) { ...
>
> > > On Wed, Sep 23, 2009 at 6:32 PM, Simon  wrote:
>
> > > > whats the best way to show the user if there is no items found 
> > > > any code i can use  in my view
>
> > > > this i used but didnt work i got error
>
> > > >  > > > if (!$item) {
>
> > > > echo' no items found  found'; } ?>
>
> > > > this is in my post controller
>
> > > > function search($item = null) {
> > > >    $item = $this->params['url']['q'];
> > > >    $post = $this->Post->find('all',
> > > >        array('conditions' => array(
> > > >            'AND' => array(
> > > >                'OR' =>array(
> > > >                    'Post.name LIKE'      => '%' . $item . '%',
> > > >                    'Post.date LIKE'  => '%' . $item . '%',
> > > >                    'Post.poster LIKE' => '%' . $item . '%'),
> > > >            'NOT'=>array('Post.active'=> '0'))),
> > > >             'order' => 'Post.name',
> > > >             'recursive' => 1));
>
> > > >                if (!$item) {
> > > >                        $this->Session->setFlash(__('No Search 
> > > > Items Found', true));
> > > >                        
> > > > $this->redirect(array('action'=>'index'));
> > > >                }
>
> > > >                $this->set('search', $posts);
> > > >        }- Hide quoted text -
>
> > > - Show quoted text 

Re: Search and Find all

2009-09-24 Thread Simon

thank you Dave And Brian

i got it i'm knida blonde  haha

here is what i did

function search($item = null) {
$item = $this->params['url']['q'];
$params = array('conditions' => array(
'AND' => array(
'OR' =>array(
'Post.name LIKE'  => '%' . $item . '%',
'Post.date LIKE'  => '%' . $item . '%',
'Post.poster LIKE' => '%' . $item . '%'),
'NOT'=>array('Post.active'=> '0'))),
 'order' => 'Post.name',
 'recursive' => 1));


if (!$item) {
$this->Session->setFlash(__('No Search Items
Found', true));
$this->redirect(array('action'=>'index'));
}

$this->set('results', $this->Post->find('all' ,
$params));


}




On Sep 24, 7:18 am, Simon  wrote:
> you ment like this correct me if i worng
>
> function search($item = null) {
>     $item = $this->params['url']['q'];
>     $post = $this->Post->find('all', $params =>
>         array('conditions' => array(
>             'AND' => array(
>                 'OR' =>array(
>                     'Post.name LIKE'      => '%' . $item . '%',
>                     'Post.date LIKE'  => '%' . $item . '%',
>                     'Post.poster LIKE' => '%' . $item . '%'),
>             'NOT'=>array('Post.active'=> '0'))),
>              'order' => 'Post.name',
>              'recursive' => 1));
>
>                 if (!$item) {
>                         $this->Session->setFlash(__('No Search Items
> Found', true));
>                         $this->redirect(array('action'=>'index'));
>                 }
>
>                 $this->set('search', $posts);
>                 $this->set('results', $this->Post->find('all' ,
> $params));
>
>         }
>
> On Sep 24, 6:56 am, "Dave Maharaj :: WidePixels.com"
>
>
>
>  wrote:
> > Your telling it to find nothing.
>
> > You need to tell it what to find.
>
> > Like you had before
>
> >  $params => array('conditions' => array(
> >             'AND' => array(
> >                 'OR' =>array(
> >                     'Post.name LIKE'      => '%' . $item . '%',
> >                    'Post.date LIKE'  => '%' . $item . '%',
> >                     'Post.poster LIKE' => '%' . $item . '%'),
> >             'NOT'=>array('Post.active'=> '0'))),
> >             'order' => 'Post.name',
> >              'recursive' => 1));  
>
> > $this->set('results', $this->Post->find('all' , $params));
>
> > It will find ALL Posts that meet these PARAMS and whatever you define in the
> > PARAMS
>
> > Dave
>
> >     
>
> > -Original Message-
> > From: Simon [mailto:simon_d...@hotmail.com]
> > Sent: September-24-09 11:09 AM
> > To: CakePHP
> > Subject: Re: Search and Find all
>
> > hi
> > thanks for you time i get  parse erorr when i  do this
>
> > $this->set('results', $this->find(...));
>
> > i tried it without the dots
>
> > $this->set('results', $this->find());
>
> > then i get
> > Call to undefined method PostsController::find()
>
> > thank you
>
> > On Sep 23, 5:45 pm, brian  wrote:
> > > You're testing for $item but your controller setting a variable $search.
>
> > > lthough, on 2nd look, you have a problem there, also. You're assigning
> > > the result of your find() to $post but, further down, refer to $posts.
>
> > > Maybe you should simply do:
>
> > > $this->set('results', $this->find(...));
>
> > > view:
>
> > > if (empty($results)) { ...
>
> > > On Wed, Sep 23, 2009 at 6:32 PM, Simon  wrote:
>
> > > > whats the best way to show the user if there is no items found any
> > > > code i can use  in my view
>
> > > > this i used but didnt work i got error
>
> > > >  > > > if (!$item) {
>
> > > > echo' no items found  found'; } ?>
>
> > > > this is in my post controller
>
> > > > function search($item = null) {
> > > >    $item = $this->params['url']['q'];
> > > >    $post = $this->Post->find('all',
> > > >        array('conditions' => array(
> > > >            'AND' => array(
> > > >                'OR' =>array(
> > > >                    'Post.name LIKE'      => '%' . $item . '%',
> > > >                    'Post.date LIKE'  => '%' . $item . '%',
> > > >                    'Post.poster LIKE' => '%' . $item . '%'),
> > > >            'NOT'=>array('Post.active'=> '0'))),
> > > >             'order' => 'Post.name',
> > > >             'recursive' => 1));
>
> > > >                if (!$item) {
> > > >                        $this->Session->setFlash(__('No Search Items
> > > > Found', true));
> > > >                        $this->redirect(array('action'=>'index'));
> > > >                }
>
> > > >                $this->set('search', $posts);
> > > >        }- Hide quoted text -
>
> > > - Show quoted text -- Hide quoted text -
>
> > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP

Re: executing queries from a .sql file in the console

2009-09-24 Thread Stinkbug

I'm somewhat familiar with the schema stuff.  However, the .sql file
is a file that's going to be provided to us and not a file that will
be generated by cake.  Our .sql file isn't just about the schema, it
could be large amounts of data manipulation using sql.  So unless the
schema stuff will execute a .sql file (rather than just generate it).
I don't think it will work for us.  That's why I was trying to get the
code above to work.

Any other thoughts?

On Sep 23, 4:39 pm, Sam Sherlock  wrote:
> I think you want to create a 
> schemahttp://book.cakephp.org/view/735/Generating-and-using-Schema-files
> - S
>
> 2009/9/23 Stinkbug 
>
>
>
> > I'm trying to execute a bunch of sql from a .sql file from the
> > console.  I was trying to use the query method inside the Model class,
> > but I keep getting the following error.
>
> > Error: Missing database table 'models' for model 'Model'
>
> > Below is my code:
>
> >  > App::import('Core', array('Model'));
> > class UpgradeShell extends Shell {
> >        var $uses = array();
>
> >        function main() {
> >                $filename = APP . 'config/sql/upgrade.sql';
> >                if (file_exists($filename)) {
> >                        $handle = fopen($filename, "r");
> >                        $sql = fread($handle, filesize($filename));
> >                        fclose($handle);
> >                        echo $sql;
> >                        if ($sql) {
> >                                //Model::query($sql);
> >                                $model = new Model();
> >                                //$model->query($sql);
> >                        }
> >                }
> >        }
>
> > }
> > ?>
>
> > When I try Model::query($sql);
>
> > I get the following error:
> > Notice: Undefined property: UpgradeShell::$Model in C:\wamp\www\rx.com
> > \app\vendors\shells\upgrade.php on line 13
>
> > Fatal error: Call to a member function query() on a non-object in C:
> > \wamp\www\rx.com\app\vendors\shells\upgrade.php on line 13
>
> > I don't really need to specify models, I just want to execute the
> > queries inside the .sql file.
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Search and Find all

2009-09-24 Thread Simon

you ment like this correct me if i worng

function search($item = null) {
$item = $this->params['url']['q'];
$post = $this->Post->find('all', $params =>
array('conditions' => array(
'AND' => array(
'OR' =>array(
'Post.name LIKE'  => '%' . $item . '%',
'Post.date LIKE'  => '%' . $item . '%',
'Post.poster LIKE' => '%' . $item . '%'),
'NOT'=>array('Post.active'=> '0'))),
 'order' => 'Post.name',
 'recursive' => 1));


if (!$item) {
$this->Session->setFlash(__('No Search Items
Found', true));
$this->redirect(array('action'=>'index'));
}


$this->set('search', $posts);
$this->set('results', $this->Post->find('all' ,
$params));


}


On Sep 24, 6:56 am, "Dave Maharaj :: WidePixels.com"
 wrote:
> Your telling it to find nothing.
>
> You need to tell it what to find.
>
> Like you had before
>
>  $params => array('conditions' => array(
>             'AND' => array(
>                 'OR' =>array(
>                     'Post.name LIKE'      => '%' . $item . '%',
>                    'Post.date LIKE'  => '%' . $item . '%',
>                     'Post.poster LIKE' => '%' . $item . '%'),
>             'NOT'=>array('Post.active'=> '0'))),
>             'order' => 'Post.name',
>              'recursive' => 1));  
>
> $this->set('results', $this->Post->find('all' , $params));
>
> It will find ALL Posts that meet these PARAMS and whatever you define in the
> PARAMS
>
> Dave
>
>     
>
>
>
> -Original Message-
> From: Simon [mailto:simon_d...@hotmail.com]
> Sent: September-24-09 11:09 AM
> To: CakePHP
> Subject: Re: Search and Find all
>
> hi
> thanks for you time i get  parse erorr when i  do this
>
> $this->set('results', $this->find(...));
>
> i tried it without the dots
>
> $this->set('results', $this->find());
>
> then i get
> Call to undefined method PostsController::find()
>
> thank you
>
> On Sep 23, 5:45 pm, brian  wrote:
> > You're testing for $item but your controller setting a variable $search.
>
> > lthough, on 2nd look, you have a problem there, also. You're assigning
> > the result of your find() to $post but, further down, refer to $posts.
>
> > Maybe you should simply do:
>
> > $this->set('results', $this->find(...));
>
> > view:
>
> > if (empty($results)) { ...
>
> > On Wed, Sep 23, 2009 at 6:32 PM, Simon  wrote:
>
> > > whats the best way to show the user if there is no items found any
> > > code i can use  in my view
>
> > > this i used but didnt work i got error
>
> > >  > > if (!$item) {
>
> > > echo' no items found  found'; } ?>
>
> > > this is in my post controller
>
> > > function search($item = null) {
> > >    $item = $this->params['url']['q'];
> > >    $post = $this->Post->find('all',
> > >        array('conditions' => array(
> > >            'AND' => array(
> > >                'OR' =>array(
> > >                    'Post.name LIKE'      => '%' . $item . '%',
> > >                    'Post.date LIKE'  => '%' . $item . '%',
> > >                    'Post.poster LIKE' => '%' . $item . '%'),
> > >            'NOT'=>array('Post.active'=> '0'))),
> > >             'order' => 'Post.name',
> > >             'recursive' => 1));
>
> > >                if (!$item) {
> > >                        $this->Session->setFlash(__('No Search Items
> > > Found', true));
> > >                        $this->redirect(array('action'=>'index'));
> > >                }
>
> > >                $this->set('search', $posts);
> > >        }- Hide quoted text -
>
> > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Best way to accomplish acl for database records owned by a user

2009-09-24 Thread Rick

I know that globals are bad but...

I just set a global $gblCurrentUser when the user logs in.  Then
accessing that in models, I can add a select condition for that user
in the beforeFind etc..

You get the idea?

Rick




On Sep 24, 12:20 am, brian  wrote:
> I did something similar to this. However, I was so overwhelmed by the
> contradictory and/or incomplete information I found about Cake's ACL
> (mostly because it was quite dated) that I really don't know for sure
> that I did it the best way.
>
> My app is an extranet that has several different Groups. The
> navigation consists of many Sections that are stored as a tree (MPTT).
> Some Sections may not be seen by certain Groups. So, to display this
> navigation tree, I called this method in my SectionsController:
>
> public function nav($group_id = null)
> {
>         if (is_null($group_id))
>         {
>                 if (!$this->params['admin'])
>                 {
>                         $group_id = $this->Auth->user('group_id');
>                 }
>         }
>         $this->Session->write('group_id_for_nav', $group_id);
>
>         /* try getting the nodes from the cache
>          */
>         $sections = Cache::read("group_sections_${group_id}", 'default');
>
>         if (!$sections)
>         {
>                 /* fetch the permissions for this group
>                  */
>                 $perms = $this->Acl->Aco->find(
>                         'all',
>                         array(
>                                 'fields' => array('Aco.foreign_key'),
>                                 'conditions' => array(
>                                         'Aco.model' => 'Section',
>                                         'Aco.id = Permission.aco_id'
>                                 ),
>                                 'recursive' => -1,
>                                 'joins' => array(
>                                         array(
>                                                 'table' => 'aros',
>                                                 'alias' => 'Aro',
>                                                 'type' => 'INNER',
>                                                 'conditions'=> array(
>                                                         'Aro.model' => 
> 'Group',
>                                                         "Aro.foreign_key = 
> ${group_id}"
>                                                 )
>                                         ),
>                                         array(
>                                                 'table' => 'aros_acos',
>                                                 'alias' => 'Permission',
>                                                 'type' => 'INNER',
>                                                 'conditions'=> array(
>                                                         'Permission.aro_id = 
> Aro.id',
>                                                         'Permission._read >= 
> 0'
>                                                 )
>                                         )
>                                 )                                      
>                         )
>                 );
>
>                 $section_ids = Set::extract($perms, '{n}.Aco.foreign_key');
>
>                 /* we don't want to see the root node
>                  */
>                 unset($section_ids[0]);
>
>                 /* now grab the sections these permissions allow
>                  */
>                 $sections = $this->Section->threaded($section_ids);
>
>                 /* save this group's allowed sections
>                  */
>                 Cache::write("group_sections_${group_id}", $sections, 
> 'default');
>         }
>         return $sections;
>
> }
>
> So, the Aco.foreign_key fields I'm after correspond to Section.ids.
> Once i have those, I fetch the relevant Sections as a threaded list.
> Obviously, you'd just be interested in the record IDs.
>
> What I'm storing in the cache is the Sections themselves. For your
> case, you'd likely want to save the record IDs in the session instead
> of caching them.
>
> Anyway, the important thing is the joins used to get at the model IDs
> for your record-level ACL through the ACO.foreign_key.
>
> Let me know if you want more info.
>
> On Wed, Sep 23, 2009 at 5:19 PM, rOger  wrote:
>
> > Hi @all,
>
> > I'm really new to CakePHP and I read about the ACL modell of CakePHP.
> > As usual also the examples seems to be simple so it is easy to
> > understand the system. I'm evaluating cakePHP for a new project where
> > I have records which belongs to a given user = that is the owner of
> > the record. Now I want to have a ACL system which enables some groups
> > (like Administrators) full access to these records. That is the "easy"
> > part and is well documented. The second part is a little bit more
> > tricky (in my opinion): The owner should also have full access to his
> > record detai

RE: Search and Find all

2009-09-24 Thread Dave Maharaj :: WidePixels.com

Your telling it to find nothing.

You need to tell it what to find.

Like you had before

 $params => array('conditions' => array(
            'AND' => array(
                'OR' =>array(
                    'Post.name LIKE'      => '%' . $item . '%',
                   'Post.date LIKE'  => '%' . $item . '%',
                    'Post.poster LIKE' => '%' . $item . '%'),
            'NOT'=>array('Post.active'=> '0'))),
            'order' => 'Post.name',
             'recursive' => 1));  

$this->set('results', $this->Post->find('all' , $params));

It will find ALL Posts that meet these PARAMS and whatever you define in the
PARAMS

Dave

     
-Original Message-
From: Simon [mailto:simon_d...@hotmail.com] 
Sent: September-24-09 11:09 AM
To: CakePHP
Subject: Re: Search and Find all


hi
thanks for you time i get  parse erorr when i  do this

$this->set('results', $this->find(...));

i tried it without the dots

$this->set('results', $this->find());

then i get
Call to undefined method PostsController::find()

thank you

On Sep 23, 5:45 pm, brian  wrote:
> You're testing for $item but your controller setting a variable $search.
>
> lthough, on 2nd look, you have a problem there, also. You're assigning 
> the result of your find() to $post but, further down, refer to $posts.
>
> Maybe you should simply do:
>
> $this->set('results', $this->find(...));
>
> view:
>
> if (empty($results)) { ...
>
>
>
> On Wed, Sep 23, 2009 at 6:32 PM, Simon  wrote:
>
> > whats the best way to show the user if there is no items found any 
> > code i can use  in my view
>
> > this i used but didnt work i got error
>
> >  > if (!$item) {
>
> > echo' no items found  found'; } ?>
>
> > this is in my post controller
>
> > function search($item = null) {
> >    $item = $this->params['url']['q'];
> >    $post = $this->Post->find('all',
> >        array('conditions' => array(
> >            'AND' => array(
> >                'OR' =>array(
> >                    'Post.name LIKE'      => '%' . $item . '%',
> >                    'Post.date LIKE'  => '%' . $item . '%',
> >                    'Post.poster LIKE' => '%' . $item . '%'),
> >            'NOT'=>array('Post.active'=> '0'))),
> >             'order' => 'Post.name',
> >             'recursive' => 1));
>
> >                if (!$item) {
> >                        $this->Session->setFlash(__('No Search Items 
> > Found', true));
> >                        $this->redirect(array('action'=>'index'));
> >                }
>
> >                $this->set('search', $posts);
> >        }- Hide quoted text -
>
> - Show quoted text -


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



Re: Search and Find all

2009-09-24 Thread Simon

hi
thanks for you time i get  parse erorr when i  do this

$this->set('results', $this->find(...));

i tried it without the dots

$this->set('results', $this->find());

then i get
Call to undefined method PostsController::find()

thank you

On Sep 23, 5:45 pm, brian  wrote:
> You're testing for $item but your controller setting a variable $search.
>
> lthough, on 2nd look, you have a problem there, also. You're assigning
> the result of your find() to $post but, further down, refer to $posts.
>
> Maybe you should simply do:
>
> $this->set('results', $this->find(...));
>
> view:
>
> if (empty($results)) { ...
>
>
>
> On Wed, Sep 23, 2009 at 6:32 PM, Simon  wrote:
>
> > whats the best way to show the user if there is no items found
> > any code i can use  in my view
>
> > this i used but didnt work i got error
>
> >  > if (!$item) {
>
> > echo' no items found  found';
> > }
> > ?>
>
> > this is in my post controller
>
> > function search($item = null) {
> >    $item = $this->params['url']['q'];
> >    $post = $this->Post->find('all',
> >        array('conditions' => array(
> >            'AND' => array(
> >                'OR' =>array(
> >                    'Post.name LIKE'      => '%' . $item . '%',
> >                    'Post.date LIKE'  => '%' . $item . '%',
> >                    'Post.poster LIKE' => '%' . $item . '%'),
> >            'NOT'=>array('Post.active'=> '0'))),
> >             'order' => 'Post.name',
> >             'recursive' => 1));
>
> >                if (!$item) {
> >                        $this->Session->setFlash(__('No Search Items Found', 
> > true));
> >                        $this->redirect(array('action'=>'index'));
> >                }
>
> >                $this->set('search', $posts);
> >        }- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Number of Affected Rows

2009-09-24 Thread blake

Works perfect. Thanks for the quick help.


-Blake


On Sep 24, 9:07 am, Bert Van den Brande  wrote:
> You can call getAffectedRows() on any model class.
>
> From class Model :
>
> /**
>  * Returns the number of rows affected by the last query
>  *
>  * @return int Number of rows
>  * @access public
>  */
>     function getAffectedRows() {
>         $db =& ConnectionManager::getDataSource($this->useDbConfig);
>         return $db->lastAffected();
>     }
>
>
>
> On Thu, Sep 24, 2009 at 3:01 PM, blake  wrote:
>
> > I'm running an updateAll and would like to know the number of rows
> > that actually got updated. Is there an easy way to do this? The debug
> > query results at the bottom show me the number of rows affected, so
> > hopefully theres a way for me to access that?
>
> > Thanks,
> > -Blake
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



How to send data from controller to controller?

2009-09-24 Thread LPaulino

Hi guys,

I would like to know how can I send data from 1 controller to another
one. Let me explain better why I need that.

I have in my view 1 form with a select:


   Test1 
   Test2 
   Test3 




When it is send to controller "test", the action index will check
which test was select and will send the data to another controller,
something like a redirect but I dont wanna pass the selectTest value
in the URL. Something like that:

function index()
{
   if($this->data['Test']['selectTest'] == 'Test1')
   {
  $this->redirect(array('controller' => 'test', 'action' =>
'test1', 'data' => $this->data));
   }
   if($this->data['Test']['selectTest'] == 'Test2')
   {
  $this->redirect(array('controller' => 'test', 'action' =>
'test2', 'data' => $this->data));
   }
   if($this->data['Test']['selectTest'] == 'Test3')
   {
  $this->redirect(array('controller' => 'test', 'action' =>
'test3', 'data' => $this->data));
   }
}

Changing redirect to send, I dont know...
Is that possible? How can I do that?

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



Question about a Relationship

2009-09-24 Thread Luke

Hi,

I am sitting on a Relationship issue where I would like to hear your
opinion about. It is a recipe page. A user can write Recipes and save
other Recipes as Favourites.

A User hasMany Recipe(Recipe belong to User)
A User hasMany Favourite (Favourite belong to User)

My Favourite Table:
id
user_id
recipe_id


My Recipe Table:
id
recipe_name
user_id

When a User is logged in he can see his Favourite Recipes. When
looking at a recipe in detail, he can take it off the favourite list
aswell. Because I only have the relation between Recipe and User and
User and Favourite, I actually don't get the favoruite_id from the
Favourites table. I was thinking to say Recipe belongsTo Favourite and
Favourite hasMany Recipes, but than it complains that there is not
favourite_id in the Recipes table.

What am I doing wrong? I obviously got a thinking mistake in this and
can't find it out. Any thoughts?
Thanks in advance.

Luke

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



Re: Number of Affected Rows

2009-09-24 Thread Bert Van den Brande
You can call getAffectedRows() on any model class.

>From class Model :

/**
 * Returns the number of rows affected by the last query
 *
 * @return int Number of rows
 * @access public
 */
function getAffectedRows() {
$db =& ConnectionManager::getDataSource($this->useDbConfig);
return $db->lastAffected();
}

On Thu, Sep 24, 2009 at 3:01 PM, blake  wrote:

>
> I'm running an updateAll and would like to know the number of rows
> that actually got updated. Is there an easy way to do this? The debug
> query results at the bottom show me the number of rows affected, so
> hopefully theres a way for me to access that?
>
> Thanks,
> -Blake
> >
>

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



Number of Affected Rows

2009-09-24 Thread blake

I'm running an updateAll and would like to know the number of rows
that actually got updated. Is there an easy way to do this? The debug
query results at the bottom show me the number of rows affected, so
hopefully theres a way for me to access that?

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



Re: eCommerce question

2009-09-24 Thread danfreak


Thanks for your answer Bert!

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



Re: recursive find: related models order

2009-09-24 Thread lorenx

ok, thank you very much!

On Sep 24, 1:58 pm, Bert Van den Brande  wrote:
> If I understand you question correctly I think you're right :)
>
>
>
> On Thu, Sep 24, 2009 at 1:27 PM, lorenx  wrote:
>
> > perfect, thanks!
>
> > just one little question:
> > if i have a deep and complex recursion and i just want a condition on
> > a single model in the middle of the tree... it seems that i also have
> > to specify all the other models not to have them filtered out, am i
> > right?
>
> > On Sep 24, 11:09 am, Bert Van den Brande  wrote:
> > > Search the Cake book for 'Containable' behavior , I think you will find
> > your
> > > answer there
>
> > > On Thu, Sep 24, 2009 at 10:53 AM, lorenx  wrote:
>
> > > > hi all.
>
> > > > i'm trying to order a deeply related model but the following code
> > > > gives me an error.
>
> > > > $params = array(
> > > >        'order' => 'RelatedModel.relatedmodel_field DESC',
> > > >        'recursive' => 3
> > > > );
> > > > $models_array = $this->Model->find('all', $params);
>
> > > > i saw that cakephp do several queries to build $models_array and the
> > > > order parameter is appended to the first query, the one with no
> > > > RelatedModel reference.
> > > > i also tried to set $order in the model but it didn't solve (and i
> > > > don't want a static order anyway...)
>
> > > > how does cakephp handle this issue?
>
> > > > thanks to all, very much.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: recursive find: related models order

2009-09-24 Thread Bert Van den Brande
If I understand you question correctly I think you're right :)

On Thu, Sep 24, 2009 at 1:27 PM, lorenx  wrote:

>
> perfect, thanks!
>
> just one little question:
> if i have a deep and complex recursion and i just want a condition on
> a single model in the middle of the tree... it seems that i also have
> to specify all the other models not to have them filtered out, am i
> right?
>
>
> On Sep 24, 11:09 am, Bert Van den Brande  wrote:
> > Search the Cake book for 'Containable' behavior , I think you will find
> your
> > answer there
> >
> >
> >
> > On Thu, Sep 24, 2009 at 10:53 AM, lorenx  wrote:
> >
> > > hi all.
> >
> > > i'm trying to order a deeply related model but the following code
> > > gives me an error.
> >
> > > $params = array(
> > >'order' => 'RelatedModel.relatedmodel_field DESC',
> > >'recursive' => 3
> > > );
> > > $models_array = $this->Model->find('all', $params);
> >
> > > i saw that cakephp do several queries to build $models_array and the
> > > order parameter is appended to the first query, the one with no
> > > RelatedModel reference.
> > > i also tried to set $order in the model but it didn't solve (and i
> > > don't want a static order anyway...)
> >
> > > how does cakephp handle this issue?
> >
> > > thanks to all, very much.
> >
>

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



Re: eCommerce question

2009-09-24 Thread Bert Van den Brande
I would only decrease stock value when the shopping cart gets converted to a
purchase.

Chances are rather slim that many people will buy the book at the same time,
and if it does you should try to anticipate this and create a larger stock
for popular books :)

Also, every formula you invent to calculate stock values will never be
accurate ... and I'm pretty sure you don't want to miss out on a sale just
because your formula calculated a negative stock but in reality it was only
10 people having it in their shopping cart and not buying the product.

Keep it simple :)


On Thu, Sep 24, 2009 at 12:44 PM, cakeFreak  wrote:

>
> Hey guys,
>
> my question is about developing an eCommerce solution in PHP, and it
> about dealing with stock quantities.
>
> When you have real products (not services or e-books, for example, but
> real books instead) how do you deal with the following situation:
>
> 1) you have 10 copies of Book "Learning CakePHP"  in stock
> 2) you have 20 customers in the eCommerce website at the same time
> 3) 15 customers add a copy of the Book "Learning CakePHP" to their
> shopping chart
> 4) only 5 customers finally biught the book
>
> At this point my question is: how do you work with your stock values?
> Decreasing the stock every time a customer adds to chart, is a bit
> risky.
> Maybe using a kinda average purchasing rate (say only 50% of those
> that added to chart bought the book) it would be less risky to manage
> stock values?
>
> Dunno if I'm overcomplicating the problem. Just Curious about your
> opinion and solutions to this issue.
>
> Daniel
> >
>

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



Re: update multiple divs with ajax

2009-09-24 Thread senser

Hi Werschinger,

First of all - thank you for the help.

Schnemi - thank you too. I've read topic you posted link, but method
mentioned there works only with divs, but not other html elements.
It's my fault that in question I asked for div elements but not for
*any* - I just wanted to make things much more simple.
In my real application I had to update 2 or 3 table rows with an ajax
link and wanted to skip writing id for every table row.

Werschinger, your code looks fine and I'll give it a try, but will
have to read a bit more for prototype framework.


On Sep 24, 11:14 am, Werschinger  wrote:
> In cases like this (and also other cases), I typically do not rely on
> Cake's built-in ajax functions. What I'd do if I were in your
> position:
>
> * Create my own JS-functions that handle the deletion of an email.
> * Have the delete action do the deletion and return whatever data you
> need in JSON format
> * With the JSON data, take care of updating the corresponding divs.
>
> Pros
> Less redundancy, i.e. you don't have things like
> ---
> Event.observe('link2116879578', 'click', function(event) { new
> Ajax.Updater(document.createElement('div'),'/taxundo/Emails/delete',
> {asynchronous:true, evalScripts:true, requestHeaders:['X-Update',
> 'div1 div2']}) }, false);
> ---
> for each ajax call but rather just
> Event.observe('link2116879578', 'click', function(event) { myCustomFxn
> () }
> or
> delete me yourtag>
>
> This gives you more flexibility.
>
> Cons: it's a little more overhead but well worth it in the end, I
> 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 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Making Databases Optional in CakePHP

2009-09-24 Thread Erik Kristensen

Good Morning Everyone!

I am a long time user and I absolutely love CakePHP, however there is
one problem that I have run into lately that I think deserves some
attention, though I am sure there are those that will disagree with
me.

For the most part most of the applications I have written have all had
databases and so it has never been a problem, however recently, I have
an pre-existing open source application that I am a developer on that
doesn't use a database, and I find that CakePHP doesn't exactly play
nice without a database. I found a few articles on the internet that
talk about creating a dummy dbo source, etc etc to get CakePHP to work
without a database, but I feel that a better solution might be
warrented.

Why not add an option to the config.php file to disable database use?
Or at least add an option to make a database optional?

Other frameworks handle this by just allowing to include the use of
models or to not include them.

Now I am not suggesting we change to be like other frameworks, but
allow one to not use them and have the entire framework understand
that it doesn't need to expect a database connection I think only
makes sense, especially to open the doors to people that don't want to
use the framework because of the database requirements.

I am big on UI in my applications, and I found that CakePHP View and
Theming capabilities dwarf those of other frameworks, IMHO, that is
one of the biggest reasons I want to use CakePHP for this project that
doesn't use a database (but might in the future, thats why being
optional would be nice)

Thoughts on this?
-Erik

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



Re: recursive find: related models order

2009-09-24 Thread lorenx

perfect, thanks!

just one little question:
if i have a deep and complex recursion and i just want a condition on
a single model in the middle of the tree... it seems that i also have
to specify all the other models not to have them filtered out, am i
right?


On Sep 24, 11:09 am, Bert Van den Brande  wrote:
> Search the Cake book for 'Containable' behavior , I think you will find your
> answer there
>
>
>
> On Thu, Sep 24, 2009 at 10:53 AM, lorenx  wrote:
>
> > hi all.
>
> > i'm trying to order a deeply related model but the following code
> > gives me an error.
>
> > $params = array(
> >        'order' => 'RelatedModel.relatedmodel_field DESC',
> >        'recursive' => 3
> > );
> > $models_array = $this->Model->find('all', $params);
>
> > i saw that cakephp do several queries to build $models_array and the
> > order parameter is appended to the first query, the one with no
> > RelatedModel reference.
> > i also tried to set $order in the model but it didn't solve (and i
> > don't want a static order anyway...)
>
> > how does cakephp handle this issue?
>
> > thanks to all, very much.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



eCommerce question

2009-09-24 Thread cakeFreak

Hey guys,

my question is about developing an eCommerce solution in PHP, and it
about dealing with stock quantities.

When you have real products (not services or e-books, for example, but
real books instead) how do you deal with the following situation:

1) you have 10 copies of Book "Learning CakePHP"  in stock
2) you have 20 customers in the eCommerce website at the same time
3) 15 customers add a copy of the Book "Learning CakePHP" to their
shopping chart
4) only 5 customers finally biught the book

At this point my question is: how do you work with your stock values?
Decreasing the stock every time a customer adds to chart, is a bit
risky.
Maybe using a kinda average purchasing rate (say only 50% of those
that added to chart bought the book) it would be less risky to manage
stock values?

Dunno if I'm overcomplicating the problem. Just Curious about your
opinion and solutions to this issue.

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



Re: Get keyword from Search Engine

2009-09-24 Thread Bert Van den Brande
Nice tip ... I'm gonna remember that one :)

On Thu, Sep 24, 2009 at 12:22 PM, Dr. Loboto  wrote:

>
> Check $this->params['requested'] in beforeFilter. If it is set and
> true, you are processing requestAction this time.
>
> On Sep 24, 2:01 pm, igorfelluga  wrote:
> > Hi
> > I did a component to get/save the search engine keyword if same one
> > arrive from google,msn,yahoo.
> > I call it in app_model with beforeFilter.
> > The problem is that in home page or wherever it save the same keywords
> > group more than one time.
> > I think that happen because the page call 2/3/4 controller.
> >
> > How I must do it?
> > Thanks
> >
>

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



Re: Get keyword from Search Engine

2009-09-24 Thread igorfelluga

Thanks !

I put a if with $this->params['requested'], now is working

On 24 Set, 12:22, "Dr. Loboto"  wrote:
> Check $this->params['requested'] in beforeFilter. If it is set and
> true, you are processing requestAction this time.
>
> On Sep 24, 2:01 pm, igorfelluga  wrote:
>
> > Hi
> > I did a component to get/save the search engine keyword if same one
> > arrive from google,msn,yahoo.
> > I call it in app_model with beforeFilter.
> > The problem is that in home page or wherever it save the same keywords
> > group more than one time.
> > I think that happen because the page call 2/3/4 controller.
>
> > How I must do it?
> > Thanks
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Get keyword from Search Engine

2009-09-24 Thread Dr. Loboto

Check $this->params['requested'] in beforeFilter. If it is set and
true, you are processing requestAction this time.

On Sep 24, 2:01 pm, igorfelluga  wrote:
> Hi
> I did a component to get/save the search engine keyword if same one
> arrive from google,msn,yahoo.
> I call it in app_model with beforeFilter.
> The problem is that in home page or wherever it save the same keywords
> group more than one time.
> I think that happen because the page call 2/3/4 controller.
>
> How I must do it?
> Thanks
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: URL Routing

2009-09-24 Thread Dr. Loboto

Form itself cannot do it. Only JavaScript.

On Sep 23, 10:12 pm, persianshadow  wrote:
> hi
>
> i have  form with one field that get number from user , i want send
> this number to my controller from
>
> url . i change my form type to "get" but i need to nice url
> routing .for example
>
> with "get" type i get this :
>
> http://.../admin/edit?id=100
>
> but i want this :
>
> http://../admin/edit/100
>
> please help me for solve this.
>
> thanks
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: recursive find: related models order

2009-09-24 Thread Bert Van den Brande
Search the Cake book for 'Containable' behavior , I think you will find your
answer there

On Thu, Sep 24, 2009 at 10:53 AM, lorenx  wrote:

>
> hi all.
>
> i'm trying to order a deeply related model but the following code
> gives me an error.
>
> $params = array(
>'order' => 'RelatedModel.relatedmodel_field DESC',
>'recursive' => 3
> );
> $models_array = $this->Model->find('all', $params);
>
> i saw that cakephp do several queries to build $models_array and the
> order parameter is appended to the first query, the one with no
> RelatedModel reference.
> i also tried to set $order in the model but it didn't solve (and i
> don't want a static order anyway...)
>
> how does cakephp handle this issue?
>
> thanks to all, very much.
> >
>

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



Re: Get keyword from Search Engine

2009-09-24 Thread Bert Van den Brande
If you have XDebug or Zend Debugger, just put a breakpoint at the
beforeFilter code and then look at the stacktrace each time you are halted.

As said, unless you use 'requestAction' calls inside your view I can't think
of any reason why the beforeFilter is called multiple times ...

On Thu, Sep 24, 2009 at 10:38 AM, igorfelluga wrote:

>
> Sorry you are right, I call in app_controller :)
>
> in the only homepage it save the keywords group 5 times
>
>
> On 24 Set, 10:32, Bert Van den Brande  wrote:
> > Any way, unless you use 'requestAction' calls inside your view I don't
> think
> > a controller's beforeFilter method is called multiple times for one http
> > request ...
> >
> > On Thu, Sep 24, 2009 at 9:56 AM, Bert Van den Brande  >wrote:
> >
> > > Don't you mean "beforeFilter" from "app_controller" ?
> > > "app_model" has no "beforeFilter".
> >
> > > On Thu, Sep 24, 2009 at 9:01 AM, igorfelluga  >wrote:
> >
> > >> Hi
> > >> I did a component to get/save the search engine keyword if same one
> > >> arrive from google,msn,yahoo.
> > >> I call it in app_model with beforeFilter.
> > >> The problem is that in home page or wherever it save the same keywords
> > >> group more than one time.
> > >> I think that happen because the page call 2/3/4 controller.
> >
> > >> How I must do it?
> > >> Thanks
> >
> >
> >
>

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



recursive find: related models order

2009-09-24 Thread lorenx

hi all.

i'm trying to order a deeply related model but the following code
gives me an error.

$params = array(
'order' => 'RelatedModel.relatedmodel_field DESC',
'recursive' => 3
);
$models_array = $this->Model->find('all', $params);

i saw that cakephp do several queries to build $models_array and the
order parameter is appended to the first query, the one with no
RelatedModel reference.
i also tried to set $order in the model but it didn't solve (and i
don't want a static order anyway...)

how does cakephp handle this issue?

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



Re: Get keyword from Search Engine

2009-09-24 Thread igorfelluga

Sorry you are right, I call in app_controller :)

in the only homepage it save the keywords group 5 times


On 24 Set, 10:32, Bert Van den Brande  wrote:
> Any way, unless you use 'requestAction' calls inside your view I don't think
> a controller's beforeFilter method is called multiple times for one http
> request ...
>
> On Thu, Sep 24, 2009 at 9:56 AM, Bert Van den Brande wrote:
>
> > Don't you mean "beforeFilter" from "app_controller" ?
> > "app_model" has no "beforeFilter".
>
> > On Thu, Sep 24, 2009 at 9:01 AM, igorfelluga wrote:
>
> >> Hi
> >> I did a component to get/save the search engine keyword if same one
> >> arrive from google,msn,yahoo.
> >> I call it in app_model with beforeFilter.
> >> The problem is that in home page or wherever it save the same keywords
> >> group more than one time.
> >> I think that happen because the page call 2/3/4 controller.
>
> >> How I must do it?
> >> Thanks
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Missing Controller

2009-09-24 Thread Selva manickaraja
Thanks alot guys. I was just about to edit the php.ini. Since I got advice
to stick to long tags, I wil continue using long tags not to suffer from
deprecations.

On Thu, Sep 24, 2009 at 12:08 PM, dhiraj ray  wrote:

> hi
>create controler name just pulural of modle
>
> check naming in data base.
>
> sorry for bad english.
>
>
> >
>

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



Re: Get keyword from Search Engine

2009-09-24 Thread Bert Van den Brande
Any way, unless you use 'requestAction' calls inside your view I don't think
a controller's beforeFilter method is called multiple times for one http
request ...

On Thu, Sep 24, 2009 at 9:56 AM, Bert Van den Brande wrote:

> Don't you mean "beforeFilter" from "app_controller" ?
> "app_model" has no "beforeFilter".
>
>
>
> On Thu, Sep 24, 2009 at 9:01 AM, igorfelluga wrote:
>
>>
>> Hi
>> I did a component to get/save the search engine keyword if same one
>> arrive from google,msn,yahoo.
>> I call it in app_model with beforeFilter.
>> The problem is that in home page or wherever it save the same keywords
>> group more than one time.
>> I think that happen because the page call 2/3/4 controller.
>>
>> How I must do it?
>> Thanks
>> >>
>>
>

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



Re: update multiple divs with ajax

2009-09-24 Thread Werschinger

In cases like this (and also other cases), I typically do not rely on
Cake's built-in ajax functions. What I'd do if I were in your
position:

* Create my own JS-functions that handle the deletion of an email.
* Have the delete action do the deletion and return whatever data you
need in JSON format
* With the JSON data, take care of updating the corresponding divs.

Pros
Less redundancy, i.e. you don't have things like
---
Event.observe('link2116879578', 'click', function(event) { new
Ajax.Updater(document.createElement('div'),'/taxundo/Emails/delete',
{asynchronous:true, evalScripts:true, requestHeaders:['X-Update',
'div1 div2']}) }, false);
---
for each ajax call but rather just
Event.observe('link2116879578', 'click', function(event) { myCustomFxn
() }
or
delete me

This gives you more flexibility.

Cons: it's a little more overhead but well worth it in the end, I
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 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Get keyword from Search Engine

2009-09-24 Thread Bert Van den Brande
Don't you mean "beforeFilter" from "app_controller" ?
"app_model" has no "beforeFilter".


On Thu, Sep 24, 2009 at 9:01 AM, igorfelluga  wrote:

>
> Hi
> I did a component to get/save the search engine keyword if same one
> arrive from google,msn,yahoo.
> I call it in app_model with beforeFilter.
> The problem is that in home page or wherever it save the same keywords
> group more than one time.
> I think that happen because the page call 2/3/4 controller.
>
> How I must do it?
> Thanks
> >
>

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



Re: Sorting pagination with HasMany and SQL Aggregation

2009-09-24 Thread WebbedIT

Make life easier by adding an afterSave() callback to Rating to
populate a field in Article with the average value (and possibly one
for rating_count, but that can easily be done using counterCache).
It's the more efficient way to do it and sorting would then be on the
Article model.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: URL Routing

2009-09-24 Thread WebbedIT

Not sure why you've gone off on a tangent of URL Routing for this.
Read more in the book about form helper, which automagically packages
all submitted form data into $this->data, and you should get there.

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



Re: Problem setting up a relation

2009-09-24 Thread WebbedIT

First thing, using conventions (which is always the best way as much
easier to debug issues) your foreignKey should be user_id unless you
already have that foreignKey in the table.  If you do already have an
existing foreignKey of user_id in the super_users table or really
really want to associate it as ControlledUser then your foreignKey
should be controlled_user_id.  However, as you have specified the
foreignKey it should still work (as long as you've specified it
correctly).

Secondly, I would get rid of all the other attributes if you're not
using them ... not sure what it does if you send them through as blank
strings.

Thirdly, if you do a debug($controlledUsers); in both your controller
action and your view does it show any data? (make sure you have debug
set to level 1 or above)

And finally, any chance of seeing your view's code?  I assume you're
trying to create a multiple select list?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Get keyword from Search Engine

2009-09-24 Thread igorfelluga

Hi
I did a component to get/save the search engine keyword if same one
arrive from google,msn,yahoo.
I call it in app_model with beforeFilter.
The problem is that in home page or wherever it save the same keywords
group more than one time.
I think that happen because the page call 2/3/4 controller.

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