Re: How to correct: double file-extension when i download something (media view)

2010-02-03 Thread John Andersen
I suggest you turn on debug and add some debug statements in between
your code, so you can see what the content of each variable is at
specific places. Debug is turned on in your core.php file in the
config directory.

Use debug statements:
debug($basename);
debug($file_extension);
and maybe some more, so you can check the content.
Enjoy,
   John

On Feb 4, 9:06 am, sebb86  wrote:
> John
>
> Hello,
> thanks for your answer! :)
> I've added your code.
> Well, I found out, that my old code (same result with your code) also
> works, but only with 3 of my 4 test-data-rows.
> It works for '13.pdf', '288.pdf' and '3.pdf'. It fails for
> '19.pdf' (result on click = 19.pdf.pdf) and i absolutely dont know
> why??!??!? That's very confusing.
> The pdf-fles are all the same, only the filename is changed.
>
> Also thanks for your addition to use "strtolower" with the file
> extension.

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: HABTM view: how to retrieve data in extra column?

2010-02-03 Thread John Andersen
No, not that way, you have to use your existing code and use an inner
loop, example:

[code]
  <- your outer loop! Good!
...
...
   
   <- the inner loop!
  
   
...
[/code]

The outer loop gives you an array containing the 'staff' and the
'room' arrays.
The inner loop takes the room array from the outer loop and gives you
each room therein.

Enjoy,
   John
On Feb 4, 9:14 am, sebb86  wrote:
> John
>
> Hello,
> i tryed:
>
> [code]
> 
>                  ,
>        
> [/code]
>
> But with that code i get the following error-message: "Warning (2):
> Illegal offset type [APP\views\staffs\index.ctp, line 40]".
> Where is my fault?
> Thanks very 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: Doing CakePHP 1.2.x in PHP 5 way

2010-02-03 Thread Miles J
beforeFilter() isn't a constructor. Its just a normal method, which is
used as a callback.

You should never overwrite the constructor as it has important code.
That's what the callbacks are for, to define custom code to not
conflict.

Also, this has nothing really to do with PHP 4 or 5, its a
architecture setup.

On Feb 3, 11:37 pm, Okto Silaban  wrote:
> Can I refere to a complete documentation how can I work with strict
> PHP5 on CakePHP?
>
> For example : Can I remove beforeFilter() and use __construct() instead ?

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 in element

2010-02-03 Thread John Andersen
If I understand you correctly Dave, then you have a page A on which is
a newsletter signup form. When the user submits an e-mail address, you
want to present the user to page B if the e-mail address is valid. If
the e-mail address is not valid, stay on page A. Correct?

Assuming I am correct :) ... in the controller receiving the
newsletter signup submit - if the e-mail address is valid, redirect
the user to page B. If the e-mail address is not valid, redirect the
user to page A, using $this->referer() as the redirect address.

Enjoy,
   John

On Feb 4, 4:03 am, "Dave"  wrote:
> I have a form in an element and wondering how to return back to the page it
> was sent from if its successful or if there are errors display the errors on
> the same page.
>
> Basically its a side menu and at the bottom a mini form to signup for
> newsletter which is on every page. So if the user adds their email and saved
> success im still on that page...not newsletters/index and if not successful
> same page but with errors.
> (not using ajax and not an option)
>
> 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


Doing CakePHP 1.2.x in PHP 5 way

2010-02-03 Thread Okto Silaban
Can I refere to a complete documentation how can I work with strict
PHP5 on CakePHP?

For example : Can I remove beforeFilter() and use __construct() instead ?

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: help for installing cakephp in a linux public_html directory!!!

2010-02-03 Thread cherif_Gsoul
thank you very much.

On 3 fév, 23:41, Jeff Deroshia  wrote:
> You can't rewrite in userDir directories, since they are already 
> rewritten:http://httpd.apache.org/docs/2.0/misc/rewriteguide.html
>
> On Wed, Feb 3, 2010 at 9:20 AM, cherif_Gsoul wrote:
>
> > hi, i need help for installing cakephp in a linux's public_html
> > directory exactly fedora 12, i put cakephp in that directory but it
> > seems that the mod_rewrite doesnt work and i dont know how to enable
> > it for public_html but it works very well in /var/www/html and i
> > configured the console too .
>
> > Tkx.
>
> > 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 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: help for installing cakephp in a linux public_html directory!!!

2010-02-03 Thread cherif_Gsoul
thank you i apperciate your help.

On 3 fév, 18:58, "Daniel S. Reichenbach"
 wrote:
> Hi,
>
> > hi, i need help for installing cakephp in a linux's public_html
> > directory exactly fedora 12, i put cakephp in that directory but it
> > seems that the mod_rewrite doesnt work and i dont know how to enable
> > it for public_html but it works very well in /var/www/html and i
> > configured the console too .
>
> you will have to check the Apache2 configuration. In Fedora Apache is
> configured to disallow configuration changes such as mod_rewrite does
> in user directories.
>
> You will need to tweak the mod_userdir configurations settings for
> AllowOverride.
>
> WkR,
> Daniel

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: app function

2010-02-03 Thread Dave
I tried using App Import model set up but got the same error message. Is
that what you mean? 

-Original Message-
From: cake-php@googlegroups.com [mailto:cake-...@googlegroups.com] On Behalf
Of Miles J
Sent: February-04-10 3:39 AM
To: CakePHP
Subject: Re: app function

You must have the model Link defined and loaded before you run your
navigation method.

On Feb 3, 9:38 pm, "Dave"  wrote:
> How do i run a function from app controller?
>
> in app_controller i have  in beforeFilter { $this->buildNavigations();
>
> }
>
> function buildNavigations()
>   {
>
>    $links = $this->Link->find('list'); //$links = $this->find('list');
>
>      }
>
> Resilts in:
> Undefined property: PagesController::$Link
>
> I simply want to build a navigation from the db Links which holds the 
> nav links.
>
> Ideas?
>
> 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 
cake-php+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: HABTM view: how to retrieve data in extra column?

2010-02-03 Thread sebb86
John

Hello,
i tryed:

[code]

 ,
   
[/code]

But with that code i get the following error-message: "Warning (2):
Illegal offset type [APP\views\staffs\index.ctp, line 40]".
Where is my fault?
Thanks very 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: app function

2010-02-03 Thread Miles J
You must have the model Link defined and loaded before you run your
navigation method.

On Feb 3, 9:38 pm, "Dave"  wrote:
> How do i run a function from app controller?
>
> in app_controller i have  in beforeFilter {
> $this->buildNavigations();
>
> }
>
> function buildNavigations()
>   {
>
>    $links = $this->Link->find('list');
> //$links = $this->find('list');
>
>      }
>
> Resilts in:
> Undefined property: PagesController::$Link
>
> I simply want to build a navigation from the db Links which holds the nav
> links.
>
> Ideas?
>
> 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: How to correct: double file-extension when i download something (media view)

2010-02-03 Thread sebb86
John

Hello,
thanks for your answer! :)
I've added your code.
Well, I found out, that my old code (same result with your code) also
works, but only with 3 of my 4 test-data-rows.
It works for '13.pdf', '288.pdf' and '3.pdf'. It fails for
'19.pdf' (result on click = 19.pdf.pdf) and i absolutely dont know
why??!??!? That's very confusing.
The pdf-fles are all the same, only the filename is changed.

Also thanks for your addition to use "strtolower" with the file
extension.

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 correct: double file-extension when i download something (media view)

2010-02-03 Thread sebb86
John

Hello,
thanks for your answer! :)
I've added your code.
Well, I found out, that my old code (same result with your code) also
works, but only with 3 of my 4 test-data-rows.
It works for '13.pdf', '288.pdf' and '3.pdf'. It fails for
'19.pdf' (result on click = 19.pdf.pdf) and i absolutely dont know
why??!??!? That's very confusing.
The pdf-fles are all the same, only the filename is changed.

Also thanks for your addition with "strtolower" with the file
extension!

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 correct: double file-extension when i download something (media view)

2010-02-03 Thread sebb86
John

Hello,
thanks for your answer! :)
I've added your code.
Well, I found out, that my old code (same result with your code) also
works, but only with 3 of my 4 test-data-rows.
It works for '13.pdf', '288.pdf' and '3.pdf'. It fails for
'19.pdf' (result on click = 19.pdf.pdf) and i absolutely dont know
why??!??!? That's very confusing.
The pdf-fles are all the same, only the filename is changed.

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: validation strangeness

2010-02-03 Thread cricket
I did debug the data; it was fine. My usual first strategy also :-)

The answer was 'on' => 'create', not 'add'.

On Feb 4, 12:32 am, Jeremy Burns  wrote:
> This might not be the answer you are looking for, but when I have had similar 
> issues before I have always debugged $this->data at various points to see 
> what is actually being validated and saved. Then I double check the shape of 
> the data against the save (and if necessary, saveAll) functions 
> inhttp://book.cakephp.org/view/75/Saving-Your-Datahere. Sometimes I have 
> found that the shape of the array is not what is expected.
>
> Jeremy Burns
>
> On 4 Feb 2010, at 04:25, cricket wrote:
>
> > Oops. I messed up the call to validate(). But, when I do ...
>
> > if ($this->User->create($this->data) && $this->User->validates())
> > {
> >    if ($this->User->save($this->data, true))
> >    {
>
> > ... validation passes! It should fail. WTF?
>
> > 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


app function

2010-02-03 Thread Dave
How do i run a function from app controller?
 
in app_controller i have  in beforeFilter {
$this->buildNavigations();
}
 
 
function buildNavigations()
  {
   
   $links = $this->Link->find('list');
//$links = $this->find('list');

 }

Resilts in:
Undefined property: PagesController::$Link

I simply want to build a navigation from the db Links which holds the nav
links.

Ideas?
 
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: Plugin using different Dynamic Database Connection

2010-02-03 Thread Zaky Katalan-Ezra
http://dev.mysql.com/doc/refman/5.0/en/federated-use.html

On Wed, Feb 3, 2010 at 11:08 PM, Bryan De Asis wrote:

> Sorry Zaky can you elaborate it more... what do you mean by create a view
> in the database that select from the other database?
>
> Thanks
>
>
> On Wed, Feb 3, 2010 at 3:45 PM, Zaky Katalan-Ezra wrote:
>
>> Create a view in the database that select from the other database.
>> This way you need only one connection.
>>
>> On Tue, Feb 2, 2010 at 7:58 PM, Bryan De Asis wrote:
>>
>>> Co'z I'm creating a database table which contains the database connection
>>> credentials so i can have thousands hundreds of config... so i can manage
>>> other news articles table databases using same plugin...
>>>
>>>
>>>
>>>
>>> On Tue, Feb 2, 2010 at 12:51 PM, Miles J wrote:
>>>
 Why aren't you just placing the config in database.php?

 On Feb 2, 8:48 am, bryan de asis  wrote:
 > Hello,
 >
 > Has anyone here tried to create a plugin which connects to a
 > difference database dynamically?
 > My Plugin name is "News"
 > I have tried adding this lines on beforeFilter on my
 > ArticlesController:
 > $db =& ConnectionManager::getDataSource('default');
 > $db->disconnect();
 > $db->config['host'] = 'localhost';
 > $db->config['login'] = 'login';
 > $db->config['password'] = 'password';
 > $db->config['database'] = 'database_name';
 > $db->connect();
 > and it doesn't work... it still doesnt work.
 >
 > anyone have any idea...

 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
>>>
>>
>>
>>
>> --
>> Regards,
>> Zaky Katalan-Ezra
>> QA Administrator
>> www.IGeneriX.com
>> Sites.IGeneriX.com
>> 054-7762312
>>
>> 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
>



-- 
Regards,
Zaky Katalan-Ezra
QA Administrator
www.IGeneriX.com
Sites.IGeneriX.com
054-7762312

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: validation strangeness

2010-02-03 Thread Jeremy Burns
This might not be the answer you are looking for, but when I have had similar 
issues before I have always debugged $this->data at various points to see what 
is actually being validated and saved. Then I double check the shape of the 
data against the save (and if necessary, saveAll) functions in 
http://book.cakephp.org/view/75/Saving-Your-Data here. Sometimes I have found 
that the shape of the array is not what is expected.

Jeremy Burns


On 4 Feb 2010, at 04:25, cricket wrote:

> Oops. I messed up the call to validate(). But, when I do ...
> 
> if ($this->User->create($this->data) && $this->User->validates())
> {
>   if ($this->User->save($this->data, true))
>   {
> 
> ... validation passes! It should fail. WTF?
> 
> 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: Associated Pagination

2010-02-03 Thread Changoso
Thanks a lot!

[Resolved]   :D :D

On Feb 3, 4:56 am, John Andersen  wrote:
> You probably need to add this to your view, so that any parameters in
> the URL is passed on to the paginator in the view.
>
> [code]
> $paginator->options(array('url' => $this->passedArgs));
> [/code]
>
> Seehttp://book.cakephp.org/view/166/Pagination-in-Viewsfor the
> pagination setup in the view.
> Enjoy,
>    John
>
> On Feb 2, 9:01 pm, Changoso  wrote:
>
>
>
> > I modified the view so it looks something more lke the manual...
>
> > 
> > 
> >         
> >          >                 $i = 0;
> >                 foreach ($data as $interest):
> >         ?>
> >         
> >                         
> >                                         echo 
> > $html->link($html->image('photos/'.$interest['Photo']
> > ['foto'], array('align'=>'middle', 'height'=>'50%')), array
> > ('controller'=>'photos', 'action' => 'view', $interest['Photo']
> > ['id']), array('escape' => false));
>
> >                          ?>
> >         
> >         = 1){
> >                 echo "";
> >                 $i = -1;
> >         }?>
> >         
> >         
> > 
> > 
>
> > Now it kind of works... it does only show me 2 or 3 or 5 (The limit I
> > set on the controller) the problem now is that when I press Next>> I
> > get a INvalid Gallery...
>
> [snip]

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: validation strangeness

2010-02-03 Thread cricket
Oops. I messed up the call to validate(). But, when I do ...

if ($this->User->create($this->data) && $this->User->validates())
{
if ($this->User->save($this->data, true))
{

... validation passes! It should fail. WTF?

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


validation strangeness

2010-02-03 Thread cricket
cake_1.2.6

I'm thoroughly confused by what's happening (or not happening) with my
validation. For one thing, save() does not appear to be calling
validate(). Even when I pass true as the 2nd param, validation does
not occur.

Secondly, the validation, when called explicitly, seems to be wrong.

User model:

public $validate = array(
'name' => array (
'username' => array(
'rule' => array('minLength', '1'),
'required' => true,
'message' => 'Please choose a username'
),
'unique' => array(
'rule' => array('isUnique'),
'on' => 'add',
'required' => true,
'message' => 'This username is already registered'
)
),
'email' => array (
'email' => array(
'rule' => 'email',
'required' => true,
'message' => 'A valid email address is required'
),
'unique' => array(
'rule' => array('isUnique'),
'on' => 'add',
'required' => true,
'message' => 'This email address is already registered'
)
),
);

UsersController:

if ($this->User->save($this->data, true))
{

}

The form inputs are a unique, valid name and a non-unique, valid email
address.

Cake ignores validation and tries to save the data, leading to a DB
error (because of a unique key). When called like this:

if ($this->User->validates($this->data))
{
if ($this->User->save($this->data, true))
{

... the save does not proceed. But FormHelper display the wrong
messages:

"Please choose a username"
"A valid email address is required"

I expect to see just one error msg: "This email address is already
registered".

So, first off, has Cake change something with save() recently? Looking
at the source, I can plainly see where it calls validate(). Why do I
need to explicitly call it?

And why are the messages wrong?

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


Quotes in options array

2010-02-03 Thread Furuno
Ok, so I want to pass an image from my custom file browser to
CKEditor. Here, the code I'm using to draw the image in the file
browser :

image('pool/' . $image, array('width' => 155,
'onclick' => 'window.opener.CKEDITOR.tools.callFunction(' .
$func_num . ', \'/mysite/img/pool/' . $image . '\')')); ?>

I expect it will produce something like this :



but instead, CakePHP "parse" the single quote into HTML encode :



Is there anyway to prevent 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


Re: How to include an element in a view.

2010-02-03 Thread Lance Willett
Hi Pau,
Are you using 1.2? If so, $this->renderElement is deprecated and you
should use $this->element instead. You can read up on elements at
http://book.cakephp.org/view/97/Elements.

But this specific situation sounds like a perfect task for a helper.
Helpers (see http://book.cakephp.org/view/101/Creating-Helpers) are
great for reusing code that will be used in multiple views across your
app. Doing so keeps you from repeating that code in lots of view
files.

Start by create a helper and placing the processing code there. Then
call the helper function from your view and pass in the data to be
processed. The helper should simply return the string for final
output, which you'd then echo in the view.

Does that make sense? Hope it works for you.

-Lance

On Feb 3, 2:33 am, Pau  wrote:
> Hi.
> I'm traying to display in a view a string asociated to a field value.
>
>    $i = 0;
>   foreach ($datas as $data):
>     $class = null;
>     if ($i++ % 2 == 0) {
>       $class = ' class="altrow"';
>     }
>
>    switch ($data['Model']['field'])
>     {
>     case 'A':
>          $varp = __('String1',true);
>          break;
>     case 'B':
>          $pasta = __('String2',true);
>          break;
>     case 'C':
>          $pasta = __('String3',true);
>          break;
>     };
>
>      .
>      ..  echo $varp ..
>
> endforeach;
>
> ?>
>
> I need to reuse this switch statement in other views. I create an
> element with this code and store this file in the views/elements
> folder.
>
>    $i = 0;
>   foreach ($datas as $data):
>     $class = null;
>     if ($i++ % 2 == 0) {
>       $class = ' class="altrow"';
>     }
>
>    $this->renderElement('mycode');
>
>      .
>      ..  echo $varp ..
>
> endforeach;
>
> ?>
> If I use renderElement doesn´t work because the code is a Swicht
> estatement and render the element for each bucle cicle.
> I tryed a include('mycode.ctp') by I don´t know how to reach this
> folder.
>
> How is the best way to do this?
>
> Thanks.
> Pau.

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: Plugin using different Dynamic Database Connection

2010-02-03 Thread Bryan De Asis
everything is encrypted...


On Wed, Feb 3, 2010 at 4:45 PM, Miles J  wrote:

> From an architecture standpoint, storing credentials in a database is
> a pretty bad idea.
>
> On Feb 3, 1:08 pm, Bryan De Asis  wrote:
> > Sorry Zaky can you elaborate it more... what do you mean by create a view
> in
> > the database that select from the other database?
> >
> > Thanks
> >
> > On Wed, Feb 3, 2010 at 3:45 PM, Zaky Katalan-Ezra  >wrote:
> >
> > > Create a view in the database that select from the other database.
> > > This way you need only one connection.
> >
> > > On Tue, Feb 2, 2010 at 7:58 PM, Bryan De Asis  >wrote:
> >
> > >> Co'z I'm creating a database table which contains the database
> connection
> > >> credentials so i can have thousands hundreds of config... so i can
> manage
> > >> other news articles table databases using same plugin...
> >
> > >> On Tue, Feb 2, 2010 at 12:51 PM, Miles J 
> wrote:
> >
> > >>> Why aren't you just placing the config in database.php?
> >
> > >>> On Feb 2, 8:48 am, bryan de asis  wrote:
> > >>> > Hello,
> >
> > >>> > Has anyone here tried to create a plugin which connects to a
> > >>> > difference database dynamically?
> > >>> > My Plugin name is "News"
> > >>> > I have tried adding this lines on beforeFilter on my
> > >>> > ArticlesController:
> > >>> > $db =& ConnectionManager::getDataSource('default');
> > >>> > $db->disconnect();
> > >>> > $db->config['host'] = 'localhost';
> > >>> > $db->config['login'] = 'login';
> > >>> > $db->config['password'] = 'password';
> > >>> > $db->config['database'] = 'database_name';
> > >>> > $db->connect();
> > >>> > and it doesn't work... it still doesnt work.
> >
> > >>> > anyone have any idea...
> >
> > >>> 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 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 at
> > >>http://groups.google.com/group/cake-php?hl=en
> >
> > > --
> > > Regards,
> > > Zaky Katalan-Ezra
> > > QA Administrator
> > >www.IGeneriX.com
> > > Sites.IGeneriX.com
> > > 054-7762312
> >
> > > 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 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


Form in element

2010-02-03 Thread Dave
I have a form in an element and wondering how to return back to the page it
was sent from if its successful or if there are errors display the errors on
the same page.
 
Basically its a side menu and at the bottom a mini form to signup for
newsletter which is on every page. So if the user adds their email and saved
success im still on that page...not newsletters/index and if not successful
same page but with errors.
(not using ajax and not an option)
 
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: htaccess help

2010-02-03 Thread Jeff Deroshia
You don't need to use mod_rewrite to share one cake core with multiple apps.
 Instead, in app/webroot/index.php change the following:
if (!defined('CAKE_CORE_INCLUDE_PATH')) {
define('CAKE_CORE_INCLUDE_PATH', ROOT);
}

To

if (!defined('CAKE_CORE_INCLUDE_PATH')) {
define('CAKE_CORE_INCLUDE_PATH', DS . 'path' . DS . 'to' . DS . 'core' );
}

in each of your apps.  The rest will be handled fine.

You can break your app directory out of the server document path as well by
modifying the appropriate lines.

See http://book.cakephp.org/view/35/Advanced-Installation

Jeff

On Tue, Feb 2, 2010 at 9:49 PM, Dave  wrote:

>  I have moved my cake folder and set up multiple apps running 1 cake
> setup.
>
> But my css / images are all going looking in the site root.
>
> My guess is this ss to do withthe htaccess in webroot
>
> 
> RewriteEngine on
> RewriteRule^$webroot/[L]
> RewriteRule(.*) webroot/$1[L]
>  
>
> my site1 is actually
>
> www/dev/site1
>
> and my cake is in
>
> www/dev/libs/cake
>
> Any ideas how to fix this?
>
> 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


Re: Related lists, polymorphic habtm? (fao: AD7six ;))

2010-02-03 Thread Jeff Deroshia
I did something similar using the relations of the main model in this
instance.  In this case the model 'Message' could be associated with
different things, 'Product', 'Invoice', etc.  There were only a few, so I
made a separate relation for each using the 'conditions' parameter to filter
by related model name.

Example belongsTo for model 'Message':
var $belongsTo = array(
'Invoice' => array(
'className' => 'Invoice',
'foreignKey' => 'reference_id',
'conditions' => array('Message.reference_model' => 'Invoice'),
'fields' => '',
'order' => ''
),
'Product' => array(
'className' => 'Product',
'foreignKey' => 'reference_id',
'conditions' => array('Message.reference_model' => 'Product'),
'fields' => '',
'order' => ''
)
);

Jeff

On Wed, Feb 3, 2010 at 5:30 AM, Jon Bennett  wrote:

> Hi AD,
>
> >> I think what I want is a habtm that can connect to multiple models
> >> with some additional fields in the join table, but I'm not sure that's
> >> feasible, but hope it is.
> >
> > a join table with more than 2 fields is a model, and a model that can
> > link to anything is (as you know) polymorphic.
> >
> > Therefore you want a join table something like this:
> >
> > relations
> >  id
> >  model
> >  foreign_id
> >  url
> >  title
> >  related_model
> >  related_foreign_id
> >  related_url
> >  related_title
> >
> > which would allow you to relate anything to anything. I wouldn't use
> > the polymorphic behavior though. just create a method for returning
> > you related stuff - unless you denormalize as hinted above so you
> > don't even need to.
> >
> > class Relation extends AppModel {
> >  function related($model, $id) {
> >  $return = array();
> >  $data = $this->find('all', array('conditions' => array(
> >   'OR' => array(
> > array('model' => $model, 'foreign_id' => $id),
> > array('related_model' => $model, 'related_foreign_id' => $id),
> >   )
> >  );
> >  }
> >  .. efficiently loop and get data if at all necessary
> >  return $return;
> > }
>
> Ahh, ok - thanks. Will have a play then hit you back if I come unstuck.
>
> Cheers,
>
> jb
>
>
> --
> jon bennett - www.jben.net - blog.jben.net
>
> 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: Trouble Baking with MAMP

2010-02-03 Thread mariano
Use the bundled php bin from MAMP in your call to bake i.e. /
Applications/MAMP/bin/php/php5/bin/php

cheers.


On Feb 3, 6:20 pm, B_Fraser  wrote:
> I've spent a few hours on this so far and haven't had any luck. I've
> read all the previous posts but still no joy.
>
> When I attempt to bake I get:
>
> Warning: mysql_connect(): Can't connect to local MySQL server through
> socket '/var/mysql/mysql.sock' (2) in /Applications/MAMP/htdocs/cake/
> acl_tutorial/cake/libs/model/datasources/dbo/dbo_mysql.php on line 454
> etc...
>
> The site connects properly to the database in a browser but has
> trouble in the command line.
>
> Following a previous post I checked and it does appear that my console
> it using my systems built in php. When I type 'what php' I see it
> point to: /usr/bin/php
>
> I've tried the method of typing '/Applications/MAMP/tmp/mysql/
> mysql.sock /tmp/mysql.sock' into the command line and have not had any
> success.
>
> Any help would be greatly appreciated!

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: help for installing cakephp in a linux public_html directory!!!

2010-02-03 Thread Jeff Deroshia
You can't rewrite in userDir directories, since they are already rewritten:
http://httpd.apache.org/docs/2.0/misc/rewriteguide.html

On Wed, Feb 3, 2010 at 9:20 AM, cherif_Gsoul wrote:

> hi, i need help for installing cakephp in a linux's public_html
> directory exactly fedora 12, i put cakephp in that directory but it
> seems that the mod_rewrite doesnt work and i dont know how to enable
> it for public_html but it works very well in /var/www/html and i
> configured the console too .
>
> Tkx.
>
> 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: Inner join querys: two fields from one table

2010-02-03 Thread andy
I think I found an article that fixed this issue.

It can be found here:
http://bakery.cakephp.org/articles/view/quick-tip-doing-ad-hoc-joins-in-model-find

I had read it before when searching... but didn't realize that it was
what I had been looking for all along.
Sorry for the misspelled "querys" in the title of this post as well.

Thanks,
andy


On Feb 3, 11:17 am, andy  wrote:
> Hello,
>
> Sorry for the strangely-worded question title.  I've been searching
> around for a few days here on the CakePHP doc book, CakePHP group, and
> around the Internet but I haven't been able to find a tip on how to do
> this.
>
> I have a MySQL database with these tables (names are simplified):
>
> + school_classes
>  id
>  grade_from
>  grade_to
>
> + grade_levels
>  id
>  short_name
>
> So basically I have a table that contains information for different
> school-related classes.  And I have another table that has a list of
> grade levels that are available to choose when editing (or viewing in
> this case,) school classes.
>
> For example:
>
> school_classes
> id: 1
> grade_from: 1
> grade_to: 3
>
> grade_levels
> id: 1
> short_name: K
>
> id: 2
> short_name: 1
>
> id: 3
> short_name: 2
>
> would mean that I have a school class with a grade-level range of
> Kindergarten (K) to Second Grade (2).
>
> I know what type of MySQL query I am looking for... I am just unclear
> about how to create the same behavior in CakePHP as far as my hasMany
> or belongsTo behaviors might go.
>
> Here is a query that shows what I'm trying to do here if that helps
> (ClassSession = school_classes from example above.  GradeLevel =
> grade_levels from example above):
>
> SELECT `ClassSession`.`id`, `ClassSession`.`title`,
> `ClassSession`.`session_date`, `ClassSession`.`description`,
> `ClassSession`.`speaker`, `ClassSession`.`grade_from`,
> `ClassSession`.`grade_to`, `ClassSession`.`room`,
> `ClassSession`.`time_block`, `ClassSession`.`owner`,
> `ClassSession`.`created_at`, `ClassSession`.`modified_at`,
> `Speaker`.`id`, `Speaker`.`first_name`, `Speaker`.`last_name`,
> `Speaker`.`mailing_address`, `Speaker`.`city`, `Speaker`.`state`,
> `Speaker`.`zip`, `Speaker`.`country`, `Speaker`.`email_address`,
> `Speaker`.`phone_number`, `Speaker`.`affiliation`, `Speaker`.`owner`,
> `Speaker`.`created_at`, `Speaker`.`modified_at`,
> `GradeLevelFrom`.`id`, `GradeLevelFrom`.`short_name`,
> `GradeLevelFrom`.`full_name`, `GradeLevelTo`.`id`,
> `GradeLevelTo`.`short_name`, `GradeLevelTo`.`full_name` FROM
> `class_sessions` AS `ClassSession` INNER JOIN `speakers` AS `Speaker`
> ON (`Speaker`.`id` = `ClassSession`.`speaker`) INNER JOIN
> `grade_levels` AS `GradeLevelFrom` ON (`GradeLevelFrom`.`id` =
> `ClassSession`.`grade_from`) INNER JOIN `grade_levels` AS
> `GradeLevelTo` ON (`GradeLevelTo`.`id` = `ClassSession`.`grade_to`)
> WHERE 1 = 1;
>
> The results look like this:
>
> | id | title          | session_date        |
> description                 | speaker | grade_from | grade_to |
> room     | time_block | owner | created_at          |
> modified_at         | id | first_name | last_name | mailing_address |
> city             | state    | zip   | country                  |
> email_address       | phone_number | affiliation     | owner |
> created_at | modified_at | id | short_name | full_name    | id |
> short_name | full_name    |
> +++-
> +-+-++--
> +--++---+-
> +-+++---+-
> +--+--+---+--
> +-+--+-+---
> ++-+++--+
> ++--+
> |  1 | First Session  | 2010-02-02 22:23:56 | This is the first
> session.  |       1 |          1 |        3 | Room 205 |       NULL
> |     1 | 2010-02-02 22:23:56 | 2010-02-02 22:23:56 |  1 | Speaker A
> | Smith     | 123 SW 1st      | Colorado Springs | Colorado | 80995 |
> United States of America | smi...@smitha.com   | 111-222- | A
> Middle School |     1 | NULL       | NULL        |  1 | K          |
> Kindergarten |  3 | 2          | Second Grade |
> |  2 | Second Session | 2010-02-02 22:23:56 | This is the second
> session. |       2 |          1 |        6 | Room 207 |       NULL
> |     1 | 2010-02-02 22:23:56 | 2010-02-02 22:23:56 |  2 | Speaker B
> | Tuttle    | 245 SE 3st      | Colorado Springs | Colorado | 80995 |
> United States of America | tutt...@tuttleb.com | 222-333- | B
> Middle School |     1 | NULL       | NULL        |  1 | K          |
> Kindergarten |  6 | 5          | Fifth Grade  |
>
> Is there any way I can do this natively in CakePHP?
> Any tips would be appreciated.
>
> Thanks,
> andy

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

Trouble Baking with MAMP

2010-02-03 Thread B_Fraser
I've spent a few hours on this so far and haven't had any luck. I've
read all the previous posts but still no joy.

When I attempt to bake I get:

Warning: mysql_connect(): Can't connect to local MySQL server through
socket '/var/mysql/mysql.sock' (2) in /Applications/MAMP/htdocs/cake/
acl_tutorial/cake/libs/model/datasources/dbo/dbo_mysql.php on line 454
etc...

The site connects properly to the database in a browser but has
trouble in the command line.

Following a previous post I checked and it does appear that my console
it using my systems built in php. When I type 'what php' I see it
point to: /usr/bin/php

I've tried the method of typing '/Applications/MAMP/tmp/mysql/
mysql.sock /tmp/mysql.sock' into the command line and have not had any
success.

Any help would be greatly appreciated!

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


Inner join querys: two fields from one table

2010-02-03 Thread andy
Hello,

Sorry for the strangely-worded question title.  I've been searching
around for a few days here on the CakePHP doc book, CakePHP group, and
around the Internet but I haven't been able to find a tip on how to do
this.

I have a MySQL database with these tables (names are simplified):

+ school_classes
 id
 grade_from
 grade_to

+ grade_levels
 id
 short_name


So basically I have a table that contains information for different
school-related classes.  And I have another table that has a list of
grade levels that are available to choose when editing (or viewing in
this case,) school classes.


For example:

school_classes
id: 1
grade_from: 1
grade_to: 3

grade_levels
id: 1
short_name: K

id: 2
short_name: 1

id: 3
short_name: 2


would mean that I have a school class with a grade-level range of
Kindergarten (K) to Second Grade (2).


I know what type of MySQL query I am looking for... I am just unclear
about how to create the same behavior in CakePHP as far as my hasMany
or belongsTo behaviors might go.



Here is a query that shows what I'm trying to do here if that helps
(ClassSession = school_classes from example above.  GradeLevel =
grade_levels from example above):

SELECT `ClassSession`.`id`, `ClassSession`.`title`,
`ClassSession`.`session_date`, `ClassSession`.`description`,
`ClassSession`.`speaker`, `ClassSession`.`grade_from`,
`ClassSession`.`grade_to`, `ClassSession`.`room`,
`ClassSession`.`time_block`, `ClassSession`.`owner`,
`ClassSession`.`created_at`, `ClassSession`.`modified_at`,
`Speaker`.`id`, `Speaker`.`first_name`, `Speaker`.`last_name`,
`Speaker`.`mailing_address`, `Speaker`.`city`, `Speaker`.`state`,
`Speaker`.`zip`, `Speaker`.`country`, `Speaker`.`email_address`,
`Speaker`.`phone_number`, `Speaker`.`affiliation`, `Speaker`.`owner`,
`Speaker`.`created_at`, `Speaker`.`modified_at`,
`GradeLevelFrom`.`id`, `GradeLevelFrom`.`short_name`,
`GradeLevelFrom`.`full_name`, `GradeLevelTo`.`id`,
`GradeLevelTo`.`short_name`, `GradeLevelTo`.`full_name` FROM
`class_sessions` AS `ClassSession` INNER JOIN `speakers` AS `Speaker`
ON (`Speaker`.`id` = `ClassSession`.`speaker`) INNER JOIN
`grade_levels` AS `GradeLevelFrom` ON (`GradeLevelFrom`.`id` =
`ClassSession`.`grade_from`) INNER JOIN `grade_levels` AS
`GradeLevelTo` ON (`GradeLevelTo`.`id` = `ClassSession`.`grade_to`)
WHERE 1 = 1;

The results look like this:

| id | title  | session_date|
description | speaker | grade_from | grade_to |
room | time_block | owner | created_at  |
modified_at | id | first_name | last_name | mailing_address |
city | state| zip   | country  |
email_address   | phone_number | affiliation | owner |
created_at | modified_at | id | short_name | full_name| id |
short_name | full_name|
+++-
+-+-++--
+--++---+-
+-+++---+-
+--+--+---+--
+-+--+-+---
++-+++--+
++--+
|  1 | First Session  | 2010-02-02 22:23:56 | This is the first
session.  |   1 |  1 |3 | Room 205 |   NULL
| 1 | 2010-02-02 22:23:56 | 2010-02-02 22:23:56 |  1 | Speaker A
| Smith | 123 SW 1st  | Colorado Springs | Colorado | 80995 |
United States of America | smi...@smitha.com   | 111-222- | A
Middle School | 1 | NULL   | NULL|  1 | K  |
Kindergarten |  3 | 2  | Second Grade |
|  2 | Second Session | 2010-02-02 22:23:56 | This is the second
session. |   2 |  1 |6 | Room 207 |   NULL
| 1 | 2010-02-02 22:23:56 | 2010-02-02 22:23:56 |  2 | Speaker B
| Tuttle| 245 SE 3st  | Colorado Springs | Colorado | 80995 |
United States of America | tutt...@tuttleb.com | 222-333- | B
Middle School | 1 | NULL   | NULL|  1 | K  |
Kindergarten |  6 | 5  | Fifth Grade  |




Is there any way I can do this natively in CakePHP?
Any tips would be appreciated.

Thanks,
andy

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


HABT many saveAll problem with multiple child records,

2010-02-03 Thread waseem gondal
hi,
I have scenario , where i want to save a meeting,  and meeting has
relation with topic habtm,
Tables: Meeting, Topic, MeetingsTopics
Meeting HABTM with Topic


this  sample data is working fine,

[Meeting] => Array
(
[date] => 2010-02-10
[Priority] => 1
)

[Topic] => Array
(
[id] => Array
(
[0] => 6
)

)

These below data is saving properly.
But it didn't save data when i have meeting ids more than one.

[Meeting] => Array
(
[date] => 2010-02-06
[name] => "test"
[Priority] => 1
)

[Topic] => Array
(
[id] => Array
(
[0] => 7
[1] => 14
[2] => 13
)

)

I am using saveAll($this->data) function to save that.

and how can i hand the scenario when i have to add new topic at
meetings view and automatically relate this current meeting

[Meeting] => Array
(
[date] =>
[Priority] => 1
)

[Topic] => Array
(
[id] => Array
(
[0] => 16
)

[name] => adsfasdfasdfasdfas
)

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


ACOs on aspects of controller actions

2010-02-03 Thread Chris
Hi there everyone. Newbie CakePHP individual here. This framework has
really taught me the concepts of MVC, moreso than Drupal ever did,
anyway.

I have a question regarding the ACL component: I understand that the
component restricts access of a requester object to a control object
based on controller/action.  Is it possible to restrict it one level
further, controller/action/[SomePermission]? Exampe: Suppose I want to
have a users controller with editable data, accessible by user/[id]/
edit or something similar, but suppose I want some people to only edit
their own profile, and others to be able to edit anyone's profile.
Would I create another ACO for those two options (permission to edit
one's own profile or anyone's profile) or, would I just restrict
general access to controller actions using the Auth component, and
then restrict which rows a user has access to in the controller
itself?

This question is more or less one of row-level permissions and how to
restrict users from accessing one row versus another.  I've reasoned
in my head that row-level permissions are children of controller/
action permissions, but am I looking at things wrong? Any suggestions
would be greatly appreciated.

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


Does Cakephp support distributed database?

2010-02-03 Thread Arthas
Hi Guys

I am working on a project with distributed database (5000 users per
each).
Can Cakephp support such system?

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


Re: Plugin using different Dynamic Database Connection

2010-02-03 Thread Miles J
>From an architecture standpoint, storing credentials in a database is
a pretty bad idea.

On Feb 3, 1:08 pm, Bryan De Asis  wrote:
> Sorry Zaky can you elaborate it more... what do you mean by create a view in
> the database that select from the other database?
>
> Thanks
>
> On Wed, Feb 3, 2010 at 3:45 PM, Zaky Katalan-Ezra wrote:
>
> > Create a view in the database that select from the other database.
> > This way you need only one connection.
>
> > On Tue, Feb 2, 2010 at 7:58 PM, Bryan De Asis wrote:
>
> >> Co'z I'm creating a database table which contains the database connection
> >> credentials so i can have thousands hundreds of config... so i can manage
> >> other news articles table databases using same plugin...
>
> >> On Tue, Feb 2, 2010 at 12:51 PM, Miles J  wrote:
>
> >>> Why aren't you just placing the config in database.php?
>
> >>> On Feb 2, 8:48 am, bryan de asis  wrote:
> >>> > Hello,
>
> >>> > Has anyone here tried to create a plugin which connects to a
> >>> > difference database dynamically?
> >>> > My Plugin name is "News"
> >>> > I have tried adding this lines on beforeFilter on my
> >>> > ArticlesController:
> >>> >         $db =& ConnectionManager::getDataSource('default');
> >>> >         $db->disconnect();
> >>> >                 $db->config['host'] = 'localhost';
> >>> >                 $db->config['login'] = 'login';
> >>> >                 $db->config['password'] = 'password';
> >>> >                 $db->config['database'] = 'database_name';
> >>> >         $db->connect();
> >>> > and it doesn't work... it still doesnt work.
>
> >>> > anyone have any idea...
>
> >>> 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 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 at
> >>http://groups.google.com/group/cake-php?hl=en
>
> > --
> > Regards,
> > Zaky Katalan-Ezra
> > QA Administrator
> >www.IGeneriX.com
> > Sites.IGeneriX.com
> > 054-7762312
>
> > 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 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: Plugin using different Dynamic Database Connection

2010-02-03 Thread Bryan De Asis
Sorry Zaky can you elaborate it more... what do you mean by create a view in
the database that select from the other database?

Thanks

On Wed, Feb 3, 2010 at 3:45 PM, Zaky Katalan-Ezra wrote:

> Create a view in the database that select from the other database.
> This way you need only one connection.
>
> On Tue, Feb 2, 2010 at 7:58 PM, Bryan De Asis wrote:
>
>> Co'z I'm creating a database table which contains the database connection
>> credentials so i can have thousands hundreds of config... so i can manage
>> other news articles table databases using same plugin...
>>
>>
>>
>>
>> On Tue, Feb 2, 2010 at 12:51 PM, Miles J  wrote:
>>
>>> Why aren't you just placing the config in database.php?
>>>
>>> On Feb 2, 8:48 am, bryan de asis  wrote:
>>> > Hello,
>>> >
>>> > Has anyone here tried to create a plugin which connects to a
>>> > difference database dynamically?
>>> > My Plugin name is "News"
>>> > I have tried adding this lines on beforeFilter on my
>>> > ArticlesController:
>>> > $db =& ConnectionManager::getDataSource('default');
>>> > $db->disconnect();
>>> > $db->config['host'] = 'localhost';
>>> > $db->config['login'] = 'login';
>>> > $db->config['password'] = 'password';
>>> > $db->config['database'] = 'database_name';
>>> > $db->connect();
>>> > and it doesn't work... it still doesnt work.
>>> >
>>> > anyone have any idea...
>>>
>>> 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
>>
>
>
>
> --
> Regards,
> Zaky Katalan-Ezra
> QA Administrator
> www.IGeneriX.com
> Sites.IGeneriX.com
> 054-7762312
>
> 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: How to correct: double file-extension when i download something (media view)

2010-02-03 Thread John Andersen
The basename function returns the filename with the suffix! Try to
change your code to:

[code]
   $basename = basename($file);
   $file_extension = substr(strrchr($basename,"."),1);
   $basename = basename($file, '.'.$file_extension);
...
   $this->set('extension', strtolower($file_extension));
[/code]

The first basename() usage gets the full filename, including the
suffix.
The second basename() usage removes the suffix from the filename.
Hope this helps you on the way,
   John

On Feb 3, 9:34 am, sebb86  wrote:
> Hello,
> i almost solved my problem, but there is still a little fault. In one
> of my views i readout a database cell, with a text inside, e.g. 13.pdf
> (13.pdf = document_name).
>
> The little fault is, when i click on the text in the column (e.g.
> 13.pdf) a download-windows opens and the file i download is called
> "13.pdf.pdf". :(
> So what is wrong there?
>
> Source-code in my view to invoke the download-method in the
> controller:
> {{{
> link($document['Document']['document_name'],
> array('action'=>'download', $document['Document']['id'])); ?>
>
> }}}
>
> Source of my download-function in my documents_controller:
> {{{
> function download($id = null)
>   {
>     $this->view = 'Media';
>         $this->autoLayout = false;
>
>                 $this->Document->recursive = -1;
>                 $document = $this->Document->read(null, $id);
>
>     if (empty($document))
>     {
>                   $this->redirect('/', 404, true);
>         }
>
>     $file = $document['Document']['document_name'];
>     $basename = basename($file);
>     $file_extension = strtolower(substr(strrchr($basename,"."),1));
>
>     $this->set('id', $document['Document']['document_name']);
>     $this->set('name', $basename);
>         $this->set('download', true);
>     $this->set('extension', $file_extension);
>         $this->set('path',APP.'files'.DS);
>         
>
> The files are stored in cake -> app -> files.
>
> Thanks if someone can 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: Plugin using different Dynamic Database Connection

2010-02-03 Thread Zaky Katalan-Ezra
Create a view in the database that select from the other database.
This way you need only one connection.

On Tue, Feb 2, 2010 at 7:58 PM, Bryan De Asis  wrote:

> Co'z I'm creating a database table which contains the database connection
> credentials so i can have thousands hundreds of config... so i can manage
> other news articles table databases using same plugin...
>
>
>
>
> On Tue, Feb 2, 2010 at 12:51 PM, Miles J  wrote:
>
>> Why aren't you just placing the config in database.php?
>>
>> On Feb 2, 8:48 am, bryan de asis  wrote:
>> > Hello,
>> >
>> > Has anyone here tried to create a plugin which connects to a
>> > difference database dynamically?
>> > My Plugin name is "News"
>> > I have tried adding this lines on beforeFilter on my
>> > ArticlesController:
>> > $db =& ConnectionManager::getDataSource('default');
>> > $db->disconnect();
>> > $db->config['host'] = 'localhost';
>> > $db->config['login'] = 'login';
>> > $db->config['password'] = 'password';
>> > $db->config['database'] = 'database_name';
>> > $db->connect();
>> > and it doesn't work... it still doesnt work.
>> >
>> > anyone have any idea...
>>
>> 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
>



-- 
Regards,
Zaky Katalan-Ezra
QA Administrator
www.IGeneriX.com
Sites.IGeneriX.com
054-7762312

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: help for installing cakephp in a linux public_html directory!!!

2010-02-03 Thread Daniel S. Reichenbach

Hi,


hi, i need help for installing cakephp in a linux's public_html
directory exactly fedora 12, i put cakephp in that directory but it
seems that the mod_rewrite doesnt work and i dont know how to enable
it for public_html but it works very well in /var/www/html and i
configured the console too .

you will have to check the Apache2 configuration. In Fedora Apache is
configured to disallow configuration changes such as mod_rewrite does
in user directories.

You will need to tweak the mod_userdir configurations settings for
AllowOverride.

WkR,
Daniel

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: Cake 1.3-beta: cake schema doesn't accept the run param

2010-02-03 Thread Daniel S. Reichenbach

Hi,


When using cake console, 'cake schema run create DbAcl' throws the
default cake schema help but if i use 'cake schema create DbAcl' i was
prompted to create acos, aros and aros_acos tables.

is this the expected  behavior?

as stated in the Migration guide[1] this is indeed intended behavior.

It's one of the tiny but appreciated changes in 1.3

[1] http://cakephp.lighthouseapp.com/projects/42648/13-migration-guide


WkR,
Daniel

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: checking whether a table exists

2010-02-03 Thread Miles J
Yes straight SQL, as schema files are only really usable in the
shell.

On Feb 3, 2:06 am, Lorenzo Bettini  wrote:
> Yes, I finally did that, and switch to the UpdatesController when the
> tables are in place.
>
> I noted that you use sql directly, and not schema files generated by
> cake console, don't you?
>
> cheers
>         Lorenzo
>
>
>
> Miles J wrote:
> > I had to do the same thing for my plugin. Simply dont use Models.
>
> >http://github.com/milesj/forum/blob/master/controllers/install_contro...
>
> > On Feb 1, 11:39 pm, Lorenzo Bettini  wrote:
> >> Hi
>
> >> I'm trying to build an installation procedure for my site based on
> >> cakephp; thus I have an updates table where information concerning
> >> version updates are stored.  However, I need to bootstrap this procedure
> >> so the first thing the installation script does is to check whether the
> >> database exists and the updates table exists (and is not empty): in such
> >> case it's a brand new installation.  So I put some of this logic in the
> >> UpdatesController but I have the problem that the model Update cannot
> >> find the table.
>
> >> Now, what I did, is to create an InstallsController with $uses=null so
> >> that I can perform these bootstrap checks from there.  This should be
> >> fine, shouldn't it?
>
> >> thanks
> >>         Lorenzo
>
> >> Miles J wrote:
> >>> Yes like Nabil said, most models should be related to a table. If you
> >>> are trying to figure out if a table exists, then you shouldn't have a
> >>> model.
> >>> Can you explain your situation a bit more?
> >>> On Feb 1, 11:16 am, Nabil Alsharif  wrote:
>  Controllers expect to have a model which in turn expects to have a table
>  in the DB by default. If you have a controller that doesn't use a model
>  set $uses to 'null' or an empty array... if you have a model that
>  doesn't have a datasource then look at $useTable and $schema variables
>  inhttp://api.cakephp.org/class/model
>  On Mon, 2010-02-01 at 19:29 +0100, Lorenzo Bettini wrote:
> > The problem I have with my solution, but I guess it's the same of the
> > one of the link, is that if I use it inside a controller, I get an error
> > before even reaching that code, due to a missing table... is there a way
> > to avoid this?
> > Of course I need this check for an installation page, which I'm
> > developing using a controller...
> > thanks in advance
> >    Lorenzo
> > Miles J wrote:
> >> You can try this, then see if your table exists within the array.
> >>http://www.milesj.me/blog/read/75/Retrieving-Tables-Within-Your-Cake-...
> >> On Feb 1, 8:27 am, Lorenzo Bettini  wrote:
> >>> Hi
> >>> is this a correct way of checking whether a table exists?
> >>>         function check_table_exists($table) {
> >>>                 $dbo = $this->getDataSource();
> >>>                 $result = $dbo->_execute('DESCRIBE '.$table);
> >>>                 return !empty($result);
> >>>         }
> >>> thanks in advance
> >>>         Lorenzo
>
> --
> Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
> HOME:http://www.lorenzobettini.itMUSIC:http://www.purplesucker.com
> BLOGS:http://tronprog.blogspot.com http://longlivemusic.blogspot.com

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: Tree Behavior does not work with multiple parents?

2010-02-03 Thread Jon Bennett
hi ShereWeb,

> I am somewhet a newbie to CakePHP. I am trying to migrate my website
> from own framework to CakePHP. Everything is wonderful until i got to
> tree behavior issue for categories. I will explain a little bit what i
> am trying to achieve:
>
> I have many categories that can have multiple parent categories
> ie. Travel Websites category has two parents:
>
> Business » Travel » Travel Websites
> AND
> Internet » Websites » Travel Websites

I don't think this is possible within a MPTT tree structure, which is
what the Tree behaviour creates. You would need 2 sets of lft and rgt
values for a branch that had 2 parents.

hth

J

-- 
jon bennett - www.jben.net - blog.jben.net

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


Tree Behavior does not work with multiple parents?

2010-02-03 Thread sphereweb
Hello,

I am somewhet a newbie to CakePHP. I am trying to migrate my website
from own framework to CakePHP. Everything is wonderful until i got to
tree behavior issue for categories. I will explain a little bit what i
am trying to achieve:

I have many categories that can have multiple parent categories
ie. Travel Websites category has two parents:

Business » Travel » Travel Websites
AND
Internet » Websites » Travel Websites

DATA MODEL:

Categories
  id, category_id

Categories_Categories
 id, parent_id, category_id

I have looked in CakePHP's book at the Tree Behavior chapter. I saw
that a node (category) can have only 1 parent node (category). This
behavior seems not to work with multiple parent nodes. Anyone is able
to give me some hints if there is a work around for my issue with tree
behavior?

I have thought about this for past few days and I am stuck. Any help
is greatly appreciated! Thanks in advance for your time!

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: HABTM view: how to retrieve data in extra column?

2010-02-03 Thread John Andersen
Do a foreach loop on the $staff['Room'] array in the table cell!
Enjoy,
   John

On Feb 3, 9:24 am, sebb86  wrote:
> Hello,
> in my database, there is a HABTM association between model "rooms" and
> "staffs".
> In my index-view of "staffs", when i retrieve the data, i'd like to
> have an extra column for each datarow with all rooms, which belongs to
> the current staff(id).
> The join table contains "room_id" and "staff_id" and is called
> "rooms_staffs".
>
> **table staff: controller:**
> {{{
> function index()
>         {
>                 $this->set('staffs', $this->paginate('Staff'));
>         
>
> **table staff: part of the view:**
> {{{
> 
>         
>           
>           
>           
>           
>           
>           at this place, i need all description fields from the
> matching rooms
>         
>         
>
> }}}
>
> debug($staffs) result in index-view of staff:
> {{{
> Array
> (
>     [0] => Array
>         (
>             [Staff] => Array
>                 (
>                     [id] => 3
>                     [forename] => Patrick
>                     [surname] => Hartung
>                     [telephon_number] => 0124144214
>                     [e_mail] => ba...@taptap.de
>                     [full_name] => 3 (Hartung)
>                 )
>
>             [Room] => Array
>                 (
>                     [0] => Array
>                         (
>                             [id] => 1
>                             [location_id] => 1
>                             [description] => Serverraum
>                         )
>
>                     [1] => Array
>                         (
>                             [id] => 3
>                             [location_id] => 2
>                             [description] => Buero
>                         )
>                 )
>         )
>
> }}}
>
> When i try:    echo $staff['Room']['0']['description'];    i can get
> the first datarow. but how can i get all in my new column?
>
> I've read in the book but i really don't know how to code this :(
> Thanks a lot if someone can 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: how to validate two unique fields together?

2010-02-03 Thread BrendonKoz
I'm not sure I understand the problem directly, so I'll just try to
give an example of how you can use the model class' custom validation
methods to handle a validation of two fields at the same time.

>From the book, check out how to manage custom validations (http://
book.cakephp.org/view/152/Adding-your-own-Validation-Methods), then
look over the code below.

function oneOfTwoNotEmpty($fieldValue, $fieldNameToCompare){
if(!empty($fieldValue)){
return true;
}else{
if(!empty($this->data[$this->name][$fieldNameToCompare])){
return true;
}
}
return false;
}

This code comes directly from a plugin model class I am working on at
the moment, and is used in validation. In this code, really the only
pertinent part for you to see is the function call:
function functionName ($value_of_field_we_are_validating,
$field_name_1, $field_name_2, [etc...]) {
Since you mentioned "two unique fields", you should only need to pass
2 arguments, the current field's value, and the name of the 2nd field
you want to compare (or validate) it with.
The important part within this method that would be helpful to you
would be:
$this->data[$this->name][$fieldNameToCompare]
This line would contain the value of the 2nd field passed to my
method.

Therefore... I'd set this validation on the building_id field, and...
function checkBuildingRoomExists($building_id, $room_field){
if(empty($building_id) || empty($room_field)){
return false;
}
$room_id = $this->data[$this->name][$room_field];
//continue your own checking here with $room_id and $building_id...
//[...code...]
}

Hopefully this will help you get started on your way.  Again, be sure
to read the validation section in the book - both the "Multiple
Validation per Field" and the linked section.

On Feb 3, 2:47 am, sebb86  wrote:
> Hello,
> my table **rooms** contains three fields: //id//, //building_id//
> and //room//.
>
> //Building_id// and //room// have to be UNIQUE together, because room
> 9 is in building 1 only one time but room 9 can also conained in
> building 2.
> The //building_id// in the view is realized as a drop-down field. So i
> can only choose buildings, which already exists. Now i want to check
> the existence of the "room"-value, which i type in a form, with the
> actual //building_id//.
>
> How can i solve this problem?
>
> I retrieve my data the following way (view:)
> {{{
> 
>         
>         
>      ( ['Building']['description']; ?>)
>     
>         
>         
>
> }}}
>
> Thanks ver much if someone can help.
> Greetings :)

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: Find help for $this->set(compact())

2010-02-03 Thread Jeremy Burns
It's actually a php function: http://php.net/manual/en/function.compact.php

Jeremy Burns
jeremybu...@me.com

On 3 Feb 2010, at 16:16, McScreech wrote:

> Hello,
> 
> Where do I find the definition or explanation of '$this->set(compact
> ())' in the Cookbook or API?
> 
> Thanx, DaveT.
> 
> 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


Find help for $this->set(compact())

2010-02-03 Thread McScreech
Hello,

Where do I find the definition or explanation of '$this->set(compact
())' in the Cookbook or API?

Thanx, DaveT.

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: Bypassing validation

2010-02-03 Thread Craig Francis
Hopefully a slightly better method... I've created a custom AppModel
that ensures that every field listed in the 'fieldList' during save
(whitelist) has all of its rules set to 'required'... and it will also
complain if the 'fieldList' isn't provided to the save() method.

whitelist as $cField) {

if (!isset($this->validate[$cField])) {


//--
// There is no validation for this field

continue;

} else if (is_string($this->validate[$cField])) 
{


//--
// Simple string validation:
//
//   var $validate = array(
//   'field' => 'notempty'
//   );
//

//--

$rule = 
$this->validate[$cField];

$this->validate[$cField] = 
array(
$rule => array(

'rule' => $rule,

'required' => true,
),
);

} else if 
(isset($this->validate[$cField]['rule'])) {


//--
// Array for a single rule validation:
//
//  var $validate = array(
//  'notEmpty' => array(
//  'rule' => 'notEmpty',
//  'message' => 'Your 
email address is required.',
//  ),
//  );
//

//--


$this->validate[$cField]['required'] = true;

} else if (is_array($this->validate[$cField])) {

foreach ($this->validate[$cField] as 
$cRuleName => $cRuleValue) {

if (is_array($cRuleValue) && 
isset($cRuleValue['rule'])) {


//--
// Array of rules 
validation:
//
//  var $validate = 
array(
//  'email' => 
array(
//  
'notEmpty' => array(
//  
'rule' => 'notEmpty',
//  
'message' => 'Your email address is
required.',
//  ),
//  ),
//  );
//

//--


$this->validate[$cField][$cRuleName]['required'] = true;

} else if 
(is_string($cRuleValue)) {


//--
// Simple array 
validation:
//
//   var $validate = 
array(
//   'field' => 
array('notempty')
//   );
//

Re: how to validate two unique fields together?

2010-02-03 Thread matzeh...@googlemail.com
take a look at:
http://www.mail-archive.com/cake-php@googlegroups.com/msg33243.html

they discussed the Problem an found a nice solution!

On 3 Feb., 08:47, sebb86  wrote:
> Hello,
> my table **rooms** contains three fields: //id//, //building_id//
> and //room//.
>
> //Building_id// and //room// have to be UNIQUE together, because room
> 9 is in building 1 only one time but room 9 can also conained in
> building 2.
> The //building_id// in the view is realized as a drop-down field. So i
> can only choose buildings, which already exists. Now i want to check
> the existence of the "room"-value, which i type in a form, with the
> actual //building_id//.
>
> How can i solve this problem?
>
> I retrieve my data the following way (view:)
> {{{
> 
>         
>         
>      ( ['Building']['description']; ?>)
>     
>         
>         
>
> }}}
>
> Thanks ver much if someone can help.
> Greetings :)

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


CakePHP CakeSchema question

2010-02-03 Thread Дмитрий Николаев
Hi! If there any manual or article on how use CakeShema? I'm
interested in using models & using bare sql in before() and after()
methods.

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: logins worked, now they fail

2010-02-03 Thread BrendonKoz
I don't have time at the moment to look through all of that (though I
do appreciate your thoroughness).  The first thing I would recommend
is try disabling all of your redirects from your related (user?)
controller's methods.  By doing so, you should once again be able to
see the SQL debug output which may give you an idea of where you would
need to look.

Alternatively, Mark Story's debug_kit plugin should let you see SQL
queries from previous requests.

On Feb 2, 4:28 pm, cricket  wrote:
> The site I'm working on had authentication working fine (it was one of
> the first things I set up). but suddenly I find that they no longer
> work. Auth isn't showing me anything helpful, and there are no SQL
> queries displayed (debug => 2), just the usual DESCRIBEs.
>
> Passwords were created using Security::hash($cleartext, null, true)
> but, as I said, these were fine before.
>
> I'm completely at a loss as to what's changed as I've been working on
> all public stuff and haven't been logged into the site for awhile now.
> Can anyone think of anything to check? I'm baffled.
>
> AppController:
>
> public $components = array('Auth', 'Session', 'Cookie',
> 'RequestHandler');
>
> public function beforeFilter()
> {
>         parent::beforeFilter();
>
>         $this->Auth->fields = array(
>                 'username' => 'email',
>                 'password' => 'password'
>         );
>         $this->Auth->loginAction = array(
>                 'controller' => 'users',
>                 'action' => 'login',
>                 'language' => $this->Session->read('Config.language')
>         );
>
>         $this->Auth->loginRedirect = array(
>                 'controller' => 'posts',
>                 'action' => 'index'
>         );
>         $this->Auth->logoutRedirect = array(
>                 'controller' => 'posts',
>                 'action' => 'index'
>         );
>
>         $admin = Configure::read('Routing.admin');
>
>         if (isset($this->params[$admin]) && $this->params[$admin])
>         {
>                 $this->layout = 'admin';
>         }
>
> }
>
> UserController:
>
> function beforeFilter()
> {
>         parent::beforeFilter();
>         $this->Auth->allowedActions = array('add', 'forgot_password',
> 'view');
>
> }
>
> public function login()
> {
>         //debug($this->Auth);
>
> }
>
> If I uncomment the line above, I see:
>
> [loginError] => Login failed. Invalid username or password.
> [authError] => You are not authorized to access that location.
>
> mysql> describe users;
> +---+--+--+-+-
> ++
> | Field         | Type             | Null | Key | Default |
> Extra          |
> +---+--+--+-+-
> ++
> | id            | int(10) unsigned | NO   | PRI | NULL    |
> auto_increment |
> | created       | datetime         | YES  |     | NULL
> |                |
> | modified      | datetime         | YES  |     | NULL
> |                |
> | last_login_ts | datetime         | YES  |     | NULL
> |                |
> | admin         | tinyint(1)       | YES  |     | 0
> |                |
> | enabled       | tinyint(1)       | YES  |     | 0
> |                |
> | email         | varchar(64)      | NO   | UNI | NULL
> |                |
> | password      | char(40)         | YES  |     | NULL
> |                |
> | name          | varchar(64)      | YES  |     | NULL
> |                |
> | bio           | text             | YES  |     | NULL
> |                |
> | display_email | tinyint(1)       | YES  |     | 0
> |                |
> +---+--+--+-+-
> ++

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: getClientIP ?? strange format...

2010-02-03 Thread BrendonKoz
That would only solve his testing methods here.  If his host supports
IPv6, it's still possible for him to get those values under his
production site from visitors.  It's best to account for both.

On Feb 2, 11:24 am, Andras Kende  wrote:
> Tomas,
>
> You could try disable IPV6:  
>
> System preferences -> Network -> Ethernet -> Advanced -> Configure IPV6 = Off
>
> Also comment out the IPV6 addresses in /etc/hosts file
>
> Or try to access that site not byhttp://localhostbut by ip 
> likehttp://192.168.1.101
>
> Andras
>
> On Feb 2, 2010, at 3:18 AM, toka...@gmail.com wrote:
>
>
>
> > Hi,
>
> > anybody know why cake or PHP native method is returning IP in this
> > strange format??
>
> > getClientIP()   fe80::222:41ff:fe2e:b64b
>
> > $_SERVER['REMOTE_ADDR']   fe80::222:41ff:fe2e:b64b
>
> > PS: I am running apache on MacOS Leopard using XAMPP.
>
> > Many thanks
> > Tomas
>
> > 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- Hide quoted text -
>
> - Show quoted text -

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: Weird problem with form that doesn't use model

2010-02-03 Thread BrendonKoz
If you want to validate the data input from that form, you'd still
need to create a model class (and schema variable).  You won't have to
create a database table, but it might still be helpful to you to
create the model class itself.

On Jan 31, 5:33 am, Jules  wrote:
> Bingo! It's a beautiful thing. Thanks Miles J.
>
> On Jan 31, 9:27 pm, Miles J  wrote:
>
>
>
> > Try null instead of false, see if that works.
>
> > On Jan 30, 8:02 pm, Jules  wrote:
>
> > > Hi everyone, I'm experiencing extreme frustration with this problem!
> > > Luckily, it's easy to reproduce.
>
> > > In any controller, create this method;
>
> > > function test() {
> > >        debug($this->data);
>
> > > }
>
> > > Then create a corresponding view called 'test';
>
> > >  > > echo $form->create(false,array('action'=>'test'));
> > > echo $form->input('address');
> > > echo $form->end('Submit');
> > > ?>
>
> > > You'll note that the form is created WITHOUT a model.
>
> > > When I enter something into the field, however, the page returns with
> > > ONLY THE FIRST character populated in the field! E.g., if I enter '123
> > > smith st', when it reloads it only say '1'.
>
> > > Examining $this->data, I can see that the whole string is being
> > > passed. Can anyone help?
>
> > > P.S. there's a good reason I'm not using the model.- Hide quoted text -
>
> - Show quoted text -

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: Error after adding database.php file to project (happening on Windows and Ubuntu)

2010-02-03 Thread BrendonKoz
You probably could have found that particular error out had you
checked the Apache error logs.  I would suggest checking both
CakePHP's error logs (app/tmp/logs/error.log), as well as your
server's error logs to determine what could be the cause.

If there are no errors on your Linux server, verify that mod_rewrite
is enabled for that particular domain/folder hierarchy.


On Jan 30, 6:34 am, Lucas Loss  wrote:
> First of all: Thank you guys for the responses! I really appreciate! :)
>
> The problem is now fixed (on Windows)!
>
> The problem was I installed PHP using a windows installer and when asked to
> install the extensions I never installed them. So, in order to PHP connect
> to MySQL it needs the mysql extension.
>
> I was able to find this out when, without using cake, I was trying to make
> PHP connect to mysql. When trying that, there was no errors, just a blank
> screen, but I knew it was not able to connect. So, after installing the
> php-mysql extension, I was able to connect and cake was able to access the
> database.
>
> I was really a stupid mistake but I believed it was a CakePHP problem
> because of that page that, when not able to connect o mysql, was loosing all
> it styles.
>
> And I'm sorry for the delay on writing this reply to you guys. I really
> appreciate the help! :)
>
> Unfortunatelly I'm not able to make this work on Linux (Ubuntu). I have the
> mysql extension installed but PHP is not able to connect to the database.
> But this is not a CakePHP problem. I'm going to search a little more about
> this problem.
>
> Thanks again! I really appreciate all the help! :)
>
> On Fri, Jan 22, 2010 at 5:59 AM, Fran Iglesias wrote:
>
>
>
> > Hi
>
> > El 21/01/2010, a las 23:44, Lucas Loss escribió:
>
> >  4. Then I've renamed the file database.php.default to database.php;
> >> 5. Back to the browser I reloaded the page and noticed a new sentence:
>
> > I miss a step between these. Have you configured your database connection
> > in database.php? And, by the way, is a database server up and running?
>
> >  see a print of the page onhttp://yfrog.com/jp125afterdatabasep;
>
> > Have you read the error message in the top? It looks that you need to set
> > the right permissions in the tmp folder so Apache can write.
>
> > Please, read the manual on installation, I think the answers are all there.
>
> > 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 at
> >http://groups.google.com/group/cake-php?hl=en
>
>
>
>  database125.php
> 4KViewDownload
>
>  database130.php
> 4KViewDownload- Hide quoted text -
>
> - Show quoted text -

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


Cake 1.3-beta: cake schema doesn't accept the run param

2010-02-03 Thread Luigi Castro Cardeles
Hi,

i am using cake 1.3.0-beta from git (git clone 
git://github.com/cakephp/cakephp1x.git
and git checkout 1.3.0-beta).

When using cake console, 'cake schema run create DbAcl' throws the
default cake schema help but if i use 'cake schema create DbAcl' i was
prompted to create acos, aros and aros_acos tables.

is this the expected  behavior?

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


Re: Advanced Install

2010-02-03 Thread Massimiliano Bertinetti
I think the best solution is to have app1 app2 and so on in the root
(same level of cake...) instead.

Max-B

Il giorno mar, 02/02/2010 alle 18.37 -0330, Dave ha scritto:
> I am trying to set up multiple apps using 1 cake so i have currently:
> public_html/
>   dev/
>   libs/
>   cake1.2.6/
>   site1/
>   /app
>   site2/
>   /app
> 
> Webroot index.php (site1)
> 
> if (!defined('ROOT')) { 
>   define('ROOT', DS.'dev'.DS.'site1'); 
>   }
> 
> if (!defined('APP_DIR')) { 
>   define('APP_DIR', 'app'); 
>   }
> 
> if (!defined('CAKE_CORE_INCLUDE_PATH')) { 
>   
> define('CAKE_CORE_INCLUDE_PATH',DS.'dev'.DS.'lib'.DS.'cake1.2.6'); 
>   }
> 
> 
> Results in 
> Warning: include(cake/bootstrap.php) [function.include]: failed to open
> stream: No such file or directory in
> /home/duee8441/public_html/dev/site1/app/webroot/index.php on line 93
> 
> Fatal error: CakePHP core could not be found. Check the value of
> CAKE_CORE_INCLUDE_PATH in APP/webroot/index.php. It should point to the
> directory containing your /cake core directory and your /vendors root
> directory. in /home/duee8441/public_html/dev/site1/app/webroot/index.php on
> line 94
> 
> Ideas where I went wrong? 
>   
> 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: Advanced Install

2010-02-03 Thread Providence
This should be:

define('CAKE_CORE_INCLUDE_PATH',DS.'dev'.DS.'lib');

On Feb 3, 6:07 am, "Dave"  wrote:
> I am trying to set up multiple apps using 1 cake so i have currently:
> public_html/
>                 dev/
>                         libs/
>                                 cake1.2.6/
>                         site1/
>                                 /app
>                         site2/
>                                 /app
>
> Webroot index.php (site1)
>
> if (!defined('ROOT')) {
>                 define('ROOT', DS.'dev'.DS.'site1');
>         }
>
> if (!defined('APP_DIR')) {
>                 define('APP_DIR', 'app');
>         }
>
> if (!defined('CAKE_CORE_INCLUDE_PATH')) {
>
> define('CAKE_CORE_INCLUDE_PATH',DS.'dev'.DS.'lib'.DS.'cake1.2.6');
>         }
>
> Results in
> Warning: include(cake/bootstrap.php) [function.include]: failed to open
> stream: No such file or directory in
> /home/duee8441/public_html/dev/site1/app/webroot/index.php on line 93
>
> Fatal error: CakePHP core could not be found. Check the value of
> CAKE_CORE_INCLUDE_PATH in APP/webroot/index.php. It should point to the
> directory containing your /cake core directory and your /vendors root
> directory. in /home/duee8441/public_html/dev/site1/app/webroot/index.php on
> line 94
>
> Ideas where I went wrong?                      
>
> 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


retrieve related model data (combination $hasOne and $belongsTo)

2010-02-03 Thread sebb86
Hello,
I'd like to show the following things in my view (respectively in the
field uplink_id in the view): attribute "uplink_id" from table "ports"
with attribute "schenker_number" from table "hardware_units".
My problem are the associations, respectively i don't know the source
code to retrieve the information i want.

Fields:
- "id" (table "ports" = primary-key)
- "hardware_unit_id" (table "ports", = foreign-key associated with
"id" from table "hardware_units")
- "id" (table "hardware_units" = primary-key)
- "uplink_id" (table "ports" = foreign-key associated with "id" from
table "ports")

Example with values:
- "id" (table "ports") has value 4
- "hardware_unit_id" has value 2 ---> "id" (table "hardware_units")
has also value 2
- "uplink_id" has value 1 (points to the "id" (table "ports" with
value 1)

So when i do this:
{{{
echo $port['HardwareUnit']['schenker_number'];
}}}
, i get the "schenker_number" from the hardware_unit, which is
associated with the port ("id" = 4) BUT i need the "schenker_number"
which matches with the "hardware_unit_id" from the port with "id"
value 1 because of the "uplink_id" (value 1).

**Model:**
{{{
class Port extends AppModel
{
  var $name= 'Port';

  public $belongsTo = array(
'HardwareUnit' => array(
'className'  => 'HardwareUnit'
 )
   );

   var $hasOne = array(
'PortUplink' => array(
'className' => 'Port',
'foreignKey' => 'uplink_id'
)
   );
}}}

**Controller:**
{{{
class PortsController extends AppController
{
var $name = 'Ports';
function index()
{
$this->set('ports', $this->Port->find('all'));
}
}}}

**View:**
{{{


}}}

Please don't hesitate to ask if i expressed myself unclearly.
Thanks if someone can help.
Greetings. :)

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 validate two unique fields together?

2010-02-03 Thread sebb86
Hello,
my table **rooms** contains three fields: //id//, //building_id//
and //room//.

//Building_id// and //room// have to be UNIQUE together, because room
9 is in building 1 only one time but room 9 can also conained in
building 2.
The //building_id// in the view is realized as a drop-down field. So i
can only choose buildings, which already exists. Now i want to check
the existence of the "room"-value, which i type in a form, with the
actual //building_id//.

How can i solve this problem?

I retrieve my data the following way (view:)
{{{



 ()



}}}

Thanks ver much if someone can help.
Greetings :)

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 correct: double file-extension when i download something (media view)

2010-02-03 Thread sebb86
Hello,
i almost solved my problem, but there is still a little fault. In one
of my views i readout a database cell, with a text inside, e.g. 13.pdf
(13.pdf = document_name).

The little fault is, when i click on the text in the column (e.g.
13.pdf) a download-windows opens and the file i download is called
"13.pdf.pdf". :(
So what is wrong there?


Source-code in my view to invoke the download-method in the
controller:
{{{
link($document['Document']['document_name'],
array('action'=>'download', $document['Document']['id'])); ?>
}}}

Source of my download-function in my documents_controller:
{{{
function download($id = null)
  {
$this->view = 'Media';
$this->autoLayout = false;

$this->Document->recursive = -1;
$document = $this->Document->read(null, $id);

if (empty($document))
{
  $this->redirect('/', 404, true);
}

$file = $document['Document']['document_name'];
$basename = basename($file);
$file_extension = strtolower(substr(strrchr($basename,"."),1));

$this->set('id', $document['Document']['document_name']);
$this->set('name', $basename);
$this->set('download', true);
$this->set('extension', $file_extension);
$this->set('path',APP.'files'.DS);
}
}}}
The files are stored in cake -> app -> files.

Thanks if someone can 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


HABTM view: how to retrieve data in extra column?

2010-02-03 Thread sebb86
Hello,
in my database, there is a HABTM association between model "rooms" and
"staffs".
In my index-view of "staffs", when i retrieve the data, i'd like to
have an extra column for each datarow with all rooms, which belongs to
the current staff(id).
The join table contains "room_id" and "staff_id" and is called
"rooms_staffs".

**table staff: controller:**
{{{
function index()
{
$this->set('staffs', $this->paginate('Staff'));
}
}}}
**table staff: part of the view:**
{{{


  
  
  
  
  
  at this place, i need all description fields from the
matching rooms


}}}

debug($staffs) result in index-view of staff:
{{{
Array
(
[0] => Array
(
[Staff] => Array
(
[id] => 3
[forename] => Patrick
[surname] => Hartung
[telephon_number] => 0124144214
[e_mail] => ba...@taptap.de
[full_name] => 3 (Hartung)
)

[Room] => Array
(
[0] => Array
(
[id] => 1
[location_id] => 1
[description] => Serverraum
)

[1] => Array
(
[id] => 3
[location_id] => 2
[description] => Buero
)
)
)
}}}

When i try:echo $staff['Room']['0']['description'];i can get
the first datarow. but how can i get all in my new column?

I've read in the book but i really don't know how to code this :(
Thanks a lot if someone can 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


Issues with Searchable Behavior and PHP 4.x.x

2010-02-03 Thread Mayank Singhal
Hi,
I am trying to use Searchable Behaviour hosted here:
http://code.google.com/p/searchable-behaviour-for-cakephp/
To initialize the search_index table with existing data, I have used this:
http://code.google.com/p/searchable-behaviour-for-cakephp/issues/detail?id=1&q=controllerReply
No. 2 which creates the class SearchController.

The code was working fine on my local test server which runs PHP5.
However, the server has PHP 4 and when I tried the code on server it gives
this error:
*Fatal error*: Cannot redeclare class searchcontroller in *
LONG_PATH/cake/app/models/behaviors/searchable.php* on line *2***

Does it really has to do something with the PHP version or have I done some
logical mistake?

Regards and Thanks
-Mayank Singhal

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: Error in define HABTM relation with 'joinTable' and with 'with'

2010-02-03 Thread marco.rizze...@gmail.com
I think that the use of 'with' and 'joinTable' attributes is excatly
for tha case where models tables don't respect the cake convention
otherwise these attributes aren't useful

On 3 Feb, 15:23, Lorenzo Bettini  wrote:
> I'm not sure, but it looks like the problem is due to the table name
> which is in Italian, thus, it does not respect the conventions of
> cakephp; have you got a model for GroupsUser as well?  I mean a real
> class for that model?  In that case, you need to make sure that that
> class has the right name for the used table.
>
> I guess.
>
> cheers
>         Lorenzo
>
>
>
> marco.rizze...@gmail.com wrote:
> > Is there someone that can help me about this?
>
> > On 2 Feb, 19:02, "marco.rizze...@gmail.com" 
> > wrote:
> >> Hi
> >> I'm working on a legacy system , i must to defina an HABTM relation
> >> between User and Group. In User model I have this:
>
> >>         var $hasAndBelongsToMany=array(
> >>                 'Group' =>array(
> >>                         'className'    => 'Group',
> >>                         'joinTable'    => 'utenti_gruppi',
> >>                         'with' => 'GroupsUser',
> >>                         'foreignKey'   => 'username',
> >>                         'associationForeignKey'=> 'gruppo_id',
> >>                         'order'        => 'gruppo_nome ASC'
> >>                 )
> >>         );
>
> >> But I get this error:
>
> >> Error:  Database table groups_users for model GroupsUser was not
> >> found.
>
> >> Is it not possible define a HABTM relation with 'with' and with
> >> 'joinTable' that I want?
>
> --
> Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
> HOME:http://www.lorenzobettini.itMUSIC:http://www.purplesucker.com
> BLOGS:http://tronprog.blogspot.com http://longlivemusic.blogspot.com

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: Error in define HABTM relation with 'joinTable' and with 'with'

2010-02-03 Thread Lorenzo Bettini
I'm not sure, but it looks like the problem is due to the table name 
which is in Italian, thus, it does not respect the conventions of 
cakephp; have you got a model for GroupsUser as well?  I mean a real 
class for that model?  In that case, you need to make sure that that 
class has the right name for the used table.


I guess.

cheers
Lorenzo

marco.rizze...@gmail.com wrote:

Is there someone that can help me about this?

On 2 Feb, 19:02, "marco.rizze...@gmail.com" 
wrote:

Hi
I'm working on a legacy system , i must to defina an HABTM relation
between User and Group. In User model I have this:

var $hasAndBelongsToMany=array(
'Group' =>array(
'className'=> 'Group',
'joinTable'=> 'utenti_gruppi',
'with' => 'GroupsUser',
'foreignKey'   => 'username',
'associationForeignKey'=> 'gruppo_id',
'order'=> 'gruppo_nome ASC'
)
);

But I get this error:

Error:  Database table groups_users for model GroupsUser was not
found.

Is it not possible define a HABTM relation with 'with' and with
'joinTable' that I want?




--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
BLOGS: http://tronprog.blogspot.com  http://longlivemusic.blogspot.com

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


help for installing cakephp in a linux public_html directory!!!

2010-02-03 Thread cherif_Gsoul
hi, i need help for installing cakephp in a linux's public_html
directory exactly fedora 12, i put cakephp in that directory but it
seems that the mod_rewrite doesnt work and i dont know how to enable
it for public_html but it works very well in /var/www/html and i
configured the console too .

Tkx.

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: Advanced Install

2010-02-03 Thread AD7six


On Feb 2, 11:07 pm, "Dave"  wrote:
> I am trying to set up multiple apps using 1 cake so i have currently:
> public_html/
>                 dev/
>                         libs/
>                                 cake1.2.6/
>                         site1/
>                                 /app
>                         site2/
>                                 /app
>
> Webroot index.php (site1)
>
> if (!defined('ROOT')) {
>                 define('ROOT', DS.'dev'.DS.'site1');

You're defining an absolute path to something that doesn't exist. you
probably meant '/var/www//dev/site1'

However I'd suggest using a file structure as described here:
http://github.com/AD7six/mi_install/blob/master/README.markdown

which is also described in the book.

since it means you don't need to change anything in your index.php. If
you don't want to modify your include path server wide just symlink
apps/cake to cakes/.../cake

hth,

AD

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: Advanced Install

2010-02-03 Thread John Andersen
Do you have a cake directory under cake1.2.6?
If not, then rename the cake1.2.6 directory to cake and use:
define('CAKE_CORE_INCLUDE_PATH',DS.'dev'.DS.'lib');

I have this directory setup:
/cake
/app1
/app2
/app3

and I use the following in the /appx/webroot/index.php to define the
constants:
...
   define('ROOT', dirname(dirname(dirname(__FILE__;
...
   define('APP_DIR', basename(dirname(dirname(__FILE__;
...
   define('CAKE_CORE_INCLUDE_PATH', ROOT);

Hope this helps you with your definitions :)
   John


On Feb 3, 12:07 am, "Dave"  wrote:
> I am trying to set up multiple apps using 1 cake so i have currently:
> public_html/
>                 dev/
>                         libs/
>                                 cake1.2.6/
>                         site1/
>                                 /app
>                         site2/
>                                 /app
>
> Webroot index.php (site1)
>
> if (!defined('ROOT')) {
>                 define('ROOT', DS.'dev'.DS.'site1');
>         }
>
> if (!defined('APP_DIR')) {
>                 define('APP_DIR', 'app');
>         }
>
> if (!defined('CAKE_CORE_INCLUDE_PATH')) {
>
> define('CAKE_CORE_INCLUDE_PATH',DS.'dev'.DS.'lib'.DS.'cake1.2.6');
>         }
>
> Results in
> Warning: include(cake/bootstrap.php) [function.include]: failed to open
> stream: No such file or directory in
> /home/duee8441/public_html/dev/site1/app/webroot/index.php on line 93
>
> Fatal error: CakePHP core could not be found. Check the value of
> CAKE_CORE_INCLUDE_PATH in APP/webroot/index.php. It should point to the
> directory containing your /cake core directory and your /vendors root
> directory. in /home/duee8441/public_html/dev/site1/app/webroot/index.php on
> line 94
>
> Ideas where I went wrong?                      
>
> 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: Problem with relations when recursive > 1

2010-02-03 Thread John Andersen
As far as I can understand from your tables, and your own statement:

> Tuotteet hasOne Tekstit which hasMany Kaannokset.

then the following associations should be defined:
1) Tuotteet hasOne Tekstit
This means that Tekstit has a field named tuotteet_id if you follow
the CakePHP conventions.
But looking at your class Tuotteet, I assume that you want the id of
both tables to be equal, so your hasOne association should be defined
as:
[code]
   var $hasOne = array(
   'Tekstit' => array(
   'className' => 'Tekstit',
   'foreignKey' => false,
   'conditions' => 'Tekstit.id = Tuotteet.id'
   )
   );
[/code]

2) Tekstit hasMany Kaannokset
This means that Kaannokset has a field name tekstit_id, thus your
class Kaannokset should define the belongsTo association as:
[code]
   var $belongsTo = array(
   'Tekstit' => array(
   'className' => 'Tekstit',
   'foreignKey' => 'tekstit_id',
   )
   );
[/code]

Hope this helps you on the way,
   John

On Feb 2, 6:37 pm, doze  wrote:
> Hello!
>
> I have following database tables and relations:
>
> |---|               |-|
> ||
> | Tuotteet  |               | Tekstit  |                 | Kaannokset
> |
> |---|               |-|
> ||
> | teksti_id  | hasOne  | id          |  hasMany | teksti_id      |
> |           |               |         |
> |                |
> |           |               |         |
> |                |
> |---|               |-|
> ||
>
> Eg.
>
> Tuotteet hasOne Tekstit which hasMany Kaannokset.
>
> Here's the models:
>
>  class Tuotteet extends AppModel {
>     var $name = 'Tuotteet';
>     var $useTable = 'tuotteet';
>     var $hasOne = array(
>         'Tekstit' => array(
>             'className' => 'Tekstit',
>             'foreignKey' => false,
>             'conditions' => 'Tekstit.id = Tuotteet.teksti_id'
>         )
>     );}
>
> ?>
>
>  class Tekstit extends AppModel {
>     var $name = 'Tekstit';
>     var $useTable = 'tekstit';
>     var $hasMany = array(
>         'Kaannokset' => array(
>             'className' => 'Kaannokset',
>             'foreignKey' => 'teksti_id',
>             'dependent' => true
>         )
>     );}
>
> ?>
>
>  class Kaannokset extends AppModel {
>     var $name = 'Kaannokset';
>     var $useTable = 'kaannokset';
>     var $belongsTo = array(
>         'Tekstit' => array(
>             'className' => 'Tekstit',
>             'foreignKey' => 'id',
>         )
>     );}
>
> ?>
>
> And the current situation and problem...
>
> I'm trying to query all "Tuotteet" and get all "Kaannokset" for it.
>
> Here's the controller code:
>
>  class TuotteetController extends AppController {
>
>     var $name = 'Tuotteet';
>
>     function index() {
>         $this->Tuotteet->recursive = 1;
>         $this->set('tuotteet', $this->paginate());
>     }
>
> }
>
> ?>
>
> If $this->Tuotteet->recursive is set to 1, everything works and it
> returns:
>
> Array
> (
>     [Tuotteet] => Array
>         (
>             [id] => 1
>             [tuotenro] => 133
>             [teksti_id] => 2
>             [kuva] => /img/data/tuotteet/Water lilies.jpg
>         )
>
>     [Tekstit] => Array
>         (
>             [id] => 2
>             [teksti] => Kuvasarja 5 x 5 x 5
>         )
> )
>
> But to get also all "Kaannokset" for that "Tekstit" record, I set
> $this->Tuotteet->recursive to 2.
>
> That leads to following errors:
>
> Warning (2): Invalid argument supplied for foreach() [CORE/cake/libs/
> model/datasources/dbo_source.php, line 1229]
>
> Warning (512): SQL Error: 1054: Unknown column 'Tuotteet.teksti_id' in
> 'where clause' [CORE/cake/libs/model/datasources/dbo_source.php, line
> 635]
>
> Query: SELECT `Tekstit`.`id`, `Tekstit`.`teksti` FROM `tekstit` AS
> `Tekstit` WHERE `Tekstit`.`id` = `Tuotteet`.`teksti_id`
>
> Why?
>
> And how should this be done??

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: Error in define HABTM relation with 'joinTable' and with 'with'

2010-02-03 Thread marco.rizze...@gmail.com
Is there someone that can help me about this?

On 2 Feb, 19:02, "marco.rizze...@gmail.com" 
wrote:
> Hi
> I'm working on a legacy system , i must to defina an HABTM relation
> between User and Group. In User model I have this:
>
>         var $hasAndBelongsToMany=array(
>                 'Group' =>array(
>                         'className'    => 'Group',
>                         'joinTable'    => 'utenti_gruppi',
>                         'with' => 'GroupsUser',
>                         'foreignKey'   => 'username',
>                         'associationForeignKey'=> 'gruppo_id',
>                         'order'        => 'gruppo_nome ASC'
>                 )
>         );
>
> But I get this error:
>
> Error:  Database table groups_users for model GroupsUser was not
> found.
>
> Is it not possible define a HABTM relation with 'with' and with
> 'joinTable' that I want?
> Many 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


Re: Associated Pagination

2010-02-03 Thread John Andersen
You probably need to add this to your view, so that any parameters in
the URL is passed on to the paginator in the view.

[code]
$paginator->options(array('url' => $this->passedArgs));
[/code]

See http://book.cakephp.org/view/166/Pagination-in-Views for the
pagination setup in the view.
Enjoy,
   John

On Feb 2, 9:01 pm, Changoso  wrote:
> I modified the view so it looks something more lke the manual...
>
> 
> 
>         
>                          $i = 0;
>                 foreach ($data as $interest):
>         ?>
>         
>                         
>                                         echo 
> $html->link($html->image('photos/'.$interest['Photo']
> ['foto'], array('align'=>'middle', 'height'=>'50%')), array
> ('controller'=>'photos', 'action' => 'view', $interest['Photo']
> ['id']), array('escape' => false));
>
>                          ?>
>         
>         = 1){
>                 echo "";
>                 $i = -1;
>         }?>
>         
>         
> 
> 
>
> Now it kind of works... it does only show me 2 or 3 or 5 (The limit I
> set on the controller) the problem now is that when I press Next>> I
> get a INvalid Gallery...
[snip]

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: Related lists, polymorphic habtm? (fao: AD7six ;))

2010-02-03 Thread Jon Bennett
Hi AD,

>> I think what I want is a habtm that can connect to multiple models
>> with some additional fields in the join table, but I'm not sure that's
>> feasible, but hope it is.
>
> a join table with more than 2 fields is a model, and a model that can
> link to anything is (as you know) polymorphic.
>
> Therefore you want a join table something like this:
>
> relations
>  id
>  model
>  foreign_id
>  url
>  title
>  related_model
>  related_foreign_id
>  related_url
>  related_title
>
> which would allow you to relate anything to anything. I wouldn't use
> the polymorphic behavior though. just create a method for returning
> you related stuff - unless you denormalize as hinted above so you
> don't even need to.
>
> class Relation extends AppModel {
>  function related($model, $id) {
>  $return = array();
>  $data = $this->find('all', array('conditions' => array(
>   'OR' => array(
>     array('model' => $model, 'foreign_id' => $id),
>     array('related_model' => $model, 'related_foreign_id' => $id),
>   )
>  );
>  }
>  .. efficiently loop and get data if at all necessary
>  return $return;
> }

Ahh, ok - thanks. Will have a play then hit you back if I come unstuck.

Cheers,

jb


-- 
jon bennett - www.jben.net - blog.jben.net

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: save default values when $this->data['field'] is empty

2010-02-03 Thread matzeh...@googlemail.com
Thanks Jeremy,

the best way to solve a problem is to explain to an other person :)
2 min after i wrote it I found following solution:

foreach($this->data['mode'] as $v=> $val){
if(empty($val)) unset($this->data['model'][$v]);
}

Then cake or better say MySql takes the default value
Thanks



On 3 Feb., 11:18, Jeremy Burns  wrote:
> You could either add a hidden text field to the form or set 
> $this->data['model']['field'] to the value in the controller before you do a 
> save.
>
> Jeremy Burns
> jeremybu...@me.com
> (Skype) +44 208 123 3822 (jeremy_burns)
> (m) +44 7973 481949
> (h) +44 208 530 7573
>
> On 3 Feb 2010, at 10:16, matzeh...@googlemail.com wrote:
>
> > Hi,
>
> > what would you do if you want to save a default value and don´t want
> > to predefine a input field?
> > I tried with a custom validation rule but the return of it is true/
> > false not the corrected value.
> > Is the best way to do this in an function in the controller?
>
> > Greetings
>
> > 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: save default values when $this->data['field'] is empty

2010-02-03 Thread Jeremy Burns
You could either add a hidden text field to the form or set 
$this->data['model']['field'] to the value in the controller before you do a 
save.

Jeremy Burns
jeremybu...@me.com
(Skype) +44 208 123 3822 (jeremy_burns)
(m) +44 7973 481949
(h) +44 208 530 7573

On 3 Feb 2010, at 10:16, matzeh...@googlemail.com wrote:

> Hi,
> 
> what would you do if you want to save a default value and don´t want
> to predefine a input field?
> I tried with a custom validation rule but the return of it is true/
> false not the corrected value.
> Is the best way to do this in an function in the controller?
> 
> Greetings
> 
> 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


save default values when $this->data['field'] is empty

2010-02-03 Thread matzeh...@googlemail.com
Hi,

what would you do if you want to save a default value and don´t want
to predefine a input field?
I tried with a custom validation rule but the return of it is true/
false not the corrected value.
Is the best way to do this in an function in the controller?

Greetings

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: checking whether a table exists

2010-02-03 Thread Lorenzo Bettini
Yes, I finally did that, and switch to the UpdatesController when the 
tables are in place.


I noted that you use sql directly, and not schema files generated by 
cake console, don't you?


cheers
Lorenzo

Miles J wrote:

I had to do the same thing for my plugin. Simply dont use Models.

http://github.com/milesj/forum/blob/master/controllers/install_controller.php

On Feb 1, 11:39 pm, Lorenzo Bettini  wrote:

Hi

I'm trying to build an installation procedure for my site based on
cakephp; thus I have an updates table where information concerning
version updates are stored.  However, I need to bootstrap this procedure
so the first thing the installation script does is to check whether the
database exists and the updates table exists (and is not empty): in such
case it's a brand new installation.  So I put some of this logic in the
UpdatesController but I have the problem that the model Update cannot
find the table.

Now, what I did, is to create an InstallsController with $uses=null so
that I can perform these bootstrap checks from there.  This should be
fine, shouldn't it?

thanks
Lorenzo



Miles J wrote:

Yes like Nabil said, most models should be related to a table. If you
are trying to figure out if a table exists, then you shouldn't have a
model.
Can you explain your situation a bit more?
On Feb 1, 11:16 am, Nabil Alsharif  wrote:

Controllers expect to have a model which in turn expects to have a table
in the DB by default. If you have a controller that doesn't use a model
set $uses to 'null' or an empty array... if you have a model that
doesn't have a datasource then look at $useTable and $schema variables
inhttp://api.cakephp.org/class/model
On Mon, 2010-02-01 at 19:29 +0100, Lorenzo Bettini wrote:

The problem I have with my solution, but I guess it's the same of the
one of the link, is that if I use it inside a controller, I get an error
before even reaching that code, due to a missing table... is there a way
to avoid this?
Of course I need this check for an installation page, which I'm
developing using a controller...
thanks in advance
   Lorenzo
Miles J wrote:

You can try this, then see if your table exists within the array.
http://www.milesj.me/blog/read/75/Retrieving-Tables-Within-Your-Cake-...
On Feb 1, 8:27 am, Lorenzo Bettini  wrote:

Hi
is this a correct way of checking whether a table exists?
function check_table_exists($table) {
$dbo = $this->getDataSource();
$result = $dbo->_execute('DESCRIBE '.$table);
return !empty($result);
}
thanks in advance
Lorenzo




--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
BLOGS: http://tronprog.blogspot.com  http://longlivemusic.blogspot.com

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 include an element in a view.

2010-02-03 Thread Pau
Hi.
I'm traying to display in a view a string asociated to a field value.

 ..  echo $varp ..

endforeach;

?>

I need to reuse this switch statement in other views. I create an
element with this code and store this file in the views/elements
folder.

renderElement('mycode');

 .
 ..  echo $varp ..

endforeach;

?>
If I use renderElement doesn´t work because the code is a Swicht
estatement and render the element for each bucle cicle.
I tryed a include('mycode.ctp') by I don´t know how to reach this
folder.

How is the best way to do this?

Thanks.
Pau.

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: Related lists, polymorphic habtm? (fao: AD7six ;))

2010-02-03 Thread AD7six


On Feb 3, 2:46 am, Jon Bennett  wrote:
> Hi bakers,
>
> Been mulling this over and haven't hit on the ideal solution yet, so
> thought I'd try and put it down to get some outside ideas.
>
> I'm trying to find a flexible way to associate a record in one table
> with many other records from other tables, but contained within a
> single list. Eg, say you're building a CMS and the home page has a
> large features 'carousel', or on a product page you want a 'if you
> like this you might like' list to point people into other areas of the
> site. An item in either of those could be a Page, Event, Article,
> Post, Product - basically any type of content in your system.
>
> I'm keen to avoid having a features and feature_items table, as
>
> General things I'm after are:
>
> - store this info in a single table (composite, I think) table
> - be able to override certain fields such as name on a per list item
> basis, or use the values from the linked data
> - be able to retrieve each list in a single set of data, allowing a
> custom order to be used
> - data should be retrievable using a standard find with contain
>
> I think what I want is a habtm that can connect to multiple models
> with some additional fields in the join table, but I'm not sure that's
> feasible, but hope it is.

a join table with more than 2 fields is a model, and a model that can
link to anything is (as you know) polymorphic.

Therefore you want a join table something like this:

relations
 id
 model
 foreign_id
 url
 title
 related_model
 related_foreign_id
 related_url
 related_title

which would allow you to relate anything to anything. I wouldn't use
the polymorphic behavior though. just create a method for returning
you related stuff - unless you denormalize as hinted above so you
don't even need to.

class Relation extends AppModel {
 function related($model, $id) {
  $return = array();
  $data = $this->find('all', array('conditions' => array(
   'OR' => array(
 array('model' => $model, 'foreign_id' => $id),
 array('related_model' => $model, 'related_foreign_id' => $id),
   )
  );
 }
 .. efficiently loop and get data if at all necessary
 return $return;
}

hth,

AD

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