error message

2008-08-24 Thread .
I have a class called Message. When I do this

$this->Message->find('first', array('conditions'=>
array('Message.id'=>$id)));

I get the following error *SQL Error:* 1066: Not unique table/alias:
'Message'

Is Message a reserved keyword in cake? what's causing 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Cake sheet

2008-08-24 Thread Samuel DeVore

It is possible I have a copy of the original omni graffle,
I'll look on monday

Sam D


On Sun, Aug 24, 2008 at 12:20 AM, Daniel Hofstetter <[EMAIL PROTECTED]> wrote:
>
> Hi Sam,
>
>> is controller beforeFilter really a goner?
>
> The beforeFilter property is gone, but not the beforeFilter callback
> method.
>
> --
> Daniel Hofstetter
> http://cakebaker.42dh.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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Cache slows my App

2008-08-24 Thread Jerry

Hi:

Here is my app structure:

/approot
 -  cake  cake core
 -  appmy app
- files  uploaded files
- controllers
- models
...

Theses days I upgraded to 1.2RC2 and found my app slows down while
doing cache.
/approot/app/tmp/cache/persistent/cake_core_dir_map  is big (46KB) and
takes much time to process and sometimes even makes my app run out
maximum execution time (60 secs)

I am worrying if my files/ dir grow and with many files and sub-
directories this cache mechanism
will kill my app.

Is there anyway to improve this?

Your help is appreciated. thanks,

Jerry
http://www.fonsen.com.tw/

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



Re: Focus On cake Validation

2008-08-24 Thread RichardAtHome

Typo:

It will fail silently if the first errored input element on the form
is not a
input control (a textarea for example).

Might be possible to expand the rule to include other input element
types...

On Aug 24, 10:14 pm, RichardAtHome <[EMAIL PROTECTED]> wrote:
> A quick bit of jQuery:
>
> $("#content form:first div.error:first input:first").focus();
>
> Will focus the first errored input field on the first form in the
> #content div.
>
> It will fail silently if the first input element on the forum is not a
> input control (a textarea for example).
>
> [EMAIL PROTECTED] wrote:
> > hello guys
>
> > in my cakephp project i uses the cake validation witch uses server
> > side validation , i need it to focus on the error field after
> > detecting it so how can i do something like this  ?? since the focus
> > can be done with a client side  validation , so im wondiring if there
> > is any way in cake to do that in the same validation process .
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: relationships, joins and pagination. I've hit a wall.

2008-08-24 Thread David C. Zentgraf

Your question is a bit long, so I'm not quite sure what you're asking.
It sounds to me like you're having trouble finding() stuff with the  
condition being on an associated model?
For HABTMs or very deeply nested associations Cake indeed doesn't seem  
to handle it very gracefully yet.
I recently used this code for a HABTM relationship (Place HABTM  
Categories):

$conditions['Place.id'] = Set::extract(
'/Place/id',
$this->Place->Category->find('all', array(
'conditions'=> array(' Category.id' => $id),
'contain'   => 'Place.id'
))
);

It searches for the category with id = $id and gives me an array of  
all Place.ids in that Category.
Next I'm using this array as a condition when searching for the actual  
places:

$this->paginate = array(
'limit' => 10,
'conditions' => $conditions,
'order' => array('Place.name_e' => 'asc')
);
$results = $this->paginate('Place');

$conditions holds a bunch of belongsTo conditions like  
'Place.location_id' => $location_id etc,
but also the array of Place.ids I got earlier, which translated to an  
SQL query like
WHERE `Place`.`id` IN (1, 2, 3, ...), which essentially works like a  
subquery, only in two steps.

Might not be as elegant as a multiple JOIN query, but works well  
enough and purely within Cake.
Maybe this'll tip you off in the right direction?


On 25 Aug 2008, at 11:18, Ariel Arjona wrote:

>
> What I'm trying to model is the following: I have a number of Sites
> which represent wells. From these sites at certain depths Samples are
> collected. Each Sample contains a number of different Subjects
> (specimens) found in varying quantities. These are represented by the
> SubjectHits model in the SubjectHit.hits field. The Sites also have a
> number of geological Formations found at diverse depths. The Formation
> top and bottom for a particular Site are saved in
> FormationsSite.formtop and FormationsSite.formbot.
>
> On each Subject's view page I need to display a list of where has this
> particular species appeared and in what quantity. This list can be
> quite large so I need to use the pagination helper. I also need to
> display which Sample this hit belongs to and to which Site. So far
> I've accomplished this with the following code in the Subject
> controller:
> $this->set('subjectHits', $this->paginate('SubjectHit',
> array('SubjectHit.subject_id'=>$id)));
> and on the $paginate property:
>  var $paginate = array(
>   'SubjectHit' => array(
>'limit'  => '50',
>'page'  => '1',
>'contain'=> array('Sample.Site'),
>   ),
>  );
> using Containable to reach Site.name
>
> My problem comes from the following:
> I also need to show within which Formation for that particular Site
> does that Sample falls within. Basically Sample.depth must be between
> FormationsSite.formtop and FormationsSite.formbot.
>
> With a raw query I would do this like this:
>
> select Formation.name, Site.name, Sample.depth, SubjectHit.hits
> from subject_hits as SubjectHit
> left join samples as Sample on SubjectHit.sample_id = Sample.id
> left join sites as Site on Sample.site_id = Site.id
> left join formations_sites as FormationsSite on
>   (Site.id = FormationsSite.site_id
>   AND Sample.depth <= FormationsSite.formbot
>   AND Sample.depth >= FormationsSite.formtop)
> left join formations as Formation on FormationsSite.formation_id =
> Formation.id
> where SubjectHit.subject_id = 1234
> limit 20
>
> Problem is, I need to paginate these results. If I override paginate()
> and paginateCount() for SubjectHit for this specific query  it will
> interfere with regular pagination for this model when I don't need to
> show the Formation. Is there a way I can obtain this information via a
> regular find() call? What I'm doing right now is to Contain
> Sample.Site.FormationsSite.Formation which brings me every formation
> for that particular Site and in the view I walk the array looking for
> the one matching the conditions. This, however, is pretty inefficient
> and also generates a ton of queries.
>
> Here's some additional info on my schema:
>
> Models:
> Site
> Sample
> SubjectHit
> Subject
> Formation
> FormationsSite
>
> Site hasMany Sample
> Sample hasMany SubjectHits
> Subject hasMany SubjectHits
> Site hasMany FormationsSite
> Formation hasMany FormationsSite
>
> Each hasMany relationship has its corresponding belongsTo relationship
> as well.
>
> Tables:
> sites: id, name
> samples: id, site_id, name, depth
> subjects: id, name
> subject_hits: id, sample_id, subject_id, hits
> formations: id, name
> formations_sites: id, formation_id, site_id, formtop, formbot
>
> >


--~--~-~--~~~---~--~~
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 gro

Re: Auth Component admin login redirect for unauthorized page access

2008-08-24 Thread mario

Thanks Marcin. I solve the problem by using $this->Auth->loginAction()
of the Auth Component.


On Aug 24, 9:02 am, "Marcin Domanski" <[EMAIL PROTECTED]> wrote:
> C'mon man- do some searching. I suggest looking at the api at auth
> component properties.
> HTH
>
> 2008/8/24,mario<[EMAIL PROTECTED]>:
>
>
>
>
>
>
>
> > Hello,
>
> > How can I configure the Auth component so that
> > it will redirect me to the login action of my admins_controller
> > everytime someone access an unauthorized page?
>
> > I see that it redirects me to the login action of my user_controller
> > which I don't want to happen.
>
> > Here is a snippet of my app_controller.php
>
> >  > class AppController extends Controller {
> >    var $components = array('Auth');
> >    function beforeFilter()
> >    {
> >            $this->Auth->loginRedirect = array('controller' => 'mainpage',
> > 'action' => 'home');
> >            $this->Auth->logoutRedirect = array('controller' => 'mainpage',
> > 'action' => 'home');
> >            $this->Auth->allow('home');
> >            $this->Auth->authorize = 'controller';
> >            $this->set('loggedIn', $this->Auth->user('id'));
> >    }
> >    function isAuthorized()
> >    {
> >                    return true;
> >    }
> > }
> > ?>
>
> > Thanks,
>
> >Mario
>
> --
> Marcin Domanskihttp://kabturek.info
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



relationships, joins and pagination. I've hit a wall.

2008-08-24 Thread Ariel Arjona

What I'm trying to model is the following: I have a number of Sites
which represent wells. From these sites at certain depths Samples are
collected. Each Sample contains a number of different Subjects
(specimens) found in varying quantities. These are represented by the
SubjectHits model in the SubjectHit.hits field. The Sites also have a
number of geological Formations found at diverse depths. The Formation
top and bottom for a particular Site are saved in
FormationsSite.formtop and FormationsSite.formbot.

On each Subject's view page I need to display a list of where has this
particular species appeared and in what quantity. This list can be
quite large so I need to use the pagination helper. I also need to
display which Sample this hit belongs to and to which Site. So far
I've accomplished this with the following code in the Subject
controller:
 $this->set('subjectHits', $this->paginate('SubjectHit',
array('SubjectHit.subject_id'=>$id)));
and on the $paginate property:
  var $paginate = array(
   'SubjectHit' => array(
'limit'  => '50',
'page'  => '1',
'contain'=> array('Sample.Site'),
   ),
  );
using Containable to reach Site.name

My problem comes from the following:
I also need to show within which Formation for that particular Site
does that Sample falls within. Basically Sample.depth must be between
FormationsSite.formtop and FormationsSite.formbot.

With a raw query I would do this like this:

select Formation.name, Site.name, Sample.depth, SubjectHit.hits
from subject_hits as SubjectHit
left join samples as Sample on SubjectHit.sample_id = Sample.id
left join sites as Site on Sample.site_id = Site.id
left join formations_sites as FormationsSite on
(Site.id = FormationsSite.site_id
AND Sample.depth <= FormationsSite.formbot
AND Sample.depth >= FormationsSite.formtop)
left join formations as Formation on FormationsSite.formation_id =
Formation.id
where SubjectHit.subject_id = 1234
limit 20

Problem is, I need to paginate these results. If I override paginate()
and paginateCount() for SubjectHit for this specific query  it will
interfere with regular pagination for this model when I don't need to
show the Formation. Is there a way I can obtain this information via a
regular find() call? What I'm doing right now is to Contain
Sample.Site.FormationsSite.Formation which brings me every formation
for that particular Site and in the view I walk the array looking for
the one matching the conditions. This, however, is pretty inefficient
and also generates a ton of queries.

Here's some additional info on my schema:

Models:
Site
Sample
SubjectHit
Subject
Formation
FormationsSite

Site hasMany Sample
Sample hasMany SubjectHits
Subject hasMany SubjectHits
Site hasMany FormationsSite
Formation hasMany FormationsSite

Each hasMany relationship has its corresponding belongsTo relationship
as well.

Tables:
sites: id, name
samples: id, site_id, name, depth
subjects: id, name
subject_hits: id, sample_id, subject_id, hits
formations: id, name
formations_sites: id, formation_id, site_id, formtop, formbot

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



Re: Struggling with associated models ... still .... :-(

2008-08-24 Thread David C. Zentgraf

Jon already pointed this out, just to make it more clear:

$this->paginate() and $this->Venue->find() are both fetching data from  
the database, with the difference being that paginate() takes  
pagination into account, whereas the Model::find() method does not.

$this->set() hands data over to the view.

So your doing a $venues = $this->Venues->find() is great and all,  
except that you're not doing anything with the results in $venues  
after that.
Instead you run a second query with $this->paginate('Venues'), totally  
independent of your previous $this->Venues->find(), and you're handing  
the results of this second query over to the view.

If you want pagination with conditions, you will have to hand your  
conditions over to the paginate() call.

On 25 Aug 2008, at 09:09, eagle wrote:

>
> Jon,
> Thanks for the pointer.  I had looked at containable behaviour as it
> seemed to be the solution.
> This was what I tried (in venues_controller.php):
>
> debug($this->Venue->find('all', array('contain' => array('Contact' =>
> array('conditions' => array('Contact.jobType' =>'main';
> $this->set('venues', $this->paginate('Venue'));
>
> This generates the correct data (in debug view)
>
> but if I change to:
>
> $venues = $this->Venue->find('all', array('contain' => array('Contact'
> => array('conditions' => array('Contact.jobType' =>'main');
> $this->set('venues', $this->paginate('Venue'));
>
> I get all the contacts displayed in the view.
>
> So I guess my problem lies in the VIEW.?  I run a foreach loop:
>  foreach ($venue['Contact'] as $contact) :
>  //if ($contact['jobType'] == 'main') {
>  echo '';
>  $thisContact = $contact['fName'] . ' ' . $contact['lName'];
>  echo $html->link($thisContact, 'mailto:'.$contact['email']);
>  echo ' (' . $contact['position'] . ')  T: ' .$contact['telephone'] .
> '  E: ' . $contact['email'];
>  echo "";
>  //}
> endforeach; ?>
> and it prints ALL the contacts for that venue, but debug is telling me
> that it has only found the correct one.  At this point I got confused
> and so moved to looking for alternative solutions.
> Any ideas?
> Thanks
> Eagle
>
> On Aug 25, 12:17 am, "Jon Bennett" <[EMAIL PROTECTED]> wrote:
>>> I don't know how good practice it is, but in this kind of  
>>> situation, I
>>> use to change temporarily the association conditions before
>>> paginating, like this :
>>> $this->Venue->hasMany['Contact']['conditions'] =
>>> array('Contact.jobType'=>'main');
>>> $this->paginate('Venue');
>>> There may be more elegant solutions to do this, but ...
>>
>> yep, use the Containable 
>> behaviourhttp://book.cakephp.org/view/474/Containable
>>
>> jon
> >


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



Re: Struggling with associated models ... still .... :-(

2008-08-24 Thread Jon Bennett

Hi eagle,

> $venues = $this->Venue->find('all', array('contain' => array('Contact'
> => array('conditions' => array('Contact.jobType' =>'main');
> $this->set('venues', $this->paginate('Venue'));

the problem is you're running two different queries,
$this->paginate('Venue') is similar to $this->Venue->find('all'), try:

$this->set('venues',
$this->Venue->find('all', array('contain' => array(
'Contact'=> array(
'conditions' => array('Contact.jobType' 
=>'main')
)
)
)
)
);

hth

jon

-- 

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

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



Re: CakePHP User Authentication

2008-08-24 Thread villas

Also searching on this group, this thread may help:

"Cake 1.2 Auth - Is someone logged in?"

On Aug 24, 5:16 pm, ss <[EMAIL PROTECTED]> wrote:
> Hello all,
> I want to set up a user authentication and check in the "View".
> Meaning, if a user is logged in, it should say "Welcome [user]" and
> then the regular form content.  If the user is not logged in, it
> should just display the regular content on the view page.
>
> Any thoughts?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Struggling with associated models ... still .... :-(

2008-08-24 Thread Jon Bennett

> I don't know how good practice it is, but in this kind of situation, I
> use to change temporarily the association conditions before
> paginating, like this :
> $this->Venue->hasMany['Contact']['conditions'] =
> array('Contact.jobType'=>'main');
> $this->paginate('Venue');
> There may be more elegant solutions to do this, but ...

yep, use the Containable behaviour http://book.cakephp.org/view/474/Containable

jon

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



Re: Struggling with associated models ... still .... :-(

2008-08-24 Thread eagle

Thanks Clemos,

Your code does the trick.

I had already tried moving the paginate statement to after the find
statement and saw no change in the result:

$venues = $this->Venue->Contact-
>find('first',array('conditions'=>array('Contact.jobType'=>'main')));
$this->set('venues', $this->paginate('Venue'));

So ... Is the problem with the paginate statement or the find?
Paginate makes no changes whether it is before or after the
$venues= , so I assumed that paginate was not the problem.  It
must be with the find ... changing the association temporarily will
work.  Is this the only solution?

Anyways - I shall ponde ront his and hack up some more code to
experiment - but thank you very much for pointing this out and helping
me.

Regards

Eagle

On Aug 24, 11:37 pm, clemos <[EMAIL PROTECTED]> wrote:
> Hi
>
> Hehe, now there's too much information :)
> Your problem is here:
>
> >function index() {
> >$this->pageTitle = 'CTT::All venues';
> >$this->set('venues',$this->paginate('Venue'));
> >$venues = $this->Venue->Contact-
> >>find('first',array('conditions'=>array('Contact.jobType'=>'main')));
> >}
>
> You actually paginate the Venues first, and fill the $venues view
> variable with the result. Paginating generates all your queries but
> the last one (it needs to count all venues, query for associated
> models, etc).
> Then you find() the 'first' Contact with jobType=main, but don't even
> pass this variable to the view, so your last line of code, your
> 'find', your condition have no effect.
>
> I don't know how good practice it is, but in this kind of situation, I
> use to change temporarily the association conditions before
> paginating, like this :
> $this->Venue->hasMany['Contact']['conditions'] =
> array('Contact.jobType'=>'main');
> $this->paginate('Venue');
> There may be more elegant solutions to do this, but ...
>
> +
> Clément
>
> On Mon, Aug 25, 2008 at 12:09 AM, eagle <[EMAIL PROTECTED]> wrote:
>
> > Hi Clemos,
> > Thanks fro the reply ... more detail below 
> > I agree it does look like I am finding all venues, all contacts then
> > all contacts with a condition but I do not believe I am - hence my
> > confusion!
>
> > The venues_controller.php:
>
> > class VenuesController extends AppController {
>
> >var $name = 'Venues';
> >var $helpers = array('Html', 'Form');
> >var $paginate = array(
> >'limit' => 10,
> >'page' => 1,
> >'order' => array(
> >'Venue.name' => 'ASC'
> >)
> >);
>
> >function index() {
> >$this->pageTitle = 'CTT::All venues';
> >$this->set('venues',$this->paginate('Venue'));
> >$venues = $this->Venue->Contact-
> >>find('first',array('conditions'=>array('Contact.jobType'=>'main')));
> >}
> > }
>
> > Venue MODEL:
> > class Venue extends AppModel
> > {
> >var $name = 'Venue';
> >var $hasMany = array(
> >'Contact' => array(
> >'className' => 'Contact',
> >'foreignKey' => 'venue_id',
> >)
> >);
> >var $belongsTo = array(
> >'County' => array(
> >'className' => 'County',
> >'foreignKey' => 'county_id'
> >),
> >'VenueType' => array (
> >'className' => 'VenueType',
> >'foreignKey' => 'venueType_id'
> >),
> >'Flag' => array (
> >'className' => 'Flag',
> >'foreignKey' => 'flag_id'
> >)
> >);
> > }
> > ?>
> > Contact MODEL
> > class Contact extends AppModel
> > {
> >var $name = 'Contact';
> >var $belongsTo = array(
> >'Venue' => array(
> >'className' => 'Venue',
> >'foreignKey' => 'venue_id'
> >)
> >);
> > }
>
> > Finally the VIEW:
> > 
> > 
> > 
> > 
> >sort('Flag', 'flag_id'); ?>
> >sort('Venue Details', 'name'); ?> 
> >sort('Contact','contact'); ?> 
> >
> > 
> >  >$i = 0;
> >foreach ($venues as $venue):
> >$class = null;
> >if ($i++ % 2 ==0) {
> >$class = ' class="altrow"';
> >}
> > ?>
> > >
> >
> >
> >
> >
> >link(__($venue['Venue']['name'],true),
> > array('action'=>'view',$venue['Venue']['id']));?>
> >
> >
> >
> > >//if ($contact['jobType'] == 'main') {
> >echo '';
> >$thisContact = $contact['fName'] . ' ' . 
> > $contact['lName'];
> >   

Re: Custom validation for two fields

2008-08-24 Thread villas

Take a look at this,  it may help:

http://bakery.cakephp.org/articles/view/using-equalto-validation-to-compare-two-form-fields

On Aug 24, 8:48 pm, cem <[EMAIL PROTECTED]> wrote:
> Hi ;
>
>  I want to code a custom validation function for my model which
> compares two fields in the database table . One is budgetMin and the
> other is BudgetMax . If the budget min < budgetMax return true . But
> how can I pass the budget variables in the fgunction did anyone do
> that before ?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



flash and requestAction. message is flashed twice

2008-08-24 Thread Pentla

I am using Session helper for flashing messages.

Pages Controller, Add action:
...
if($this->Page->save($this->data) {
  $this->setFlash('saved', 'flash');
  $this->redirect('pages/index');
} else {
  $this->setFlash('error', 'flash');
  $this->render();
}

Everything works fine. But when I am using $this->requestAction(), It
flash message and message stay in Session (so message is flashed
twice).

For example:
I have view without table, and I am rendering table by $this-
>requestAction('pages/list_data').

Pages Controller. list_data action:
function list_data() {
  $this->layout = null;
  $this->render()
}
so it render table, but flashMessage one more time. $session->flash()
is used in default view, so it should be the problem.

Any ideas?
Many thanks

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



Re: Struggling with associated models ... still .... :-(

2008-08-24 Thread eagle

Hi Clemos,
Thanks fro the reply ... more detail below 
I agree it does look like I am finding all venues, all contacts then
all contacts with a condition but I do not believe I am - hence my
confusion!

The venues_controller.php:

class VenuesController extends AppController {

var $name = 'Venues';
var $helpers = array('Html', 'Form');
var $paginate = array(
'limit' => 10,
'page' => 1,
'order' => array(
'Venue.name' => 'ASC'
)
);

function index() {
$this->pageTitle = 'CTT::All venues';
$this->set('venues',$this->paginate('Venue'));
$venues = $this->Venue->Contact-
>find('first',array('conditions'=>array('Contact.jobType'=>'main')));
}
}

Venue MODEL:
class Venue extends AppModel
{
var $name = 'Venue';
var $hasMany = array(
'Contact' => array(
'className' => 'Contact',
'foreignKey' => 'venue_id',
)
);
var $belongsTo = array(
'County' => array(
'className' => 'County',
'foreignKey' => 'county_id'
),
'VenueType' => array (
'className' => 'VenueType',
'foreignKey' => 'venueType_id'
),
'Flag' => array (
'className' => 'Flag',
'foreignKey' => 'flag_id'
)
);
}
?>
Contact MODEL
class Contact extends AppModel
{
var $name = 'Contact';
var $belongsTo = array(
'Venue' => array(
'className' => 'Venue',
'foreignKey' => 'venue_id'
)
);
}

Finally the VIEW:




sort('Flag', 'flag_id'); ?>
sort('Venue Details', 'name'); ?> 
sort('Contact','contact'); ?> 



>




link(__($venue['Venue']['name'],true),
array('action'=>'view',$venue['Venue']['id']));?>



';
$thisContact = $contact['fName'] . ' ' . 
$contact['lName'];
echo $html->link($thisContact, 
'mailto:'.$contact['email']);
echo ' (' . $contact['position'] . ')  T: ' .
$contact['telephone'] . '  E: ' . $contact['email'];
echo "";
//}
?>



link(__('Edit', true), array('action'=>'edit',
$venue['Venue']['id'])); ?> |
link(__('Delete', true), 
array('action'=>'delete',
$venue['Venue']['id']), null, sprintf(__('Are you sure you want to
delete # %s?', true), $venue['Venue']['name'])); ?>









prev('<< '.__('previous', true), array(),
null, array('class'=>'disabled'));?>
 |  numbers();?>
next(__('next', true).' >>', array(), null,
array('class'=>'disabled'));?>


You should be able to view the data thus far at: 
http://ctt.homelinux.net/cttManager/venues

Thanks again for your attention to this.

Regards

Eagle

On Aug 24, 10:54 pm, clemos <[EMAIL PROTECTED]> wrote:
> Hi eagle.
>
> Once again, I think there is not enough information to help. From the
> queries outputted, it looks like you do more in your controller method
> than a single "find".
> It looks like you find(all) Venues, not Contacts, and then find(all)
> Contacts with the jobType condition, so that the Contacts associated
> to the Venues you list aren't properly selected, because the jobType
> condition is only defined later, in another 'find'...
> Can you please give more detail, like the full controller action code,
> including the way you set your variables for your view, and eventually
> your Model definitions (associations).
> Also, what is the result of changing "jobType"=>"main" to
> "Contact.jobType"=>"main" ?
> (I don't think your problem is here, but anyway it's still better practice...)
>
> 
> Clément
>
> On Sun, Aug 24, 2008 at 10:23 PM, eagle <[EMAIL PROTECTED]> wrote:
>
> > Thanks for the useful advice Clement.
> > The queries that are run are as follows:
>
> > DESCRIBE `venues`   15  15  3
> > DESCRIBE `counties` 2   2   2
> > DESCRIBE `venue_types`  2   2   2
> > DESCRIBE `flags`2   2   2
> > DESCRIBE `contacts` 11  11  3
> > SELECT COUNT(*) AS `count` FROM `venues` AS `Venue` LEFT JOIN
> > `counties` AS `County` ON (`Venue`.`county_id` = `County`.`id`) LEFT
> > JOIN `venue_types` AS `VenueType` ON (`Venue`.`venueType_id` =
> > `VenueType`.`id`) LEFT JOIN `flags` AS `Flag` ON (`Venue`.`flag_id` =
> > `Flag`.`id`) WHERE 1 = 1
> > SELE

Re: How to send email using build-in email component

2008-08-24 Thread [EMAIL PROTECTED]

thanks for your reply. Does that mean firstly I need to set up a mail
server on my machine, and then try to use php mail function to see
what is happening?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: How to send email using build-in email component

2008-08-24 Thread clemos

Hi

By default, it'll simply use the mail() php function (see the email
component sourcecode).
You should first try to use "mail()" without Cake, to see if it's a
Cake issue or not (I think it's not). If your mail never arrives, then
your problem is likely with your server setup, not with Cake.
If so, it can be an issue with your php configuration (see:
http://fr.php.net/manual/en/mail.configuration.php), or with your
sendmail configuration, and lots of other things...

+
Clément

On Sun, Aug 24, 2008 at 11:38 PM, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
>
> Hi, there
>
> I have the following code to send a very simple email,
>
> $this->Email->to = '[EMAIL PROTECTED]';
> $this->Email->subject = 'Welcome to our website';
> $success = $this->Email->send('Welcome to our website. Please login
> using the following link');
>
> if ($success)
> {
>$this->Session->setFlash('Information: email was sent.',null);
> }
> else
> {
>$this->Session->setFlash('Information: Failed to send
> email.',null);
> }
>
> well, function send return true in this case. Does that mean it
> already sent the email? Why didn't I see the email in my gmail
> account?
>
> I didn't add/create any mail system on my linux system. The only thing
> I can ensure is my compute is access to internet.
>
> Cakephp version: 1.2RC
>
> I'd appreciate your help very much.
>
> Thanks,
> Bo
>
> >
>

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



Re: Struggling with associated models ... still .... :-(

2008-08-24 Thread clemos

Hi eagle.

Once again, I think there is not enough information to help. From the
queries outputted, it looks like you do more in your controller method
than a single "find".
It looks like you find(all) Venues, not Contacts, and then find(all)
Contacts with the jobType condition, so that the Contacts associated
to the Venues you list aren't properly selected, because the jobType
condition is only defined later, in another 'find'...
Can you please give more detail, like the full controller action code,
including the way you set your variables for your view, and eventually
your Model definitions (associations).
Also, what is the result of changing "jobType"=>"main" to
"Contact.jobType"=>"main" ?
(I don't think your problem is here, but anyway it's still better practice...)


Clément

On Sun, Aug 24, 2008 at 10:23 PM, eagle <[EMAIL PROTECTED]> wrote:
>
> Thanks for the useful advice Clement.
> The queries that are run are as follows:
>
> DESCRIBE `venues`   15  15  3
> DESCRIBE `counties` 2   2   2
> DESCRIBE `venue_types`  2   2   2
> DESCRIBE `flags`2   2   2
> DESCRIBE `contacts` 11  11  3
> SELECT COUNT(*) AS `count` FROM `venues` AS `Venue` LEFT JOIN
> `counties` AS `County` ON (`Venue`.`county_id` = `County`.`id`) LEFT
> JOIN `venue_types` AS `VenueType` ON (`Venue`.`venueType_id` =
> `VenueType`.`id`) LEFT JOIN `flags` AS `Flag` ON (`Venue`.`flag_id` =
> `Flag`.`id`) WHERE 1 = 1
> SELECT `Venue`.`id`, `Venue`.`name`, `Venue`.`add1`, `Venue`.`add2`,
> `Venue`.`town`, `Venue`.`county_id`, `Venue`.`postcode`,
> `Venue`.`telephone`, `Venue`.`boxOffice`, `Venue`.`fax`,
> `Venue`.`website`, `Venue`.`publicity`, `Venue`.`venueNotes`,
> `Venue`.`flag_id`, `Venue`.`venueType_id`, `County`.`id`,
> `County`.`name`, `VenueType`.`id`, `VenueType`.`name`, `Flag`.`id`,
> `Flag`.`name` FROM `venues` AS `Venue` LEFT JOIN `counties` AS
> `County` ON (`Venue`.`county_id` = `County`.`id`) LEFT JOIN
> `venue_types` AS `VenueType` ON (`Venue`.`venueType_id` =
> `VenueType`.`id`) LEFT JOIN `flags` AS `Flag` ON (`Venue`.`flag_id` =
> `Flag`.`id`) WHERE 1 = 1 ORDER BY `Venue`.`name` ASC LIMIT 10
> SELECT `Contact`.`venue_id`, `Contact`.`id`, `Contact`.`title`,
> `Contact`.`fName`, `Contact`.`lName`, `Contact`.`telephone`,
> `Contact`.`mobile`, `Contact`.`email`, `Contact`.`contactNotes`,
> `Contact`.`jobType`, `Contact`.`position` FROM `contacts` AS `Contact`
> WHERE `Contact`.`venue_id` IN (7, 8, 9, 10, 11, 12, 13, 14, 15, 16)
> SELECT `Contact`.`venue_id`, `Contact`.`id`, `Contact`.`title`,
> `Contact`.`fName`, `Contact`.`lName`, `Contact`.`telephone`,
> `Contact`.`mobile`, `Contact`.`email`, `Contact`.`contactNotes`,
> `Contact`.`jobType`, `Contact`.`position`, `Venue`.`id`,
> `Venue`.`name`, `Venue`.`add1`, `Venue`.`add2`, `Venue`.`town`,
> `Venue`.`county_id`, `Venue`.`postcode`, `Venue`.`telephone`,
> `Venue`.`boxOffice`, `Venue`.`fax`, `Venue`.`website`,
> `Venue`.`publicity`, `Venue`.`venueNotes`, `Venue`.`flag_id`,
> `Venue`.`venueType_id` FROM `contacts` AS `Contact` LEFT JOIN `venues`
> AS `Venue` ON (`Contact`.`venue_id` = `Venue`.`id`) WHERE `jobType` =
> 'main' LIMIT 1
>
> So I get the venues ... fine.  Then CakePHP runs two SELECT queries
> from the contacts table.  The second is the one I want, not the
> first.  This, as far as I can see, is being produced from:
>
> $this->Venue->Contact-
>>find('all',array('conditions'=>array('jobType'=>'main')));
>
> The output from  is:
>
> Array
> (
>[Venue] => Array
>(
>[id] => 7
>[name] => Abbey Green
>[add1] => Close Place
>[add2] =>
>[town] => Anytown
>[county_id] => 7
>[postcode] => I
>[telephone] => 01222 222333
>[boxOffice] =>
>[fax] => 01222 222334
>[website] =>
>[publicity] => 0
>[venueNotes] =>
>[flag_id] => 2
>[venueType_id] => 1
>)
>
>[County] => Array
>(
>[id] => 7
>[name] => Suffolk
>)
>
>[VenueType] => Array
>(
>[id] => 1
>[name] => National Trust
>)
>
>[Flag] => Array
>(
>[id] => 2
>[name] => Maybe
>)
>
>[Contact] => Array
>(
>[0] => Array
>(
>[venue_id] => 7
>[id] => 5
>[title] => Ms
>[fName] => Sally
>[lName] => Jones
>[telephone] => 01223 111222
>[mobile] => 07897 123123
>[email] => [EMAIL PROTECTED]
>[contactNotes] =>
>[jobType] => finance
>[position] => Finance Manager
>)
>
>[1] => Array
>(
>[venue_id] =

How to send email using build-in email component

2008-08-24 Thread [EMAIL PROTECTED]

Hi, there

I have the following code to send a very simple email,

$this->Email->to = '[EMAIL PROTECTED]';
$this->Email->subject = 'Welcome to our website';
$success = $this->Email->send('Welcome to our website. Please login
using the following link');

if ($success)
{
$this->Session->setFlash('Information: email was sent.',null);
}
else
{
$this->Session->setFlash('Information: Failed to send
email.',null);
}

well, function send return true in this case. Does that mean it
already sent the email? Why didn't I see the email in my gmail
account?

I didn't add/create any mail system on my linux system. The only thing
I can ensure is my compute is access to internet.

Cakephp version: 1.2RC

I'd appreciate your help very much.

Thanks,
Bo

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



Re: Focus On cake Validation

2008-08-24 Thread RichardAtHome

A quick bit of jQuery:

$("#content form:first div.error:first input:first").focus();

Will focus the first errored input field on the first form in the
#content div.

It will fail silently if the first input element on the forum is not a
input control (a textarea for example).

[EMAIL PROTECTED] wrote:
> hello guys
>
> in my cakephp project i uses the cake validation witch uses server
> side validation , i need it to focus on the error field after
> detecting it so how can i do something like this  ?? since the focus
> can be done with a client side  validation , so im wondiring if there
> is any way in cake to do that in the same validation process .
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Cake + WAMP

2008-08-24 Thread Joe

Sounds like you don't have mod_rewrite turned on. Click on the icon in
the taskbar and locate "Apache Modules", in there you should see one
called mod_rewrite, click it and it should restart WAMP. Should work
after that.

On Aug 22, 11:14 am, "Arak Tai'Roth" <[EMAIL PROTECTED]> wrote:
> So I decided I would try using WAMP for my development setup. But for
> some reason I go to localhost and get the WAMP homepage fine, yet when
> I try to access my project I get this "The requested URL /app/webroot/
> was not found on this server.".
>
> I did edit the httpd.conf file to load mod_rewrite and I did restart
> the services after doing that.
>
> I am using the newest version of WAMP, freshly downloaded, and using
> the latest build of Cake. My directory structure for this is C:\wamp
> \www\projectname\
>
> Does anyone know if there is anything else I need to do to get this
> working on WAMP?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Pagination question about filtered views

2008-08-24 Thread itsnotvalid

Thanks.

On Aug 25, 12:59 am, clemos <[EMAIL PROTECTED]> wrote:
> Hi
>
> You need to set the "url" option of the paginator, by writing this
> kind of code on top of your view (before the paginator links are
> generated)
> options(array("url"=>"/categories/view/".$category_id)); ?>
>
> +++
> Clément
>
>
>
> On Sun, Aug 24, 2008 at 6:33 PM, itsnotvalid <[EMAIL PROTECTED]> wrote:
>
> > I have made an app using pagination. Recently I discovered that the
> > links generated isn't valid for some use.
> > e.g.http://example.com/categories/view/1is the page refering to
> > using 'categories' controller's 'view' action, listing information for
> > category_id = 1.
>
> > Now I want to apply pagination for this page, using $paginator-
> >>next(), but the link points tohttp://example.com/categories/view/page:2
> > which is not what I really wanted. What I want is something like
> >http://example.com/categories/view/1/page:2.
>
> > How can I achieve this?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Struggling with associated models ... still .... :-(

2008-08-24 Thread eagle

Thanks for the useful advice Clement.
The queries that are run are as follows:

DESCRIBE `venues`   15  15  3
DESCRIBE `counties` 2   2   2
DESCRIBE `venue_types`  2   2   2
DESCRIBE `flags`2   2   2
DESCRIBE `contacts` 11  11  3
SELECT COUNT(*) AS `count` FROM `venues` AS `Venue` LEFT JOIN
`counties` AS `County` ON (`Venue`.`county_id` = `County`.`id`) LEFT
JOIN `venue_types` AS `VenueType` ON (`Venue`.`venueType_id` =
`VenueType`.`id`) LEFT JOIN `flags` AS `Flag` ON (`Venue`.`flag_id` =
`Flag`.`id`) WHERE 1 = 1
SELECT `Venue`.`id`, `Venue`.`name`, `Venue`.`add1`, `Venue`.`add2`,
`Venue`.`town`, `Venue`.`county_id`, `Venue`.`postcode`,
`Venue`.`telephone`, `Venue`.`boxOffice`, `Venue`.`fax`,
`Venue`.`website`, `Venue`.`publicity`, `Venue`.`venueNotes`,
`Venue`.`flag_id`, `Venue`.`venueType_id`, `County`.`id`,
`County`.`name`, `VenueType`.`id`, `VenueType`.`name`, `Flag`.`id`,
`Flag`.`name` FROM `venues` AS `Venue` LEFT JOIN `counties` AS
`County` ON (`Venue`.`county_id` = `County`.`id`) LEFT JOIN
`venue_types` AS `VenueType` ON (`Venue`.`venueType_id` =
`VenueType`.`id`) LEFT JOIN `flags` AS `Flag` ON (`Venue`.`flag_id` =
`Flag`.`id`) WHERE 1 = 1 ORDER BY `Venue`.`name` ASC LIMIT 10
SELECT `Contact`.`venue_id`, `Contact`.`id`, `Contact`.`title`,
`Contact`.`fName`, `Contact`.`lName`, `Contact`.`telephone`,
`Contact`.`mobile`, `Contact`.`email`, `Contact`.`contactNotes`,
`Contact`.`jobType`, `Contact`.`position` FROM `contacts` AS `Contact`
WHERE `Contact`.`venue_id` IN (7, 8, 9, 10, 11, 12, 13, 14, 15, 16)
SELECT `Contact`.`venue_id`, `Contact`.`id`, `Contact`.`title`,
`Contact`.`fName`, `Contact`.`lName`, `Contact`.`telephone`,
`Contact`.`mobile`, `Contact`.`email`, `Contact`.`contactNotes`,
`Contact`.`jobType`, `Contact`.`position`, `Venue`.`id`,
`Venue`.`name`, `Venue`.`add1`, `Venue`.`add2`, `Venue`.`town`,
`Venue`.`county_id`, `Venue`.`postcode`, `Venue`.`telephone`,
`Venue`.`boxOffice`, `Venue`.`fax`, `Venue`.`website`,
`Venue`.`publicity`, `Venue`.`venueNotes`, `Venue`.`flag_id`,
`Venue`.`venueType_id` FROM `contacts` AS `Contact` LEFT JOIN `venues`
AS `Venue` ON (`Contact`.`venue_id` = `Venue`.`id`) WHERE `jobType` =
'main' LIMIT 1

So I get the venues ... fine.  Then CakePHP runs two SELECT queries
from the contacts table.  The second is the one I want, not the
first.  This, as far as I can see, is being produced from:

$this->Venue->Contact-
>find('all',array('conditions'=>array('jobType'=>'main')));

The output from  is:

Array
(
[Venue] => Array
(
[id] => 7
[name] => Abbey Green
[add1] => Close Place
[add2] =>
[town] => Anytown
[county_id] => 7
[postcode] => I
[telephone] => 01222 222333
[boxOffice] =>
[fax] => 01222 222334
[website] =>
[publicity] => 0
[venueNotes] =>
[flag_id] => 2
[venueType_id] => 1
)

[County] => Array
(
[id] => 7
[name] => Suffolk
)

[VenueType] => Array
(
[id] => 1
[name] => National Trust
)

[Flag] => Array
(
[id] => 2
[name] => Maybe
)

[Contact] => Array
(
[0] => Array
(
[venue_id] => 7
[id] => 5
[title] => Ms
[fName] => Sally
[lName] => Jones
[telephone] => 01223 111222
[mobile] => 07897 123123
[email] => [EMAIL PROTECTED]
[contactNotes] =>
[jobType] => finance
[position] => Finance Manager
)

[1] => Array
(
[venue_id] => 7
[id] => 4
[title] => Mr
[fName] => Fred
[lName] => Smith
[telephone] => 01223 123123
[mobile] => 07678 123123
[email] => [EMAIL PROTECTED]
[contactNotes] =>
[jobType] => main
[position] => Marketing Manager
)

)

)

Pertinent here are the two contacts being fetched ... I want only the
one where the jobType = 'main'.  I reckon the first SELECT query is
being used, not teh filtered one.

I hope this provides some more detail ... I was concerned about
sending too long a message.

I rellay appreciate the help on here.

Thanks

Eagle
On Aug 24, 2:57 pm, clemos <[EMAIL PROTECTED]> wrote:
> Hi
>
> Why exactly do you want to "switch off the first query" ? Maybe you
> could provide us with these queries you get, so that we can tell if
> they really need to be "switched off" or not...
> What

Re: generatetreelist()

2008-08-24 Thread validkeys

I believe that you are missing: $this->Category->create();

$this->Category->create();
$data['Category']['parent_id'] = 3;
$data['Category']['name'] = $fieldName ;
if($this->Category->save($data)){
exit;
}

I don't believe this is deprecated or is it?

On Aug 23, 12:56 pm, Abrar <[EMAIL PROTECTED]> wrote:
> hi , here im trying to use generatetreelist() first time,  so whats
> problem im facing is that it saves the data two times with once
> execution of code.
>
>  here is my code that im using
>
>         function addData($fieldName = null, $pa_id = null){
>
>                 $existance = $this->Category->findByName($fieldName);
>                 if($existance){
>                 $this->set('error','This name already exists.');
>                 }else{
>                         $data['Category']['parent_id'] = 3;
>                         $data['Category']['name'] = $fieldName ;
>                         if($this->Category->save($data)){
>                             exit;
>                         }
>                 }
>         }//addData
>
> result in the database
>
>        id   parent_id     lft      rght     name
> 
>       48        3           34       35       bari      --->
> only this result should be saved here
>
>       47        3        NULL    NULL    bari   ---> this
> is unexpected ( problem )
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Custom validation for two fields

2008-08-24 Thread cem

Hi ;

 I want to code a custom validation function for my model which
compares two fields in the database table . One is budgetMin and the
other is BudgetMax . If the budget min < budgetMax return true . But
how can I pass the budget variables in the fgunction did anyone do
that before ?


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



Re: Allowing entire controllers with Auth component

2008-08-24 Thread tekomp

I was still having a problem with it because I created my own
pages_controller.php.  Once I copied the default one from /cake/libs/
controller/pages_controller.php and added the snippets posted here, I
was able to override the display action and all my "pages" didn't
require authorization, while at the same time still have the Auth
component work in the background.

On Aug 23, 3:49 pm, tekomp <[EMAIL PROTECTED]> wrote:
> I'm using the Auth Component in my app_controller.php in the
> beforeFilter function, which is great for making people login, but I'm
> having a hard time allowing certain pages.  I want all pages in my
> "Pages" controller to not require authorization, so I added 
> $this->Auth->allow('*')  in my beforeFilter in pages_controller.php.
>
> Problem with that is that it overrides the beforeFilter in
> app_controller.php and I cannot access $this->Auth.  I tried adding
> parent::beforeFilter in pages_controller.php, but it then does not
> recognize my $this->Auth->allow('*').
>
> I've tried a number of things and read all the tutorials I could find,
> but still can't find a way to allow an entire controller while
> maintaining this->Auth.  It doesn't seem right that I'd have to add
> the Auth code to each individual controller.
>
> Any ideas?
>
> Thanks.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: make .js on fly using cakephp

2008-08-24 Thread spyros k.

Hi, I'm having some trouble understanding how one can create .js files
on the fly using cakephp.

I've read the resources mentioned in this thread but I still can't
understand how to do it, and I'd like to ask if someone could help me.

I have two models associated with a hasMany and belongsTo relationship
(let's say modelA hasMany modelB and modelB belongsTo modelA) and what
I want to do is:
1) get a field from those modelB entries, that belong to a specific
modelA record, when a user makes calls an action from modelA's
controller
2) write the results to a .js file to be used by the action's view

As far as (1) goes, I believe I know how to do that, the big problem
i'm having is (2).
Does anyone have any suggestions or ideas on how I could accomplish
that?

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



Re: Problems with the Bake (Windows Vista + Xampp + MinGW)

2008-08-24 Thread clemos

Then you must also add the path to php.exe cli to your path
environment variable.

+++
Clément

On Sun, Aug 24, 2008 at 7:31 AM, giulio <[EMAIL PROTECTED]> wrote:
>
> If i write cake.bat it returns me the answer that php is not know as
> command
>
> Thanks for the help
>
> Giulio
>
>
>
> On 24 Ago, 07:29, giulio <[EMAIL PROTECTED]> wrote:
>> Hi,
>>
>> I see the tutorial and i read a lot of articles on the web, but this
>> not solve my problems.
>>
>> I'm trying to configure cake php on windows vista using xampp.
>>
>> I've added the path to the environment variable, and i tried to
>> substitute with an updated version the mysqli.dll but it seems that
>> windows doesn't recognise .php extension.
>>
>> When i try to digit cake.php in my app/console folder, it opens a txt
>> file like this
>>
>> #!/usr/bin/php -q
>> > /* SVN FILE: $Id: cake.php 7296 2008-06-27 09:09:03Z gwoo $ */
>> /**
>>  * Command-line code generation utility to automate programmer chores.
>>  *
>>  * Shell dispatcher class
>>  *
>>  * PHP versions 4 and 5
>>  *
>>  * CakePHP(tm) :  Rapid Development Framework >
>>  * Copyright 2005-2008, Cake Software Foundation, Inc.
>>  *
>>
>> Excuse me but i never work with CLI and this is one of the first time
>> that i use windows vista, so please write to me all the things to do:
>> adding environment variables etc etc...
>>
>> Thanks Giulio
>>
>> On 22 Ago, 04:26, "Chris Hartjes" <[EMAIL PROTECTED]> wrote:
>>
>> > On Thu, Aug 21, 2008 at 10:22 PM, giulio <[EMAIL PROTECTED]> wrote:
>>
>> > > Thank you very much for the help.
>>
>> > > Can i find also a text help insted of videos?... i've some problems
>> > > with my connection to see videos.
>>
>> > I don't know of any off-hand, but you can probably find them via Google.
>>
>> > --
>> > Chris Hartjes
>> > Motto for 2008: "Moving from herding elephants to handling snakes..."
>> > @TheKeyBoard:http://www.littlehart.net/atthekeyboard
> >
>

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



Struggling with associated models ... still .... :-(

2008-08-24 Thread eagle

Hi,
I'm still struggling with a problem - which should be easy (I think)
but  :-(  Any advice you more experienced folks could give ?

I want to achieve something akin to the following (building on the
example in the manual):

$this->Recipe->Ingredient->find('all');

my code is

$this->Venue->Contact->find('all',
array('conditions'=>array('jobType'=>'main')));

I am expecting this to retrieve data for venues and contacts where
their jobtype is stated as 'main', but it fetches all venues and all
contacts irrespective of their 'jobType'.  I have tried replacing
'all' with 'first' but the same behaviour.

The SQL debug info shows the Venue query running then TWO Contact
queries - the first getting everything, the second filtering as I
want  how can I switch off the first CONTACT query ...?

How can I get only the 'main' contacts for each venue and then display
in a view?

My latest fudge is to get them all and the filter in the view with:
if ($contact['jobType'] == 'main') { ... }
but I reckon I'm missing something much cleaner than this.

Thanks for your help

Eagle

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



Re: CakePHP User Authentication

2008-08-24 Thread clemos

I think it's a very clever idea, despite the fact that it's a quite
common behaviour.
Also, I think this exact same kind of thing has been discussed quite a
lot of times here, so I suggest that you read the numerous googlegroup
posts that cover this subject, or the bakery, or the blog entries, all
of which you can find on the Internets by typing "auth cakephp" on the
following website :
http://google.com

+++
Clément

On Sun, Aug 24, 2008 at 6:16 PM, ss <[EMAIL PROTECTED]> wrote:
>
> Hello all,
> I want to set up a user authentication and check in the "View".
> Meaning, if a user is logged in, it should say "Welcome [user]" and
> then the regular form content.  If the user is not logged in, it
> should just display the regular content on the view page.
>
> Any thoughts?
> >
>

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



Re: CakePHP User Authentication

2008-08-24 Thread Sam Sherlock
check the session using the session helper.



2008/8/24 ss <[EMAIL PROTECTED]>

>
> Hello all,
> I want to set up a user authentication and check in the "View".
> Meaning, if a user is logged in, it should say "Welcome [user]" and
> then the regular form content.  If the user is not logged in, it
> should just display the regular content on the view page.
>
> Any thoughts?
> >
>

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



Pagination question about filtered views

2008-08-24 Thread itsnotvalid

I have made an app using pagination. Recently I discovered that the
links generated isn't valid for some use.
e.g. http://example.com/categories/view/1 is the page refering to
using 'categories' controller's 'view' action, listing information for
category_id = 1.

Now I want to apply pagination for this page, using $paginator-
>next(), but the link points to http://example.com/categories/view/page:2
which is not what I really wanted. What I want is something like
http://example.com/categories/view/1/page:2.

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



Re: Removing page execution time from bottom of page

2008-08-24 Thread itsnotvalid

Or disable it on the specific view using $config.

On Aug 24, 5:35 am, majna <[EMAIL PROTECTED]> wrote:
> just set Debug to 0.
> (execution time is echoed from webroot/index.php, but only in debug
> mode)
>
> On Aug 23, 11:02 pm, Aaron <[EMAIL PROTECTED]> wrote:
>
>
>
> > At the bottom of every rendered page is an execution time (i.e.
> > )  I have views that return json and this breaks the
> > parsing.  How do I remove this?
>
> > -Aaron
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Database relationships etc

2008-08-24 Thread fuSEboX

Hi,

Thank You Rafael.
Pointing out that verborragic and many explanation issues was helpful
too... I always thought that when I try to explain things just like
they are in my head, it gives reader greater overview. Now I see that
it's wrong. So if some time ago I wrote too less and now I wrote too
much, then it seems I need to find that golden center. :)

And about groups in my language...I admit, that for CakePHP I haven't
even look for groups in my language. And times are shown that I'm able
to get more info from English speaking groups/forums...also chance for
me to learn. :)

But You've done great job by understanding and answering all those
questions. :P
This post cleared many things out and I'll make this post my road map
for relationships. And currently I don't have any questions...just
lots of testing now. :)

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



CakePHP User Authentication

2008-08-24 Thread ss

Hello all,
I want to set up a user authentication and check in the "View".
Meaning, if a user is logged in, it should say "Welcome [user]" and
then the regular form content.  If the user is not logged in, it
should just display the regular content on the view page.

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



Re: 1.2 and Paypal

2008-08-24 Thread Riccardo

Hi,
Also i search it.
Thanks!

On 24 Ago, 09:30, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> Hi all,
> I've  noticed that the primary Paypal component (http://
> bakery.cakephp.org/articles/view/paypal-direct-payment-api-component)
> is for 1.1 and not 1.2. For anyone out there using 1.2, what component
> are you using?
>
> Thanks!

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



Re: Auth Component admin login redirect for unauthorized page access

2008-08-24 Thread Marcin Domanski

C'mon man- do some searching. I suggest looking at the api at auth
component properties.
HTH

2008/8/24, mario <[EMAIL PROTECTED]>:
>
> Hello,
>
> How can I configure the Auth component so that
> it will redirect me to the login action of my admins_controller
> everytime someone access an unauthorized page?
>
> I see that it redirects me to the login action of my user_controller
> which I don't want to happen.
>
> Here is a snippet of my app_controller.php
>
>  class AppController extends Controller {
>   var $components = array('Auth');
>   function beforeFilter()
>   {
>   $this->Auth->loginRedirect = array('controller' => 'mainpage',
> 'action' => 'home');
>   $this->Auth->logoutRedirect = array('controller' => 'mainpage',
> 'action' => 'home');
>   $this->Auth->allow('home');
>   $this->Auth->authorize = 'controller';
>   $this->set('loggedIn', $this->Auth->user('id'));
>   }
>   function isAuthorized()
>   {
>   return true;
>   }
> }
> ?>
>
> Thanks,
>
> Mario
>
>
> >
>


-- 
Marcin Domanski
http://kabturek.info

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



Re: Changing default directories

2008-08-24 Thread Fahad

you can even try this:

$html->css("/includes/style.css");
$javascript->link("/includes/script.js");

--
Fahad
http://frinity.blogspot.com

On Aug 24, 4:08 am, seanislegend <[EMAIL PROTECTED]> wrote:
> Just had a look on the Book, and this is what I'm after (in case
> anyone else may find it handy):http://api.cakephp.org/paths_8php.html
>
> On Aug 23, 10:43 pm, majna <[EMAIL PROTECTED]> wrote:
>
> > fast and stupid:
> > webroot/index.php
> > -add at top  define ('WEBROOT_DIR', 'includes');
> > -point domain documemt root to "includes"
>
> > On Aug 23, 11:00 pm, seanislegend <[EMAIL PROTECTED]> wrote:
>
> > > Is there any way to do this? I'd like to my CSS and JS folders from
> > > the webroot to 'includes/css' etc. as this is the way I organised them
> > > before I began working with Cake, and if possible I'd like to continue
> > > like so.
>
> > > Any suggestions?
>
> > > Thanks.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Cake sheet

2008-08-24 Thread Paolo Stancato

2008/8/23 NOSLOW <[EMAIL PROTECTED]>:
>
> Here's a few more items that have been deprecated in 1.2 that are
> listed on that sheet:
>
> Global Functions: vendor(...), cache(...)
> Controller: $beforeFilter, cleanUpFields()
> Model: execute(data), findAll(...); findNeighbours(...),
> findCount(...), findAllThreaded(...)
>
> Model onError() callback was added.

Good update!

> The biggest thing to remember is to use the new find() syntax, which
> replaces the other find variants.
>
> Here's the deprecated list, which includes many things not on the
> CakeSheet:
> http://api.cakephp.org/deprecated.html
>
> Any talented and ambitious takers out there willing to create the 1.2
> CakeSheet?


It would be really great to get the source sheet. Thus anyone can update it
(as a designer I am a good coder :-S )

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



Re: Focus On cake Validation

2008-08-24 Thread Fahad

if you want to focus a validation error, you can use css.
when a submitted form has validation errors, cake will return that
field with a css class.
so its better if u define that class in ur stylesheet with a red
border for example.

hope that helps.

--
Fahad
http://frinity.blogspot.com

On Aug 24, 7:28 pm, [EMAIL PROTECTED] wrote:
> hello guys
>
> in my cakephp project i uses the cake validation witch uses server
> side validation , i need it to focus on the error field after
> detecting it so how can i do something like this  ?? since the focus
> can be done with a client side  validation , so im wondiring if there
> is any way in cake to do that in the same validation process .
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Struggling with associated models ... still .... :-(

2008-08-24 Thread clemos

Hi

Why exactly do you want to "switch off the first query" ? Maybe you
could provide us with these queries you get, so that we can tell if
they really need to be "switched off" or not...
What you say about "two queries" with one retrieving all the data, and
the other "filtering" the previous ones result doesn't make sense at
all, to me. That's definitely not how "find" works, I've never seen it
act that way. And anyway, even from a SQL point of view, it doesn't
make sense (how can a query "filter" the results of a previous query
?).
Be more precise when you expose your problem, because we can't reply
something meaningful with so few informations...

Also, is "jobType" a field of the Contact model ? if so (just trying
guess), you should write your condition like this :
"conditions"=>array("Contact.jobType"=>"main")
It should do what you're trying to do...

Rather than asking two question at the same time, whereas they're not
really related to each other, you should split your problem in two
like : (1) try to get the data you want from the Model::find method,
and once you get how "find" works, (2) see if there actually is still
too many queries being done to the database, and provide us with more
debug data so we can have a small idea of why this happens...

+++
clément

On Sun, Aug 24, 2008 at 2:13 AM, eagle <[EMAIL PROTECTED]> wrote:
>
> Hi,
> I'm still struggling with a problem - which should be easy (I think)
> but  :-(  Any advice you more experienced folks could give ?
>
> I want to achieve something akin to the following (building on the
> example in the manual):
>
> $this->Recipe->Ingredient->find('all');
>
> my code is
>
> $this->Venue->Contact->find('all',
> array('conditions'=>array('jobType'=>'main')));
>
> I am expecting this to retrieve data for venues and contacts where
> their jobtype is stated as 'main', but it fetches all venues and all
> contacts irrespective of their 'jobType'.  I have tried replacing
> 'all' with 'first' but the same behaviour.
>
> The SQL debug info shows the Venue query running then TWO Contact
> queries - the first getting everything, the second filtering as I
> want  how can I switch off the first CONTACT query ...?
>
> How can I get only the 'main' contacts for each venue and then display
> in a view?
>
> My latest fudge is to get them all and the filter in the view with:
> if ($contact['jobType'] == 'main') { ... }
> but I reckon I'm missing something much cleaner than this.
>
> Thanks for your help
>
> Eagle
>
> >
>

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



Focus On cake Validation

2008-08-24 Thread amro . t17

hello guys

in my cakephp project i uses the cake validation witch uses server
side validation , i need it to focus on the error field after
detecting it so how can i do something like this  ?? since the focus
can be done with a client side  validation , so im wondiring if there
is any way in cake to do that in the same validation process .
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: $this->element() and Model:$_schema

2008-08-24 Thread RichardAtHome

Also (may be related), in the element, why doesn't the following work?

css(array(
"element.site_search"
), null, array(), false);
?>

(the CSS file isn't being linked in the head)

It works if the last param is true, but the code is embeded in the
page and not the head.

On Aug 24, 11:27 am, RichardAtHome <[EMAIL PROTECTED]> wrote:
> I have a simple element:
>
> site_search.ctp:
> create("Search") ?>
> inputs() ?>
> end("Search") ?>
>
> Model Search is a tableless model which I manually create the schema
> for:
>
> search.php:
> class Search extends AppModel {
>
>         var $useTable = false;
>
>         var $_schema = array(
>                 "search_for"=>array(
>                         "type"=>"string",
>                         "length"=>128
>                 )
>         );
>
> }
>
> Problem: The inputs() call in the element is coming back blank. It
> works fine if I point the form at a model (ie. it generates the
> inputs) with a real database table behind it, but not for one with a
> $_schema.
>
> I tried adding:
>
> App:Imort("model", "Search");
>
> to the element, but that didn't help.
>
> How do I get an element to 'see' a model in this way?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Auth Component admin login redirect for unauthorized page access

2008-08-24 Thread mario

Hello,

How can I configure the Auth component so that
it will redirect me to the login action of my admins_controller
everytime someone access an unauthorized page?

I see that it redirects me to the login action of my user_controller
which I don't want to happen.

Here is a snippet of my app_controller.php

Auth->loginRedirect = array('controller' => 'mainpage',
'action' => 'home');
$this->Auth->logoutRedirect = array('controller' => 'mainpage',
'action' => 'home');
$this->Auth->allow('home');
$this->Auth->authorize = 'controller';
$this->set('loggedIn', $this->Auth->user('id'));
}
function isAuthorized()
{
return true;
}
}
?>

Thanks,

Mario


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



Re: Getting CakePHP to connect to MySQL

2008-08-24 Thread Jonathan Snook

On Wed, Aug 20, 2008 at 7:03 PM, Peter Weicker <[EMAIL PROTECTED]> wrote:
>
> Thank you both. I decided to try installing Cake on my ISP instead of
> running it on my own PC. They asked me to send in photo ID before
> they'd let me use the system services I'd need to complete the
> install. Not very reassuring.
>
> So, I tried installing CodeIgniter and had it up 15 minutes after I
> started Googling for it. We Windows types may complain about our
> environment, but we are used to just downloading, installing, and
> running stuff. It seems normal to us. If CakePHP was anything like
> that it would probably rule the world.

The requirements for CodeIgniter and CakePHP are very similar. I'm
surprised that CI worked where CakePHP wouldn't. It'd be interesting
to see what you tried to do in both circumstances to see how CakePHP
could improve.

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



$this->element() and Model:$_schema

2008-08-24 Thread RichardAtHome

I have a simple element:

site_search.ctp:
create("Search") ?>
inputs() ?>
end("Search") ?>

Model Search is a tableless model which I manually create the schema
for:

search.php:
class Search extends AppModel {

var $useTable = false;

var $_schema = array(
"search_for"=>array(
"type"=>"string",
"length"=>128
)
);

}

Problem: The inputs() call in the element is coming back blank. It
works fine if I point the form at a model (ie. it generates the
inputs) with a real database table behind it, but not for one with a
$_schema.

I tried adding:

App:Imort("model", "Search");

to the element, but that didn't help.

How do I get an element to 'see' a model in this way?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Database relationships etc

2008-08-24 Thread RichardAtHome

Nothing to add apart from props to Rafael for an excellent answer.

On Aug 23, 2:05 am, Rafael Bandeira aka rafaelbandeira3
<[EMAIL PROTECTED]> wrote:
> Oh, I almost slept, you should try to more clear and less verborragic,
> so many explanation just messed up things more and more...
> And you should do 2 things when you can't speak a language : 1) look
> for groups with the same language of yours and 2) say your
> nacionality, so members from the same country can get sensible with
> you and try to help you more
>
> "stop the bullshit and answer me..."
>
> OK, answers :
>
> > 1) Do I have to manually set up Foreign keys for tables?
>
> it depends, did you sitcked to conventions?
> Your CarAd Model has the following scheme and linking convention:
>
> id                                      - primaryKey
> car_type_id                        - className => CarType, uses table -> 
> car_types
>
> car_brand_id                      - className => CarBrand, uses table ->  
> car_brands
>
> car_fuel_id                         - className => CarFuel, uses table
> ->  car_fuels
> car_transmission_id            - className => CarTransmission, uses
> table ->  car_transmissions
> year
> ad_county_id                      - className => AdCountry, uses table
> ->  ad_countries
> ad_borough_id                    - className => AdBorough, uses table -> 
> ad_boroughs (?)
>
> info
> price
> car_ad_type_id                   - className => CarAdType, uses tabl -> 
> car_ad_types
>
> added                      <- tip : is this field meant to hold the
> datetime of row creation? if yes, rename it to "created" and cakePHP
> will handle it for you
>
> Said that all this foreign keys says : this CarAd belongs to this
> CarType, and to this CarBrand, and to that CarFuel... so you should
> have in your model class:
>
> class CarAd extends AppModel {
>    var $belongsTo = array (
>         'CarType', 'CarBrand', 'CarFuel', 'CarType',
>         'CarTransmission', 'AdCountry', 'AdBorough',
>    )
>
> }
>
> now CakePHP will map all your model's foreign keys and you will be
> able to access this relateds models as a property of your CarAd
> model :
> // inside your model
> $this->CarType->find([...]);
> inside your controller
> $this->CarAd->CarType->find([...]);
>
> answered? moving on...
>
> > 2) Do I have to build model for each table I need to get id's
> > from..even if the table itself will stay static ? (model for
> > car_transmissions, car_fuels_id... tables)
>
> No, actually CakePHP map table names for you too. 
> >>http://www.littlehart.net/atthekeyboard/2008/08/05/dynamic-models-in-...
>
> >   By static I mean that I don't need to add or delete data from it
> > because probably there will not be any new transmission types
> > coming. I only need to read info from it.
>
> > I know 100% that I have to build model for tables which will have
> > dynamic content...like table car_brand. (new car brand comes.. for ex.
> > "BMW-Jaguar"..and I need to add it to table from site...not manually)
>
> you should avoid this kind of thinking...
>
> > So my main table at this time is car_ads and I have controller for
> > it... and it also gives me it's table contents with simple index():
> >    function index() {
> >            $this->set('carads',$this->CarAd->find('all'));
> >    }
>
> > But I want to see text in the list..not that number which I have on
> > car_transmission_id field. (Instead of number 1 I would like to see
> > text: "Automatic")
> > Currently line looks like this: Brand: 5  Year: 2000 Transmission: 1
> > Gas: 2
> > But it should look like this:   Brand: Chevrolet Astro Year: 2000
> > Transmission: Automatic  Gas: Benzine
>
> No actually it shouldn't, what is happening is the normal and expected
> behavior.
>
> I'll explain what is already in the manual about cakePHP's data
> scheme, I'll wont reproduce arrays here because it would be very ugly
> and painfull for me so take this as example 
> :http://book.cakephp.org/view/448/findall
> -> the grey box at the bottom of the content...
>
> that's how your data will return but with the your model names...
> back to your CarAdsController::index() :
>
> >    function index() {
> >            $this->set('carads',$this->CarAd->find('all'));
> >    }
>
> in your view you will have a var named 'carads', and you'll be able to
> access data as the array in the link shows :
> // first entry's CarTransmission.transmission wil be accessed like
> this
> echo $carads[0]['CarTransmission']['transmission'];
>
> // the nth entry/row CarBrand.name will be accessed like this
> echo $carads[$num]['CarBrand']['name'];
>
> for a dynamic list or table generation, you would do something like
> this:
> foreach($carads as $entryNum => $entryData)
> {
>    echo 'Transmission: ' . $entryData['CarTransmission']
> ['transmission'];
>    echo 'Brand : ' . $entryData['CarBrand']['name'];
>    echo 'Country :  ' . $entryData['CarCountry']['name'] . '';
>
> }
> > I'll try to explain it once more..maybe

Re: Allowing entire controllers with Auth component

2008-08-24 Thread RichardAtHome

I'd do it this way round:

parent::beforeFilter();
$this->Auth->allow(array('display'));

So the controllers can override settings in AppController

On Aug 24, 8:44 am, tekomp <[EMAIL PROTECTED]> wrote:
> Thanks Sam.  Got it to work after realizing that "display" is a built-
> in action to the built-in pages controller.
>
> On Aug 23, 8:22 pm, "Sam Sherlock" <[EMAIL PROTECTED]> wrote:
>
> > try
> >         $this->Auth->allow(array('display'));
> >         parent::beforeFilter();
>
> > 2008/8/23 tekomp <[EMAIL PROTECTED]>
>
> > > I'm using the Auth Component in my app_controller.php in the
> > > beforeFilter function, which is great for making people login, but I'm
> > > having a hard time allowing certain pages.  I want all pages in my
> > > "Pages" controller to not require authorization, so I added $this-
> > > >Auth->allow('*')  in my beforeFilter in pages_controller.php.
> > > Problem with that is that it overrides the beforeFilter in
> > > app_controller.php and I cannot access $this->Auth.  I tried adding
> > > parent::beforeFilter in pages_controller.php, but it then does not
> > > recognize my $this->Auth->allow('*').
>
> > > I've tried a number of things and read all the tutorials I could find,
> > > but still can't find a way to allow an entire controller while
> > > maintaining this->Auth.  It doesn't seem right that I'd have to add
> > > the Auth code to each individual controller.
>
> > > Any ideas?
>
> > > Thanks.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Cake sheet

2008-08-24 Thread Daniel Hofstetter

Hi Sam,

> is controller beforeFilter really a goner?

The beforeFilter property is gone, but not the beforeFilter callback
method.

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



Re: Authentication for admin and public user in one(1) app

2008-08-24 Thread Sam Sherlock
have a look at these. check the role in the isAuthorized function

http://book.cakephp.org/view/396/authorize

I would not have a separate table for admins (maybe others might disagree
with me here; it may be suited to your intentions to do so) I would prevent
them based on their role

more info
http://www.littlehart.net/atthekeyboard/2007/07/28/two-headed-application-authentication-in-cakephp-12/
http://www.studiocanaria.com/articles/cakephp_auth_component_users_groups_permissions_1

- S

2008/8/23 mario <[EMAIL PROTECTED]>

>
> Hello everyone,
>
> I just learn cakephp and I'm having trouble creating the admin section
> of my app.
>
> These are what I've done so far.
>
> 1. I've created a user section with the capabilities of login/logout
> and signup.
> 2. I've created a "users" table for it.
> 3. I've overriden the app_controller and define the Auth component.
> I've also
>   created its' own beforeFilter() function.
>
>Here is a snippet of my app_controller.php code:
>
>  class AppController extends Controller {
>var $components = array('Auth');
>function beforeFilter()
>{
>$this->Auth->loginRedirect = array('controller' =>
> 'mainpage',
> 'action' => 'home');
>$this->Auth->logoutRedirect = array('controller' =>
> 'mainpage',
> 'action' => 'home');
>$this->Auth->allow('signup','home');
>$this->Auth->authorize = 'controller';
>$this->set('loggedIn', $this->Auth->user('id'));
>   }
>   function isAuthorized()
>   {
> return true;
>   }
> }
> ?>
>
> Now, i've decided to create an admin section that could
> edit,view,delete users.
> I've created a separate table for the admin, namely, "admins" table.
> I've also
> created its' own model,view, and controller.
>
> Now I'm stuck in implementing the admins' login/logout feature because
> my main problem
> is that the app_controller that I made is already "specific" to my
> user's controller.
>
> Please advise me on what to do.
>
>
>
> Thanks,
>
> Mario
>
> >
>

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



Re: Allowing entire controllers with Auth component

2008-08-24 Thread tekomp

Thanks Sam.  Got it to work after realizing that "display" is a built-
in action to the built-in pages controller.

On Aug 23, 8:22 pm, "Sam Sherlock" <[EMAIL PROTECTED]> wrote:
> try
>         $this->Auth->allow(array('display'));
>         parent::beforeFilter();
>
> 2008/8/23 tekomp <[EMAIL PROTECTED]>
>
>
>
> > I'm using the Auth Component in my app_controller.php in the
> > beforeFilter function, which is great for making people login, but I'm
> > having a hard time allowing certain pages.  I want all pages in my
> > "Pages" controller to not require authorization, so I added $this-
> > >Auth->allow('*')  in my beforeFilter in pages_controller.php.
> > Problem with that is that it overrides the beforeFilter in
> > app_controller.php and I cannot access $this->Auth.  I tried adding
> > parent::beforeFilter in pages_controller.php, but it then does not
> > recognize my $this->Auth->allow('*').
>
> > I've tried a number of things and read all the tutorials I could find,
> > but still can't find a way to allow an entire controller while
> > maintaining this->Auth.  It doesn't seem right that I'd have to add
> > the Auth code to each individual controller.
>
> > Any ideas?
>
> > Thanks.
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



1.2 and Paypal

2008-08-24 Thread [EMAIL PROTECTED]

Hi all,
I've  noticed that the primary Paypal component (http://
bakery.cakephp.org/articles/view/paypal-direct-payment-api-component)
is for 1.1 and not 1.2. For anyone out there using 1.2, what component
are you using?

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



Re: Removing page execution time from bottom of page

2008-08-24 Thread Daniel Hofstetter

Hi Aaron,

> At the bottom of every rendered page is an execution time (i.e.
> )  I have views that return json and this breaks the
> parsing.  How do I remove this?

You could remove it from the end of app/webroot/index.php

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