[RESOLVED] Re: Problem running shell task with DB access on HostGator
Fixed it with a some help from cakebaker at http://cakebaker.42dh.com/2007/05/07/writing-a-custom-cakephp-console-script/comment-page-1/#comment-156432 The suggestion was to remove the $uses statement and replace with App:import and then a ClassRegistry in the function. This change, plus re-reading the instructions from http://bakery.cakephp.org/articles/view/updated-swiftmailer-4-xx-component-with-attachments-and-plugins on where to put the shell script and task, enabled the shell script to work from SSH as well as in cron. (Turns out you really do need to put the shell task in /app/vendors/shell. For some reason I had it in / vendors/shell.) The final SSH and cron command looks like this for HostGator: php /home/USER NAME/public_html/cake/console/cake.php -app /home/USER NAME/public_html/app reminders lof I hope that this helps someone else in the future. Shell scripts and tasks are really cool. On Apr 8, 3:33 pm, FrederickD wrote: > I was successfully able to create a shell with a task that contains DB > access and get it to run on DreamHost in either SSH or cron. However, > our project lead chose to host the site on HostGator. As you know, > each hosting service differs ever so slightly in their implementation. > > At this point I can run my test shell that has no DB access perfectly > on HostGator. The syntax for it is much different than DreamHost. Here > is the command: > > php /home/USER NAME/public_html/cake/console/cake.php -app /home/USER > NAME/public_html/cake/app test main > > The output is as expected: > > Welcome to CakePHP v1.2.1.8004 Console > --- > App : app > Path: /home/USER NAME/public_html/cake/app > --- > Please specify which reminder task to run; LOF or Other. > > Now, when I try to use a shell with a task that has a $uses statement > I get an error like this: > > php /home/USER NAME/public_html/cake/console/cake.php -app /home/USER > NAME/public_html/cake/app reminders main > Error: Missing Database Connection. Try 'cake bake' > > The shell with the function I am trying to execute looks like this: > > > class RemindersShell extends Shell { > var $components = array('SwiftMailer'); > var $tasks = array('SwiftMailer'); > > var $uses = array('Repairorder'); > > function main() { > echo "Please specify which reminder task to run; LOF or > Other.\n\n"; > } > > } > > ?> > > The shell is the same as the test shell except with $components, > $tasks, and $uses statements. This works fine on DreamHost that has a > CLI of PHP4. To make it work I did need to change the cake console > file to force PHP5 use, as per this > articlehttp://www.milesj.me/blog/read/83/Setting-Up-Cron-Jobs-With-Cake-Shells > and DreamHost support. > > Can anyone spot what is the difference with HostGator so that my shell > with a DB reference does not execute in either SSH or cron? Do you > think I need to change the cake console file? It appears that > HostGator is running PHP5, but I am not sure about the CLI. Thank you > in advance for your help. > > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others with > their CakePHP related questions. > > You received this message because you are subscribed to the Google Groups > "CakePHP" group. > To post to this group, send email to cake-php@googlegroups.com > To unsubscribe from this group, send email to > cake-php+unsubscr...@googlegroups.com For more options, visit this group > athttp://groups.google.com/group/cake-php?hl=en Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en To unsubscribe, reply using "remove me" as the subject.
Problem running shell task with DB access on HostGator
I was successfully able to create a shell with a task that contains DB access and get it to run on DreamHost in either SSH or cron. However, our project lead chose to host the site on HostGator. As you know, each hosting service differs ever so slightly in their implementation. At this point I can run my test shell that has no DB access perfectly on HostGator. The syntax for it is much different than DreamHost. Here is the command: php /home/USER NAME/public_html/cake/console/cake.php -app /home/USER NAME/public_html/cake/app test main The output is as expected: Welcome to CakePHP v1.2.1.8004 Console --- App : app Path: /home/USER NAME/public_html/cake/app --- Please specify which reminder task to run; LOF or Other. Now, when I try to use a shell with a task that has a $uses statement I get an error like this: php /home/USER NAME/public_html/cake/console/cake.php -app /home/USER NAME/public_html/cake/app reminders main Error: Missing Database Connection. Try 'cake bake' The shell with the function I am trying to execute looks like this: The shell is the same as the test shell except with $components, $tasks, and $uses statements. This works fine on DreamHost that has a CLI of PHP4. To make it work I did need to change the cake console file to force PHP5 use, as per this article http://www.milesj.me/blog/read/83/Setting-Up-Cron-Jobs-With-Cake-Shells and DreamHost support. Can anyone spot what is the difference with HostGator so that my shell with a DB reference does not execute in either SSH or cron? Do you think I need to change the cake console file? It appears that HostGator is running PHP5, but I am not sure about the CLI. Thank you in advance for your help. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
[SOLVED] Re: How to debug my save command
Solved it. First, looking more deeply at the cook book on the save() command I noticed an element for 'callbacks' which defaults to 'true' but can also accept 'false'. So I coded up this for a save() with only the field I wanted to update: $this->Repairorder->save($data, array( 'validate' => true, 'fieldList' => array( 'lof_act_60', 'lof_act_75', 'lof_act_90', 'lof' ), 'callbacks' => false ) ); Lo and behold, none of my debug log entries fired in the beforeSave callback method! Yeah! So always remember that the beforeSave is useful, but can be 'hidden' if you don't remember about it. Plus, remember you can turn off the callback in the save() if you really want to. I hope this helps someone else. On Jan 22, 5:37 pm, FrederickD wrote: > I saw something in another post that made me stop and think. I have a > 'beforeSave' callback in my model that sets the 'actual' dates to null > on create or edit from a form. > > Of course, the 'beforeSave' was being executed before my updates. I > commented out the 'beforeSave' just to verify. So now this code is > working fine: > > $this->Repairorder->id = $data['Repairorder']['id']; > $this->Repairorder->saveField('lof_act_60', $data['Repairorder'] > ['lof_act_60']); > $this->Repairorder->saveField('lof_act_75', $data['Repairorder'] > ['lof_act_75']); > $this->Repairorder->saveField('lof_act_90', $data['Repairorder'] > ['lof_act_90']); > > Now the question becomes, are there any ideas on how to selectively > execute the 'beforeSave' callback in the model? > > Thank you for your help! > > On Jan 22, 5:10 pm, FrederickD wrote: > > > I've been reading the manual and looking for examples, but I am still > > having difficulty with issuing a save to update only three fields that > > I have updated. > > > I have a foreach loop to read $data for records that have been > > previously selected based on the 'scheduled' date for the reminder. I > > am doing setup of some variables from $data values in order to send an > > e-mail reminder for the next service interval. (Background: when a > > repair order is created or updated, the scheduled dates for the e-mail > > reminders are set and the 'actual' date is set to null.) After sending > > the e-mail I want to update the 'actual' field as proof that an e-mail > > was sent. > > > Here is the code I have been working with in my controller: > > > // Loop through eligible repair orders, send reminder, and update > > actual date > > foreach ( $data as $data ) { > > > $to = $data['Repairorder']['customer_email']; > > $vin = $data['Repairorder']['vin']; > > $services = $data['Repairorder']['lof'] . ' lubrication service'; > > switch($data['Repairorder']['odometer_type']) { > > case 'Kms': > > $interval = 5000; > > break; > > case 'Miles': > > $interval = 3000; > > break; > > } > > $new_odometer = $data['Repairorder']['odometer'] + $interval; > > $odometer_type = $data['Repairorder']['odometer_type']; > > > // Send e-mail reminder message > > // $id = $this->sendMail( > > // $data['Repairorder']['id'], > > // $to, > > // $vin, > > // $services, > > // $new_odometer, > > // $interval, > > // $odometer_type); > > > // Update 'actual' date field(s) > > if ($data['Repairorder'
Re: How to debug my save command
I saw something in another post that made me stop and think. I have a 'beforeSave' callback in my model that sets the 'actual' dates to null on create or edit from a form. Of course, the 'beforeSave' was being executed before my updates. I commented out the 'beforeSave' just to verify. So now this code is working fine: $this->Repairorder->id = $data['Repairorder']['id']; $this->Repairorder->saveField('lof_act_60', $data['Repairorder'] ['lof_act_60']); $this->Repairorder->saveField('lof_act_75', $data['Repairorder'] ['lof_act_75']); $this->Repairorder->saveField('lof_act_90', $data['Repairorder'] ['lof_act_90']); Now the question becomes, are there any ideas on how to selectively execute the 'beforeSave' callback in the model? Thank you for your help! On Jan 22, 5:10 pm, FrederickD wrote: > I've been reading the manual and looking for examples, but I am still > having difficulty with issuing a save to update only three fields that > I have updated. > > I have a foreach loop to read $data for records that have been > previously selected based on the 'scheduled' date for the reminder. I > am doing setup of some variables from $data values in order to send an > e-mail reminder for the next service interval. (Background: when a > repair order is created or updated, the scheduled dates for the e-mail > reminders are set and the 'actual' date is set to null.) After sending > the e-mail I want to update the 'actual' field as proof that an e-mail > was sent. > > Here is the code I have been working with in my controller: > > // Loop through eligible repair orders, send reminder, and update > actual date > foreach ( $data as $data ) { > > $to = $data['Repairorder']['customer_email']; > $vin = $data['Repairorder']['vin']; > $services = $data['Repairorder']['lof'] . ' lubrication service'; > switch($data['Repairorder']['odometer_type']) { > case 'Kms': > $interval = 5000; > break; > case 'Miles': > $interval = 3000; > break; > } > $new_odometer = $data['Repairorder']['odometer'] + $interval; > $odometer_type = $data['Repairorder']['odometer_type']; > > // Send e-mail reminder message > // $id = $this->sendMail( > // $data['Repairorder']['id'], > // $to, > // $vin, > // $services, > // $new_odometer, > // $interval, > // $odometer_type); > > // Update 'actual' date field(s) > if ($data['Repairorder']['lof_sch_60'] <= date('Y-m-d')) > $data['Repairorder']['lof_act_60'] = date('Y-m-d'); > if ($data['Repairorder']['lof_sch_75'] <= date('Y-m-d')) > $data['Repairorder']['lof_act_75'] = date('Y-m-d'); > if ($data['Repairorder']['lof_sch_90'] <= date('Y-m-d')) > $data['Repairorder']['lof_act_90'] = date('Y-m-d'); > > $this->Repairorder->id = $data['Repairorder']['id']; > $this->Repairorder->save($data); > // array('fieldlist' => array( > // > 'lof_act_60', > // > 'lof_act_75', > // > 'lof_act_90' > // ))); > > /* Debug information to the error.log file in ../app/tmp/ */ > $this->log(array( > 'record' => $data['Repairorder']['id'], > 'lof_sch_60' => $data['Repairorder']['lof_sch_60'], > 'lof_act_60' => $data[&
How to debug my save command
I've been reading the manual and looking for examples, but I am still having difficulty with issuing a save to update only three fields that I have updated. I have a foreach loop to read $data for records that have been previously selected based on the 'scheduled' date for the reminder. I am doing setup of some variables from $data values in order to send an e-mail reminder for the next service interval. (Background: when a repair order is created or updated, the scheduled dates for the e-mail reminders are set and the 'actual' date is set to null.) After sending the e-mail I want to update the 'actual' field as proof that an e-mail was sent. Here is the code I have been working with in my controller: // Loop through eligible repair orders, send reminder, and update actual date foreach ( $data as $data ) { $to = $data['Repairorder']['customer_email']; $vin = $data['Repairorder']['vin']; $services = $data['Repairorder']['lof'] . ' lubrication service'; switch($data['Repairorder']['odometer_type']) { case 'Kms': $interval = 5000; break; case 'Miles': $interval = 3000; break; } $new_odometer = $data['Repairorder']['odometer'] + $interval; $odometer_type = $data['Repairorder']['odometer_type']; // Send e-mail reminder message // $id = $this->sendMail( // $data['Repairorder']['id'], // $to, // $vin, // $services, // $new_odometer, // $interval, // $odometer_type); // Update 'actual' date field(s) if ($data['Repairorder']['lof_sch_60'] <= date('Y-m-d')) $data['Repairorder']['lof_act_60'] = date('Y-m-d'); if ($data['Repairorder']['lof_sch_75'] <= date('Y-m-d')) $data['Repairorder']['lof_act_75'] = date('Y-m-d'); if ($data['Repairorder']['lof_sch_90'] <= date('Y-m-d')) $data['Repairorder']['lof_act_90'] = date('Y-m-d'); $this->Repairorder->id = $data['Repairorder']['id']; $this->Repairorder->save($data); // array('fieldlist' => array( // 'lof_act_60', // 'lof_act_75', // 'lof_act_90' // ))); /* Debug information to the error.log file in ../app/tmp/ */ $this->log(array( 'record' => $data['Repairorder']['id'], 'lof_sch_60' => $data['Repairorder']['lof_sch_60'], 'lof_act_60' => $data['Repairorder']['lof_act_60'], 'lof_sch_75' => $data['Repairorder']['lof_sch_75'], 'lof_act_75' => $data['Repairorder']['lof_act_75'], 'lof_sch_90' => $data['Repairorder']['lof_sch_90'], 'lof_act_90' => $data['Repairorder']['lof_act_90'] )); } // end_foreach on $data results The log entry for each record has the correct value set for the 'actual' field, but the update to the database is not occurring. Ultimately I would like to provide an array with the fieldlist of the three fields I want to update. In the $data array is ['Repairorder']['id']. That should be enough to access the individual record, right? I shouldn't have to set that before a save, but only set it if I was doing a saveField. Is that understanding correct? Where is the error(s) in my code for the save to not work? Thank you in advance for your assistance. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
[SOLVED] Re: How to format numbers in an e-mail template
Just had a "Duh" moment... To format the number in the .ctp file, for an e-mail or anything else, you do the following: 1. Add the helper of 'Number' either to the action or the controller itself, 2. Use this syntax as an example: format ($new_odometer);?> I was not putting $number in front in order to access the helper. Hence the "Duh" moment. The CakePHP cookbook shows all the other options for formatting numbers. Maybe this will help some other newbie... On Jan 11, 10:16 pm, Everton Yoshitani wrote: > I'm not sure about the number helper in the element, anyway if you arent > allowed to use it you could simple use the php > functionhttp://jp2.php.net/number_format? > > Att, > Everton > > On Tue, Jan 12, 2010 at 2:09 PM, FrederickD > wrote: > > > I have added the helper 'Number' in to controller actions using the > > statement $this->helpers[] = 'Number';". My goal is to format two > > whole numbers with commas in the thousands position when sending an e- > > mail for a more professional presentation. > > > The .ctp file paragraph (../app/views/elements/email/html/ > > email_reminder.ctp) containing the replacement variables I want to > > format looks like this: > > > If so, please return to your Service Department for another > > > > before your odometer shows > > , > > and we will extend your coverage for another > > > > . > > > The replacement field variables $new_odometer and $service_interval > > are numbers in the database. It seemed according to the CakePHP > > cookbook (http://book.cakephp.org/view/409/format) that I could use a > > statement like format($new_odometer);?>. > > However, that doesn't work at all. > > > Is there a way to format the number in the controller action, perhaps > > creating a formatted string field, that then could be sent as the > > replacement element? > > > Thanks in advance! > > > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others > > with their CakePHP related questions. > > > You received this message because you are subscribed to the Google Groups > > "CakePHP" group. > > To post to this group, send email to cake-php@googlegroups.com > > To unsubscribe from this group, send email to > > cake-php+unsubscr...@googlegroups.comFor > > more options, visit this group at > >http://groups.google.com/group/cake-php?hl=en > > Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
How to format numbers in an e-mail template
I have added the helper 'Number' in to controller actions using the statement $this->helpers[] = 'Number';". My goal is to format two whole numbers with commas in the thousands position when sending an e- mail for a more professional presentation. The .ctp file paragraph (../app/views/elements/email/html/ email_reminder.ctp) containing the replacement variables I want to format looks like this: If so, please return to your Service Department for another before your odometer shows , and we will extend your coverage for another . The replacement field variables $new_odometer and $service_interval are numbers in the database. It seemed according to the CakePHP cookbook (http://book.cakephp.org/view/409/format) that I could use a statement like format($new_odometer);?>. However, that doesn't work at all. Is there a way to format the number in the controller action, perhaps creating a formatted string field, that then could be sent as the replacement element? Thanks in advance! Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: iPhone users: help with idea of a CakePHP plugin
Have you checked out the latest tool created by WidgetPress? It integrates iPhone app development with a CakePHP generator. Check it out at http://widgetpress.com/. I haven't used it yet, but I have used ModelBaker to good success. It might prove interesting... On Jan 9, 10:49 am, BrendonKoz wrote: > Yes, that is correct. I suppose it can easily be likened to a text > message, except there's no fee associated with it (other than the > immediate and upfront purchase of the application to run on the > phone). There are 3 fields that (can) get sent to the device: > Application Name, Event, and Description. It could be something like > "CakePHP Unofficial Forums", "A reply to your topic has been made", > "In order to solve the problem you're having with the AppController, > you'd want to make sure to.." (the description field can contain > 1 characters). > > Really, the actual solution of how it's used or what's sent is up to > the developer. It might be more interesting for you personally if it > sent messages on new account signups, but it might also be of value to > visitors of your site that own a capable device. I'm stuck on how > developers might want to access or use it. I see little value in > releasing a plugin if developers would need to further tweak it to > make it work the way they want. That's where my problem is. :) For > another example of how Prowl was used (in conjunction with Growl) in a > business setting:http://ex-libris.ca/?s=prowl- although it uses > Growl, it could just as easily use a web API. > > As an aside: from what I've read, the author of Prowl intends to > eventually extend support for other phone brands, but there's no > timeframe for that. I don't own an iPhone either, but I have an iPod > touch so that I can get all of the same functionality. ;) > > On Jan 8, 10:53 pm, euromark wrote: > > > looks really interesting! > > if only i had an iphone... :( > > > did i get this right - via API you can send notifications to your > > mobile? > > like if somebody new registers on your website etc? > > > On 8 Jan., 21:19, BrendonKoz wrote: > > > > I've recently discovered Prowl (http://prowl.weks.net/) for the iPhone/ > > > iPod touch. It's basically an alerting system that sends Push > > > notifications to your device for certain actions. It can integrate > > > with Growl for Windows or OSX, but more importantly (in this case), it > > > offers up an API. > > > > I've used the API to create a datasource (before realizing there have > > > been others who've created > > > components:http://projects.ofjacob.com/cakephp-prowl-component/ > > > andhttp://thewebandthings.synodicsolutions.com/2009/08/06/introducing-th...). > > > Regardless of this fact, there still exists the ability to incorporate > > > more features out of the box than simply a call to a component within > > > a controller. > > > > Here's what I need help with conceptually: > > > - What feature(s) would you like to have in such a plugin (assuming > > > this would be useful to you)? > > Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Export to CSV... almost there... what am I missing? [SOLVED]
This is now SOLVED. Thanks to this post (http://www.dnamique.com/ cakephp-export-data-to-excel-the-easy-way/) I was able to reduce a considerable amount of code and eliminate using a helper. My button from the ExtJS grid was able to reconfigured to call the new action and it worked the first time! It doesn't get much simpler. Whew! Now on to search/filter in ExtJS and CakePHP... On Nov 24, 11:23 am, FrederickD wrote: > Sorry about the tabs. I though I took those out... > > What is also strange to me is that when core.php has 'debug' >= '1' I > get the 404 message. When 'debug' is set to '0', I get the prompt to > create a CSV file, but not with the formatted name as defined in the > exportrepairorders.ctp file. The file name being generated is > exportrepairorders.csv and is empty. > > Thank you for your help. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Export to CSV using Helper, resulting error
I just had a similar problem and post here: http://groups.google.com/group/cake-php/browse_thread/thread/f9d8203a3acb0e8f#. I solved the issue a few hours ago using this approach: http://www.dnamique.com/cakephp-export-data-to-excel-the-easy-way/. No helper needed. It was done in 15 minutes. I could not believe it. I was even able to access the action in CakePHP from a button on an ExtJS grid. I would highly recommend taking a look at this approach. It is the simplest approach I have found, and a very clear explanation. Hopefully it helps... On Nov 24, 10:03 pm, E T wrote: > Hi all, > > I am trying to put a download link on one of my view, so when user click on > that link it will automatically generate a csv file and pop up for user to > download. > > I followed the instruction > herehttp://blog.allmythingstodo.com/tag/cakephp/usingthe helper from Adam > Royle (http://bakery.cakephp.org/articles/view/csv-helper-php5) > > However, when I click on my link.. this is shown: > > Notice (8): Undefined variable: csv > [APP\controllers\dispatches_controller.php, line 158] > > Fatal error: Call to a member function addRow() on a non-object in > C:\xampp\htdocs\cake\app\controllers\dispatches_controller.php on line 158 > > Please help. Thank you. > ** Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Export to CSV... almost there... what am I missing?
Sorry about the tabs. I though I took those out... What is also strange to me is that when core.php has 'debug' >= '1' I get the 404 message. When 'debug' is set to '0', I get the prompt to create a CSV file, but not with the formatted name as defined in the exportrepairorders.ctp file. The file name being generated is exportrepairorders.csv and is empty. Thank you for your help. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Export to CSV... almost there... what am I missing?
I am in the process of adding an "Export to CSV" capability to my project. I am using the latest version of the csv helper found here: http://ifunk.net/cakephp/helpers/csv.php.txt. I have this code as ../ app/views/helpers/csv.php. I also have added Router::parseExtensions ('json', 'xml', 'csv'); to my routes.php file. In my ../app/controllers/repairorders_controller.php I have this action defined: function exportrepairorders() { Configure::write('debug', '0'); $this->layout = 'ajax'; // use the Ajax layout $data = array();// hold the data from the database /* Set up the "conditions" array to retrieve selected Repairorder data */ $params = array( 'order' => array( 'Repairorder.servicedate DESC', 'Repairorder.distributor_id', 'Repairorder.dealer_id' ) ); $paramsCount = array(); /* Set up for an export request, if requested */ $exportRequest = ($this->RequestHandler->ext == 'csv' || $this->RequestHandler->ext == 'xml' || ($this->RequestHandler->ext == 'json' && !$this->RequestHandler->isAjax()) ); if ($exportRequest) { if ($this->RequestHandler->ext == 'csv') { $this->helpers[] = 'Csv'; } if ($this->RequestHandler->ext == 'xml') { // Do nothing, no helper needed } } /* Retrieve count of selected Repairorder and associated data and then the data */ $count = $this->Repairorder->find('count', $paramsCount); $this->Repairorder->recursive = 0; $data = $this->Repairorder->find('all', $params); // Debugger::dump($data); $this->set('total', $count);// send total to the view $this->set('repairorders', $data); // send repairorders to the view } I have a corresponding view established in ../app/views/repairorders/ csv/exportrepairorders.ctp which looks like this: addRow(array($line)); echo $csv->render('Repair Order Export ' . date('Y-m-d h:i') . '.csv'); return; } if (!array_key_exists('results', $data) || !count($data['results'])) { $csv->addRow('No data found.'); echo $csv->render('Repair Order Export ' . date('Y-m-d h:i') . '.csv'); return; } $csv->addRow(array( 'Distributor Name', 'Dealer Name', 'Advisor Name', 'Date of Service', 'Repair Order Number', 'VIN', 'Year', 'Make', 'Model', 'Odometer', 'Kms/Miles', 'Basic LOF?', 'Premier LOF?', 'Performance LOF?', 'Transmission?', 'Brakes?', 'Front Diff?', 'Rear Diff?', 'Transaxle?', 'Power Steering?', 'Transfer Case?', 'Date Created' ) ); foreach ($data['results'] as $result) { $csv->addRow( array( $result['Distributor']['name'], $result['Dealer']['name'], $result['Advisor']['name'], $result['Repairorder']['servicedate'], $result['Repairorder']['number'], $result['Repairorder']['vin'], $result['Repairorder']['year'], $result['Repairorder']['make'], $result['Repairorder']['model'], $result['Repairorder']['odometer'], $result['Repairorder']['odometer_type'], intval($result['Repairorder']['basic_lof']) ? 'Yes' : 'No', intval($result['Repairorder']['premier_lof']) ? 'Yes' : 'No', intval($result['Repairorder']['performance_lof']) ? 'Yes' : 'No',
Re: Database Design Advice Needed - Multiple Companies having Accounting, Production and CRM components
You have quite an ambitious project. What you are wanting to create is an integrated ERP system. Now you have the individual pieces but want them integrated. Is this system feasible in CakePHP? Absolutely! One database with multiple tables would be fine, IMHO. (Even when developing on a mainframe, in most cases, it is technically one database with thousands of tables...We would segregate the tables into 'libraries' by application but that was mostly for convenience of backup and restore.) However, you have a classic "make or buy" decision. Making a custom ERP system for your companies is not for the faint of heart. You didn't mention your team of developers and analysts. I came across something yesterday that you may want to consider. This article described an individual that is helping companies like yours: http://www.bloomberg.com/apps/news?pid=20601109&sid=arPzMR.hhDq0. Follow the links in the articles to products like Open ERP and you may find that using their products will get you an integrated system you desire, and be up and running making a profit sooner than rolling your own. Yes it is possible to do this in CakePHP. There are other business decisions that come into play also. On Oct 30, 6:15 pm, cakephp user wrote: > Good day. Please note that I am not a professional and the software > I'm creating is for two small companies i own. Please take it easy on > me. My plan is to create a cakephp app which has accounting, > production (job tracking) and crm components. I understand it sounds > ambitious but I'd like to able to finish this project in the near > future. I need your advice on a good database design for this kind of > system. > > I have 2 small businesses which would use this system independently. > Each company will have their own customers and database users. The > customers tie all of the Accounting, Production and CRM Components > together. > > Companies --> Corresponding Database Users > (i.e. Company 1, Company 2) > | > | > Customers > | > > | | | > Accounting Production CRM > > I'd like to know a couple of things. > > 1. Do you think this kind of system is feasible to do with cakephp and > mysql? We are currently using different third party software for > these components except the Production system which is done in php. > Having no tie-in between the three creates discrepancies. > > 2. Database Design - Here is where I get stumped. While it's easy to > put everything on one database, I am inclined to believe that this > isn't in line with good database design practices. I maybe wrong here > but please give me your opinion. Single database (with all of the > levels in tables) or multiple databases? > > 3. If I were to use multiple databases, which ones would need their > own database? Should all components in the diagram have their own > databases or should the databases be on a company level? (i.e. each > company has its own mysql database) Since customers tie in the > Accounting, Production and CRM components, should it have a separate > database as well as these three? > > Please take it easy on me. I'd really appreciate some advice/feedback > on my dilemma. Thank you for your time. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Server has broken links
Michael... I was able to fix my problem. I had one extra layer in my directory structure that was not necessary. Here is a google document I've started to record different shared web hosting sites. http://docs.google.com/leaf?id=0B_kFlIFfrTc7NjI4YTYzOTAtYWIyZC00Yzk3LTg2MmItNTI5MjJkNGFlMTkz&hl=en I initially was thinking of a different tab for each hosting service, however, it may be best to have a separate document for each hosting service and then tabs within the document for other tips. For instance, with GoDaddy.com I understand there are certain things that need to be done in order to send mail from within Cake. That would be a natural for an additional tab in a document about GoDaddy.com hosting of Cake apps. Do you want to check it out and see if you want to add information about digitalspace.net? On Oct 15, 11:14 am, Michael Gaiser wrote: > That would be great. I am using digitalspace.net as my host if anyone else > has had luck with getting Cake to run on them. > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Deployment issue - must be simple but I am missing it
Solved it! I just had to flatten out the production structure. The changes to the .htaccess files were correct, or at least the work! If anyone would like, I have started a Google Docs spreadsheet where people could put their directory structures for various hosting sites. Perhaps seeing an example will be easier than reading a myriad of posts. Anyway, here it is if any would like to contribute. I was think each hosting site could be a separate tab in the spreadsheet, or perhaps it would be best to have separate spreadsheets. See what you think. This is a work in process... http://docs.google.com/leaf?id=0B_kFlIFfrTc7NjI4YTYzOTAtYWIyZC00Yzk3LTg2MmItNTI5MjJkNGFlMTkz&hl=en --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send 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 / .htaccess issue
number9, Kudos on getting your deployment to work! Would you have time, please, to look at my thread for my deployment issues? It is http://groups.google.com/group/cake-php/browse_thread/thread/6e5fa3a941dce149. Would you mind sharing your directory structure too? I am about to flatten my production installation and try starting again. So I could use your valuable insight. Thanks in advance! On Oct 16, 8:48 am, number9 wrote: > Managed to finally solve this with a bit of fiddling! > > I basically moved the entire webroot folder to the public_html folder, > as well as the tmp and config files, overwriting the .htaccess and > index.php (so I now have just 3 .htaccess files), and the index.php as > well (updated the paths in the index file). > > So it was a mod rewrite issue after all! > > On Oct 15, 6:26 pm, number9 wrote: > > > I have setup a cakephp installation so that the app, cake and webroot > > folders have been moved from their default location. I have updated > > the values in the /webroot/index.php and the application is working > > fine, except that the webroot is not being recognised as the > > public_html root. > > > Instead of images being displayed aswww.domain.com/img/img-name.jpg, > > they need a path from the public_html. > > > How can I set the webroot as the site root without interfering with > > everything else (which is working fine). I suspect it is a mod rewrite > > issue... but I'm not sure. > > > Here is the layout and .htaccess files: > > > /etc/app (contains APP folder) > > > /etc/app/.htaccess > > > > > RewriteEngine on > > RewriteRule ^$ webroot/ [L] > > RewriteRule (.*) webroot/$1 [L] > > > > > /etc/cake (contains CAKE folder) > > > /etc/cake/.htaccess > > > > > RewriteEngine on > > RewriteRule ^$ app/webroot/ [L] > > RewriteRule (.*) app/webroot/$1 [L] > > > > > /public_html/app/webroot (contains WEBROOT folder) > > > /public_html/.htaccess > > > > > RewriteEngine On > > RewriteBase /~sitebase/ > > RewriteCond %{REQUEST_FILENAME} !-d > > RewriteCond %{REQUEST_FILENAME} !-f > > RewriteRule ^(.*)$ index.php?url=$1 [QSA,L] > > > > > /public_html/app/webroot/.htaccess > > > > > RewriteEngine On > > RewriteCond %{REQUEST_FILENAME} !-d > > RewriteCond %{REQUEST_FILENAME} !-f > > RewriteRule ^(.*)$ index.php?url=$1 [QSA,L] > > > > > Do the .htaccess files look right? Or is this more likely to be > > something to do with the webroot/index.php file? > > > Thanks in advance for any help - I've tried changing various things > > with no joy. > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Server has broken links
Same exact thing happening to me on this thread: http://groups.google.com/group/cake-php/browse_thread/thread/6e5fa3a941dce149. Debug is set to '2'. In my case it is not Cake that is generating the 404, it is goDaddy.com the shared hosting server. Nothing in the Cake logs. In the goDaddy.com logs it only shows the incorrect URL. A support ticket to goDaddy.com was less than helpful. Since they don't support CakePHP they said it was my problem. I suggested they consider supporting Cake to tap into the great developer community, instead of getting bad press. They replied with basically, 'So what.' [sigh] I will need to experiment some more today. It seems that a lot of traffic on this group has to do with basically the same issues when deploying. The articles on the Cook Book are not helping in all cases. I made the suggestion on my thread that a central document, perhaps on the pages portion of this site, be created with suggested deployment instructions for various shared hosting sites. If scenarios for directory structures were included that may help. When I get this working (not if!) I will do what I can to initiate that. Everyone could then contribute for their shared hosting site and what is working. Thoughts? On Oct 14, 8:52 am, Michael Gaiser wrote: > Nope. Already went though that page and everything was set right. > > On Tue, Oct 13, 2009 at 11:30 PM, AD7six wrote: > > > On 14 oct, 08:09, Michael Gaiser wrote: > > > When I uncomment "Configure::write('App.baseUrl', env('SCRIPT_NAME'));" > > in > > > my core.php it seems to work but feels like a cheat. Any reason > > mod_rewrite > > > isnt working with the default setup? when I did a php info, it shows > > > rewrite_mod loaded. > > > Probably reason 1 > >http://book.cakephp.org/view/37/Apache-and-mod_rewrite-and-htaccess > > > 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: Deployment issue - must be simple but I am missing it
Thanks for the reply. The debug value has always been '2' so that I see the poopy pants on deployment. I actually have made no other changes than the .htaccess files until I was approaching vague awareness from the group. So far I'm still in the dark. I can start over easily enough. I still am wondering if my directory structure is compatible with my deployment. It is quite conceivable to have more than one Cake application for this client. It would seem logical to put Cake at the root level of the shared hosting for the start. Am I understanding that correctly? If I do that would I then follow the instructions from http://groups.google.com/group/cake-php/browse_thread/thread/1d2abbf25e150420?hl=en? Thank you! On Oct 14, 11:38 am, me me me wrote: > On Oct 12, 2:47 pm, FrederickD wrote: > > > > > My site is herehttp://bgnation.ca/reporting/. The initial page > > renders fine (I haven't replaced the lorem ipsum yet... mea culpa...). > > However, when I try to log in on the side bar I receive a 404 error > > forhttp://bgnation.ca/users/login. Using a URL to access any other > > controller action yields the same result. The 'Home' button on the > > navigation bar works however. > > Is debug set to 0? When it is, Cake emits a 404 whenever there's a > nasty error. This is to keep regular users from seeing your dirty > laundry.Set it to 2 and try again. > > Of course, now that you've been fiddling around you may have created > more problems. :-( --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Deployment issue - must be simple but I am missing it
Thank you for your response. However, I am confused. How is my directory structure different than the suggested one here: http://book.cakephp.org/view/34/Production? This is my first deployment to a production server, so please excuse my desire to come close to being able to understand what I am doing. I tried to follow these instructions for the .htaccess files: http://book.cakephp.org/view/37/Apache-and-mod_rewrite-and-htaccess. Should the directory structure be like this? / [root] /cake [moved up to root level of shared hosting account] /reporting /reporting/.htaccess /reporting/app /reporting/app/[plus everything else app related] /reporting/app/.htaccess /reporting/app/webroot/.htaccess /reporting/index.php /reporting/README /reporting/vendors With a structure like this wouldn't I need to change some more of the Cake values as found in this article: http://book.cakephp.org/view/35/Advanced-Installation? Thanks in advance for your help. This is a little bit confusing since there is conflicting advice in other articles outside of the CookBook. Maybe someone could create an overview document that lists known shared hosting servers (like fatCow, 1and1, goDaddy, etc.) and what experienced developers have found to the optimal structure for production deployment. That would be a terrific tool for everyone. Thanks again! On Oct 12, 11:51 pm, "Dr. Loboto" wrote: > Looks like you installed cake into subdir, but followed instructions > about install into root dir and messed .htaccess files. > > On Oct 13, 1:47 am, FrederickD wrote: > > > I finally have my project up on a production server. My client is > > using goDaddy.com. Following my research here and other places, I > > uploaded the project, verified folder write-ability for /tmp and the > > subordinates, cleared the /tmp directory contents, and changed the > > database.php file (not sure if that part is working yet). > > > My folder structure looks like this: > > / [root] > > /reporting > > /reporting/.htaccess > > /reporting/app > > /reporting/app/[everything else app replated including /tmp and / > > webroot] > > /reporting/app/.htaccess > > /reporting/app/webroot/.htaccess > > /reporting/cake > > /reporting/index.php > > /reporting/README > > /reporting/vendors > > > My site is herehttp://bgnation.ca/reporting/. The initial page > > renders fine (I haven't replaced the lorem ipsum yet... mea culpa...). > > However, when I try to log in on the side bar I receive a 404 error > > forhttp://bgnation.ca/users/login. Using a URL to access any other > > controller action yields the same result. The 'Home' button on the > > navigation bar works however. > > > I changed the routes.php file to be this, just commenting out a chunk: > > > > Router::connect('/tests', > > array( > > 'controller' => 'tests' > > ,'action' => 'index' > > ) > > ); > > > Router::connect('/', > > array( > > 'controller' => 'pages' > > ,'action' => 'display' > > ,'/index' > > ) > > ); > > > // Router::connect('/pages/*', > > // array( > > // 'controller' => 'pages' > > // ,'action' => 'display' > > // ) > > // ); > > > ?> > > > The.htaccess file in /webroot/ was changed to add a '/' in front of > > the 'index' as per this article about hosting on > > goDaddy.com:http://techiedesi.com/post/327-setup-cakephp-modrewrite-to-work-with- > > So it looks like this: > > > > > RewriteEngine On > > RewriteCond %{REQUEST_FILENAME} !-d > > RewriteCond %{REQUEST_FILENAME} !-f > > RewriteRule ^(.*)$ /index.php?url=$1 [QSA,L] > > > > > The.htaccess file in /app was changed to look like this (just added > > the 'RewriteBase /' line): > > > > > RewriteEngine on > > RewriteBase / > > RewriteRule ^$ webroot/ [L] > > RewriteRule (.*) webroot/$1 [L] > > > > > In order to have even the first page render, I had to leave > > the .htaccess file at the root of my project looking like this: > > > > > RewriteEngine on > > RewriteRule ^$ app/webroot/ [L]
Deployment issue - must be simple but I am missing it
I finally have my project up on a production server. My client is using goDaddy.com. Following my research here and other places, I uploaded the project, verified folder write-ability for /tmp and the subordinates, cleared the /tmp directory contents, and changed the database.php file (not sure if that part is working yet). My folder structure looks like this: / [root] /reporting /reporting/.htaccess /reporting/app /reporting/app/[everything else app replated including /tmp and / webroot] /reporting/app/.htaccess /reporting/app/webroot/.htaccess /reporting/cake /reporting/index.php /reporting/README /reporting/vendors My site is here http://bgnation.ca/reporting/. The initial page renders fine (I haven't replaced the lorem ipsum yet... mea culpa...). However, when I try to log in on the side bar I receive a 404 error for http://bgnation.ca/users/login. Using a URL to access any other controller action yields the same result. The 'Home' button on the navigation bar works however. I changed the routes.php file to be this, just commenting out a chunk: 'tests' ,'action' => 'index' ) ); Router::connect('/', array( 'controller' => 'pages' ,'action' => 'display' ,'/index' ) ); // Router::connect('/pages/*', // array( // 'controller' => 'pages' // ,'action' => 'display' // ) // ); ?> The.htaccess file in /webroot/ was changed to add a '/' in front of the 'index' as per this article about hosting on goDaddy.com: http://techiedesi.com/post/327-setup-cakephp-modrewrite-to-work-with-godaddy-shared-linux-hosting-package. So it looks like this: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ /index.php?url=$1 [QSA,L] The.htaccess file in /app was changed to look like this (just added the 'RewriteBase /' line): RewriteEngine on RewriteBase / RewriteRule^$webroot/[L] RewriteRule(.*) webroot/$1[L] In order to have even the first page render, I had to leave the .htaccess file at the root of my project looking like this: RewriteEngine on RewriteRule^$ app/webroot/[L] RewriteRule(.*) app/webroot/$1 [L] All of this works on localhost yet not on the production server. So is something wrong with my routes.php file? I'm sure it is simple, but I just don't see it. I have tried to do my research but cannot find something that works. Would someone help me please? I am DITW (dead in the water) at this point. 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: How to convert tinyint(1) back to boolean?
Ausgezeichnet! (My father is from München and has the bumper sticker... I bin a Bayer! Host mi?) Would you mind sharing that helper? Vielen dank. On Oct 10, 4:56 am, "euromark (munich)" wrote: > i even use a helper funtion > > echo $common->yesNo($val) > > which results in one of 2 icons: green check mark or a red cross > (even more pleasing visual appearance) > > On 9 Okt., 15:00, FrederickD wrote: > > > I may not understand completely what you are trying to do. I've kept > > my boolean elements at tinyint and use something like this with the > > views for presentation: > > > > 'No'; ?> > > > That give a more pleasing visual appearance than a '1' or '0', yet > > maintains the database value as boolean. > > > There is something similar that can be done in Javascript for ExtJS > > grids and forms. > > > Does this help? > > > On Oct 8, 6:36 pm, Xhaphir wrote: > > > > Hi, > > > > i have a small problem in cakePHP. I saved a lot of booleans and > > > integers in a mySQL Database and > > > cakePHP is converting my boolean values nicely to a tinyint. But not > > > back. > > > > In most cases this is not a problem but I would like to iterate over > > > all values and convert all booleans to "yes"/"no". > > > In this case I am unable to determine if a value is a boolean or an > > > integer. > > > > Maybe I'm just don't see the solution.. > > > > Thanks for your help, > > > Helmut > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: ability to users to delete their comment's
If all you want to do is to prevent a user from deleting something they are authorized to view, but not delete, then that code is all you need. If, however, you want to prevent a savvy user, or a curious user, or a malicious user, from changing the URL and accessing data they are NOT authorized to even view (let alone edit or delete), then you need a more robust approach in the beforeFilter. It just depends on your application and your design goals. On Oct 9, 11:14 am, Simon wrote: > Thank you Brian thats what i was looking for > > On Oct 9, 9:04 am, brian wrote: > > > On Fri, Oct 9, 2009 at 11:19 AM, Simon wrote: > > > > if that code gose to controller then this should go to view but the > > > other users will see this link > > > link(__('Delete', true), array('action'=>'delete', > > > $comment['Comment']['id']), null, sprintf(__('Are you sure you want to > > > delete # %s?', true), $comment['Comment']['id'])); ?> > > > if ($comment['Comment']['user_id'] == $session->read('Auth.User.id')) > > { > > echo $html->link(__('Delete', true), array('action'=>'delete', > > $comment['Comment']['id']), null, sprintf(__('Are you sure you want to > > delete # %s?', true), $comment['Comment']['id'])); > > > }- 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: ability to users to delete their comment's
Understood. Simple is good. Yes... you would put the code in your controller and not the view. Here is a suggestion that you would need to customize to your own needs: /* Execute this code before filtering */ function beforeFilter() { /* Initialize Auth component first from parent */ parent::beforeFilter(); if (in_array($this->action, array('view')) or in_array($this->action, array('edit')) or in_array($this->action, array('delete'))) { $distributor_id = $this->Distributor->field( 'id', array('user_id' => $this->user['id'])); if(!$this->Dealer->find( 'first', array( 'conditions' => array( 'distributor_id' => $distributor_id, 'id' => $dealer_id ), 'recursive' => -1 ) ) ) { $this->Session->setFlash('You are not authorized for that information.', true); } } Something like that. I am doing the initial find on Distributor to an array because my results could have one that one distributor that is authorized to view the requested dealer. Your specifications will vary. I'm sure this code can be improved on, but it may get you started in the right direction. On Oct 9, 9:36 am, Simon wrote: > yep i looked at that its pretty good i'm going to use it but for now i > need a simple sloution like miles j's > whats the good place for this code i tried in view but no luck maybe > controller > if ($comment['Comment']['user_id'] == $this->Auth->user('id')) { > $this->Comment->delete(); > > } > > On Oct 9, 7:29 am, FrederickD wrote: > > > I believe the article has a portion of code that goes in the > > applicable model, or even app_model to be available system wide. Then > > other code goes in the applicable controller, not the view. > > > If you implement this, be sure to follow all the instructions. You > > need both the Auth and Security components for the controller, or > > system wide, for the way the tutorial is written. I forgot the > > Security component at first and it didn't work at all. > > > There are other options on how to accomplish the same task. It is good > > to experiment and see what works best for your application. > > > On Oct 9, 9:03 am, Simon wrote: > > > > is this for view or controller if its for view i get error i changed > > > to my model but this is the error > > > > Fatal error: Call to a member function User() on a non-object in > > > > On Oct 9, 6:02 am, FrederickD wrote: > > > > > There is an interesting article about row-level access here that may > > > > help too: > > > > >http://teknoid.wordpress.com/2009/04/22/simplistic-example-of-row-lev... > > > > > It may generate some other ideas for you too. > > > > > On Oct 8, 5:59 pm, Miles J wrote: > > > > > > Check that the logged in user matches the owner of the post. > > > > > > if ($post['Comment']['user_id'] == $this->Auth->user('id')) { > > > > > $this->Comment->delete(); > > > > > > } > > > > > > On Oct 8, 2:33 pm, Simon wrote: > > > > > > > is there any way for the users delete their own comment's not the > > > > > > others how can i do that ?- 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: ability to users to delete their comment's
I believe the article has a portion of code that goes in the applicable model, or even app_model to be available system wide. Then other code goes in the applicable controller, not the view. If you implement this, be sure to follow all the instructions. You need both the Auth and Security components for the controller, or system wide, for the way the tutorial is written. I forgot the Security component at first and it didn't work at all. There are other options on how to accomplish the same task. It is good to experiment and see what works best for your application. On Oct 9, 9:03 am, Simon wrote: > is this for view or controller if its for view i get error i changed > to my model but this is the error > > Fatal error: Call to a member function User() on a non-object in > > On Oct 9, 6:02 am, FrederickD wrote: > > > There is an interesting article about row-level access here that may > > help too: > > >http://teknoid.wordpress.com/2009/04/22/simplistic-example-of-row-lev... > > > It may generate some other ideas for you too. > > > On Oct 8, 5:59 pm, Miles J wrote: > > > > Check that the logged in user matches the owner of the post. > > > > if ($post['Comment']['user_id'] == $this->Auth->user('id')) { > > > $this->Comment->delete(); > > > > } > > > > On Oct 8, 2:33 pm, Simon wrote: > > > > > is there any way for the users delete their own comment's not the > > > > others how can i do that ?- 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: ability to users to delete their comment's
There is an interesting article about row-level access here that may help too: http://teknoid.wordpress.com/2009/04/22/simplistic-example-of-row-level-access-control-with-auth-security-and-app-model-in-cakephp/ It may generate some other ideas for you too. On Oct 8, 5:59 pm, Miles J wrote: > Check that the logged in user matches the owner of the post. > > if ($post['Comment']['user_id'] == $this->Auth->user('id')) { > $this->Comment->delete(); > > } > > On Oct 8, 2:33 pm, Simon wrote: > > > is there any way for the users delete their own comment's not the > > others how can i do that ? > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: How to convert tinyint(1) back to boolean?
I may not understand completely what you are trying to do. I've kept my boolean elements at tinyint and use something like this with the views for presentation: That give a more pleasing visual appearance than a '1' or '0', yet maintains the database value as boolean. There is something similar that can be done in Javascript for ExtJS grids and forms. Does this help? On Oct 8, 6:36 pm, Xhaphir wrote: > Hi, > > i have a small problem in cakePHP. I saved a lot of booleans and > integers in a mySQL Database and > cakePHP is converting my boolean values nicely to a tinyint. But not > back. > > In most cases this is not a problem but I would like to iterate over > all values and convert all booleans to "yes"/"no". > In this case I am unable to determine if a value is a boolean or an > integer. > > Maybe I'm just don't see the solution.. > > Thanks for your help, > Helmut --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Cannot figure out my $conditions array
Nope. The code is real and working. I believe I figured it out about an hour ago using an example from here: http://www.pubbs.net/cakephp/200905/101772/ Here is the working code now: switch($this->user['group_id']) { case '1':/* Admin shows all */ $conditions = array(); /* Redundant but I like it over and over */ break; case '2':/* Distributor sees their dealer's advisors */ /* Get list of distributors for logged in user */ $distributor_id = $this->Distributor->find( 'list', array( 'fields' => array('Distributor.id'), 'conditions' => array('user_id' => $this->user ['id']) ) ); /* Add list of distributors to conditions array */ $conditions = array( 'conditions' => array( 'Advisor.distributor_id' => $distributor_id ) ); break; case '3':/* Dealer sees only their advisors */ /* Get list of dealers for logged in user */ $dealer_id = $this->Dealer->find( 'list', array( 'fields' => array('Dealer.id'), 'conditions' => array('user_id' => $this->user ['id']) ) ); /* Add list of dealers to conditions array */ $conditions = array('conditions' => array('Advisor.dealer_id' => $dealer_id)); break; case '4':/* Logged in advisor sees only records for Auth.User.id */ $conditions = array('conditions' => array( 'Advisor.user_id' => $this- >Auth->user('id') ) ); break; } /* Retrieve count of selected Dealer and associated data and then the data */ $count = $this->Advisor->find('count', $conditions); /* Now add the other parameter elements, if needed */ $params = $conditions; $advisorArray = $this->Advisor->find('all', $params ); Turns out I had to separate the array for the list of values for what would become the "IN" element of the "WHERE" clause from the actual conditions element. Works like a charm, and makes sense now that it works. Maybe this will help someone else too. On Oct 1, 8:22 pm, "Dr. Loboto" wrote: > If assume that you posted here edited code I suggest that in real one > you have misspelled variables inside switch or forgotten lines that > blank $conditions array before dump or something else of same type. > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Cannot figure out my $conditions array
I am sure this is a simple error, but I am just not seeing it. Would you help me please? I am trying to build a $conditions array with results from a find ('list'). I have the following models: Distributor which hasMany Dealers. Dealers which hasMany Advisors. Advisors which belongsTo Distributors and belongsTo Dealers. So for my Advisor schema looks like: id, distributor_id, dealer_id, user_id, name, [etc.] A Distributor is logged in and has a User.id value of "2". This user has two Distributor records that they own; Distributor.id value of "1" and "2". Those distributors have a total of two Advisors records. I want to gather all the Advisors records for those two Distributors. Here is my code so far in the advisors_controller.php: /* Set up the "conditions" array to retrieve selected Advisor data */ $conditions = array(); $distributor_id = array(); // Could be more than one distributor... $dealer_id = array(); // Could be more than one dealer... $this->Advisor->recursive = 0; // Advisor and dealer and distributor data switch($this->user['group_id']) { case '1': /* Admin shows all */ $conditions = array(); /* Redundant but I like it over and over */ break; case '2': /* Distributor sees their dealer's advisors */ $distributor_id = $this->Distributor->find( 'list', array( 'fields' => array('Distributor.id'), 'conditions' => array('user_id' => $this->user['id']) ) ); Debugger::dump($distributor_id); $conditions = array('Advisor.distributor_id' => array("1", "2")); Debugger::dump($conditions); break; } With this code, with the $conditions hard-coded with the values of "1", and "2", I have this for the Debugger results: /* The contents of $distributor_id */ array( "1", "2" ) /* The contents fo $conditions */ array( "Advisor.distributor_id" => array()/* Why is this empty??? */ ) /* JSON object results */ {"total":2, "advisors":[... then the data ...] I want my $conditions array to dynamically load the contents of the $distributor_id array. I've been experimenting and cannot find the proper syntax. I was hoping that a statement like this would work ... $conditions = array('Advisor.distributor_id' => $distributor_id); ... but it doesn't. Would you help me please? I am trying to simulate the third example from The Cookbook entry http://book.cakephp.org/view/74/Complex-Find-Conditions. Thank you in advance for your 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: Best way to accomplish acl for database records owned by a user
I came across this same issue. You can call it "row level access". An article that pointed me in the right direction was this one: http://teknoid.wordpress.com/2009/04/22/simplistic-example-of-row-level-access-control-with-auth-security-and-app-model-in-cakephp/. I took that article and expanded on it. The key for my application was the design of the database. My application has distributors that own dealers that then have service advisers. A distributor should be able to access only his distributor record and the associated dealers and the associated service advisers. A dealer can access only his dealer record and his service advisers. Etc., etc. Distributors and dealers and service advisers are individual group records. There are users belonging to those groups. Currently I don't allow a user to be in multiple groups, but I could. So using the article above I was able to build in internal security using the group_id as a first cut for access to the record being requested, and then the user_id as well to make sure it was "their" record. For the security on associated records this is where having the 'belongsTo' and 'hasMany' relationships really helped. But the real key discovery for me was in my dealers_controller.php. I needed to reach back and get the associated distributor for the dealer record being requested to compare if it was the same distributor. If not, no access. I found I could use var $uses = array('Dealers' 'Distributors') to allow me to bring in the distributor (only one field actually, the 'id') to my security check. It is some code. I'm sure it could be cleaned up a bit and maybe put more into the model to have a skinnier controller, but it is working well and seems to be a flexible approach that does not involve the complexities of ACL. Maybe some of this helps. On Sep 25, 1:25 am, rOger wrote: > Thanks for your answers!! > > @brian: It looks rather complex to accomplish such a "easy" task so I > think there must be an easier way to get the same result... > > @Rick: Your solution is the one I used before but I thought that there > must be a solution that is integrated into the ACO/ACL concept... > > It's always the same problem with every framework; simple tasks are > easy; real world scenarios are big challenges. It would be interesting > to know how the developers of cakePHP/ACL-system would accomplish this > task... > > regards, > rOger > > On 24 Sep., 16:09, Rick wrote: > > > I know that globals are bad but... > > > I just set a global $gblCurrentUser when the user logs in. Then > > accessing that in models, I can add a select condition for that user > > in the beforeFind etc.. > > > You get the idea? > > > Rick > > > On Sep 24, 12:20 am, brian wrote: > > > > I did something similar to this. However, I was so overwhelmed by the > > > contradictory and/or incomplete information I found about Cake's ACL > > > (mostly because it was quite dated) that I really don't know for sure > > > that I did it the best way. > > > > My app is an extranet that has several different Groups. The > > > navigation consists of many Sections that are stored as a tree (MPTT). > > > Some Sections may not be seen by certain Groups. So, to display this > > > navigation tree, I called this method in my SectionsController: > > > > public function nav($group_id = null) > > > { > > > if (is_null($group_id)) > > > { > > > if (!$this->params['admin']) > > > { > > > $group_id = $this->Auth->user('group_id'); > > > } > > > } > > > $this->Session->write('group_id_for_nav', $group_id); > > > > /* try getting the nodes from the cache > > > */ > > > $sections = Cache::read("group_sections_${group_id}", 'default'); > > > > if (!$sections) > > > { > > > /* fetch the permissions for this group > > > */ > > > $perms = $this->Acl->Aco->find( > > > 'all', > > > array( > > > 'fields' => array('Aco.foreign_key'), > > > 'conditions' => array( > > > 'Aco.model' => 'Section', > > > 'Aco.id = Permission.aco_id' > > > ), > > > 'recursive' => -1, > > > 'joins' => array( > > > array( > > > 'table' => 'aros', > > > 'alias' => 'Aro', > > > 'type' => 'INNER', > > > 'conditions'=> array( > > > 'Aro.model' => > > > 'Group', > > >
Re: MAMP + CakePHP issues
Hi Fahd! I can advise you on the first question, but not the second. I had been using MAMP but decided to take it off and go with a stock approach. It took a little bit, but works solidly now. What makes it very easy is to use a cheap product called VirtualHostX. You can find it at http://www.macupdate.com/info.php/id/25689/virtualhostx. The price recently went up it appears, but it is so worth it to not be frustrated while developing multiple sites. VirtualHostX is MAMP- friendly. I use it to have a sandbox site where I'm testing code and integration before moving that code over to the development site. Both can be up at the same time, obviously with different databases, but it could be the same one. Hmmm... Anyway, I am also using a product called ModelBaker from http://widgetpress.com that also is MAMP-friendly and removes the need to use a command line when baking. All the database design is visual and the configuration of Cake is a snap. It is a RAP (rapid application prototype) tool that does a great job at generating 80% of the Cake code so you can focus on the 20% that is unique to your application. Plus it can generate an iPhone-aware web application. That's like getting a two-for-one deal! Very promising product. I hope some of this helps. On Sep 24, 3:10 pm, fahd wrote: > Hey fellow Cakers, > > I've been developing on CakePHP for a bit and decided to have a > localhost version on MAMP so that I could demo my app to people > without being dependent on an Internet connection. > > Ran into a few issues ofcourse and hoping someone can give some > insight: > > 1) I have several sites under the /Sites/ folder and I pointed MAMP's > Apache document root there. For example /Sites/project1/ is where the > Cake app sites. It finds the /project1/ site fine (after some > htaccess mods) but there are issues with relative links. Any link that > is manually coded and not using $html->link uses /Sites/ instead of / > Sites/project1/ as the base. This is for images and any Ajax calls > from jQuery. (css and js files are fine). The images I can bare, but > the site is unusable without Ajax. > > Temp solution: changed the document root to /Sites/project1/. This is > not ideal, but I'd like to know if you guys have a fix so I don't have > to change the document root all the time for previewing different > projects. > > 2) We have a lot of complex MySQL queries being made, using > $this->query('SELECT...'). We've placed these in the appropriate models > > within a function. Hence from the Controller we'll have something like > $this->Users->getMeSomething($variable), that goes to the user.php > model and runs that function. This works fine on our live and dev > sites, but for some reason on MAMP I'm getting the error: > > Warning (512): SQL Error: 1064: You have an error in your SQL syntax; > check the manual that corresponds to your MySQL server version for the > right syntax to use near '__getUsersForUsers' at line 1 [CORE/cake/ > libs/model/datasources/dbo_source.php, line 525] > > The context: > == > DboSource::showQuery() - CORE/cake/libs/model/datasources/ > dbo_source.php, line 525 > DboSource::execute() - CORE/cake/libs/model/datasources/ > dbo_source.php, line 201 > DboSource::fetchAll() - CORE/cake/libs/model/datasources/ > dbo_source.php, line 336 > DboSource::query() - CORE/cake/libs/model/datasources/dbo_source.php, > line 297 > Model::call__() - CORE/cake/libs/model/model.php, line 441 > Overloadable::__call() - CORE/cake/libs/overloadable_php5.php, line 52 > AppModel::__getUsersForUsers() - [internal], line ?? > UsersController::view() - APP/controllers/users_controller.php, line > 401 > Object::dispatchMethod() - CORE/cake/libs/object.php, line 118 > Dispatcher::_invoke() - CORE/cake/dispatcher.php, line 227 > Dispatcher::dispatch() - CORE/cake/dispatcher.php, line 194 > [main] - APP/webroot/index.php, line 88 > == > Line 88 on webroot is this: $Dispatcher->dispatch($url); > > Thanks for any help > > Fahd --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Checkboxes in index view
If you don't want your index to be editable, yet display something more intelligible than a '1' or '0' for a Boolean field, you can use this: The field 'active' is a Boolean and this is a simple way to show 'Yes' or 'No' on the index view. It is not editable, but much better for reading. On Sep 8, 3:49 am, WebbedIT wrote: > In your edit view you will be using the form helper which knows to > convert tinyint(1) or bool field to a checkbox. > > If you are looking to add multiple checkboxes to your index view (so > you can check multiple records) you need to edit your index view to > include a form which would use the form helper to echo out your delete > fields checkboxes. > > Don't expect baked views to do this for you as this sort of feature is > not included in a basic baked index. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Setting Up CakePHP on MAC with MAMP and Eclipse
Hey Kludge! Try going to www.widgetpress.com and checking out ModelBaker. It is a Mac front-end to CakePHP so that you never have to use the CLI. The product has a graphical representation of the database model you are creating for the project. ModelBaker is not an end-all solution. It is designed to quickly get you up and running with CakePHP code that you then tweak for the unique business logic for your project. It has some limitations as it was just released at MacWorld in January. Overall it promises to be a very strong product for Mac development with CakePHP. There is a demo version available for you to try out. I am not affiliated with WidgetPress at all. I do use ModelBaker because I'm a Mac guy and don't care much for the Terminal and command line interfaces anymore. Been there, did that, haven't done it for 25 years now. Check it out! On Sep 6, 4:14 pm, Kludge wrote: > Anyone have any idea on how to do this? I have MAMP and Eclipse > installed correctly and have been doing PHP development for a while > now and everything works fine. I now want to jump into CakePHP but > can't wrap my head around setting it up. Any insight and or steps on > getting there would be great. Thank you 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: Has anyone had success using Ext JS 2.2.2 and a grouping grid?
Hey wirtsi... Would you mind sending me your replies to the blog post via e-mail? For some reason I'm not picking them up. I'm very eager to get the grouping working in my project so I can show the customer. Thanks! On Sep 2, 10:47 am, FrederickD wrote: > Thanks for your reply! I am missing the replies to the blog post > though. I've experienced a long time lag between posts being approved > on the extjs.com/forum lately. I will check again periodicaly. > > I have changed the datastore over to the GroupingStore, but I am not > coding the field name correctly somehow. I need some assistance there. > It is good to know the Ext will take care of the rest. That is what I > was hoping for. > > I look forward to converting over to your tool very soon. Looking > forward to some tutorials on how to do various Ext functions. > > On Sep 1, 1:29 am, wirtsi wrote: > > > Hey Frederik > > > check out the replies I gave you on the blog post ... grouping is > > quite easy actually, all you need to do is change the datastore into a > > GroupingStore and give it a groupField (ie. what field to group by). > > Ext will take care of the rest ... > > > wirtsi > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Learning cakePHP debugging
I have used DebugKit with great success. Here is the article about it: http://thechaw.com/debug_kit/wiki You get a toolbar at the top of the window with access to tons of stuff. It does not do line by line debugging. I would like to use FirePHP for adding breakpoints and watching variables, but I have not have had the time to figure it out yet. There are instructions for it, I just don't understand them yet. p.s.: Thanks for sharing your code. I'm doing something similar, but like your use of elements. I appreciate the example! On Sep 2, 9:57 am, LunarDraco wrote: > $activeUser = $this->User->find(array($this->Auth->user('id'))); > Not sure I understand why you set the active user with this line: > as $this->Auth->user() should contain everything you need from the > user model. > > After a user is logged in you never tell the auth component that the > user has logged out. So even after logging out this->Auth->user > contains a valid user. > I suppose after you've logged out and you click on your login link > from the home page it probably never asks for new credentials and goes > straight to the start page. > > At the end of your logout you should be calling: > $this->redirect($this->Auth->logout()); > > That will clear the $this->Auth->user() object and you can test for it > via: > if($this->Auth->user()) > > You'll want to set in your beforeFilter: > $this->Auth->logoutRedirect = array('controller' => 'pages', 'action' > => 'home'); > > which should take care of your redirect to the home page when a user > logs out. > > On Sep 2, 7:54 am, McScreech wrote: > > > @Martin, thanks. debug($activeUser); returns the type of output I was > > expecting. > > > @abc, I'll look into the php version also. > > > Now on to my problem, once I actually stopped to _read_ the debug > > output I realized that the $activeUser variable is NOT CHANGING when I > > log out and log back in again. In addition to the partial setup that I > > described above, here are the login and logout functions in my > > users_controller.php: > > > function login() { > > if( $this->Auth->user() ) { > > // Redirect to start page. > > $this->redirect( array('controller' => 'pages', > > 'action' => > > 'start') ); > > } > > } // end login() > > > function logout() { > > $this->Session->destroy(); > > $this->Session->SetFlash(__('Successfully logged out', > > true)); > > $this->redirect( array('controller' => 'pages', 'action' => > > 'home') ); > > } // end logout() > > > I am using php 5.2.9-1 and cakePHP 1.2.3.8166. > > > Thanx again, McS. > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: admin application
I have had the same requirement, and ACL was "a bit heavy" for me too. Plus I am too green to understand it. Check out this tutorial that really helped me: http://teknoid.wordpress.com/2009/04/22/simplistic-example-of-row-level-access-control-with-auth-security-and-app-model-in-cakephp/ I have applied the techniques in that tutorial, along with some relationships amongst my tables. My project involves distributors who own dealerships, the dealers have technicians and services. I want the admin group members to see all, the distributor group members to see only their distributor(s) plus only their associated dealers, technicians, and services. It takes a little coding in the controller but works very well. I can post a sample of the code if you like. I'm sure there will be some constructive criticism of the code, which I need to improve my coding style with Cake. On Sep 2, 9:41 am, brian wrote: > ACL might be a bit heavy for this. You can achieve this by using admin > routing and AuthComponent. In your non-admin actions, just ensure that > your conditions check for the user_id so that only books belonging to > that user can be edited, deleted, etc. For example: > > 'conditions' => array('Book.user_id' => $this->Auth->user('id')) > > For editing a Book, pass the id as normal but check it first against > the IDs of all books owned by the user. When a user logs in, grab the > book IDs and store them in the session to make this easier. > > For the admin pages, of course, leave out this 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: Has anyone had success using Ext JS 2.2.2 and a grouping grid?
Thanks for your reply! I am missing the replies to the blog post though. I've experienced a long time lag between posts being approved on the extjs.com/forum lately. I will check again periodicaly. I have changed the datastore over to the GroupingStore, but I am not coding the field name correctly somehow. I need some assistance there. It is good to know the Ext will take care of the rest. That is what I was hoping for. I look forward to converting over to your tool very soon. Looking forward to some tutorials on how to do various Ext functions. On Sep 1, 1:29 am, wirtsi wrote: > Hey Frederik > > check out the replies I gave you on the blog post ... grouping is > quite easy actually, all you need to do is change the datastore into a > GroupingStore and give it a groupField (ie. what field to group by). > Ext will take care of the rest ... > > wirtsi > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: need help in $ajax->observerField
Friend, I have been where you are. Here is a tutorial that helped me greatly: http://forum.phpsitesolutions.com/php-frameworks/cakephp/ajax-cakephp-dynamically-populate-html-select-dropdown-box-t29.html Of course I was not satisfied with just that, so check out this thread and the final answer at the end of it: http://groups.google.com/group/cake-php/browse_thread/thread/25fa39d4e10bff7c/8698c1252b3cf49a?lnk=gst&q=frederickd#8698c1252b3cf49a Let me know if this helps. On Aug 30, 11:06 pm, "adilraufk...@gmail.com" wrote: > I have a ajax application form , i need to add state country select > boxes to it (again using ajax) > > in my view file every thing goes fine if i use > > ///apply.ctp > echo $form->create('User'); > echo $form->select('country_id',array($countries),null,array > ('id'=>'countries'),false); > echo $form->select('region_id',array(),null,array > ('id'=>'regions'),false); > echo $ajax->observeField('countries',array > ('url'=>'update_region_select','update'=>'regions')); > > but nothing gets updated in state if i am using > > //apply.ctp > echo $ajax->form(); > echo $form->select('country_id',array($countries),null,array > ('id'=>'countries'),false); > echo $form->select('region_id',array(),null,array > ('id'=>'regions'),false); > echo $ajax->observeField('countries',array > ('url'=>'update_region_select','update'=>'regions')); > > is it possible to do this anyway, Please help, 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: How may I 'trick' $ajax->observeField into firing with linked combo boxes?
I think I solved my problem referenced on this thread. The solution proposed with the array_unshift scrambled the data inside the dropdown. The names were still sorted properly, but the id number with that name got resequenced. Apparently that is what array_unshift does for you, according to the docs. So what I did, and I think it will work for me is I added this code to the .ctp file that creates the dropdown list. Mine is called ajax_dropdown.ctp because that is how it was in the tutorial I have been using. Here is the code: $v) : ?> This successfully adds an element at the beginning of the dropdown list 'Pick me!' (a reference to Donkey in Shrek...) and preserves the elements beneath it. I think I can move on to the next issue now... --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Joining two arrays to use in a Select box with the formhelper
Not one to give up easily, if at all... I gave it another try. I remember reading a post somewhere that an easy way to add an entry to the beginning of a dropdown list was like this: echo $form->input( 'county_id', array( 'options' => array('Please pick a country') + $counties ) ); So I experimented in the ajax_dropdown.ctp file and did this: $v) : ?> Now it works! I can tell the ajax observeField is firing the ajax_dropdown.ctp because I get "Pick me!" as the first entry and all the elements in the dropdown are correct in name and in id value. Whew! Is there a better way to do this, or just be glad it does and move on? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Joining two arrays to use in a Select box with the formhelper
Thanks Brian! I received both your message on this thread and on the other one. Adding the statements below in the controller function had no effect. function getCounties() { $this->set('options', $this->Example->County->find('list', array( 'conditions' => array( 'County.state_id' => $this->data['Example']['state_id'] ), 'group' => array('County.name') ) ) ); array_unshift($counties, array("none"=>"Pick me please!")); $this->set(compact('counties')); $this->render('/examples/ajax_dropdown'); } I even tried $options instead of $counties and still no effect. Then I got to thinking about the /examples/ajax_dropdown .ctp file. It loops through $options and creates the entries for the dropdown. So I modified it to look like this: "Pick me!")); ?> $v) : ?> Then the first entry was the word 'array'. So I read the www.php.net/manual for array_unshift and saw an example and tried the following: $v) : ?> Now I do get the value of "Pick me!" in the county dropdown after the state is selected. So the observeField is firing. The counties are in name order on the dropdown. However, the array_unshift has resequenced the county_id value associated with a county name. Apparently that is what array_unshift does. "All numerical array keys will be modified to start counting from zero while literal keys won't be touched." Hopefully I have not done something wrong in my code. Perhaps because of ajax I am not accessing the $options or $counties array in the correct spot. Any good ideas? The sample data and Cake file are available here: http://forum.phpsitesolutions.com/php-frameworks/cakephp/ajax-cakephp-dynamically-populate-html-select-dropdown-box-t29.html Thanks! On Aug 30, 11:01 am, brian wrote: > You have to set() the variable afterwards. You're adding a value to a > purely local variable. > > array_unshift($counties, array("none"=>"Pick me!")); > $this->set(compact('counties')); > $this->render('/examples/ajax_dropdown'); > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send 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 may I 'trick' $ajax->observeField into firing with linked combo boxes?
I understand. That is what I would like to do; have the first row be 'Please select...' so that the observeField 'sees' a change in the field. I am just not sure how to push an entry into element 0 of an array that has already been loaded by a find('List'), and thereby pushing all the other elements down by one. This was an interesting thread: http://groups.google.com/group/cake-php/browse_thread/thread/a342e152400d0d88?hl=en The suggestion there is to use array_unshift($isps, array ("none"=>"None of the above"));. I tried that and placed the array_unshift just before the render statement, but to no avail. Is my code, and or placement, incorrect? Thank you! On Aug 30, 3:48 am, WebbedIT wrote: > As brian states you add the blank entry to the arrays that you pass > from the controller to the view. > > So the $states, $counties and $cities arrays need to include the blank > 'Please select ...' options as their first 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 -~--~~~~--~~--~--~---
Has anyone had success using Ext JS 2.2.2 and a grouping grid?
I am trying to make my HTML tables look a little prettier using Ext JS. I would like to take a simple HTML table that lists users and the corresponding group name and produce a grouping grid in Ext JS. There is a javascript file named from-html.js in the examples folder of Ext JS. I have been using that to read the HTML from Cake and transform it into a pretty simple grid. (Yes... I know having HTML translated by javascript is not the future. The direction the CakeXT project is going with JSON objects is better, but the grouping functionality is not yet included...) Simple grids work great, except for the pagination part. That will be a separate post. It may be possible to use the Ext.data.GroupingStore function, but I am having trouble with the syntax for the 'sortinfo' and 'grouping'. Here is what I have so far: var ds = new Ext.data.GroupingStore({// Create data grouping reader: new Ext.data.XmlReader({ record:'tbody tr'}, fields), // sortInfo: {field: 'username', direction: "ASC"}, // groupField:'group_name' }); With the two lines commented, I get a simple data grid. With the two lines not comments I only get an HTML table. Does anyone have any experience with this part of Ext JS so that I can reference these fields? A more complete code example can be found at http://extjs.com/forum/showthread.php?t=78141. So far no answers from that forum... I'm hoping somebody here can help me. Please. Thank you. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Joining two arrays to use in a Select box with the formhelper
Hey there... this thread may hold the answer to my post that is here: http://groups.google.com/group/cake-php/browse_thread/thread/25fa39d4e10bff7c# Would one of you please take a quick look at my question on the thread? I tried the array_unshift and put it in my controller just before the render, as Brian suggested, but I did not get the 'Pick me!' in the list after I selected a state. array_unshift($counties, array("none"=>"Pick me!")); $this->render('/examples/ajax_dropdown'); Thoughts? Comments? Code snippet? Thank you! On Aug 27, 2:44 pm, channel5 wrote: > Thanks all for your help, worked a charm! > > Thanks again :) > c5 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send 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 may I 'trick' $ajax->observeField into firing with linked combo boxes?
Thank you Brian. Yes, that is what I would like to do. What would that piece of code look like before the $this->render('/examples/ ajax_dropdown');? Is it as simple as $counties = "Please select a ..." . $counties;? I'm not sure how to insert the empty item at the beginning of the array before rendering. Would you be so kind as to demonstrate for me please? Thanks! On Aug 29, 11:14 am, brian wrote: > You have to add an empty item to the beginning of the array before > rendering the options. And I suggest you put the "Please select a ..." > text in a label or elsewhere and just leave the 1st option of each > select list empty. > > On Sat, Aug 29, 2009 at 10:08 AM, > > FrederickD wrote: > > > After hours of research and trial and error, I must turn to the group > > for help with this. I have a series of three linked combo boxes for > > state, county, and city from the tutorial here: > >http://forum.phpsitesolutions.com/php-frameworks/cakephp/ajax-cakephp > > > They work great... mostly. I have added to the code in the add.ctp > > file to include an 'empty' element of 'Please select a [whatever]'. So > > all three combo boxes start out with the first value being 'Please > > select a [whatever]'. > > > The user selects a state. The $ajax->observeField on the state combo > > box fires and loads the county combo box. This loses the initial > > 'Please select a [whatever] and displays the first entry in the list > > of counties for the selected state. > > > Even if the user opens the county combo box and selects the first > > entry, the $ajax->observeField does not fire to load the next combo > > box of cities, probably because there is no actual change. Only if the > > user selects a DIFFERENT element than the first one does the event > > fire. > > > A possible way around this is to still have the 'Please select a > > [whatever]' as the first element in the county combo box, forcing the > > user to make another selection and thus firing the next observeField > > trigger to load the cities applicable for a selected county. > > > How do I do that? How do I force another 'Please select a [whatever] > > element into the list that is returned from the controller function to > > retrieve the counties for the selected state? > > > Here are some code snippets: > > > /app/controllers/examples_controller.php > > > function getCounties() { > > $this->set('options', > > $this->Example->County->find('list', > > array( > > 'conditions' => array( > > 'County.state_id' => > > $this->data['Example']['state_id'] > > ), > > 'group' => array('County.name') > > ) > > ) > > ); > > $this->render('/examples/ajax_dropdown'); > > } > > > function add() { > > if (!empty($this->data)) { > > $this->Example->create(); > > if ($this->Example->save($this->data)) { > > $this->Session->setFlash(__('The Example has been saved', > > true)); > > $this->redirect(array('action'=>'index')); > > } else { > > $this->Session->setFlash(__('The Example could not > > be saved. > > Please, try again.', true)); > > } > > } > > $cities = array(); > > $counties = array(); > > $states = $this->Example->State->find('list'); > > $this->set(compact('cities', 'counties', 'states')); > > } > > > /app/views/examples/add.ctp > > > > echo $form->input( > > 'state_id', > > array( > > 'options' => $states, > > 'empty' => 'Please select a state' > > ), > > null, > > array( > > 'id' => 'states', > > 'label' => 'State' > > ) > > ); > > echo $form-
How may I 'trick' $ajax->observeField into firing with linked combo boxes?
After hours of research and trial and error, I must turn to the group for help with this. I have a series of three linked combo boxes for state, county, and city from the tutorial here: http://forum.phpsitesolutions.com/php-frameworks/cakephp/ajax-cakephp-dynamically-populate-html-select-dropdown-box-t29.html. They work great... mostly. I have added to the code in the add.ctp file to include an 'empty' element of 'Please select a [whatever]'. So all three combo boxes start out with the first value being 'Please select a [whatever]'. The user selects a state. The $ajax->observeField on the state combo box fires and loads the county combo box. This loses the initial 'Please select a [whatever] and displays the first entry in the list of counties for the selected state. Even if the user opens the county combo box and selects the first entry, the $ajax->observeField does not fire to load the next combo box of cities, probably because there is no actual change. Only if the user selects a DIFFERENT element than the first one does the event fire. A possible way around this is to still have the 'Please select a [whatever]' as the first element in the county combo box, forcing the user to make another selection and thus firing the next observeField trigger to load the cities applicable for a selected county. How do I do that? How do I force another 'Please select a [whatever] element into the list that is returned from the controller function to retrieve the counties for the selected state? Here are some code snippets: /app/controllers/examples_controller.php function getCounties() { $this->set('options', $this->Example->County->find('list', array( 'conditions' => array( 'County.state_id' => $this->data['Example']['state_id'] ), 'group' => array('County.name') ) ) ); $this->render('/examples/ajax_dropdown'); } function add() { if (!empty($this->data)) { $this->Example->create(); if ($this->Example->save($this->data)) { $this->Session->setFlash(__('The Example has been saved', true)); $this->redirect(array('action'=>'index')); } else { $this->Session->setFlash(__('The Example could not be saved. Please, try again.', true)); } } $cities = array(); $counties = array(); $states = $this->Example->State->find('list'); $this->set(compact('cities', 'counties', 'states')); } /app/views/examples/add.ctp input( 'state_id', array( 'options' => $states, 'empty' => 'Please select a state' ), null, array( 'id' => 'states', 'label' => 'State' ) ); echo $form->input( 'county_id', array( 'options' => $counties, 'empty' => 'Please select a county' ), null, array( 'id' => 'counties', 'label' => 'County' ) ); $options = array('url' => 'getcounties', 'update' => 'ExampleCountyId'); echo $ajax->observeField('ExampleStateId', $options); Thank you in advance for your kind assistance. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send 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
Does this same code snippet apply when the code is in the model too? I'm trying for fat models and skinny controllers. Thanks in advance. On Aug 27, 6:00 am, "rich...@home" wrote: > Just to clarify mike's point: > > in your controller: > > $conditions = array("Property.zip" => $this->data); > > should be: > > $conditions = array("Property.zip" => $this->data['Property'] > ['zip']); > > On Aug 26, 10:15 pm, mike karthauser wrote: > > > hi > > you should turn on debug=2 and have a look at your query. i suspect you > > aren't returning the value you want to return any data. > > > have you pr($this->data) within your controller action? i suspect your > > > echo $form->input('Zip Code'); field is better named as > > > echo $form->input('zip', array(label'=>'Zip Code'));which will give you > > $this->data['Property']['zip'] with a value > > > when you post > > > HTH > > > bumper wrote: > > > I'm brand new to cake so please be gentle > > > > My view look like the following : > > > > > > > > > echo $form->create('property', array('action' => 'findzip')); > > > echo $form->input('Zip Code'); > > > echo $form->submit(); > > > echo $form->end(); > > > ?> > > > > > > > > > > > element('property', array('property' => > > > $property)); ?> > > > > > > > > my function in the controller looks like : > > > > function findzip() > > > { > > > > if (!empty($this->data)) { > > > > $conditions = array("Property.zip" => $this->data); > > > $foundProperties = $this->Property->findall > > > ($conditions); > > > $this->set(compact('foundProperties'));} > > > > } > > > > all I want to do is return the properties that have the zip code sent > > > by the form. I've been working on it for > > > two days and I'm at my wits end. > > > > Rich > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: actual CakePHP books
Hopefully I don't get flamed for saying this... but "anders" has a point. The senior contributors to this group already understand Cake, possibly even contributing to the development of Cake or writing articles on it. Thank you for your contributions! That being said, there is a lot of misleading and conflicting information about Cake out there. It takes hours to research a topic (like how to use ExtJS with Cake) and then filter through the results to make sure it is Cake 1.2 compatible and the code suggested actually works. Often it does not, as comments to the posts frequently point out. Yes, the API is a great resource as is the "book." When reading those docs it helps to already understand some things about Cake. For newcomers to Cake, perhaps coming to Cake with a lot of experience in procedural languages but not OO languages, it is a daunting task to learn what the official docs are explaining. Add to this that not everyone learns the same way. It is a simple fact that educators have begun to recognize over the last 10 to 15 years. Different styles of learning need to accommodated. That's why there are books, tutorials, articles, samples, even video tutorials now. "[Write] some of your own stuff…" is good advice to contribute back to the Cake community. However it is a 'chicken and egg' scenario. When you read reviews about the available Cake books, there are some comments that are quite critical indicating that the code in the book is not correct. That's not good. I've found the style of the books from Packt Publishing to be helpful to my style of learning. Their book "CakePHP Application Development" presents theory first, what we are going to do with it, the code, then a section "What just happened?" That fits the classic model for teaching: tell them what you are going to tell them, tell them, then tell them what you told them. Ancient principle but it works. After reading a book, plus countless hours researching and filtering information from tutorials, I've found I tend to approach vague awareness and then I am more equipped to understand what I read in the API or official docs. What was the catch line for X Files? "The truth is out there." Be patient "anders" and you will slowly start to increase your fund of knowledge about Cake. On Aug 17, 10:58 am, thatsgreat2345 wrote: > Read the API, don't like the docs? Right some of your own stuff if you > believe you can present it clearer. But the API and Book are very nice > and show everything that is needed. > > On Aug 17, 6:29 am, anders als wrote: > > > hi there, > > > i like cake but my problem is finding ressources from which i can > > learn. > > > The cake manual does not provide every data i need, and often i have > > to test something 1000 times after shutting down my computer going > > outside and yelling "** it does not work". > > > The problem is not the amount of information, it is the way how > > information were present in the manual. > > I look for code snippets and examples which aren't that much complex > > AND which are up2date (1.2 - 1.3). > > > My next point is, that i can not find any book which is about cakephp > > and is not older than 1 1/2 years :( > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Related drop-down list
Hello there! Yes, you certainly can do what you want in Cake... but it requires the use of AJAX. It took me many hours to get this working in my application and a little frustration. So don't give up. There are many posts on this group on this topic. Distilling all that has been written, for my project it boiled down to these two articles: 1) http://www.croyantdebridiers.com/?p=52 This article has a demo link that works and kept me focused that I could do it too. I could not get the code to work for my adaptation. (Instead of country->region I was working to do distributor->dealer. Same difference, just different tables...) 2) http://www.endyourif.com/ajax-select-box-in-cakephp/#codesyntax2 This code worked for me, but you must read the text of the article VERY carefully. The paragraph that begins "Next up..." had the key with how CakePHP converts a field name. I was having trouble retrieving the data from the secondary table until I finally understood what I had been reading a little past midnight. I hope some of this helps. Just let me know if I can answer any questions. I'm new to CakePHP but am willing to do what I can to be of assistance. On Aug 17, 4:21 pm, albe wrote: > Hello everybody! > I have to realize a form with two drop-down lists related. > Let me explain: the first d.d.l. takes its data directly from the > database and the data on the second d.d.l. change depending on the > choice that the user performs on the first d.d.l. > I'd like to do this without make any loading after the first choice > (without pressing any button... when the user chooses something from > the first d.d.l the contents of the second changes "automagically"). > Is it possible in 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: Is there a way to select an action from a double-click?
Those are really great answers and give me a direction to look to do more research. Thanks very much for comments! On Aug 12, 8:53 am, Bart wrote: > Frederick, > > There are many options. To get the best feel you are probably looking > at some ajax. You can use many different list controls that will give > you the browse feel. As far as using html there are options there > too. > > For example, you could turn your title or name field into an edit > link. Just use something like this in your code that creates the > list... > > link($client['Event']['name'], array > ('action'=>'edit', $client['Event']['id'])); ?> > > This will make each Event name in your list a link that can be clicked > to edit. If you wanted to be really fancy, you could presumably use > the link to set an EvenId variable that you could reference when you > click edit or delete buttons. If you really wanted to be "Windows" > like you could put Insert, Change, and Delete buttons somewhere and > then use the EventId variable for the edit and delete functions. But > that might not look really pretty. > > The problem with your question is there are too many answers. I > understand what you are wanting to do. There are just way too many > different ways to approach the solution. > > Hope this helps. > > On Aug 12, 8:02 am, FrederickD wrote: > > > I'm sorry my post was not more clear. I know in things Internet- > > related there is no double-click like in a local application. However, > > I cannot figure out how to have a row in a list of users (from /users/ > > index.ctp), or even an attribute within that row (perhaps 'username'), > > be a hot spot so that clicking on that would request an action (view, > > edit, or delete). > > > Having the links at the end of the row in a list takes up valuable > > 'real estate' from the area to display information. > > > I'm just looking for suggestions on alternate UI architecture. Thank > > you for the suggested link with jQuery. I will check that out. > > > I wasn't being deliberately obtuse... it just happens sometimes. > > Thanks for your patience. > > > On Aug 11, 10:57 pm, Robert P wrote: > > > > It sounds like (no, no it doesn't - i'm just guessing) what you're > > > after is some kind of inline editing jQuery plugin... something > > > likehttp://www.appelsiini.net/projects/jeditable > > > > Or perhaps you mean something like a drop-down RED (http://paul-m- > > > jones.com/?p=291) list for each 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: Is there a way to select an action from a double-click?
I'm sorry my post was not more clear. I know in things Internet- related there is no double-click like in a local application. However, I cannot figure out how to have a row in a list of users (from /users/ index.ctp), or even an attribute within that row (perhaps 'username'), be a hot spot so that clicking on that would request an action (view, edit, or delete). Having the links at the end of the row in a list takes up valuable 'real estate' from the area to display information. I'm just looking for suggestions on alternate UI architecture. Thank you for the suggested link with jQuery. I will check that out. I wasn't being deliberately obtuse... it just happens sometimes. Thanks for your patience. On Aug 11, 10:57 pm, Robert P wrote: > It sounds like (no, no it doesn't - i'm just guessing) what you're > after is some kind of inline editing jQuery plugin... something > likehttp://www.appelsiini.net/projects/jeditable > > Or perhaps you mean something like a drop-down RED (http://paul-m- > jones.com/?p=291) list for each 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 -~--~~~~--~~--~--~---
Is there a way to select an action from a double-click?
Thank you for your on-going support! There are a lot of good answers on this group. I've searched for this answer here and in "the book" but cannot find it. What is the best way to have the user select an action (RUD; read, update, delete) without a separate link at the end of the row, as in the default behavior? Is there a way to describe a 'hot spot' for one or more attributes in a list so that if there is a double-click an action can be executed? I'm wondering if this is the world of jQuery. I have not yet explored that area yet. Thanks in advance for your 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: AuthComponent - Need more explanation about "$this->Auth->authorize"
Hello! It took me a while, but I was finally able to understand and implement a good system for the Auth component. This tutorial helped to explain what I was reading in book.cakephp.org: http://www.jbcrawford.net/archives/45 In the near future I will possibly be upgrading what I have done to ACL. This tutorial looked like the best for my needs: http://brolly.ca/blog/web-development/cakephp-acl-tutorial/ For my application (groups, user, distributors, dealers, technicians, etc.) I may not need ACL just yet. With model associations I have been able to limit access to just the rows for a logged in distributor, for example. That yields the dealers associated with that distributor via choices set in "recursive" on the find(all) and paginate functions. I am going for simple right now, and may expand the application to ACL after my base knowledge is more solid. Hopefully this helps a bit. Keep on it! You can do it! On Aug 9, 12:24 am, delocalizer wrote: > Hi Miguel > Remember that Acl and Auth are quite different things - Acl only > establishes the *rules* for what can control what, Auth does the > actual authentication (permits or denies). Having said that, Auth is > designed to work with Acl, and it can do that in a couple of different > ways - if you set the authorize property to 'actions' (easiest to do > this in your AppController::beforeFilter, so it's set for all your > controllers) then Auth will expect to validate against aros_acos table > where acos are aliases for controllers/actions. You don't need to use > mapActions if you're doing that. The example in the manual (http:// > book.cakephp.org/view/641/Simple-Acl-controlled-Application) is > excellent. If you set authorize to 'crud' then it expects that the > acos are database objects. > > On Aug 8, 5:05 am, mig_akira wrote: > > > Hello everyone! > > > I've been trying to make a simple site using Acl/Auth. Everything is going > > fine, except that I don't quite understand the differences between the 4 > > kinds of 'authorizes', nor how to implement them. > > > For example, I don't understand how can I use the AclComponent::check() to > > authenticate the user when using authorize->'actions'. The same with > > authorize->'crud'. Where do I put the mapAction? In appController, or in > > every controller? What does it exactly do? > > > Sorry, but every blog I found about this say that they don't really know how > > to use those, and the manual is very briefly about this! > > > Thanks!!! > > > (By the way, I'm using authorize->'actions' and I keep getting > > [code] > > DbAcl::check() - Failed ARO/ACO node lookup in permissions check. Node > > references: > > Aro: Array > > ( > > [User] => Array > > ( > > [id] => 3 > > [username] => normaluser > > [name] => miguel > > [email] => d...@d.com > > [group_id] => 2 > > [active] => 1 > > [created] => -00-00 00:00:00 > > [modified] => -00-00 00:00:00 > > ) > > > ) > > [/code] > > ) > > > -- > > View this message in > > context:http://www.nabble.com/AuthComponent---Need-more-explanation-about-%22... > > 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: what's the best, most current book available in English?
I am a newbie to CakePHP also. I've found the book mentioned above good also, up to a point. The book gives me ideas and concepts and mostly concise examples with lots of explanation. From that, I (usually) am able to understand what I had read previously on the book.CakePHP.org site. What is difficult is searching with Google. There is a LOT of information on CakePHP out there, but you have to spend time sifting through a lot. I tend not to read much that is not at least from 2008 and specifically mentions CakePHP 1.2. Apparently the 'point' upgrade was quite major and several often-used functions were deprecated. (Never had used that word before...) I find almost as much relevant information, often more to the point I need, by reading the comments left on a tutorial posted on the web. Don't give up! I recently made several breakthroughs in knowledge and application. If I can do it you can too! On Aug 8, 7:14 pm, JamesF wrote: > http://www.amazon.com/CakePHP-Application-Development-Step-step/dp/18... > > was a good read when i first started.i find the docs to be good > but too verbose for a quick start sometimes. > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send 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 is wrong with this code?
Thanks Brian! I realize nobody is paid. Yes there is frustration and desperation at times. I do know how to live with it and continue to forge ahead. Indeed I was treating check() incorrectly. I read the entry in book.cakephp.org about six times until it finally sunk in. Once you understand what is written in the manual it makes much more sense. I am using the Auth component. I did try your suggestion at first but I kept getting an "Undefined property" error on that line in the default.ctp view. I'm sure it is a timing thing and I could load user somewhere, but ultimately reading from the session seemed to work out for now. Thanks for the encouragement to keep going. I shall. I need the money. Badly. Now on to model relationships... On Aug 7, 8:57 pm, brian wrote: > Nobody on this list is being paid to answer anyone's questions. We've > all been there before where our desperate queries have gone ignored. > Learn to live with it. In the meantime, maybe you should give this a > read: > > http://catb.org/esr/faqs/smart-questions.html > > But back to your problem, you're treating check() incorrectly. It > returns a boolean, not the value of the field. It returns true if the > param has been set. If you were to use AuthComponent, you could use > it's user() method like so" > > if ($this->Auth->user('group_id') == 2) > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send 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 is wrong with this code?
Never mind. So far two posts... ZERO answers... I kept banging on it and fixed it. Instead of using ($session->check...), which now I learned returns true or false, I am now using ($session->read...) which works well. I guess I have to figure out the right combination of things to put into a post in order to receive an answer from this group. I will keep trying. In case any other newbie has this issue, here is the code that works: read('Auth.User.group_id') == 1): ?> link(__ ('distributors',true),''.'/'.'distributors'); ?> link(__('dealers',true),''.'/'.'dealers'); ? > link(__('groups',true),''.'/'.'groups'); ?> link(__('users',true),''.'/'.'users'); ?> read('Auth.User.group_id') == 2): ?> link(__ ('distributors',true),''.'/'.'distributors'); ?> read('Auth.User.group_id') == 3): ?> link(__('dealers',true),''.'/'.'dealers'); ? > check('Auth.User.id')): ?> link(__ ('login',true),''.'/'.'users'.'/'.'login'); ?> link(__ ('logout',true),''.'/'.'users'.'/'.'logout'); ?> On Aug 7, 1:23 pm, FrederickD wrote: > I am in a quandary as to what is wrong with this code: > > > > check('Auth.User.group_id') == > 1): ?> > link(__ > ('distributors',true),''.'/'.'distributors'); ?> > $html->link(__('dealers',true),''.'/'.'dealers'); ?> > > $html->link(__('groups',true),''.'/'.'groups'); ?> li> > $html->link(__('users',true),''.'/'.'users'); ?> li> > check('Auth.User.group_id') > == 2): ?> > link(__ > ('distributors',true),''.'/'.'distributors'); ?> > check('Auth.User.group_id') > == 3): ?> > $html->link(__('dealers',true),''.'/'.'dealers'); ?> > > > check('Auth.User.id')): ?> > link(__ > ('login',true),''.'/'.'users'.'/'.'login'); ?> > > link(__ > ('logout',true),''.'/'.'users'.'/'.'logout'); ?> > > > > > > The "If" construct at the bottom works to toggle the 'Login' and > 'Logout' buttons. However, the "If" construct above based on > 'Auth.User.group_id' always acts as if the value == '1' > > I have DebugKit installed and it shows the value of 2 for the person > logged in through Session->Auth->User. The field 'group_id' is a > foreign key in the Users table. > > Please help me out here! 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 -~--~~~~--~~--~--~---
What is wrong with this code?
I am in a quandary as to what is wrong with this code: check('Auth.User.group_id') == 1): ?> link(__ ('distributors',true),''.'/'.'distributors'); ?> link(__('dealers',true),''.'/'.'dealers'); ? > link(__('groups',true),''.'/'.'groups'); ?> link(__('users',true),''.'/'.'users'); ?> check('Auth.User.group_id') == 2): ?> link(__ ('distributors',true),''.'/'.'distributors'); ?> check('Auth.User.group_id') == 3): ?> link(__('dealers',true),''.'/'.'dealers'); ? > check('Auth.User.id')): ?> link(__ ('login',true),''.'/'.'users'.'/'.'login'); ?> link(__ ('logout',true),''.'/'.'users'.'/'.'logout'); ?> The "If" construct at the bottom works to toggle the 'Login' and 'Logout' buttons. However, the "If" construct above based on 'Auth.User.group_id' always acts as if the value == '1' I have DebugKit installed and it shows the value of 2 for the person logged in through Session->Auth->User. The field 'group_id' is a foreign key in the Users table. Please help me out here! 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: CakePHP Auth Redirect
Would you show me how you put the element to log in on the side of your pages? I've been wondering how to do that, and then turn it off if logged in. For now I am using a login.ctp and a button on the navigation bar that flips between "Log In" and "Log Out" depending on if the user is logged in or not. All is working except for when the user clicks "Log Out". Now the user is directed BACK to the login.ctp, and I want it to go to the static home page. I know it is something simple, but I am missing it. Part of the answer for me was here http://book.cakephp.org/view/395/autoRedirect What do you think? FD On Aug 3, 7:09 pm, Styles wrote: > I currently have an element that sits on the side of all my pages. It > has the login form. I want to know, how can I stop CakePHP from > redirecting the user to /users/login (default) when the login fails > and they putting up the flash message there saying, you failed the > login. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Redirect issue on logout
I have been doing research on the group and it is awesome! I am new to CakePHP and trying to learn as quickly as I can. This is my first post to this group. Here is what I am trying to accomplish: 1) If user not logged in, have navigation bar show only button for "Log In" and static start page. 2) When "Log In" requested, go to login.ctp 3) After successful log in, go back to static start page and display message "You are now logged in." and change the button on the navigation bar to "Log Out". [Eventually I would like to personalize the message to be "You are now logged in as {userID}" but I don't know how to do that yet...] 4) When "Log Out" requested, log the user out and display message "Logged Out." and change the navigation bar to "Log In" on the static page. I am very very close to accomplishing those objectives. I have 1 through 3 working, with the exception of displaying the userID. When I press "Log Out", the button does change to "Log In" but I am redirected back to the login.ctp page. I don't want that! It must be something simple, as usual in CakePHP. Here is my code: The app_controller.php file class AppController extends Controller { var $view = 'Theme'; var $theme = 'CornFlowerBlue'; var $components = array( 'Email', 'Session', 'Cookie', 'Auth' ); var $helpers = array( 'Javascript', 'Form', 'Html', 'Session' ); function beforeFilter() { $this->Auth->loginAction = array ('controller'=>'users','action'=>'login'); $this->Auth->loginRedirect = array ('controller'=>'users','action'=>'add'); $this->Auth->logoutRedirect = '/'; $this->Auth->allow('display'); $this->Auth->authorize = 'controller'; $this->Auth->userScope = array('User.active'=>1); } The default.ctp file in /app/view/layouts link('BG Products, Inc. Canada','/'); ?> check('Auth.User.id')): ?> link(__ ('login',true),''.'/'.'users'.'/'.'login'); ?> link(__ ('logout',true),''.'/'.'users'.'/'.'logout'); ?> check('Message.flash')): $session->flash(); endif; ?> The users_controller.php file class UsersController extends AppController { var $name='Users'; var $uses = array( 'User' ); function beforeFilter() { $this->Auth->autoRedirect = false; } function login() { $this->Session->setFlash('Please enter your Username and Password.'); //-- code inside this function will execute only when autoRedirect was set to false if ($this->Auth->user()) { $this->Session->setFlash('You are now logged in.'); $this->redirect($this->Auth->redirect()); } } function logout() { $this->Session->setFlash('Logout'); $this->redirect($this->Auth->logout()); } The login.ctp file is just standard check('Message.auth')) $session->flash('auth'); ?> create('User', array('action' => 'login')); ?> input('User.username'); ?> input('User.password'); ?> end('Login'); ?> The logout.ctp file is present, but empty. Thanks in advance for your advice! FD --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---