Re: Why unbind directive doesn't works on read function?

2010-12-11 Thread Dr. Loboto
Because unbind works only for one next query but you do two reads.

On Dec 11, 6:21 pm, "Mariano C."  wrote:
> I have two function getBasicInfo read specific book's information
> through $book_id then pass the record readed to increaseOwners that
> should upgrade owners field of recordset passed.
>
> This works pretty good, but $this- information, even if I have unbinded it.
> Why?
>
>         function getBasicInfo($book_id)
>         {
>                 $this->unbindModel(array('hasMany' => array('BooksUser')));
>                 $this->id = $book_id;
>
>                 if(is_null($this->read()))
>                         return false;
>
>                 return $this->read();
>         }
>
>         function increaseOwners($book_id)
>         {
>                 $this->data = $this->getBasicInfo($book_id);
>                 $owners = $this->data['Book']['owners'] + 1;
>
>                 // on success
>                 if($this->saveField('owners', $owners))
>                         return true;
>
>                 // on errror
>                 return false;
>         }

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: Form is not defined

2010-12-11 Thread Rishi
I have to Form & Ajax helper in the controller

On Dec 11, 6:39 pm, cricket  wrote:
> On Sat, Dec 11, 2010 at 6:29 PM, Rishi  wrote:
> > Hi
>
> > I am trying to send a ajax call to an action when ever there is a
> > change in selection.
>
> > create(''); ?>
>
> >                input('selected',array('label'=>'Select
> > Category','id'=>'selected','type'=>'select','options'=>$select));?>
>
> >                observeField('selected',
> >                                
> > array('with'=>'Form.Element.serialize(\'selected\')','url' =>
> > 'display','update'=>'codes',
> >                                
> > 'complete'=>"Effect.Appear('selected');",'onChange'=>true));?>
>
> >                end(); ?>
>
> > When I check the consle.
>
> > Form is not defined
> >http://localhost/index.php/codes/code
> > Line 46
>
> You need to have 'Form' in your $helpers array for this controller (or
> AppController).

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: Passing Variable to delete

2010-12-11 Thread Jamie
My post didn't mention checking for a valid ID or saving. I said that
Cake's DB layer sanitizes values before passing them to your database.
In other words, it filters out SQL injection attempts. To connect the
dots, this means that, no, you shouldn't have to do extra checking
(though a redundant check isn't the end of the world!).

- Jamie


On Dec 11, 4:07 pm, "Dave Maharaj"  wrote:
> What im trying to say is take site/some/action/id for example
>
> Nothing to do with checking if it’s a valid id nothing to do with saving.
>
> Can a user add anything into the url to act as an attempt to reek havoc. Say
> the id is as an example 123 and someone types in select* from I don’t know
> anything malicious so that just what I am trying to say. Similar to
> injections thru a form but this time in the url.  Just like sanitize a form
> before you save, is there anything you need to do to a variable from the
> url? That’s what im trying to ask.
>
> Do you just trust the the id passed will be good. I know check if id 123
> belongs to userbut I want to know can a user manually type something
> into the place of id that would be harful to the site?
>
>
>
>
>
>
>
> -Original Message-
> From: Jamie [mailto:jamie@gmail.com]
> Sent: December-11-10 4:16 PM
> To: CakePHP
> Subject: Re: Passing Variable to delete
>
> Cake's DB layer (i.e. DboSource and its children) sanitizes everything
> before passing it to your database.
>
> - Jamie
>
> On Dec 11, 6:29 am, "Dave Maharaj"  wrote:
> > When passing an id / slug  thru a url for delete is there any security
> > precautions to add?
>
> > Example
>
> > Function delete ($id) {
>
> > $this->Model->deleteAll(array(Model.id => $id, Model.owner =>
> > $this->Auth->user('id')));
>
> > }
>
> > So I pretty much always use deleteAll so its got multiple values of
> checking
> > rightful owner / permission to delete but I'm more curious about the
> passing
> > of the actual $id since anyone can pass anything they want as an $id if
> they
> > want to get smart and mess with your site. So what should you do? Any
> added
> > precautions? Sanitize:: the slug / id?
>
> > Thanks,
>
> > Dave
>
> Check out the new CakePHP Questions sitehttp://cakeqs.organd help others
> with their CakePHP related questions.
>
> 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 
> athttp://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: Passing Variable to delete

2010-12-11 Thread Ryan Schmidt
On Dec 11, 2010, at 21:12, Dave Maharaj wrote:

> I have been taking the $id /$slug / $whatever_anyone_wants_to_call_it at
> face value and doing
> 
> $data = $this->Model->some_function($id, $other, $var);
> 
> if(!data){
> 
> //see ya 
> 
> }
> 
> if($data){
> 
> //good stuff do what I need to do
> 
> }
> 
> But that's why I was wondering about simply taking whats given ($id) in the
> example and firing it off straight to the Model since the user could simply
> have changed it to anything. Sure it won't find anything but that's not the
> question im asking. Can it do anything is what I really want to know. I know
> very little about these security risks that's why im asking to see what the
> real deal is here.
> 
> Can $id (any variable passed from URL) be manipulated into something that
> would delete the db? Add a million empty records? Pretty much do anything
> other than what its intended for. Thats the million dollar question im
> trying to get. Not talking about changing $id value 5 to 6 or converting it
> into a slug.


Well, I like the code I just posted, since it certainly can do no harm to 
verify a parameter like an id is in the correct format, and it saves a hit to 
the database if it's not in the correct format, so that's certainly a good 
thing.

But to answer the question of whether there is any risk in passing arbitrary 
values to the database layer, I guess we have to dive into the code and find 
out.

I can't vouch for your "some_function" because I don't know what it does. The 
models cake baked for me loaded the data using the Model->read() method. 
Looking in cake/libs/model/model.php I see Model->read() just passes the id 
unchanged to the Model->find() method, in the conditions array. This in turn 
calls the data source's read() method. My data source is a MySQL database using 
the mysqli adapter, whose read() method seems to be the shared read() method in 
the cake/libs/model/datasources/dbo_source.php. There the code becomes too 
complicated for me to feel like analyzing any further, so I'll switch to 
testing.

I tried calling up the URL /images/edit/1'%20OR%201 on my app, disabling the 
aforementioned code I had in place so that this value gets passed directly to 
cake. In the SQL debug, I see proper escaping / quoting going on:

WHERE `Image`.`id` = '1\' OR 1'

So this seems fine to me; I don't see any SQL injection vulnerabilities here. 
Of course, if you're generating any SQL fragments that get inserted directly 
into the SQL statement, that might be a different matter. (Not sure, for 
example, what happens when you're trying to find() things with your own WHERE 
conditions.)



Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: Localize only some of a controller's pages

2010-12-11 Thread Ryan Schmidt

On Dec 11, 2010, at 21:24, Dave Maharaj wrote:

> You mean in the whatever_controller?
> 
> This?
> 
> function beforeFilter() {
>   //run parent first
>   parent::beforeFilter();
>   //run local to make specific change 
>   $this->layout('alternate_layout');
>   
> 
> }

Exactly. As I previously posted in this thread, I use a code block similar to 
that, not in a whatever_controller, but in app_controller.php (i.e. globally), 
to change $this->layout to 'admin' when on an admin page. I want to do similar 
global trickery with the name of the view, for localization purposes, but 
unlike the name of the layout, I cannot find any place in the object where the 
name of the view is available. Is it there somewhere and I've missed it?



Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: Localize only some of a controller's pages

2010-12-11 Thread Dave Maharaj
You mean in the whatever_controller?

This?

function beforeFilter() {
//run parent first
parent::beforeFilter();
//run local to make specific change 
$this->layout('alternate_layout');

  
}



-Original Message-
From: Ryan Schmidt [mailto:google-2...@ryandesign.com] 
Sent: December-11-10 11:08 PM
To: cake-php@googlegroups.com
Subject: Re: Localize only some of a controller's pages

On Dec 11, 2010, at 10:58, cricket wrote:
> You could extend the test to check which page is being requested. Or,
> whether $this->params['admin'] is set, etc.

Yes but I wouldn't like to have to put all sorts of page-specific logic
into the global beforeFilter. Just as I can access and change the layout
from within the beforeFilter, I would have expected to be able to access and
change the view from within the beforeFilter. Does anybody have a suggestion
how I can do that?


Check out the new CakePHP Questions site http://cakeqs.org and help others
with their CakePHP related questions.

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

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: Passing Variable to delete

2010-12-11 Thread Dave Maharaj
Thanks for the links.

Im am glad someone finally understood the question.

I have been taking the $id /$slug / $whatever_anyone_wants_to_call_it at
face value and doing

$data = $this->Model->some_function($id, $other, $var);

if(!data){

//see ya 

}

if($data){

//good stuff do what I need to do

}

But that's why I was wondering about simply taking whats given ($id) in the
example and firing it off straight to the Model since the user could simply
have changed it to anything. Sure it won't find anything but that's not the
question im asking. Can it do anything is what I really want to know. I know
very little about these security risks that's why im asking to see what the
real deal is here.

Can $id (any variable passed from URL) be manipulated into something that
would delete the db? Add a million empty records? Pretty much do anything
other than what its intended for. Thats the million dollar question im
trying to get. Not talking about changing $id value 5 to 6 or converting it
into a slug.

Thanks,

Dave 

-Original Message-
From: Ryan Schmidt [mailto:google-2...@ryandesign.com] 
Sent: December-11-10 11:21 PM
To: cake-php@googlegroups.com
Subject: Re: Passing Variable to delete


On Dec 11, 2010, at 08:29, Dave Maharaj wrote:

> When passing an id / slug  thru a url for delete is there any security
precautions to add?
>  
> Example
>  
> Function delete ($id) {
>  
> $this->Model->deleteAll(array(Model.id => $id, Model.owner =>
$this->Auth->user('id')));
>  
> }
>  
> So I pretty much always use deleteAll so its got multiple values of
checking rightful owner / permission to delete but I'm more curious about
the passing of the actual $id since anyone can pass anything they want as an
$id if they want to get smart and mess with your site. So what should you
do? Any added precautions? Sanitize:: the slug / id?

Being new to CakePHP, I've wondered this too. Since CakePHP is a 5-year-old
well-regarded PHP framework I would hope that all SQL injection issues are
long taken care of, but I haven't tested it myself yet.


I was concerned, for example, by this post, which seems to suggest SQL
injection vulnerabilities do exist in CakePHP:

http://groups.google.com/group/cake-php/browse_thread/thread/cdeb26085c38a8a
6?hl=en

Then again, he didn't post the code of his CakePHP project so I don't know
what's triggering it.


There were several problems I had with the files baked by "cake bake". One
of those is that 404 errors are not handled: you can request the page of a
nonexistent id, and it'll happily display it, when it should throw a 404 not
found error. This has been remarked here before:

http://www.dereuromark.de/2010/06/22/cake-bake-custom-templates/

I also didn't like how it took anything passed in the URL, be it a valid id
or not, to the database. So I changed my controllers (and will change my
bake templates, I suppose) so that these issues are taken care of. The
beginning of my view, edit and delete methods now looks something like this:


$data = ctype_digit($id) ? $this->MyModel->read(null, $id) : null;
if (empty($data)) {
$this->cakeError('error404');
}


This ensures that the passed-in $id is at least formatted as an id (composed
entirely of the digits 0-9) before being passed to the database. This should
avoid unnecessary hits to the database when $id can't possibly be a valid
id, and would avoid any SQL injection possibilities for this case.



Check out the new CakePHP Questions site http://cakeqs.org and help others
with their CakePHP related questions.

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

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: Passing Variable to delete

2010-12-11 Thread Ryan Schmidt

On Dec 11, 2010, at 08:29, Dave Maharaj wrote:

> When passing an id / slug  thru a url for delete is there any security 
> precautions to add?
>  
> Example
>  
> Function delete ($id) {
>  
> $this->Model->deleteAll(array(Model.id => $id, Model.owner => 
> $this->Auth->user(‘id’)));
>  
> }
>  
> So I pretty much always use deleteAll so its got multiple values of checking 
> rightful owner / permission to delete but I’m more curious about the passing 
> of the actual $id since anyone can pass anything they want as an $id if they 
> want to get smart and mess with your site. So what should you do? Any added 
> precautions? Sanitize:: the slug / id?

Being new to CakePHP, I've wondered this too. Since CakePHP is a 5-year-old 
well-regarded PHP framework I would hope that all SQL injection issues are long 
taken care of, but I haven't tested it myself yet.


I was concerned, for example, by this post, which seems to suggest SQL 
injection vulnerabilities do exist in CakePHP:

http://groups.google.com/group/cake-php/browse_thread/thread/cdeb26085c38a8a6?hl=en

Then again, he didn't post the code of his CakePHP project so I don't know 
what's triggering it.


There were several problems I had with the files baked by "cake bake". One of 
those is that 404 errors are not handled: you can request the page of a 
nonexistent id, and it'll happily display it, when it should throw a 404 not 
found error. This has been remarked here before:

http://www.dereuromark.de/2010/06/22/cake-bake-custom-templates/

I also didn't like how it took anything passed in the URL, be it a valid id or 
not, to the database. So I changed my controllers (and will change my bake 
templates, I suppose) so that these issues are taken care of. The beginning of 
my view, edit and delete methods now looks something like this:


$data = ctype_digit($id) ? $this->MyModel->read(null, $id) : null;
if (empty($data)) {
$this->cakeError('error404');
}


This ensures that the passed-in $id is at least formatted as an id (composed 
entirely of the digits 0-9) before being passed to the database. This should 
avoid unnecessary hits to the database when $id can't possibly be a valid id, 
and would avoid any SQL injection possibilities for this case.



Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: Localize only some of a controller's pages

2010-12-11 Thread Ryan Schmidt
On Dec 11, 2010, at 10:58, cricket wrote:
> You could extend the test to check which page is being requested. Or,
> whether $this->params['admin'] is set, etc.

Yes but I wouldn't like to have to put all sorts of page-specific logic 
into the global beforeFilter. Just as I can access and change the layout from 
within the beforeFilter, I would have expected to be able to access and change 
the view from within the beforeFilter. Does anybody have a suggestion how I can 
do that?


Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Internationalization in Cake - not works for me

2010-12-11 Thread Andrew Hodirevski
What am I doing wrong?
I've got the next part of View:

__('Ваш логин', true),

After that I've generated using cake 'cake i18n extract' neccessary
path and default.pot, which I copied to app/locale/eng/LC_MESSAGES/
default.po and edited with PoEdit.

The part of default.po for the previous string is:
msgid "Ваш логин"
msgstr "Your login"

And:
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

The Debug level is 2, so I have no caching.

So, what the problem is?

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: Simple "join => array('Post')" creates invalid SQL command! --psybear

2010-12-11 Thread Joshua Muheim
Thanks, but while hoping that DRY and convention over configuration
would apply here too, adding these informations still results in an
invalid SQL statement:

SELECT COUNT(*) AS `count` FROM `meta_tags` AS `MetaTag` Post posts
left LEFT JOIN `posts` AS `Post` ON (`MetaTag`.`post_id` =
`Post`.`id`)  WHERE `MetaTag`.`id` = 1601 AND `Post`.`user_id` = 1103

On Sun, Dec 12, 2010 at 12:34 AM, cricket  wrote:
> On Sat, Dec 11, 2010 at 2:27 PM, psybear83  wrote:
>> Hey everybody
>>
>> class MetaTag extends AppModel {
>>        var $name = 'MetaTag';
>>        var $displayField = 'name';
>>
>>        function allowsAdd(&$user, $options) {
>>                $this->find('count', array('joins' => array('Post'),
>> 'conditions' => array('MetaTag.id' => $this->id(;
>>        }
>> }
>>
>> This simple JOIN gives me a wrong SQL command:
>>
>> SELECT COUNT(*) AS `count` FROM `meta_tags` AS `MetaTag` Post LEFT
>> JOIN `posts` AS `Post` ON (`MetaTag`.`post_id` = `Post`.`id`)  WHERE
>> `MetaTag`.`id` = 1601
>>
>> ...while the correct one would look like this:
>>
>> SELECT COUNT(*) AS `count` FROM `meta_tags` AS `MetaTag` LEFT JOIN
>> `posts` AS `Post` ON (`MetaTag`.`post_id` = `Post`.`id`)  WHERE
>> `MetaTag`.`id` = 1601
>>
>> Where does this "Post" word come from?? Do I do anything wrong?
>
> There are no keys to the joins array. It should be an array of arrays.
>
> $this->find(
>        'count',
>        array(
>                'joins' => array(
>                        array(
>                                'alias' => 'Post',
>                                'table' => 'posts',
>                                'type' => 'left'
>                        )
>                ),
>                'conditions' => array(
>                        'MetaTag.id' => $this->id()
>                )
>        )
> );
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
>
> 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
>

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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 $this->values

2010-12-11 Thread Dave Maharaj
I saw something in an earlier post and did not want to hi-jack the thread
so.

 

Cricket posted a snip:

 

$this->find(

  'count',

  array(

'joins' => array(

  array(

'alias' => 'Post',

'table' => 'posts',

'type' => 'left'

  )

),

'conditions' => array(

  'MetaTag.id' => $this->id()

)

  )

);

 

 

I am wondering about 'MetaTag.id' => $this->id() $this->id

Will get be the id get the current record id But what if you were using
another field as identifier?.

 

Can you use $this->any_field from the table? If field was current_day could
you use $this->currentDay or is it $this->current_day?

 

Just curious.

 

Thanks

 

Dave

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: Form is not defined

2010-12-11 Thread cricket
On Sat, Dec 11, 2010 at 6:29 PM, Rishi  wrote:
> Hi
>
> I am trying to send a ajax call to an action when ever there is a
> change in selection.
>
> create(''); ?>
>
>                input('selected',array('label'=>'Select
> Category','id'=>'selected','type'=>'select','options'=>$select));?>
>
>                observeField('selected',
>                                
> array('with'=>'Form.Element.serialize(\'selected\')','url' =>
> 'display','update'=>'codes',
>                                
> 'complete'=>"Effect.Appear('selected');",'onChange'=>true));?>
>
>                end(); ?>
>
> When I check the consle.
>
> Form is not defined
> http://localhost/index.php/codes/code
> Line 46

You need to have 'Form' in your $helpers array for this controller (or
AppController).

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: Tmp is not writable

2010-12-11 Thread cricket
On Sat, Dec 11, 2010 at 11:51 AM, lucaswxp  wrote:
> Hello guys.
> Yesterday I have installed my first linux, and today I'm tryind to get
> cakephp to work... But I get the error:
>
> tmp/cache/ is not writable [CORE/cake/libs/cache/file.php, line 267]
> app/tmp/cache/persistent/ is not writable [CORE/cake/libs/cache/
> file.php, line 267]
> app/tmp/cache/models/ is not writable [CORE/cake/libs/cache/file.php,
> line 267]
>
> And I already have do:
> chmod -R 777 app/tmp and
> chown apache:apache app/tmp
>
> But the errors continue...
> Anyone knows what it can be?

As Jeremy said, make sure the other directories are writable. You
didn't chown recursive:

chown -R apache:apache app/tmp

And you should probably do:

chmod -R 0775 app/tmp


> PS: sorry for the bad english

Looks ok to me!

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: Simple "join => array('Post')" creates invalid SQL command! --psybear

2010-12-11 Thread cricket
On Sat, Dec 11, 2010 at 2:27 PM, psybear83  wrote:
> Hey everybody
>
> class MetaTag extends AppModel {
>        var $name = 'MetaTag';
>        var $displayField = 'name';
>
>        function allowsAdd(&$user, $options) {
>                $this->find('count', array('joins' => array('Post'),
> 'conditions' => array('MetaTag.id' => $this->id(;
>        }
> }
>
> This simple JOIN gives me a wrong SQL command:
>
> SELECT COUNT(*) AS `count` FROM `meta_tags` AS `MetaTag` Post LEFT
> JOIN `posts` AS `Post` ON (`MetaTag`.`post_id` = `Post`.`id`)  WHERE
> `MetaTag`.`id` = 1601
>
> ...while the correct one would look like this:
>
> SELECT COUNT(*) AS `count` FROM `meta_tags` AS `MetaTag` LEFT JOIN
> `posts` AS `Post` ON (`MetaTag`.`post_id` = `Post`.`id`)  WHERE
> `MetaTag`.`id` = 1601
>
> Where does this "Post" word come from?? Do I do anything wrong?

There are no keys to the joins array. It should be an array of arrays.

$this->find(
'count',
array(
'joins' => array(
array(
'alias' => 'Post',
'table' => 'posts',
'type' => 'left'
)
),
'conditions' => array(
'MetaTag.id' => $this->id()
)
)
);

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Form is not defined

2010-12-11 Thread Rishi
Hi

I am trying to send a ajax call to an action when ever there is a
change in selection.

create(''); ?>

input('selected',array('label'=>'Select
Category','id'=>'selected','type'=>'select','options'=>$select));?>

observeField('selected',

array('with'=>'Form.Element.serialize(\'selected\')','url' =>
'display','update'=>'codes',

'complete'=>"Effect.Appear('selected');",'onChange'=>true));?>

end(); ?>

When I check the consle.

Form is not defined
http://localhost/index.php/codes/code
Line 46

new Form.Element.EventObserver('selected', function(element, value)
{new Ajax.Updater('codes','/index.php/codes/display',
{asynchronous:true, evalScripts:true, onComplete:function(request,
json) {Effect.Appear('selected');},
parameters:Form.Element.serialize('selected'), requestHeaders:['X-
Update', 'codes']})})


Any help !!!



Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: $primaryKey not working

2010-12-11 Thread Tilen Majerle
yes, it does, but magic methods findByFieldName is that the method search
exacly for 'Fieldname' so in this case 'Id' is not recognized, that this is
not primary key, it will work (it should) is u do this is in model

$this->Model->id = 'valuefromyourprimarykey'; //even if ur primary_key is
not id and u r working with this record from db...i hope u understand

--
Tilen Majerle
http://majerle.eu



2010/12/11 Rishi 

> Thanks. I am new, so I have look what exactly "conditions" do.
>
> But, according to documentation, declaring $primaryKey must override
> the 'id' field. Please correct me if I am wrong.
>
> On Dec 11, 4:26 pm, Jeremy Burns | Class Outfit
>  wrote:
> > Rather than do findById try find (...'conditions' =>
> array('CodeCategory.CodeCatId' => $id)...
> >
> > You might need t experiment with different iterations of the field name
> but I think that's what you need to do. findById will look for a field
> called id, just as findByTractor will search for a field called tractor.
> >
> > Jeremy Burns
> > Class Outfit
> >
> > jeremybu...@classoutfit.comhttp://www.classoutfit.com
> >
> > On 11 Dec 2010, at 20:56, Rishi wrote:
> >
> >
> >
> >
> >
> >
> >
> > > No I dont have a ''ID ' in the database. This is the strcture of my
> > > table
> >
> > > CREATE TABLE  `cvmdl`.`code_categories` (
> > >  `CODE_CAT_ID` int(10) unsigned NOT NULL AUTO_INCREMENT,
> > >  `CODE_CAT` varchar(45) NOT NULL,
> > >  `CODE_DESC` varchar(225) DEFAULT NULL,
> > >  PRIMARY KEY (`CODE_CAT_ID`) USING BTREE
> > > ) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=latin1;
> >
> > > On Dec 11, 3:52 pm, Tilen Majerle  wrote:
> > >> ofc...have u 'id' field in table in database?...if no, this is problem
> :D
> > >> --
> > >> Tilen Majerlehttp://majerle.eu
> >
> > >> 2010/12/11 Rishi 
> >
> > >>> hi group,
> >
> > >>> I have the following model
> >
> > >>> //file model name: code_category.php
> > >>>  >
> > >>> class CodeCategory extends AppModel {
> >
> > >>>var $name = 'CodeCategory';
> > >>>var $primaryKey = 'CODE_CAT_ID'; // exactly same in db
> > >>> }
> > >>> ?>
> >
> > >>> when I try to find a row using $this->CodeCategory->findById($id);
> >
> > >>> I have the following error .
> >
> > >>> SQL Error: 1054: Unknown column 'CodeCategory.id' in 'where clause'
> >
> > >>> Can someone please help me.
> >
> > >>> Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp
> others
> > >>> with their CakePHP related questions.
> >
> > >>> 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
> >
> > > Check out the new CakePHP Questions sitehttp://cakeqs.organd help
> others with their CakePHP related questions.
> >
> > > 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.comFor
> > >  more options, visit this group athttp://
> groups.google.com/group/cake-php?hl=en
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others
> with their CakePHP related questions.
>
> 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.comFor
>  more options, visit this group at
> http://groups.google.com/group/cake-php?hl=en
>

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: $primaryKey not working

2010-12-11 Thread Rishi
Thanks. I am new, so I have look what exactly "conditions" do.

But, according to documentation, declaring $primaryKey must override
the 'id' field. Please correct me if I am wrong.

On Dec 11, 4:26 pm, Jeremy Burns | Class Outfit
 wrote:
> Rather than do findById try find (...'conditions' => 
> array('CodeCategory.CodeCatId' => $id)...
>
> You might need t experiment with different iterations of the field name but I 
> think that's what you need to do. findById will look for a field called id, 
> just as findByTractor will search for a field called tractor.
>
> Jeremy Burns
> Class Outfit
>
> jeremybu...@classoutfit.comhttp://www.classoutfit.com
>
> On 11 Dec 2010, at 20:56, Rishi wrote:
>
>
>
>
>
>
>
> > No I dont have a ''ID ' in the database. This is the strcture of my
> > table
>
> > CREATE TABLE  `cvmdl`.`code_categories` (
> >  `CODE_CAT_ID` int(10) unsigned NOT NULL AUTO_INCREMENT,
> >  `CODE_CAT` varchar(45) NOT NULL,
> >  `CODE_DESC` varchar(225) DEFAULT NULL,
> >  PRIMARY KEY (`CODE_CAT_ID`) USING BTREE
> > ) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=latin1;
>
> > On Dec 11, 3:52 pm, Tilen Majerle  wrote:
> >> ofc...have u 'id' field in table in database?...if no, this is problem :D
> >> --
> >> Tilen Majerlehttp://majerle.eu
>
> >> 2010/12/11 Rishi 
>
> >>> hi group,
>
> >>> I have the following model
>
> >>> //file model name: code_category.php
> >>> 
> >>> class CodeCategory extends AppModel {
>
> >>>        var $name = 'CodeCategory';
> >>>        var $primaryKey = 'CODE_CAT_ID'; // exactly same in db
> >>> }
> >>> ?>
>
> >>> when I try to find a row using $this->CodeCategory->findById($id);
>
> >>> I have the following error .
>
> >>> SQL Error: 1054: Unknown column 'CodeCategory.id' in 'where clause'
>
> >>> Can someone please help me.
>
> >>> Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp others
> >>> with their CakePHP related questions.
>
> >>> 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 >>>  om>For more options, visit this group at
> >>>http://groups.google.com/group/cake-php?hl=en
>
> > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others 
> > with their CakePHP related questions.
>
> > 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 
> > athttp://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: Tmp is not writable

2010-12-11 Thread Jeremy Burns | Class Outfit
Make sure all the folders within tmp are writable too.

Jeremy Burns
Class Outfit

jeremybu...@classoutfit.com
http://www.classoutfit.com

On 11 Dec 2010, at 16:51, lucaswxp wrote:

> Hello guys.
> Yesterday I have installed my first linux, and today I'm tryind to get
> cakephp to work... But I get the error:
> 
> tmp/cache/ is not writable [CORE/cake/libs/cache/file.php, line 267]
> app/tmp/cache/persistent/ is not writable [CORE/cake/libs/cache/
> file.php, line 267]
> app/tmp/cache/models/ is not writable [CORE/cake/libs/cache/file.php,
> line 267]
> 
> And I already have do:
> chmod -R 777 app/tmp and
> chown apache:apache app/tmp
> 
> But the errors continue...
> Anyone knows what it can be?
> 
> PS: sorry for the bad english
> 
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
> 
> 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

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: $primaryKey not working

2010-12-11 Thread Jeremy Burns | Class Outfit
Rather than do findById try find (...'conditions' => 
array('CodeCategory.CodeCatId' => $id)...

You might need t experiment with different iterations of the field name but I 
think that's what you need to do. findById will look for a field called id, 
just as findByTractor will search for a field called tractor.

Jeremy Burns
Class Outfit

jeremybu...@classoutfit.com
http://www.classoutfit.com

On 11 Dec 2010, at 20:56, Rishi wrote:

> No I dont have a ''ID ' in the database. This is the strcture of my
> table
> 
> CREATE TABLE  `cvmdl`.`code_categories` (
>  `CODE_CAT_ID` int(10) unsigned NOT NULL AUTO_INCREMENT,
>  `CODE_CAT` varchar(45) NOT NULL,
>  `CODE_DESC` varchar(225) DEFAULT NULL,
>  PRIMARY KEY (`CODE_CAT_ID`) USING BTREE
> ) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=latin1;
> 
> 
> 
> On Dec 11, 3:52 pm, Tilen Majerle  wrote:
>> ofc...have u 'id' field in table in database?...if no, this is problem :D
>> --
>> Tilen Majerlehttp://majerle.eu
>> 
>> 2010/12/11 Rishi 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>>> hi group,
>> 
>>> I have the following model
>> 
>>> //file model name: code_category.php
>>> > 
>>> class CodeCategory extends AppModel {
>> 
>>>var $name = 'CodeCategory';
>>>var $primaryKey = 'CODE_CAT_ID'; // exactly same in db
>>> }
>>> ?>
>> 
>>> when I try to find a row using $this->CodeCategory->findById($id);
>> 
>>> I have the following error .
>> 
>>> SQL Error: 1054: Unknown column 'CodeCategory.id' in 'where clause'
>> 
>>> Can someone please help me.
>> 
>>> Check out the new CakePHP Questions sitehttp://cakeqs.organd help others
>>> with their CakePHP related questions.
>> 
>>> 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>> om>For more options, visit this group at
>>> http://groups.google.com/group/cake-php?hl=en
> 
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
> 
> 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

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: Passing Variable to delete

2010-12-11 Thread Dave Maharaj
Ok from the beginning time to rephrase:

Forget delete.

Site/page/id

Id gets passed to some_controller

function some_function($id) {

$this->set(pageContent, $this->Page->getContent($id));


}

Some_model

Function getContent($id) {

$params = array(



Some.id' => $id);

Return $this->find('first', $params);
}

See how $id gets takes straight from the url and filters straight into the
model find.

I know if no $id is found then nothing returned, that not the point...
whatever $id is gets put right into the model for the query. So do you need
to do anything prior to this? That’s the question or does cake take care of
this so no matter what is $id is its going to be safe.

Thanks for the patience.

Dave

-Original Message-
From: Jamie [mailto:jamie@gmail.com] 
Sent: December-11-10 4:16 PM
To: CakePHP
Subject: Re: Passing Variable to delete

Cake's DB layer (i.e. DboSource and its children) sanitizes everything
before passing it to your database.

- Jamie

On Dec 11, 6:29 am, "Dave Maharaj"  wrote:
> When passing an id / slug  thru a url for delete is there any security
> precautions to add?
>
> Example
>
> Function delete ($id) {
>
> $this->Model->deleteAll(array(Model.id => $id, Model.owner =>
> $this->Auth->user('id')));
>
> }
>
> So I pretty much always use deleteAll so its got multiple values of
checking
> rightful owner / permission to delete but I'm more curious about the
passing
> of the actual $id since anyone can pass anything they want as an $id if
they
> want to get smart and mess with your site. So what should you do? Any
added
> precautions? Sanitize:: the slug / id?
>
> Thanks,
>
> Dave

Check out the new CakePHP Questions site http://cakeqs.org and help others
with their CakePHP related questions.

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

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Tmp is not writable

2010-12-11 Thread lucaswxp
Hello guys.
Yesterday I have installed my first linux, and today I'm tryind to get
cakephp to work... But I get the error:

tmp/cache/ is not writable [CORE/cake/libs/cache/file.php, line 267]
app/tmp/cache/persistent/ is not writable [CORE/cake/libs/cache/
file.php, line 267]
app/tmp/cache/models/ is not writable [CORE/cake/libs/cache/file.php,
line 267]

And I already have do:
chmod -R 777 app/tmp and
chown apache:apache app/tmp

But the errors continue...
Anyone knows what it can be?

PS: sorry for the bad english

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: friends please help

2010-12-11 Thread Alok Mishra
Rewrite htaccess file url

On Sat, Dec 11, 2010 at 4:51 PM, Miqdad Ali  wrote:

> tanx 4 ur reply
>
> i corrected that problem by editing .htaccess file
>
>
> 
> Miqdad Ali
> http://www.miqdadali.co.cc
>
>
>
>
> On Fri, Dec 10, 2010 at 12:10 AM, cricket  wrote:
>
>> On Thu, Dec 9, 2010 at 1:49 AM, Miqdad Ali wrote:
>>
>>> friends please help
>>>
>>> i have a form in ctp and when i hit the save button it shown
>>>
>>>
>>>
>>> You don't have permission to access /uscb/pers/save_data on this server.
>>>
>>> --
>>> Apache/1.3.41 Server at www.www.imeseat.com Port 80
>>>
>>>
>>>
>>> but it's working fine in localhos
>>>
>>>
>> Looks like an Apache issue. Are you sure the path is correct?
>>
>> And why does the URL have 'www' twice?
>>
>> Check out the new CakePHP Questions site http://cakeqs.org and help
>> others with their CakePHP related questions.
>>
>> 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.comFor
>>  more options, visit this group at
>> http://groups.google.com/group/cake-php?hl=en
>>
>
>  Check out the new CakePHP Questions site http://cakeqs.org and help
> others with their CakePHP related questions.
>
> 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.comFor
>  more options, visit this group at
> http://groups.google.com/group/cake-php?hl=en
>



-- 
Alok Mishra
Software Engg.
A1 Technology Inc Chandigarh Mohali.
mob...@9569881400
aloksoft2...@gmail.xom

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: Passing Variable to delete

2010-12-11 Thread Dave Maharaj
What im trying to say is take site/some/action/id for example

Nothing to do with checking if it’s a valid id nothing to do with saving.

Can a user add anything into the url to act as an attempt to reek havoc. Say
the id is as an example 123 and someone types in select* from I don’t know
anything malicious so that just what I am trying to say. Similar to
injections thru a form but this time in the url.  Just like sanitize a form
before you save, is there anything you need to do to a variable from the
url? That’s what im trying to ask.

Do you just trust the the id passed will be good. I know check if id 123
belongs to userbut I want to know can a user manually type something
into the place of id that would be harful to the site?

-Original Message-
From: Jamie [mailto:jamie@gmail.com] 
Sent: December-11-10 4:16 PM
To: CakePHP
Subject: Re: Passing Variable to delete

Cake's DB layer (i.e. DboSource and its children) sanitizes everything
before passing it to your database.

- Jamie

On Dec 11, 6:29 am, "Dave Maharaj"  wrote:
> When passing an id / slug  thru a url for delete is there any security
> precautions to add?
>
> Example
>
> Function delete ($id) {
>
> $this->Model->deleteAll(array(Model.id => $id, Model.owner =>
> $this->Auth->user('id')));
>
> }
>
> So I pretty much always use deleteAll so its got multiple values of
checking
> rightful owner / permission to delete but I'm more curious about the
passing
> of the actual $id since anyone can pass anything they want as an $id if
they
> want to get smart and mess with your site. So what should you do? Any
added
> precautions? Sanitize:: the slug / id?
>
> Thanks,
>
> Dave

Check out the new CakePHP Questions site http://cakeqs.org and help others
with their CakePHP related questions.

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

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: $primaryKey not working

2010-12-11 Thread Rishi
No I dont have a ''ID ' in the database. This is the strcture of my
table

CREATE TABLE  `cvmdl`.`code_categories` (
  `CODE_CAT_ID` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `CODE_CAT` varchar(45) NOT NULL,
  `CODE_DESC` varchar(225) DEFAULT NULL,
  PRIMARY KEY (`CODE_CAT_ID`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=latin1;



On Dec 11, 3:52 pm, Tilen Majerle  wrote:
> ofc...have u 'id' field in table in database?...if no, this is problem :D
> --
> Tilen Majerlehttp://majerle.eu
>
> 2010/12/11 Rishi 
>
>
>
>
>
>
>
> > hi group,
>
> > I have the following model
>
> > //file model name: code_category.php
> > 
> > class CodeCategory extends AppModel {
>
> >        var $name = 'CodeCategory';
> >        var $primaryKey = 'CODE_CAT_ID'; // exactly same in db
> > }
> > ?>
>
> > when I try to find a row using $this->CodeCategory->findById($id);
>
> > I have the following error .
>
> > SQL Error: 1054: Unknown column 'CodeCategory.id' in 'where clause'
>
> > Can someone please help me.
>
> > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others
> > with their CakePHP related questions.
>
> > 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 > om>For more options, visit this group at
> >http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: $primaryKey not working

2010-12-11 Thread Tilen Majerle
ofc...have u 'id' field in table in database?...if no, this is problem :D
--
Tilen Majerle
http://majerle.eu



2010/12/11 Rishi 

> hi group,
>
> I have the following model
>
> //file model name: code_category.php
> 
> class CodeCategory extends AppModel {
>
>var $name = 'CodeCategory';
>var $primaryKey = 'CODE_CAT_ID'; // exactly same in db
> }
> ?>
>
> when I try to find a row using $this->CodeCategory->findById($id);
>
> I have the following error .
>
> SQL Error: 1054: Unknown column 'CodeCategory.id' in 'where clause'
>
>
> Can someone please help me.
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others
> with their CakePHP related questions.
>
> 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.comFor
>  more options, visit this group at
> http://groups.google.com/group/cake-php?hl=en
>

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


$primaryKey not working

2010-12-11 Thread Rishi
hi group,

I have the following model

//file model name: code_category.php


when I try to find a row using $this->CodeCategory->findById($id);

I have the following error .

SQL Error: 1054: Unknown column 'CodeCategory.id' in 'where clause'


Can someone please help me.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: Media Plugin - How to set different instructions for differents kinds of images?

2010-12-11 Thread huoxito
this is the error i keep getting ...

Warning (512): GeneratorBehavior::make - Failed to make version `s` of
file `/var/www/optogrupo/app/webroot/media/transfer/img/
dsc02738_13.jpg`.  [APP/plugins/media/models/behaviors/generator.php,
line 167]

... when I try to set up Media filter instructions inside a model on a
beforeValdate method:

$l = array('convert' => 'image/jpeg', 'fit' => array(600,
450));
$m = array('convert' => 'image/jpeg', 'fitCrop' => array(318,
160));
$s = array('convert' => 'image/jpeg', 'fit' => array(200,
125));
Configure::write('Media.filter', array('image' =>
compact('m','l','s')));
return true;

On 11 dez, 16:38, huoxito  wrote:
> Could anybody post any examples on how I could have Media.filter
> instructions on the same upload?
>
> I want to upload two kind of images on the same form, For one of them
> I need only two copies, versions. And for the other one I need three
> copies I tried to do it on a beforeFilter but I was still getting some
> errors saying that the generator behavior couldn't created some
> versions. Now itm trying this code but I still don't feel that I got
> the plugin working idea right so far:
>
>     function beforeValidate(){
>
>         if(isset($this->data['AttachmentNoticias']['group'])){
>
>             if($this->data['AttachmentNoticias']['group'] ===
> 'imgFront'){
>                 $l = array('convert' => 'image/jpeg', 'fit' =>
> array(600, 450));
>                 $m = array('convert' => 'image/jpeg', 'fitCrop' =>
> array(318, 160));
>                 $s = array('convert' => 'image/jpeg', 'fit' =>
> array(200, 125));
>             }
>
>             if($this->data['AttachmentNoticias']['group'] ===
> 'imgText'){
>                 $l = array('convert' => 'image/jpeg', 'fit' =>
> array(600, 450));
>                 $m = array('convert' => 'image/jpeg', 'fitCrop' =>
> array(318, 160));
>                 $s = array('convert' => 'image/jpeg', 'fit' =>
> array(200, 125));
>             }
>
>             Configure::write('Media.filter', array('image' =>
> compact('m','l','s')));
>         }
>
>         return true;
>     }

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: Passing Variable to delete

2010-12-11 Thread Jamie
Cake's DB layer (i.e. DboSource and its children) sanitizes everything
before passing it to your database.

- Jamie

On Dec 11, 6:29 am, "Dave Maharaj"  wrote:
> When passing an id / slug  thru a url for delete is there any security
> precautions to add?
>
> Example
>
> Function delete ($id) {
>
> $this->Model->deleteAll(array(Model.id => $id, Model.owner =>
> $this->Auth->user('id')));
>
> }
>
> So I pretty much always use deleteAll so its got multiple values of checking
> rightful owner / permission to delete but I'm more curious about the passing
> of the actual $id since anyone can pass anything they want as an $id if they
> want to get smart and mess with your site. So what should you do? Any added
> precautions? Sanitize:: the slug / id?
>
> Thanks,
>
> Dave

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: Passing Variable to delete

2010-12-11 Thread Dave Maharaj
It's ok nevermind. You do not understand what I am asking.

 

Dave

 

From: Tilen Majerle [mailto:tilen.maje...@gmail.com] 
Sent: December-11-10 3:53 PM
To: cake-php@googlegroups.com
Subject: Re: Passing Variable to delete

 

if u sanitize string it's the same shit as if u slug it...so u in link pass
just id (slug) and if slug exists in database, then ok, if not, then won't
be deleted...

nothing can be error
--
Tilen Majerle

http://majerle.eu





2010/12/11 Dave Maharaj 

No no you do not understand what I am asking.

 

Site/page/$foo

 

$foo can be 1 hundred million things 1 being something correct everything
else is wrong so a user can put in &something=this&that=somethingelse. I am
asking because that get pumped right into cake is there anything you should
do in general (not inflector::slug) to make sure its safe to use since you
cant trust everything coming in. Sure 99% of users will not mess with URLs
but that 1 % who decides to change and mess with things.

 

Should you sanitize $foo so its only [az-09-] do you need to? And no not
because its a slug  but because its safer if you took the & = out of all the
url if you know it should not be there. I am asking in general not in a case
specifi if it's a slug if not forget I even used that word. Think of any url
on your site and think of a evil user typing in something they should not.
Now what would you do to protect the site from what they wrote. That's what
I am asking. Do you need to check the data in the url (and I do not mean
check if it the owner) before you send it to delete / save/ update/ redirect
anything. 

 

Having the site do something or attempt to do something by messing with the
url.

 

Does that make sense or am I just not clear?

 

 

 

From: Tilen Majerle [mailto:tilen.maje...@gmail.com] 
Sent: December-11-10 2:55 PM


To: cake-php@googlegroups.com
Subject: Re: Passing Variable to delete

 

with Inflector::slug($id) i think that will be ok
--
Tilen Majerle

http://majerle.eu

 

2010/12/11 Dave Maharaj 

Sorry..

 

Not what I was trying to ask. 

Not the if owner delete part of the action.just the passing of variables
thru url.the actual variable. Cake spits out code link/delete/this_slug what
could a user change the "this_slug" variable too that could be harful. What
should you check /clean / for the variable its self. I only used the delete
as a general example so in any case anytime a variable is passed directly to
the controller what should you do if anything to make sure its no code
capable of damage / injection / disruption  

 

Dave

 

From: Tilen Majerle [mailto:tilen.maje...@gmail.com] 
Sent: December-11-10 12:08 PM
To: cake-php@googlegroups.com
Subject: Re: Passing Variable to delete

 

in ur case, i will first check, if given id is id for record from some user,
and if is, then delete it, otherwise don't delete it...
--
Tilen Majerle

http://majerle.eu

 

2010/12/11 Dave Maharaj 

When passing an id / slug  thru a url for delete is there any security
precautions to add?

 

Example 

 

Function delete ($id) {

 

$this->Model->deleteAll(array(Model.id => $id, Model.owner =>
$this->Auth->user('id')));

 

}

 

So I pretty much always use deleteAll so its got multiple values of checking
rightful owner / permission to delete but I'm more curious about the passing
of the actual $id since anyone can pass anything they want as an $id if they
want to get smart and mess with your site. So what should you do? Any added
precautions? Sanitize:: the slug / id?

 

Thanks,

Dave

 

 

Check out the new CakePHP Questions site http://cakeqs.org and help others
with their CakePHP related questions.
 
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

 

Check out the new CakePHP Questions site http://cakeqs.org and help others
with their CakePHP related questions.
 
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

Check out the new CakePHP Questions site http://cakeqs.org and help others
with their CakePHP related questions.
 
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-

Simple "join => array('Post')" creates invalid SQL command! --psybear

2010-12-11 Thread psybear83
Hey everybody

class MetaTag extends AppModel {
var $name = 'MetaTag';
var $displayField = 'name';

function allowsAdd(&$user, $options) {
$this->find('count', array('joins' => array('Post'),
'conditions' => array('MetaTag.id' => $this->id(;
}
}

This simple JOIN gives me a wrong SQL command:

SELECT COUNT(*) AS `count` FROM `meta_tags` AS `MetaTag` Post LEFT
JOIN `posts` AS `Post` ON (`MetaTag`.`post_id` = `Post`.`id`)  WHERE
`MetaTag`.`id` = 1601

...while the correct one would look like this:

SELECT COUNT(*) AS `count` FROM `meta_tags` AS `MetaTag` LEFT JOIN
`posts` AS `Post` ON (`MetaTag`.`post_id` = `Post`.`id`)  WHERE
`MetaTag`.`id` = 1601

Where does this "Post" word come from?? Do I do anything wrong?

Thanks for help,
Josh

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: Passing Variable to delete

2010-12-11 Thread Tilen Majerle
if u sanitize string it's the same shit as if u slug it...so u in link pass
just id (slug) and if slug exists in database, then ok, if not, then won't
be deleted...
nothing can be error
--
Tilen Majerle
http://majerle.eu



2010/12/11 Dave Maharaj 

>  No no you do not understand what I am asking.
>
>
>
> Site/page/$foo
>
>
>
> $foo can be 1 hundred million things 1 being something correct everything
> else is wrong so a user can put in &something=this&that=somethingelse. I am
> asking because that get pumped right into cake is there anything you should
> do in general (not inflector::slug) to make sure its safe to use since you
> cant trust everything coming in. Sure 99% of users will not mess with URLs
> but that 1 % who decides to change and mess with things.
>
>
>
> Should you sanitize $foo so its only [az-09-] do you need to? And no not
> because its a slug  but because its safer if you took the & = out of all the
> url if you know it should not be there. I am asking in general not in a case
> specifi if it’s a slug if not forget I even used that word. Think of any url
> on your site and think of a evil user typing in something they should not.
> Now what would you do to protect the site from what they wrote. That’s what
> I am asking. Do you need to check the data in the url (and I do not mean
> check if it the owner) before you send it to delete / save/ update/ redirect
> anything.
>
>
>
> Having the site do something or attempt to do something by messing with the
> url.
>
>
>
> Does that make sense or am I just not clear?
>
>
>
>
>
>
>
> *From:* Tilen Majerle [mailto:tilen.maje...@gmail.com]
> *Sent:* December-11-10 2:55 PM
>
> *To:* cake-php@googlegroups.com
> *Subject:* Re: Passing Variable to delete
>
>
>
> with Inflector::slug($id) i think that will be ok
> --
> Tilen Majerle
>
> http://majerle.eu
>
>
>
>  2010/12/11 Dave Maharaj 
>
> Sorry….
>
>
>
> Not what I was trying to ask.
>
> Not the if owner delete part of the action…just the passing of variables
> thru url…the actual variable. Cake spits out code link/delete/this_slug what
> could a user change the “this_slug” variable too that could be harful. What
> should you check /clean / for the variable its self. I only used the delete
> as a general example so in any case anytime a variable is passed directly to
> the controller what should you do if anything to make sure its no code
> capable of damage / injection / disruption
>
>
>
> Dave
>
>
>
> *From:* Tilen Majerle [mailto:tilen.maje...@gmail.com]
> *Sent:* December-11-10 12:08 PM
> *To:* cake-php@googlegroups.com
> *Subject:* Re: Passing Variable to delete
>
>
>
> in ur case, i will first check, if given id is id for record from some
> user, and if is, then delete it, otherwise don't delete it...
> --
> Tilen Majerle
>
> http://majerle.eu
>
>
>
> 2010/12/11 Dave Maharaj 
>
> When passing an id / slug  thru a url for delete is there any security
> precautions to add?
>
>
>
> Example
>
>
>
> Function delete ($id) {
>
>
>
> $this->Model->deleteAll(array(Model.id => $id, Model.owner =>
> $this->Auth->user(‘id’)));
>
>
>
> }
>
>
>
> So I pretty much always use deleteAll so its got multiple values of
> checking rightful owner / permission to delete but I’m more curious about
> the passing of the actual $id since anyone can pass anything they want as an
> $id if they want to get smart and mess with your site. So what should you
> do? Any added precautions? Sanitize:: the slug / id?
>
>
>
> Thanks,
>
> Dave
>
>
>
>
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others
> with their CakePHP related questions.
>
> 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.comFor
>  more options, visit this group at
> http://groups.google.com/group/cake-php?hl=en
>
>
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others
> with their CakePHP related questions.
>
> 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.comFor
>  more options, visit this group at
> http://groups.google.com/group/cake-php?hl=en
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others
> with their CakePHP related questions.
>
> 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.comFor
>  more options, visit this group at
> http://groups.google.com/group/cake-php?hl=en
>
>
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others
> with their CakePHP related questions.
>
> You

RE: Passing Variable to delete

2010-12-11 Thread Dave Maharaj
No no you do not understand what I am asking.

 

Site/page/$foo

 

$foo can be 1 hundred million things 1 being something correct everything
else is wrong so a user can put in &something=this&that=somethingelse. I am
asking because that get pumped right into cake is there anything you should
do in general (not inflector::slug) to make sure its safe to use since you
cant trust everything coming in. Sure 99% of users will not mess with URLs
but that 1 % who decides to change and mess with things.

 

Should you sanitize $foo so its only [az-09-] do you need to? And no not
because its a slug  but because its safer if you took the & = out of all the
url if you know it should not be there. I am asking in general not in a case
specifi if it's a slug if not forget I even used that word. Think of any url
on your site and think of a evil user typing in something they should not.
Now what would you do to protect the site from what they wrote. That's what
I am asking. Do you need to check the data in the url (and I do not mean
check if it the owner) before you send it to delete / save/ update/ redirect
anything. 

 

Having the site do something or attempt to do something by messing with the
url.

 

Does that make sense or am I just not clear?

 

 

 

From: Tilen Majerle [mailto:tilen.maje...@gmail.com] 
Sent: December-11-10 2:55 PM
To: cake-php@googlegroups.com
Subject: Re: Passing Variable to delete

 

with Inflector::slug($id) i think that will be ok
--
Tilen Majerle

http://majerle.eu





2010/12/11 Dave Maharaj 

Sorry..

 

Not what I was trying to ask. 

Not the if owner delete part of the action.just the passing of variables
thru url.the actual variable. Cake spits out code link/delete/this_slug what
could a user change the "this_slug" variable too that could be harful. What
should you check /clean / for the variable its self. I only used the delete
as a general example so in any case anytime a variable is passed directly to
the controller what should you do if anything to make sure its no code
capable of damage / injection / disruption  

 

Dave

 

From: Tilen Majerle [mailto:tilen.maje...@gmail.com] 
Sent: December-11-10 12:08 PM
To: cake-php@googlegroups.com
Subject: Re: Passing Variable to delete

 

in ur case, i will first check, if given id is id for record from some user,
and if is, then delete it, otherwise don't delete it...
--
Tilen Majerle

http://majerle.eu

 

2010/12/11 Dave Maharaj 

When passing an id / slug  thru a url for delete is there any security
precautions to add?

 

Example 

 

Function delete ($id) {

 

$this->Model->deleteAll(array(Model.id => $id, Model.owner =>
$this->Auth->user('id')));

 

}

 

So I pretty much always use deleteAll so its got multiple values of checking
rightful owner / permission to delete but I'm more curious about the passing
of the actual $id since anyone can pass anything they want as an $id if they
want to get smart and mess with your site. So what should you do? Any added
precautions? Sanitize:: the slug / id?

 

Thanks,

Dave

 

 

Check out the new CakePHP Questions site http://cakeqs.org and help others
with their CakePHP related questions.
 
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

 

Check out the new CakePHP Questions site http://cakeqs.org and help others
with their CakePHP related questions.
 
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

Check out the new CakePHP Questions site http://cakeqs.org and help others
with their CakePHP related questions.
 
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

 

Check out the new CakePHP Questions site http://cakeqs.org and help others
with their CakePHP related questions.
 
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

Check out the new CakePHP Questions 

Media Plugin - How to set different instructions for differents kinds of images?

2010-12-11 Thread huoxito
Could anybody post any examples on how I could have Media.filter
instructions on the same upload?

I want to upload two kind of images on the same form, For one of them
I need only two copies, versions. And for the other one I need three
copies I tried to do it on a beforeFilter but I was still getting some
errors saying that the generator behavior couldn't created some
versions. Now itm trying this code but I still don't feel that I got
the plugin working idea right so far:

function beforeValidate(){

if(isset($this->data['AttachmentNoticias']['group'])){

if($this->data['AttachmentNoticias']['group'] ===
'imgFront'){
$l = array('convert' => 'image/jpeg', 'fit' =>
array(600, 450));
$m = array('convert' => 'image/jpeg', 'fitCrop' =>
array(318, 160));
$s = array('convert' => 'image/jpeg', 'fit' =>
array(200, 125));
}

if($this->data['AttachmentNoticias']['group'] ===
'imgText'){
$l = array('convert' => 'image/jpeg', 'fit' =>
array(600, 450));
$m = array('convert' => 'image/jpeg', 'fitCrop' =>
array(318, 160));
$s = array('convert' => 'image/jpeg', 'fit' =>
array(200, 125));
}

Configure::write('Media.filter', array('image' =>
compact('m','l','s')));
}

return true;
}

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: Passing Variable to delete

2010-12-11 Thread Tilen Majerle
with Inflector::slug($id) i think that will be ok
--
Tilen Majerle
http://majerle.eu



2010/12/11 Dave Maharaj 

>  Sorry….
>
>
>
> Not what I was trying to ask.
>
> Not the if owner delete part of the action…just the passing of variables
> thru url…the actual variable. Cake spits out code link/delete/this_slug what
> could a user change the “this_slug” variable too that could be harful. What
> should you check /clean / for the variable its self. I only used the delete
> as a general example so in any case anytime a variable is passed directly to
> the controller what should you do if anything to make sure its no code
> capable of damage / injection / disruption
>
>
>
> Dave
>
>
>
> *From:* Tilen Majerle [mailto:tilen.maje...@gmail.com]
> *Sent:* December-11-10 12:08 PM
> *To:* cake-php@googlegroups.com
> *Subject:* Re: Passing Variable to delete
>
>
>
> in ur case, i will first check, if given id is id for record from some
> user, and if is, then delete it, otherwise don't delete it...
> --
> Tilen Majerle
>
> http://majerle.eu
>
>
>
>  2010/12/11 Dave Maharaj 
>
> When passing an id / slug  thru a url for delete is there any security
> precautions to add?
>
>
>
> Example
>
>
>
> Function delete ($id) {
>
>
>
> $this->Model->deleteAll(array(Model.id => $id, Model.owner =>
> $this->Auth->user(‘id’)));
>
>
>
> }
>
>
>
> So I pretty much always use deleteAll so its got multiple values of
> checking rightful owner / permission to delete but I’m more curious about
> the passing of the actual $id since anyone can pass anything they want as an
> $id if they want to get smart and mess with your site. So what should you
> do? Any added precautions? Sanitize:: the slug / id?
>
>
>
> Thanks,
>
> Dave
>
>
>
>
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others
> with their CakePHP related questions.
>
> 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.comFor
>  more options, visit this group at
> http://groups.google.com/group/cake-php?hl=en
>
>
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others
> with their CakePHP related questions.
>
> 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.comFor
>  more options, visit this group at
> http://groups.google.com/group/cake-php?hl=en
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others
> with their CakePHP related questions.
>
> 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.comFor
>  more options, visit this group at
> http://groups.google.com/group/cake-php?hl=en
>

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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

2010-12-11 Thread dtemes
It looks great, but isn't cakephp version 1.2.1 a bit outdated? I
would love to see a Windows and Linux version



On 10 dic, 18:36, cake-learner  wrote:
> I was looking for something like this and share with you guys
>
> http://www.youtube.com/watch?v=JOOhSQqANQs

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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 publish first paragraph only

2010-12-11 Thread cricket
On Fri, Dec 10, 2010 at 12:02 PM, Stephen
 wrote:
> I personally would present a optional field in the table for an introduction
> paragraph (optional), if the admin didn't want to write an introduction
> paragraph I would then fall back onto creating an excerpt with php/cakephp
> and simply ammend "..." to the end with a read more link.

Same thing I usually do--have both body/content and intro. Except that
I create the truncated version for intro upon save (if intro doesn't
exist, obviously) so that it's unnecessary to do so when displaying
the view (caching aside,, of course).

> I would allow the admin to set the amount of characters as a preference.

But where do you save the pref? I just set the length as a class var
in the model. That means that it's not configurable by an admin, but
there's unlikely to be a need to changed it much.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: Time Helper to show only the date and not the time

2010-12-11 Thread cricket
echo date('M j, Y', strtotime($post['Post']['created']));

What I've done in the past a couple of times is put code in
afterFind() to add something like this as
$data[$this->alias]['created_string'].

On Fri, Dec 10, 2010 at 11:41 AM, georgeman  wrote:
> What if I want to only show the date and not the time, for example:
> December 10, 2010
>
> I have a solution that works but it seems to me there must be an
> easier way to do, something that I overlooked. Here is my solution:
>
> Time->fromString($post['Post']
> ['created']))); ?>
>
> Is there an easier way to do this?
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
>
> 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
>

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: Localize only some of a controller's pages

2010-12-11 Thread cricket
On Thu, Dec 9, 2010 at 9:27 PM, Ryan Schmidt  wrote:
> I'm reading about how internationalization and localization are handled in 
> CakePHP. On this page...
>
> http://book.cakephp.org/view/1229/Internationalizing-Your-Application
>
> ...the book explains how to use gettext and the __() function to localize 
> strings, but also says that if I want to translate longer passages or entire 
> pages of text, I should use a different solution, like writing individual 
> language-specific templates and loading them using code like this in 
> app_controller.php:
>
>
> function beforeFilter() {
>    $locale = Configure::read('Config.language');
>    if ($locale && file_exists(VIEWS . $locale . DS . $this->viewPath)) {
>        // e.g. use /app/views/fre/pages/tos.ctp instead of 
> /app/views/pages/tos.ctp
>        $this->viewPath = $locale . DS . $this->viewPath;
>    }
> }
>
>
> My initial reading of this code suggested to me that it would look for a 
> localized template, and if none was found, it would fall back to a 
> non-localized one. This is what I want. But I was thrown off by the call to 
> the file_exists() function. In fact, $this->viewPath is not a file; it's a 
> directory. It's only checking if the localized directory name exists, and if 
> so, tries to access the views inside it. This means *all* of a given 
> controller's views must either be localized with individual files, or none of 
> them can be. This is not what I want. I want, for example, my terms and 
> conditions page (served by the pages controller) to be localized in 
> individual language-specific files, but I want my admin main page (also 
> served by the pages controller) to be localized using gettext.

You could extend the test to check which page is being requested. Or,
whether $this->params['admin'] is set, etc.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: Passing Variable to delete

2010-12-11 Thread Dave Maharaj
Sorry..

 

Not what I was trying to ask. 

Not the if owner delete part of the action.just the passing of variables
thru url.the actual variable. Cake spits out code link/delete/this_slug what
could a user change the "this_slug" variable too that could be harful. What
should you check /clean / for the variable its self. I only used the delete
as a general example so in any case anytime a variable is passed directly to
the controller what should you do if anything to make sure its no code
capable of damage / injection / disruption  

 

Dave

 

From: Tilen Majerle [mailto:tilen.maje...@gmail.com] 
Sent: December-11-10 12:08 PM
To: cake-php@googlegroups.com
Subject: Re: Passing Variable to delete

 

in ur case, i will first check, if given id is id for record from some user,
and if is, then delete it, otherwise don't delete it...
--
Tilen Majerle

http://majerle.eu





2010/12/11 Dave Maharaj 

When passing an id / slug  thru a url for delete is there any security
precautions to add?

 

Example 

 

Function delete ($id) {

 

$this->Model->deleteAll(array(Model.id => $id, Model.owner =>
$this->Auth->user('id')));

 

}

 

So I pretty much always use deleteAll so its got multiple values of checking
rightful owner / permission to delete but I'm more curious about the passing
of the actual $id since anyone can pass anything they want as an $id if they
want to get smart and mess with your site. So what should you do? Any added
precautions? Sanitize:: the slug / id?

 

Thanks,

Dave

 

 

Check out the new CakePHP Questions site http://cakeqs.org and help others
with their CakePHP related questions.
 
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

 

Check out the new CakePHP Questions site http://cakeqs.org and help others
with their CakePHP related questions.
 
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

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: Passing Variable to delete

2010-12-11 Thread Tilen Majerle
in ur case, i will first check, if given id is id for record from some user,
and if is, then delete it, otherwise don't delete it...
--
Tilen Majerle
http://majerle.eu



2010/12/11 Dave Maharaj 

>  When passing an id / slug  thru a url for delete is there any security
> precautions to add?
>
>
>
> Example
>
>
>
> Function delete ($id) {
>
>
>
> $this->Model->deleteAll(array(Model.id => $id, Model.owner =>
> $this->Auth->user(‘id’)));
>
>
>
> }
>
>
>
> So I pretty much always use deleteAll so its got multiple values of
> checking rightful owner / permission to delete but I’m more curious about
> the passing of the actual $id since anyone can pass anything they want as an
> $id if they want to get smart and mess with your site. So what should you
> do? Any added precautions? Sanitize:: the slug / id?
>
>
>
> Thanks,
>
> Dave
>
>
>
>
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others
> with their CakePHP related questions.
>
> 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.comFor
>  more options, visit this group at
> http://groups.google.com/group/cake-php?hl=en
>

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Passing Variable to delete

2010-12-11 Thread Dave Maharaj
When passing an id / slug  thru a url for delete is there any security
precautions to add?

 

Example 

 

Function delete ($id) {

 

$this->Model->deleteAll(array(Model.id => $id, Model.owner =>
$this->Auth->user('id')));

 

}

 

So I pretty much always use deleteAll so its got multiple values of checking
rightful owner / permission to delete but I'm more curious about the passing
of the actual $id since anyone can pass anything they want as an $id if they
want to get smart and mess with your site. So what should you do? Any added
precautions? Sanitize:: the slug / id?

 

Thanks,

Dave

 

 

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Listing 23 & 24. Validate the username (problem understanding at all)

2010-12-11 Thread John Maxim
Taking validation further
(TUTORIAL)
Sometimes you can't tell if data is valid just by looking at it. For
example, the username may be between six and 40 characters, but you
will have to check the database to see if the username is already
taken. CakePHP provides the ability to manually mark a field as
invalid. Take a look at the beforeValidate method in Listing 23. This
method would be added to the user model.

Listing 23. Validate the username


 function beforeValidate() {
if (!$this->id) {
if ($this->findCount(array('User.username'
=> $this->data['User']['username'])) > 0) {
$this->invalidate('username_unique');
return false;
}
}
return true;
}


+QUESTIONER++
So we need to put this in user model ? but currently there isn't any
function in it.. how do I add it in ?

Before posting for help here, I have tried adding in and it all went
wrong. Now I would like to find out where exactly to add this and is
this the phpcake 3.1 version's script ? I noticed many scripts were
deprecated and I have to keep checking on the comments.

My current user model script is as follow:

 array ('rule' => '/^.{6,40}$/'),

'password' => array('rule'=>'/^.{6,40}$/'),

'email' => array(
'notEmpty' => array(
'rule' => 'notEmpty',
'message' => 'This field cannot be blank',
'last' => true
),
'email' => array(
'rule' => 'email',
'message' => 'That is not a valid email
address'
)
)

);

}

?>

(TUTORIAL CONTINUE)
Is Listing 24 compulsory ? :

You can take full advantage of this by changing the username input
line in the register.ctp view to the following.

Listing 24. New username input line

 echo $form->input('username', array('after' => $form->error
   ('username_unique', 'The username is taken. Please try
again.')));

+++QUESTIONER+++
I really have no idea what this can do, lost. I have put both Listing
23 & 24 in but it gave a list of 4-5 errors



Any help please, Thanks !

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Hello

2010-12-11 Thread a.g.p.
Hi, does anybody can tell me how to show a video on a website with php, once it 
has been uploaded into the server?
Thanks!
-
Crea tus propias redes de amigos.
Sin limitaciones ni restricciones.
Libérate de publicaciones de desconocidos
Llego http://www.friend2friend.com.ar
Te invito a descubrirlo!

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: friends please help

2010-12-11 Thread Miqdad Ali
tanx 4 ur reply

i corrected that problem by editing .htaccess file



Miqdad Ali
http://www.miqdadali.co.cc




On Fri, Dec 10, 2010 at 12:10 AM, cricket  wrote:

> On Thu, Dec 9, 2010 at 1:49 AM, Miqdad Ali wrote:
>
>> friends please help
>>
>> i have a form in ctp and when i hit the save button it shown
>>
>>
>>
>> You don't have permission to access /uscb/pers/save_data on this server.
>>
>> --
>> Apache/1.3.41 Server at www.www.imeseat.com Port 80
>>
>>
>>
>> but it's working fine in localhos
>>
>>
> Looks like an Apache issue. Are you sure the path is correct?
>
> And why does the URL have 'www' twice?
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others
> with their CakePHP related questions.
>
> 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.comFor
>  more options, visit this group at
> http://groups.google.com/group/cake-php?hl=en
>

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Why unbind directive doesn't works on read function?

2010-12-11 Thread Mariano C.
I have two function getBasicInfo read specific book's information
through $book_id then pass the record readed to increaseOwners that
should upgrade owners field of recordset passed.

This works pretty good, but $this-unbindModel(array('hasMany' => array('BooksUser')));
$this->id = $book_id;

if(is_null($this->read()))
return false;

return $this->read();
}

function increaseOwners($book_id)
{
$this->data = $this->getBasicInfo($book_id);
$owners = $this->data['Book']['owners'] + 1;

// on success
if($this->saveField('owners', $owners))
return true;

// on errror
return false;
}

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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 achieve Email Validation - with 2 different messages

2010-12-11 Thread John Maxim
Solved !

Thanks very much Jeremy.

On Dec 11, 6:37 pm, Jeremy Burns | Class Outfit
 wrote:
> var $validate = array(
>         'email' => array(
>                 'notEmpty' => array(
>                         'rule' => 'notEmpty',
>                         'message' => 'Please enter your email address.',
>                         'last' => true
>                 ),
>                 'email' => array(
>                         'rule' => 'email',
>                         'message' => 'That is not a valid email address'
>                 )
>         )
> );
>
> Jeremy Burns
> Class Outfit
>
> jeremybu...@classoutfit.comhttp://www.classoutfit.com
>
> On 11 Dec 2010, at 10:33, John Maxim wrote:
>
> > I have to be honest here I am not programming inclined. I have no idea
> > how to apply your sample to my actual problem...
>
> > On Dec 11, 6:30 pm, Jeremy Burns | Class Outfit
> >  wrote:
> >> You need an nested array:
>
> >> var $validate = array(
> >>         'fieldName' => array(
> >>                 'ruleName1' => array(
> >>                         'rule' => ..rule...,
> >>                         'message' => ...message...,
> >>                         'last' => true
> >>                 ),
> >>                 'ruleName2' => array(
> >>                         'rule' => ..rule...,
> >>                         'message' => ...message...
> >>                 )
> >>         )
> >> );
>
> >> This will make it check ruleName1 first, then ruleName2 and so on. You can 
> >> call them whatever you want, but I generally mirror the actual rule name 
> >> (e.g. notEmpty etc). The 'last' option will make it stop there for that 
> >> field if the validation rule fails, else it will continue on and only 
> >> report the final broken validation rule for that field.
>
> >> Jeremy Burns
> >> Class Outfit
>
> >> jeremybu...@classoutfit.comhttp://www.classoutfit.com
>
> >> On 11 Dec 2010, at 10:25, John Maxim wrote:
>
> >>> In email validation - tutorial IBM build a quick web: if it is left
> >>> blank, the message displays "enter a valid email".
>
> >>> How to make it so it displays "this field cannot be left blank" ?
>
> >>> Only when something not-email entered in it so does it display "enter
> >>> a valid email" ...
>
> >>> I see we at least need to create 2 validation for email field ? the
> >>> below is what is being used at the moment:
>
> >>> class User extends AppModel
> >>>    {
> >>>            var $name = 'User';
>
> >>>            var $validate = array (
> >>>            'username' => array ('rule' => '/^.{6,40}$/'),
> >>>            'password' => array('rule'=>'/^.{6,40}$/'),
> >>>            'email' => array('rule'=> array('email', true),
> >>>            'message' => 'Enter a valid email')
>
> >>>            );
>
> >>>    }
>
> >>> Any help with this ?
>
> >>> Thanks !
>
> >>> Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp others 
> >>> with their CakePHP related questions.
>
> >>> 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 
> >>> athttp://groups.google.com/group/cake-php?hl=en
>
> > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others 
> > with their CakePHP related questions.
>
> > 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 
> > athttp://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: The query number and error number display at bottom of the page ..

2010-12-11 Thread John Maxim
Hey just as simple as it would be, may I ask if there's any usefulness
in keeping the query number .. while developing my website or should I
turn it off, which is a better practice ? The pros and cons ?

I know in the end it would have to be off

Thanks

On Nov 27, 12:14 pm, John Maxim  wrote:
> Greetings,
>
> Hey thanks, I have not done it. As I'm with other stuff... working my
> way to this project soon. I'd reply once it is done or any issues
> encountered. Thanks! Really glad to know there's a solution to this
> and it sounds simple enough for a newbie.
>
> On Nov 26, 12:52 am, build33  wrote:
>
> > Hey John, if you edit app/config/core.php
> > and change
> > Configure::write('debug', 2);
> > to
> > Configure::write('debug', 1);
> > that should get rid of the sql info etc

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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 achieve Email Validation - with 2 different messages

2010-12-11 Thread Jeremy Burns | Class Outfit
var $validate = array(
'email' => array(
'notEmpty' => array(
'rule' => 'notEmpty',
'message' => 'Please enter your email address.',
'last' => true
),
'email' => array(
'rule' => 'email',
'message' => 'That is not a valid email address'
)
)
);

Jeremy Burns
Class Outfit

jeremybu...@classoutfit.com
http://www.classoutfit.com

On 11 Dec 2010, at 10:33, John Maxim wrote:

> I have to be honest here I am not programming inclined. I have no idea
> how to apply your sample to my actual problem...
> 
> On Dec 11, 6:30 pm, Jeremy Burns | Class Outfit
>  wrote:
>> You need an nested array:
>> 
>> var $validate = array(
>> 'fieldName' => array(
>> 'ruleName1' => array(
>> 'rule' => ..rule...,
>> 'message' => ...message...,
>> 'last' => true
>> ),
>> 'ruleName2' => array(
>> 'rule' => ..rule...,
>> 'message' => ...message...
>> )
>> )
>> );
>> 
>> This will make it check ruleName1 first, then ruleName2 and so on. You can 
>> call them whatever you want, but I generally mirror the actual rule name 
>> (e.g. notEmpty etc). The 'last' option will make it stop there for that 
>> field if the validation rule fails, else it will continue on and only report 
>> the final broken validation rule for that field.
>> 
>> Jeremy Burns
>> Class Outfit
>> 
>> jeremybu...@classoutfit.comhttp://www.classoutfit.com
>> 
>> On 11 Dec 2010, at 10:25, John Maxim wrote:
>> 
>>> In email validation - tutorial IBM build a quick web: if it is left
>>> blank, the message displays "enter a valid email".
>> 
>>> How to make it so it displays "this field cannot be left blank" ?
>> 
>>> Only when something not-email entered in it so does it display "enter
>>> a valid email" ...
>> 
>>> I see we at least need to create 2 validation for email field ? the
>>> below is what is being used at the moment:
>> 
>>> class User extends AppModel
>>>{
>>>var $name = 'User';
>> 
>>>var $validate = array (
>>>'username' => array ('rule' => '/^.{6,40}$/'),
>>>'password' => array('rule'=>'/^.{6,40}$/'),
>>>'email' => array('rule'=> array('email', true),
>>>'message' => 'Enter a valid email')
>> 
>>>);
>> 
>>>}
>> 
>>> Any help with this ?
>> 
>>> Thanks !
>> 
>>> Check out the new CakePHP Questions sitehttp://cakeqs.organd help others 
>>> with their CakePHP related questions.
>> 
>>> 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 
>>> athttp://groups.google.com/group/cake-php?hl=en
> 
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
> 
> 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

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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 achieve Email Validation - with 2 different messages

2010-12-11 Thread John Maxim
I have to be honest here I am not programming inclined. I have no idea
how to apply your sample to my actual problem...

On Dec 11, 6:30 pm, Jeremy Burns | Class Outfit
 wrote:
> You need an nested array:
>
> var $validate = array(
>         'fieldName' => array(
>                 'ruleName1' => array(
>                         'rule' => ..rule...,
>                         'message' => ...message...,
>                         'last' => true
>                 ),
>                 'ruleName2' => array(
>                         'rule' => ..rule...,
>                         'message' => ...message...
>                 )
>         )
> );
>
> This will make it check ruleName1 first, then ruleName2 and so on. You can 
> call them whatever you want, but I generally mirror the actual rule name 
> (e.g. notEmpty etc). The 'last' option will make it stop there for that field 
> if the validation rule fails, else it will continue on and only report the 
> final broken validation rule for that field.
>
> Jeremy Burns
> Class Outfit
>
> jeremybu...@classoutfit.comhttp://www.classoutfit.com
>
> On 11 Dec 2010, at 10:25, John Maxim wrote:
>
> > In email validation - tutorial IBM build a quick web: if it is left
> > blank, the message displays "enter a valid email".
>
> > How to make it so it displays "this field cannot be left blank" ?
>
> > Only when something not-email entered in it so does it display "enter
> > a valid email" ...
>
> > I see we at least need to create 2 validation for email field ? the
> > below is what is being used at the moment:
>
> > class User extends AppModel
> >    {
> >            var $name = 'User';
>
> >            var $validate = array (
> >            'username' => array ('rule' => '/^.{6,40}$/'),
> >            'password' => array('rule'=>'/^.{6,40}$/'),
> >            'email' => array('rule'=> array('email', true),
> >            'message' => 'Enter a valid email')
>
> >            );
>
> >    }
>
> > Any help with this ?
>
> > Thanks !
>
> > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others 
> > with their CakePHP related questions.
>
> > 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 
> > athttp://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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 achieve Email Validation - with 2 different messages

2010-12-11 Thread Jeremy Burns | Class Outfit
You need an nested array:

var $validate = array(
'fieldName' => array(
'ruleName1' => array(
'rule' => ..rule...,
'message' => ...message...,
'last' => true
),
'ruleName2' => array(
'rule' => ..rule...,
'message' => ...message...
)
)
);

This will make it check ruleName1 first, then ruleName2 and so on. You can call 
them whatever you want, but I generally mirror the actual rule name (e.g. 
notEmpty etc). The 'last' option will make it stop there for that field if the 
validation rule fails, else it will continue on and only report the final 
broken validation rule for that field.

Jeremy Burns
Class Outfit

jeremybu...@classoutfit.com
http://www.classoutfit.com

On 11 Dec 2010, at 10:25, John Maxim wrote:

> In email validation - tutorial IBM build a quick web: if it is left
> blank, the message displays "enter a valid email".
> 
> How to make it so it displays "this field cannot be left blank" ?
> 
> Only when something not-email entered in it so does it display "enter
> a valid email" ...
> 
> I see we at least need to create 2 validation for email field ? the
> below is what is being used at the moment:
> 
> class User extends AppModel
>   {
>   var $name = 'User';
> 
>   var $validate = array (
>   'username' => array ('rule' => '/^.{6,40}$/'),
>   'password' => array('rule'=>'/^.{6,40}$/'),
>   'email' => array('rule'=> array('email', true),
>   'message' => 'Enter a valid email')
> 
>   );
> 
>   }
> 
> Any help with this ?
> 
> Thanks !
> 
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
> 
> 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

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: UNIQUE key doesn't work as it is supposed ? How to check and confirm if it is UNIQUE

2010-12-11 Thread John Maxim
Hi Jeremy, I want each column to be unique and it has been solved by
altering the users table... well I actually dropped it and created a
new one with each of the field I wanted unique to be unique..

I posted as solved above, thanks anyway.

JM

On Dec 11, 3:26 pm, Jeremy Burns | Class Outfit
 wrote:
> Can I ask a question? Did you want the combination of the two columns 
> together to be unique, or just the values within each column to be unique in 
> that column? In other words, two separate unrelated unique indexes, or a 
> single unique index comprised of both columns?
>
> Jeremy Burns
> Class Outfit
>
> jeremybu...@classoutfit.comhttp://www.classoutfit.com
>
> On 11 Dec 2010, at 07:23, John Maxim wrote:
>
> > Oh, I didn't know it was sent to your email instead...
>
> > Yup it's fixed.
>
> > Thanks.
>
> > On Dec 11, 3:10 pm, Ryan Schmidt  wrote:
> >> Great, glad you got it solved. (Sending this message back to the group so 
> >> others know it's fixed.)
>
> >> On Dec 11, 2010, at 01:06, John Maxim wrote:
>
> >>> Thanks Ryan, I understand after you've pointed out with the UNIQUE
> >>> column having 2 fields makes it a combination. It's solved by making 2
> >>> different columns as UNIQUE each.
>
> >>> On Dec 10, 4:34 pm, Ryan Schmidt  wrote:
>  On Dec 10, 2010, at 02:07, John Maxim wrote:
>
> > Hi guys can you help explain why the unique key for mine doesn't
> > work ? I set username and email as UNIQUE but I tried entering another
> > registration with a different username, but same email it went through
> > the registration and added on MySQL database table that means my
> > UNIQUE key not working properly huh ?
> > More info, I have checked on phpmyadmin that both the username and
> > email are in the UNIQUE column.
>
>  This last sentence may indicate the problem. Do you mean that you have a 
>  single UNIQUE index over both the username and email fields? If so, that 
>  only means that the *combination* of username and email must be unique. 
>  If you want the username to be unique, and the email to be unique, 
>  independent of one another (and you probably do), then you need two 
>  UNIQUE indexes: one on the username field and another on the email field.
>
> > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others 
> > with their CakePHP related questions.
>
> > 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 
> > athttp://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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 achieve Email Validation - with 2 different messages

2010-12-11 Thread John Maxim
In email validation - tutorial IBM build a quick web: if it is left
blank, the message displays "enter a valid email".

How to make it so it displays "this field cannot be left blank" ?

Only when something not-email entered in it so does it display "enter
a valid email" ...

I see we at least need to create 2 validation for email field ? the
below is what is being used at the moment:

class User extends AppModel
{
var $name = 'User';

var $validate = array (
'username' => array ('rule' => '/^.{6,40}$/'),
'password' => array('rule'=>'/^.{6,40}$/'),
'email' => array('rule'=> array('email', true),
'message' => 'Enter a valid email')

);

}

Any help with this ?

Thanks !

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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