multiple depending selectfields with ajax?
*using cakephp 1.3 jquery 1.7.1 i tried to get the following thing working i have three tables jobs customers customer_contacts now, when i add a new job the user should be able to select the customer and after that only one of the contacts of this customer. I have done the following: customer_contacts_controller CODE public $helpers = array('Js' = array('Jquery')); public $components = array('RequestHandler'); function get(){ $customerContacts = $this-CustomerContact-find('all', array('conditions' = 'Customer.Id = 2')); $this-set('customerContacts', $customerContacts); } Here i get only the contact with the customer_id 2 for testing. With pr() i get the right result here. So i am right at this point. View Jobs CODE echo $this-Form-input('customer_id', array('id' = 'customer')); echo $this-Form-input('customer_contact_id', array('id' = 'customercontact')); $this-Js-get(#customer)-event('change','$(#customercontact).load(customerContacts/get)'); echo $this-Js-writeBuffer(); Ok, and this isnt working. If i select a customer the customer contact selectfield will be cleared but nothing further happend. I know the load() is for html injection but i have no idea how to get the output from the controller method get() into my selectfield. Greets Dennis * -- Dennis Reinert-Frerich -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
CakePHP Media Plugin of David Persson and CDN
Hi I use the fantastic Media Plugin of David Persson. For now I have all my uploaded files in the same server I would ask if someone uses this plugin with some CDN and how use it with CDN? Many Thanks -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: ACL manager plugin
See alaxos acl plugin - S On 30 Jan 2012 03:47, Justin Edwards justinledwa...@gmail.com wrote: Hello all! I am currently managing ACL by hand, and have seen a couple of projects that do some ACL management (croogo and quickapps I believe). I am developing a framework for all of my SaaS cakephp applications that allows for unification of applications and centralized billing / accounting for the subscriber. I've come across a few good plugins so far, and was wondering if there was anything already created for 2.0+ for ACL management as far as a GUI. What I plan on doing will be a little beyond the normal ACL. I intend on creating another table (roles), which will be many to many with users, and each role will be linked to an array of aco ids, each record will also be assigned to a particular application_id so that the subscriber of the software for their organization (subscriber admin from the normal ACL related groups table) can assign roles within applications.If a user is assigned to that role, I plan on adding entries for that user's ARO id into the normal cakephp aros_acos table for the related acos. Is there anything like this already in existence, or will I have to write it all out completely from scratch?I haven't had time to look over croogo or quickapps code yet to see how they handled it, I wanted to see their code to get an idea of how best to get started. All of the best information I've learned so far is by looking at how other people were doing it. I'm planning on releasing my code so that others who might want to be making business applications or software as a service applications can put it to good use, and maybe get some good contributions back. -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Associations model linking
This shoud work too: User $belongsTo Group User $hasOne Teacher (1:1) User $hasOne Student (1:1) A user don't have multiple (belongsTo/hasMany) students or teachers, he IS the teacher OR the student... so hasOne should do the trick. Cya, -- ***Thiago Belem* Desenvolvedor Rio de Janeiro - RJ - Brasil +55 (21) 8865.9250 thiagobelem.net cont...@thiagobelem.net *Skype / gTalk **»* thiago.belem.web *LinkedIn* *»* br.linkedin.com/in/thiagobelem/pt* Assando Sites*, curso de CakePHP *»* assando-sites.com.br 2012/1/30 succer...@tiscali.it succer...@tiscali.it Hi everybody! I want to know if i'm doing things right, please! I have 3 kind of users: admin,teacher,students, so i've created 3 different groups (for ACL). For the users, I've made 3 separated tables: users (for login), teachers, and students. So: Users $belongsTo Group teachers $belongsTo Users teachers $hasMany users students $belongsTo User students $belongsTo teacher Ok? Recap: -Users: id,user,password,teachers_id,students_id,group_id -Teachers:id, ..stuff.. , user_id -Students:id, ..stuff.., teachers_id, user_id Is this correct? Thanks :) -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: not updating modified, how ?
Hi again, thanks to your tips, I effectively missed an example. This one worked : Change this line: $this-request-data['modified'] = false; to: $this-request-data['Device']['modified'] = false; also make sure you don't forget those fields in your whitelist array then (which you seem to have) Wasn't needed, as I don't updated modified. Thanks all and best regards, Charles On 28.1.2012 22:37 , Charles Bueche wrote: Hey bakers, I'm using CakePHP 2.1 on Ubuntu. I'm trying to update a single DB field, without CakePHP updating the modified field. Here is my code: $this-Device-id = $device_id; $this-request-data['Device']['last_seen'] = date(Y-m-d H:i:s); $this-request-data['modified'] = false; $this-Device-save($this-request-data, array('fieldList' = array( 'last_seen'))); However, modified gets an update. In http://book.cakephp.org/2.0/en/models/saving-your-data.html, there is a tip saying If you don't want the updated field to be updated when saving some data add 'updated' = false to your $data array. I tried 'updated' = false and 'modified' = false, but modified always gets an update. Any idea how I can avoid this ? TIA, Charles -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Associations model linking
Ups, Actually i forgot to say: a teacher is ALSO a student!! I've invented teacher-students names on the fly for a better explanation! So every teacher somewhere in the webapp can act as a students. On Jan 30, 12:32 pm, Thiago Belem cont...@thiagobelem.net wrote: This shoud work too: User $belongsTo Group User $hasOne Teacher (1:1) User $hasOne Student (1:1) A user don't have multiple (belongsTo/hasMany) students or teachers, he IS the teacher OR the student... so hasOne should do the trick. Cya, -- ***Thiago Belem* Desenvolvedor Rio de Janeiro - RJ - Brasil +55 (21) 8865.9250 thiagobelem.net cont...@thiagobelem.net *Skype / gTalk **»* thiago.belem.web *LinkedIn* *»* br.linkedin.com/in/thiagobelem/pt* Assando Sites*, curso de CakePHP *»* assando-sites.com.br 2012/1/30 succer...@tiscali.it succer...@tiscali.it Hi everybody! I want to know if i'm doing things right, please! I have 3 kind of users: admin,teacher,students, so i've created 3 different groups (for ACL). For the users, I've made 3 separated tables: users (for login), teachers, and students. So: Users $belongsTo Group teachers $belongsTo Users teachers $hasMany users students $belongsTo User students $belongsTo teacher Ok? Recap: -Users: id,user,password,teachers_id,students_id,group_id -Teachers:id, ..stuff.. , user_id -Students:id, ..stuff.., teachers_id, user_id Is this correct? Thanks :) -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help others with their CakePHP related questions. 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 -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: CakePHP Media Plugin of David Persson and CDN
Add a behavior that has an afterSave and afterDelete that take care of it (or attach those actions to your model). Here's a helper function to get a list of files based on your filters set (hardcoded for images, but you can adapt it to use whatever types you want). Once you have that list of files, you can move them to your CDN or remove them if they were deleted. function _getFiles($model, $id = null) { if (!$id) { return array(); } $result = $model-read(null, $id); // get all including filtered $files = array(); $files[] = array( 'path' = $result[$model-alias]['file'], 'url' = MEDIA_TRANSFER_URL . $result[$model-alias]['dirname'] . '/' . $result[$model-alias]['basename'] ); $extension = Mime_Type::guessExtension($files[0]['path']); $filters = Configure::read('Media.filter.image'); foreach ($filters as $size = $filter) { if (isset($filter['convert'])) { $newextension = Mime_Type::guessExtension($filter['convert']); } else { $newextension = $extension; } $newbasename = str_replace($extension, $newextension, $result[$model-alias]['basename']); $path = MEDIA_FILTER . $size . DS . $result[$model-alias]['dirname'] . DS . $newbasename; $url = MEDIA_FILTER_URL . $size . '/' . $result[$model-alias]['dirname'] . '/'. $newbasename; $files[] = compact('path', 'url'); } return $files; } -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: how to confiure myproject with cakephp 1.3 on shaing host
You would place it in public_html, since you want people to be able to visit the site. After doing that, you should be able to browse your domain and at least see something (hopefully the site home page with a list of things that may or may not need to be fixed). -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: multiple depending selectfields with ajax?
You should probably just use the Js::submit() method instead, to actually submit the form and replace the div. // assuming this is the customer_contacts/get view echo $this-Form-create(); echo $this-Form-input('customer_id', array('id' = 'customer')); echo $this-Form-input('customer_contact_id', array('id' = 'customercontact')); echo $this-Js-submit('Submit form', array('update'= '#customercontact')); echo $this-Form-end(); Then when the user submits the form, it will actually POST to /customer_contacts/get and the resulting view will replace the #customercontact element. -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: $persistModel is removed in Cake 2.0?
$persistModels does not exist anymore, the table structure is cached either in files or in APC cache if available (the faster APC cache is used if detected) -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Content Type in cakephp 2.0
echo in controller? hmm you might want to try this: $this-response-type('json'); $this-response-body(json_encode($var)); return $this-response; -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Help Understanding Fat Models
I see the oft-repeated phrase Keep your controllers thin and models fat, but I'm having a problem wrapping my head around it. Most of the tutorials and examples I see have just about all of the code in the controllers, and the models have little more than associations. So.. what exactly does a fat model look like? How do I know what to pull out of my controllers to move into models - everything seems to be working great the way it is. Do methods/actions/functions look and work the same in a model as they do in a controller? Any advice, pointers, links are much appreciated! {c} -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: how to confiure myproject with cakephp 1.3 on shaing host
ok i uploaded it into public_html , project name is (tet) now i see this page http://www12.0zz0.com/2012/01/30/19/838270121.jpg when click on my project (tet) i see this page http://www6.0zz0.com/thumbs/2012/01/30/19/650556076.jpg so what i can do to see my project please -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: how to confiure myproject with cakephp 1.3 on shaing host
Your project files should be in the root of public_html. So move everything out of the tet folder down one level, then delete it. public_html should look like this: public_html/ app lib plugins vendors index.php Also, check with your webhost that the .htaccess files will be processed. If not, consult the documentation site as there are some workarounds. You may need to show hidden files in your ftp client to see the .htaccess files - so make sure they are visible and got uploaded to the host. The .htaccess files are located in the root folder as well as app and app/webroot. {c} On Mon, Jan 30, 2012 at 2:55 PM, ahmed fakher spcial...@gmail.com wrote: ok i uploaded it into public_html , project name is (tet) now i see this page http://www12.0zz0.com/2012/01/30/19/838270121.jpg when click on my project (tet) i see this page http://www6.0zz0.com/thumbs/2012/01/30/19/650556076.jpg so what i can do to see my project please -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Cake 2.1 Events:
Book: http://book.cakephp.org/2.0/en/core-libraries/events.html Trying to get to grips with one of the new features of CakePHP 2.1. Have read the above page in the book and want to implement the code shown in the 'Registering Listeners' section but no indication given as to where the following code goes: App::uses('CakeEventListener', 'Event');class UserStatistic implements CakeEventListener { public function implementedEvents() { return array( 'Model.Order.afterPlace' = 'updateBuyStatistic', ); } public function updateBuyStatistic($event) { // Code to update statistics }} What I need to know is - What the file should be named - What folder it should reside in - How I include it in the app I assume the following goes in the Order controller, but not confident: // Attach the UserStatistic object to the Order's event manager$statistics = new UserStatistic;$this-Order-getEventManager($statistics); If anyone can make sense of it and give me some pointers I would much appreciate it. Here's someone asking the same question on CakePHP Questions: http://ask.cakephp.org/questions/view/cakephp_2_1_global_events_system Paul. -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: how to confiure myproject with cakephp 1.3 on shaing host
i move files into public_html like this image http://www10.0zz0.com/2012/01/30/20/968254408.jpg when request site url (http://alashera.3owl.com/) i see this error http://www2.0zz0.com/2012/01/30/20/161043849.jpg -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
cakephp error interrupts my jquery callback
hi, i coded a saving procedure. if the saving works the user gets redirected to a different page. if it fails he is supposed to get an ajax-like message with jquery. now when the saving really works out, everything goes fine. BUT: I created a scenario to simulate a failed saving (a passed a NULL to a database field when it is not allowed). and somehow it seems, that the cake thrown error message is blocking my jquery. here it is. my JS function: -- function save(id) { $.post(installFolder + 'users/save', { }, function(result){ var result = jQuery.parseJSON(result); if(result.successful == false) $.pnotify({ pnotify_title: 'Error.'}); else window.location.href = installFolder + '/users/view/'+id; }); } to check if the jquery pnotify works I I set if(result.successful == TRUE) and it pops up. so jquery works here. my controller: save() - some code here . . $saving = $this-User-save($this-data); if(!$saving) { $result = array(successful = false); } else { $result = array(successful = true); $this- Session-setFlash('Saving successful'); } $this-renderJSON($result); when debugging cakes error with firebug a huge load of text appears saying stuff like... uncaught exception: Invalid JSON: pre class=cake-debug AND verletzt Not-Null-Constraint... AND most importantly {successful:false} but somehow this callback wont get to my JS-functionjust nothing happens... hope someone can help me :) thanks a lot -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: cakephp error interrupts my jquery callback
If the controller method throws an error it will stop the data being returned correctly and will stop your ajax call from functioning as expacted. You need to figure out why Cake is spitting out uncaught exception: Invalid JSON With my jQuery AJAX stuff I return values using: $response = json_encode($results); echo $response; Not sure if this make's any difference. -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: cakephp error interrupts my jquery callback
hi, thanks. i know why. i made it. i forced that error to occur to simulate a failed saving to see if the user gets a proper feedback, which he does not. so i was right. question is: how can I handle this error throwing that my data will get returned correctly big big thx :) On 30 Jan., 21:58, phpMagpie p...@webbedit.co.uk wrote: If the controller method throws an error it will stop the data being returned correctly and will stop your ajax call from functioning as expacted. You need to figure out why Cake is spitting out uncaught exception: Invalid JSON With my jQuery AJAX stuff I return values using: $response = json_encode($results); echo $response; Not sure if this make's any difference. -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: authentication with 2 tables
Thank you for your answers ! I will try your solutions. -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: cakephp error interrupts my jquery callback
You need to get rid of all the cake errors on a failed save so it only returns {successful:false} Looks like you have some sort of model/dbo error related to Not-Null-Constraint ... resolve that and all the controller should return true or false and your view can handle the response accordingly. -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Help Understanding Fat Models
The best advice is to keep things DRY (Don't Repeat Yourself). Generally, this results in thin controllers (small controller functions) and fat models (more methods on the models). Any functionality that you will find yourself reusing across different controllers that appropriately relate to a model should be on that model, instead. As an example (typical blog example). //posts_controller function edit($id) { // check if user is the creator of this post and is therefore allowed to edit $post = $this-Post-read(null, $id); if (empty($post) || $post['Post']['created_by'] != $this-Auth-user('id')) { //redirect return; } } function delete($id) { // check if user has rights to delete $post = $this-Post-read(null, $id); if (empty($post) || $post['Post']['created_by'] != $this-Auth-user('id')) { //redirect return; } } Your controller would be considered fat because you duplicated code and this is logic that belongs in the model. Instead, something like this looks better: // post model function userOwnsPost($userId, $postId) { return $this-hasAny(array( 'id' = $postId, 'created_by' = $userId )); } // posts controller function edit($id) { if (!$this-Post-userOwnsPost($this-Auth-user('id'), $id)) { //redirect } } function delete($id) { if (!$this-Post-userOwnsPost($this-Auth-user('id'), $id)) { //redirect } } Perhaps not the *best* example, but you get the idea. This code is also much easier to test. If you ever change the behavior of userOwnsPost, it will change across the app. It's also very specific, which makes writing tests really easy. If you find yourself writing long, complex find conditions and using them over and over again, they probably belong in model. Remember, many small functions are easier to test and predict the outcome than large functions. Another example might be finding a list of posts that belong to a tag. You would place this in your Post or Tag model, and might call it in /posts/index, /pages/home, /posts/view, /users/posts_in_tags_i_have_created, etc. For small apps, it may not be necessary to move these functions around! But, I'd say the more you have in models the better, even if only for testing's sake. It's easier to find out what went wrong when your methods are smaller and very specific. Controller methods are usually less specific than model methods. Hope that clears it up a bit. -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: cakephp error interrupts my jquery callback
any idea how i eliminate any error output like this? thx On Jan 30, 10:51 pm, phpMagpie p...@webbedit.co.uk wrote: You need to get rid of all the cake errors on a failed save so it only returns {successful:false} Looks like you have some sort of model/dbo error related to Not-Null-Constraint ... resolve that and all the controller should return true or false and your view can handle the response accordingly. -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Cake 2.1 Events:
Listeners configured somewhere else, maybe a config file a comment from code block on cake event doc page I was thinking that the events are set much like custom error handling http://book.cakephp.org/2.0/en/development/errors.html - S On 30 January 2012 20:32, phpMagpie p...@webbedit.co.uk wrote: Book: http://book.cakephp.org/2.0/en/core-libraries/events.html Trying to get to grips with one of the new features of CakePHP 2.1. Have read the above page in the book and want to implement the code shown in the 'Registering Listeners' section but no indication given as to where the following code goes: App::uses('CakeEventListener', 'Event');class UserStatistic implements CakeEventListener { public function implementedEvents() { return array( 'Model.Order.afterPlace' = 'updateBuyStatistic', ); } public function updateBuyStatistic($event) { // Code to update statistics }} What I need to know is - What the file should be named - What folder it should reside in - How I include it in the app I assume the following goes in the Order controller, but not confident: // Attach the UserStatistic object to the Order's event manager$statistics = new UserStatistic;$this-Order-getEventManager($statistics); If anyone can make sense of it and give me some pointers I would much appreciate it. Here's someone asking the same question on CakePHP Questions: http://ask.cakephp.org/questions/view/cakephp_2_1_global_events_system Paul. -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: how to confiure myproject with cakephp 1.3 on shaing host
I'm pretty sure that is an .htaccess file issue. See the Cake Documentation at this link: http://book.cakephp.org/2.0/en/installation/advanced-installation.html#apache-and-mod-rewrite-and-htaccess Specifically, the last paragraph related to shared hosts. {c} On Mon, Jan 30, 2012 at 3:38 PM, ahmed fakher spcial...@gmail.com wrote: i move files into public_html like this image http://www10.0zz0.com/2012/01/30/20/968254408.jpg when request site url (http://alashera.3owl.com/) i see this error http://www2.0zz0.com/2012/01/30/20/161043849.jpg -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Help Understanding Fat Models
Thank you Jeremy. This is a great, concise description and the example code helps a lot to see the difference. {c} On Mon, Jan 30, 2012 at 4:52 PM, jeremyharris funeralm...@gmail.com wrote: The best advice is to keep things DRY (Don't Repeat Yourself). Generally, this results in thin controllers (small controller functions) and fat models (more methods on the models). Any functionality that you will find yourself reusing across different controllers that appropriately relate to a model should be on that model, instead. As an example (typical blog example). //posts_controller function edit($id) { // check if user is the creator of this post and is therefore allowed to edit $post = $this-Post-read(null, $id); if (empty($post) || $post['Post']['created_by'] != $this-Auth-user('id')) { //redirect return; } } function delete($id) { // check if user has rights to delete $post = $this-Post-read(null, $id); if (empty($post) || $post['Post']['created_by'] != $this-Auth-user('id')) { //redirect return; } } Your controller would be considered fat because you duplicated code and this is logic that belongs in the model. Instead, something like this looks better: // post model function userOwnsPost($userId, $postId) { return $this-hasAny(array( 'id' = $postId, 'created_by' = $userId )); } // posts controller function edit($id) { if (!$this-Post-userOwnsPost($this-Auth-user('id'), $id)) { //redirect } } function delete($id) { if (!$this-Post-userOwnsPost($this-Auth-user('id'), $id)) { //redirect } } Perhaps not the *best* example, but you get the idea. This code is also much easier to test. If you ever change the behavior of userOwnsPost, it will change across the app. It's also very specific, which makes writing tests really easy. If you find yourself writing long, complex find conditions and using them over and over again, they probably belong in model. Remember, many small functions are easier to test and predict the outcome than large functions. Another example might be finding a list of posts that belong to a tag. You would place this in your Post or Tag model, and might call it in /posts/index, /pages/home, /posts/view, /users/posts_in_tags_i_have_created, etc. For small apps, it may not be necessary to move these functions around! But, I'd say the more you have in models the better, even if only for testing's sake. It's easier to find out what went wrong when your methods are smaller and very specific. Controller methods are usually less specific than model methods. Hope that clears it up a bit. -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Help Understanding Fat Models
Cool, glad it helped. There are other examples around the internet too. -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Nick Baker's FileUpload Plugin + phpThumb Generator for existing files
Hi All, I have Nick Baker's FileUpload working for an image gallery aloong with a phpThumb generator and all works well except if there is an existing file in the folder. The FileUpload plugin is renaming the files correctly e.g. filename-1.jpg but I have something wrong in my controller where I am calling the original name of the uploaded file and not the newly generated name so the thumbnail is being created off filename.jpg. I have an add function in my GalleryphotosController that has this line: if(!$this-PhpThumb- generateThumbnail($_SERVER['DOCUMENT_ROOT'] . '/siteadmin/app/webroot/ files/galleryphotos/' . $this-data['Galleryphoto']['file']['name'], $_SERVER['DOCUMENT_ROOT'] . '/siteadmin/app/webroot/files/ galleryphotos/thumbs/' . $this-data['Galleryphoto']['file']['name'])) { pr($this-PhpThumb-errors); } I'm sure all I need to do is replace $this-data['Galleryphoto'] ['file']['name'] with the filename that the plugin makes but I cannot work out how. I'm sure it is simple but everything I have tried is failing. I am using cakephp 2.0.5 Thanks -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: how to confiure myproject with cakephp 1.3 on shaing host
thanls chooch...i follow your steps and also i found this great tutorial ad my project works in this link http://alashera.3owl.com/ /// steps /// first i move all folders from myprojectfolder to public_html second i remove myprojectfolder third i move webroot folder from app to public_html and change path from index.php like youtube tutorial /// one problem /// but something wrong need to correct..when i clicked at any link to enter to classes it give me also this error http://www2.0zz0.com/2012/01/30/20/161043849.jpg i guess this error because i remove projectfolder like tutoriali will give you one example : before uploaded my project ..i used this links to enter to this classes in localhost http://localhost/tet/galleries/ http://localhost/tet/articles/ s\and after removed tet folder i use this links but get error .. http://alashera.3owl.com/galleries http://alashera.3owl.com/articles so what i can do now...thanks -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: how to confiure myproject with cakephp 1.3 on shaing host
this link for you tube tutorial http://www.youtube.com/watch?v=4GobWo1rIkE On Jan 31, 4:28 am, ahmed fakher spcial...@gmail.com wrote: thanls chooch...i follow your steps and also i found this great tutorial ad my project works in this linkhttp://alashera.3owl.com/ /// steps /// first i move all folders from myprojectfolder to public_html second i remove myprojectfolder third i move webroot folder from app to public_html and change path from index.php like youtube tutorial /// one problem /// but something wrong need to correct..when i clicked at any link to enter to classes it give me also this errorhttp://www2.0zz0.com/2012/01/30/20/161043849.jpg i guess this error because i remove projectfolder like tutoriali will give you one example : before uploaded my project ..i used this links to enter to this classes in localhosthttp://localhost/tet/galleries/http://localhost/tet/articles/ s\and after removed tet folder i use this links but get error .. http://alashera.3owl.com/gallerieshttp://alashera.3owl.com/articles so what i can do now...thanks -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
HttpSocket won't use 443 port for https request automatically
when I pass a https url to HttpSocket::get, it won't use 443 port automatically, and return nothing but when i specify the port in url, like https://example.com:443/, it works fine is this a bug? -- Perry | 彭琪 http://pengqi.me -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php