Re: Cake 2.2 Can't save/update database

2012-09-17 Thread Max Dörfler

A few Ideas:
* set your primaryKey attribute to 'ID' in the model: 
http://book.cakephp.org/2.0/en/models/model-attributes.html#primarykey

* debug the return value of your save($data) call
* debug $this->Player->validationErrors after the save call
* try setting the model ID ($this->Player->id = $playerID) and then save 
or saveField


Max

On 09/16/2012 11:18 PM, d6games wrote:
The following code in my PlayersController doesn't error but also 
doesn't save anything to the database table...


private function authorize($tag, $pass) {
$findPlayer = $this->Player->find('first', array(
'conditions' => array('Tag' => $tag, 'Password' => $pass)
));
$playerID = 0;
if ( count($findPlayer) > 0 ) {
$playerID = $findPlayer['Player']['ID'];
$data = array('id' => $playerID, 'CurrentLogin' => date('c'));
$this->Player->save($data);
}
unset($findPlayer);
return $playerID;
}

In my table the "id" field is actually "ID", however if I change the 
$data line above to "ID", then cake switches to Insert mode and blows 
up. So far nothing I do will update the table. What am I doing wrong?


Thanks for your advice. I'm spinning my wheels...

Mark

--
Like Us on FacekBook 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.




--
Like Us on FacekBook 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: Problem with adding records

2012-07-11 Thread Max Dörfler

Is the Auto Increment attribute set for the ID column?

On 07/11/2012 03:39 PM, mohit kumar wrote:

Hi Folks,

I created an add action for users,
I am trying to register them using this action. Everything is going 
fine, the data is being submitted, the passwords are being hash and if 
I check the registration is happening. But I am getting the following 
error.


Integrity constraint violation: 1062 Duplicate entry '0' for key
'PRIMARY'


I googled it to found a link which states that

The only way we could fix it, is by rebuilding the entire database
from scratch.

Dropping all tables and reloading them from a backup.


I tried that also , still getting that error.

Thanks for help in advance

--
Best Regards,
Mohit Kumar


--
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: Edit User on second submit

2012-07-11 Thread Max Dörfler
I guess in your view you have to pass in the id (echo 
$this->Form->input('id');). This should include a hidden id field.
I wonder why it works the first time (without leaving a field blank). 
Are you sure the user gets edited and not a new user created? Because 
when you save $this->request->data, the data shouldn't contain the id if 
you didn't pass it from the view!


On 07/11/2012 03:20 PM, Banana Man wrote:

Hi,

I am trying to setup an Edit User authentication action.  I have 
authentication working fine for adding a user but when i try to edit a 
user i am running into a problem.


If i try to edit a user when all information supplied passes 
validation it works fine (URL: http://localhost/users/edit/3).  If 
however i leave a textfield blank when i am validating it against 
'notEmpty' the first time i hit the form submit button it works as 
expected and reloads the edit user page with the validation error 
displayed (URL: http://localhost/users/edit/3).  If i do nothing and 
try to submit the form again with the blank textfield i now get 
redirected to http://localhost/users/edit with an Invalid User message 
"*Error: * The requested address *'/users/edit'* was not found on this 
server."



 public function edit($id = null) {
$this->User->id = $id;
if (!$this->User->exists()) {
throw new NotFoundException(__('Invalid user'));
}
if ($this->request->is('post') || $this->request->is('put')) {
if ($this->User->save($this->request->data)) {
$this->Session->setFlash(__('The user has been saved'));
$this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The user could not be 
saved. Please, try again.'));

}
} else {
$this->request->data = $this->User->read(null, $id);
}
}





Form->create('User', array('action' => 'edit'));?>


Session->flash();
echo $this->Form->input('firstname', array('label' => 'First Name'));
echo $this->Form->input('secondname', array('label' => 'Second Name'));
echo $this->Form->input('address_01', array('label' => 'Address Line 1'));
echo $this->Form->input('address_02', array('label' => 'Address Line 2'));
echo $this->Form->input('address_03', array('label' => 'Address Line 3'));
echo $this->Form->input('address_04', array('label' => 'Address Line 4'));
echo $this->Form->input('tel_01', array('label' => 'Telephone'));
echo $this->Form->input('email');
echo $this->Form->hidden('role', array('value' => 'customer'));
?>

Form->end(__('Submit'));?>





Html->link(__('List Users'), array('action' => 
'index'));?>






Does anyone know why i am getting redirected on the second submit?

Thanks!
--
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: Is there a way to override CakeRequest.php (and for that matter any other Lib file) at the App level?

2012-07-03 Thread Max Dörfler

Hi,

have you tried copying the core "CakeRequest.php" to 
"app/Lib/Cake/Network/CakeRequest.php" and do your changes there? I 
think I remeber doing something like this with the Dispatcher and cake 
automagically used the one from the app. The problem I had back then was 
that I had to copy the whole class instead of just putting an extended 
class there.


On 07/03/2012 03:01 PM, Tom Cowle wrote:
My web hosting in on a load balanced server, which means that HTTPS 
cannot be detected in the usual way. My host includes a custom header 
which allows detection of HTTPS.


This means that the CakePHP request->isSSL() functionality does not 
work out of the box.


I can fix this easily in Lib/Cake/Network/CakeRequest.php - however, I 
know it is bad practice to modify files in Lib as changes will be 
overridden if CakePHP is upgraded.


Is there a way to override CakeRequest (and for that matter any other 
Lib file) at the App level?


Thanks,

Tom
--
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: User Info from Auth Component

2012-06-20 Thread Max Dörfler
Like I said: You are passing data into the login function. In 2.0 this 
"will log the user in with whatever data is posted". Thats why only the 
two fields posted are displayed and the PW isn't hashed. Since you 
haven't specified what version of cake you are using, I still assume 
this is the reason. If you say you don't use cake 2.x I'll stop 
bothering you. ;)


On 06/20/2012 09:27 PM, Joey Hauschildt wrote:
I just followed the tutorial in the book. The only custimization I 
made was was using the email field instead of the username field.


Here is my AppController:

class AppController extends Controller {

public $uses = array('User');
public $components = array(
'Session',
'Auth' => array(
'loginRedirect' => array('controller' => 'posts', 'action' 
=> 'index'),
'logoutRedirect' => array('controller' => 'pages', 
'action' => 'display', 'home')

)
);

public function beforeFilter() {
$this->Auth->allow('index', 'view');
$this->set('logged_in', $this->Auth->LoggedIn());
$this->set('current_user', $this->Auth->user());
//debug($this->Session->read('Auth.User'));
}

public function isAuthorized($user) {
return TRUE;
}

}


And here is my Users/login action:

public function login() {
if ($this->request->is('post')) {

if ($this->Auth->login($this->request->data)) {
return $this->redirect($this->Auth->redirect());
} else {
$this->Session->setFlash(__('Username or password is 
incorrect'), 'default', array(), 'auth');

}
}
}


The beforeFilter in my Users controller:

public function beforeFilter() {
parent::beforeFilter();
$this->Auth->fields = array('username' => 'email', 'password' 
=> 'password');

$this->Auth->allow('add', 'logout');
}



On Wednesday, June 20, 2012 12:31:35 AM UTC-6, Борислав Събев wrote:

This could be the case - a wrongly implemented Authentication
system. @Joey Hauschildt $this->Auth->user() and the "Auth.User"
Session key should both return/contain the full user information -
i.e. all fields from the users DB table. This behaviour is
strange. Can you provide more info on your exact implementation.

Cheers,
   Borislav.


On Wednesday, 20 June 2012 00:36:24 UTC+3, Max Dörfler wrote:


http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html#identifying-users-and-logging-them-in

<http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html#identifying-users-and-logging-them-in>

"In 2.0 $this->Auth->login($this->request->data) will log the
user in with whatever data is posted, whereas in 1.3
$this->Auth->login($this->data) would try to identify the user
first and only log in when successful."

I assume you are yousing 2.x. I guess this is what you are
looking for. Call login() without params.

On 06/19/2012 11:18 PM, Joey Hauschildt wrote:

I am. All passwords in the db are hashed. The problem seems
to be that instead of getting info from the users table, it
is only filling debug($this->Session->read('Auth.User'));
and debug($this->Auth->User()) with data from the form.
Otherwise the password would be hashed. It has nowhere else
to get an unhashed password from. This seems like a pretty
poor choice for default behavior. I would prefer that my app
didn't store passwords from the form anywhere.

On Tuesday, June 19, 2012 2:50:45 PM UTC-6, Jeremy Burns wrote:

You should be hashing the password before saving it.

Jeremy Burns
Class Outfit

http://www.classoutfit.com

On 19 Jun 2012, at 19:41:30, Joey Hauschildt wrote:


debug($this->Session->read('Auth.User'));
and debug($this->Auth->User()); both return:

array(
'User' => array(
'password' => '*',
'email' => 't...@example.com <mailto:t...@example.com>'
)
)

These are the fields that the user uses to log in. The
password isn't even hashed. When I print_r, it displays
the actual password. I would like to have acce

Re: User Info from Auth Component

2012-06-19 Thread Max Dörfler

http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html#identifying-users-and-logging-them-in

"In 2.0 $this->Auth->login($this->request->data) will log the user in 
with whatever data is posted, whereas in 1.3 
$this->Auth->login($this->data) would try to identify the user first and 
only log in when successful."


I assume you are yousing 2.x. I guess this is what you are looking for. 
Call login() without params.


On 06/19/2012 11:18 PM, Joey Hauschildt wrote:
I am. All passwords in the db are hashed. The problem seems to be that 
instead of getting info from the users table, it is only filling 
debug($this->Session->read('Auth.User')); 
and debug($this->Auth->User()) with data from the form. Otherwise the 
password would be hashed. It has nowhere else to get an unhashed 
password from. This seems like a pretty poor choice for default 
behavior. I would prefer that my app didn't store passwords from the 
form anywhere.


On Tuesday, June 19, 2012 2:50:45 PM UTC-6, Jeremy Burns wrote:

You should be hashing the password before saving it.

Jeremy Burns
Class Outfit

http://www.classoutfit.com

On 19 Jun 2012, at 19:41:30, Joey Hauschildt wrote:


debug($this->Session->read('Auth.User'));
and debug($this->Auth->User()); both return:

array(
'User' => array(
'password' => '*',
'email' => 't...@example.com '
)
)

These are the fields that the user uses to log in. The password
isn't even hashed. When I print_r, it displays the actual
password. I would like to have access to other user info like an
ID or role. Do I need to use my own query to get this info or
should the Auth Component be grabbing that stuff for me?.

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


--
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: Count (return as a number) associated data.

2012-06-18 Thread Max Dörfler
You could get the size of $result['Post'] if you already have the 
$result like you wrote. See count() or sizeof().
Or you could do a find('count') on the Post Model like 
$this->User->Post->find('count', array('conditions' => 
array('Post.user_id' => 2)));


On 06/19/2012 12:24 AM, JonStark wrote:

Sorry, incomplete :

It will produce an array like :

array(
'User' =>  array(
'password' =>  '*',
'id' =>  '2',
'username' =>  'test',

),
'Post' =>  array(
(int) 0 =>  array(
'id' =>  '36',
'user_id' =>  '2', (...)

)
),

How can I display the number of Posts this user have ? (in this 
example 1) ?


Thanks a lot.

Le mardi 19 juin 2012 00:21:25 UTC+2, JonStark a écrit :

Let's say USer hasMany Post.

If i debug my user it will produce an array like :

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


--
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: RSS in the Bakery broken

2010-10-27 Thread Max Dörfler

Am 27.10.2010 12:19, schrieb Max D:

Hey,

the RSS feed in the bakery seems to be broken. I worked a while ago,
but now http://bakery.cakephp.org/articles/rss throws an error:
Error:  The requested address '/articles/rss' was not found on this
server.

I didn't know who to contact with this issue.

Regards
Max
   
Okay, they seem to have changed the URL, but didn't change the link tags 
in the head.

The new url is http://bakery.cakephp.org/articles.rss

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: where can i find permissions to delete folders?

2010-09-07 Thread Max Dörfler
Sorry, I thought you could delete the emty dir but not as long as it has 
a subfolder.
Are you running a unix OS? I guess it's some kind of permission error. 
The directory you want to delete needs to be writable by the user the 
webserver runs under (usually www-data or something).
I cant't go into great detail, because now I'm not sure what causes the 
problem. I thought it just was the rmdir thingie. ;) Sorry!


Max


Am 07.09.2010 14:40, schrieb Tomfox Wiranata:

thx max...

but even if it is empty i get the same error

is there maybe a file where i can set some paths free for deletion?

On 7 Sep., 14:19, "Max Dörfler"  wrote:
   

rmdir just works on emty directories

 NAME
 rmdir - remove empty directories

 SYNOPSIS
 rmdir [OPTION]... DIRECTORY...

 DESCRIPTION
 Remove the DIRECTORY(ies), if they are empty.

"rm -r" would recursively delete a nonempty directory, but it's a
dangerous command to use :)

Am 07.09.2010 13:38, schrieb Tomfox Wiranata:

 

hi
   
 

i am getting a permission denied when using the rmdir function. but
just for a subfolder. like this. i can delete the folder 666 in
   
 

WWW_ROOT. "links/tmp/666
   
 

but i cant delete folder 666 when a subfolder is in it, like
WWW_ROOT. "links/tmp/666/attachments
   
 

is this a permission thing?
   
 

i appreciate your help :)
   
 

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
   


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: where can i find permissions to delete folders?

2010-09-07 Thread Max Dörfler

rmdir just works on emty directories

   NAME
   rmdir - remove empty directories

   SYNOPSIS
   rmdir [OPTION]... DIRECTORY...

   DESCRIPTION
   Remove the DIRECTORY(ies), if they are empty.


"rm -r" would recursively delete a nonempty directory, but it's a 
dangerous command to use :)


Am 07.09.2010 13:38, schrieb Tomfox Wiranata:

hi

i am getting a permission denied when using the rmdir function. but
just for a subfolder. like this. i can delete the folder 666 in

WWW_ROOT. "links/tmp/666


but i cant delete folder 666 when a subfolder is in it, like
WWW_ROOT. "links/tmp/666/attachments

is this a permission thing?

i appreciate your help :)


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: isAuthorized seems not to be called

2010-09-06 Thread Max Dörfler

Hi,

Since it's the login and register action, I bet you have them in 
allow(). So the Auth component is disabled for those actions and 
isAuthorized is never called. You need to check it somewhere else (e.g. 
beforeFilter).


Max

Am 05.09.2010 22:28, schrieb Simon:

I have a isAuthorized function in my controller because $this->Auth-
   

authorize is set to 'controller'.
 

This is my function (the comments explains everything):
function isAuthorized()
{
parent::isAuthorized();

//if the user is logged in. He cannot access the register and login
function
if( ($this->action == 'registreren') || ($this->action ==
'login') )
{
 if( $this->Auth->user() )
{
return false;
 }
else
{
   return true;
}
 }

 //other actions are available for everyone
 return true;
}

The problem is that it seems that this function is not called because
when I'm logged in, I still can access the registreren action.

Is there something I'm doing wrong. Or have I misunderstood the
meaning of this function?

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: CakePHP site, all pages locked out to non-admins

2010-09-01 Thread Max Dörfler
 This sounds like the default deny message by the Auth component. 
(http://book.cakephp.org/view/1250/Authentication)
Putting Auth in the components array locks you out of every action by 
default. Look if the Auth component is in your app_controller or some 
other controller. To disable Auth for all/some actions, read about the 
allow() function (http://book.cakephp.org/view/1257/allow)


Max

Am 01.09.2010 20:04, schrieb Skip Evans:

Hey all,

I'm pretty new to CakePHP, but a long time PHP coder, and am doing
some maintenance work on an existing Cake site. Right now, any attempt
to access a page results in a message displayed that says "You are not
authorized to access that location.".

I've been searching docs, the web, etc, and believe perhaps the
original programmer, who of course is MIA, implemented something with
"function afterFilter()" or some other mechanisms that locks all the
pages out.

This was originally done to protect sections during development, but
the site is now ready for some live testing operations like PayPal e-
commerce stuff I've built in and I need to release the site from this
protections.

Any help would be greatly appreciated.

If it turns out we need to contract a Cake expert for a few hours I
think the client will go for that.

Skip

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: after adding an hasOne relation to model it is not available in my view anymore

2010-08-19 Thread Max Dörfler

 Hi,

whats the find call for $user?
what does debug($user); spit out?

Greetings
Max

Am 19.08.2010 20:58, schrieb Tomfox Wiranata:

hi,

weird thing. i declare a hasOne relation:

class User extends AppModel
{
 var $name = 'User';

 var $hasOne = array(
'Link' =>  array(
'className' =>  'Link',
'dependent' =>  true
)
);
}


suddenly i am having "undefined index" everywhere i use that model in
my views, like:




if i delete the hasOne part it works fine and the view shows the user
data...what the heck did i do wrong? looking forward to your
feedback..

big 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


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: Save moltiple fields at once

2010-08-17 Thread Max Dörfler

Hi,

see saveAll http://book.cakephp.org/view/1031/Saving-Your-Data
You can create the form which generates the needed output to feed 
saveAll like the following:


Form->create('Setting');
foreach ($settings as $key => $setting) {
echo $this->Form->input('Setting.'.$key.'.id', array('value' => 
$setting['Setting']['id']));

echo $this->Form->input('Setting.'.$key.'.value');
}
echo $this->Form->end('edit');
?>

This should work. Please correct me, if there is an easier way.

Regards
Max

Am 17.08.2010 10:39, schrieb Konstantin:

Hello!

I have a settings table and I want to edit all fields on one page and
save them all with one click. Table structure and sample html are
listed below.
How can I create a form in CakePHP? $form->input seems to work with
only a single element, and I don't know how to loop through all
elements and create multiple inputs.

Thanks!

CREATE TABLE IF NOT EXISTS `settings` (
   `id` int(11) NOT NULL,
   `field` varchar(255) NOT NULL,
   `value` varchar(255) NOT NULL
);



   Field 1:
   


   Field 2:
   


   Field 3:
   



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: auth component issue

2010-08-12 Thread Max Dörfler

Hi,

that is beacuse when you create the user, the plaintext password gets 
encrypted. When you now edit the user, the encrypted password gets 
loaded and when you save your user, the encrypted password gets 
encrypted again. (so the already encrypted password is handled as if 
it's a plaintext password).
So, to keep the encrypted password, don't save it again. (unset the 
password field or don't load it or exclude it from your fields array or ...)


Greetings
Max

Am 12.08.2010 14:32, schrieb james:

Hi,

I'm using the auth component and ive noticed that if i edit a users
details from within the app it automatically changes the encrypted
password. Any ideas as to why it would do this?

thanks,

James.

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: hasMany Problem

2010-08-11 Thread Max Dörfler

Hi,

ich bin mir nicht sicher, ob ich das alles richtig verstehe, kannst du 
vielleicht den Code deiner Models (den ganzen hasOne, hasMany, belongsTo 
Kram) schicken? Da du dich scheinbar auch nicht so richtig an die 
Namenskonventionen hältst, ist das übersichtlicher. :)
Weil z.B. eine "Friend" Relation ja typischerweise User HABTM User 
Relation ist.
Ich denke, wenn die ganzen Relationen ordentlich definiert sind, sollte 
das mit dem richtigen Rekursionslevel out of the box funktionieren.


Und wenn du hier auf englisch fragst, sind die Chancen eine gute Antwort 
zu erhalten wesentlich höher. ;)


Gruß
Max

Am 11.08.2010 10:30, schrieb JuMiFi:

Hallo liebe Community,

ich habe eine Frage bzgl. hasMany...

Ich habe ein Model "User" (users), welches via hasOne u.a. auf
"Account" (users_accounts) und "File" (users_files) zugreift.
Ausserdem kann es via hasMany auf "Friends" (friends) zugreifen.

users_files beinhaltet die Uploads eines Users (Profilepic etc...).
Jetzt würde ich gerne mit $this->User->findById() nicht nur User,
Account, File und Friends bekommen, sondern für die Friends wiederum
ausserdem File aus users_files und Account aus users_account...
Verknüpfungen laufen natürlich jeweils über user(s)_id bzw.
friend_id

Strukturell also so:

User
User[Account]
User[File]
User[Friends]
User[Friends][Account]
User[Friends][File]

Danke für eure Hilfe!

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


Custom find Methods in Behavior

2010-08-11 Thread Max Dörfler

Hey,

I heard of this cool method of writing custom find methods in 
tehtreags's bakery post 
(http://bakery.cakephp.org/articles/view/model-repletion) and now tried 
to use it in a Behavior, but failed.


Im using cake 1.3.0

The Code:
http://pastebin.com/92753BmZ

The Problem:
- I have an article Model which acts as Featurable
- In the Featurable behavior setup method  I set the models 
_findMethods['featured'] as true. and define a function 
_findFeatured($state, $query, $results=array())
- When I do an Article->find('featured'), it seems to look for the right 
find function, but cannot find it, which results in a SQL error, because 
the query is "_findFeatured"
- When I define the _findFeatured(...) method in the actual Article 
Model, it works


I think it has something to do with the _findFeatured function being 
protected. Am I right? Is there any way to  add custom find methods in a 
behavior?


Thanks
Max


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: Upload Photo Using PHP

2010-07-22 Thread Max Dörfler

Hi,

have a look at File Fields:
http://book.cakephp.org/view/1411/File-Fields

and the FileUpload Component, which does pretty much everything for you.
http://github.com/webtechnick/CakePHP-FileUpload-Plugin
It works with or without a model, but it's all explained in the readme.

Am 22.07.2010 11:09, schrieb Norsyahida Sulaiman:

I'm new in framework. to use upload photo function. what should be
done on view , function on Controller and also model part. i'm
freaking out

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


saveAll and validation Error on associated Model

2010-07-19 Thread Max Dörfler

Hi Folks,

I Have the following:

Transaction hasMany ArticlesTransaction
Transaction belongsTo Address

ArticlesTransaction belongsTo Article
ArticlesTransaction belongsTo Transaction
ArticlesTransaction belongsTo Shipping

(and some other Associations)

and want to save the following with Transaction->saveAll()

Array
(
[Address] =>  Array
(
[firstname] =>  Peter
[secondname] =>  Lustig
[street] =>  bananenstr. 123
[town] =>  Bierlin
[postcode] =>  12345
[country_id] =>  11
)

[Transaction] =>  Array
(
[user_id] =>  3
[state] =>  confirmed
)

[ArticlesTransaction] =>  Array
(
[0] =>  Array
(
[article_id] =>  1
[quantity] =>  3
[shipping_id] =>  6
)

[1] =>  Array
(
[article_id] =>  2
[quantity] =>  2
[shipping_id] =>  4
)

[2] =>  Array
(
[article_id] =>  3
[quantity] =>  2
[shipping_id] =>  4
)

)

)

But saveAll fails and the following is in $this->Transaction->validationErrors

Array
(
[ArticlesTransaction] =>  Array
(
[0] =>  Array
(
[transaction_id] =>  numeric
)

[1] =>  Array
(
[transaction_id] =>  numeric
)

[2] =>  Array
(
[transaction_id] =>  numeric
)

)

)

When I comment out validation on ArticlesTransaction->transaction_id, 
everything gets saved perfectly fine. (With transaction_id set to the saved 
Transaction) Is it normal that ArticlesTransaction gets validated before 
transaction_id is set? How can I avoid disabling validation? Am I doing something 
wrong?
I hope I provided enough info to understand my problem.

Cheers
Max

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: Cakephp and XAMPP installation nightmare, Can't get cake to understand root

2010-07-12 Thread Max Dörfler

And try "registration" in the url, not "registeration"

cheers

Am 12.07.2010 10:30, schrieb nini:

Try
http://localhost/cake1.3.2/users/registeration

and please read manual.

On Jul 12, 1:20 am, Dinu464  wrote:
   

1) XAMPP 1.7.3 setup and workinghttp://localhost/xampp/->  success
2) Unpacked cake1.3.2, installed under XAMPP ->  htdocs ->  cake1.3.2
(folder)
Checked setuphttp://localhost/cake1.3.2/->  success

Your tmp directory is writable.
The FileEngine is being used for caching. To change the config edit
APP/config/core.php
Your database configuration file is present.
Cake is able to connect to the database.

3) Trying to Implement IBM tutorial Part1

Created MySQL tabel 'Users'
under cake1.3.2\app\models, created user.php
under cake1.3.2\app\controllers, created users_controller.php, with
action registration
under cake1.3.2\app\view\users, created registration.ctp

4) nowhttp://localhost/cake1.3.2/app/views/users/registeration

throws an err

Error: ViewsController could not be found.
Error: Create the class ViewsController below in file: app\controllers
\views_controller.php


This is where I am stuck for a week now, can’t get passed this screen,
tried several solutions but still cant get this to work..really
frustrated. please help!
 

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