Re: 'add' action and auto-setting model id

2009-06-29 Thread Adam Royle
Hi Vijay,

Have a look at the source of controller.php in constructClasses() and you will 
see what Ralph is experiencing. Line numbers are indicative of r8204 (current 
branch).

line 448:
$id = $this->passedArgs['0'];

line 452:
$this->loadModel($this->modelClass, $id);

Cheers,
Adam
  - Original Message - 
  From: Vijay Kumbhar 
  To: cake-php@googlegroups.com 
  Sent: Monday, June 29, 2009 11:03 PM
  Subject: Re: 'add' action and auto-setting model id


  Hello Raph,

  I think you are making a mistake that you are providing a id while adding a 
record.
  If you provide the id to the save method it fires the update query.

  For further explanation Can you please paste the code here?


  On Mon, Jun 29, 2009 at 5:44 PM, Raph  wrote:


I have weird (I think) problem. When I've added "add()" action to the
contoller, the id of coresponding model has been set automaticlly to
"add()" method parameter, and when I try to save data using that
action update instead of save is made.

This method singature looks like this:

public function add($someId).

Is it normal behavior? Do I have to manually call "create()" method in
my model if I want to save, not update data?





  -- 
  Thanks & Regards,
  Vijayk.
  Co-founder (www.weboniselab.com)

  "You Bring the Dreams, We'll Bring the Means"

  

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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: 'add' action and auto-setting model id

2009-06-29 Thread Adam Royle

Yes, whether it is right or not, that is the way cake behaves. You should 
always use Model::create() before saving a new record just in case.

For the extra paranoid, you can do this on your add() action:

$this->Model->create($this->data, false);
$this->Model->save();

The second parameter (false) means that if there is an id set in $this->data 
then it will be reset, so an insert will always occur.

Cheers,
Adam

- Original Message - 
From: "Raph" 
To: "CakePHP" 
Sent: Monday, June 29, 2009 10:14 PM
Subject: 'add' action and auto-setting model id


>
> I have weird (I think) problem. When I've added "add()" action to the
> contoller, the id of coresponding model has been set automaticlly to
> "add()" method parameter, and when I try to save data using that
> action update instead of save is made.
>
> This method singature looks like this:
>
> public function add($someId).
>
> Is it normal behavior? Do I have to manually call "create()" method in
> my model if I want to save, not update data?
> >
>
> 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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

2009-06-23 Thread Adam Royle

Each and every CakePHP app is like a hand-woven Persian rug - unique and 
each comes with its own beautiful imperfections.

I implore you to accept our flaws as part of our personality and embrace all 
that is CakePHP!

Cheers,
Adam

- Original Message - 
From: "Nate Brunette" 
To: "CakePHP" 
Sent: Tuesday, June 23, 2009 1:56 PM
Subject: Validation


>
> When I validate the cakephp.org pages, it comes back with html and css
> errors.  I was hoping to start developing with cakephp, but I don't
> think I will be able to if it creates validation errors like this.
> Any reason for this?
>
> >
>
> 


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



Re: n-categories URL routing

2009-06-23 Thread Adam Royle

You could do it on a few levels - really depends on your setup (and if you 
need dynamic subdomains, etc). But yes, using .htaccess (or inside 
httpd.ini) would be your fastest options.

Cheers,
Adam

- Original Message - 
From: 
To: "CakePHP" 
Sent: Tuesday, June 23, 2009 11:19 PM
Subject: Re: n-categories URL routing



one more question:) is it possible to route subdomains as well such
easy way? :)

let say that we rout ... subdomain.example.com to index of a
specific controller...

OR this is done in httpd.ini ??

Thanks
Tomas


On Jun 23, 2:26 pm, "toka...@gmail.com"  wrote:
> Hi Adam,
> thanks a lot, I did not realize that it is so easy... I have already
> try it and it is working. :)
> anyway good point with the whole path...
>
> Tomas
>
> On Jun 23, 12:45 pm, "Adam Royle"  wrote:
>
> > Setup a route like this:
>
> > Router::connect('/categories/*', array('controller' => 'categories',
> > 'action' => 'index'));
>
> > Then in your index() method of CategoriesController you can then check 
> > for
> > the additional params in $this->params...
>
> > This is not so dissimilar how Cake's PagesController works.
>
> > I do something like this, however I store the entire path (eg 
> > "slug1/slug2")
> > in the database, since you might have duplicate identifiers like so:
>
> > /categories/sony/video-cameras/
> > /categories/philips/video-cameras/
>
> > Cheers,
> > Adam
>
> > - Original Message -
> > From: 
> > To: "CakePHP" 
> > Sent: Tuesday, June 23, 2009 8:20 PM
> > Subject: n-categories URL routing
>
> > > Hi,
> > > I it possible to make such a URL routing in cake?
>
> > > subdomain.example.com/categories/category1/category2/category-n
>
> > > I am wondering whether is possible to specify an URL relatively for N-
> > > levels of nested sub-categories...
>
> > > imagine you have e.g. eshop with following structure:
>
> > > *Electronics
> > > *Computers
> > > Accesories
>
> > > So the following url would look like
> > > - Electronics/Computers/Accesories
>
> > > for accessing accesories I need only accesories slug or ID - and it
> > > already knows its parents in the tree representation. How can I
> > > relatively specify in router that everything in-between categories and
> > > category-n (**)
> > > is ignored?? or in other words, how to extract only the last items
> > > which is the identifier??
>
> > > myshop.example.com/categories/**/**/**/**/identifier-
> > > slug
>
> > > I have found very nice real example:
> > >http://www.mujmultimarket.cz/kategorie/elektronika/audio-video/audios...
>
> > > Thanks!! Tomas




--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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: n-categories URL routing

2009-06-23 Thread Adam Royle

Setup a route like this:

Router::connect('/categories/*', array('controller' => 'categories', 
'action' => 'index'));

Then in your index() method of CategoriesController you can then check for 
the additional params in $this->params...

This is not so dissimilar how Cake's PagesController works.

I do something like this, however I store the entire path (eg "slug1/slug2") 
in the database, since you might have duplicate identifiers like so:

/categories/sony/video-cameras/
/categories/philips/video-cameras/

Cheers,
Adam

- Original Message - 
From: 
To: "CakePHP" 
Sent: Tuesday, June 23, 2009 8:20 PM
Subject: n-categories URL routing


>
> Hi,
> I it possible to make such a URL routing in cake?
>
> subdomain.example.com/categories/category1/category2/category-n
>
> I am wondering whether is possible to specify an URL relatively for N-
> levels of nested sub-categories...
>
> imagine you have e.g. eshop with following structure:
>
> *Electronics
> *Computers
> Accesories
>
> So the following url would look like
> - Electronics/Computers/Accesories
>
> for accessing accesories I need only accesories slug or ID - and it
> already knows its parents in the tree representation. How can I
> relatively specify in router that everything in-between categories and
> category-n (**)
> is ignored?? or in other words, how to extract only the last items
> which is the identifier??
>
> myshop.example.com/categories/**/**/**/**/identifier-
> slug
>
>
> I have found very nice real example:
> http://www.mujmultimarket.cz/kategorie/elektronika/audio-video/audiosystemy/
>
>
> Thanks!! Tomas
> >
>
> 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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: transactions + redirect doesn't work!

2009-06-22 Thread Adam Royle

What I am saying is you can't redirect to another page in the same 
transaction. If you really need to do something over multiple page loads, 
then you should save this data in temporary tables or in the session, and 
then add it all to the real tables on the final page. Transactions are meant 
to be kept as short as possible.

Cheers,
Adam

- Original Message - 
From: "Mateo San Román" 
To: "CakePHP" 
Sent: Tuesday, June 23, 2009 7:02 AM
Subject: Re: transactions + redirect doesn't work!



Thank you for you quick answer.
Any way to do that operation in a standard way?

Thanks,
Mateo

On 22 jun, 00:45, "Adam Royle"  wrote:
> Yes. You must start and end atransactionwith the same mysql connection.
> MySQL connections are automatically closed once the page has finished
> executing. Aredirectstops the current page execution.
>
> Cheers,
> Adam
>
> - Original Message -
> From: "Mateo San Román" 
> To: "CakePHP" 
> Sent: Monday, June 22, 2009 2:49 PM
> Subject: transactions +redirectdoesn't work!
>
> > Hello
>
> > I have this code:
>
> > function A () {
> > $this->query('BEGINTRANSACTIONA');
> > xxx
> > xxx
> > $this->redirect('/controller/B);
> > }
>
> > function B () {
> > xxx
> > xxx
> > $this->query('COMMITTRANSACTIONA');
> > }
>
> > doesn't work because there is a missing "BEGINTRANSACTION"
>
> > However, if I use instead
>
> > $this->query('BEGINTRANSACTIONA');
> > xxx
> > xxx
> > $this->B();
> > }
>
> > It works somehow. Any ideas about this? Doesredirectautomatically
> > shuts down existingtransaction?
>
> > Thanks a lot




--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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: transactions + redirect doesn't work!

2009-06-21 Thread Adam Royle

Yes. You must start and end a transaction with the same mysql connection. 
MySQL connections are automatically closed once the page has finished 
executing. A redirect stops the current page execution.

Cheers,
Adam

- Original Message - 
From: "Mateo San Román" 
To: "CakePHP" 
Sent: Monday, June 22, 2009 2:49 PM
Subject: transactions + redirect doesn't work!


>
> Hello
>
> I have this code:
>
>
> function A () {
> $this->query('BEGIN TRANSACTION A');
>  xxx
>  xxx
>  $this->redirect('/controller/B);
> }
>
> function B () {
> xxx
> xxx
> $this->query('COMMIT TRANSACTION A');
> }
>
> doesn't work  because there is a missing "BEGIN TRANSACTION"
>
> However, if I use instead
>
> $this->query('BEGIN TRANSACTION A');
>  xxx
>  xxx
>  $this->B();
> }
>
> It works somehow. Any ideas about this? Does redirect automatically
> shuts down existing transaction?
>
> Thanks a lot
>
>
>
> >
>
> 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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: Dynamic use of MySQL views

2009-06-18 Thread Adam Royle

Does this work?

$this->Item->setSource($locationId.'_items');

Cheers,
Adam

On Jun 19, 12:43 pm, VisionIzoizo  wrote:
> Hi, I have one big table named 'items'. It's split into many views,
> according to a custom defined criteria (location). I want to access
> these views dynamically, I tried the 'useTable' property, but it
> doesn't work at all. This is my controller action:
>
>         function listLocation($locationId)
>         {
>                 $this->Item->useTable = $locationId.'_items';
>                 $this->Item->recursive = 0;
>                 $this->set('items', $this->paginate());
>         }
>
> My views are named according to the location Id, i.e. 1_items,
> 2_items, ...
>
> Is there any way to make this work?
>
> Thanks in advance.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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: Router Connect

2009-06-18 Thread Adam Royle

Look into admin routing in the cakephp cookbook.

Cheers,
Adam

On Jun 19, 12:44 pm, thatsgreat2345  wrote:
> I'm a little confused by routes at the moment. Currently I have an
> admin structure where each function such as
> function users($load = null, $id = null) {
>     $this->viewPath = 'admins/users';
>                 switch ($load) {
>                         Case 'add':
>
>                         $this->render('add');
>                         break;
>
> Changing the viewpath each time, and adding in the render is annoying.
> I'm curious if there is any way to fix this with routes, as the url
> would look like /admins/users/add/ but after searching can't seem to
> see how to do this.
>
> I was thinking that maybe I could create some sort of beforeFilter and
> have it do it then except I think routers would be a better fit.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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: Flash site With Cake Php

2009-06-18 Thread Adam Royle

Put this in app/views/users/xml/index.ctp

';
echo $xml->serialize($users, array('format' => 'tags'));
echo '';
?>

and put this in app/views/layouts/xml/default.ctp

header();
echo $content_for_layout;
?>

XML it doesn't show as XML in your browser if debug is set to 2,
because RequestHandler won't output the necessary headers. If that's
the case, add this in your AppController's beforeFilter() to override
this behaviour:

if (!empty($this->params['url']['ext']) && $this->params['url']['ext']
== 'xml' && Configure::read('debug') > 0) {
Configure::write('debug', 1);
}

And then it should all work!

Cheers,
Adam

On Jun 19, 4:43 am, taufiq ridha  wrote:
> Hello, nice to meet u all!!
> sorry for this stupid question, but i'm really new on this framework.
> i was try to search for this subject, but not find yet, so i decided
> to ask for all guru's here :)
>
> i want to build flash site, which cake php will provide xml for my
> flash,
>
> here's what i was done to get xml :
>
> Routes by adding :
> Router::parseExtensions();
>
> on the controller :
>
>  class UsersController extends AppController {
>
>         var $name = 'Users';
>         var $helpers = array('Html', 'Form');
>         var $components = array('RequestHandler');
>
>         function index() {
>                 $this->User->recursive = 0;
>                 $this->set('users', $this->paginate());
>         }}
>
> ?>
>
> finnaly here's code for my views on views/users/xml/index.ctp
>
>  echo $xml->serialize($users);
> ?>
>
> Now, when i pointing tohttp://localhost/example/users/index.xmli got
> very messy xml
>
>  username="taufiqridha" password="taufiq123"
> email="taufiq.ri...@gmail.com" name="Taufiq Ridha" birth="2009-06-17"
> sex="1" city="Jakarta" phone="2147483647" avatar_face_id="1"
> avatar_hair_id="1" avatar_top_id="1" avatar_bottom_id="1"
> avatar_shoe_id="1" avatar_acc1_id="1" avatar_acc2_id="1" shout="ini
> shout out 2" point="0" created="2009-06-17 01:05:50"
> modified="2009-06-17 01:32:07"> sex="1" path_image="http://taufiq-ridha.co.cc"; created="2009-06-14
> 20:14:27" modified="2009-06-14 20:14:27" /> name="Belah Tengah" sex="1" path_image="http://taufiq-ridha.co.cc";
> created="2009-06-14 20:15:31" modified="2009-06-14 20:15:31" /> id="1" name="Atasan Kurus" sex="1" path_image="http://
>
> taufiq-ridha.co.cc" created="2009-06-14 20:16:09" modified="2009-06-14
> 20:16:09" /> path_image="http://taufiq-ridha.co.cc"; created="2009-06-14 20:16:35"
> modified="2009-06-14 20:16:35" />http://taufiq-ridha.co.cc";
> created="2009-06-14 20:17:38" modified="2009-06-14 20:17:38" /> id="1" name="Gelang Punk" sex="1" path_image="http://
>
> taufiq-ridha.co.cc" created="2009-06-14 20:16:59" modified="2009-06-14
> 20:16:59" /> path_image="http://taufiq-ridha.co.cc"; created="2009-06-14 20:17:16"
> modified="2009-06-14 20:17:16" /> created="" modified="" /> user_id="1" created="2009-06-14 23:51:53" modified="2009-06-18
> 14:00:35" />
>
> did anyone know how to make this xml more friendly(costum) also with
> list view, just like :
>
> 
>    
>        taufiq ridha
>       1
>       2
>       /* and so on */
>    
> 
>
> thanks for advice guys, and sorry for this basic questions
>
> regards
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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: Webroot and prefix in Router::connect()

2009-06-17 Thread Adam Royle

I see from a previous email you overrode your AppHelper to automatically 
prepend "/fb" onto all of your links which is causing the prob. Short of 
re-writing your links everywhere, you could modify this method so absolute 
files are not prepended with "/fb".

Cheers,
Adam

- Original Message - 
From: "Greg Baker" 
To: "CakePHP" 
Sent: Thursday, June 18, 2009 10:51 AM
Subject: Webroot and prefix in Router::connect()


>
> I am working on my facebook app (you may have seen other messages here
> by me about this) and I have hit another small problem.
>
> Having set up my routing so that I may enter my app either via
> facebook or via a webpage I find that I cannot access files in the
> folders in my webroot in facebook.
>
> For example, some of my routes:
> Router::connect('/fb', array('controller'=>'pages',
> 'action'=>'display', 'facebook'=>true, 'canvas'));
> Router::connect('/fb/help', array('controller'=>'pages',
> 'action'=>'display',  'facebook'=>true, 'help'));
> Router::connect('/fb/:controller/:action/*', array
> ('facebook'=>true));
>
> Router::connect('/', array('controller'=>'pages',
> 'action'=>'display', 'canvas'));
> Router::connect('/help', array('controller'=>'pages',
> 'action'=>'display', 'help'));
>
> Now facebook hits my app using /fb/whatever.  This works so far for
> everything except for my .swf files which reside in my webroot/flash
> directory./
>
> If I go to /flash/flash.swf I get my file
> If I go to /fb/flash/flash.swf it looks for a FlashController.
>
> I am so close to getting this working just as I need it.  I think this
> will be my last snag.
> >
>
> 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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: Auth Problem using in Login Process

2009-06-17 Thread Adam Royle

A bit hard to diagnose without seeing any code... but is your form posting 
to the login action?

And also make sure cookies are enabled in your browser.

Cheers,
Adam


- Original Message - 
From: "uday" 
To: "CakePHP" 
Sent: Thursday, June 18, 2009 7:36 AM
Subject: Auth Problem using in Login Process


>
> Hi,
>
> I am using the Auth component for registration and login, registration
> is working perfectly, but login doesnt seem to be doing anything at
> all,
>
> I have Auth loaded in the AppController since I will be using it site
> wide, however when I try to log in I just return to the login page
> because the page it is supposed to redirect me to requires you to be
> logged in.
>
> The only message I get from auth is the message I set "Sorry you
> cannot access this page"
>
> my login.ctp is just a simple login form with a username and password
> field, and my Users controller has an empty login function at the
> moment.
>
> from what i've read everything should work, however it is not...
>
> am I missing something here? do I need to add code to the login
> function of the controller? or add anything to the user model?
>
> >
>
> 


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



Re: https

2009-06-17 Thread Adam Royle

There is no code you need to change to get ssl working with cakephp. Make 
sure you have ssl setup on the site correctly with just static files first.

Cheers,
Adam

- Original Message - 
From: "rakesh singh" 
To: "CakePHP" 
Sent: Wednesday, June 17, 2009 8:43 PM
Subject: https


>
> hican anyone explain me how to use https in cakephp as i m
> having a problem in my project
>
> >
>
> 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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: CakePHP XSS protection?

2009-06-17 Thread Adam Royle

Depends on if you will reuse the content in various places that do not 
accept html entities... although I use h() in my views, and if I need to 
strip unweildy html from large blocks of text I'll do it in a beforeSave 
callback - therefore it only does it once.

Cheers,
Adam
- Original Message - 
From: "Marcel" 
To: 
Sent: Wednesday, June 17, 2009 10:58 PM
Subject: Re: CakePHP XSS protection?


>
> Adam Royle wrote:
>> You need to handle this manually. Look at the Sanitize class for cake's
>> built-in methods.
>>
>> http://api.cakephp.org/class/sanitize
>>
>> If you don't need the user to enter any html at all, consider using the 
>> h()
>> method while outputting your data, which will convert any html tags to 
>> their
>> entities so they will no longer be interpreted by the browser as html.
>>
>> Cheers,
>> Adam
>
> Thanks!
> Should this also be used while saving data? Or only in the views?
>
> Marcel
>
> >
>
> 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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: CakePHP XSS protection?

2009-06-17 Thread Adam Royle

You need to handle this manually. Look at the Sanitize class for cake's 
built-in methods.

http://api.cakephp.org/class/sanitize

If you don't need the user to enter any html at all, consider using the h() 
method while outputting your data, which will convert any html tags to their 
entities so they will no longer be interpreted by the browser as html.

Cheers,
Adam

- Original Message - 
From: "Marcel" 
To: 
Sent: Wednesday, June 17, 2009 10:36 PM
Subject: CakePHP XSS protection?


>
> Hi,
>
> I'm using the save(), saveField() and saveAll() model methods to save
> userdata directly to the database.
> On some sites I've read that CakePHP does things against XSS, but when
> I'm trying to save the standard example xss string
>
> alert("XSS");
>
> to the database it's saved as it is. So the alert box is shown when e.g.
> I just do a findAll() and print it out on a table.
>
> Is there an easy way to solve this issue? Do I have to handle this in
> beforeSave? Or can it be done in $validate?
>
>
> Marcel
>
>
> >
>
> 


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



Re: Changing view file in controller

2009-06-17 Thread Adam Royle

Why certainly! In your AppController add this:

function beforeFilter() {
if (!empty($this->params['facebook'])) {
$this->viewPath = 'fbml';
}
}

And then you would have your fbml view in:

app/views/YourModel/fbml/index.ctp

and then you put your xhtml view in:

app/views/YourModel/index.ctp

Cheers,
Adam

- Original Message - 
From: "Greg Baker" 
To: "CakePHP" 
Sent: Wednesday, June 17, 2009 8:21 PM
Subject: Changing view file in controller


>
> Is it possible to change the view file easily in the AppController?
> Basically I want to check $this->params['facebook'] and if it exists I
> want the view to render to be, say fbindex.ctp instead of
> index.ctp...or fbadd.ctp instead of add.ctp.  I want to do this
> because the facebook pages contains fbml while the other pages contain
> xhtml.
>
> I know I can do this in every action in my controllers by using $this-
>>render('fbindex')but is there a more elegant solution?  Perhaps
> adding something to AppController::beforeRender() ?
> >
>
> 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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(?) Behavior question

2009-06-16 Thread Adam Royle

And both models had the behavior attached to them?

- Original Message - 
From: "Brendon Kozlowski (Realm)" 
To: "CakePHP" 
Sent: Wednesday, June 17, 2009 1:09 PM
Subject: Re: Advanced(?) Behavior question



That's what I was hoping too. Unfortunately that didn't seem to be the
case.

I did a users/posts/comments example site to test functionality.
User's email address was encrypted in the DB, and when viewing the
index page, it was decrypted (working for user model). Post's title
was encrypted (just a test) and I created a method "testDecrypt" in
the Post model...all it did was a find('all') with recursive set to 3.
I then pr()'d the result and used die() to stop operation. All post
titles were decrypted (they were encrypted in the database) but the
user emails showed up as encrypted.


On Jun 16, 9:24 pm, "Adam Royle"  wrote:
> I am fairly certain that each related model will take care of it's own
> beforeSave and afterFind callbacks, so you should just need to handle
> encryption/decryption for the primary model, and each other model that is
> saved/found will handle its own as well.
>
> Cheers,
> Adam
>
> - Original Message -
> From: "BrendonKoz" 
> To: "CakePHP" 
> Sent: Wednesday, June 17, 2009 6:55 AM
> Subject: Advanced(?) Behavior question
>
> > I've been writing an encryption/decryption behavior that will
> > automatically encrypt and decrypt model data on-the-fly, according to
> > settings defined for the behavior (per model) within the model.
>
> > I have it working for DEEP finds (set recursive to 5 just to test) on
> > all fields for the current model that should be decrypted within the
> > returned result array from afterFind.
>
> > My question is...(this would be an option)...if I wanted to decrypt
> > ALL fields for ALL models that utilize the encryption behavior
> > regardless of which model is requesting the data - what would be the
> > best way to approach this?
>
> > Within my behavior's code, I'm able to tell which model I'm currently
> > in (which fields in the non-primary query belong to which model), but
> > would I have to instantiate all found models (each time? - I hope not)
> > other than the current model in order to determine which fields are
> > supposed to be encrypted/decrypted? Although I took an example page
> > from the Cipher Behavior in having a prefix on the field data to
> > determine whether a field is encrypted or not, since it's something
> > that can be changed per database, I can't necessarily rely on it to be
> > the same for ALL fields within the resultant array from the find
> > query.
>
> > Any ideas?




--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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: MySQL function escape with multiple conditions

2009-06-16 Thread Adam Royle

If I am doing something like this I generally just create a string and pass 
it through. Make sure to encapsulate it in parenthesis () in case you have 
other conditions.

$event_conditions = array(
'(Event.start BETWEEN DATE_SUB(CURDATE(), INTERVAL 1 DAY) AND 
DATE_ADD(CURDATE(), INTERVAL 7 DAY))'
);

Cheers,
Adam


- Original Message - 
From: 
To: "CakePHP" 
Sent: Wednesday, June 17, 2009 8:19 AM
Subject: MySQL function escape with multiple conditions


>
> $event_conditions = array(
>   'Event.start'=>array('< -!DATE_ADD(CURDATE(), INTERVAL 7 DAY)', '>
> -!DATE_SUB(CURDATE(), INTERVAL 1 DAY)')
> );
>
> Cake is producing an IN() statement.
>
> I'm wondering how to use MySQL functions with more than one condition?
> >
>
> 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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: array extraction

2009-06-16 Thread Adam Royle

$this->set() doesn't return a value. so $transaction_amount_total will be 
null. Try something like this:

$data = $this->Jurisdiction->Transaction->find('all', array(
 'conditions' => array('Transaction.jurisdiction_id =' => $id),
 'fields' => array('Transaction.id','SUM(Transaction.amount) AS Amount'))
));

$transaction_amount_total = $data[0][0]['Amount'];

$this->set('transaction_amount_total, $transaction_amount_total);

Cheers,
Adam

- Original Message - 
From: 
To: "CakePHP" 
Sent: Wednesday, June 17, 2009 3:54 AM
Subject: Re: array extraction


>
> Hi Adam:
>  I tried it but it wouldn't work. Can anybody else help,
> please.
> the original array is an output from a calculated find('all') as in:
>
> $transaction_amount_total = $this->set('transaction_amount_total',
> $this->Jurisdiction->Transaction->find('all',array('conditions'=>array
> ('Transaction.jurisdiction_id ='=>$id),'fields' => array
> ('Transaction.id','SUM(Transaction.amount) AS Amount';
>
> I don't know if that has anything to do with why I can't any array PHP
> functions like remove(), array_chunk(), array_slice() etc to work.
>
>
> -sam
>
> On Jun 15, 5:32 pm, "Adam Royle"  wrote:
>> use this function, it works well...
>>
>> // recursively reduces deep arrays to single-dimensional arrays
>> // $preserve_keys: (0=>never, 1=>strings, 2=>always)
>> function array_flatten($array, $preserve_keys = 1, &$return = array()) {
>>  foreach ($array as $key => $child) {
>>   if (is_array($child)) {
>>$return =& array_flatten($child, $preserve_keys, $return);
>>   } elseif ($preserve_keys + is_string($key) > 1) {
>>$return[$key] = $child;
>>   } else {
>>$return[] = $child;
>>   }
>>  }
>>  return $return;
>>
>> }
>>   - Original Message -
>>   From: samuel darko
>>   To: cake-php@googlegroups.com
>>   Sent: Tuesday, June 16, 2009 1:16 AM
>>   Subject: array extraction
>>
>>   Hi guys:
>>   i need help trimming down this:
>>
>> Array(  [0] => Array(  [0] => Array   ( [Amount] => 
>> 72.64   ) ))
>>   TO this:
>>
>>  Array (  [Amount] => 72.64 )I tried the ff code but 
>> to no avail:function afterFind($results, $primary=false) { 
>> if($primary == true) {
>>if(Set::check($results, '0.0')) { 
>> $fieldName = key($results[0][0]);foreach($results as 
>> $key=>$value) { 
>> $results[$key][$this->alias][$fieldName] = $value[0][$fieldName];
>> 
>>unset($results[$key][0]);} 
>> }   }   return $results;} 
>> Thanks, in advance, for your help
>>   -sam
> >
>
> 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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: Organization issues and more...

2009-06-16 Thread Adam Royle

Wow. Sorry, I didn't read your entire email. But a few things..

1) Yes, generally you have just one table per model per controller.
2) A more flexible solution is to have your menu heirarchy to be separate 
from your controller/action heriarchy. This will allow you to separate your 
visual navigation from your controller structure. Design your database 
around the data that you'll be housing. That will then dictate the 
models/controllers to use. Then once you're happy with the structure, you 
can then create a menu that can point to any resource, and be structured how 
you want it. And if you change your mind about how the menu should be 
displayed, you shouldn't need to change your database/model/controller 
structure.

Cheers,
Adam

- Original Message - 
From: "Phil" 
To: "CakePHP" 
Sent: Wednesday, June 17, 2009 7:12 AM
Subject: Organization issues and more...



My questions aren't exactly about CakePHP, but more so around the MVC
architecture. I couldn't find my particular answer through searching,
but at least I discovered that this seems like an acceptable question
here.

I have a main menu. For each main menu item, there is a sub menu. To
me, it made more sense that the URL would be //
/, which would be /controller/action/. Because of this,
I created a controller for each main menu item, and created actions in
the appropriate controller for each sub menu item. My intents are for
the user to click the main menu item, and the first sub menu item will
be selected by default. As such, I used the index() for each
controller to be the first (default) sub menu item.

This is where I get confused though. The main menu item is simply for
organizational purpose. It is almost as if I shouldn’t even have a
controller for the main menu items, but rather, a controller for each
sub menu item. I guess I would have to split my current database table
up into multiple database tables, one for each controller (sub menu).
I guess that also means one model for each controller as well. Does
this make more sense?

I have further issues, which go a bit further off topic but my main
question is about MVC still. On each of these sub menu pages, the
information from the database for the authorized user is displayed for
the particular section they are on. I wanted to be able to edit this
information by clicking on the text displayed and having it turn into
a input box for editing. Then, when the user clicks away or presses
enter, it turns back into normal text, without the input box. I can do
this with Javascript just fine, but I don't know how this fits in with
MVC. I guess I would just put it in my view and use it how I would
without this framework, except input boxes will be created using the
form helper? I really think I would prefer this method of editing over
a separate edit page, but if you strongly disagree then constructive
criticism is accepted. However, I'm still not entirely sure when the
actual saving to the database should take place if I went about it
this way. I was thinking it could commit the changes every time the
text box turns back into normal text through AJAX, but depending on
how many fields are being edited, that could be putting an unnecessary
extra load on the server. I suppose it is a design decision I should
be asking myself rather than people who are reading this that don't
know any details of my project, but I am open for suggestions. The
point was that I wanted the page to almost always have a presentation
appearance and a bit more of an interactive feel to editing rather
than switching entirely to an editing view.

Congratulations to those of you who actually read everything. Thanks
in advance for any help or insight.





--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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(?) Behavior question

2009-06-16 Thread Adam Royle

I am fairly certain that each related model will take care of it's own 
beforeSave and afterFind callbacks, so you should just need to handle 
encryption/decryption for the primary model, and each other model that is 
saved/found will handle its own as well.

Cheers,
Adam

- Original Message - 
From: "BrendonKoz" 
To: "CakePHP" 
Sent: Wednesday, June 17, 2009 6:55 AM
Subject: Advanced(?) Behavior question


>
> I've been writing an encryption/decryption behavior that will
> automatically encrypt and decrypt model data on-the-fly, according to
> settings defined for the behavior (per model) within the model.
>
> I have it working for DEEP finds (set recursive to 5 just to test) on
> all fields for the current model that should be decrypted within the
> returned result array from afterFind.
>
> My question is...(this would be an option)...if I wanted to decrypt
> ALL fields for ALL models that utilize the encryption behavior
> regardless of which model is requesting the data - what would be the
> best way to approach this?
>
> Within my behavior's code, I'm able to tell which model I'm currently
> in (which fields in the non-primary query belong to which model), but
> would I have to instantiate all found models (each time? - I hope not)
> other than the current model in order to determine which fields are
> supposed to be encrypted/decrypted?  Although I took an example page
> from the Cipher Behavior in having a prefix on the field data to
> determine whether a field is encrypted or not, since it's something
> that can be changed per database, I can't necessarily rely on it to be
> the same for ALL fields within the resultant array from the find
> query.
>
> Any ideas?
> >
>
> 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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 Large Datasets

2009-06-16 Thread Adam Royle
It's possible to use a combination of cake's magic and raw sql together, which 
I use occasionally when I need something a bit out of the ordinary but still 
want to use the cake methods (to make use of model binding, etc).

eg.

function getHomepageArtists() {
$query = array(
'fields' => array('id', 'name', 'slug'),
'conditions' => 'Artist.id IN (SELECT artists_events.artist_id FROM 
artists_images INNER JOIN artists_events ON artists_events.artist_id = 
artists_images.artist_id)',
'contain' => array('Image'),
'order' => 'popularity, RAND()',
);
return $this->find('all', $query);
}


Hope that helps,
Adam

- Original Message - 
  From: Femi Taiwo 
  To: cake-php@googlegroups.com 
  Sent: Tuesday, June 16, 2009 8:32 PM
  Subject: Re: Problem with Large Datasets


  Thanks for replying.

  Actually, I've got everything properly indexed and closely followed standards 
on that. I honestly just wanted to avoid writing a custom query (lazy me). Was 
only hoping that there was a way to avoid custom queries. Will give that a try 
then.

  Thanks!

  Femi


  Adam Royle wrote: 
Hi Femi,

You should really just use one query for that with a number of joins and 
let the database do all the work. My advice is to get someone familiar with sql 
and construct the raw query and get it running at a decent speed inside the 
mysql console, and then find a way to get that sql into cake. 

I'm guessing you don't have any indexes on your tables either, so best to 
get that same person to look over them. 20,000 records is not a lot and mysql 
can handle that easily if you know what you are doing.

Best of luck!

Cheers,
Adam

- Original Message - 
  From: Femi Taiwo 
  To: Cake PHP 
  Sent: Tuesday, June 16, 2009 7:05 PM
  Subject: Problem with Large Datasets


  Hi all,

  I'm having a scalability problem, and urgently need to refactor. The 
project is just 2 months old and already has over 20,000 users.
  How do you handle passing an array with 5000+ values as a condition 
  e.g. $conditions = array('User.id'=>$bigArray); 
  As the records grow bigger, it takes longer. 

  I'm not looking to paginate because what happens is that an alert is sent 
to the users in the final result set. Browsing through the result set is NOT 
necessary.

  Models?
  I have a User model  with the following key relationships

  hasMany UserDegree
  hasMany Certification
  hasMany Skill
  hasMany Language
  belongsTo City

  The User model has a few columns as well - dob, marital status  and 
gender.

  Herein lies the problem - a user can set different criteria for searching 
through the entire user database using any of the attributes above.
  She can say for example, I want users in Kansas, aged between 22 and 27, 
who have degrees in either Computer Science, Mathematics or Physics, has 
Marketing skills
  and can speak a bit of  French.

  What I do right now is select from the users table, those aged between 22 
and 27, then amongst these ones, those with the relevant degrees => then get 
from this set, the ones that have marketing skills. So I keep filtering using 
their user_ids. and passing them to the relevant model using conditions like 
$conditions = array('UserDegree.user_id'=>$bigArray); 

  Initially, this worked well with a few thousand records. But now with 
20,000. Takes  3-5 seconds and is really cpu intensive and hard on the MySQL 
server.

  What can I do?

  Thanks!!

  Femi












  

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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 Large Datasets

2009-06-16 Thread Adam Royle
Hi Femi,

You should really just use one query for that with a number of joins and let 
the database do all the work. My advice is to get someone familiar with sql and 
construct the raw query and get it running at a decent speed inside the mysql 
console, and then find a way to get that sql into cake. 

I'm guessing you don't have any indexes on your tables either, so best to get 
that same person to look over them. 20,000 records is not a lot and mysql can 
handle that easily if you know what you are doing.

Best of luck!

Cheers,
Adam

- Original Message - 
  From: Femi Taiwo 
  To: Cake PHP 
  Sent: Tuesday, June 16, 2009 7:05 PM
  Subject: Problem with Large Datasets


  Hi all,

  I'm having a scalability problem, and urgently need to refactor. The project 
is just 2 months old and already has over 20,000 users.
  How do you handle passing an array with 5000+ values as a condition 
  e.g. $conditions = array('User.id'=>$bigArray); 
  As the records grow bigger, it takes longer. 

  I'm not looking to paginate because what happens is that an alert is sent to 
the users in the final result set. Browsing through the result set is NOT 
necessary.

  Models?
  I have a User model  with the following key relationships

  hasMany UserDegree
  hasMany Certification
  hasMany Skill
  hasMany Language
  belongsTo City

  The User model has a few columns as well - dob, marital status  and gender.

  Herein lies the problem - a user can set different criteria for searching 
through the entire user database using any of the attributes above.
  She can say for example, I want users in Kansas, aged between 22 and 27, who 
have degrees in either Computer Science, Mathematics or Physics, has Marketing 
skills
  and can speak a bit of  French.

  What I do right now is select from the users table, those aged between 22 and 
27, then amongst these ones, those with the relevant degrees => then get from 
this set, the ones that have marketing skills. So I keep filtering using their 
user_ids. and passing them to the relevant model using conditions like 
$conditions = array('UserDegree.user_id'=>$bigArray); 

  Initially, this worked well with a few thousand records. But now with 20,000. 
Takes  3-5 seconds and is really cpu intensive and hard on the MySQL server.

  What can I do?

  Thanks!!

  Femi







  

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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: routing to control layout

2009-06-15 Thread Adam Royle

Sorry, I never used reverse routing like that. Maybe someone else with more 
experience can help out?

With my facebook app I used fbml so my views were custom anyway which meant 
I had to use explicit urls.

Cheers,
Adam

- Original Message - 
From: "Greg Baker" 
To: "CakePHP" 
Sent: Tuesday, June 16, 2009 11:36 AM
Subject: Re: routing to control layout



Ahh thank you, that works nicely.
How about if I want the URLs to persist throughout the app, so that
$html->link(), say, would point to /AppName/facebook/controller/action
if $this->params['facebook'] were set?  Would this be possible using
routing or would I have to do something else?

On Jun 15, 10:36 pm, "Adam Royle"  wrote:
> Sure...
>
> Router::connect('/AppName/facebook/:controller/:action/*', 
> array('facebook'
> => 1));
>
> then in your app controller just check for
>
> $this->param['facebook']
>
> - Original Message -
> From: "Greg Baker" 
> To: "CakePHP" 
> Sent: Tuesday, June 16, 2009 10:28 AM
> Subject: routing to control layout
>
> > I'm trying to make an app that works standalone as well as with
> > facebook. Is it possible to define routing so that if the URL
> > matches /AppName/facebook/* it will route to /AppName/* and set a
> > parameter facebook=true so I can catch this in the AppController and
> > render it using my facebook layout?




--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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: routing to control layout

2009-06-15 Thread Adam Royle

Sure...

Router::connect('/AppName/facebook/:controller/:action/*', array('facebook' 
=> 1));

then in your app controller just check for

$this->param['facebook']

- Original Message - 
From: "Greg Baker" 
To: "CakePHP" 
Sent: Tuesday, June 16, 2009 10:28 AM
Subject: routing to control layout


>
> I'm trying to make an app that works standalone as well as with
> facebook.  Is it possible to define routing so that if the URL
> matches /AppName/facebook/* it will route to /AppName/* and set a
> parameter facebook=true so I can catch this in the AppController and
> render it using my facebook layout?
> >
>
> 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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: grr help with cron/shell tabs

2009-06-15 Thread Adam Royle

"cake" is a shell script which needs to be chmod'ed to 755 to allow being 
executed (also chmod +x will do that)

If you're getting the output of the file instead of it being executed, then 
it seems you're passing the script onto something else (such as the php 
interpreter) rather than executing it as a script.

Do you have command line access? If so, try it first manually before trying 
to run in cron.

Even if you try and run the shell script with no arguments you should get 
something.

btw, this is the full command to run (either in cron or manually, no 
linebreaks either):

/home/mileswj/cake/console/cake your_shell_name -app 
/home/mileswj/sc2armory.com/app/

Even if you run this manually, you should get a listing of the available 
shells:

/home/mileswj/cake/console/cake -app /home/mileswj/sc2armory.com/app/

If you don't have command line access it's possible that the control panel 
you're using is changing the command before entering into cron (such as 
prefixing it with path of php). If that is happening you might need to write 
a dummy php script that exec()'s your real command.

Cheers,
Adam

- Original Message - 
From: "Miles J" 
To: "CakePHP" 
Sent: Tuesday, June 16, 2009 10:02 AM
Subject: Re: grr help with cron/shell tabs


>
> Nope, still getting this:
>
> clear
>
> LIB=${0/%cake/}
> APP=`pwd`
>
> exec php -q ${LIB}cake.php -working "${APP}" "$@"
>
> exit;
>
> >
>
> 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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: array extraction

2009-06-15 Thread Adam Royle
use this function, it works well...



// recursively reduces deep arrays to single-dimensional arrays
// $preserve_keys: (0=>never, 1=>strings, 2=>always)
function array_flatten($array, $preserve_keys = 1, &$return = array()) {
 foreach ($array as $key => $child) {
  if (is_array($child)) {
   $return =& array_flatten($child, $preserve_keys, $return);
  } elseif ($preserve_keys + is_string($key) > 1) {
   $return[$key] = $child;
  } else {
   $return[] = $child;
  }
 }
 return $return;
}



  - Original Message - 
  From: samuel darko 
  To: cake-php@googlegroups.com 
  Sent: Tuesday, June 16, 2009 1:16 AM
  Subject: array extraction


  Hi guys:
  i need help trimming down this:


Array(  [0] => Array(  [0] => Array   ( [Amount] => 72.64   
) ))
  TO this:

 Array (  [Amount] => 72.64 )I tried the ff code but to no 
avail:function afterFind($results, $primary=false) { if($primary == 
true) {
   if(Set::check($results, '0.0')) {  
$fieldName = key($results[0][0]);foreach($results as 
$key=>$value) {$results[$key][$this->alias][$fieldName] 
= $value[0][$fieldName];
  unset($results[$key][0]);}
}   }   return $results;}   
 Thanks, in advance, for your help
  -sam
  

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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: grr help with cron/shell tabs

2009-06-15 Thread Adam Royle

chmod +x /home/mileswj/cake/console/cake

then put this in cron

/home/mileswj/cake/console/cake your_shell_name -app /home/mileswj/
sc2armory.com/app/

Cheers,
Adam


On Jun 15, 6:25 pm, Miles J  wrote:
> Heres my current folder setup.
>
> /home/mileswj/cake/ (below root and shared between many apps)
> /home/mileswj/sc2armory.com/app/
> /home/mileswj/milesj.me/app/
> ... etc ...
>
> All the sites work correctly, im just trying to get a cron running on
> sc2armory. Ive tried all the following and none of them work.
>
> /usr/local/php5/bin/php /home/mileswj/cake/console/cake cron
> /usr/local/php5/bin/php /home/mileswj/cake/console/cake -app /home/
> mileswj/sc2armory.com/app/ cron
> /usr/local/php5/bin/php /home/mileswj/cake/console/cake -app "/home/
> mileswj/sc2armory.com/app/" cron
>
> All of those output this data into my email:
>
> clear
> LIB=${0/%cake/}
> APP=`pwd`
> exec php -q ${LIB}cake.php -working "${APP}" "$@"
> exit;
>
> Also tried using exec php -q and some other commands and nothing.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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: Any idea how to put one cakephp project in the directory structure of another cakephp project?

2009-06-14 Thread Adam Royle

You will need to exclude the portfolio directory from being sent to your 
default cake installation. Something like this might work...


   RewriteEngine on
   RewriteRule^$ app/webroot/[L]
   RewriteCond %{REQUEST_URI} !^/portfolio(/|$)
   RewriteRule(.*) app/webroot/$1 [L]


- Original Message - 
From: "tarapage" 
To: 
Sent: Monday, June 15, 2009 1:09 PM
Subject: Any idea how to put one cakephp project in the directory structure 
of another cakephp project?


>
>
> Hi
>
> I want to host multiple cakephp projects on one domain.  I want to be able
> to have the following:
>
> www.julabay.com is our main website, it is a cakephp website.
> I want to be able to add the following:
>
>  /portfolio/project1
>  /portfolio/project2
>
> etc, and be able to access them by:
>
> www.julabay.com/portfolio/project1
>
> I want project 1 to then load up the cakephp application that is under
> project1.  I hope that this makes sense.  When I put a subdir in the main
> cakephp layout, of course it says:
>
>
> Not Found
>
> Error: The requested address '/portfolio/project1 was not found on this
> server.
>
>
> The reason that I want to do this is that I don't want to keep all of the
> websites that I have created, some of the domains will expire and I do not
> need to keep them live.  However, I want to keep them onfile for portfolio
> reasons, and want a fully functioning cakephp site living within another.
>
> Is this possible?
>
> Thanks
>
>
> -- 
> View this message in context: 
> http://www.nabble.com/Any-idea-how-to-put-one-cakephp-project-in-the-directory-structure-of-another-cakephp-project--tp24028258p24028258.html
> Sent from the CakePHP mailing list archive at Nabble.com.
>
>
> >
>
> 


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



Re: Modifying Html Helper Image method for localization support

2009-06-14 Thread Adam Royle

I guess it depends if you have any shared images that might be generic and 
used with all languages.

If you want to override the helper, you can do it by creating an AppHelper 
class in app/app_helper.php

Although this does change your functionality and you would have to duplicate 
any shared images between all languages.

I would probably go the more explicit route, and just append the language to 
the image path ($lang = 'en/').

$html->image($lang.'btn_action.gif');

Cheers,
Adam

- Original Message - 
From: "daedalus" 
To: "CakePHP" 
Sent: Monday, June 15, 2009 6:24 AM
Subject: Modifying Html Helper Image method for localization support


>
> Hello,
>
> I'm fairly new to CakePHP and have a question about the best way to
> accomplish a task. Here is my situation: I'm building a little
> localized app that incorporates a dozen or so images that will need to
> be localized - for example navigation buttons.  The most logical way
> to organize these images, it seems to me, is to put the images for
> each language into a folder bearing the language abbreviation in the
> "img" directory.  So, for instance, English images would be in "img/
> eng/".
>
> The app is working nicely now with Html helper image calls such as
> $html->image('btn_action.gif').  The language variable is written to
> the Config class in a beforeFilter of the (only) controller.  Ideally,
> I guess, I need to modify or extend the Html helper to automatically
> add the correct language directory into the image path, but as much as
> I've looked around for examples I'm still a bit hazy on how to best
> accomplish this.  Can I overwrite the "image" method of the Html
> helper by including an appropriate class in /app/helpers? Am I going
> about this in the right way to begin with?  I'm not so much interested
> in what merely works, but with what is most elegant, logical, and
> maintainable.
>
> Thanks a lot,
>
> AH
>
> >
>
> 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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: Cakephp equivalent of mysql_fetch_row

2009-06-14 Thread Adam Royle

http://book.cakephp.org/view/809/find-count

- Original Message - 
From: "Wayne" 
To: "CakePHP" 
Sent: Sunday, June 14, 2009 6:55 PM
Subject: Cakephp equivalent of mysql_fetch_row


>
> Hi,
> i need a function that returns the number of rows from a table. How
> do i do that in cakephp?
>
> Regards,
> wayne
> >
>
> 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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: PHP Fatal error: Class 'Router' not found in cake\libs\view\helper.php on line 178

2009-06-13 Thread Adam Royle

I found this problem too, when I was sending emails using a cron job, and 
needed to link back to the site. However there is an easy workaround.

I am using the EmailTask from the Bakery, and added importing the router and 
routes definitions in here.


To: "CakePHP" 
Sent: Sunday, June 14, 2009 3:09 AM
Subject: Re: PHP Fatal error: Class 'Router' not found in 
cake\libs\view\helper.php on line 178



Well, if you use xxx then it's not using the router is
it?

Why would you want to be outputting links in a shell script anyway?

On Jun 13, 10:57 am, joshua  wrote:
> Why if I change to $html->link to xxx, there will be no 
> this
> error?
> Did that mean we couldn't use html helper in shell script?
>
>
>
> On Sat, Jun 13, 2009 at 2:01 PM, AD7six  wrote:
>
> > On Jun 13, 5:19 am, joshua  wrote:
> > > Hi Cakes,
> > > Is there anybody come across this problem? When I try to run cron job 
> > > in
> > > cake console, it print out this error.
>
> > > PHP Fatal error: Class 'Router' not found in cake\libs\view\helper.php
> > on
> > > line 178
>
> > > If I change to $html->link to xxx, there will be no 
> > > this
> > > error.
>
> > > My Shell Scripts like this:
> > > [code]
> > > class AbcShell extends Shell {
> > > var $uses = array('modelA' );
> > > var $helpers = array('Html','Javascript');
>
> > > function main(){
> > > //
> > > }
>
> > > [/code]
>
> > > Is there anything I missed? Thanks in advance for your reply.
>
> > The router isn't needed for shell access, so most likely that's the
> > reason it's not loaded.
>
> > AD
>
> --
> Thanks
> Joshua




--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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: Manual sorting of data records (datasets)

2009-03-14 Thread Adam Royle
Something like this should work (as long as you include the 
RequestHandler component). Personally, I use an extra field "rank" in my 
table which is just an integer.

if ($this->RequestHandler->isAjax() && 
!empty($this->params['form']['tableId'])) {
 foreach ($this->params['form']['tableId'] as $rank => $id) {
 $this->YourModel->save(compact('id','rank'));
 }
}

brian wrote:
> On Fri, Mar 13, 2009 at 3:50 PM, hasentopf
>   wrote:
>
>> Hi all.
>>
>> One more question:
>>
>> I tried it with the "Table Drag and Drop JQuery plugin" from
>> http://www.isocra.com/2008/02/table-drag-and-drop-jquery-plugin/
>>
>> The Plugin returns a string of the form "tableId[]=rowId1&tableId[]
>> =rowId2&tableId[]=rowId3..." via Ajax.
>>
>> I wrote an Action which receives this data. Now I need to write the
>> new order back to the database. Do you know a good cake-way-
>> possibility for updating the ids in the table?
>>
>> It must be something like "UPDATE id SET old.id=new.id" for each
>> entry, or?
>>  
>
> I would avoid changing the IDs themselves. That'll likely lead to
> *many* headaches. Better to a) have a separate column just for
> ordering or, b) use TreeBehavior. Your data isn't nested but Tree
> could still help with ordering a single level. I haven't done this but
> I don't see why it wouldn't work well.
>
> One thing though: if this data is paginated, you'll have a bit of a
> problem, as you'll only be re-ordering one "page" of the set.
>
> >
>
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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: A list of more productive tutorials?

2009-03-09 Thread Adam Royle

Can you be more explicit about what you are looking for? Is there 
something in particular you don't know how to do?

Adam

webperson wrote:
> Hello,
>
> Does anyone know of a single sole source of free phpcake tutorials? I
> have found and completed all of the ones I could find, but I am
> assuming there are more out there.
>
> Thanks for any tips.
>
> >
>
>

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



Re: Find max(id)

2009-03-03 Thread Adam Royle
Oh right I see what it's doing now. I would say that it's a bug then. 
CakePHP should not generate invalid SQL queries. Although I'm pretty 
sure Cake adds the id field to the field list because it is required for 
recursively finding associated records, it could prob be modified to 
always add the MAX() command around the id field it when using "group 
by", for mssql at least.

Time for a ticket I reckon. You can submit it via trac.cakephp.org

Cheers,
Adam


blake wrote:
> I don't think its a bug, I think its more of the way Cake generates
> queries. Even though the Model.id field was not specified in the find
> (), Cake includes it in the select anyway. MS SQL complains about the
> GROUP BY when you don't also include Model.id in the group, since it
> is being selected. I'm actually not sure why MySQL accepts the query
> without id in the group, but it does.
>
> I really wanted to avoid using manual queries with this app, since I
> develop it with MySQL but the production server is MS SQL. So far,
> everything I've written works on both databases until this.
>
> Is there some way to force Cake to not select Model.id also? Any ideas
> on an alternative way to do this? It really sucks if I have to start
> doing manual queries after getting so far without them.
>
>
> Thanks,
>
> -Blake
>
>
>
> On Mar 2, 7:16 pm, Adam Royle  wrote:
>
>> I think the majority of CakePHP users are using MySQL, so it could be a
>> bug in the cake's MSSQL datasource. You should do some investigating
>> into what query is generated, does it run if you try it through sql
>> server directly? If not, what needs to be changed for it to work? Then
>> look at the mssql datasource and see if it's a bug or whether it could
>> be improved upon. If not then you may just need to execute a raw sql
>> query instead of using the find methods.
>>
>> Cheers,
>> Adam
>>
>> blake wrote:
>>  
>>> I'm trying to do the following find() to find the highest id for each
>>> name value in the table.
>>>
>>> $result = $this->Model->find('all', array('conditions' =>array
>>> ('Model.parent_id' =>$parent_id),
>>> 'fields' =>
>>> array('MAX(Model.id) as max_id', 'Model.name'),
>>> 'recursive' =>  
>>>   1,
>>> 'group' =>
>>> array('Model.name')
>>> ));
>>>
>>> For the example table:
>>>
>>> 1ItemA
>>> 2ItemB
>>> 3ItemC
>>> 4ItemB
>>> 5ItemA
>>>
>>> I want the result (any order):
>>>
>>> 5ItemA
>>> 4ItemB
>>> 3ItemC
>>>
>>> The find() works in MySQL, but not in MS SQL. MS SQL wants me to group
>>> on Model.id also, which then returns more results than I want. What is
>>> the best way for me to do this query?
>>>
> >
>
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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: One directory for all view files.

2009-03-03 Thread Adam Royle
Yes, CakePHP has a separate folder for each controllers views, but I 
would imagine if you had a ton of controllers you might want to separate 
them anyway?

I recommend you stick with the conventions to start with, and further 
down the track if you still want to change it, you'll find a way.

Cheers,
Adam

lakers fan wrote:
> Hello,
>  Can I create all the view files inside one directory. Right now 
> what I understood is you got to create a folder named after 
> controller. if I have many controllers, does it mean that I have to 
> create that many folders for view files?
>
> Thanks,
> Bharani
>
> 
> Windows Live™ Groups: Create an online spot for your favorite groups 
> to meet. Check it out. 
> 
> 
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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 max(id)

2009-03-02 Thread Adam Royle

I think the majority of CakePHP users are using MySQL, so it could be a 
bug in the cake's MSSQL datasource. You should do some investigating 
into what query is generated, does it run if you try it through sql 
server directly? If not, what needs to be changed for it to work? Then 
look at the mssql datasource and see if it's a bug or whether it could 
be improved upon. If not then you may just need to execute a raw sql 
query instead of using the find methods.

Cheers,
Adam

blake wrote:
> I'm trying to do the following find() to find the highest id for each
> name value in the table.
>
> $result = $this->Model->find('all', array('conditions' =>  array
> ('Model.parent_id' =>  $parent_id),
>   'fields' =>  
> array('MAX(Model.id) as max_id', 'Model.name'),
>   'recursive' =>  
> 1,
>   'group' =>  
> array('Model.name')
>   ));
>
>
> For the example table:
>
> 1ItemA
> 2ItemB
> 3ItemC
> 4ItemB
> 5ItemA
>
> I want the result (any order):
>
> 5ItemA
> 4ItemB
> 3ItemC
>
>
> The find() works in MySQL, but not in MS SQL. MS SQL wants me to group
> on Model.id also, which then returns more results than I want. What is
> the best way for me to do this query?
>
> >
>
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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: Security component breaks my ajax requests

2009-02-28 Thread Adam Royle

Looking at the Security component source, you need to override the 
validatePost value in SecurityComponent. The following is untested code, 
but I think it should work.

function beforeFilter() {
 if ($this->action == 'your_action') {
 $this->Security->validatePost = false;
 }
 parent::beforeFilter();
}

Miles J wrote:
> When I add the Security component, all my ajax requests fail. They
> never finish or return data. I am using jQuery and not the built in
> ajax.
>
> What do I have to do to allow this to work? The manual for Security is
> a bit vague.
> >
>
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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 set up site structure with Admin folder and controllers?

2009-02-25 Thread Adam Royle

Have you looked into admin routing?

You'll just need to prefix your actions and your views with "admin_" to get 
it to work (and enable it in app/core.php)

And then set up a route for your admin homepage, which would point to 
AdministratorsController::admin_dashboard()

Router::connect('/admin', array('controller' => 'administrators', 'action' 
=> 'dashboard', 'admin' => 'admin'));

Hope that helps,
Adam

- Original Message - 
From: "Leonard Teo" 
To: "CakePHP" 
Sent: Thursday, February 26, 2009 12:25 AM
Subject: How to set up site structure with Admin folder and controllers?


>
> Hi,
>
> I'm an experienced PHP developer that's just started using Cake.
> Apologies in advance if this is a n00bish question.
>
>
> I've created several models, controllers and scaffolds but I would
> like them all to reside in a /admin  folder in the site structure.
>
>
> E.g.  Models
> - Administrator
> - Story
> - File
>
>
> The default cake site structure is this:
> root/administrators
> root/stories
> root/files
>
> How do I set Cake up so that all the above go into a backend
> directory?
>
> E.g:
>
> root/admin/administrators
> root/admin/stories
> root/admin/files
>
>
> I would also like to create an admin controller so that the homepage
> for admin will show a dashboard:
> e.g.
> root/admin/. will show a backend dashboard.
>
>
> I've been generally good at finding my way around but was unable to
> find information on doing this - If anyone could help point me in the
> right direction, that'd be great.
>
> Thanks!! :)
>
> Leo
>
>
> >
>
> 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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: Manual sorting of data records (datasets)

2009-02-24 Thread Adam Royle
Both protaculous and jquery (and prob most other js libraries) have a 
sortable function so you can drag and drop records  (re-ordering) with 
your mouse, and a serialize function so you can send the re-ordered ids 
back to the server to update the database.

I'm sure you could also do the move up/down code pretty easily, but drag 
and drop is pretty common these days and is not too difficult. One thing 
to be aware, is not all libraries support sorting table rows (afaik), 
but there are workarounds.

Hope that helps,
Adam

hasentopf wrote:
> Clicking on the table header is only temporary. I need a permanent
> solution which changes the order of the table.
>
> Something like: "Move up", "Move down", "Move to the top" and "Move to
> the bottom"
>
> Best Mathias
>
> On 24 Feb., 11:51, "Liebermann, Anja Carolin"
>   wrote:
>
>> Hi Hasentopf,
>>
>> Do you think of drag and drop or sorting by clicking on the table header?
>>
>> Anja
>>
>>  
>
> >
>
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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: Plugins - Calling plugin App Controller from base application App Controller

2009-02-23 Thread Adam Royle

Due to the way plugin controllers work with inheritance, you can only 
access the plugin's beforeFilter logic when the page is requested 
through the plugin (ie. /plugin/controller/action/)

 From what I can tell you want to execute plugin logic from your base app?

The proper way to do this is by creating a component inside your plugin, 
and adding it to your $components array inside app_controller. Look at 
the DebugKit plugin as an example of how this can be achieved.

Cheers,
Adam


adam wrote:
> How do I call the app_controller beforeFilter logic from a plugin?
> Such as plugin_name/plugin_name_app_controller from the app/
> app_controller.php?
> >
>
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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: Pages and Views

2009-02-23 Thread Adam Royle

I think you're on the right track with your thinking.

1) You should route to your "users" controller, not the pages controller

Router::connect('/search', array('controller' =>  'users', 'action' =>  
'search'));

2) You should explicitly set your search form url.

echo $form->create('User',array('url' =>  '/search'));

3) Then inside your "users" controller, you'll have a "search" method 
that looks at $this->data['User']['search'] for the search string.

Make sense?

Adam

Mike wrote:
> Hi everyone,
>
> I'd like to manage my users search functionality on a page called
> search, then the end users will be able to access it using the url
> www.mywebsite.com/search.
>
> Actually, i already created a search.ctp element with just a form to
> process the search on the user table here is the code :
>
> //Search Box
> echo $form->create('User',array('action' =>  'search'));
> echo $form->input('search', array('label' =>  __('search',true), 'type'
> =>  'text'));
> echo $form->submit(__('search',true));
>
> The search function is in the search method in the User controller
> class, which means the results of the search should actually be
> managed in a search view in views/users/search.ctp.
>
> I created a file at this location views/pages/search.ctp and in
> routes.php file I have the following connection :
> Router::connect('/search', array('controller' =>  'pages', 'action' =>
> 'display', 'search'));
> Which means this file is accessible from www.mywebsite.com/search
>
> I'd like the user search to be managed on this file, then the end
> users when performing a search will be redirected to view the results
> under a url like this www.mywebsite.com/search, including the search
> element define before, not a url like www.mywebsite.com/users/search
>
> Is there a way to manage this ? maybe a redirection but I'm completely
> stuck at this point.
>
> Thx,
> >
>
>

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



Re: Tree misbehaviour

2009-02-23 Thread Adam Royle

What data type are you using for your lft and rght columns?

I'm not sure if it will help you, but have a browse over my article 
which has all the code to get the Tree behavior working and see if 
you're doing anything differently.

http://blogs.bigfish.tv/adam/2008/02/12/drag-and-drop-using-ext-js-with-the-cakephp-tree-behavior/

Cheers,
Adam

Mark wrote:
> Hi All,
>
> I’m having a problem with the Tree behaviour that I was hoping
> somebody could help me with.
> I’m setting my object id and parent_id, but the 'lft' and 'rght'
> columns are not being updated by the tree behaviour. They are being
> left as their defaults (NULL).
>
> The CakePHP 1.2 manual indicates that these fields will be handled by
> the Tree behaviour, but they don’t seem to be for me.
> I’m using MySQL 5.0.67-community with CakePHP 1.2 Stable.
>
> Any help would be appreciated! I’ve spent days messing with this and
> just finished a 5 hour session tinkering with it too. I hope this post
> makes sense… I’m shattered ;)
>
> Thanks,
> Mark
>
> >
>
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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 embed flash when using CakePHP

2009-02-23 Thread Adam Royle

You might want to give some examples of your code if you want anything 
more specific than what I have said.

However, if you aren't already, use Firebug to look at what URLs flash 
is requesting.

And make sure you have debug = 0 when doing this so you can easily see 
404 errors when they occur.

Cheers,
Adam

Bankai wrote:
> How can I make the paths relative to the root?
>
> I tried absolute paths in both the xhtml and xml and still doesn´t
> work.
>
>
> >
>
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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 embed flash when using CakePHP

2009-02-22 Thread Adam Royle
Brian is right. You need to change the path to be relative to the root 
of your site, not the page.

So change this:

media/jpgrotator.swf

to this:

/media/jpgrotator.swf


In all instances and it should work.

Also, if you are loading other swfs, images, text files, etc, from 
inside flash, those paths will need to be relative to the root as well.

Cheers,
Adam

brian wrote:
> On Sun, Feb 22, 2009 at 2:34 PM, Bankai  wrote:
>
>> My flash movies are not loading in cakephp. All the files are located
>> in the webroot directory.
>> In the past I use the following (valid xhtml code) to embed flash:
>> 
>> 
>> 
>> AC_FL_RunContent(
>> "type","application/x-shockwave-flash",
>> "data","media/jpgrotator.swf",
>> "width","742px",
>> "height","275px",
>> "movie","media/jpgrotator",
>> "quality","high",
>> "wmode","transparent" );
>> 
>> 
>> 
>> 
>> 
>> 
>> > value="transparent" />
>> 
>> 
>> 
>> 
>> >  
>> Web URL: http://www.hld-hoteles.com/
>>
>> In the body I would use the script: AC_RunActiveContent.js.
>> http://www.hld-hoteles.com/js/AC_RunActiveContent.js
>>
>> When I run the swf directly it runs fine: 
>> http://www.hld-hoteles.com/media/jpgrotator.swf
>>
>> I am using xml to load the images: 
>> http://www.hld-hoteles.com/media/jpgrotator.xml
>> When I right click on the banner I can tell that the flash is loading,
>> but the images are not showing up.
>> I wanna know why the images are not loading.
>>  
>
> Well, I'd guess that your image paths are wrong.
>
> >
>
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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: Debug off denies access to login page

2009-02-21 Thread Adam Royle

Try debugging by putting logging statements in your code step by step and 
see what you get.

$this->log('yayaya');

And you can check them inside app/tmp/logs/

Cheers,
Adam

- Original Message - 
From: "benjam" 
To: "CakePHP" 
Sent: Saturday, February 21, 2009 8:15 PM
Subject: Debug off denies access to login page


>
> I have a site that uses ACL and Auth to control access to the admin
> portion of the site, as well as one other non-admin page.
>
> When I have debug set to 2, I can log in and access the admin fine,
> and when I'm logged off, it blocks everything as it should.
>
> When I turn debugging off, and try to access the admin section, it
> redirects me to the login page (as it should), but then gives me a 404
> on the login page.
>
> I don't have any debug specific code anywhere, so I can't seem to put
> my finger on why this may be happening.  And the real kicker is, it
> only happens when debug is off, so I can't debug it.
>
> Any ideas as to why this may be happening?
> >
>
> 


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



Re: email to blog functionality

2009-02-19 Thread Adam Royle
I've done it using cpanel (quite easy actually), and from some googling 
it seems possible with plesk too. Just search for " pipe email to script".

With #1, you can use php imap extension, which lets you access both pop 
and imap mailboxes.

Adam

leo wrote:
> Thanks, I'd assumed #1 was the only option, but #2 sounds interesting.
> Do you have any pointers on how to set up the email account? I don't
> know whether it'll be possible using shared hosting.
>
> Regarding #1, do you have any pointers for the script? I have no idea
> how to programatically access an email account.
>
> L
>
> On Feb 19, 10:17 am, Adam Royle  wrote:
>
>> Depends on your server setup. Two solutions:
>>
>> 1. Write a script that is called periodically through cron that checks
>> an email mailbox for new messages.
>> 2. Setup your email account to pipe to a script instead of to a mailbox.
>>
>> I have used #2 and it works well because the script only runs when it
>> needs to.
>>
>> Either way, once you get the email content you'll need to parse it
>> somehow to find the relevant content. I've used the mailparse php
>> extension and it works pretty well.
>>
>> Cheers,
>> Adam
>>
>> leo wrote:
>>  
>>> I'm looking at updating a blog by email - a la blogger&wordpress.
>>>
>>> Anybody have any ideas about how to go about this?
>>>
>>> Last time I thought about it I found some protocols and stuff through
>>> google, but google seems these days do be a bit chaffy and I can't
>>> remember what the protocol was.
>>>
>>> Anyway, it seems to me that protocol isn't important, it's how to get
>>> at the email from the blog script.
>>>
>>> Anyone?
>>>
> >
>
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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: email to blog functionality

2009-02-19 Thread Adam Royle

Depends on your server setup. Two solutions:

1. Write a script that is called periodically through cron that checks 
an email mailbox for new messages.
2. Setup your email account to pipe to a script instead of to a mailbox.

I have used #2 and it works well because the script only runs when it 
needs to.

Either way, once you get the email content you'll need to parse it 
somehow to find the relevant content. I've used the mailparse php 
extension and it works pretty well.

Cheers,
Adam

leo wrote:
> I'm looking at updating a blog by email - a la blogger&  wordpress.
>
> Anybody have any ideas about how to go about this?
>
> Last time I thought about it I found some protocols and stuff through
> google, but google seems these days do be a bit chaffy and I can't
> remember what the protocol was.
>
> Anyway, it seems to me that protocol isn't important, it's how to get
> at the email from the blog script.
>
> Anyone?
> >
>
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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: Calling a (empty!) model-method causes SQL Error: 1064

2009-02-18 Thread Adam Royle
Sounds like you have a typo somewhere (maybe you've got plural instead 
of singular?). Cake automatically creates models if they don't exist. 
Therefore it is creating a model (an instance of AppModel) and your 
method is not defined in AppModel.

Make sense?

Adam

Mr Speaker wrote:
> I think I must have some kind of scoping issue - the problem only
> occurs when I try to call a method from a Model from a different
> controller. So from the original example below, if I do:
>
>  function index() {
>  $this->Abc->doTest();
>  }
>
> inside AbcController, then it works as expected and returns null.
> If I call it from StartController, then it gives the error below (and
> as you pointed out, looks like it tries to call AppModel::doTest not
> AbcModel::doTest)
>
> By the way, the reason I am trying to call the method from the model
> not the controller is that I was trying to follow this advice:
> http://weblog.jamisbuck.org/2006/10/18/skinny-controller-fat-model
> which is from a Ruby on Rails guy - so perhaps I'm just going about it
> in the wrong manner!
>
> Thanks!
>
> On Feb 18, 11:14 pm, AD7six  wrote:
>
>> On Feb 18, 1:01 pm, Mr Speaker  wrote:
>>
>>  
>>> I have this same issue (exactly)... what am i doing wrong?
>>>
>> You are (both) calling a method on a (model) object that doesn't exist
>> - probably because of a misnamed file.
>>
>> "AppModel::doTest() - [internal], line ?? "<- it's an instance of
>> AppModel, not your model.
>>
>> Check the conventions page regarding filenames.
>>
>> hth,
>>
>> AD
>>  
> >
>
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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: Book Comments - Should they be removed

2009-02-17 Thread Adam Royle

I think the comments should stay, but improve the functionality to make 
them more useful/constructive.

Develop a upvote/downvote system for comments. This should eliminate 
stupid comments from wasting people's time, and the popular comments 
should indicate what parts of the manual could be improved. The good 
comments could even be visible on the page by default instead of hidden.

Although I understand your suggestion that people should just edit the 
manual to include what they're suggesting, some people:

a) might not want to impose their code on others (beginners might be 
unsure what is the best way to do something and don't want to mislead 
others)
b) might be too lazy to contribute something of value, due to language 
barriers or lack of ability to write meaningful prose

I'm sure we all agree that reading through the user comments in the PHP 
manual is a great source of WTF fodder, but there are some serious gems 
in there that have saved my butt a ton of times.

Cheers,
Adam

AD7six wrote:
> Hi All,
>
> Before doing anything rash I'd like to ask the community: Is the
> possibility to add comments to the book doing more harm than good?
> Should the possibility to add comments be removed?
>
> The main reason for asking is that, although things have improved
> lately, many comments should have been submitted as corrections or
> additions to the contents.  Some examples to illustrate (the goal is
> examples, not finger pointing/witch hunting):
>
> Should have been a ticket:
> http://book.cakephp.org/comments/3#comment_562
>
> Should have been an edit:
> http://book.cakephp.org/comments/index/162/Localizing-Your-Application#comment_510
>
> Should maybe have been a post here:
> http://book.cakephp.org/comments/index/162/Localizing-Your-Application#comment_641
>
> Trying to talk to Admins:
> http://book.cakephp.org/comments/29#comment_536
>
> Talking to yourself:
> http://book.cakephp.org/comments/566#comment_462
>
> Should not have started reading at the end of the manual:
> http://book.cakephp.org/comments/index/449
>
> Misleading:
> http://book.cakephp.org/comments/index/449#comment_639
>
> Flat out wrong:
> http://book.cakephp.org/comments/index/449#comment_574
>
> Vampy:
> http://book.cakephp.org/comments/95#comment_529
>
> Etc.
>
> Probably the biggest problem with adding comments (and users who speak
> more than one language will have already noticed this) is: if it's
> actually useful - the translations have absolutely not indication of
> whatever nugget of information unless it is submitted as an edit to
> the contents.
>
> If you're familiar with the book's source (http://thechaw.com/
> cakebook) you'll know that there are some things coming to help guide
> users to channel their efforts to be more effective, what else/more
> should be done to further improve things in this regard?
>
> On topic suggestions on a postcard please,
>
> AD
> PS. No how-the-book-should-work wishlist hijacking please (RFC/
> enhancement tickets as appropriate http://thechaw.com/cakebook/tickets
> OR fork, implement your functionality and ask for it to be integrated)
> >
>
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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: Displaying Unrelated Models in an Index View

2009-02-17 Thread Adam Royle

I would probably add another model, Post, like you've mentioned. I would 
also probably create a behaviour that would exist in all the sub-post 
models, which would add and remove a link from the Post model on 
save/delete.

Although I haven't used it myself, it looks like you could then use 
AD7six's Polymorphic Behavior on the Post model.

http://bakery.cakephp.org/articles/view/polymorphic-behavior

Cheers,
Adam

savant wrote:
> I am trying to figure out how to best display a myriad of different
> posting types within the same base index page.
>
> To give an idea of what I am dealing with, consider a system with News
> Posts and Photo Posts. Each News Post has its own MVC, separate from
> the MVC for the Photo Post (different database table, different files,
> different functioning, etc.). Each of these does pagination by itself
> (default) and calls related items. I would like to have a main index
> page that shows all of these, sorted by a datetime field in the
> database which each item has.
>
> Each one is different enough such that I wouldnt have a relationship
> between them other than calling them all "Posts", which I can if it
> renders a solution. I don't know quite how to show different data
> within the same page as if it were functionally the same. Is there
> something simple that I am missing, perhaps a helper, out there? It's
> most likely best to envision the app as a blog-like application
>
> >
>
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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: Can you have multiple hasAndBelongsToMany relationships in one model?

2009-02-16 Thread Adam Royle

var $hasAndBelongsToMany = array('Developer','Publisher');

- Original Message - 
From: "mklappen" 
To: "CakePHP" 
Sent: Tuesday, February 17, 2009 9:24 AM
Subject: Can you have multiple hasAndBelongsToMany relationships in one 
model?


>
> Hi,
>
> I'm new to cake and this group, I would like to know if it is possible
> to add multiple hasAndBelongsToMany relationships in one model? ( I
> assume it is...)
>
> my declaration & first instance of it is working fine, however it's
> not letting me add another...
> example:
>  class Game extends AppModel {
> var $name = 'Game';
> var $hasAndBelongsToMany = array('Developer');
> //want to add second many to many relationship here.
>
> $hasAndBelongsToMany = array('Publisher'); //does not work... tried
> other syntax as well w/ no luck.
> }
> ?>
>
> Thanks in advance.
> mk
>
> >
>
> 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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: Problems with code using cake 1.2

2009-02-15 Thread Adam Royle
Your syntax is not valid. Try reading up on the new form helper on the 
cookbook.

http://book.cakephp.org/view/183/Creating-Forms

Cheers
Adam

simon...@gmail.com wrote:
> Good Night,
>
> I'm trying to make this code work but they are 3 problems with it.
>
> Here are the 3 errors:
>
> Method HtmlHelper::FormHelper does not exist
>
> Method HtmlHelper::hiddenTag does not exist
>
> Method HtmlHelper::radio does not exist
>
>
> Heres's the file general.ctp that I'm using:
>
> I tryied to find a solution searching on the Net, but I couldn't find
> a way to fix it.
>
> Regards,
>
>
>
> Well, the poll
>
> 
> image("static/loading.gif", array
> ("alt"=>"Loading")); ?>
> 
>
> 
>
>  if ( !isset( $_SESSION["poll"] )  ) // the user has not voted, so,
> set the form
> {
>   echo $html->FormHelper('#','post', array("onsubmit"=>"return
> false;"));// do nothing
>
>   $array   = array();
>
>   echo "" . $poll[0]['Poll']['question'] ."";
>
>   echo $html->hiddenTag('Pollrow/poll_id', $poll[0]['Poll']
> ['id']);   // Poll_id
>
>   foreach ($poll[0]['Pollrow'] as $key=>$val)
>   {
>$array[$val['id']] = $val
> ['answer'];  // construct id-
>
>> value array
>>  
>   }
>
>  echo $html->radio('Pollrow/id', $array, '
>> ');  //print the answers
>>  
>
>  echo '';
>
>  echo $ajax->submit('Vote', array("url" =>  "/pollrows/vote",
>   "update"=>"add_pollrow",   //
> add_pollrow wil be updated with app/views/pollrows/results.thtml
> render
>   "loading" =>  "Element.hide
> ('add_pollrow');Element.show('loading')",
>   "complete" =>  "Element.hide
> ('loading');Effect.Appear('add_pollrow')"
>  ));
>echo '';
>}
>else // the user has voted, so just print the poll results
>{
>
>  $total_votes = 0;
>
>  foreach ($poll[0]["Pollrow"] as $key =>  $val)
>  {
>  $total_votes += $val["vote"];  // the total votes
>  }
>
>  foreach ($poll[0]["Pollrow"] as $key =>  $val)
>  {
>   $percent = ($val["vote"] * 100) / $total_votes;  // % =
> votes * 100 / total
>   $width   = number_format($percent, 0);
>   echo ''.$val['answer'].'  '.number_format
> ($percent, 2).'%';
>   echo $html->image('static/poll/'.$val["color"].'.png',
> array("height"=>"10", "width"=>$width,"alt"=>$val["answer"], "title"=>
> $val["answer"]) );
>   echo "  ". $val['vote'];
>  }
>
>echo "Total votes:" . $total_votes . "";
> }
> ?>
> 
>
> >
>
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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 w/ Shells

2009-02-15 Thread Adam Royle

Have you checked your database connection? (Just a thought)

Also, with shells you need to ensure you execute the shell from the app 
folder, or specify the path to your app in -app

Cheers,
Adam

Kyle Decot wrote:
> I'm trying to create a shell but I'm running into some problems. If I
> add $uses = array("User"); to my shell then I get:
>
> Error: Missing Database Connection. Try 'cake bake'
>
> Any ideas? I'm new to shells so I have no clue. Any help is, as
> always, appreciated.
> >
>
>

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



Re: When to use Data caching??

2009-02-14 Thread Adam Royle

I don't tend to cache data by itself, as like you've said it generally 
won't save you much time vs mysql alone. I do use view caching on busy 
sites for static content and also for elements, as it can give a 
noticeable improvement.

I guess it really depends on your traffic and the type of site you run. 
I've not tested the difference but memcache would probably give you much 
better performance than file caching.

Cheers,
Adam

floepi wrote:
> Hi all,
>
> I am investigating the use of data caching at the moment and was
> digging around this google group. I found some very interesting posts
> on how to optimize cake but no satisfactory answer to "when should I
> actually use a file cache for my data".
>
> I took over a website which uses data caching heavily, but the queries
> are actually pretty straight forward with just one joint. Nothing too
> recursive. The previous developer cached all that data using the cake
> file cache method.
>
> I'm not the database expert but I know that most queries are chached
> in MySQL and therefore take just a few milliseconds to retrieve. Isn't
> opening a file, reading the content, converting the string into an
> actual php array much slower. I understand data caching makes sense
> for heavy queries or when using memcache, but caching every query to
> file doesn't seem right. The site is pretty big and has lots of
> traffic, but I still think MySQL is better optimized than the file
> system, no?
>
> Please let me know when you are using data caching and why.
>
> Thanks a lot.
>
> Phil
>
> >
>
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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: switching databases on dev and production

2009-02-10 Thread Adam Royle

I use svn:ignore on app/config/database.php, and only commit a generic
database.php.default file (that contains no usernames/passwords). Each
time I checkout the code (dev, staging, production) I rename
the .default file to database.php and make my edits on the server. So
ultimately no passwords are stored in version control. The downside to
this approach is that if you need to change the database.php.default
file (adding another db source, etc) you then need to manually add the
changes into each deployment area.

I'm sure there's a better way, but this works for me.

Cheers,
Adam

On Feb 11, 12:38 pm, travisbeck  wrote:
> i see that you can add multiple database defnitions for
> development,production, and test in the database.php file.
>
> how do you get your application to switch between the different
> environments?  Our app is in version control and i'd very much like to
> not have to constantly worry about the database config everytime a
> change gets commited.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Best way to clear cache?

2009-02-08 Thread Adam Royle

I think you might benefit from a deploy script. I have a bash script
that updates the site code from subversion and clears my cache dirs at
the same time. I have command-line access and it runs on linux, so
it's pretty easy to do that.

On Feb 9, 9:30 am, Miles J  wrote:
> Everytime I upload and update my site online, everythings cached.
> Whats the best way to clear cache? Right now I just set debug to 2
> upload and clear cache, then set to 0 and reupload.
>
> Ive also tried deleting all the files in the cache folder, but
> sometimes I get an fopen() error.
>
> Just wondering if theres an easier way to do it.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Image Association with Records

2009-01-30 Thread Adam Royle

I do something similar and it works quite well for my purposes,
however I save my images in /files/images/, and I use behaviors to
abstract the file management away from my model.

So usually I have something like this:
Image actsAs ImageBehavior (subclass of FileBehavior)

Cheers,
Adam

On Jan 31, 12:11 am, Jesse  wrote:
> I'm looking for some advice for images.
>
> I've got a system for an advertising piece on a app I'm working on.
> There is a 'companies' table that has all the company info and we need
> to add a "logo" field and the ability to upload up to 5 images. What's
> the best way to do this?
>
> I don't want to save all the images in a database. I want to hold them
> in a file system (that's how it's currently set up). My thought to to
> simple save them in /img/companies/1_logo.jpg and then /img/companies/
> 1_[1 2 3 ...].jpg. Write an image model to associate images with
> records, and custom write the adding, updating and deleting of images.
> (This is how the current system works, but I want to port the system
> over to cakePHP).
>
> Any better suggestions?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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: Are we using the slowest PHP framework there is?

2009-01-25 Thread Adam Royle

Yes, it would be great to have a fully-fledged application example,
complete with "time to develop" and "lines of maintainable code"
benchmarks. And another one which measures mental anguish experienced
by the framework.

On Jan 26, 7:38 am, Miles J  wrote:
> Yes I always hate benchmarks because it only deals with "Hello world"
> applications. How about they build robust applications in each
> framework and then give us a real benchmark that matters.
>
> Also Symfony is slower then Cake.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Create html files dynamically

2009-01-24 Thread Adam Royle

I would recommend using routes to accomplish this - you don't need to
write to a static html file.

http://book.cakephp.org/view/542/Defining-Routes

Cheers,
Adam

On Jan 24, 6:48 pm, Sumesh G  wrote:
> thanks for your reply
>
> i want to create the html pages with the dynamic contents,
> i had created all the dynamic pages to add and display the contents
> but i dont know how to convert it to html pages
> please give me an idea
>
> thanks
> sumesh
>
> On Jan 24, 1:52 am, Miles J  wrote:
>
> > You would only need 1 view for this.
>
> > If the data is stored in the database, just grab the data and display
> > it in that single view, for all the pages.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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: Automatic table generation?

2009-01-24 Thread Adam Royle

Hi Carlosz,

#1. I find using a gui db program is much quicker than defining
everything in a text file. I use navicat and it's awesome.

However...

#2. CakePHP does have a thing called CakeSchema, which can be used to
generate table structures from a file definition. For more info, look
at the cookbook.
http://book.cakephp.org/view/734/Schema-management-and-migrations

Cheers,
Adam

On Jan 24, 5:33 pm, carlosz  wrote:
> Hi all, I've just seen this python project:http://elixir.ematia.de/trac/wiki
> which uses models to create the database tables and their
> relationships and I was wondering if something like that could be done
> in cake (or already exists?).
>
> Maybe not writing it in the actual models, but something you could
> feed to the console (like a file with an array) so cake generates the
> tables and join tables, and then follow with bake for the models, etc.
>
> Something like that, for the starters at least, would make cake even
> easier than... cake :)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: How can "TMP" be set to some other directory?

2009-01-20 Thread Adam Royle

Can you explain why you need different tmp directories for the same
actual app? If it's for caching, etc, maybe you can use a cache prefix
dynamically?

Cheers,
Adam

Martin Westin wrote:
> Hi (again),
>
> I want to try to host one application under several domains.
>
> One Cake
> One App
> Many configs
> Many temp dirs
>
> It is that last bit I get stuck on. I really want to split the tmps so
> I have one for each domain. Unfortunately defining "TMP" in
> bootstrap.php is too late. It is already set in paths.php before I get
> a chance to "take over" so to speak.
>
> The only place inside the app I would be abel to do it is index.php.
> But that would be a headache all on its own hacking in a lot of domain
> parsing there.
>
> Is there a less "hacky" way to point tmp somewhere else?
>
> thanks
> /Martin
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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: About custom cache features

2009-01-19 Thread Adam Royle

Btw, it wasn't deleted, only the "version" and "milestone" metadata
was deleted from the ticket. It is still an open ticket.

Cheers,
Adam

On Jan 19, 6:26 pm, kiang  wrote:
> I submitted a ticket about adding tag feature to cache and it got
> deleted soon.https://trac.cakephp.org/ticket/5965
>
> OK, somebody think it's bad idea to touch the great core of CakePHP.
> But how to add custom cache features in CakePHP besides modifying the
> core? It had been mentioned in this 
> ticket:https://trac.cakephp.org/ticket/3981
>
> How do you use cache in CakePHP?
> 1. Clear all the cache in afterSave() method?
> 2. Clear all the cache in afterSave() method when saving some models?
> 3. Never using the built in cache feature?
>
> I don't like to submit another ticket to be deleted without any
> reason.
>
> ---
> kiang
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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: Associations on the Fly - Good or Bad?

2009-01-17 Thread Adam Royle

Personally I find it easier to define all associations and use
Containable or recursive = -1 to define what data I get back. It's
easier to understand for me and works fairly well, makes it quick to
develop and easy to debug.

The only potential downside is that every associated model is loaded,
whether or not it is needed. If you have tons of models, all
associated together, then maybe you'll have a few performance issues,
however I've never been in that situation, so maybe someone else could
comment on that.

Cheers,
Adam

Chad Casselman wrote:
> Are there any known advantages or disadvantages of
> 1) doing all associations ONLY when needed and only the ones that are needed
> or
> 2) putting lots of associations in the models and trying to unbind / contain
> them out of the urls ?
>
>
> Just trying to find a consistent way to get the most out of the
> applications.
>
> Chad
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Using a different path for image storage

2009-01-16 Thread Adam Royle

This error happens when the image doesn't exist, and the request is
forwarded to cakephp. Make sure the file is there and case-sensitive
if on linux.

Cheers,
Adam

On Jan 16, 8:48 pm, g4b0  wrote:
> Hi all,
> I'm trying to put some images in /app/webroot/img/photo, but the
> following html doesn't display anything:
>
> 
>
> In addiction, if I point my broser directly 
> tohttp://mysite.com/img/photo/HawaiiSurf.jpg
> I get this:
>
> Missing Controller
> Error: ImgController could not be found.
> Error: Create the class ImgController below in file: app/controllers/
> img_controller.php
>
>  class ImgController extends AppController {
>
>         var $name = 'Img';}
>
> ?>
>
> How can I solve it?
>
> Thanks a lot
> g4b0
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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: where to start - basic security question?

2009-01-13 Thread Adam Royle

Yes, I would say most people use the controller/action/params type
urls.

Most people's thoughts about passing the action through a POST instead
of a GET to make it more secure are moot. You can fake (and modify
variables) in a POST request just as easy as you can with GET.

Your post indicates that you are aware of verifying user permissions
before you do any modifications to the database, so I won't go into
that.

Typically, a GET request should never modify anything on the server.
The default baked controllers in cake still use a GET for the delete
action for simplicity, but really they should be POST in a secure
application. You are left to implement this yourself (with the help of
the RequestHandler/Security components).

Cheers,
Adam

On Jan 13, 9:27 am, SethA  wrote:
> I'm new to all this. It all started with a desire on my part to start
> building some PHP based apps on my own time. I'm not a programmer by
> trade, so try to be understanding with me :). After months of [part
> time] googling, I've become familiar (somewhat) with MVC, why it is
> important, frameworks, why I should use one, etc. (problem with
> googling is that in a fluid landscape, often times it is hard to
> discern obsolete info/articles from contemporary and current best
> practices) Haven't started anything yet due to my perfectionism
> wanting to "do it right" the first time. I've finally gotten myself to
> the point of taking that leap, and I think I am ready. Not wanting to
> write spaghetti PHP just to have to redo later in a better way it once
> I get my feet wet Up till now, I've just been finding my way by
> stumbling across this blog, that article, yada yada. This is my first
> time posting anywhere to ask specific questions that are troubling me.
>
> I've been trying to find a good framework, what do most people use
> these days, yada, yada. Yeah, I know probably a stupid question. I
> have looked at Phrame (I know...) because some [old] articles I read
> during my research used it as an example for MVC based apps. I was
> tempted to build my first app with it, but decided that due to its
> apparent lack of maintenance and aging state (uses PHP4), I should
> find out what else is out there. Stumbled across CakePHP, and this
> seems like a good place to begin (at least). I haven't completely
> settled on this as my choice to dive in and am hoping the answer I get
> can help me fully decide.
>
> S, anywho...  here goes. What is bothering me as I have begun
> looking through the docs and the example blog app is this: I see that
> the basic mechanism for the web app to trigger various actions and so
> forth is to use URLs of this form "site.com/controller/action/param1/
> param2". I fully accept that I may be the idiot of the year for asking
> whether I am wrong in thinking that this is a basic security problem?
> I personally don't want to expose this to an end user. I guess I am
> thinking that anyone could attempt to type a desired action into the
> address bar whether or not the application should allow them to take
> that action. For example, /posts/delete/52. Obviously you could/should
> build the logic into the controller to check the rights for the user
> to take an action, in this case maybe delete a particular blog post,
> only if the user has rights to do so. That goes without saying, and I
> consider a must anyway.
>
> But I would still prefer to not even expose the application controller
> logic at all to the end user if that is possible. I would assume that
> CakePHP can just as easily use POST variables to contain the action
> and params and then a redirect to avoid the "browser refresh" issue
> that POST tends to create. Is this assumption correct? Am I crazy for
> even worrying about this? I'm curious if most people just follow the
> generic CakePHP convention for URLs (controller/action/params), or if
> there is something that is a better practice to implement.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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: share function in views

2009-01-12 Thread Adam Royle

If it's just a simple function, then you can place it in bootstrap.php
and it will be globally available.

Cheers,
Adam

On Jan 12, 8:51 pm, Henrik Gemal  wrote:
> I have a custom html escape function that I like to be able to use in
> two views.
> What's the best way to share function between views?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Simple String Manipulations?

2009-01-10 Thread Adam Royle

Try this in your model...

class Whatever extends AppModel {
function beforeSave() {
$data = &$this->data[$this->alias];
if (!empty($data['title'])) {
$data['title'] = ucwords($data['title']);
}
return parent::beforeSave();
}
}

Your could then make this a behavior down the track if you want to re-
use this functionality.

Cheers,
Adam

On Jan 10, 10:20 am, ingenious paradox  wrote:
> I'm very new to cake and I was hoping someone could demonstrate the
> code necessary to take a form field input value and convert it to
> uppercase. I know this is simple with the ucwords() function, but for
> some reason I just can't get it to work properly.
> I read that you have to perform your own methods before cakes
> execution of built in functions so I tried the beforeFilter() and no
> luck.
>
> Some where in referencing the correct variable, converting it, and
> then passing it back to the array that cake creates I'm screwing
> things up. I simply want to take a word and capitalize it before it
> gets stored in my database.
>
> this->($confused);
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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: TreeBehaviour reorder performance issue

2009-01-10 Thread Adam Royle

I've had a tree with that many records and had no issues re-ordering
it (maybe 1-2 seconds max).

I seem to remember needing to set $this->MyModel->recursive = -1;
before calling the reorder methods. Maybe that is your problem - you
might be selecting more than you need to?

Maybe you should show your code though, because 10 queries is a
lot!

Cheers,
Adam

On Jan 10, 8:40 pm, "Peter A. Shevtsov"  wrote:
> Hello,
>
> I have a tree with about 400+ records and when I try to call reorder method
> it executes about 10 SQL queries and takes several minutes to finish. Is
> there any way to optimize it?
>
> Thanks!
>
> --
> Пётр Шевцов
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: dynamic content from infinite 'tree' categories

2009-01-09 Thread Adam Royle

Maybe you could try a real tree component?

http://blogs.bigfish.tv/adam/2008/02/12/drag-and-drop-using-ext-js-with-the-cakephp-tree-behavior/

Cheers,
Adam

On Jan 9, 8:19 pm, "designv...@gmail.com" 
wrote:
> Has anyone done aything along the lines of dynamically adding divs/
> select boxes as a user drills down through tree data?
>
> ie select box with top level categories, then they make a choice and
> another select appears etc etc until they reach the lowest level?
>
> I have down updating select boxes before but never with an unknown
> depth, just wondered if anyone had any suggestions?
>
> TIA
>
> d.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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 requested for a "complex" find

2009-01-08 Thread Adam Royle

Hi Rob,

For complex conditions you're probably better off using a combination
of strings and arrays.

I find they're much simpler to read than cake's array syntax...

'conditions' => array(
array('alert_subject_id' => $subject),
'(Alert.start_date IS NULL OR Alert.start_date < NOW())',
'(Alert.end_date IS NULL OR Alert.end_date > NOW())',
)


Also, the reason why your initial array wasn't working is because you
defined two "OR" keys in the same array, when only one can exist.

Cheers,
Adam

On Jan 8, 6:58 am, Rob Wilkerson  wrote:
> I'm working on what I guess I would consider the very low end of a
> complex find and yet I can't seem to get it quite right.
>
> In my Alert model, I'm trying to find all of the alerts of a
> particular type whose start date is null or less than NOW and whose
> end date is null or greater than NOW:
>
> return $this->find (
>         'list',
>         array (
>                 'fields' => array ( 'Alert.message' ),
>                 'conditions' => array (
>                         'Alert.alert_subject_id' => strtoupper ( $subject ),
>                         'OR' => array (
>                                 'Alert.start_date'     => null,
>                                 'Alert.start_date <= ' => date ( 'Y-m-d 
> H:i:s' )
>                         ),
>                         'OR' => array (
>                                 'Alert.end_date'       => null,
>                                 'Alert.end_date >= '   => date ( 'Y-m-d 
> H:i:s' )
>                         )
>                 )
>         )
> );
>
> The SQL I get out seems to ignore the start_date conditions, but
> includes the end_date conditions as I'd expect. If I switch the order,
> then the end_date conditions are ignored and the start_date conditions
> are translated to SQL as I'd expect. In my debug output, here's what I
> get for this particular find() syntax (formatted for some semblance of
> readability):
>
> SELECT
>    `Alert`.`id`,
>    `Alert`.`message`
> FROM `alerts` AS `Alert`
> WHERE
>    `Alert`.`alert_subject_id` = 'TICKET'
>    AND (
>       (`Alert`.`end_date` IS NULL) OR (`Alert`.`end_date` >=
> '2009-01-07 15:54:09')
>    )
>
> As you can see, no mention of the start_date conditions at all. Am I
> missing an array or something? Have I been looking at this too long to
> see something else that's absurdly obvious?  I'm using the final
> release of v1.2.
>
> Any additional eyeballs would be a much appreciated sanity check.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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: Fatal error: Call to a member function findByFromApplication() on a non-object in

2009-01-07 Thread Adam Royle

No, accessing models by default is always singular, not plural.

On Jan 8, 1:21 pm, gearvOsh  wrote:
> If it is within the Billings model itself, it is $this->.
>
> But if its used in a controller, it is $this->Billings->.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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: Fatal error: Call to a member function findByFromApplication() on a non-object in

2009-01-07 Thread Adam Royle

It is saying $this->Billings is not an object try singular - $this-
>Billing->findByFromApplication()

On Jan 8, 12:54 pm, "Louie Miranda"  wrote:
> Guys,
>
> I have a field name from_application and I tried to do a:
>
> $results = $this->Billings->findByFromApplication('10');
> print_r($results);
>
> Well, the result I am getting is Undefined property:
> BillingsController::$Billings [*CORE/app/controllers/billings_controller.php
> *, line *70*]
>
> *Fatal error*: Call to a member function findByFromApplication() on a
> non-object in */web/app/controllers/billings_controller.php* on line *70*
>
> Which is weird? Any ideas? Please help!
>
> --
> Louie Miranda (lmira...@gmail.com)http://www.louiemiranda.net
>
> Security Is A Series Of Well-Defined Steps
> chmod -R 0 / ; and smile :)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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 get the find result more convenience?

2009-01-06 Thread Adam Royle

Without seeing your sql code, it's hard to help, but I recommend you
learn the Model methods available to you, as it can often shorten the
amount of code needing to be written. Often I use a mixture between
arrays and strings for my conditions, etc, depending on how
complicated the query is.

$unreadCount = $this->MyModel->find('count', array('conditions' =>
'status < 1'));

which is the equivalent of:

$sql = "SELECT COUNT(*) as unread_count FROM my_models WHERE
my_models.status < 1";
$results = $this->MyModel->query($sql);
$unreadCount = $results[0][0]['unread_count'];

You can also go a step further and put the "find" logic into your
model, but just take one step at a time :)

Cheers,
Adam

Rimoe wrote:
> hi,everyone!
>
> I'm a newbie.
>
> I have saw In the bake view, If you want to use the resultset,
> only use the $form->input('mail'),
>
> but the find result ()
> In the controller
> $unreadcounts==$this->query($sql);
> $this->set(compact('unreadcounts'));
>
> in the view, I must to get the result use the
> $unreadcounts[0][0]['unread'];
> It's so long.
> what has the short method to get the result of 'unread'
>
> Thank U.
>
> rimoe
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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: debug a failed save()

2009-01-06 Thread Adam Royle

Can you show your model & app model code? I'm guessing somewhere
you're not returning true from a beforeValidate() or beforeSave()
method.

Eg. you should do something like this if that's the case.

function beforeSave() {

if (  ) {
// cancel the save
return false;
} else {
// modify a field before saving
$this->data[$this->alias]['field'] = 'blah';
}

// ask our parent if it's ok to save!
return parent::beforeSave();

}


On Jan 6, 5:13 am, brian  wrote:
> I've gone as far as I can in debugging why a save() is failing. I'd
> appreciate any tips.
>
> The situation:
>
> I have a form on a user's profile page for uploading a headshot image.
> The image is being saved ok. The part that's failing is updating the
> user's record in the DB.
>
> The code:
> $this->Member->recursive = -1;
> $this->data = $this->Member->read(null, $id);
>
> ...  // upload and add headhsot info to $this->data['Member']
>
> $this->Member->validate = array();
>
> if ($this->Member->save($this->data))
> {
>         $this->flash('image uploaded', $referer);}
>
> else
> {
>         //debug($this->data);exit;
>         //debug($this->Member->validationErrors);exit;
>         $this->flash('DB info not saved', $referer);
>
> }
>
> As you can see, I've disabled validation in an attempt to get this to
> work. And I've also tried dumping both $this-data and
> $validationErrors. The latter, as expected, is empty. The former
> appears perfectly fine. An example:
>
> Array
> (
>     [Member] => Array
>         (
>             [id] => 1596
>             [created] => 2009-01-05 03:32:31
>             [modified] => 2009-01-05 13:26:03
>             [last_login] => 2009-01-05 13:26:03
>             ...
>             [headshot] => test1_test1.png
>             [headshot_width] => 225
>             [headshot_height] => 228
>             [headshot_mimetype] => image/png
>         )
> )
>
> I've enabled query logging for the DB and dropped this in just before
> the attempt to save:
>
> $this->Member->query("SELECT('SAVING ...')");
>
> This is the result:
>
> 5 Query       SELECT('SAVING ...')
> 5 Query       SELECT COUNT(*) AS `count` FROM `users` AS `Member`
> WHERE `Member`.`id` = 1596
> 5 Quit
>
> That query, used in a terminal, returns 1, as expected.
>
> So, can anyone suggest some other way to debug this failed save? I
> need to figure out why Cake packed it in after that count() query. The
> Model class doesn't seem to have anything else available beside
> $validationErrors. I hunted around a little in DataSource and DboMysql
> but it doesn't appear to be an SQL issue.
>
> In a nutshell, where does one look to learn the reason for a failed
> save? And, as the save method is in the model, why doesn't the model
> expose failed saves?
>
> A note about the users/Member thing: I'm using inheritance here but I
> can confirm that saves do work fine. It's just this one action that's
> giving me trouble. In any case, the point of this is that I don't know
> where to look to find out for sure.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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: include calculated data in the model

2009-01-05 Thread Adam Royle

Just add a physical "amount" field to your orders table, and then add
a method to your Order model which calculates the order total and
updates the order. Then call that method whenever you add/modify/
delete your OrderProducts.

On Jan 6, 8:21 am, Yannis  wrote:
> I have this kind of db structure:
>
> Each Account has many Orders.
> Each Order has many OrderProducts.
> OrderProduct contains fields like product name, price, quantity.
>
> I want to show at the account view a list of related orders and each
> order has a field "amount" which will be the sum of related
> orderproducts price * quantity.
>
> Is this possible? Where and how should I put the relation data?
>
> thank you for any help!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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: Return compressed XML

2009-01-04 Thread Adam Royle

If you're sending unique data for each request, I wouldn't bother
using the MediaView. Just output data in your views and set some
custom headers.

You can also find out about an easier way to gzip output in cakephp
here:

http://debuggable.com/posts/issues-with-output-buffering-in-cakephp:480f4dd5-b4fc-42a7-a5ab-4544cbdd56cb

Cheers,
Adam

On Jan 4, 2:15 pm, ace2600  wrote:
> Hi,
>
> I want to return unique compressed XML for each user request.
> Something like this in the controller:
>
> public function download()
> {
>     $filename = 'some_temporary_file_name.gz';
>     $this->view = 'Media';
>     $params = array(
>               'id' => $filename,
>               'name' => 'some_temporary_file_name',
>               'download' => true,
>               'extension' => 'gz',
>               'path' => ''
>     );
>
>     // open file for writing with maximum compression
>     $zp = gzopen($filename, "w9");
>     // write string to file
>     gzwrite($zp, $unique_xml_here);
>     // close file
>     gzclose($zp);
>
> }
>
> How can I create a unique file for each request and have the file be
> deleted after the user downloaded it? I'm mostly concerned with the
> deleting part unless there is a convenient CakePHP for the unique file
> part.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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: Exposing a Web Service on a Cake Shell

2009-01-04 Thread Adam Royle

Todays databases are designed to handle a crapload of queries, so
don't be afraid to take advantage of this. Just make sure you've got
indexes on the right columns and your queries are using those indexes.
You could possible create another table which is optimised to hold any
database changes made along with a timestamp.

Cheers,
Adam

On Jan 4, 6:44 pm, "Juan Luis Baptiste" 
wrote:
> Hi,
>
> It's possible to expose a web service that receives some data on a
> Cake shell? I have a cake shell that monitors a log and reads from it
> some data and compares it with another data in a database to do some
> stuff. The problem is that if the data in the database get's updated,
> the only way to get it into the cake shell without querying the
> database each time the shell reads something from the log file is by
> restarting the cake shell. I was thinking that I could expose a web
> service method on the cake shell that receives the new data it needs
> to compare, so it could be invoked from the cake web application that
> saves the data into the database. Is this possible ? or anyone else
> has another solution that avoids querying the database on each read
> from the log ?
>
> Cheers,
> Juan Luis
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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: Adding table row with AJAX

2009-01-02 Thread Adam Royle

It is my understanding that CakePHP is planning to migrate to jQuery
in the near future (much like the rest of the world, even my
grandmother, and she doesn't even have a computer!).

I use jQuery to add an extra row by cloning the last row, incrementing
the ids and names of the elements and appending it to the container.
Works very well without the need for any "ajax".

Cheers,
Adam

On Jan 3, 7:31 am, "rhythmicde...@gmail.com" 
wrote:
> Can someone please give me some pointers on this? I have a table. I
> have a button that when clicked should called an action. That action
> should return the HTML for a new row. The row should then be appended
> to the table.
>
> If I use 'update' in the options array the entire content of the page
> is put inside the row.
> If I use 'append' in the options array nothing happens.
>
> echo $ajax->link('Click Here', 'edit/', array('update' => 'mytable'));
>
> I have looked through the manual and found nothing. I reviewed the API
> and followed the link to the definition of ajax->link but did not find
> anything to help.
>
> I have been advised to use jQuery. But I want to make it work with
> what CakePHP recommends.
>
> Thanks for any help.
>
> VIEW
>
> Testing AJAX with CakePHP and Prototype and Scriptaculous
>
> 
>         
>                 Row1
>         
> 
>
> 
> This is a div
> 
>
>          echo $ajax->link('Click Here', 'edit/', array('update' =>
> 'mytable'));
> ?>
>
> ACTION
>
>         function edit()
>         {
>                 $this->pageTitle = 'Edit Page';
>                 if($this->RequestHandler->isAjax())
>                 {
>                         $this->layout = 'ajax';
>                         echo 'This is a row';
>
>                 }
>         }
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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 in model designing

2008-12-31 Thread Adam Royle

For simplicity's sake I would keep them in the one table, and
dynamically change the $validate array in my beforeValidate method of
the model to suit.

I've never used this but it may help you:
http://bakery.cakephp.org/articles/view/conditinalvalidation-behavior

Cheers,
Adam

On Dec 26 2008, 11:40 pm, kaushik  wrote:
> I am going develop a system where there is two types of members.
> During registration or edit profile, there will be some common fields
> as well as some member type specific fields. Some of the common fields
> are mandatory, some are not. Same is true for member type specific
> fields. But both type of members will share same log in panel and
> other features. So I will like to store them in same table. But I am
> facing problem to create the model for it and write the validate code
> there.
> Anyone can give me any idea for that issue.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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: what's wrong with my route?

2008-12-30 Thread Adam Royle

I don't usually care about routes for my admin controllers since no
one except administrators see them, so if it was me I wouldn't worry
about it.

However you could probably simplify your routes:

Router::connect('/admin/islandnews/:action/*', array('controller' =>
'newsletters', 'admin' => true));

Hope that helps.

Cheers,
Adam

On Dec 31, 9:57 am, brian  wrote:
> using 1.2.0.7962
>
> The model is Newsletter but I'd like to keep the legacy path,
> "islandnews". Some of the routes are working but others are not. For
> instance, this works:
> Router::connect('/admin/islandnews',
>         array('controller' => 'newsletters', 'action' => 'index', 'admin' => 
> true)
> );
>
> However, in that view, I set up some links using the array notation:
> $edit_link = $html->link(
>         'edit',
>         array(
>                 'controller' => 'newsletters',
>                 'action' => 'edit',
>                 $newsletter['Newsletter']['id']
>         ),
>         array('title' => 'edit this edition')
> );
>
> Now, from what I understand, the fact that I have the following route set up:
> Router::connect('/admin/islandnews/edit/:id',
>         array('controller' => 'newsletters', 'action' => 'edit', 'admin' => 
> true),
>         array(
>                 'id' => '[0-9]?',
>                 'pass' => array('id')
>         )
> );
>
> ... should cause Cake to create this 
> URL:http://my.domain/admin/islandnews/edit/29
>
> Instead, I get:http://my.domain/admin/newsletters/edit/29
>
> If, in the view, I give "islandnews" for the controller, the link  is
> good, but the route still is not recognised.
>
> Strangely, in my admin_add() action, I have the following:
>
> if ($this->Newsletter->save($this->data))
> {
>         $this->flash('The newsletter has been created', array('action' => 
> 'edit'));
>
> ... which redirects me to /admin/newsletters/edit (again, the route is
> ignored) where I have:
>
> $form->create('Newsletter', array('action' => 'edit'))
>
> Now, suddenly the route is recognised and I get a form with
> action="/admin/islandnews/edit/29"
>
> However, the route fails when the form is posted. So, how/why did the
> route get written that way? What the heck am I doing wrong here?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Order associated data

2008-12-30 Thread Adam Royle

That's how I would have done it. Maybe I am imagining things but I'm
sure that worked in the past. Maybe a good chance to dig through the
core and submit an enhancement on trac.

Cheers,
Adam

On Dec 31, 8:13 am, Daniel  wrote:
> Hi, thank you for the advice - the first one works fine, but the
> second one doesn't.
>
> I've added it to the top of the Product model, just below the $name
> variable, like so:
>
> var $name = 'Product';
> var $order = 'Product.title ASC';
>
> Any idea?
>
> On Dec 30, 10:04 pm, Adam Royle  wrote:
>
> > Yes, you've got the categories/products thing set up as I would do it.
>
> > With ordering, you can do it both ways:
>
> > 1) Just for this association - use the 'order' key when setting up the
> > association in categories model... eg.
>
> >http://book.cakephp.org/view/78/Associations-Linking-Models-Together#...
>
> > 2) Globally - add it into the products model.
>
> > var $order = 'Product.name DESC';
>
> > Cheers,
> > Adam
>
> > On Dec 31, 7:31 am, Daniel  wrote:
>
> > > Hi, me again, I hope you don't mind me coming back with another
> > > question.
>
> > > I'm not sure if I'm going about this the best way or not, so some
> > > general advice would be handy.
>
> > > I've got two models: Category and Product, Product belongs to
> > > Category, with Category having many Product (with me so far?).
>
> > > I'm using the view function within the Categories controller to list
> > > the products displayed within that category. I'm using the read()
> > > function to pull the data from the Category model, which of course is
> > > pulling with it data from the associated Product model - which I'm
> > > then just using a simple foreach ($category['Product'] as $product) {}
> > > to display within the view.
>
> > > Two questions - first, is this the best way of displaying products
> > > within a specific category.
>
> > > Second - is there anyway to change the order of the $category
> > > ['Product'] array, so that it's ordered by a field other than the id.
>
> > > Thank you
>
> > > - Daniel
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Order associated data

2008-12-30 Thread Adam Royle

Yes, you've got the categories/products thing set up as I would do it.

With ordering, you can do it both ways:

1) Just for this association - use the 'order' key when setting up the
association in categories model... eg.

http://book.cakephp.org/view/78/Associations-Linking-Models-Together#Relationship-Types-79

2) Globally - add it into the products model.

var $order = 'Product.name DESC';

Cheers,
Adam

On Dec 31, 7:31 am, Daniel  wrote:
> Hi, me again, I hope you don't mind me coming back with another
> question.
>
> I'm not sure if I'm going about this the best way or not, so some
> general advice would be handy.
>
> I've got two models: Category and Product, Product belongs to
> Category, with Category having many Product (with me so far?).
>
> I'm using the view function within the Categories controller to list
> the products displayed within that category. I'm using the read()
> function to pull the data from the Category model, which of course is
> pulling with it data from the associated Product model - which I'm
> then just using a simple foreach ($category['Product'] as $product) {}
> to display within the view.
>
> Two questions - first, is this the best way of displaying products
> within a specific category.
>
> Second - is there anyway to change the order of the $category
> ['Product'] array, so that it's ordered by a field other than the id.
>
> Thank you
>
> - Daniel
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: HTML 4 specific CakePHP?

2008-12-28 Thread Adam Royle

Is it possible that you can just overwrite the tag list with your HTML
equivalents?

http://bakery.cakephp.org/articles/view/overriding-specific-html-tags-before-using-helper-methods

Cheers,
Adam

On Dec 29, 8:24 am, gearvOsh  wrote:
> I have not found any option or setting for using HTML or XHTML.
>
> All I have seen is that you can set the Doctype, but even if you set
> the Doctype as HTML, all the tags are in XHTML.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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: Run Queries Unrelated to Controller

2008-12-26 Thread Adam Royle

If your models are not directly related (as you've said above) you can
do this to load the other models.

var $uses = array('Job', 'OtherModel', 'OtherModel2');

function index() {
  $this->OtherModel->find('all');
  $this->OtherModel2->find('all');
  // ... etc
}

Or if you won't be using the other models in any other actions, you
could do this (leave out the var $uses):

function index() {
  $this->OtherModel = ClassRegistry::init('OtherModel');
  $this->OtherModel2 = ClassRegistry::init('OtherModel2');
  $this->OtherModel->find('all');
  $this->OtherModel2->find('all');
  // ... etc
}

On Dec 27, 9:14 am, "Chad Casselman"  wrote:
> I have a Controller for Jobs with a model Job.
>
> When I hit /jobs  (the index function of Job Controller), I need to run a
> query on 2 other tables (not joined to Job) to find values to manually
> insert into jobs before actually displaying the index.
>
> I have tried several things but can't seem to make any progress on this.
>
> Can anyone help me with this?
>
> 1) select fields from a join on customers and packages (complex conditions)
> 2) iterate through results and insert/update values in job
> 3) display jobs
>
> Thank you in advance.
>
> Chad
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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: Containable behavior not working as expected

2008-12-25 Thread Adam Royle

Admittedly I skimmed through your post, but what sql is executed? Are
sure you sure you've attached the Containable behavior to your model?

Cheers,
Adam

On Dec 26, 1:28 pm, Aidan Lister  wrote:
> I'm having trouble with the Containable behavior.
>
> My first query,
>  $this->Controller->Paper->recursive = 3;
> $this->Controller->Paper->Volume->unbindModel(array('hasMany' => array
> ('Paper')));
> $data = $this->Controller->Paper->find('first', array(
>             'conditions' => array('Paper.id' => $id)));
> debug($data);
> ?>
>
> Returns the following information:
>
> 
> html/controllers/components/generate.php (line 185)
> Array
> (
>     [Paper] => Array
>         (
>             [id] => 1
>             [weight] => 4
>             [volume_id] => 1
>             [user_id] =>
>             [slug] => xx
>             [is_deleted] => 0
>             [is_published] => 1
>             [is_doisubmitted] => 1
>             [created] => 2000-01-01 00:00:00
>             [modified] => 2008-12-26 14:05:01
>             [deleted] =>
>             [published] =>
>             [htmlgenerated] => 2008-12-26 14:05:01
>             [pdfgenerated] => 2008-12-26 13:44:41
>             [doisubmitted] => 2008-12-26 13:45:08
>             [legacy_key] => ailleres
>             [title] => xxx
>             [titleabbrev] => xxx
>             [keywords] => xxx
>         )
>
>     [Volume] => Array
>         (
>             [id] => 1
>             [created] => 2008-12-11 20:11:42
>             [modified] => 2008-12-21 22:48:52
>             [published] => -00-00 00:00:00
>             [is_published] => 1
>             [type] => Normal
>             [title] => xx
>             [number] => 01
>             [year] => 2000
>             [blurb] =>
>             [User] => Array
>                 (
>                     [0] => Array
>                         (
>                             [id] => 2
>                             [editor_id] => 81
>                             [group_id] => 4
>                             [is_deleted] => 0
>                             [type] => Individual
>                             [created] => 2008-11-26 00:07:53
>                             [modified] => 2008-12-18 12:01:47
>                             [deleted] => -00-00 00:00:00
>                             [name] => yyy
>                             [network] =>
>                             [UsersVolume] => Array
>                                 (
>                                     [id] => 3
>                                     [user_id] => 2
>                                     [volume_id] => 1
>                                     [weight] => 100
>                                 )
>
>                            ...
>
>                         )
>
>                 )
>
>         )
>
>     [User] => Array
>         (
>         )
>   ...
> )
> 
>
> As you can see, The relationship Volume->User is working as expected,
> and any HABTM Users are returned with the Volume.
>
> Attempting to replicate this with Containable however, I can't get any
> User information.
>
>          $data = $this->Controller->Paper->find('first', array(
>             'conditions' => array('Paper.id' => $id),
>             'fields' => array('title', 'id', 'created'),
>             'contain' => array(
>                 'Volume' => array(
>                     'fields' => array('id', 'title', 'number'),
>                     'User' => array(
>                         'order' => 'UsersVolume.weight ASC',
>                         'fields' => array('id', 'name'),
>                 );
>         debug($data);
> ?>
>
> The output is:
>
> 
> html/controllers/components/generate.php (line 196)
> Array
> (
>     [Paper] => Array
>         (
>             [title] => xxx
>             [id] => 1
>             [created] => 2000-01-01 00:00:00
>         )
>
>     [Volume] => Array
>         (
>             [id] => 1
>             [title] => yyy
>             [number] => 01
>         )
>
> )
> 
>
> I'm sure it's something simple ... I would appreciate any help.
>
> Thanks,
> Aidan
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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: parseExtension and 404 throwing

2008-12-25 Thread Adam Royle

Are you including the RequestHandler component in AppController? If
not, that would explain why it's not working.

You can check the view path using pr($this); in your controller in
your view() and beforeRender() methods. I would check in both,
analysing all the values, etc.

Cheers,
Adam


On Dec 25, 9:37 pm, Jne  wrote:
> The problem is that the MovieCommentsController cannot be more simpler
> thant that !
> (And there are no funny stuff in the app_controller)
>
> Does your application also invoque parameters in the parseExtension ?
> Because in my case there are
>
> class MovieCommentsController extends AppController {
>
>         var $name = 'MovieComments';
>         var $helpers = array('Html', 'Form');
>
>         var $paginate = array(
>                 'order' => 'MovieComment.created DESC'
>         );
>
>         function beforeFilter() {
>                 parent::beforeFilter();
>                 $this->Auth->allowedActions = array('feed');
>         }
>
>         function feed($id = null) {
>
>                 //Configure::write('debug', 0);
>
>                 $params = array(
>                         'contain' => array(
>                                 'MovieComment' => array(
>                                         'fields' => 
> array('MovieComment.comment',
> 'MovieComment.created'),
>                                         'order' => 
> array('MovieComment.created' => 'desc'),
>                                         'limit' => 30,
>                                         'User' => array(
>                                                 'fields' => 
> array('User.firstname', 'User.lastname')
>                                         ),
>                                         'Movie' => array(
>                                                 'fields' => 
> array('Movie.slug')
>                                         )
>                                 )
>                         ),
>                         'conditions' => array('Movie.id' => $id, 
> 'Movie.avail' => 1),
>                         'fields' => array('Movie.title', 'Movie.description',
> 'Movie.created', 'Movie.slug'),
>                         );
>
>                 $comments = $this->MovieComment->Movie->find('first', 
> $params);
>
>                 $channel = array('title' => 'sph3re.tv : latest comments on ' 
> .
> $comments['Movie']['title'] ,
>                                 'link' => array('controller' => 
> 'movie_comments', 'action' =>
> 'feed', 'ext' => 'rss', $id),
>                                 'description' => 'Recent comments posted on 
> sph3re.tv',
>                                 'language' => 'en-us'
>                                 );
>
>                 //debug($comments); exit();
>                 $this->set(compact('channel', 'comments'));
>
>         }
>
> I do not think it can be more basic...
>
> And what is really strange is that both :
>
> http://beta.sph3re.tv/movies/mainfeed.rssandhttp://beta.sph3re.tv/xmlconfig/400.xmlare
>  both OK
>
> And everything is OK in RC3.
>
> Can you please help on how to track the view path ?
>
> Thank you !
>
> Jérôme
>
> On 25 déc, 12:14, Adam Royle  wrote:
>
> > Hmm... that's unusual. I did a quick test with one of my apps that
> > uses parseExtensions, upgraded it from RC3 to RC4 and it worked as
> > expected.
>
> > Maybe there is something else in your application which is overwriting
> > the view path after it is set by the RequestHandler component? Try
> > following through the code to see why the "rss" folder is not being
> > set in the view path and you should find your answer.
>
> > Cheers,
> > Adam
>
> > On Dec 25, 8:12 pm, Jne  wrote:
>
> > > Hi Adam,
>
> > >http://beta.sph3re.tv/movie_comments/feed/151.rssispluggedto RC4
> > > with Debug = 2 (and cache disabled) and it's complaining about view
> > > not found but it's looking for the wrong one since the feed.ctp is in
> > > the views/movie_comments/rss/ dir as it is supposed to be.
>
> > > Thanks !
>
>

Re: Using dynamic values in model validation

2008-12-25 Thread Adam Royle

Controllers talk to models, not the other way round, so you would need
to call a method in your model from your controllers, passing the
params as necessary.

On Dec 23, 8:52 am, gearvOsh  wrote:
> No not that. In the models beforeValidate() is it possible for me to
> do like $controller->params?
>
> UsersController -> User Model
>
> So in User::beforeValidate() can I get UsersControllers params, is
> basically what im asking?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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: parseExtension and 404 throwing

2008-12-25 Thread Adam Royle

Hmm... that's unusual. I did a quick test with one of my apps that
uses parseExtensions, upgraded it from RC3 to RC4 and it worked as
expected.

Maybe there is something else in your application which is overwriting
the view path after it is set by the RequestHandler component? Try
following through the code to see why the "rss" folder is not being
set in the view path and you should find your answer.

Cheers,
Adam

On Dec 25, 8:12 pm, Jne  wrote:
> Hi Adam,
>
> http://beta.sph3re.tv/movie_comments/feed/151.rssis plugged to RC4
> with Debug = 2 (and cache disabled) and it's complaining about view
> not found but it's looking for the wrong one since the feed.ctp is in
> the views/movie_comments/rss/ dir as it is supposed to be.
>
> Thanks !
>
> Jérôme
>
> On 25 déc, 09:48, Adam Royle  wrote:
>
> > Have you tried turning debug to 2 and seeing what the error is?
>
> > Cheers,
> > Adam
>
> > On Dec 25, 3:40 am, Jne  wrote:
>
> > > Hi,
>
> > > on my website I have a 'movie_comments' controller and a feed($id)
> > > action.
>
> > > With RC3 :http://sph3re.tv/movie_comments/feed/151.rssisoutputtingthe 
> > > proper
> > > RSS feedhttp://sph3re.tv/movies/mainfeed.rssalso
>
> > > With RC4 (caching 
> > > disabled)http://sph3re.tv/movie_comments/feed/151.rssisthrowinga 404 error
> > > buthttp://sph3re.tv/movies/mainfeed.rssstillworks
>
> > > On my routes.php I have the following line :    Router::parseExtensions
> > > ('rss', 'xml');
>
> > > Any idea why this has changed between the two releases ?
>
> > > Thanks !
>
> > > Jérôme
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: parseExtension and 404 throwing

2008-12-25 Thread Adam Royle

Have you tried turning debug to 2 and seeing what the error is?

Cheers,
Adam

On Dec 25, 3:40 am, Jne  wrote:
> Hi,
>
> on my website I have a 'movie_comments' controller and a feed($id)
> action.
>
> With RC3 :http://sph3re.tv/movie_comments/feed/151.rssis outputting the proper
> RSS feedhttp://sph3re.tv/movies/mainfeed.rssalso
>
> With RC4 (caching disabled)http://sph3re.tv/movie_comments/feed/151.rssis 
> throwing a 404 error
> buthttp://sph3re.tv/movies/mainfeed.rssstill works
>
> On my routes.php I have the following line :    Router::parseExtensions
> ('rss', 'xml');
>
> Any idea why this has changed between the two releases ?
>
> Thanks !
>
> Jérôme
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Using dynamic values in model validation

2008-12-22 Thread Adam Royle

I don't really understand your question... are you asking if you can
see what data is going to be saved from inside the beforeValidate()
method?

If so, look at  $this->data

Cheers,
Adam



On Dec 22, 8:20 pm, gearvOsh  wrote:
> Thanks, also is there a way I can get the parent controller data as
> well?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Using dynamic values in model validation

2008-12-21 Thread Adam Royle

When defining class properties you can't use expressions - only data
structures, so you need to populate the $validate array dynamically
inside the model. You can do this in beforeValidate() method in your
model, but be sure to return true.

beforeValidate() {
  $this->validate['fieldName'] = array('between' => array(...
etc ...));
  return true;
}

Cheers,
Adam

On Dec 22, 4:57 pm, gearvOsh  wrote:
> Is there a way to use dynamic variables within the Model validation,
> an example below.
>
> 'between' => array(
>         'rule' => array('between', $passMin, $passMax),
>         'message' => 'Password must be between '. $passMin .' and '. $passMax
> )
>
> I have an array of config settings that I would like to use here, but
> am lost on a way to do this.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: exclude form helper markup?

2008-12-21 Thread Adam Royle

I was the same as you when I first started, but over time I started
seeing the usefulness of cake's magic.

You can change the label easily by doing this:

input('email', array('label' => 'Your Email
Address:')); ?>

Cheers,
Adam

On Dec 22, 6:58 am, justclint  wrote:
> I notice when I use the form helper like:
>
> input('Email'); ?>
>
> it keeps resulting with an added div tag around it like so:
>
> Email type="text" id="Email" value="" name="data[Email]"/>
>
> Is there a way to prevent the form adding its own markup?
>
> Also, I notice cakephp automatically gives the input name the name of
> the label. But say I want my label and input name to be different. How
> do I accomplish this?
>
> For example, I would like my label to be Email: (with :) but I dont
> want the : in my input name.
>
> Thanks!
>
> justclint
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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 CakePHP 1.2 recursive including content to page, big problem.

2008-12-21 Thread Adam Royle

Oh, and make sure you have writable tmp folders and mod_rewrite and
AllowOverride, etc, all the things you should check for a standard
install.

On Dec 21, 6:44 pm, Petr Vytlačil  wrote:
> Hi i developing a application for my friends, i try this applicaton on
> two webhosting (on local and other) all go very fine, but when i
> uploaded application on webhosting my friends application show bad.
>
> My problem you can see on this url:http://www.pdreality.cz/, how you
> can see in content is show full page, its look like recursing include.
> If you want show in source output html, its look like very bad .-(
>
> There is source of my default layout:
>
>  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
> http://www.w3.org/1999/xhtml";>
> 
>     
>     
>     
>     
>     
>         PD Reality | 
>                          echo $html->meta('icon');
>                 echo $html->css('main');
>                 echo $html->css('jquery.lightbox.css');
>                 echo $scripts_for_layout;
>         ?>
>         link('jquery.js'); ?>
>         link('jquery.lightbox-0.5.pack.js'); ?>
> 
> 
>         
>                 
>                         PD Reality
>                         element('topmenu');?>
>                         
>                 
>                 
>                         
>                         
>                         
>                                 PD REALITY Vám 
> pomůže při prodeji
> nebo nákupu realit
>                                 
>                                         Naše realitní kancelář, Vám ráda 
> pomůže s prodejem nebo
> pronájmem Vaší reality.
>                                         Pomůžeme Vám nalézt vhodné 
> bydlení, rekreační chatu nebo
> komerční prostory pro Vaše podnikání.
>                                         Spotředkujeme Vám vhodný úvěr pro 
> financování nákupu vybrané
> nemovitosti.
>                                 
>                         
>                 
>                 
>                         
>                                 element('leftpanel');?>
>                         
>                         
>                                 flash(); ?>
>                                 
>                         
>                         
>                                 element('rightpanel');?>
>                         
>                         
>                 
>                 
>                         Copyright (c) 2008 PD Reality - Realitní kancelář 
> | realizace:  href="http://www.4people.cz";>Webdesign 4People
>                 
>         
>         
> 
> 
>
> I tried show page only with blank default layout and in output is
> still in body tag is any h2.
> Im desperate, I dont know how solve this problem, on two webhosting
> application show good but on this no.
>
> THX
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Problem with CakePHP 1.2 recursive including content to page, big problem.

2008-12-21 Thread Adam Royle

If you look at the page title, it says "PD Reality | Errors" - this
indicates there were errors. Double-check to make sure you have
uploaded all files, database connection is fine, and you've cleared
the tmp folders. Set debug = 2 and it should show you what is going
wrong. Otherwise, check the app and server logs.

Cheers,
Adam

On Dec 21, 6:44 pm, Petr Vytlačil  wrote:
> Hi i developing a application for my friends, i try this applicaton on
> two webhosting (on local and other) all go very fine, but when i
> uploaded application on webhosting my friends application show bad.
>
> My problem you can see on this url:http://www.pdreality.cz/, how you
> can see in content is show full page, its look like recursing include.
> If you want show in source output html, its look like very bad .-(
>
> There is source of my default layout:
>
>  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
> http://www.w3.org/1999/xhtml";>
> 
>     
>     
>     
>     
>     
>         PD Reality | 
>                          echo $html->meta('icon');
>                 echo $html->css('main');
>                 echo $html->css('jquery.lightbox.css');
>                 echo $scripts_for_layout;
>         ?>
>         link('jquery.js'); ?>
>         link('jquery.lightbox-0.5.pack.js'); ?>
> 
> 
>         
>                 
>                         PD Reality
>                         element('topmenu');?>
>                         
>                 
>                 
>                         
>                         
>                         
>                                 PD REALITY Vám 
> pomůže při prodeji
> nebo nákupu realit
>                                 
>                                         Naše realitní kancelář, Vám ráda 
> pomůže s prodejem nebo
> pronájmem Vaší reality.
>                                         Pomůžeme Vám nalézt vhodné 
> bydlení, rekreační chatu nebo
> komerční prostory pro Vaše podnikání.
>                                         Spotředkujeme Vám vhodný úvěr pro 
> financování nákupu vybrané
> nemovitosti.
>                                 
>                         
>                 
>                 
>                         
>                                 element('leftpanel');?>
>                         
>                         
>                                 flash(); ?>
>                                 
>                         
>                         
>                                 element('rightpanel');?>
>                         
>                         
>                 
>                 
>                         Copyright (c) 2008 PD Reality - Realitní kancelář 
> | realizace:  href="http://www.4people.cz";>Webdesign 4People
>                 
>         
>         
> 
> 
>
> I tried show page only with blank default layout and in output is
> still in body tag is any h2.
> Im desperate, I dont know how solve this problem, on two webhosting
> application show good but on this no.
>
> THX
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Is it possible to redefine Inflector::slug()?

2008-12-21 Thread Adam Royle

The best solution is to write a patch and submit it into the cake
core.

On Dec 20, 11:22 am, Jaime  wrote:
> Hi all,
>
> I did a nice app which makes heavy use of Inflector::slug() to convert
> "My Strings" inoto "my_strings".
>
> However, now I find that the core slug() function is not working with
> my uppercase accentuated wovels (Á, É...). Of course I can patch
> inflector.php, but I DON'T like to touch Cake's core in order to
> easily upgrade later. I won't replace all calls to slug() in my whole
> code neither :-)
>
> Any idea? Is it possible somehow to redefine inflector::slug() or to
> extend the class in a way that I don't need to modify all my code nor
> to modify Cake's core? :-)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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: appmodel save returns true to data not in database

2008-12-20 Thread Adam Royle

If you are upgrading from 1.1 there could be many things that are
tripping you up. You controller code looks fine, although I would
change your view code to this:

create('User');
echo $form->input('about_me', array('type' => 'textarea');
echo $form->end('Submit');
?>

Also, in 1.2 "User/about_me" would be changed to "User.about_me".

Lastly maybe there is something not right in your AppModel, or any
behaviors you might have enabled?

And make sure you try running in debug mode = 2 to ensure table cache
is being refreshed.

Cheers,
Adam

mike wrote:
> please someone help with this! I'm stuck
>
> On Dec 19, 10:49�pm, mike  wrote:
> > somehow, the only sql i see in debug mode is DESCRIBE `users`
> >
> > On Dec 16, 4:28�am, grigri  wrote:
> >
> >
> >
> > > What SQL is being executed?
> >
> > > On Dec 16, 5:26�am, mike  wrote:
> >
> > > > somehow, its getting to 'test2' in the controller, however, I don't
> > > > see thedatain the table! �I actually had this working in cake1.1 but
> > > > updated to 1.2 changed htmlhelper to formhelper, and now it doesn't
> > > > work! �any help appreciated.
> >
> > > > Thanks.
> >
> > > >database:
> > > > CREATE TABLE users
> > > > (
> > > > id intNOTNULL AUTO_INCREMENT,
> > > > /* ... some other fields here */
> > > > about_me varchar(255),
> > > > PRIMARY KEY (id)
> > > > );
> >
> > > > model:
> > > > class User extendsAppModel
> > > > {
> > > > � � var $name = 'User';
> >
> > > > � � var $validate = array();
> >
> > > > }
> >
> > > > view:
> >
> > > > create('User', array('action' => '/add')); ?>
> >
> > > > textarea('User/about_me')?>
> >
> > > > submit('Add'); ?>
> >
> > > > end('Add User'); ?>
> > > > 
> >
> > > > controller:
> > > > ...
> > > > � � � � function add() {
> > > > � � � � � � � � $this->log('in newuser_controller add()');
> > > > � � � � � � � � $this->User->create();
> > > > � � � � � � � � if(!empty($this->data)) {
> > > > � � � � � � � � � � � � $this->log($this->data);
> > > > � � � � � � � � � � � � $this->log('test1');
> > > > � � � � � � � � � � � � //If the formdatacan be validated and saved...
> > > > � � � � � � � � � � � � if($this->User->save($this->data)) {
> > > > � � � � � � � � � � � � $this->log('test2');
> > > > � � � � � � � � � � � � //Set a session flash message and redirect.
> > > > � � � � � � � � � � � � � � � � $this->Session->setFlash("User Saved!");
> > > > � � � � � � � � � � � � � � � � //$this->redirect('newuser/add');
> > > > � � � � � � � � � � � � }
> > > > � � � � � � � � }
> > > > � � � � }- Hide quoted text -
> >
> > > - Show quoted text -- Hide quoted text -
> >
> > - Show quoted text -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Inflector::singularize converts "Is" to "I"

2008-12-18 Thread Adam Royle

Well, "Is" is not actually a plural... so... what behaviour would you
expect?

Maybe some context of where you are using this would be beneficial.

Cheers,
Adam

On Dec 19, 12:45 pm, bingo  wrote:
> hi bakers,
>
> I just stumbled across a weird problem and not sure whether its a bug
> in my code or Core library.
>
> I am using Inflector::Singularize to convert tags into singular form.
> However, during my test, I found singularize function converts "Is" to
> "I", which seems wrong. simply try this
>
> debug(Inflector::singularize('is'));  //this will return "I".
>
> does anyone known how to solve this problem ? (in a generic way)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Controller action randomly running twice

2008-12-18 Thread Adam Royle

By the way, you can also do this:

$this->log($this) if you want to really analyse the request. :)

Cheers,
Adam

On Dec 19, 12:13 am, WebbedIT  wrote:
> Tested your theory that something in my page with a local relative
> path was calling the page again.  To do this I added an extra
> parameter to my edit function to see if it would echo any extra params
> into my debug message.
>
> function edit($id = null, $extra = null) {
>   ..
>   $this->log('Edit form displayed for record # '.$id.' ('.$extra.')
> ', LOG_DEBUG);
>   ..
>
> }
>
> A few tests showed that when the Edit form loaded twice there wasn't
> an extra parameter being passed.
>
> 2008-12-18 14:05:59 Debug: TelephonyNumber Index
> 2008-12-18 14:06:23 Debug: Edit form displayed for record # 6815 ()
> 2008-12-18 14:06:24 Debug: Edit form displayed for record # 6815 ()
> 2008-12-18 14:06:27 Debug: TelephonyNumber Index
> 2008-12-18 14:06:31 Debug: Edit form displayed for record # 877 ()
> 2008-12-18 14:06:32 Debug: Edit form displayed for record # 877 ()
>
> It was a nice punt though as I can see how referencing a script or img
> src without a leading / would cause it to look for the script/img
> within the same action causing it to execute again.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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: Action-Specific Helpers

2008-12-18 Thread Adam Royle

What you are doing is perfectly fine, I personally use $this->helpers
[] = 'Blah'; since it's quick and easy.

Cake will only load your helper once even if it appears multiple times
in your helpers array, so don't even worry about checking for this.

Heck, just include it twice to make sure it gets loaded!

$this->helpers[] = 'Textile';
$this->helpers[] = 'Textile';
$this->helpers[] = 'Javascript';
$this->helpers[] = 'Javascript';

(j/k on that last bit by the way)

On Dec 16, 11:31 pm, Rob Wilkerson  wrote:
> How should I add multiple action-specific helpers?  Originally I had:
>
> $this->helpers[] = 'Textile';
>
> When I wanted to include the Javascript helper for this action, I
> couldn't find the "right" syntax (if there is a right syntax) to do
> so. I want to retain the default helpers, too.  I've made it work
> using traditional PHP array syntax, but am wondering if that's going
> to cause me any problems down the line.  For now, at least, I have:
>
> array_push ( $this->helpers, 'Textile' );
> array_push ( $this->helpers, 'Javascript' );
>
> Total noob question, I know, but I _am_ a noob so it probably won't be
> the last time while I get a grip on what's possible and the best
> practices. :-)
>
> Thanks.
>
> Rob
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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
-~--~~~~--~~--~--~---



  1   2   3   4   5   >