HTTP Authentication and Security Component Redirect
Hey Folks, I'm trying to use the Security component for a simple HTTP authentication on a single item in my Cake App, and I'm having trouble getting a proper error message to display upon incorrect login or when I cancel the login. At the moment, I just a blank page when I would expected a standard Apache 401 Authorization error screen to appear. I've traced through the code, and see that $this-redirect is being trigged from Security::blackHole() as: $controller-redirect(null, $code, true); Where $code is set to 401. Also, the session does not seem to reset between a failed login attempt, so I don't get prompted for a login screen again until I delete my authenticated sessions in my browser. I'm using the code almost exactly as suggested in the Cake Book. In my app_controller.php : function beforeFilter() { // othAuth login stuff that triggers on Cake.admin // if not admin then. $pass = Router::getParam('pass'); $controller = Router::getParam('controller'); # See if there are any pages set to be protected in the current controller # $protectedPages = Configure::read('HTTPAuth.'.$controller); if (!is_array($protectedPages)) { $protectedPages = array(); } if (isset($pass[0]) array_key_exists($pass[0],$protectedPages)) { $this-Security-loginOptions = array( 'type'='basic', 'realm'=$controller.'/'; ); $password = Configure::read('HTTPAuth.generalLogin.password'); $user = Configure::read('HTTPAuth.generalLogin.username'); $this-Security-loginUsers[$user] = $password; $this-Security-requireLogin(); } } I've doubled checked, and I am getting values for $username and $password. The prompt works, it's just the error I'm having trouble making work correctly. Thanks in advance for any and all help! -Casey --~--~-~--~~~---~--~~ 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: How to create tabs?
Well, the link I posted was just the first thing that came up in a Google search for CSS Tabs. It's up to you to make them look good or not. And yeah, Cake isn't a visual framework. Cake give you a strong PHP framework to help you organize and maintain a strong PHP logic codebase. With the MVC structure it uses, data processed by the Model and Controller are then passed to the view, which is (ideally) a passive receptacle for data. Cake gives you some function to help you display HTML, found in the Html Helper, but there is no inherent structure for organizing your layout. If you don't want to be coding your website, I would recommend you use a program like Dreamweaver, though I do recommend getting down and dirty into HTML and CSS, you just get more control over your final product that way. It sounds like Cake is not really what you need. I recommend looking through PHP tutorials at: http://www.tizag.com/phpT/ if you need some basic PHP logic for your website. best, -c On May 12, 5:03 pm, wesleygray [EMAIL PROTECTED] wrote: Could you clarify what you mean by a Cake-specific problem? Are you saying Cake doesn't help with generating the HTML/CSS, just with accessing the database? If so, is there a framework that does? I looked at the link you suggested and it looked like a lot of work to get some very ugly tabs. I'm looking for a high- level solution to creating a website, I don't want to be hand-coding stuff like tabs. Should I use an HTML editor and then use Cake to stuff the data into the form? Forgive my newbie questions... On May 10, 4:23 pm, daphonz [EMAIL PROTECTED] wrote: This doesn't sound like a Cake-specific problem. Cake will provide you the data you need in your views, and it's inside your views that need to code the data to display as tabs using HTML/CSS. You might try this tutorial:http://www.htmldog.com/articles/tabs/ Most likely you'll have whatever data you have to display as a tab in an array sent to your view. Then you can cycle through that data and echo them out as unordered list elements. For example: ul ?php foreach ($data as $item) { echo 'li'.$item['title'].'/li';} ? /ul -casey On May 9, 8:29 pm, wesleygray [EMAIL PROTECTED] wrote: I can't seem to find any examples of how to create a page of tabs using CakePHP. I would like to read rows from a table and create a tab for each one. The closes thing I could find is this:http://bakery.cakephp.org/articles/view/threaded-lists Anyone have a pointer? --~--~-~--~~~---~--~~ 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: How to create tabs?
This doesn't sound like a Cake-specific problem. Cake will provide you the data you need in your views, and it's inside your views that need to code the data to display as tabs using HTML/CSS. You might try this tutorial: http://www.htmldog.com/articles/tabs/ Most likely you'll have whatever data you have to display as a tab in an array sent to your view. Then you can cycle through that data and echo them out as unordered list elements. For example: ul ?php foreach ($data as $item) { echo 'li'.$item['title'].'/li'; } ? /ul -casey On May 9, 8:29 pm, wesleygray [EMAIL PROTECTED] wrote: I can't seem to find any examples of how to create a page of tabs using CakePHP. I would like to read rows from a table and create a tab for each one. The closes thing I could find is this:http://bakery.cakephp.org/articles/view/threaded-lists Anyone have a pointer? --~--~-~--~~~---~--~~ 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: Additional information about association in the HABTM table
Yes. You can use the with setting in your HABTM many model setup for this. For example, in your foo model, you can sort your HABTM entries by a unique ordering stored in the join table: class FooModel extends AppModel { var $hasAndBelongsToMany = array('Bar' = array('className'= 'Bar', 'with'='BarredFoo', 'joinTable'= 'bar_foo', 'foreignKey' = 'foo_id', 'associationForeignKey'= 'bar_id', 'conditions' = '', 'order'= array('BarredFoo.ordering'='ASC'), 'limit'= '', 'unique' = true, 'finderQuery' = '', 'deleteQuery' = '', ) } Here the model, BarredFoo, is a model defined as such: ?php class BarredFoo extends AppModel { var $name = 'BarredFoo'; var $useTable = 'bar_foo'; } ? To save extra data to the jointable, you can use a custom SQL query. You can make functions in your new join Model: ?php class BarredFoo extends AppModel { var $name = 'BarredFoo'; var $useTable = 'bar_foo'; function updateOrdering($associated_id,$content_id,$ordering) { $content_key = 'foo_id'; $associated_key = 'bar_id'; return $this-query(UPDATE `.$this-useTable.` SET `.$associated_key.`='.$associated_id.', `.$content_key.`='. $content_id.', `ordering`='.$ordering.' WHERE `.$associated_key.` = '.$associated_id.' AND `.$content_key.` = '.$content_id.';); } } ? And you can call this function in the afterSave callback in your initial model: ?php class FooModel extends AppModel { var $hasAndBelongsToMany = array('Bar' = array('className'= 'Bar', 'with'='BarredFoo', 'joinTable'= 'bar_foo', 'foreignKey' = 'foo_id', 'associationForeignKey'= 'bar_id', 'conditions' = '', 'order'= array('BarredFoo.ordering'='ASC'), 'limit'= '', 'unique' = true, 'finderQuery' = '', 'deleteQuery' = '', ) function afterSave() { if (isset($this-data['Bar']['Bar'][0])) { foreach ($this-data['Bar']['Bar'] as $key = $bar_id) { $this-BarredFoo-updateOrdering($bar_id,$this- id,$key); } } return true; } } ? That's how I order my HABTM relationships, but obviously you could extend this ad absurdum. A good article to to read about basic With relationships is here: http://www.littlehart.net/atthekeyboard/2007/09/04/a-glimpse-inside-cakephp-12/ Hope this helps, Casey On Apr 30, 9:24 am, grigri [EMAIL PROTECTED] wrote: For retrieval, this is easy: just add the extra columns to the join table; you can optionally create a model file for the join if you need to. Do a debug() on the fetched data array and you'll see all the extra fields in there. It's putting the extra data in there easily that's more complicated - the normal form helper / model __saveMulti() combo don't play nicely with extra fields, afaik. On Apr 30, 1:23 pm, tgies [EMAIL PROTECTED] wrote: foo HABTM bar, but I also need to store some specific information about that association -- say, a user HABTM groups, but each user also has a role within that group and a date of joining that group which I need to store in the foos_bars table. How do I get CakePHP to clue into this and pull out that information from the foos_bars table? --~--~-~--~~~---~--~~ 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: Saving two models from the same controller
Use two save commands: $this-A-save($this-data['A']); $this-A-B-save($this-data['B']); I think there's a new(er) function called saveAll(), which should do what you want automatically. I'm not sure about the level of implementation for that yet, though, it may only be in the latest beta release. Casey On Mar 6, 11:19 am, Juan Luis Baptiste [EMAIL PROTECTED] wrote: Hi, I have two models that have associations between them. Let call them A and B. B has a belongsTo association with A and A has a hasMany association with B. For model A I have an action called register and the form in it's view has fields for both models so I can use the same for to save the info for both. Someone on IRC told me that cake was able to save both models when the method $this-A-save($this-data) was called but that isn't working for me, it only saves data for model A. I tried doing it the other way, adding the register action to B controller and doing $this-B-save($this-data) there but it doesn't work either. I also tried calling the add method in B controller from A controller but it seems that cake tries to excecute add as an SQL string and get an SQL error instead of calling the method. So is there a way to save both models from same controller ? Thanks, -- Juan Luis Baptiste --~--~-~--~~~---~--~~ 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: $this-create() //confusion
I had a similar problem. If you read the API entry for the create() function, you'll see that it says it Initializes the model for writing a new record, loading the default values for those fields that are not defined in $data. So any default conditions you set in your DB fields are auto-loaded into the Model's data variable. I think saveField then sees these entries and includes them in the save action. Why it does this, I'm not sure. So yeah, you probably shouldn't use it before saveField. If you want to be safe, you can wipe out the Model's data array before using saveField, and then set the ID: $this-ModelName-data = array(); $this-ModelName-id = $your_record_id; $this-ModelName-saveField('field',$data); And that should do it. Casey On Mar 5, 9:29 am, bingo [EMAIL PROTECTED] wrote: hi all, Can someone explain me when to use create() function. I believe it make sense to use it when adding a record. But should it be used before saving a particular field. It seems if you use create function before saveField, CakePHP update all the fields with default values. Is this an expected behaviour or some bug ? --~--~-~--~~~---~--~~ 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 OthAuth Component, Permissions -- Home Page Access HOW?
Do you need to do permissions checking on the home page? In you app_controller.php file, you can set the actions that trigger the auth checking using the othAuthRestrictions var. Also, in addition to allowing access to orders and stock, you can add additional rules to let them access the pages controller (which is a core controller used to display page files). Also, I think you need to add permissions so like so: /groups/* /pages/* or: /pages/home.html For things to work properly. Hope this helps. -Casey On Feb 3, 10:27 am, SteveScan [EMAIL PROTECTED] wrote: Hi, Please bear with me as I am new to PHP and CakePHP. I have implemented Authentication using the OthAuth component (http:// bakery.cakephp.org/articles/view/othauth-component-v0-5-4-5). In the groups table I have created 1, administrators ; 2 orders ; 3 stock. In the permissions table I have created 1, *; 2, order ; 3, stock. Hence Group 1 has access to everything. Orders Group has permissions on controller order, and Stock Group has permissions on the Stock controller. These have been assigned in the group permissions table. Group 1 administrators can access everything (including the home page). However Groups 2 and 3 (Orders and Stock) CAN NOT ACCESS THE HOME PAGE How do I set this up at the home page is defined in app/views/pages/ home.thtml. There is NO Controller for the HOME PAGE so how do I assign ALL Groups permission(s) to access the home page in the permissions table or is there some other mechanism. Other than the fact that ALL groups Except the administrators (permissions set to *) access their own area's fine BUT CAN NOT SEE the HOME page!!! HELP! And how do I set up a nice Sorry you are not permitted to see this page other than a flash message and then re-direct to the home page that hopefully ALL will be able to see. Other than this it all appears to be fine I am missing something that I do not understand. Thank you all for your help in advance. SteveScan --~--~-~--~~~---~--~~ 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: Importing and Executing Raw SQL: Problems with Semicolons
At the moment, there is no reason beyond the fact I hadn't thought to do it. I ideally would like be able to read a straight SQL-dump, so I guess that would work, though I'd have to parse through the SQL first to construct the arrays. But those are the kind of philosophical changes that I'm looking for, so thanks for your advice! Casey On Jan 24, 3:58 pm, Chris Hartjes [EMAIL PROTECTED] wrote: On Jan 24, 2008 2:48 PM, daphonz [EMAIL PROTECTED] wrote: But when I try to use it to insert a line like: INSERT INTO `categories` (`id`,`parent_id`,`slug`,`name`,`teaser`,`description`,`model`,`options`,`ordering`,`lft`,`rght`,`enabled`,`type`,`level`,`created`,`modified`) VALUES ('2','0','file-repository','File Repository','pnbsp;/ p',NULL,'Document','a:1:{i:0;s: 1:\0\;}','1','3','4','true','nested',NULL,'2007-11-01 17:33:17','2007-11-01 17:33:17'); Is there any reason you're not building up an array containing that information and using $this-Model-save($dataArray) ? -- Chris Hartjes Internet Loudmouth Motto for 2008: Moving from herding elephants to handling snakes... @TheKeyBoard:http://www.littlehart.net/atthekeyboard --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Importing and Executing Raw SQL: Problems with Semicolons
Hi Folks, I'm trying to create a self-install routine for my web app, part of which requires it to create multiple tables with some pre-set content. I use a system similar to that mentioned by Cakebaker, (http:// cakebaker.42dh.com/2007/04/16/writing-an-installer-for-your-cakephp- application/), which, for the most part, works fine. The problem arises when I'm trying to load the SQL data into the database. The tables will load just fine, but there are content rows that contain serialized information. When it comes to executing those lines of code, (using the rawQuery routine, I get an MySQL syntax error. Here's what I'm currently doing: $statements = file_get_contents($fileNameOfSQLDump,'FILE_TEXT'); $db-rawQuery($statements); I'm reasonably sure that the problem comes in on the first line of content that includes a serialized data string. Also, I've used this same SQL data to import through other programs such as PHPMyAdmin, so I know it's not a fundamental problem with the data itself. I've tried using the Sanitize class to escape the text, but that escapes everything, and nothing is executed. Any guidance in this area would be appreciated. Either in alternate methods to load in the SQL data dump, or basic philosophical changes in how I approach this problem. Thanks! Casey --~--~-~--~~~---~--~~ 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: Importing and Executing Raw SQL: Problems with Semicolons
I may not understand the LOAD DATA LOCAL INFILE fully, but doesn't that require special security access? I'm trying to get this system to work off of a generic apache server out-of-the-box. On Jan 24, 12:26 pm, b logica [EMAIL PROTECTED] wrote: On Jan 24, 2008 11:14 AM, daphonz [EMAIL PROTECTED] wrote: Hi Folks, I'm trying to create a self-install routine for my web app, part of which requires it to create multiple tables with some pre-set content. I use a system similar to that mentioned by Cakebaker, (http:// cakebaker.42dh.com/2007/04/16/writing-an-installer-for-your-cakephp- application/), which, for the most part, works fine. The problem arises when I'm trying to load the SQL data into the database. The tables will load just fine, but there are content rows that contain serialized information. When it comes to executing those lines of code, (using the rawQuery routine, I get an MySQL syntax error. Here's what I'm currently doing: $statements = file_get_contents($fileNameOfSQLDump,'FILE_TEXT'); $db-rawQuery($statements); I'm reasonably sure that the problem comes in on the first line of content that includes a serialized data string. Also, I've used this same SQL data to import through other programs such as PHPMyAdmin, so I know it's not a fundamental problem with the data itself. Can you execute the same statements using LOAD DATA LOCAL INFILE? --~--~-~--~~~---~--~~ 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: Importing and Executing Raw SQL: Problems with Semicolons
Oh, sorry, I misunderstood your initial reply. So to properly answer you: yes. The SQL syntax works when directly loaded through the command line or PHPMyAdmin. When I remove any INSERT data that contains serialized content, my initial system works just fine, and the SQL file is successfully loaded into the MySQL server. But when I try to use it to insert a line like: INSERT INTO `categories` (`id`,`parent_id`,`slug`,`name`,`teaser`,`description`,`model`,`options`,`ordering`,`lft`,`rght`,`enabled`,`type`,`level`,`created`,`modified`) VALUES ('2','0','file-repository','File Repository','pnbsp;/ p',NULL,'Document','a:1:{i:0;s: 1:\0\;}','1','3','4','true','nested',NULL,'2007-11-01 17:33:17','2007-11-01 17:33:17'); And run it with query(), rawQuery(), or execute(), the system fails. I'm pretty sure it's related to those additional semi-colons in the serialized content. Thanks for your continued assistance. -Casey On Jan 24, 2:32 pm, b logica [EMAIL PROTECTED] wrote: On Jan 24, 2008 1:46 PM, daphonz [EMAIL PROTECTED] wrote: I may not understand the LOAD DATA LOCAL INFILE fully, but doesn't that require special security access? If you have shell access to the database you can use this command to load the data into a table. One needs to have the FILE privilege unless LOCAL is used. See here for all the dirty details: http://dev.mysql.com/doc/refman/5.0/en/load-data.html Alternatively (because i'm not entirely sure what you have in your file--raw data or SQL statements) you can connect to mysql from a shell and use this syntax: \. /path/to/your/file I'm trying to get this system to work off of a generic apache server out-of-the-box. I realise that. What i mean is, can the statements in the file be run against a database without errors when doing so directly (ie. without PHP)? If you can't get shell access, can you load the contents of the file using PHPMyAdmin? The point is to ensure that your SQL syntax is ok to begin with. --~--~-~--~~~---~--~~ 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: include everywhere | app_controller.php
Sure. You can use the controller callback functions in app_controller, listed here: http://tempdocs.cakephp.org/#TOC52711 So try doing something like: function beforeFilter() { /* Super controller logic that accesses a function in app_model or something */ return true; } If you need to access a model every time you run a controller action, you may want to add: var $uses('NecessaryModel'); to your app_controller as well. -Casey On Dec 21, 10:33 am, carSign [EMAIL PROTECTED] wrote: Hi - So I am trying to include a small snippet of code in each page of my site. Is there a way to do this without modifying each controller? For example - I want to log visitors to my site. Each page visited would have some information put into the database. URL User info tiestamp browser info Can I do this using the app_controller? Can it be done without the need to modify all of my existing controllers? If I include it in the app_controller do I name that action 'index'? do I then create a app_model? --~--~-~--~~~---~--~~ 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
It looks like you need to set PHP to allow call-time pass by reference, which is technically depreciated, but works fine. You can do that by adding the following line to the .htaccess file in your cake directory: php_flag allow_call_time_pass_reference on Hope this helps. Casey On Dec 20, 5:43 am, pandako [EMAIL PROTECTED] wrote: ok, since i use cake 1.1.8 i changed two lines in oth_auth component file on line 333,334 so i dont get the mysql error anymore. but whats with the headers and that variable notice?... On Dec 20, 11:22 am, pandako [EMAIL PROTECTED] wrote: ok new thing didnt do anything, now it seems that oth_msg outputs right when blank it says so, when wrong usrnm or pswd also, but when i write the right username and password i get following errors: Notice: Only variables should be assigned by reference in /localhost/ hola/app/controllers/components/oth_auth.php on line 308 Warning: Cannot modify header information - headers already sent by (output started at /localhost/hola/app/controllers/components/ oth_auth.php:308) in /localhost/hola/app/controllers/components/ oth_auth.php on line 554 Query: INSERT INTO `users` (`last_visit`,`created`,`modified`) VALUES ('2007-12-20 11:18:13','2007-12-20 11:18:13','2007-12-20 11:18:13') Warning: SQL Error: 1062: Duplicate entry '' for key 2 in /localhost/ hola/cake/libs/model/datasources/dbo_source.php on line 440 Warning: Cannot modify header information - headers already sent by (output started at /localhost/hola/app/controllers/components/ oth_auth.php:308) in /localhost/hola/cake/libs/controller/ controller.php on line 447 On Dec 19, 4:37 pm, daphonz [EMAIL PROTECTED] wrote: What is yourothAuthsetup? On Dec 19, 10:15 am, pandako [EMAIL PROTECTED] wrote: ok, i made new clean install of cake without ani paginations and decorate.php... now when i try to login it simply doesnt redirect me to any page but to login.thtml forever. i imputed: auth_msg and it says Plaese login! no matter what i type in form, even if i leave it blank.. Any sugestions? --~--~-~--~~~---~--~~ 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: Bakery article on Testing Models -- Missing Database Table
Hello, I've been having a very similar problem in 1.2.5875. I followed the above tips, using them to modify the instructions in the Bakery article. It looks like the fixture tables are being created, but that I am unable to access any data from them. For example: My user_test_fixture.php: class UserTestFixture extends CakeTestFixture { var $name = 'UserTest'; var $import = array('table' = 'users'); var $records = array( array ('id' = 1, 'group_id' = '1', 'username' = 'admin', 'passwd' = '21232f297a57a5a743894a0e4a801fc3', 'name' = 'Admin User', 'email'='[EMAIL PROTECTED]','last_visit'='2007-03-18 10:41:31', 'active'='1', 'created'='2007-01-18 10:41:31','created_by_user_id'='1','modified' = '2007-03-18 10:41:31','modified_by_user_id'='1'), array ('id' = 2, 'group_id' = '2', 'username' = 'testuser', 'password' = '5d9c68c6c50ed3d02a2fcf54f63993b6', 'name' = 'Test User', 'email'='[EMAIL PROTECTED]','last_visit'='2007-03-18 10:41:31', 'active'='1', 'created'='2007-01-18 10:41:31','created_by_user_id'='1','modified' = '2007-03-18 10:41:31','modified_by_user_id'='1') ); } Here is my user.test.php: ?php loadModel('User'); class UserTest extends User { var $name = 'UserTest'; var $useDbConfig = 'test_suite'; var $useTable = 'user_tests'; var $cacheSources = false; var $belongsTo = array(); } class UserTestCase extends CakeTestCase { var $fixtures = array( 'user_test' ); function startTest($method) { $this-UserTest = new UserTest(); } function endTest($method) { unset($this-UserTest); } function testCheckUserExistence() { /* Existing Username */ /* The command pr($this-UserTest-find('count')); retuns 0 here */ $result = $this-UserTest-checkUserExistence('admin'); $this-assertTrue($result,'User, admin, should be found'); } } ? So, yes, the test method reports a failure. Can anyone offer some help or suggestions? It would be greatly, greatly appreciated. On Dec 20, 11:06 am, Mariano Iglesias [EMAIL PROTECTED] wrote: That's because setUp should not be used with test cases that descend from CakeTestCase (i.e: test cases with fixtures) or you are going to get those nasty side effects. Instead use their equivalents: startCase(): called ONCE during the execution of ALL test methods, and right before the first test method is executed endCase(): called ONCE, after all test methods have executed startTest($method): called right before EACH test method is executed, and the parameter $method includes the name of the test method that is about to start endTest($method): called right after EACH test method is executed, and the parameter $method includes the name of the test method that has just finished executing -MI --- Remember, smart coders answer ten questions for every question they ask. So be smart, be cool, and share your knowledge. BAKE ON! blog:http://www.MarianoIglesias.com.ar -Mensaje original- De: cake-php@googlegroups.com [mailto:[EMAIL PROTECTED] En nombre de Philip Enviado el: Jueves, 20 de Diciembre de 2007 12:50 p.m. Para: Cake PHP Asunto: Re: Bakery article on Testing Models -- Missing Database Table I also am finding that if I try to load the ...Test model in the setUp, the Missing Database Table resurface --~--~-~--~~~---~--~~ 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
What is your othAuth setup? On Dec 19, 10:15 am, pandako [EMAIL PROTECTED] wrote: ok, i made new clean install of cake without ani paginations and decorate.php... now when i try to login it simply doesnt redirect me to any page but to login.thtml forever. i imputed: auth_msg and it says Plaese login! no matter what i type in form, even if i leave it blank.. Any sugestions? --~--~-~--~~~---~--~~ 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: Bakery article on Testing Models -- Missing Database Table
I found that instead of following that article completely, I modified one of the baked model tests, which had two extra functions, setUp and tearDown: class UserTestCase extends CakeTestCase { var $fixtures = array( 'user_test' ); function setUp() { $this-UserTest = new User(); } function tearDown() { unset($this-UserTest); } function testStuff() { } } And there I initialize the User model as $this-UserTest in the setUp function. Everything else from the article I followed, and it seemed to work fine (with the fixture data and everything). Hope this helps. -Casey On Dec 19, 2:50 pm, Philip [EMAIL PROTECTED] wrote: I'm attempting to apply the Bakery article Testing Models with CakePHP 1.2 test suite http://bakery.cakephp.org/articles/view/ testing-models-with-cakephp-1-2-test-suite by Mariano Iglesias to my own testing, but I'm getting Missing Database Table for my *Test class. Is anyone successfully using these techniques and willing to volunteer to answer questions? Technical details of my specific issue follow. = I'm try to adapt Mariano's examples to a test for the TournamentGame model, so my derived class should be this, right?: loadModel('TournamentGame'); class TournamentGameTest extends TournamentGame { var $name = 'TournamentGameTest'; var $useDbConfig = 'test_suite'; } But I get this error: Missing Database Table No Database table for model TournamentGameTest (expected test_suite_tournament_game_tests), create it first. Notice: If you want to customize this error message, create app\views \errors\missing_table.ctp I was under the impression from the article that CakePHP automagically knows that the *Test derived class corresponds to the model, but perhaps I'm misunderstanding something, or perhaps it's changed in present versions. I notice that it's correctly applying the test_suite prefix, but I was under the impression that those needed tables are automatically created during the execution of the test. Am I missing something here? I'm on SVN revision 6123, by the way. = Thanks, Philip --~--~-~--~~~---~--~~ 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: pagination of child model
If you have the recursive property on your Article model set to 1 or higher, a find() or read() function call in the Article model will automatically associate the related comments. Try: $this-Article-recursive = 1; $data = $this-Article-read($article_id); then, pr($data); To see the the associated data in the array. To paginate, you could probably make another function that searches for things more manually: function paginateAssociatedComments($article_id) { $data = $this-paginate($this-Article- Comment,array('conditions'=array('Comment.article_id'= $article_id))); $this-set('data',$data); $this-layout = 'ajax'; } Or something like that. -Casey On Dec 18, 7:07 am, dr. Hannibal Lecter [EMAIL PROTECTED] wrote: Em..anyone..? If it's not doable I'd also like to know.. --~--~-~--~~~---~--~~ 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: $this-Session-setFlash(' -- msg here -- '); not showing up on 1.2.x
Also make sure you have something in your view to display the message: ?php if($session-check('Message.flash')): $session-flash(); endif; ? Or the like. -Casey On Dec 9, 10:44 pm, Louie Miranda [EMAIL PROTECTED] wrote: Got this working.. Just add.. $this-Session-setFlash('Sorry, the information you\'ve entered is incorrect.'); $this-redirect('login'); *$this-redirect('login');* So, there will be no blank page. And the flash message will be shown on the login() Louie On Dec 10, 2007 8:51 AM, Louie Miranda [EMAIL PROTECTED] wrote: Guys, this is fairly simple setFlash. But, i wonder why it is now showing up? A few of my simple auth codes.. ?php class UsersController extends AppController { var $name = Users; var $helpers = array('Html', 'Form', 'Session'); function login() { if(empty($this-data) == false) { if(($user = $this-User-validateLogin($this-data['User'])) == true) { $this-Session-write('User', $user); $this-Session-setFlash('You\'ve successfully logged in.'); $this-redirect('/statistics/display'); exit(); } else { $this-Session-setFlash('Sorry, the information you\'ve entered is incorrect.'); exit(); } } } ... ? I can successfully login, and it redirects right away. But, i could not see the flash message. Did, i missed something here? I am using the latest 1.2.x (pre-beta) Please help! -- Louie Miranda ([EMAIL PROTECTED]) http://www.axishift.com Security Is A Series Of Well-Defined Steps chmod -R 0 / ; and smile :) -- Louie Miranda ([EMAIL PROTECTED])http://www.axishift.com Security Is A Series Of Well-Defined Steps chmod -R 0 / ; and smile :) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups 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
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 -~--~~~~--~~--~--~---
Re: cakephp 1.2: saveField, why ?
I was getting a similar problem when I was using saveField. In Cake 1.2.4605 alpha I used a saveField call while updating my Category model. The SQL command would look like this: UPDATE `categories` SET `options` = 'a:2:{i:0;s:1:\0\;i:1;s: 0:\\;}' WHERE `id` IN (66) and work just fine. Whereas in Cake 1.2.5875 pre-beta, the same command would result in the SQL line: UPDATE `categories` SET `id` = 67,`parent_id` = 66,`numberOfChildren` = NULL,`options` = 'a:2:{i:0;s:1:\0\;i:1;s:0:\\;}',`name` = 'Default',`teaser` = NULL,`description` = NULL,`model` = 'Image',`ordering` = 1,`created` = '2007-08-27 17:33:24',`modified` = '2007-08-27 17:33:24' WHERE `id` IN (66) Notice it would set the category ID incorrectly, as well as update the entire entry, which sounds similar to what's happening to you. I fixed this by moving from saveField to the model save function, as such: $saveData = array('Category'=array('id'=$category['ParentCategory'] ['id'],'options'=serialize($options))); $this-Image-Category- save($saveData,false,array('Category.options')); And that seemed to work. So in your case, try: $saveData = array('Category'=array('id'=$category_id,'title'= $title)); $this-Category-save($saveData,false,array('Category.title')); And hopefully that will work for you. On Oct 26, 4:58 am, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I have model Category with fields: id title parent_id (yep category with subcategory, like threaded in bakery). In model I don't put any belongs/has... base, empty model... Ok. So, when I change title by saveField $this-Category-saveField('title',$title); I see this query: UPDATE `categories` SET `parent_id` = '0',`title` = 'My new title' WHERE `id` IN (1) So, WHY I get parent_id = 0, 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: Cake 1.2 Pre-Beta Self-Referential Model Problem?
Playing around more, the saveField problem seems to not occur in PHP 5, only in PHP 4. Any ideas? On Oct 24, 2:42 pm, daphonz [EMAIL PROTECTED] wrote: I have a Categories Model that references itself to create Child Categories. It also has multiple Has Many associations with other models that I use, such as Images, Documents, and Content. The basic logic is that all associated models have a category_id that keys into a child category's id, essentially placing every entry in a child category of a parent category. This whole system worked fine with the previous main alpha releases. When I updated to Cake's pre-Beta, I noticed several problems. First, it seems that recursive association results have changed. When I do a findAll in Categories with my recursive level set to 2, Child Categories are returned, but not their associated model entries. Currently, my Categories model looks like this: class Category extends AppModel { var $name = 'Category'; var $belongsTo = array('ParentCategory'= array('className'='Category', 'foreignKey'='parent_id' ) ); var $hasMany = array('ChildCategory'= array('className'='Category', 'foreignKey'='parent_id', 'order'=array('ChildCategory.ordering'='ASC'), 'dependent'=true ), 'Content'= array('className'='Content', 'foreignKey'='category_id', 'order'=array('Content.ordering'='ASC'), 'dependent'=true ), 'News' = array('className' = 'News', 'conditions'= '', 'order' = array('News.newsDate'='DESC'), 'limit' = '', 'foreignKey'= 'category_id', 'dependent' = true, 'exclusive' = false, 'finderQuery' = '' ), 'Image' = array('className' = 'Image', 'conditions'= '', 'order' = array('Image.ordering'='ASC'), 'limit' = '', 'foreignKey'= 'category_id', 'dependent' = true, 'exclusive' = false, 'finderQuery' = '' ), etc. } Up until the latest alpha of Cake 1.2, any recursive findAll calls to the Category model would return categories, category children, and the model associations to the category children. For example: $this-Document-Category-recursive = 2; $this-Document-Category- findAll(array('Category.model'='Document','Category.parent_id'='0'),null,array('Category.ordering'='ASC')); Would return: [2] = Array ( [Category] = Array ( [id] = 131 [parent_id] = 0 [numberOfChildren] = [options] = a:1:{i:0;s:1:1;} [name] = Newsletters [teaser] = [description] = [model] = Document [ordering] = 3 [created] = 2007-10-16 14:02:33 [modified] = 2007-10-16 14:27:26 ) [ParentCategory] = Array ( [id] = [parent_id] = [numberOfChildren] = [options] = [name] = [teaser] = [description] = [model] = [ordering] = [created] = [modified] = ) [ChildCategory] = Array ( [0] = Array ( [id] = 132 [parent_id] = 131 [numberOfChildren] = [options] = [name] = Default [teaser] = [description
Cake 1.2 Pre-Beta Self-Referential Model Problem?
I have a Categories Model that references itself to create Child Categories. It also has multiple Has Many associations with other models that I use, such as Images, Documents, and Content. The basic logic is that all associated models have a category_id that keys into a child category's id, essentially placing every entry in a child category of a parent category. This whole system worked fine with the previous main alpha releases. When I updated to Cake's pre-Beta, I noticed several problems. First, it seems that recursive association results have changed. When I do a findAll in Categories with my recursive level set to 2, Child Categories are returned, but not their associated model entries. Currently, my Categories model looks like this: class Category extends AppModel { var $name = 'Category'; var $belongsTo = array('ParentCategory'= array('className'='Category', 'foreignKey'='parent_id' ) ); var $hasMany = array('ChildCategory'= array('className'='Category', 'foreignKey'='parent_id', 'order'=array('ChildCategory.ordering'='ASC'), 'dependent'=true ), 'Content'= array('className'='Content', 'foreignKey'='category_id', 'order'=array('Content.ordering'='ASC'), 'dependent'=true ), 'News' = array('className' = 'News', 'conditions'= '', 'order' = array('News.newsDate'='DESC'), 'limit' = '', 'foreignKey'= 'category_id', 'dependent' = true, 'exclusive' = false, 'finderQuery' = '' ), 'Image' = array('className' = 'Image', 'conditions'= '', 'order' = array('Image.ordering'='ASC'), 'limit' = '', 'foreignKey'= 'category_id', 'dependent' = true, 'exclusive' = false, 'finderQuery' = '' ), etc. } Up until the latest alpha of Cake 1.2, any recursive findAll calls to the Category model would return categories, category children, and the model associations to the category children. For example: $this-Document-Category-recursive = 2; $this-Document-Category- findAll(array('Category.model'='Document','Category.parent_id'='0'),null,array('Category.ordering'='ASC')); Would return: [2] = Array ( [Category] = Array ( [id] = 131 [parent_id] = 0 [numberOfChildren] = [options] = a:1:{i:0;s:1:1;} [name] = Newsletters [teaser] = [description] = [model] = Document [ordering] = 3 [created] = 2007-10-16 14:02:33 [modified] = 2007-10-16 14:27:26 ) [ParentCategory] = Array ( [id] = [parent_id] = [numberOfChildren] = [options] = [name] = [teaser] = [description] = [model] = [ordering] = [created] = [modified] = ) [ChildCategory] = Array ( [0] = Array ( [id] = 132 [parent_id] = 131 [numberOfChildren] = [options] = [name] = Default [teaser] = [description] = [model] = Document [ordering] = 1 [created] = 2007-10-16 14:02:33 [modified] = 2007-10-16 14:02:33 [ParentCategory] = Array (
Re: Dynamic form fields / multi-dimension array inside $this-data
Sure. The following example uses Cake 1.2's FormHelper, but the general syntax should work for 1.1's HTMLHelper: for ($i=0;$i$weekMax;$i++) { echo $form-text('User.start]['.$i); } Or you could just generate the inputs by hand, using the structure: input type=text id=UserStart1 name=data[User][start][1] value= / input type=text id=UserStart2 name=data[User][start][2] value= / etc. Using either of the above methods, the $this-data array in your controller will have $this-data['start'] as an array with the same number of elements you specified in your view. You could then serialize this array before storing it in your DB to reduce the number of fields you need. Hope this helps, Casey On Oct 16, 12:20 pm, MarsDev [EMAIL PROTECTED] wrote: Hi guys, I am building a training scheduling app where I am stuck at the weekly schedule list form. Each training class is a multi-week schedule, somewhere between 15-20 weeks. I have a table that keep tracks thes length of the training class. However, when it comes to the frontend rendering, I don't know how to assign the text fields to capture all the start date / end date of the each week: For example: tr tdWeek 1/td td ?php echo $html-input('User/start_date', array('size' = '20')? ?php echo $html-tagErrorMsg('User/start_date', 'Start Date is required'); ? /td td ?php echo $html-input('User/end_date', array('size' = '20')? ?php echo $html-tagErrorMsg('User/end_date', 'End Date is required'); ? /td /tr ... ... Is there some way to make cakePHP keep all week schedule data into $this-data['User']['start'][0] to $this-data['User']['start'][15], for instance? If so, what should I put for the first parameter of HtmlHelper::input() method? Thanks a lot!! --~--~-~--~~~---~--~~ 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: Dynamic page titles and keywords.
You could also use the $this-set() command in your controller after you read in your data but before you render your view. For example (assuming you're displaying data from a Page model with fields called metadesc and metakeys: $data = $this-Page-read($id); $this-set(array('metadata'=array('meta'=$data['Page'] ['metadesc'],'metakeys'=$data['Page']['metakeys']))); $this-render(); Then, in your layout view, you call echo various fields of the variable to display as needed: meta name=keywords content=?php echo $meta['metadesc']; ? / meta name=description content=?php echo $meta['metakeys']; ? / etc. You would probably want to add some checks to make sure $meta variable exists, even if there is no information for it. Also, you can set your page title in the controller, before you render your view: $this-pageTitle = $data['Page']['title']; or the like. Good luck! On Oct 1, 4:11 am, phantz [EMAIL PROTECTED] wrote: Hey, I am having trouble working out how to accomplish dynamic titles and key words for each page. I want each page to have its own meta data that I will store in the database. The problem is I don't see how I can pass that information to that part of the layout when each view is called. I get how to set where my views are displayed in my layout but how would I go about displaying meta data in my layout each time I load a different view? 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: Fetching data from model not binded
Depending on your model recursion level, you should get Project information associated with each Project item returned from a Category Find request. You can use pr($this-Category-find(Category.id=2)); to see the array of data returned by that function. If you're not seeing any Project information, set the recursion level in the category model to 2: $this-Category-recursive = 2; before you call the find function. Once you get all the data you need you can sort it as you see fit in your controller. On Jul 26, 4:33 am, lgarcia [EMAIL PROTECTED] wrote: I need an urgent solution. I have all my products associated to a category and owned by a project. The association between this three models is: * Project.id = Product.project_id * product and category == HABTM (products_categories) So, products and projects are related, but categories and projects are not... how can i show products related to a certain project in the Category-show action? Now i'm doing... function show(id) { $this-Category-find(Category.id = 2); } I'm quite lost thanks in advance --~--~-~--~~~---~--~~ 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: Mac install using MAMP get MYSQL can't connect error
Are you adding the port value in the db config array? Here's my congif setup, using MAMP as on my local machine: var $default = array( 'driver' = 'mysql', 'persistent' = false, 'host' = 'localhost', 'port' = '8889', 'login' = 'root', 'password' = 'root', 'database' = 'my_db', 'prefix' = '' ); On Jul 21, 11:31 am, road runner [EMAIL PROTECTED] wrote: Hi, installing latest version of Cake on Mac OS 10.3.9 Using MAMP but when I access the following page is returned properly but with message Can't connect see below. CakePHP Rapid Development Your database configuration file is present. Warning: mysql_connect() [function.mysql-connect]: Can't connect to local MySQL server through socket '8889' (2) in /Applications/MAMP/ htdocs/cake/cake/libs/model/dbo/dbo_mysql.php on line 100 Warning: mysql_select_db(): supplied argument is not a valid MySQL- Link resource in /Applications/MAMP/htdocs/cake/cake/libs/model/dbo/ dbo_mysql.php on line 105 Cake is not able to connect to the database. According to MAMP need to use port 8889 which I changed in the dbo_mysql.php file and again in the database.php file also changed sign in and password to what MAMP expects and created database cAlled cake. I used phpmyadmin to create a database cake without tables. If someone can point me in right direction would be appreciated. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---