Adding a custom CakePHP Route
How can i configure a route connection to handle... /users/{nameofuser_as_param}/{action}.json?limit_as_param=20_as_param=20_as_param=created_at in the routes.php file such that it calls my controller action like... /users/{action}/{nameofuser_as_param}/{limit_as_param}/{offset_as_param}/{order_as_param}.json? Note: Iam using Cakephp 2.X -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups "CakePHP" group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout.
Re: Retrieve attachment from a Post - mailgun
Did you ever solve this? Thanks -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout.
Re: How to modify a field in afterFind()
I just wanted to thank both of you for working through this and figuring it out. Nearly five years later, CakePHP still has this issue with version 2 and this code worked flawlessly. You guys rock! On Wednesday, December 17, 2008 1:04:52 PM UTC-5, Martin Westin wrote: thanks for the modifications. I am happy it works for you too. /Martin On Dec 17, 5:56 pm, Matt Huggins matt.hugg...@gmail.com wrote: Your solution worked flawlessly! I ended up making two small changes. First, I changed your references for 'id' to $this-primaryKey so that it can work with any model. Second, I put the afterFind/_afterFind into app_model.php so that it will call the doAfterFind of any model that implements it, as per the following: class AppModel extends Model { /** * sigh... $primary doesn't work as designed in CakePHP RC2 :( * this hack will manually go through and tear shit up */ public function afterFind($results, $primary = false) { if (method_exists($this, 'doAfterFind')) { if ($primary) { foreach ($results as $key = $val) { if (isset($val[$this-alias])) { $results[$key][$this-alias] = $this-doAfterFind ($results[$key][$this-alias]); } } } else { if (isset($results[$this-primaryKey])) { $results = $this-doAfterFind($results); } else { foreach ($results as $key = $val) { if (isset($val[$this-alias])) { if (isset($val[$this-alias][$this-primaryKey])) { $results[$key][$this-alias] = $this-doAfterFind ($results[$key][$this-alias]); } else { foreach ($results[$key][$this-alias] as $key2 = $val2) { $results[$key][$this-alias][$key2] = $this-doAfterFind($results[$key][$this-alias][$key2]); } } } } } } } return $results; } } On Dec 17, 5:36 am, martin.westin...@gmail.com martin.westin...@gmail.com wrote: Hi Matt, I ended up creating a special set of functions for this. afterFind() calls _afterFind() _afterFind() locates the data and calls doAfterFind() This works for what I use afterFind for. I will only have one place to edit if the data-structires change or I find I have missed something. It makes my models a lot more readable. The relevant code if you should find it useful: in SomeModel: // this just calls the real afterFind function afterFind($data, $primary) { return $this-_afterFind($data, $primary); } // receives data as a flat array of fields, no Modelname or anything. // run from _afterFind splits datetime-field sendat into senddate and sendtime function doAfterFind($data) { if ( !isset($data['senddate']) ) { $timestamp = strtotime($data['sendat']); $data['senddate'] = date('Y-m-d', $timestamp); $data['sendtime'] = date('H', $timestamp); } return $data; } // AppModel::_afterFind() function _afterFind($data, $primary) { if ( $primary ) { foreach ( $data as $key = $val ) { if ( isset($val[$this-alias]) ) { $data[$key][$this-alias] = $this-doAfterFind( $data [$key][$this-alias] ); } } } else { if ( isset($data['id']) ) { $data = $this-doAfterFind( $data ); } else { foreach ( $data as $key = $val ) { if ( isset($val[$this-alias]) ) { if ( isset($val[$this-alias]['id']) ) { $data[$key][$this-alias] = $this-doAfterFind ( $data[$key][$this-alias] ); } else { foreach ( $data[$key][$this-alias] as $key2 = $val2 ) { $data[$key][$this-alias][$key2] =
Re: Dreamweaver - Getting Code Coloring and Design View to work on CTP files
Does anyone know if this type of solution will work in CS6? I have spent way too much time trying to get this working, and...no dice. I can get the file to open in Dreamweaver, but the color coding and code hinting won't work at all. Very frustrating. I am using a Mac, running OSX Mountain Lion and Dreamweaver CS6 (version 12). I have added the CTP extension to: /Users/[username]/Library/Application Support/Adobe/Dreamweaver CS6/en_US/Configuration/Extensions.txt /Users/[username]/Library/Application Support/Adobe/Dreamweaver CS6/en_US/Configuration-1/Extensions.txt (I don't even know why this folder exists) /Applications/Adobe Dreamweaver CS6/Configuration/Extensions.txt /Applications/Adobe Dreamweaver CS6/Configuration/DocumentTypes/MMDocumentTypes.xml I have tried adding it as HTML files and PHP files. I have tried every combination that I can think of. I have tried including THTML as well as CTP to the lists. I have restarted Dreamweaver after each change. Nothing seems to be working. Nothing in Dreamweaver seems to be changing at all. I also can't find any recent threads addressing this issue in CS6. All these posts seem to be dated a few years ago. Am I the only one trying to edit CTP files any more? Any help would be greatly appreciated. -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. 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. Visit this group at http://groups.google.com/group/cake-php?hl=en.
Missing Controller
Hi everyone, I'm new to cake. I've installed Cake into a subdirectory (http://server.com/my-admin/), and it's all working well! However, when I access the site via https instead of http I get an error: Missing Controller *Error: **My-adminController* could not be found. *Error: *Create the class *My-adminController* below in file: app/Controller/My-adminController.php Any hints on how I can get the site to work under http AND https? Thanks, Luke -- 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: Cache problem using CakePHP default File config on apache 1.3.x - server crashes
hi Jon, thanks for your helpful reply. I am not sure that it is performance, since the site is not really busy as yet, but maybe you have something. I wonder if it is my statement to cache index action in my services controller for example that is breaking things, I might try just having caching on but no actions. Then gradually add an action in 1 each few days. My index action you see in actual fact takes an ID and so has about 40 diffferent pages formed from it. I put about 15 of these in like so in my controller: var $cacheAction = array( // 'index/' = '1 day', 'index/1' = 172800, //2 days 'index/2' = 172800, 'index/3' = 172800, (I wonder if it is something like this that somehow forcing a high load on the server and then the cache file write is broken as you say. I really don't know much at all about linux/server related things. Do you think another caching system might be a better route - or is File cache the most robust? Rather than Memcache etc. thanks for your help and to people on IRC. cheers Luke -- 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: Corrupted app/tmp/cache/views/ Files
Hey Dwayne did you get this resolved or find out why? I am having a similar issue with some cake sites. And using File caching - default as defined in the core.php. I am only caching some actions, in the controller. On Mar 15, 8:57 pm, Dwayne dwayne.kristjan...@gmail.com wrote: I've run into the followingproblemsporadically on different sites we have running on top of Cake: A client will report in that some page or other isn't loading, when it's examined the page will be a blank screen. Turning on debug will give a PHP syntax error in the cachedfilein app/tmp/cache/views/. It appears that thefilewas not completely written to disk, and therefore is invalid. Deleting thatfilefixes theproblem. I'm not sure how these files are becoming corrupted, though. Theproblemseems mostly random, but it is tied in to server load. When the server is heavily loaded this will happen more frequently. Today a client reported aproblemagain. The cachedfilehad been created at 2:25AM, but there were records in the DB created closer to noon that couldn't have been created if that page were broken. Some additional details: the sites that have thisproblemare running a custom CMS we've written on top of Cake. This makes use of a modified version requestAction() to load parts of a page. I'm not sure if that could have an effect or not. Thecachefiles generated are enormous as well, so scanning through them to see how they work hasn't done me much good. I don't know if that's typical of Cake or specific to our CMS. Has anyone else experienced aproblemlike this? Searching for corruptedcache in this group doesn't return anything that seems directly related, nor does searching for cakephp corruptedcache in google. I'm still a bit unclear on exactly how Cake's caching works under the hood, but at a surface level the caching works except for when the files themselves are busted. Any ideas on how to prevent or detect this? Ideally I'd rather this didn't happen, but if I can at least prevent things from needing a user to contact our client that a page is down and then have the client contact me that would be a significant improvement. -- 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
Cache problem using CakePHP default File config on apache 1.3.x - server crashes
Hi I am using some controller level caching for a few actions on a couple of cakePHP sites. both are cake1.3 sites, and are on the same VPS, running php 5.2.11 and it has eAccelrator too. the cache seemed to work for a few days and then both sites became unreachable this morning. I restarted the VPS as it had crashed, and then the sites still didnt come back up. I turned debug on to 1 on both and then they worked (implying cache issues) - and since cacheing was added just last week to one of them I belive it is a caching problem. I have checked in my error_log for apche and there are segmentation faults 11 around the time the server crashed, also child processes exiting. (thanks to theAnachron in IRC for their help in finding this). I have now set the prefixes to explicitly different things for these 2 cake apps. Any other suggestions for me to get cache wokring without crashing? Would I be better sidestepping and using MemCache or similar (are these more robust?) sorry for my obvious cache n00b-iness. I want to sue it as the performance boost seems great and is suitable for these sites, whose content is reasonably static on popular pages. thanks boobyW -- 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: Cache problem using CakePHP default File config on apache 1.3.x - server crashes
Hi - no - do you think that would help? I tried making the prefix of the cache different in case there was a conflict with other caching in the /tmp of the server but that hasn't worked, as the site has hung again just now. I will see if I can find some info on the lock thing, thanks. Luke -- 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
alternative $ajax-remoteTimer in CakePHP 1.3
Hello, how can I rewrite part of my view using $ajax-remoteTimer (http:// book.cakephp.org/view/627/remoteTimer) in CakePHP 1.3? I know I need to using helpers Html and Js but how can I use them in this case? Thank you Lukas 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
adding $javascript helper to libs/Error.php and CakeError in 1.2.x - problem
hi I tried copying cake/libs/error.php to my app/controllers and then adding $helpers = array('Javascript') but it didn't work, although adding it (temporarily. natch!) to the lib file does work. What is the thing with the inheritance that I am missing here? cheers Luke 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: Implementing uploadify - File upload issue - param definitions issue
any luck with this? I would like to try uploadify but it seems there are only broken reports with cake in the google group? Anybody used it successfully out there? regards Luke On Mar 21, 10:41 pm, abocanegra aaronbocane...@gmail.com wrote: Correction - However, problems still not fixed upload function had a typo, fixed it but still not uploading file function upload() { if (isset($this-params['form']['Filedata'])) { //Derived from theuploadify.php file - does not work $tempFile = $this-params['form']['Filedata']['name']; $targetPath = 'http://www.whatartist.com/uploads/temp'; $targetFile = str_replace('//','/',$targetPath) . $this-params['form']['Filedata']['name']; move_uploaded_file($tempFile,$targetFile); $image_path = $this-params['form']['Filedata']['name']; if(isset($image_path)) { $this-Photo-saveField('image',$image_path); //Put success message and redirect here }else{ //Put error message here } } } Also, I beleive the multiple posting - beyond 2 entries - was a session issue. I deleted all sessions in the phptmpdir and it fixed that issue. I still cannot upload the file though. On Mar 20, 9:40 pm, abocanegra aaronbocane...@gmail.com wrote: Alright, ahead of time thanks for any help on this. I have been researching for far longer than I care to admit. I am attempting to getuploadify2.1 to work with cakePHP 1.3. I have read up a great deal on other formats as well, such as swfupload. Controller name = photos_controller.php relevant functions = upload addmult Model Name = photo.php views= addmult.ctp (upload.ctp is just the function being called from addmult) Sucesses - I have been able to get the browse and upload working (on the surface). It appears to handle a multi-upload, or at least goes through the paces. Also I am able to trigger the upload function from the controller and add either the name using $this-params['form'] ['Filedata']['name']. Problems - I cannot get the file uploaded to my uploads/temp directory (it is 777 and works well with my single image upload script). I have tried every variation including absolute paths to get to it . There does not seem to be any error messages, I have tried adding a few from the various forums, none have done anything. When I trigger the multiple uploads it goes through the paces, but only adds one entry into the database. Also It appears the database tends to only accept 2 entries, though I haven't thoroughly tested that problem. Goal - I am hoping to implement this function so that I can utilize it with image.php which i have altered to create the files in the manner I need. To do this I will need to be able to send the file to image.php for scale changes, multifolder organization and name changes. After which it will redirect to a page to add the additional info (title, client, etc) needed. Any advice on any of the issues would be appreciated. Code Snippets: Controller: # class PhotosController extends AppController { var $name = 'Photos'; var $components = array(Image); var $helpers = array('Html', 'Javascript', 'Form'); function beforeFilter() { if ($this-action == 'upload') { $this-Session-id($this-params['pass'][0]); $this-Session-start(); } parent::beforeFilter(); } function upload() { if (isset($this-params['form']['Filedata'])) { //Derived from theuploadify.php file - does not work //$tempFile = $this-params['form']['Filedata']['tmp_name']; // $targetPath = 'http://www.whatartist.coms/uploads/temp'; // $targetFile = str_replace('//','/',$targetPath) . $this-params['form']['Filedata']['name']; //move_uploaded_file($tempFile,$targetFile); $image_path = $this-params['form']['Filedata']['name']; if(isset($image_path)) { $this-Photo-saveField('image',$image_path); //Put success message and redirect here }else{ //Put error message here } } } // Handle multiple incoming uploads. function addmulti
display if field is null .
hii, In my program i added one item in add.ctp with return_date DATE field as null. This field will edit at the time of item return. After issuing an item i want to display the remaining items in list.The issued item should not display.(file: available_item.ctp). In basic query, Select all from items where item.return_date=null. How I can implement this condition in cakephp ? plz help me. regards, luke -- You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-...@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=.
Re: null value from date field.
hello, In my program i added one item in add.ctp with return_date DATE field as null. This field will edit at the time of item return. After issuing an item i want to display the remaining items in list.The issued item should not display.(file: available_item.ctp). In basic query, Select all from items where item.return_date=null. How I can implement this condition in cakephp ? plz help me. On Nov 11, 4:41 pm, Marcelo Andrade mfandr...@gmail.com wrote: On Tue, Nov 10, 2009 at 8:09 AM, jiru jiransl...@gmail.com wrote: Please give me the code for to check date field isnullornot. ? http://book.cakephp.org/view/74/Complex-Find-Conditions ''' Cake can also check fornullfields. In this example, the query will return records where the post title isnotnull: array (not = array ( Post.title =null ) ) ''' Best regards. -- MARCELO DE F. ANDRADE Belem, PA, Amazonia, Brazil Linux User #221105 -- You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-...@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=.
autosuggest and auto-completion in text boxes
Hii, developers, in my ajax auto complete program , // add.ctp div class=Users form ?php echo $form-create('User');? fieldset legend/legend ?php echo $form-select('country_id',array($countries),null,array ('id'='countries'),false); ?br /br /? echo $form-select('region_id',array(),null,array ('id'='regions'),false); ? /fieldset ?php echo $ajax-observeField('countries',array ('url'='update_region_select','update'='regions'));? ?php echo $form-end('Submit');? /div !--?php __('Add');?-- and //select.ctp ?php if (!empty($options)) { foreach ($options as $k = $v) { // echo option value='$k'$v/option; } } ? I want both values in text boxes. The input box should need textbox with autosuggest from databsse and output should autocomplete textbox . Please help me. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Find Value in $this-data
Hi Guys, I am trying to find out if a Value in the $this-data Array excists. Here the structure of the Array: Array ( [Recipe] = Array ( [recipe_name] = ) [Ingredient] = Array ( [1] = Array ( [ingredientname] = Milk ) [0] = Array ( [ingredientname] = Water ) ) } I now wanted to use: if (!in_array($value['In']['ingredientname'],$this-data ['Ingredient']) ) So, if it is not in the array I wanted to give a message out. This does not work for some reason, did I missunderstand the in_array function? Any idea to achieve it otherwise? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. 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 -~--~~~~--~~--~--~---
Question about a Relationship
Hi, I am sitting on a Relationship issue where I would like to hear your opinion about. It is a recipe page. A user can write Recipes and save other Recipes as Favourites. A User hasMany Recipe(Recipe belong to User) A User hasMany Favourite (Favourite belong to User) My Favourite Table: id user_id recipe_id My Recipe Table: id recipe_name user_id When a User is logged in he can see his Favourite Recipes. When looking at a recipe in detail, he can take it off the favourite list aswell. Because I only have the relation between Recipe and User and User and Favourite, I actually don't get the favoruite_id from the Favourites table. I was thinking to say Recipe belongsTo Favourite and Favourite hasMany Recipes, but than it complains that there is not favourite_id in the Recipes table. What am I doing wrong? I obviously got a thinking mistake in this and can't find it out. Any thoughts? Thanks in advance. Luke --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. 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 -~--~~~~--~~--~--~---
Drag and Drop with jQuery
Hi, I have implemented a Drag and Drop effect with jQuery. To make it easier, I read a list of elements from the database, these elements can be moved into a different folder. The Folders show the amount of Elements. Here you see my Folders: li id=\{$value['Cookbook']['id']}\span id=\countFav\{$amount} /span span{$value['Cookbook']['cookbookname']}/span/li; Everything works fine so far, but now I also wanted to make sure that the amount of Elements get updated. so I need to update the $amount. So what I figured out is that with this line of code I can overwrite my HTML with the ID in my case amount $.post('../dropZone', {cookbook_id: $(this).attr('id'),id:id}, function (data) { $(amount).html(data)}); But obviously if I do this the whole li dissapears and gets replaced with the AJAX response. Does anyone got an idea how I can just update the PHP variable $amount? Thank you very much in advance. Luke --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. 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: Drag and Drop with jQuery
Hi Jon, Great, this was the solution. Thank you so much for the help. Its the first time that I am using jQuery and I surley have to learn a lot more about it. I now only have one small issue left, where I am not 100% sure. I want that the Element I dropped dissapears when its dropped on a folder. I have actually taken the example from this page as the base: http://jqueryui.com/demos/droppable/#photo-manager So I suppose I have to add something in this area: // let the trash be droppable, accepting the gallery items $trash.droppable({ accept: '#gallery li', activeClass: 'ui-state-highlight', drop: function(ev, ui) { deleteImage(ui.draggable); } }); But I am really not sure, what would make the dropped element dissapear. Any hint on this aswell maybe? I have tried out different solutions, but never got anywhere. Do I have to somehow overwrite the class? Luke --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. 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: Drag and Drop with jQuery
Hi Jon, It really is a very cool framework. I guess I was always trying to get around it since it looks complicated the first time you look at it and I was already busy enough picking up on OOP and now CakePHP. But you can't try to avoid it, since there would be too much to miss out. I thank you very much for your help, otherwise this would have been very frustrating I am now looking into the option you mention above, the call .hide ('normal'); on the element Unfortunately I thought that it would be just: $(ui.draggable).hide('normal'); but it is not, so I will have to play around a bit more with it. Thank you again. Luke --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. 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 -~--~~~~--~~--~--~---
Question about dropRemote
Hi, I had already posted a question, but figured out that this might have been too confusing. i want to use a Drag and Drop AJAX Function. I have got 2 Drop Zones. div id=dropZone11/div div id=dropZone22/div Question: 1. Do I need now 2 dropRemote for this? 2. I know I can use with to hand over data through the $this-params ['form'], but how would I send over the id from the dropZone? My dropRemote looks like this: echo $ajax-dropRemote('dropZone1', null, array('url' = '/categories/dropZone/', 'hoverclass' = 'dropzone1', 'update' = 'dropZone1', 'with'='{draggedid:element.id.}', 'indicator' = 'loading')); Any information will help. Thanks a lot. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
dropRemote Update Div and Database
Hi, I am trying the following with AJAX, I have a list of entries from the Database, which you can take and move into different boxes. I suppose I need the drag and drop function from AJAX. ich have been going through the world wide web to find some solutions but struggle badly. I also thought that I need dropRemote. So I found some stuff on the net and tried to change this. ?php echo $ajax-drag(cakepowerpng, $dragoptions1); ? ?php echo $ajax-drag(item_with_title, $dragoptions2); ? div id=box1 div id=drag_area1div id=drag_space1 style=height:150px;1/ div/div /div div id=box2 div id=drag_area2div id=drag_space1 style=height:150px;2/ div/div /div div id=loading_div style=display:none;padding:6px; ?php echo $html-image(ajax-loader.gif); ? /div ?php $drop_options1 = array( url = /dragdrop/dropped/, with = 'id='+encodeURIComponent(element.id), loading = Element.show('loading_div'), complete= Element.hide('loading_div'), update = '+dropped.id+', // I suppose here I have to update the box where the element was dropped on ); echo $ajax-dropRemote('drag_space2', //ID array (accept=drop_ok_class,hoverclass=dropspace_hover), $drop_options1); //AJAX option echo $ajax-dropRemote('drag_space1', //ID array (accept=drop_ok_class,hoverclass=dropspace_hover), $drop_options1); //AJAX option Of course the above does not work at all. But How would I get it working? I need to see all the Elements in Box1 and Box2 and of course this should be going to the controller aswell to update the Database. Does anyone got an Idea how I would solve this? I am running out of ideas. Thanks a lot. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Drag and Drop with Ajax
Hi, I am trying to implement a Drag and Drop Ajax Feature. I found the below site with some examples: http://cakephp.cba-japan.com/ Unfortunately I will need a slightly different solution, since I want to be able to move an article from a list of articles either in Category 1 or Category 2, so I will need to know in the end which Article was moved into which Category. I am sure there must be examples like this on internet, but I can not find it anywhere. What should I look for excatly or does someone got any other hint? Thanks a lot in advance. Luke --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. 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: saveAll with a hasMany relationship
Hi Nancy, I have a setup where I save the hasMany and HABTM in 1 go. It was a bit tricky and took me aswell, I think 3 weeks (shame) to finally get it sorted when I got the hint with the array setup. It really is all about having the $this-data set up in the right way. I suppose you have a form where your data comes from, how do your input fields are set up? What is the outcome of print_r($this-data)? Luke --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Add input field with jquery
Hi brian, excellent, thank you for your help. I got it to work. It is slightly different but your answer got me on the right route. Thank you again. Luke --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. 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: saveAll with a hasMany relationship
Hi Nancy, I had the same issue like you are describing, how to save the hasMany after positing it on here, I found the solution. I have a recipe hasMany Ingredient relationship, the importance is to have the array formated in the right way. It needs to look like below, than it will work. [Recipe] = Array ( [recipe_name] = Champions [Rezeptportion] = 2 ) [Ingredient] = Array ( [0] = Array ( [ingredientname] = Champions ) [1] = Array ( [ingredientname] = pepper ) Try this out and let me know if you struggle, maybe we find an answer. Luke --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. 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: Ubdate HABTM and hasMany
Hi delocalizer, Thank you very much for your hint. You are absolutley right, I had an issue with the set up of the array. I now got it all to work, finally after 2 weeks I have to say. So for everyone who got the same problem, the array for the hasMany needs to look like this: [Recipe] = Array ( [recipe_name] = Champions [Rezeptportion] = 2 ) [Ingredient] = Array ( [0] = Array ( [ingredientname] = Champions ) [1] = Array ( [ingredientname] = pepper ) Thank you very much again for your help. Luke --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. 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 -~--~~~~--~~--~--~---
Add input field with jquery
Hi, I am having a form, where I want the User to be able to dynamically add input fields. I have found some jquery script to achieve this. Everything works fine, besides when I have a validation error and the Form needs to shown again, the new input field is gone. Does anyone got an idea how I could solve this? Thanks a lot. Luke --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. 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: Ubdate HABTM and hasMany
Hi, Sorry that I have to get back again. I am still hanging on this issue. recipe HABTM subcategories recipe hasMany ingredients My $this-data array Array ( [Recipe] = Array ( [id] = 6 [RecipeUIED] = [recipe_name] = Testname ) [Ingredient] = Array ( [ingredientname] = Array ( [0] = water [1] = meat [2] = salt [3] = pepper ) ) [Subcategory] = Array ( [checkbox] = Array ( [1] = 1 [2] = 0 ) ) Is the Array correct formated or what is wrong? saveAll does not want to save everything. INSERT INTO `ingredients` (`ingredientname`) VALUES (Array) So, $this-Recipe-saveAll($this-data) does not seem to work. How can I save the hasMany and HABTM relationship than? I tried to implement Persivo's hint, but was not successfull either. Any hint is much appreciate, since I don't seem to move any step. Thanks a lot in advance. Luke --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. 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: Ubdate HABTM and hasMany
Hi, i have to get back to this topic, since I still have not found the solution. When I print out the $this-data array, i get the below. So now not forget, recipe HABTM subcategories recipe hasMany ingredients Array ( [Recipe] = Array ( [id] = 6 [RecipeUIED] = [recipe_name] = Testname ) [Ingredient] = Array ( [ingredientname] = Array ( [0] = water [1] = meat [2] = salt [3] = pepper ) ) [Subcategory] = Array ( [checkbox] = Array ( [1] = 1 [2] = 0 ) ) Is it possible to get everything saved with one go? And if so, is the Array formated wrong and how does it need to look? Hope someone can give me a hint. I am runing around in circles. Thanks a lot Luke --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. 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: Search function
Hi Dave, Maybe not the nicest solution, but this should work: $i=0; // This is your counter // Now build your SQL String $sql = SELECT * FROM table; foreach ($string as $key = $value) { $value = trim($value); //strip white space befor and after each term // $value = trim($string[$i]); $sql.= Post.title LIKE '% . $value. %' OR Post.description LIKE '% . $value . %' ; $i++; // Put your counter up by 1 if($i count($string)) // Check if your counter is smaller than amount of values in array, if there are still values, add a OR { $sql.=OR; } } You can try out by putting in echo $sql at the end. Is this what you were looking for or did I missunderstood? Luke --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. 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: Search function
You are missing a few OR in your below text, I have tried it out and get all the needed OR, did you just keft it out below or what is the issue? Oh and by the way of course you will need a WHERE aswell in the first part $sql = SELECT * FROM table; I forgot that one. On 12 Aug., 17:00, Dave Maharaj :: WidePixels.com d...@widepixels.com wrote: Yeah that's the basic idea to build the Post.title LIKE '% . $value. %' OR Post.description LIKE '% . $value . %' ; string from the user submitted text So if there are 3 words it ends up Post.title LIKE '% . $value. %' OR Post.description LIKE '% . $value . %' ;Post.title LIKE '% . $value. %' OR Post.description LIKE '% . $value . %' ;Post.title LIKE '% . $value. %' OR Post.description LIKE '% . $value . %' ; -Original Message- From: Luke [mailto:eik...@hotmail.com] Sent: August-12-09 11:43 AM To: CakePHP Subject: Re: Search function Hi Dave, Maybe not the nicest solution, but this should work: $i=0; // This is your counter // Now build your SQL String $sql = SELECT * FROM table; foreach ($string as $key = $value) { $value = trim($value); //strip white space befor and after each term // $value = trim($string[$i]); $sql.= Post.title LIKE '% . $value. %' OR Post.description LIKE '% . $value . %' ; $i++; // Put your counter up by 1 if($i count($string)) // Check if your counter is smaller than amount of values in array, if there are still values, add a OR { $sql.=OR; } } You can try out by putting in echo $sql at the end. Is this what you were looking for or did I missunderstood? Luke- Zitierten Text ausblenden - - Zitierten Text anzeigen - --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. 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 -~--~~~~--~~--~--~---
Ubdate HABTM and hasMany
Hi, I have a form to add recipes to a database. I have got a HABTM Relationship and a hasMany. recipe HABTM subcategories recipe hasMany ingredients In my controller I using the following: $this-Recipe-saveAll($this-data['Recipe']) This updates my Recipe table with the HABTM Relationship. After that I decided to add this part if($this-Recipe-saveAll($this-data['Recipe'])){ $this-Recipe-Ingredient-save($ingredient); } I now have two problems 1. The if condition does not work out, so I never get to $this-Recipe- Ingredient-save($ingredient); 2. But even when I just try out $this-Recipe-Ingredient-save ($ingredient); the update is not working. I cant see what is going wrong. Any ideas? thanks a lot in advance. Luke --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. 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: Saving both habtm and hasmany data
Hi, I am just struggling on the same issue I think. I have a HABTM which works fine, additional I now have a hasMany to be saved, which is no problem if it is only a single input field. But I am actually trying to add another. Here is my Array: [Recipe] = Array ( [recipe_name] = Test [user_id] = 1 ) [Ingredient] = Array ( [ingredientname] = Array ( [0] = salt [1] = pepper ) ) [Subcategory] = Array ( [Subcategory] = Array ( [0] = Maindish ) ) Recipe HABTM Subcategory Recipe hasMany Ingredient Ingredient belongsTo Recipe in my recipe_controller I use this: $this-Recipe-create(); if ($this-Recipe-saveAll($this-data)) This way, Recipe and Subcategories get saved without a Problem, but for Ingredient I get this: INSERT INTO `ingredients` (`ingredientname`, `recipe_id`) VALUES (Array, 125) My add.ctp: for ($counter=0;$counter5;$counter++) { echo $form-input(Ingredient.0.ingredientname. $counter,array( 'label'= 'ingredient')); } What I don't understand is that the Array looks the same for Subcategory and Ingredient, but why is it not saving on both with them? INSERT INTO `ingredients` (`ingredientname`) VALUES (Array) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. 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 -~--~~~~--~~--~--~---
Counter Cache behavior for HABTM relations
Hi I have a HABTM Relationship and was using CounterCache, following the below script: http://bakery.cakephp.org/articles/view/counter-cache-behavior-for-habtm-relations It worked well, till I decided that a user should be able to choose more than 1 Category. Since than the CounterCache is not working anymore, because it is complaining that the id I am looking for to update is now an Array. (WHERE `subcategory_id` = (Array)) Does anyone knows the above script and maybe know how to get this to work? It was a nice function and it would be great to work again. Thanks a lot. Luke --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. 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: Counter Cache behavior for HABTM relations
Hi, I just found the solution myself I think, I added foreach ($this-foreignTableIDs[$assocData['className']] as $id) into the updateCounters method and it now updates for every category. Maybe this comes handy for someone. It seem to work and I get no error message anymore. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. 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 -~--~~~~--~~--~--~---
understanding blackHoleCallback
Hi, I am using the Security component, but would like to make sure that if the security check fails, the User will get an Error message displayed inside the Layout. So, when I use just: $this-Security-blackHole($this, 'You are not authorized to process this request!'); I only get a blank white page with nothing else displayed. So I added: $this-Security-blackHoleCallback = 'accessError'; With this, I now get the You are not authorized to process this request! displayed, but it sits outside of my Layout, its actually even outside the !DOCTYPE What am I doing wrong? If I understand right, than I would need a function accessError() , but what do i need to add into this to make sure it is all in one Layout? I look forward to any help, I have read backwards and forwards through the www but could not find an answer. Thanks a lot for your help. Luke --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. 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 -~--~~~~--~~--~--~---
blackHole and Callback Question
Hi, I am finally moving on with my first Cake Project. (Recipe Page) User can add Recipes and of course they must be able to delete them aswell. So if they are logged in, they see their own recipes. To secure other recipes of being deleted, I wanted to use the Security Component. So I added below in the recipe_controller function beforeFilter if(!$this-canAccess($this-Auth-user('id'), $this-params['pass'] [0])) { $this-Security-blackHoleCallback = 'accessError'; $this-Security-blackHole($this); } In my App Controller, I have now got the function accessError() method and function canAccess($userId = null, $primaryKey = null) { if($this-Recipe-find('first', array('conditions' = array ('recipe.user_id' = $userId, 'recipe.id'= $primaryKey), 'recursive' = -1))) { return true; } return false; } I would like now that the User stays on the same site, but gets an Error Message displayed. How would the accessError method have to look to achieve this? I have searched through the www, but could not find any examples. Hope you guys understand what I am looking for. Is this the right way to achieve it or how are you securing against manipulation? Look forward to some ideas. Thanks so much 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 -~--~~~~--~~--~--~---
Counter_cache in 2 tables
Hi, I finally got Counterchache for HABTM running. I have now got these 3 tables: subcategories - subcategory - maincategory_id - recipe_count recipes_subcategories - recipe_id - subcategory_id maincategories - id - maincategory Each Maincategory has many Subcategories. So when I add a new Recipe, the subcategories table gets updated with recipe_count. I now have a Navigation, which reads out the Maincategories. I would like to get the amount of recipes inside each Mainnavigation. Currently I just use this for my Element: return $this-Maincategory-find('all', array('order'=array ('Maincategory'='asc'), 'recursive' = 0)); Is there any chance to combine this with the recipe_count from the subcategories table or is there a chance that i also get a figure straight written in my maincategories table when i add a recipe? I am a bit confused on that issue, since I am not sure if I use CounterCache right or if it can update the count in 2 tables. Look forward to you guys feeback. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. 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 -~--~~~~--~~--~--~---
Stop AJAX Request
Hi, I am still working on my first Cake Project and I am now stuck in some AJAX Request where I would need some feedback. I am trying to achieve the following. I have recipes everybody can see. There is a link above the recipe to add it to your favorites. If you are logged in the page should check if you have it already saved, than the link should show Already in cookbook otherwise Add to favorites. Next step is when you want to add it, you have to be logged in, otherwise the login window should show up. The Add to cookbook I wanted to do with AJAX in the background. So I am using if($this-Auth-user() == null) { $this-redirect('/users/login'); } in my addToFavorites($id) to check if the User is logged in, if not, the Login Form shows up above the recipe. But what I actually would like to reach is that the recipe doesn't show up at all anymore but instead just the Login Form. If you are than logged in, you should be seeing the recipe again and the link should have changed. I suppose it happens, because I am only replacing the content in the div with AJAX. Is there any chance to stop the AJAX response and instead re-load the full page or what would you guys suggest? Thanks for any advice. Luke --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. 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: Stop AJAX Request
Hi, Oh, so I can not re-send the complete Page when I realise the User is not logged in!? So I will have to re-think my idea. I really thought that there is a possibility, but good that you have given a clear No, not possible I have now tried something out from the IBM Tutorial, its a bit of a different issue, but I did not want to start a new post. http://www.ibm.com/developerworks/opensource/library/os-php-cake5/index.html?S_TACT=105AGX44S_CMP=TUT They use the following: function removeFromFavorites($id) { $username = $this-Session-read('user'); $success = false; $user = $this-Product-User-findByUsername ($username, 'User.id'); $this-Product-User-id = $user['User']['id']; $success = $this-Product-User-removeFavorite($id); if ( $this-RequestHandler-isAjax() ) { echo 'Removed product from favorites'; exit; } else { if ( $success ) { $this-Session-setFlash('Removed product from favorites'); $this-redirect('/users/favorites'); } else { $this-Session-setFlash('Access denied'); $this-redirect('/products/index'); } } } I have tried this out to understand the structure behind it but get Query: removeFavorite So it must be the below line, but what is the issue with this code? Why is it using the method as a query? $success = $this-Product-User-removeFavorite($id); I can't see what is wrong. Anyone an idea? Thanks so much in advance. Luke --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. 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: Structual controller question
Hi Guys, Thanks for the answers. So do I understand it right, Either add it to the user_controller or the recipe_controller. So you guys would drop the idea of having a mybox controller than, even if I have a mybox table where I store the IDs of the recipes a user watches. So from my feeling I would think that the mybox section should be than in the user_controller. Are there any other thoughts maybe? I look forward to any feedback. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. 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: Count RS for element
Hi, I just had a look at the CounterCache, but seem to struggle on the implementation. I added another field to my maincategories table: recipes_count I suppose I have to add now 'counterCache'=true to my Maincategory model, my relationships are currently looking like this - Maincategory model - var $hasMany = array('Subcategory' ) - Recipe Model: - var $belongsTo = array( 'User' = array( var $hasAndBelongsToMany = array( 'Subcategory'= array( - Subcategory Model: - var $belongsTo = array('Maincategory') var $hasAndBelongsToMany = array( 'Recipe' = array( into which Model I have to add the 'counterCache'=true ?? I have tried it with the HABTM so into recipe and subcategory model and than used this: http://bakery.cakephp.org/articles/view/counter-cache-behavior-for-habtm-relations Unfortunately this did not work. Of course I would like to have the counter in the maincategory table, but is this so easy to reach if I actualy don't save anything into this table when I add a new recipe? How would counterCache be activated? Do I have to call it up in the controller aswell? Any advice will be great. Luke --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. 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 -~--~~~~--~~--~--~---
Count RS for element
Hi, I have the following issue where I am a bit stuck. I have 3 tables maincategories - id - maincategory subcategories - id - subcategory - maincategory_id recipes_subcategories - id - recipe_id - subcategory_id The Maincategories are shown as a Navigation. I created an element for this. Everything works fine. The next step I would like to achieve is to count the amount of recipes for each maincategory. Right now I use this code in my maincategories_controller: if(isset($this-params['requested'])) { return $this-Maincategory-find('all', array('order'=array ('Maincategory'='asc'), 'recursive' = 0)); } How do I get the amount of recipes shown with my above Database struktur? Could someone give me a hint? I am pretty stuck with it and can't think of a solution. Thank you very much in advance. Regards Luke --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. 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 -~--~~~~--~~--~--~---
observeField Question
Hi, I am struggling with cakePHP a bit. I have setup a dependable dropdown. I was now thinking about having the second dropdown hidden, till you actually choose something from the first dropdown. So I thought about doing this via a div which is hidden in the beginning. echo 'div id=subs style=visibility: hidden;'; echo $form-input('Subcategory.subcategories_id', array('empty' = '-- Select --')); echo '/div'; $options = array('url' = 'getSubcategories', 'update' = 'subs'); I don't really know what I would have to add into the array to now set the visibility to visible. Someone maybe with a thought on this issue? Thanks a lot 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: Database and Model Design for HABTM
Hi, Thanks for your answers. Actually, if I look at the first one, I do understand that the way I am doing it right now, I would have duplications in my db tables. maincategories and subcategories will be filled manually, recipes_subcategories and recipes will be filled through the Add recipe Form. F.e. maincategories (id, maincategory_name) 1 | Main Dish 2 | Appetizer 3 | BBQ subcategories (id, subcategory_name, maincategory_id) 1 | Beef | 1 2 | Beef | 3 3 | Pork |1 4 | Vegtarian | 2 recipes_subcategories (id,recipe_id) 1 | 1 | 1 2 | 1 | 2 recipes (id, Name) 1| Beef Chops I can't see how I could otherwise design the tables. 1 maincategory has many subcategories, 1 recipes can belong to many main/ subcategories, but I am thinking that if i use the subcategory_id for the recipe, that this subcategory is already bind to a maincategory, so I wont have to add this into the recipes_subcategories. Does this makes sense? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. 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: Database and Model Design for HABTM
Hi John, Shame, but thanks a lot. I think I will really need the option to have a recipe in more than 1 category. I will probably allow up to 2 categories. Where I now just struggle with is that I am trying to read out all the recipes which belong to a subcategory. So I clicked on BBQ and than on Beef. Now I should get a list of all the recipes. I would have to read out the DB table recipes_subcategories to get all the recipe id's of all the recipes from that subcategory and than read out the information from the recipe table (At least the recipe name and the id) to create an overview of all the available recipes. So in my RecipesController I have add: $this-set('recipes', $this-Recipe-RecipesSubcategory-find ('all',array('conditions' = array('subcategory_id' = $id; In my view I get this now. Great, but how do I now get the connection to the recipe table at the same time? Array ( [0] = Array ( [RecipesSubcategory] = Array ( [recipe_id] = 28 [subcategory_id] = 49 ) ) [1] = Array ( [RecipesSubcategory] = Array ( [recipe_id] = 29 [subcategory_id] = 49 ) ) [2] = Array ( [RecipesSubcategory] = Array ( [recipe_id] = 31 [subcategory_id] = 49 ) ) ) On 1 Jun., 13:41, John Andersen j.andersen...@gmail.com wrote: Disregard my mail! Not usesful solution, if your receipe can belong to more than one category! John --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. 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 -~--~~~~--~~--~--~---
Database and Model Design for HABTM
Hi, I am still a Cake newbie, but maybe someone give me a hint on my issue. I am trying to learn cake by developing a recipe site. There are Maincategories and Subcategories. F.e. BBQ - (Pork, Beef, Vegetarian) Main Dish - (Vegetarian) A recipe can belong to different Categories, so a Steak could show up under BBQ and Main Dish and there under Beef. I'm planing to have a Form which reads out the Maincategories from the DB and when you click on a checkbox, the subcategories should show up (AJAX Request?) I have been thinking about the DB Design now for a while and thought I first had a solution. Than I got doubts and re-designed the tables and the models. I am now rather confused if this design is correct and would hope that someone could give some feedback. Okay, here the tables: === maincategories *** this table is filled manually - id - maincategory === subcategories *** this table is filled manually - id - subcategory - maincategory_id === recipes_subcategories ** this will be filled in when Add Recipe Form was send off - id - subcategory_id - recipe_id === recipes ** this will be filled in when Add Recipe Form was send off - id - recipename === My Models: == Recipe Model === class Recipe extends AppModel { var $name = 'Recipe'; var $belongsTo = array( 'User' = array( 'className' = 'User' ) ); var $hasAndBelongsToMany = array( 'Subcategory' = array( 'className' = 'Subcategory', 'joinTable' = 'recipes_subcategories', 'foreignKey' = 'recipe_id', 'associationForeignKey' = 'subcategory_id' ) ); == Subcategory Model === class Subcategory extends AppModel { var $name = 'Subcategory'; var $belongsTo = array('Maincategory'); var $hasAndBelongsToMany = array( 'Recipe' = array( 'className' = 'Recipe', 'joinTable' = 'recipes_subcategories', 'foreignKey' = 'subcategory_id', 'associationForeignKey' = 'recipe_id' ) ); } Is this setup correct or any advice how it should look instead? Thanks a lot 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: AppController issue
Hi, I am very new to cakePHP aswell, but I just tried something out which seems to work. In the beforeFilter of the AppController, I added the variable the following way: $this-set('admin', false); I can now access my $admin in the view without a problem. But as I said I am very new to cakePHP so maybe a Cake Guru want to comment on it. Regards, Luke --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Problem with Auth. with an AJAX Request
Hi, I have again read backwards and forwards through the www to find a solution for my problem. I am sure that there is other people running into the same issue. How do you guys solve it? All I want is a link saying Add article to watchlist which than, if the User is logged in writes it into the DB, Article gets shown again and link changes to In watchlist and if User is not logged in redirects to the Login Window with a message that you need to be logged in to use this feature. All this should happen with AJAX. My normal login is happening with Auth. and the typical stuff in the beforeFilter() of the app_controller. In the watchlist controller I have added function beforeFilter() { parent::beforeFilter(); $this-Auth-deny('addToWatchlist'); } It should be very common and sometimesI think that maybe I am searching for the wrong topic. Can anyone give me an advice? Thanks so much. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Problem with Auth. with an AJAX Request
Hi, I am not sure what else I could copy paste from the sourcecode. I only have a normal login action, in my user controller, which only saves the last login and thats pretty much it. An Login AJAX action? How would this look? Have you got an example? Thanks. Luke On 20 Mai, 22:18, christo christia...@gmail.com wrote: all I can think of is that you don't have a login AJAX action set up so the request dies without redirecting to a log in if you try to access the link from not logged in? I dunno it's hard to tell from your description. pastebin maybe? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. 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 -~--~~~~--~~--~--~---
Problem with Auth. with an AJAX Request
Hi, I am still pretty new to CakePHP, so I am sorry if this is a silly issue I am dealing with. Ok, I am working on a site where you have different sections which require a Login. I therefore added the below Code into the app_controller var $components = array('Auth'); var $helpers = array('Html','Form','Ajax','Javascript'); function beforeFilter() { $this-Auth-loginAction = array('controller' = 'users', 'action' = 'login'); $this-Auth-logoutRedirect = array('controller' = 'users', 'action' = 'login'); $this-Auth-allow('*'); $this-Auth-authorize = 'controller'; $this-Auth-userScope = array('User.confirmed' = '1'); $this-set('loggedIn', $this-Auth-user('id')); $this-set('username', $this-Auth-user('username')); } function isAuthorized() { return true; } So, all in all I allow all pages and than deny access to some functions which are than directly in the controller. I thought that this will be the easier way. I have now got a link to add a new article. In my controller I than have added this part: function beforeFilter() { parent::beforeFilter(); $this-Auth-deny('add'); } As I planned, if you are not logged in, the Login Window shows up and only when you logged in, the Form to add an article will show up. So all this works and I thought I now go a step further. You can add articles on your watchlist. Great, the article shows up, a link gets displayed on top of it Add article to watchlist this time I want to use an AJAX request. So I created the AJAX link echo $ajax-link(Add article to watchlist', array('controller' = mylist, 'action' ='add', $articledetail ['Article']['id']), array('update' = 'message', )); and added the below in my watchlist_controller function beforeFilter() { parent::beforeFilter(); $this-Auth-deny('add'); } So, what happens now? When you are not logged in, the article does not get add to your watchlist, but the Login Window does not show up. Instead you just still see the article not knowing if anything happened in the background. Of course I would like the Login Window to show up and when you are logged in the Article should be added to your watchlist, the article should show up again and the link should change to Article in watchlist. Why is this not working with AJAX Link and how to I get it to work? I have read through the www, but can't find an answer. Maybe I am looking for the wrong topic... Can anyone here help? Look forward to some response. Thanks so much in advance. Luke --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Problem with Auth. with an AJAX Request
Hi brian, thanks for your response. This is not really a solution I am looking for. I think the link should still be visible all the time and I can't imagine that cake and AJAX would not be able to handle this somehow. I am sure that someone has faced a similar issue before and I am hoping that they will share their solution. But thank you anyway. Luke --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. 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: saveAll not saving habtm with build 8004
hi use save() not saveAll with HABTM On Feb 25, 7:01 am, spazard1 spaza...@gmail.com wrote: Hello all. I am running into a problem where my join tables are not being updated when I call saveAll. I have the latest stable version of cakephp, in which this bug was fixed. Here is the relevant action code: //first update the ['Player'] array to replace username with ['User'] ['id'] foreach ($this-data['Player'] as $key = $row) { $this-data['Player'][$key]['campaign_id'] = $id; if ($this-data['Player'][$key]['username'] != ) { $this-data['Player'][$key]['User']['id'] = $this-User-field('id', array('User.username' = $this-data['Player'][$key] ['username'])); } } debug($this-data['Player']); if ($this-Campaign-save($this-data)) { if ($this-Player-saveAll($this-data['Player'])) { $this-flash('Your campaign has been setup.', / campaigns/run/$id); } } } And the Player data that is in $this-data['Player'] (only showing the first) [0] = Array ( [characterName] = [playerName] = [username] = testing [baseExperienceSpent] = [overlord] = 0 [campaign_id] = 3 [User] = Array ( [id] = 11 ) ) The way I understand it, this should cause my players_users table to have a row inserted into it. However that is not happening. When I do a find() on Player, it does return to me the associated Users, so I'm pretty sure the model associations are setup correctly. Thanks for any help you can offer. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. 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: AppController methods
I'd be 'Api to. On Feb 20, 11:47 am, kaushik kaushikwo...@gmail.com wrote: Can anyone provide me list of AppController methods with their definations? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. 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 -~--~~~~--~~--~--~---
Display Checkbox Array and read values
Hi, I am very new to CakePHP (and Google Groups) and now struggle badly with a Form. I have got a Site with Main- and Subcategories. In the Form you can post an entry and choose 1 or more Main and Subcategories. To keep it easy, I have now started just with the Maincategories. For this I use checkboxes, which are read out from the database. foreach($options as $option) { echo $form-input('Recipe.maincategory_id.'.$counter.'.', array( 'label'= array( 'text'=$option ['Maincategory']['maincategory']), 'type' = 'checkbox', 'multiple'='checkbox', 'value'=$option['Maincategory']['id'])); $counter++; } This displays my checkboxes nicley. I am now trying to read out the choosen maincategories and this is where I am badly stuck. if (!empty($this-data)) { if ($this-Maincategories_subcategories-saveAll($this-data)) { $this-Session-setFlash(Entry saved'); } } Maincategories_subcategories is my DB Tables to connect Maincategories, Subcategories and Recipes together. Can someone tell me if I have set up the checkboxes correctly and tell me how I than save it aswell? I would think I need a foreach aswell to go through the Array of the Maincategories, but how would this look? I am struggling on this issue already a week and just can not get on. I look forward for any tip which will get me forward on this issue. Thanks a lot in advance. Luke --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. 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 shop
bakesale is great. 1.2 version is more recently developed than 8 months, for sure! Google a bit more. Matti Putkonen is the developer. If you cannot find the SVN release he will put you in the right direction. Luke On Jan 13, 8:30 pm, Miles J mileswjohn...@gmail.com wrote: Building the products and listings should be easy, a day or 2 worth of development. The only thing you really have to research are the payment gateways. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. 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: Anyone in North East England?
Anyone going to the PHP conference on Friday 27th Feb in London? Perhaps we could do an informal CakePHP discussion there - either on the day or night before or Saturday morning? I might start a UK mailing list or wiki or something! Luke On Jan 9, 2:49 pm, ianh ian.h...@portlanddata.co.uk wrote: On Jan 9, 2:32 pm, Penfold ianwtas...@gmail.com wrote: hi ianh, whats your skype id? Ian Tasker My skype id is ian_at_portlanddata ianhhttp://www.eventhq.co.uk --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. 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: hasMany bind on the fly
Hey Teknoid, you were helping me with this on IRC the other day, thanks for this thread too! Your work is appreciated!!! Luke On Oct 31, 11:23 pm, teknoid [EMAIL PROTECTED] wrote: no, cake can easily build the join that you need:http://teknoid.wordpress.com/2008/07/17/forcing-an-sql-join-in-cakephp/ as matter of fact there is an example like like this one in the manual. and i must've posted this link on the list a bunch of times. so searching is always a good idea... On Oct 31, 6:06 pm, Ita [EMAIL PROTECTED] wrote: Well since no shiny knight in white armor came to my rescue I wound up creating my query. I guess cake has its own limitations. On Oct 30, 7:41 am, Ita [EMAIL PROTECTED] wrote: So it just can't handle the conditions? What should I do in this case? create my own query? On Oct 29, 7:29 pm, teknoid [EMAIL PROTECTED] wrote: cake does not create joins for hasMany (only hasOne and belongsTo) On Oct 29, 12:27 pm, Ita [EMAIL PROTECTED] wrote: Hi, I have 2 models Item and Defect. both of them have description. an Item can have many Defects and my defects table has a an item_id field. Now I'm trying to create a search query that will search both the item description and the defect description. What I do is this: $this-Item-bindModel( array('hasMany' = array( 'Defect' = array( 'className' = 'Defect', 'foreignKey' = 'item_id', 'type' = 'INNER' ) ) ) ); then I run findAll. Now when I use findAll with no conditions everything works fine. cake seems to run 2 queries: SELECT `Item`.`id`,.. FROM `items` AS `Item` WHERE 1 = 1 SELECT `Defect`.`id`,.. FROM `defects` AS `Defect` WHERE `Defect`.`item_id` IN (1, 2, 16, 15, 14, 13, 12, 11, 10, 17, 18, 19, 20) My first question is why does cake doesn't create one query with INNER JOIN? The second problem is when I add conditions: $conditions[] = `Item`.`name` LIKE '% .$search_term .%' OR `Defect`.`description` LIKE '% . $search_term . %'; It seems that cake in this case ignores the join all together and just does a regular select so I get an error: 1054: Unknown column 'Defect.description' in 'where clause' Does anyone know what I'm doing wrong? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Validation for saveAll not returning messages
Hi Lane, I'm getting this exact same problem, invlaidation occurs, but the messages are not populated and I get an empty array for the model that failed in the view's $this-validationErrors. Strange! I'm using RC 3 - LANE, did you work out any solution other than the workaround you provided? Luke On Sep 10, 5:57 pm, Lane [EMAIL PROTECTED] wrote: Hello, I'm trying to usesaveAllto save multiple records of a model in one form. Everything works fine as far as saving and validation goes except for one little problem. If the data entered does not validate, the validationErrors array that is returned does not contain the fields or the error messages for the fields that did not validate. Here is an example setup (same ashttp://teknoid.wordpress.com/2008/08/04/practical-use-of-saveall-part... view echo $form-create(); echo $form-input('0.name'); echo $form-input('0.username'); echo $form-input('0.email'); echo $form-input('0.company_id', array('type'='hidden', 'value'=1)); echo $form-input('1.name'); echo $form-input('1.username'); echo $form-input('1.email'); echo $form-input('1.company_id', array('type'='hidden', 'value'=1)); echo $form-end('Add'); controller function add() { if(!empty($this-data)) { $this-Account-saveAll($this-data['Account'], array('validate'='first')); }} If I try to submit the form without entering a username for either (or entering one that is not alphanumeric), the form does not validate, but it does not show any errors. When I print out $this-Account- validationErrors I get the following array: Array ( [0] = Array ( ) [1] = Array ( ) ) So it knows that entry 0 and 1 did not validate, but it doesn't return the error messages or fields. Has anyone encountered this problem, or perhaps know a fix. I created a work around for now, but it would be nice ifsaveAllwould display the errors. If I do this method it works fine: foreach($this-data['Account'] as $k = $v) { $this-Account-set($v); if(!$this-Account-validates()) { $errors[$k] = $this-Account-validationErrors; } } if(empty($errors)) { // All records have validated, it is safe to save $this-Account-saveAll($this-data['Account']);} else { $this-Account-validationErrors = $errors; } --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Auth Redirect Problems
yeah Tony I am seeming to get this too :/ someone on IRC said to check that things like favicons are correctly being pointed at and so on. can anyone post a sample of some redirect Auth code? Luke On Sep 15, 5:21 pm, Tony Thomas [EMAIL PROTECTED] wrote: I did that. Same problem. To explain further, if I'm logging in for the first time on a given day, theredirectworks fine. It's only if I log out or my session expires and I log back in that the problem occurs. On Sep 9, 12:55 pm, Yodi Aditya [EMAIL PROTECTED] wrote: Try using : $this-Auth-loginRedirect = array('controller'='users', 'action'='profile'); on beforeFilter() then function login() { $this-redirect($this-Auth-redirect()); } Yodiaditya -http://re.web.id On 9/9/08, Tony Thomas [EMAIL PROTECTED] wrote: If someone is familiar with a post to this group or blog entry that addresses this issue, please let me know. I've spent the morning scouring both with no satisfactory results. I have a cakePHP app on a shared server. In local testing, everything worked fine. But mod_rewrite did not function properly on the shared server, so I'm using CakePHP pretty URLS instead. Also caching (at least temporarily) is off. I've uncommented the pertinent lines of code in core.php and I've dutifully deleted the .htaccess files. The problem I have is that after logging in, theredirectis inconsistent. About 2/3 of the time I get redirected to https://[base_url]/https:/[domain]. I just can't seem to find away around this problem. My login function looks like this: function login() { $this-Auth-loginRedirect = array('controller' = 'controller_name', 'action' = 'index'); } I still get inconsistent results with theredirectgoing to a URL like the former example the majority of the time. Any insight, links, etc. would be appreciated. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Acl and Auth at record level with crud mode
aranworld - I am wondering how this could be made universal throughout an app...better possibly in the app_model somehow? but obvioulsy Auth is a component :/ On Aug 28, 8:22 am, aranworld [EMAIL PROTECTED] wrote: You can add this to your UsersController: function __checkUsersOwnRecord($recordId = null) { if( $this-Auth-user('id') == $recordId ){ return TRUE; } else { return FALSE; } } Give all users access to users/edit ... however, before you do any edit functionality first check that the logged inuseris the sameuseras the record being edited. The basic answer is that since theAuthComponent does not look at the record ID when it verifies access, then you cannot rely on it to automatically handle record level access, and you therefore have to create such logic on your own. On Aug 12, 5:02 am, [EMAIL PROTECTED] wrote: I have the same problem, but let us take a look to the debug messages: (we say thatusermodel must behave as requester, and in the model it's written var $actsAs = array('Acl' = array('type'='requester')); ) So the debug is SELECT `Aro`.`id`, `Aro`.`parent_id`, `Aro`.`model`, `Aro`.`foreign_key`, `Aro`.`alias` FROM `aros` AS `Aro` LEFT JOIN `aros` AS `Aro0` ON (`Aro`.`lft` = `Aro0`.`lft` AND `Aro`.`rght` = `Aro0`.`rght`) WHERE `Aro0`.`model` = 'User' AND `Aro0`.`foreign_key` = 29 ORDER BY `Aro`.`lft` DESC here 29 is id of theuserrequesting some permissions ok, works perfectly then SELECT `Aco`.`id`, `Aco`.`parent_id`, `Aco`.`model`, `Aco`.`foreign_key`, `Aco`.`alias` FROM `acos` AS `Aco` LEFT JOIN `acos` AS `Aco0` ON (`Aco0`.`alias` = 'Users') WHERE `Aco`.`lft` = `Aco0`.`lft` AND `Aco`.`rght` = `Aco0`.`rght` ORDER BY `Aco`.`lft` DESC Here you see `Aco0`.`alias` = 'Users'!!! but it's not true, i do not want to request permissions on the whole users group, i'm interested only in aco with alias, say,User::29, or, i would say it must be better, in aco with foreign_key=29 so then as a consequence we have SELECT `Permission`.`id`, `Permission`.`aro_id`, `Permission`.`aco_id`, `Permission`.`_create`, `Permission`.`_read`, `Permission`.`_update`, `Permission`.`_delete`, `Aro`.`id`, `Aro`.`parent_id`, `Aro`.`model`, `Aro`.`foreign_key`, `Aro`.`alias`, `Aro`.`lft`, `Aro`.`rght`, `Aco`.`id`, `Aco`.`parent_id`, `Aco`.`model`, `Aco`.`foreign_key`, `Aco`.`alias`, `Aco`.`lft`, `Aco`.`rght` FROM `aros_acos` AS `Permission` LEFT JOIN `aros` AS `Aro` ON (`Permission`.`aro_id` = `Aro`.`id`) LEFT JOIN `acos` AS `Aco` ON (`Permission`.`aco_id` = `Aco`.`id`) WHERE `Permission`.`aro_id` = 5 AND `Permission`.`aco_id` = (1) ORDER BY `Aco`.`lft` desc where we have correct aro_id and incorrect aco_id so it seemsUsermodel must behave as a requester and as a controlled, but you cannot define such a behaviour (at least i don't know how) reasonable solutions are to check permissions in such a situations yourself (but i cannot switch off auto check!), to define additional model like profile or to make some correction in some cake files (still don't know where) any suggestions? On Aug 8, 6:31 am, KoPanda [EMAIL PROTECTED] wrote: Yes, I'm using crud mode inAuth. The Aro and Aco trees are like this. Aro users |- user1 |- user2 |- administrators |- admin Aco Site |- Users |-user1 |-user2 The permissions were setup like this, cakeaclgrant administrator Site * cakeaclgrant users Site read And then in the register() action after saving theuserdata, //Usermodel is define with $actAs = array('Acl' = 'requester') so the Aro is automatically handled // some code to create the aco and set the $alias to the username $this-Acl-allow($alias, $alias, array('read','update')); For example, ARO user1 would have read and updatepermissionto ACO user1. I supposeAuthwould check through the tree and see if ARO user1 can update ACO user1 and then allow edit() action when I do / users/edit/5 (suppose user1 has id:5). But that's not the case. It kicks me back to /users/view/5, as ARO user1 has readpermissionto ACO Users. If I want to make /users/edit/5 runs as I wish, I have to grant updatepermissionto Users controller, which eventually let all users to edit any records of other users. Well, I know I can do an extra check() in edit() action and see if the currentuserhas updatepermissionto the record but I don't understand why theAuthcomponent acts like this. Is my approach wrong? OrAclandAuthare not supposed to do the work like this? On Aug 8, 2:29 am, francky06l [EMAIL PROTECTED] wrote: You have to set (or use) the right mode toAuth, in this case model or crud. On Aug 7, 12:02 pm, KoPanda [EMAIL PROTECTED] wrote: I'm trying to develop a community website usingcrudmode onAuth component.Userprofiles can be viewed by all users while
Re: Save / saving records with extra fields in a HABTM join table ( possibly using 'with' parameter ?)
thanks James, yes I have got a solution with a model I created for the join and I simply edit and add the entries on that form. The 'with' parameter has certainly proved useful to read out the data simply , I still think the way I have saved it is not the most cake way, which is what I am still interested in learning about. I am grateful to AD7six who also helped me in IRC with this matter. He advised to treat the joinTable as a hasMany joined model for the purpose of saving - and I still use the habtm with' association therefore when I read data. cheers Luke On Jul 2, 2:53 pm, James K [EMAIL PROTECTED] wrote: The framework has changed in this regard several times and most of the documentation and tutorials about it are outdated, or were actually written based on PLANNED functionality, not implemented functionality. I've never been able to get this to work, and the whole HABTM implementation is currently pretty kludgey. I find it's just best to forgo trying to use the automagic (that doesn't even work), write a model for your join table, and save it manually. It's a bit more work this way, but you'll save yourself a lot of headaches this way. On Jul 1, 5:56 am, luke BAKING barker [EMAIL PROTECTED] wrote: Hi I was wondering if someone could help me with saving the data of a join table, when it has extra fields in cake 1.2? I have read Mariano Iglesias' helpful blog post relating to this, where he explains the findings of the 'with' specified model, which was a great help. However, I am still unable to solve my problem - sorry if I am being dense over it! I have a model PlantItem and it is HABTM Specification. I have to also include a field in the join table (plant_items_specifications) alt_description to allow a particular descriptive comment about this particular pairing. So I have a user form where they add a new Plant Item, and I want to allow them to note which specifications it should have (it is a kind of technical catalogue I am building) also. I can see there are 2 ways to do this possibly: 1) have a multiple record section on this add form Spec 1 - spec1name [x] spec1name_alt_description [___] Spec 2 spec2name [x] spec2name_alt_description [___] Spec 3 - spec3name [x] spec3name_alt_description [___] etc - 1 for each spec... and try and save that along with the PlantITem data there and then. 2) have a second step after saving the PlantItem, using a basic controller for the join-model PlIsSpec and a form where the new created Plant_Item id can now be embedded, that wd be like: Spec 1 - spec1name [x] spec1name_alt_description [___] (hidden PlantItem id) Spec 2 spec2name [x] spec2name_alt_description [___] (hidden PlantItem id) Spec 3 - spec3name [x] spec3name_alt_description [___] (hidden PlantItem id) and then do a multi-save. I think the 2nd way looks a better start for me as it is walking before running, so-to-speak. Also I think it will be easier to create an edit form in this case. If anyone can help me I would be very grateful as I am keen to do the most Cake way and learn a bit more about these concepts. Useful references for this question: detailed blog post:http://cricava.com/blogs/index.php?blog=6title=modelizing_habtm_join... manual:http://book.cakephp.org/view/85/saving-related-model-data-habt --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Save / saving records with extra fields in a HABTM join table ( possibly using 'with' parameter ?)
Hi I was wondering if someone could help me with saving the data of a join table, when it has extra fields in cake 1.2? I have read Mariano Iglesias' helpful blog post relating to this, where he explains the findings of the 'with' specified model, which was a great help. However, I am still unable to solve my problem - sorry if I am being dense over it! I have a model PlantItem and it is HABTM Specification. I have to also include a field in the join table (plant_items_specifications) alt_description to allow a particular descriptive comment about this particular pairing. So I have a user form where they add a new Plant Item, and I want to allow them to note which specifications it should have (it is a kind of technical catalogue I am building) also. I can see there are 2 ways to do this possibly: 1) have a multiple record section on this add form Spec 1 - spec1name [x] spec1name_alt_description [___] Spec 2 spec2name [x] spec2name_alt_description [___] Spec 3 - spec3name [x] spec3name_alt_description [___] etc - 1 for each spec... and try and save that along with the PlantITem data there and then. 2) have a second step after saving the PlantItem, using a basic controller for the join-model PlIsSpec and a form where the new created Plant_Item id can now be embedded, that wd be like: Spec 1 - spec1name [x] spec1name_alt_description [___] (hidden PlantItem id) Spec 2 spec2name [x] spec2name_alt_description [___] (hidden PlantItem id) Spec 3 - spec3name [x] spec3name_alt_description [___] (hidden PlantItem id) and then do a multi-save. I think the 2nd way looks a better start for me as it is walking before running, so-to-speak. Also I think it will be easier to create an edit form in this case. If anyone can help me I would be very grateful as I am keen to do the most Cake way and learn a bit more about these concepts. Useful references for this question: detailed blog post: http://cricava.com/blogs/index.php?blog=6title=modelizing_habtm_join_tables_in_cakephp_more=1c=1tb=1pb=1 manual: http://book.cakephp.org/view/85/saving-related-model-data-habt --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
saveAll difficulty in combination with Generic Upload Behaviour
Hi I have posted this to cakeBin so it is easier to read: http://bin.cakephp.org/view/7031334 My problem is that it saves the Attachment file and entry but the foreignkey (in this case foreign_id) does not get saved. # Using CakePHP nightly from 28/5/08 # on Mac os X apache # # # # DEBUG SQL, upon saving the form with all fields and a specified valid image file in admin_add: # START TRANSACTION 00 # 9 INSERT INTO `plant_items` (`plant_category_id`,`name`,`description`,`modified`,`created`) VALUES (1,'ddd','','2008-05-30 12:37:26','2008-05-30 12:37:26')1 1 # 10 SELECT LAST_INSERT_ID() AS insertID 1 1 1 # 11 INSERT INTO `attachments` (`description`,`class`,`filename`,`foreign_id`,`modified`,`created`,`dir`,`mimetype`,`filesize`) VALUES ('upload','PlantItem','_upload_15.jpg','','2008-05-30 12:37:26','2008-05-30 12:37:26','PlantItem/','image/jpeg',2703) # # # the file saves, but the foreign Id is not picked up in the upload behaviour. # It also throws three warning: # - Undefined index: size [APP/models/behaviors/upload.php, line 114] # - Undefined index: size [APP/models/behaviors/upload.php, line 154] # - Undefined index: filename [APP/models/behaviors/upload.php, line 296] # # attachment.php # ?php # class Attachment extends AppModel { # var $name = 'Attachment'; # # var $hasMany = array(); # var $hasOne = array(); # # var $actsAs = array( # 'ImageUpload' = array( # 'allowedMime' = '*', # 'allowedExt' = '*' # ) # ); # var $validate = array ( # 'description' = array( # 'required' = VALID_NOT_EMPTY # ) # ); # # # // possibly: need afterfind? # } # ? # # plant_item.php # ?php # class PlantItem extends AppModel { # var $name = 'PlantItem'; # # # var $hasMany = array( 'Attachment'= array( 'foreignKey' = 'foreign_id', # //'conditions' = array('Attachment.class' = 'PlantItem'), # 'dependent' = true # ) # ); # /*var $hasOne = array( # 'Thumb' = array( # 'className' = 'Attachment', # 'foreignKey' = 'foreign_id', # 'conditions' = array('Thumb.class' = 'PlantItem', 'Thumb.thumb' = true), # 'dependent' = true # ) # );*/ # # var $belongsTo = array('PlantCategory'); # # var $hasAndBelongsToMany = array( 'Specification' # # # ); # # }? # plant_items_controller.php # ?php # //excerpt :: # # function admin_add() { # if (!empty($this-data)) { # # $this-PlantItem-create(); # // pr($this-data); # if ($this-PlantItem-saveAll($this-data )) { # # $this-Session-setFlash(__('The PlantItem has been saved', true)); # //$this-redirect(array('action'='index')); # } else { # # $this-Session-setFlash(__('The PlantItem could not be saved. Please, try again.', true)); # } # } # $specifications = $this-PlantItem-Specification-find('list'); # $plantCategories = $this-PlantItem-PlantCategory-find('list'); # $this-set(compact('specifications', 'plantCategories')); # # } # ? # # # # # admin_add.ctp # # div class=plantItems form # ?php echo $form-create('PlantItem', array('type' = 'file' ));? # fieldset # legend?php __('Add PlantItem');?/legend # ?php # echo $form-input('PlantItem.plant_category_id'); # echo $form-input('PlantItem.name'); # echo $form-input('PlantItem.description'); # echo $form-input('Attachment.Attachment.filename', array('type'='file')); # echo $form-input('Attachment.Attachment.description', array('type'='hidden', 'value'='upload')); # echo $form-input('Attachment.Attachment.class', array('type'='hidden', 'value'=Inflector::singularize($this- name))); # # // try with just one for now, so commented out: # //echo $form-input('Attachment.1.filename', array('type'='file')); # // echo $form-input('Attachment.1.description', array('type'='hidden', 'value'='upload')); # // echo $form-input('Attachment.1.class', array('type'='hidden', 'value'=Inflector::singularize($this- name))); # // # // # echo $form-input('Specification'); # ? # /fieldset # ?php echo $form-end('Submit');? # /div # # # upload .php behaviour # # ?php # class UploadBehavior extends ModelBehavior { # # var $__defaultSettings = array( # 'enabled' = true, # 'fileField' = 'filename', # 'dirField' = 'dir', # 'allowedMime' = '*', //array('image/jpeg', 'image/pjpeg', 'image/gif', 'image/png'), # 'allowedExt' = '*', //array('jpg','jpeg','gif','png'), # 'allowedSize' = '1', // '*'
Use routes to permanently redirect?
I have the following route: Router::connect('/newrv.cfm', array('controller' = 'rvs', 'action' = 'index', 'new')); Is it possible to do this, but issue a 301 and redirect to the correct url? Right now it does the right thing, but no 301 and it stays at / newrv.cfm in the location bar. 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Mac OS developper setup
I use XAMPP on 10.4 -- it works well, as you just edit the httpd.conf -- I have multiple document roots, the way I do it, and have different versions of Cake for each project. Annoying fo rupgrading the version of Cake, but I generally don't do such massive projects that it hinders me and I like to be able to quickly switch between the different projects I do have, by jsut changing the httpd.conf (of XAMPP Apache == also called MAMPP) DocumentRoot. I do not know MAMP, but XAMPP/MAMPP has a builtin phpmyadmin and you can switch between php4 and 5 with a single command. It is pretty sweet. I use Textmate to edit and CocoaMySQL for the db. Both work well in a Cake context. currently preparing Leopard Subversion server and will prbably rethink the way I run off Cake and try and just use one SVN updateable latest nightly of Cake to run all my apps. Luke On Feb 5, 9:10 am, boyracerr [EMAIL PROTECTED] wrote: I use MAMP for my PHP5, and the standard Apache that comes with the Mac plus a selfcompiled PHP for PHP4. They seem to live quite happily together. I have had some problems before, but got things working (with the exception of Jake, which is another story). What problem are you having? Any error message? Ben On Feb 5, 9:47 am, zeugme [EMAIL PROTECTED] wrote: Hi, I'm wondering what kind of software setup are you using on Mac OS as a developper machine ? I'm using MAMP for the Apache, PHP, MySQL stack and IntelliJ for code edition. I created a symlink from MAMP htdocs to my dev web folder. I'm not sure but I think I might have a mod_rewrite issue, maybe due to that MAMP htdocs symlink or apache default config ? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: CakePHP guide
theres a book coming for Cake too - by David Golding: http://www.amazon.com/Beginning-CakePHP-Professional-David-Golding/dp/1430209771/ On Feb 5, 10:11 am, accom06 [EMAIL PROTECTED] wrote: This is great! Thanks. -- Aaron On 5 Feb, 08:58, Julio Protzek [EMAIL PROTECTED] wrote: Hey, awsome work Zoe :) The official docs is really missing something like this. As Mark said, a rails book like tutorial is a great idea too. The lack of good, consistent and updated documentation is the worst problem for new users. I agree with brian about the 'hidden' 1.2 docs. In the end every effort will be good for people learning cake. Be it already official, or new. It's very important use as many ways as possible to teach things, so we can touch as many minds as possible too. Learning and teaching needs to bee plural. Lets get the best ideas and make it official when its mature. -- Julio Vinicius Protzek --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: .htaccess password in CAKE
Hi 2 questions regarding this: 1) I am trying it with a virtualHost in my httpd.conf - I put the Location /admin inside my virtualHost directive (At the bottom) but when I go to anything with www.example.com/admin I get a 401.shtml error served by Cake. This is a server-authentication apache error. I have a htpasswd file setup and a single user added to it. So I think the problem is with VirtualHost but I read on several Django sites that one can nest the Location directive within the virtualHost one. 2) Is there a way that you can specify the Location set of instructions within an .htaccess file of Cake? If so, which one to make the /admin protected? the document root? Or the webroot? Any ideas? thanks for the tip anyway - I tried ti on a non-virtualhost setup and worked a charm Luke On Jan 2, 9:02 pm, Mazgalici [EMAIL PROTECTED] wrote: Thanks adica Multumesc :D On 26 Noi 2007, 21:39, Dragos Chiriac [EMAIL PROTECTED] wrote: Mazgalici wrote: Does anybody know how to put a passoword on .htaccessfile for a direcory for examplehttp://localhost/admin? Thanks Hi, though it seems a stupid question it is not, and you'll see why : Part one, preety straight forward : Put a .htaccessin the dir you want to protect AuthUserFile /my/passwd/file AuthName Title AuthType Basic Require valid-user /my/passwd/file is created with the following command : htpasswd -c /my/passwd/file bob PS: Does not really have much to do with cake. Part 2 /admin(as cake uses rewrites) is not actually a directory. So then you have a problem :) Solvable though , putting in the docroot ahtaccesswith something like : Location /admin AuthType Basic AuthName Title AuthUserFile /my/passwd/file Require valid-user /Location Of course if you need to match a regexp : LocationMatch /mysecret/[^/]+/ AuthType Basic AuthName Title AuthUserFile /my/passwd/file Require valid-user /LocationMatch Hopefully it works, most is from memory, I think I installed to many TRACs lately. This part have something tangential with cake anyway. And if we are so offtopic, in my language Mazgalici means the ones that smears/scribbles :). Kind regards, D --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Using Acl to display a user-specific menu
I am writing an application that has three user groups: admin, user, and photo manager. I want all three to have basically the same interface, but admins will obviously have more things available to them (ability to add things, edit things, etc), photo managers will be allowed to add / edit photos, and all users will be able to view just about anything in the system. I'm just wondering what the best way to go about displaying the menu to my uses is. Should I run a beforeFilter in my AppController that grabs all the user's permissions and stores them in the session? Then I could check the session to know what parts of the menu to display. Is this a good idea? If not, why? What would you do? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Using Acl to display a user-specific menu
Correction: I'm just wondering what the best way to go about displaying the menu to my uses is should read: I'm just wondering what the best way to go about displaying the menu to my users is. On Jan 16, 2:13 pm, Luke [EMAIL PROTECTED] wrote: I am writing an application that has three user groups: admin, user, and photo manager. I want all three to have basically the same interface, but admins will obviously have more things available to them (ability to add things, edit things, etc), photo managers will be allowed to add / edit photos, and all users will be able to view just about anything in the system. I'm just wondering what the best way to go about displaying the menu to my uses is. Should I run a beforeFilter in my AppController that grabs all the user's permissions and stores them in the session? Then I could check the session to know what parts of the menu to display. Is this a good idea? If not, why? What would you do? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Using Acl to display a user-specific menu
like 3 different menu.ctp files (menu-admin.ctp, menu-manager.ctp, and menu-default.ctp) ? On Jan 16, 2:47 pm, AD7six [EMAIL PROTECTED] wrote: On Jan 16, 11:13 pm, Luke [EMAIL PROTECTED] wrote: I am writing an application that has three user groups: admin, user, and photo manager. I want all three to have basically the same interface, but admins will obviously have more things available to them (ability to add things, edit things, etc), photo managers will be allowed to add / edit photos, and all users will be able to view just about anything in the system. I'm just wondering what the best way to go about displaying the menu to my uses is. Should I run a beforeFilter in my AppController that grabs all the user's permissions and stores them in the session? Then I could check the session to know what parts of the menu to display. Is this a good idea? If not, why? What would you do? I did that a long time ago on a small scale, result: awful performance. Probably better to define, in whatever way suits you best, the 3 permutations in separate elements and add logic to render the right one. hth, AD --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: othAuth looses session - upgrading to new 1.2.0.6311 (2008)
Hi I am running Cake build from August, I have an app using database sessions and othAuth. I want to try and upgrade my app to the new beta - I was just wondering then what other problems/issues might I face? I saw the red frog blog comments about the pre-beta...so can anyone advise me? I take it all of you can get it working OK with database sessions? thanks to othman also for a great component / system. cheers Luke On Jan 8, 10:57 am, hoerbuchhoerer [EMAIL PROTECTED] wrote: solved similar issue with using database sessions, carefully search for session_start() in vendor files, remove them all. hoerer --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: othAuth component + CakePHP 1.2.0.5875 prebeta = broken == saveField not working
check red frogs blog on this too and other posts in the group..othAuth 1.2 pre-beta On Dec 10, 4:19 pm, daphonz [EMAIL PROTECTED] wrote: I had some issues getting the othAuth component to work with Cake pre- beta as well. I think had the same problem you did. You can read my blog post about it: http://www.ancientwisdom.cc/news/archives/111 Hope that helps. Casey On Dec 8, 11:09 am, bingo [EMAIL PROTECTED] wrote: hi, I did some debugging..and it seems the above problem is only with OthAuth component. I searched through all the possible sources..but couldn't find any reason why its not working. Any help will be appreciated. Regards, Ritesh --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
acl manager plugin not working
I am trying to install the ACL Manager I found here: http://bakery.cakephp.org/articles/view/acl-management-plugin I followed the directions exactly, but it still isn't working correctly. The directions tell me that once it's installed, you can access it at /admin/acl, and sure enough I can, but if I click any of the three links on that screen, I get this error: Missing controller You are seeing this error because controller AclController could not be found. Notice: If you want to customize this error message, create app\views \errors\missing_controller.ctp Fatal: Create the class below in file: app\controllers \acl_controller.php ?php class AclController extends AppController { var $name = 'Acl'; } ? I realize you guys probably aren't experts on every plugin, but any insight into what could be causing this would be greatly appreciated. Thanks! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Ajax - help in serialize of data from mootools sortable OL list for CakePHP to use
whoa hang on - http://groups.google.com/group/cake-php/browse_thread/thread/8de4714f1a04a97b/fd8011bfed27c381?lnk=gstq=mootools#fd8011bfed27c381 I should have searched mootools on here before! (tried google...but not the group search!) On Dec 6, 10:24 am, luke BAKING barker [EMAIL PROTECTED] wrote: Hi Adam, thanks for your replies. In fact I am using mootools for the nested drag and drop sortable - I am not sure there is an equivalent in Scriptaculous although it should be possible. Mootools and Prototype are not compatible however. Your example has given me a bit of an idea of the best way of naming my lists and items however! can anyone else point me in the direction of documentation/tips on serializing Ajax data with Cake ? cheers Luke On Dec 6, 4:57 am, Adam Royle [EMAIL PROTECTED] wrote: I forgot to mention you need to include the prototype+scriptaculous javascript libraries - this is what the ajax helper uses. Adam On Dec 6, 2:57 pm, Adam Royle [EMAIL PROTECTED] wrote: here is my code for the view using the ajax helper (note the ids are important, these are actually the ids that exist in the database) ul id=items li id=item_1Item 1/li li id=item_2Item 2/li li id=item_3Item 3/li /ul ?php echo $ajax-sortable('items', array('constraint' = false, 'url'='/myitems/updaterank/')); ? and now the code in the myitems controller: function updaterank() { foreach ($this-params['form']['items'] as $rank = $id){ $this-MyItem-id = $id; $this-MyItem-saveField('rank',$rank); } $this-autoRender = false; } Cheers, Adam On Dec 6, 4:19 am, luke BAKING barker [EMAIL PROTECTED] wrote: Hi I am building a little menu manager for a backend of a site. I am using this Nestable Sortable drag and drop script , using mootools framework. demo and script:http://youmuppet.com/?page_id=9 description:http://forum.mootools.net/viewtopic.php?id=1106 It essentially allows the reordering of a OL's LI's and nested OLs , and does it very nciely. I want to allow the user to re-order the list as they want the tree to be, then hit a Submit button, which will post this and update all the items in the database with their new order. I know this involves serializing the data, but am asking for a few pointers on finding out how to do this, with particular reference to the most Cake way(s) of doing this? I havent any experience really with AJAX in CakePHP, and didnt want to steam ahead and miss out any of the goodness there may be! thanks for any help you may be able to give, Luke --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Ajax - help in serialize of data from mootools sortable OL list for CakePHP to use
Hi I am building a little menu manager for a backend of a site. I am using this Nestable Sortable drag and drop script , using mootools framework. demo and script: http://youmuppet.com/?page_id=9 description: http://forum.mootools.net/viewtopic.php?id=1106 It essentially allows the reordering of a OL's LI's and nested OLs , and does it very nciely. I want to allow the user to re-order the list as they want the tree to be, then hit a Submit button, which will post this and update all the items in the database with their new order. I know this involves serializing the data, but am asking for a few pointers on finding out how to do this, with particular reference to the most Cake way(s) of doing this? I havent any experience really with AJAX in CakePHP, and didnt want to steam ahead and miss out any of the goodness there may be! thanks for any help you may be able to give, Luke --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: multiple hasMany?
alright it appears that the associations are working correctly, but the scaffolding just isn't being generated for notes. oh well I guess On Nov 30, 1:23 pm, Jon Bennett [EMAIL PROTECTED] wrote: On 30/11/2007, Luke [EMAIL PROTECTED] wrote: no that would only allow me to have one note and one item per order... I want many items and many notes per order... so I put order_id inside each of those tables. oh yeah, doh! it's even easier then, the issue is most likely cause by cake's scaffolding assuming alphabetically, eg, 'i' before 'n' orderItem before orderNote! this is why your associations work when you do: class Order extends AppModel { var $name = 'Order'; var $hasMany = array( 'OrderItem'=array('dependent'=true), 'OrderNote' = array('dependent'=true) ); } hth jon -- jon bennett w:http://www.jben.net/ iChat (AIM): jbendotnet Skype: jon-bennett --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: multiple hasMany?
no that would only allow me to have one note and one item per order... I want many items and many notes per order... so I put order_id inside each of those tables. On Nov 30, 1:16 pm, Jon Bennett [EMAIL PROTECTED] wrote: do you mean my table names? no I'm assuming your orders table is: Order - id - order_item_id - order_note_id - created - modified and you have in your order model class Order extends AppModel { var $name = 'Order'; var $hasMany = array( 'OrderNote' = array( 'className' = 'OrderNote', 'dependent' = true, ), 'OrderItem' = array( 'className' = 'OrderItem', 'dependent' = true, ) ); } is that correct? cheers, jon -- jon bennett w:http://www.jben.net/ iChat (AIM): jbendotnet Skype: jon-bennett --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: multiple hasMany?
do you mean my table names? On Nov 30, 1:09 pm, Dardo Sordi Bogado [EMAIL PROTECTED] wrote: Try defining your model classes whitout the 'order_' prefix, and set $useTable = 'order_whatever'; in the model. 2007/11/30, Luke [EMAIL PROTECTED]: umm I might have asked the question wrong. here is what I am trying to do: I have 3 tables: orders, order_items, and order_notes Orders is full of all of my store's orders. Order items are all the items the customer purchased, and order_notes contains all of the notes associated with an order. so the tables look like: orders: id date customer_name customer_phone customer_etc total order_items: id order_id name description price sku order_notes: order_id note date So it isn't a many-to-many association, it's just two one-to-many associates. On Nov 30, 9:17 am, Anupom [EMAIL PROTECTED] wrote: Join tables should be named after the tables that will join, in alphabetical order, with underscores in between. As an example, a join table between posts and tags tables should be named posts_tags, not tags_posts. The default value of the foreign keys used in the join table must be underscored, singular name of the models in relation, suffixed with '_id'. Like, post_id, tag_id. If you want to override the defaults, you can explicitly define it in the association attribute of the model - ?php class Post extends AppModel { var $name = 'Post'; var $hasAndBelongsToMany = array( 'Tag' = array('className'= 'Tag', 'joinTable' = 'tags_posts, //altered the default - posts_tags 'foreignKey' = 'article_id', //altered the default -post_id 'associationForeignKey' = 'category_id' //altered the default - tag_id ) );} ? On Nov 30, 2007 11:12 PM, Jon Bennett [EMAIL PROTECTED] wrote: Always best to stick to a A-Z (why can't I think of the correct term for that!) ALPHABETICAL cheers, jon -- jon bennett w:http://www.jben.net/ iChat (AIM): jbendotnet Skype: jon-bennett -- Thanks Anupom Trippert Inc. [http://www.trippert.com] GopherNow. [http://www.gophernow.com/] Homepage. [http://www.anupom.wordpress.com/] --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: scaffold error
it outputs app\controllers\orders_controller.php (line 41) and an empty yellow box. I am on version 1.2.0.5875 pre-beta On Nov 30, 12:27 pm, Dardo Sordi Bogado [EMAIL PROTECTED] wrote: what version? Try debug($this-data) in beforeFilter; 2007/11/30, Luke [EMAIL PROTECTED]: I am not sure what I did, but for some reason the edit action isn't working in any of my controllers. It keeps telling me Invalid id for Order::edit(). Why would it be doing that? Here is an example controller: ?php class OrderItemsController extends AppController { var $name = 'OrderItems'; var $uses = array('OrderItem', 'Order'); var $helpers = array('Html', 'Form' ); var $scaffold; } ? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
scaffold error
I am not sure what I did, but for some reason the edit action isn't working in any of my controllers. It keeps telling me Invalid id for Order::edit(). Why would it be doing that? Here is an example controller: ?php class OrderItemsController extends AppController { var $name = 'OrderItems'; var $uses = array('OrderItem', 'Order'); var $helpers = array('Html', 'Form' ); var $scaffold; } ? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: multiple hasMany?
does nobody know or is it impossible or what? On Nov 29, 3:39 pm, Luke [EMAIL PROTECTED] wrote: Does cake not allow multiple hasMany associations? for some reason it is only rendering scaffolding for the first of the two I'm putting in here: class Order extends AppModel { var $name = 'Order'; var $hasMany = array( 'OrderNote' = array( 'className' = 'OrderNote', 'dependent' = true, ), 'OrderItem' = array( 'className' = 'OrderItem', 'dependent' = true, ) ); } if I switch the two and make OrderItem first, then that shows up in the scaffolding. What's the deal?? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: multiple hasMany?
umm I might have asked the question wrong. here is what I am trying to do: I have 3 tables: orders, order_items, and order_notes Orders is full of all of my store's orders. Order items are all the items the customer purchased, and order_notes contains all of the notes associated with an order. so the tables look like: orders: id date customer_name customer_phone customer_etc total order_items: id order_id name description price sku order_notes: order_id note date So it isn't a many-to-many association, it's just two one-to-many associates. On Nov 30, 9:17 am, Anupom [EMAIL PROTECTED] wrote: Join tables should be named after the tables that will join, in alphabetical order, with underscores in between. As an example, a join table between posts and tags tables should be named posts_tags, not tags_posts. The default value of the foreign keys used in the join table must be underscored, singular name of the models in relation, suffixed with '_id'. Like, post_id, tag_id. If you want to override the defaults, you can explicitly define it in the association attribute of the model - ?php class Post extends AppModel { var $name = 'Post'; var $hasAndBelongsToMany = array( 'Tag' = array('className'= 'Tag', 'joinTable' = 'tags_posts, //altered the default - posts_tags 'foreignKey' = 'article_id', //altered the default -post_id 'associationForeignKey' = 'category_id' //altered the default - tag_id ) );} ? On Nov 30, 2007 11:12 PM, Jon Bennett [EMAIL PROTECTED] wrote: Always best to stick to a A-Z (why can't I think of the correct term for that!) ALPHABETICAL cheers, jon -- jon bennett w:http://www.jben.net/ iChat (AIM): jbendotnet Skype: jon-bennett -- Thanks Anupom Trippert Inc. [http://www.trippert.com] GopherNow. [http://www.gophernow.com/] Homepage. [http://www.anupom.wordpress.com/] --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: why am I getting this undefined index error?
nobody? On Nov 28, 10:41 am, Luke [EMAIL PROTECTED] wrote: I am trying to set up associations between my orders model and my orderitems model. It seems to be working except for this error I'm getting. What am I doing wrong? (see screenshot below) Here are my models: ?php class OrderItem extends AppModel { var $name = 'OrderItem'; var $belongsTo = array('Order' = array('className' = 'Order', 'foreignKey' = 'order_id' ) );} ? ?php class Order extends AppModel { var $name = 'Order'; var $hasMany = array('OrderItem' = array('className' = 'OrderItem', 'order' = 'OrderItem.status_id DESC', 'foreignKey'= 'order_id', 'dependent' = true ) );} ? here is a screenshot of the error I am getting: http://pleaseproof.com/luke/cake.gif --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
multiple hasMany?
Does cake not allow multiple hasMany associations? for some reason it is only rendering scaffolding for the first of the two I'm putting in here: class Order extends AppModel { var $name = 'Order'; var $hasMany = array( 'OrderNote' = array( 'className' = 'OrderNote', 'dependent' = true, ), 'OrderItem' = array( 'className' = 'OrderItem', 'dependent' = true, ) ); } if I switch the two and make OrderItem first, then that shows up in the scaffolding. What's the deal?? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
how do I validate *only if value is present*
I have a model called Orders that I need to validate. In this model, there is a fax number that is not required, but if submitted must be in the format of a phone number. I cannot seem to figure out how to do something like this in cake. It seems to me that it should be something as easy as var $validate = array( 'shipping_fax' = array('required' = false, 'rule' = 'validatePhone') ) am I going about it wrong? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
generating scaffolding
in rails one of the most useful things I've found is the ability to generate the entire scaffolding in your directory app so that you can slowly mold it into what you want. is this not a feature of cake? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
why am I getting this undefined index error?
I am trying to set up associations between my orders model and my orderitems model. It seems to be working except for this error I'm getting. What am I doing wrong? (see screenshot below) Here are my models: ?php class OrderItem extends AppModel { var $name = 'OrderItem'; var $belongsTo = array('Order' = array('className' = 'Order', 'foreignKey' = 'order_id' ) ); } ? ?php class Order extends AppModel { var $name = 'Order'; var $hasMany = array('OrderItem' = array('className' = 'OrderItem', 'order' = 'OrderItem.status_id DESC', 'foreignKey'= 'order_id', 'dependent' = true ) ); } ? here is a screenshot of the error I am getting: http://pleaseproof.com/luke/cake.gif --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: a lot of the features that make rails so cool are totally missing in cake :(
thanks guys I take back my gripe... cakephp rocks On Nov 28, 11:39 am, foxmask [EMAIL PROTECTED] wrote: D:\wamp\www_cakephp\cake\consolecake bake help Welcome to CakePHP v1.2.0.5875 pre-beta Console --- App : console Path: D:\wamp\www_cakephp\cake\console --- CakePHP Bake: --- The Bake script generates controllers, views and models for your application. If run with no command line arguments, Bake guides the user through the class creation process. You can customize the generation process by telling Bake where different parts of your application are using command line arguments. --- Usage: cake bake command arg1 arg2... --- Params: -app path Absolute/Relative path to your app folder. Commands: bake help shows this help message. bake project path bakes a new app folder in the path supplied or in current directory if no path is specified bake db_config bakes a database.php file in config directory. bake model bakes a model. run 'bake model help' for more info bake view bakes views. run 'bake view help' for more info bake controller bakes a controller. run 'bake controller help' for more info On 28 nov, 20:37, AD7six [EMAIL PROTECTED] wrote: On Nov 28, 8:33 pm, Luke [EMAIL PROTECTED] wrote: I'm sorry I honestly forgot I already asked this question... I was wondering why you said again - thanks for answering anyway :) Try a screen cast:http://cakephp.org/screencasts(setting up the CakePHP console) Bake is self documenting really, i.e. you start it and it asks you what you want to do. hth, AD --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
why do i get so many weird errors?
I have a completely BLANK controller... all it is is this: function import() { } in my view I have a form with a file upload element in it. whenever I press submit I get this error on the top of the page Warning (2): Invalid argument supplied for foreach() [CORE\cake\dispatcher.php, line 381] WHY? :( --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: why do i get so many weird errors?
form action=?php echo $this-webroot; ?orders/import/ enctype=multipart/form-data method=post p?php echo $form-file('import'); ?/p p?php echo $form-submit('Import'); ?/p /form On Nov 28, 2:06 pm, Baz [EMAIL PROTECTED] wrote: What's in the view? On Nov 28, 2007 3:47 PM, Luke [EMAIL PROTECTED] wrote: I have a completely BLANK controller... all it is is this: function import() { } in my view I have a form with a file upload element in it. whenever I press submit I get this error on the top of the page Warning (2): Invalid argument supplied for foreach() [CORE\cake\dispatcher.php, line 381] WHY? :( --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: why do i get so many weird errors?
I guess because I don't know how I'm supposed to... slowly figuring it out. On Nov 28, 2:28 pm, Baz [EMAIL PROTECTED] wrote: Hmmph, I don't know dudeWhy don't you just write the thing like you're supposed to? I never messed with a black controller before. Your controller code should be done way before your view anyway On Nov 28, 2007 4:16 PM, Luke [EMAIL PROTECTED] wrote: form action=?php echo $this-webroot; ?orders/import/ enctype=multipart/form-data method=post p?php echo $form-file('import'); ?/p p?php echo $form-submit('Import'); ?/p /form On Nov 28, 2:06 pm, Baz [EMAIL PROTECTED] wrote: What's in the view? On Nov 28, 2007 3:47 PM, Luke [EMAIL PROTECTED] wrote: I have a completely BLANK controller... all it is is this: function import() { } in my view I have a form with a file upload element in it. whenever I press submit I get this error on the top of the page Warning (2): Invalid argument supplied for foreach() [CORE\cake\dispatcher.php, line 381] WHY? :( --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: othAuth with Cake 1.2.x.x Nightly Build (5938)
Is this happening only for admin actions or all POSTs ? Luke On Nov 3, 12:47 am, gmwebs [EMAIL PROTECTED] wrote: For some reason or another, since upgrading to the latest pre-beta 1.2.x.x I have been experiencing issues with the othAuth component. I have also upgraded to the latest nightly build but it has not made any difference. I followed the instructions inhttp://www.ancientwisdom.cc/news/archives/111 which sorts out the admin routing issues. The problem I am having is that if I login as an administrator and then perform an admin function (like editing an article) it logs me out when I submit the form. All other restricted functions work fine as long as they are not admin functions. Any ideas? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: HTTP-auth and Security Component cake 1.2 - POST a form cause me difficulty
Hi McFadly, hats interesting thanks. I normally use othAuth but I jsut wanted a very simple HTTP-Auth, and it seems to me that should be easily achievable with this Security component, although I have not been able to get it to work! All I would like to do is turn off the separate checking of POSTed data -- can anyone help? Or even someone who uses a HTTP-auth (with or without the digest) to post an example of their code to achieve it? I am not sure if a problem is arsing becasue my code is in the app_controller, maybe it would be better in each controller that needs the HTTP-auth; this seems to be the way of the OC presentation on Cake's example. thanks Luke On Nov 1, 4:58 pm, McFadly [EMAIL PROTECTED] wrote: Hi Luke - I think you're making this process more difficult than it needs to be. I haven't used HTTP auth in theSecuritycomponent, so I can't offer much insight in that realm. But you may just want to look into using the Auth component, its pretty straightforward. Check out Chris's article here:http://www.littlehart.net/atthekeyboard/2007/09/11/a-hopefully-useful... On Nov 1, 7:03 am, luke BAKING barker [EMAIL PROTECTED] wrote: looking at the HTML of the form I am submitting, I see there is this token: form id=MemberAddForm method=post action=/admin/members/addp style=display: none;input type=hidden name=data[__Token][key] value=451ed6fb6ba0df462ad05faad6f0bdaab07b667c id=Token1063112810 / I suppose that is causing a mismatch upon a POST? regards luke On Nov 1, 12:55 pm, luke BAKING barker [EMAIL PROTECTED] wrote: Hi, I am using Cake 1.2 - 14th October nightly build. I have set up my app_controller with admin routing, so that an admin function will ask the user to authenticate with HTTP auth. (I had wanted to do a simple .htaccess, with .htpasswd - so I thought I would try the Cake way). I have this working, BUT, when I submit an add form (e.g. submit admin_Add or admin_edit) I get asked to authenticate again, which also doesnt seem to work if correct details are put in. (The latter is to do with my custom blackhole callback I think). How can I tell theSecuritycomponent not to ask for Auth again upon a POST? here is my app_controller code: class AppController extends Controller { var $helpers = array('Html','Form','Javascript'); var $components = array(Security); function beforeFilter() { if (isset($this-params[admin])) { $this-Security-blackHoleCallback = 'incorrect'; $this-Security-requireLogin('*',array('type'='basic','realm' = Configure::read('Settings.title'))); $this-Security-loginUsers = array(admin = 'password'); } } // added this callback because without, if a user enters wrong details, auth prompt will not re-display function incorrect () { header('WWW-Authenticate: Basic' .' realm=' . Configure::read('Settings.title') . ''); header('HTTP/1.1 401 Unauthorized'); $this-autoRender = false; $this-layout = ''; die('h1HTTP/1.1 401 Unauthorized./h1 Details incorrect. Please refresh.'); } if I change my callback to this, it will work, but this is insecure, obviously as it simply authenticates any POSTs! function incorrect () { if(!$this-RequestHandler-isPost()) { header('WWW-Authenticate: Basic' .' realm=' . Configure::read('Settings.title') . ''); header('HTTP/1.1 401 Unauthorized'); $this-autoRender = false; $this-layout = ''; die('h1HTTP/1.1 401 Unauthorized./h1 Details incorrect. Please refresh.'); } else { return true; } } thank you in advance for any help you can offer. Luke aka boobyW --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
HTTP-auth and Security Component cake 1.2 - POST a form cause me difficulty
Hi, I am using Cake 1.2 - 14th October nightly build. I have set up my app_controller with admin routing, so that an admin function will ask the user to authenticate with HTTP auth. (I had wanted to do a simple .htaccess, with .htpasswd - so I thought I would try the Cake way). I have this working, BUT, when I submit an add form (e.g. submit admin_Add or admin_edit) I get asked to authenticate again, which also doesnt seem to work if correct details are put in. (The latter is to do with my custom blackhole callback I think). How can I tell the Security component not to ask for Auth again upon a POST? here is my app_controller code: class AppController extends Controller { var $helpers = array('Html','Form','Javascript'); var $components = array(Security); function beforeFilter() { if (isset($this-params[admin])) { $this-Security-blackHoleCallback = 'incorrect'; $this-Security-requireLogin('*',array('type'='basic','realm' = Configure::read('Settings.title'))); $this-Security-loginUsers = array(admin = 'password'); } } // added this callback because without, if a user enters wrong details, auth prompt will not re-display function incorrect () { header('WWW-Authenticate: Basic' .' realm=' . Configure::read('Settings.title') . ''); header('HTTP/1.1 401 Unauthorized'); $this-autoRender = false; $this-layout = ''; die('h1HTTP/1.1 401 Unauthorized./h1 Details incorrect. Please refresh.'); } if I change my callback to this, it will work, but this is insecure, obviously as it simply authenticates any POSTs! function incorrect () { if(!$this-RequestHandler-isPost()) { header('WWW-Authenticate: Basic' .' realm=' . Configure::read('Settings.title') . ''); header('HTTP/1.1 401 Unauthorized'); $this-autoRender = false; $this-layout = ''; die('h1HTTP/1.1 401 Unauthorized./h1 Details incorrect. Please refresh.'); } else { return true; } } thank you in advance for any help you can offer. Luke aka boobyW --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
HTTP-auth and Security Component cake 1.2 - POST a form cause me difficulty
Hi, I am using Cake 1.2 - 14th October nightly build. I have set up my app_controller with admin routing, so that an admin function will ask the user to authenticate with HTTP auth. (I had wanted to do a simple .htaccess, with .htpasswd - so I thought I would try the Cake way). I have this working, BUT, when I submit an add form (e.g. submit admin_Add or admin_edit) I get asked to authenticate again, which also doesnt seem to work if correct details are put in. (The latter is to do with my custom blackhole callback I think). How can I tell the Security component not to ask for Auth again upon a POST? here is my app_controller code: class AppController extends Controller { var $helpers = array('Html','Form','Javascript'); var $components = array(Security); function beforeFilter() { if (isset($this-params[admin])) { $this-Security-blackHoleCallback = 'incorrect'; $this-Security-requireLogin('*',array('type'='basic','realm' = Configure::read('Settings.title'))); $this-Security-loginUsers = array(admin = 'password'); } } // added this callback because without, if a user enters wrong details, auth prompt will not re-display function incorrect () { header('WWW-Authenticate: Basic' .' realm=' . Configure::read('Settings.title') . ''); header('HTTP/1.1 401 Unauthorized'); $this-autoRender = false; $this-layout = ''; die('h1HTTP/1.1 401 Unauthorized./h1 Details incorrect. Please refresh.'); } if I change my callback to this, it will work, but this is insecure, obviously as it simply authenticates any POSTs! function incorrect () { if(!$this-RequestHandler-isPost()) { header('WWW-Authenticate: Basic' .' realm=' . Configure::read('Settings.title') . ''); header('HTTP/1.1 401 Unauthorized'); $this-autoRender = false; $this-layout = ''; die('h1HTTP/1.1 401 Unauthorized./h1 Details incorrect. Please refresh.'); } else { return true; } } thank you in advance for any help you can offer. Luke aka boobyW --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: HTTP-auth and Security Component cake 1.2 - POST a form cause me difficulty
looking at the HTML of the form I am submitting, I see there is this token: form id=MemberAddForm method=post action=/admin/members/addp style=display: none;input type=hidden name=data[__Token][key] value=451ed6fb6ba0df462ad05faad6f0bdaab07b667c id=Token1063112810 / I suppose that is causing a mismatch upon a POST? regards luke On Nov 1, 12:55 pm, luke BAKING barker [EMAIL PROTECTED] wrote: Hi, I am using Cake 1.2 - 14th October nightly build. I have set up my app_controller with admin routing, so that an admin function will ask the user to authenticate with HTTP auth. (I had wanted to do a simple .htaccess, with .htpasswd - so I thought I would try the Cake way). I have this working, BUT, when I submit an add form (e.g. submit admin_Add or admin_edit) I get asked to authenticate again, which also doesnt seem to work if correct details are put in. (The latter is to do with my custom blackhole callback I think). How can I tell the Security component not to ask for Auth again upon a POST? here is my app_controller code: class AppController extends Controller { var $helpers = array('Html','Form','Javascript'); var $components = array(Security); function beforeFilter() { if (isset($this-params[admin])) { $this-Security-blackHoleCallback = 'incorrect'; $this-Security-requireLogin('*',array('type'='basic','realm' = Configure::read('Settings.title'))); $this-Security-loginUsers = array(admin = 'password'); } } // added this callback because without, if a user enters wrong details, auth prompt will not re-display function incorrect () { header('WWW-Authenticate: Basic' .' realm=' . Configure::read('Settings.title') . ''); header('HTTP/1.1 401 Unauthorized'); $this-autoRender = false; $this-layout = ''; die('h1HTTP/1.1 401 Unauthorized./h1 Details incorrect. Please refresh.'); } if I change my callback to this, it will work, but this is insecure, obviously as it simply authenticates any POSTs! function incorrect () { if(!$this-RequestHandler-isPost()) { header('WWW-Authenticate: Basic' .' realm=' . Configure::read('Settings.title') . ''); header('HTTP/1.1 401 Unauthorized'); $this-autoRender = false; $this-layout = ''; die('h1HTTP/1.1 401 Unauthorized./h1 Details incorrect. Please refresh.'); } else { return true; } } thank you in advance for any help you can offer. Luke aka boobyW --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Email component (1.2) fails to send attachment and content
hmm looking more closely at mine, I actually get a weird error. My layout is rendering, asHTML in the email, but the view is not. However - in the original (show original as I am looking at in GMail) the view HTML does show. I havent included anything weird, but I wonder if there is some missing encoding going on on the view part. I am looking at the email.php lines to see if I can fix this: function send($content = null, $template = null, $layout = null) { $this-__createHeader(); $this-subject = $this-__encode($this-subject); if ($template) { $this-template = $template; } if ($layout) { $this-layout = $layout; } if (($template === null) ($this-template === null)) { if (is_array($content)) { $message = null; foreach ($content as $key = $value) { $message .= $value . $this-_newLine; } } else { $message = $content; } $this-__formatMessage($message); } else { $this-__message = $this-__renderTemplate($content); } if (!empty($this-attachments)) { $this-__attachFiles(); } if (!is_null($this-__boundary)) { $this-__message .= $this-_newLine .'--' . $this-__boundary . '--' . $this-_newLine . $this-_newLine; } somewhere in there lies why! Luke On Oct 19, 1:03 pm, luke BAKING barker [EMAIL PROTECTED] wrote: Hi Francky, I just had a similar bit of difficulty getting this going. I don't think it is a bug though, there were a coupe of things: 1) I had an absoulte filepath for my $attachment; but you must specify a filepath (look at theemail.php code to see -- if there are no filepaths it won't work, sO I just chanegd to relative path and included the lines like so : $this-Email-attachments[] = $poem['Poem']['filename']; $this-Email-filePaths[] = WWW_ROOT . $this-Poem-uploads ;// require this relative path prefix 2) My install of PHP on my hosting didnt have mime_content_type (it is deprecated and also I think needs magic.mime enabled in php.ini so in my app/config/bootstrap I whacked this: if (!function_exists('mime_content_type')) { function mime_content_type($file) { return trim ( exec ('file -bi ' . escapeshellarg ( $file ) ) ) ; } } I might adjust this in fact as I don't like using exec, it was jsut to get it working. (opinons on this function please!) 3) it still didnt work but I was getting the attahcment inline; garbled. I noticed there was no newline though, and so in myemail/html/ default.ctp email/text/default.ctp layouts I added a newline at the end... And SUCCESS! thanks for theEmailcomponentdevs :) makes it very easy... hth Luke aka boobyWomack On Oct 2, 11:17 pm, francky06l [EMAIL PROTECTED] wrote: Does anyone succeed to send a 'text' message with an attached file using theEmailcomponent? I am using the cake1.2 from branch, and when attaching a file to a simple text mail, the content does not appear, the attachment is there. If I remove the attachment, the content is there. Same results using html, also after trying to send a template. I use UTF-8 charset, very simple default layout (text is just ?php echo $content_for_layout; ? ). I am using Thunderbird, and looking at the message source, actually the content is there but not showing. Seems to be a story of boundary / new lines, but mail protocol is not my cup of tea. Anyone experienced this and maybe give me some hints ? Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Email component (1.2) fails to send attachment and content
Hi Francky, I just had a similar bit of difficulty getting this going. I don't think it is a bug though, there were a coupe of things: 1) I had an absoulte filepath for my $attachment; but you must specify a filepath (look at the email.php code to see -- if there are no filepaths it won't work, sO I just chanegd to relative path and included the lines like so : $this-Email-attachments[] = $poem['Poem']['filename']; $this-Email-filePaths[] = WWW_ROOT . $this-Poem-uploads ;// require this relative path prefix 2) My install of PHP on my hosting didnt have mime_content_type (it is deprecated and also I think needs magic.mime enabled in php.ini so in my app/config/bootstrap I whacked this: if (!function_exists('mime_content_type')) { function mime_content_type($file) { return trim ( exec ('file -bi ' . escapeshellarg ( $file ) ) ) ; } } I might adjust this in fact as I don't like using exec, it was jsut to get it working. (opinons on this function please!) 3) it still didnt work but I was getting the attahcment inline; garbled. I noticed there was no newline though, and so in my email/html/ default.ctp email/text/default.ctp layouts I added a newline at the end... And SUCCESS! thanks for the Email component devs :) makes it very easy... hth Luke aka boobyWomack On Oct 2, 11:17 pm, francky06l [EMAIL PROTECTED] wrote: Does anyone succeed to send a 'text' message with an attached file using theEmailcomponent? I am using the cake1.2 from branch, and when attaching a file to a simple text mail, the content does not appear, the attachment is there. If I remove the attachment, the content is there. Same results using html, also after trying to send a template. I use UTF-8 charset, very simple default layout (text is just ?php echo $content_for_layout; ? ). I am using Thunderbird, and looking at the message source, actually the content is there but not showing. Seems to be a story of boundary / new lines, but mail protocol is not my cup of tea. Anyone experienced this and maybe give me some hints ? Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---