Re: Sanitize::clean breaking file uploads
The file uploads are working fine without Sanitize::clean(). The only solution I see is to handle the file validation/copy logic before executing the sanitization. I'm puzzled. Maybe I should mention that I'm running on my local windows machine using XAMPP. But all the php.ini upload-related variables are set... On May 19, 8:00 pm, calvin cal...@rottenrecords.com wrote: Were the file uploads working before you used Sanitize::clean? Because cake doesn't handle file uploads automatically. Aside from having to set array('type'='file') in your $form-create() statement, you also need to move/save the uploaded file yourself. Unless you're manually moving the file, either to a permanent upload directory or into a database or something, the web server (and cake) has no way of knowing what you want to do with the file. It'll just sit in the temp directory until the script terminates, at which point the file will be deleted. On May 19, 3:37 am, Michele Ferri zomgs...@gmail.com wrote: Hello. I'm using Sanitize::clean for cleaning the $this-data arrays in the controllers before saving them to the db. example if (!empty($this-data)) { $this-data = Sanitize::clean($this-data); [...] } The problem is that if a form contains a file input, the file is not uploaded. The file array is correctly populated after the post (with tmp_name and everything), but the physical file is not present in the upload folder. Is there any workaround for this? Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group athttp://groups.google.com/group/cake-php?hl=en Check out the new CakePHP Questions sitehttp://cakeqs.organd help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group athttp://groups.google.com/group/cake-php?hl=en Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Sanitize::clean breaking file uploads
Posting my solution. function edit($id = null) { [...] if (!empty($this-data)) { $img = $this-data['Model']['image']; // save file upload array into a variable before sanitizing $this-data = Sanitize::clean($this-data); // perform sanitization if ($this-Model-save($this-data)) { // clean data has now been saved. // file upload logic, using the array we saved before if (!is_uploaded_file($img['tmp_name'])) { [...] // etc etc } } } } No problems encountered using this approach. On May 20, 9:38 am, Michele Ferri zomgs...@gmail.com wrote: The file uploads are working fine without Sanitize::clean(). The only solution I see is to handle the file validation/copy logic before executing the sanitization. I'm puzzled. Maybe I should mention that I'm running on my local windows machine using XAMPP. But all the php.ini upload-related variables are set... On May 19, 8:00 pm, calvin cal...@rottenrecords.com wrote: Were the file uploads working before you used Sanitize::clean? Because cake doesn't handle file uploads automatically. Aside from having to set array('type'='file') in your $form-create() statement, you also need to move/save the uploaded file yourself. Unless you're manually moving the file, either to a permanent upload directory or into a database or something, the web server (and cake) has no way of knowing what you want to do with the file. It'll just sit in the temp directory until the script terminates, at which point the file will be deleted. On May 19, 3:37 am, Michele Ferri zomgs...@gmail.com wrote: Hello. I'm using Sanitize::clean for cleaning the $this-data arrays in the controllers before saving them to the db. example if (!empty($this-data)) { $this-data = Sanitize::clean($this-data); [...] } The problem is that if a form contains a file input, the file is not uploaded. The file array is correctly populated after the post (with tmp_name and everything), but the physical file is not present in the upload folder. Is there any workaround for this? Check out the new CakePHP Questions sitehttp://cakeqs.organdhelpothers with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group athttp://groups.google.com/group/cake-php?hl=en Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group athttp://groups.google.com/group/cake-php?hl=en Check out the new CakePHP Questions sitehttp://cakeqs.organd help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group athttp://groups.google.com/group/cake-php?hl=en Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Sanitize::clean breaking file uploads
Hello. I'm using Sanitize::clean for cleaning the $this-data arrays in the controllers before saving them to the db. example if (!empty($this-data)) { $this-data = Sanitize::clean($this-data); [...] } The problem is that if a form contains a file input, the file is not uploaded. The file array is correctly populated after the post (with tmp_name and everything), but the physical file is not present in the upload folder. Is there any workaround for this? Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Automatically select a subset of a model's fields
Thanks. Now I gotta figure out how to limit the fields stored in session by the Auth component, and I'm set. On May 12, 11:46 pm, WoJoCo j...@wojoco.com wrote: Hi, In your associations you can name the fields that Cake retrieves in the model associations - something like: var $belongsTo = array( 'User' = array( 'className' = 'User', 'foreignKey' = 'user_id', 'fields' = array( 'User.id', 'User.email', 'etc', 'etc'), ) ); Is the basic structure that will do the trick for you. John On May 12, 1:11 pm, Michele Ferri zomgs...@gmail.com wrote: Hi. In my web app I am bridging with PHPBB for user authentication, so my main user database table is PHPBB's user table. I created a Cake model for it. The problem is, lots of tables in my app join with the user table, which has a lot of fields related to PHPBB stuff, but I only really need the user id, name and email. Cake fetches all the fields everytime. Is there a way to specify a subset of fields to select, without having to add everytime a 'fields' option in the queries? I tried with the $_schema property but to no avail. Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group athttp://groups.google.com/group/cake-php?hl=en Check out the new CakePHP Questions sitehttp://cakeqs.organd help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group athttp://groups.google.com/group/cake-php?hl=en Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Automatically select a subset of a model's fields
Hi. In my web app I am bridging with PHPBB for user authentication, so my main user database table is PHPBB's user table. I created a Cake model for it. The problem is, lots of tables in my app join with the user table, which has a lot of fields related to PHPBB stuff, but I only really need the user id, name and email. Cake fetches all the fields everytime. Is there a way to specify a subset of fields to select, without having to add everytime a 'fields' option in the queries? I tried with the $_schema property but to no avail. 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: Pagination not working with custom conditions on query
Thanks for the heads up. You pointed me in the right way, but the problem wasn't in the controller. I had to modify the table header in the view: table cellpadding=0 cellspacing=0 tr th?php echo $paginator-sort('Group.name');?/th Using 'Group.name' instead of just 'name' fixes the sorting. I guess it was because I was paginating on the Membership model. Also, thanks for the hint to get the user id from the auth component. 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
Pagination not working with custom conditions on query
Hi. I have the following models: User, Membership, Group. The Membership model is like a HABTM table, but contains some more info, like the role of the user in the group. I want to have an index page that lists all the groups of the logged user. Controller code class GroupsController extends AppController { ... function my_index() { $user_id = $this-Session-read('Auth.User.user_id'); $this-paginate = array( 'conditions' = array('Membership.user_id' = $user_id), 'limit' = 25 ); $this-set('groups', $this-paginate('Membership')); } } View code table cellpadding=0 cellspacing=0 tr th?php echo $paginator-sort('name');?/th th class=actions?php __('Actions');?/th /tr ?php foreach ($groups as $group): ? tr td ?php echo $group['Group']['name']; ? /td td class=actions style=width: 400px; ... /td /tr ?php endforeach; ? /table The records are displayed fine. The problem is, when I click on the table header to sort the results, nothing happens. It is always sorted ASC. Also, there is no ORDER BY clause in the select query, in the sql debug table. 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