Re: Remote Login Form - security blocking?

2008-11-12 Thread brandags

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?

2008-11-11 Thread brandags

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?

2008-11-10 Thread brandags

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');
else
   

Remote Login Form - security blocking?

2008-11-08 Thread brandags

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

2008-01-29 Thread brandags

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

2007-12-01 Thread brandags

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()?

2006-11-17 Thread brandags

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
-~--~~~~--~~--~--~---



Accessing variable in child class from app_controller's beforeFilter

2006-10-17 Thread brandags

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: Accessing variable in child class from app_controller's beforeFilter

2006-10-17 Thread brandags

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
-~--~~~~--~~--~--~---



Re: Accessing variable in child class from app_controller's beforeFilter

2006-10-17 Thread brandags

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: views controlling layouts

2006-08-08 Thread brandags

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
?php $this-variable = 'Something';?

// layout.thtml
?php echo $this-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

2006-07-25 Thread brandags

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

2006-07-10 Thread brandags

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

2006-07-07 Thread brandags

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

2006-07-04 Thread brandags

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
-~--~~~~--~~--~--~---



Dynamic Subdomains and Wildcard DNS

2006-07-03 Thread brandags

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: Dynamic Subdomains and Wildcard DNS

2006-07-03 Thread brandags

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
-~--~~~~--~~--~--~---



Re: This is a design issue.

2006-06-29 Thread brandags

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
-~--~~~~--~~--~--~---



Possible AJAX Bug in 1.1.5.3148

2006-06-29 Thread brandags

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: including an element in the head depending on which view I'm in

2006-06-29 Thread brandags

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:
?php $this-addHead .= 'This will go in the head section';?

layout.thtml:
head
?php if (isset($this-addHead)) echo $this-addHead;?
/head

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
-~--~~~~--~~--~--~---



Re: Naming Conventions and Case Sensitivity (Linux Windows)

2006-06-14 Thread brandags

@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)

2006-06-14 Thread brandags

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)

2006-06-14 Thread brandags

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)

2006-06-14 Thread brandags

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
-~--~~~~--~~--~--~---



Where do I put custom validators?

2006-06-13 Thread brandags

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: Where do I put custom validators?

2006-06-13 Thread brandags

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
-~--~~~~--~~--~--~---



Naming Conventions and Case Sensitivity (Linux Windows)

2006-06-13 Thread brandags

I've written a form component and helper
(http://cakeforge.org/snippet/detail.php?type=packageid=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
? pr($formData); ?

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: Uploaded Form Helper: FormationHelper

2006-06-12 Thread brandags

I've also been working on a similar form helper. I just uploaded it at:
http://cakeforge.org/snippet/detail.php?type=snippetid=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: Uploaded Form Helper: FormationHelper

2006-06-12 Thread brandags

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: Shopping Cart in CakePHP

2006-06-11 Thread brandags

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

2006-06-10 Thread brandags

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

2006-05-16 Thread brandags

In your component, try this:
?php
class RecentPapersComponent extends Object
{
var $name = 'RecentPapers';
var $controller = true;

function init ($number = 5)
{
$Paper = new Paper;
$data = $Paper-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: Simple HABTM Question

2006-04-25 Thread brandags

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
-~--~~~~--~~--~--~---



Re: Simple HABTM Question

2006-04-25 Thread brandags

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: Multi user login

2006-04-15 Thread brandags

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

2006-04-08 Thread brandags

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
-~--~~~~--~~--~--~---