CakePHP3: ErrorController, beforeRender and view variables

2014-12-06 Thread Oli
Hi all, giving CakePHP3 a spin and loving it, but there's something that's 
stumped me

In CakePHP2, as far as I can tell, the ErrorController extended 
AppController and executed the beforeRender method of the AppController, 
ensuring any view variables needed for the layout were set and that Errors 
displayed correctly.

In CakePHP3, it seems that the ErrorController no longer extends from 
AppController, and thus the beforeRender method of AppController doesn't 
get called, but the default template is still used. This leaves a large 
amount of variables unset, with no obvious way to set them, as far as I can 
tell? 

It's likely I'm missing something obvious here, so would greatly appreciate 
any help!

Cheers,

Oli

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

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: How do I read and write session variables in CakePHP 3?

2014-12-01 Thread frocco
Thanks, my eyes are tired. :)

On Monday, December 1, 2014 8:51:34 PM UTC-5, rchavik wrote:
>
>
>
> On Tuesday, December 2, 2014 7:59:40 AM UTC+7, frocco wrote:
>>
>> $session = $this->request->session();
>> $session()->write('Search.category', $catid);
>>
>> $value $session->read('Search.category');
>>
>> syntax error, unexpected '$session' (T_VARIABLE) 
>>
>> What is wrong?
>>
>
> You are missing a '='. 
>

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

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: How do I read and write session variables in CakePHP 3?

2014-12-01 Thread rchavik


On Tuesday, December 2, 2014 7:59:40 AM UTC+7, frocco wrote:
>
> $session = $this->request->session();
> $session()->write('Search.category', $catid);
>
> $value $session->read('Search.category');
>
> syntax error, unexpected '$session' (T_VARIABLE) 
>
> What is wrong?
>

You are missing a '='. 

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

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


How do I read and write session variables in CakePHP 3?

2014-12-01 Thread frocco
$session = $this->request->session();
$session()->write('Search.category', $catid);

$value $session->read('Search.category');

syntax error, unexpected '$session' (T_VARIABLE) 

What is wrong?

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

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: Is there a way to put request variables in paginate class property?

2014-11-30 Thread Matt Murphy
You're on the right track with the second code bit.. but i'd abstract that
assignment into its own controller method and then call that from whatever
action you need it set -- or if the request params are avaialble early
enough (i don't know -- i don't do automagical platforms these days -- I'm
on ZF2) then call it on __invoke or __constructor or something.

On Sun, Nov 30, 2014 at 4:23 PM, Sam Clauw  wrote:

> I want to sort an array of data in my index action and one condition
> depends on the id given by the request object (attraction_id). Is there a
> way to set up the paginate component as a controller class method (see
> under)?
>
> 
> class AttractionCommentsController extends CoasterCmsAppController
> {
> public $paginate = array(
> 'AttractionComment' => array(
> 'conditions' => array(
> 'Attraction.id' => *$this*
> *->request->params['named']['attraction_id'**]*,
> 'AttractionComment.deleted' => null
> ),
> 'order' => array(
> 'AttractionComment.created' => 'DESC',
> 'AttractionComment.id' => 'ASC'
> ),
> 'limit' => 15
> )
> );
>
> public function index()
> {
> $this->Paginator->settings = $this->paginate;
>
> $comments = $this->Paginator->paginate('AttractionComment');
>
> $this->set('comments', $comments);
> }
>
> ?>
>
>
> The above code can't handle the request variable (*$this*
> *->request->params['named']['attraction_id'**])* within the class method.
> So... is there a solution for this or is it required to drop the class
> property and do something like this:
>
> 
> class AttractionCommentsController extends CoasterCmsAppController
> {
> public function index()
> {
>
> $this->Paginator->settings = array(
> 'AttractionComment' => array(
> 'conditions' => array(
> 'Attraction.id' => $this->request->params['named'][
> 'attraction_id'],
> 'AttractionComment.deleted' => null
> ),
> 'order' => array(
> 'AttractionComment.created' => 'DESC',
> 'AttractionComment.id' => 'ASC'
> ),
> 'limit' => 15
> )
> );
> $comments = $this->Paginator->paginate('AttractionComment');
>
> $this->set('comments', $comments);
> }
>
> ?>
>
> Thx 4 helping!
>
> --
> Like Us on FaceBook https://www.facebook.com/CakePHP
> Find us on Twitter http://twitter.com/CakePHP
>
> ---
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to cake-php+unsubscr...@googlegroups.com.
> To post to this group, send email to cake-php@googlegroups.com.
> Visit this group at http://groups.google.com/group/cake-php.
> For more options, visit https://groups.google.com/d/optout.
>

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

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Is there a way to put request variables in paginate class property?

2014-11-30 Thread Sam Clauw
I want to sort an array of data in my index action and one condition 
depends on the id given by the request object (attraction_id). Is there a 
way to set up the paginate component as a controller class method (see 
under)?

 array(
'conditions' => array(
'Attraction.id' => *$this*
*->request->params['named']['attraction_id'**]*,
'AttractionComment.deleted' => null
),
'order' => array(
'AttractionComment.created' => 'DESC',
'AttractionComment.id' => 'ASC'
),
'limit' => 15
)
);

public function index()
{
$this->Paginator->settings = $this->paginate;

$comments = $this->Paginator->paginate('AttractionComment');

$this->set('comments', $comments);
}

?>


The above code can't handle the request variable (*$this*
*->request->params['named']['attraction_id'**])* within the class method.
So... is there a solution for this or is it required to drop the class 
property and do something like this:

Paginator->settings = array(
'AttractionComment' => array(
'conditions' => array(
'Attraction.id' => $this->request->params['named'][
'attraction_id'],
'AttractionComment.deleted' => null
),
'order' => array(
'AttractionComment.created' => 'DESC',
'AttractionComment.id' => 'ASC'
),
'limit' => 15
)
); 
$comments = $this->Paginator->paginate('AttractionComment');

$this->set('comments', $comments);
}

?>

Thx 4 helping!

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

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: 3.0 - Getting variables into anonymous functions

2014-06-02 Thread Dakota
I was on my mobile at the time of posting the reply, otherwise I'd have 
given you an example as well :) Glad I could help!

On Tuesday, 3 June 2014 07:17:58 UTC+2, Reuben wrote:
>
> Oh, that's handy.  As you can see, I've zero experience in anonymous 
> functions.
>
> For those at home:
>
> $name = 'CakePHP';
>
> $query = $articles->find();
>
> $query->matching('Tags', function($q) use ($name){
> return $q->where(['Tags.name' => $name]);});
>
>
> On Tuesday, 3 June 2014 14:45:14 UTC+10, Dakota wrote:
>>
>> Use the use statement. See 
>> http://www.php.net/manual/en/functions.anonymous.php example 3 for an 
>> example.
>
>

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

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: 3.0 - Getting variables into anonymous functions

2014-06-02 Thread Reuben
Oh, that's handy.  As you can see, I've zero experience in anonymous 
functions.

For those at home:

$name = 'CakePHP';

$query = $articles->find();

$query->matching('Tags', function($q) use ($name){
return $q->where(['Tags.name' => $name]);});


On Tuesday, 3 June 2014 14:45:14 UTC+10, Dakota wrote:
>
> Use the use statement. See 
> http://www.php.net/manual/en/functions.anonymous.php example 3 for an 
> example.

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

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


3.0 - Getting variables into anonymous functions

2014-06-02 Thread Dakota
Use the use statement. See http://www.php.net/manual/en/functions.anonymous.php 
example 3 for an example.

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

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


3.0 - Getting variables into anonymous functions

2014-06-02 Thread Dakota
Use the use statement. See http://www.php.net/manual/en/functions.anonymous.php 
example 3 for an example.

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

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


3.0 - Getting variables into anonymous functions

2014-06-02 Thread Reuben
Hi

In the example from the CakePHP 3 Book, how would one replace 'CakePHP' 
with a variable (i.e. $name), and have that passed from the calling code?

Would is be via a call back, or property set on the $query, and accessible 
via $q?


$query = $articles->find();$query->matching('Tags', function($q) {
return $q->where(['Tags.name' => 'CakePHP']);});

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

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: Automatically Serialize All View Variables

2013-10-28 Thread euromark
Why not making this a clean component or custom View class, e.g. 
SerializeView etc?
Hacking this in the AppController (which should stay lean) doesnt sound 
right to me.
Also, re-usability is not very good this way.

And don't use private, use protected :P


Am Montag, 28. Oktober 2013 01:50:38 UTC+1 schrieb Matt Bowden:
>
> No question here, just thought I'd share a solution to a problem I needed 
> to solve.
>
> I'm working on a decoupled application where the back-end is all CakePHP 
> and the front-end is all Javascript. The front-end communicates with the 
> back-end as a RESTful API. I could write a handful of posts in here about 
> some of the problems I ran into, but right now, I just want to share a 
> trick I developed with serializing view variables.
>
> I use jQuery AJAX functions to get json from CakePHP. I got tired of 
> writing this all over my controllers:
>
> $this->set('_serialize', array('omg', 'so' 'many', 'view', 'vars'));
>
> So I decided to automatically serialize all my view variables in my app 
> controller's beforeRender callback. (beforeRender is called after all the 
> application logic is finished, right before the view is rendered. Good name 
> for it huh?)
>
> // AppController.php
> public function beforeRender(){
>
> // When setting _serialize, you pass in a list of variable names.
>
> // array_keys($this->viewVars) returns an array of the names of the view 
> variables 
>
> $this->set('_serialize', array_keys($this->viewVars));
>
> }
>
> That works, but if I need a way to ignore some view variables, I would 
> have to do something a little more elaborate.
>
> // AppController.php
> public function beforeRender(){
>
> // When setting _serialize, you pass in a list of variable names.
> // array_keys($this->viewVars) returns an array of the names of the view 
> variables
>
> $viewVars = array_keys($this->viewVars);
>
>  
>
> // I include _serialize to prevent the possibility of a _serialize inside 
> another _serialize 
>
> $varsToIgnore = array('_serialize', 'debugToolbarPanels', 
> 'varThatOnlyAppliesToBackEnd');
>
>  
>
> foreach($varsToIgnore as $varToIgnore){
>
> // Might be a better way of doing this, but it works and seems safe
>
> // in_array checks if a value exists in an array
>
> // unset removes an array or array index in this case
>
> // array_search returns the index of where a value is found 
>
> if(in_array($varToIgnore, $viewVars)) 
> unset($viewVars[array_search($varToIgnore, $viewVars)]);
>
> }
>
>  
>
> // Reindex the viewVars array after removing variables from above
>
> // I don't know if this is really necessary, but I did it anyway.
>
> $viewVars = array_values($viewVars);
>
>  
>
> $this->set('_serialize', $viewVars);
>
> }
>
> My beforeRender method is getting a little too long for my liking, so I 
> decided to clean it up a bit, by moving the variables to ignore into a 
> private property and the logic to serialize the view variables into its own 
> private method.
>
> // AppController.php
> // A shorter name would be easier to type
> private var $viewVariablesNotToSerialize = array('_serialize', 
> 'debugToolbarPanels', 'varThatOnlyAppliesToBackEnd');
>
> public function beforeRender(){
>
> $this->__serializeViewVars();
>
> }
>
> private function __serializeViewVars(){
>
> // When setting _serialize, you pass in a list of variable names.
> // array_keys($this->viewVars) returns an array of the names of the view 
> variables
>
> $viewVars = array_keys($this->viewVars);
>
>  
>
> foreach($this->__viewVarsNotToSerialize as $varToIgnore){
>
> // Might be a better way of doing this, but it works and seems safe
>
> // in_array checks if a value exists in an array
>
> // unset removes an array or array index in this case
>
> // array_search returns the index of where a value is found 
>
> if(in_array($varToIgnore, $viewVars)) 
> unset($viewVars[array_search($varToIgnore, $viewVars)]);
>
> }
>
>  
>
> // Reindex the viewVars array after remove variables from above
>
> // I don't know if this is really necessary, but I did it anyway. 
>
> $viewVars = array_values($viewVars);
>
>  
>
> $this->set('_serialize', $viewVars); 
>
> }
>
> I hope someone finds this useful.
>
> Matt Bowden
> Web Application Developer
> Skybrick
>

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

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.


Automatically Serialize All View Variables

2013-10-28 Thread Matt Bowden
No question here, just thought I'd share a solution to a problem I needed 
to solve.

I'm working on a decoupled application where the back-end is all CakePHP 
and the front-end is all Javascript. The front-end communicates with the 
back-end as a RESTful API. I could write a handful of posts in here about 
some of the problems I ran into, but right now, I just want to share a 
trick I developed with serializing view variables.

I use jQuery AJAX functions to get json from CakePHP. I got tired of 
writing this all over my controllers:

$this->set('_serialize', array('omg', 'so' 'many', 'view', 'vars'));

So I decided to automatically serialize all my view variables in my app 
controller's beforeRender callback. (beforeRender is called after all the 
application logic is finished, right before the view is rendered. Good name 
for it huh?)

// AppController.php
public function beforeRender(){

// When setting _serialize, you pass in a list of variable names.

// array_keys($this->viewVars) returns an array of the names of the view 
variables 

$this->set('_serialize', array_keys($this->viewVars));

}

That works, but if I need a way to ignore some view variables, I would have 
to do something a little more elaborate.

// AppController.php
public function beforeRender(){

// When setting _serialize, you pass in a list of variable names.
// array_keys($this->viewVars) returns an array of the names of the view 
variables

$viewVars = array_keys($this->viewVars);

 

// I include _serialize to prevent the possibility of a _serialize inside 
another _serialize 

$varsToIgnore = array('_serialize', 'debugToolbarPanels', 
'varThatOnlyAppliesToBackEnd');

 

foreach($varsToIgnore as $varToIgnore){

// Might be a better way of doing this, but it works and seems safe

// in_array checks if a value exists in an array

// unset removes an array or array index in this case

// array_search returns the index of where a value is found 

if(in_array($varToIgnore, $viewVars)) 
unset($viewVars[array_search($varToIgnore, $viewVars)]);

}

 

// Reindex the viewVars array after removing variables from above

// I don't know if this is really necessary, but I did it anyway.

$viewVars = array_values($viewVars);

 

$this->set('_serialize', $viewVars);

}

My beforeRender method is getting a little too long for my liking, so I 
decided to clean it up a bit, by moving the variables to ignore into a 
private property and the logic to serialize the view variables into its own 
private method.

// AppController.php
// A shorter name would be easier to type
private var $viewVariablesNotToSerialize = array('_serialize', 
'debugToolbarPanels', 'varThatOnlyAppliesToBackEnd');

public function beforeRender(){

$this->__serializeViewVars();

}

private function __serializeViewVars(){

// When setting _serialize, you pass in a list of variable names.
// array_keys($this->viewVars) returns an array of the names of the view 
variables

$viewVars = array_keys($this->viewVars);

 

foreach($this->__viewVarsNotToSerialize as $varToIgnore){

// Might be a better way of doing this, but it works and seems safe

// in_array checks if a value exists in an array

// unset removes an array or array index in this case

// array_search returns the index of where a value is found 

if(in_array($varToIgnore, $viewVars)) 
unset($viewVars[array_search($varToIgnore, $viewVars)]);

}

 

// Reindex the viewVars array after remove variables from above

// I don't know if this is really necessary, but I did it anyway. 

$viewVars = array_values($viewVars);

 

$this->set('_serialize', $viewVars); 

}

I hope someone finds this useful.

Matt Bowden
Web Application Developer
Skybrick

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

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Why isn't $this->Auth->user() passing all of the variables?

2013-03-18 Thread lowpass
Had you changed the table schema at some point? Try deleting the files
in app/tmp/cache/models if this is still happening.

On Thu, Mar 14, 2013 at 7:10 PM, Charley Bodkin  wrote:
> Some additional info: If a user logins in then logs out, the information is
> indeed pulled from the database. Just not on the first login.
>
> --
> Like Us on FaceBook https://www.facebook.com/CakePHP
> Find us on Twitter http://twitter.com/CakePHP
>
> ---
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to cake-php+unsubscr...@googlegroups.com.
> To post to this group, send email to cake-php@googlegroups.com.
> Visit this group at http://groups.google.com/group/cake-php?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

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

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Why isn't $this->Auth->user() passing all of the variables?

2013-03-17 Thread godjen99
Normally it's setup in the AppControler, but it can be defined per 
controller as well.

You should have something set up like this - about half way down the page. Auth 
Docs

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

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Why isn't $this->Auth->user() passing all of the variables?

2013-03-17 Thread Charley Bodkin
Would that be the UserController file?

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

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Why isn't $this->Auth->user() passing all of the variables?

2013-03-17 Thread godjen99
Could you post your Auth component setup code?

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

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Why isn't $this->Auth->user() passing all of the variables?

2013-03-14 Thread Charley Bodkin
Some additional info: If a user logins in then logs out, the information is 
indeed pulled from the database. Just not on the first login.

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

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Why isn't $this->Auth->user() passing all of the variables?

2013-03-14 Thread Charley Bodkin


Hey guys, I have a user stored in a database like so:


Now, in the AppController, I am trying to store whats in the table to a 
variable like this:

$this->set("currentUser", $this->Auth->user());  

My problem is that the only things beings passed are the facebook_id, the 
id, password, created and modified times, and nothing else like so:



What's going on? Why aren't the first names, the last names, the emails, or 
any of the location data being passed? Any ideas?

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

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Auth Redirect and GET Variables

2013-02-18 Thread Thomas Belknap
If this topic is covered specifically on these forums or elsewhere, I'm not 
finding it. 

The problem is: I'm using a URL for a component of my site that looks like 
this:
http://example.com/carts/weblines?co=1234567890

This is an operation that only authenticated users can perform. So, if 
they're not yet authenticated, they get redirected to the login form. Upon 
successful login, CakePHP should be redirecting them back to where they 
came from.

Which it is, after a fashion. However, it is dropping the GET variables off 
the end of the URL. Is there a way to prevent this from happening?

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

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Auth component doesn't set session variables !

2012-11-10 Thread SPH92
I have the same problem,

and change the order of components, but nothing change.

if i put $this->Session->read(); , it's work but display a message error 
for regenerate_id session

public function login() {
if ($this->request->is('post')) {
//$this->Session->read();
if ($this->Auth->login()) {
$this->redirect($this->Auth->redirect());

Le jeudi 31 mars 2011 21:11:28 UTC+2, damien durant a écrit :
>
> i will try.
>
> In fact it's strange. Because i don't touch anything and it works from my 
> home computers.
> It doesn't from my work, maybe because of proxy setting but it's weird.
>
> On Thu, Mar 31, 2011 at 8:42 PM, cricket 
> > wrote:
>
>> On Thu, Mar 31, 2011 at 10:43 AM, damien d 
>> > 
>> wrote:
>> > Hi,
>> >
>> > I have trouble with the Auth component.
>> >
>> > I try something really simple :
>> >  - I create a user db (with name,password field)
>> >  - I use a appcontroler with this code :
>> >
>> > var $components = array("Session","Auth");
>> >function beforeFilter() {
>> >$this->Auth->fields = array('username' => 'name',
>> > 'password' => 'password');
>> >$this->Auth->loginAction = array('controller' =>
>> > 'users', 'action' => 'login');
>> >$this->Auth->loginRedirect = array('controller' => 
>> 'discs', 'action'
>> > => 'hello');
>> >$this->Auth->logoutRedirect = '/';
>> >$this->Auth->loginError = 'Invalid name / password
>> > combination.  Please try again';
>> >}
>> >
>> >  - I got a classic login.ctp
>> >  - and in my discs_controller :
>> >
>> > function beforeFilter() {
>> >$this->Auth->allow("*");
>> >parent::beforeFilter();
>> >}
>> >
>> >
>> > The issue is, when i log through the login page, i am correctly
>> > redirected, but on the redirect page the Auth variable aren't set.
>> > Here is the content of $session->read() on hello.ctp, after login.
>> > ($session->read('Auth.User') is empty);
>> >
>> > Array ( [Config] => Array ( [userAgent] => [time] => 1301618408
>> > [timeout] => 10 ) )
>> >
>> >
>> > I see there is some trouble with some fix on the net so i :
>> >  - Configure::write('Session.checkAgent', false);
>> >  - Configure::write('Security.level', 'low');
>> > in core.php but without any success.
>>
>> Try putting Auth before Session in the $components array.
>>
>> --
>> 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+u...@googlegroups.com  For more options, visit 
>> this group at http://groups.google.com/group/cake-php
>>
>
>
>
> -- 
> Damien Durant
>  

-- 
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: Passing variables between AppController and Models / Access Auth data in Models

2012-11-06 Thread Nir Regev
Works perfect !
Thanks :)

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

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To 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: Passing variables between AppController and Models / Access Auth data in Models

2012-11-06 Thread LipeDjow
If you're using CakePHP 2.0+, use AuthComponent::user() static method.

$queryData['conditions']['customer_id'] = 
AuthComponent::user('customer_id');

Em segunda-feira, 5 de novembro de 2012 22h14min48s UTC-2, Nir Regev 
escreveu:
>
> Hi all !
>
> I need to implement a little complex user permissions over data in tables :
>
> relations are similar to the following :
>
> - user belongs to a customer
> - book belongs to a customer
>
> In order to keep it DRY and "fat model / slim controller", I thought I 
> could just add something like :
>
> // Book Model
> $queryData['conditions']['customer_id']=$this->Auth->User['customer_id'];
>
> But, I don't get how to access Auth parameters from the models.
>
> The only way I found to pass this barrier is to send the user's 
> customer_id via the $_SESSION which is quite .. err .. ugly :)
>
> Any suggestions on how to pass parameters to all models ?
>
> Note that I need the customer_id available for all models, not just "Book" 
> ..
>

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




Passing variables between AppController and Models / Access Auth data in Models

2012-11-05 Thread Nir Regev
Hi all !

I need to implement a little complex user permissions over data in tables :

relations are similar to the following :

- user belongs to a customer
- book belongs to a customer

In order to keep it DRY and "fat model / slim controller", I thought I 
could just add something like :

// Book Model
$queryData['conditions']['customer_id']=$this->Auth->User['customer_id'];

But, I don't get how to access Auth parameters from the models.

The only way I found to pass this barrier is to send the user's customer_id 
via the $_SESSION which is quite .. err .. ugly :)

Any suggestions on how to pass parameters to all models ?

Note that I need the customer_id available for all models, not just "Book" 
..

-- 
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: Using function config() fails to define PHP variables

2012-10-20 Thread Vanja Dizdarević
>From cake docs:

Config folder:
> Holds the (few) configuration files CakePHP uses. Database connection
> details, bootstrapping, core configuration files and more should be stored
> here.


So, I think config() is really not meant to be used in Views. If you just
need a way of reusing some variables inside views, you should use the
solution I described earlier.

Every time you have content (or logic) repeating in many views, you should
also consider using a view element or view helper.

That being said, config() function uses "include_once" internally, which
means that it will be included only the first time any of these views are
rendered. Since the current variable scope is different for each view,
calling config('myForms') will fail to load these variables, except the
first time you call it.

So, your options are:

   - In AppController::beforeRender() - set the vars with
   $this->set('myForms', array(...))
   - Make a Helper
   - Make an Element
   - Write/Read it with Configure class

-- 
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: Using function config() fails to define PHP variables

2012-10-20 Thread glk
Sorry, I didn't specify this earlier.  I'm trying to use the function 
described in the docs at: 

   - Core Libraries <http://book.cakephp.org/2.0/en/core-libraries.html>
  - General 
Purpose<http://book.cakephp.org/2.0/en/core-libraries/toc-general-purpose.html>
 - Global Constants and 
Functions<http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html>
  

config()

Can be used to load files from your application config-folder via 
include_once. Function checks for existence before include and returns 
boolean. Takes an optional number of arguments.

Example: config('some_file', 'myconfig');
Just seems odd that the variables are not visible outside of the "included" 
php module.  Yes, the variables are only necessary within the views..  I 
was just wondering *why*?


-- 
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: Using function config() fails to define PHP variables

2012-10-19 Thread Vanja Dizdarević
WHICH config() function are you using?

You might want to see the Configure:: read/write 
methods<http://book.cakephp.org/2.0/en/development/configuration.html#configure-class>or
 Configure 
class - loading configuration 
files<http://book.cakephp.org/2.0/en/development/configuration.html#loading-configuration-files>
.

If you need these only for views, your could maybe use
  $this->set('commonVars', array('something'=>'somethingelse')) 

inside your appController's beforeRender() function and then access these 
vars from

$commonVars['something']

Inside all of your views.

On Thursday, October 18, 2012 8:23:02 PM UTC+2, glk wrote:
>
> I need the same variables in every view (with a form) and tried using 
> the config() function to read the file from the Config folder.  It is 
> read in just fine, and I can generate output from the config file 
> (e.g. debug($variable)).  However, after the loading of the file, none 
> of the variables are defined within the view.  In other words, the 
> $variable is not defined outside of the included file itself. 
>
> If I change the use of config() to be an include_once(APP. 'Config' . 
> DS . 'form_input_params.php') everything works just fine. 
>
> What am I missing here? 
>
> Thanks in advance for any ideas, 
>

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




Using function config() fails to define PHP variables

2012-10-18 Thread glk
I need the same variables in every view (with a form) and tried using
the config() function to read the file from the Config folder.  It is
read in just fine, and I can generate output from the config file
(e.g. debug($variable)).  However, after the loading of the file, none
of the variables are defined within the view.  In other words, the
$variable is not defined outside of the included file itself.

If I change the use of config() to be an include_once(APP. 'Config' .
DS . 'form_input_params.php') everything works just fine.

What am I missing here?

Thanks in advance for any ideas,

-- 
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: How can I Show my Database Global Variables and Full Process List?

2012-08-29 Thread lowpass
Works for me:

$q = $this->Post->query("SHOW FULL PROCESSLIST");
die(debug($q));

Of course, debug needs to be enabled, and caching disabled. Have you
checked that?

On Wed, Aug 29, 2012 at 2:24 PM, andrewperk  wrote:
> Hello,
>
> I need to be able to print out some data from my database such as:
>
> "SHOW FULL PROCESSLIST"
> "SHOW GLOBAL STATUS"
> "SHOW GLOBAL VARIABLES LIKE 'hostname'"
>
> etc..
>
> How can I accomplish this? What I've been trying to do is use the query()
> method in a model to run my own custom query but that's not working:
>
> $this->query("SHOW FULL PROCESSLIST");
>
> This doesn't return anything, there is no error either, it's just empty. Any
> help would be appreciated.
>
> Thanks,
>
> --
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com.
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@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.




How can I Show my Database Global Variables and Full Process List?

2012-08-29 Thread andrewperk
Hello,

I need to be able to print out some data from my database such as:

"SHOW FULL PROCESSLIST"
"SHOW GLOBAL STATUS"
"SHOW GLOBAL VARIABLES LIKE 'hostname'"

etc..

How can I accomplish this? What I've been trying to do is use the query() 
method in a model to run my own custom query but that's not working:

$this->query("SHOW FULL PROCESSLIST");

This doesn't return anything, there is no error either, it's just empty. 
Any help would be appreciated.

Thanks,

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




Re: Session variables are PHP_Incomplete_Class, throwing errors

2012-07-10 Thread John Hardy
The class "Team" is not in the scope of PHP. ( IE: the class has not been 
declared as a symbol )

You will need to overload the __autoload function and have the file where the 
class is declared included.

http://php.net/__autoload

On Jul 10, 2012, at 5:01 PM, Wendall wrote:

> Hi all,
> 
> I've set a session variable that I assign to an object.  When I load other 
> pages, sometimes I can get data out of the session var, sometimes I can't.  
> For example, I check a property of the object in the session var to 
> dynamically assign a stylesheet to the page.  In some controller views, this 
> stylesheet is being attached, while in some other views it is not.  I'm not 
> altering, deleting, or destroying my session var between these views, so am 
> unsure as to why this is happening.  When I run a debug on this session var 
> on the pages that it's not  working properly on, I'm seeing the object being 
> described as an instance of "__PHP_Incomplete_Class".  In the debug, I can 
> see all the properties of the object, but when I try to do something simple 
> like get the object's id, the id comes back as "null" and I get the following 
> Notice:
> 
> The script tried to execute a method or access a property of an incomplete 
> object. Please ensure that the class definition "Team" of the object you are 
> trying to operate on was loaded _before_ unserialize() gets called or provide 
> a __autoload() function to load the class definition.
> 
> Any thoughts on what's going on?  Am I trying to stuff too much data into a 
> session var?  Thanks for any 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

-- 
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: Session variables are PHP_Incomplete_Class, throwing errors

2012-07-10 Thread rchavik


On Wednesday, July 11, 2012 7:01:07 AM UTC+7, Wendall wrote:
>
> Hi all,
>
> I've set a session variable that I assign to an object.  When I load other 
> pages, sometimes I can get data out of the session var, sometimes I can't.  
> For example, I check a property of the object in the session var to 
> dynamically assign a stylesheet to the page.  In some controller views, 
> this stylesheet is being attached, while in some other views it is not.  
> I'm not altering, deleting, or destroying my session var between these 
> views, so am unsure as to why this is happening.  When I run a debug on 
> this session var on the pages that it's not  working properly on, I'm 
> seeing the object being described as an instance of 
> "__PHP_Incomplete_Class".  In the debug, I can see all the properties of 
> the object, but when I try to do something simple like get the object's id, 
> the id comes back as "null" and I get the following Notice:
>
> The script tried to execute a method or access a property of an incomplete 
> object. Please ensure that the class definition "Team" of the object you 
> are trying to operate on was loaded _before_ unserialize() gets called or 
> provide a __autoload() function to load the class definition.
>
> Any thoughts on what's going on?  Am I trying to stuff too much data into 
> a session var?  Thanks for any help.
>

Don't store objects in sessions? 

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


Session variables are PHP_Incomplete_Class, throwing errors

2012-07-10 Thread Wendall
Hi all,

I've set a session variable that I assign to an object.  When I load other 
pages, sometimes I can get data out of the session var, sometimes I can't.  
For example, I check a property of the object in the session var to 
dynamically assign a stylesheet to the page.  In some controller views, 
this stylesheet is being attached, while in some other views it is not.  
I'm not altering, deleting, or destroying my session var between these 
views, so am unsure as to why this is happening.  When I run a debug on 
this session var on the pages that it's not  working properly on, I'm 
seeing the object being described as an instance of 
"__PHP_Incomplete_Class".  In the debug, I can see all the properties of 
the object, but when I try to do something simple like get the object's id, 
the id comes back as "null" and I get the following Notice:

The script tried to execute a method or access a property of an incomplete 
object. Please ensure that the class definition "Team" of the object you 
are trying to operate on was loaded _before_ unserialize() gets called or 
provide a __autoload() function to load the class definition.

Any thoughts on what's going on?  Am I trying to stuff too much data into a 
session var?  Thanks for any 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: Variables

2012-05-02 Thread luca capra


Il 02/05/2012 09:18, Historiker ha scritto:

Kann mit jemand erklären, warum



im default.ctp funktioniert und im add.ctp nicht?


Version 2.1
 current_user gesetzt in AppController.php
 ...
 public function beforeFilter() {
...
$this->set('current_user', $this->Auth->user());

Maybe you implement beforeFilter in the add.ctp related controller 
without parent::beforeFilter ?


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


Variables

2012-05-02 Thread Historiker
Kann mit jemand erklären, warum



im default.ctp funktioniert und im add.ctp nicht?


Version 2.1
current_user gesetzt in AppController.php
...
public function beforeFilter() {
   ...
   $this->set('current_user', $this->Auth->user());

-- 
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: Read configuration variables from the controller, CakePHP V2

2012-01-18 Thread Abraham Boray
Okay, Thank YOU :)..It's workin'!


-- 
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: Read configuration variables from the controller, CakePHP V2

2012-01-18 Thread Tilen Majerle
You cannot functions while declaring propertiesso create constructor
and there set value from method/function...
Dne sreda, 18. januar 2012 je pošiljatelj Abraham Boray <
abrahambo...@gmail.com> napisal:
> I'm trying to read some of the variable I put in the configuration file
Core.php.
> So I can have like class Variables that takes their values from the core
Variable.
> EG
>class QuestionsController extends AppController {
>var $visite_status = Configure::read('visite_status');
> }
> But this isn't working in the controller, any ideas how can I do this ?
> Thank you in advance.
>
> --
> 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
>

-- 
--
Lep pozdrav, Tilen Majerle
http://majerle.eu

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


Read configuration variables from the controller, CakePHP V2

2012-01-18 Thread Abraham Boray
I'm trying to read some of the variable I put in the configuration file 
Core.php.
So I can have like class Variables that takes their values from the core 
Variable.

EG

   class QuestionsController extends AppController {
   var $visite_status = Configure::read('visite_status');

}
But this isn't working in the controller, any ideas how can I do this ?

Thank you in advance. 

-- 
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: cakephp 2.0 Email - Passing variables to templates

2011-09-06 Thread #2Will
oh yeah.  doh.  thanks!

its also in the docs i was attempting to read:
http://book2.cakephp.org/en/core-utility-libraries/email.html

will

On Sep 7, 2:20 pm, "Dr. Tarique Sani"  wrote:
> CakeEmail::viewVars()
>
> Seehttps://github.com/cakephp/docs/blob/master/en/core-utility-libraries...
> for more
>
> Tarique
>
> On Wed, Sep 7, 2011 at 4:40 AM, #2Will  wrote:
> > Hello,
>
> > When using the new email Utility library with cake 2.0, what is the
> > procedure for passing variables?
>
> --
> =
> PHP for E-Biz:http://sanisoft.com
> =

-- 
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: cakephp 2.0 Email - Passing variables to templates

2011-09-06 Thread Dr. Tarique Sani
CakeEmail::viewVars()

See 
https://github.com/cakephp/docs/blob/master/en/core-utility-libraries/email.rst
for more

Tarique

On Wed, Sep 7, 2011 at 4:40 AM, #2Will  wrote:
> Hello,
>
> When using the new email Utility library with cake 2.0, what is the
> procedure for passing variables?
>
>

-- 
=
PHP for E-Biz: http://sanisoft.com
=

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


cakephp 2.0 Email - Passing variables to templates

2011-09-06 Thread #2Will
Hello,

When using the new email Utility library with cake 2.0, what is the
procedure for passing variables?

In the past, I just used set, and that passed a variable to the
view  / email template.  I could also use Configure::read

these aren't working any more.

Thanks

will

-- 
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: Setting variables in AppController to use in Layout.

2011-07-10 Thread Angad Nadkarni
I figured out out guys. The reason was there were some syntax errors
in other parts of the code (in my case, a ClassnameComponent was named
as ClassnameHelper), due to which this part of the code wasn't getting
executed.

Also, I shifted all the 'set's to beforeRender(). I was using a few of
these varnames in other views as well, so they ended up getting
overwritten.
I later fixed this by renaming the view-copy of these variables
differently.

Thanks for your time!

On Jul 10, 2:31 pm, euromark  wrote:
> well,
> beforeFilter() is not always triggered
> why not putting everything in beforeRender()
> would make more sense to me
>
> by the way:
> for some data you can always use Configure::write() and
> Configure::load()
> might make sense if you want to use it in different locations
>
> On 10 Jul., 10:00, runckel  wrote:
>
>
>
> > Hi,
>
> > i dont see anything wrong there, so i would first write a $this-
> > log($login_url) in the app controllers beforeRender to be sure it will
> > be called and the $login_url is filled. One reason it will not be
> > called could be a beforeRender in the calling Controller whitch doesnt
> > call his Parent.
>
> > On 8 Jul., 22:25, Angad Nadkarni  wrote:
>
> > > I am setting variables in AppController in order to use them in
> > > default.ctp.
>
> > > This is my code:
>
> > >         function beforeRender ( )
> > >         {
> > >                 @Controller::loadModel('User');
> > >                 $login_url = [trimmed];
> > >                 $this->set('loginurl', $login_url);
> > >                 $this->set('user', $this->Cookie->read('User'));
> > >                 $this->set('examdata', $this->User->query('select listing 
> > > from exams
> > > limit 0,1'));
> > >                 $this->set('exam', $this->Cookie->read('exam'));
> > >         }
>
> > > The logic for above code has been performed in beforeFilter().
>
> > > Now when I use the variables in default.ctp, such as say $loginurl, or
> > > $examdata, I get:
>
> > > Undefined variable: loginurl
>
> > > or Undefined variable: examdata
>
> > > What am I doing wrong?- Hide quoted text -
>
> - Show quoted text -

-- 
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: Setting variables in AppController to use in Layout.

2011-07-10 Thread euromark
well,
beforeFilter() is not always triggered
why not putting everything in beforeRender()
would make more sense to me

by the way:
for some data you can always use Configure::write() and
Configure::load()
might make sense if you want to use it in different locations


On 10 Jul., 10:00, runckel  wrote:
> Hi,
>
> i dont see anything wrong there, so i would first write a $this-
> log($login_url) in the app controllers beforeRender to be sure it will
> be called and the $login_url is filled. One reason it will not be
> called could be a beforeRender in the calling Controller whitch doesnt
> call his Parent.
>
> On 8 Jul., 22:25, Angad Nadkarni  wrote:
>
>
>
>
>
>
>
> > I am setting variables in AppController in order to use them in
> > default.ctp.
>
> > This is my code:
>
> >         function beforeRender ( )
> >         {
> >                 @Controller::loadModel('User');
> >                 $login_url = [trimmed];
> >                 $this->set('loginurl', $login_url);
> >                 $this->set('user', $this->Cookie->read('User'));
> >                 $this->set('examdata', $this->User->query('select listing 
> > from exams
> > limit 0,1'));
> >                 $this->set('exam', $this->Cookie->read('exam'));
> >         }
>
> > The logic for above code has been performed in beforeFilter().
>
> > Now when I use the variables in default.ctp, such as say $loginurl, or
> > $examdata, I get:
>
> > Undefined variable: loginurl
>
> > or Undefined variable: examdata
>
> > What am I doing wrong?

-- 
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: Setting variables in AppController to use in Layout.

2011-07-10 Thread runckel
Hi,

i dont see anything wrong there, so i would first write a $this-
log($login_url) in the app controllers beforeRender to be sure it will
be called and the $login_url is filled. One reason it will not be
called could be a beforeRender in the calling Controller whitch doesnt
call his Parent.

On 8 Jul., 22:25, Angad Nadkarni  wrote:
> I am setting variables in AppController in order to use them in
> default.ctp.
>
> This is my code:
>
>         function beforeRender ( )
>         {
>                 @Controller::loadModel('User');
>                 $login_url = [trimmed];
>                 $this->set('loginurl', $login_url);
>                 $this->set('user', $this->Cookie->read('User'));
>                 $this->set('examdata', $this->User->query('select listing 
> from exams
> limit 0,1'));
>                 $this->set('exam', $this->Cookie->read('exam'));
>         }
>
> The logic for above code has been performed in beforeFilter().
>
> Now when I use the variables in default.ctp, such as say $loginurl, or
> $examdata, I get:
>
> Undefined variable: loginurl
>
> or Undefined variable: examdata
>
> What am I doing wrong?

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


Setting variables in AppController to use in Layout.

2011-07-08 Thread Angad Nadkarni
I am setting variables in AppController in order to use them in
default.ctp.

This is my code:

function beforeRender ( )
{
@Controller::loadModel('User');
$login_url = [trimmed];
$this->set('loginurl', $login_url);
$this->set('user', $this->Cookie->read('User'));
$this->set('examdata', $this->User->query('select listing from 
exams
limit 0,1'));
$this->set('exam', $this->Cookie->read('exam'));
}

The logic for above code has been performed in beforeFilter().

Now when I use the variables in default.ctp, such as say $loginurl, or
$examdata, I get:

Undefined variable: loginurl

or Undefined variable: examdata


What am I doing wrong?

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


Pagination Routing (With other variables)

2011-06-09 Thread Rjs37
The url structure on my website (in progress) is pretty complicated and I've 
been having some trouble getting pagination to display urls that are less 
messy.

The routes that is currently used for the page I'm having trouble with is as 
follows:

Router::connect('/:console/:arena/:controller/:slug/:action/*', array(),
array('console' => "ps3|360"));

So an example url would be something like: 
http://domain.com/ps3/blackops/ladders/clan

On top of that I have a query variable to make the url:
http://domain.com/ps3/blackops/ladders/clan

The URL's that the paginator is coming out with are:

http://domain.com/ps3/blackops/ladders/clan/view/page:2/sort:Clan.name/direction:asc?season=3

As you can see it's pretty long winded (plus colons in the url look 
horrible) and I was hoping to improve it. First of all I'd like to get rid 
of the view action from the url. And then either by switching the pagination 
to use Query Variables (like my season variable) or by switching to a url 
format like:
http://domain.com/ps3/blackops/ladders/clan/season-3/2/Clan.name/asc

Even that doesn't look too appealing. I'm using Jquery so it doesn't 
physically go to those pages but I'd still like to sort out the url's it's 
using. Presumably it'd need a new route defining but I'm not sure how I'd 
approach that route. 

Any help provided would be greatly appreciated.

Robert

-- 
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: Accessing variables in referenced tables in views

2011-05-18 Thread Jeremy Burns | Class Outfit
And look at the Containable behaviour.

Jeremy Burns
Class Outfit

jeremybu...@classoutfit.com
http://www.classoutfit.com

On 17 May 2011, at 23:06, mmlunjwa wrote:

> In your threads controller change the recursive value to 2:
> 
> $this->threads->recursive = 2;
> $event = $this->Threads->read(null, $id);
> 
> The recursive property defines how deep CakePHP should go to fetch
> associated model data via find(), findAll() and read() methods.
> 
> Then in your view use:
> 
> $post['User']['username']
> 
> I suggest you study the manual: book.cakephp.org/view/1063/recursive 
> 
> --
> View this message in context: 
> http://cakephp.1045679.n5.nabble.com/Accessing-variables-in-referenced-tables-in-views-tp2638874p4404922.html
> Sent from the CakePHP mailing list archive at Nabble.com.
> 
> -- 
> 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

-- 
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: Accessing variables in referenced tables in views

2011-05-18 Thread mmlunjwa
In your threads controller change the recursive value to 2:

$this->threads->recursive = 2;
$event = $this->Threads->read(null, $id);

The recursive property defines how deep CakePHP should go to fetch
associated model data via find(), findAll() and read() methods.

Then in your view use:

$post['User']['username']

I suggest you study the manual: book.cakephp.org/view/1063/recursive 

--
View this message in context: 
http://cakephp.1045679.n5.nabble.com/Accessing-variables-in-referenced-tables-in-views-tp2638874p4404922.html
Sent from the CakePHP mailing list archive at Nabble.com.

-- 
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: Problem with Variables in Elements

2011-04-30 Thread DigitalDude
Hey,


what's the code inside of your header-element that tries to use the
'variable'?

Is it a simple echo?



On 28 Apr., 16:10, Santiago Basulto 
wrote:
> Hello People,
>
> i'm using CakePHP 1.3.5.
>
> When i pass a variable to an element, as the book says
> (http://book.cakephp.org/view/1081/Elements) i can't use it, i get
> this error message: Notice (8): Undefined variable: variable
> [APP/views/elements/header.ctp, line 2]
>
> Here's my code:
>     In the layout:
>         element('header',array('variable'=>'value')); ?>
>     In the element (here's where te error arises):
>         Notice (8): Undefined variable:
> variable [APP/views/elements/header.ctp, line 2]
>
> What's going on? I've disabled all cache but still doesn't work.
>
> --
> Santiago Basulto.-

-- 
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: Problem with Variables in Elements

2011-04-28 Thread cricket
On Thu, Apr 28, 2011 at 2:28 PM, cricket  wrote:
>
> Looks ok to me. Are you sure the spelling is good? Does the call to
> this element occur in any other layouts? Maybe you're in a different
> layout, which doesn't also have the variable assignment. Long shot, I
> know.
>

Also, try debug($this->viewVars);

-- 
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: Problem with Variables in Elements

2011-04-28 Thread cricket
On Thu, Apr 28, 2011 at 10:10 AM, Santiago Basulto
 wrote:
> Hello People,
>
> i'm using CakePHP 1.3.5.
>
> When i pass a variable to an element, as the book says
> (http://book.cakephp.org/view/1081/Elements) i can't use it, i get
> this error message: Notice (8): Undefined variable: variable
> [APP/views/elements/header.ctp, line 2]
>
> Here's my code:
>    In the layout:
>        element('header',array('variable'=>'value')); ?>
>    In the element (here's where te error arises):
>        Notice (8): Undefined variable:
> variable [APP/views/elements/header.ctp, line 2]
>
> What's going on? I've disabled all cache but still doesn't work.

Looks ok to me. Are you sure the spelling is good? Does the call to
this element occur in any other layouts? Maybe you're in a different
layout, which doesn't also have the variable assignment. Long shot, I
know.

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


Problem with Variables in Elements

2011-04-28 Thread Santiago Basulto
Hello People,

i'm using CakePHP 1.3.5.

When i pass a variable to an element, as the book says
(http://book.cakephp.org/view/1081/Elements) i can't use it, i get
this error message: Notice (8): Undefined variable: variable
[APP/views/elements/header.ctp, line 2]

Here's my code:
In the layout:
element('header',array('variable'=>'value')); ?>
In the element (here's where te error arises):
Notice (8): Undefined variable:
variable [APP/views/elements/header.ctp, line 2]

What's going on? I've disabled all cache but still doesn't work.

-- 
Santiago Basulto.-

-- 
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: Auth component doesn't set session variables !

2011-03-31 Thread damien durant
i will try.

In fact it's strange. Because i don't touch anything and it works from my
home computers.
It doesn't from my work, maybe because of proxy setting but it's weird.

On Thu, Mar 31, 2011 at 8:42 PM, cricket  wrote:

> On Thu, Mar 31, 2011 at 10:43 AM, damien d 
> wrote:
> > Hi,
> >
> > I have trouble with the Auth component.
> >
> > I try something really simple :
> >  - I create a user db (with name,password field)
> >  - I use a appcontroler with this code :
> >
> > var $components = array("Session","Auth");
> >function beforeFilter() {
> >$this->Auth->fields = array('username' => 'name',
> > 'password' => 'password');
> >$this->Auth->loginAction = array('controller' =>
> > 'users', 'action' => 'login');
> >$this->Auth->loginRedirect = array('controller' =>
> 'discs', 'action'
> > => 'hello');
> >$this->Auth->logoutRedirect = '/';
> >$this->Auth->loginError = 'Invalid name / password
> > combination.  Please try again';
> >}
> >
> >  - I got a classic login.ctp
> >  - and in my discs_controller :
> >
> > function beforeFilter() {
> >$this->Auth->allow("*");
> >parent::beforeFilter();
> >}
> >
> >
> > The issue is, when i log through the login page, i am correctly
> > redirected, but on the redirect page the Auth variable aren't set.
> > Here is the content of $session->read() on hello.ctp, after login.
> > ($session->read('Auth.User') is empty);
> >
> > Array ( [Config] => Array ( [userAgent] => [time] => 1301618408
> > [timeout] => 10 ) )
> >
> >
> > I see there is some trouble with some fix on the net so i :
> >  - Configure::write('Session.checkAgent', false);
> >  - Configure::write('Security.level', 'low');
> > in core.php but without any success.
>
> Try putting Auth before Session in the $components array.
>
> --
> 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
>



-- 
Damien Durant

-- 
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: Auth component doesn't set session variables !

2011-03-31 Thread cricket
On Thu, Mar 31, 2011 at 10:43 AM, damien d  wrote:
> Hi,
>
> I have trouble with the Auth component.
>
> I try something really simple :
>  - I create a user db (with name,password field)
>  - I use a appcontroler with this code :
>
> var $components = array("Session","Auth");
>        function beforeFilter() {
>                $this->Auth->fields = array('username' => 'name',
> 'password' => 'password');
>                $this->Auth->loginAction = array('controller' =>
> 'users', 'action' => 'login');
>                $this->Auth->loginRedirect = array('controller' => 'discs', 
> 'action'
> => 'hello');
>                $this->Auth->logoutRedirect = '/';
>                $this->Auth->loginError = 'Invalid name / password
> combination.  Please try again';
>        }
>
>  - I got a classic login.ctp
>  - and in my discs_controller :
>
> function beforeFilter() {
>                $this->Auth->allow("*");
>                parent::beforeFilter();
>        }
>
>
> The issue is, when i log through the login page, i am correctly
> redirected, but on the redirect page the Auth variable aren't set.
> Here is the content of $session->read() on hello.ctp, after login.
> ($session->read('Auth.User') is empty);
>
> Array ( [Config] => Array ( [userAgent] => [time] => 1301618408
> [timeout] => 10 ) )
>
>
> I see there is some trouble with some fix on the net so i :
>  - Configure::write('Session.checkAgent', false);
>  - Configure::write('Security.level', 'low');
> in core.php but without any success.

Try putting Auth before Session in the $components array.

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


Auth component doesn't set session variables !

2011-03-31 Thread damien d
Hi,

I have trouble with the Auth component.

I try something really simple :
 - I create a user db (with name,password field)
 - I use a appcontroler with this code :

var $components = array("Session","Auth");
function beforeFilter() {
$this->Auth->fields = array('username' => 'name',
'password' => 'password');
$this->Auth->loginAction = array('controller' =>
'users', 'action' => 'login');
$this->Auth->loginRedirect = array('controller' => 'discs', 
'action'
=> 'hello');
$this->Auth->logoutRedirect = '/';
$this->Auth->loginError = 'Invalid name / password
combination.  Please try again';
}

 - I got a classic login.ctp
 - and in my discs_controller :

function beforeFilter() {
$this->Auth->allow("*");
parent::beforeFilter();
}


The issue is, when i log through the login page, i am correctly
redirected, but on the redirect page the Auth variable aren't set.
Here is the content of $session->read() on hello.ctp, after login.
($session->read('Auth.User') is empty);

Array ( [Config] => Array ( [userAgent] => [time] => 1301618408
[timeout] => 10 ) )


I see there is some trouble with some fix on the net so i :
 - Configure::write('Session.checkAgent', false);
 - Configure::write('Security.level', 'low');
in core.php but without any success.

-- 
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: Variables for Validation

2011-02-20 Thread Krissy Masters
Thanks,

I like the $this->field('name', array('id' => $id)); Nice and simple.

K

-Original Message-
From: cake-php@googlegroups.com [mailto:cake-php@googlegroups.com] On Behalf
Of cricket
Sent: Sunday, February 20, 2011 2:41 PM
To: cake-php@googlegroups.com
Subject: Re: Variables for Validation

On Sun, Feb 20, 2011 at 8:22 AM, Krissy Masters
 wrote:
> Not sure why I only thought of this now.
>
> Any form: quick dummy function
>
> function edit() {
>
> If(!empty($this->data)) {
>
>       If($this->save());
>
>        // whatever
>       }
> $countries = $this->Model->_getCountries(); // returns list of countries
> $this->set(compact('countries'));
>
>
> }
>
> So you have a full list of countries in the form user can select from.
>
> $validate array() in model I have a function to check the country_id value
> and that function also uses _getCountries();
>
> public function checkCountryValues( $data, $field ){
>
> $valid = false;
>        if( !empty( $this->data[$this->alias][$field] ) ) {
>                if ( array_key_exists($this->data[$this->alias][$field],
> $this->_getCountries() ) ){
>                        $valid = true;
>                }
>        }
>        return $valid;
> }
>
>
>
> So I am essentially grabbing that data twice. How can I reuse that initial
> $countries throughout the whole process rather than grabbing the same data
> over and over?
> Might sounds trivial but some models might have 6 or more related models
and
> then validating pulling all the same values used in the view / form it is
> just added work.

You're making the mistake of focusing on the action instead of the
request. In your example, "the whole process" occurs over two separate
requests.

In the validation scenario, I think it's just as well to check if
$this->field('name', array('id' => $id)) returns empty or not.

It's just an example, I know, but your model's method is also
protected, so the controller could not call it.

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

-- 
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: Variables for Validation

2011-02-20 Thread cricket
On Sun, Feb 20, 2011 at 8:22 AM, Krissy Masters
 wrote:
> Not sure why I only thought of this now.
>
> Any form: quick dummy function
>
> function edit() {
>
> If(!empty($this->data)) {
>
>       If($this->save());
>
>        // whatever
>       }
> $countries = $this->Model->_getCountries(); // returns list of countries
> $this->set(compact('countries'));
>
>
> }
>
> So you have a full list of countries in the form user can select from.
>
> $validate array() in model I have a function to check the country_id value
> and that function also uses _getCountries();
>
> public function checkCountryValues( $data, $field ){
>
> $valid = false;
>        if( !empty( $this->data[$this->alias][$field] ) ) {
>                if ( array_key_exists($this->data[$this->alias][$field],
> $this->_getCountries() ) ){
>                        $valid = true;
>                }
>        }
>        return $valid;
> }
>
>
>
> So I am essentially grabbing that data twice. How can I reuse that initial
> $countries throughout the whole process rather than grabbing the same data
> over and over?
> Might sounds trivial but some models might have 6 or more related models and
> then validating pulling all the same values used in the view / form it is
> just added work.

You're making the mistake of focusing on the action instead of the
request. In your example, "the whole process" occurs over two separate
requests.

In the validation scenario, I think it's just as well to check if
$this->field('name', array('id' => $id)) returns empty or not.

It's just an example, I know, but your model's method is also
protected, so the controller could not call it.

-- 
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: Variables for Validation

2011-02-20 Thread John Andersen
I would say yes, as it follows the normal way in CakePHP and by using
the Cache feature in the model, the second call will just take the
same data from the cache instead of querying the database again.
Enjoy,
   John

On Feb 20, 2:43 pm, "Krissy Masters" 
wrote:
> Sorry, everything is cached either in memory (Memcache) or plain file
> depending on the data pulled. I was just wondering if it made sense to ask
> for the same data twice in the same action (once for the view and again for
> validation) in these cases.
>
> K
>
[snip]

-- 
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: Variables for Validation

2011-02-20 Thread Krissy Masters
Sorry, everything is cached either in memory (Memcache) or plain file
depending on the data pulled. I was just wondering if it made sense to ask
for the same data twice in the same action (once for the view and again for
validation) in these cases.

K

-Original Message-
From: cake-php@googlegroups.com [mailto:cake-php@googlegroups.com] On Behalf
Of John Andersen
Sent: Sunday, February 20, 2011 10:06 AM
To: CakePHP
Subject: Re: Variables for Validation

I would look into using the cache! Start from here in the CakePHP
book:
http://book.cakephp.org/view/1193/Caching

Enjoy,
   John

On Feb 20, 2:22 pm, "Krissy Masters" 
wrote:
> Not sure why I only thought of this now.
>
> Any form: quick dummy function
>
> function edit() {
>
> If(!empty($this->data)) {
>
>        If($this->save());
>
>         // whatever
>        }
> $countries = $this->Model->_getCountries(); // returns list of countries
> $this->set(compact('countries'));
>
> }
>
> So you have a full list of countries in the form user can select from.
>
> $validate array() in model I have a function to check the country_id value
> and that function also uses _getCountries();
>
> public function checkCountryValues( $data, $field ){
>
> $valid = false;
>         if( !empty( $this->data[$this->alias][$field] ) ) {
>                 if ( array_key_exists($this->data[$this->alias][$field],
> $this->_getCountries() ) ){
>                         $valid = true;
>                 }
>         }
>         return $valid;
>
> }
>
> So I am essentially grabbing that data twice. How can I reuse that initial
> $countries throughout the whole process rather than grabbing the same data
> over and over?
> Might sounds trivial but some models might have 6 or more related models
and
> then validating pulling all the same values used in the view / form it is
> just added work.
>
> Thanks,
> K

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

-- 
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: Variables for Validation

2011-02-20 Thread John Andersen
I would look into using the cache! Start from here in the CakePHP
book:
http://book.cakephp.org/view/1193/Caching

Enjoy,
   John

On Feb 20, 2:22 pm, "Krissy Masters" 
wrote:
> Not sure why I only thought of this now.
>
> Any form: quick dummy function
>
> function edit() {
>
> If(!empty($this->data)) {
>
>        If($this->save());
>
>         // whatever
>        }
> $countries = $this->Model->_getCountries(); // returns list of countries
> $this->set(compact('countries'));
>
> }
>
> So you have a full list of countries in the form user can select from.
>
> $validate array() in model I have a function to check the country_id value
> and that function also uses _getCountries();
>
> public function checkCountryValues( $data, $field ){
>
> $valid = false;
>         if( !empty( $this->data[$this->alias][$field] ) ) {
>                 if ( array_key_exists($this->data[$this->alias][$field],
> $this->_getCountries() ) ){
>                         $valid = true;
>                 }
>         }
>         return $valid;
>
> }
>
> So I am essentially grabbing that data twice. How can I reuse that initial
> $countries throughout the whole process rather than grabbing the same data
> over and over?
> Might sounds trivial but some models might have 6 or more related models and
> then validating pulling all the same values used in the view / form it is
> just added work.
>
> Thanks,
> K

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


Variables for Validation

2011-02-20 Thread Krissy Masters
Not sure why I only thought of this now.

Any form: quick dummy function 

function edit() {

If(!empty($this->data)) {

   If($this->save());

// whatever
   }
$countries = $this->Model->_getCountries(); // returns list of countries
$this->set(compact('countries'));


}

So you have a full list of countries in the form user can select from.

$validate array() in model I have a function to check the country_id value
and that function also uses _getCountries();

public function checkCountryValues( $data, $field ){

$valid = false;
if( !empty( $this->data[$this->alias][$field] ) ) {
if ( array_key_exists($this->data[$this->alias][$field],
$this->_getCountries() ) ){
$valid = true;
}
}
return $valid;
}



So I am essentially grabbing that data twice. How can I reuse that initial
$countries throughout the whole process rather than grabbing the same data
over and over?
Might sounds trivial but some models might have 6 or more related models and
then validating pulling all the same values used in the view / form it is
just added work.

Thanks,
K

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


Ratings plugin (undefined variables)

2011-01-16 Thread John Maxim
Hi,

Ok here's the deal. I installed the ratings plugin from CakeDC:
https://github.com/CakeDC/ratings

After doing all the steps as stated, It was fine until including this
form in my view:

Rating->display(array(
'item' => $post['Post']['id'],  <== line 3
'type' => 'radio',
'stars' => 5,
'value' => $item['rating'], <== line 6( line 7 right below this
where the variable item is)
'createForm' => array('url' => array($this->passedArgs, 'rate' =>
$item['id'], 'redirect' => true;
?>

At first the errors were:
undefined variable for post and item line 3, 6 and 7.

So after modifying line 3 to $food['Food']['id'] this undefined
variable post is solved. Now the line 6 and 7 error: Undefined item
variable remain. What is the problem ?

The model I'm getting it to work is here:

mysql> describe foods;
+-+--+--+-+-++
| Field   | Type | Null | Key | Default | Extra  |
+-+--+--+-+-++
| id  | int(11)  | NO   | PRI | NULL| auto_increment |
| name| varchar(255) | NO   | MUL | NULL||
| description | varchar(255) | NO   | | NULL||
| created | datetime | YES  | | NULL||
| modified| datetime | YES  | | NULL||
+-+--+--+-+-++
5 rows in set (0.04 sec)

and the ratings table is here:

mysql> describe ratings;
+-+--+--+-+-+---+
| Field   | Type | Null | Key | Default | Extra |
+-+--+--+-+-+---+
| id  | varchar(36)  | NO   | PRI | NULL|   |
| user_id | varchar(36)  | NO   | MUL | NULL|   |
| foreign_key | varchar(36)  | NO   | | NULL|   |
| model   | varchar(255) | NO   | | NULL|   |
| value   | float(8,4)   | YES  | | 0.  |   |
| created | datetime | YES  | | NULL|   |
| modified| datetime | YES  | | NULL|   |
+-+--+--+-+-+---+
7 rows in set (0.04 sec)


I'm suspecting a function missing in my Controller::Food ?

Or a step is missing?

I have searched over google but find no hints or solutions to this:

http://ask.cakephp.org/questions/view/cakedc_ratings_plugin_error

Any help ?
Thanks, cheers, regards.
John Maxim
:-)

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Re: call in to variables...

2010-12-23 Thread chris...@yahoo.com
Hi cricket, Thank You for your reply,

speaking of "unique usernames"... in fact yes, they are all unique.
i'm not quite understud what Amit meant to be,... yes they are all
unique, and each user has its own Videos, Groups, Blogs, Profile,
Business Profile, etc... and in order to favorite let say I (user1)
want to favorite video that you (user2) have post it in from youtube
or google and have favorite section so I can access with no time. the
clear picture of this,... if its not to much trouble could you please
access http://www.zippopeople.com and please signup to see your
favorite section in My Videos, My Groups, ... this is just a testing
URL and all records will be deleted after all... here is my ../views/
videos/favorites.ctp file, and in order to link to that ORIGINAL VIDEO
that have been posted from your favorites you need to have a some
unique string (i name it $parent['User']['username']) other from
($user_obj['User']['username']) where in my case "user_obj" is the
User1 and "parent" is User2. and I have to link it to ORIGINAL video
show page. here is my favorites.ctp file








  link($photoShow->buddy($user_obj, array('height'
=> 36, 'width' => 36)), '/profile/' . $user_obj['User']['username'],
false, false, false) ?>




  

  
  : link($user_obj['User']['firstname'] . ' ' .
$user_obj['User']['lastname'], '/profile/' . $user_obj['User']
['username'], array('style' => 'color: #00;')) ?>

  


  


   : 
   
   : 
   


  





 

 

link(ucfirst(__('ALL VIDEOS', true)), '/
videos' , array('style' => 'color: #00;')) ?>
 


 
 is_authorized($user_obj['User']['id'])): ?>
link(ucfirst(__('my favorites', true)) . ' - ' .
$user_obj['User']['video_favorites'], '/videos/favorites/' .
$user_obj['User']['username']) ?>
  |  

  link(ucfirst(Inflector::pluralize(__('video',
true))) . ' ' . $user_obj['User']['firstname'] . ' ' .
$user_obj['User']['lastname'] . ' - ' . $user_obj['User']['videos'], '/
videos/index/' . $user_obj['User']['username']) ?>


 







:


sort(__('added date', true), 'created',
array('model' => 'VideoFavorite', 'escape' => false, 'url' =>
am($url_options, array('direction' => 'desc', 'page' => 1)), 'class'
=> $application->paginator_order() == 'created' ? 'selected' : '')) ?>
 -
sort(__('alphabetically', true), 'name',
array('model' => 'VideoFavorite', 'direction' => 'desc', 'escape' =>
false, 'url' => am($url_options, array('direction' => 'asc', 'page' =>
1)), 'class' => $application->paginator_order() == 'name' ?
'selected' : '')) ?>
     

  link(ucfirst(__('videos', true)) . ' - ' .
$this->params['paging']['VideoFavorite']['count'], '/videos/index/' .
$user_obj['User']['username'], array('class' => 'photos')) ?>
   

  params['pass'])): ?>
  link(ucfirst(__('added date', true)) . ' : ' .
$application->daysAgo($time, strftime('%Y-%m-%d', strtotime($this-
>params['pass']['date']))), '/videos/favorites/' . $user_obj['User']
['username'] . '/date:' . $this->params['pass']['date'], array('class'
=> 'calendar')) ?>
  
  link(ucfirst(__('added date', true)) . ' : ' .
__('all', true), '/videos/favorites/' . $user_obj['User']['username'],
array('class' => 'calendar')) ?>
  

  

  
link(__('all', true) . ' - ' .
$videos_count, '/videos/index/' . $user_obj['User']['username']) ?>

link($application->daysAgo($time,
current(current($date))) . ' - ' . $date[0]['videos'], $paginator-
>url(am($url_options, array('date' => $time->format('j.n.Y',
current(current($date), true)) ?>
 
  







 is_authorized($user_obj['User']['id'])): ?>
  

   link(ucfirst(__('upload Videos', true)), '/
videoupload', array('class' => 'photos'), false, false, false) ?>
|
 link(ucfirst(__('manage Videos', true)), '/videos/
manage/' . $user_obj['User']['id'], array('class' => 'edit'), false,
false) ?>

  









  




link($html->image("myplay.jpg", array('height' =>
84, 'width' => 120)),'/videos/show/'.$user_obj['User']['username'].'/'.
$video['Video']['id'],array('escape'=>false))?>


link($html->image($video['Video']['video_thumb'],
array('height' => 84, 'width' => 120)),'/videos/show/'.
$user_obj['User']['username'].'/'.$video['Video']
['id'],array('escape'=>false))?>









: 
cut($video['Video']['name'], 60) ?>





: 
cut($video['Video']['description'], 100) ?>




  

: 
link($video['VideoCategory']['name'], '/videos/' .
$video['VideoCategory']['name']) ?>

 : 
link($parent['User']['username'], '/profile/' .
$parent['User']['username']) ?>





: 

   |   
link(ucfirst(Inflector::pluralize(__('comment',
true))) . ' - ' . $video['Video']['comments'], '/videos/show/' .
$user_obj['User']['username'] . '/' . $video['Video']['id']) 

Re: call in to variables...

2010-12-23 Thread cricket
On Wed, Dec 22, 2010 at 8:56 PM, chris...@yahoo.com  wrote:
>
> no there is no unique username, this is a social network site with
> lots of users ;) I guess,... this still in construction...

If username is not unique your favorites action will never work
properly as it's only param is $username. You'll either need to ensure
that usernames are unique across your DB or use something else with
which to get a particular user's favorites.

I haven't gone through all of your code (frankly, it looks like it
would benefit from a careful re-write, especially moving quite a lot
of it to a model) but, in order to use model::field() you first must
set the model's id. The point of field() is to get the column value
for a particular row. If the model's id is not set, you can't query
that row.

I think $parent_id isn't a good choice for variable name here, as
you're not dealing with the parent Video of another Video. I assume
that it's the User that created the Video, but I'm unsure.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Re: call in to variables...

2010-12-22 Thread chris...@yahoo.com
and here what I have in models: I roow knoow knoow what's right what's
wrong anymore...

 VALID_NOT_EMPTY,
'user_id' => VALID_NOT_EMPTY,
'category_id' => VALID_NOT_EMPTY,
'description' => VALID_NOT_EMPTY,
'embed_code' => VALID_NOT_EMPTY
);

var $belongsTo = array(
'VideoCategory' => array(
'className' => 'VideoCategory',
'foreignKey'=> 'category_id'
),
'User'
);

var $hasMany = array(
'VideoComment' => array(
'className' => 'VideoComment',
'foreignKey'=> 'video_id'
),
'VideoFavorite' => array(
'className' => 'VideoFavorite',
'foreignKey'=> 'video_id'
)
);

   function afterDelete()
   {
 $this->loadModels('VideoComment');

 foreach($this->VideoComment->find('all', array('conditions' =>
array('VideoComment.video_id' => $this->id( as $video_comment)
   $this->VideoComment->delete($video_comment);
   }


}
?>

AND

 VALID_NOT_EMPTY,
'user_id' => VALID_NOT_EMPTY,
'parent_id' => VALID_NOT_EMPTY,
'category_id' => VALID_NOT_EMPTY
  );

var $belongsTo = array(
'VideoCategory' => array(
'className' => 'VideoCategory',
'foreignKey'=> 'category_id'
), 'User', 'Video'
);


var $hasMany = array(
'Video' => array(
'className' => 'Video',
'foreignKey'=> 'id'
),
'VideoCategory' => array(
'className' => 'VideoCategory',
'foreignKey'=> 'id'
)

);

  function afterDelete()
  {
  }
}
?>

MUCHO THANKS !!!
Chris


On Dec 22, 5:56 pm, "chris...@yahoo.com"  wrote:
> Hi Amit, thanks again,...
>
> no there is no unique username, this is a social network site with
> lots of users ;) I guess,... this still in construction...
> and I'm building and adding Users Video Favorites Section, Group
> Favorites, Blog Favorites etc...
> And I think I have to call user_id or parent_id either from Video or
> VideoFavorite tables.
>
> I already set it up VideoFavorite parent_id value to = Video user_id
>
>   function set_favorites($id)
>   {
>
>     if(!($user = $this->User->findById($this->user['id'])))
>     {
>       $this->flash('error', ucfirst(i18n::translate('user not
> found')));
>       $this->redirect('/');
>     }
>     else
>     {
>       if(!($video = $this->Video->findById($id)))
>       {
>         $this->flash('error', ucfirst(i18n::translate('video not
> found')));
>         $this->redirect('/');
>       }
>       else
>       {
>         $favorites['VideoFavorite']['video_id'] = $video['Video']
> ['id'];
>         $favorites['VideoFavorite']['parent_id'] = $video['Video']
> ['user_id'];
>         $favorites['VideoFavorite']['category_id'] = $video['Video']
> ['category_id'];
>         $favorites['VideoFavorite']['privacy'] = $video['Video']
> ['privacy'];
>         $favorites['VideoFavorite']['created'] = $video['Video']
> ['created'];
>         $favorites['VideoFavorite']['user_id'] = $user['User']['id'];
>
>         if(!$this->VideoFavorite->save($favorites))
>         {
>           $this->flash('error',
> ucfirst(i18n::translate('unexpected')));
>         }
>         else
>         {
>           $this->flash('valid', ucfirst(i18n::translate('favorites
> added')));
>         }
>
>         $this->redirect('/videos/favorites/' . $user['User']
> ['username']);
>       }
>     }
>   }
>
> Thanks
> Chris
>
> On Dec 22, 5:26 pm, Amit Rawat  wrote:
>
>
>
>
>
>
>
> > Hi,
>
> > Is  your username unique?
>
> > if yes then you can use this
>
> > $parent_id=$this->User->field('id',array('username'=>$username));
>
> > Enjoy
>
> > On Thu, Dec 23, 2010 at 6:48 AM, chris...@yahoo.com 
> > wrote:
>
> > > Hi Amit, thank you for your help. But it didn't work. I may, as well
> > > post the whole function here. This is a favorites section that I'm
> > > trying to create. All I'm trying to do,... is call parent_id so I can
> > > link it to original video user username(profile) and video from view
> > > page favorites.ctp. If you have a time can you please take peak at
>
> > >http://www.zippopeople.com
> > > and this is a testing URL
>
> > > Thank Yo..All !
>
> > >   function favorites($username = null)
> > >  {
>
> > >    if($username == 'unknown')
> > >      $this->authorize();
>
> > >    if(!($user = $this->User->findByUsername($username)))
> > >    {
> > >      $this->flash('error', ucfirst(i18n::translate('user not
> > > found')));
> > >      $this->redirect('/');
> > >    }
>
> > >    else
> > >    {
> > >      $filter = $this->params['pass'];
> > >      unset($filter['page']);
> > >      unset(

Re: call in to variables...

2010-12-22 Thread chris...@yahoo.com
I have tried them all,...
nothing seems working


  // $parent_id = $this->VideoFavorite-
>findById($user['VideoFavorite']['parent_id']);


  // $parent_id = $this->User->field('id',array('username'=>
$username));


  // $parent_id = $this->Video->field('id',array('user_id'=>
$user_id));


  $parent_id = $this->VideoFavorite->field('id',array('parent_id'=>
$parent_id));


 // $parent_id = $this->Video->field(user_id);

Please help...
Thanks


On Dec 22, 5:56 pm, "chris...@yahoo.com"  wrote:
> Hi Amit, thanks again,...
>
> no there is no unique username, this is a social network site with
> lots of users ;) I guess,... this still in construction...
> and I'm building and adding Users Video Favorites Section, Group
> Favorites, Blog Favorites etc...
> And I think I have to call user_id or parent_id either from Video or
> VideoFavorite tables.
>
> I already set it up VideoFavorite parent_id value to = Video user_id
>
>   function set_favorites($id)
>   {
>
>     if(!($user = $this->User->findById($this->user['id'])))
>     {
>       $this->flash('error', ucfirst(i18n::translate('user not
> found')));
>       $this->redirect('/');
>     }
>     else
>     {
>       if(!($video = $this->Video->findById($id)))
>       {
>         $this->flash('error', ucfirst(i18n::translate('video not
> found')));
>         $this->redirect('/');
>       }
>       else
>       {
>         $favorites['VideoFavorite']['video_id'] = $video['Video']
> ['id'];
>         $favorites['VideoFavorite']['parent_id'] = $video['Video']
> ['user_id'];
>         $favorites['VideoFavorite']['category_id'] = $video['Video']
> ['category_id'];
>         $favorites['VideoFavorite']['privacy'] = $video['Video']
> ['privacy'];
>         $favorites['VideoFavorite']['created'] = $video['Video']
> ['created'];
>         $favorites['VideoFavorite']['user_id'] = $user['User']['id'];
>
>         if(!$this->VideoFavorite->save($favorites))
>         {
>           $this->flash('error',
> ucfirst(i18n::translate('unexpected')));
>         }
>         else
>         {
>           $this->flash('valid', ucfirst(i18n::translate('favorites
> added')));
>         }
>
>         $this->redirect('/videos/favorites/' . $user['User']
> ['username']);
>       }
>     }
>   }
>
> Thanks
> Chris
>
> On Dec 22, 5:26 pm, Amit Rawat  wrote:
>
>
>
>
>
>
>
> > Hi,
>
> > Is  your username unique?
>
> > if yes then you can use this
>
> > $parent_id=$this->User->field('id',array('username'=>$username));
>
> > Enjoy
>
> > On Thu, Dec 23, 2010 at 6:48 AM, chris...@yahoo.com 
> > wrote:
>
> > > Hi Amit, thank you for your help. But it didn't work. I may, as well
> > > post the whole function here. This is a favorites section that I'm
> > > trying to create. All I'm trying to do,... is call parent_id so I can
> > > link it to original video user username(profile) and video from view
> > > page favorites.ctp. If you have a time can you please take peak at
>
> > >http://www.zippopeople.com
> > > and this is a testing URL
>
> > > Thank Yo..All !
>
> > >   function favorites($username = null)
> > >  {
>
> > >    if($username == 'unknown')
> > >      $this->authorize();
>
> > >    if(!($user = $this->User->findByUsername($username)))
> > >    {
> > >      $this->flash('error', ucfirst(i18n::translate('user not
> > > found')));
> > >      $this->redirect('/');
> > >    }
>
> > >    else
> > >    {
> > >      $filter = $this->params['pass'];
> > >      unset($filter['page']);
> > >      unset($filter['sort']);
> > >      unset($filter['direction']);
> > >      $this->set('url_options', $filter);
>
> > >        $parent_id = $this->Video->field('user_id');
>
> > >      $this->menu->setSelected('/videos/index/' . $user['User']
> > > ['username']);
> > >      $this-
> > > >set_title(ucfirst(Inflector::pluralize(i18n::translate('favorite
> > > videos'))) . ' : ' . $user['User']['firstname'] . ' ' . $user['User']
> > > ['lastname']);
>
> > >      $scope = array('VideoFavorite.user_id' => $user['User']['id']);
> > >            if(array_key_exists('date', $this->params['pass']))
> > >        $scope[] = 'DATE(VideoFavorite.created) = \'' . strftime('%Y-
> > > %m-%d', strtotime($this->params['pass']['date'])) . '\'';
>
> > >      if($this->is_user())
> > >        $is_friend = in_array($this->user['id'], $this->Friend-
> > > >myFriends($user['User']['id']));
> > >      else
> > >        $is_friend = false;
>
> > >      if($this->is_user() && $this->user['id'] == $user['User']['id'])
> > >      {
> > >        // the owner has no restriction
> > >      }
> > >      elseif($this->is_user() && $is_friend)
> > >      {
> > >        $scope[] = 'VideoFavorite.privacy <= ' .
> > > array_search('friend', Configure::read('Site.privacy'));
> > >      }
> > >      else
> > >      {
> > >        $scope[] = 'VideoFavorite.privacy <= ' .
> > > array_search('public', Configure::read('Site.privacy'));
> > >      }
>
> > >      $videos = $this->paginate('VideoFavorite', $scope);
>
> > >      $this->

Re: call in to variables...

2010-12-22 Thread chris...@yahoo.com
Hi Amit, thanks again,...

no there is no unique username, this is a social network site with
lots of users ;) I guess,... this still in construction...
and I'm building and adding Users Video Favorites Section, Group
Favorites, Blog Favorites etc...
And I think I have to call user_id or parent_id either from Video or
VideoFavorite tables.

I already set it up VideoFavorite parent_id value to = Video user_id

  function set_favorites($id)
  {

if(!($user = $this->User->findById($this->user['id'])))
{
  $this->flash('error', ucfirst(i18n::translate('user not
found')));
  $this->redirect('/');
}
else
{
  if(!($video = $this->Video->findById($id)))
  {
$this->flash('error', ucfirst(i18n::translate('video not
found')));
$this->redirect('/');
  }
  else
  {
$favorites['VideoFavorite']['video_id'] = $video['Video']
['id'];
$favorites['VideoFavorite']['parent_id'] = $video['Video']
['user_id'];
$favorites['VideoFavorite']['category_id'] = $video['Video']
['category_id'];
$favorites['VideoFavorite']['privacy'] = $video['Video']
['privacy'];
$favorites['VideoFavorite']['created'] = $video['Video']
['created'];
$favorites['VideoFavorite']['user_id'] = $user['User']['id'];

if(!$this->VideoFavorite->save($favorites))
{
  $this->flash('error',
ucfirst(i18n::translate('unexpected')));
}
else
{
  $this->flash('valid', ucfirst(i18n::translate('favorites
added')));
}

$this->redirect('/videos/favorites/' . $user['User']
['username']);
  }
}
  }


Thanks
Chris

On Dec 22, 5:26 pm, Amit Rawat  wrote:
> Hi,
>
> Is  your username unique?
>
> if yes then you can use this
>
> $parent_id=$this->User->field('id',array('username'=>$username));
>
> Enjoy
>
> On Thu, Dec 23, 2010 at 6:48 AM, chris...@yahoo.com wrote:
>
>
>
>
>
>
>
> > Hi Amit, thank you for your help. But it didn't work. I may, as well
> > post the whole function here. This is a favorites section that I'm
> > trying to create. All I'm trying to do,... is call parent_id so I can
> > link it to original video user username(profile) and video from view
> > page favorites.ctp. If you have a time can you please take peak at
>
> >http://www.zippopeople.com
> > and this is a testing URL
>
> > Thank Yo..All !
>
> >   function favorites($username = null)
> >  {
>
> >    if($username == 'unknown')
> >      $this->authorize();
>
> >    if(!($user = $this->User->findByUsername($username)))
> >    {
> >      $this->flash('error', ucfirst(i18n::translate('user not
> > found')));
> >      $this->redirect('/');
> >    }
>
> >    else
> >    {
> >      $filter = $this->params['pass'];
> >      unset($filter['page']);
> >      unset($filter['sort']);
> >      unset($filter['direction']);
> >      $this->set('url_options', $filter);
>
> >        $parent_id = $this->Video->field('user_id');
>
> >      $this->menu->setSelected('/videos/index/' . $user['User']
> > ['username']);
> >      $this-
> > >set_title(ucfirst(Inflector::pluralize(i18n::translate('favorite
> > videos'))) . ' : ' . $user['User']['firstname'] . ' ' . $user['User']
> > ['lastname']);
>
> >      $scope = array('VideoFavorite.user_id' => $user['User']['id']);
> >            if(array_key_exists('date', $this->params['pass']))
> >        $scope[] = 'DATE(VideoFavorite.created) = \'' . strftime('%Y-
> > %m-%d', strtotime($this->params['pass']['date'])) . '\'';
>
> >      if($this->is_user())
> >        $is_friend = in_array($this->user['id'], $this->Friend-
> > >myFriends($user['User']['id']));
> >      else
> >        $is_friend = false;
>
> >      if($this->is_user() && $this->user['id'] == $user['User']['id'])
> >      {
> >        // the owner has no restriction
> >      }
> >      elseif($this->is_user() && $is_friend)
> >      {
> >        $scope[] = 'VideoFavorite.privacy <= ' .
> > array_search('friend', Configure::read('Site.privacy'));
> >      }
> >      else
> >      {
> >        $scope[] = 'VideoFavorite.privacy <= ' .
> > array_search('public', Configure::read('Site.privacy'));
> >      }
>
> >      $videos = $this->paginate('VideoFavorite', $scope);
>
> >      $this->set('videos', $videos);
> >      $this->set('dates', $dates = $this->VideoFavorite->query('SELECT
> > DATE(created) AS date, COUNT(*) AS videos FROM fociki_video_favorites
> > WHERE user_id = ' . $user['User']['id'] . ' GROUP BY DATE(created)
> > ORDER BY created DESC'));
> >      $videos_count = 0;
> >      foreach($dates as $date)
> >        $videos_count += $date[0]['videos'];
> >      $this->set('videos_count', $videos_count);
>
> >      $this->set('user_obj', $user);
> >      $this->set('parent', $parent_id);
>
> >      $this->set('friends', $this->Friend->find('all', array('limit'
> > => 12, 'conditions' => array('Friend.user_id' => $user['User']['id']),
> > 'order' => array('Friend.created' => 'DESC';
>
> >    }
>
> >  }
>
> > and here is my tab

Re: call in to variables...

2010-12-22 Thread Amit Rawat
Hi,

Is  your username unique?

if yes then you can use this

$parent_id=$this->User->field('id',array('username'=>$username));

Enjoy

On Thu, Dec 23, 2010 at 6:48 AM, chris...@yahoo.com wrote:

> Hi Amit, thank you for your help. But it didn't work. I may, as well
> post the whole function here. This is a favorites section that I'm
> trying to create. All I'm trying to do,... is call parent_id so I can
> link it to original video user username(profile) and video from view
> page favorites.ctp. If you have a time can you please take peak at
>
> http://www.zippopeople.com
> and this is a testing URL
>
> Thank Yo..All !
>
>
>   function favorites($username = null)
>  {
>
>if($username == 'unknown')
>  $this->authorize();
>
>if(!($user = $this->User->findByUsername($username)))
>{
>  $this->flash('error', ucfirst(i18n::translate('user not
> found')));
>  $this->redirect('/');
>}
>
>else
>{
>  $filter = $this->params['pass'];
>  unset($filter['page']);
>  unset($filter['sort']);
>  unset($filter['direction']);
>  $this->set('url_options', $filter);
>
>$parent_id = $this->Video->field('user_id');
>
>  $this->menu->setSelected('/videos/index/' . $user['User']
> ['username']);
>  $this-
> >set_title(ucfirst(Inflector::pluralize(i18n::translate('favorite
> videos'))) . ' : ' . $user['User']['firstname'] . ' ' . $user['User']
> ['lastname']);
>
>  $scope = array('VideoFavorite.user_id' => $user['User']['id']);
>if(array_key_exists('date', $this->params['pass']))
>$scope[] = 'DATE(VideoFavorite.created) = \'' . strftime('%Y-
> %m-%d', strtotime($this->params['pass']['date'])) . '\'';
>
>  if($this->is_user())
>$is_friend = in_array($this->user['id'], $this->Friend-
> >myFriends($user['User']['id']));
>  else
>$is_friend = false;
>
>  if($this->is_user() && $this->user['id'] == $user['User']['id'])
>  {
>// the owner has no restriction
>  }
>  elseif($this->is_user() && $is_friend)
>  {
>$scope[] = 'VideoFavorite.privacy <= ' .
> array_search('friend', Configure::read('Site.privacy'));
>  }
>  else
>  {
>$scope[] = 'VideoFavorite.privacy <= ' .
> array_search('public', Configure::read('Site.privacy'));
>  }
>
>  $videos = $this->paginate('VideoFavorite', $scope);
>
>
>  $this->set('videos', $videos);
>  $this->set('dates', $dates = $this->VideoFavorite->query('SELECT
> DATE(created) AS date, COUNT(*) AS videos FROM fociki_video_favorites
> WHERE user_id = ' . $user['User']['id'] . ' GROUP BY DATE(created)
> ORDER BY created DESC'));
>  $videos_count = 0;
>  foreach($dates as $date)
>$videos_count += $date[0]['videos'];
>  $this->set('videos_count', $videos_count);
>
>  $this->set('user_obj', $user);
>  $this->set('parent', $parent_id);
>
>  $this->set('friends', $this->Friend->find('all', array('limit'
> => 12, 'conditions' => array('Friend.user_id' => $user['User']['id']),
> 'order' => array('Friend.created' => 'DESC';
>
>
>}
>
>  }
>
> and here is my tables:
>
> videos table
> id  int(11) UNSIGNEDNo  auto_increment
>user_id int(11) Yes NULL
>category_id int(11) Yes NULL
>namevarchar(120)latin1_swedish_ci   No
>description textlatin1_swedish_ci   Yes NULL
>embed_code  textlatin1_swedish_ci   Yes NULL
>video_thumb textlatin1_swedish_ci   Yes NULL
>views   int(11) No  0
>commentsint(11) No  0
>last_commentdatetimeYes NULL
>promo_statusint(11) No  0
>privacy int(1)  UNSIGNEDNo  0
>created datetimeNo  -00-00 00:00:00
>
> video_favorites table
>id  int(11) UNSIGNEDNo
>  auto_increment
>video_idint(11) UNSIGNEDNo  0
>user_id int(11) Yes NULL
>category_id int(11) Yes NULL
>privacy int(1)  UNSIGNEDNo  0
>created datetimeNo  -00-00 00:00:00
>parent_id   int(11) Yes NULL
>
>
>
> Thanks again, any help is appreciated !!!
> Chris
>
>
>
> On Dec 22, 4:20 pm, Amit Rawat  wrote:
> > Hi Chris,
> >
> > Use find field
> >
> > $parent_id = $this->Video->field('user_id',array('your condition goes
> > here'))
> >
> > enjoy,
> >
> > Amit
> >
> > On Thu, Dec 23, 2010 at 3:41 AM, chris...@yahoo.com  >wrote:
> >
> >
> >
> >
> >
> >
> >
> > > Hi All,... sound stupid but I have to ask...
> > > I want to call user_id from Video table in to $parent_id variable in
> > > my controller i

Re: call in to variables...

2010-12-22 Thread chris...@yahoo.com
Hi Amit, thank you for your help. But it didn't work. I may, as well
post the whole function here. This is a favorites section that I'm
trying to create. All I'm trying to do,... is call parent_id so I can
link it to original video user username(profile) and video from view
page favorites.ctp. If you have a time can you please take peak at

http://www.zippopeople.com
and this is a testing URL

Thank Yo..All !


   function favorites($username = null)
  {

if($username == 'unknown')
  $this->authorize();

if(!($user = $this->User->findByUsername($username)))
{
  $this->flash('error', ucfirst(i18n::translate('user not
found')));
  $this->redirect('/');
}

else
{
  $filter = $this->params['pass'];
  unset($filter['page']);
  unset($filter['sort']);
  unset($filter['direction']);
  $this->set('url_options', $filter);

$parent_id = $this->Video->field('user_id');

  $this->menu->setSelected('/videos/index/' . $user['User']
['username']);
  $this-
>set_title(ucfirst(Inflector::pluralize(i18n::translate('favorite
videos'))) . ' : ' . $user['User']['firstname'] . ' ' . $user['User']
['lastname']);

  $scope = array('VideoFavorite.user_id' => $user['User']['id']);
if(array_key_exists('date', $this->params['pass']))
$scope[] = 'DATE(VideoFavorite.created) = \'' . strftime('%Y-
%m-%d', strtotime($this->params['pass']['date'])) . '\'';

  if($this->is_user())
$is_friend = in_array($this->user['id'], $this->Friend-
>myFriends($user['User']['id']));
  else
$is_friend = false;

  if($this->is_user() && $this->user['id'] == $user['User']['id'])
  {
// the owner has no restriction
  }
  elseif($this->is_user() && $is_friend)
  {
$scope[] = 'VideoFavorite.privacy <= ' .
array_search('friend', Configure::read('Site.privacy'));
  }
  else
  {
$scope[] = 'VideoFavorite.privacy <= ' .
array_search('public', Configure::read('Site.privacy'));
  }

  $videos = $this->paginate('VideoFavorite', $scope);


  $this->set('videos', $videos);
  $this->set('dates', $dates = $this->VideoFavorite->query('SELECT
DATE(created) AS date, COUNT(*) AS videos FROM fociki_video_favorites
WHERE user_id = ' . $user['User']['id'] . ' GROUP BY DATE(created)
ORDER BY created DESC'));
  $videos_count = 0;
  foreach($dates as $date)
$videos_count += $date[0]['videos'];
  $this->set('videos_count', $videos_count);

  $this->set('user_obj', $user);
  $this->set('parent', $parent_id);

  $this->set('friends', $this->Friend->find('all', array('limit'
=> 12, 'conditions' => array('Friend.user_id' => $user['User']['id']),
'order' => array('Friend.created' => 'DESC';


}

  }

and here is my tables:

videos table
id  int(11) UNSIGNEDNo  auto_increment
user_id int(11) Yes NULL
category_id int(11) Yes NULL
namevarchar(120)latin1_swedish_ci   No
description textlatin1_swedish_ci   Yes NULL
embed_code  textlatin1_swedish_ci   Yes NULL
video_thumb textlatin1_swedish_ci   Yes NULL
views   int(11) No  0
commentsint(11) No  0
last_commentdatetimeYes NULL
promo_statusint(11) No  0
privacy int(1)  UNSIGNEDNo  0
created datetimeNo  -00-00 00:00:00

video_favorites table
id  int(11) UNSIGNEDNo  auto_increment
video_idint(11) UNSIGNEDNo  0
user_id int(11) Yes NULL
category_id int(11) Yes NULL
privacy int(1)  UNSIGNEDNo  0
created datetimeNo  -00-00 00:00:00
parent_id   int(11) Yes NULL



Thanks again, any help is appreciated !!!
Chris



On Dec 22, 4:20 pm, Amit Rawat  wrote:
> Hi Chris,
>
> Use find field
>
> $parent_id = $this->Video->field('user_id',array('your condition goes
> here'))
>
> enjoy,
>
> Amit
>
> On Thu, Dec 23, 2010 at 3:41 AM, chris...@yahoo.com wrote:
>
>
>
>
>
>
>
> > Hi All,... sound stupid but I have to ask...
> > I want to call user_id from Video table in to $parent_id variable in
> > my controller in order to display and link to parent user username,
> > video in ..."Favorites" section. And how do I do that...? Please
> > help...
>
> > $parent_id = $this->Video ???
>
> > thanks
>
> > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others
> > with their CakePHP related questions.
>
> > You received this message because you are subscribed to the Google Groups
> > 

Re: call in to variables...

2010-12-22 Thread Amit Rawat
Hi Chris,

Use find field

$parent_id = $this->Video->field('user_id',array('your condition goes
here'))


enjoy,

Amit

On Thu, Dec 23, 2010 at 3:41 AM, chris...@yahoo.com wrote:

> Hi All,... sound stupid but I have to ask...
> I want to call user_id from Video table in to $parent_id variable in
> my controller in order to display and link to parent user username,
> video in ..."Favorites" section. And how do I do that...? Please
> help...
>
> $parent_id = $this->Video ???
>
> thanks
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others
> with their CakePHP related questions.
>
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.comFor
>  more options, visit this group at
> http://groups.google.com/group/cake-php?hl=en
>

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


call in to variables...

2010-12-22 Thread chris...@yahoo.com
Hi All,... sound stupid but I have to ask...
I want to call user_id from Video table in to $parent_id variable in
my controller in order to display and link to parent user username,
video in ..."Favorites" section. And how do I do that...? Please
help...

$parent_id = $this->Video ???

thanks

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Re: Losing Session variables

2010-12-15 Thread Rishi
Hey All,

I have made changes you have listed above and now it works. I have no
idea what I was doing wrong.

Thanks for all the help

On Dec 13, 11:56 am, Rishi  wrote:
> Hi All
>
> Thanks for all the help. Here is what I have.
>
> 1. I am not using any Auth helper or component. I am simply trying to
> query the database for the  "username" & "password" and allowing the
> user to login. Once I find the user. I am having the following code :
>
>                         if(!empty($user)){
>                                 $this->Session->write('user',$user);
>                                 $this->redirect(array('controller' => 
> 'users', 'action' =>
> 'action'));
>                         }
>
> 2. Once I redirect the user to the "action", I am trying to read the
> session variable.
>
>                    $this->Session->read('user');
>   I can read the session variable in the next immediately called
> action. ( First action "Login"  and second Action "Action").
>
> 3. When I try to read the variable in the another action, I am losing
> the variable. So when I read the session variable in action "
> Preview" ( which is down the line not the immediate) I am losing the
> "user" session variable..
>
> 4. Thanks for the debug tool. I was able to track the session
> variable. I can see session variable when I set it, but lost it the
> consecutive actions (like the "Preview"). I am not using a shares
> server, I am testing it on my local machine. I am using production
> environment setting. I did try
>
>                  ini_set("session.cookie_domain", "yourdomain.com");
> But not use.
>
> 5. I have tried debug($this->Session) before and after reading the
> session variable in the "action" action.
>
>  Before Reading
> 
> SessionComponent Object
> (
>     [__active] => 1
>     [__bare] => 0
>     [__started] => 1
>     [valid] =>
>     [error] => Array
>         (
>             [2] => Config.userAgent doesn't exist
>         )
>
>     [_userAgent] =>
>     [path] => /
>     [lastError] => 2
>     [security] => low
>     [time] => 1292259231
>     [sessionTime] => 1292295231
>     [cookieLifeTime] =>
>     [watchKeys] => Array
>         (
>         )
>
>     [id] =>
>     [host] => localhost
>     [timeout] =>
>     [enabled] => 1
> )
>
> ---
> $this->Session->read('user');
> - After
> ---
>  SessionComponent Object
> (
>     [__active] => 1
>     [__bare] => 0
>     [__started] => 1
>     [valid] =>
>     [error] => Array
>         (
>             [2] => Config.userAgent doesn't exist
>         )
>
>     [_userAgent] =>
>     [path] => /
>     [lastError] => 2
>     [security] => low
>     [time] => 1292259231
>     [sessionTime] => 1292295231
>     [cookieLifeTime] =>
>     [watchKeys] => Array
>         (
>         )
>
>     [id] =>
>     [host] => localhost
>     [timeout] =>
>     [enabled] => 1
> )
> 
>
> 6. I can see my session varibale in the debug console.
>
> Thanks for all the help. !!!
>
> On Dec 13, 6:03 am, Renato de Freitas Freire 
> wrote:
>
>
>
>
>
>
>
> > Try to put this code into your bootstrap.php file:
>
> > ini_set("session.cookie_domain", "yourdomain.com");
>
> > You might be using a shared server...
>
> > --
> > Renato de Freitas Freire
> > ren...@morfer.org
>
> > On Mon, Dec 13, 2010 at 6:37 AM, Jeremy Burns | Class Outfit <
>
> > jeremybu...@classoutfit.com> wrote:
> > > 1) Install the Debug Kit (https://github.com/cakephp/debug_kit) and
> > > examine the contents of your session
> > > 2) Are you loading both the Session component and the Session helper?
> > > 3) How are you writing to and reading from the session (please show code)?
> > > 4) What do you see when you die(debug($this->Session)); immediately before
> > > and then immediately after writing to the session?
> > > 5) What do you see when you die(debug($this->Session)); immediately before
> > > and then immediately after reading from the session?
>
> > > Jeremy Burns
> > > Class Outfit
>
> > > jeremybu...@classoutfit.com
> > >http://www.classoutfit.com
>
> > > On 13 Dec 2010, at 08:25, dtemes wrote:
>
> > > Without looking at your code nor knowing more about your environment I
> > > guess it will not be easy to help you.
>
> > > Are you sure the code in your login action is being executed? (if
> > > using auth check the autoRedirect variable)
>
> > > On 12 dic, 16:37, Rishi  wrote:
>
> > > Does anyone have any idea of what is going on ! .. its dealing
>
> > > with sessions. I really need some wayout. Please help !!!
>
> > > On Dec 10, 10:42 am, Rishi  wrote:
>
> > > Hi,
>
> > > No. I am not trying to switch between protocols.
>
> > > On Dec 8, 11:47 pm, Jeremy Burns | Class Outfit
>
> > >  wrote:
>
> > > Are yo switching between http and https

Re: Losing Session variables

2010-12-13 Thread Rishi
Hi All

Thanks for all the help. Here is what I have.

1. I am not using any Auth helper or component. I am simply trying to
query the database for the  "username" & "password" and allowing the
user to login. Once I find the user. I am having the following code :

if(!empty($user)){
$this->Session->write('user',$user);
$this->redirect(array('controller' => 'users', 
'action' =>
'action'));
}

2. Once I redirect the user to the "action", I am trying to read the
session variable.

   $this->Session->read('user');
  I can read the session variable in the next immediately called
action. ( First action "Login"  and second Action "Action").

3. When I try to read the variable in the another action, I am losing
the variable. So when I read the session variable in action "
Preview" ( which is down the line not the immediate) I am losing the
"user" session variable..


4. Thanks for the debug tool. I was able to track the session
variable. I can see session variable when I set it, but lost it the
consecutive actions (like the "Preview"). I am not using a shares
server, I am testing it on my local machine. I am using production
environment setting. I did try

 ini_set("session.cookie_domain", "yourdomain.com");
But not use.

5. I have tried debug($this->Session) before and after reading the
session variable in the "action" action.

 Before Reading

SessionComponent Object
(
[__active] => 1
[__bare] => 0
[__started] => 1
[valid] =>
[error] => Array
(
[2] => Config.userAgent doesn't exist
)

[_userAgent] =>
[path] => /
[lastError] => 2
[security] => low
[time] => 1292259231
[sessionTime] => 1292295231
[cookieLifeTime] =>
[watchKeys] => Array
(
)

[id] =>
[host] => localhost
[timeout] =>
[enabled] => 1
)

---
$this->Session->read('user');
- After
---
 SessionComponent Object
(
[__active] => 1
[__bare] => 0
[__started] => 1
[valid] =>
[error] => Array
(
[2] => Config.userAgent doesn't exist
)

[_userAgent] =>
[path] => /
[lastError] => 2
[security] => low
[time] => 1292259231
[sessionTime] => 1292295231
[cookieLifeTime] =>
[watchKeys] => Array
(
)

[id] =>
[host] => localhost
[timeout] =>
[enabled] => 1
)



6. I can see my session varibale in the debug console.


Thanks for all the help. !!!

On Dec 13, 6:03 am, Renato de Freitas Freire 
wrote:
> Try to put this code into your bootstrap.php file:
>
> ini_set("session.cookie_domain", "yourdomain.com");
>
> You might be using a shared server...
>
> --
> Renato de Freitas Freire
> ren...@morfer.org
>
> On Mon, Dec 13, 2010 at 6:37 AM, Jeremy Burns | Class Outfit <
>
>
>
>
>
>
>
> jeremybu...@classoutfit.com> wrote:
> > 1) Install the Debug Kit (https://github.com/cakephp/debug_kit) and
> > examine the contents of your session
> > 2) Are you loading both the Session component and the Session helper?
> > 3) How are you writing to and reading from the session (please show code)?
> > 4) What do you see when you die(debug($this->Session)); immediately before
> > and then immediately after writing to the session?
> > 5) What do you see when you die(debug($this->Session)); immediately before
> > and then immediately after reading from the session?
>
> > Jeremy Burns
> > Class Outfit
>
> > jeremybu...@classoutfit.com
> >http://www.classoutfit.com
>
> > On 13 Dec 2010, at 08:25, dtemes wrote:
>
> > Without looking at your code nor knowing more about your environment I
> > guess it will not be easy to help you.
>
> > Are you sure the code in your login action is being executed? (if
> > using auth check the autoRedirect variable)
>
> > On 12 dic, 16:37, Rishi  wrote:
>
> > Does anyone have any idea of what is going on ! .. its dealing
>
> > with sessions. I really need some wayout. Please help !!!
>
> > On Dec 10, 10:42 am, Rishi  wrote:
>
> > Hi,
>
> > No. I am not trying to switch between protocols.
>
> > On Dec 8, 11:47 pm, Jeremy Burns | Class Outfit
>
> >  wrote:
>
> > Are yo switching between http and https?
>
> > Jeremy Burns
>
> > Class Outfit
>
> > jeremybu...@classoutfit.comhttp://www.classoutfit.com
>
> > On 9 Dec 2010, at 02:43, Rishi wrote:
>
> > Hi All,
>
> > I am new Cakephp. I am using simple login mechanism ( not the standard
>
> > Auth) for checking in user login. I set a session variable in the
>
> > login action and try to access the variable in "graph" action. I am
>
> > unable to read the variable. When I do a var_dum

Re: Losing Session variables

2010-12-13 Thread Renato de Freitas Freire
Try to put this code into your bootstrap.php file:

ini_set("session.cookie_domain", "yourdomain.com");

You might be using a shared server...

--
Renato de Freitas Freire
ren...@morfer.org


On Mon, Dec 13, 2010 at 6:37 AM, Jeremy Burns | Class Outfit <
jeremybu...@classoutfit.com> wrote:

> 1) Install the Debug Kit (https://github.com/cakephp/debug_kit) and
> examine the contents of your session
> 2) Are you loading both the Session component and the Session helper?
> 3) How are you writing to and reading from the session (please show code)?
> 4) What do you see when you die(debug($this->Session)); immediately before
> and then immediately after writing to the session?
> 5) What do you see when you die(debug($this->Session)); immediately before
> and then immediately after reading from the session?
>
>
> Jeremy Burns
> Class Outfit
>
> jeremybu...@classoutfit.com
> http://www.classoutfit.com
>
> On 13 Dec 2010, at 08:25, dtemes wrote:
>
> Without looking at your code nor knowing more about your environment I
> guess it will not be easy to help you.
>
> Are you sure the code in your login action is being executed? (if
> using auth check the autoRedirect variable)
>
> On 12 dic, 16:37, Rishi  wrote:
>
> Does anyone have any idea of what is going on ! .. its dealing
>
> with sessions. I really need some wayout. Please help !!!
>
>
> On Dec 10, 10:42 am, Rishi  wrote:
>
>
> Hi,
>
>
> No. I am not trying to switch between protocols.
>
>
> On Dec 8, 11:47 pm, Jeremy Burns | Class Outfit
>
>
>  wrote:
>
> Are yo switching between http and https?
>
>
> Jeremy Burns
>
> Class Outfit
>
>
> jeremybu...@classoutfit.comhttp://www.classoutfit.com
>
>
> On 9 Dec 2010, at 02:43, Rishi wrote:
>
>
> Hi All,
>
>
> I am new Cakephp. I am using simple login mechanism ( not the standard
>
> Auth) for checking in user login. I set a session variable in the
>
> login action and try to access the variable in "graph" action. I am
>
> unable to read the variable. When I do a var_dump, i get NULL. I have
>
> tried all the options suggested by users in this group like setting
>
> security low/medium. Changed cake_session.php @ like 595
>
>
>   if(session_id() == '') {
>
>session_start();
>
>}
>
>
> I am using CakePhp 1.3 and Php 5.2.
>
>
> I have been trying to get this up for past couple of days. Please help
>
> me to solve this problem.!!
>
>
> Check out the new CakePHP Questions sitehttp://cakeqs.organdhelpotherswith 
> their CakePHP related questions.
>
>
> You received this message because you are subscribed to the Google
> Groups "CakePHP" group.
>
> To post to this group, send email to cake-php@googlegroups.com
>
> To unsubscribe from this group, send email to
>
> cake-php+unsubscr...@googlegroups.com For more options, visit this group
> athttp://groups.google.com/group/cake-php?hl=en
>
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others
> with their CakePHP related questions.
>
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group
> at http://groups.google.com/group/cake-php?hl=en
>
>
>  Check out the new CakePHP Questions site http://cakeqs.org and help
> others with their CakePHP related questions.
>
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.comFor
>  more options, visit this group at
> http://groups.google.com/group/cake-php?hl=en
>

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Re: Losing Session variables

2010-12-13 Thread Jeremy Burns | Class Outfit
1) Install the Debug Kit (https://github.com/cakephp/debug_kit) and examine the 
contents of your session
2) Are you loading both the Session component and the Session helper?
3) How are you writing to and reading from the session (please show code)?
4) What do you see when you die(debug($this->Session)); immediately before and 
then immediately after writing to the session?
5) What do you see when you die(debug($this->Session)); immediately before and 
then immediately after reading from the session?

Jeremy Burns
Class Outfit

jeremybu...@classoutfit.com
http://www.classoutfit.com

On 13 Dec 2010, at 08:25, dtemes wrote:

> Without looking at your code nor knowing more about your environment I
> guess it will not be easy to help you.
> 
> Are you sure the code in your login action is being executed? (if
> using auth check the autoRedirect variable)
> 
> On 12 dic, 16:37, Rishi  wrote:
>> Does anyone have any idea of what is going on ! .. its dealing
>> with sessions. I really need some wayout. Please help !!!
>> 
>> On Dec 10, 10:42 am, Rishi  wrote:
>> 
>>> Hi,
>> 
>>> No. I am not trying to switch between protocols.
>> 
>>> On Dec 8, 11:47 pm, Jeremy Burns | Class Outfit
>> 
>>>  wrote:
 Are yo switching between http and https?
>> 
 Jeremy Burns
 Class Outfit
>> 
 jeremybu...@classoutfit.comhttp://www.classoutfit.com
>> 
 On 9 Dec 2010, at 02:43, Rishi wrote:
>> 
> Hi All,
>> 
> I am new Cakephp. I am using simple login mechanism ( not the standard
> Auth) for checking in user login. I set a session variable in the
> login action and try to access the variable in "graph" action. I am
> unable to read the variable. When I do a var_dump, i get NULL. I have
> tried all the options suggested by users in this group like setting
> security low/medium. Changed cake_session.php @ like 595
>> 
>   if(session_id() == '') {
>session_start();
>}
>> 
> I am using CakePhp 1.3 and Php 5.2.
>> 
> I have been trying to get this up for past couple of days. Please help
> me to solve this problem.!!
>> 
> Check out the new CakePHP Questions sitehttp://cakeqs.organdhelpothers 
> with their CakePHP related questions.
>> 
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group 
> athttp://groups.google.com/group/cake-php?hl=en
> 
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
> 
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Re: Losing Session variables

2010-12-13 Thread dtemes
Without looking at your code nor knowing more about your environment I
guess it will not be easy to help you.

Are you sure the code in your login action is being executed? (if
using auth check the autoRedirect variable)

On 12 dic, 16:37, Rishi  wrote:
> Does anyone have any idea of what is going on ! .. its dealing
> with sessions. I really need some wayout. Please help !!!
>
> On Dec 10, 10:42 am, Rishi  wrote:
>
> > Hi,
>
> > No. I am not trying to switch between protocols.
>
> > On Dec 8, 11:47 pm, Jeremy Burns | Class Outfit
>
> >  wrote:
> > > Are yo switching between http and https?
>
> > > Jeremy Burns
> > > Class Outfit
>
> > > jeremybu...@classoutfit.comhttp://www.classoutfit.com
>
> > > On 9 Dec 2010, at 02:43, Rishi wrote:
>
> > > > Hi All,
>
> > > > I am new Cakephp. I am using simple login mechanism ( not the standard
> > > > Auth) for checking in user login. I set a session variable in the
> > > > login action and try to access the variable in "graph" action. I am
> > > > unable to read the variable. When I do a var_dump, i get NULL. I have
> > > > tried all the options suggested by users in this group like setting
> > > > security low/medium. Changed cake_session.php @ like 595
>
> > > >                       if(session_id() == '') {
> > > >                            session_start();
> > > >                    }
>
> > > > I am using CakePhp 1.3 and Php 5.2.
>
> > > > I have been trying to get this up for past couple of days. Please help
> > > > me to solve this problem.!!
>
> > > > Check out the new CakePHP Questions sitehttp://cakeqs.organdhelpothers 
> > > > with their CakePHP related questions.
>
> > > > You received this message because you are subscribed to the Google 
> > > > Groups "CakePHP" group.
> > > > To post to this group, send email to cake-php@googlegroups.com
> > > > To unsubscribe from this group, send email to
> > > > cake-php+unsubscr...@googlegroups.com For more options, visit this 
> > > > group athttp://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Re: Losing Session variables

2010-12-12 Thread Rishi
Does anyone have any idea of what is going on ! .. its dealing
with sessions. I really need some wayout. Please help !!!

On Dec 10, 10:42 am, Rishi  wrote:
> Hi,
>
> No. I am not trying to switch between protocols.
>
> On Dec 8, 11:47 pm, Jeremy Burns | Class Outfit
>
>
>
>
>
>
>
>  wrote:
> > Are yo switching between http and https?
>
> > Jeremy Burns
> > Class Outfit
>
> > jeremybu...@classoutfit.comhttp://www.classoutfit.com
>
> > On 9 Dec 2010, at 02:43, Rishi wrote:
>
> > > Hi All,
>
> > > I am new Cakephp. I am using simple login mechanism ( not the standard
> > > Auth) for checking in user login. I set a session variable in the
> > > login action and try to access the variable in "graph" action. I am
> > > unable to read the variable. When I do a var_dump, i get NULL. I have
> > > tried all the options suggested by users in this group like setting
> > > security low/medium. Changed cake_session.php @ like 595
>
> > >                       if(session_id() == '') {
> > >                            session_start();
> > >                    }
>
> > > I am using CakePhp 1.3 and Php 5.2.
>
> > > I have been trying to get this up for past couple of days. Please help
> > > me to solve this problem.!!
>
> > > Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp others 
> > > with their CakePHP related questions.
>
> > > You received this message because you are subscribed to the Google Groups 
> > > "CakePHP" group.
> > > To post to this group, send email to cake-php@googlegroups.com
> > > To unsubscribe from this group, send email to
> > > cake-php+unsubscr...@googlegroups.com For more options, visit this group 
> > > athttp://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Re: Losing Session variables

2010-12-10 Thread Rishi
Hi,

No. I am not trying to switch between protocols.

On Dec 8, 11:47 pm, Jeremy Burns | Class Outfit
 wrote:
> Are yo switching between http and https?
>
> Jeremy Burns
> Class Outfit
>
> jeremybu...@classoutfit.comhttp://www.classoutfit.com
>
> On 9 Dec 2010, at 02:43, Rishi wrote:
>
>
>
>
>
>
>
> > Hi All,
>
> > I am new Cakephp. I am using simple login mechanism ( not the standard
> > Auth) for checking in user login. I set a session variable in the
> > login action and try to access the variable in "graph" action. I am
> > unable to read the variable. When I do a var_dump, i get NULL. I have
> > tried all the options suggested by users in this group like setting
> > security low/medium. Changed cake_session.php @ like 595
>
> >                       if(session_id() == '') {
> >                            session_start();
> >                    }
>
> > I am using CakePhp 1.3 and Php 5.2.
>
> > I have been trying to get this up for past couple of days. Please help
> > me to solve this problem.!!
>
> > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others 
> > with their CakePHP related questions.
>
> > You received this message because you are subscribed to the Google Groups 
> > "CakePHP" group.
> > To post to this group, send email to cake-php@googlegroups.com
> > To unsubscribe from this group, send email to
> > cake-php+unsubscr...@googlegroups.com For more options, visit this group 
> > athttp://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Re: Losing Session variables

2010-12-08 Thread Jeremy Burns | Class Outfit
Are yo switching between http and https?

Jeremy Burns
Class Outfit

jeremybu...@classoutfit.com
http://www.classoutfit.com

On 9 Dec 2010, at 02:43, Rishi wrote:

> Hi All,
> 
> I am new Cakephp. I am using simple login mechanism ( not the standard
> Auth) for checking in user login. I set a session variable in the
> login action and try to access the variable in "graph" action. I am
> unable to read the variable. When I do a var_dump, i get NULL. I have
> tried all the options suggested by users in this group like setting
> security low/medium. Changed cake_session.php @ like 595
> 
>   if(session_id() == '') {
>   session_start();
>   }
> 
> I am using CakePhp 1.3 and Php 5.2.
> 
> I have been trying to get this up for past couple of days. Please help
> me to solve this problem.!!
> 
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
> 
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Losing Session variables

2010-12-08 Thread Rishi
Hi All,

I am new Cakephp. I am using simple login mechanism ( not the standard
Auth) for checking in user login. I set a session variable in the
login action and try to access the variable in "graph" action. I am
unable to read the variable. When I do a var_dump, i get NULL. I have
tried all the options suggested by users in this group like setting
security low/medium. Changed cake_session.php @ like 595

   if(session_id() == '') {
session_start();
}

I am using CakePhp 1.3 and Php 5.2.

I have been trying to get this up for past couple of days. Please help
me to solve this problem.!!

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Re: Auth component variables

2010-10-07 Thread Marco
did you try 'allowedActions' => '*', 'allow' is the method.

Marco

On Oct 6, 2:31 am, Jeremy Burns  wrote:
> Looking at this page in the 
> guide:http://book.cakephp.org/view/1251/Setting-Auth-Component-Variables,
> you'd think you could do this:
>
> var $components = array(
>   'Auth' => array(
>         /.../
>         'allow' => '*',
>         /.../
>  )
> );
>
> ...but it seems this is ignored. You have to specify $this->Auth-
>
> >allow('*'); in beforeFilter().
>
> Is this correct, or is it a bug?

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Auth component variables

2010-10-05 Thread Jeremy Burns
Looking at this page in the guide: 
http://book.cakephp.org/view/1251/Setting-Auth-Component-Variables,
you'd think you could do this:

var $components = array(
  'Auth' => array(
/.../
'allow' => '*',
/.../
 )
);

...but it seems this is ignored. You have to specify $this->Auth-
>allow('*'); in beforeFilter().

Is this correct, or is it a bug?

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Re: models: fundamental question referring to member variables

2010-10-03 Thread Jack Timmons
On Sun, Oct 3, 2010 at 6:56 PM, DerBjörn  wrote:
> The user table has a column 'birthtime', but in my page i want to show
> the age in years and days of the user instead.

The you should make a view helper for this, and not bother the data in-transit.

class AgeHelper extends AppHelper {} (I think, I don't have the
inclination ATM to ensure I'm accurate).

> So when i retrieve the data of the database i first need to set the
> birthtime:
>
> $this->Age->setBirthtime($data['User']['birthtime']);
> to be then able to access to calculated years and days:
>
> $user->getAge()->getYears();
> $user->getAge()->getDays();
>
> The same the other way round:
> If i want to randomize the birthtime of the user with my solution i am
> able to do it like that:
> $user->getAge()->randomizeBirthtime();

If you go with my Helper idea, I see no point in any of this. The data
should stay exactly as it came from the database, and your Helper
handle displaying how you want it.

> But when i want to save the user of course first i have to get the
> random birthtime out of its class and put it in the array:
> $this->data['User']['birthtime'] = $this->Age->getBirthtime();
> $this->save($this->data);
>
> Something like that, sorry about my pseudo code.
> The problem is that the most of my member varables are classes
> actually to be able to randomize or do calculations with their values.

And if you go with my method, you don't have to worry about messing
with the data at all. If they change it, you do the same calculations
in the model's beforeSave. Or the controller, whichever holds Cthulhu
off another night.

-- 
Jack Timmons
@_Codeacula

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Re: models: fundamental question referring to member variables

2010-10-03 Thread DerBjörn
Your example and explaination I understand, but what about using other
classes as member variables and not just simple values.
Let me give you an example:
The user table has a column 'birthtime', but in my page i want to show
the age in years and days of the user instead.
So i have a class 'Age':

Pseudocode:
class User(
private $Age = new Age());

So when i retrieve the data of the database i first need to set the
birthtime:
$this->Age->setBirthtime($data['User']['birthtime']);
to be then able to access to calculated years and days:

$user->getAge()->getYears();
$user->getAge()->getDays();

The same the other way round:
If i want to randomize the birthtime of the user with my solution i am
able to do it like that:
$user->getAge()->randomizeBirthtime();

But when i want to save the user of course first i have to get the
random birthtime out of its class and put it in the array:
$this->data['User']['birthtime'] = $this->Age->getBirthtime();
$this->save($this->data);

Something like that, sorry about my pseudo code.
The problem is that the most of my member varables are classes
actually to be able to randomize or do calculations with their values.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Re: models: fundamental question referring to member variables

2010-10-03 Thread Miles J
Theres no point for getters and setters if they dont do anything to
the property. If it just sets and gets without modifying the data in
any way, you might as well just use public properties. However, Cake
does support the active record approach.

$user = new User();
$user->username = 'miles';
$user->email = 'em...@domain.com';
$user->save();

On Oct 3, 1:12 pm, DerBjörn  wrote:
> Hi,
>
> as a newbie to cakephp for me it looks like that 'normal' models don't
> have any more common member variables, but associative arrays.
>
> For example I have a model 'Person' with firstname, lastname, age etc.
>
> Generally i would solve this with member variables $firstname,
> $lastname and $age and their common getters and setters
> setFirstname($value), getAge(), etc., but this still does have sense?
> When i save a person i have to use an associative array, so with my
> technique i need to create first an array ($data = array()) out of my
> common member variables to pass it to model's function ->save($data)
>
> Does it mean that the common member variables are obsolete and i
> actually only have to use one member variable $data and use it then
> like:
>
> function setFirstname($value){ $this->data['firstname'] = $value;}; or
> function getAge(){ return $this->data['age']; }; ?
>
> The same when i want to make a new instance of a Person and retrieve
> their variables from the database:
> Does it has to look like following then?
>
> $person = new Person();
> $person->retrieve(5); // ID
>
> and the model Person has a function retrieve($id) when i get then its
> data from the database and set it to $this->data??
>
> I hope i made me explain at least a little and you understand my
> question :)
> Thanks for any advice or example!

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


models: fundamental question referring to member variables

2010-10-03 Thread DerBjörn
Hi,

as a newbie to cakephp for me it looks like that 'normal' models don't
have any more common member variables, but associative arrays.

For example I have a model 'Person' with firstname, lastname, age etc.

Generally i would solve this with member variables $firstname,
$lastname and $age and their common getters and setters
setFirstname($value), getAge(), etc., but this still does have sense?
When i save a person i have to use an associative array, so with my
technique i need to create first an array ($data = array()) out of my
common member variables to pass it to model's function ->save($data)

Does it mean that the common member variables are obsolete and i
actually only have to use one member variable $data and use it then
like:

function setFirstname($value){ $this->data['firstname'] = $value;}; or
function getAge(){ return $this->data['age']; }; ?

The same when i want to make a new instance of a Person and retrieve
their variables from the database:
Does it has to look like following then?

$person = new Person();
$person->retrieve(5); // ID

and the model Person has a function retrieve($id) when i get then its
data from the database and set it to $this->data??

I hope i made me explain at least a little and you understand my
question :)
Thanks for any advice or example!

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Re: Accessing variables in referenced tables in views

2010-09-14 Thread Andrew Alexander
So am I approaching this the wrong way?
I could make a method in my controller to retrieve the variables, but
that seems like bad design to me

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Re: passing variables to controller function from JS

2010-08-29 Thread Anthony
I make use of the automatic url parsing and pass my URLs in the form
controller/action/var1:value1/var2:value2/etc:etc

This provides two benefits, one you setup your actions like this:

function action_name(var1, var2) {  if your always going to submit in
the same order

or you can make use of the named variables so that order no longer
matters.

you then setup your action to not use any parameters and instead check
the named variables existence and value like this:

function action_name() {
if (!empty( $this->params['named'][var1'] ) {
   $var1 = $this->params['named'][var1'];
}
else {
 die('var1 is empty');
}



On Aug 29, 8:14 am, Tomfox Wiranata  wrote:
> hi,
>
> i have this function called in my view. it is JS.
>
> ajaxUpload(form,'processFlyer','flyer_css',' loader.gif\' width=\'16\' height=\'16\' border=\'0\' />','Fehler beim
> Upload');
>
> the processFlyer is a function in my controller. how can i pass
> variables with this call?
>
> i know it works with jquery like this
> $('#flyer_preview').('countattachments', {attachmentcount: count});
>
> but not with pure JS...
>
> big thx  :)

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


passing variables to controller function from JS

2010-08-29 Thread Tomfox Wiranata
hi,

i have this function called in my view. it is JS.

ajaxUpload(form,'processFlyer','flyer_css','','Fehler beim
Upload');

the processFlyer is a function in my controller. how can i pass
variables with this call?

i know it works with jquery like this
$('#flyer_preview').('countattachments', {attachmentcount: count});


but not with pure JS...

big thx  :)

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Re: Accessing variables in referenced tables in views

2010-08-18 Thread Andrew Alexander
And yes thread.php and post.php has a belongsTo User.

post.php:
var $belongsTo = array(
'Thread' => array(
'className' => 'Thread',
'foreignKey' => 'thread_id',
'conditions' => '',
'fields' => '',
'order' => ''
),
'User' => array(
'className' => 'User',
'foreignKey' => 'user_id',
'conditions' => '',
'fields' => '',
'order' => ''
)
);

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Re: Accessing variables in referenced tables in views

2010-08-18 Thread Andrew Alexander
Placing "" in view.ctp gives me the error:
Notice (8): Undefined variable: threads [APP\views\threads\view.ctp,
line 1]

If I use the "$thread" variable instead, I get an array with posts and
their user_ids but not the usernames:
"Array ( [Thread] => Array ( [id] => 7 [subject] => c [user_id] => 5
[body] => c [created] => 2010-08-16 14:00:31 [modified] => 2010-08-16
14:00:31 ) [User] => Array ( [id] => 5 [username] => root [password]
=> 6abfa9223de79de9fbb2327c8c999043c2210177 [group_id] => 1 [created]
=> 2010-08-16 12:20:32 [modified] => 2010-08-16 12:20:32 ) [Post] =>
Array ( [0] => Array ( [id] => 62 [subject] => [body] => ... [created]
=> 2010-08-17 14:43:42 [modified] => 2010-08-17 14:43:42 [thread_id]
=> 7 [user_id] => 8 ) [1] => Array ( [id] => 61 [subject] => [body]
=> ... [created] => 2010-08-17 14:43:38 [modified] => 2010-08-17
14:43:38 [thread_id] => 7 [user_id] => 8 ) [2] => Array ( [id] => 60
[subject] => . [body] => . [created] => 2010-08-17 14:43:34 [modified]
=> 2010-08-17 14:43:34 [thread_id] => 7 [user_id] => 8 ) ) ) "

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Re: Accessing variables in referenced tables in views

2010-08-17 Thread Andras Kende


Is your thread.php model has a belongsTo User ?

 is this prints the User array ?

Andras Kende
http://www.kende.com

On Aug 17, 2010, at 11:22 AM, Andrew Alexander wrote:

> I am attempting to create a forum in php. In my project I have tables:
> threads, posts, users. And each post has a foreign key for a thread
> and a user. In my thread view I want to replace the user_id field with
> the corresponding username for each post. I've tried "echo
> $post['User']['username'];" but that gives me an error.
> 
> Is there a way to access the username variable from the thread view?
> 
> 
> Here's the code I have in view now:
>  $i = 0;
>   foreach ($thread['Post'] as $post):
>   $class = null;
>   if ($i++ % 2 == 0) {
>   $class = ' class="altrow"';
>   }
>   ?>
>   >
>   
>   
>   
>   
>   
>   Html->link(__('View', true), 
> array('controller'
> => 'posts', 'action' => 'view', $post['id'])); ?>
>   Html->link(__('Edit', true), 
> array('controller'
> => 'posts', 'action' => 'edit', $post['id'])); ?>
>   Html->link(__('Delete', true),
> array('controller' => 'posts', 'action' => 'delete', $post['id']),
> null, sprintf(__('Are you sure you want to delete # %s?', true),
> $post['id'])); ?>
>   
>   
>   
> 
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
> 
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Accessing variables in referenced tables in views

2010-08-17 Thread Andrew Alexander
I am attempting to create a forum in php. In my project I have tables:
threads, posts, users. And each post has a foreign key for a thread
and a user. In my thread view I want to replace the user_id field with
the corresponding username for each post. I've tried "echo
$post['User']['username'];" but that gives me an error.

Is there a way to access the username variable from the thread view?


Here's the code I have in view now:

>





Html->link(__('View', true), 
array('controller'
=> 'posts', 'action' => 'view', $post['id'])); ?>
Html->link(__('Edit', true), 
array('controller'
=> 'posts', 'action' => 'edit', $post['id'])); ?>
Html->link(__('Delete', true),
array('controller' => 'posts', 'action' => 'delete', $post['id']),
null, sprintf(__('Are you sure you want to delete # %s?', true),
$post['id'])); ?>




Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Re: Using Variables (data from db) in Controller

2010-07-21 Thread cricket
On Wed, Jul 21, 2010 at 9:51 AM, Mad Stacks  wrote:
> Hi, I'm new to CakePHP. I'm working on a project using it and so far I
> love it, but I have a question.
>
> I have created my database, and the tables, filled in some sample
> data, and used cake bake all for each of my tables.
> Everything worked great, my table relationships were all configured
> correctly because I followed the Cake naming conventions.
>
> There are Submissions, that belong to a Job. (a submission has a
> job_id)
>
>
> In my submissions controller, I want to retrieve the job_id.
>
> Here is the code:
> $temp = $this->Submission->Job->id;    //this does not work
>
> $temp = $this->Submission->Job;  // this however DOES return the Job
> object??? (i think)
>
> $temp = $this->Submission->id;  // this does return the Submission ID
>
> $temp = $this->Submission->job_id;   //this does not work though...
>
>
>
> These were tried in the function:
>
> function delete($id = null) {
>
> }
>

function delete($id = null)
{
if (empty($id))
{
$this->Session->flash(...);
}

$data = $this->Submission->read(null, $id);

...
}

You should then be able to get the Job id from either
$data['Submission']['id'] or $data['Job']['id'].

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Using Variables (data from db) in Controller

2010-07-21 Thread Mad Stacks
Hi, I'm new to CakePHP. I'm working on a project using it and so far I
love it, but I have a question.

I have created my database, and the tables, filled in some sample
data, and used cake bake all for each of my tables.
Everything worked great, my table relationships were all configured
correctly because I followed the Cake naming conventions.

There are Submissions, that belong to a Job. (a submission has a
job_id)


In my submissions controller, I want to retrieve the job_id.

Here is the code:
$temp = $this->Submission->Job->id;//this does not work

$temp = $this->Submission->Job;  // this however DOES return the Job
object??? (i think)

$temp = $this->Submission->id;  // this does return the Submission ID

$temp = $this->Submission->job_id;   //this does not work though...



These were tried in the function:

function delete($id = null) {

}


Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Re: load configure variables from DB.

2010-07-13 Thread Shashidhar
the second implementation could work for me. Thanks :)

Regards,
Shashidhar.G

On Jul 14, 2:02 am, Sam  wrote:
> Actually, this implementation is 
> better:http://dsi.vozibrale.com/articles/view/simple-db-based-configuration-...
>
> On Jul 13, 1:45 pm, Shashidhar  wrote:
>
> > Hello,
>
> > In my project we need to store come configure in the DB, and these
> > need to variables needs to be accessed though out the files. I have
> > been trying to figure a way to do this, by googling around. I keep
> > getting the answer as to have in the bootstrap.php, but no examples.
> > Can anyone suggest me how can load these variables stored in the DB
> > and be available through out my modes, controllers and views. If the
> > answer is still to put it in the bootstrap.php please provide with
> > examples, as I am unable to find any good examples for bootstrap.php
> > file.
>
> > Thanks & Regards,
> > Shashidhar.G

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Re: load configure variables from DB.

2010-07-13 Thread Sam
Actually, this implementation is better:
http://dsi.vozibrale.com/articles/view/simple-db-based-configuration-for-cakephp-apps

On Jul 13, 1:45 pm, Shashidhar  wrote:
> Hello,
>
> In my project we need to store come configure in the DB, and these
> need to variables needs to be accessed though out the files. I have
> been trying to figure a way to do this, by googling around. I keep
> getting the answer as to have in the bootstrap.php, but no examples.
> Can anyone suggest me how can load these variables stored in the DB
> and be available through out my modes, controllers and views. If the
> answer is still to put it in the bootstrap.php please provide with
> examples, as I am unable to find any good examples for bootstrap.php
> file.
>
> Thanks & Regards,
> Shashidhar.G

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Re: load configure variables from DB.

2010-07-13 Thread Sam
Behold, Google Search:
http://bakery.cakephp.org/articles/view/simply-storing-config-values-in-the-db


variables can be accessed throughout the App via Configure::read

On Jul 13, 1:45 pm, Shashidhar  wrote:
> Hello,
>
> In my project we need to store come configure in the DB, and these
> need to variables needs to be accessed though out the files. I have
> been trying to figure a way to do this, by googling around. I keep
> getting the answer as to have in the bootstrap.php, but no examples.
> Can anyone suggest me how can load these variables stored in the DB
> and be available through out my modes, controllers and views. If the
> answer is still to put it in the bootstrap.php please provide with
> examples, as I am unable to find any good examples for bootstrap.php
> file.
>
> Thanks & Regards,
> Shashidhar.G

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


load configure variables from DB.

2010-07-13 Thread Shashidhar
Hello,

In my project we need to store come configure in the DB, and these
need to variables needs to be accessed though out the files. I have
been trying to figure a way to do this, by googling around. I keep
getting the answer as to have in the bootstrap.php, but no examples.
Can anyone suggest me how can load these variables stored in the DB
and be available through out my modes, controllers and views. If the
answer is still to put it in the bootstrap.php please provide with
examples, as I am unable to find any good examples for bootstrap.php
file.


Thanks & Regards,
Shashidhar.G

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Re: Auth variables being ignored

2010-06-23 Thread Jeremy Burns | Class Outfit
I was making a stupid mistake. For the record, I was calling 
parent::beforeFilter(), which was overriding my values.

Jeremy Burns
Class Outfit

jeremybu...@classoutfit.com
http://www.classoutfit.com

On 23 Jun 2010, at 08:55, Jeremy Burns wrote:

> I have a site built on 1.3.2 with the following app_controller.php
> file:
> 
>   class AppController extends Controller {
> 
>   var $components = array('Auth', 'Session');
> 
>   var $helpers = array('Html', 'Form', 'Session', 'Text');
> 
>   function beforeFilter() {
> 
>   parent::beforeFilter();
> 
>   $this->Auth->loginError = "You have entered the wrong 
> username or
> password.";
>   $this->Auth->authError = "You do not have permission to 
> access that
> page.";
>   $this->Auth->logoutRedirect = array('controller' => 
> 'pages',
> 'action' => 'home');
> 
>   }
> 
>   }
> 
> When a login fails I get the standard error message ("Login failed.
> Invalid username or password.") so it appears that the settings in
> app_controller are being ignored. I have also added other variables
> such as logoutRedirect and they are being ignored too.
> 
> Any ideas?
> 
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
> 
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


  1   2   3   4   5   >