Redirect Loop

2012-11-27 Thread Andrew Johnston
Hello-

I'm having the weirdest Cake error with my code. When the code below calls 
the add() method (also reproduced here and from a different controller), 
the code redirects him back the edit() action (in essence, to the user it 
appears as if nothing happens). To further complicate matters, when I call 
the same URL when I'm not on that page (despite the pages not being reliant 
on each other), I get redirected to the base of my app, which results in a 
redirect loop. I tried calling other methods from this controller (with 
their proper arguments) to see if this was just a problem with the add() 
action, but I get the same redirect loop.

Here is the relevant code:
 function edit($id=null) {
 if(!$id) {
 $this->Session->setFlash('Invalid!');
$this->redirect(array(
'action' => 'index')
);

 }
 else {
 //Get the slides themselves
$slides = $this->Slide->find('all', array('conditions' => 
array('Slide.module_id' => $id)));
$this->set('slides', $slides);
//Get the data for the Module
$module = $this->Module->find('first',
array(
'conditions' => array (
'Module.id' => $id
),
'fields' => array(
'Module.module_name',
'Module.id')
)
);
 }
 }
And here is the add() code (again, from a different module):
function add($module = null) {
if ($this->request->is('get')) {
//Set some variables for the view (this code I know 
works as it has been used successfully elsewhere
} 
else { //User is POSTing
$this->Slide->create();
$this->Slide->save($this->data);
}
}

Thanks to everyone in advance; I couldn't do this without your support!

Andrew

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Re: Yet another "Call to a member function find on a non-object" error

2012-11-14 Thread Andrew Johnston
I didn't post any code because any piece of code where I try to call a 
related model I get the error, but for example, here's one:

$slides = $this->Module->Slide->find('all', array('conditions' => 
array('Module.id' => $id)));

I've since changed the code to a poor workaround, so I'll change it back 
later to get a stack trace. 

On Wednesday, November 14, 2012 12:14:34 AM UTC-5, bs28723 wrote:
>
> I don't think you provided enough info for anyone to help you. 
>
> Please provide the function and point out the line that is getting the 
> error. 
>
> Thanks,
> Bill Stoltz
>
> On Nov 13, 2012, at 10:31 PM, "Andrew Johnston [via CakePHP]" <[hidden 
> email] <http://user/SendEmail.jtp?type=node&node=5712254&i=0>> wrote:
>
> I know this post gets written every couple of months, and I swear that 
> I've read through all of the back posts, yet can't find a solution that 
> works.
>
> Whenever I try to call related data from one of my models, I get the above 
> error. Below is the relationship code for each model.
>
> class Slide extends AppModel {
> public $name = 'Slide';
> public $belongsTo =  array(
> 'Module' => array(
> 'className' => 'Module',
> 'foreignKey' => 'module_id',
> ));
>
> class Module extends AppModel {
> public $name = 'Module';
> public $hasMany = array(
> 'Slide' => array(
> 'className'  => 'Slide',
> 'foreignKey' => 'module_id',
> 'order' => 'Slide.position ASC',
> 'dependent' => true
> )
> );
> public $belongsTo = array(
> 'Creator' => array(
> 'className' => 'User')); 
> public $hasAndBelongsToMany = array(
> 'Learner' => array(
>'className'  => 'User',
>'joinTable'  => 'modules_users',
>'foreignKey' => 'module_id',
>'associationForeignKey'  => 'users_id',
>'unique' => 'keepExisting',
> )); 
>
> class User extends AppModel {
> public $name = 'User';
> public $uses = 'users';
> public $hasMany = array(
> 'OModule' => array(
> 'className' => 'Module',
> 'foreignKey' => 'users_id',
> 'order' => 'Module.created DESC'
> ));
> public $hasAndBelongsToMany = array(
> 'Module' => array( //We gotta remember this later...
>'className'  => 'Module',
>'joinTable'  => 'modules_users',
>'foreignKey' => 'user_id',
>'associationForeignKey'  => 'module_id',
>'unique' => 'keepExisting',
> ));
>
> I've tried to adhere to all of the requirements outlined in the CookBook, 
> but I know I must be doing something wrong. Any help is appreciated. Thanks 
> in advance.
>
> Andrew
>
> -- 
> Like Us on FaceBook https://www.facebook.com/CakePHP
> Find us on Twitter http://twitter.com/CakePHP
>  
> --- 
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to [hidden 
> email]<http://user/SendEmail.jtp?type=node&node=5712251&i=0>
> .
> To unsubscribe from this group, send email to [hidden 
> email]<http://user/SendEmail.jtp?type=node&node=5712251&i=1>
> .
> Visit this group at http://groups.google.com/group/cake-php?hl=en.
>  
>  
>
>
> --
>  If you reply to this email, your message will be added to the discussion 
> below:
>
> http://cakephp.1045679.n5.nabble.com/Yet-another-Call-to-a-member-function-find-on-a-non-object-error-tp5712251.html
>  
>  To start a new topic under CakePHP, email [hidden 
> email]<http://user/SendEmail.jtp?type=node&node=5712254&i=1> 
> To unsubscribe from CakePHP, click here.
> NAML<http://cakephp.1045679.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>  
>
>
> --
> View this message in context: Re: Yet another "Call to a member function 
> find on a non-object" 
> error<http://cakephp.1045679.n5.nabble.com/Yet-another-Call-to-a-member-function-find-on-a-non-object-error-tp5712251p5712254.html>
> Sent from the CakePHP mailing list 
> archive<http://cakephp.1045679.n5.nabble.com/>at Nabble.com.
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Yet another "Call to a member function find on a non-object" error

2012-11-13 Thread Andrew Johnston
I know this post gets written every couple of months, and I swear that I've 
read through all of the back posts, yet can't find a solution that works.

Whenever I try to call related data from one of my models, I get the above 
error. Below is the relationship code for each model.

class Slide extends AppModel {
public $name = 'Slide';
public $belongsTo =  array(
'Module' => array(
'className' => 'Module',
'foreignKey' => 'module_id',
));

class Module extends AppModel {
public $name = 'Module';
public $hasMany = array(
'Slide' => array(
'className'  => 'Slide',
'foreignKey' => 'module_id',
'order' => 'Slide.position ASC',
'dependent' => true
)
);
public $belongsTo = array(
'Creator' => array(
'className' => 'User')); 
public $hasAndBelongsToMany = array(
'Learner' => array(
   'className'  => 'User',
   'joinTable'  => 'modules_users',
   'foreignKey' => 'module_id',
   'associationForeignKey'  => 'users_id',
   'unique' => 'keepExisting',
)); 

class User extends AppModel {
public $name = 'User';
public $uses = 'users';
public $hasMany = array(
'OModule' => array(
'className' => 'Module',
'foreignKey' => 'users_id',
'order' => 'Module.created DESC'
));
public $hasAndBelongsToMany = array(
'Module' => array( //We gotta remember this later...
   'className'  => 'Module',
   'joinTable'  => 'modules_users',
   'foreignKey' => 'user_id',
   'associationForeignKey'  => 'module_id',
   'unique' => 'keepExisting',
));

I've tried to adhere to all of the requirements outlined in the CookBook, 
but I know I must be doing something wrong. Any help is appreciated. Thanks 
in advance.

Andrew

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Re: Multiple Database relations (HABTM and HasMany)?

2012-08-20 Thread Andrew Johnston
I won't write out the models (too tired), but I'll give you the DB 
structure and you can base the models off that:
Table: users
id (primary key)
username
pass

Table: tasks
id (primary key)
user_id  <--- This is the user that created the task

Table users_tasks
id (primary key)
user_id
task_id

This way, given a certain task you can find the creator and all of the 
people assigned to the task. 

On Sunday, August 19, 2012 8:50:52 PM UTC-4, InJu wrote:
>
> Hi everybody,
>
> this my first time working with CakePHP and my first big PHO project as 
> well.
>
> I want to build the Model associations between a User and Task database. 
> Every user has many tasks and a task can be linked to many users. As I 
> understand HABTM-Relations this should be one. But I also want to save the 
> User who created the task. This is a hasMany relation. My question is now, 
> how does the models for Users and Tasks look like?
>
> Thanks in advance!
>

-- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.




Re: My auth plugin doesn't protect the rest of my application

2012-08-20 Thread Andrew Johnston
If you add a check for your Plugin's authentication in the beforeFilter() 
callback of your controllers it should address the problem.

On Monday, August 20, 2012 8:19:25 PM UTC-4, andrewperk wrote:
>
> Hello,
>
> I've created a plugin which handles authentication(using Auth component) 
> for my projects. The plugin authentication works inside of the plugin 
> itself but it does not authenticate or protect any of my controller/actions 
> outside of the plugin.
>
> For instance my plugin:
>
> /app/Plugin/Logger
>
> The Auth component protects everything inside of the Logger plugin and all 
> of its controllers/actions. But inside of my regular app:
>
> /app/Controller/ExercisesController
>
> This controller and all other controllers in my /app act as if there is no 
> Auth being applied. I'm thinking I need to link it through my AppController 
> but I'm not sure how to make that work with my Plugin which has Auth config 
> already defined in it. Won''t that override my Plugin Auth settings?
>
> How can I make my app recognize and use my Plugin's authentication?
>
> Thanks,
>
> Andrew
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.




Re: PHPUnit Fixture Failure

2012-08-20 Thread Andrew Johnston
Yes, the user does. It has all privileges.

On Monday, August 20, 2012 4:33:34 PM UTC-4, Jeremy Burns wrote:
>
> Does the test user have full access to the database (including create and 
> drop)?
>
> Jeremy Burns
> Class Outfit
>
> http://www.classoutfit.com 
>
> On 20 Aug 2012, at 20:38:14, Andrew Johnston 
> > 
> wrote:
>
> Hello everyone-
>
> I started testing my application with PHPUnit. All of the built in 
> tests succeed, but the test I created failed with the following error:
>
> SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error 
> in your SQL syntax; check the manual that corresponds to your MySQL server 
> version for the right syntax to use near '' at line 1
> Test case: UserTest(testCheck)
> I can't figure out the error; I tried basing my fixture and test case off 
> of the Cookbook. What is causing the error? How can I fix it?
>
> To help you help me, I've attached the relevant code.  Thanks in Advance!
>
> -- 
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake...@googlegroups.com
> .
> To unsubscribe from this group, send email to 
> cake-php+u...@googlegroups.com .
> Visit this group at http://groups.google.com/group/cake-php?hl=en-US.
>  
>  
> 
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.




PHPUnit Fixture Failure

2012-08-20 Thread Andrew Johnston
Hello everyone-

I started testing my application with PHPUnit. All of the built in 
tests succeed, but the test I created failed with the following error:

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error 
in your SQL syntax; check the manual that corresponds to your MySQL server 
version for the right syntax to use near '' at line 1
Test case: UserTest(testCheck)
I can't figure out the error; I tried basing my fixture and test case off 
of the Cookbook. What is causing the error? How can I fix it?

To help you help me, I've attached the relevant code.  Thanks in Advance!

-- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.


<>
<>
<>


Get Data about Current Page

2012-07-23 Thread Andrew Johnston
How would I get data for a current view? For example, if I had the page:
http://example.com/view/2

and I wanted to link to:

http://example.com/view/3

How would I do that? I don't use Paginator. 

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Two tables with multiple relationships

2012-07-17 Thread Andrew Johnston
Hello Again Everyone-

I'm having a bit of trouble establishing my databases. To sum up my 
application, it allows users to make modules which then can be viewed by 
other users of the creator's choice. 

So I have:

User hasMany Module <-- This is where I place the user id number of the 
creator of the module
Module belongsTo User
User HABTM Module <-- This table is only for those who are allowed to view 
the module, but don't own it

But I feel that this isn't the right way to do it. How should I implement 
this?

Is it possible to do this solely in ACL? If so, how?

Thanks to everyone in advance for their help!

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Login Forms

2012-07-13 Thread Andrew Johnston
Thanks Steve, but that doesn't quite answer my question. Can home.ctp be a 
login page? As it has no controller I don't know where I could put the Auth 
components. 

Andrew

On Friday, July 13, 2012 7:42:27 AM UTC-4, Steve wrote:
>
> You can use a Eagle User Management Plugin that gives Login options. I am 
> using a great Plugin original cost $197 , now at an offer price of 30$ 
> which gives Login with FB, Twitter, Foursquare, LinkedIn, Google, Yahoo and 
> it has 56 more features. Check website http://www.eagle.getyourplugin.com
>
> On Friday, July 13, 2012 2:29:47 AM UTC+5:30, Andrew Johnston wrote:
>>
>> Hello Everyone-
>>
>> I'm new to CakePHP and I'm a bit confused with the idea of login forms. 
>> I've read just about every page I could find on the issue, but none of them 
>> seemed to mirror my problem exactly. 
>>
>> I'm using Wordpress for the static portion of my site and I wanted to 
>> have a link that said "Login". Upon clicking the link it would take the 
>> user to a form with the standard email/password boxes. When the user 
>> submitted the data, only then would it pass it over solely to the web app, 
>> which would verify the user, log them in, and redirect them to the home 
>> page of the web app. Is this possible?
>>
>> Follow up question: If it would be easier/possible, can I modify my 
>> home.ctp to be a login form? If so, how?
>>
>> Thank you everyone for bearing with me as I struggle through this. I love 
>> Cake and it really is making my job easier! 
>>
>

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Login Forms

2012-07-13 Thread Andrew Johnston
Hello Everyone-

I'm new to CakePHP and I'm a bit confused with the idea of login forms. 
I've read just about every page I could find on the issue, but none of them 
seemed to mirror my problem exactly. 

I'm using Wordpress for the static portion of my site and I wanted to have 
a link that said "Login". Upon clicking the link it would take the user to 
a form with the standard email/password boxes. When the user submitted the 
data, only then would it pass it over solely to the web app, which would 
verify the user, log them in, and redirect them to the home page of the web 
app. Is this possible?

Follow up question: If it would be easier/possible, can I modify my 
home.ctp to be a login form? If so, how?

Thank you everyone for bearing with me as I struggle through this. I love 
Cake and it really is making my job easier! 

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php