Re: Remote Login Form - security blocking?
Okay, I found the solution! I needed to set cake security to medium instead of high, so that the session_id isn't regenerated upon every request. That's my solution for now anyway. It works! --~--~-~--~~~---~--~~ 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: Remote Login Form - security blocking?
Update: I was able to pinpoint that the issue is in fact a session issue. I created a smaller test case to verify this, although I still don't know what the solution is. When I submit the form to the server, it saves some values in the session, but then when it redirects, the session variables are gone. The server is secure (https), and I've tried submitting from both http and an https and am getting the same results. It works fine on my local machine to my local machine, or on the server to the server, but not from one posting to the other. What can I do? Thanks, Brandon --~--~-~--~~~---~--~~ 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: Remote Login Form - security blocking?
Thanks for the reply. Here is the login function code. (see below) I have verified that it is at least getting to this function, and the Authentication component is finding and returning the user properly. Yes, I am redirecting at the end of the function. Is there some trouble then, with having sessions created after coming from remote server? function login() { if (!empty($this->data)) { if (!empty($this->data['User']['current_url'])) // for remote logins $this->Session->write('current_url', $this->data['User'] ['current_url']); $this->Authentication->userFieldName = 'username'; $data = $this->Authentication->userExists($this->data['User'] ['username'], $this->data['User']['password']); // Just checking here to make sure the user's account is active. if (!empty($data) && $data['Usergroup']['name'] == 'Site Admin' || ( ($data['Studio']['StudioStatus']['name'] == 'Active' || $data['Studio']['StudioStatus']['name'] == 'Trial') ) ) { if (is_null($data['Studio']['expiration_date']) || strtotime($data['Studio']['expiration_date']) > time()) { $expired = false; } else { if ($data['Usergroup']['name'] == 'Studio Admin') { // Account is expired. Let studio admin login just to update billing info $expired = true; $this->Session->write('expired', true); } else // Don't let other users in the studio login { $this->flash('Sorry, this account is not currently active. Please contact the studio administrator.', 'warning'); $this->redirect('/users/login'); exit(); } } $this->Session->write('User', $data['User']); $this->Session->write('Usergroup', $data['Usergroup']); if (isset($data['User']['studio_id'])) { $this->Session->write('Studio', $data['Studio']); } else { $data['Studio']['name'] = 'Studio Helper'; $this->Session->write('Studio', $data['Studio']); } $this->Session->write('Usergroup.child_usergroup_id', $this- >Usergroup->field('id', 'rank < '.$this->Session- >read('Usergroup.rank').' ORDER BY rank DESC')); $this->flash('Welcome, '.$data['User']['first_name'].'!', 'success'); // Update last login date $userdata['User']['id'] = $data['User']['id']; $userdata['User']['last_login_date'] = date('Y-m-d H:i:s'); $this->User->save($userdata); if ($data['Usergroup']['name'] == 'Site Admin') { if (DEVELOPMENT_MODE) $this->redirect('/studios'); else { // Make SSL //if (!env("HTTPS")) $this->redirect('https://' . $_SERVER['SERVER_NAME'] .'/ studios'); //$this->redirect('https://studiohelper.com/studios'); } } else { // Default initial login page(s) if (DEVELOPMENT_MODE) $this->redirect('/users/dashboard');
Remote Login Form - security blocking?
Hello, I'm trying to allow users to login to my CakePHP website from remote servers. So, they can put a login form on their own website to login, rather than having to go to my website. This is simply a regular html form created that posts to the /users/remote_login action of my website. (Yes, I'm making sure that it's posting to the correct domain - the domain that's hosting the website and the Cake code, not the the domain that's hosting the login form). So, it submits the POST request to my website, logs in their session, and then redirects them to a page on my site. This remote login form works great if it's done from the same server (so, locally, not remotely), but if the form is placed on a remote server, and you try to login, permission is denied. I'm just wondering if there's something in Cake's security component, or something else that is prohibiting remote logins. Does it reject post requests if they come from an IP address that's different from what the server is sitting on? I've tried disabling the security component and it still doesn't work, so I'm not sure what else to try. Can anyone offer some insight into how I might resolve this? Thanks, Brandon --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
findAll with OR, AND, and BETWEEN
Hello, I'm trying to generate a query with the following condition: WHERE Lead.user_id = $user_id OR (Lead.time_found BETWEEN '$start_time' AND '$end_time' AND Lead.user_id IN ('0',NULL)) Here is the condition I'm using, but it's not giving the right result. $conditions[] = array('Lead.user_id'=>$user_id 'or'=>array( 'Lead.time_found'=>'> '.$this->Session->read('User.start_time'), 'Lead.time_found'=>'< '.$this->Session->read('User.end_time'), 'Lead.user_id'=>array('0',NULL) ) ); Here is what I'm getting back: WHERE (`Lead`.`user_id` = 3) AND (((`Lead`.`time_found` < '09:00:00') OR (`Lead`.`user_id` IN ('0', NULL) ))) It's leaving out the first start time, and switching some of the AND's and OR's. What am I doing wrong? I've also tried just using BETWEEN '$value' in my query, but it ends up putting slashes in front of the apostrophes in the sql query which makes it invalid (ie. BETWEEN \'2008-01-01\' AND \'2008-02-01\') Any ideas? Thank you! Brandon --~--~-~--~~~---~--~~ 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 models with plugins in CakePHP 1.2
Yes, it doesn't seem fair that just because I'm using a certain Model from my app controller, that makes my plugin not work because its AppModel extends my main app model and it can't find the one I'm trying to use. Is there no way around this? On Nov 17, 11:00 am, Aaron Shafovaloff <[EMAIL PROTECTED]> wrote: > I'd have to agree with some folks here---it'd be great if plugins > could "plugin" into the existing application and have access to the > main app's models, etc. > > Perhaps plugins could be split into two types? One of the reasons > Wordpress is so popular is itspluginsystem (which tap into the > larger app). It'd be nice if CakePHP made it easy for us to set up our > apps this way. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Overriding Session Component for better setFlash()?
I'm using Session::setFlash() to show messages to the user, but there are some things I don't like about it: 1) It can only show one message at a time. I'd like to be able to set several messages and have them all displayed once the page refreshes. 2) While you can set layouts for the entire flash message, I'd rather be able to set a flash "type", which would simply change the CSS class for each message I set (depending on the layout). This way, I could have a list of several messages, and some could be confirmations (with a green checkmark) and other could be errors or warnings in red, all in the same "flash box". I was thinking if there was a way I could override the Session component (particularly the setFlash() function), that would be an easy way to handle it. Is this possible, and if so, is it the best way to do what I want above? Thank you, Brandon --~--~-~--~~~---~--~~ 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: Accessing variable in child class from app_controller's beforeFilter
Great! Thanks for your help. I'll continue to consider ACL. But since I want (non-techy) end-users to be able to manage permissions for those in their hierarchy, I don't want them to be confused with having to grant access to particlar controllers or function names (actions), etc. So in this system, I'm categorizing my controllers, and using some default actions (view,index,add,edit,delete), and mapping all other actions (the exceptions) to one of the defaults - to make it easy for the end user, and the programmer, to manage permissions. If ACL can do this well, I'm certainly open to it. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Accessing variable in child class from app_controller's beforeFilter
Absolutely. But when does Cake ever create an Animal alone? Doesn't it always create a Dog, which is an animal? Or in Cake terms: When do we ever have just an App? Won't it always be a user? Does Cake ever create an AppController by itself? Isn't it instead creating a UserController which extends AppController? When I'm in the AppController::beforeFilter(), having accessed the function via /users/add, isn't the object really a User, rather than an App, thereby giving me access to the variables in the UserController? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Accessing variable in child class from app_controller's beforeFilter
Alright. That makes sense. But since the Users controller extends the App controller, if I go to a page like: /users/add Shouldn't that be creating a User object rather than an App object? So that when the beforeFilter runs, it's running through the User object? For example, if I put the beforeFilter in the userController, it understands it. And I can call a function in the App controller which can THEN reference variables in the User controller just fine. But it seems that the beforeFilter runs BEFORE the User controller is created, as if the App controller runs on its own before it's run as an "extension" of the Users controller. Am I making sense? When does the beforeFilter run when calling /users/add? And if I have a beforeFilter in both my Users and App controllers, in what order are they run? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Accessing variable in child class from app_controller's beforeFilter
I'm setting a few variables in my UserController that I want to access in my AppController (in the beforeFilter). But I'm getting this error: Notice: Undefined property: PagesController::$accessExceptions in C:\websites\klickfile.com\app\app_controller.php on line 67 I get the same error with the $this->category variable as well. In the app_controller's beforeFilter, are the variables in the child class not available yet? How can I access them? (If I can, this will be a really slick way to do user-managed ACL). class UsersController extends AppController { var $uses = array('User'); var $category = 'Users'; // The category this controller belongs to /** * Exceptions for access_rights other that view,index,add,edit,delete. Maps the exceptions to one of the default access_rights */ var $accessExceptions = array( 'dashboard'=>'view', 'login'=>'view', 'email'=>'add', ); } class AppController extends Controller { var $beforeFilter = array('_checkAccess'); var $uses = array('UsergroupRight', 'AccessCategory'); /** * Default actions (bit values) */ var $defaults = array( 'view'=>1, 'index'=>2, 'add'=>4, 'edit'=>8, 'delete'=>16 ); /** * Checks to see whether a usegroup has permission to perform the requested * action on the requested controller. */ function _checkAccess() { // Check for accessExceptions $checkAction = in_array($this->action, $this->defaults) ? $this->action : $this->accessExceptions[$this->action]; $hasAccess = $this->UsergroupRight->find(array('AccessCatetegory.name'=>$this->category, 'UsergroupRight.usergroup_id'=>$this->Session->read('usergroup_id'), 'UsergroupRight.access_rights_value & '.$checkAction.' > 0')); echo 'hasAccess?: '.$hasAccess; exit(); } } --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: views controlling layouts
I also found a need for the view to set variables that can be used by the layout. I think even things like setting the page title, or including special CSS for that page should be done in that specific page view and not the layout or the controller. The method I used was this: // mypage.thtml variable = 'Something';?> // layout.thtml variable?> It's not the most elegant solution, but seems to work fine. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Session doesn't carry across subdomain
Hello, I have a website where each user gets their own subdomain (http://whatever.domain.com). They login from the main site (www.domain.com), but once they login, it redirects them to their subdomain so it looks like their editing their content on their own domain. However, when I redirect them to it, I lose all session information I saved during the login process (such as permission level, user_id, etc). If I go back to the www domain, the session variables are back. I noticed that the "host" property in the CakeSession object is different, of course, and wonder if that may have anything to do with it. But I'm not sure how to change it or if that would even fix the problem. Is what I'm wanting possible or does anyone have any suggestions? How do sessions handle variables across subdomains? Thanks, Brandags --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Dynamic Subdomains and Wildcard DNS
That makes sense. My application will also be using the same database and folders. I've been experimenting a little and have come up with a solution that's working fairly well, but just needs a little tweaking. I actually didn't need to use .htaccess at all, but used routes to route all requests that do not have a subdomain to a controller that will parse the url and figure out via variables stored in the database, which controller should handle the request, and then I use requestAction() to grab the content. I think it will work well. In routes.php: $subdomain = substr($_SERVER['HTTP_HOST'], 0,strpos($_SERVER['HTTP_HOST'],'.') ); if (!defined('DISPATCH_ROUTE')) { define ('DISPATCH_ROUTE', 'userpages/display/'.$subdomain.'/'.$from_url); $from_url = DISPATCH_ROUTE; } Then I handle the routing in userpages_controller.php, display() function. function display($subdomain, $page_name, $action='index', $id=null) { // Grab page type based on the $page_name, and match with appropriate controller } --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: limiting what fields can be saved
Would the Security component be a solution to this problem? http://manual.cakephp.org/chapter/18 With it, I believe you can ensure that people can't post data to your controller from another server - so they'd have to somehow change the html form on your own server for it to validate. I've never used it, so I may not be understanding what it can do, but I thought I'd throw it out there since it seems applicable. - Brandon --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Dynamic Subdomains and Wildcard DNS
Thank you for sharing your method! It does seem like that would work. Am I understanding correctly that you're creating an additional bootstrap.php file for each domain? It seems like there should be a way to do it dynamically so that no additional files are required. I did this on a non-Cake site. Using mod rewrites I passed the subdomain to the url in a variable and used that to determine which data to grab from the database. See http://blog.brandags.com/dynamic-subdomains.html (old, non-Cake stuff) I haven't tried it in Cake, but maybe a similar thing would work? I'm just not sure how it would interfere with routes and the existing .htaccess contents. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Dynamic Subdomains and Wildcard DNS
Okay, never mind. It looks like although view.php copied over, the filesize was 0, so obviously it couldn't read what it needed to. FTP upload problem, I guess. Although, I still haven't figured out dynamic subdomains. I guess I'll address that more when I get to it. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Dynamic Subdomains and Wildcard DNS
Hello, I'm trying to create a site where users can have their own subdomain, which will be created dynamically: http://john.myfamilyswing.com http://suzie.myfamilyswing.com etc. So I had my web host enable wildcard DNS in Apache, but for some reason, Cake is acting as if it can't find all the files it needs. I've re-uploaded all the files several times, and I haven't changed anything in the .htaccess file. It works fine on my dev machine before uploading. The error I'm getting is: Fatal error: Cannot instantiate non-existent class: view in [path]/public_html/cake/libs/controller/controller.php on line 546 Has anyone successfully dealt with this problem before? Or do you have any suggestions that might help? I'm kind of at a loss here. Maybe I need to mess with routes? Any help would be appreciated. Brandon --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: including an element in the depending on which view I'm in
I don't know if this is the best solution, but I created a variable called "addHead", which I create in my view (or maybe I created it in my app controller...? can't remember..), then use it in the layout. Like so: index.thtml: addHead .= 'This will go in the head section';?> layout.thtml: addHead)) echo $this->addHead;?> If anyone has a better way, let it be heard! --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Possible AJAX Bug in 1.1.5.3148
I just upgraded from version 1.0.1.2708 to 1.1.5.3148, and found that one of my ajax links stopped working. When I switched it back to the old version, it worked again. It may be rare that this scenario occurs, but I thought I'd point it out to see if it's just something I'm doing wrong. In this site, the user can browse through photos and add them to their shopping cart via ajax. When they click "Add to Cart", it refreshes the cart div via ajax to show all the photos in the cart and re-calculate the totals. This link still works fine. Using $ajax->link(). However, I am also using Lightbox 2.0, so that they can view a larger version of the image. Lightbox lets you specify text to go under the image in the title="" attribute of the link. If you use html in it, it must be escaped with htmlspecialchars(). So I created an ajax link inside of the title attribute so they could add the photo to their cart while looking at the enlarged lightbox version. It worked fine in 1.0.1.2708 and added it to the cart in the background (although since it darkens the screen, it's hard to see - I'm still trying to figure out how to make it update the link text via ajax as well as the cart so they know it's been updated.). But when I upgraded to 1.1.5.3148 (to test the ajax feature that updates multiple divs through one link), the link didn't work. It didn't give me an error, but the cart just didn't update, even when I used the exact same code in the view. Not sure why, but if anyone has any comments, I'd love to hear them. If you'd like to take a look at the site, it's still in development, but you can see it at: http://dev.screamcheesephotos.com (using 1.0.1.2708). Thanks, Brandon --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: This is a design issue.
Or you could do something as simple as: 1) When they login, use: $this->Session->write('loggedIn', true); 2) Then your checkSession() function would be: function checkSession() { if ($this->Session->read('loggedIn') == true) return true; else return false; } --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Naming Conventions and Case Sensitivity (Linux & Windows)
Okay. Maybe it would be good to state that they're the same (in the manual) so people don't get confused or think their might be a different convention for a component or helper. Just a thought. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Naming Conventions and Case Sensitivity (Linux & Windows)
I think it would be helpful to update the naming conventions page (http://manual.cakephp.org/chapter/20) to show the conventions for components, behaviors, helpers, and elements as well. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Naming Conventions and Case Sensitivity (Linux & Windows)
Hey - what do you know? That did it! Maybe I should make it backward compatible and use the & when assigning the controller? Thanks for your help. It's working fine now. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Naming Conventions and Case Sensitivity (Linux & Windows)
@RoSoft - so you're saying I should make all the filenames lowercase? Does that mean I need to use lowercase class names as well? class myformComponent extends Object You bring up a good point. I'm running PHP5 on my Windows machine, but I need to tweak an .htaccess parameter to get PHP5 working on Linux. It must still be running under PHP4. I'll make the change and see what it does. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Naming Conventions and Case Sensitivity (Linux & Windows)
Thank you for your comments. I changed the filenames on the helper and controller to Myform.php (with capital M), but I'm still getting the same error. I've posted the code and filenames exactly as I have it (correct case). Is there anything else that might be 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 -~--~~~~--~~--~--~---
Naming Conventions and Case Sensitivity (Linux & Windows)
I've written a form component and helper (http://cakeforge.org/snippet/detail.php?type=package&id=17) that work fine in Windows, but when I upload them to Linux, I get an error. A variable that is being set in the component does not seem to be available in the view, when on Linux. But it works fine in Windows. I assume this is because of some case-sensitivity issue since Linux is case-sensitive. Maybe I'm making a mistake with naming conventions or using the wrong case somewhere. Can anyone see what I'm doing wrong in my declarations? /controllers//components/myform.php class MyformComponent extends Object { function startup( &$controller ) { $validations = array() ; foreach( $controller->modelNames as $model ) { $validations += $controller->$model->validate ; } $this->controller = $controller; $this->controller->set( 'formData', array( 'validations' => $validations, 'data' => $this->controller->data ) ); } } /controllers/photographers_controller.php class PhotographersController extends AppController { var $name = 'Photographers'; // for PHP4 var $helpers = array('Html', 'form', 'Myform','Javascript', 'Error'); var $components = array('Myform'); ... } /views/helpers/myform.php class MyformHelper extends FormHelper { ... } /views/photographers/add.thtml The view is where the error is - I only showed the line with the problem. Here is the error message: Notice: Undefined variable: formData in /.../app/views/photographers/add.thtml on line 12 I have debugged it enough to know that the component's startup() function is running and that $formData is getting set in the component (a pr() inside the startup function shows the $formData variable full of data), but somehow the variable $formData doesn't seem to be getting to the view in Linux. Any ideas what would be causing this? Thanks, Brandon --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Where do I put custom validators?
Thanks! That works great. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Where do I put custom validators?
In cake/libs/validators.php there are four regular expressions for validators. I would love to add to this list, but know I'm not supposed to touch anything in the cake folder. How do I add more global validator regular expressions to my app? Thanks, Brandon --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Uploaded Form Helper: FormationHelper
Wow, that is awesome. Thank you. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Uploaded Form Helper: FormationHelper
Wait - but don't I still need to send the validation rules, etc. to the view? Can you change what parameters are sent to the startup() function? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Uploaded Form Helper: FormationHelper
Oh, that's very nice! I was wondering if there was something like that. Thanks for letting me 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 -~--~~~~--~~--~--~---
Re: Uploaded Form Helper: FormationHelper
I've also been working on a similar form helper. I just uploaded it at: http://cakeforge.org/snippet/detail.php?type=snippet&id=75 It extends Cake's Form helper and also takes the validation from the model (using the advanced validation method - multiple rules per field) so you don't have to retype the validation messages or which fields are required, in your view. It's still a work in progress and requires a few other components (the advanced validator, and error helper), but maybe we can learn from each other and get a really good form helper out there. I'm all for as little typing as possible! --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Shopping Cart in CakePHP
Hmm... So can you store a component in the session? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Shopping Cart in CakePHP
I'm trying to make a simple shopping cart - just basically a way to store product id's in the session, and maybe a function that calls a view to display the cart. Should I be doing this as a regular controller, or should I make a component for it? Either way, how can I make the cart (as well as the displayCart() function, etc.) persist in the session? What is the best way to do this? Thank you, Brandon --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Components
In your component, try this: findAll ( null, null, 'Paper.modified DESC', $number ); pr($data); // This is where it will spit out the contents of the data. If you don't see anything, then you may have nothing in your database. $this->controller->set('recentpapers',$data); } } --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Automatically generating 's?
Or you could just use and float them next to each other, each with a width of 33% so there are always three in a row, but that makes it easier to expand or change later if you want to. http://www.alistapart.com/articles/practicalcss/ --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Components
You can use variables in your view, just like you did, but my guess is that $data is probably not an array. If you use a variable in a foreach() loop that is not an array, that is the error you get. Try doing: pr($data); in your controller to see what's inside. You may also want to enclose your foreach in if statements like this: No recent papers found. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Can you use beforeFilter on Helpers?
I'm creating a form helper that generates your html with all validation from the model in place (This keeps the validation rules out of your view 100%). I'm using it kind of like this: init(@$validations, @$data); ?> Property Information hidden(array('id'=>'Property/id'))?> text(array('id'=>'Property/year_built', 'attrib'=>'size="5"'))?> text(array('id'=>'Property/price', 'attrib'=>'size="10"'))?> text(array('id'=>'Property/short_title'))?> select(array('id'=>'Property/beds', 'options'=>array(0,1,2,3,4,5,6,7,8,9,10)))?> etc. But it would really simplify the writing of this class if I could use a beforeFilter on the helper, so that before each of those field functions is called (ie. text(), hidden(), select(), etc.), an initialization function would be called to set the validation rules, field parameters, etc., for the field so I don't have to do again in every function. Is this possible or should I be doing this a different way? Also, if anyone is interested in this idea of quick & simple form creation, let me know and I'll put it on the wiki or something so others can take a stab at it too. Thanks, Brandon --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Simple HABTM Question
Ha! What do you know - that was it! Thank you! --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Simple HABTM Question
Sorry for the double post there. I also tried querying by the service_name rather than the id, and that seemed to work better. I also changed the loop a little bit (because of how I'm grabbing the data in my view). This seems to work great. (Although, as you mentioned, it's not sorted) $result = $this->Contractor->Service->find("service_name = 'Web Design'"); if ($result['Contractor']) { foreach ($result['Contractor'] as $r) { $data[]['Contractor'] = $r; } $this->set('data', $data); } else { $this->set('data', Array()); } --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Simple HABTM Question
I get a very strange result when I do that. I did have to singularize the Model names as well: $result = $this->Contractor->Service->findByID($service_id); SQL Error in model Service: 1054: Unknown column 'Service.i_d' in 'where clause' The query that's run is this: SELECT `Service`.`id`, `Service`.`service_name` FROM `services` AS `Service` WHERE (`Service`.`i_d` = 2) LIMIT 1 Why is the 'id' split up like 'i_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 -~--~~~~--~~--~--~---
Simple HABTM Question
I have two tables: contractors = id first_name last_name services == id service_name Then a table to join them together in a many-to-many relationship: contractors_services === id contractor_id service_id In other words, a contractor can be associated with many services, and a service can be associated with multiple contractors. All I want is a list of all the contractors for a particular service. In regular SQL, the query would look like this: SELECT c.* FROM contractors c JOIN contractors_services cs ON cs.contractor_id = c.id WHERE cs.service_id = 2; /* Where 2 is the service_id you're looking for */ So, how do I get this to work using the Cake method? I have tried: $data = $this->Contractor->findAll('contractors_services.service_id = '.$service_id); But it doesn't like that. Look at the query it wrote, it didn't actually join the services table at all. Here is my code: class Contractor extends AppModel { var $name = 'Contractor'; var $hasAndBelongsToMany = 'Service'; } class Service extends AppModel { var $name = 'Service'; // required for php4 var $hasAndBelongsToMany = 'Contractor'; } class ContractorsController extends AppController { var $name = 'Contractors'; // for php4 var $helpers= array('Html', 'Javascript'); function index($service_id='') { // What do I need to put here to return all the contractors linked to $service_id? $data = $this->Contractor->findAll(); //'service_id = '.$service_id); $this->set('data', $data); $this->render(); } } Can anyone see what I'm doing wrong or what more I need to do to be able to get this simple query to work? Thank you, Brandon --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Multi user login
I just wrote my own using sessions. Create a users table with username and password. When they submit the form to the Users::login function, check to see if the username and password match, and if so, log them in: $this->Session->write('loggedIn', true); $this->Session->write('user_id', $user_id); Then redirect them to wherever you want them to go. When you're ready to log them out, just reverse the process $this->Session->write('loggedOut', false); $this->Session->write('user_id', false); Or something like that. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
$this->params['data'] vs. $this->data
What is the difference between $this->params['data'] and $this->data in the controller. They look like they contain the same thing. Is one deprecated? Just wondering which I should be using. 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 -~--~~~~--~~--~--~---
Re: How do I create a variable in the view to use in the layout?
Thank you. That's what I was wanting to do. Strange that you have to use $this-> and set it from the controller. But it seems to be working fine now. That will simplify things a ton with this submenu stuff. Thanks again. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: How do I create a variable in the view to use in the layout?
@AD7six: Thanks for the good info. I'll see if I can get a component/element control working submenus. Are you thinking something like: pass in a controller/action combination, and get back the appropriate submenu? @Samuel: Does that mean that if I wanted a special title for my static pages, I'd need to create an action for them in the pages controller? Or hard code the title into the display() function of the pages controller? Is just seems that titles other static display variables would be best if they could be set in the view for each page. What does that have to do with "logic"? Am I the only one that thinks this way? @Armando: Really? How did you get it to work? I wonder if they removed that functionality from the newer versions. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: acl.php doesnt seem to work
There are bugs in the latest release of acl.php Check out this post: http://groups.google.com/group/cake-php/browse_thread/thread/aa36201e1277f4cc --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: How do I create a variable in the view to use in the layout?
Wow, that's too bad. It would seem better if the view were rendered before the layout, and any variables set could apply to it. How do you set things like a page and keywords, etc., for specific pages? Do you have to set them in the controller? That doesn't seem right. And how would that work with static pages (in the /pages/) folder - how could I set the submenu variable in the controller for each of those pages when they don't each have their own action in the pages controller? I could create a controller for each main menu item, and create actions for each static page under that menu, but then I'd also need to create a model and a database table, which I don't really need. There's got to be a better way to do this seemingly common thing. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
How do I create a variable in the view to use in the layout?
I'm trying to get a site working with submenu navigation - when you click a main menu link, the submenus on the side change. Some of the pages are static (in /pages/) folder and some use controllers. I have tried assigning a variable in the view to tell it which submenu I wanted to use for this page, hoping I could it in the layout, but the layout didn't recognize it. In view.thtml In layout.thtml The submenu is: (Here I would actually check if the submenu == "buymenu" or another menu, and display the appropriate submenu items) But it says that $submenu doesn't exist in the layout. Do I have to set these variables in the controller? If so, how would I assign the variable for the static /pages/? Does anyone know of a better way to do submenus than this? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Should I use Smarty?
Good comments. I still haven't figured out in Smarty how to use the {include file=""} function, since templates are separated into separate "view" folders and aren't in a single "templates" folder like non-cake apps. Instead of include, should I be using use helpers here? What is the syntax for including another tpl file in Smarty? So, other potential disadvantages I see to Smarty are things like passing arrays (since you have to create arrays separately from the function that calls them), using Cake's AJAX functions since they use curly braces a lot - escaping those in Smarty is just extra typing - {ldelim} {rdelim} or {literal}, and possible integration issues with scaffolding or other Cake code (would I have to rewrite a lot of it in Smarty?). Does anyone else find these to be a pain, or is it worth it for the benefits? If I were using Cake, I probably would use the short tag syntax: since I just couldn't stand typing: and I'll never put my site on a server with short tags disabled. Any other thoughts? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Should I use Smarty?
I'm trying to debate whether or not to use Smarty in my cake app. I've used it a lot before and am familiar with the syntax. I like how it makes my code look cleaner, saves lots of typing, and that you can write custom functions and modifiers, etc. It also does caching. But now that Cake's templating system also does caching, and since I could use regular PHP functions in my views (as well as my own that I could write), I wonder what the trade-off is. Taking into considering things like displaying and formatting variables, looping over arrays, speed, caching, integration with AJAX (are the {} delimeters going to be annoying in Smarty?), and using helpers, etc., what are the advantages and disadvantages of both systems? Installation isn't an issue for me - I've already got Smarty working great with my cake app. I'm just wondering which is going to be better over the long haul. Any comments here? Thanks, Brandon --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---